Lines Matching +full:lpc1850 +full:- +full:rgu
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Reset driver for NXP LPC18xx/43xx Reset Generation Unit (RGU).
16 #include <linux/reset-controller.h>
19 /* LPC18xx RGU registers */
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()
109 udelay(rc->delay_us); in lpc18xx_rgu_reset()
129 return !(readl(rc->base + offset) & bit); in lpc18xx_rgu_status()
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_enabled(&pdev->dev, "reg"); in lpc18xx_rgu_probe()
154 if (IS_ERR(rc->clk_reg)) in lpc18xx_rgu_probe()
155 return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_reg), in lpc18xx_rgu_probe()
158 rc->clk_delay = devm_clk_get_enabled(&pdev->dev, "delay"); in lpc18xx_rgu_probe()
159 if (IS_ERR(rc->clk_delay)) in lpc18xx_rgu_probe()
160 return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_delay), in lpc18xx_rgu_probe()
163 fcclk = clk_get_rate(rc->clk_reg) / USEC_PER_SEC; in lpc18xx_rgu_probe()
164 firc = clk_get_rate(rc->clk_delay) / USEC_PER_SEC; in lpc18xx_rgu_probe()
166 rc->delay_us = 2; in lpc18xx_rgu_probe()
168 rc->delay_us = DIV_ROUND_UP(fcclk, firc * firc); in lpc18xx_rgu_probe()
170 spin_lock_init(&rc->lock); in lpc18xx_rgu_probe()
172 rc->rcdev.owner = THIS_MODULE; in lpc18xx_rgu_probe()
173 rc->rcdev.nr_resets = 64; in lpc18xx_rgu_probe()
174 rc->rcdev.ops = &lpc18xx_rgu_ops; in lpc18xx_rgu_probe()
175 rc->rcdev.of_node = pdev->dev.of_node; in lpc18xx_rgu_probe()
177 ret = reset_controller_register(&rc->rcdev); in lpc18xx_rgu_probe()
179 return dev_err_probe(&pdev->dev, ret, "unable to register device\n"); in lpc18xx_rgu_probe()
181 rc->restart_nb.priority = 192, in lpc18xx_rgu_probe()
182 rc->restart_nb.notifier_call = lpc18xx_rgu_restart, in lpc18xx_rgu_probe()
183 ret = register_restart_handler(&rc->restart_nb); in lpc18xx_rgu_probe()
185 dev_warn(&pdev->dev, "failed to register restart handler\n"); in lpc18xx_rgu_probe()
191 { .compatible = "nxp,lpc1850-rgu" },
198 .name = "lpc18xx-reset",