[PATCH v6 0/7] TAS2562 issue fixes and slot programming
Hello
This series fixes issues tih the shut-down gpio device tree allocation and a code format issue found.
While working on a project slot programming for the tx and rx paths needed to be enabled. In addition the vsense slot programming needed to be configurable and not directly a simpler adder to the isense slot.
Finally the yaml conversion patch was moved to be the last patch in the series so that the fixes can be applied and the yaml can be reviewed appropriately and does not hold up the rest of the fixes.
Dan
Dan Murphy (7): dt-bindings: tas2562: Fix shut-down gpio property ASoC: tas2562: Update shutdown GPIO property ASoC: tas2562: Fix format issue for extra space before a comma ASoC: tas2562: Add rx and tx slot programming dt-bindings: tas2562: Add voltage sense slot property ASoC: tas2562: Add voltage sense slot configuration dt-bindings: tas2562: Convert the tas2562 binding to yaml
.../devicetree/bindings/sound/tas2562.txt | 34 ------- .../devicetree/bindings/sound/tas2562.yaml | 77 ++++++++++++++++ sound/soc/codecs/tas2562.c | 88 +++++++++++++++---- sound/soc/codecs/tas2562.h | 4 + 4 files changed, 151 insertions(+), 52 deletions(-) delete mode 100644 Documentation/devicetree/bindings/sound/tas2562.txt create mode 100644 Documentation/devicetree/bindings/sound/tas2562.yaml
Fix the shut-down gpio property to be shut-down-gpio and fix the example.
Signed-off-by: Dan Murphy dmurphy@ti.com --- Documentation/devicetree/bindings/sound/tas2562.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/tas2562.txt b/Documentation/devicetree/bindings/sound/tas2562.txt index 94796b547184..fd0ac8636c01 100644 --- a/Documentation/devicetree/bindings/sound/tas2562.txt +++ b/Documentation/devicetree/bindings/sound/tas2562.txt @@ -16,7 +16,7 @@ Optional properties: - interrupt-parent: phandle to the interrupt controller which provides the interrupt. - interrupts: (GPIO) interrupt to which the chip is connected. -- shut-down: GPIO used to control the state of the device. +- shut-down-gpio: GPIO used to control the state of the device.
Examples: tas2562@4c { @@ -28,7 +28,7 @@ tas2562@4c { interrupt-parent = <&gpio1>; interrupts = <14>;
- shut-down = <&gpio1 15 0>; + shut-down-gpio = <&gpio1 15 0>; ti,imon-slot-no = <0>; };
Update the shutdown GPIO property to be shutdown from shut-down.
Fixes: c173dba44c2d2 ("ASoC: tas2562: Introduce the TAS2562 amplifier") Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2562.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c index 7fae88655a0f..f6495426f562 100644 --- a/sound/soc/codecs/tas2562.c +++ b/sound/soc/codecs/tas2562.c @@ -619,8 +619,8 @@ static int tas2562_parse_dt(struct tas2562_data *tas2562) struct device *dev = tas2562->dev; int ret = 0;
- tas2562->sdz_gpio = devm_gpiod_get_optional(dev, "shut-down-gpio", - GPIOD_OUT_HIGH); + tas2562->sdz_gpio = devm_gpiod_get_optional(dev, "shut-down", + GPIOD_OUT_HIGH); if (IS_ERR(tas2562->sdz_gpio)) { if (PTR_ERR(tas2562->sdz_gpio) == -EPROBE_DEFER) { tas2562->sdz_gpio = NULL;
Fix the issue found that there is an extra space before a comma in the volume control.
Fixes: bf726b1c86f2c ("ASoC: tas2562: Add support for digital volume control") Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2562.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c index f6495426f562..d26e30a2948c 100644 --- a/sound/soc/codecs/tas2562.c +++ b/sound/soc/codecs/tas2562.c @@ -504,7 +504,7 @@ static const struct snd_kcontrol_new tas2562_snd_controls[] = { .info = snd_soc_info_volsw, .get = tas2562_volume_control_get, .put = tas2562_volume_control_put, - .private_value = SOC_SINGLE_VALUE(TAS2562_DVC_CFG1, 0, 110, 0, 0) , + .private_value = SOC_SINGLE_VALUE(TAS2562_DVC_CFG1, 0, 110, 0, 0), }, };
Add programming for the tdm slots for both tx and rx offsets.
Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2562.c | 17 ++++++++++++++++- sound/soc/codecs/tas2562.h | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c index d26e30a2948c..2f1d4b697f01 100644 --- a/sound/soc/codecs/tas2562.c +++ b/sound/soc/codecs/tas2562.c @@ -208,6 +208,22 @@ static int tas2562_set_dai_tdm_slot(struct snd_soc_dai *dai, if (ret < 0) return ret;
+ if (tx_mask > TAS2562_TX_OFF_MAX) { + dev_err(tas2562->dev, "TX slot is larger then %d", + TAS2562_TX_OFF_MAX); + return -EINVAL; + } + + ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG1, + TAS2562_RX_OFF_MASK, rx_mask << 1); + if (ret < 0) + return ret; + + ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG4, + TAS2562_TX_OFF_MASK, tx_mask << 1); + if (ret < 0) + return ret; + return 0; }
@@ -327,7 +343,6 @@ static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG1, TAS2562_TDM_CFG1_RX_OFFSET_MASK, tdm_rx_start_slot); - if (ret < 0) return ret;
diff --git a/sound/soc/codecs/tas2562.h b/sound/soc/codecs/tas2562.h index 28e75fc431d0..47e59c82eef3 100644 --- a/sound/soc/codecs/tas2562.h +++ b/sound/soc/codecs/tas2562.h @@ -34,6 +34,10 @@ #define TAS2562_TDM_DET TAS2562_REG(0, 0x11) #define TAS2562_REV_ID TAS2562_REG(0, 0x7d)
+#define TAS2562_RX_OFF_MASK GENMASK(5, 1) +#define TAS2562_TX_OFF_MASK GENMASK(3, 1) +#define TAS2562_TX_OFF_MAX 7 + /* Page 2 */ #define TAS2562_DVC_CFG1 TAS2562_REG(2, 0x0c) #define TAS2562_DVC_CFG2 TAS2562_REG(2, 0x0d)
Hello
On 6/24/20 12:49 PM, Dan Murphy wrote:
Add programming for the tdm slots for both tx and rx offsets.
Signed-off-by: Dan Murphy dmurphy@ti.com
sound/soc/codecs/tas2562.c | 17 ++++++++++++++++- sound/soc/codecs/tas2562.h | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c index d26e30a2948c..2f1d4b697f01 100644 --- a/sound/soc/codecs/tas2562.c +++ b/sound/soc/codecs/tas2562.c @@ -208,6 +208,22 @@ static int tas2562_set_dai_tdm_slot(struct snd_soc_dai *dai, if (ret < 0) return ret;
- if (tx_mask > TAS2562_TX_OFF_MAX) {
dev_err(tas2562->dev, "TX slot is larger then %d",
TAS2562_TX_OFF_MAX);
return -EINVAL;
- }
- ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG1,
TAS2562_RX_OFF_MASK, rx_mask << 1);
- if (ret < 0)
return ret;
- ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG4,
TAS2562_TX_OFF_MASK, tx_mask << 1);
- if (ret < 0)
return ret;
I need to fix this patch to remove the slot programming during dai_fmt as the code is not correct and resets the slots
Dan
Add a property to configure the slot for the voltage sense monitoring of the device. Vsense data will be sent to the processor via the slot defined by the property
Signed-off-by: Dan Murphy dmurphy@ti.com --- Documentation/devicetree/bindings/sound/tas2562.txt | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/tas2562.txt b/Documentation/devicetree/bindings/sound/tas2562.txt index fd0ac8636c01..dc6d7362ded7 100644 --- a/Documentation/devicetree/bindings/sound/tas2562.txt +++ b/Documentation/devicetree/bindings/sound/tas2562.txt @@ -11,6 +11,8 @@ Required properties: - compatible: - Should contain "ti,tas2562", "ti,tas2563". - reg: - The i2c address. Should be 0x4c, 0x4d, 0x4e or 0x4f. - ti,imon-slot-no:- TDM TX current sense time slot. + - ti,vmon-slot-no:- TDM TX voltage sense time slot. This slot must always be + greater then ti,imon-slot-no.
Optional properties: - interrupt-parent: phandle to the interrupt controller which provides @@ -30,5 +32,6 @@ tas2562@4c {
shut-down-gpio = <&gpio1 15 0>; ti,imon-slot-no = <0>; + ti,vmon-slot-no = <1>; };
Add Vsense slot configuration based on the device tree. Adding this property enables the slot programming to be moved to the tdm_set_slot callback. This in affect sets the slots for the Isense and Vsense and enabling this these modes are now based on whether these features were powered on or not.
Signed-off-by: Dan Murphy dmurphy@ti.com --- sound/soc/codecs/tas2562.c | 65 ++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 14 deletions(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c index 2f1d4b697f01..b0b7cef79433 100644 --- a/sound/soc/codecs/tas2562.c +++ b/sound/soc/codecs/tas2562.c @@ -224,12 +224,26 @@ static int tas2562_set_dai_tdm_slot(struct snd_soc_dai *dai, if (ret < 0) return ret;
+ ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG5, + TAS2562_TDM_CFG5_VSNS_SLOT_MASK, + tas2562->v_sense_slot); + if (ret < 0) + return ret; + + ret = snd_soc_component_update_bits(component, TAS2562_TDM_CFG6, + TAS2562_TDM_CFG6_ISNS_SLOT_MASK, + tas2562->i_sense_slot); + if (ret < 0) + return ret; + return 0; }
static int tas2562_set_bitwidth(struct tas2562_data *tas2562, int bitwidth) { int ret; + int val; + int sense_en;
switch (bitwidth) { case SNDRV_PCM_FORMAT_S16_LE: @@ -237,21 +251,18 @@ static int tas2562_set_bitwidth(struct tas2562_data *tas2562, int bitwidth) TAS2562_TDM_CFG2, TAS2562_TDM_CFG2_RXWLEN_MASK, TAS2562_TDM_CFG2_RXWLEN_16B); - tas2562->v_sense_slot = tas2562->i_sense_slot + 2; break; case SNDRV_PCM_FORMAT_S24_LE: snd_soc_component_update_bits(tas2562->component, TAS2562_TDM_CFG2, TAS2562_TDM_CFG2_RXWLEN_MASK, TAS2562_TDM_CFG2_RXWLEN_24B); - tas2562->v_sense_slot = tas2562->i_sense_slot + 4; break; case SNDRV_PCM_FORMAT_S32_LE: snd_soc_component_update_bits(tas2562->component, TAS2562_TDM_CFG2, TAS2562_TDM_CFG2_RXWLEN_MASK, TAS2562_TDM_CFG2_RXWLEN_32B); - tas2562->v_sense_slot = tas2562->i_sense_slot + 4; break;
default: @@ -259,17 +270,27 @@ static int tas2562_set_bitwidth(struct tas2562_data *tas2562, int bitwidth) return -EINVAL; }
- ret = snd_soc_component_update_bits(tas2562->component, - TAS2562_TDM_CFG5, - TAS2562_TDM_CFG5_VSNS_EN | TAS2562_TDM_CFG5_VSNS_SLOT_MASK, - TAS2562_TDM_CFG5_VSNS_EN | tas2562->v_sense_slot); + val = snd_soc_component_read(tas2562->component, TAS2562_PWR_CTRL); + if (val < 0) + return val; + + if (val & (1 << TAS2562_VSENSE_POWER_EN)) + sense_en = 0; + else + sense_en = TAS2562_TDM_CFG5_VSNS_EN; + + ret = snd_soc_component_update_bits(tas2562->component, TAS2562_TDM_CFG5, + TAS2562_TDM_CFG5_VSNS_EN, sense_en); if (ret < 0) return ret;
- ret = snd_soc_component_update_bits(tas2562->component, - TAS2562_TDM_CFG6, - TAS2562_TDM_CFG6_ISNS_EN | TAS2562_TDM_CFG6_ISNS_SLOT_MASK, - TAS2562_TDM_CFG6_ISNS_EN | tas2562->i_sense_slot); + if (val & (1 << TAS2562_ISENSE_POWER_EN)) + sense_en = 0; + else + sense_en = TAS2562_TDM_CFG6_ISNS_EN; + + ret = snd_soc_component_update_bits(tas2562->component, TAS2562_TDM_CFG6, + TAS2562_TDM_CFG6_ISNS_EN, sense_en); if (ret < 0) return ret;
@@ -645,9 +666,25 @@ static int tas2562_parse_dt(struct tas2562_data *tas2562)
ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no", &tas2562->i_sense_slot); - if (ret) - dev_err(dev, "Looking up %s property failed %d\n", - "ti,imon-slot-no", ret); + if (ret) { + dev_err(dev, "Property %s is missing setting default slot\n", + "ti,imon-slot-no"); + tas2562->i_sense_slot = 0; + } + + + ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no", + &tas2562->v_sense_slot); + if (ret) { + dev_info(dev, "Property %s is missing setting default slot\n", + "ti,vmon-slot-no"); + tas2562->v_sense_slot = 2; + } + + if (tas2562->v_sense_slot < tas2562->i_sense_slot) { + dev_err(dev, "Vsense slot must be greater than Isense slot\n"); + return -EINVAL; + }
return ret; }
Convert the TAS2562 text file to yaml format.
Signed-off-by: Dan Murphy dmurphy@ti.com --- .../devicetree/bindings/sound/tas2562.txt | 37 --------- .../devicetree/bindings/sound/tas2562.yaml | 77 +++++++++++++++++++ 2 files changed, 77 insertions(+), 37 deletions(-) delete mode 100644 Documentation/devicetree/bindings/sound/tas2562.txt create mode 100644 Documentation/devicetree/bindings/sound/tas2562.yaml
diff --git a/Documentation/devicetree/bindings/sound/tas2562.txt b/Documentation/devicetree/bindings/sound/tas2562.txt deleted file mode 100644 index dc6d7362ded7..000000000000 --- a/Documentation/devicetree/bindings/sound/tas2562.txt +++ /dev/null @@ -1,37 +0,0 @@ -Texas Instruments TAS2562 Smart PA - -The TAS2562 is a mono, digital input Class-D audio amplifier optimized for -efficiently driving high peak power into small loudspeakers. -Integrated speaker voltage and current sense provides for -real time monitoring of loudspeaker behavior. - -Required properties: - - #address-cells - Should be <1>. - - #size-cells - Should be <0>. - - compatible: - Should contain "ti,tas2562", "ti,tas2563". - - reg: - The i2c address. Should be 0x4c, 0x4d, 0x4e or 0x4f. - - ti,imon-slot-no:- TDM TX current sense time slot. - - ti,vmon-slot-no:- TDM TX voltage sense time slot. This slot must always be - greater then ti,imon-slot-no. - -Optional properties: -- interrupt-parent: phandle to the interrupt controller which provides - the interrupt. -- interrupts: (GPIO) interrupt to which the chip is connected. -- shut-down-gpio: GPIO used to control the state of the device. - -Examples: -tas2562@4c { - #address-cells = <1>; - #size-cells = <0>; - compatible = "ti,tas2562"; - reg = <0x4c>; - - interrupt-parent = <&gpio1>; - interrupts = <14>; - - shut-down-gpio = <&gpio1 15 0>; - ti,imon-slot-no = <0>; - ti,vmon-slot-no = <1>; -}; - diff --git a/Documentation/devicetree/bindings/sound/tas2562.yaml b/Documentation/devicetree/bindings/sound/tas2562.yaml new file mode 100644 index 000000000000..1fb467e14d4c --- /dev/null +++ b/Documentation/devicetree/bindings/sound/tas2562.yaml @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause) +# Copyright (C) 2019 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/sound/tas2562.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Texas Instruments TAS2562 Smart PA + +maintainers: + - Dan Murphy dmurphy@ti.com + +description: | + The TAS2562 is a mono, digital input Class-D audio amplifier optimized for + efficiently driving high peak power into small loudspeakers. + Integrated speaker voltage and current sense provides for + real time monitoring of loudspeaker behavior. + +properties: + compatible: + enum: + - ti,tas2562 + - ti,tas2563 + + reg: + maxItems: 1 + description: | + I2C address of the device can be one of these 0x4c, 0x4d, 0x4e or 0x4f + + shut-down-gpio: + description: GPIO used to control the state of the device. + deprecated: true + + shutdown-gpio: + description: GPIO used to control the state of the device. + + interrupts: + maxItems: 1 + + ti,imon-slot-no: + $ref: /schemas/types.yaml#/definitions/uint32 + description: TDM TX current sense time slot. + + ti,vmon-slot-no: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + TDM TX voltage sense time slot. This slot must always be greater then + ti,imon-slot-no. + + '#sound-dai-cells': + const: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + codec: codec@4c { + compatible = "ti,tas2562"; + reg = <0x4c>; + #sound-dai-cells = <1>; + interrupt-parent = <&gpio1>; + interrupts = <14>; + shutdown-gpio = <&gpio1 15 0>; + ti,imon-slot-no = <0>; + ti,vmon-slot-no = <2>; + }; + }; + +...
On Wed, 24 Jun 2020 12:49:25 -0500, Dan Murphy wrote:
This series fixes issues tih the shut-down gpio device tree allocation and a code format issue found.
While working on a project slot programming for the tx and rx paths needed to be enabled. In addition the vsense slot programming needed to be configurable and not directly a simpler adder to the isense slot.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/6] ASoC: tas2562: Fix shut-down gpio property commit: 6f81e520b2906258a063f09b8d1dd9d0cc6a3172 [2/6] ASoC: tas2562: Update shutdown GPIO property commit: bc07b54459cbb3a572a78b5c200ff79ef11b8158 [3/6] ASoC: tas2562: Fix format issue for extra space before a comma commit: c8294da2ed0be726bb87019eba3a6367c7f1c922 [4/6] ASoC: tas2562: Add rx and tx slot programming (no commit info) [5/6] dt-bindings: tas2562: Add voltage sense slot property (no commit info) [6/6] ASoC: tas2562: Add voltage sense slot configuration (no commit info)
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