Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: 88pm860x: Use regmap for I/O

As part of a move to remove the duplication of regmap functionality in ASoC
convert the 88pm860x driver to use the regmap from the MFD. This means that
we no longer cache the registers so performance will be slightly reduced
on I/O operations.

Signed-off-by: Mark Brown <broonie@linaro.org>

+63 -114
+5 -55
sound/soc/codecs/88pm860x-codec.c
··· 16 16 #include <linux/mfd/88pm860x.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/delay.h> 19 + #include <linux/regmap.h> 19 20 #include <sound/core.h> 20 21 #include <sound/pcm.h> 21 22 #include <sound/pcm_params.h> ··· 141 140 unsigned int filter; 142 141 struct snd_soc_codec *codec; 143 142 struct i2c_client *i2c; 143 + struct regmap *regmap; 144 144 struct pm860x_chip *chip; 145 145 struct pm860x_det det; 146 146 ··· 270 268 { -214, 25, 0}, { -180, 26, 0}, { -148, 27, 0}, { -116, 28, 0}, 271 269 { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0}, 272 270 }; 273 - 274 - static int pm860x_volatile(unsigned int reg) 275 - { 276 - BUG_ON(reg >= REG_CACHE_SIZE); 277 - 278 - switch (reg) { 279 - case PM860X_AUDIO_SUPPLIES_2: 280 - return 1; 281 - } 282 - 283 - return 0; 284 - } 285 - 286 - static unsigned int pm860x_read_reg_cache(struct snd_soc_codec *codec, 287 - unsigned int reg) 288 - { 289 - unsigned char *cache = codec->reg_cache; 290 - 291 - BUG_ON(reg >= REG_CACHE_SIZE); 292 - 293 - if (pm860x_volatile(reg)) 294 - return cache[reg]; 295 - 296 - reg += REG_CACHE_BASE; 297 - 298 - return pm860x_reg_read(codec->control_data, reg); 299 - } 300 - 301 - static int pm860x_write_reg_cache(struct snd_soc_codec *codec, 302 - unsigned int reg, unsigned int value) 303 - { 304 - unsigned char *cache = codec->reg_cache; 305 - 306 - BUG_ON(reg >= REG_CACHE_SIZE); 307 - 308 - if (!pm860x_volatile(reg)) 309 - cache[reg] = (unsigned char)value; 310 - 311 - reg += REG_CACHE_BASE; 312 - 313 - return pm860x_reg_write(codec->control_data, reg, value); 314 - } 315 271 316 272 static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, 317 273 struct snd_ctl_elem_value *ucontrol) ··· 1324 1364 1325 1365 pm860x->codec = codec; 1326 1366 1327 - codec->control_data = pm860x->i2c; 1367 + codec->control_data = pm860x->regmap; 1328 1368 1329 1369 for (i = 0; i < 4; i++) { 1330 1370 ret = request_threaded_irq(pm860x->irq[i], NULL, ··· 1337 1377 } 1338 1378 1339 1379 pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1340 - 1341 - ret = pm860x_bulk_read(pm860x->i2c, REG_CACHE_BASE, 1342 - REG_CACHE_SIZE, codec->reg_cache); 1343 - if (ret < 0) { 1344 - dev_err(codec->dev, "Failed to fill register cache: %d\n", 1345 - ret); 1346 - goto out; 1347 - } 1348 1380 1349 1381 return 0; 1350 1382 ··· 1360 1408 static struct snd_soc_codec_driver soc_codec_dev_pm860x = { 1361 1409 .probe = pm860x_probe, 1362 1410 .remove = pm860x_remove, 1363 - .read = pm860x_read_reg_cache, 1364 - .write = pm860x_write_reg_cache, 1365 - .reg_cache_size = REG_CACHE_SIZE, 1366 - .reg_word_size = sizeof(u8), 1367 1411 .set_bias_level = pm860x_set_bias_level, 1368 1412 1369 1413 .controls = pm860x_snd_controls, ··· 1385 1437 pm860x->chip = chip; 1386 1438 pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client 1387 1439 : chip->companion; 1440 + pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap 1441 + : chip->regmap_companion; 1388 1442 platform_set_drvdata(pdev, pm860x); 1389 1443 1390 1444 for (i = 0; i < 4; i++) {
+58 -59
sound/soc/codecs/88pm860x-codec.h
··· 12 12 #ifndef __88PM860X_H 13 13 #define __88PM860X_H 14 14 15 - /* The offset of these registers are 0xb0 */ 16 - #define PM860X_PCM_IFACE_1 0x00 17 - #define PM860X_PCM_IFACE_2 0x01 18 - #define PM860X_PCM_IFACE_3 0x02 19 - #define PM860X_PCM_RATE 0x03 20 - #define PM860X_EC_PATH 0x04 21 - #define PM860X_SIDETONE_L_GAIN 0x05 22 - #define PM860X_SIDETONE_R_GAIN 0x06 23 - #define PM860X_SIDETONE_SHIFT 0x07 24 - #define PM860X_ADC_OFFSET_1 0x08 25 - #define PM860X_ADC_OFFSET_2 0x09 26 - #define PM860X_DMIC_DELAY 0x0a 15 + #define PM860X_PCM_IFACE_1 0xb0 16 + #define PM860X_PCM_IFACE_2 0xb1 17 + #define PM860X_PCM_IFACE_3 0xb2 18 + #define PM860X_PCM_RATE 0xb3 19 + #define PM860X_EC_PATH 0xb4 20 + #define PM860X_SIDETONE_L_GAIN 0xb5 21 + #define PM860X_SIDETONE_R_GAIN 0xb6 22 + #define PM860X_SIDETONE_SHIFT 0xb7 23 + #define PM860X_ADC_OFFSET_1 0xb8 24 + #define PM860X_ADC_OFFSET_2 0xb9 25 + #define PM860X_DMIC_DELAY 0xba 27 26 28 - #define PM860X_I2S_IFACE_1 0x0b 29 - #define PM860X_I2S_IFACE_2 0x0c 30 - #define PM860X_I2S_IFACE_3 0x0d 31 - #define PM860X_I2S_IFACE_4 0x0e 32 - #define PM860X_EQUALIZER_N0_1 0x0f 33 - #define PM860X_EQUALIZER_N0_2 0x10 34 - #define PM860X_EQUALIZER_N1_1 0x11 35 - #define PM860X_EQUALIZER_N1_2 0x12 36 - #define PM860X_EQUALIZER_D1_1 0x13 37 - #define PM860X_EQUALIZER_D1_2 0x14 38 - #define PM860X_LOFI_GAIN_LEFT 0x15 39 - #define PM860X_LOFI_GAIN_RIGHT 0x16 40 - #define PM860X_HIFIL_GAIN_LEFT 0x17 41 - #define PM860X_HIFIL_GAIN_RIGHT 0x18 42 - #define PM860X_HIFIR_GAIN_LEFT 0x19 43 - #define PM860X_HIFIR_GAIN_RIGHT 0x1a 44 - #define PM860X_DAC_OFFSET 0x1b 45 - #define PM860X_OFFSET_LEFT_1 0x1c 46 - #define PM860X_OFFSET_LEFT_2 0x1d 47 - #define PM860X_OFFSET_RIGHT_1 0x1e 48 - #define PM860X_OFFSET_RIGHT_2 0x1f 49 - #define PM860X_ADC_ANA_1 0x20 50 - #define PM860X_ADC_ANA_2 0x21 51 - #define PM860X_ADC_ANA_3 0x22 52 - #define PM860X_ADC_ANA_4 0x23 53 - #define PM860X_ANA_TO_ANA 0x24 54 - #define PM860X_HS1_CTRL 0x25 55 - #define PM860X_HS2_CTRL 0x26 56 - #define PM860X_LO1_CTRL 0x27 57 - #define PM860X_LO2_CTRL 0x28 58 - #define PM860X_EAR_CTRL_1 0x29 59 - #define PM860X_EAR_CTRL_2 0x2a 60 - #define PM860X_AUDIO_SUPPLIES_1 0x2b 61 - #define PM860X_AUDIO_SUPPLIES_2 0x2c 62 - #define PM860X_ADC_EN_1 0x2d 63 - #define PM860X_ADC_EN_2 0x2e 64 - #define PM860X_DAC_EN_1 0x2f 65 - #define PM860X_DAC_EN_2 0x31 66 - #define PM860X_AUDIO_CAL_1 0x32 67 - #define PM860X_AUDIO_CAL_2 0x33 68 - #define PM860X_AUDIO_CAL_3 0x34 69 - #define PM860X_AUDIO_CAL_4 0x35 70 - #define PM860X_AUDIO_CAL_5 0x36 71 - #define PM860X_ANA_INPUT_SEL_1 0x37 72 - #define PM860X_ANA_INPUT_SEL_2 0x38 27 + #define PM860X_I2S_IFACE_1 0xbb 28 + #define PM860X_I2S_IFACE_2 0xbc 29 + #define PM860X_I2S_IFACE_3 0xbd 30 + #define PM860X_I2S_IFACE_4 0xbe 31 + #define PM860X_EQUALIZER_N0_1 0xbf 32 + #define PM860X_EQUALIZER_N0_2 0xc0 33 + #define PM860X_EQUALIZER_N1_1 0xc1 34 + #define PM860X_EQUALIZER_N1_2 0xc2 35 + #define PM860X_EQUALIZER_D1_1 0xc3 36 + #define PM860X_EQUALIZER_D1_2 0xc4 37 + #define PM860X_LOFI_GAIN_LEFT 0xc5 38 + #define PM860X_LOFI_GAIN_RIGHT 0xc6 39 + #define PM860X_HIFIL_GAIN_LEFT 0xc7 40 + #define PM860X_HIFIL_GAIN_RIGHT 0xc8 41 + #define PM860X_HIFIR_GAIN_LEFT 0xc9 42 + #define PM860X_HIFIR_GAIN_RIGHT 0xca 43 + #define PM860X_DAC_OFFSET 0xcb 44 + #define PM860X_OFFSET_LEFT_1 0xcc 45 + #define PM860X_OFFSET_LEFT_2 0xcd 46 + #define PM860X_OFFSET_RIGHT_1 0xce 47 + #define PM860X_OFFSET_RIGHT_2 0xcf 48 + #define PM860X_ADC_ANA_1 0xd0 49 + #define PM860X_ADC_ANA_2 0xd1 50 + #define PM860X_ADC_ANA_3 0xd2 51 + #define PM860X_ADC_ANA_4 0xd3 52 + #define PM860X_ANA_TO_ANA 0xd4 53 + #define PM860X_HS1_CTRL 0xd5 54 + #define PM860X_HS2_CTRL 0xd6 55 + #define PM860X_LO1_CTRL 0xd7 56 + #define PM860X_LO2_CTRL 0xd8 57 + #define PM860X_EAR_CTRL_1 0xd9 58 + #define PM860X_EAR_CTRL_2 0xda 59 + #define PM860X_AUDIO_SUPPLIES_1 0xdb 60 + #define PM860X_AUDIO_SUPPLIES_2 0xdc 61 + #define PM860X_ADC_EN_1 0xdd 62 + #define PM860X_ADC_EN_2 0xde 63 + #define PM860X_DAC_EN_1 0xdf 64 + #define PM860X_DAC_EN_2 0xe1 65 + #define PM860X_AUDIO_CAL_1 0xe2 66 + #define PM860X_AUDIO_CAL_2 0xe3 67 + #define PM860X_AUDIO_CAL_3 0xe4 68 + #define PM860X_AUDIO_CAL_4 0xe5 69 + #define PM860X_AUDIO_CAL_5 0xe6 70 + #define PM860X_ANA_INPUT_SEL_1 0xe7 71 + #define PM860X_ANA_INPUT_SEL_2 0xe8 73 72 74 - #define PM860X_PCM_IFACE_4 0x39 75 - #define PM860X_I2S_IFACE_5 0x3a 73 + #define PM860X_PCM_IFACE_4 0xe9 74 + #define PM860X_I2S_IFACE_5 0xea 76 75 77 76 #define PM860X_SHORTS 0x3b 78 77 #define PM860X_PLL_ADJ_1 0x3c