Lines Matching refs:dev

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