soundwire: bus: add enumerated Slave device to device list
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Thu, 24 Sep 2020 19:44:29 +0000 (14:44 -0500)
committerVinod Koul <vkoul@kernel.org>
Mon, 28 Sep 2020 05:47:40 +0000 (11:17 +0530)
Currently Slave devices are only added on startup, either from Device
Tree or ACPI entries. However Slave devices that are physically
present on the bus, but not described in platform firmware, will never
be added to the device list. The user/integrator can only know the
list of devices by looking a dynamic debug logs.

This patch suggests adding a Slave device even if there is no matching
DT or ACPI entry, so that we can see this in sysfs entry.

Initial code from Srinivas. Comments, fixes for ACPI probe and edits
of commit message by Pierre.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Co-developed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200924194430.121058-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/bus.c
drivers/soundwire/bus.h
drivers/soundwire/bus_type.c
drivers/soundwire/slave.c

index e3fe53f..f4c7887 100644 (file)
@@ -747,6 +747,15 @@ static int sdw_program_device_num(struct sdw_bus *bus)
 
                if (!found) {
                        /* TODO: Park this device in Group 13 */
+
+                       /*
+                        * add Slave device even if there is no platform
+                        * firmware description. There will be no driver probe
+                        * but the user/integration will be able to see the
+                        * device, enumeration status and device number in sysfs
+                        */
+                       sdw_slave_add(bus, &id, NULL);
+
                        dev_err(bus->dev, "Slave Entry not found\n");
                }
 
index e070399..2e049d3 100644 (file)
@@ -19,6 +19,8 @@ static inline int sdw_acpi_find_slaves(struct sdw_bus *bus)
 int sdw_of_find_slaves(struct sdw_bus *bus);
 void sdw_extract_slave_id(struct sdw_bus *bus,
                          u64 addr, struct sdw_slave_id *id);
+int sdw_slave_add(struct sdw_bus *bus, struct sdw_slave_id *id,
+                 struct fwnode_handle *fwnode);
 int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
                          struct fwnode_handle *fwnode);
 int sdw_master_device_del(struct sdw_bus *bus);
index 6fba558..575b9ba 100644 (file)
@@ -84,6 +84,15 @@ static int sdw_drv_probe(struct device *dev)
        const struct sdw_device_id *id;
        int ret;
 
+       /*
+        * fw description is mandatory to bind
+        */
+       if (!dev->fwnode)
+               return -ENODEV;
+
+       if (!IS_ENABLED(CONFIG_ACPI) && !dev->of_node)
+               return -ENODEV;
+
        id = sdw_get_device_id(slave, drv);
        if (!id)
                return -ENODEV;
index 4a250d3..19b0123 100644 (file)
@@ -20,8 +20,8 @@ struct device_type sdw_slave_type = {
        .uevent =       sdw_slave_uevent,
 };
 
-static int sdw_slave_add(struct sdw_bus *bus,
-                        struct sdw_slave_id *id, struct fwnode_handle *fwnode)
+int sdw_slave_add(struct sdw_bus *bus,
+                 struct sdw_slave_id *id, struct fwnode_handle *fwnode)
 {
        struct sdw_slave *slave;
        int ret;