soundwire: bus: introduce controller_id
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tue, 17 Oct 2023 16:09:32 +0000 (11:09 -0500)
committerVinod Koul <vkoul@kernel.org>
Fri, 24 Nov 2023 06:54:37 +0000 (12:24 +0530)
The existing SoundWire support misses a clear Controller/Manager
hiearchical definition to deal with all variants across SOC vendors.

a) Intel platforms have one controller with 4 or more Managers.
b) AMD platforms have two controllers with one Manager each, but due
to BIOS issues use two different link_id values within the scope of a
single controller.
c) QCOM platforms have one or more controller with one Manager each.

This patch adds a 'controller_id' which can be set by higher
levels. If assigned to -1, the controller_id will be set to the
system-unique IDA-assigned bus->id.

The main change is that the bus->id is no longer used for any device
name, which makes the definition completely predictable and not
dependent on any enumeration order. The bus->id is only used to insert
the Managers in the stream rt context.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/stable/20231017160933.12624-2-pierre-louis.bossart%40linux.intel.com
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231017160933.12624-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/amd_manager.c
drivers/soundwire/bus.c
drivers/soundwire/debugfs.c
drivers/soundwire/intel_auxdevice.c
drivers/soundwire/master.c
drivers/soundwire/qcom.c
include/linux/soundwire/sdw.h

index 3a99f6dcdfafa24b9115ea7358837a57aa95a423..a3b1f4e6f0f90bdfdd5310db45b29f4e1c384fe8 100644 (file)
@@ -927,6 +927,14 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
        amd_manager->bus.clk_stop_timeout = 200;
        amd_manager->bus.link_id = amd_manager->instance;
 
+       /*
+        * Due to BIOS compatibility, the two links are exposed within
+        * the scope of a single controller. If this changes, the
+        * controller_id will have to be updated with drv_data
+        * information.
+        */
+       amd_manager->bus.controller_id = 0;
+
        switch (amd_manager->instance) {
        case ACP_SDW0:
                amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;
index 41b0d9adf68ef349053b0fe8317bc9817eba4f31..f3fec15c311229f7a1da48bfb3de416ed52a95d6 100644 (file)
@@ -22,6 +22,10 @@ static int sdw_get_id(struct sdw_bus *bus)
                return rc;
 
        bus->id = rc;
+
+       if (bus->controller_id == -1)
+               bus->controller_id = rc;
+
        return 0;
 }
 
index d1553cb77187471b40e4601f3cd5399e241ad076..67abd7e52f092a988a2e3f20e253dd76c53b178f 100644 (file)
@@ -20,7 +20,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus)
                return;
 
        /* create the debugfs master-N */
-       snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id);
+       snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id);
        bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root);
 }
 
index 7f15e3549e539d053a82b63b8346a362c6d0145c..93698532deac4098706099dfceaf85055f563b09 100644 (file)
@@ -234,6 +234,9 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
        cdns->instance = sdw->instance;
        cdns->msg_count = 0;
 
+       /* single controller for all SoundWire links */
+       bus->controller_id = 0;
+
        bus->link_id = auxdev->id;
        bus->clk_stop_timeout = 1;
 
index 9b05c9e25ebe48a7d135ff45ad4b3af0fb1cb2aa..51abedbbaa6630e53ab301b85d6dcefe2f8ce9ac 100644 (file)
@@ -145,7 +145,7 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
        md->dev.fwnode = fwnode;
        md->dev.dma_mask = parent->dma_mask;
 
-       dev_set_name(&md->dev, "sdw-master-%d", bus->id);
+       dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id);
 
        ret = device_register(&md->dev);
        if (ret) {
index e9a52c1bd3594ba3543d192b0d62f91bf43382ff..7f8549aab42f329b21dc11dbd7524306a521543a 100644 (file)
@@ -1620,6 +1620,9 @@ static int qcom_swrm_probe(struct platform_device *pdev)
                }
        }
 
+       /* FIXME: is there a DT-defined value to use ? */
+       ctrl->bus.controller_id = -1;
+
        ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
        if (ret) {
                dev_err(dev, "Failed to register Soundwire controller (%d)\n",
index 904004d8b562296fc2173e2b5ee371d5c85f27f7..66f814b63a435f65bcdf8743d7adbfde39ca7ad7 100644 (file)
@@ -886,7 +886,8 @@ struct sdw_master_ops {
  * struct sdw_bus - SoundWire bus
  * @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
  * @md: Master device
- * @link_id: Link id number, can be 0 to N, unique for each Master
+ * @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
+ * @link_id: Link id number, can be 0 to N, unique for each Controller
  * @id: bus system-wide unique id
  * @slaves: list of Slaves on this bus
  * @assigned: Bitmap for Slave device numbers.
@@ -918,6 +919,7 @@ struct sdw_master_ops {
 struct sdw_bus {
        struct device *dev;
        struct sdw_master_device *md;
+       int controller_id;
        unsigned int link_id;
        int id;
        struct list_head slaves;