Lines Matching refs:dmt
48 static inline void dmt_enable(struct pic32_dmt *dmt) in dmt_enable() argument
50 writel(DMT_ON, PIC32_SET(dmt->regs + DMTCON_REG)); in dmt_enable()
53 static inline void dmt_disable(struct pic32_dmt *dmt) in dmt_disable() argument
55 writel(DMT_ON, PIC32_CLR(dmt->regs + DMTCON_REG)); in dmt_disable()
63 static inline int dmt_bad_status(struct pic32_dmt *dmt) in dmt_bad_status() argument
67 val = readl(dmt->regs + DMTSTAT_REG); in dmt_bad_status()
75 static inline int dmt_keepalive(struct pic32_dmt *dmt) in dmt_keepalive() argument
81 writel(DMT_STEP1_KEY << 8, dmt->regs + DMTPRECLR_REG); in dmt_keepalive()
85 v = readl(dmt->regs + DMTSTAT_REG) & DMTSTAT_WINOPN; in dmt_keepalive()
91 writel(DMT_STEP2_KEY, dmt->regs + DMTCLR_REG); in dmt_keepalive()
94 return dmt_bad_status(dmt); in dmt_keepalive()
97 static inline u32 pic32_dmt_get_timeout_secs(struct pic32_dmt *dmt) in pic32_dmt_get_timeout_secs() argument
101 rate = clk_get_rate(dmt->clk); in pic32_dmt_get_timeout_secs()
103 return readl(dmt->regs + DMTPSCNT_REG) / rate; in pic32_dmt_get_timeout_secs()
108 static inline u32 pic32_dmt_bootstatus(struct pic32_dmt *dmt) in pic32_dmt_bootstatus() argument
127 struct pic32_dmt *dmt = watchdog_get_drvdata(wdd); in pic32_dmt_start() local
129 dmt_enable(dmt); in pic32_dmt_start()
130 return dmt_keepalive(dmt); in pic32_dmt_start()
135 struct pic32_dmt *dmt = watchdog_get_drvdata(wdd); in pic32_dmt_stop() local
137 dmt_disable(dmt); in pic32_dmt_stop()
144 struct pic32_dmt *dmt = watchdog_get_drvdata(wdd); in pic32_dmt_ping() local
146 return dmt_keepalive(dmt); in pic32_dmt_ping()
176 struct pic32_dmt *dmt; in pic32_dmt_probe() local
179 dmt = devm_kzalloc(dev, sizeof(*dmt), GFP_KERNEL); in pic32_dmt_probe()
180 if (!dmt) in pic32_dmt_probe()
183 dmt->regs = devm_platform_ioremap_resource(pdev, 0); in pic32_dmt_probe()
184 if (IS_ERR(dmt->regs)) in pic32_dmt_probe()
185 return PTR_ERR(dmt->regs); in pic32_dmt_probe()
187 dmt->clk = devm_clk_get(dev, NULL); in pic32_dmt_probe()
188 if (IS_ERR(dmt->clk)) { in pic32_dmt_probe()
190 return PTR_ERR(dmt->clk); in pic32_dmt_probe()
193 ret = clk_prepare_enable(dmt->clk); in pic32_dmt_probe()
197 dmt->clk); in pic32_dmt_probe()
201 wdd->timeout = pic32_dmt_get_timeout_secs(dmt); in pic32_dmt_probe()
209 wdd->bootstatus = pic32_dmt_bootstatus(dmt) ? WDIOF_CARDRESET : 0; in pic32_dmt_probe()
212 watchdog_set_drvdata(wdd, dmt); in pic32_dmt_probe()