- 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(ifxmips_r32(IFXMIPS_BIU_WDT_CR)));
- wdt_pwl = 0x8000 >> IFXMIPS_BIU_WDT_CR_PWL_GET(ifxmips_r32(IFXMIPS_BIU_WDT_CR));
-
- 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 */
- ifxmips_w32(IFXMIPS_BIU_WDT_CR_PW_SET(IFXMIPS_WDT_PW1), IFXMIPS_BIU_WDT_CR);
-
- wdt_cr = ifxmips_r32(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(ifxmips_r32(IFXMIPS_BIU_WDT_CR))) |
- IFXMIPS_BIU_WDT_CR_CLKDIV_SET(IFXMIPS_BIU_WDT_CR_CLKDIV_GET(ifxmips_r32(IFXMIPS_BIU_WDT_CR))) |
- IFXMIPS_BIU_WDT_CR_RELOAD_SET(wdt_reload) |
- IFXMIPS_BIU_WDT_CR_GEN);
-
- ifxmips_w32(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;