soundwire: intel: add sync_arm/sync_go to ops
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tue, 14 Mar 2023 01:54:00 +0000 (09:54 +0800)
committerVinod Koul <vkoul@kernel.org>
Wed, 15 Mar 2023 13:54:02 +0000 (19:24 +0530)
The bus start/stop sequences can be reused between platforms if we add
a couple of new callbacks. In following patches the code will be moved to
a shared file.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230314015410.487311-7-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/intel.c
drivers/soundwire/intel.h
include/linux/soundwire/sdw_intel.h

index 6fdb10117e5918f21d5c4016a4ccf37f747acefa..902934cbb27b73310e2a17d0ed84a5e73f861c1a 100644 (file)
@@ -686,7 +686,7 @@ static int intel_pre_bank_switch(struct sdw_intel *sdw)
        if (!bus->multi_link)
                return 0;
 
-       intel_shim_sync_arm(sdw);
+       sdw_intel_sync_arm(sdw);
 
        return 0;
 }
@@ -720,7 +720,7 @@ static int intel_post_bank_switch(struct sdw_intel *sdw)
                goto unlock;
        }
 
-       ret = intel_shim_sync_go_unlocked(sdw);
+       ret = sdw_intel_sync_go_unlocked(sdw);
 unlock:
        mutex_unlock(sdw->link_res->shim_lock);
 
@@ -1140,7 +1140,7 @@ static int intel_start_bus(struct sdw_intel *sdw)
         * gsync is enabled
         */
        if (bus->multi_link)
-               intel_shim_sync_arm(sdw);
+               sdw_intel_sync_arm(sdw);
 
        ret = sdw_cdns_init(cdns);
        if (ret < 0) {
@@ -1155,7 +1155,7 @@ static int intel_start_bus(struct sdw_intel *sdw)
        }
 
        if (bus->multi_link) {
-               ret = intel_shim_sync_go(sdw);
+               ret = sdw_intel_sync_go(sdw);
                if (ret < 0) {
                        dev_err(dev, "%s: sync go failed: %d\n", __func__, ret);
                        goto err_interrupt;
@@ -1210,7 +1210,7 @@ static int intel_start_bus_after_reset(struct sdw_intel *sdw)
                 * timeouts when gsync is enabled
                 */
                if (bus->multi_link)
-                       intel_shim_sync_arm(sdw);
+                       sdw_intel_sync_arm(sdw);
 
                /*
                 * Re-initialize the IP since it was powered-off
@@ -1239,7 +1239,7 @@ static int intel_start_bus_after_reset(struct sdw_intel *sdw)
                }
 
                if (bus->multi_link) {
-                       ret = intel_shim_sync_go(sdw);
+                       ret = sdw_intel_sync_go(sdw);
                        if (ret < 0) {
                                dev_err(sdw->cdns.dev, "sync go failed during resume\n");
                                goto err_interrupt;
@@ -1342,6 +1342,10 @@ const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = {
 
        .pre_bank_switch = intel_pre_bank_switch,
        .post_bank_switch = intel_post_bank_switch,
+
+       .sync_arm = intel_shim_sync_arm,
+       .sync_go_unlocked = intel_shim_sync_go_unlocked,
+       .sync_go = intel_shim_sync_go,
 };
 EXPORT_SYMBOL_NS(sdw_intel_cnl_hw_ops, SOUNDWIRE_INTEL);
 
index 089c41babfc1e51b6fcdaf3ed13f27607a6304ef..28b21a92e28b8a5bee4ae6841a7603d55df05bee 100644 (file)
@@ -167,4 +167,24 @@ static inline void sdw_intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
                SDW_INTEL_OPS(sdw, shim_wake)(sdw, wake_enable);
 }
 
+static inline void sdw_intel_sync_arm(struct sdw_intel *sdw)
+{
+       if (SDW_INTEL_CHECK_OPS(sdw, sync_arm))
+               SDW_INTEL_OPS(sdw, sync_arm)(sdw);
+}
+
+static inline int sdw_intel_sync_go_unlocked(struct sdw_intel *sdw)
+{
+       if (SDW_INTEL_CHECK_OPS(sdw, sync_go_unlocked))
+               return SDW_INTEL_OPS(sdw, sync_go_unlocked)(sdw);
+       return -ENOTSUPP;
+}
+
+static inline int sdw_intel_sync_go(struct sdw_intel *sdw)
+{
+       if (SDW_INTEL_CHECK_OPS(sdw, sync_go))
+               return SDW_INTEL_OPS(sdw, sync_go)(sdw);
+       return -ENOTSUPP;
+}
+
 #endif /* __SDW_INTEL_LOCAL_H */
index 91f0dc564fe59f134a47de1ac826f93cc90013a8..06fa30929ebd940b1a2bfd29d910336dc799c7be 100644 (file)
@@ -309,6 +309,10 @@ struct sdw_intel;
  * @shim_wake: enable/disable in-band wake management
  * @pre_bank_switch: helper for bus management
  * @post_bank_switch: helper for bus management
+ * @sync_arm: helper for multi-link synchronization
+ * @sync_go_unlocked: helper for multi-link synchronization -
+ * shim_lock is assumed to be locked at higher level
+ * @sync_go: helper for multi-link synchronization
  */
 struct sdw_intel_hw_ops {
        void (*debugfs_init)(struct sdw_intel *sdw);
@@ -330,6 +334,10 @@ struct sdw_intel_hw_ops {
 
        int (*pre_bank_switch)(struct sdw_intel *sdw);
        int (*post_bank_switch)(struct sdw_intel *sdw);
+
+       void (*sync_arm)(struct sdw_intel *sdw);
+       int (*sync_go_unlocked)(struct sdw_intel *sdw);
+       int (*sync_go)(struct sdw_intel *sdw);
 };
 
 extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops;