@@ -47,12 +47,10 @@ static const struct reg_default sgtl5000_reg_defaults[] = {
47
47
{ SGTL5000_CHIP_ANA_ADC_CTRL , 0x0000 },
48
48
{ SGTL5000_CHIP_ANA_HP_CTRL , 0x1818 },
49
49
{ SGTL5000_CHIP_ANA_CTRL , 0x0111 },
50
- { SGTL5000_CHIP_LINREG_CTRL , 0x0000 },
51
50
{ SGTL5000_CHIP_REF_CTRL , 0x0000 },
52
51
{ SGTL5000_CHIP_MIC_CTRL , 0x0000 },
53
52
{ SGTL5000_CHIP_LINE_OUT_CTRL , 0x0000 },
54
53
{ SGTL5000_CHIP_LINE_OUT_VOL , 0x0404 },
55
- { SGTL5000_CHIP_ANA_POWER , 0x7060 },
56
54
{ SGTL5000_CHIP_PLL_CTRL , 0x5000 },
57
55
{ SGTL5000_CHIP_CLK_TOP_CTRL , 0x0000 },
58
56
{ SGTL5000_CHIP_ANA_STATUS , 0x0000 },
@@ -93,6 +91,7 @@ static const char *supply_names[SGTL5000_SUPPLY_NUM] = {
93
91
};
94
92
95
93
#define LDO_VOLTAGE 1200000
94
+ #define LINREG_VDDD ((1600 - LDO_VOLTAGE / 1000) / 50)
96
95
97
96
enum sgtl5000_micbias_resistor {
98
97
SGTL5000_MICBIAS_OFF = 0 ,
@@ -1002,25 +1001,6 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
1002
1001
1003
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
1005
* set ADC/DAC VAG to vdda / 2,
1026
1006
* should stay in range (0.8v, 1.575v)
@@ -1242,6 +1222,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1242
1222
int ret , reg , rev ;
1243
1223
struct device_node * np = client -> dev .of_node ;
1244
1224
u32 value ;
1225
+ u16 ana_pwr ;
1245
1226
1246
1227
sgtl5000 = devm_kzalloc (& client -> dev , sizeof (* sgtl5000 ), GFP_KERNEL );
1247
1228
if (!sgtl5000 )
@@ -1299,29 +1280,34 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
1299
1280
sgtl5000 -> revision = rev ;
1300
1281
1301
1282
/* Follow section 2.2.1.1 of AN3663 */
1283
+ ana_pwr = SGTL5000_ANA_POWER_DEFAULT ;
1302
1284
if (sgtl5000 -> num_supplies <= VDDD ) {
1303
1285
/* 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" );
1313
1297
} else {
1314
1298
/* using external LDO for VDDD
1315
1299
* Clear startup powerup and simple powerup
1316
1300
* bits to save power
1317
1301
*/
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 );
1323
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
1312
if (np ) {
1327
1313
if (!of_property_read_u32 (np ,
0 commit comments