[alsa-devel] [PATCH] ASoC: tlv320aic3x: Support for OCMV configuration

Peter Ujfalusi peter.ujfalusi at ti.com
Thu Aug 31 10:06:05 CEST 2017





Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

On 2017-08-31 11:00, Peter Ujfalusi wrote:
> In aic3x class of devices Output Common-Mode Voltage can be configured for
> better analog performance.
> The OCMV value depends on the Analog and digital domain power supply
> voltage configuration.
> 
> The default OCMV of 1.35V gives best performance when AVDD is around 2.7V
> and DVDD is 1.525V, but for higher AVDD/DVDD higher OCMV setting is
> recommended.
> 
> The patch gives an automatic way of guessing the best OCMV which can be
> overwritten by a DT parameter if needed.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi at ti.com>
> ---
>  .../devicetree/bindings/sound/tlv320aic3x.txt      |  5 +++
>  sound/soc/codecs/tlv320aic3x.c                     | 45 ++++++++++++++++++++++
>  sound/soc/codecs/tlv320aic3x.h                     |  8 ++++
>  3 files changed, 58 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt
> +static void aic3x_configure_ocmv(struct i2c_client *client)
> +{
> +	struct device_node *np = client->dev.of_node;
> +	struct aic3x_priv *aic3x = i2c_get_clientdata(client);
> +	u32 value;
> +	int dvdd, avdd;
> +
> +	if (np && !of_property_read_u32(np, "ai3x-ocmv", &value)) {
> +		/* OCMV setting is forced by DT */
> +		if (value <= 3) {
> +			aic3x->ocmv = value;
> +			return;
> +		}
> +	}
> +
> +	dvdd = regulator_get_voltage(aic3x->supplies[1].consumer);
> +	avdd = regulator_get_voltage(aic3x->supplies[2].consumer);
> +
> +	if (avdd > 3600000 || dvdd > 1950000) {
> +		dev_warn(&client->dev,
> +			 "Too high supply voltage(s) AVDD: %d, DVDD: %d\n",
> +			 avdd, dvdd);
> +	} else if (avdd == 3600000 && dvdd == 1950000) {
> +		aic3x->ocmv = HPOUT_SC_OCMV_1_8V;
> +	} else if (avdd > 3300000 && dvdd > 1800000) {
> +		aic3x->ocmv = HPOUT_SC_OCMV_1_65V;
> +	} else if (avdd > 3000000 && dvdd > 1650000) {
> +		aic3x->ocmv = HPOUT_SC_OCMV_1_5V;
> +	} else if (avdd > 2700000 && dvdd > 1525000) {

this should have been:
} else if (avdd >= 2700000 && dvdd >= 1525000) {

as AVDD 2.7V and DVDD 1.525V is the lowest supported supply voltages.

> +		aic3x->ocmv = HPOUT_SC_OCMV_1_35V;
> +	} else {
> +		dev_warn(&client->dev,
> +			 "Invalid supply voltage(s) AVDD: %d, DVDD: %d\n",
> +			 avdd, dvdd);
> +	}
> +}
> +
>  /*
>   * AIC3X 2 wire address can be up to 4 devices with device addresses
>   * 0x18, 0x19, 0x1A, 0x1B
> @@ -1816,6 +1859,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
>  		goto err_gpio;
>  	}
>  
> +	aic3x_configure_ocmv(i2c);
> +
>  	if (aic3x->model == AIC3X_MODEL_3007) {
>  		ret = regmap_register_patch(aic3x->regmap, aic3007_class_d,
>  					    ARRAY_SIZE(aic3007_class_d));
> diff --git a/sound/soc/codecs/tlv320aic3x.h b/sound/soc/codecs/tlv320aic3x.h
> index 89fa692df206..34c35196aa0d 100644
> --- a/sound/soc/codecs/tlv320aic3x.h
> +++ b/sound/soc/codecs/tlv320aic3x.h
> @@ -243,6 +243,14 @@
>  #define MICBIAS_LEVEL_SHIFT	(6)
>  #define MICBIAS_LEVEL_MASK	(3 << 6)
>  
> +/* HPOUT_SC */
> +#define HPOUT_SC_OCMV_MASK	(3 << 6)
> +#define HPOUT_SC_OCMV_SHIFT	(6)
> +#define HPOUT_SC_OCMV_1_35V	0
> +#define HPOUT_SC_OCMV_1_5V	1
> +#define HPOUT_SC_OCMV_1_65V	2
> +#define HPOUT_SC_OCMV_1_8V	3
> +
>  /* headset detection / button API */
>  
>  /* The AIC3x supports detection of stereo headsets (GND + left + right signal)
> 

- Péter



More information about the Alsa-devel mailing list