wm8904.c (d633edd95dc938f3f5f0d4e431932f4ca042bffb) | wm8904.c (433897f7408b556f7dfbb98c94deea02e634d2a7) |
---|---|
1/* 2 * wm8904.c -- WM8904 ALSA SoC Audio driver 3 * | 1/* 2 * wm8904.c -- WM8904 ALSA SoC Audio driver 3 * |
4 * Copyright 2009-12 Wolfson Microelectronics plc | 4 * Copyright 2009 Wolfson Microelectronics plc |
5 * 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 7 * 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 */ --- 2066 unchanged lines hidden (view full) --- 2079 ARRAY_SIZE(wm8904_eq_controls)); 2080} 2081 2082 2083static int wm8904_probe(struct snd_soc_codec *codec) 2084{ 2085 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); 2086 struct wm8904_pdata *pdata = wm8904->pdata; | 5 * 6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 7 * 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 */ --- 2066 unchanged lines hidden (view full) --- 2079 ARRAY_SIZE(wm8904_eq_controls)); 2080} 2081 2082 2083static int wm8904_probe(struct snd_soc_codec *codec) 2084{ 2085 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); 2086 struct wm8904_pdata *pdata = wm8904->pdata; |
2087 u16 *reg_cache = codec->reg_cache; | |
2088 int ret, i; 2089 2090 codec->cache_sync = 1; 2091 codec->control_data = wm8904->regmap; 2092 2093 switch (wm8904->devtype) { 2094 case WM8904: 2095 break; --- 79 unchanged lines hidden (view full) --- 2175 WM8904_SR_MODE, 0); 2176 2177 /* Apply configuration from the platform data. */ 2178 if (wm8904->pdata) { 2179 for (i = 0; i < WM8904_GPIO_REGS; i++) { 2180 if (!pdata->gpio_cfg[i]) 2181 continue; 2182 | 2087 int ret, i; 2088 2089 codec->cache_sync = 1; 2090 codec->control_data = wm8904->regmap; 2091 2092 switch (wm8904->devtype) { 2093 case WM8904: 2094 break; --- 79 unchanged lines hidden (view full) --- 2174 WM8904_SR_MODE, 0); 2175 2176 /* Apply configuration from the platform data. */ 2177 if (wm8904->pdata) { 2178 for (i = 0; i < WM8904_GPIO_REGS; i++) { 2179 if (!pdata->gpio_cfg[i]) 2180 continue; 2181 |
2183 reg_cache[WM8904_GPIO_CONTROL_1 + i] 2184 = pdata->gpio_cfg[i] & 0xffff; | 2182 regmap_update_bits(wm8904->regmap, 2183 WM8904_GPIO_CONTROL_1 + i, 2184 0xffff, 2185 pdata->gpio_cfg[i]); |
2185 } 2186 2187 /* Zero is the default value for these anyway */ 2188 for (i = 0; i < WM8904_MIC_REGS; i++) | 2186 } 2187 2188 /* Zero is the default value for these anyway */ 2189 for (i = 0; i < WM8904_MIC_REGS; i++) |
2189 reg_cache[WM8904_MIC_BIAS_CONTROL_0 + i] 2190 = pdata->mic_cfg[i]; | 2190 regmap_update_bits(wm8904->regmap, 2191 WM8904_MIC_BIAS_CONTROL_0 + i, 2192 0xffff, 2193 pdata->mic_cfg[i]); |
2191 } 2192 2193 /* Set Class W by default - this will be managed by the Class 2194 * G widget at runtime where bypass paths are available. 2195 */ 2196 snd_soc_update_bits(codec, WM8904_CLASS_W_0, 2197 WM8904_CP_DYN_PWR, WM8904_CP_DYN_PWR); 2198 --- 59 unchanged lines hidden (view full) --- 2258 struct wm8904_priv *wm8904; 2259 int ret; 2260 2261 wm8904 = devm_kzalloc(&i2c->dev, sizeof(struct wm8904_priv), 2262 GFP_KERNEL); 2263 if (wm8904 == NULL) 2264 return -ENOMEM; 2265 | 2194 } 2195 2196 /* Set Class W by default - this will be managed by the Class 2197 * G widget at runtime where bypass paths are available. 2198 */ 2199 snd_soc_update_bits(codec, WM8904_CLASS_W_0, 2200 WM8904_CP_DYN_PWR, WM8904_CP_DYN_PWR); 2201 --- 59 unchanged lines hidden (view full) --- 2261 struct wm8904_priv *wm8904; 2262 int ret; 2263 2264 wm8904 = devm_kzalloc(&i2c->dev, sizeof(struct wm8904_priv), 2265 GFP_KERNEL); 2266 if (wm8904 == NULL) 2267 return -ENOMEM; 2268 |
2266 wm8904->regmap = devm_regmap_init_i2c(i2c, &wm8904_regmap); | 2269 wm8904->regmap = regmap_init_i2c(i2c, &wm8904_regmap); |
2267 if (IS_ERR(wm8904->regmap)) { 2268 ret = PTR_ERR(wm8904->regmap); 2269 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 2270 ret); 2271 return ret; 2272 } 2273 2274 wm8904->devtype = id->driver_data; 2275 i2c_set_clientdata(i2c, wm8904); 2276 wm8904->pdata = i2c->dev.platform_data; 2277 2278 ret = snd_soc_register_codec(&i2c->dev, 2279 &soc_codec_dev_wm8904, &wm8904_dai, 1); 2280 if (ret != 0) 2281 goto err; 2282 2283 return 0; 2284 2285err: | 2270 if (IS_ERR(wm8904->regmap)) { 2271 ret = PTR_ERR(wm8904->regmap); 2272 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 2273 ret); 2274 return ret; 2275 } 2276 2277 wm8904->devtype = id->driver_data; 2278 i2c_set_clientdata(i2c, wm8904); 2279 wm8904->pdata = i2c->dev.platform_data; 2280 2281 ret = snd_soc_register_codec(&i2c->dev, 2282 &soc_codec_dev_wm8904, &wm8904_dai, 1); 2283 if (ret != 0) 2284 goto err; 2285 2286 return 0; 2287 2288err: |
2289 regmap_exit(wm8904->regmap); |
|
2286 return ret; 2287} 2288 2289static __devexit int wm8904_i2c_remove(struct i2c_client *client) 2290{ | 2290 return ret; 2291} 2292 2293static __devexit int wm8904_i2c_remove(struct i2c_client *client) 2294{ |
2295 struct wm8904_priv *wm8904 = i2c_get_clientdata(client); |
|
2291 snd_soc_unregister_codec(&client->dev); | 2296 snd_soc_unregister_codec(&client->dev); |
2297 regmap_exit(wm8904->regmap); |
|
2292 return 0; 2293} 2294 2295static const struct i2c_device_id wm8904_i2c_id[] = { 2296 { "wm8904", WM8904 }, 2297 { "wm8912", WM8912 }, 2298 { "wm8918", WM8904 }, /* Actually a subset, updates to follow */ 2299 { } --- 5 unchanged lines hidden (view full) --- 2305 .name = "wm8904", 2306 .owner = THIS_MODULE, 2307 }, 2308 .probe = wm8904_i2c_probe, 2309 .remove = __devexit_p(wm8904_i2c_remove), 2310 .id_table = wm8904_i2c_id, 2311}; 2312 | 2298 return 0; 2299} 2300 2301static const struct i2c_device_id wm8904_i2c_id[] = { 2302 { "wm8904", WM8904 }, 2303 { "wm8912", WM8912 }, 2304 { "wm8918", WM8904 }, /* Actually a subset, updates to follow */ 2305 { } --- 5 unchanged lines hidden (view full) --- 2311 .name = "wm8904", 2312 .owner = THIS_MODULE, 2313 }, 2314 .probe = wm8904_i2c_probe, 2315 .remove = __devexit_p(wm8904_i2c_remove), 2316 .id_table = wm8904_i2c_id, 2317}; 2318 |
2313module_i2c_driver(wm8904_i2c_driver); | 2319static int __init wm8904_modinit(void) 2320{ 2321 int ret = 0; 2322 ret = i2c_add_driver(&wm8904_i2c_driver); 2323 if (ret != 0) { 2324 printk(KERN_ERR "Failed to register wm8904 I2C driver: %d\n", 2325 ret); 2326 } 2327 return ret; 2328} 2329module_init(wm8904_modinit); |
2314 | 2330 |
2331static void __exit wm8904_exit(void) 2332{ 2333 i2c_del_driver(&wm8904_i2c_driver); 2334} 2335module_exit(wm8904_exit); 2336 |
|
2315MODULE_DESCRIPTION("ASoC WM8904 driver"); 2316MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 2317MODULE_LICENSE("GPL"); | 2337MODULE_DESCRIPTION("ASoC WM8904 driver"); 2338MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 2339MODULE_LICENSE("GPL"); |