ASoC: cs35l56: Share common SoundWire interrupt enable/disable code
Subsystems (3)
Richard Fitzgerald
maintainerPATCH 1/1 ASoC: cs35l56: Share common SoundWire interrupt enable/disable code
Move the duplicated SoundWire interrupt enable/disable code into shared functions. These functions must be in cs35l56-shared module to prevent circular dependency between cs35l56.c and cs35l56-sdw.c
Signed-off-by Richard Fitzgerald <[email protected]>
--- sound/soc/codecs/cs35l56-sdw.c | 43 ++++++------------------------ sound/soc/codecs/cs35l56-shared.c | 44 +++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l56.c | 16 ++--------- sound/soc/codecs/cs35l56.h | 5 ++++ 4 files changed, 59 insertions(+), 49 deletions(-)
sound/soc/codecs/cs35l56-sdw.c +8 -35
@@ -230,11 +230,8 @@ static void cs35l56_sdw_init(struct sdw_slave *peripheral)* cs35l56_init can return with !init_done if it triggered * a soft reset. */ -if (cs35l56->base.init_done) { -/* Enable SoundWire interrupts */ -sdw_write_no_pm (peripheral,CS35L56_SDW_GEN_INT_MASK_1 , -CS35L56_SDW_INT_MASK_CODEC_IRQ ); - } +if (cs35l56->base.init_done) +cs35l56_unmask_soundwire_interrupts (cs35l56->sdw_peripheral); out:pm_runtime_put_autosuspend (cs35l56->base.dev);
@@ -259,15 +256,11 @@ static int cs35l56_sdw_interrupt(struct sdw_slave *peripheral,pm_runtime_get_noresume (cs35l56->base.dev);/* -* Mask and clear until it has been handled. The read of GEN_INT_STAT_1 -* is required as per the SoundWire spec for interrupt status bits -* to clear. GEN_INT_MASK_1 masks the _inputs_ to GEN_INT_STAT1. +* Mask and clear until it has been handled. * None of the interrupts are time-critical so use the * power-efficient queue. */ -sdw_write_no_pm (peripheral,CS35L56_SDW_GEN_INT_MASK_1 ,0 ); -sdw_read_no_pm (peripheral,CS35L56_SDW_GEN_INT_STAT_1 ); -sdw_write_no_pm (peripheral,CS35L56_SDW_GEN_INT_STAT_1 ,0xFF ); +cs35l56_mask_soundwire_interrupts (peripheral);queue_work (system_power_efficient_wq, &cs35l56->sdw_irq_work);return 0 ;
@@ -283,8 +276,7 @@ static void cs35l56_sdw_irq_work(struct work_struct *work)/* unmask interrupts */ if (!cs35l56->sdw_irq_no_unmask) -sdw_write_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_MASK_1 , -CS35L56_SDW_INT_MASK_CODEC_IRQ ); +cs35l56_unmask_soundwire_interrupts (cs35l56->sdw_peripheral);pm_runtime_put_autosuspend (cs35l56->base.dev); }
@@ -441,9 +433,7 @@ static int __maybe_unused cs35l56_sdw_runtime_resume(struct device *dev)if (ret)return ret; -/* Re-enable SoundWire interrupts */ -sdw_write_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_MASK_1 , -CS35L56_SDW_INT_MASK_CODEC_IRQ ); +cs35l56_unmask_soundwire_interrupts (cs35l56->sdw_peripheral);return 0 ; }
@@ -455,18 +445,7 @@ static int __maybe_unused cs35l56_sdw_system_suspend(struct device *dev)if (!cs35l56->base.init_done)return 0 ; -/* -* Disable SoundWire interrupts. -* Flush - don't cancel because that could leave an unbalanced pm_runtime_get. -*/ - cs35l56->sdw_irq_no_unmask = true; -flush_work (&cs35l56->sdw_irq_work); - -/* Mask interrupts and flush in case sdw_irq_work was queued again */ -sdw_write_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_MASK_1 ,0 ); -sdw_read_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_STAT_1 ); -sdw_write_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_STAT_1 ,0xFF ); -flush_work (&cs35l56->sdw_irq_work); +cs35l56_disable_sdw_interrupts (cs35l56);return cs35l56_system_suspend (dev); }
@@ -542,13 +521,7 @@ static void cs35l56_sdw_remove(struct sdw_slave *peripheral) {struct cs35l56_private *cs35l56 =dev_get_drvdata (&peripheral->dev); -/* Disable SoundWire interrupts */ - cs35l56->sdw_irq_no_unmask = true; -flush_work (&cs35l56->sdw_irq_work); -sdw_write_no_pm (peripheral,CS35L56_SDW_GEN_INT_MASK_1 ,0 ); -sdw_read_no_pm (peripheral,CS35L56_SDW_GEN_INT_STAT_1 ); -sdw_write_no_pm (peripheral,CS35L56_SDW_GEN_INT_STAT_1 ,0xFF ); -flush_work (&cs35l56->sdw_irq_work); +cs35l56_disable_sdw_interrupts (cs35l56);cs35l56_remove (cs35l56); }
sound/soc/codecs/cs35l56-shared.c +44 -0
56 lines not on this page · raw message
sound/soc/codecs/cs35l56.c +2 -14
@@ -790,14 +790,7 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56, bool firmware_missing* Setting sdw_irq_no_unmask prevents the handler re-enabling * the SoundWire interrupt. */ -if (cs35l56->sdw_peripheral) { - cs35l56->sdw_irq_no_unmask = true; -flush_work (&cs35l56->sdw_irq_work); -sdw_write_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_MASK_1 ,0 ); -sdw_read_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_STAT_1 ); -sdw_write_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_STAT_1 ,0xFF ); -flush_work (&cs35l56->sdw_irq_work); - } +cs35l56_disable_sdw_interrupts (cs35l56); ret =cs35l56_firmware_shutdown (&cs35l56->base);if (ret)
@@ -849,12 +842,7 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56, bool firmware_missing err_unlock:mutex_unlock (&cs35l56->base.irq_lock); err: -/* Re-enable SoundWire interrupts */ -if (cs35l56->sdw_peripheral) { - cs35l56->sdw_irq_no_unmask = false; -sdw_write_no_pm (cs35l56->sdw_peripheral,CS35L56_SDW_GEN_INT_MASK_1 , -CS35L56_SDW_INT_MASK_CODEC_IRQ ); - } +cs35l56_enable_sdw_interrupts (cs35l56); }static void cs35l56_dsp_work (struct work_struct *work)
sound/soc/codecs/cs35l56.h +5 -0
@@ -66,6 +66,11 @@ static inline struct cs35l56_private *cs35l56_private_from_base(struct cs35l56_bextern const struct dev_pm_ops cs35l56_pm_ops_i2c_spi; +void cs35l56_mask_soundwire_interrupts (struct sdw_slave *peripheral); +void cs35l56_unmask_soundwire_interrupts (struct sdw_slave *peripheral); +void cs35l56_disable_sdw_interrupts (struct cs35l56_private *cs35l56); +void cs35l56_enable_sdw_interrupts (struct cs35l56_private *cs35l56); +int cs35l56_system_suspend (struct device *dev);int cs35l56_system_suspend_late (struct device *dev);int cs35l56_system_suspend_no_irq (struct device *dev);
Signature · 1 line
2.47.3
Mark Brown
maintainerQuoted 9 lines · Richard Fitzgerald
Move the duplicated SoundWire interrupt enable/disable code into shared functions. These functions must be in cs35l56-shared module to prevent circular dependency between
cs35l56.candcs35l56-sdw.c#include "
cs35l56.h"sound/soc/codecs/cs35l56-shared.c +3
-0+void cs35l56_mask_soundwire_interrupts (struct sdw_slave *peripheral) +{ +/*
sound/soc/codecs/cs35l56-shared.c line 42
Quoted 10 lines
sound/soc/codecs/cs35l56-shared.c +10
-0+* The read of GEN_INT_STAT_1 is required as per the SoundWire spec +* for interrupt status bits to clear. +* GEN_INT_MASK_1 masks the _inputs_ to GEN_INT_STAT1. +*/ +sdw_write_no_pm (peripheral,CS35L56_SDW_GEN_INT_MASK_1 ,0 ); +sdw_read_no_pm (peripheral,CS35L56_SDW_GEN_INT_STAT_1 ); +sdw_write_no_pm (peripheral,CS35L56_SDW_GEN_INT_STAT_1 ,0xFF ); +} +EXPORT_SYMBOL_NS_GPL (cs35l56_mask_soundwire_interrupts,"SND_SOC_CS35L56_SHARED" ); +
This adds SoundWire usage to cs35l56-shared.c - we either need ifdefs for the !SOUNDWIRE case or more dependencies in Kconfig. I guess the former?