ASoC: tas2552: Support TI TAS2552 Amplifier
PATCH v6 1/1 ASoC: tas2552: Support TI TAS2552 Amplifier
Support the TI TAS2552 Class D amplifier.
The TAS2552 is a high efficiency Class-D audio power amplifier with advanced battery current management and an integrated Class-G boost The device constantly measures the
current and voltage across the load and provides a digital stream of this information.
---
v6 - Addressed comments from v5 also added PLL algorithim instead of
hard coding PLL registers - https://patchwork.kernel.org/patch/4476001/
v5 - Consolidated dai_fmt call back to write serial control register
once - https://patchwork.kernel.org/patch/4474531/
v4 - Added pm_runtime support, removed magical numbers, added regulator support, changed from legacy gpio to new gpiod calls, fixed default register values, flipped on battery tracking support and
added suspend/resume support - https://patchwork.kernel.org/patch/4465611/
v3 - Updated bindings doc per comments, rearranged probe pdata vs
np check - https://patchwork.kernel.org/patch/4453481/
v2 - Address RFC comments- Added regmap, and snd_soc calls
removed debug code, address checkpatch errors -https://patchwork.kernel.org/patch/4378281/
.../devicetree/bindings/sound/tas2552.txt | 25 + include/sound/tas2552-plat.h | 25 + sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tas2552.c | 538 ++++++++++++++++++++ sound/soc/codecs/tas2552.h | 129 +++++ 6 files changed, 724 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tas2552.txt create mode 100644 include/sound/tas2552-plat.h create mode 100644 sound/soc/codecs/tas2552.c create mode 100644 sound/soc/codecs/tas2552.h
Documentation/devicetree/bindings/sound/tas2552.txt new file +25 -0
@@ -0,0 +1,25 @@ +Texas Instruments - tas2552 Codec module + +The tas2552 serial control bus communicates through I2C protocols + +Required properties: + +- compatible - One of: + "ti,tas2552" - TAS2552 + +- reg - I2C slave address + +Optional properties: + +- enable-gpio - gpio pin to enable/disable the device + +Example: + +tas2552: tas2552@41 { + compatible = "ti,tas2552"; + reg = <0x41>; + enable-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>; +}; + +For more product information please see the link below: +http://www.ti.com/product/TAS2552
include/sound/tas2552-plat.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* TAS2552 driver platform header +* +* Copyright (C) 2014 Texas Instruments Inc. +* +* Author: Dan Murphy <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +*/ + +#ifndef TAS2552_PLAT_H +#define TAS2552_PLAT_H + +struct tas2552_platform_data { +int enable_gpio; +}; + +#endif
sound/soc/codecs/Kconfig +5 -0
@@ -99,6 +99,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_TLV320AIC32X4 if I2C select SND_SOC_TLV320AIC3X if I2C select SND_SOC_TPA6130A2 if I2C + select SND_SOC_TAS2552 if I2C select SND_SOC_TLV320DAC33 if I2C select SND_SOC_TWL4030 if TWL4030_CORE select SND_SOC_TWL6040 if TWL6040_CORE
@@ -754,4 +755,8 @@ config SND_SOC_TPA6130A2 tristate "Texas Instruments TPA6130A2 headphone amplifier" depends on I2C +config SND_SOC_TAS2552 + tristate "Texas Instruments TAS2552 Mono Audio amplifier" + depends on I2C + endmenu
sound/soc/codecs/Makefile +2 -0
@@ -162,6 +162,7 @@ snd-soc-wm-hubs-objs := wm_hubs.o # Amp snd-soc-max9877-objs := max9877.o snd-soc-tpa6130a2-objs := tpa6130a2.o +snd-soc-tas2552-objs := tas2552.o obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o obj-$(CONFIG_SND_SOC_AB8500_CODEC) += snd-soc-ab8500-codec.o
@@ -325,3 +326,4 @@ obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o # Amp obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o obj-$(CONFIG_SND_SOC_TPA6130A2) += snd-soc-tpa6130a2.o +obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o
sound/soc/codecs/tas2552.c new file +538 -0
538 lines not on this page · raw message
sound/soc/codecs/tas2552.h new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Mark Brown
maintainersound/soc/codecs/Kconfig config SND_SOC_TPA6130A2 · line 762
Quoted 9 lines · Dan Murphy
sound/soc/codecs/Kconfig +4
-0@@ -754,4 +755,8 @@ config SND_SOC_TPA6130A2 tristate "Texas Instruments TPA6130A2 headphone amplifier" depends on I2C +config SND_SOC_TAS2552 + tristate "Texas Instruments TAS2552 Mono Audio amplifier" + depends on I2C + endmenu
Keep this and Makefile sorted - since this is a proper CODEC driver it should be in with the CODECs and also sorted in alphabetical order.
Quoted 7 lines
sound/soc/codecs/tas2552.c new file +7
-0+static int tas2552_startup (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_codec *codec = dai->codec; + +pm_runtime_get_sync (codec->dev); +
sound/soc/codecs/tas2552.c line 288
Quoted 10 lines
sound/soc/codecs/tas2552.c new file +10
-0+return 0 ; +} + +static void tas2552_shutdown (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_codec *codec = dai->codec; + +pm_runtime_put (codec->dev); +}
These runtime calls should be redundant, the framework should hold a runtime PM reference on devices while they are active. Does this not work for you?
Review
Quoted 1 line
(quoted diff) +1
-0+ pm_runtime_get_sync(codec->dev);
Check the return value here.
sound/soc/codecs/tas2552.c line 371
Quoted 3 lines
sound/soc/codecs/tas2552.c new file +3
-0+snd_soc_write (codec,TAS2552_CFG_2 ,TAS2552_CLASSD_EN | +TAS2552_BOOST_EN |TAS2552_APT_EN | +TAS2552_PLL_ENABLE |TAS2552_LIM_EN );
The PLL is enabled all the time not via DAPM or similar (it's never disabled)?
Quoted 4 lines
sound/soc/codecs/tas2552.c new file +4
-0+static int tas2552_resume (struct snd_soc_codec *codec) +{ +struct tas2552_data *tas2552 =snd_soc_codec_get_drvdata (codec); +int ret;
sound/soc/codecs/tas2552.c line 415
Quoted 10 lines
sound/soc/codecs/tas2552.c new file +10
-0+ + ret =regulator_bulk_enable (ARRAY_SIZE (tas2552->supplies), + tas2552->supplies); + +if (ret !=0 ) { +dev_err (codec->dev,"Failed to enable supplies: %d\n" , + ret); + } + +pm_runtime_get_sync (codec->dev);
Remove these runtime PM calls from suspend and resume, they're not doing what you think (and will prevent runtime PM from doing anything). Let the frameworks worry about it for now, or explicitly call the runtime suspend and resume operators if and only if the device is runtime active.
sound/soc/codecs/tas2552.c line 482
Quoted 7 lines
sound/soc/codecs/tas2552.c new file +7
-0+for (i =0 ; i <ARRAY_SIZE (data->supplies); i++) + data->supplies[i].supply = tas2552_supply_names[i]; + + ret =devm_regulator_bulk_get (dev,ARRAY_SIZE (data->supplies), + data->supplies); +if (ret !=0 ) +dev_err (dev,"Failed to request supplies: %d\n" , ret);
These supplies are mandatory (as they should be) but weren't mentioned in the DT binding - please add them there.
sound/soc/codecs/tas2552.c line 511
Quoted 4 lines
sound/soc/codecs/tas2552.c new file +4
-0+static const struct i2c_device_id tas2552_id[] = { + {"tas2552-codec" ,0 }, + { } +};
No -codec.
Quoted 6 lines · Mark Brown
Quoted 4 lines · Dan Murphy
sound/soc/codecs/Kconfig +0
-0@@ -754,4 +755,8 @@ config SND_SOC_TPA6130A2 tristate "Texas Instruments TPA6130A2 headphone amplifier" depends on I2C
Quoted 7 lines
sound/soc/codecs/Kconfig config SND_SOC_TPA6130A2 · line 762
Quoted 5 lines
sound/soc/codecs/Kconfig +4
-0+config SND_SOC_TAS2552 + tristate "Texas Instruments TAS2552 Mono Audio amplifier" + depends on I2C + endmenuKeep this and
Makefilesorted - since this is a proper CODEC driver it should be in with the CODECs and also sorted in alphabetical order.
OK. I was trying to stay away from a conflict by adding to the bottom of the file.
Quoted 13 lines
Quoted 13 lines
sound/soc/codecs/tas2552.c new file +12
-0+static int tas2552_startup (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_codec *codec = dai->codec; + +pm_runtime_get_sync (codec->dev); + +return 0 ; +} + +static void tas2552_shutdown (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai)
Quoted 8 lines
sound/soc/codecs/tas2552.c line 288
Quoted 5 lines
sound/soc/codecs/tas2552.c new file +5
-0+{ +struct snd_soc_codec *codec = dai->codec; + +pm_runtime_put (codec->dev); +}These runtime calls should be redundant, the framework should hold a runtime PM reference on devices while they are active. Does this not work for you?
I will verify that the calls get called.
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ pm_runtime_get_sync(codec->dev);Check the return value here.
OK
Quoted 6 lines
sound/soc/codecs/tas2552.c line 371
Quoted 4 lines
sound/soc/codecs/tas2552.c new file +3
-0+snd_soc_write (codec,TAS2552_CFG_2 ,TAS2552_CLASSD_EN | +TAS2552_BOOST_EN |TAS2552_APT_EN | +TAS2552_PLL_ENABLE |TAS2552_LIM_EN );The PLL is enabled all the time not via DAPM or similar (it's never disabled)?
Good catch. I will make sure the PLL Is disabled in the shutdown call.
Quoted 12 lines
Quoted 12 lines
sound/soc/codecs/tas2552.c new file +11
-0+static int tas2552_resume (struct snd_soc_codec *codec) +{ +struct tas2552_data *tas2552 =snd_soc_codec_get_drvdata (codec); +int ret; + + ret =regulator_bulk_enable (ARRAY_SIZE (tas2552->supplies), + tas2552->supplies); + +if (ret !=0 ) { +dev_err (codec->dev,"Failed to enable supplies: %d\n" , + ret);
Quoted 8 lines
sound/soc/codecs/tas2552.c line 277
Quoted 3 lines
sound/soc/codecs/tas2552.c new file +3
-0+ } + +pm_runtime_get_sync (codec->dev);Remove these runtime PM calls from suspend and resume, they're not doing what you think (and will prevent runtime PM from doing anything). Let the frameworks worry about it for now, or explicitly call the runtime suspend and resume operators if and only if the device is runtime active.
OK
Quoted 10 lines
sound/soc/codecs/tas2552.c line 482
Quoted 8 lines
sound/soc/codecs/tas2552.c new file +7
-0+for (i =0 ; i <ARRAY_SIZE (data->supplies); i++) + data->supplies[i].supply = tas2552_supply_names[i]; + + ret =devm_regulator_bulk_get (dev,ARRAY_SIZE (data->supplies), + data->supplies); +if (ret !=0 ) +dev_err (dev,"Failed to request supplies: %d\n" , ret);These supplies are mandatory (as they should be) but weren't mentioned in the DT binding - please add them there.
Will add
Quoted 6 lines
sound/soc/codecs/tas2552.c line 511
Quoted 5 lines
sound/soc/codecs/tas2552.c new file +4
-0+static const struct i2c_device_id tas2552_id[] = { + {"tas2552-codec" ,0 }, + { } +};No -codec.
Missed this one
Signature · 2 lines
------------------ Dan Murphy
Mark Brown
maintainerQuoted 11 lines · Dan
Quoted 8 lines · Mark Brown
sound/soc/codecs/Kconfig config SND_SOC_TPA6130A2 · line 762
Quoted 5 lines
sound/soc/codecs/Kconfig +4
-0+config SND_SOC_TAS2552 + tristate "Texas Instruments TAS2552 Mono Audio amplifier" + depends on I2C + endmenuKeep this and
Makefilesorted - since this is a proper CODEC driver it should be in with the CODECs and also sorted in alphabetical order.
Quoted 2 lines
OK. I was trying to stay away from a conflict by adding to the bottom of the file.
The whole point is to avoid conflicts - if everyone adds at the bottom of the file any two adds are pretty much guaranteed to conflict either on application or on merge. Sorting avoids most of these and makes any that do occur much clearer.
Mark
Quoted 9 lines · Mark Brown
Quoted 8 lines · Dan
Quoted 7 lines · Mark Brown
sound/soc/codecs/Kconfig config SND_SOC_TPA6130A2 · line 762
Quoted 5 lines
sound/soc/codecs/Kconfig +4
-0+config SND_SOC_TAS2552 + tristate "Texas Instruments TAS2552 Mono Audio amplifier" + depends on I2C + endmenuKeep this and
Makefilesorted - since this is a proper CODEC driver it should be in with the CODECs and also sorted in alphabetical order.
Quoted 6 lines
Quoted 2 lines
OK. I was trying to stay away from a conflict by adding to the bottom of the file.
The whole point is to avoid conflicts - if everyone adds at the bottom of the file any two adds are pretty much guaranteed to conflict either on application or on merge. Sorting avoids most of these and makes any that do occur much clearer.
No worries I will fix it
Signature · 2 lines
------------------ Dan Murphy