Lines Matching +full:primecell +full:- +full:periphid

1 // SPDX-License-Identifier: GPL-2.0-only
19 #include <linux/clk/clk-conf.h>
27 /* called on periphid match and class 0x9 coresight device. */
34 uci = table->data; in amba_cs_uci_id_match()
36 /* no table data or zero mask - return match on periphid */ in amba_cs_uci_id_match()
37 if (!uci || (uci->devarch_mask == 0)) in amba_cs_uci_id_match()
41 ret = (dev->uci.devtype == uci->devtype) && in amba_cs_uci_id_match()
42 ((dev->uci.devarch & uci->devarch_mask) == uci->devarch); in amba_cs_uci_id_match()
49 while (table->mask) { in amba_lookup()
50 if (((dev->periphid & table->mask) == table->id) && in amba_lookup()
51 ((dev->cid != CORESIGHT_CID) || in amba_lookup()
63 pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk"); in amba_get_enable_pclk()
64 if (IS_ERR(pcdev->pclk)) in amba_get_enable_pclk()
65 return PTR_ERR(pcdev->pclk); in amba_get_enable_pclk()
67 ret = clk_prepare_enable(pcdev->pclk); in amba_get_enable_pclk()
69 clk_put(pcdev->pclk); in amba_get_enable_pclk()
76 clk_disable_unprepare(pcdev->pclk); in amba_put_disable_pclk()
77 clk_put(pcdev->pclk); in amba_put_disable_pclk()
88 len = sprintf(buf, "%s\n", dev->driver_override); in driver_override_show()
101 if (count >= (PAGE_SIZE - 1)) in driver_override_store()
102 return -EINVAL; in driver_override_store()
106 return -ENOMEM; in driver_override_store()
113 old = dev->driver_override; in driver_override_store()
115 dev->driver_override = driver_override; in driver_override_store()
118 dev->driver_override = NULL; in driver_override_store()
137 amba_attr_func(id, "%08x\n", dev->periphid);
138 amba_attr_func(irq0, "%u\n", dev->irq[0]);
139 amba_attr_func(irq1, "%u\n", dev->irq[1]);
141 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
142 dev->res.flags);
158 if (pcdev->driver_override) in amba_match()
159 return !strcmp(pcdev->driver_override, drv->name); in amba_match()
161 return amba_lookup(pcdrv->id_table, pcdev) != NULL; in amba_match()
169 retval = add_uevent_var(env, "AMBA_ID=%08x", pcdev->periphid); in amba_uevent()
173 retval = add_uevent_var(env, "MODALIAS=amba:d%08X", pcdev->periphid); in amba_uevent()
184 struct amba_driver *pcdrv = to_amba_driver(dev->driver); in amba_probe()
185 const struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev); in amba_probe()
189 ret = of_clk_set_defaults(dev->of_node, false); in amba_probe()
207 ret = pcdrv->probe(pcdev, id); in amba_probe()
225 struct amba_driver *drv = to_amba_driver(dev->driver); in amba_remove()
228 if (drv->remove) in amba_remove()
229 drv->remove(pcdev); in amba_remove()
245 if (!dev->driver) in amba_shutdown()
248 drv = to_amba_driver(dev->driver); in amba_shutdown()
249 if (drv->shutdown) in amba_shutdown()
250 drv->shutdown(to_amba_device(dev)); in amba_shutdown()
264 if (ret == 0 && dev->driver) { in amba_pm_runtime_suspend()
266 clk_disable(pcdev->pclk); in amba_pm_runtime_suspend()
268 clk_disable_unprepare(pcdev->pclk); in amba_pm_runtime_suspend()
279 if (dev->driver) { in amba_pm_runtime_resume()
281 ret = clk_enable(pcdev->pclk); in amba_pm_runtime_resume()
283 ret = clk_prepare_enable(pcdev->pclk); in amba_pm_runtime_resume()
334 * amba_driver_register - register an AMBA device driver
338 * core. If devices pre-exist, the drivers probe function will
343 if (!drv->probe) in amba_driver_register()
344 return -EINVAL; in amba_driver_register()
346 drv->drv.bus = &amba_bustype; in amba_driver_register()
348 return driver_register(&drv->drv); in amba_driver_register()
352 * amba_driver_unregister - remove an AMBA device driver
361 driver_unregister(&drv->drv); in amba_driver_unregister()
369 if (d->res.parent) in amba_device_release()
370 release_resource(&d->res); in amba_device_release()
380 WARN_ON(dev->irq[0] == (unsigned int)-1); in amba_device_try_add()
381 WARN_ON(dev->irq[1] == (unsigned int)-1); in amba_device_try_add()
383 ret = request_resource(parent, &dev->res); in amba_device_try_add()
387 /* Hard-coded primecell ID instead of plug-n-play */ in amba_device_try_add()
388 if (dev->periphid != 0) in amba_device_try_add()
395 size = resource_size(&dev->res); in amba_device_try_add()
396 tmp = ioremap(dev->res.start, size); in amba_device_try_add()
398 ret = -ENOMEM; in amba_device_try_add()
402 ret = dev_pm_domain_attach(&dev->dev, true); in amba_device_try_add()
414 * Find reset control(s) of the amba bus and de-assert them. in amba_device_try_add()
416 rstc = of_reset_control_array_get_optional_shared(dev->dev.of_node); in amba_device_try_add()
419 if (ret != -EPROBE_DEFER) in amba_device_try_add()
420 dev_err(&dev->dev, "can't get reset: %d\n", in amba_device_try_add()
432 pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << in amba_device_try_add()
435 cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << in amba_device_try_add()
440 void __iomem *csbase = tmp + size - 4096; in amba_device_try_add()
442 dev->uci.devarch = in amba_device_try_add()
444 dev->uci.devtype = in amba_device_try_add()
451 dev->periphid = pid; in amba_device_try_add()
452 dev->cid = cid; in amba_device_try_add()
455 if (!dev->periphid) in amba_device_try_add()
456 ret = -ENODEV; in amba_device_try_add()
460 dev_pm_domain_detach(&dev->dev, true); in amba_device_try_add()
466 ret = device_add(&dev->dev); in amba_device_try_add()
470 if (dev->irq[0]) in amba_device_try_add()
471 ret = device_create_file(&dev->dev, &dev_attr_irq0); in amba_device_try_add()
472 if (ret == 0 && dev->irq[1]) in amba_device_try_add()
473 ret = device_create_file(&dev->dev, &dev_attr_irq1); in amba_device_try_add()
477 device_unregister(&dev->dev); in amba_device_try_add()
480 release_resource(&dev->res); in amba_device_try_add()
487 dev_pm_domain_detach(&dev->dev, true); in amba_device_try_add()
521 int ret = amba_device_try_add(ddev->dev, ddev->parent); in amba_deferred_retry()
523 if (ret == -EPROBE_DEFER) in amba_deferred_retry()
526 list_del_init(&ddev->node); in amba_deferred_retry()
546 * amba_device_add - add a previously allocated AMBA device structure
558 if (ret == -EPROBE_DEFER) { in amba_device_add()
563 return -ENOMEM; in amba_device_add()
565 ddev->dev = dev; in amba_device_add()
566 ddev->parent = parent; in amba_device_add()
574 list_add_tail(&ddev->node, &deferred_devices); in amba_device_add()
585 void *pdata, unsigned int periphid, u64 dma_mask, in amba_aphb_device_add() argument
593 return ERR_PTR(-ENOMEM); in amba_aphb_device_add()
595 dev->dev.coherent_dma_mask = dma_mask; in amba_aphb_device_add()
596 dev->irq[0] = irq1; in amba_aphb_device_add()
597 dev->irq[1] = irq2; in amba_aphb_device_add()
598 dev->periphid = periphid; in amba_aphb_device_add()
599 dev->dev.platform_data = pdata; in amba_aphb_device_add()
600 dev->dev.parent = parent; in amba_aphb_device_add()
614 void *pdata, unsigned int periphid) in amba_apb_device_add() argument
617 periphid, 0, &iomem_resource); in amba_apb_device_add()
624 void *pdata, unsigned int periphid) in amba_ahb_device_add() argument
627 periphid, ~0ULL, &iomem_resource); in amba_ahb_device_add()
634 int irq2, void *pdata, unsigned int periphid, in amba_apb_device_add_res() argument
638 periphid, 0, resbase); in amba_apb_device_add_res()
645 int irq2, void *pdata, unsigned int periphid, in amba_ahb_device_add_res() argument
649 periphid, ~0ULL, resbase); in amba_ahb_device_add_res()
656 device_initialize(&dev->dev); in amba_device_initialize()
658 dev_set_name(&dev->dev, "%s", name); in amba_device_initialize()
659 dev->dev.release = amba_device_release; in amba_device_initialize()
660 dev->dev.bus = &amba_bustype; in amba_device_initialize()
661 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; in amba_device_initialize()
662 dev->dev.dma_parms = &dev->dma_parms; in amba_device_initialize()
663 dev->res.name = dev_name(&dev->dev); in amba_device_initialize()
667 * amba_device_alloc - allocate an AMBA device
683 dev->res.start = base; in amba_device_alloc()
684 dev->res.end = base + size - 1; in amba_device_alloc()
685 dev->res.flags = IORESOURCE_MEM; in amba_device_alloc()
693 * amba_device_register - register an AMBA device
703 amba_device_initialize(dev, dev->dev.init_name); in amba_device_register()
704 dev->dev.init_name = NULL; in amba_device_register()
710 * amba_device_put - put an AMBA device
715 put_device(&dev->dev); in amba_device_put()
720 * amba_device_unregister - unregister an AMBA device
732 device_unregister(&dev->dev); in amba_device_unregister()
750 r = (pcdev->periphid & d->mask) == d->id; in amba_find_match()
751 if (d->parent) in amba_find_match()
752 r &= d->parent == dev->parent; in amba_find_match()
753 if (d->busid) in amba_find_match()
754 r &= strcmp(dev_name(dev), d->busid) == 0; in amba_find_match()
758 d->dev = pcdev; in amba_find_match()
765 * amba_find_device - locate an AMBA device given a bus id
796 * amba_request_regions - request all mem regions associated with device
806 name = dev->dev.driver->name; in amba_request_regions()
808 size = resource_size(&dev->res); in amba_request_regions()
810 if (!request_mem_region(dev->res.start, size, name)) in amba_request_regions()
811 ret = -EBUSY; in amba_request_regions()
817 * amba_release_regions - release mem regions associated with device
826 size = resource_size(&dev->res); in amba_release_regions()
827 release_mem_region(dev->res.start, size); in amba_release_regions()