diff options
| -rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 138165c3a180..86e5a5868c3c 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
| @@ -112,18 +112,6 @@ static const u8 aic3x_reg[AIC3X_CACHEREGNUM] = { | |||
| 112 | }; | 112 | }; |
| 113 | 113 | ||
| 114 | /* | 114 | /* |
| 115 | * read aic3x register cache | ||
| 116 | */ | ||
| 117 | static inline unsigned int aic3x_read_reg_cache(struct snd_soc_codec *codec, | ||
| 118 | unsigned int reg) | ||
| 119 | { | ||
| 120 | u8 *cache = codec->reg_cache; | ||
| 121 | if (reg >= AIC3X_CACHEREGNUM) | ||
| 122 | return -1; | ||
| 123 | return cache[reg]; | ||
| 124 | } | ||
| 125 | |||
| 126 | /* | ||
| 127 | * write aic3x register cache | 115 | * write aic3x register cache |
| 128 | */ | 116 | */ |
| 129 | static inline void aic3x_write_reg_cache(struct snd_soc_codec *codec, | 117 | static inline void aic3x_write_reg_cache(struct snd_soc_codec *codec, |
| @@ -136,28 +124,6 @@ static inline void aic3x_write_reg_cache(struct snd_soc_codec *codec, | |||
| 136 | } | 124 | } |
| 137 | 125 | ||
| 138 | /* | 126 | /* |
| 139 | * write to the aic3x register space | ||
| 140 | */ | ||
| 141 | static int aic3x_write(struct snd_soc_codec *codec, unsigned int reg, | ||
| 142 | unsigned int value) | ||
| 143 | { | ||
| 144 | u8 data[2]; | ||
| 145 | |||
| 146 | /* data is | ||
| 147 | * D15..D8 aic3x register offset | ||
| 148 | * D7...D0 register data | ||
| 149 | */ | ||
| 150 | data[0] = reg & 0xff; | ||
| 151 | data[1] = value & 0xff; | ||
| 152 | |||
| 153 | aic3x_write_reg_cache(codec, data[0], data[1]); | ||
| 154 | if (codec->hw_write(codec->control_data, data, 2) == 2) | ||
| 155 | return 0; | ||
| 156 | else | ||
| 157 | return -EIO; | ||
| 158 | } | ||
| 159 | |||
| 160 | /* | ||
| 161 | * read from the aic3x register space | 127 | * read from the aic3x register space |
| 162 | */ | 128 | */ |
| 163 | static int aic3x_read(struct snd_soc_codec *codec, unsigned int reg, | 129 | static int aic3x_read(struct snd_soc_codec *codec, unsigned int reg, |
| @@ -1299,10 +1265,16 @@ static int aic3x_init(struct snd_soc_codec *codec) | |||
| 1299 | static int aic3x_probe(struct snd_soc_codec *codec) | 1265 | static int aic3x_probe(struct snd_soc_codec *codec) |
| 1300 | { | 1266 | { |
| 1301 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); | 1267 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); |
| 1268 | int ret; | ||
| 1302 | 1269 | ||
| 1303 | codec->hw_write = (hw_write_t) i2c_master_send; | ||
| 1304 | codec->control_data = aic3x->control_data; | 1270 | codec->control_data = aic3x->control_data; |
| 1305 | 1271 | ||
| 1272 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type); | ||
| 1273 | if (ret != 0) { | ||
| 1274 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | ||
| 1275 | return ret; | ||
| 1276 | } | ||
| 1277 | |||
| 1306 | aic3x_init(codec); | 1278 | aic3x_init(codec); |
| 1307 | 1279 | ||
| 1308 | if (aic3x->setup) { | 1280 | if (aic3x->setup) { |
| @@ -1330,8 +1302,6 @@ static int aic3x_remove(struct snd_soc_codec *codec) | |||
| 1330 | } | 1302 | } |
| 1331 | 1303 | ||
| 1332 | static struct snd_soc_codec_driver soc_codec_dev_aic3x = { | 1304 | static struct snd_soc_codec_driver soc_codec_dev_aic3x = { |
| 1333 | .read = aic3x_read_reg_cache, | ||
| 1334 | .write = aic3x_write, | ||
| 1335 | .set_bias_level = aic3x_set_bias_level, | 1305 | .set_bias_level = aic3x_set_bias_level, |
| 1336 | .reg_cache_size = ARRAY_SIZE(aic3x_reg), | 1306 | .reg_cache_size = ARRAY_SIZE(aic3x_reg), |
| 1337 | .reg_word_size = sizeof(u8), | 1307 | .reg_word_size = sizeof(u8), |
| @@ -1375,6 +1345,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1375 | } | 1345 | } |
| 1376 | 1346 | ||
| 1377 | aic3x->control_data = i2c; | 1347 | aic3x->control_data = i2c; |
| 1348 | aic3x->control_type = SND_SOC_I2C; | ||
| 1349 | |||
| 1378 | i2c_set_clientdata(i2c, aic3x); | 1350 | i2c_set_clientdata(i2c, aic3x); |
| 1379 | if (pdata) { | 1351 | if (pdata) { |
| 1380 | aic3x->gpio_reset = pdata->gpio_reset; | 1352 | aic3x->gpio_reset = pdata->gpio_reset; |
