]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
soundwire: bus: add new manager callback to deal with peripheral enumeration
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 15 May 2023 07:10:35 +0000 (15:10 +0800)
committerVinod Koul <vkoul@kernel.org>
Sat, 27 May 2023 10:36:46 +0000 (16:06 +0530)
When a peripheral reports as ATTACHED, the manager may need to follow
a programming sequence, e.g. to assign DMA resources and/or assign a
command queue for that peripheral.

This patch adds an optional callback, which will be invoked every time
the peripheral attaches. This might be overkill in some scenarios, and
one could argue that this should be invoked only on the first
attachment. The bus does not however track this first attachment with
any existing state-mirroring variable, and using dev_num_sticky would
not work across suspend-resume cycles.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230515071042.2038-20-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/bus.c
include/linux/soundwire/sdw.h

index 338f4f0b5d0cc4355fcf96bca967f1f67049ffa9..b44f8d0affa67074e925406d4f5ccbb7786c39a0 100644 (file)
@@ -769,6 +769,9 @@ static int sdw_assign_device_num(struct sdw_slave *slave)
        /* After xfer of msg, restore dev_num */
        slave->dev_num = slave->dev_num_sticky;
 
+       if (bus->ops && bus->ops->new_peripheral_assigned)
+               bus->ops->new_peripheral_assigned(bus, dev_num);
+
        return 0;
 }
 
index ef645de13ae93c1ae4ea61e479846dce80809158..c076a3f879b3a23bd3dd3f057f4f683603b25315 100644 (file)
@@ -846,6 +846,7 @@ struct sdw_defer {
  * @post_bank_switch: Callback for post bank switch
  * @read_ping_status: Read status from PING frames, reported with two bits per Device.
  * Bits 31:24 are reserved.
+ * @new_peripheral_assigned: Callback to handle enumeration of new peripheral.
  */
 struct sdw_master_ops {
        int (*read_prop)(struct sdw_bus *bus);
@@ -860,7 +861,7 @@ struct sdw_master_ops {
        int (*pre_bank_switch)(struct sdw_bus *bus);
        int (*post_bank_switch)(struct sdw_bus *bus);
        u32 (*read_ping_status)(struct sdw_bus *bus);
-
+       void (*new_peripheral_assigned)(struct sdw_bus *bus, int dev_num);
 };
 
 /**