Lines Matching refs:dev

32 amba_cs_uci_id_match(const struct amba_id *table, struct amba_device *dev)  in amba_cs_uci_id_match()  argument
44 ret = (dev->uci.devtype == uci->devtype) && in amba_cs_uci_id_match()
45 ((dev->uci.devarch & uci->devarch_mask) == uci->devarch); in amba_cs_uci_id_match()
50 amba_lookup(const struct amba_id *table, struct amba_device *dev) in amba_lookup() argument
53 if (((dev->periphid & table->mask) == table->id) && in amba_lookup()
54 ((dev->cid != CORESIGHT_CID) || in amba_lookup()
55 (amba_cs_uci_id_match(table, dev)))) in amba_lookup()
66 pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk"); in amba_get_enable_pclk()
87 struct amba_device *dev = to_amba_device(_dev); in driver_override_show() local
91 len = sprintf(buf, "%s\n", dev->driver_override); in driver_override_show()
100 struct amba_device *dev = to_amba_device(_dev); in driver_override_store() local
103 ret = driver_set_override(_dev, &dev->driver_override, buf, count); in driver_override_store()
115 struct amba_device *dev = to_amba_device(_dev); \
120 amba_attr_func(id, "%08x\n", dev->periphid);
122 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
123 dev->res.flags);
133 static int amba_read_periphid(struct amba_device *dev) in amba_read_periphid() argument
140 ret = dev_pm_domain_attach(&dev->dev, true); in amba_read_periphid()
142 dev_dbg(&dev->dev, "can't get PM domain: %d\n", ret); in amba_read_periphid()
146 ret = amba_get_enable_pclk(dev); in amba_read_periphid()
148 dev_dbg(&dev->dev, "can't get pclk: %d\n", ret); in amba_read_periphid()
155 rstc = of_reset_control_array_get_optional_shared(dev->dev.of_node); in amba_read_periphid()
159 dev_err(&dev->dev, "can't get reset: %d\n", ret); in amba_read_periphid()
165 size = resource_size(&dev->res); in amba_read_periphid()
166 tmp = ioremap(dev->res.start, size); in amba_read_periphid()
185 dev->uci.devarch = readl(csbase + UCI_REG_DEVARCH_OFFSET); in amba_read_periphid()
186 dev->uci.devtype = readl(csbase + UCI_REG_DEVTYPE_OFFSET) & 0xff; in amba_read_periphid()
190 dev->periphid = pid; in amba_read_periphid()
191 dev->cid = cid; in amba_read_periphid()
194 if (!dev->periphid) in amba_read_periphid()
200 amba_put_disable_pclk(dev); in amba_read_periphid()
202 dev_pm_domain_detach(&dev->dev, true); in amba_read_periphid()
207 static int amba_match(struct device *dev, struct device_driver *drv) in amba_match() argument
209 struct amba_device *pcdev = to_amba_device(dev); in amba_match()
226 dev_set_uevent_suppress(dev, false); in amba_match()
227 kobject_uevent(&dev->kobj, KOBJ_ADD); in amba_match()
238 static int amba_uevent(const struct device *dev, struct kobj_uevent_env *env) in amba_uevent() argument
240 const struct amba_device *pcdev = to_amba_device(dev); in amba_uevent()
251 static int of_amba_device_decode_irq(struct amba_device *dev) in of_amba_device_decode_irq() argument
253 struct device_node *node = dev->dev.of_node; in of_amba_device_decode_irq()
266 dev->irq[i] = irq; in of_amba_device_decode_irq()
277 static int amba_probe(struct device *dev) in amba_probe() argument
279 struct amba_device *pcdev = to_amba_device(dev); in amba_probe()
280 struct amba_driver *pcdrv = to_amba_driver(dev->driver); in amba_probe()
289 ret = of_clk_set_defaults(dev->of_node, false); in amba_probe()
293 ret = dev_pm_domain_attach(dev, true); in amba_probe()
299 dev_pm_domain_detach(dev, true); in amba_probe()
303 pm_runtime_get_noresume(dev); in amba_probe()
304 pm_runtime_set_active(dev); in amba_probe()
305 pm_runtime_enable(dev); in amba_probe()
311 pm_runtime_disable(dev); in amba_probe()
312 pm_runtime_set_suspended(dev); in amba_probe()
313 pm_runtime_put_noidle(dev); in amba_probe()
316 dev_pm_domain_detach(dev, true); in amba_probe()
322 static void amba_remove(struct device *dev) in amba_remove() argument
324 struct amba_device *pcdev = to_amba_device(dev); in amba_remove()
325 struct amba_driver *drv = to_amba_driver(dev->driver); in amba_remove()
327 pm_runtime_get_sync(dev); in amba_remove()
330 pm_runtime_put_noidle(dev); in amba_remove()
333 pm_runtime_disable(dev); in amba_remove()
334 pm_runtime_set_suspended(dev); in amba_remove()
335 pm_runtime_put_noidle(dev); in amba_remove()
338 dev_pm_domain_detach(dev, true); in amba_remove()
341 static void amba_shutdown(struct device *dev) in amba_shutdown() argument
345 if (!dev->driver) in amba_shutdown()
348 drv = to_amba_driver(dev->driver); in amba_shutdown()
350 drv->shutdown(to_amba_device(dev)); in amba_shutdown()
353 static int amba_dma_configure(struct device *dev) in amba_dma_configure() argument
355 struct amba_driver *drv = to_amba_driver(dev->driver); in amba_dma_configure()
359 if (dev->of_node) { in amba_dma_configure()
360 ret = of_dma_configure(dev, dev->of_node, true); in amba_dma_configure()
361 } else if (has_acpi_companion(dev)) { in amba_dma_configure()
362 attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); in amba_dma_configure()
363 ret = acpi_dma_configure(dev, attr); in amba_dma_configure()
367 ret = iommu_device_use_default_domain(dev); in amba_dma_configure()
369 arch_teardown_dma_ops(dev); in amba_dma_configure()
375 static void amba_dma_cleanup(struct device *dev) in amba_dma_cleanup() argument
377 struct amba_driver *drv = to_amba_driver(dev->driver); in amba_dma_cleanup()
380 iommu_device_unuse_default_domain(dev); in amba_dma_cleanup()
389 static int amba_pm_runtime_suspend(struct device *dev) in amba_pm_runtime_suspend() argument
391 struct amba_device *pcdev = to_amba_device(dev); in amba_pm_runtime_suspend()
392 int ret = pm_generic_runtime_suspend(dev); in amba_pm_runtime_suspend()
394 if (ret == 0 && dev->driver) { in amba_pm_runtime_suspend()
395 if (pm_runtime_is_irq_safe(dev)) in amba_pm_runtime_suspend()
404 static int amba_pm_runtime_resume(struct device *dev) in amba_pm_runtime_resume() argument
406 struct amba_device *pcdev = to_amba_device(dev); in amba_pm_runtime_resume()
409 if (dev->driver) { in amba_pm_runtime_resume()
410 if (pm_runtime_is_irq_safe(dev)) in amba_pm_runtime_resume()
419 return pm_generic_runtime_resume(dev); in amba_pm_runtime_resume()
527 static void amba_device_release(struct device *dev) in amba_device_release() argument
529 struct amba_device *d = to_amba_device(dev); in amba_device_release()
531 of_node_put(d->dev.of_node); in amba_device_release()
547 int amba_device_add(struct amba_device *dev, struct resource *parent) in amba_device_add() argument
551 ret = request_resource(parent, &dev->res); in amba_device_add()
556 if (!dev->periphid) { in amba_device_add()
565 if (amba_read_periphid(dev)) in amba_device_add()
566 dev_set_uevent_suppress(&dev->dev, true); in amba_device_add()
569 ret = device_add(&dev->dev); in amba_device_add()
571 release_resource(&dev->res); in amba_device_add()
577 static void amba_device_initialize(struct amba_device *dev, const char *name) in amba_device_initialize() argument
579 device_initialize(&dev->dev); in amba_device_initialize()
581 dev_set_name(&dev->dev, "%s", name); in amba_device_initialize()
582 dev->dev.release = amba_device_release; in amba_device_initialize()
583 dev->dev.bus = &amba_bustype; in amba_device_initialize()
584 dev->dev.dma_mask = &dev->dev.coherent_dma_mask; in amba_device_initialize()
585 dev->dev.dma_parms = &dev->dma_parms; in amba_device_initialize()
586 dev->res.name = dev_name(&dev->dev); in amba_device_initialize()
587 mutex_init(&dev->periphid_lock); in amba_device_initialize()
602 struct amba_device *dev; in amba_device_alloc() local
604 dev = kzalloc(sizeof(*dev), GFP_KERNEL); in amba_device_alloc()
605 if (dev) { in amba_device_alloc()
606 amba_device_initialize(dev, name); in amba_device_alloc()
607 dev->res.start = base; in amba_device_alloc()
608 dev->res.end = base + size - 1; in amba_device_alloc()
609 dev->res.flags = IORESOURCE_MEM; in amba_device_alloc()
612 return dev; in amba_device_alloc()
625 int amba_device_register(struct amba_device *dev, struct resource *parent) in amba_device_register() argument
627 amba_device_initialize(dev, dev->dev.init_name); in amba_device_register()
628 dev->dev.init_name = NULL; in amba_device_register()
630 return amba_device_add(dev, parent); in amba_device_register()
638 void amba_device_put(struct amba_device *dev) in amba_device_put() argument
640 put_device(&dev->dev); in amba_device_put()
655 void amba_device_unregister(struct amba_device *dev) in amba_device_unregister() argument
657 device_unregister(&dev->dev); in amba_device_unregister()
666 int amba_request_regions(struct amba_device *dev, const char *name) in amba_request_regions() argument
672 name = dev->dev.driver->name; in amba_request_regions()
674 size = resource_size(&dev->res); in amba_request_regions()
676 if (!request_mem_region(dev->res.start, size, name)) in amba_request_regions()
689 void amba_release_regions(struct amba_device *dev) in amba_release_regions() argument
693 size = resource_size(&dev->res); in amba_release_regions()
694 release_mem_region(dev->res.start, size); in amba_release_regions()