ALSA: hda: Adding support for CS35L56 on HDA systems
Subsystems (3)
Richard Fitzgerald
maintainerPATCH 3/13 ASoC: cs35l56: Convert utility functions to use common data structure
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
Use the new cs35l56_base struct for utility functions.
--- sound/soc/codecs/cs35l56.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
sound/soc/codecs/cs35l56.c +16 -16
@@ -805,14 +805,14 @@ static const struct reg_sequence cs35l56_system_reset_seq[] = { REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_SYSTEM_RESET), }; -static void cs35l56_system_reset (struct cs35l56_private *cs35l56,bool is_soundwire) +static void cs35l56_system_reset (struct cs35l56_base *cs35l56_base,bool is_soundwire) {/* * Must enter cache-only first so there can't be any more register * accesses other than the controlled system reset sequence below. */ -regcache_cache_only (cs35l56->base.regmap, true); -regmap_multi_reg_write_bypassed (cs35l56->base.regmap, +regcache_cache_only (cs35l56_base->regmap, true); +regmap_multi_reg_write_bypassed (cs35l56_base->regmap, cs35l56_system_reset_seq,ARRAY_SIZE (cs35l56_system_reset_seq));
@@ -821,7 +821,7 @@ static void cs35l56_system_reset(struct cs35l56_private *cs35l56, bool is_soundwreturn ;usleep_range (CS35L56_CONTROL_PORT_READY_US ,CS35L56_CONTROL_PORT_READY_US +400 ); -regcache_cache_only (cs35l56->base.regmap, false); +regcache_cache_only (cs35l56_base->regmap, false); }static void cs35l56_secure_patch (struct cs35l56_private *cs35l56)
@@ -885,7 +885,7 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56)init_completion (&cs35l56->init_completion); cs35l56->soft_resetting = true; -cs35l56_system_reset (cs35l56, !!cs35l56->sdw_peripheral); +cs35l56_system_reset (&cs35l56->base, !!cs35l56->sdw_peripheral);if (cs35l56->sdw_peripheral) {/*
@@ -1140,20 +1140,20 @@ int cs35l56_runtime_resume_common(struct cs35l56_private *cs35l56) }EXPORT_SYMBOL_NS_GPL (cs35l56_runtime_resume_common,SND_SOC_CS35L56_CORE ); -static int cs35l56_is_fw_reload_needed (struct cs35l56_private *cs35l56) +static int cs35l56_is_fw_reload_needed (struct cs35l56_base *cs35l56_base) {unsigned int val;int ret;/* Nothing to re-patch if we haven't done any patching yet. */ -if (!cs35l56->base.fw_patched) +if (!cs35l56_base->fw_patched)return false;/* * If we have control of RESET we will have asserted it so the firmware * will need re-patching. */ -if (cs35l56->base.reset_gpio) +if (cs35l56_base->reset_gpio)return true;/*
@@ -1161,22 +1161,22 @@ static int cs35l56_is_fw_reload_needed(struct cs35l56_private *cs35l56)* can't be used here to test for memory retention. * Assume that tuning must be re-loaded. */ -if (cs35l56->base.secured) +if (cs35l56_base->secured)return true; - ret =pm_runtime_resume_and_get (cs35l56->base.dev); + ret =pm_runtime_resume_and_get (cs35l56_base->dev);if (ret) { -dev_err (cs35l56->base.dev,"Failed to runtime_get: %d\n" , ret); +dev_err (cs35l56_base->dev,"Failed to runtime_get: %d\n" , ret);return ret; } - ret =regmap_read (cs35l56->base.regmap,CS35L56_PROTECTION_STATUS , &val); + ret =regmap_read (cs35l56_base->regmap,CS35L56_PROTECTION_STATUS , &val);if (ret) -dev_err (cs35l56->base.dev,"Failed to read PROTECTION_STATUS: %d\n" , ret); +dev_err (cs35l56_base->dev,"Failed to read PROTECTION_STATUS: %d\n" , ret);else ret = !!(val &CS35L56_FIRMWARE_MISSING ); -pm_runtime_put_autosuspend (cs35l56->base.dev); +pm_runtime_put_autosuspend (cs35l56_base->dev);return ret; }
@@ -1305,7 +1305,7 @@ int cs35l56_system_resume(struct device *dev)if (!cs35l56->component)return 0 ; - ret =cs35l56_is_fw_reload_needed (cs35l56); + ret =cs35l56_is_fw_reload_needed (&cs35l56->base);dev_dbg (cs35l56->base.dev,"fw_reload_needed: %d\n" , ret);if (ret <1 )return ret;
@@ -1550,7 +1550,7 @@ int cs35l56_init(struct cs35l56_private *cs35l56)if (!cs35l56->base.reset_gpio) {dev_dbg (cs35l56->base.dev,"No reset gpio: using soft reset\n" ); cs35l56->soft_resetting = true; -cs35l56_system_reset (cs35l56, !!cs35l56->sdw_peripheral); +cs35l56_system_reset (&cs35l56->base, !!cs35l56->sdw_peripheral);if (cs35l56->sdw_peripheral) {/* Keep alive while we wait for re-enumeration */ pm_runtime_get_noresume (cs35l56->base.dev);
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 11/13 ALSA: hda: Fix missing header dependencies
In reply to Richard FitzgeraldAdd #includes of dependencies into hda_auto_parser.h and hda_generic.h
hda_auto_parser.h uses definitions in hda_local.h.
hda_generic.h uses definitions in hda_local.h and hda_auto_parser.h. It also references struct hda_jack_callback, but only as a pointer. This has been forward-declared so hda_jack.h only needs to be included in source that actually uses it.
--- sound/pci/hda/hda_auto_parser.h | 2 ++ sound/pci/hda/hda_generic.h | 3 +++ 2 files changed, 5 insertions(+)
sound/pci/hda/hda_auto_parser.h +2 -0
@@ -8,6 +8,8 @@#ifndef __SOUND_HDA_AUTO_PARSER_H#define __SOUND_HDA_AUTO_PARSER_H +#include "hda_local.h" +/* * Helper for automatic pin configuration */
sound/pci/hda/hda_generic.h +3 -0
@@ -9,6 +9,9 @@#define __SOUND_HDA_GENERIC_H#include <linux/leds.h> +#include "hda_auto_parser.h" + +struct hda_jack_callback ;/* table entry for multi-io paths */ struct hda_multi_io {
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 12/13 ALSA: hda: Add mute_hook to hda_component
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
Add a hook into hda_component to allow the amplifier mute to be controlled by the owning HDA codec driver.
--- sound/pci/hda/hda_component.h | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/hda_component.h +1 -0
@@ -16,4 +16,5 @@ struct hda_component {char name[HDA_MAX_NAME_SIZE ];struct hda_codec *codec;void (*playback_hook)(struct device *dev,int action); +void (*mute_hook)(struct device *dev,bool mute); };
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 8/13 ASoC: cs35l56: Pass correct pointer to cs35l56_irq()
In reply to Richard Fitzgeraldcs35l56_irq() was changed to take a cs35l56_base* but the code in cs35l56-sdw was still passing it a cs35l56_private*.
--- sound/soc/codecs/cs35l56-sdw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs35l56-sdw.c +1 -1
@@ -230,7 +230,7 @@ static void cs35l56_sdw_irq_work(struct work_struct *work) struct cs35l56_private, sdw_irq_work); -cs35l56_irq (-1 , cs35l56); +cs35l56_irq (-1 , &cs35l56->base);/* unmask interrupts */ if (!cs35l56->sdw_irq_no_unmask)
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainercover ALSA: hda: Adding support for CS35L56 on HDA systems
This set of patches adds support for using the CS35L56 boosted smart amplifier on HDA systems. In these systems the CS35L56 audio is routed through a HDA-to-I2S bridge codec.
This doesn't include the changes to the Realtek driver to actually hook up the CS35L56 driver, because we don't yet have the QUIRK IDs to associate it with. But we want to publish the driver now so that it is available for bringing up hardware with the CS35L56.
The first 10 patches are moving code out of the ASoC driver and into the shared library so that it can be shared with the HDA driver.
Patch #11 fixes missing #includes in the HDA headers so that the CS35L56 driver doesn't have to #include headers that it doesn't use.
Finally, #12 and #13 actually add the support for CS35L56 on HDA.
Richard Fitzgerald (5):
ASoC: cs35l56: Move runtime suspend/resume to shared library
ASoC: cs35l56: Move cs_dsp init into shared library
ASoC: cs35l56: Move part of cs35l56_init() to shared library
ASoC: cs35l56: Pass correct pointer to cs35l56_irq()
ALSA: hda: Fix missing header dependencies
Simon Trimmer (8):
ASoC: cs35l56: Move shared data into a common data structure
ASoC: cs35l56: Make cs35l56_system_reset() code more generic
ASoC: cs35l56: Convert utility functions to use common data structure
ASoC: cs35l56: Move utility functions to shared file
ASoC: cs35l56: Make common function for control port wait
ASoC: cs35l56: Make a common function to shutdown the DSP
ALSA: hda: Add mute_hook to hda_component
ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier
include/sound/cs35l56.h | 29 +- sound/pci/hda/Kconfig | 31 + sound/pci/hda/Makefile | 6 + sound/pci/hda/cs35l56_hda.c | 995 ++++++++++++++++++++++++++++++ sound/pci/hda/cs35l56_hda.h | 48 ++ sound/pci/hda/cs35l56_hda_i2c.c | 69 +++ sound/pci/hda/cs35l56_hda_spi.c | 68 ++ sound/pci/hda/hda_auto_parser.h | 2 + sound/pci/hda/hda_component.h | 1 + sound/pci/hda/hda_generic.h | 3 + sound/soc/codecs/cs35l56-i2c.c | 14 +- sound/soc/codecs/cs35l56-sdw.c | 72 +-- sound/soc/codecs/cs35l56-shared.c | 459 +++++++++++++- sound/soc/codecs/cs35l56-spi.c | 10 +- sound/soc/codecs/cs35l56.c | 648 ++++--------------- sound/soc/codecs/cs35l56.h | 15 +- 16 files changed, 1878 insertions(+), 592 deletions(-) create mode 100644 sound/pci/hda/cs35l56_hda.c create mode 100644 sound/pci/hda/cs35l56_hda.h create mode 100644 sound/pci/hda/cs35l56_hda_i2c.c create mode 100644 sound/pci/hda/cs35l56_hda_spi.c
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 2/13 ASoC: cs35l56: Make cs35l56_system_reset() code more generic
From: Simon Trimmer <[email protected]>
The function can be more easily reused in HDA if the tracking of whether a soft reset is being performed and whether the device is connected to a SoundWire bus is moved out of the function.
--- sound/soc/codecs/cs35l56.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/codecs/cs35l56.c +6 -6
@@ -805,10 +805,8 @@ static const struct reg_sequence cs35l56_system_reset_seq[] = { REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_SYSTEM_RESET), }; -static void cs35l56_system_reset (struct cs35l56_private *cs35l56) +static void cs35l56_system_reset (struct cs35l56_private *cs35l56,bool is_soundwire) { - cs35l56->soft_resetting = true; -/* * Must enter cache-only first so there can't be any more register * accesses other than the controlled system reset sequence below.
@@ -819,7 +817,7 @@ static void cs35l56_system_reset(struct cs35l56_private *cs35l56) ARRAY_SIZE(cs35l56_system_reset_seq));/* On SoundWire the registers won't be accessible until it re-enumerates. */ -if (cs35l56->sdw_peripheral) +if (is_soundwire)return ;usleep_range (CS35L56_CONTROL_PORT_READY_US ,CS35L56_CONTROL_PORT_READY_US +400 );
@@ -886,7 +884,8 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56)init_completion (&cs35l56->init_completion); -cs35l56_system_reset (cs35l56); + cs35l56->soft_resetting = true; +cs35l56_system_reset (cs35l56, !!cs35l56->sdw_peripheral);if (cs35l56->sdw_peripheral) {/*
@@ -1550,7 +1549,8 @@ int cs35l56_init(struct cs35l56_private *cs35l56)if (!cs35l56->base.reset_gpio) {dev_dbg (cs35l56->base.dev,"No reset gpio: using soft reset\n" ); -cs35l56_system_reset (cs35l56); + cs35l56->soft_resetting = true; +cs35l56_system_reset (cs35l56, !!cs35l56->sdw_peripheral);if (cs35l56->sdw_peripheral) {/* Keep alive while we wait for re-enumeration */ pm_runtime_get_noresume (cs35l56->base.dev);
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 9/13 ASoC: cs35l56: Make common function for control port wait
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
Move the waits for CS35L56_CONTROL_PORT_READY_US into a common function, and also allow a wider range of allowed wait times.
--- include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56-shared.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-)
include/sound/cs35l56.h +1 -0
@@ -275,6 +275,7 @@ extern const unsigned int cs35l56_tx_input_values[CS35L56_NUM_INPUT_SRC];void cs35l56_reread_firmware_registers (struct cs35l56_base *cs35l56_base);int cs35l56_mbox_send (struct cs35l56_base *cs35l56_base,unsigned int command);int cs35l56_wait_for_firmware_boot (struct cs35l56_base *cs35l56_base); +void cs35l56_wait_control_port_ready (void );void cs35l56_wait_min_reset_pulse (void );void cs35l56_system_reset (struct cs35l56_base *cs35l56_base,bool is_soundwire);int cs35l56_irq_request (struct cs35l56_base *cs35l56_base,int irq);
sound/soc/codecs/cs35l56-shared.c +10 -6
@@ -249,6 +249,13 @@ int cs35l56_wait_for_firmware_boot(struct cs35l56_base *cs35l56_base) }EXPORT_SYMBOL_NS_GPL (cs35l56_wait_for_firmware_boot,SND_SOC_CS35L56_SHARED ); +void cs35l56_wait_control_port_ready (void ) +{ +/* Wait for control port to be ready (datasheet tIRS). */ +usleep_range (CS35L56_CONTROL_PORT_READY_US ,2 *CS35L56_CONTROL_PORT_READY_US ); +} +EXPORT_SYMBOL_NS_GPL (cs35l56_wait_control_port_ready,SND_SOC_CS35L56_SHARED ); +void cs35l56_wait_min_reset_pulse (void ) {/* Satisfy minimum reset pulse width spec */
@@ -275,7 +282,7 @@ void cs35l56_system_reset(struct cs35l56_base *cs35l56_base, bool is_soundwire)if (is_soundwire)return ; -usleep_range (CS35L56_CONTROL_PORT_READY_US ,CS35L56_CONTROL_PORT_READY_US +400 ); +cs35l56_wait_control_port_ready ();regcache_cache_only (cs35l56_base->regmap, false); }EXPORT_SYMBOL_NS_GPL (cs35l56_system_reset,SND_SOC_CS35L56_SHARED );
@@ -486,8 +493,7 @@ int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_sou cs35l56_hibernate_wake_seq, ARRAY_SIZE(cs35l56_hibernate_wake_seq)); -usleep_range (CS35L56_CONTROL_PORT_READY_US , -CS35L56_CONTROL_PORT_READY_US +400 ); +cs35l56_wait_control_port_ready (); } out_sync:
@@ -561,9 +567,7 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base)if (!cs35l56_base->reset_gpio)regmap_read (cs35l56_base->regmap,CS35L56_DSP_VIRTUAL1_MBOX_1 , &devid); -/* Wait for control port to be ready (datasheet tIRS). */ -usleep_range (CS35L56_CONTROL_PORT_READY_US , -CS35L56_CONTROL_PORT_READY_US +400 ); +cs35l56_wait_control_port_ready ();/* * The HALO_STATE register is in different locations on Ax and B0
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 7/13 ASoC: cs35l56: Move part of cs35l56_init() to shared library
In reply to Richard FitzgeraldPart of the initialization code in cs35l56_init() can be re-used by the HDA driver so move it into a new function in the shared library.
--- include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56-shared.c | 79 +++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l56.c | 71 +-------------------------- 3 files changed, 82 insertions(+), 69 deletions(-)
include/sound/cs35l56.h +1 -0
@@ -283,6 +283,7 @@ int cs35l56_is_fw_reload_needed(struct cs35l56_base *cs35l56_base);int cs35l56_runtime_suspend_common (struct cs35l56_base *cs35l56_base);int cs35l56_runtime_resume_common (struct cs35l56_base *cs35l56_base,bool is_soundwire);void cs35l56_init_cs_dsp (struct cs35l56_base *cs35l56_base,struct cs_dsp *cs_dsp); +int cs35l56_hw_init (struct cs35l56_base *cs35l56_base);int cs35l56_get_bclk_freq_id (unsigned int freq);void cs35l56_fill_supply_names (struct regulator_bulk_data *data);
sound/soc/codecs/cs35l56-shared.c +79 -0
85 lines not on this page · raw message
sound/soc/codecs/cs35l56.c +2 -69
90 lines not on this page · raw message
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 6/13 ASoC: cs35l56: Move cs_dsp init into shared library
In reply to Richard FitzgeraldMove the code that initialized the struct cs_dsp members into the shared library so that the HDA driver can use it.
--- include/sound/cs35l56.h | 2 +- sound/soc/codecs/cs35l56-shared.c | 18 ++++++++++++++++-- sound/soc/codecs/cs35l56.c | 11 +---------- 3 files changed, 18 insertions(+), 13 deletions(-)
include/sound/cs35l56.h +1 -1
@@ -269,7 +269,6 @@ extern struct regmap_config cs35l56_regmap_i2c;extern struct regmap_config cs35l56_regmap_spi;extern struct regmap_config cs35l56_regmap_sdw; -extern const struct cs_dsp_region cs35l56_dsp1_regions[CS35L56_NUM_DSP_REGIONS ];extern const char *const cs35l56_tx_input_texts[CS35L56_NUM_INPUT_SRC ];extern const unsigned int cs35l56_tx_input_values[CS35L56_NUM_INPUT_SRC ];
@@ -283,6 +282,7 @@ irqreturn_t cs35l56_irq(int irq, void *data);int cs35l56_is_fw_reload_needed (struct cs35l56_base *cs35l56_base);int cs35l56_runtime_suspend_common (struct cs35l56_base *cs35l56_base);int cs35l56_runtime_resume_common (struct cs35l56_base *cs35l56_base,bool is_soundwire); +void cs35l56_init_cs_dsp (struct cs35l56_base *cs35l56_base,struct cs_dsp *cs_dsp);int cs35l56_get_bclk_freq_id (unsigned int freq);void cs35l56_fill_supply_names (struct regulator_bulk_data *data);
sound/soc/codecs/cs35l56-shared.c +16 -2
@@ -526,14 +526,28 @@ int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_sou }EXPORT_SYMBOL_NS_GPL (cs35l56_runtime_resume_common,SND_SOC_CS35L56_SHARED ); -const struct cs_dsp_region cs35l56_dsp1_regions[] = { +static const struct cs_dsp_region cs35l56_dsp1_regions[] = { { .type =WMFW_HALO_PM_PACKED , .base =CS35L56_DSP1_PMEM_0 }, { .type =WMFW_HALO_XM_PACKED , .base =CS35L56_DSP1_XMEM_PACKED_0 }, { .type =WMFW_HALO_YM_PACKED , .base =CS35L56_DSP1_YMEM_PACKED_0 }, { .type =WMFW_ADSP2_XM , .base =CS35L56_DSP1_XMEM_UNPACKED24_0 }, { .type =WMFW_ADSP2_YM , .base =CS35L56_DSP1_YMEM_UNPACKED24_0 }, }; -EXPORT_SYMBOL_NS_GPL (cs35l56_dsp1_regions,SND_SOC_CS35L56_SHARED ); + +void cs35l56_init_cs_dsp (struct cs35l56_base *cs35l56_base,struct cs_dsp *cs_dsp) +{ + cs_dsp->num =1 ; + cs_dsp->type =WMFW_HALO ; + cs_dsp->rev =0 ; + cs_dsp->dev = cs35l56_base->dev; + cs_dsp->regmap = cs35l56_base->regmap; + cs_dsp->base =CS35L56_DSP1_CORE_BASE ; + cs_dsp->base_sysinfo =CS35L56_DSP1_SYS_INFO_ID ; + cs_dsp->mem = cs35l56_dsp1_regions; + cs_dsp->num_mems =ARRAY_SIZE (cs35l56_dsp1_regions); + cs_dsp->no_core_startstop = true; +} +EXPORT_SYMBOL_NS_GPL (cs35l56_init_cs_dsp,SND_SOC_CS35L56_SHARED );static const u32 cs35l56_bclk_valid_for_pll_freq_table[] = { [0x0C ] =128000 ,
sound/soc/codecs/cs35l56.c +1 -10
@@ -1019,18 +1019,9 @@ static int cs35l56_dsp_init(struct cs35l56_private *cs35l56)INIT_WORK (&cs35l56->dsp_work, cs35l56_dsp_work); dsp = &cs35l56->dsp; +cs35l56_init_cs_dsp (&cs35l56->base, &dsp->cs_dsp); dsp->part ="cs35l56" ; - dsp->cs_dsp.num =1 ; - dsp->cs_dsp.type =WMFW_HALO ; - dsp->cs_dsp.rev =0 ; dsp->fw =12 ; - dsp->cs_dsp.dev = cs35l56->base.dev; - dsp->cs_dsp.regmap = cs35l56->base.regmap; - dsp->cs_dsp.base =CS35L56_DSP1_CORE_BASE ; - dsp->cs_dsp.base_sysinfo =CS35L56_DSP1_SYS_INFO_ID ; - dsp->cs_dsp.mem = cs35l56_dsp1_regions; - dsp->cs_dsp.num_mems =ARRAY_SIZE (cs35l56_dsp1_regions); - dsp->cs_dsp.no_core_startstop = true; dsp->wmfw_optional = true;dev_dbg (cs35l56->base.dev,"DSP system name: '%s'\n" , dsp->system_name);
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 4/13 ASoC: cs35l56: Move utility functions to shared file
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
Move the cs35l56 utility functions into the shared file so they are available for use in HDA.
--- include/sound/cs35l56.h | 7 + sound/soc/codecs/cs35l56-shared.c | 208 ++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l56.c | 203 ----------------------------- 3 files changed, 215 insertions(+), 203 deletions(-)
include/sound/cs35l56.h +7 -0
@@ -274,6 +274,13 @@ extern const char * const cs35l56_tx_input_texts[CS35L56_NUM_INPUT_SRC];extern const unsigned int cs35l56_tx_input_values[CS35L56_NUM_INPUT_SRC ];void cs35l56_reread_firmware_registers (struct cs35l56_base *cs35l56_base); +int cs35l56_mbox_send (struct cs35l56_base *cs35l56_base,unsigned int command); +int cs35l56_wait_for_firmware_boot (struct cs35l56_base *cs35l56_base); +void cs35l56_wait_min_reset_pulse (void ); +void cs35l56_system_reset (struct cs35l56_base *cs35l56_base,bool is_soundwire); +int cs35l56_irq_request (struct cs35l56_base *cs35l56_base,int irq); +irqreturn_t cs35l56_irq (int irq,void *data); +int cs35l56_is_fw_reload_needed (struct cs35l56_base *cs35l56_base);int cs35l56_get_bclk_freq_id (unsigned int freq);void cs35l56_fill_supply_names (struct regulator_bulk_data *data);
sound/soc/codecs/cs35l56-shared.c +208 -0
214 lines not on this page · raw message
sound/soc/codecs/cs35l56.c +0 -203
227 lines not on this page · raw message
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 10/13 ASoC: cs35l56: Make a common function to shutdown the DSP
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
Move issuing of a CS35L56_MBOX_CMD_SHUTDOWN command and then waiting for the DSP to reach CS35L56_HALO_STATE_SHUTDOWN in the register appropriate for the hardware revision into a common function.
--- include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56-shared.c | 26 ++++++++++++++++++++++++++ sound/soc/codecs/cs35l56.c | 17 +---------------- 3 files changed, 28 insertions(+), 16 deletions(-)
include/sound/cs35l56.h +1 -0
@@ -274,6 +274,7 @@ extern const unsigned int cs35l56_tx_input_values[CS35L56_NUM_INPUT_SRC];void cs35l56_reread_firmware_registers (struct cs35l56_base *cs35l56_base);int cs35l56_mbox_send (struct cs35l56_base *cs35l56_base,unsigned int command); +int cs35l56_firmware_shutdown (struct cs35l56_base *cs35l56_base);int cs35l56_wait_for_firmware_boot (struct cs35l56_base *cs35l56_base);void cs35l56_wait_control_port_ready (void );void cs35l56_wait_min_reset_pulse (void );
sound/soc/codecs/cs35l56-shared.c +26 -0
@@ -218,6 +218,32 @@ int cs35l56_mbox_send(struct cs35l56_base *cs35l56_base, unsigned int command) }EXPORT_SYMBOL_NS_GPL (cs35l56_mbox_send,SND_SOC_CS35L56_SHARED ); +int cs35l56_firmware_shutdown (struct cs35l56_base *cs35l56_base) +{ +int ret; +unsigned int reg; +unsigned int val; + + ret =cs35l56_mbox_send (cs35l56_base,CS35L56_MBOX_CMD_SHUTDOWN ); +if (ret) +return ret; + +if (cs35l56_base->rev <CS35L56_REVID_B0 ) + reg =CS35L56_DSP1_PM_CUR_STATE_A1 ; +else + reg =CS35L56_DSP1_PM_CUR_STATE ; + + ret =regmap_read_poll_timeout (cs35l56_base->regmap, reg, + val, (val ==CS35L56_HALO_STATE_SHUTDOWN ), +CS35L56_HALO_STATE_POLL_US , +CS35L56_HALO_STATE_TIMEOUT_US ); +if (ret <0 ) +dev_err (cs35l56_base->dev,"Failed to poll PM_CUR_STATE to 1 is %d (ret %d)\n" , + val, ret); +return ret; +} +EXPORT_SYMBOL_NS_GPL (cs35l56_firmware_shutdown,SND_SOC_CS35L56_SHARED ); +int cs35l56_wait_for_firmware_boot (struct cs35l56_base *cs35l56_base) {unsigned int reg;
sound/soc/codecs/cs35l56.c +1 -16
@@ -676,8 +676,6 @@ static void cs35l56_secure_patch(struct cs35l56_private *cs35l56)static void cs35l56_patch (struct cs35l56_private *cs35l56) { -unsigned int reg; -unsigned int val;int ret;/*
@@ -694,23 +692,10 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56)flush_work (&cs35l56->sdw_irq_work); } - ret =cs35l56_mbox_send (&cs35l56->base,CS35L56_MBOX_CMD_SHUTDOWN ); + ret =cs35l56_firmware_shutdown (&cs35l56->base);if (ret) goto err; -if (cs35l56->base.rev <CS35L56_REVID_B0 ) - reg =CS35L56_DSP1_PM_CUR_STATE_A1 ; -else - reg =CS35L56_DSP1_PM_CUR_STATE ; - - ret =regmap_read_poll_timeout (cs35l56->base.regmap, reg, - val, (val ==CS35L56_HALO_STATE_SHUTDOWN ), -CS35L56_HALO_STATE_POLL_US , -CS35L56_HALO_STATE_TIMEOUT_US ); -if (ret <0 ) -dev_err (cs35l56->base.dev,"Failed to poll PM_CUR_STATE to 1 is %d (ret %d)\n" , - val, ret); -/* Use wm_adsp to load and apply the firmware patch and coefficient files */ ret =wm_adsp_power_up (&cs35l56->dsp);if (ret) {
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 1/13 ASoC: cs35l56: Move shared data into a common data structure
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
The ASoC and HDA drivers have structures that contain some of the same information - instead of maintaining two locations for this data the drivers should share a common data structure as this will enable common utility functions to be created.
The first step is to move the location of these members in the ASoC driver.
--- include/sound/cs35l56.h | 15 +- sound/soc/codecs/cs35l56-i2c.c | 14 +- sound/soc/codecs/cs35l56-sdw.c | 66 ++--- sound/soc/codecs/cs35l56-shared.c | 6 +- sound/soc/codecs/cs35l56-spi.c | 10 +- sound/soc/codecs/cs35l56.c | 404 +++++++++++++++--------------- sound/soc/codecs/cs35l56.h | 13 +- 7 files changed, 269 insertions(+), 259 deletions(-)
include/sound/cs35l56.h +14 -1
@@ -252,6 +252,19 @@#define CS35L56_NUM_BULK_SUPPLIES 3#define CS35L56_NUM_DSP_REGIONS 5 +struct cs35l56_base { +struct device *dev; +struct regmap *regmap; +int irq; +struct mutex irq_lock; +u8 rev; +bool init_done; +bool fw_patched; +bool secured; +bool can_hibernate; +struct gpio_desc *reset_gpio; +}; +extern struct regmap_config cs35l56_regmap_i2c;extern struct regmap_config cs35l56_regmap_spi;extern struct regmap_config cs35l56_regmap_sdw;
@@ -260,7 +273,7 @@ extern const struct cs_dsp_region cs35l56_dsp1_regions[CS35L56_NUM_DSP_REGIONS];extern const char *const cs35l56_tx_input_texts[CS35L56_NUM_INPUT_SRC ];extern const unsigned int cs35l56_tx_input_values[CS35L56_NUM_INPUT_SRC ]; -void cs35l56_reread_firmware_registers (struct device *dev,struct regmap *regmap); +void cs35l56_reread_firmware_registers (struct cs35l56_base *cs35l56_base);int cs35l56_get_bclk_freq_id (unsigned int freq);void cs35l56_fill_supply_names (struct regulator_bulk_data *data);
sound/soc/codecs/cs35l56-i2c.c +7 -7
@@ -26,14 +26,14 @@ static int cs35l56_i2c_probe(struct i2c_client *client)if (!cs35l56)return -ENOMEM ; - cs35l56->dev = dev; - cs35l56->can_hibernate = true; + cs35l56->base.dev = dev; + cs35l56->base.can_hibernate = true;i2c_set_clientdata (client, cs35l56); - cs35l56->regmap =devm_regmap_init_i2c (client, regmap_config); -if (IS_ERR (cs35l56->regmap)) { - ret =PTR_ERR (cs35l56->regmap); -return dev_err_probe (cs35l56->dev, ret,"Failed to allocate register map\n" ); + cs35l56->base.regmap =devm_regmap_init_i2c (client, regmap_config); +if (IS_ERR (cs35l56->base.regmap)) { + ret =PTR_ERR (cs35l56->base.regmap); +return dev_err_probe (cs35l56->base.dev, ret,"Failed to allocate register map\n" ); } ret =cs35l56_common_probe (cs35l56);
@@ -42,7 +42,7 @@ static int cs35l56_i2c_probe(struct i2c_client *client) ret =cs35l56_init (cs35l56);if (ret ==0 ) - ret =cs35l56_irq_request (cs35l56, client->irq); + ret =cs35l56_irq_request (&cs35l56->base, client->irq);if (ret <0 )cs35l56_remove (cs35l56);
sound/soc/codecs/cs35l56-sdw.c +34 -32
213 lines not on this page · raw message
sound/soc/codecs/cs35l56-shared.c +3 -3
@@ -187,14 +187,14 @@ static const u32 cs35l56_firmware_registers[] = { CS35L56_MAIN_POSTURE_NUMBER, }; -void cs35l56_reread_firmware_registers (struct device *dev,struct regmap *regmap) +void cs35l56_reread_firmware_registers (struct cs35l56_base *cs35l56_base) {int i;unsigned int val;for (i =0 ; i <ARRAY_SIZE (cs35l56_firmware_registers); i++) { -regmap_read (regmap, cs35l56_firmware_registers[i], &val); -dev_dbg (dev,"%s: %d: %#x: %#x\n" , __func__, +regmap_read (cs35l56_base->regmap, cs35l56_firmware_registers[i], &val); +dev_dbg (cs35l56_base->dev,"%s: %d: %#x: %#x\n" , __func__, i, cs35l56_firmware_registers[i], val); } }
sound/soc/codecs/cs35l56-spi.c +5 -5
@@ -25,13 +25,13 @@ static int cs35l56_spi_probe(struct spi_device *spi)return -ENOMEM ;spi_set_drvdata (spi, cs35l56); - cs35l56->regmap =devm_regmap_init_spi (spi, regmap_config); -if (IS_ERR (cs35l56->regmap)) { - ret =PTR_ERR (cs35l56->regmap); + cs35l56->base.regmap =devm_regmap_init_spi (spi, regmap_config); +if (IS_ERR (cs35l56->base.regmap)) { + ret =PTR_ERR (cs35l56->base.regmap);return dev_err_probe (&spi->dev, ret,"Failed to allocate register map\n" ); } - cs35l56->dev = &spi->dev; + cs35l56->base.dev = &spi->dev; ret =cs35l56_common_probe (cs35l56);if (ret !=0 )
@@ -39,7 +39,7 @@ static int cs35l56_spi_probe(struct spi_device *spi) ret =cs35l56_init (cs35l56);if (ret ==0 ) - ret =cs35l56_irq_request (cs35l56, spi->irq); + ret =cs35l56_irq_request (&cs35l56->base, spi->irq);if (ret <0 )cs35l56_remove (cs35l56);
sound/soc/codecs/cs35l56.c +204 -200
1,035 lines not on this page · raw message
sound/soc/codecs/cs35l56.h +2 -11
@@ -32,26 +32,17 @@ struct sdw_slave;struct cs35l56_private {struct wm_adsp dsp;/* must be first member */ +struct cs35l56_base base;struct work_struct dsp_work;struct workqueue_struct *dsp_wq; -struct mutex irq_lock;struct snd_soc_component *component; -struct device *dev; -struct regmap *regmap;struct regulator_bulk_data supplies[CS35L56_NUM_BULK_SUPPLIES ]; -int irq;struct sdw_slave *sdw_peripheral; -u8 rev;struct work_struct sdw_irq_work; -bool secured;bool sdw_irq_no_unmask;bool soft_resetting; -bool init_done;bool sdw_attached; -bool fw_patched; -bool can_hibernate;struct completion init_completion; -struct gpio_desc *reset_gpio;u32 rx_mask;u32 tx_mask;
@@ -73,7 +64,7 @@ int cs35l56_system_resume_no_irq(struct device *dev);int cs35l56_system_resume_early (struct device *dev);int cs35l56_system_resume (struct device *dev);irqreturn_t cs35l56_irq (int irq,void *data); -int cs35l56_irq_request (struct cs35l56_private *cs35l56,int irq); +int cs35l56_irq_request (struct cs35l56_base *cs35l56_base,int irq);int cs35l56_common_probe (struct cs35l56_private *cs35l56);int cs35l56_init (struct cs35l56_private *cs35l56);void cs35l56_remove (struct cs35l56_private *cs35l56);
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH 5/13 ASoC: cs35l56: Move runtime suspend/resume to shared library
In reply to Richard FitzgeraldThe majority of runtime_suspend and runtime_resume handling doesn't have anything specific to the ASoC driver, so can be shared by the HDA driver. Move this code into the shared library.
--- include/sound/cs35l56.h | 2 + sound/soc/codecs/cs35l56-sdw.c | 4 +- sound/soc/codecs/cs35l56-shared.c | 118 +++++++++++++++++++++++++++++ sound/soc/codecs/cs35l56.c | 120 +----------------------------- sound/soc/codecs/cs35l56.h | 2 - 5 files changed, 126 insertions(+), 120 deletions(-)
include/sound/cs35l56.h +2 -0
@@ -281,6 +281,8 @@ void cs35l56_system_reset(struct cs35l56_base *cs35l56_base, bool is_soundwire);int cs35l56_irq_request (struct cs35l56_base *cs35l56_base,int irq);irqreturn_t cs35l56_irq (int irq,void *data);int cs35l56_is_fw_reload_needed (struct cs35l56_base *cs35l56_base); +int cs35l56_runtime_suspend_common (struct cs35l56_base *cs35l56_base); +int cs35l56_runtime_resume_common (struct cs35l56_base *cs35l56_base,bool is_soundwire);int cs35l56_get_bclk_freq_id (unsigned int freq);void cs35l56_fill_supply_names (struct regulator_bulk_data *data);
sound/soc/codecs/cs35l56-sdw.c +2 -2
@@ -424,7 +424,7 @@ static int __maybe_unused cs35l56_sdw_runtime_suspend(struct device *dev)if (!cs35l56->base.init_done)return 0 ; -return cs35l56_runtime_suspend (dev); +return cs35l56_runtime_suspend_common (&cs35l56->base); }static int __maybe_unused cs35l56_sdw_runtime_resume (struct device *dev)
@@ -441,7 +441,7 @@ static int __maybe_unused cs35l56_sdw_runtime_resume(struct device *dev)if (ret <0 )return ret; - ret =cs35l56_runtime_resume_common (cs35l56); + ret =cs35l56_runtime_resume_common (&cs35l56->base, true);if (ret)return ret;
sound/soc/codecs/cs35l56-shared.c +118 -0
124 lines not on this page · raw message
sound/soc/codecs/cs35l56.c +4 -116
143 lines not on this page · raw message
sound/soc/codecs/cs35l56.h +0 -2
@@ -55,8 +55,6 @@ struct cs35l56_private {extern const struct dev_pm_ops cs35l56_pm_ops_i2c_spi; -int cs35l56_runtime_suspend (struct device *dev); -int cs35l56_runtime_resume_common (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.30.2
Richard Fitzgerald
maintainerPATCH 13/13 ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier
In reply to Richard FitzgeraldFrom: Simon Trimmer <[email protected]>
Add a driver for the Cirrus Logic CS35L56 amplifier. This uses the same component binding API as the CS35L41 driver. This is not a standalone HDA device; it provides control of the CS35L56 for systems that use a combination of an HDA codec and CS35L56 amplifiers with audio routed through the HDA codec.
The CS35L56 combines a high-performance mono audio amplifier, Class-H tracking inductive boost converter, Halo Core(TM) DSP and a DC-DC boost converter supporting Class-H tracking.
Control interfaces are I2C or SPI through the standard Linux I2C or SPI bus framework.
Most chip functionality is controlled by on-board ROM firmware that is always running. Firmware patches can be applied by the driver in the form of a .wmfw file (firmware patch) and/or a .bin file (system tuning).
--- sound/pci/hda/Kconfig | 31 + sound/pci/hda/Makefile | 6 + sound/pci/hda/cs35l56_hda.c | 995 ++++++++++++++++++++++++++++++++ sound/pci/hda/cs35l56_hda.h | 48 ++ sound/pci/hda/cs35l56_hda_i2c.c | 69 +++ sound/pci/hda/cs35l56_hda_spi.c | 68 +++ 6 files changed, 1217 insertions(+) create mode 100644 sound/pci/hda/cs35l56_hda.c create mode 100644 sound/pci/hda/cs35l56_hda.h create mode 100644 sound/pci/hda/cs35l56_hda_i2c.c create mode 100644 sound/pci/hda/cs35l56_hda_spi.c
sound/pci/hda/Kconfig +31 -0
@@ -130,6 +130,37 @@ config SND_HDA_SCODEC_CS35L41_SPI comment "Set to Y if you want auto-loading the side codec driver" depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_SPI=m +config SND_HDA_SCODEC_CS35L56 + tristate + +config SND_HDA_SCODEC_CS35L56_I2C + tristate "Build CS35L56 HD-audio side codec support for I2C Bus" + depends on I2C + depends on ACPI || COMPILE_TEST + depends on SND_SOC + select CS_DSP + select SND_HDA_GENERIC + select SND_SOC_CS35L56_SHARED + select SND_HDA_SCODEC_CS35L56 + select SND_HDA_CS_DSP_CONTROLS + help + Say Y or M here to include CS35L56 amplifier support with + I2C control. + +config SND_HDA_SCODEC_CS35L56_SPI + tristate "Build CS35L56 HD-audio codec support for SPI Bus" + depends on SPI_MASTER + depends on ACPI || COMPILE_TEST + depends on SND_SOC + select CS_DSP + select SND_HDA_GENERIC + select SND_SOC_CS35L56_SHARED + select SND_HDA_SCODEC_CS35L56 + select SND_HDA_CS_DSP_CONTROLS + help + Say Y or M here to include CS35L56 amplifier support with + SPI control. + config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERIC
sound/pci/hda/Makefile +6 -0
@@ -31,6 +31,9 @@ snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o snd-hda-scodec-cs35l41-objs := cs35l41_hda.o snd-hda-scodec-cs35l41-i2c-objs := cs35l41_hda_i2c.o snd-hda-scodec-cs35l41-spi-objs := cs35l41_hda_spi.o +snd-hda-scodec-cs35l56-objs := cs35l56_hda.o +snd-hda-scodec-cs35l56-i2c-objs := cs35l56_hda_i2c.o +snd-hda-scodec-cs35l56-spi-objs := cs35l56_hda_spi.o snd-hda-cs-dsp-ctls-objs := hda_cs_dsp_ctl.o # common driver
@@ -55,6 +58,9 @@ obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o obj-$(CONFIG_SND_HDA_SCODEC_CS35L41) += snd-hda-scodec-cs35l41.o obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_I2C) += snd-hda-scodec-cs35l41-i2c.o obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_SPI) += snd-hda-scodec-cs35l41-spi.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L56) += snd-hda-scodec-cs35l56.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_I2C) += snd-hda-scodec-cs35l56-i2c.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_SPI) += snd-hda-scodec-cs35l56-spi.o obj-$(CONFIG_SND_HDA_CS_DSP_CONTROLS) += snd-hda-cs-dsp-ctls.o # this must be the last entry after codec drivers;
sound/pci/hda/cs35l56_hda.c new file +995 -0
995 lines not on this page · raw message
sound/pci/hda/cs35l56_hda.h new file +48 -0
48 lines not on this page · raw message
sound/pci/hda/cs35l56_hda_i2c.c new file +69 -0
69 lines not on this page · raw message
sound/pci/hda/cs35l56_hda_spi.c new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.30.2
Mark Brown
maintainerRe: [PATCH 08/13] ASoC: cs35l56: Pass correct pointer to cs35l56_irq()
In reply to Richard FitzgeraldQuoted 2 lines · Richard Fitzgerald
cs35l56_irq()was changed to take a cs35l56_base* but the code in cs35l56-sdw was still passing it a cs35l56_private*.
For bisection this should be squashed into the change it's fixing.
Richard Fitzgerald
maintainerRe: [PATCH 08/13] ASoC: cs35l56: Pass correct pointer to cs35l56_irq()
Quoted 5 lines · Mark Brown
Quoted 2 lines · Richard Fitzgerald
cs35l56_irq()was changed to take a cs35l56_base* but the code in cs35l56-sdw was still passing it a cs35l56_private*.For bisection this should be squashed into the change it's fixing.
Oh damn. I knew I had to do that and forgot.
Quoted 8 lines · Richard Fitzgerald
This set of patches adds support for using the CS35L56 boosted smart amplifier on HDA systems. In these systems the CS35L56 audio is routed through a HDA-to-I2S bridge codec.
This doesn't include the changes to the Realtek driver to actually hook up the CS35L56 driver, because we don't yet have the QUIRK IDs to associate it with. But we want to publish the driver now so that it is available for bringing up hardware with the CS35L56.
The ASoC bits look fine modulo the one issue I mentioned, with that fixed
Re: [PATCH 13/13] ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier
In reply to Richard FitzgeraldQuoted 480 lines · Richard Fitzgerald
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
From: Simon Trimmer <[email protected]>
Add a driver for the Cirrus Logic CS35L56 amplifier. This uses the same component binding API as the CS35L41 driver. This is not a standalone HDA device; it provides control of the CS35L56 for systems that use a combination of an HDA codec and CS35L56 amplifiers with audio routed through the HDA codec.
The CS35L56 combines a high-performance mono audio amplifier, Class-H tracking inductive boost converter, Halo Core(TM) DSP and a DC-DC boost converter supporting Class-H tracking.
Control interfaces are I2C or SPI through the standard Linux I2C or SPI bus framework.
Most chip functionality is controlled by on-board ROM firmware that is always running. Firmware patches can be applied by the driver in the form of a .wmfw file (firmware patch) and/or a .bin file (system tuning).
Signed-off-by Simon Trimmer <[email protected]>Signed-off-by Richard Fitzgerald <[email protected]>--- sound/pci/hda/Kconfig | 31 + sound/pci/hda/Makefile | 6 + sound/pci/hda/cs35l56_hda.c | 995 ++++++++++++++++++++++++++++++++ sound/pci/hda/cs35l56_hda.h | 48 ++ sound/pci/hda/cs35l56_hda_i2c.c | 69 +++ sound/pci/hda/cs35l56_hda_spi.c | 68 +++ 6 files changed, 1217 insertions(+) create mode 100644 sound/pci/hda/cs35l56_hda.c create mode 100644 sound/pci/hda/cs35l56_hda.h create mode 100644 sound/pci/hda/cs35l56_hda_i2c.c create mode 100644 sound/pci/hda/cs35l56_hda_spi.csound/pci/hda/Kconfig +31
-0@@ -130,6 +130,37 @@ config SND_HDA_SCODEC_CS35L41_SPI comment "Set to Y if you want auto-loading the side codec driver" depends on SND_HDA=y && SND_HDA_SCODEC_CS35L41_SPI=m +config SND_HDA_SCODEC_CS35L56 + tristate + +config SND_HDA_SCODEC_CS35L56_I2C + tristate "Build CS35L56 HD-audio side codec support for I2C Bus" + depends on I2C + depends on ACPI || COMPILE_TEST + depends on SND_SOC + select CS_DSP + select SND_HDA_GENERIC + select SND_SOC_CS35L56_SHARED + select SND_HDA_SCODEC_CS35L56 + select SND_HDA_CS_DSP_CONTROLS + help + Say Y or M here to include CS35L56 amplifier support with + I2C control. + +config SND_HDA_SCODEC_CS35L56_SPI + tristate "Build CS35L56 HD-audio codec support for SPI Bus" + depends on SPI_MASTER + depends on ACPI || COMPILE_TEST + depends on SND_SOC + select CS_DSP + select SND_HDA_GENERIC + select SND_SOC_CS35L56_SHARED + select SND_HDA_SCODEC_CS35L56 + select SND_HDA_CS_DSP_CONTROLS + help + Say Y or M here to include CS35L56 amplifier support with + SPI control. + config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERICsound/pci/hda/Makefile +6
-0@@ -31,6 +31,9 @@ snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o snd-hda-scodec-cs35l41-objs := cs35l41_hda.o snd-hda-scodec-cs35l41-i2c-objs := cs35l41_hda_i2c.o snd-hda-scodec-cs35l41-spi-objs := cs35l41_hda_spi.o +snd-hda-scodec-cs35l56-objs := cs35l56_hda.o +snd-hda-scodec-cs35l56-i2c-objs := cs35l56_hda_i2c.o +snd-hda-scodec-cs35l56-spi-objs := cs35l56_hda_spi.o snd-hda-cs-dsp-ctls-objs := hda_cs_dsp_ctl.o # common driver@@ -55,6 +58,9 @@ obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o obj-$(CONFIG_SND_HDA_SCODEC_CS35L41) += snd-hda-scodec-cs35l41.o obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_I2C) += snd-hda-scodec-cs35l41-i2c.o obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_SPI) += snd-hda-scodec-cs35l41-spi.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L56) += snd-hda-scodec-cs35l56.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_I2C) += snd-hda-scodec-cs35l56-i2c.o +obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_SPI) += snd-hda-scodec-cs35l56-spi.o obj-$(CONFIG_SND_HDA_CS_DSP_CONTROLS) += snd-hda-cs-dsp-ctls.o # this must be the last entry after codec drivers;sound/pci/hda/cs35l56_hda.c new file +372
-0@@ -0,0 +1,995 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// HDA audio driver for Cirrus Logic CS35L56 smart amp +// +// Copyright (C) 2023 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. +// + +#include <linux/acpi.h> +#include <linux/debugfs.h> +#include <linux/gpio/consumer.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <sound/core.h> +#include <sound/hda_codec.h> +#include <sound/tlv.h> +#include "cs35l56_hda.h" +#include "hda_component.h" +#include "hda_cs_dsp_ctl.h" +#include "hda_generic.h" + +/* +* The cs35l56_hda_dai_config[] reg sequence configures the device as +* ASP1_BCLK_FREQ = 3.072 MHz +* ASP1_RX_WIDTH = 32 cycles per slot, ASP1_TX_WIDTH = 32 cycles per slot, ASP1_FMT = I2S +* ASP1_DOUT_HIZ_CONTROL = Hi-Z during unused timeslots +* ASP1_RX_WL = 24 bits per sample +* ASP1_TX_WL = 24 bits per sample +* ASP1_RXn_EN 1..3 and ASP1_TXn_EN 1..4 disabled +*/ +static const struct reg_sequence cs35l56_hda_dai_config[] = { + {CS35L56_ASP1_CONTROL1 ,0x00000021 }, + {CS35L56_ASP1_CONTROL2 ,0x20200200 }, + {CS35L56_ASP1_CONTROL3 ,0x00000003 }, + {CS35L56_ASP1_DATA_CONTROL5 ,0x00000018 }, + {CS35L56_ASP1_DATA_CONTROL1 ,0x00000018 }, + {CS35L56_ASP1_ENABLES1 ,0x00000000 }, +}; + +static void cs35l56_hda_play (struct cs35l56_hda *cs35l56) +{ +unsigned int val; +int ret; + +pm_runtime_get_sync (cs35l56->base.dev); + ret =cs35l56_mbox_send (&cs35l56->base,CS35L56_MBOX_CMD_AUDIO_PLAY ); +if (ret ==0 ) { +/* Wait for firmware to enter PS0 power state */ + ret =regmap_read_poll_timeout (cs35l56->base.regmap, +CS35L56_TRANSDUCER_ACTUAL_PS , + val, (val ==CS35L56_PS0 ), +CS35L56_PS0_POLL_US , +CS35L56_PS0_TIMEOUT_US ); +if (ret) +dev_warn (cs35l56->base.dev,"PS0 wait failed: %d\n" , ret); + } +regmap_set_bits (cs35l56->base.regmap,CS35L56_ASP1_ENABLES1 , +BIT (CS35L56_ASP_RX1_EN_SHIFT ) |BIT (CS35L56_ASP_RX2_EN_SHIFT ) | + cs35l56->asp_tx_mask); + cs35l56->playing = true; +} + +static void cs35l56_hda_pause (struct cs35l56_hda *cs35l56) +{ + cs35l56->playing = false; +cs35l56_mbox_send (&cs35l56->base,CS35L56_MBOX_CMD_AUDIO_PAUSE ); +regmap_clear_bits (cs35l56->base.regmap,CS35L56_ASP1_ENABLES1 , +BIT (CS35L56_ASP_RX1_EN_SHIFT ) |BIT (CS35L56_ASP_RX2_EN_SHIFT ) | +BIT (CS35L56_ASP_TX1_EN_SHIFT ) |BIT (CS35L56_ASP_TX2_EN_SHIFT ) | +BIT (CS35L56_ASP_TX3_EN_SHIFT ) |BIT (CS35L56_ASP_TX4_EN_SHIFT )); + +pm_runtime_mark_last_busy (cs35l56->base.dev); +pm_runtime_put_autosuspend (cs35l56->base.dev); +} + +static void cs35l56_hda_playback_hook (struct device *dev,int action) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +dev_dbg (cs35l56->base.dev,"%s()%d: action: %d\n" , __func__, __LINE__, action); + +switch (action) { +case HDA_GEN_PCM_ACT_PREPARE : +if (cs35l56->playing) +break ; + +/* If we're suspended: flag that resume should start playback */ +if (cs35l56->suspended) { + cs35l56->playing = true; +break ; + } + +cs35l56_hda_play (cs35l56); +break ; +case HDA_GEN_PCM_ACT_CLEANUP : +if (!cs35l56->playing) +break ; + +cs35l56_hda_pause (cs35l56); +break ; +default : +break ; + } +} + +static void cs35l56_hda_mute_hook (struct device *dev,bool mute) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); +unsigned int val; + +if (mute) + val =CS35L56_MAIN_RENDER_USER_MUTE_MASK ; +else + val =0 ; + +regmap_write (cs35l56->base.regmap,CS35L56_MAIN_RENDER_USER_MUTE , val); +} + +static int cs35l56_hda_runtime_suspend (struct device *dev) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +if (cs35l56->cs_dsp.booted) +cs_dsp_stop (&cs35l56->cs_dsp); + +return cs35l56_runtime_suspend_common (&cs35l56->base); +} + +static int cs35l56_hda_runtime_resume (struct device *dev) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); +int ret; + + ret =cs35l56_runtime_resume_common (&cs35l56->base, false); +if (ret <0 ) +return ret; + +if (cs35l56->cs_dsp.booted) { + ret =cs_dsp_run (&cs35l56->cs_dsp); +if (ret) { +dev_dbg (cs35l56->base.dev,"%s: cs_dsp_run ret %d\n" , __func__, ret); + goto err; + } + } + +return 0 ; + +err: +cs35l56_mbox_send (&cs35l56->base,CS35L56_MBOX_CMD_ALLOW_AUTO_HIBERNATE ); +regmap_write (cs35l56->base.regmap,CS35L56_DSP_VIRTUAL1_MBOX_1 , +CS35L56_MBOX_CMD_HIBERNATE_NOW ); + +regcache_cache_only (cs35l56->base.regmap, true); + +return ret; +} + +static int cs35l56_hda_mixer_info (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_info *uinfo) +{ + uinfo->type =SNDRV_CTL_ELEM_TYPE_ENUMERATED ; + uinfo->count =1 ; + uinfo->value.enumerated.items =CS35L56_NUM_INPUT_SRC ; +if (uinfo->value.enumerated.item >=CS35L56_NUM_INPUT_SRC ) + uinfo->value.enumerated.item =CS35L56_NUM_INPUT_SRC -1 ; +strcpy (uinfo->value.enumerated.name, cs35l56_tx_input_texts[uinfo->value.enumerated.item]); + +return 0 ; +} + +static int cs35l56_hda_mixer_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct cs35l56_hda *cs35l56 = (struct cs35l56_hda *)kcontrol->private_data; +unsigned int reg_val; +int i; + +regmap_read (cs35l56->base.regmap, kcontrol->private_value, ®_val); + reg_val &= CS35L56_ASP_TXn_SRC_MASK; + +for (i =0 ; i <CS35L56_NUM_INPUT_SRC ; ++i) { +if (cs35l56_tx_input_values[i] == reg_val) { + ucontrol->value.enumerated.item[0 ] = i; +break ; + } + } + +return 0 ; +} + +static int cs35l56_hda_mixer_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct cs35l56_hda *cs35l56 = (struct cs35l56_hda *)kcontrol->private_data; +unsigned int item = ucontrol->value.enumerated.item[0 ]; +bool changed; + +if (item >=CS35L56_NUM_INPUT_SRC ) +return -EINVAL ; + +regmap_update_bits_check (cs35l56->base.regmap, kcontrol->private_value, +CS35L56_INPUT_MASK , cs35l56_tx_input_values[item], + &changed); + +return changed; +} + +static int cs35l56_hda_posture_info (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_info *uinfo) +{ + uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; + uinfo->count =1 ; + uinfo->value.integer.min =CS35L56_MAIN_POSTURE_MIN ; + uinfo->value.integer.max =CS35L56_MAIN_POSTURE_MAX ; +return 0 ; +} + +static int cs35l56_hda_posture_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct cs35l56_hda *cs35l56 = (struct cs35l56_hda *)kcontrol->private_data; +unsigned int pos; +int ret; + + ret =regmap_read (cs35l56->base.regmap,CS35L56_MAIN_POSTURE_NUMBER , &pos); +if (ret) +return ret; + + ucontrol->value.integer.value[0 ] = pos; + +return ret; +} + +static int cs35l56_hda_posture_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct cs35l56_hda *cs35l56 = (struct cs35l56_hda *)kcontrol->private_data; +unsigned long pos = ucontrol->value.integer.value[0 ]; +bool changed; +int ret; + +if ((pos <CS35L56_MAIN_POSTURE_MIN ) || + (pos >CS35L56_MAIN_POSTURE_MAX )) +return -EINVAL ; + + ret =regmap_update_bits_check (cs35l56->base.regmap, +CS35L56_MAIN_POSTURE_NUMBER , +CS35L56_MAIN_POSTURE_MASK , + pos, &changed); +if (ret) +return ret; + +return changed; +} + +static const struct { +const char *name; +unsigned int reg; +} cs35l56_hda_mixer_controls[] = { + {"ASP1 TX1 Source" ,CS35L56_ASP1TX1_INPUT }, + {"ASP1 TX2 Source" ,CS35L56_ASP1TX2_INPUT }, + {"ASP1 TX3 Source" ,CS35L56_ASP1TX3_INPUT }, + {"ASP1 TX4 Source" ,CS35L56_ASP1TX4_INPUT }, +}; + +static const DECLARE_TLV_DB_SCALE(cs35l56_hda_vol_tlv, -10000, 25, 0); + +static int cs35l56_hda_vol_info (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_info *uinfo) +{ + uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; + uinfo->count =1 ; + uinfo->value.integer.step =1 ; + uinfo->value.integer.min =0 ; + uinfo->value.integer.max =CS35L56_MAIN_RENDER_USER_VOLUME_MAX - +CS35L56_MAIN_RENDER_USER_VOLUME_MIN ; + +return 0 ; +} + +static int cs35l56_hda_vol_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct cs35l56_hda *cs35l56 = (struct cs35l56_hda *)kcontrol->private_data; +unsigned int raw_vol; +int vol; +int ret; + + ret =regmap_read (cs35l56->base.regmap,CS35L56_MAIN_RENDER_USER_VOLUME , &raw_vol); + +if (ret) +return ret; + + vol = (s16)(raw_vol &0xFFFF ); + vol >>=CS35L56_MAIN_RENDER_USER_VOLUME_SHIFT ; + +if (vol &BIT (CS35L56_MAIN_RENDER_USER_VOLUME_SIGNBIT )) + vol |= ~((int )(BIT (CS35L56_MAIN_RENDER_USER_VOLUME_SIGNBIT ) -1 )); + + ucontrol->value.integer.value[0 ] = vol -CS35L56_MAIN_RENDER_USER_VOLUME_MIN ; + +return 0 ; +} + +static int cs35l56_hda_vol_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct cs35l56_hda *cs35l56 = (struct cs35l56_hda *)kcontrol->private_data; +long vol = ucontrol->value.integer.value[0 ]; +unsigned int raw_vol; +bool changed; +int ret; + +if ((vol <0 ) || (vol > (CS35L56_MAIN_RENDER_USER_VOLUME_MAX - +CS35L56_MAIN_RENDER_USER_VOLUME_MIN ))) +return -EINVAL ; + + raw_vol = (vol +CS35L56_MAIN_RENDER_USER_VOLUME_MIN ) << +CS35L56_MAIN_RENDER_USER_VOLUME_SHIFT ; + + ret =regmap_update_bits_check (cs35l56->base.regmap, +CS35L56_MAIN_RENDER_USER_VOLUME , +CS35L56_MAIN_RENDER_USER_VOLUME_MASK , + raw_vol, &changed); +if (ret) +return ret; + +return changed; +} + +static void cs35l56_hda_create_controls (struct cs35l56_hda *cs35l56) +{ +struct snd_kcontrol_new ctl_template = { + .iface =SNDRV_CTL_ELEM_IFACE_MIXER , + .access =SNDRV_CTL_ELEM_ACCESS_READWRITE , + .info = cs35l56_hda_posture_info, + .get = cs35l56_hda_posture_get, + .put = cs35l56_hda_posture_put, + }; +char name[64 ]; +int i; + +snprintf (name,sizeof (name),"%s Posture Number" , cs35l56->amp_name); + ctl_template.name = name; + cs35l56->posture_ctl =snd_ctl_new1 (&ctl_template, cs35l56); +if (snd_ctl_add (cs35l56->codec->card, cs35l56->posture_ctl)) { +dev_err (cs35l56->base.dev,"Failed to add KControl: %s\n" , ctl_template.name); +return ; + } + +/* Mixer controls */ + ctl_template.info = cs35l56_hda_mixer_info; + ctl_template.get = cs35l56_hda_mixer_get; + ctl_template.put = cs35l56_hda_mixer_put; + +BUILD_BUG_ON (ARRAY_SIZE (cs35l56->mixer_ctl) !=ARRAY_SIZE (cs35l56_hda_mixer_controls)); + +for (i =0 ; i <ARRAY_SIZE (cs35l56_hda_mixer_controls); ++i) { +snprintf (name,sizeof (name),"%s %s" , cs35l56->amp_name, + cs35l56_hda_mixer_controls[i].name); + ctl_template.private_value = cs35l56_hda_mixer_controls[i].reg; + cs35l56->mixer_ctl[i] =snd_ctl_new1 (&ctl_template, cs35l56); +if (snd_ctl_add (cs35l56->codec->card, cs35l56->mixer_ctl[i])) { +dev_err (cs35l56->base.dev,"Failed to add KControl: %s\n" , + ctl_template.name); +return ; + } + } + + ctl_template.info = cs35l56_hda_vol_info;
sound/pci/hda/cs35l56_hda.c line 382
Quoted 10 lines
sound/pci/hda/cs35l56_hda.c new file +10
-0+ ctl_template.get = cs35l56_hda_vol_get; + ctl_template.put = cs35l56_hda_vol_put; + ctl_template.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |SNDRV_CTL_ELEM_ACCESS_TLV_READ ); + ctl_template.tlv.p = cs35l56_hda_vol_tlv; +snprintf (name,sizeof (name),"%s Speaker Playback Volume" , cs35l56->amp_name); + ctl_template.name = name; + cs35l56->volume_ctl =snd_ctl_new1 (&ctl_template, cs35l56); +if (snd_ctl_add (cs35l56->codec->card, cs35l56->volume_ctl)) { +dev_err (cs35l56->base.dev,"Failed to add KControl: %s\n" , ctl_template.name); +return ;
No need for return here.
Quoted 50 lines
sound/pci/hda/cs35l56_hda.c new file +50
-0+ } +} + +static void cs35l56_hda_remove_controls (struct cs35l56_hda *cs35l56) +{ +int i; + +for (i =ARRAY_SIZE (cs35l56->mixer_ctl) -1 ; i >=0 ; i--) +snd_ctl_remove (cs35l56->codec->card, cs35l56->mixer_ctl[i]); + +snd_ctl_remove (cs35l56->codec->card, cs35l56->posture_ctl); +snd_ctl_remove (cs35l56->codec->card, cs35l56->volume_ctl); +} + +static const struct cs_dsp_client_ops cs35l56_hda_client_ops = { + .control_remove = hda_cs_dsp_control_remove, +}; + +static int cs35l56_hda_request_firmware_file (struct cs35l56_hda *cs35l56, +const struct firmware **firmware,char **filename, +const char *dir,const char *system_name, +const char *amp_name, +const char *filetype) +{ +char *s, c; +int ret =0 ; + +if (system_name && amp_name) + *filename =kasprintf (GFP_KERNEL ,"%scs35l56%s-%02x-dsp1-misc-%s-%s.%s" , dir, + cs35l56->base.secured ?"s" :"" , cs35l56->base.rev, + system_name, amp_name, filetype); +else if (system_name) + *filename =kasprintf (GFP_KERNEL ,"%scs35l56%s-%02x-dsp1-misc-%s.%s" , dir, + cs35l56->base.secured ?"s" :"" , cs35l56->base.rev, + system_name, filetype); +else + *filename =kasprintf (GFP_KERNEL ,"%scs35l56%s-%02x-dsp1-misc.%s" , dir, + cs35l56->base.secured ?"s" :"" , cs35l56->base.rev, + filetype); + +if (!*filename) +return -ENOMEM ; + +/* +* Make sure that filename is lower-case and any non alpha-numeric +* characters except full stop and forward slash are replaced with +* hyphens. +*/ + s = *filename; +while (*s) {
sound/pci/hda/cs35l56_hda.c line 442
Quoted 10 lines
sound/pci/hda/cs35l56_hda.c new file +10
-0+ c = *s; +if (isalnum (c)) + *s =tolower (c); +else if (c !='.' && c !='/' ) + *s ='-' ; + s++; + } + + ret =firmware_request_nowarn (firmware, *filename, cs35l56->base.dev); +if (ret !=0 ) {
if (ret)
Quoted 213 lines
sound/pci/hda/cs35l56_hda.c new file +213
-0+dev_dbg (cs35l56->base.dev,"Failed to request '%s'\n" , *filename); +kfree (*filename); + *filename =NULL ; + }else { +dev_dbg (cs35l56->base.dev,"Found '%s'\n" , *filename); + } + +return ret; +} + +static const char cirrus_dir[] ="cirrus/" ; +static int cs35l56_hda_request_firmware_files (struct cs35l56_hda *cs35l56, +const struct firmware **wmfw_firmware, +char **wmfw_filename, +const struct firmware **coeff_firmware, +char **coeff_filename) +{ +const char *system_name = cs35l56->system_name; +const char *amp_name = cs35l56->amp_name; +int ret; + +if (system_name && amp_name) { +if (!cs35l56_hda_request_firmware_file (cs35l56, wmfw_firmware, wmfw_filename, + cirrus_dir, system_name, amp_name,"wmfw" )) { +cs35l56_hda_request_firmware_file (cs35l56, coeff_firmware, coeff_filename, + cirrus_dir, system_name, amp_name,"bin" ); +return 0 ; + } + } + +if (system_name) { +if (!cs35l56_hda_request_firmware_file (cs35l56, wmfw_firmware, wmfw_filename, + cirrus_dir, system_name,NULL ,"wmfw" )) { +if (amp_name) +cs35l56_hda_request_firmware_file (cs35l56, + coeff_firmware, coeff_filename, + cirrus_dir, system_name, + amp_name,"bin" ); +if (!*coeff_firmware) +cs35l56_hda_request_firmware_file (cs35l56, + coeff_firmware, coeff_filename, + cirrus_dir, system_name, +NULL ,"bin" ); +return 0 ; + } + } + + ret =cs35l56_hda_request_firmware_file (cs35l56, wmfw_firmware, wmfw_filename, + cirrus_dir,NULL ,NULL ,"wmfw" ); +if (!ret) { +cs35l56_hda_request_firmware_file (cs35l56, coeff_firmware, coeff_filename, + cirrus_dir,NULL ,NULL ,"bin" ); +return 0 ; + } + +/* When a firmware file is not found must still search for the coeff files */ +if (system_name) { +if (amp_name) +cs35l56_hda_request_firmware_file (cs35l56, coeff_firmware, coeff_filename, + cirrus_dir, system_name, amp_name,"bin" ); +if (!*coeff_firmware) +cs35l56_hda_request_firmware_file (cs35l56, coeff_firmware, coeff_filename, + cirrus_dir, system_name,NULL ,"bin" ); + } + +if (!*coeff_firmware) +cs35l56_hda_request_firmware_file (cs35l56, coeff_firmware, coeff_filename, + cirrus_dir,NULL ,NULL ,"bin" ); + +return 0 ; +} + +static void cs35l56_hda_add_dsp_controls (struct cs35l56_hda *cs35l56) +{ +struct hda_cs_dsp_ctl_info info; + + info.device_name = cs35l56->amp_name; + info.fw_type =HDA_CS_DSP_FW_MISC ; + info.card = cs35l56->codec->card; + +hda_cs_dsp_add_controls (&cs35l56->cs_dsp, &info); +} + +static int cs35l56_hda_fw_load (struct cs35l56_hda *cs35l56) +{ +const struct firmware *coeff_firmware =NULL ; +const struct firmware *wmfw_firmware =NULL ; +char *coeff_filename =NULL ; +char *wmfw_filename =NULL ; +int ret =0 ; + +mutex_lock (&cs35l56->base.irq_lock); +pm_runtime_get_sync (cs35l56->base.dev); + +/* +* When the device is running in secure mode the firmware files can +* only contain insecure tunings and therefore we do not need to +* shutdown the firmware to apply them and can use the lower cost +* reinit sequence instead. +*/ +if (!cs35l56->base.secured) { + ret =cs35l56_firmware_shutdown (&cs35l56->base); +if (ret) + goto err; + } + +cs35l56_hda_request_firmware_files (cs35l56, &wmfw_firmware, &wmfw_filename, + &coeff_firmware, &coeff_filename); + + ret =cs_dsp_power_up (&cs35l56->cs_dsp, wmfw_firmware, wmfw_filename, + coeff_firmware, coeff_filename,"misc" ); +if (ret) { +dev_dbg (cs35l56->base.dev,"%s: cs_dsp_power_up ret %d\n" , __func__, ret); + goto err; + } + +if (wmfw_filename) +dev_dbg (cs35l56->base.dev,"Loaded WMFW Firmware: %s\n" , wmfw_filename); + +if (coeff_filename) +dev_dbg (cs35l56->base.dev,"Loaded Coefficients: %s\n" , coeff_filename); + + ret =cs_dsp_run (&cs35l56->cs_dsp); +if (ret) { +dev_dbg (cs35l56->base.dev,"%s: cs_dsp_run ret %d\n" , __func__, ret); + goto err; + } + +if (cs35l56->base.secured) { + ret =cs35l56_mbox_send (&cs35l56->base,CS35L56_MBOX_CMD_AUDIO_REINIT ); +if (ret) + goto err; + }else { +/* Reset the device and wait for it to boot */ +cs35l56_system_reset (&cs35l56->base, false); + ret =cs35l56_wait_for_firmware_boot (&cs35l56->base); +if (ret) + goto err; + } + +/* Disable auto-hibernate so that runtime_pm has control */ + ret =cs35l56_mbox_send (&cs35l56->base,CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE ); +if (ret) + goto err; + +/* Re-read the values from the device after a firmware/cofficient download */ +cs35l56_reread_firmware_registers (&cs35l56->base); + +regcache_mark_dirty (cs35l56->base.regmap); +regcache_sync (cs35l56->base.regmap); + +regmap_clear_bits (cs35l56->base.regmap,CS35L56_PROTECTION_STATUS , +CS35L56_FIRMWARE_MISSING ); + cs35l56->base.fw_patched = true; +err: +pm_runtime_put (cs35l56->base.dev); +mutex_unlock (&cs35l56->base.irq_lock); + +return ret; +} + +static int cs35l56_hda_bind (struct device *dev,struct device *master,void *master_data) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); +struct hda_component *comps = master_data; +int ret; + +if (!comps || cs35l56->index <0 || cs35l56->index >=HDA_MAX_COMPONENTS ) +return -EINVAL ; + + comps = &comps[cs35l56->index]; +if (comps->dev) +return -EBUSY ; + + comps->dev = dev; + cs35l56->codec = comps->codec; +strscpy (comps->name,dev_name (dev),sizeof (comps->name)); + comps->playback_hook = cs35l56_hda_playback_hook; + comps->mute_hook = cs35l56_hda_mute_hook; + + ret =cs35l56_hda_fw_load (cs35l56); +if (ret) +return ret; + +cs35l56_hda_create_controls (cs35l56); +cs35l56_hda_add_dsp_controls (cs35l56); + +#if IS_ENABLED (CONFIG_SND_DEBUG ) + cs35l56->debugfs_root =debugfs_create_dir (dev_name (cs35l56->base.dev), sound_debugfs_root); +cs_dsp_init_debugfs (&cs35l56->cs_dsp, cs35l56->debugfs_root); +#endif + +dev_dbg (cs35l56->base.dev,"Bound\n" ); + +return 0 ; +} + +static void cs35l56_hda_unbind (struct device *dev,struct device *master,void *master_data) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); +struct hda_component *comps = master_data; + +cs35l56_hda_remove_controls (cs35l56); + +#if IS_ENABLED (CONFIG_SND_DEBUG ) +cs_dsp_cleanup_debugfs (&cs35l56->cs_dsp); +debugfs_remove_recursive (cs35l56->debugfs_root); +#endif + +cs_dsp_remove (&cs35l56->cs_dsp); + +if (comps[cs35l56->index].dev == dev) +memset (&comps[cs35l56->index],0 ,sizeof (*comps));
sound/pci/hda/cs35l56_hda.c line 665
Quoted 10 lines
sound/pci/hda/cs35l56_hda.c new file +10
-0+ +dev_dbg (cs35l56->base.dev,"Unbound\n" ); +} + +static const struct component_ops cs35l56_hda_comp_ops = { + .bind = cs35l56_hda_bind, + .unbind = cs35l56_hda_unbind, +}; + +static int __maybe_unused cs35l56_hda_system_suspend (struct device *dev)
You can get rid of __maybe_unused here if using SYSTEM_SLEEP_PM_OPS(). Same for the resume counterpart function.
Quoted 11 lines
sound/pci/hda/cs35l56_hda.c new file +11
-0+{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +if (cs35l56->playing) +cs35l56_hda_pause (cs35l56); + + cs35l56->suspended = true; + +/* +* The interrupt line is normally shared, but after we start suspending +* we can't check if our device is the source of an interrupt, and can't
sound/pci/hda/cs35l56_hda.c line 686
Quoted 10 lines
sound/pci/hda/cs35l56_hda.c new file +10
-0+* clear it. Prevent this race by temporarily disabling the parent irq +* until we reach _no_irq. +*/ +if (cs35l56->base.irq) +disable_irq (cs35l56->base.irq); + +return pm_runtime_force_suspend (dev); +} + +static int __maybe_unused cs35l56_hda_system_suspend_late (struct device *dev)
There shoud be no need of __maybe_unused here. Same for the resume counterpart function.
Quoted 6 lines
sound/pci/hda/cs35l56_hda.c new file +6
-0+{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +/* +* RESET is usually shared by all amps so it must not be asserted until +* all driver instances have done their suspend() stage.
sound/pci/hda/cs35l56_hda.c line 702
Quoted 10 lines
sound/pci/hda/cs35l56_hda.c new file +10
-0+*/ +if (cs35l56->base.reset_gpio) { +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 ); +cs35l56_wait_min_reset_pulse (); + } + +return 0 ; +} + +static int __maybe_unused cs35l56_hda_system_suspend_no_irq (struct device *dev)
Same here.
Quoted 130 lines
sound/pci/hda/cs35l56_hda.c new file +130
-0+{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +/* Handlers are now disabled so the parent IRQ can safely be re-enabled. */ +if (cs35l56->base.irq) +enable_irq (cs35l56->base.irq); + +return 0 ; +} + +static int __maybe_unused cs35l56_hda_system_resume_no_irq (struct device *dev) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +/* +* WAKE interrupts unmask if the CS35L56 hibernates, which can cause +* spurious interrupts, and the interrupt line is normally shared. +* We can't check if our device is the source of an interrupt, and can't +* clear it, until it has fully resumed. Prevent this race by temporarily +* disabling the parent irq until we complete resume(). +*/ +if (cs35l56->base.irq) +disable_irq (cs35l56->base.irq); + +return 0 ; +} + +static int __maybe_unused cs35l56_hda_system_resume_early (struct device *dev) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +/* Ensure a spec-compliant RESET pulse. */ +if (cs35l56->base.reset_gpio) { +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 ); +cs35l56_wait_min_reset_pulse (); + +/* Release shared RESET before drivers start resume(). */ +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,1 ); +cs35l56_wait_control_port_ready (); + } + +return 0 ; +} + +static int __maybe_unused cs35l56_hda_system_resume (struct device *dev) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); +int ret; + +/* Undo pm_runtime_force_suspend() before re-enabling the irq */ + ret =pm_runtime_force_resume (dev); +if (cs35l56->base.irq) +enable_irq (cs35l56->base.irq); + +if (ret) +return ret; + + cs35l56->suspended = false; + + ret =cs35l56_is_fw_reload_needed (&cs35l56->base); +dev_dbg (cs35l56->base.dev,"fw_reload_needed: %d\n" , ret); +if (ret >0 ) { + ret =cs35l56_hda_fw_load (cs35l56); +if (ret) +return ret; + } + +if (cs35l56->playing) +cs35l56_hda_play (cs35l56); + +return 0 ; +} + +static int cs35l56_hda_read_acpi (struct cs35l56_hda *cs35l56,int id) +{ +u32 values[HDA_MAX_COMPONENTS ]; +struct acpi_device *adev; +const char *property, *sub; +size_t nval; +int i, ret; + +/* +* ACPI_COMPANION isn't available when this driver was instantiated by +* the serial-multi-instantiate driver, so lookup the node by HID +*/ +if (!ACPI_COMPANION (cs35l56->base.dev)) { + adev =acpi_dev_get_first_match_dev ("CSC3556" ,NULL ,-1 ); +if (!adev) { +dev_err (cs35l56->base.dev,"Failed to find an ACPI device for %s\n" , +dev_name (cs35l56->base.dev)); +return -ENODEV ; + } +ACPI_COMPANION_SET (cs35l56->base.dev, adev); + } + + property ="cirrus,dev-index" ; + ret =device_property_count_u32 (cs35l56->base.dev, property); +if (ret <=0 ) + goto err; + +if (ret >ARRAY_SIZE (values)) { + ret = -EINVAL ; + goto err; + } + nval = ret; + + ret =device_property_read_u32_array (cs35l56->base.dev, property, values, nval); +if (ret) + goto err; + + cs35l56->index =-1 ; +for (i =0 ; i < nval; i++) { +if (values[i] == id) { + cs35l56->index = i; +break ; + } + } +if (cs35l56->index ==-1 ) { +dev_err (cs35l56->base.dev,"No index found in %s\n" , property); + ret = -ENODEV ; + goto err; + } + + sub =acpi_get_subsystem_id (ACPI_HANDLE (cs35l56->base.dev)); + +if (IS_ERR (sub)) { +/* If no ACPI SUB, return 0 and fallback to legacy firmware path, otherwise fail */ +if (PTR_ERR (sub) == -ENODATA ) +return 0 ; +else
sound/pci/hda/cs35l56_hda.c line 842
Quoted 10 lines
sound/pci/hda/cs35l56_hda.c new file +10
-0+return PTR_ERR (sub); + } + + cs35l56->system_name = sub; + + cs35l56->base.reset_gpio =devm_gpiod_get_index_optional (cs35l56->base.dev, +"reset" , + cs35l56->index, +GPIOD_OUT_LOW ); +if (IS_ERR (cs35l56->base.reset_gpio)) {
devm_gpiod_get_index_optional() can also return NULL.
Quoted 66 lines
sound/pci/hda/cs35l56_hda.c new file +66
-0+ ret =PTR_ERR (cs35l56->base.reset_gpio); + +/* +* If RESET is shared the first amp to probe will grab the reset +* line and reset all the amps +*/ +if (ret != -EBUSY ) +return dev_err_probe (cs35l56->base.dev, ret,"Failed to get reset GPIO\n" ); + +dev_info (cs35l56->base.dev,"Reset GPIO busy, assume shared reset\n" ); + cs35l56->base.reset_gpio =NULL ; + } + +return 0 ; + +err: +dev_err (cs35l56->base.dev,"Failed property %s: %d\n" , property, ret); + +return ret; +} + +int cs35l56_hda_common_probe (struct cs35l56_hda *cs35l56,int id) +{ +int ret; + +mutex_init (&cs35l56->base.irq_lock); +dev_set_drvdata (cs35l56->base.dev, cs35l56); + + ret =cs35l56_hda_read_acpi (cs35l56, id); +if (ret) { +dev_err_probe (cs35l56->base.dev, ret,"Platform not supported\n" ); + goto err; + } + + cs35l56->amp_name =devm_kasprintf (cs35l56->base.dev,GFP_KERNEL ,"AMP%d" , + cs35l56->index +1 ); +if (!cs35l56->amp_name) { + ret = -ENOMEM ; + goto err; + } + +cs35l56_init_cs_dsp (&cs35l56->base, &cs35l56->cs_dsp); + cs35l56->cs_dsp.client_ops = &cs35l56_hda_client_ops; + +if (cs35l56->base.reset_gpio) { +dev_dbg (cs35l56->base.dev,"Hard reset\n" ); + +/* +* The GPIOD_OUT_LOW to *_gpiod_get_*() will be ignored if the +* ACPI defines a different default state. So explicitly set low. +*/ +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 ); +cs35l56_wait_min_reset_pulse (); +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,1 ); + } + + ret =cs35l56_hw_init (&cs35l56->base); +if (ret <0 ) + goto err; + +/* Reset the device and wait for it to boot */ +cs35l56_system_reset (&cs35l56->base, false); + ret =cs35l56_wait_for_firmware_boot (&cs35l56->base); +if (ret) + goto err; +
sound/pci/hda/cs35l56_hda.c line 918
Quoted 10 lines
sound/pci/hda/cs35l56_hda.c new file +10
-0+regcache_mark_dirty (cs35l56->base.regmap); +regcache_sync (cs35l56->base.regmap); + +/* Disable auto-hibernate so that runtime_pm has control */ + ret =cs35l56_mbox_send (&cs35l56->base,CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE ); +if (ret) + goto err; + + ret =cs_dsp_halo_init (&cs35l56->cs_dsp); +if (ret !=0 ) {
if (ret)
Quoted 161 lines
sound/pci/hda/cs35l56_hda.c new file +77
-0+dev_err_probe (cs35l56->base.dev, ret,"cs_dsp_halo_init failed\n" ); + goto err; + } + +dev_dbg (cs35l56->base.dev,"DSP system name: '%s', amp name: '%s'\n" , + cs35l56->system_name, cs35l56->amp_name); + +/* Populate soft registers in the regmap cache */ +cs35l56_reread_firmware_registers (&cs35l56->base); + +regmap_multi_reg_write (cs35l56->base.regmap, cs35l56_hda_dai_config, +ARRAY_SIZE (cs35l56_hda_dai_config)); + +/* +* By default only enable one ASP1TXn, where n=amplifier index, +* This prevents multiple amps trying to drive the same slot. +*/ + cs35l56->asp_tx_mask =BIT (cs35l56->index); + +pm_runtime_set_autosuspend_delay (cs35l56->base.dev,3000 ); +pm_runtime_use_autosuspend (cs35l56->base.dev); +pm_runtime_set_active (cs35l56->base.dev); +pm_runtime_mark_last_busy (cs35l56->base.dev); +pm_runtime_enable (cs35l56->base.dev); + + ret =component_add (cs35l56->base.dev, &cs35l56_hda_comp_ops); +if (ret) { +dev_err (cs35l56->base.dev,"Register component failed: %d\n" , ret); + goto pm_err; + } + + cs35l56->base.init_done = true; + +return 0 ; + +pm_err: +pm_runtime_disable (cs35l56->base.dev); +err: +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 ); + +return ret; +} +EXPORT_SYMBOL_NS_GPL (cs35l56_hda_common_probe,SND_HDA_SCODEC_CS35L56 ); + +void cs35l56_hda_remove (struct device *dev) +{ +struct cs35l56_hda *cs35l56 =dev_get_drvdata (dev); + +pm_runtime_get_sync (cs35l56->base.dev); +pm_runtime_disable (cs35l56->base.dev); + +component_del (cs35l56->base.dev, &cs35l56_hda_comp_ops); + +kfree (cs35l56->system_name); +pm_runtime_put_noidle (cs35l56->base.dev); + +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 ); +} +EXPORT_SYMBOL_NS_GPL (cs35l56_hda_remove,SND_HDA_SCODEC_CS35L56 ); + +const struct dev_pm_ops cs35l56_hda_pm_ops = { + SET_RUNTIME_PM_OPS(cs35l56_hda_runtime_suspend, cs35l56_hda_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(cs35l56_hda_system_suspend, cs35l56_hda_system_resume) + LATE_SYSTEM_SLEEP_PM_OPS(cs35l56_hda_system_suspend_late, + cs35l56_hda_system_resume_early) +NOIRQ_SYSTEM_SLEEP_PM_OPS (cs35l56_hda_system_suspend_no_irq, + cs35l56_hda_system_resume_no_irq) +}; +EXPORT_SYMBOL_NS_GPL (cs35l56_hda_pm_ops,SND_HDA_SCODEC_CS35L56 ); + +MODULE_DESCRIPTION ("CS35L56 HDA Driver" ); +MODULE_IMPORT_NS (SND_HDA_CS_DSP_CONTROLS ); +MODULE_IMPORT_NS (SND_SOC_CS35L56_SHARED ); +MODULE_AUTHOR ("Richard Fitzgerald <[email protected]>" ); +MODULE_AUTHOR ("Simon Trimmer <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS (FW_CS_DSP );sound/pci/hda/cs35l56_hda.h new file +48
-0@@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only +* +* HDA audio driver for Cirrus Logic CS35L56 smart amp +* +* Copyright (C) 2023 Cirrus Logic, Inc. and +* Cirrus Logic International Semiconductor Ltd. +*/ + +#ifndef __CS35L56_HDA_H__ +#define __CS35L56_HDA_H__ + +#include <linux/device.h> +#include <linux/gpio/consumer.h> +#include <linux/firmware/cirrus/cs_dsp.h> +#include <linux/firmware/cirrus/wmfw.h> +#include <linux/regulator/consumer.h> +#include <sound/cs35l56.h> + +struct dentry ; + +struct cs35l56_hda { +struct cs35l56_base base; +struct hda_codec *codec; + +int index; +const char *system_name; +const char *amp_name; + +struct cs_dsp cs_dsp; +bool playing; +bool suspended; +u8 asp_tx_mask; + +struct snd_kcontrol *posture_ctl; +struct snd_kcontrol *volume_ctl; +struct snd_kcontrol *mixer_ctl[4 ]; + +#if IS_ENABLED (CONFIG_SND_DEBUG ) +struct dentry *debugfs_root; +#endif +}; + +extern const struct dev_pm_ops cs35l56_hda_pm_ops; + +int cs35l56_hda_common_probe (struct cs35l56_hda *cs35l56,int id); +void cs35l56_hda_remove (struct device *dev); + +#endif /*__CS35L56_HDA_H__*/ sound/pci/hda/cs35l56_hda_i2c.c new file +24
-0@@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// CS35L56 HDA audio driver I2C binding +// +// Copyright (C) 2023 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. + +#include <linux/i2c.h> +#include <linux/module.h> +#include <linux/regmap.h> + +#include "cs35l56_hda.h" + +static int cs35l56_hda_i2c_probe (struct i2c_client *clt) +{ +struct cs35l56_hda *cs35l56; +int ret; + + cs35l56 =devm_kzalloc (&clt->dev,sizeof (*cs35l56),GFP_KERNEL ); +if (!cs35l56) +return -ENOMEM ; + + cs35l56->base.dev = &clt->dev; + cs35l56->base.can_hibernate = true;
sound/pci/hda/cs35l56_hda_i2c.c line 34
Quoted 10 lines
sound/pci/hda/cs35l56_hda_i2c.c new file +10
-0+ cs35l56->base.regmap =devm_regmap_init_i2c (clt, &cs35l56_regmap_i2c); +if (IS_ERR (cs35l56->base.regmap)) { + ret =PTR_ERR (cs35l56->base.regmap); +dev_err (cs35l56->base.dev,"Failed to allocate register map: %d\n" , + ret); +return ret; + } + + ret =cs35l56_hda_common_probe (cs35l56, clt->addr); +if (ret !=0 )
if (ret)
Quoted 64 lines
sound/pci/hda/cs35l56_hda_i2c.c new file +35
-0+return ret; + ret =cs35l56_irq_request (&cs35l56->base, clt->irq); +if (ret <0 ) +cs35l56_hda_remove (cs35l56->base.dev); + +return ret; +} + +static void cs35l56_hda_i2c_remove (struct i2c_client *clt) +{ +cs35l56_hda_remove (&clt->dev); +} + +static const struct i2c_device_id cs35l56_hda_i2c_id[] = { + {"cs35l56-hda" ,0 }, + {} +}; + +static struct i2c_driver cs35l56_hda_i2c_driver = { + .driver = { + .name ="cs35l56-hda" , + .pm = &cs35l56_hda_pm_ops, + }, + .id_table = cs35l56_hda_i2c_id, + .probe_new = cs35l56_hda_i2c_probe, + .remove = cs35l56_hda_i2c_remove, +}; +module_i2c_driver (cs35l56_hda_i2c_driver); + +MODULE_DESCRIPTION ("HDA CS35L56 I2C driver" ); +MODULE_IMPORT_NS (SND_HDA_SCODEC_CS35L56 ); +MODULE_IMPORT_NS (SND_SOC_CS35L56_SHARED ); +MODULE_AUTHOR ("Richard Fitzgerald <[email protected]>" ); +MODULE_AUTHOR ("Simon Trimmer <[email protected]>" ); +MODULE_LICENSE ("GPL" );sound/pci/hda/cs35l56_hda_spi.c new file +23
-0@@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// CS35L56 HDA audio driver SPI binding +// +// Copyright (C) 2023 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. + +#include <linux/module.h> +#include <linux/regmap.h> +#include <linux/spi/spi.h> + +#include "cs35l56_hda.h" + +static int cs35l56_hda_spi_probe (struct spi_device *spi) +{ +struct cs35l56_hda *cs35l56; +int ret; + + cs35l56 =devm_kzalloc (&spi->dev,sizeof (*cs35l56),GFP_KERNEL ); +if (!cs35l56) +return -ENOMEM ; + + cs35l56->base.dev = &spi->dev;
sound/pci/hda/cs35l56_hda_spi.c line 33
Quoted 10 lines
sound/pci/hda/cs35l56_hda_spi.c new file +10
-0+ cs35l56->base.regmap =devm_regmap_init_spi (spi, &cs35l56_regmap_spi); +if (IS_ERR (cs35l56->base.regmap)) { + ret =PTR_ERR (cs35l56->base.regmap); +dev_err (cs35l56->base.dev,"Failed to allocate register map: %d\n" , + ret); +return ret; + } + + ret =cs35l56_hda_common_probe (cs35l56, spi->chip_select); +if (ret !=0 )
if (ret)
Quoted 38 lines
sound/pci/hda/cs35l56_hda_spi.c new file +35
-1+return ret; + ret =cs35l56_irq_request (&cs35l56->base, spi->irq); +if (ret <0 ) +cs35l56_hda_remove (cs35l56->base.dev); + +return ret; +} + +static void cs35l56_hda_spi_remove (struct spi_device *spi) +{ +cs35l56_hda_remove (&spi->dev); +} + +static const struct spi_device_id cs35l56_hda_spi_id[] = { + {"cs35l56-hda" ,0 }, + {} +}; + +static struct spi_driver cs35l56_hda_spi_driver = { + .driver = { + .name ="cs35l56-hda" , + .pm = &cs35l56_hda_pm_ops, + }, + .id_table = cs35l56_hda_spi_id, + .probe = cs35l56_hda_spi_probe, + .remove = cs35l56_hda_spi_remove, +}; +module_spi_driver (cs35l56_hda_spi_driver); + +MODULE_DESCRIPTION ("HDA CS35L56 SPI driver" ); +MODULE_IMPORT_NS (SND_HDA_SCODEC_CS35L56 ); +MODULE_IMPORT_NS (SND_SOC_CS35L56_SHARED ); +MODULE_AUTHOR ("Richard Fitzgerald <[email protected]>" ); +MODULE_AUTHOR ("Simon Trimmer <[email protected]>" ); +MODULE_LICENSE ("GPL" ); --2.30.2
Richard Fitzgerald
maintainerRe: [PATCH 13/13] ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier
Quoted 11 lines · On 26/5/23 05:40, [email protected] wrote:
Quoted 10 lines · Richard Fitzgerald
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
From: Simon Trimmer <[email protected]>
Add a driver for the Cirrus Logic CS35L56 amplifier. This uses the same component binding API as the CS35L41 driver. This is not a standalone HDA device; it provides control of the CS35L56 for systems that use a combination of an HDA codec and CS35L56 amplifiers with audio routed through the HDA codec.
<SNIP>
Quoted 9 lines
sound/pci/hda/cs35l56_hda.c line 842
Quoted 6 lines
sound/pci/hda/cs35l56_hda.c new file +6
-0+ + cs35l56->base.reset_gpio =devm_gpiod_get_index_optional (cs35l56->base.dev, +"reset" , + cs35l56->index, +GPIOD_OUT_LOW ); +if (IS_ERR (cs35l56->base.reset_gpio)) {
devm_gpiod_get_index_optional()can also return NULL.
Yes, that is expected. It's optional. It's not an error. In that case cs35l56->base.reset_gpio will already be NULL.
Quoted 20 lines
Quoted 20 lines
sound/pci/hda/cs35l56_hda.c new file +20
-0+ ret =PTR_ERR (cs35l56->base.reset_gpio); + +/* +* If RESET is shared the first amp to probe will grab the reset +* line and reset all the amps +*/ +if (ret != -EBUSY ) +return dev_err_probe (cs35l56->base.dev, ret,"Failed to get reset GPIO\n" ); + +dev_info (cs35l56->base.dev,"Reset GPIO busy, assume shared reset\n" ); + cs35l56->base.reset_gpio =NULL ; + } + +return 0 ; + +err: +dev_err (cs35l56->base.dev,"Failed property %s: %d\n" , property, ret); + +return ret; +}
Mark Brown
maintainerRe: [PATCH 13/13] ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier
In reply to [email protected]Quoted 8 lines · On Fri, May 26, 2023 at 04:40:23AM +0000, [email protected] wrote:
Quoted 7 lines · Richard Fitzgerald
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
From: Simon Trimmer <[email protected]>
Add a driver for the Cirrus Logic CS35L56 amplifier. This uses the same component binding API as the CS35L41 driver. This is not a standalone HDA device; it provides control of the CS35L56 for systems that use a
Please delete unneeded context from mails when replying. Doing this makes it much easier to find your reply in the message, helping ensure it won't be missed by people scrolling through the irrelevant quoted material.