Skip to content

Commit 3db0c5a

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: intel: add bus management callbacks in hw_ops
No functionality change, only add indirection for bus management helpers. Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Rander Wang <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent b6234bc commit 3db0c5a

File tree

3 files changed

+60
-9
lines changed

3 files changed

+60
-9
lines changed

drivers/soundwire/intel.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,12 @@ const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = {
14281428

14291429
.register_dai = intel_register_dai,
14301430

1431+
.check_clock_stop = intel_check_clock_stop,
1432+
.start_bus = intel_start_bus,
1433+
.start_bus_after_reset = intel_start_bus_after_reset,
1434+
.start_bus_after_clock_stop = intel_start_bus_after_clock_stop,
1435+
.stop_bus = intel_stop_bus,
1436+
14311437
.pre_bank_switch = intel_pre_bank_switch,
14321438
.post_bank_switch = intel_post_bank_switch,
14331439
};
@@ -1622,7 +1628,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)
16221628
sdw_intel_debugfs_init(sdw);
16231629

16241630
/* start bus */
1625-
ret = intel_start_bus(sdw);
1631+
ret = sdw_intel_start_bus(sdw);
16261632
if (ret) {
16271633
dev_err(dev, "bus start failed: %d\n", ret);
16281634
goto err_power_up;
@@ -1850,7 +1856,7 @@ static int __maybe_unused intel_suspend(struct device *dev)
18501856
return 0;
18511857
}
18521858

