Commit 1f817805 authored by Joerg Schambacher's avatar Joerg Schambacher Committed by Mark Brown

ASoC: Adds support for TAS575x to the pcm512x driver

Enables the existing pcm512x driver to control the almost
compatible TAS5754 and -76 amplifers. Both amplifiers support
only an I2C interface and the internal PLL must be always
on to provide necessary clocks to the amplifier section.
Tested on TAS5756 with support from Andreas Arbesser-Krasser
from Texas Instruments <a-krasser@ti.com>
Signed-off-by: default avatarJoerg Schambacher <joerg.hifiberry@gmail.com>
Link: https://lore.kernel.org/r/20230929150722.405415-1-joerg.hifiberry@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a9b696c8
...@@ -39,6 +39,8 @@ static const struct i2c_device_id pcm512x_i2c_id[] = { ...@@ -39,6 +39,8 @@ static const struct i2c_device_id pcm512x_i2c_id[] = {
{ "pcm5122", }, { "pcm5122", },
{ "pcm5141", }, { "pcm5141", },
{ "pcm5142", }, { "pcm5142", },
{ "tas5754", },
{ "tas5756", },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
...@@ -49,6 +51,8 @@ static const struct of_device_id pcm512x_of_match[] = { ...@@ -49,6 +51,8 @@ static const struct of_device_id pcm512x_of_match[] = {
{ .compatible = "ti,pcm5122", }, { .compatible = "ti,pcm5122", },
{ .compatible = "ti,pcm5141", }, { .compatible = "ti,pcm5141", },
{ .compatible = "ti,pcm5142", }, { .compatible = "ti,pcm5142", },
{ .compatible = "ti,tas5754", },
{ .compatible = "ti,tas5756", },
{ } { }
}; };
MODULE_DEVICE_TABLE(of, pcm512x_of_match); MODULE_DEVICE_TABLE(of, pcm512x_of_match);
......
...@@ -48,6 +48,7 @@ struct pcm512x_priv { ...@@ -48,6 +48,7 @@ struct pcm512x_priv {
int mute; int mute;
struct mutex mutex; struct mutex mutex;
unsigned int bclk_ratio; unsigned int bclk_ratio;
int force_pll_on;
}; };
/* /*
...@@ -1258,10 +1259,34 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ...@@ -1258,10 +1259,34 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream,
return ret; return ret;
} }
ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, if (!pcm512x->force_pll_on) {
PCM512x_PLLE, 0); ret = regmap_update_bits(pcm512x->regmap,
PCM512x_PLL_EN, PCM512x_PLLE, 0);
} else {
/* provide minimum PLL config for TAS575x clocking
* and leave PLL enabled
*/
ret = regmap_write(pcm512x->regmap,
PCM512x_PLL_COEFF_0, 0x01);
if (ret != 0) { if (ret != 0) {
dev_err(component->dev, "Failed to disable pll: %d\n", ret); dev_err(component->dev,
"Failed to set pll coefficient: %d\n", ret);
return ret;
}
ret = regmap_write(pcm512x->regmap,
PCM512x_PLL_COEFF_1, 0x04);
if (ret != 0) {
dev_err(component->dev,
"Failed to set pll coefficient: %d\n", ret);
return ret;
}
ret = regmap_write(pcm512x->regmap,
PCM512x_PLL_EN, 0x01);
dev_dbg(component->dev, "Enabling PLL for TAS575x\n");
}
if (ret != 0) {
dev_err(component->dev, "Failed to set pll mode: %d\n", ret);
return ret; return ret;
} }
} }
...@@ -1659,6 +1684,11 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) ...@@ -1659,6 +1684,11 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap)
ret = -EINVAL; ret = -EINVAL;
goto err_pm; goto err_pm;
} }
if (!strcmp(np->name, "tas5756") ||
!strcmp(np->name, "tas5754"))
pcm512x->force_pll_on = 1;
dev_dbg(dev, "Device ID: %s\n", np->name);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment