aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8990.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-11-22 09:36:23 -0500
committerMark Brown <broonie@linaro.org>2013-11-25 10:50:00 -0500
commit0112b62b12e18b883e1027689acab8eaa8830bac (patch)
treeea9660a7c7bfa7184a76f5d0a638e78298e899a6 /sound/soc/codecs/wm8990.c
parentd2fd5fe7ee3bc231e21aeb9ee120e0e61a79f8be (diff)
ASoC: wm8990: Convert to direct regmap API usage
Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8990.c')
-rw-r--r--sound/soc/codecs/wm8990.c156
1 files changed, 81 insertions, 75 deletions
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index 2261fe1b68ce..0ccd4d8d043b 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -17,6 +17,7 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/regmap.h>
20#include <linux/slab.h> 21#include <linux/slab.h>
21#include <sound/core.h> 22#include <sound/core.h>
22#include <sound/pcm.h> 23#include <sound/pcm.h>
@@ -30,13 +31,12 @@
30 31
31/* codec private data */ 32/* codec private data */
32struct wm8990_priv { 33struct wm8990_priv {
33 enum snd_soc_control_type control_type; 34 struct regmap *regmap;
34 unsigned int sysclk; 35 unsigned int sysclk;
35 unsigned int pcmclk; 36 unsigned int pcmclk;
36}; 37};
37 38
38static int wm8990_volatile_register(struct snd_soc_codec *codec, 39static bool wm8990_volatile_register(struct device *dev, unsigned int reg)
39 unsigned int reg)
40{ 40{
41 switch (reg) { 41 switch (reg) {
42 case WM8990_RESET: 42 case WM8990_RESET:
@@ -46,71 +46,69 @@ static int wm8990_volatile_register(struct snd_soc_codec *codec,
46 } 46 }
47} 47}
48 48
49static const u16 wm8990_reg[] = { 49static const struct reg_default wm8990_reg_defaults[] = {
50 0x8990, /* R0 - Reset */ 50 { 1, 0x0000 }, /* R1 - Power Management (1) */
51 0x0000, /* R1 - Power Management (1) */ 51 { 2, 0x6000 }, /* R2 - Power Management (2) */
52 0x6000, /* R2 - Power Management (2) */ 52 { 3, 0x0000 }, /* R3 - Power Management (3) */
53 0x0000, /* R3 - Power Management (3) */ 53 { 4, 0x4050 }, /* R4 - Audio Interface (1) */
54 0x4050, /* R4 - Audio Interface (1) */ 54 { 5, 0x4000 }, /* R5 - Audio Interface (2) */
55 0x4000, /* R5 - Audio Interface (2) */ 55 { 6, 0x01C8 }, /* R6 - Clocking (1) */
56 0x01C8, /* R6 - Clocking (1) */ 56 { 7, 0x0000 }, /* R7 - Clocking (2) */
57 0x0000, /* R7 - Clocking (2) */ 57 { 8, 0x0040 }, /* R8 - Audio Interface (3) */
58 0x0040, /* R8 - Audio Interface (3) */ 58 { 9, 0x0040 }, /* R9 - Audio Interface (4) */
59 0x0040, /* R9 - Audio Interface (4) */ 59 { 10, 0x0004 }, /* R10 - DAC CTRL */
60 0x0004, /* R10 - DAC CTRL */ 60 { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */
61 0x00C0, /* R11 - Left DAC Digital Volume */ 61 { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */
62 0x00C0, /* R12 - Right DAC Digital Volume */ 62 { 13, 0x0000 }, /* R13 - Digital Side Tone */
63 0x0000, /* R13 - Digital Side Tone */ 63 { 14, 0x0100 }, /* R14 - ADC CTRL */
64 0x0100, /* R14 - ADC CTRL */ 64 { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */
65 0x00C0, /* R15 - Left ADC Digital Volume */ 65 { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */
66 0x00C0, /* R16 - Right ADC Digital Volume */ 66
67 0x0000, /* R17 */ 67 { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */
68 0x0000, /* R18 - GPIO CTRL 1 */ 68 { 19, 0x1000 }, /* R19 - GPIO1 & GPIO2 */
69 0x1000, /* R19 - GPIO1 & GPIO2 */ 69 { 20, 0x1010 }, /* R20 - GPIO3 & GPIO4 */
70 0x1010, /* R20 - GPIO3 & GPIO4 */ 70 { 21, 0x1010 }, /* R21 - GPIO5 & GPIO6 */
71 0x1010, /* R21 - GPIO5 & GPIO6 */ 71 { 22, 0x8000 }, /* R22 - GPIOCTRL 2 */
72 0x8000, /* R22 - GPIOCTRL 2 */ 72 { 23, 0x0800 }, /* R23 - GPIO_POL */
73 0x0800, /* R23 - GPIO_POL */ 73 { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */
74 0x008B, /* R24 - Left Line Input 1&2 Volume */ 74 { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */
75 0x008B, /* R25 - Left Line Input 3&4 Volume */ 75 { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */
76 0x008B, /* R26 - Right Line Input 1&2 Volume */ 76 { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */
77 0x008B, /* R27 - Right Line Input 3&4 Volume */ 77 { 28, 0x0000 }, /* R28 - Left Output Volume */
78 0x0000, /* R28 - Left Output Volume */ 78 { 29, 0x0000 }, /* R29 - Right Output Volume */
79 0x0000, /* R29 - Right Output Volume */ 79 { 30, 0x0066 }, /* R30 - Line Outputs Volume */
80 0x0066, /* R30 - Line Outputs Volume */ 80 { 31, 0x0022 }, /* R31 - Out3/4 Volume */
81 0x0022, /* R31 - Out3/4 Volume */ 81 { 32, 0x0079 }, /* R32 - Left OPGA Volume */
82 0x0079, /* R32 - Left OPGA Volume */ 82 { 33, 0x0079 }, /* R33 - Right OPGA Volume */
83 0x0079, /* R33 - Right OPGA Volume */ 83 { 34, 0x0003 }, /* R34 - Speaker Volume */
84 0x0003, /* R34 - Speaker Volume */ 84 { 35, 0x0003 }, /* R35 - ClassD1 */
85 0x0003, /* R35 - ClassD1 */ 85
86 0x0000, /* R36 */ 86 { 37, 0x0100 }, /* R37 - ClassD3 */
87 0x0100, /* R37 - ClassD3 */ 87 { 38, 0x0079 }, /* R38 - ClassD4 */
88 0x0079, /* R38 - ClassD4 */ 88 { 39, 0x0000 }, /* R39 - Input Mixer1 */
89 0x0000, /* R39 - Input Mixer1 */ 89 { 40, 0x0000 }, /* R40 - Input Mixer2 */
90 0x0000, /* R40 - Input Mixer2 */ 90 { 41, 0x0000 }, /* R41 - Input Mixer3 */
91 0x0000, /* R41 - Input Mixer3 */ 91 { 42, 0x0000 }, /* R42 - Input Mixer4 */
92 0x0000, /* R42 - Input Mixer4 */ 92 { 43, 0x0000 }, /* R43 - Input Mixer5 */
93 0x0000, /* R43 - Input Mixer5 */ 93 { 44, 0x0000 }, /* R44 - Input Mixer6 */
94 0x0000, /* R44 - Input Mixer6 */ 94 { 45, 0x0000 }, /* R45 - Output Mixer1 */
95 0x0000, /* R45 - Output Mixer1 */ 95 { 46, 0x0000 }, /* R46 - Output Mixer2 */
96 0x0000, /* R46 - Output Mixer2 */ 96 { 47, 0x0000 }, /* R47 - Output Mixer3 */
97 0x0000, /* R47 - Output Mixer3 */ 97 { 48, 0x0000 }, /* R48 - Output Mixer4 */
98 0x0000, /* R48 - Output Mixer4 */ 98 { 49, 0x0000 }, /* R49 - Output Mixer5 */
99 0x0000, /* R49 - Output Mixer5 */ 99 { 50, 0x0000 }, /* R50 - Output Mixer6 */
100 0x0000, /* R50 - Output Mixer6 */ 100 { 51, 0x0180 }, /* R51 - Out3/4 Mixer */
101 0x0180, /* R51 - Out3/4 Mixer */ 101 { 52, 0x0000 }, /* R52 - Line Mixer1 */
102 0x0000, /* R52 - Line Mixer1 */ 102 { 53, 0x0000 }, /* R53 - Line Mixer2 */
103 0x0000, /* R53 - Line Mixer2 */ 103 { 54, 0x0000 }, /* R54 - Speaker Mixer */
104 0x0000, /* R54 - Speaker Mixer */ 104 { 55, 0x0000 }, /* R55 - Additional Control */
105 0x0000, /* R55 - Additional Control */ 105 { 56, 0x0000 }, /* R56 - AntiPOP1 */
106 0x0000, /* R56 - AntiPOP1 */ 106 { 57, 0x0000 }, /* R57 - AntiPOP2 */
107 0x0000, /* R57 - AntiPOP2 */ 107 { 58, 0x0000 }, /* R58 - MICBIAS */
108 0x0000, /* R58 - MICBIAS */ 108
109 0x0000, /* R59 */ 109 { 60, 0x0008 }, /* R60 - PLL1 */
110 0x0008, /* R60 - PLL1 */ 110 { 61, 0x0031 }, /* R61 - PLL2 */
111 0x0031, /* R61 - PLL2 */ 111 { 62, 0x0026 }, /* R62 - PLL3 */
112 0x0026, /* R62 - PLL3 */
113 0x0000, /* R63 - Driver internal */
114}; 112};
115 113
116#define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0) 114#define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0)
@@ -1114,6 +1112,7 @@ static int wm8990_mute(struct snd_soc_dai *dai, int mute)
1114static int wm8990_set_bias_level(struct snd_soc_codec *codec, 1112static int wm8990_set_bias_level(struct snd_soc_codec *codec,
1115 enum snd_soc_bias_level level) 1113 enum snd_soc_bias_level level)
1116{ 1114{
1115 struct wm8990_priv *wm8990 = snd_soc_codec_get_drvdata(codec);
1117 int ret; 1116 int ret;
1118 1117
1119 switch (level) { 1118 switch (level) {
@@ -1128,7 +1127,7 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec,
1128 1127
1129 case SND_SOC_BIAS_STANDBY: 1128 case SND_SOC_BIAS_STANDBY:
1130 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { 1129 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1131 ret = snd_soc_cache_sync(codec); 1130 ret = regcache_sync(wm8990->regmap);
1132 if (ret < 0) { 1131 if (ret < 0) {
1133 dev_err(codec->dev, "Failed to sync cache: %d\n", ret); 1132 dev_err(codec->dev, "Failed to sync cache: %d\n", ret);
1134 return ret; 1133 return ret;
@@ -1226,7 +1225,7 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec,
1226 /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ 1225 /* disable POBCTRL, SOFT_ST and BUFDCOPEN */
1227 snd_soc_write(codec, WM8990_ANTIPOP2, 0x0); 1226 snd_soc_write(codec, WM8990_ANTIPOP2, 0x0);
1228 1227
1229 codec->cache_sync = 1; 1228 regcache_mark_dirty(wm8990->regmap);
1230 break; 1229 break;
1231 } 1230 }
1232 1231
@@ -1295,7 +1294,7 @@ static int wm8990_probe(struct snd_soc_codec *codec)
1295{ 1294{
1296 int ret; 1295 int ret;
1297 1296
1298 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); 1297 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
1299 if (ret < 0) { 1298 if (ret < 0) {
1300 printk(KERN_ERR "wm8990: failed to set cache I/O: %d\n", ret); 1299 printk(KERN_ERR "wm8990: failed to set cache I/O: %d\n", ret);
1301 return ret; 1300 return ret;
@@ -1334,10 +1333,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8990 = {
1334 .suspend = wm8990_suspend, 1333 .suspend = wm8990_suspend,
1335 .resume = wm8990_resume, 1334 .resume = wm8990_resume,
1336 .set_bias_level = wm8990_set_bias_level, 1335 .set_bias_level = wm8990_set_bias_level,
1337 .reg_cache_size = ARRAY_SIZE(wm8990_reg),
1338 .reg_word_size = sizeof(u16),
1339 .reg_cache_default = wm8990_reg,
1340 .volatile_register = wm8990_volatile_register,
1341 .controls = wm8990_snd_controls, 1336 .controls = wm8990_snd_controls,
1342 .num_controls = ARRAY_SIZE(wm8990_snd_controls), 1337 .num_controls = ARRAY_SIZE(wm8990_snd_controls),
1343 .dapm_widgets = wm8990_dapm_widgets, 1338 .dapm_widgets = wm8990_dapm_widgets,
@@ -1346,6 +1341,17 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8990 = {
1346 .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes), 1341 .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes),
1347}; 1342};
1348 1343
1344static const struct regmap_config wm8990_regmap = {
1345 .reg_bits = 8,
1346 .val_bits = 16,
1347
1348 .max_register = WM8990_PLL3,
1349 .volatile_reg = wm8990_volatile_register,
1350 .reg_defaults = wm8990_reg_defaults,
1351 .num_reg_defaults = ARRAY_SIZE(wm8990_reg_defaults),
1352 .cache_type = REGCACHE_RBTREE,
1353};
1354
1349static int wm8990_i2c_probe(struct i2c_client *i2c, 1355static int wm8990_i2c_probe(struct i2c_client *i2c,
1350 const struct i2c_device_id *id) 1356 const struct i2c_device_id *id)
1351{ 1357{