Skip to content

Commit 19b0fa1

Browse files
Peter Ujfalusibroonie
authored andcommitted
ASoC: tlv320aic3x: Support for OCMV configuration
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 <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 5771a8c commit 19b0fa1

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

Documentation/devicetree/bindings/sound/tlv320aic3x.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ Optional properties:
2626
3 - MICBIAS output is connected to AVDD,
2727
If this node is not mentioned or if the value is incorrect, then MicBias
2828
is powered down.
29+
- ai3x-ocmv - Output Common-Mode Voltage selection:
30+
0 - 1.35V,
31+
1 - 1.5V,
32+
2 - 1.65V,
33+
3 - 1.8V
2934
- AVDD-supply, IOVDD-supply, DRVDD-supply, DVDD-supply : power supplies for the
3035
device as covered in Documentation/devicetree/bindings/regulator/regulator.txt
3136

sound/soc/codecs/tlv320aic3x.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ struct aic3x_priv {
9393

9494
/* Selects the micbias voltage */
9595
enum aic3x_micbias_voltage micbias_vg;
96+
/* Output Common-Mode Voltage */
97+
u8 ocmv;
9698
};
9799

98100
static const struct reg_default aic3x_reg[] = {
@@ -1572,6 +1574,10 @@ static int aic3x_init(struct snd_soc_codec *codec)
15721574
break;
15731575
}
15741576

1577+
/* Output common-mode voltage = 1.5 V */
1578+
snd_soc_update_bits(codec, HPOUT_SC, HPOUT_SC_OCMV_MASK,
1579+
aic3x->ocmv << HPOUT_SC_OCMV_SHIFT);
1580+
15751581
return 0;
15761582
}
15771583

@@ -1699,6 +1705,43 @@ static struct snd_soc_codec_driver soc_codec_dev_aic3x = {
16991705
},
17001706
};
17011707

1708+
static void aic3x_configure_ocmv(struct i2c_client *client)
1709+
{
1710+
struct device_node *np = client->dev.of_node;
1711+
struct aic3x_priv *aic3x = i2c_get_clientdata(client);
1712+
u32 value;
1713+
int dvdd, avdd;
1714+
1715+
if (np && !of_property_read_u32(np, "ai3x-ocmv", &value)) {
1716+
/* OCMV setting is forced by DT */
1717+
if (value <= 3) {
1718+
aic3x->ocmv = value;
1719+
return;
1720+
}
1721+
}
1722+
1723+
dvdd = regulator_get_voltage(aic3x->supplies[1].consumer);
1724+
avdd = regulator_get_voltage(aic3x->supplies[2].consumer);
1725+
1726+
if (avdd > 3600000 || dvdd > 1950000) {
1727+
dev_warn(&client->dev,
1728+
"Too high supply voltage(s) AVDD: %d, DVDD: %d\n",
1729+
avdd, dvdd);
1730+
} else if (avdd == 3600000 && dvdd == 1950000) {
1731+
aic3x->ocmv = HPOUT_SC_OCMV_1_8V;
1732+
} else if (avdd > 3300000 && dvdd > 1800000) {
1733+
aic3x->ocmv = HPOUT_SC_OCMV_1_65V;
1734+
} else if (avdd > 3000000 && dvdd > 1650000) {
1735+
aic3x->ocmv = HPOUT_SC_OCMV_1_5V;
1736+
} else if (avdd >= 2700000 && dvdd >= 1525000) {
1737+
aic3x->ocmv = HPOUT_SC_OCMV_1_35V;
1738+
} else {
1739+
dev_warn(&client->dev,
1740+
"Invalid supply voltage(s) AVDD: %d, DVDD: %d\n",
1741+
avdd, dvdd);
1742+
}
1743+
}
1744+
17021745
/*
17031746
* AIC3X 2 wire address can be up to 4 devices with device addresses
17041747
* 0x18, 0x19, 0x1A, 0x1B
@@ -1816,6 +1859,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
18161859
goto err_gpio;
18171860
}
18181861

1862+
aic3x_configure_ocmv(i2c);
1863+
18191864
if (aic3x->model == AIC3X_MODEL_3007) {
18201865
ret = regmap_register_patch(aic3x->regmap, aic3007_class_d,
18211866
ARRAY_SIZE(aic3007_class_d));

sound/soc/codecs/tlv320aic3x.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@
243243
#define MICBIAS_LEVEL_SHIFT (6)
244244
#define MICBIAS_LEVEL_MASK (3 << 6)
245245

246+
/* HPOUT_SC */
247+
#define HPOUT_SC_OCMV_MASK (3 << 6)
248+
#define HPOUT_SC_OCMV_SHIFT (6)
249+
#define HPOUT_SC_OCMV_1_35V 0
250+
#define HPOUT_SC_OCMV_1_5V 1
251+
#define HPOUT_SC_OCMV_1_65V 2
252+
#define HPOUT_SC_OCMV_1_8V 3
253+
246254
/* headset detection / button API */
247255

248256
/* The AIC3x supports detection of stereo headsets (GND + left + right signal)

0 commit comments

Comments
 (0)