- unsigned int wdt_cr = 0;
- unsigned int wdt_reload = 0;
- unsigned int wdt_clkdiv, wdt_pwl, ffpi;
- int retval = 0;
-
- /* clock divider & prewarning limit */
- wdt_clkdiv = 1 << (7 * IFXMIPS_BIU_WDT_CR_CLKDIV_GET(readl(IFXMIPS_BIU_WDT_CR)));
- wdt_pwl = 0x8000 >> IFXMIPS_BIU_WDT_CR_PWL_GET(readl(IFXMIPS_BIU_WDT_CR));
-
- //TODO
- printk("WARNING FUNCTION CALL MISSING!!!");
- //ffpi = cgu_get_io_region_clock();
- printk("cpu clock = %d\n", ffpi);
-
- /* caculate reload value */
- wdt_reload = (timeout * (ffpi / wdt_clkdiv)) + wdt_pwl;
-
- printk(KERN_WARNING DRVNAME ": wdt_pwl=0x%x, wdt_clkdiv=%d, ffpi=%d, wdt_reload = 0x%x\n",
- wdt_pwl, wdt_clkdiv, ffpi, wdt_reload);
-
- if (wdt_reload > 0xFFFF)
- {
- printk(KERN_WARNING DRVNAME ": timeout too large %d\n", timeout);
- retval = -EINVAL;
- goto out;
- }
-
- /* Write first part of password access */
- writel(IFXMIPS_BIU_WDT_CR_PW_SET(IFXMIPS_WDT_PW1), IFXMIPS_BIU_WDT_CR);
-
- wdt_cr = readl(IFXMIPS_BIU_WDT_CR);
- wdt_cr &= (!IFXMIPS_BIU_WDT_CR_PW_SET(0xff) &
- !IFXMIPS_BIU_WDT_CR_PWL_SET(0x3) &
- !IFXMIPS_BIU_WDT_CR_CLKDIV_SET(0x3) &
- !IFXMIPS_BIU_WDT_CR_RELOAD_SET(0xffff));
-
- wdt_cr |= (IFXMIPS_BIU_WDT_CR_PW_SET(IFXMIPS_WDT_PW2) |
- IFXMIPS_BIU_WDT_CR_PWL_SET(IFXMIPS_BIU_WDT_CR_PWL_GET(readl(IFXMIPS_BIU_WDT_CR))) |
- IFXMIPS_BIU_WDT_CR_CLKDIV_SET(IFXMIPS_BIU_WDT_CR_CLKDIV_GET(readl(IFXMIPS_BIU_WDT_CR))) |
- IFXMIPS_BIU_WDT_CR_RELOAD_SET(wdt_reload) |
- IFXMIPS_BIU_WDT_CR_GEN);
-
- writel(wdt_cr, IFXMIPS_BIU_WDT_CR);
-
- printk("watchdog enabled\n");
-
-out:
- return retval;
+ u32 fpi;
+ fpi = cgu_get_io_region_clock();
+ ifxmips_w32(IFXMIPS_WDT_PW1, IFXMIPS_BIU_WDT_CR);
+ ifxmips_w32(IFXMIPS_WDT_PW2 |
+ (0x3 << 26) | // PWL
+ (0x3 << 24) | // CLKDIV
+ (0x1 << 31) | // enable
+ ((timeout * (fpi / 0x40000)) + 0x1000), // reload
+ IFXMIPS_BIU_WDT_CR);
+ return 0;