Skip to content

Commit 3d632cc

Browse files
ericnelsonazbroonie
authored andcommitted
ASoC: sgtl5000: Initialize CHIP_ANA_POWER to power-on defaults
Initialize CHIP_ANA_POWER to match power on defaults, which disables ADC, DAC, and charge pumps. In the process, remove references to the following register/bitfields from the sgtl5000_set_power_regs routine: CHIP_ANA_POWER/LINREG_SIMPLE_POWERUP and CHIP_LINREG_CTRL/LINREG_VDD_MASK And remove CHIP_ANA_POWER and CHIP_LINREG_CTRL from the set of default registers so they don't get clobbered by sgtl5000_fill_defaults(). Signed-off-by: Eric Nelson <[email protected]> Signed-off-by: Clemens Gruber <[email protected]> Tested-by: Fabio Estevam <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent f219b16 commit 3d632cc

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

sound/soc/codecs/sgtl5000.c

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ static const struct reg_default sgtl5000_reg_defaults[] = {
4747
{ SGTL5000_CHIP_ANA_ADC_CTRL, 0x0000 },
4848
{ SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 },
4949
{ SGTL5000_CHIP_ANA_CTRL, 0x0111 },
50-
{ SGTL5000_CHIP_LINREG_CTRL, 0x0000 },
5150
{ SGTL5000_CHIP_REF_CTRL, 0x0000 },
5251
{ SGTL5000_CHIP_MIC_CTRL, 0x0000 },
5352
{ SGTL5000_CHIP_LINE_OUT_CTRL, 0x0000 },
5453
{ SGTL5000_CHIP_LINE_OUT_VOL, 0x0404 },
55-
{ SGTL5000_CHIP_ANA_POWER, 0x7060 },
5654
{ SGTL5000_CHIP_PLL_CTRL, 0x5000 },
5755
{ SGTL5000_CHIP_CLK_TOP_CTRL, 0x0000 },
5856
{ SGTL5000_CHIP_ANA_STATUS, 0x0000 },
@@ -93,6 +91,7 @@ static const char *supply_names[SGTL5000_SUPPLY_NUM] = {
9391
};
9492

9593
#define LDO_VOLTAGE 1200000
94+
#define LINREG_VDDD ((1600 - LDO_VOLTAGE / 1000) / 50)
9695

9796
enum sgtl5000_micbias_resistor {
9897
SGTL5000_MICBIAS_OFF = 0,
@@ -1002,25 +1001,6 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
10021001

10031002
snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, ana_pwr);
10041003

1005-
/* set voltage to register */
1006-
snd_soc_update_bits(codec, SGTL5000_CHIP_LINREG_CTRL,
1007-
SGTL5000_LINREG_VDDD_MASK, 0x8);
1008-
1009-
/*
1010-
* if vddd linear reg has been enabled,
1011-
* simple digital supply should be clear to get
1012-
* proper VDDD voltage.
1013-
*/
1014-
if (ana_pwr & SGTL5000_LINEREG_D_POWERUP)
1015-
snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
1016-
SGTL5000_LINREG_SIMPLE_POWERUP,
1017-
0);
1018-
else
1019-
snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
1020-
SGTL5000_LINREG_SIMPLE_POWERUP |
1021-
SGTL5000_STARTUP_POWERUP,
1022-
0);
1023-
10241004
/*
10251005
* set ADC/DAC VAG to vdda / 2,
10261006
* should stay in range (0.8v, 1.575v)
@@ -1242,6 +1222,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
12421222
int ret, reg, rev;
12431223
struct device_node *np = client->dev.of_node;
12441224
u32 value;
1225+
u16 ana_pwr;
12451226

12461227
sgtl5000 = devm_kzalloc(&client->dev, sizeof(*sgtl5000), GFP_KERNEL);
12471228
if (!sgtl5000)
@@ -1299,29 +1280,34 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
12991280
sgtl5000->revision = rev;
13001281

13011282
/* Follow section 2.2.1.1 of AN3663 */
1283+
ana_pwr = SGTL5000_ANA_POWER_DEFAULT;
13021284
if (sgtl5000->num_supplies <= VDDD) {
13031285
/* internal VDDD at 1.2V */
1304-
regmap_update_bits(sgtl5000->regmap,
1305-
SGTL5000_CHIP_LINREG_CTRL,
1306-
SGTL5000_LINREG_VDDD_MASK, 8);
1307-
regmap_update_bits(sgtl5000->regmap,
1308-
SGTL5000_CHIP_ANA_POWER,
1309-
SGTL5000_LINEREG_D_POWERUP
1310-
| SGTL5000_LINREG_SIMPLE_POWERUP,
1311-
SGTL5000_LINEREG_D_POWERUP);
1312-
dev_info(&client->dev, "Using internal LDO instead of VDDD: check ER1\n");
1286+
ret = regmap_update_bits(sgtl5000->regmap,
1287+
SGTL5000_CHIP_LINREG_CTRL,
1288+
SGTL5000_LINREG_VDDD_MASK,
1289+
LINREG_VDDD);
1290+
if (ret)
1291+
dev_err(&client->dev,
1292+
"Error %d setting LINREG_VDDD\n", ret);
1293+
1294+
ana_pwr |= SGTL5000_LINEREG_D_POWERUP;
1295+
dev_info(&client->dev,
1296+
"Using internal LDO instead of VDDD: check ER1\n");
13131297
} else {
13141298
/* using external LDO for VDDD
13151299
* Clear startup powerup and simple powerup
13161300
* bits to save power
13171301
*/
1318-
regmap_update_bits(sgtl5000->regmap,
1319-
SGTL5000_CHIP_ANA_POWER,
1320-
SGTL5000_STARTUP_POWERUP
1321-
| SGTL5000_LINREG_SIMPLE_POWERUP,
1322-
0);
1302+
ana_pwr &= ~(SGTL5000_STARTUP_POWERUP
1303+
| SGTL5000_LINREG_SIMPLE_POWERUP);
13231304
dev_dbg(&client->dev, "Using external VDDD\n");
13241305
}
1306+
ret = regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, ana_pwr);
1307+
if (ret)
1308+
dev_err(&client->dev,
1309+
"Error %d setting CHIP_ANA_POWER to %04x\n",
1310+
ret, ana_pwr);
13251311

13261312
if (np) {
13271313
if (!of_property_read_u32(np,

sound/soc/codecs/sgtl5000.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@
325325
/*
326326
* SGTL5000_CHIP_ANA_POWER
327327
*/
328+
#define SGTL5000_ANA_POWER_DEFAULT 0x7060
328329
#define SGTL5000_DAC_STEREO 0x4000
329330
#define SGTL5000_LINREG_SIMPLE_POWERUP 0x2000
330331
#define SGTL5000_STARTUP_POWERUP 0x1000

0 commit comments

Comments
 (0)