Skip to content

Commit b3ad31f

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: intel: start using hw_ops
Before introducing new hardware with completely different register spaces and programming sequences, we need to abstract some of the existing routines in hw_ops that will be platform-specific. For now we only use the 'cnl' ops - after the first Intel platform with SoundWire capabilities. Rather than one big intrusive patch, hw_ops are introduced in this patch so show the dependencies between drivers. Follow-up patches will introduce callbacks for debugfs, power and bus management. 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 ca1c131 commit b3ad31f

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

drivers/soundwire/intel.c

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,10 @@ static int intel_free_stream(struct sdw_intel *sdw,
745745
* bank switch routines
746746
*/
747747

748-
static int intel_pre_bank_switch(struct sdw_bus *bus)
748+
static int intel_pre_bank_switch(struct sdw_intel *sdw)
749749
{
750-
struct sdw_cdns *cdns = bus_to_cdns(bus);
751-
struct sdw_intel *sdw = cdns_to_intel(cdns);
750+
struct sdw_cdns *cdns = &sdw->cdns;
751+
struct sdw_bus *bus = &cdns->bus;
752752

753753
/* Write to register only for multi-link */
754754
if (!bus->multi_link)
@@ -759,10 +759,10 @@ static int intel_pre_bank_switch(struct sdw_bus *bus)
759759
return 0;
760760
}
761761

762-
static int intel_post_bank_switch(struct sdw_bus *bus)
762+
static int intel_post_bank_switch(struct sdw_intel *sdw)
763763
{
764-
struct sdw_cdns *cdns = bus_to_cdns(bus);
765-
struct sdw_intel *sdw = cdns_to_intel(cdns);
764+
struct sdw_cdns *cdns = &sdw->cdns;
765+
struct sdw_bus *bus = &cdns->bus;
766766
void __iomem *shim = sdw->link_res->shim;
767767
int sync_reg, ret;
768768

@@ -1422,6 +1422,28 @@ static int intel_stop_bus(struct sdw_intel *sdw, bool clock_stop)
14221422
return 0;
14231423
}
14241424

1425+
const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = {
1426+
.pre_bank_switch = intel_pre_bank_switch,
1427+
.post_bank_switch = intel_post_bank_switch,
1428+
};
1429+
EXPORT_SYMBOL_NS(sdw_intel_cnl_hw_ops, SOUNDWIRE_INTEL);
1430+
1431+
static int generic_pre_bank_switch(struct sdw_bus *bus)
1432+
{
1433+
struct sdw_cdns *cdns = bus_to_cdns(bus);
1434+
struct sdw_intel *sdw = cdns_to_intel(cdns);
1435+
1436+
return sdw->link_res->hw_ops->pre_bank_switch(sdw);
1437+
}
1438+
1439+
static int generic_post_bank_switch(struct sdw_bus *bus)
1440+
{
1441+
struct sdw_cdns *cdns = bus_to_cdns(bus);
1442+
struct sdw_intel *sdw = cdns_to_intel(cdns);
1443+
1444+
return sdw->link_res->hw_ops->post_bank_switch(sdw);
1445+
}
1446+
14251447
static int sdw_master_read_intel_prop(struct sdw_bus *bus)
14261448
{
14271449
struct sdw_master_prop *prop = &bus->prop;
@@ -1477,8 +1499,8 @@ static struct sdw_master_ops sdw_intel_ops = {
14771499
.xfer_msg_defer = cdns_xfer_msg_defer,
14781500
.reset_page_addr = cdns_reset_page_addr,
14791501
.set_bus_conf = cdns_bus_conf,
1480-
.pre_bank_switch = intel_pre_bank_switch,
1481-
.post_bank_switch = intel_post_bank_switch,
1502+
.pre_bank_switch = generic_pre_bank_switch,
1503+
.post_bank_switch = generic_post_bank_switch,
14821504
.read_ping_status = cdns_read_ping_status,
14831505
};
14841506

drivers/soundwire/intel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/**
88
* struct sdw_intel_link_res - Soundwire Intel link resource structure,
99
* typically populated by the controller driver.
10+
* @hw_ops: platform-specific ops
1011
* @mmio_base: mmio base of SoundWire registers
1112
* @registers: Link IO registers base
1213
* @shim: Audio shim pointer
@@ -22,6 +23,8 @@
2223
* @list: used to walk-through all masters exposed by the same controller
2324
*/
2425
struct sdw_intel_link_res {
26+
const struct sdw_intel_hw_ops *hw_ops;
27+
2528
void __iomem *mmio_base; /* not strictly needed, useful for debug */
2629
void __iomem *registers;
2730
void __iomem *shim;

drivers/soundwire/intel_init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
6060

6161
/* Add link information used in the driver probe */
6262
link = &ldev->link_res;
63+
link->hw_ops = res->hw_ops;
6364
link->mmio_base = res->mmio_base;
6465
link->registers = res->mmio_base + SDW_LINK_BASE
6566
+ (SDW_LINK_SIZE * link_id);

include/linux/soundwire/sdw_intel.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ struct sdw_intel_ctx {
233233
* struct sdw_intel_res - Soundwire Intel global resource structure,
234234
* typically populated by the DSP driver
235235
*
236+
* @hw_ops: abstraction for platform ops
236237
* @count: link count
237238
* @mmio_base: mmio base of SoundWire registers
238239
* @irq: interrupt number
@@ -249,6 +250,7 @@ struct sdw_intel_ctx {
249250
* @alh_base: sdw alh base.
250251
*/
251252
struct sdw_intel_res {
253+
const struct sdw_intel_hw_ops *hw_ops;
252254
int count;
253255
void __iomem *mmio_base;
254256
int irq;
@@ -292,4 +294,17 @@ irqreturn_t sdw_intel_thread(int irq, void *dev_id);
292294

293295
#define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1)
294296

297+
struct sdw_intel;
298+
299+
/* struct intel_sdw_hw_ops - SoundWire ops for Intel platforms.
300+
* @pre_bank_switch: helper for bus management
301+
* @post_bank_switch: helper for bus management
302+
*/
303+
struct sdw_intel_hw_ops {
304+
int (*pre_bank_switch)(struct sdw_intel *sdw);
305+
int (*post_bank_switch)(struct sdw_intel *sdw);
306+
};
307+
308+
extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops;
309+
295310
#endif

sound/soc/sof/intel/hda.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)
188188

189189
memset(&res, 0, sizeof(res));
190190

191+
res.hw_ops = &sdw_intel_cnl_hw_ops;
191192
res.mmio_base = sdev->bar[HDA_DSP_BAR];
192193
res.shim_base = hdev->desc->sdw_shim_base;
193194
res.alh_base = hdev->desc->sdw_alh_base;
@@ -1694,3 +1695,4 @@ MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC_I915);
16941695
MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
16951696
MODULE_IMPORT_NS(SND_INTEL_SOUNDWIRE_ACPI);
16961697
MODULE_IMPORT_NS(SOUNDWIRE_INTEL_INIT);
1698+
MODULE_IMPORT_NS(SOUNDWIRE_INTEL);

0 commit comments

Comments
 (0)