Lines Matching +full:max +full:- +full:reason

6  * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcosoft.com>
20 #include <linux/reset-controller.h>
26 #include <dt-bindings/reset/sama7g5-reset.h>
47 * enum reset_type - reset types
48 * @RESET_TYPE_GENERAL: first power-up reset
69 * struct at91_reset - AT91 reset specific data structure
97 * struct at91_reset_data - AT91 reset data
101 * @device_reset_max_id: max id for device reset
141 : "r" (reset->ramc_base[0]), in at91_reset()
142 "r" (reset->ramc_base[1]), in at91_reset()
143 "r" (reset->rstc_base), in at91_reset()
146 "r" (reset->data->reset_args), in at91_reset()
147 "r" (reset->ramc_lpr) in at91_reset()
155 u32 reg = readl(reset->rstc_base + AT91_RSTC_SR); in at91_reset_reason()
156 const char *reason; in at91_reset_reason() local
160 reason = POWER_ON_REASON_REGULAR; in at91_reset_reason()
163 reason = POWER_ON_REASON_RTC; in at91_reset_reason()
166 reason = POWER_ON_REASON_WATCHDOG; in at91_reset_reason()
169 reason = POWER_ON_REASON_SOFTWARE; in at91_reset_reason()
172 reason = POWER_ON_REASON_RST_BTN; in at91_reset_reason()
175 reason = POWER_ON_REASON_CPU_CLK_FAIL; in at91_reset_reason()
178 reason = POWER_ON_REASON_XTAL_FAIL; in at91_reset_reason()
181 reason = POWER_ON_REASON_BROWN_OUT; in at91_reset_reason()
184 reason = POWER_ON_REASON_UNKNOWN; in at91_reset_reason()
188 return reason; in at91_reset_reason()
203 .compatible = "atmel,at91sam9260-sdramc",
207 .compatible = "atmel,at91sam9g45-ddramc",
230 .compatible = "atmel,at91sam9260-rstc",
234 .compatible = "atmel,at91sam9g45-rstc",
238 .compatible = "atmel,sama5d3-rstc",
242 .compatible = "atmel,samx7-rstc",
246 .compatible = "microchip,sam9x60-rstc",
250 .compatible = "microchip,sama7g5-rstc",
264 spin_lock_irqsave(&reset->lock, flags); in at91_reset_update()
265 val = readl_relaxed(reset->dev_base); in at91_reset_update()
270 writel_relaxed(val, reset->dev_base); in at91_reset_update()
271 spin_unlock_irqrestore(&reset->lock, flags); in at91_reset_update()
294 val = readl_relaxed(reset->dev_base); in at91_reset_dev_status()
310 if (!reset->data->n_device_reset || in at91_reset_of_xlate()
311 (reset_spec->args[0] < reset->data->device_reset_min_id || in at91_reset_of_xlate()
312 reset_spec->args[0] > reset->data->device_reset_max_id)) in at91_reset_of_xlate()
313 return -EINVAL; in at91_reset_of_xlate()
315 return reset_spec->args[0]; in at91_reset_of_xlate()
321 if (!reset->data->n_device_reset) in at91_rcdev_init()
324 reset->dev_base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 1, in at91_rcdev_init()
326 if (IS_ERR(reset->dev_base)) in at91_rcdev_init()
327 return -ENODEV; in at91_rcdev_init()
329 spin_lock_init(&reset->lock); in at91_rcdev_init()
330 reset->rcdev.ops = &at91_reset_ops; in at91_rcdev_init()
331 reset->rcdev.owner = THIS_MODULE; in at91_rcdev_init()
332 reset->rcdev.of_node = pdev->dev.of_node; in at91_rcdev_init()
333 reset->rcdev.nr_resets = reset->data->n_device_reset; in at91_rcdev_init()
334 reset->rcdev.of_reset_n_cells = 1; in at91_rcdev_init()
335 reset->rcdev.of_xlate = at91_reset_of_xlate; in at91_rcdev_init()
337 return devm_reset_controller_register(&pdev->dev, &reset->rcdev); in at91_rcdev_init()
347 reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL); in at91_reset_probe()
349 return -ENOMEM; in at91_reset_probe()
351 reset->rstc_base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); in at91_reset_probe()
352 if (IS_ERR(reset->rstc_base)) { in at91_reset_probe()
353 dev_err(&pdev->dev, "Could not map reset controller address\n"); in at91_reset_probe()
354 return -ENODEV; in at91_reset_probe()
357 if (!of_device_is_compatible(pdev->dev.of_node, "atmel,sama5d3-rstc")) { in at91_reset_probe()
360 reset->ramc_lpr = (u32)match->data; in at91_reset_probe()
361 reset->ramc_base[idx] = devm_of_iomap(&pdev->dev, np, 0, NULL); in at91_reset_probe()
362 if (IS_ERR(reset->ramc_base[idx])) { in at91_reset_probe()
363 dev_err(&pdev->dev, "Could not map ram controller address\n"); in at91_reset_probe()
365 return -ENODEV; in at91_reset_probe()
371 reset->data = device_get_match_data(&pdev->dev); in at91_reset_probe()
372 if (!reset->data) in at91_reset_probe()
373 return -ENODEV; in at91_reset_probe()
375 reset->nb.notifier_call = at91_reset; in at91_reset_probe()
376 reset->nb.priority = 192; in at91_reset_probe()
378 reset->sclk = devm_clk_get(&pdev->dev, NULL); in at91_reset_probe()
379 if (IS_ERR(reset->sclk)) in at91_reset_probe()
380 return PTR_ERR(reset->sclk); in at91_reset_probe()
382 ret = clk_prepare_enable(reset->sclk); in at91_reset_probe()
384 dev_err(&pdev->dev, "Could not enable slow clock\n"); in at91_reset_probe()
394 if (of_device_is_compatible(pdev->dev.of_node, "microchip,sam9x60-rstc")) { in at91_reset_probe()
395 u32 val = readl(reset->rstc_base + AT91_RSTC_MR); in at91_reset_probe()
398 reset->rstc_base + AT91_RSTC_MR); in at91_reset_probe()
401 ret = register_restart_handler(&reset->nb); in at91_reset_probe()
405 ret = device_create_file(&pdev->dev, &dev_attr_power_on_reason); in at91_reset_probe()
407 dev_err(&pdev->dev, "Could not create sysfs entry\n"); in at91_reset_probe()
411 dev_info(&pdev->dev, "Starting after %s\n", at91_reset_reason(reset)); in at91_reset_probe()
416 clk_disable_unprepare(reset->sclk); in at91_reset_probe()
424 unregister_restart_handler(&reset->nb); in at91_reset_remove()
425 clk_disable_unprepare(reset->sclk); in at91_reset_remove()
432 .name = "at91-reset",