X-Git-Url: https://repo.jachan.dev/J-u-boot.git/blobdiff_plain/c2279d784e35fa25ee3a9fa28a74a1ba545f8c1e..65fbdab27224ee3943a89496b21862db83c34da2:/drivers/timer/mpc83xx_timer.c diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c index ad8bb28e8b3..9da74479aaa 100644 --- a/drivers/timer/mpc83xx_timer.c +++ b/drivers/timer/mpc83xx_timer.c @@ -4,21 +4,26 @@ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc */ -#include -#include +#include #include #include #include #include #include +#include #include #include #include +#include #include #include 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), };