Move the support for CS35L41 external boost to its shared library
for ASoC use.
This move resulted in cs35l41_hda_reg_sequence being removed,
and its steps were broken down into regmap writes or functions
from the library. And hardware configuration struct was unified
for its use in the shared lib.
While at it, some minor bugs were found and fixed it.
David Rhodes (2):
ASoC: cs35l41: Fix GPIO2 configuration
Documentation: devicetree: CS35l41 External Boost
Lucas Tanure (18):
ASoC: cs35l41: Fix max number of TX channels
ASoC: cs35l41: Fix DSP mbox start command and global enable order
ASoC: cs35l41: Remove unnecessary param
sound: cs35l41: Unify hardware configuration
sound: cs35l41: Check hw_config before using it
sound: cs35l41: Move cs35l41_gpio_config to shared lib
hda: cs35l41: Fix I2S params comments
hda: cs35l41: Always configure the DAI
hda: cs35l41: Add Boost type flag
hda: cs35l41: Put the device into safe mode for external boost
hda: cs35l41: Mute the device before shutdown
sound: cs35l41: Enable Internal Boost in shared lib
hda: cs35l41: Move boost config to initialization code
hda: cs35l41: Remove unnecessary log
hda: cs35l41: Remove cs35l41_hda_reg_sequence struct
hda: cs35l41: Handle all external boost setups the same way
hda: cs35l41: Move external boost handling to lib for ASoC use
ASoC: cs35l41: Support external boost
.../bindings/sound/cirrus,cs35l41.yaml | 42 ++-
include/sound/cs35l41.h | 53 +++-
sound/pci/hda/cs35l41_hda.c | 296 +++++-------------
sound/pci/hda/cs35l41_hda.h | 27 +-
sound/soc/codecs/cs35l41-i2c.c | 4 +-
sound/soc/codecs/cs35l41-lib.c | 185 ++++++++++-
sound/soc/codecs/cs35l41-spi.c | 4 +-
sound/soc/codecs/cs35l41.c | 174 +++++-----
sound/soc/codecs/cs35l41.h | 5 +-
9 files changed, 431 insertions(+), 359 deletions(-)
--
2.35.1
Global enable must happen before CSPL_MBOX_CMD_RESUME command
is sent. Move it to PRE_PMU as both events use
SND_SOC_DAPM_OUT_DRV_E macro.
Signed-off-by: Lucas Tanure <[email protected]>
---
sound/soc/codecs/cs35l41.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index f3787d77f892..05de94fd2e55 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -573,7 +573,7 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w,
int ret = 0;
switch (event) {
- case SND_SOC_DAPM_POST_PMU:
+ case SND_SOC_DAPM_PRE_PMU:
regmap_multi_reg_write_bypassed(cs35l41->regmap,
cs35l41_pup_patch,
ARRAY_SIZE(cs35l41_pup_patch));
@@ -649,7 +649,7 @@ static const struct snd_soc_dapm_widget cs35l41_dapm_widgets[] = {
SND_SOC_DAPM_OUT_DRV_E("Main AMP", CS35L41_PWR_CTRL2, 0, 0, NULL, 0,
cs35l41_main_amp_event,
- SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),
+ SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU),
SND_SOC_DAPM_MUX("ASP TX1 Source", SND_SOC_NOPM, 0, 0, &asp_tx1_mux),
SND_SOC_DAPM_MUX("ASP TX2 Source", SND_SOC_NOPM, 0, 0, &asp_tx2_mux),
--
2.35.1
From: David Rhodes <[email protected]>
Document external boost feature on CS35L41
Signed-off-by: David Rhodes <[email protected]>
---
.../bindings/sound/cirrus,cs35l41.yaml | 42 +++++++++++++++++--
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml b/Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml
index 3235702ce402..51b5d86661d5 100644
--- a/Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml
+++ b/Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml
@@ -75,6 +75,19 @@ properties:
maximum: 3
default: 2
+ cirrus,boost-type:
+ description:
+ Configures the type of Boost being used.
+ Internal boost requires boost-peak-milliamp, boost-ind-nanohenry and
+ boost-cap-microfarad.
+ External Boost must have GPIO1 as GPIO output. GPIO1 will be set high to
+ enable boost voltage.
+ 0 = Internal Boost
+ 1 = External Boost
+ $ref: "/schemas/types.yaml#/definitions/uint32"
+ minimum: 0
+ maximum: 1
+
cirrus,gpio1-polarity-invert:
description:
Boolean which specifies whether the GPIO1
@@ -131,9 +144,32 @@ required:
- compatible
- reg
- "#sound-dai-cells"
- - cirrus,boost-peak-milliamp
- - cirrus,boost-ind-nanohenry
- - cirrus,boost-cap-microfarad
+
+allOf:
+ - if:
+ properties:
+ cirrus,boost-type:
+ contains:
+ const: 0
+
+ then:
+ required:
+ - cirrus,boost-peak-milliamp
+ - cirrus,boost-ind-nanohenry
+ - cirrus,boost-cap-microfarad
+
+ - if:
+ properties:
+ cirrus,boost-type:
+ contains:
+ const: 1
+
+ then:
+ required:
+ - cirrus,gpio1-output-enable
+ properties:
+ cirrus,gpio1-src-select:
+ const: 1
additionalProperties: false
--
2.35.1
Replace vspk_always_on by a enum that better
characterizes the system, as there is 3 types
of boost hardware.
Signed-off-by: Lucas Tanure <[email protected]>
---
include/sound/cs35l41.h | 9 ++++++--
sound/pci/hda/cs35l41_hda.c | 43 +++++++++++++++++++++----------------
2 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h
index e3ec0f422fff..fbf38f32e36d 100644
--- a/include/sound/cs35l41.h
+++ b/include/sound/cs35l41.h
@@ -725,6 +725,12 @@
#define CS35L41_SPI_MAX_FREQ 4000000
#define CS35L41_REGSTRIDE 4
+enum cs35l41_boost_type {
+ CS35L41_INT_BOOST,
+ CS35L41_EXT_BOOST,
+ CS35L41_EXT_BOOST_NO_VSPK_SWITCH,
+};
+
enum cs35l41_clk_ids {
CS35L41_CLKID_SCLK = 0,
CS35L41_CLKID_LRCLK = 1,
@@ -762,8 +768,7 @@ struct cs35l41_hw_cfg {
struct cs35l41_gpio_cfg gpio2;
unsigned int spk_pos;
- /* Don't put the AMP in reset if VSPK can not be turned off */
- bool vspk_always_on;
+ enum cs35l41_boost_type bst_type;
};
struct cs35l41_otp_packed_element_t {
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 4c99dcac2dd7..17660ce71f93 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -210,20 +210,30 @@ static const struct component_ops cs35l41_hda_comp_ops = {
static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41)
{
struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg;
- bool internal_boost = false;
int ret;
if (!cs35l41->hw_cfg.valid)
return -EINVAL;
- if (hw_cfg->vspk_always_on) {
+ switch (hw_cfg->bst_type) {
+ case CS35L41_INT_BOOST:
+ cs35l41->reg_seq = &cs35l41_hda_reg_seq_int_bst;
+ ret = cs35l41_boost_config(cs35l41->dev, cs35l41->regmap,
+ hw_cfg->bst_ind, hw_cfg->bst_cap, hw_cfg->bst_ipk);
+ if (ret)
+ return ret;
+ break;
+ case CS35L41_EXT_BOOST:
+ cs35l41->reg_seq = &cs35l41_hda_reg_seq_ext_bst;
+ break;
+ case CS35L41_EXT_BOOST_NO_VSPK_SWITCH:
cs35l41->reg_seq = &cs35l41_hda_reg_seq_no_bst;
- return 0;
+ break;
+ default:
+ dev_err(cs35l41->dev, "Boost type %d not supported\n", hw_cfg->bst_type);
+ return -EINVAL;
}
- if (hw_cfg->bst_ind > 0 || hw_cfg->bst_cap > 0 || hw_cfg->bst_ipk > 0)
- internal_boost = true;
-
if (hw_cfg->gpio1.valid) {
switch (hw_cfg->gpio1.func) {
case CS35L41_NOT_USED:
@@ -256,16 +266,6 @@ static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41)
cs35l41_gpio_config(cs35l41->regmap, hw_cfg);
- if (internal_boost) {
- cs35l41->reg_seq = &cs35l41_hda_reg_seq_int_bst;
- ret = cs35l41_boost_config(cs35l41->dev, cs35l41->regmap,
- hw_cfg->bst_ind, hw_cfg->bst_cap, hw_cfg->bst_ipk);
- if (ret)
- return ret;
- } else {
- cs35l41->reg_seq = &cs35l41_hda_reg_seq_ext_bst;
- }
-
return cs35l41_hda_channel_map(cs35l41->dev, 0, NULL, 1, &hw_cfg->spk_pos);
}
@@ -363,6 +363,11 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
else
hw_cfg->bst_cap = -1;
+ if (hw_cfg->bst_ind > 0 || hw_cfg->bst_cap > 0 || hw_cfg->bst_ipk > 0)
+ hw_cfg->bst_type = CS35L41_INT_BOOST;
+ else
+ hw_cfg->bst_type = CS35L41_EXT_BOOST;
+
hw_cfg->valid = true;
put_device(physdev);
@@ -388,7 +393,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
/* check I2C address to assign the index */
cs35l41->index = id == 0x40 ? 0 : 1;
cs35l41->reset_gpio = gpiod_get_index(physdev, NULL, 0, GPIOD_OUT_HIGH);
- cs35l41->hw_cfg.vspk_always_on = true;
+ cs35l41->hw_cfg.bst_type = CS35L41_EXT_BOOST_NO_VSPK_SWITCH;
cs35l41->hw_cfg.valid = true;
put_device(physdev);
@@ -515,7 +520,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i
return 0;
err:
- if (!cs35l41->hw_cfg.vspk_always_on)
+ if (cs35l41->hw_cfg.bst_type != CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
gpiod_set_value_cansleep(cs35l41->reset_gpio, 0);
gpiod_put(cs35l41->reset_gpio);
@@ -529,7 +534,7 @@ void cs35l41_hda_remove(struct device *dev)
component_del(cs35l41->dev, &cs35l41_hda_comp_ops);
- if (!cs35l41->hw_cfg.vspk_always_on)
+ if (cs35l41->hw_cfg.bst_type != CS35L41_EXT_BOOST_NO_VSPK_SWITCH)
gpiod_set_value_cansleep(cs35l41->reset_gpio, 0);
gpiod_put(cs35l41->reset_gpio);
}
--
2.35.1
On Thu, 03 Mar 2022 17:30:59 +0000, Lucas Tanure wrote:
> From: David Rhodes <[email protected]>
>
> Document external boost feature on CS35L41
>
> Signed-off-by: David Rhodes <[email protected]>
> ---
> .../bindings/sound/cirrus,cs35l41.yaml | 42 +++++++++++++++++--
> 1 file changed, 39 insertions(+), 3 deletions(-)
>
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/cirrus,cs35l41.example.dt.yaml: cs35l41@2: 'cirrus,gpio1-output-enable' is a required property
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1600514
This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit.
Remove cs35l41_hd_reg_sequence as it adds a
layer of flexibility not needed.
Signed-off-by: Lucas Tanure <[email protected]>
---
sound/pci/hda/cs35l41_hda.c | 77 ++++++++++++++-----------------------
sound/pci/hda/cs35l41_hda.h | 14 -------
2 files changed, 29 insertions(+), 62 deletions(-)
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index f21d048e60ab..e61bab8db68d 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -32,14 +32,6 @@ static const struct reg_sequence cs35l41_hda_mute[] = {
{ CS35L41_AMP_DIG_VOL_CTRL, 0x0000A678 }, // AMP_VOL_PCM Mute
};
-static const struct reg_sequence cs35l41_hda_start_bst[] = {
- { CS35L41_PWR_CTRL1, 0x00000001, 3000}, // set GLOBAL_EN = 1
-};
-
-static const struct reg_sequence cs35l41_hda_stop_bst[] = {
- { CS35L41_PWR_CTRL1, 0x00000000, 3000}, // set GLOBAL_EN = 0
-};
-
// only on amps where GPIO1 is used to control ext. VSPK switch
static const struct reg_sequence cs35l41_start_ext_vspk[] = {
{ 0x00000040, 0x00000055 },
@@ -109,31 +101,38 @@ static const struct reg_sequence cs35l41_reset_to_safe[] = {
{ 0x00000040, 0x00000033 },
};
-static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_no_bst = {
- .prepare = cs35l41_safe_to_active,
- .num_prepare = ARRAY_SIZE(cs35l41_safe_to_active),
- .cleanup = cs35l41_active_to_safe,
- .num_cleanup = ARRAY_SIZE(cs35l41_active_to_safe),
-};
-
-static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_ext_bst = {
- .prepare = cs35l41_start_ext_vspk,
- .num_prepare = ARRAY_SIZE(cs35l41_start_ext_vspk),
- .cleanup = cs35l41_stop_ext_vspk,
- .num_cleanup = ARRAY_SIZE(cs35l41_stop_ext_vspk),
-};
-
-static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_int_bst = {
- .prepare = cs35l41_hda_start_bst,
- .num_prepare = ARRAY_SIZE(cs35l41_hda_start_bst),
- .cleanup = cs35l41_hda_stop_bst,
- .num_cleanup = ARRAY_SIZE(cs35l41_hda_stop_bst),
+static void cs35l41_hda_global_enable(struct cs35l41_hda *cs35l41, int enable)
+{
+ switch (cs35l41->hw_cfg.bst_type) {
+ case CS35L41_INT_BOOST:
+ regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL1, CS35L41_GLOBAL_EN_MASK,
+ enable << CS35L41_GLOBAL_EN_SHIFT);
+ usleep_range(3000, 3100);
+ break;
+ case CS35L41_EXT_BOOST:
+ if (enable)
+ regmap_multi_reg_write(cs35l41->regmap, cs35l41_start_ext_vspk,
+ ARRAY_SIZE(cs35l41_start_ext_vspk));
+ else
+ regmap_multi_reg_write(cs35l41->regmap, cs35l41_stop_ext_vspk,
+ ARRAY_SIZE(cs35l41_stop_ext_vspk));
+ break;
+ case CS35L41_EXT_BOOST_NO_VSPK_SWITCH:
+ if (enable)
+ regmap_multi_reg_write(cs35l41->regmap, cs35l41_safe_to_active,
+ ARRAY_SIZE(cs35l41_safe_to_active));
+ else
+ regmap_multi_reg_write(cs35l41->regmap, cs35l41_active_to_safe,
+ ARRAY_SIZE(cs35l41_active_to_safe));
+ break;
+ default:
+ break;
+ }
};
static void cs35l41_hda_playback_hook(struct device *dev, int action)
{
struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev);
- const struct cs35l41_hda_reg_sequence *reg_seq = cs35l41->reg_seq;
struct regmap *reg = cs35l41->regmap;
switch (action) {
@@ -143,19 +142,15 @@ static void cs35l41_hda_playback_hook(struct device *dev, int action)
CS35L41_AMP_EN_MASK, 1 << CS35L41_AMP_EN_SHIFT);
break;
case HDA_GEN_PCM_ACT_PREPARE:
- if (reg_seq->prepare)
- regmap_multi_reg_write(reg, reg_seq->prepare, reg_seq->num_prepare);
+ cs35l41_hda_global_enable(cs35l41, 1);
break;
case HDA_GEN_PCM_ACT_CLEANUP:
regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute));
- if (reg_seq->cleanup)
- regmap_multi_reg_write(reg, reg_seq->cleanup, reg_seq->num_cleanup);
+ cs35l41_hda_global_enable(cs35l41, 0);
break;
case HDA_GEN_PCM_ACT_CLOSE:
regmap_update_bits(reg, CS35L41_PWR_CTRL2,
CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT);
- if (reg_seq->close)
- regmap_multi_reg_write(reg, reg_seq->close, reg_seq->num_close);
break;
default:
break;
@@ -215,7 +210,6 @@ static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41)
switch (hw_cfg->bst_type) {
case CS35L41_INT_BOOST:
- cs35l41->reg_seq = &cs35l41_hda_reg_seq_int_bst;
ret = cs35l41_boost_config(cs35l41->dev, cs35l41->regmap,
hw_cfg->bst_ind, hw_cfg->bst_cap, hw_cfg->bst_ipk);
if (ret)
@@ -223,10 +217,6 @@ static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41)
break;
case CS35L41_EXT_BOOST:
case CS35L41_EXT_BOOST_NO_VSPK_SWITCH:
- if (hw_cfg->bst_type == CS35L41_EXT_BOOST)
- cs35l41->reg_seq = &cs35l41_hda_reg_seq_ext_bst;
- else
- cs35l41->reg_seq = &cs35l41_hda_reg_seq_no_bst;
regmap_multi_reg_write(cs35l41->regmap, cs35l41_reset_to_safe,
ARRAY_SIZE(cs35l41_reset_to_safe));
regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, CS35L41_BST_EN_MASK,
@@ -503,15 +493,6 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i
if (ret)
goto err;
- if (cs35l41->reg_seq->probe) {
- ret = regmap_multi_reg_write(cs35l41->regmap, cs35l41->reg_seq->probe,
- cs35l41->reg_seq->num_probe);
- if (ret) {
- dev_err(cs35l41->dev, "Fail to apply probe reg patch: %d\n", ret);
- goto err;
- }
- }
-
ret = component_add(cs35l41->dev, &cs35l41_hda_comp_ops);
if (ret) {
dev_err(cs35l41->dev, "Register component failed: %d\n", ret);
diff --git a/sound/pci/hda/cs35l41_hda.h b/sound/pci/hda/cs35l41_hda.h
index 17f10764f174..44d9204ffdf1 100644
--- a/sound/pci/hda/cs35l41_hda.h
+++ b/sound/pci/hda/cs35l41_hda.h
@@ -27,24 +27,10 @@ enum cs35l41_hda_gpio_function {
CS35l41_SYNC,
};
-struct cs35l41_hda_reg_sequence {
- const struct reg_sequence *probe;
- unsigned int num_probe;
- const struct reg_sequence *open;
- unsigned int num_open;
- const struct reg_sequence *prepare;
- unsigned int num_prepare;
- const struct reg_sequence *cleanup;
- unsigned int num_cleanup;
- const struct reg_sequence *close;
- unsigned int num_close;
-};
-
struct cs35l41_hda {
struct device *dev;
struct regmap *regmap;
struct gpio_desc *reset_gpio;
- const struct cs35l41_hda_reg_sequence *reg_seq;
struct cs35l41_hw_cfg hw_cfg;
int irq;
--
2.35.1
The Dai configuration is always the same and
should always configured during open.
Signed-off-by: Lucas Tanure <[email protected]>
---
sound/pci/hda/cs35l41_hda.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index fe6f6a208d29..4c99dcac2dd7 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -111,8 +111,6 @@ static const struct reg_sequence cs35l41_reset_to_safe[] = {
static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_no_bst = {
.probe = cs35l41_reset_to_safe,
.num_probe = ARRAY_SIZE(cs35l41_reset_to_safe),
- .open = cs35l41_hda_config,
- .num_open = ARRAY_SIZE(cs35l41_hda_config),
.prepare = cs35l41_safe_to_active,
.num_prepare = ARRAY_SIZE(cs35l41_safe_to_active),
.cleanup = cs35l41_active_to_safe,
@@ -120,8 +118,6 @@ static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_no_bst = {
};
static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_ext_bst = {
- .open = cs35l41_hda_config,
- .num_open = ARRAY_SIZE(cs35l41_hda_config),
.prepare = cs35l41_start_ext_vspk,
.num_prepare = ARRAY_SIZE(cs35l41_start_ext_vspk),
.cleanup = cs35l41_stop_ext_vspk,
@@ -129,8 +125,6 @@ static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_ext_bst = {
};
static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_int_bst = {
- .open = cs35l41_hda_config,
- .num_open = ARRAY_SIZE(cs35l41_hda_config),
.prepare = cs35l41_hda_start_bst,
.num_prepare = ARRAY_SIZE(cs35l41_hda_start_bst),
.cleanup = cs35l41_hda_stop_bst,
@@ -146,8 +140,8 @@ static void cs35l41_hda_playback_hook(struct device *dev, int action)
switch (action) {
case HDA_GEN_PCM_ACT_OPEN:
- if (reg_seq->open)
- ret = regmap_multi_reg_write(reg, reg_seq->open, reg_seq->num_open);
+ ret = regmap_multi_reg_write(reg, cs35l41_hda_config,
+ ARRAY_SIZE(cs35l41_hda_config));
break;
case HDA_GEN_PCM_ACT_PREPARE:
if (reg_seq->prepare)
--
2.35.1
From: David Rhodes <[email protected]>
Fix GPIO2 polarity and direction configuration
Fixes: fe1024d50477b ("ASoC: cs35l41: Combine adjacent register writes")
Signed-off-by: David Rhodes <[email protected]>
---
sound/soc/codecs/cs35l41.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index 77a017694645..90c91b00288b 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -1035,8 +1035,8 @@ static int cs35l41_irq_gpio_config(struct cs35l41_private *cs35l41)
regmap_update_bits(cs35l41->regmap, CS35L41_GPIO2_CTRL1,
CS35L41_GPIO_POL_MASK | CS35L41_GPIO_DIR_MASK,
- irq_gpio_cfg1->irq_pol_inv << CS35L41_GPIO_POL_SHIFT |
- !irq_gpio_cfg1->irq_out_en << CS35L41_GPIO_DIR_SHIFT);
+ irq_gpio_cfg2->irq_pol_inv << CS35L41_GPIO_POL_SHIFT |
+ !irq_gpio_cfg2->irq_out_en << CS35L41_GPIO_DIR_SHIFT);
regmap_update_bits(cs35l41->regmap, CS35L41_GPIO_PAD_CONTROL,
CS35L41_GPIO1_CTRL_MASK | CS35L41_GPIO2_CTRL_MASK,
--
2.35.1
Boost configuration doesn't need to be written for
every new stream, so move it to the initialization code.
Signed-off-by: Lucas Tanure <[email protected]>
---
include/sound/cs35l41.h | 1 +
sound/pci/hda/cs35l41_hda.c | 9 ++++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h
index fbf38f32e36d..a8537bccedcf 100644
--- a/include/sound/cs35l41.h
+++ b/include/sound/cs35l41.h
@@ -661,6 +661,7 @@
#define CS35L41_GLOBAL_EN_SHIFT 0
#define CS35L41_BST_EN_MASK 0x0030
#define CS35L41_BST_EN_SHIFT 4
+#define CS35L41_BST_DIS_FET_OFF 0x00
#define CS35L41_BST_EN_DEFAULT 0x2
#define CS35L41_AMP_EN_SHIFT 0
#define CS35L41_AMP_EN_MASK 1
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 75c5088cb224..90c833a25599 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -25,7 +25,6 @@ static const struct reg_sequence cs35l41_hda_config[] = {
{ CS35L41_DAC_PCM1_SRC, 0x00000008 }, // DACPCM1_SRC = ASPRX1
{ CS35L41_AMP_DIG_VOL_CTRL, 0x00000000 }, // AMP_VOL_PCM 0.0 dB
{ CS35L41_AMP_GAIN_CTRL, 0x00000084 }, // AMP_GAIN_PCM 4.5 dB
- { CS35L41_PWR_CTRL2, 0x00000001 }, // AMP_EN = 1
};
static const struct reg_sequence cs35l41_hda_mute[] = {
@@ -34,7 +33,6 @@ static const struct reg_sequence cs35l41_hda_mute[] = {
};
static const struct reg_sequence cs35l41_hda_start_bst[] = {
- { CS35L41_PWR_CTRL2, 0x00000021 }, // BST_EN = 10, AMP_EN = 1
{ CS35L41_PWR_CTRL1, 0x00000001, 3000}, // set GLOBAL_EN = 1
};
@@ -94,7 +92,6 @@ static const struct reg_sequence cs35l41_active_to_safe[] = {
{ 0x00000040, 0x00000055 },
{ 0x00000040, 0x000000AA },
{ 0x00007438, 0x00585941 },
- { CS35L41_PWR_CTRL2, 0x00000000 }, // AMP_EN = 0
{ CS35L41_PWR_CTRL1, 0x00000000 },
{ 0x0000742C, 0x00000009, 2000 },
{ 0x00007438, 0x00580941 },
@@ -144,6 +141,8 @@ static void cs35l41_hda_playback_hook(struct device *dev, int action)
case HDA_GEN_PCM_ACT_OPEN:
ret = regmap_multi_reg_write(reg, cs35l41_hda_config,
ARRAY_SIZE(cs35l41_hda_config));
+ regmap_update_bits(reg, CS35L41_PWR_CTRL2,
+ CS35L41_AMP_EN_MASK, 1 << CS35L41_AMP_EN_SHIFT);
break;
case HDA_GEN_PCM_ACT_PREPARE:
if (reg_seq->prepare)
@@ -155,6 +154,8 @@ static void cs35l41_hda_playback_hook(struct device *dev, int action)
ret = regmap_multi_reg_write(reg, reg_seq->cleanup, reg_seq->num_cleanup);
break;
case HDA_GEN_PCM_ACT_CLOSE:
+ regmap_update_bits(reg, CS35L41_PWR_CTRL2,
+ CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT);
if (reg_seq->close)
ret = regmap_multi_reg_write(reg, reg_seq->close, reg_seq->num_close);
break;
@@ -234,6 +235,8 @@ static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41)
cs35l41->reg_seq = &cs35l41_hda_reg_seq_no_bst;
regmap_multi_reg_write(cs35l41->regmap, cs35l41_reset_to_safe,
ARRAY_SIZE(cs35l41_reset_to_safe));
+ regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, CS35L41_BST_EN_MASK,
+ CS35L41_BST_DIS_FET_OFF << CS35L41_BST_EN_SHIFT);
break;
default:
dev_err(cs35l41->dev, "Boost type %d not supported\n", hw_cfg->bst_type);
--
2.35.1
Fix clock and slot size comments
Signed-off-by: Lucas Tanure <[email protected]>
---
sound/pci/hda/cs35l41_hda.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 81cdbd84cf7d..fe6f6a208d29 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -17,11 +17,11 @@
#include "cs35l41_hda.h"
static const struct reg_sequence cs35l41_hda_config[] = {
- { CS35L41_PLL_CLK_CTRL, 0x00000430 }, // 3200000Hz, BCLK Input, PLL_REFCLK_EN = 1
+ { CS35L41_PLL_CLK_CTRL, 0x00000430 }, // 3072000Hz, BCLK Input, PLL_REFCLK_EN = 1
{ CS35L41_GLOBAL_CLK_CTRL, 0x00000003 }, // GLOBAL_FS = 48 kHz
{ CS35L41_SP_ENABLES, 0x00010000 }, // ASP_RX1_EN = 1
{ CS35L41_SP_RATE_CTRL, 0x00000021 }, // ASP_BCLK_FREQ = 3.072 MHz
- { CS35L41_SP_FORMAT, 0x20200200 }, // 24 bits, I2S, BCLK Slave, FSYNC Slave
+ { CS35L41_SP_FORMAT, 0x20200200 }, // 32 bits RX/TX slots, I2S, clk consumer
{ CS35L41_DAC_PCM1_SRC, 0x00000008 }, // DACPCM1_SRC = ASPRX1
{ CS35L41_AMP_DIG_VOL_CTRL, 0x00000000 }, // AMP_VOL_PCM 0.0 dB
{ CS35L41_AMP_GAIN_CTRL, 0x00000084 }, // AMP_GAIN_PCM 4.5 dB
--
2.35.1
On Thu, Mar 03, 2022 at 05:30:42PM +0000, Lucas Tanure wrote:
> Global enable must happen before CSPL_MBOX_CMD_RESUME command
> is sent. Move it to PRE_PMU as both events use
> SND_SOC_DAPM_OUT_DRV_E macro.
>
> Signed-off-by: Lucas Tanure <[email protected]>
> ---
Acked-by: Charles Keepax <[email protected]>
Thanks,
Charles
On Thu, Mar 03, 2022 at 05:30:40PM +0000, Lucas Tanure wrote:
> From: David Rhodes <[email protected]>
>
> Fix GPIO2 polarity and direction configuration
>
> Fixes: fe1024d50477b ("ASoC: cs35l41: Combine adjacent register writes")
> Signed-off-by: David Rhodes <[email protected]>
> ---
Acked-by: Charles Keepax <[email protected]>
Thanks,
Charles
All external boost setups should be put into safe mode.
Signed-off-by: Lucas Tanure <[email protected]>
---
sound/pci/hda/cs35l41_hda.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 17660ce71f93..665f0b4e191a 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -109,8 +109,6 @@ static const struct reg_sequence cs35l41_reset_to_safe[] = {
};
static const struct cs35l41_hda_reg_sequence cs35l41_hda_reg_seq_no_bst = {
- .probe = cs35l41_reset_to_safe,
- .num_probe = ARRAY_SIZE(cs35l41_reset_to_safe),
.prepare = cs35l41_safe_to_active,
.num_prepare = ARRAY_SIZE(cs35l41_safe_to_active),
.cleanup = cs35l41_active_to_safe,
@@ -224,10 +222,13 @@ static int cs35l41_hda_apply_properties(struct cs35l41_hda *cs35l41)
return ret;
break;
case CS35L41_EXT_BOOST:
- cs35l41->reg_seq = &cs35l41_hda_reg_seq_ext_bst;
- break;
case CS35L41_EXT_BOOST_NO_VSPK_SWITCH:
- cs35l41->reg_seq = &cs35l41_hda_reg_seq_no_bst;
+ if (hw_cfg->bst_type == CS35L41_EXT_BOOST)
+ cs35l41->reg_seq = &cs35l41_hda_reg_seq_ext_bst;
+ else
+ cs35l41->reg_seq = &cs35l41_hda_reg_seq_no_bst;
+ regmap_multi_reg_write(cs35l41->regmap, cs35l41_reset_to_safe,
+ ARRAY_SIZE(cs35l41_reset_to_safe));
break;
default:
dev_err(cs35l41->dev, "Boost type %d not supported\n", hw_cfg->bst_type);
--
2.35.1
On Thu, 3 Mar 2022 17:30:39 +0000, Lucas Tanure wrote:
> Move the support for CS35L41 external boost to its shared library
> for ASoC use.
> This move resulted in cs35l41_hda_reg_sequence being removed,
> and its steps were broken down into regmap writes or functions
> from the library. And hardware configuration struct was unified
> for its use in the shared lib.
> While at it, some minor bugs were found and fixed it.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-linus
Thanks!
[01/20] ASoC: cs35l41: Fix GPIO2 configuration
commit: 03a7895ee701e873c88c06bdb830ff40adb2be73
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark