Add support for TI TAS6424 digital amplifier
Subsystems (3)
v3 cover Add support for TI TAS6424 digital amplifier
Hello all,
This two-patch series adds the dt bindings, driver, and other related changes for the TAS6424 digital amplifier. I am upstreaming this driver on behalf of Andreas.
Regards,
Michael Stecklein <[email protected]>
Changes since v2:
- fixed binding as per Rob Herring's comments on v2
Changes since v1:
- rebased on 4.13-rc1
Original v1 patches:
- https://patchwork.kernel.org/patch/9795235/
- https://patchwork.kernel.org/patch/9795237/
Andreas Dannenberg (1):
ASoC: add support for TAS6424 digital amplifier
Michael Stecklein (1):
dt-bindings: sound: add bindings for TAS6424
.../devicetree/bindings/sound/ti,tas6424.txt | 28 + sound/soc/codecs/Kconfig | 8 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tas6424.c | 755 +++++++++++++++++++++ sound/soc/codecs/tas6424.h | 127 ++++ 5 files changed, 920 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ti,tas6424.txt create mode 100644 sound/soc/codecs/tas6424.c create mode 100644 sound/soc/codecs/tas6424.h
Signature · 1 line
2.7.4
PATCH v3 1/2 dt-bindings: sound: add bindings for TAS6424
Add the bindings for the TAS6424 digital amplifier.
--- .../devicetree/bindings/sound/ti,tas6424.txt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ti,tas6424.txt
Documentation/devicetree/bindings/sound/ti,tas6424.txt new file +28 -0
@@ -0,0 +1,28 @@ +Texas Instruments TAS6424 Quad-Channel Audio amplifier + +The TAS6424 serial control bus communicates through I2C protocols. + +Required properties: + - compatible - One of: "ti,tas6424" - TAS6424 + - reg - I2C slave address + - sound-dai-cells: must be equal to 0 + +Optional properties: + - pinctrl-names, pinctrl-0 - Please refer to pinctrl-bindings.txt + +Example: + +tas6424: tas6424@6a { + + compatible = "ti,tas6424"; + reg = <0x6a>; + + #sound-dai-cells = <0>; + + pinctrl-names = "default"; + pinctrl-0 = <&tas6424_int_pin>; + interrupts-extended = <&gpio1 28 IRQ_TYPE_EDGE_FALLING>; +}; + +For more product information please see the link below: +http://www.ti.com/product/TAS6424-Q1
Signature · 1 line
2.7.4
Re: [PATCH v3 1/2] dt-bindings: sound: add bindings for TAS6424
Quoted 7 lines · Michael Stecklein
Add the bindings for the TAS6424 digital amplifier.
Signed-off-by Michael Stecklein <[email protected]>--- .../devicetree/bindings/sound/ti,tas6424.txt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ti,tas6424.txt
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/2 ASoC: add support for TAS6424 digital amplifier
In reply to Michael SteckleinFrom: Andreas Dannenberg <[email protected]>
The Texas Instruments TAS6424 device is a high-efficiency quad-channel Class-D audio power amplifier. Its digital time division multiplexed (TDM) interface enables up to 2 devices to share the same bus, supporting a total of eight channels from one audio serial port.
This is an initial version of the driver that does not yet support all device capabilities.
--- sound/soc/codecs/Kconfig | 8 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tas6424.c | 755 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/tas6424.h | 127 ++++++++ 4 files changed, 892 insertions(+) create mode 100644 sound/soc/codecs/tas6424.c create mode 100644 sound/soc/codecs/tas6424.h
sound/soc/codecs/Kconfig +8 -0
@@ -146,6 +146,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_TAS5086 if I2C select SND_SOC_TAS571X if I2C select SND_SOC_TAS5720 if I2C + select SND_SOC_TAS6424 if I2C select SND_SOC_TFA9879 if I2C select SND_SOC_TLV320AIC23_I2C if I2C select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
@@ -865,6 +866,13 @@ config SND_SOC_TAS5720 Enable support for Texas Instruments TAS5720L/M high-efficiency mono Class-D audio power amplifiers. +config SND_SOC_TAS6424 + tristate "Texas Instruments TAS6424 Quad-Channel Audio amplifier" + depends on I2C + help + Enable support for Texas Instruments TAS6424 high-efficiency + digital input quad-channel Class-D audio power amplifiers. + config SND_SOC_TFA9879 tristate "NXP Semiconductors TFA9879 amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -153,6 +153,7 @@ snd-soc-sti-sas-objs := sti-sas.o snd-soc-tas5086-objs := tas5086.o snd-soc-tas571x-objs := tas571x.o snd-soc-tas5720-objs := tas5720.o +snd-soc-tas6424-objs := tas6424.o snd-soc-tfa9879-objs := tfa9879.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
@@ -386,6 +387,7 @@ obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o +obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
sound/soc/codecs/tas6424.c new file +755 -0
755 lines not on this page · raw message
sound/soc/codecs/tas6424.h new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.7.4
Mark Brown
maintainerRe: [PATCH v3 2/2] ASoC: add support for TAS6424 digital amplifier
sound/soc/codecs/tas6424.c line 177
Quoted 4 lines · Michael Stecklein
sound/soc/codecs/tas6424.c new file +4
-0+if (!tx_mask) { +dev_err (codec->dev,"tdm mask must not be 0\n" ); +return -EINVAL ; + }
Setting the mask to 0 is used when turning off TDM.
sound/soc/codecs/tas6424.c line 340
Quoted 5 lines
sound/soc/codecs/tas6424.c new file +5
-0+if ((reg &TAS6424_WARN_VDD_UV ) && !(tas6424->last_warn &TAS6424_WARN_VDD_UV )) +dev_warn (dev,"experienced a VDD under voltage condition\n" ); + +if ((reg &TAS6424_WARN_VDD_POR ) && !(tas6424->last_warn &TAS6424_WARN_VDD_POR )) +dev_warn (dev,"experienced a VDD POR condition\n" );
These look like they are errors rather than warnings and should be critical prints like the other errors.
sound/soc/codecs/tas6424.c line 358
Quoted 2 lines
sound/soc/codecs/tas6424.c new file +2
-0+/* Store current warn value so we can detect any changes next time */ + tas6424->last_warn = reg;
It would be better to clear these at some point, perhaps after a delay. Especially with thermal issues they could come and go over device operation.
sound/soc/codecs/tas6424.c line 389
Quoted 13 lines
sound/soc/codecs/tas6424.c new file +13
-0+static int tas6424_codec_probe (struct snd_soc_codec *codec) +{ +struct tas6424_data *tas6424 =snd_soc_codec_get_drvdata (codec); +int ret; + + tas6424->codec = codec; + + ret =regulator_bulk_enable (ARRAY_SIZE (tas6424->supplies), + tas6424->supplies); +if (ret !=0 ) { +dev_err (codec->dev,"failed to enable supplies: %d\n" , ret); +return ret; + }
This init stuff should be in either the main I2C probe, DAPM or bias level management. The CODEC probe should be very minimal.
sound/soc/codecs/tas6424.c line 449
Quoted 3 lines
sound/soc/codecs/tas6424.c new file +2
-0+if (event &SND_SOC_DAPM_POST_PMU ) { + }else if (event &SND_SOC_DAPM_PRE_PMD ) {
You're trying to write a switch statement here.
sound/soc/codecs/tas6424.c line 512
Quoted 5 lines
sound/soc/codecs/tas6424.c new file +5
-0+switch (level) { +case SND_SOC_BIAS_ON : +case SND_SOC_BIAS_PREPARE : +msleep (500 ); +break ;
You need a 500ms sleep in all these cases? That's a lot of sleeping.
Quoted 9 lines
sound/soc/codecs/tas6424.c new file +9
-0+case SND_SOC_BIAS_STANDBY : + ret =snd_soc_update_bits (codec,TAS6424_CH_STATE_CTRL_REG , +0xff ,TAS6424_CH1_STATE_MUTE |TAS6424_CH2_STATE_MUTE | +TAS6424_CH3_STATE_MUTE |TAS6424_CH4_STATE_MUTE ); + +if (ret <0 ) { +dev_err (codec->dev,"error resuming device: %d\n" , ret); +return ret; + }
sound/soc/codecs/tas6424.c line 531
Quoted 10 lines
sound/soc/codecs/tas6424.c new file +10
-0+break ; +case SND_SOC_BIAS_OFF : + ret =snd_soc_update_bits (codec,TAS6424_CH_STATE_CTRL_REG , +0xff ,TAS6424_CH1_STATE_HIZ |TAS6424_CH2_STATE_HIZ | +TAS6424_CH3_STATE_HIZ |TAS6424_CH4_STATE_HIZ ); + +if (ret <0 ) { +dev_err (codec->dev,"error suspending device: %d\n" , ret); +return ret; + }
These mutes seem very random disassociated from anything else?
Re: [PATCH v3 2/2] ASoC: add support for TAS6424 digital amplifier
Quoted 7 lines · Mark Brown
sound/soc/codecs/tas6424.c line 177
Quoted 4 lines · Michael Stecklein
sound/soc/codecs/tas6424.c new file +4
-0+if (!tx_mask) { +dev_err (codec->dev,"tdm mask must not be 0\n" ); +return -EINVAL ; + }Setting the mask to 0 is used when turning off TDM.
When turning off TDM, will the set_tdm_slot function ever get called? (Since the TDM was turned off the slots don't need to be set.) Also, for this device TDM mode is automatically selected based on the presence of a TDM clock, so there is nothing to do to switch into or out of TDM mode. Similar parts handle this the same way, such as: tlv320aic3x.c, tas2552.c, tas5720.c, ssm4567.c
Quoted 8 lines
sound/soc/codecs/tas6424.c line 340
Quoted 6 lines
sound/soc/codecs/tas6424.c new file +5
-0+if ((reg &TAS6424_WARN_VDD_UV ) && !(tas6424->last_warn &TAS6424_WARN_VDD_UV )) +dev_warn (dev,"experienced a VDD under voltage condition\n" ); + +if ((reg &TAS6424_WARN_VDD_POR ) && !(tas6424->last_warn &TAS6424_WARN_VDD_POR )) +dev_warn (dev,"experienced a VDD POR condition\n" );These look like they are errors rather than warnings and should be critical prints like the other errors.
These conditions happened on the previous shutdown/reset of the device. We are letting the user know about them, but they are not critical to the current device state, so I have left them as warnings.
Quoted 6 lines
sound/soc/codecs/tas6424.c line 358
Quoted 3 lines
sound/soc/codecs/tas6424.c new file +2
-0+/* Store current warn value so we can detect any changes next time */ + tas6424->last_warn = reg;It would be better to clear these at some point, perhaps after a delay. Especially with thermal issues they could come and go over device operation.
Since this function is called every 200ms, if an issue comes and goes, last_warn will be cleared during the next function call after the issue ends; the function regmap_read will read in a 0 for that flag's bit, and that new reg value will be saved. Therefore, the user will be warned only once if the issue is persistent, but rewarned if the issues leaves and comes back, so I do not think clearing after a delay is necessary.
Quoted 16 lines
Quoted 4 lines
sound/soc/codecs/tas6424.c new file +3
-0+static int tas6424_codec_probe (struct snd_soc_codec *codec) +{ +struct tas6424_data *tas6424 =snd_soc_codec_get_drvdata (codec);sound/soc/codecs/tas6424.c line 389
Quoted 10 lines
sound/soc/codecs/tas6424.c new file +10
-0+int ret; + + tas6424->codec = codec; + + ret =regulator_bulk_enable (ARRAY_SIZE (tas6424->supplies), + tas6424->supplies); +if (ret !=0 ) { +dev_err (codec->dev,"failed to enable supplies: %d\n" , ret); +return ret; + }This init stuff should be in either the main I2C probe, DAPM or bias level management. The CODEC probe should be very minimal.
This is a single codec device, does it make sense to leave the device running without its codec? Other single codec devices initialize regulators in codec probe similarly.
Quoted 4 lines
sound/soc/codecs/tas6424.c line 449
Quoted 3 lines
sound/soc/codecs/tas6424.c new file +2
-0+if (event &SND_SOC_DAPM_POST_PMU ) { + }else if (event &SND_SOC_DAPM_PRE_PMD ) {You're trying to write a switch statement here.
Acked.
Quoted 7 lines
sound/soc/codecs/tas6424.c line 512
Quoted 6 lines
sound/soc/codecs/tas6424.c new file +5
-0+switch (level) { +case SND_SOC_BIAS_ON : +case SND_SOC_BIAS_PREPARE : +msleep (500 ); +break ;You need a 500ms sleep in all these cases? That's a lot of sleeping.
Unfortunately, the device runs diagnostics at this point, which take upwards of 480ms.
Quoted 13 lines
Quoted 13 lines
sound/soc/codecs/tas6424.c new file +12
-0+case SND_SOC_BIAS_STANDBY : + ret =snd_soc_update_bits (codec,TAS6424_CH_STATE_CTRL_REG , +0xff ,TAS6424_CH1_STATE_MUTE |TAS6424_CH2_STATE_MUTE | +TAS6424_CH3_STATE_MUTE |TAS6424_CH4_STATE_MUTE ); + +if (ret <0 ) { +dev_err (codec->dev,"error resuming device: %d\n" , ret); +return ret; + } +break ; +case SND_SOC_BIAS_OFF : + ret = snd_soc_update_bits(codec, TAS6424_CH_STATE_CTRL_REG,
Quoted 8 lines
sound/soc/codecs/tas6424.c line 531
Quoted 7 lines
sound/soc/codecs/tas6424.c new file +7
-0+0xff ,TAS6424_CH1_STATE_HIZ |TAS6424_CH2_STATE_HIZ | + TAS6424_CH3_STATE_HIZ | TAS6424_CH4_STATE_HIZ); + +if (ret <0 ) { +dev_err (codec->dev,"error suspending device: %d\n" , ret); +return ret; + }These mutes seem very random disassociated from anything else?
What do you mean by this comment? The control register is set to STATE_MUTE and STATE_HIZ depending on what the device needs for the new BIAS level.
Mark Brown
maintainerRe: [PATCH v3 2/2] ASoC: add support for TAS6424 digital amplifier
Quoted 2 lines · Michael Stecklein
Quoted 1 line · Mark Brown
On Tue, Jul 18, 2017 at 02:20:04PM -0500, Michael Stecklein wrote:
Please leave blank lines between paragraphs, it makes things easier to read.
Quoted 9 lines
Quoted 6 lines
sound/soc/codecs/tas6424.c line 177
Quoted 4 lines
sound/soc/codecs/tas6424.c new file +4
-0+if (!tx_mask) { +dev_err (codec->dev,"tdm mask must not be 0\n" ); +return -EINVAL ; + }Setting the mask to 0 is used when turning off TDM.
When turning off TDM, will the
set_tdm_slotfunction ever get called? (Since the TDM was turned off the slots don't need to
Of course, that's how you turn off TDM mode.
Quoted 5 lines
be set.) Also, for this device TDM mode is automatically selected based on the presence of a TDM clock, so there is nothing to do to switch into or out of TDM mode. Similar parts handle this the same way, such as:
tlv320aic3x.c,tas2552.c,tas5720.c,ssm4567.c
It's possible there's bugs in older drivers, sometimes things get missed in review.
Quoted 9 lines
Quoted 8 lines
sound/soc/codecs/tas6424.c line 340
Quoted 5 lines
sound/soc/codecs/tas6424.c new file +5
-0+if ((reg &TAS6424_WARN_VDD_UV ) && !(tas6424->last_warn &TAS6424_WARN_VDD_UV )) +dev_warn (dev,"experienced a VDD under voltage condition\n" ); + +if ((reg &TAS6424_WARN_VDD_POR ) && !(tas6424->last_warn &TAS6424_WARN_VDD_POR )) +dev_warn (dev,"experienced a VDD POR condition\n" );These look like they are errors rather than warnings and should be critical prints like the other errors.
Quoted 4 lines
These conditions happened on the previous shutdown/reset of the device. We are letting the user know about them, but they are not critical to the current device state, so I have left them as warnings.
I'd expect errors from previous uses of the driver to be discarded, especially things that might've resulted from something like the reboot process.
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
sound/soc/codecs/tas6424.c new file +7
-0+static int tas6424_codec_probe (struct snd_soc_codec *codec) +{ +struct tas6424_data *tas6424 =snd_soc_codec_get_drvdata (codec); +int ret; + + tas6424->codec = codec; +Quoted 8 lines
sound/soc/codecs/tas6424.c line 389
Quoted 6 lines
sound/soc/codecs/tas6424.c new file +6
-0+ ret =regulator_bulk_enable (ARRAY_SIZE (tas6424->supplies), + tas6424->supplies); +if (ret !=0 ) { +dev_err (codec->dev,"failed to enable supplies: %d\n" , ret); +return ret; + }This init stuff should be in either the main I2C probe, DAPM or bias level management. The CODEC probe should be very minimal.
Quoted 3 lines
This is a single codec device, does it make sense to leave the device running without its codec? Other single codec devices initialize regulators in codec probe similarly.
I'm not sure what you mean by a "single CODEC device". Most devices are so CODEC enables in I2C probe and then either leave everything on all the time or manage the regulators with runtime power management of some kind (either actual runtime PM or DAPM). Managing things only in the ASoC level probe increases complexity and in actual running systems makes a marginal difference to real systems (you'd need to enable the CODEC but not the card).
Quoted 8 lines
Quoted 6 lines
sound/soc/codecs/tas6424.c line 512
Quoted 5 lines
sound/soc/codecs/tas6424.c new file +5
-0+switch (level) { +case SND_SOC_BIAS_ON : +case SND_SOC_BIAS_PREPARE : +msleep (500 ); +break ;You need a 500ms sleep in all these cases? That's a lot of sleeping.
Unfortunately, the device runs diagnostics at this point, which take upwards of 480ms.
On both entry to _ON and both entries to _PREPARE (from _ON and from _STANDBY)? How does the device know we made these state changes? It's a total sleep of 1s on power on.
Quoted 12 lines
Quoted 11 lines
sound/soc/codecs/tas6424.c line 531
Quoted 9 lines
sound/soc/codecs/tas6424.c new file +9
-0+case SND_SOC_BIAS_OFF : + ret =snd_soc_update_bits (codec,TAS6424_CH_STATE_CTRL_REG , +0xff ,TAS6424_CH1_STATE_HIZ |TAS6424_CH2_STATE_HIZ | +TAS6424_CH3_STATE_HIZ |TAS6424_CH4_STATE_HIZ ); + +if (ret <0 ) { +dev_err (codec->dev,"error suspending device: %d\n" , ret); +return ret; + }These mutes seem very random disassociated from anything else?
Quoted 3 lines
What do you mean by this comment? The control register is set to
STATE_MUTEandSTATE_HIZdepending on what the device needs for the new BIAS level.
This doesn't seem very joined up with the rest of the power control of the device - you're setting the high impedence state here, it's not clear what undoes that and there's other power control in the suspend and resume stuff. I didn't notice anything in a nearby place that cleared this state for example.