aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serdev/core.c')
-rw-r--r--drivers/tty/serdev/core.c83
1 files changed, 69 insertions, 14 deletions
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index c5f0d936b003..fe97d6085f6d 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -32,7 +32,18 @@ static ssize_t modalias_show(struct device *dev,
32 if (len != -ENODEV) 32 if (len != -ENODEV)
33 return len; 33 return len;
34 34
35 return of_device_modalias(dev, buf, PAGE_SIZE); 35 len = of_device_modalias(dev, buf, PAGE_SIZE);
36 if (len != -ENODEV)
37 return len;
38
39 if (dev->parent->parent->bus == &platform_bus_type) {
40 struct platform_device *pdev =
41 to_platform_device(dev->parent->parent);
42
43 len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
44 }
45
46 return len;
36} 47}
37static DEVICE_ATTR_RO(modalias); 48static DEVICE_ATTR_RO(modalias);
38 49
@@ -46,13 +57,18 @@ static int serdev_device_uevent(struct device *dev, struct kobj_uevent_env *env)
46{ 57{
47 int rc; 58 int rc;
48 59
49 /* TODO: platform modalias */
50
51 rc = acpi_device_uevent_modalias(dev, env); 60 rc = acpi_device_uevent_modalias(dev, env);
52 if (rc != -ENODEV) 61 if (rc != -ENODEV)
53 return rc; 62 return rc;
54 63
55 return of_device_uevent_modalias(dev, env); 64 rc = of_device_uevent_modalias(dev, env);
65 if (rc != -ENODEV)
66 return rc;
67
68 if (dev->parent->parent->bus == &platform_bus_type)
69 rc = dev->parent->parent->bus->uevent(dev->parent->parent, env);
70
71 return rc;
56} 72}
57 73
58static void serdev_device_release(struct device *dev) 74static void serdev_device_release(struct device *dev)
@@ -88,11 +104,17 @@ static int serdev_device_match(struct device *dev, struct device_driver *drv)
88 if (!is_serdev_device(dev)) 104 if (!is_serdev_device(dev))
89 return 0; 105 return 0;
90 106
91 /* TODO: platform matching */
92 if (acpi_driver_match_device(dev, drv)) 107 if (acpi_driver_match_device(dev, drv))
93 return 1; 108 return 1;
94 109
95 return of_driver_match_device(dev, drv); 110 if (of_driver_match_device(dev, drv))
111 return 1;
112
113 if (dev->parent->parent->bus == &platform_bus_type &&
114 dev->parent->parent->bus->match(dev->parent->parent, drv))
115 return 1;
116
117 return 0;
96} 118}
97 119
98/** 120/**
@@ -729,16 +751,45 @@ static inline int acpi_serdev_register_devices(struct serdev_controller *ctrl)
729} 751}
730#endif /* CONFIG_ACPI */ 752#endif /* CONFIG_ACPI */
731 753
754static int platform_serdev_register_devices(struct serdev_controller *ctrl)
755{
756 struct serdev_device *serdev;
757 int err;
758
759 if (ctrl->dev.parent->bus != &platform_bus_type)
760 return -ENODEV;
761
762 serdev = serdev_device_alloc(ctrl);
763 if (!serdev) {
764 dev_err(&ctrl->dev, "failed to allocate serdev device for %s\n",
765 dev_name(ctrl->dev.parent));
766 return -ENOMEM;
767 }
768
769 pm_runtime_no_callbacks(&serdev->dev);
770
771 err = serdev_device_add(serdev);
772 if (err) {
773 dev_err(&serdev->dev,
774 "failure adding device. status %d\n", err);
775 serdev_device_put(serdev);
776 }
777
778 return err;
779}
780
781
732/** 782/**
733 * serdev_controller_add() - Add an serdev controller 783 * serdev_controller_add_platform() - Add an serdev controller
734 * @ctrl: controller to be registered. 784 * @ctrl: controller to be registered.
785 * @platform: whether to permit fallthrough to platform device probe
735 * 786 *
736 * Register a controller previously allocated via serdev_controller_alloc() with 787 * Register a controller previously allocated via serdev_controller_alloc() with
737 * the serdev core. 788 * the serdev core. Optionally permit probing via a platform device fallback.
738 */ 789 */
739int serdev_controller_add(struct serdev_controller *ctrl) 790int serdev_controller_add_platform(struct serdev_controller *ctrl, bool platform)
740{ 791{
741 int ret_of, ret_acpi, ret; 792 int ret, ret_of, ret_acpi, ret_platform = -ENODEV;
742 793
743 /* Can't register until after driver model init */ 794 /* Can't register until after driver model init */
744 if (WARN_ON(!is_registered)) 795 if (WARN_ON(!is_registered))
@@ -752,9 +803,13 @@ int serdev_controller_add(struct serdev_controller *ctrl)
752 803
753 ret_of = of_serdev_register_devices(ctrl); 804 ret_of = of_serdev_register_devices(ctrl);
754 ret_acpi = acpi_serdev_register_devices(ctrl); 805 ret_acpi = acpi_serdev_register_devices(ctrl);
755 if (ret_of && ret_acpi) { 806 if (platform)
756 dev_dbg(&ctrl->dev, "no devices registered: of:%pe acpi:%pe\n", 807 ret_platform = platform_serdev_register_devices(ctrl);
757 ERR_PTR(ret_of), ERR_PTR(ret_acpi)); 808 if (ret_of && ret_acpi && ret_platform) {
809 dev_dbg(&ctrl->dev,
810 "no devices registered: of:%pe acpi:%pe platform:%pe\n",
811 ERR_PTR(ret_of), ERR_PTR(ret_acpi),
812 ERR_PTR(ret_platform));
758 ret = -ENODEV; 813 ret = -ENODEV;
759 goto err_rpm_disable; 814 goto err_rpm_disable;
760 } 815 }
@@ -768,7 +823,7 @@ err_rpm_disable:
768 device_del(&ctrl->dev); 823 device_del(&ctrl->dev);
769 return ret; 824 return ret;
770}; 825};
771EXPORT_SYMBOL_GPL(serdev_controller_add); 826EXPORT_SYMBOL_GPL(serdev_controller_add_platform);
772 827
773/* Remove a device associated with a controller */ 828/* Remove a device associated with a controller */
774static int serdev_remove_device(struct device *dev, void *data) 829static int serdev_remove_device(struct device *dev, void *data)