[PATCH 1/2] ASoC: codecs: tfa989x: Add support for tfa9890

Stephan Gerhold stephan at gerhold.net
Fri Jun 3 20:20:28 CEST 2022


On Thu, Jun 02, 2022 at 06:45:03PM +0200, Alexander Martinz wrote:
> The initialization sequence is taken from the version provided
> by the supplier [1].
> 
> This allows speakers using the TFA9890 amplifier to work, which are
> used by various mobile phones such as the SHIFT6mq.
> 
> [1]: https://source.codeaurora.org/external/mas/tfa98xx/tree/src/tfa_init.c?id=d2cd12931fbc48df988b62931fb9960d4e9dc05d#n1827
> 
> Signed-off-by: Alexander Martinz <amartinz at shiftphones.com>
> ---
>  sound/soc/codecs/tfa989x.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c
> index dc86852752c5..8ab2656de750 100644
> --- a/sound/soc/codecs/tfa989x.c
> +++ b/sound/soc/codecs/tfa989x.c
...
> @@ -188,6 +190,33 @@ static struct snd_soc_dai_driver tfa989x_dai = {
>  	.ops = &tfa989x_dai_ops,
>  };
>  
> +static int tfa9890_init(struct regmap *regmap)
> +{
> +	int ret;
> +
> +	/* unhide keys to allow updating them */

Nitpick: I think the magic number is the "key" to hide/unhide certain
*registers*. This comment implies that you are hiding *keys*.

Maybe just write something like

	/* temporarily allow access to hidden registers */
	...
	/* hide registers again */

With that fixed, feel free to add my

Reviewed-by: Stephan Gerhold <stephan at gerhold.net>

Thanks!
Stephan

> +	ret = regmap_write(regmap, TFA989X_HIDE_UNHIDE_KEY, 0x5a6b);
> +	if (ret)
> +		return ret;
> +
> +	/* update PLL registers */
> +	ret = regmap_set_bits(regmap, 0x59, 0x3);
> +	if (ret)
> +		return ret;
> +
> +	/* hide keys again */
> +	ret = regmap_write(regmap, TFA989X_HIDE_UNHIDE_KEY, 0x0000);
> +	if (ret)
> +		return ret;
> +
> +	return regmap_write(regmap, TFA989X_CURRENTSENSE2, 0x7BE1);
> +}
> +
> +static const struct tfa989x_rev tfa9890_rev = {
> +	.rev	= TFA9890_REVISION,
> +	.init	= tfa9890_init,
> +};
> +
k


More information about the Alsa-devel mailing list