Lines Matching +full:npcm750 +full:- +full:reset
1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/reset-controller.h>
29 /* NPCM7xx Reset registers */
71 writel(NPCM_SWRST << rc->sw_reset_number, rc->base + NPCM_SWRSTR); in npcm_rc_restart()
88 spin_lock_irqsave(&rc->lock, flags); in npcm_rc_setclear_reset()
89 stat = readl(rc->base + ctrl_offset); in npcm_rc_setclear_reset()
91 writel(stat | rst_bit, rc->base + ctrl_offset); in npcm_rc_setclear_reset()
93 writel(stat & ~rst_bit, rc->base + ctrl_offset); in npcm_rc_setclear_reset()
94 spin_unlock_irqrestore(&rc->lock, flags); in npcm_rc_setclear_reset()
117 return (readl(rc->base + ctrl_offset) & rst_bit); in npcm_rc_status()
125 offset = reset_spec->args[0]; in npcm_reset_xlate()
128 dev_err(rcdev->dev, "Error reset register (0x%x)\n", offset); in npcm_reset_xlate()
129 return -EINVAL; in npcm_reset_xlate()
131 bit = reset_spec->args[1]; in npcm_reset_xlate()
133 dev_err(rcdev->dev, "Error reset number (%d)\n", bit); in npcm_reset_xlate()
134 return -EINVAL; in npcm_reset_xlate()
141 { .compatible = "nuvoton,npcm750-reset",
142 .data = (void *)"nuvoton,npcm750-gcr" },
153 struct device *dev = &pdev->dev; in npcm_usb_reset()
161 of_match_device(dev->driver->of_match_table, dev)->data; in npcm_usb_reset()
165 dev_err(&pdev->dev, "Failed to find %s\n", gcr_dt); in npcm_usb_reset()
187 /* assert reset USB PHY and USB devices */ in npcm_usb_reset()
188 iprst1 = readl(rc->base + NPCM_IPSRST1); in npcm_usb_reset()
189 iprst2 = readl(rc->base + NPCM_IPSRST2); in npcm_usb_reset()
190 iprst3 = readl(rc->base + NPCM_IPSRST3); in npcm_usb_reset()
197 writel(iprst1, rc->base + NPCM_IPSRST1); in npcm_usb_reset()
198 writel(iprst2, rc->base + NPCM_IPSRST2); in npcm_usb_reset()
199 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset()
207 /* deassert reset USB PHY */ in npcm_usb_reset()
209 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset()
219 /* deassert reset USB devices*/ in npcm_usb_reset()
224 writel(iprst1, rc->base + NPCM_IPSRST1); in npcm_usb_reset()
225 writel(iprst2, rc->base + NPCM_IPSRST2); in npcm_usb_reset()
226 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset()
242 rc = devm_kzalloc(&pdev->dev, sizeof(*rc), GFP_KERNEL); in npcm_rc_probe()
244 return -ENOMEM; in npcm_rc_probe()
246 rc->base = devm_platform_ioremap_resource(pdev, 0); in npcm_rc_probe()
247 if (IS_ERR(rc->base)) in npcm_rc_probe()
248 return PTR_ERR(rc->base); in npcm_rc_probe()
250 spin_lock_init(&rc->lock); in npcm_rc_probe()
252 rc->rcdev.owner = THIS_MODULE; in npcm_rc_probe()
253 rc->rcdev.ops = &npcm_rc_ops; in npcm_rc_probe()
254 rc->rcdev.of_node = pdev->dev.of_node; in npcm_rc_probe()
255 rc->rcdev.of_reset_n_cells = 2; in npcm_rc_probe()
256 rc->rcdev.of_xlate = npcm_reset_xlate; in npcm_rc_probe()
260 ret = devm_reset_controller_register(&pdev->dev, &rc->rcdev); in npcm_rc_probe()
262 dev_err(&pdev->dev, "unable to register device\n"); in npcm_rc_probe()
267 dev_warn(&pdev->dev, "NPCM USB reset failed, can cause issues with UDC and USB host\n"); in npcm_rc_probe()
269 if (!of_property_read_u32(pdev->dev.of_node, "nuvoton,sw-reset-number", in npcm_rc_probe()
270 &rc->sw_reset_number)) { in npcm_rc_probe()
271 if (rc->sw_reset_number && rc->sw_reset_number < 5) { in npcm_rc_probe()
272 rc->restart_nb.priority = 192, in npcm_rc_probe()
273 rc->restart_nb.notifier_call = npcm_rc_restart, in npcm_rc_probe()
274 ret = register_restart_handler(&rc->restart_nb); in npcm_rc_probe()
276 dev_warn(&pdev->dev, "failed to register restart handler\n"); in npcm_rc_probe()
286 .name = "npcm-reset",