aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/sgtl5000.c56
-rw-r--r--sound/soc/codecs/sgtl5000.h1
2 files changed, 22 insertions, 35 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 56d61a212083..42f2eb62664e 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -47,12 +47,10 @@ static const struct reg_default sgtl5000_reg_defaults[] = {
47 { SGTL5000_CHIP_ANA_ADC_CTRL, 0x0000 }, 47 { SGTL5000_CHIP_ANA_ADC_CTRL, 0x0000 },
48 { SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 }, 48 { SGTL5000_CHIP_ANA_HP_CTRL, 0x1818 },
49 { SGTL5000_CHIP_ANA_CTRL, 0x0111 }, 49 { SGTL5000_CHIP_ANA_CTRL, 0x0111 },
50 { SGTL5000_CHIP_LINREG_CTRL, 0x0000 },
51 { SGTL5000_CHIP_REF_CTRL, 0x0000 }, 50 { SGTL5000_CHIP_REF_CTRL, 0x0000 },
52 { SGTL5000_CHIP_MIC_CTRL, 0x0000 }, 51 { SGTL5000_CHIP_MIC_CTRL, 0x0000 },
53 { SGTL5000_CHIP_LINE_OUT_CTRL, 0x0000 }, 52 { SGTL5000_CHIP_LINE_OUT_CTRL, 0x0000 },
54 { SGTL5000_CHIP_LINE_OUT_VOL, 0x0404 }, 53 { SGTL5000_CHIP_LINE_OUT_VOL, 0x0404 },
55 { SGTL5000_CHIP_ANA_POWER, 0x7060 },
56 { SGTL5000_CHIP_PLL_CTRL, 0x5000 }, 54 { SGTL5000_CHIP_PLL_CTRL, 0x5000 },
57 { SGTL5000_CHIP_CLK_TOP_CTRL, 0x0000 }, 55 { SGTL5000_CHIP_CLK_TOP_CTRL, 0x0000 },
58 { SGTL5000_CHIP_ANA_STATUS, 0x0000 }, 56 { SGTL5000_CHIP_ANA_STATUS, 0x0000 },
@@ -93,6 +91,7 @@ static const char *supply_names[SGTL5000_SUPPLY_NUM] = {
93}; 91};
94 92
95#define LDO_VOLTAGE 1200000 93#define LDO_VOLTAGE 1200000
94#define LINREG_VDDD ((1600 - LDO_VOLTAGE / 1000) / 50)
96 95
97enum sgtl5000_micbias_resistor { 96enum sgtl5000_micbias_resistor {
98 SGTL5000_MICBIAS_OFF = 0, 97 SGTL5000_MICBIAS_OFF = 0,
@@ -1002,25 +1001,6 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
1002 1001
1003 snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, ana_pwr); 1002 snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, ana_pwr);
1004 1003
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
1024 /* 1004 /*
1025 * set ADC/DAC VAG to vdda / 2, 1005 * set ADC/DAC VAG to vdda / 2,
1026 * should stay in range (0.8v, 1.575v) 1006 * should stay in range (0.8v, 1.575v)
@@ -1242,6 +1222,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1242 int ret, reg, rev; 1222 int ret, reg, rev;
1243 struct device_node *np = client->dev.of_node; 1223 struct device_node *np = client->dev.of_node;
1244 u32 value; 1224 u32 value;
1225 u16 ana_pwr;
1245 1226
1246 sgtl5000 = devm_kzalloc(&client->dev, sizeof(*sgtl5000), GFP_KERNEL); 1227 sgtl5000 = devm_kzalloc(&client->dev, sizeof(*sgtl5000), GFP_KERNEL);
1247 if (!sgtl5000) 1228 if (!sgtl5000)
@@ -1299,29 +1280,34 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1299 sgtl5000->revision = rev; 1280 sgtl5000->revision = rev;
1300 1281
1301 /* Follow section 2.2.1.1 of AN3663 */ 1282 /* Follow section 2.2.1.1 of AN3663 */
1283 ana_pwr = SGTL5000_ANA_POWER_DEFAULT;
1302 if (sgtl5000->num_supplies <= VDDD) { 1284 if (sgtl5000->num_supplies <= VDDD) {
1303 /* internal VDDD at 1.2V */ 1285 /* internal VDDD at 1.2V */
1304 regmap_update_bits(sgtl5000->regmap, 1286 ret = regmap_update_bits(sgtl5000->regmap,
1305 SGTL5000_CHIP_LINREG_CTRL, 1287 SGTL5000_CHIP_LINREG_CTRL,
1306 SGTL5000_LINREG_VDDD_MASK, 8); 1288 SGTL5000_LINREG_VDDD_MASK,
1307 regmap_update_bits(sgtl5000->regmap, 1289 LINREG_VDDD);
1308 SGTL5000_CHIP_ANA_POWER, 1290 if (ret)
1309 SGTL5000_LINEREG_D_POWERUP 1291 dev_err(&client->dev,
1310 | SGTL5000_LINREG_SIMPLE_POWERUP, 1292 "Error %d setting LINREG_VDDD\n", ret);
1311 SGTL5000_LINEREG_D_POWERUP); 1293
1312 dev_info(&client->dev, "Using internal LDO instead of VDDD: check ER1\n"); 1294 ana_pwr |= SGTL5000_LINEREG_D_POWERUP;
1295 dev_info(&client->dev,
1296 "Using internal LDO instead of VDDD: check ER1\n");
1313 } else { 1297 } else {
1314 /* using external LDO for VDDD 1298 /* using external LDO for VDDD
1315 * Clear startup powerup and simple powerup 1299 * Clear startup powerup and simple powerup
1316 * bits to save power 1300 * bits to save power
1317 */ 1301 */
1318 regmap_update_bits(sgtl5000->regmap, 1302 ana_pwr &= ~(SGTL5000_STARTUP_POWERUP
1319 SGTL5000_CHIP_ANA_POWER, 1303 | SGTL5000_LINREG_SIMPLE_POWERUP);
1320 SGTL5000_STARTUP_POWERUP
1321 | SGTL5000_LINREG_SIMPLE_POWERUP,
1322 0);
1323 dev_dbg(&client->dev, "Using external VDDD\n"); 1304 dev_dbg(&client->dev, "Using external VDDD\n");
1324 } 1305 }
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);
1325 1311
1326 if (np) { 1312 if (np) {
1327 if (!of_property_read_u32(np, 1313 if (!of_property_read_u32(np,
diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h
index 1c317de26176..1be82379c689 100644
--- a/sound/soc/codecs/sgtl5000.h
+++ b/sound/soc/codecs/sgtl5000.h
@@ -325,6 +325,7 @@
325/* 325/*
326 * SGTL5000_CHIP_ANA_POWER 326 * SGTL5000_CHIP_ANA_POWER
327 */ 327 */
328#define SGTL5000_ANA_POWER_DEFAULT 0x7060
328#define SGTL5000_DAC_STEREO 0x4000 329#define SGTL5000_DAC_STEREO 0x4000
329#define SGTL5000_LINREG_SIMPLE_POWERUP 0x2000 330#define SGTL5000_LINREG_SIMPLE_POWERUP 0x2000
330#define SGTL5000_STARTUP_POWERUP 0x1000 331#define SGTL5000_STARTUP_POWERUP 0x1000