]> Git Repo - J-u-boot.git/blobdiff - drivers/timer/mpc83xx_timer.c
Merge branch 'next'
[J-u-boot.git] / drivers / timer / mpc83xx_timer.c
index ad8bb28e8b39d7989df7b4f4ccb5b9bb7ad9faae..9da74479aaa678bfab861950a770b216b604c433 100644 (file)
@@ -4,21 +4,26 @@
  * Mario Six, Guntermann & Drunck GmbH, [email protected]
  */
 
-#include <common.h>
-#include <board.h>
+#include <config.h>
 #include <clk.h>
 #include <dm.h>
 #include <irq_func.h>
 #include <log.h>
 #include <status_led.h>
+#include <sysinfo.h>
 #include <time.h>
 #include <timer.h>
 #include <watchdog.h>
+#include <asm/global_data.h>
 #include <asm/ptrace.h>
 #include <linux/bitops.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CFG_SYS_WATCHDOG_FREQ
+#define CFG_SYS_WATCHDOG_FREQ (CONFIG_SYS_HZ / 2)
+#endif
+
 /**
  * struct mpc83xx_timer_priv - Private data structure for MPC83xx timer driver
  * @decrementer_count: Value to which the decrementer register should be re-set
@@ -97,7 +102,7 @@ int interrupt_init(void)
 {
        immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
        struct udevice *csb;
-       struct udevice *board;
+       struct udevice *sysinfo;
        struct udevice *timer;
        struct mpc83xx_timer_priv *timer_priv;
        struct clk clock;
@@ -112,12 +117,12 @@ int interrupt_init(void)
 
        timer_priv = dev_get_priv(timer);
 
-       if (board_get(&board)) {
-               debug("%s: board device could not be fetched.\n", __func__);
+       if (sysinfo_get(&sysinfo)) {
+               debug("%s: sysinfo device could not be fetched.\n", __func__);
                return -ENOENT;
        }
 
-       ret = uclass_get_device_by_phandle(UCLASS_SIMPLE_BUS, board,
+       ret = uclass_get_device_by_phandle(UCLASS_SIMPLE_BUS, sysinfo,
                                           "csb", &csb);
        if (ret) {
                debug("%s: Could not retrieve CSB device (error: %d)",
@@ -170,8 +175,8 @@ void timer_interrupt(struct pt_regs *regs)
        priv->timestamp++;
 
 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
-       if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0)
-               WATCHDOG_RESET();
+       if (CFG_SYS_WATCHDOG_FREQ && (priv->timestamp % (CFG_SYS_WATCHDOG_FREQ)) == 0)
+               schedule();
 #endif    /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
 
 #ifdef CONFIG_LED_STATUS
@@ -184,10 +189,10 @@ void wait_ticks(ulong ticks)
        ulong end = get_ticks() + ticks;
 
        while (end > get_ticks())
-               WATCHDOG_RESET();
+               schedule();
 }
 
-static int mpc83xx_timer_get_count(struct udevice *dev, u64 *count)
+static u64 mpc83xx_timer_get_count(struct udevice *dev)
 {
        u32 tbu, tbl;
 
@@ -201,14 +206,12 @@ static int mpc83xx_timer_get_count(struct udevice *dev, u64 *count)
                tbl = mftb();
        } while (tbu != mftbu());
 
-       *count = (tbu * 0x10000ULL) + tbl;
-
-       return 0;
+       return (tbu * 0x10000ULL) + tbl;
 }
 
 static int mpc83xx_timer_probe(struct udevice *dev)
 {
-       struct timer_dev_priv *uc_priv = dev->uclass_priv;
+       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
        struct clk clock;
        int ret;
 
@@ -246,5 +249,5 @@ U_BOOT_DRIVER(mpc83xx_timer) = {
        .of_match = mpc83xx_timer_ids,
        .probe = mpc83xx_timer_probe,
        .ops    = &mpc83xx_timer_ops,
-       .priv_auto_alloc_size = sizeof(struct mpc83xx_timer_priv),
+       .priv_auto      = sizeof(struct mpc83xx_timer_priv),
 };
This page took 0.029397 seconds and 4 git commands to generate.