[PATCH v1 1/4] ASoC: dt-bindings: nxp,tfa989x: Add tfa9897 support
Document TFA9897 bindings.
Signed-off-by: Vincent Knecht vincent.knecht@mailoo.org --- Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml | 1 + 1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml index 45db5776550c..46ddc1f3fc0c 100644 --- a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml +++ b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml @@ -13,6 +13,7 @@ properties: compatible: enum: - nxp,tfa9895 + - nxp,tfa9897
reg: maxItems: 1
Add specific init function to poke needed registers & values for this IC
Signed-off-by: Vincent Knecht vincent.knecht@mailoo.org --- sound/soc/codecs/tfa989x.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c index 408e26eee108..6d94865c534b 100644 --- a/sound/soc/codecs/tfa989x.c +++ b/sound/soc/codecs/tfa989x.c @@ -44,6 +44,7 @@ #define TFA989X_CURRENTSENSE4 0x49
#define TFA9895_REVISION 0x12 +#define TFA9897_REVISION 0x97
struct tfa989x_rev { unsigned int rev; @@ -175,6 +176,29 @@ static const struct tfa989x_rev tfa9895_rev = { .init = tfa9895_init, };
+static int tfa9897_init(struct regmap *regmap) +{ + int ret; + + /* Reduce slewrate by clearing iddqtestbst to avoid booster damage */ + ret = regmap_write(regmap, TFA989X_CURRENTSENSE3, 0x0300); + if (ret) + return ret; + + /* Enable clipping */ + ret = regmap_clear_bits(regmap, TFA989X_CURRENTSENSE4, 0x1); + if (ret) + return ret; + + /* Set required TDM configuration */ + return regmap_write(regmap, 0x14, 0x0); +} + +static const struct tfa989x_rev tfa9897_rev = { + .rev = TFA9897_REVISION, + .init = tfa9897_init, +}; + /* * Note: At the moment this driver bypasses the "CoolFlux DSP" built into the * TFA989X amplifiers. Unfortunately, there seems to be absolutely @@ -280,6 +304,7 @@ static int tfa989x_i2c_probe(struct i2c_client *i2c)
static const struct of_device_id tfa989x_of_match[] = { { .compatible = "nxp,tfa9895", .data = &tfa9895_rev }, + { .compatible = "nxp,tfa9897", .data = &tfa9897_rev }, { } }; MODULE_DEVICE_TABLE(of, tfa989x_of_match);
On Fri, May 28, 2021 at 12:50:59PM +0200, Vincent Knecht wrote:
Add specific init function to poke needed registers & values for this IC
Signed-off-by: Vincent Knecht vincent.knecht@mailoo.org
sound/soc/codecs/tfa989x.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c index 408e26eee108..6d94865c534b 100644 --- a/sound/soc/codecs/tfa989x.c +++ b/sound/soc/codecs/tfa989x.c @@ -44,6 +44,7 @@ #define TFA989X_CURRENTSENSE4 0x49
#define TFA9895_REVISION 0x12 +#define TFA9897_REVISION 0x97
struct tfa989x_rev { unsigned int rev; @@ -175,6 +176,29 @@ static const struct tfa989x_rev tfa9895_rev = { .init = tfa9895_init, };
+static int tfa9897_init(struct regmap *regmap) +{
- int ret;
- /* Reduce slewrate by clearing iddqtestbst to avoid booster damage */
- ret = regmap_write(regmap, TFA989X_CURRENTSENSE3, 0x0300);
- if (ret)
return ret;
- /* Enable clipping */
- ret = regmap_clear_bits(regmap, TFA989X_CURRENTSENSE4, 0x1);
- if (ret)
return ret;
- /* Set required TDM configuration */
- return regmap_write(regmap, 0x14, 0x0);
For reference:
Sadly we didn't manage to figure out what exactly this register does. There are several TDM related registers but they are not really documented. Devices usually have fixed register values specified in some configuration file, but it's not clear how to set these in a generic way (e.g. based on dai->set_tdm_slot(), dai->set_tdm_slot() etc).
On the device where we tested TFA9897 it's just used with standard I2S so we didn't need any special TDM configuration(?). I suppose we can leave this open for future improvements if someone needs something different here.
So: Reviewed-by: Stephan Gerhold stephan@gerhold.net
Thanks! Stephan
+}
+static const struct tfa989x_rev tfa9897_rev = {
- .rev = TFA9897_REVISION,
- .init = tfa9897_init,
+};
/*
- Note: At the moment this driver bypasses the "CoolFlux DSP" built into the
- TFA989X amplifiers. Unfortunately, there seems to be absolutely
@@ -280,6 +304,7 @@ static int tfa989x_i2c_probe(struct i2c_client *i2c)
static const struct of_device_id tfa989x_of_match[] = { { .compatible = "nxp,tfa9895", .data = &tfa9895_rev },
- { .compatible = "nxp,tfa9897", .data = &tfa9897_rev }, { }
}; MODULE_DEVICE_TABLE(of, tfa989x_of_match); -- 2.31.1
Add optional vddd-supply property to allow regulator control.
Signed-off-by: Vincent Knecht vincent.knecht@mailoo.org --- Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml index 46ddc1f3fc0c..ffb8fcfeb629 100644 --- a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml +++ b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml @@ -27,6 +27,9 @@ properties: Used as prefix for sink/source names of the component. Must be a unique string among multiple instances of the same component.
+ vddd-supply: + description: regulator phandle for the VDDD power supply. + required: - compatible - reg
Allow specifying Vddd regulator/supply to be enabled on I2C probing.
Signed-off-by: Vincent Knecht vincent.knecht@mailoo.org --- sound/soc/codecs/tfa989x.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c index 6d94865c534b..643b45188b6f 100644 --- a/sound/soc/codecs/tfa989x.c +++ b/sound/soc/codecs/tfa989x.c @@ -10,6 +10,7 @@ #include <linux/i2c.h> #include <linux/module.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <sound/soc.h>
#define TFA989X_STATUSREG 0x00 @@ -51,6 +52,10 @@ struct tfa989x_rev { int (*init)(struct regmap *regmap); };
+struct tfa989x { + struct regulator *vddd_supply; +}; + static bool tfa989x_writeable_reg(struct device *dev, unsigned int reg) { return reg > TFA989X_REVISIONNUMBER; @@ -242,10 +247,18 @@ static int tfa989x_dsp_bypass(struct regmap *regmap) BIT(TFA989X_SYS_CTRL_AMPC)); }
+static void tfa989x_regulator_disable(void *data) +{ + struct tfa989x *tfa989x = data; + + regulator_disable(tfa989x->vddd_supply); +} + static int tfa989x_i2c_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; const struct tfa989x_rev *rev; + struct tfa989x *tfa989x; struct regmap *regmap; unsigned int val; int ret; @@ -256,10 +269,31 @@ static int tfa989x_i2c_probe(struct i2c_client *i2c) return -ENODEV; }
+ tfa989x = devm_kzalloc(dev, sizeof(*tfa989x), GFP_KERNEL); + if (!tfa989x) + return -ENOMEM; + + i2c_set_clientdata(i2c, tfa989x); + + tfa989x->vddd_supply = devm_regulator_get(dev, "vddd"); + if (IS_ERR(tfa989x->vddd_supply)) + return dev_err_probe(dev, PTR_ERR(tfa989x->vddd_supply), + "Failed to get vddd regulator\n"); + regmap = devm_regmap_init_i2c(i2c, &tfa989x_regmap); if (IS_ERR(regmap)) return PTR_ERR(regmap);
+ ret = regulator_enable(tfa989x->vddd_supply); + if (ret) { + dev_err(dev, "Failed to enable vddd regulator: %d\n", ret); + return ret; + } + + ret = devm_add_action_or_reset(dev, tfa989x_regulator_disable, tfa989x); + if (ret) + return ret; + /* Bypass regcache for reset and init sequence */ regcache_cache_bypass(regmap, true);
On Fri, May 28, 2021 at 12:51:01PM +0200, Vincent Knecht wrote:
Allow specifying Vddd regulator/supply to be enabled on I2C probing.
Signed-off-by: Vincent Knecht vincent.knecht@mailoo.org
Reviewed-by: Stephan Gerhold stephan@gerhold.net
sound/soc/codecs/tfa989x.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c index 6d94865c534b..643b45188b6f 100644 --- a/sound/soc/codecs/tfa989x.c +++ b/sound/soc/codecs/tfa989x.c @@ -10,6 +10,7 @@ #include <linux/i2c.h> #include <linux/module.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <sound/soc.h>
#define TFA989X_STATUSREG 0x00 @@ -51,6 +52,10 @@ struct tfa989x_rev { int (*init)(struct regmap *regmap); };
+struct tfa989x {
- struct regulator *vddd_supply;
+};
static bool tfa989x_writeable_reg(struct device *dev, unsigned int reg) { return reg > TFA989X_REVISIONNUMBER; @@ -242,10 +247,18 @@ static int tfa989x_dsp_bypass(struct regmap *regmap) BIT(TFA989X_SYS_CTRL_AMPC)); }
+static void tfa989x_regulator_disable(void *data) +{
- struct tfa989x *tfa989x = data;
- regulator_disable(tfa989x->vddd_supply);
+}
static int tfa989x_i2c_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; const struct tfa989x_rev *rev;
- struct tfa989x *tfa989x; struct regmap *regmap; unsigned int val; int ret;
@@ -256,10 +269,31 @@ static int tfa989x_i2c_probe(struct i2c_client *i2c) return -ENODEV; }
tfa989x = devm_kzalloc(dev, sizeof(*tfa989x), GFP_KERNEL);
if (!tfa989x)
return -ENOMEM;
i2c_set_clientdata(i2c, tfa989x);
tfa989x->vddd_supply = devm_regulator_get(dev, "vddd");
if (IS_ERR(tfa989x->vddd_supply))
return dev_err_probe(dev, PTR_ERR(tfa989x->vddd_supply),
"Failed to get vddd regulator\n");
regmap = devm_regmap_init_i2c(i2c, &tfa989x_regmap); if (IS_ERR(regmap)) return PTR_ERR(regmap);
ret = regulator_enable(tfa989x->vddd_supply);
if (ret) {
dev_err(dev, "Failed to enable vddd regulator: %d\n", ret);
return ret;
}
ret = devm_add_action_or_reset(dev, tfa989x_regulator_disable, tfa989x);
if (ret)
return ret;
/* Bypass regcache for reset and init sequence */ regcache_cache_bypass(regmap, true);
-- 2.31.1
On Fri, May 28, 2021 at 12:50:58PM +0200, Vincent Knecht wrote:
Document TFA9897 bindings.
Signed-off-by: Vincent Knecht vincent.knecht@mailoo.org
Reviewed-by: Stephan Gerhold stephan@gerhold.net
Thanks! Stephan
Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml | 1 + 1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml index 45db5776550c..46ddc1f3fc0c 100644 --- a/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml +++ b/Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml @@ -13,6 +13,7 @@ properties: compatible: enum: - nxp,tfa9895
- nxp,tfa9897
reg: maxItems: 1
-- 2.31.1
On Fri, 28 May 2021 12:50:58 +0200, Vincent Knecht wrote:
Document TFA9897 bindings.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: dt-bindings: nxp,tfa989x: Add tfa9897 support commit: 513df99993857863e42bf3d7d65d87c191ce9493 [2/4] ASoC: codecs: tfa989x: Add support for tfa9897 commit: 1ba1d69d8aa938f64cb07604b320a5074c3bb107 [3/4] ASoC: dt-bindings: nxp, tfa989x: Add vddd-supply property commit: 9cf1a98e2b0171e2586a13197a9a1ad605336166 [4/4] ASoC: codecs: tfa989x: Add support for optional vddd-supply commit: 8e5607e9941ce915187785bd09805bf7df9f7349
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 (3)
-
Mark Brown
-
Stephan Gerhold
-
Vincent Knecht