[PATCH 1/6] dt-bindings: tas2770: Add shutdown gpio property
Add the shutdown-gpios property to the yaml to define the GPIO that can be used to place the device in shutdown mode or wake the device up.
Signed-off-by: Dan Murphy dmurphy@ti.com --- Documentation/devicetree/bindings/sound/tas2770.yaml | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/tas2770.yaml b/Documentation/devicetree/bindings/sound/tas2770.yaml index bb26d081c9fa..9fdf614add55 100644 --- a/Documentation/devicetree/bindings/sound/tas2770.yaml +++ b/Documentation/devicetree/bindings/sound/tas2770.yaml @@ -29,6 +29,9 @@ properties: reset-gpio: description: GPIO used to reset the device.
+ shutdown-gpios: + description: GPIO used to control the state of the device. + interrupts: maxItems: 1
@@ -69,6 +72,7 @@ examples: interrupt-parent = <&gpio1>; interrupts = <14>; reset-gpio = <&gpio1 15 0>; + shutdown-gpios = <&gpio1 14 0>; ti,imon-slot-no = <0>; ti,vmon-slot-no = <2>; };
Add the hardware shutdown mechanism to shutdown and wake up the device via a GPIO.
Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2770.c | 53 ++++++++++++++++++++++++++++---------- sound/soc/codecs/tas2770.h | 1 + 2 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index 386aaa11fa08..9f7363927c50 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -79,28 +79,42 @@ static int tas2770_set_bias_level(struct snd_soc_component *component, #ifdef CONFIG_PM static int tas2770_codec_suspend(struct snd_soc_component *component) { - int ret; + struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component); + int ret = 0;
- ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL, - TAS2770_PWR_CTRL_MASK, - TAS2770_PWR_CTRL_SHUTDOWN); - if (ret < 0) - return ret; + if (tas2770->sdz_gpio) { + gpiod_set_value_cansleep(tas2770->sdz_gpio, 0); + } else { + ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL, + TAS2770_PWR_CTRL_MASK, + TAS2770_PWR_CTRL_SHUTDOWN); + if (ret < 0) + return ret;
- return 0; + ret = 0; + } + + return ret; }
static int tas2770_codec_resume(struct snd_soc_component *component) { - int ret; + struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component); + int ret = 0;
- ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL, - TAS2770_PWR_CTRL_MASK, - TAS2770_PWR_CTRL_ACTIVE); - if (ret < 0) - return ret; + if (tas2770->sdz_gpio) { + gpiod_set_value_cansleep(tas2770->sdz_gpio, 1); + } else { + ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL, + TAS2770_PWR_CTRL_MASK, + TAS2770_PWR_CTRL_ACTIVE); + if (ret < 0) + return ret;
- return 0; + ret = 0; + } + + return ret; } #else #define tas2770_codec_suspend NULL @@ -498,6 +512,9 @@ static int tas2770_codec_probe(struct snd_soc_component *component)
tas2770->component = component;
+ if (tas2770->sdz_gpio) + gpiod_set_value_cansleep(tas2770->sdz_gpio, 1); + tas2770_reset(tas2770);
return 0; @@ -650,6 +667,14 @@ static int tas2770_parse_dt(struct device *dev, struct tas2770_priv *tas2770) tas2770->v_sense_slot = 2; }
+ tas2770->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH); + if (IS_ERR(tas2770->sdz_gpio)) { + if (PTR_ERR(tas2770->sdz_gpio) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + tas2770->sdz_gpio = NULL; + } + return 0; }
diff --git a/sound/soc/codecs/tas2770.h b/sound/soc/codecs/tas2770.h index 07e3556fc702..b3fc4a487033 100644 --- a/sound/soc/codecs/tas2770.h +++ b/sound/soc/codecs/tas2770.h @@ -134,6 +134,7 @@ struct tas2770_priv { int power_state; int asi_format; struct gpio_desc *reset_gpio; + struct gpio_desc *sdz_gpio; int sampling_rate; int channel_size; int slot_width;
Set the regcache to cache data and mark cache as dirty when the device is shutdown when suspend is called. When the device is woken up then sync the cache and set to not caching the data.
Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2770.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index 9f7363927c50..c42e653cd653 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -82,14 +82,20 @@ static int tas2770_codec_suspend(struct snd_soc_component *component) struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component); int ret = 0;
+ regcache_cache_only(tas2770->regmap, true); + regcache_mark_dirty(tas2770->regmap); + if (tas2770->sdz_gpio) { gpiod_set_value_cansleep(tas2770->sdz_gpio, 0); } else { ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL, TAS2770_PWR_CTRL_MASK, TAS2770_PWR_CTRL_SHUTDOWN); - if (ret < 0) + if (ret < 0) { + regcache_cache_only(tas2770->regmap, false); + regcache_sync(tas2770->regmap); return ret; + }
ret = 0; } @@ -110,11 +116,11 @@ static int tas2770_codec_resume(struct snd_soc_component *component) TAS2770_PWR_CTRL_ACTIVE); if (ret < 0) return ret; - - ret = 0; }
- return ret; + regcache_cache_only(tas2770->regmap, false); + + return regcache_sync(tas2770->regmap); } #else #define tas2770_codec_suspend NULL
Remove the property ti,asi-format as the driver only reads this property and performs no action against it.
Signed-off-by: Dan Murphy dmurphy@ti.com --- Documentation/devicetree/bindings/sound/tas2770.yaml | 7 ------- 1 file changed, 7 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/tas2770.yaml b/Documentation/devicetree/bindings/sound/tas2770.yaml index 9fdf614add55..aa8c74575ac9 100644 --- a/Documentation/devicetree/bindings/sound/tas2770.yaml +++ b/Documentation/devicetree/bindings/sound/tas2770.yaml @@ -43,13 +43,6 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 description: TDM TX voltage sense time slot.
- ti,asi-format: - $ref: /schemas/types.yaml#/definitions/uint32 - description: Sets TDM RX capture edge. - enum: - - 0 # Rising edge - - 1 # Falling edge - '#sound-dai-cells': const: 1
On Wed, Sep 23, 2020 at 08:25:58AM -0500, Dan Murphy wrote:
Remove the property ti,asi-format as the driver only reads this property and performs no action against it.
We should probably leave the property as documented and move it to deprecated rather than delete the documentation entirely.
Mark
On 9/23/20 10:51 AM, Mark Brown wrote:
On Wed, Sep 23, 2020 at 08:25:58AM -0500, Dan Murphy wrote:
Remove the property ti,asi-format as the driver only reads this property and performs no action against it.
We should probably leave the property as documented and move it to deprecated rather than delete the documentation entirely.
I mulled this over to just deprecate the property and I know removing these ABIs are not highly accepted.
But the support code for it was incomplete and if a user had it populated in the DT and we removed the support then there will be no functional change.
This property was supposed to set the RX edge SBCLK detection but this is done based on the dai format.
So removing the property will have no affect on the users.
Dan
Remove the code to support the asi-format binding property. The code does nothing except read the property and set a variable. No additional action is taken except to reset the variable. The property is supposed to set the rising or falling RX edge detection of the SBCLK but this edge detection is done by checking the DAI_FMT_INV_MASK.
Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2770.c | 11 ----------- sound/soc/codecs/tas2770.h | 1 - 2 files changed, 12 deletions(-)
diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index c42e653cd653..c7a6f7e8200c 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -391,8 +391,6 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) if (ret < 0) return ret;
- tas2770->asi_format = fmt; - return 0; }
@@ -646,15 +644,6 @@ static int tas2770_parse_dt(struct device *dev, struct tas2770_priv *tas2770) { int rc = 0;
- rc = fwnode_property_read_u32(dev->fwnode, "ti,asi-format", - &tas2770->asi_format); - if (rc) { - dev_info(tas2770->dev, "Property %s is missing setting default slot\n", - "ti,asi-format"); - - tas2770->asi_format = 0; - } - rc = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no", &tas2770->i_sense_slot); if (rc) { diff --git a/sound/soc/codecs/tas2770.h b/sound/soc/codecs/tas2770.h index b3fc4a487033..856a7c5cff5a 100644 --- a/sound/soc/codecs/tas2770.h +++ b/sound/soc/codecs/tas2770.h @@ -132,7 +132,6 @@ struct tas2770_priv { struct regmap *regmap; struct snd_soc_component *component; int power_state; - int asi_format; struct gpio_desc *reset_gpio; struct gpio_desc *sdz_gpio; int sampling_rate;
Remove unused variables in the private struct and the code as these variables are initially set and then there is no additional code utilizing these variables.
Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2770.c | 11 ----------- sound/soc/codecs/tas2770.h | 8 ++------ 2 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index c7a6f7e8200c..a91a0a31e74d 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -249,8 +249,6 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth) if (ret < 0) return ret;
- tas2770->channel_size = bitwidth; - ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG5, TAS2770_TDM_CFG_REG5_VSNS_MASK | TAS2770_TDM_CFG_REG5_50_MASK, @@ -312,7 +310,6 @@ static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate) if (ret < 0) return ret;
- tas2770->sampling_rate = samplerate; return 0; }
@@ -400,8 +397,6 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai, int slots, int slot_width) { struct snd_soc_component *component = dai->component; - struct tas2770_priv *tas2770 = - snd_soc_component_get_drvdata(component); int left_slot, right_slot; int ret;
@@ -466,7 +461,6 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai, if (ret < 0) return ret;
- tas2770->slot_width = slot_width; return 0; }
@@ -688,8 +682,6 @@ static int tas2770_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, tas2770); dev_set_drvdata(&client->dev, tas2770);
- tas2770->power_state = TAS2770_POWER_SHUTDOWN; - tas2770->regmap = devm_regmap_init_i2c(client, &tas2770_i2c_regmap); if (IS_ERR(tas2770->regmap)) { result = PTR_ERR(tas2770->regmap); @@ -716,9 +708,6 @@ static int tas2770_i2c_probe(struct i2c_client *client, } }
- tas2770->channel_size = 0; - tas2770->slot_width = 0; - result = tas2770_register_codec(tas2770); if (result) dev_err(tas2770->dev, "Register codec failed.\n"); diff --git a/sound/soc/codecs/tas2770.h b/sound/soc/codecs/tas2770.h index 856a7c5cff5a..d156666bcc55 100644 --- a/sound/soc/codecs/tas2770.h +++ b/sound/soc/codecs/tas2770.h @@ -128,15 +128,11 @@ #define ERROR_CLASSD_PWR BIT(5)
struct tas2770_priv { - struct device *dev; - struct regmap *regmap; struct snd_soc_component *component; - int power_state; struct gpio_desc *reset_gpio; struct gpio_desc *sdz_gpio; - int sampling_rate; - int channel_size; - int slot_width; + struct regmap *regmap; + struct device *dev; int v_sense_slot; int i_sense_slot; };
On Wed, 23 Sep 2020 08:25:55 -0500, Dan Murphy wrote:
Add the shutdown-gpios property to the yaml to define the GPIO that can be used to place the device in shutdown mode or wake the device up.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/5] dt-bindings: tas2770: Add shutdown gpio property commit: 29d7b36ce98eb1bfba2c5c9b2ea0d58ff778a2d4 [2/5] ASoC: tas2770: Add shutdown capability via a GPIO commit: 5d0b9dfe0de26b8c4242145cbf7de3a5a2e98293 [3/5] ASoC: tas2770: Set regcache when shutting down and waking device commit: c0a30e2e07e35f219666788c8549156eb8d74105 [4/5] ASoC: tas2770: Remove ti,asi-format code commit: dd7d9052064b4bda94a89dbc1618927319602366 [5/5] ASoC: tas2770: Remove unused variables commit: 3121420cf9b4db7f2bafcdc0e562f60779bf365d
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
participants (2)
-
Dan Murphy
-
Mark Brown