Skip to content

Commit fb43d62

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: intel: move bank switch routine to common intel_bus_common.c
No functionality change, just moving the routines to a common file so that they can be used for new hardware. 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-11-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 1e76de2 commit fb43d62

3 files changed

Lines changed: 53 additions & 49 deletions

File tree

drivers/soundwire/intel.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -682,55 +682,6 @@ static int intel_free_stream(struct sdw_intel *sdw,
682682
return 0;
683683
}
684684

685-
/*
686-
* bank switch routines
687-
*/
688-
689-
static int intel_pre_bank_switch(struct sdw_intel *sdw)
690-
{
691-
struct sdw_cdns *cdns = &sdw->cdns;
692-
struct sdw_bus *bus = &cdns->bus;
693-
694-
/* Write to register only for multi-link */
695-
if (!bus->multi_link)
696-
return 0;
697-
698-
sdw_intel_sync_arm(sdw);
699-
700-
return 0;
701-
}
702-
703-
static int intel_post_bank_switch(struct sdw_intel *sdw)
704-
{
705-
struct sdw_cdns *cdns = &sdw->cdns;
706-
struct sdw_bus *bus = &cdns->bus;
707-
int ret = 0;
708-
709-
/* Write to register only for multi-link */
710-
if (!bus->multi_link)
711-
return 0;
712-
713-
mutex_lock(sdw->link_res->shim_lock);
714-
715-
/*
716-
* post_bank_switch() ops is called from the bus in loop for
717-
* all the Masters in the steam with the expectation that
718-
* we trigger the bankswitch for the only first Master in the list
719-
* and do nothing for the other Masters
720-
*
721-
* So, set the SYNCGO bit only if CMDSYNC bit is set for any Master.
722-
*/
723-
if (sdw_intel_sync_check_cmdsync_unlocked(sdw))
724-
ret = sdw_intel_sync_go_unlocked(sdw);
725-
726-
mutex_unlock(sdw->link_res->shim_lock);
727-
728-
if (ret < 0)
729-
dev_err(sdw->cdns.dev, "Post bank switch failed: %d\n", ret);
730-
731-
return ret;
732-
}
733-
734685
/*
735686
* DAI routines
736687
*/

drivers/soundwire/intel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,8 @@ void intel_check_clock_stop(struct sdw_intel *sdw);
201201
int intel_start_bus_after_clock_stop(struct sdw_intel *sdw);
202202
int intel_stop_bus(struct sdw_intel *sdw, bool clock_stop);
203203

204+
/* common bank switch routines */
205+
int intel_pre_bank_switch(struct sdw_intel *sdw);
206+
int intel_post_bank_switch(struct sdw_intel *sdw);
207+
204208
#endif /* __SDW_INTEL_LOCAL_H */

drivers/soundwire/intel_bus_common.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,52 @@ int intel_stop_bus(struct sdw_intel *sdw, bool clock_stop)
208208

209209
return 0;
210210
}
211+
212+
/*
213+
* bank switch routines
214+
*/
215+
216+
int intel_pre_bank_switch(struct sdw_intel *sdw)
217+
{
218+
struct sdw_cdns *cdns = &sdw->cdns;
219+
struct sdw_bus *bus = &cdns->bus;
220+
221+
/* Write to register only for multi-link */
222+
if (!bus->multi_link)
223+
return 0;
224+
225+
sdw_intel_sync_arm(sdw);
226+
227+
return 0;
228+
}
229+
230+
int intel_post_bank_switch(struct sdw_intel *sdw)
231+
{
232+
struct sdw_cdns *cdns = &sdw->cdns;
233+
struct sdw_bus *bus = &cdns->bus;
234+
int ret = 0;
235+
236+
/* Write to register only for multi-link */
237+
if (!bus->multi_link)
238+
return 0;
239+
240+
mutex_lock(sdw->link_res->shim_lock);
241+
242+
/*
243+
* post_bank_switch() ops is called from the bus in loop for
244+
* all the Masters in the steam with the expectation that
245+
* we trigger the bankswitch for the only first Master in the list
246+
* and do nothing for the other Masters
247+
*
248+
* So, set the SYNCGO bit only if CMDSYNC bit is set for any Master.
249+
*/
250+
if (sdw_intel_sync_check_cmdsync_unlocked(sdw))
251+
ret = sdw_intel_sync_go_unlocked(sdw);
252+
253+
mutex_unlock(sdw->link_res->shim_lock);
254+
255+
if (ret < 0)
256+
dev_err(sdw->cdns.dev, "Post bank switch failed: %d\n", ret);
257+
258+
return ret;
259+
}

0 commit comments

Comments
 (0)