Lines Matching refs:dev
77 struct orion_watchdog *dev) in orion_wdt_clock_init() argument
81 dev->clk = clk_get(&pdev->dev, NULL); in orion_wdt_clock_init()
82 if (IS_ERR(dev->clk)) in orion_wdt_clock_init()
83 return PTR_ERR(dev->clk); in orion_wdt_clock_init()
84 ret = clk_prepare_enable(dev->clk); in orion_wdt_clock_init()
86 clk_put(dev->clk); in orion_wdt_clock_init()
90 dev->clk_rate = clk_get_rate(dev->clk); in orion_wdt_clock_init()
95 struct orion_watchdog *dev) in armada370_wdt_clock_init() argument
99 dev->clk = clk_get(&pdev->dev, NULL); in armada370_wdt_clock_init()
100 if (IS_ERR(dev->clk)) in armada370_wdt_clock_init()
101 return PTR_ERR(dev->clk); in armada370_wdt_clock_init()
102 ret = clk_prepare_enable(dev->clk); in armada370_wdt_clock_init()
104 clk_put(dev->clk); in armada370_wdt_clock_init()
109 atomic_io_modify(dev->reg + TIMER_CTRL, in armada370_wdt_clock_init()
113 dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; in armada370_wdt_clock_init()
118 struct orion_watchdog *dev) in armada375_wdt_clock_init() argument
122 dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); in armada375_wdt_clock_init()
123 if (!IS_ERR(dev->clk)) { in armada375_wdt_clock_init()
124 ret = clk_prepare_enable(dev->clk); in armada375_wdt_clock_init()
126 clk_put(dev->clk); in armada375_wdt_clock_init()
130 atomic_io_modify(dev->reg + TIMER_CTRL, in armada375_wdt_clock_init()
133 dev->clk_rate = clk_get_rate(dev->clk); in armada375_wdt_clock_init()
139 dev->clk = clk_get(&pdev->dev, NULL); in armada375_wdt_clock_init()
140 if (IS_ERR(dev->clk)) in armada375_wdt_clock_init()
141 return PTR_ERR(dev->clk); in armada375_wdt_clock_init()
143 ret = clk_prepare_enable(dev->clk); in armada375_wdt_clock_init()
145 clk_put(dev->clk); in armada375_wdt_clock_init()
149 atomic_io_modify(dev->reg + TIMER_CTRL, in armada375_wdt_clock_init()
152 dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; in armada375_wdt_clock_init()
158 struct orion_watchdog *dev) in armadaxp_wdt_clock_init() argument
162 dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); in armadaxp_wdt_clock_init()
163 if (IS_ERR(dev->clk)) in armadaxp_wdt_clock_init()
164 return PTR_ERR(dev->clk); in armadaxp_wdt_clock_init()
165 ret = clk_prepare_enable(dev->clk); in armadaxp_wdt_clock_init()
167 clk_put(dev->clk); in armadaxp_wdt_clock_init()
172 atomic_io_modify(dev->reg + TIMER_CTRL, in armadaxp_wdt_clock_init()
176 dev->clk_rate = clk_get_rate(dev->clk); in armadaxp_wdt_clock_init()
182 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_ping() local
184 writel(dev->clk_rate * wdt_dev->timeout, in orion_wdt_ping()
185 dev->reg + dev->data->wdt_counter_offset); in orion_wdt_ping()
191 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada375_start() local
195 writel(dev->clk_rate * wdt_dev->timeout, in armada375_start()
196 dev->reg + dev->data->wdt_counter_offset); in armada375_start()
199 atomic_io_modify(dev->reg + TIMER_A370_STATUS, WDT_A370_EXPIRED, 0); in armada375_start()
202 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, in armada375_start()
203 dev->data->wdt_enable_bit); in armada375_start()
206 reg = readl(dev->rstout); in armada375_start()
207 reg |= dev->data->rstout_enable_bit; in armada375_start()
208 writel(reg, dev->rstout); in armada375_start()
210 atomic_io_modify(dev->rstout_mask, dev->data->rstout_mask_bit, 0); in armada375_start()
216 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada370_start() local
220 writel(dev->clk_rate * wdt_dev->timeout, in armada370_start()
221 dev->reg + dev->data->wdt_counter_offset); in armada370_start()
224 atomic_io_modify(dev->reg + TIMER_A370_STATUS, WDT_A370_EXPIRED, 0); in armada370_start()
227 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, in armada370_start()
228 dev->data->wdt_enable_bit); in armada370_start()
231 reg = readl(dev->rstout); in armada370_start()
232 reg |= dev->data->rstout_enable_bit; in armada370_start()
233 writel(reg, dev->rstout); in armada370_start()
239 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_start() local
242 writel(dev->clk_rate * wdt_dev->timeout, in orion_start()
243 dev->reg + dev->data->wdt_counter_offset); in orion_start()
246 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, in orion_start()
247 dev->data->wdt_enable_bit); in orion_start()
250 atomic_io_modify(dev->rstout, dev->data->rstout_enable_bit, in orion_start()
251 dev->data->rstout_enable_bit); in orion_start()
258 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_start() local
261 return dev->data->start(wdt_dev); in orion_wdt_start()
266 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_stop() local
269 atomic_io_modify(dev->rstout, dev->data->rstout_enable_bit, 0); in orion_stop()
272 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, 0); in orion_stop()
279 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada375_stop() local
283 atomic_io_modify(dev->rstout_mask, dev->data->rstout_mask_bit, in armada375_stop()
284 dev->data->rstout_mask_bit); in armada375_stop()
285 reg = readl(dev->rstout); in armada375_stop()
286 reg &= ~dev->data->rstout_enable_bit; in armada375_stop()
287 writel(reg, dev->rstout); in armada375_stop()
290 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, 0); in armada375_stop()
297 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada370_stop() local
301 reg = readl(dev->rstout); in armada370_stop()
302 reg &= ~dev->data->rstout_enable_bit; in armada370_stop()
303 writel(reg, dev->rstout); in armada370_stop()
306 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, 0); in armada370_stop()
313 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_stop() local
315 return dev->data->stop(wdt_dev); in orion_wdt_stop()
318 static int orion_enabled(struct orion_watchdog *dev) in orion_enabled() argument
322 enabled = readl(dev->rstout) & dev->data->rstout_enable_bit; in orion_enabled()
323 running = readl(dev->reg + TIMER_CTRL) & dev->data->wdt_enable_bit; in orion_enabled()
328 static int armada375_enabled(struct orion_watchdog *dev) in armada375_enabled() argument
332 masked = readl(dev->rstout_mask) & dev->data->rstout_mask_bit; in armada375_enabled()
333 enabled = readl(dev->rstout) & dev->data->rstout_enable_bit; in armada375_enabled()
334 running = readl(dev->reg + TIMER_CTRL) & dev->data->wdt_enable_bit; in armada375_enabled()
341 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_enabled() local
343 return dev->data->enabled(dev); in orion_wdt_enabled()
348 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_get_timeleft() local
349 return readl(dev->reg + dev->data->wdt_counter_offset) / dev->clk_rate; in orion_wdt_get_timeleft()
393 return devm_ioremap(&pdev->dev, res->start, in orion_wdt_ioremap_rstout()
399 return devm_ioremap(&pdev->dev, rstout, 0x4); in orion_wdt_ioremap_rstout()
480 struct orion_watchdog *dev) in orion_wdt_get_regs() argument
482 struct device_node *node = pdev->dev.of_node; in orion_wdt_get_regs()
488 dev->reg = devm_ioremap(&pdev->dev, res->start, in orion_wdt_get_regs()
490 if (!dev->reg) in orion_wdt_get_regs()
496 dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & in orion_wdt_get_regs()
498 if (!dev->rstout) in orion_wdt_get_regs()
506 dev->rstout = devm_ioremap_resource(&pdev->dev, res); in orion_wdt_get_regs()
507 if (IS_ERR(dev->rstout)) in orion_wdt_get_regs()
508 return PTR_ERR(dev->rstout); in orion_wdt_get_regs()
515 dev->rstout = devm_ioremap_resource(&pdev->dev, res); in orion_wdt_get_regs()
516 if (IS_ERR(dev->rstout)) in orion_wdt_get_regs()
517 return PTR_ERR(dev->rstout); in orion_wdt_get_regs()
522 dev->rstout_mask = devm_ioremap(&pdev->dev, res->start, in orion_wdt_get_regs()
524 if (!dev->rstout_mask) in orion_wdt_get_regs()
536 struct orion_watchdog *dev; in orion_wdt_probe() local
541 dev = devm_kzalloc(&pdev->dev, sizeof(struct orion_watchdog), in orion_wdt_probe()
543 if (!dev) in orion_wdt_probe()
546 match = of_match_device(orion_wdt_of_match_table, &pdev->dev); in orion_wdt_probe()
551 dev->wdt.info = &orion_wdt_info; in orion_wdt_probe()
552 dev->wdt.ops = &orion_wdt_ops; in orion_wdt_probe()
553 dev->wdt.min_timeout = 1; in orion_wdt_probe()
554 dev->data = match->data; in orion_wdt_probe()
556 ret = orion_wdt_get_regs(pdev, dev); in orion_wdt_probe()
560 ret = dev->data->clock_init(pdev, dev); in orion_wdt_probe()
562 dev_err(&pdev->dev, "cannot initialize clock\n"); in orion_wdt_probe()
566 wdt_max_duration = WDT_MAX_CYCLE_COUNT / dev->clk_rate; in orion_wdt_probe()
568 dev->wdt.timeout = wdt_max_duration; in orion_wdt_probe()
569 dev->wdt.max_timeout = wdt_max_duration; in orion_wdt_probe()
570 dev->wdt.parent = &pdev->dev; in orion_wdt_probe()
571 watchdog_init_timeout(&dev->wdt, heartbeat, &pdev->dev); in orion_wdt_probe()
573 platform_set_drvdata(pdev, &dev->wdt); in orion_wdt_probe()
574 watchdog_set_drvdata(&dev->wdt, dev); in orion_wdt_probe()
582 if (!orion_wdt_enabled(&dev->wdt)) in orion_wdt_probe()
583 orion_wdt_stop(&dev->wdt); in orion_wdt_probe()
592 ret = devm_request_irq(&pdev->dev, irq, orion_wdt_irq, 0, in orion_wdt_probe()
593 pdev->name, dev); in orion_wdt_probe()
595 dev_err(&pdev->dev, "failed to request IRQ\n"); in orion_wdt_probe()
600 watchdog_set_nowayout(&dev->wdt, nowayout); in orion_wdt_probe()
601 ret = watchdog_register_device(&dev->wdt); in orion_wdt_probe()
606 dev->wdt.timeout, nowayout ? ", nowayout" : ""); in orion_wdt_probe()
610 clk_disable_unprepare(dev->clk); in orion_wdt_probe()
611 clk_put(dev->clk); in orion_wdt_probe()
618 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_remove() local
621 clk_disable_unprepare(dev->clk); in orion_wdt_remove()
622 clk_put(dev->clk); in orion_wdt_remove()