1853-
ret = intel_stop_bus(sdw, false);
1859+
ret = sdw_intel_stop_bus(sdw, false);
18541860
if (ret < 0) {
18551861
dev_err(dev, "%s: cannot stop bus: %d\n", __func__, ret);
18561862
return ret;
@@ -1876,14 +1882,14 @@ static int __maybe_unused intel_suspend_runtime(struct device *dev)
18761882
clock_stop_quirks = sdw->link_res->clock_stop_quirks;
18771883

18781884
if (clock_stop_quirks & SDW_INTEL_CLK_STOP_TEARDOWN) {
1879-
ret = intel_stop_bus(sdw, false);
1885+
ret = sdw_intel_stop_bus(sdw, false);
18801886
if (ret < 0) {
18811887
dev_err(dev, "%s: cannot stop bus during teardown: %d\n",
18821888
__func__, ret);
18831889
return ret;
18841890
}
18851891
} else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET || !clock_stop_quirks) {
1886-
ret = intel_stop_bus(sdw, true);
1892+
ret = sdw_intel_stop_bus(sdw, true);
18871893
if (ret < 0) {
18881894
dev_err(dev, "%s: cannot stop bus during clock_stop: %d\n",
18891895
__func__, ret);
@@ -1941,7 +1947,7 @@ static int __maybe_unused intel_resume(struct device *dev)
19411947
*/
19421948
sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);
19431949

1944-
ret = intel_start_bus(sdw);
1950+
ret = sdw_intel_start_bus(sdw);
19451951
if (ret < 0) {
19461952
dev_err(dev, "cannot start bus during resume\n");
19471953
intel_link_power_down(sdw);
@@ -1995,7 +2001,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
19952001
*/
19962002
sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);
19972003

1998-
ret = intel_start_bus(sdw);
2004+
ret = sdw_intel_start_bus(sdw);
19992005
if (ret < 0) {
20002006
dev_err(dev, "%s: cannot start bus after teardown: %d\n", __func__, ret);
20012007
intel_link_power_down(sdw);
@@ -2010,23 +2016,23 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
20102016
return ret;
20112017
}
20122018

2013-
ret = intel_start_bus_after_reset(sdw);
2019+
ret = sdw_intel_start_bus_after_reset(sdw);
20142020
if (ret < 0) {
20152021
dev_err(dev, "%s: cannot start bus after reset: %d\n", __func__, ret);
20162022
intel_link_power_down(sdw);
20172023
return ret;
20182024
}
20192025
} else if (!clock_stop_quirks) {
20202026

2021-
intel_check_clock_stop(sdw);
2027+
sdw_intel_check_clock_stop(sdw);
20222028

20232029
ret = intel_link_power_up(sdw);
20242030
if (ret) {
20252031
dev_err(dev, "%s: power_up failed: %d\n", __func__, ret);
20262032
return ret;
20272033
}
20282034

2029-
ret = intel_start_bus_after_clock_stop(sdw);
2035+
ret = sdw_intel_start_bus_after_clock_stop(sdw);
20302036
if (ret < 0) {
20312037
dev_err(dev, "%s: cannot start bus after clock stop: %d\n", __func__, ret);
20322038
intel_link_power_down(sdw);

drivers/soundwire/intel.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,38 @@ static inline int sdw_intel_register_dai(struct sdw_intel *sdw)
8484
return -ENOTSUPP;
8585
}
8686

87+
static inline void sdw_intel_check_clock_stop(struct sdw_intel *sdw)
88+
{
89+
if (SDW_INTEL_CHECK_OPS(sdw, check_clock_stop))
90+
SDW_INTEL_OPS(sdw, check_clock_stop)(sdw);
91+
}
92+
93+
static inline int sdw_intel_start_bus(struct sdw_intel *sdw)
94+
{
95+
if (SDW_INTEL_CHECK_OPS(sdw, start_bus))
96+
return SDW_INTEL_OPS(sdw, start_bus)(sdw);
97+
return -ENOTSUPP;
98+
}
99+
100+
static inline int sdw_intel_start_bus_after_reset(struct sdw_intel *sdw)
101+
{
102+
if (SDW_INTEL_CHECK_OPS(sdw, start_bus_after_reset))
103+
return SDW_INTEL_OPS(sdw, start_bus_after_reset)(sdw);
104+
return -ENOTSUPP;
105+
}
106+
107+
static inline int sdw_intel_start_bus_after_clock_stop(struct sdw_intel *sdw)
108+
{
109+
if (SDW_INTEL_CHECK_OPS(sdw, start_bus_after_clock_stop))
110+
return SDW_INTEL_OPS(sdw, start_bus_after_clock_stop)(sdw);
111+
return -ENOTSUPP;
112+
}
113+
114+
static inline int sdw_intel_stop_bus(struct sdw_intel *sdw, bool clock_stop)
115+
{
116+
if (SDW_INTEL_CHECK_OPS(sdw, stop_bus))
117+
return SDW_INTEL_OPS(sdw, stop_bus)(sdw, clock_stop);
118+
return -ENOTSUPP;
119+
}
120+
87121
#endif /* __SDW_INTEL_LOCAL_H */

include/linux/soundwire/sdw_intel.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ struct sdw_intel;
300300
* @debugfs_init: initialize all debugfs capabilities
301301
* @debugfs_exit: close and cleanup debugfs capabilities
302302
* @register_dai: read all PDI information and register DAIs
303+
* @check_clock_stop: throw error message if clock is not stopped.
304+
* @start_bus: normal start
305+
* @start_bus_after_reset: start after reset
306+
* @start_bus_after_clock_stop: start after mode0 clock stop
307+
* @stop_bus: stop all bus
303308
* @pre_bank_switch: helper for bus management
304309
* @post_bank_switch: helper for bus management
305310
*/
@@ -309,6 +314,12 @@ struct sdw_intel_hw_ops {
309314

310315
int (*register_dai)(struct sdw_intel *sdw);
311316

317+
void (*check_clock_stop)(struct sdw_intel *sdw);
318+
int (*start_bus)(struct sdw_intel *sdw);
319+
int (*start_bus_after_reset)(struct sdw_intel *sdw);
320+
int (*start_bus_after_clock_stop)(struct sdw_intel *sdw);
321+
int (*stop_bus)(struct sdw_intel *sdw, bool clock_stop);
322+
312323
int (*pre_bank_switch)(struct sdw_intel *sdw);
313324
int (*post_bank_switch)(struct sdw_intel *sdw);
314325
};

0 commit comments

Comments
 (0)