soundwire: intel: introduce hw_ops and move auxdevice handling to dedicated file
Subsystems (4)
Bard Liao
maintainercover soundwire: intel: introduce hw_ops and move auxdevice handling to dedicated file
This series adds yet another set of cleanups
a) all the helpers are now exposed as hw_ops callbacks
b) the auxiliary device code is now completely generic.
This will allow for easier introduction of new hw_ops implementations in the future without throwing away all the goodness of the auxiliary device handling. Since there will be a tighter coupling with HDaudio, it's likely that future hw_ops are implemented in the SOF driver directly.
Pierre-Louis Bossart (7):
soundwire: intel: start using hw_ops
soundwire: intel: add debugfs callbacks in hw_ops
soundwire: intel: add register_dai callback in hw_ops
soundwire: intel: add bus management callbacks in hw_ops
soundwire: intel: add link power management callbacks in hw_ops
soundwire: intel: add in-band wake callbacks in hw_ops
soundwire: intel: split auxdevice to different file
drivers/soundwire/Makefile | 2 +- drivers/soundwire/intel.c | 658 +-------------------------- drivers/soundwire/intel.h | 96 +++- drivers/soundwire/intel_auxdevice.c | 678 ++++++++++++++++++++++++++++ drivers/soundwire/intel_auxdevice.h | 18 + drivers/soundwire/intel_init.c | 2 + include/linux/soundwire/sdw_intel.h | 44 ++ sound/soc/sof/intel/hda.c | 2 + 8 files changed, 853 insertions(+), 647 deletions(-) create mode 100644 drivers/soundwire/intel_auxdevice.c create mode 100644 drivers/soundwire/intel_auxdevice.h
Signature · 1 line
2.25.1
Bard Liao
maintainerPATCH 1/7 soundwire: intel: start using hw_ops
From: Pierre-Louis Bossart <[email protected]>
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.
--- drivers/soundwire/intel.c | 38 +++++++++++++++++++++++------ drivers/soundwire/intel.h | 3 +++ drivers/soundwire/intel_init.c | 1 + include/linux/soundwire/sdw_intel.h | 15 ++++++++++++ sound/soc/sof/intel/hda.c | 2 ++ 5 files changed, 51 insertions(+), 8 deletions(-)
drivers/soundwire/intel.c +30 -8
@@ -745,10 +745,10 @@ static int intel_free_stream(struct sdw_intel *sdw,* bank switch routines */ -static int intel_pre_bank_switch (struct sdw_bus *bus) +static int intel_pre_bank_switch (struct sdw_intel *sdw) { -struct sdw_cdns *cdns =bus_to_cdns (bus); -struct sdw_intel *sdw =cdns_to_intel (cdns); +struct sdw_cdns *cdns = &sdw->cdns; +struct sdw_bus *bus = &cdns->bus;/* Write to register only for multi-link */ if (!bus->multi_link)
@@ -759,10 +759,10 @@ static int intel_pre_bank_switch(struct sdw_bus *bus)return 0 ; } -static int intel_post_bank_switch (struct sdw_bus *bus) +static int intel_post_bank_switch (struct sdw_intel *sdw) { -struct sdw_cdns *cdns =bus_to_cdns (bus); -struct sdw_intel *sdw =cdns_to_intel (cdns); +struct sdw_cdns *cdns = &sdw->cdns; +struct sdw_bus *bus = &cdns->bus;void __iomem *shim = sdw->link_res->shim;int sync_reg, ret;
@@ -1422,6 +1422,28 @@ static int intel_stop_bus(struct sdw_intel *sdw, bool clock_stop)return 0 ; } +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, +}; +EXPORT_SYMBOL_NS (sdw_intel_cnl_hw_ops,SOUNDWIRE_INTEL ); + +static int generic_pre_bank_switch (struct sdw_bus *bus) +{ +struct sdw_cdns *cdns =bus_to_cdns (bus); +struct sdw_intel *sdw =cdns_to_intel (cdns); + +return sdw->link_res->hw_ops->pre_bank_switch (sdw); +} + +static int generic_post_bank_switch (struct sdw_bus *bus) +{ +struct sdw_cdns *cdns =bus_to_cdns (bus); +struct sdw_intel *sdw =cdns_to_intel (cdns); + +return sdw->link_res->hw_ops->post_bank_switch (sdw); +} +static int sdw_master_read_intel_prop (struct sdw_bus *bus) {struct sdw_master_prop *prop = &bus->prop;
@@ -1477,8 +1499,8 @@ static struct sdw_master_ops sdw_intel_ops = { .xfer_msg_defer = cdns_xfer_msg_defer, .reset_page_addr = cdns_reset_page_addr, .set_bus_conf = cdns_bus_conf, - .pre_bank_switch = intel_pre_bank_switch, - .post_bank_switch = intel_post_bank_switch, + .pre_bank_switch = generic_pre_bank_switch, + .post_bank_switch = generic_post_bank_switch, .read_ping_status = cdns_read_ping_status, };
drivers/soundwire/intel.h +3 -0
@@ -7,6 +7,7 @@/** * struct sdw_intel_link_res - Soundwire Intel link resource structure, * typically populated by the controller driver. +* @hw_ops: platform-specific ops * @mmio_base: mmio base of SoundWire registers * @registers: Link IO registers base * @shim: Audio shim pointer
@@ -22,6 +23,8 @@* @list: used to walk-through all masters exposed by the same controller */ struct sdw_intel_link_res { +const struct sdw_intel_hw_ops *hw_ops; +void __iomem *mmio_base;/* not strictly needed, useful for debug */ void __iomem *registers;void __iomem *shim;
drivers/soundwire/intel_init.c +1 -0
@@ -60,6 +60,7 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res */* Add link information used in the driver probe */ link = &ldev->link_res; + link->hw_ops = res->hw_ops; link->mmio_base = res->mmio_base; link->registers = res->mmio_base +SDW_LINK_BASE + (SDW_LINK_SIZE * link_id);
include/linux/soundwire/sdw_intel.h +15 -0
@@ -233,6 +233,7 @@ struct sdw_intel_ctx {* struct sdw_intel_res - Soundwire Intel global resource structure, * typically populated by the DSP driver * +* @hw_ops: abstraction for platform ops * @count: link count * @mmio_base: mmio base of SoundWire registers * @irq: interrupt number
@@ -249,6 +250,7 @@ struct sdw_intel_ctx {* @alh_base: sdw alh base. */ struct sdw_intel_res { +const struct sdw_intel_hw_ops *hw_ops;int count;void __iomem *mmio_base;int irq;
@@ -292,4 +294,17 @@ irqreturn_t sdw_intel_thread(int irq, void *dev_id);#define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1) +struct sdw_intel ; + +/* struct intel_sdw_hw_ops - SoundWire ops for Intel platforms. +* @pre_bank_switch: helper for bus management +* @post_bank_switch: helper for bus management +*/ +struct sdw_intel_hw_ops { +int (*pre_bank_switch)(struct sdw_intel *sdw); +int (*post_bank_switch)(struct sdw_intel *sdw); +}; + +extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops; +#endif
sound/soc/sof/intel/hda.c +2 -0
@@ -188,6 +188,7 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)memset (&res,0 ,sizeof (res)); + res.hw_ops = &sdw_intel_cnl_hw_ops; res.mmio_base = sdev->bar[HDA_DSP_BAR ]; res.shim_base = hdev->desc->sdw_shim_base; res.alh_base = hdev->desc->sdw_alh_base;
@@ -1694,3 +1695,4 @@ MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC_I915);MODULE_IMPORT_NS (SND_SOC_SOF_XTENSA );MODULE_IMPORT_NS (SND_INTEL_SOUNDWIRE_ACPI );MODULE_IMPORT_NS (SOUNDWIRE_INTEL_INIT ); +MODULE_IMPORT_NS (SOUNDWIRE_INTEL );
Signature · 1 line
2.25.1
Bard Liao
maintainerPATCH 2/7 soundwire: intel: add debugfs callbacks in hw_ops
In reply to Bard LiaoFrom: Pierre-Louis Bossart <[email protected]>
No functionality change, only add indirection for debugfs helpers.
--- drivers/soundwire/intel.c | 7 +++++-- drivers/soundwire/intel.h | 16 ++++++++++++++++ include/linux/soundwire/sdw_intel.h | 5 +++++ 3 files changed, 26 insertions(+), 2 deletions(-)
drivers/soundwire/intel.c +5 -2
@@ -1423,6 +1423,9 @@ static int intel_stop_bus(struct sdw_intel *sdw, bool clock_stop) }const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = { + .debugfs_init = intel_debugfs_init, + .debugfs_exit = intel_debugfs_exit, + .pre_bank_switch = intel_pre_bank_switch, .post_bank_switch = intel_post_bank_switch, };
@@ -1614,7 +1617,7 @@ int intel_link_startup(struct auxiliary_device *auxdev) goto err_power_up; } -intel_debugfs_init (sdw); +sdw_intel_debugfs_init (sdw);/* start bus */ ret =intel_start_bus (sdw);
@@ -1685,7 +1688,7 @@ static void intel_link_remove(struct auxiliary_device *auxdev)* SDW_INTEL_CLK_STOP_NOT_ALLOWED */ if (!bus->prop.hw_disabled) { -intel_debugfs_exit (sdw); +sdw_intel_debugfs_exit (sdw);sdw_cdns_enable_interrupt (cdns, false); }sdw_bus_master_delete (bus);
drivers/soundwire/intel.h +16 -0
@@ -61,4 +61,20 @@ struct sdw_intel_link_dev {#define auxiliary_dev_to_sdw_intel_link_dev (auxiliary_dev) \ container_of(auxiliary_dev, struct sdw_intel_link_dev, auxdev) +#define SDW_INTEL_CHECK_OPS (sdw, cb) ((sdw) && (sdw)->link_res && (sdw)->link_res->hw_ops && \ + (sdw)->link_res->hw_ops->cb) +#define SDW_INTEL_OPS (sdw, cb) ((sdw)->link_res->hw_ops->cb) + +static inline void sdw_intel_debugfs_init (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, debugfs_init)) +SDW_INTEL_OPS (sdw, debugfs_init)(sdw); +} + +static inline void sdw_intel_debugfs_exit (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, debugfs_exit)) +SDW_INTEL_OPS (sdw, debugfs_exit)(sdw); +} +#endif /* __SDW_INTEL_LOCAL_H */
include/linux/soundwire/sdw_intel.h +5 -0
@@ -297,10 +297,15 @@ irqreturn_t sdw_intel_thread(int irq, void *dev_id);struct sdw_intel ;/* struct intel_sdw_hw_ops - SoundWire ops for Intel platforms. +* @debugfs_init: initialize all debugfs capabilities +* @debugfs_exit: close and cleanup debugfs capabilities * @pre_bank_switch: helper for bus management * @post_bank_switch: helper for bus management */ struct sdw_intel_hw_ops { +void (*debugfs_init)(struct sdw_intel *sdw); +void (*debugfs_exit)(struct sdw_intel *sdw); +int (*pre_bank_switch)(struct sdw_intel *sdw);int (*post_bank_switch)(struct sdw_intel *sdw); };
Signature · 1 line
2.25.1
Bard Liao
maintainerPATCH 3/7 soundwire: intel: add register_dai callback in hw_ops
In reply to Bard LiaoFrom: Pierre-Louis Bossart <[email protected]>
No functionality change, only add indirection for DAI registration helper.
--- drivers/soundwire/intel.c | 4 +++- drivers/soundwire/intel.h | 7 +++++++ include/linux/soundwire/sdw_intel.h | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/soundwire/intel.c +3 -1
@@ -1426,6 +1426,8 @@ const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = { .debugfs_init = intel_debugfs_init, .debugfs_exit = intel_debugfs_exit, + .register_dai = intel_register_dai, + .pre_bank_switch = intel_pre_bank_switch, .post_bank_switch = intel_post_bank_switch, };
@@ -1611,7 +1613,7 @@ int intel_link_startup(struct auxiliary_device *auxdev) goto err_init;/* Register DAIs */ - ret =intel_register_dai (sdw); + ret =sdw_intel_register_dai (sdw);if (ret) {dev_err (dev,"DAI registration failed: %d\n" , ret); goto err_power_up;
drivers/soundwire/intel.h +7 -0
@@ -77,4 +77,11 @@ static inline void sdw_intel_debugfs_exit(struct sdw_intel *sdw) SDW_INTEL_OPS(sdw, debugfs_exit)(sdw); } +static inline int sdw_intel_register_dai (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, register_dai)) +return SDW_INTEL_OPS (sdw, register_dai)(sdw); +return -ENOTSUPP ; +} +#endif /* __SDW_INTEL_LOCAL_H */
include/linux/soundwire/sdw_intel.h +3 -0
@@ -299,6 +299,7 @@ struct sdw_intel;/* struct intel_sdw_hw_ops - SoundWire ops for Intel platforms. * @debugfs_init: initialize all debugfs capabilities * @debugfs_exit: close and cleanup debugfs capabilities +* @register_dai: read all PDI information and register DAIs * @pre_bank_switch: helper for bus management * @post_bank_switch: helper for bus management */
@@ -306,6 +307,8 @@ struct sdw_intel_hw_ops {void (*debugfs_init)(struct sdw_intel *sdw);void (*debugfs_exit)(struct sdw_intel *sdw); +int (*register_dai)(struct sdw_intel *sdw); +int (*pre_bank_switch)(struct sdw_intel *sdw);int (*post_bank_switch)(struct sdw_intel *sdw); };
Signature · 1 line
2.25.1
Bard Liao
maintainerPATCH 4/7 soundwire: intel: add bus management callbacks in hw_ops
In reply to Bard LiaoFrom: Pierre-Louis Bossart <[email protected]>
No functionality change, only add indirection for bus management helpers.
--- drivers/soundwire/intel.c | 24 ++++++++++++-------- drivers/soundwire/intel.h | 34 +++++++++++++++++++++++++++++ include/linux/soundwire/sdw_intel.h | 11 ++++++++++ 3 files changed, 60 insertions(+), 9 deletions(-)
drivers/soundwire/intel.c +15 -9
@@ -1428,6 +1428,12 @@ const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = { .register_dai = intel_register_dai, + .check_clock_stop = intel_check_clock_stop, + .start_bus = intel_start_bus, + .start_bus_after_reset = intel_start_bus_after_reset, + .start_bus_after_clock_stop = intel_start_bus_after_clock_stop, + .stop_bus = intel_stop_bus, + .pre_bank_switch = intel_pre_bank_switch, .post_bank_switch = intel_post_bank_switch, };
@@ -1622,7 +1628,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)sdw_intel_debugfs_init (sdw);/* start bus */ - ret =intel_start_bus (sdw); + ret =sdw_intel_start_bus (sdw);if (ret) {dev_err (dev,"bus start failed: %d\n" , ret); goto err_power_up;
@@ -1850,7 +1856,7 @@ static int __maybe_unused intel_suspend(struct device *dev)return 0 ; } - ret =intel_stop_bus (sdw, false); + ret =sdw_intel_stop_bus (sdw, false);if (ret <0 ) {dev_err (dev,"%s: cannot stop bus: %d\n" , __func__, ret);return ret;
@@ -1876,14 +1882,14 @@ static int __maybe_unused intel_suspend_runtime(struct device *dev) clock_stop_quirks = sdw->link_res->clock_stop_quirks;if (clock_stop_quirks &SDW_INTEL_CLK_STOP_TEARDOWN ) { - ret =intel_stop_bus (sdw, false); + ret =sdw_intel_stop_bus (sdw, false);if (ret <0 ) {dev_err (dev,"%s: cannot stop bus during teardown: %d\n" , __func__, ret);return ret; } }else if (clock_stop_quirks &SDW_INTEL_CLK_STOP_BUS_RESET || !clock_stop_quirks) { - ret =intel_stop_bus (sdw, true); + ret =sdw_intel_stop_bus (sdw, true);if (ret <0 ) {dev_err (dev,"%s: cannot stop bus during clock_stop: %d\n" , __func__, ret);
@@ -1941,7 +1947,7 @@ static int __maybe_unused intel_resume(struct device *dev)*/ sdw_clear_slave_status (bus,SDW_UNATTACH_REQUEST_MASTER_RESET ); - ret =intel_start_bus (sdw); + ret =sdw_intel_start_bus (sdw);if (ret <0 ) {dev_err (dev,"cannot start bus during resume\n" );intel_link_power_down (sdw);
@@ -1995,7 +2001,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)*/ sdw_clear_slave_status (bus,SDW_UNATTACH_REQUEST_MASTER_RESET ); - ret =intel_start_bus (sdw); + ret =sdw_intel_start_bus (sdw);if (ret <0 ) {dev_err (dev,"%s: cannot start bus after teardown: %d\n" , __func__, ret);intel_link_power_down (sdw);
@@ -2010,7 +2016,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)return ret; } - ret =intel_start_bus_after_reset (sdw); + ret =sdw_intel_start_bus_after_reset (sdw);if (ret <0 ) {dev_err (dev,"%s: cannot start bus after reset: %d\n" , __func__, ret);intel_link_power_down (sdw);
@@ -2018,7 +2024,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) } }else if (!clock_stop_quirks) { -intel_check_clock_stop (sdw); +sdw_intel_check_clock_stop (sdw); ret =intel_link_power_up (sdw);if (ret) {
@@ -2026,7 +2032,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)return ret; } - ret =intel_start_bus_after_clock_stop (sdw); + ret =sdw_intel_start_bus_after_clock_stop (sdw);if (ret <0 ) {dev_err (dev,"%s: cannot start bus after clock stop: %d\n" , __func__, ret);intel_link_power_down (sdw);
drivers/soundwire/intel.h +34 -0
@@ -84,4 +84,38 @@ static inline int sdw_intel_register_dai(struct sdw_intel *sdw)return -ENOTSUPP ; } +static inline void sdw_intel_check_clock_stop (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, check_clock_stop)) +SDW_INTEL_OPS (sdw, check_clock_stop)(sdw); +} + +static inline int sdw_intel_start_bus (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, start_bus)) +return SDW_INTEL_OPS (sdw, start_bus)(sdw); +return -ENOTSUPP ; +} + +static inline int sdw_intel_start_bus_after_reset (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, start_bus_after_reset)) +return SDW_INTEL_OPS (sdw, start_bus_after_reset)(sdw); +return -ENOTSUPP ; +} + +static inline int sdw_intel_start_bus_after_clock_stop (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, start_bus_after_clock_stop)) +return SDW_INTEL_OPS (sdw, start_bus_after_clock_stop)(sdw); +return -ENOTSUPP ; +} + +static inline int sdw_intel_stop_bus (struct sdw_intel *sdw,bool clock_stop) +{ +if (SDW_INTEL_CHECK_OPS (sdw, stop_bus)) +return SDW_INTEL_OPS (sdw, stop_bus)(sdw, clock_stop); +return -ENOTSUPP ; +} +#endif /* __SDW_INTEL_LOCAL_H */
include/linux/soundwire/sdw_intel.h +11 -0
@@ -300,6 +300,11 @@ struct sdw_intel;* @debugfs_init: initialize all debugfs capabilities * @debugfs_exit: close and cleanup debugfs capabilities * @register_dai: read all PDI information and register DAIs +* @check_clock_stop: throw error message if clock is not stopped. +* @start_bus: normal start +* @start_bus_after_reset: start after reset +* @start_bus_after_clock_stop: start after mode0 clock stop +* @stop_bus: stop all bus * @pre_bank_switch: helper for bus management * @post_bank_switch: helper for bus management */
@@ -309,6 +314,12 @@ struct sdw_intel_hw_ops {int (*register_dai)(struct sdw_intel *sdw); +void (*check_clock_stop)(struct sdw_intel *sdw); +int (*start_bus)(struct sdw_intel *sdw); +int (*start_bus_after_reset)(struct sdw_intel *sdw); +int (*start_bus_after_clock_stop)(struct sdw_intel *sdw); +int (*stop_bus)(struct sdw_intel *sdw,bool clock_stop); +int (*pre_bank_switch)(struct sdw_intel *sdw);int (*post_bank_switch)(struct sdw_intel *sdw); };
Signature · 1 line
2.25.1
Bard Liao
maintainerPATCH 5/7 soundwire: intel: add link power management callbacks in hw_ops
In reply to Bard LiaoFrom: Pierre-Louis Bossart <[email protected]>
No functionality change, only add indirection for link power management helpers.
--- drivers/soundwire/intel.c | 23 +++++++++++++---------- drivers/soundwire/intel.h | 14 ++++++++++++++ include/linux/soundwire/sdw_intel.h | 5 +++++ 3 files changed, 32 insertions(+), 10 deletions(-)
drivers/soundwire/intel.c +13 -10
@@ -1434,6 +1434,9 @@ const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = { .start_bus_after_clock_stop = intel_start_bus_after_clock_stop, .stop_bus = intel_stop_bus, + .link_power_up = intel_link_power_up, + .link_power_down = intel_link_power_down, + .pre_bank_switch = intel_pre_bank_switch, .post_bank_switch = intel_post_bank_switch, };
@@ -1614,7 +1617,7 @@ int intel_link_startup(struct auxiliary_device *auxdev) bus->multi_link = multi_link;/* Initialize shim, controller */ - ret =intel_link_power_up (sdw); + ret =sdw_intel_link_power_up (sdw);if (ret) goto err_init;
@@ -1679,7 +1682,7 @@ int intel_link_startup(struct auxiliary_device *auxdev)return 0 ; err_power_up: -intel_link_power_down (sdw); +sdw_intel_link_power_down (sdw); err_init:return ret; }
@@ -1935,7 +1938,7 @@ static int __maybe_unused intel_resume(struct device *dev)pm_runtime_idle (dev); } - ret =intel_link_power_up (sdw); + ret =sdw_intel_link_power_up (sdw);if (ret) {dev_err (dev,"%s failed: %d\n" , __func__, ret);return ret;
@@ -1950,7 +1953,7 @@ static int __maybe_unused intel_resume(struct device *dev) ret =sdw_intel_start_bus (sdw);if (ret <0 ) {dev_err (dev,"cannot start bus during resume\n" ); -intel_link_power_down (sdw); +sdw_intel_link_power_down (sdw);return ret; }
@@ -1989,7 +1992,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) clock_stop_quirks = sdw->link_res->clock_stop_quirks;if (clock_stop_quirks &SDW_INTEL_CLK_STOP_TEARDOWN ) { - ret =intel_link_power_up (sdw); + ret =sdw_intel_link_power_up (sdw);if (ret) {dev_err (dev,"%s: power_up failed after teardown: %d\n" , __func__, ret);return ret;
@@ -2004,13 +2007,13 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ret =sdw_intel_start_bus (sdw);if (ret <0 ) {dev_err (dev,"%s: cannot start bus after teardown: %d\n" , __func__, ret); -intel_link_power_down (sdw); +sdw_intel_link_power_down (sdw);return ret; } }else if (clock_stop_quirks &SDW_INTEL_CLK_STOP_BUS_RESET ) { - ret =intel_link_power_up (sdw); + ret =sdw_intel_link_power_up (sdw);if (ret) {dev_err (dev,"%s: power_up failed after bus reset: %d\n" , __func__, ret);return ret;
@@ -2019,14 +2022,14 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ret =sdw_intel_start_bus_after_reset (sdw);if (ret <0 ) {dev_err (dev,"%s: cannot start bus after reset: %d\n" , __func__, ret); -intel_link_power_down (sdw); +sdw_intel_link_power_down (sdw);return ret; } }else if (!clock_stop_quirks) {sdw_intel_check_clock_stop (sdw); - ret =intel_link_power_up (sdw); + ret =sdw_intel_link_power_up (sdw);if (ret) {dev_err (dev,"%s: power_up failed: %d\n" , __func__, ret);return ret;
@@ -2035,7 +2038,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) ret =sdw_intel_start_bus_after_clock_stop (sdw);if (ret <0 ) {dev_err (dev,"%s: cannot start bus after clock stop: %d\n" , __func__, ret); -intel_link_power_down (sdw); +sdw_intel_link_power_down (sdw);return ret; } }else {
drivers/soundwire/intel.h +14 -0
@@ -118,4 +118,18 @@ static inline int sdw_intel_stop_bus(struct sdw_intel *sdw, bool clock_stop) return -ENOTSUPP; } +static inline int sdw_intel_link_power_up (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, link_power_up)) +return SDW_INTEL_OPS (sdw, link_power_up)(sdw); +return -ENOTSUPP ; +} + +static inline int sdw_intel_link_power_down (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, link_power_down)) +return SDW_INTEL_OPS (sdw, link_power_down)(sdw); +return -ENOTSUPP ; +} +#endif /* __SDW_INTEL_LOCAL_H */
include/linux/soundwire/sdw_intel.h +5 -0
@@ -305,6 +305,8 @@ struct sdw_intel;* @start_bus_after_reset: start after reset * @start_bus_after_clock_stop: start after mode0 clock stop * @stop_bus: stop all bus +* @link_power_up: power-up using chip-specific helpers +* @link_power_down: power-down with chip-specific helpers * @pre_bank_switch: helper for bus management * @post_bank_switch: helper for bus management */
@@ -320,6 +322,9 @@ struct sdw_intel_hw_ops {int (*start_bus_after_clock_stop)(struct sdw_intel *sdw);int (*stop_bus)(struct sdw_intel *sdw,bool clock_stop); +int (*link_power_up)(struct sdw_intel *sdw); +int (*link_power_down)(struct sdw_intel *sdw); +int (*pre_bank_switch)(struct sdw_intel *sdw);int (*post_bank_switch)(struct sdw_intel *sdw); };
Signature · 1 line
2.25.1
Bard Liao
maintainerPATCH 6/7 soundwire: intel: add in-band wake callbacks in hw_ops
In reply to Bard LiaoFrom: Pierre-Louis Bossart <[email protected]>
No functionality change, only add indirection for in-band wake management helpers.
--- drivers/soundwire/intel.c | 11 +++++++---- drivers/soundwire/intel.h | 13 +++++++++++++ include/linux/soundwire/sdw_intel.h | 5 +++++ 3 files changed, 25 insertions(+), 4 deletions(-)
drivers/soundwire/intel.c +7 -4
@@ -1437,6 +1437,9 @@ const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops = { .link_power_up = intel_link_power_up, .link_power_down = intel_link_power_down, + .shim_check_wake = intel_shim_check_wake, + .shim_wake = intel_shim_wake, + .pre_bank_switch = intel_pre_bank_switch, .post_bank_switch = intel_post_bank_switch, };
@@ -1720,11 +1723,11 @@ int intel_link_process_wakeen_event(struct auxiliary_device *auxdev)return 0 ; } -if (!intel_shim_check_wake (sdw)) +if (!sdw_intel_shim_check_wake (sdw))return 0 ;/* disable WAKEEN interrupt ASAP to prevent interrupt flood */ -intel_shim_wake (sdw, false); +sdw_intel_shim_wake (sdw, false);/* * resume the Master, which will generate a bus reset and result in
@@ -1852,7 +1855,7 @@ static int __maybe_unused intel_suspend(struct device *dev)*/ dev_err (dev,"%s: invalid config: parent is suspended\n" , __func__); }else { -intel_shim_wake (sdw, false); +sdw_intel_shim_wake (sdw, false); } }
@@ -1987,7 +1990,7 @@ static int __maybe_unused intel_resume_runtime(struct device *dev) }/* unconditionally disable WAKEEN interrupt */ -intel_shim_wake (sdw, false); +sdw_intel_shim_wake (sdw, false); clock_stop_quirks = sdw->link_res->clock_stop_quirks;
drivers/soundwire/intel.h +13 -0
@@ -132,4 +132,17 @@ static inline int sdw_intel_link_power_down(struct sdw_intel *sdw) return -ENOTSUPP; } +static inline int sdw_intel_shim_check_wake (struct sdw_intel *sdw) +{ +if (SDW_INTEL_CHECK_OPS (sdw, shim_check_wake)) +return SDW_INTEL_OPS (sdw, shim_check_wake)(sdw); +return -ENOTSUPP ; +} + +static inline void sdw_intel_shim_wake (struct sdw_intel *sdw,bool wake_enable) +{ +if (SDW_INTEL_CHECK_OPS (sdw, shim_wake)) +SDW_INTEL_OPS (sdw, shim_wake)(sdw, wake_enable); +} +#endif /* __SDW_INTEL_LOCAL_H */
include/linux/soundwire/sdw_intel.h +5 -0
@@ -307,6 +307,8 @@ struct sdw_intel;* @stop_bus: stop all bus * @link_power_up: power-up using chip-specific helpers * @link_power_down: power-down with chip-specific helpers +* @shim_check_wake: check if a wake was received +* @shim_wake: enable/disable in-band wake management * @pre_bank_switch: helper for bus management * @post_bank_switch: helper for bus management */
@@ -325,6 +327,9 @@ struct sdw_intel_hw_ops {int (*link_power_up)(struct sdw_intel *sdw);int (*link_power_down)(struct sdw_intel *sdw); +int (*shim_check_wake)(struct sdw_intel *sdw); +void (*shim_wake)(struct sdw_intel *sdw,bool wake_enable); +int (*pre_bank_switch)(struct sdw_intel *sdw);int (*post_bank_switch)(struct sdw_intel *sdw); };
Signature · 1 line
2.25.1
Bard Liao
maintainerPATCH 7/7 soundwire: intel: split auxdevice to different file
In reply to Bard LiaoFrom: Pierre-Louis Bossart <[email protected]>
The auxdevice layer is completely generic, it should be split from intel.c which is only geared to the 'cnl' hw_ops now.
--- drivers/soundwire/Makefile | 2 +- drivers/soundwire/intel.c | 657 --------------------------- drivers/soundwire/intel.h | 11 +- drivers/soundwire/intel_auxdevice.c | 678 ++++++++++++++++++++++++++++ drivers/soundwire/intel_auxdevice.h | 18 + drivers/soundwire/intel_init.c | 1 + 6 files changed, 700 insertions(+), 667 deletions(-) create mode 100644 drivers/soundwire/intel_auxdevice.c create mode 100644 drivers/soundwire/intel_auxdevice.h
drivers/soundwire/Makefile +1 -1
@@ -20,7 +20,7 @@ soundwire-cadence-y := cadence_master.o obj-$(CONFIG_SOUNDWIRE_CADENCE) += soundwire-cadence.o #Intel driver -soundwire-intel-y := intel.o intel_init.o dmi-quirks.o +soundwire-intel-y := intel.o intel_auxdevice.o intel_init.o dmi-quirks.o obj-$(CONFIG_SOUNDWIRE_INTEL) += soundwire-intel.o #Qualcomm driver
drivers/soundwire/intel.c +0 -657
673 lines not on this page · raw message
drivers/soundwire/intel.h +2 -9
@@ -50,16 +50,9 @@ struct sdw_intel {#endif }; -int intel_link_startup (struct auxiliary_device *auxdev); -int intel_link_process_wakeen_event (struct auxiliary_device *auxdev); +#define cdns_to_intel (_cdns) container_of(_cdns, struct sdw_intel, cdns) -struct sdw_intel_link_dev { -struct auxiliary_device auxdev; -struct sdw_intel_link_res link_res; -}; - -#define auxiliary_dev_to_sdw_intel_link_dev (auxiliary_dev) \ - container_of(auxiliary_dev, struct sdw_intel_link_dev, auxdev) +#define INTEL_MASTER_RESET_ITERATIONS 10#define SDW_INTEL_CHECK_OPS (sdw, cb) ((sdw) && (sdw)->link_res && (sdw)->link_res->hw_ops && \ (sdw)->link_res->hw_ops->cb)
drivers/soundwire/intel_auxdevice.c new file +678 -0
678 lines not on this page · raw message
drivers/soundwire/intel_auxdevice.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ +/* Copyright(c) 2015-2022 Intel Corporation. */ + +#ifndef __SDW_INTEL_AUXDEVICE_H +#define __SDW_INTEL_AUXDEVICE_H + +int intel_link_startup (struct auxiliary_device *auxdev); +int intel_link_process_wakeen_event (struct auxiliary_device *auxdev); + +struct sdw_intel_link_dev { +struct auxiliary_device auxdev; +struct sdw_intel_link_res link_res; +}; + +#define auxiliary_dev_to_sdw_intel_link_dev (auxiliary_dev) \ + container_of(auxiliary_dev, struct sdw_intel_link_dev, auxdev) + +#endif /* __SDW_INTEL_AUXDEVICE_H */
drivers/soundwire/intel_init.c +1 -0
@@ -17,6 +17,7 @@#include <linux/soundwire/sdw_intel.h> #include "cadence_master.h" #include "intel.h" +#include "intel_auxdevice.h" static void intel_link_dev_release (struct device *dev) {
Signature · 1 line
2.25.1
RE: [PATCH 7/7] soundwire: intel: split auxdevice to different file
Quoted 8 lines
-----Original Message-----
From: Bard Liao <[email protected]>
Sent: Friday, November 11, 2022 9:32 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; pierre- [email protected]; Liao, Bard <[email protected]>
Subject: [PATCH 7/7] soundwire: intel: split auxdevice to different file
Quoted 8 lines
From: Pierre-Louis Bossart <[email protected]>
The auxdevice layer is completely generic, it should be split from
intel.cwhich is only geared to the 'cnl'hw_opsnow.Signed-off-by Pierre-Louis Bossart <[email protected]>Reviewed-by Rander Wang <[email protected]>Signed-off-by Bard Liao <[email protected]>
Hi Vinod,
Note that "soundwire: intel: Initialize clock stop timeout" which is in your fixes branch, but not in your next branch is needed before applying this patch.
Quoted 8 lines · Bard Liao
This series adds yet another set of cleanups
a) all the helpers are now exposed ashw_opscallbacks
b) the auxiliary device code is now completely generic.This will allow for easier introduction of new
hw_opsimplementations in the future without throwing away all the goodness of the auxiliary device handling. Since there will be a tighter coupling with HDaudio, it's likely that futurehw_opsare implemented in the SOF driver directly.
Applied, thanks
Signature · 1 line
~Vinod