Lines Matching +full:reset +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Reset driver for NXP LPC18xx/43xx Reset Generation Unit (RGU).
9 #include <linux/delay.h>
16 #include <linux/reset-controller.h>
27 /* Internal reset outputs */
50 writel(BIT(LPC18XX_RGU_CORE_RST), rc->base + LPC18XX_RGU_CTRL0); in lpc18xx_rgu_restart()
59 * The LPC18xx RGU has mostly self-deasserting resets except for the
60 * two reset lines going to the internal Cortex-M0 cores.
79 spin_lock_irqsave(&rc->lock, flags); in lpc18xx_rgu_setclear_reset()
80 stat = ~readl(rc->base + stat_offset); in lpc18xx_rgu_setclear_reset()
82 writel(stat | rst_bit, rc->base + ctrl_offset); in lpc18xx_rgu_setclear_reset()
84 writel(stat & ~rst_bit, rc->base + ctrl_offset); in lpc18xx_rgu_setclear_reset()
85 spin_unlock_irqrestore(&rc->lock, flags); in lpc18xx_rgu_setclear_reset()
102 /* Only M0 cores require explicit reset deassert */
109 udelay(rc->delay_us); in lpc18xx_rgu_reset()
129 return !(readl(rc->base + offset) & bit); in lpc18xx_rgu_status()
133 .reset = lpc18xx_rgu_reset,
145 rc = devm_kzalloc(&pdev->dev, sizeof(*rc), GFP_KERNEL); in lpc18xx_rgu_probe()
147 return -ENOMEM; in lpc18xx_rgu_probe()
149 rc->base = devm_platform_ioremap_resource(pdev, 0); in lpc18xx_rgu_probe()
150 if (IS_ERR(rc->base)) in lpc18xx_rgu_probe()
151 return PTR_ERR(rc->base); in lpc18xx_rgu_probe()
153 rc->clk_reg = devm_clk_get(&pdev->dev, "reg"); in lpc18xx_rgu_probe()
154 if (IS_ERR(rc->clk_reg)) { in lpc18xx_rgu_probe()
155 dev_err(&pdev->dev, "reg clock not found\n"); in lpc18xx_rgu_probe()
156 return PTR_ERR(rc->clk_reg); in lpc18xx_rgu_probe()
159 rc->clk_delay = devm_clk_get(&pdev->dev, "delay"); in lpc18xx_rgu_probe()
160 if (IS_ERR(rc->clk_delay)) { in lpc18xx_rgu_probe()
161 dev_err(&pdev->dev, "delay clock not found\n"); in lpc18xx_rgu_probe()
162 return PTR_ERR(rc->clk_delay); in lpc18xx_rgu_probe()
165 ret = clk_prepare_enable(rc->clk_reg); in lpc18xx_rgu_probe()
167 dev_err(&pdev->dev, "unable to enable reg clock\n"); in lpc18xx_rgu_probe()
171 ret = clk_prepare_enable(rc->clk_delay); in lpc18xx_rgu_probe()
173 dev_err(&pdev->dev, "unable to enable delay clock\n"); in lpc18xx_rgu_probe()
177 fcclk = clk_get_rate(rc->clk_reg) / USEC_PER_SEC; in lpc18xx_rgu_probe()
178 firc = clk_get_rate(rc->clk_delay) / USEC_PER_SEC; in lpc18xx_rgu_probe()
180 rc->delay_us = 2; in lpc18xx_rgu_probe()
182 rc->delay_us = DIV_ROUND_UP(fcclk, firc * firc); in lpc18xx_rgu_probe()
184 spin_lock_init(&rc->lock); in lpc18xx_rgu_probe()
186 rc->rcdev.owner = THIS_MODULE; in lpc18xx_rgu_probe()
187 rc->rcdev.nr_resets = 64; in lpc18xx_rgu_probe()
188 rc->rcdev.ops = &lpc18xx_rgu_ops; in lpc18xx_rgu_probe()
189 rc->rcdev.of_node = pdev->dev.of_node; in lpc18xx_rgu_probe()
191 ret = reset_controller_register(&rc->rcdev); in lpc18xx_rgu_probe()
193 dev_err(&pdev->dev, "unable to register device\n"); in lpc18xx_rgu_probe()
197 rc->restart_nb.priority = 192, in lpc18xx_rgu_probe()
198 rc->restart_nb.notifier_call = lpc18xx_rgu_restart, in lpc18xx_rgu_probe()
199 ret = register_restart_handler(&rc->restart_nb); in lpc18xx_rgu_probe()
201 dev_warn(&pdev->dev, "failed to register restart handler\n"); in lpc18xx_rgu_probe()
206 clk_disable_unprepare(rc->clk_delay); in lpc18xx_rgu_probe()
208 clk_disable_unprepare(rc->clk_reg); in lpc18xx_rgu_probe()
214 { .compatible = "nxp,lpc1850-rgu" },
221 .name = "lpc18xx-reset",