Lines Matching refs:dev
55 struct resource *platform_get_resource(struct platform_device *dev, in platform_get_resource() argument
60 for (i = 0; i < dev->num_resources; i++) { in platform_get_resource()
61 struct resource *r = &dev->resource[i]; in platform_get_resource()
70 struct resource *platform_get_mem_or_io(struct platform_device *dev, in platform_get_mem_or_io() argument
75 for (i = 0; i < dev->num_resources; i++) { in platform_get_mem_or_io()
76 struct resource *r = &dev->resource[i]; in platform_get_mem_or_io()
107 return devm_ioremap_resource(&pdev->dev, r); in devm_platform_get_and_ioremap_resource()
148 return devm_ioremap_resource(&pdev->dev, res); in devm_platform_ioremap_resource_byname()
171 int platform_get_irq_optional(struct platform_device *dev, unsigned int num) in platform_get_irq_optional() argument
176 if (!dev || num >= dev->archdata.num_irqs) in platform_get_irq_optional()
178 ret = dev->archdata.irqs[num]; in platform_get_irq_optional()
183 if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) { in platform_get_irq_optional()
184 ret = of_irq_get(dev->dev.of_node, num); in platform_get_irq_optional()
189 r = platform_get_resource(dev, IORESOURCE_IRQ, num); in platform_get_irq_optional()
190 if (has_acpi_companion(&dev->dev)) { in platform_get_irq_optional()
192 ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r); in platform_get_irq_optional()
225 if (num == 0 && has_acpi_companion(&dev->dev)) { in platform_get_irq_optional()
226 ret = acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num); in platform_get_irq_optional()
259 int platform_get_irq(struct platform_device *dev, unsigned int num) in platform_get_irq() argument
263 ret = platform_get_irq_optional(dev, num); in platform_get_irq()
265 return dev_err_probe(&dev->dev, ret, in platform_get_irq()
278 int platform_irq_count(struct platform_device *dev) in platform_irq_count() argument
282 while ((ret = platform_get_irq_optional(dev, nr)) >= 0) in platform_irq_count()
306 static void devm_platform_get_irqs_affinity_release(struct device *dev, in devm_platform_get_irqs_affinity_release() argument
315 if (has_acpi_companion(dev)) in devm_platform_get_irqs_affinity_release()
316 platform_disable_acpi_irq(to_platform_device(dev), i); in devm_platform_get_irqs_affinity_release()
334 int devm_platform_get_irqs_affinity(struct platform_device *dev, in devm_platform_get_irqs_affinity() argument
351 nvec = platform_irq_count(dev); in devm_platform_get_irqs_affinity()
374 int irq = platform_get_irq(dev, i); in devm_platform_get_irqs_affinity()
391 dev_err(&dev->dev, "failed to update irq%d affinity descriptor (%d)\n", in devm_platform_get_irqs_affinity()
397 devres_add(&dev->dev, ptr); in devm_platform_get_irqs_affinity()
419 struct resource *platform_get_resource_byname(struct platform_device *dev, in platform_get_resource_byname() argument
425 for (i = 0; i < dev->num_resources; i++) { in platform_get_resource_byname()
426 struct resource *r = &dev->resource[i]; in platform_get_resource_byname()
438 static int __platform_get_irq_byname(struct platform_device *dev, in __platform_get_irq_byname() argument
444 ret = fwnode_irq_get_byname(dev_fwnode(&dev->dev), name); in __platform_get_irq_byname()
448 r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); in __platform_get_irq_byname()
467 int platform_get_irq_byname(struct platform_device *dev, const char *name) in platform_get_irq_byname() argument
471 ret = __platform_get_irq_byname(dev, name); in platform_get_irq_byname()
473 return dev_err_probe(&dev->dev, ret, "IRQ %s not found\n", in platform_get_irq_byname()
489 int platform_get_irq_byname_optional(struct platform_device *dev, in platform_get_irq_byname_optional() argument
492 return __platform_get_irq_byname(dev, name); in platform_get_irq_byname_optional()
531 pdev->dev.dma_parms = &pdev->dma_parms; in setup_pdev_dma_masks()
533 if (!pdev->dev.coherent_dma_mask) in setup_pdev_dma_masks()
534 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); in setup_pdev_dma_masks()
535 if (!pdev->dev.dma_mask) { in setup_pdev_dma_masks()
537 pdev->dev.dma_mask = &pdev->platform_dma_mask; in setup_pdev_dma_masks()
551 put_device(&pdev->dev); in platform_device_put()
555 static void platform_device_release(struct device *dev) in platform_device_release() argument
557 struct platform_object *pa = container_of(dev, struct platform_object, in platform_device_release()
558 pdev.dev); in platform_device_release()
560 of_node_put(pa->pdev.dev.of_node); in platform_device_release()
561 kfree(pa->pdev.dev.platform_data); in platform_device_release()
585 device_initialize(&pa->pdev.dev); in platform_device_alloc()
586 pa->pdev.dev.release = platform_device_release; in platform_device_alloc()
643 kfree(pdev->dev.platform_data); in platform_device_add_data()
644 pdev->dev.platform_data = d; in platform_device_add_data()
664 if (!pdev->dev.parent) in platform_device_add()
665 pdev->dev.parent = &platform_bus; in platform_device_add()
667 pdev->dev.bus = &platform_bus_type; in platform_device_add()
671 dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); in platform_device_add()
674 dev_set_name(&pdev->dev, "%s", pdev->name); in platform_device_add()
687 dev_set_name(&pdev->dev, "%s.%d.auto", pdev->name, pdev->id); in platform_device_add()
695 r->name = dev_name(&pdev->dev); in platform_device_add()
708 dev_err(&pdev->dev, "failed to claim resource %d: %pR\n", i, r); in platform_device_add()
715 dev_name(&pdev->dev), dev_name(pdev->dev.parent)); in platform_device_add()
717 ret = device_add(&pdev->dev); in platform_device_add()
751 device_del(&pdev->dev); in platform_device_del()
777 device_initialize(&pdev->dev); in platform_device_register()
816 pdev->dev.parent = pdevinfo->parent; in platform_device_register_full()
817 pdev->dev.fwnode = pdevinfo->fwnode; in platform_device_register_full()
818 pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode)); in platform_device_register_full()
819 pdev->dev.of_node_reused = pdevinfo->of_node_reused; in platform_device_register_full()
823 pdev->dev.dma_mask = &pdev->platform_dma_mask; in platform_device_register_full()
824 pdev->dev.coherent_dma_mask = pdevinfo->dma_mask; in platform_device_register_full()
838 ret = device_create_managed_software_node(&pdev->dev, in platform_device_register_full()
847 ACPI_COMPANION_SET(&pdev->dev, NULL); in platform_device_register_full()
886 static int is_bound_to_driver(struct device *dev, void *driver) in is_bound_to_driver() argument
888 if (dev->driver == driver) in is_bound_to_driver()
1095 static int platform_legacy_suspend(struct device *dev, pm_message_t mesg) in platform_legacy_suspend() argument
1097 struct platform_driver *pdrv = to_platform_driver(dev->driver); in platform_legacy_suspend()
1098 struct platform_device *pdev = to_platform_device(dev); in platform_legacy_suspend()
1101 if (dev->driver && pdrv->suspend) in platform_legacy_suspend()
1107 static int platform_legacy_resume(struct device *dev) in platform_legacy_resume() argument
1109 struct platform_driver *pdrv = to_platform_driver(dev->driver); in platform_legacy_resume()
1110 struct platform_device *pdev = to_platform_device(dev); in platform_legacy_resume()
1113 if (dev->driver && pdrv->resume) in platform_legacy_resume()
1123 int platform_pm_suspend(struct device *dev) in platform_pm_suspend() argument
1125 struct device_driver *drv = dev->driver; in platform_pm_suspend()
1133 ret = drv->pm->suspend(dev); in platform_pm_suspend()
1135 ret = platform_legacy_suspend(dev, PMSG_SUSPEND); in platform_pm_suspend()
1141 int platform_pm_resume(struct device *dev) in platform_pm_resume() argument
1143 struct device_driver *drv = dev->driver; in platform_pm_resume()
1151 ret = drv->pm->resume(dev); in platform_pm_resume()
1153 ret = platform_legacy_resume(dev); in platform_pm_resume()
1163 int platform_pm_freeze(struct device *dev) in platform_pm_freeze() argument
1165 struct device_driver *drv = dev->driver; in platform_pm_freeze()
1173 ret = drv->pm->freeze(dev); in platform_pm_freeze()
1175 ret = platform_legacy_suspend(dev, PMSG_FREEZE); in platform_pm_freeze()
1181 int platform_pm_thaw(struct device *dev) in platform_pm_thaw() argument
1183 struct device_driver *drv = dev->driver; in platform_pm_thaw()
1191 ret = drv->pm->thaw(dev); in platform_pm_thaw()
1193 ret = platform_legacy_resume(dev); in platform_pm_thaw()
1199 int platform_pm_poweroff(struct device *dev) in platform_pm_poweroff() argument
1201 struct device_driver *drv = dev->driver; in platform_pm_poweroff()
1209 ret = drv->pm->poweroff(dev); in platform_pm_poweroff()
1211 ret = platform_legacy_suspend(dev, PMSG_HIBERNATE); in platform_pm_poweroff()
1217 int platform_pm_restore(struct device *dev) in platform_pm_restore() argument
1219 struct device_driver *drv = dev->driver; in platform_pm_restore()
1227 ret = drv->pm->restore(dev); in platform_pm_restore()
1229 ret = platform_legacy_resume(dev); in platform_pm_restore()
1243 static ssize_t modalias_show(struct device *dev, in modalias_show() argument
1246 struct platform_device *pdev = to_platform_device(dev); in modalias_show()
1249 len = of_device_modalias(dev, buf, PAGE_SIZE); in modalias_show()
1253 len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1); in modalias_show()
1261 static ssize_t numa_node_show(struct device *dev, in numa_node_show() argument
1264 return sysfs_emit(buf, "%d\n", dev_to_node(dev)); in numa_node_show()
1268 static ssize_t driver_override_show(struct device *dev, in driver_override_show() argument
1271 struct platform_device *pdev = to_platform_device(dev); in driver_override_show()
1274 device_lock(dev); in driver_override_show()
1276 device_unlock(dev); in driver_override_show()
1281 static ssize_t driver_override_store(struct device *dev, in driver_override_store() argument
1285 struct platform_device *pdev = to_platform_device(dev); in driver_override_store()
1288 ret = driver_set_override(dev, &pdev->driver_override, buf, count); in driver_override_store()
1306 struct device *dev = container_of(kobj, typeof(*dev), kobj); in platform_dev_attrs_visible() local
1309 dev_to_node(dev) == NUMA_NO_NODE) in platform_dev_attrs_visible()
1335 static int platform_match(struct device *dev, struct device_driver *drv) in platform_match() argument
1337 struct platform_device *pdev = to_platform_device(dev); in platform_match()
1345 if (of_driver_match_device(dev, drv)) in platform_match()
1349 if (acpi_driver_match_device(dev, drv)) in platform_match()
1360 static int platform_uevent(const struct device *dev, struct kobj_uevent_env *env) in platform_uevent() argument
1362 const struct platform_device *pdev = to_platform_device(dev); in platform_uevent()
1366 rc = of_device_uevent_modalias(dev, env); in platform_uevent()
1370 rc = acpi_device_uevent_modalias(dev, env); in platform_uevent()
1382 struct platform_device *dev = to_platform_device(_dev); in platform_probe() local
1404 ret = drv->probe(dev); in platform_probe()
1421 struct platform_device *dev = to_platform_device(_dev); in platform_remove() local
1424 drv->remove_new(dev); in platform_remove()
1426 int ret = drv->remove(dev); in platform_remove()
1436 struct platform_device *dev = to_platform_device(_dev); in platform_shutdown() local
1444 drv->shutdown(dev); in platform_shutdown()
1447 static int platform_dma_configure(struct device *dev) in platform_dma_configure() argument
1449 struct platform_driver *drv = to_platform_driver(dev->driver); in platform_dma_configure()
1453 if (dev->of_node) { in platform_dma_configure()
1454 ret = of_dma_configure(dev, dev->of_node, true); in platform_dma_configure()
1455 } else if (has_acpi_companion(dev)) { in platform_dma_configure()
1456 attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); in platform_dma_configure()
1457 ret = acpi_dma_configure(dev, attr); in platform_dma_configure()
1461 ret = iommu_device_use_default_domain(dev); in platform_dma_configure()
1463 arch_teardown_dma_ops(dev); in platform_dma_configure()
1469 static void platform_dma_cleanup(struct device *dev) in platform_dma_cleanup() argument
1471 struct platform_driver *drv = to_platform_driver(dev->driver); in platform_dma_cleanup()
1474 iommu_device_unuse_default_domain(dev); in platform_dma_cleanup()
1496 static inline int __platform_match(struct device *dev, const void *drv) in __platform_match() argument
1498 return platform_match(dev, (struct device_driver *)drv); in __platform_match()