Lines Matching refs:dev

80 				struct orion_watchdog *dev)  in orion_wdt_clock_init()  argument
84 dev->clk = clk_get(&pdev->dev, NULL); in orion_wdt_clock_init()
85 if (IS_ERR(dev->clk)) in orion_wdt_clock_init()
86 return PTR_ERR(dev->clk); in orion_wdt_clock_init()
87 ret = clk_prepare_enable(dev->clk); in orion_wdt_clock_init()
89 clk_put(dev->clk); in orion_wdt_clock_init()
93 dev->clk_rate = clk_get_rate(dev->clk); in orion_wdt_clock_init()
98 struct orion_watchdog *dev) in armada370_wdt_clock_init() argument
102 dev->clk = clk_get(&pdev->dev, NULL); in armada370_wdt_clock_init()
103 if (IS_ERR(dev->clk)) in armada370_wdt_clock_init()
104 return PTR_ERR(dev->clk); in armada370_wdt_clock_init()
105 ret = clk_prepare_enable(dev->clk); in armada370_wdt_clock_init()
107 clk_put(dev->clk); in armada370_wdt_clock_init()
112 atomic_io_modify(dev->reg + TIMER_CTRL, in armada370_wdt_clock_init()
116 dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; in armada370_wdt_clock_init()
121 struct orion_watchdog *dev) in armada375_wdt_clock_init() argument
125 dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); in armada375_wdt_clock_init()
126 if (!IS_ERR(dev->clk)) { in armada375_wdt_clock_init()
127 ret = clk_prepare_enable(dev->clk); in armada375_wdt_clock_init()
129 clk_put(dev->clk); in armada375_wdt_clock_init()
133 atomic_io_modify(dev->reg + TIMER_CTRL, in armada375_wdt_clock_init()
136 dev->clk_rate = clk_get_rate(dev->clk); in armada375_wdt_clock_init()
142 dev->clk = clk_get(&pdev->dev, NULL); in armada375_wdt_clock_init()
143 if (IS_ERR(dev->clk)) in armada375_wdt_clock_init()
144 return PTR_ERR(dev->clk); in armada375_wdt_clock_init()
146 ret = clk_prepare_enable(dev->clk); in armada375_wdt_clock_init()
148 clk_put(dev->clk); in armada375_wdt_clock_init()
152 atomic_io_modify(dev->reg + TIMER_CTRL, in armada375_wdt_clock_init()
155 dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; in armada375_wdt_clock_init()
161 struct orion_watchdog *dev) in armadaxp_wdt_clock_init() argument
166 dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); in armadaxp_wdt_clock_init()
167 if (IS_ERR(dev->clk)) in armadaxp_wdt_clock_init()
168 return PTR_ERR(dev->clk); in armadaxp_wdt_clock_init()
169 ret = clk_prepare_enable(dev->clk); in armadaxp_wdt_clock_init()
171 clk_put(dev->clk); in armadaxp_wdt_clock_init()
177 atomic_io_modify(dev->reg + TIMER_CTRL, val, val); in armadaxp_wdt_clock_init()
179 dev->clk_rate = clk_get_rate(dev->clk); in armadaxp_wdt_clock_init()
185 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_ping() local
187 writel(dev->clk_rate * wdt_dev->timeout, in orion_wdt_ping()
188 dev->reg + dev->data->wdt_counter_offset); in orion_wdt_ping()
189 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in orion_wdt_ping()
190 writel(dev->clk_rate * (wdt_dev->timeout - wdt_dev->pretimeout), in orion_wdt_ping()
191 dev->reg + TIMER1_VAL_OFF); in orion_wdt_ping()
198 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada375_start() local
202 writel(dev->clk_rate * wdt_dev->timeout, in armada375_start()
203 dev->reg + dev->data->wdt_counter_offset); in armada375_start()
204 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in armada375_start()
205 writel(dev->clk_rate * (wdt_dev->timeout - wdt_dev->pretimeout), in armada375_start()
206 dev->reg + TIMER1_VAL_OFF); in armada375_start()
209 atomic_io_modify(dev->reg + TIMER_A370_STATUS, WDT_A370_EXPIRED, 0); in armada375_start()
212 reg = dev->data->wdt_enable_bit; in armada375_start()
213 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in armada375_start()
215 atomic_io_modify(dev->reg + TIMER_CTRL, reg, reg); in armada375_start()
218 reg = readl(dev->rstout); in armada375_start()
219 reg |= dev->data->rstout_enable_bit; in armada375_start()
220 writel(reg, dev->rstout); in armada375_start()
222 atomic_io_modify(dev->rstout_mask, dev->data->rstout_mask_bit, 0); in armada375_start()
228 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada370_start() local
232 writel(dev->clk_rate * wdt_dev->timeout, in armada370_start()
233 dev->reg + dev->data->wdt_counter_offset); in armada370_start()
236 atomic_io_modify(dev->reg + TIMER_A370_STATUS, WDT_A370_EXPIRED, 0); in armada370_start()
239 reg = dev->data->wdt_enable_bit; in armada370_start()
240 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in armada370_start()
242 atomic_io_modify(dev->reg + TIMER_CTRL, reg, reg); in armada370_start()
245 reg = readl(dev->rstout); in armada370_start()
246 reg |= dev->data->rstout_enable_bit; in armada370_start()
247 writel(reg, dev->rstout); in armada370_start()
253 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_start() local
256 writel(dev->clk_rate * wdt_dev->timeout, in orion_start()
257 dev->reg + dev->data->wdt_counter_offset); in orion_start()
260 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, in orion_start()
261 dev->data->wdt_enable_bit); in orion_start()
264 atomic_io_modify(dev->rstout, dev->data->rstout_enable_bit, in orion_start()
265 dev->data->rstout_enable_bit); in orion_start()
272 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_start() local
275 return dev->data->start(wdt_dev); in orion_wdt_start()
280 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_stop() local
283 atomic_io_modify(dev->rstout, dev->data->rstout_enable_bit, 0); in orion_stop()
286 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, 0); in orion_stop()
293 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada375_stop() local
297 atomic_io_modify(dev->rstout_mask, dev->data->rstout_mask_bit, in armada375_stop()
298 dev->data->rstout_mask_bit); in armada375_stop()
299 reg = readl(dev->rstout); in armada375_stop()
300 reg &= ~dev->data->rstout_enable_bit; in armada375_stop()
301 writel(reg, dev->rstout); in armada375_stop()
304 mask = dev->data->wdt_enable_bit; in armada375_stop()
307 atomic_io_modify(dev->reg + TIMER_CTRL, mask, 0); in armada375_stop()
314 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in armada370_stop() local
318 reg = readl(dev->rstout); in armada370_stop()
319 reg &= ~dev->data->rstout_enable_bit; in armada370_stop()
320 writel(reg, dev->rstout); in armada370_stop()
323 mask = dev->data->wdt_enable_bit; in armada370_stop()
326 atomic_io_modify(dev->reg + TIMER_CTRL, mask, 0); in armada370_stop()
333 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_stop() local
335 return dev->data->stop(wdt_dev); in orion_wdt_stop()
338 static int orion_enabled(struct orion_watchdog *dev) in orion_enabled() argument
342 enabled = readl(dev->rstout) & dev->data->rstout_enable_bit; in orion_enabled()
343 running = readl(dev->reg + TIMER_CTRL) & dev->data->wdt_enable_bit; in orion_enabled()
348 static int armada375_enabled(struct orion_watchdog *dev) in armada375_enabled() argument
352 masked = readl(dev->rstout_mask) & dev->data->rstout_mask_bit; in armada375_enabled()
353 enabled = readl(dev->rstout) & dev->data->rstout_enable_bit; in armada375_enabled()
354 running = readl(dev->reg + TIMER_CTRL) & dev->data->wdt_enable_bit; in armada375_enabled()
361 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_enabled() local
363 return dev->data->enabled(dev); in orion_wdt_enabled()
368 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_get_timeleft() local
369 return readl(dev->reg + dev->data->wdt_counter_offset) / dev->clk_rate; in orion_wdt_get_timeleft()
393 struct orion_watchdog *dev = devid; in orion_wdt_pre_irq() local
395 atomic_io_modify(dev->reg + TIMER_A370_STATUS, in orion_wdt_pre_irq()
397 watchdog_notify_pretimeout(&dev->wdt); in orion_wdt_pre_irq()
415 return devm_ioremap(&pdev->dev, res->start, in orion_wdt_ioremap_rstout()
421 return devm_ioremap(&pdev->dev, rstout, 0x4); in orion_wdt_ioremap_rstout()
502 struct orion_watchdog *dev) in orion_wdt_get_regs() argument
504 struct device_node *node = pdev->dev.of_node; in orion_wdt_get_regs()
510 dev->reg = devm_ioremap(&pdev->dev, res->start, in orion_wdt_get_regs()
512 if (!dev->reg) in orion_wdt_get_regs()
518 dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & in orion_wdt_get_regs()
520 if (!dev->rstout) in orion_wdt_get_regs()
527 dev->rstout = devm_platform_ioremap_resource(pdev, 1); in orion_wdt_get_regs()
528 if (IS_ERR(dev->rstout)) in orion_wdt_get_regs()
529 return PTR_ERR(dev->rstout); in orion_wdt_get_regs()
535 dev->rstout = devm_platform_ioremap_resource(pdev, 1); in orion_wdt_get_regs()
536 if (IS_ERR(dev->rstout)) in orion_wdt_get_regs()
537 return PTR_ERR(dev->rstout); in orion_wdt_get_regs()
542 dev->rstout_mask = devm_ioremap(&pdev->dev, res->start, in orion_wdt_get_regs()
544 if (!dev->rstout_mask) in orion_wdt_get_regs()
556 struct orion_watchdog *dev; in orion_wdt_probe() local
561 dev = devm_kzalloc(&pdev->dev, sizeof(struct orion_watchdog), in orion_wdt_probe()
563 if (!dev) in orion_wdt_probe()
566 match = of_match_device(orion_wdt_of_match_table, &pdev->dev); in orion_wdt_probe()
571 dev->wdt.info = &orion_wdt_info; in orion_wdt_probe()
572 dev->wdt.ops = &orion_wdt_ops; in orion_wdt_probe()
573 dev->wdt.min_timeout = 1; in orion_wdt_probe()
574 dev->data = match->data; in orion_wdt_probe()
576 ret = orion_wdt_get_regs(pdev, dev); in orion_wdt_probe()
580 ret = dev->data->clock_init(pdev, dev); in orion_wdt_probe()
582 dev_err(&pdev->dev, "cannot initialize clock\n"); in orion_wdt_probe()
586 wdt_max_duration = WDT_MAX_CYCLE_COUNT / dev->clk_rate; in orion_wdt_probe()
588 dev->wdt.timeout = wdt_max_duration; in orion_wdt_probe()
589 dev->wdt.max_timeout = wdt_max_duration; in orion_wdt_probe()
590 dev->wdt.parent = &pdev->dev; in orion_wdt_probe()
591 watchdog_init_timeout(&dev->wdt, heartbeat, &pdev->dev); in orion_wdt_probe()
593 platform_set_drvdata(pdev, &dev->wdt); in orion_wdt_probe()
594 watchdog_set_drvdata(&dev->wdt, dev); in orion_wdt_probe()
602 if (!orion_wdt_enabled(&dev->wdt)) in orion_wdt_probe()
603 orion_wdt_stop(&dev->wdt); in orion_wdt_probe()
605 set_bit(WDOG_HW_RUNNING, &dev->wdt.status); in orion_wdt_probe()
614 ret = devm_request_irq(&pdev->dev, irq, orion_wdt_irq, 0, in orion_wdt_probe()
615 pdev->name, dev); in orion_wdt_probe()
617 dev_err(&pdev->dev, "failed to request IRQ\n"); in orion_wdt_probe()
626 ret = devm_request_irq(&pdev->dev, irq, orion_wdt_pre_irq, in orion_wdt_probe()
627 0, pdev->name, dev); in orion_wdt_probe()
629 dev_err(&pdev->dev, "failed to request IRQ\n"); in orion_wdt_probe()
635 watchdog_set_nowayout(&dev->wdt, nowayout); in orion_wdt_probe()
636 ret = watchdog_register_device(&dev->wdt); in orion_wdt_probe()
641 dev->wdt.timeout, nowayout ? ", nowayout" : ""); in orion_wdt_probe()
645 clk_disable_unprepare(dev->clk); in orion_wdt_probe()
646 clk_put(dev->clk); in orion_wdt_probe()
653 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); in orion_wdt_remove() local
656 clk_disable_unprepare(dev->clk); in orion_wdt_remove()
657 clk_put(dev->clk); in orion_wdt_remove()