Skip to content

Commit 6bac0d8

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: bus: add new manager callback to deal with peripheral enumeration
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>
1 parent 7ba1863 commit 6bac0d8

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

  • drivers/soundwire
  • include/linux/soundwire

drivers/soundwire/bus.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ static int sdw_assign_device_num(struct sdw_slave *slave)
769769
/* After xfer of msg, restore dev_num */
770770
slave->dev_num = slave->dev_num_sticky;
771771

772+
if (bus->ops && bus->ops->new_peripheral_assigned)
773+
bus->ops->new_peripheral_assigned(bus, dev_num);
774+
772775
return 0;
773776
}
774777

include/linux/soundwire/sdw.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ struct sdw_defer {
846846
* @post_bank_switch: Callback for post bank switch
847847
* @read_ping_status: Read status from PING frames, reported with two bits per Device.
848848
* Bits 31:24 are reserved.
849+
* @new_peripheral_assigned: Callback to handle enumeration of new peripheral.
849850
*/
850851
struct sdw_master_ops {
851852
int (*read_prop)(struct sdw_bus *bus);
@@ -860,7 +861,7 @@ struct sdw_master_ops {
860861
int (*pre_bank_switch)(struct sdw_bus *bus);
861862
int (*post_bank_switch)(struct sdw_bus *bus);
862863
u32 (*read_ping_status)(struct sdw_bus *bus);
863-
864+
void (*new_peripheral_assigned)(struct sdw_bus *bus, int dev_num);
864865
};
865866

866867
/**

0 commit comments

Comments
 (0)