Lines Matching full:wdt
44 static inline bool pic32_wdt_is_win_enabled(struct pic32_wdt *wdt) in pic32_wdt_is_win_enabled() argument
46 return !!(readl(wdt->regs + WDTCON_REG) & WDTCON_WIN_EN); in pic32_wdt_is_win_enabled()
49 static inline u32 pic32_wdt_get_post_scaler(struct pic32_wdt *wdt) in pic32_wdt_get_post_scaler() argument
51 u32 v = readl(wdt->regs + WDTCON_REG); in pic32_wdt_get_post_scaler()
56 static inline u32 pic32_wdt_get_clk_id(struct pic32_wdt *wdt) in pic32_wdt_get_clk_id() argument
58 u32 v = readl(wdt->regs + WDTCON_REG); in pic32_wdt_get_clk_id()
63 static int pic32_wdt_bootstatus(struct pic32_wdt *wdt) in pic32_wdt_bootstatus() argument
65 u32 v = readl(wdt->rst_base); in pic32_wdt_bootstatus()
67 writel(RESETCON_WDT_TIMEOUT, PIC32_CLR(wdt->rst_base)); in pic32_wdt_bootstatus()
72 static u32 pic32_wdt_get_timeout_secs(struct pic32_wdt *wdt, struct device *dev) in pic32_wdt_get_timeout_secs() argument
77 rate = clk_get_rate(wdt->clk); in pic32_wdt_get_timeout_secs()
79 dev_dbg(dev, "wdt: clk_id %d, clk_rate %lu (prescale)\n", in pic32_wdt_get_timeout_secs()
80 pic32_wdt_get_clk_id(wdt), rate); in pic32_wdt_get_timeout_secs()
88 ps = pic32_wdt_get_post_scaler(wdt); in pic32_wdt_get_timeout_secs()
94 "wdt: clk_rate %lu (postscale) / terminal %d, timeout %dsec\n", in pic32_wdt_get_timeout_secs()
100 static void pic32_wdt_keepalive(struct pic32_wdt *wdt) in pic32_wdt_keepalive() argument
103 writew(WDTCON_CLR_KEY, wdt->regs + WDTCON_REG + 2); in pic32_wdt_keepalive()
108 struct pic32_wdt *wdt = watchdog_get_drvdata(wdd); in pic32_wdt_start() local
110 writel(WDTCON_ON, PIC32_SET(wdt->regs + WDTCON_REG)); in pic32_wdt_start()
111 pic32_wdt_keepalive(wdt); in pic32_wdt_start()
118 struct pic32_wdt *wdt = watchdog_get_drvdata(wdd); in pic32_wdt_stop() local
120 writel(WDTCON_ON, PIC32_CLR(wdt->regs + WDTCON_REG)); in pic32_wdt_stop()
133 struct pic32_wdt *wdt = watchdog_get_drvdata(wdd); in pic32_wdt_ping() local
135 pic32_wdt_keepalive(wdt); in pic32_wdt_ping()
159 { .compatible = "microchip,pic32mzda-wdt", },
169 struct pic32_wdt *wdt; in pic32_wdt_drv_probe() local
171 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); in pic32_wdt_drv_probe()
172 if (!wdt) in pic32_wdt_drv_probe()
175 wdt->regs = devm_platform_ioremap_resource(pdev, 0); in pic32_wdt_drv_probe()
176 if (IS_ERR(wdt->regs)) in pic32_wdt_drv_probe()
177 return PTR_ERR(wdt->regs); in pic32_wdt_drv_probe()
179 wdt->rst_base = devm_ioremap(dev, PIC32_BASE_RESET, 0x10); in pic32_wdt_drv_probe()
180 if (!wdt->rst_base) in pic32_wdt_drv_probe()
183 wdt->clk = devm_clk_get_enabled(dev, NULL); in pic32_wdt_drv_probe()
184 if (IS_ERR(wdt->clk)) { in pic32_wdt_drv_probe()
186 return PTR_ERR(wdt->clk); in pic32_wdt_drv_probe()
189 if (pic32_wdt_is_win_enabled(wdt)) { in pic32_wdt_drv_probe()
194 wdd->timeout = pic32_wdt_get_timeout_secs(wdt, dev); in pic32_wdt_drv_probe()
202 wdd->bootstatus = pic32_wdt_bootstatus(wdt) ? WDIOF_CARDRESET : 0; in pic32_wdt_drv_probe()
205 watchdog_set_drvdata(wdd, wdt); in pic32_wdt_drv_probe()
219 .name = "pic32-wdt",