• Home
  • Raw
  • Download

Lines Matching +full:npcm750 +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/reset-controller.h>
36 /* NPCM7xx Reset registers */
104 writel(NPCM_SWRST << rc->sw_reset_number, rc->base + NPCM_SWRSTR); in npcm_rc_restart()
121 spin_lock_irqsave(&rc->lock, flags); in npcm_rc_setclear_reset()
122 stat = readl(rc->base + ctrl_offset); in npcm_rc_setclear_reset()
124 writel(stat | rst_bit, rc->base + ctrl_offset); in npcm_rc_setclear_reset()
126 writel(stat & ~rst_bit, rc->base + ctrl_offset); in npcm_rc_setclear_reset()
127 spin_unlock_irqrestore(&rc->lock, flags); in npcm_rc_setclear_reset()
150 return (readl(rc->base + ctrl_offset) & rst_bit); in npcm_rc_status()
161 offset = reset_spec->args[0]; in npcm_reset_xlate()
162 for (off_num = 0 ; off_num < rc->info->num_ipsrst ; off_num++) { in npcm_reset_xlate()
163 if (offset == rc->info->ipsrst[off_num]) { in npcm_reset_xlate()
170 dev_err(rcdev->dev, "Error reset register (0x%x)\n", offset); in npcm_reset_xlate()
171 return -EINVAL; in npcm_reset_xlate()
174 bit = reset_spec->args[1]; in npcm_reset_xlate()
176 dev_err(rcdev->dev, "Error reset number (%d)\n", bit); in npcm_reset_xlate()
177 return -EINVAL; in npcm_reset_xlate()
184 { .compatible = "nuvoton,npcm750-reset", .data = &npxm7xx_reset_info},
185 { .compatible = "nuvoton,npcm845-reset", .data = &npxm8xx_reset_info},
197 regmap_read(rc->gcr_regmap, NPCM_MDLR_OFFSET, &mdlr); in npcm_usb_reset_npcm7xx()
214 /* assert reset USB PHY and USB devices */ in npcm_usb_reset_npcm7xx()
215 iprst1 = readl(rc->base + NPCM_IPSRST1); in npcm_usb_reset_npcm7xx()
216 iprst2 = readl(rc->base + NPCM_IPSRST2); in npcm_usb_reset_npcm7xx()
217 iprst3 = readl(rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm7xx()
224 writel(iprst1, rc->base + NPCM_IPSRST1); in npcm_usb_reset_npcm7xx()
225 writel(iprst2, rc->base + NPCM_IPSRST2); in npcm_usb_reset_npcm7xx()
226 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm7xx()
229 regmap_update_bits(rc->gcr_regmap, NPCM_USB1PHYCTL_OFFSET, in npcm_usb_reset_npcm7xx()
231 regmap_update_bits(rc->gcr_regmap, NPCM_USB2PHYCTL_OFFSET, in npcm_usb_reset_npcm7xx()
234 /* deassert reset USB PHY */ in npcm_usb_reset_npcm7xx()
236 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm7xx()
241 regmap_update_bits(rc->gcr_regmap, NPCM_USB1PHYCTL_OFFSET, in npcm_usb_reset_npcm7xx()
243 regmap_update_bits(rc->gcr_regmap, NPCM_USB2PHYCTL_OFFSET, in npcm_usb_reset_npcm7xx()
246 /* deassert reset USB devices*/ in npcm_usb_reset_npcm7xx()
251 writel(iprst1, rc->base + NPCM_IPSRST1); in npcm_usb_reset_npcm7xx()
252 writel(iprst2, rc->base + NPCM_IPSRST2); in npcm_usb_reset_npcm7xx()
253 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm7xx()
265 regmap_read(rc->gcr_regmap, NPCM_MDLR_OFFSET, &mdlr); in npcm_usb_reset_npcm8xx()
284 /* assert reset USB PHY and USB devices */ in npcm_usb_reset_npcm8xx()
285 iprst1 = readl(rc->base + NPCM_IPSRST1); in npcm_usb_reset_npcm8xx()
286 iprst2 = readl(rc->base + NPCM_IPSRST2); in npcm_usb_reset_npcm8xx()
287 iprst3 = readl(rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm8xx()
288 iprst4 = readl(rc->base + NPCM_IPSRST4); in npcm_usb_reset_npcm8xx()
296 writel(iprst1, rc->base + NPCM_IPSRST1); in npcm_usb_reset_npcm8xx()
297 writel(iprst2, rc->base + NPCM_IPSRST2); in npcm_usb_reset_npcm8xx()
298 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm8xx()
299 writel(iprst4, rc->base + NPCM_IPSRST4); in npcm_usb_reset_npcm8xx()
302 regmap_update_bits(rc->gcr_regmap, NPCM_USB1PHYCTL_OFFSET, in npcm_usb_reset_npcm8xx()
304 regmap_update_bits(rc->gcr_regmap, NPCM_USB2PHYCTL_OFFSET, in npcm_usb_reset_npcm8xx()
306 regmap_update_bits(rc->gcr_regmap, NPCM_USB3PHYCTL_OFFSET, in npcm_usb_reset_npcm8xx()
309 /* deassert reset USB PHY */ in npcm_usb_reset_npcm8xx()
311 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm8xx()
313 writel(iprst4, rc->base + NPCM_IPSRST4); in npcm_usb_reset_npcm8xx()
316 regmap_update_bits(rc->gcr_regmap, NPCM_USB1PHYCTL_OFFSET, in npcm_usb_reset_npcm8xx()
318 regmap_update_bits(rc->gcr_regmap, NPCM_USB2PHYCTL_OFFSET, in npcm_usb_reset_npcm8xx()
320 regmap_update_bits(rc->gcr_regmap, NPCM_USB3PHYCTL_OFFSET, in npcm_usb_reset_npcm8xx()
323 /* deassert reset USB devices*/ in npcm_usb_reset_npcm8xx()
329 writel(iprst1, rc->base + NPCM_IPSRST1); in npcm_usb_reset_npcm8xx()
330 writel(iprst2, rc->base + NPCM_IPSRST2); in npcm_usb_reset_npcm8xx()
331 writel(iprst3, rc->base + NPCM_IPSRST3); in npcm_usb_reset_npcm8xx()
332 writel(iprst4, rc->base + NPCM_IPSRST4); in npcm_usb_reset_npcm8xx()
341 struct device *dev = &pdev->dev; in npcm_usb_reset()
343 rc->gcr_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "nuvoton,sysgcr"); in npcm_usb_reset()
344 if (IS_ERR(rc->gcr_regmap)) { in npcm_usb_reset()
345 dev_warn(&pdev->dev, "Failed to find nuvoton,sysgcr property, please update the device tree\n"); in npcm_usb_reset()
346 dev_info(&pdev->dev, "Using nuvoton,npcm750-gcr for Poleg backward compatibility\n"); in npcm_usb_reset()
347 rc->gcr_regmap = syscon_regmap_lookup_by_compatible("nuvoton,npcm750-gcr"); in npcm_usb_reset()
348 if (IS_ERR(rc->gcr_regmap)) { in npcm_usb_reset()
349 dev_err(&pdev->dev, "Failed to find nuvoton,npcm750-gcr"); in npcm_usb_reset()
350 return PTR_ERR(rc->gcr_regmap); in npcm_usb_reset()
354 rc->info = (const struct npcm_reset_info *) in npcm_usb_reset()
355 of_match_device(dev->driver->of_match_table, dev)->data; in npcm_usb_reset()
356 switch (rc->info->bmc_id) { in npcm_usb_reset()
364 return -ENODEV; in npcm_usb_reset()
381 rc = devm_kzalloc(&pdev->dev, sizeof(*rc), GFP_KERNEL); in npcm_rc_probe()
383 return -ENOMEM; in npcm_rc_probe()
385 rc->base = devm_platform_ioremap_resource(pdev, 0); in npcm_rc_probe()
386 if (IS_ERR(rc->base)) in npcm_rc_probe()
387 return PTR_ERR(rc->base); in npcm_rc_probe()
389 spin_lock_init(&rc->lock); in npcm_rc_probe()
391 rc->rcdev.owner = THIS_MODULE; in npcm_rc_probe()
392 rc->rcdev.ops = &npcm_rc_ops; in npcm_rc_probe()
393 rc->rcdev.of_node = pdev->dev.of_node; in npcm_rc_probe()
394 rc->rcdev.of_reset_n_cells = 2; in npcm_rc_probe()
395 rc->rcdev.of_xlate = npcm_reset_xlate; in npcm_rc_probe()
397 ret = devm_reset_controller_register(&pdev->dev, &rc->rcdev); in npcm_rc_probe()
399 dev_err(&pdev->dev, "unable to register device\n"); in npcm_rc_probe()
404 dev_warn(&pdev->dev, "NPCM USB reset failed, can cause issues with UDC and USB host\n"); in npcm_rc_probe()
406 if (!of_property_read_u32(pdev->dev.of_node, "nuvoton,sw-reset-number", in npcm_rc_probe()
407 &rc->sw_reset_number)) { in npcm_rc_probe()
408 if (rc->sw_reset_number && rc->sw_reset_number < 5) { in npcm_rc_probe()
409 rc->restart_nb.priority = 192, in npcm_rc_probe()
410 rc->restart_nb.notifier_call = npcm_rc_restart, in npcm_rc_probe()
411 ret = register_restart_handler(&rc->restart_nb); in npcm_rc_probe()
413 dev_warn(&pdev->dev, "failed to register restart handler\n"); in npcm_rc_probe()
423 .name = "npcm-reset",