Lines Matching refs:wdt

58 static int secure_register_read(struct bcm_kona_wdt *wdt, uint32_t offset)  in secure_register_read()  argument
71 val = readl_relaxed(wdt->base + offset); in secure_register_read()
77 if (count > wdt->busy_count) in secure_register_read()
78 wdt->busy_count = count; in secure_register_read()
97 struct bcm_kona_wdt *wdt = s->private; in bcm_kona_show() local
99 if (!wdt) { in bcm_kona_show()
104 spin_lock_irqsave(&wdt->lock, flags); in bcm_kona_show()
105 ctl_val = secure_register_read(wdt, SECWDOG_CTRL_REG); in bcm_kona_show()
106 cur_val = secure_register_read(wdt, SECWDOG_COUNT_REG); in bcm_kona_show()
107 spin_unlock_irqrestore(&wdt->lock, flags); in bcm_kona_show()
117 ctl_sec = TICKS_TO_SECS(ctl, wdt); in bcm_kona_show()
118 cur_sec = TICKS_TO_SECS(cur, wdt); in bcm_kona_show()
124 res, wdt->resolution, in bcm_kona_show()
127 wdt->busy_count); in bcm_kona_show()
138 struct bcm_kona_wdt *wdt = platform_get_drvdata(pdev); in bcm_kona_wdt_debug_init() local
140 if (!wdt) in bcm_kona_wdt_debug_init()
143 wdt->debugfs = NULL; in bcm_kona_wdt_debug_init()
147 debugfs_create_file("info", S_IFREG | S_IRUGO, dir, wdt, in bcm_kona_wdt_debug_init()
149 wdt->debugfs = dir; in bcm_kona_wdt_debug_init()
154 struct bcm_kona_wdt *wdt = platform_get_drvdata(pdev); in bcm_kona_wdt_debug_exit() local
156 if (wdt) in bcm_kona_wdt_debug_exit()
157 debugfs_remove_recursive(wdt->debugfs); in bcm_kona_wdt_debug_exit()
167 static int bcm_kona_wdt_ctrl_reg_modify(struct bcm_kona_wdt *wdt, in bcm_kona_wdt_ctrl_reg_modify() argument
174 spin_lock_irqsave(&wdt->lock, flags); in bcm_kona_wdt_ctrl_reg_modify()
176 val = secure_register_read(wdt, SECWDOG_CTRL_REG); in bcm_kona_wdt_ctrl_reg_modify()
182 writel_relaxed(val, wdt->base + SECWDOG_CTRL_REG); in bcm_kona_wdt_ctrl_reg_modify()
185 spin_unlock_irqrestore(&wdt->lock, flags); in bcm_kona_wdt_ctrl_reg_modify()
190 static int bcm_kona_wdt_set_resolution_reg(struct bcm_kona_wdt *wdt) in bcm_kona_wdt_set_resolution_reg() argument
192 if (wdt->resolution > SECWDOG_MAX_RES) in bcm_kona_wdt_set_resolution_reg()
195 return bcm_kona_wdt_ctrl_reg_modify(wdt, SECWDOG_RES_MASK, in bcm_kona_wdt_set_resolution_reg()
196 wdt->resolution << SECWDOG_CLKS_SHIFT); in bcm_kona_wdt_set_resolution_reg()
202 struct bcm_kona_wdt *wdt = watchdog_get_drvdata(wdog); in bcm_kona_wdt_set_timeout_reg() local
204 return bcm_kona_wdt_ctrl_reg_modify(wdt, SECWDOG_COUNT_MASK, in bcm_kona_wdt_set_timeout_reg()
205 SECS_TO_TICKS(wdog->timeout, wdt) | in bcm_kona_wdt_set_timeout_reg()
218 struct bcm_kona_wdt *wdt = watchdog_get_drvdata(wdog); in bcm_kona_wdt_get_timeleft() local
222 spin_lock_irqsave(&wdt->lock, flags); in bcm_kona_wdt_get_timeleft()
223 val = secure_register_read(wdt, SECWDOG_COUNT_REG); in bcm_kona_wdt_get_timeleft()
224 spin_unlock_irqrestore(&wdt->lock, flags); in bcm_kona_wdt_get_timeleft()
229 return TICKS_TO_SECS(val & SECWDOG_COUNT_MASK, wdt); in bcm_kona_wdt_get_timeleft()
240 struct bcm_kona_wdt *wdt = watchdog_get_drvdata(wdog); in bcm_kona_wdt_stop() local
242 return bcm_kona_wdt_ctrl_reg_modify(wdt, SECWDOG_EN_MASK | in bcm_kona_wdt_stop()
271 struct bcm_kona_wdt *wdt; in bcm_kona_wdt_probe() local
274 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); in bcm_kona_wdt_probe()
275 if (!wdt) in bcm_kona_wdt_probe()
278 spin_lock_init(&wdt->lock); in bcm_kona_wdt_probe()
280 wdt->base = devm_platform_ioremap_resource(pdev, 0); in bcm_kona_wdt_probe()
281 if (IS_ERR(wdt->base)) in bcm_kona_wdt_probe()
282 return PTR_ERR(wdt->base); in bcm_kona_wdt_probe()
284 wdt->resolution = SECWDOG_DEFAULT_RESOLUTION; in bcm_kona_wdt_probe()
285 ret = bcm_kona_wdt_set_resolution_reg(wdt); in bcm_kona_wdt_probe()
291 platform_set_drvdata(pdev, wdt); in bcm_kona_wdt_probe()
292 watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt); in bcm_kona_wdt_probe()