soundwire: intel_ace2x: add new_peripheral_assigned callback
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 15 May 2023 07:10:36 +0000 (15:10 +0800)
committerVinod Koul <vkoul@kernel.org>
Sat, 27 May 2023 10:36:46 +0000 (16:06 +0530)
Add the abstraction needed to only program the LSDIID registers for
the HDaudio extended links. It's perfectly fine to program this
register multiple times in case devices lose sync and reattach.

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-21-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/intel_ace2x.c
drivers/soundwire/intel_auxdevice.c
include/linux/soundwire/sdw_intel.h

index a12fee8..65deb43 100644 (file)
@@ -350,6 +350,16 @@ static int intel_register_dai(struct sdw_intel *sdw)
                                               dais, num_dai);
 }
 
+static void intel_program_sdi(struct sdw_intel *sdw, int dev_num)
+{
+       int ret;
+
+       ret = hdac_bus_eml_sdw_set_lsdiid(sdw->link_res->hbus, sdw->instance, dev_num);
+       if (ret < 0)
+               dev_err(sdw->cdns.dev, "%s: could not set lsdiid for link %d %d\n",
+                       __func__, sdw->instance, dev_num);
+}
+
 const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
        .debugfs_init = intel_ace2x_debugfs_init,
        .debugfs_exit = intel_ace2x_debugfs_exit,
@@ -372,6 +382,8 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = {
        .sync_go_unlocked = intel_sync_go_unlocked,
        .sync_go = intel_sync_go,
        .sync_check_cmdsync_unlocked = intel_check_cmdsync_unlocked,
+
+       .program_sdi = intel_program_sdi,
 };
 EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL);
 
index fcdf4f2..0daa6ca 100644 (file)
@@ -60,6 +60,21 @@ static int generic_post_bank_switch(struct sdw_bus *bus)
        return sdw->link_res->hw_ops->post_bank_switch(sdw);
 }
 
+static void generic_new_peripheral_assigned(struct sdw_bus *bus, int dev_num)
+{
+       struct sdw_cdns *cdns = bus_to_cdns(bus);
+       struct sdw_intel *sdw = cdns_to_intel(cdns);
+
+       /* paranoia check, this should never happen */
+       if (dev_num < INTEL_DEV_NUM_IDA_MIN || dev_num > SDW_MAX_DEVICES)  {
+               dev_err(bus->dev, "%s: invalid dev_num %d\n", __func__, dev_num);
+               return;
+       }
+
+       if (sdw->link_res->hw_ops->program_sdi)
+               sdw->link_res->hw_ops->program_sdi(sdw, dev_num);
+}
+
 static int sdw_master_read_intel_prop(struct sdw_bus *bus)
 {
        struct sdw_master_prop *prop = &bus->prop;
@@ -117,6 +132,7 @@ static struct sdw_master_ops sdw_intel_ops = {
        .pre_bank_switch = generic_pre_bank_switch,
        .post_bank_switch = generic_post_bank_switch,
        .read_ping_status = cdns_read_ping_status,
+       .new_peripheral_assigned = generic_new_peripheral_assigned,
 };
 
 /*
index bafc6f2..1a8f320 100644 (file)
@@ -399,6 +399,7 @@ struct sdw_intel;
  * @sync_go: helper for multi-link synchronization
  * @sync_check_cmdsync_unlocked: helper for multi-link synchronization
  * and bank switch - shim_lock is assumed to be locked at higher level
+ * @program_sdi: helper for codec command/control based on dev_num
  */
 struct sdw_intel_hw_ops {
        void (*debugfs_init)(struct sdw_intel *sdw);
@@ -425,6 +426,8 @@ struct sdw_intel_hw_ops {
        int (*sync_go_unlocked)(struct sdw_intel *sdw);
        int (*sync_go)(struct sdw_intel *sdw);
        bool (*sync_check_cmdsync_unlocked)(struct sdw_intel *sdw);
+
+       void (*program_sdi)(struct sdw_intel *sdw, int dev_num);
 };
 
 extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops;