diff options
Diffstat (limited to 'sound/soc/codecs/wm8995.c')
-rw-r--r-- | sound/soc/codecs/wm8995.c | 732 |
1 files changed, 617 insertions, 115 deletions
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index 78eeb21e6696..c8aada597d70 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/pm.h> | 19 | #include <linux/pm.h> |
20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
21 | #include <linux/regmap.h> | ||
21 | #include <linux/spi/spi.h> | 22 | #include <linux/spi/spi.h> |
22 | #include <linux/regulator/consumer.h> | 23 | #include <linux/regulator/consumer.h> |
23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
@@ -43,88 +44,331 @@ static const char *wm8995_supply_names[WM8995_NUM_SUPPLIES] = { | |||
43 | "MICVDD" | 44 | "MICVDD" |
44 | }; | 45 | }; |
45 | 46 | ||
46 | static const u16 wm8995_reg_defs[WM8995_MAX_REGISTER + 1] = { | 47 | static struct reg_default wm8995_reg_defaults[] = { |
47 | [0] = 0x8995, [5] = 0x0100, [16] = 0x000b, [17] = 0x000b, | 48 | { 0, 0x8995 }, |
48 | [24] = 0x02c0, [25] = 0x02c0, [26] = 0x02c0, [27] = 0x02c0, | 49 | { 5, 0x0100 }, |
49 | [28] = 0x000f, [32] = 0x0005, [33] = 0x0005, [40] = 0x0003, | 50 | { 16, 0x000b }, |
50 | [41] = 0x0013, [48] = 0x0004, [56] = 0x09f8, [64] = 0x1f25, | 51 | { 17, 0x000b }, |
51 | [69] = 0x0004, [82] = 0xaaaa, [84] = 0x2a2a, [146] = 0x0060, | 52 | { 24, 0x02c0 }, |
52 | [256] = 0x0002, [257] = 0x8004, [520] = 0x0010, [528] = 0x0083, | 53 | { 25, 0x02c0 }, |
53 | [529] = 0x0083, [548] = 0x0c80, [580] = 0x0c80, [768] = 0x4050, | 54 | { 26, 0x02c0 }, |
54 | [769] = 0x4000, [771] = 0x0040, [772] = 0x0040, [773] = 0x0040, | 55 | { 27, 0x02c0 }, |
55 | [774] = 0x0004, [775] = 0x0100, [784] = 0x4050, [785] = 0x4000, | 56 | { 28, 0x000f }, |
56 | [787] = 0x0040, [788] = 0x0040, [789] = 0x0040, [1024] = 0x00c0, | 57 | { 32, 0x0005 }, |
57 | [1025] = 0x00c0, [1026] = 0x00c0, [1027] = 0x00c0, [1028] = 0x00c0, | 58 | { 33, 0x0005 }, |
58 | [1029] = 0x00c0, [1030] = 0x00c0, [1031] = 0x00c0, [1056] = 0x0200, | 59 | { 40, 0x0003 }, |
59 | [1057] = 0x0010, [1058] = 0x0200, [1059] = 0x0010, [1088] = 0x0098, | 60 | { 41, 0x0013 }, |
60 | [1089] = 0x0845, [1104] = 0x0098, [1105] = 0x0845, [1152] = 0x6318, | 61 | { 48, 0x0004 }, |
61 | [1153] = 0x6300, [1154] = 0x0fca, [1155] = 0x0400, [1156] = 0x00d8, | 62 | { 56, 0x09f8 }, |
62 | [1157] = 0x1eb5, [1158] = 0xf145, [1159] = 0x0b75, [1160] = 0x01c5, | 63 | { 64, 0x1f25 }, |
63 | [1161] = 0x1c58, [1162] = 0xf373, [1163] = 0x0a54, [1164] = 0x0558, | 64 | { 69, 0x0004 }, |
64 | [1165] = 0x168e, [1166] = 0xf829, [1167] = 0x07ad, [1168] = 0x1103, | 65 | { 82, 0xaaaa }, |
65 | [1169] = 0x0564, [1170] = 0x0559, [1171] = 0x4000, [1184] = 0x6318, | 66 | { 84, 0x2a2a }, |
66 | [1185] = 0x6300, [1186] = 0x0fca, [1187] = 0x0400, [1188] = 0x00d8, | 67 | { 146, 0x0060 }, |
67 | [1189] = 0x1eb5, [1190] = 0xf145, [1191] = 0x0b75, [1192] = 0x01c5, | 68 | { 256, 0x0002 }, |
68 | [1193] = 0x1c58, [1194] = 0xf373, [1195] = 0x0a54, [1196] = 0x0558, | 69 | { 257, 0x8004 }, |
69 | [1197] = 0x168e, [1198] = 0xf829, [1199] = 0x07ad, [1200] = 0x1103, | 70 | { 520, 0x0010 }, |
70 | [1201] = 0x0564, [1202] = 0x0559, [1203] = 0x4000, [1280] = 0x00c0, | 71 | { 528, 0x0083 }, |
71 | [1281] = 0x00c0, [1282] = 0x00c0, [1283] = 0x00c0, [1312] = 0x0200, | 72 | { 529, 0x0083 }, |
72 | [1313] = 0x0010, [1344] = 0x0098, [1345] = 0x0845, [1408] = 0x6318, | 73 | { 548, 0x0c80 }, |
73 | [1409] = 0x6300, [1410] = 0x0fca, [1411] = 0x0400, [1412] = 0x00d8, | 74 | { 580, 0x0c80 }, |
74 | [1413] = 0x1eb5, [1414] = 0xf145, [1415] = 0x0b75, [1416] = 0x01c5, | 75 | { 768, 0x4050 }, |
75 | [1417] = 0x1c58, [1418] = 0xf373, [1419] = 0x0a54, [1420] = 0x0558, | 76 | { 769, 0x4000 }, |
76 | [1421] = 0x168e, [1422] = 0xf829, [1423] = 0x07ad, [1424] = 0x1103, | 77 | { 771, 0x0040 }, |
77 | [1425] = 0x0564, [1426] = 0x0559, [1427] = 0x4000, [1568] = 0x0002, | 78 | { 772, 0x0040 }, |
78 | [1792] = 0xa100, [1793] = 0xa101, [1794] = 0xa101, [1795] = 0xa101, | 79 | { 773, 0x0040 }, |
79 | [1796] = 0xa101, [1797] = 0xa101, [1798] = 0xa101, [1799] = 0xa101, | 80 | { 774, 0x0004 }, |
80 | [1800] = 0xa101, [1801] = 0xa101, [1802] = 0xa101, [1803] = 0xa101, | 81 | { 775, 0x0100 }, |
81 | [1804] = 0xa101, [1805] = 0xa101, [1825] = 0x0055, [1848] = 0x3fff, | 82 | { 784, 0x4050 }, |
82 | [1849] = 0x1fff, [2049] = 0x0001, [2050] = 0x0069, [2056] = 0x0002, | 83 | { 785, 0x4000 }, |
83 | [2057] = 0x0003, [2058] = 0x0069, [12288] = 0x0001, [12289] = 0x0001, | 84 | { 787, 0x0040 }, |
84 | [12291] = 0x0006, [12292] = 0x0040, [12293] = 0x0001, [12294] = 0x000f, | 85 | { 788, 0x0040 }, |
85 | [12295] = 0x0006, [12296] = 0x0001, [12297] = 0x0003, [12298] = 0x0104, | 86 | { 789, 0x0040 }, |
86 | [12300] = 0x0060, [12301] = 0x0011, [12302] = 0x0401, [12304] = 0x0050, | 87 | { 1024, 0x00c0 }, |
87 | [12305] = 0x0003, [12306] = 0x0100, [12308] = 0x0051, [12309] = 0x0003, | 88 | { 1025, 0x00c0 }, |
88 | [12310] = 0x0104, [12311] = 0x000a, [12312] = 0x0060, [12313] = 0x003b, | 89 | { 1026, 0x00c0 }, |
89 | [12314] = 0x0502, [12315] = 0x0100, [12316] = 0x2fff, [12320] = 0x2fff, | 90 | { 1027, 0x00c0 }, |
90 | [12324] = 0x2fff, [12328] = 0x2fff, [12332] = 0x2fff, [12336] = 0x2fff, | 91 | { 1028, 0x00c0 }, |
91 | [12340] = 0x2fff, [12344] = 0x2fff, [12348] = 0x2fff, [12352] = 0x0001, | 92 | { 1029, 0x00c0 }, |
92 | [12353] = 0x0001, [12355] = 0x0006, [12356] = 0x0040, [12357] = 0x0001, | 93 | { 1030, 0x00c0 }, |
93 | [12358] = 0x000f, [12359] = 0x0006, [12360] = 0x0001, [12361] = 0x0003, | 94 | { 1031, 0x00c0 }, |
94 | [12362] = 0x0104, [12364] = 0x0060, [12365] = 0x0011, [12366] = 0x0401, | 95 | { 1056, 0x0200 }, |
95 | [12368] = 0x0050, [12369] = 0x0003, [12370] = 0x0100, [12372] = 0x0060, | 96 | { 1057, 0x0010 }, |
96 | [12373] = 0x003b, [12374] = 0x0502, [12375] = 0x0100, [12376] = 0x2fff, | 97 | { 1058, 0x0200 }, |
97 | [12380] = 0x2fff, [12384] = 0x2fff, [12388] = 0x2fff, [12392] = 0x2fff, | 98 | { 1059, 0x0010 }, |
98 | [12396] = 0x2fff, [12400] = 0x2fff, [12404] = 0x2fff, [12408] = 0x2fff, | 99 | { 1088, 0x0098 }, |
99 | [12412] = 0x2fff, [12416] = 0x0001, [12417] = 0x0001, [12419] = 0x0006, | 100 | { 1089, 0x0845 }, |
100 | [12420] = 0x0040, [12421] = 0x0001, [12422] = 0x000f, [12423] = 0x0006, | 101 | { 1104, 0x0098 }, |
101 | [12424] = 0x0001, [12425] = 0x0003, [12426] = 0x0106, [12428] = 0x0061, | 102 | { 1105, 0x0845 }, |
102 | [12429] = 0x0011, [12430] = 0x0401, [12432] = 0x0050, [12433] = 0x0003, | 103 | { 1152, 0x6318 }, |
103 | [12434] = 0x0102, [12436] = 0x0051, [12437] = 0x0003, [12438] = 0x0106, | 104 | { 1153, 0x6300 }, |
104 | [12439] = 0x000a, [12440] = 0x0061, [12441] = 0x003b, [12442] = 0x0502, | 105 | { 1154, 0x0fca }, |
105 | [12443] = 0x0100, [12444] = 0x2fff, [12448] = 0x2fff, [12452] = 0x2fff, | 106 | { 1155, 0x0400 }, |
106 | [12456] = 0x2fff, [12460] = 0x2fff, [12464] = 0x2fff, [12468] = 0x2fff, | 107 | { 1156, 0x00d8 }, |
107 | [12472] = 0x2fff, [12476] = 0x2fff, [12480] = 0x0001, [12481] = 0x0001, | 108 | { 1157, 0x1eb5 }, |
108 | [12483] = 0x0006, [12484] = 0x0040, [12485] = 0x0001, [12486] = 0x000f, | 109 | { 1158, 0xf145 }, |
109 | [12487] = 0x0006, [12488] = 0x0001, [12489] = 0x0003, [12490] = 0x0106, | 110 | { 1159, 0x0b75 }, |
110 | [12492] = 0x0061, [12493] = 0x0011, [12494] = 0x0401, [12496] = 0x0050, | 111 | { 1160, 0x01c5 }, |
111 | [12497] = 0x0003, [12498] = 0x0102, [12500] = 0x0061, [12501] = 0x003b, | 112 | { 1161, 0x1c58 }, |
112 | [12502] = 0x0502, [12503] = 0x0100, [12504] = 0x2fff, [12508] = 0x2fff, | 113 | { 1162, 0xf373 }, |
113 | [12512] = 0x2fff, [12516] = 0x2fff, [12520] = 0x2fff, [12524] = 0x2fff, | 114 | { 1163, 0x0a54 }, |
114 | [12528] = 0x2fff, [12532] = 0x2fff, [12536] = 0x2fff, [12540] = 0x2fff, | 115 | { 1164, 0x0558 }, |
115 | [12544] = 0x0060, [12546] = 0x0601, [12548] = 0x0050, [12550] = 0x0100, | 116 | { 1165, 0x168e }, |
116 | [12552] = 0x0001, [12554] = 0x0104, [12555] = 0x0100, [12556] = 0x2fff, | 117 | { 1166, 0xf829 }, |
117 | [12560] = 0x2fff, [12564] = 0x2fff, [12568] = 0x2fff, [12572] = 0x2fff, | 118 | { 1167, 0x07ad }, |
118 | [12576] = 0x2fff, [12580] = 0x2fff, [12584] = 0x2fff, [12588] = 0x2fff, | 119 | { 1168, 0x1103 }, |
119 | [12592] = 0x2fff, [12596] = 0x2fff, [12600] = 0x2fff, [12604] = 0x2fff, | 120 | { 1169, 0x0564 }, |
120 | [12608] = 0x0061, [12610] = 0x0601, [12612] = 0x0050, [12614] = 0x0102, | 121 | { 1170, 0x0559 }, |
121 | [12616] = 0x0001, [12618] = 0x0106, [12619] = 0x0100, [12620] = 0x2fff, | 122 | { 1171, 0x4000 }, |
122 | [12624] = 0x2fff, [12628] = 0x2fff, [12632] = 0x2fff, [12636] = 0x2fff, | 123 | { 1184, 0x6318 }, |
123 | [12640] = 0x2fff, [12644] = 0x2fff, [12648] = 0x2fff, [12652] = 0x2fff, | 124 | { 1185, 0x6300 }, |
124 | [12656] = 0x2fff, [12660] = 0x2fff, [12664] = 0x2fff, [12668] = 0x2fff, | 125 | { 1186, 0x0fca }, |
125 | [12672] = 0x0060, [12674] = 0x0601, [12676] = 0x0061, [12678] = 0x0601, | 126 | { 1187, 0x0400 }, |
126 | [12680] = 0x0050, [12682] = 0x0300, [12684] = 0x0001, [12686] = 0x0304, | 127 | { 1188, 0x00d8 }, |
127 | [12688] = 0x0040, [12690] = 0x000f, [12692] = 0x0001, [12695] = 0x0100 | 128 | { 1189, 0x1eb5 }, |
129 | { 1190, 0xf145 }, | ||
130 | { 1191, 0x0b75 }, | ||
131 | { 1192, 0x01c5 }, | ||
132 | { 1193, 0x1c58 }, | ||
133 | { 1194, 0xf373 }, | ||
134 | { 1195, 0x0a54 }, | ||
135 | { 1196, 0x0558 }, | ||
136 | { 1197, 0x168e }, | ||
137 | { 1198, 0xf829 }, | ||
138 | { 1199, 0x07ad }, | ||
139 | { 1200, 0x1103 }, | ||
140 | { 1201, 0x0564 }, | ||
141 | { 1202, 0x0559 }, | ||
142 | { 1203, 0x4000 }, | ||
143 | { 1280, 0x00c0 }, | ||
144 | { 1281, 0x00c0 }, | ||
145 | { 1282, 0x00c0 }, | ||
146 | { 1283, 0x00c0 }, | ||
147 | { 1312, 0x0200 }, | ||
148 | { 1313, 0x0010 }, | ||
149 | { 1344, 0x0098 }, | ||
150 | { 1345, 0x0845 }, | ||
151 | { 1408, 0x6318 }, | ||
152 | { 1409, 0x6300 }, | ||
153 | { 1410, 0x0fca }, | ||
154 | { 1411, 0x0400 }, | ||
155 | { 1412, 0x00d8 }, | ||
156 | { 1413, 0x1eb5 }, | ||
157 | { 1414, 0xf145 }, | ||
158 | { 1415, 0x0b75 }, | ||
159 | { 1416, 0x01c5 }, | ||
160 | { 1417, 0x1c58 }, | ||
161 | { 1418, 0xf373 }, | ||
162 | { 1419, 0x0a54 }, | ||
163 | { 1420, 0x0558 }, | ||
164 | { 1421, 0x168e }, | ||
165 | { 1422, 0xf829 }, | ||
166 | { 1423, 0x07ad }, | ||
167 | { 1424, 0x1103 }, | ||
168 | { 1425, 0x0564 }, | ||
169 | { 1426, 0x0559 }, | ||
170 | { 1427, 0x4000 }, | ||
171 | { 1568, 0x0002 }, | ||
172 | { 1792, 0xa100 }, | ||
173 | { 1793, 0xa101 }, | ||
174 | { 1794, 0xa101 }, | ||
175 | { 1795, 0xa101 }, | ||
176 | { 1796, 0xa101 }, | ||
177 | { 1797, 0xa101 }, | ||
178 | { 1798, 0xa101 }, | ||
179 | { 1799, 0xa101 }, | ||
180 | { 1800, 0xa101 }, | ||
181 | { 1801, 0xa101 }, | ||
182 | { 1802, 0xa101 }, | ||
183 | { 1803, 0xa101 }, | ||
184 | { 1804, 0xa101 }, | ||
185 | { 1805, 0xa101 }, | ||
186 | { 1825, 0x0055 }, | ||
187 | { 1848, 0x3fff }, | ||
188 | { 1849, 0x1fff }, | ||
189 | { 2049, 0x0001 }, | ||
190 | { 2050, 0x0069 }, | ||
191 | { 2056, 0x0002 }, | ||
192 | { 2057, 0x0003 }, | ||
193 | { 2058, 0x0069 }, | ||
194 | { 12288, 0x0001 }, | ||
195 | { 12289, 0x0001 }, | ||
196 | { 12291, 0x0006 }, | ||
197 | { 12292, 0x0040 }, | ||
198 | { 12293, 0x0001 }, | ||
199 | { 12294, 0x000f }, | ||
200 | { 12295, 0x0006 }, | ||
201 | { 12296, 0x0001 }, | ||
202 | { 12297, 0x0003 }, | ||
203 | { 12298, 0x0104 }, | ||
204 | { 12300, 0x0060 }, | ||
205 | { 12301, 0x0011 }, | ||
206 | { 12302, 0x0401 }, | ||
207 | { 12304, 0x0050 }, | ||
208 | { 12305, 0x0003 }, | ||
209 | { 12306, 0x0100 }, | ||
210 | { 12308, 0x0051 }, | ||
211 | { 12309, 0x0003 }, | ||
212 | { 12310, 0x0104 }, | ||
213 | { 12311, 0x000a }, | ||
214 | { 12312, 0x0060 }, | ||
215 | { 12313, 0x003b }, | ||
216 | { 12314, 0x0502 }, | ||
217 | { 12315, 0x0100 }, | ||
218 | { 12316, 0x2fff }, | ||
219 | { 12320, 0x2fff }, | ||
220 | { 12324, 0x2fff }, | ||
221 | { 12328, 0x2fff }, | ||
222 | { 12332, 0x2fff }, | ||
223 | { 12336, 0x2fff }, | ||
224 | { 12340, 0x2fff }, | ||
225 | { 12344, 0x2fff }, | ||
226 | { 12348, 0x2fff }, | ||
227 | { 12352, 0x0001 }, | ||
228 | { 12353, 0x0001 }, | ||
229 | { 12355, 0x0006 }, | ||
230 | { 12356, 0x0040 }, | ||
231 | { 12357, 0x0001 }, | ||
232 | { 12358, 0x000f }, | ||
233 | { 12359, 0x0006 }, | ||
234 | { 12360, 0x0001 }, | ||
235 | { 12361, 0x0003 }, | ||
236 | { 12362, 0x0104 }, | ||
237 | { 12364, 0x0060 }, | ||
238 | { 12365, 0x0011 }, | ||
239 | { 12366, 0x0401 }, | ||
240 | { 12368, 0x0050 }, | ||
241 | { 12369, 0x0003 }, | ||
242 | { 12370, 0x0100 }, | ||
243 | { 12372, 0x0060 }, | ||
244 | { 12373, 0x003b }, | ||
245 | { 12374, 0x0502 }, | ||
246 | { 12375, 0x0100 }, | ||
247 | { 12376, 0x2fff }, | ||
248 | { 12380, 0x2fff }, | ||
249 | { 12384, 0x2fff }, | ||
250 | { 12388, 0x2fff }, | ||
251 | { 12392, 0x2fff }, | ||
252 | { 12396, 0x2fff }, | ||
253 | { 12400, 0x2fff }, | ||
254 | { 12404, 0x2fff }, | ||
255 | { 12408, 0x2fff }, | ||
256 | { 12412, 0x2fff }, | ||
257 | { 12416, 0x0001 }, | ||
258 | { 12417, 0x0001 }, | ||
259 | { 12419, 0x0006 }, | ||
260 | { 12420, 0x0040 }, | ||
261 | { 12421, 0x0001 }, | ||
262 | { 12422, 0x000f }, | ||
263 | { 12423, 0x0006 }, | ||
264 | { 12424, 0x0001 }, | ||
265 | { 12425, 0x0003 }, | ||
266 | { 12426, 0x0106 }, | ||
267 | { 12428, 0x0061 }, | ||
268 | { 12429, 0x0011 }, | ||
269 | { 12430, 0x0401 }, | ||
270 | { 12432, 0x0050 }, | ||
271 | { 12433, 0x0003 }, | ||
272 | { 12434, 0x0102 }, | ||
273 | { 12436, 0x0051 }, | ||
274 | { 12437, 0x0003 }, | ||
275 | { 12438, 0x0106 }, | ||
276 | { 12439, 0x000a }, | ||
277 | { 12440, 0x0061 }, | ||
278 | { 12441, 0x003b }, | ||
279 | { 12442, 0x0502 }, | ||
280 | { 12443, 0x0100 }, | ||
281 | { 12444, 0x2fff }, | ||
282 | { 12448, 0x2fff }, | ||
283 | { 12452, 0x2fff }, | ||
284 | { 12456, 0x2fff }, | ||
285 | { 12460, 0x2fff }, | ||
286 | { 12464, 0x2fff }, | ||
287 | { 12468, 0x2fff }, | ||
288 | { 12472, 0x2fff }, | ||
289 | { 12476, 0x2fff }, | ||
290 | { 12480, 0x0001 }, | ||
291 | { 12481, 0x0001 }, | ||
292 | { 12483, 0x0006 }, | ||
293 | { 12484, 0x0040 }, | ||
294 | { 12485, 0x0001 }, | ||
295 | { 12486, 0x000f }, | ||
296 | { 12487, 0x0006 }, | ||
297 | { 12488, 0x0001 }, | ||
298 | { 12489, 0x0003 }, | ||
299 | { 12490, 0x0106 }, | ||
300 | { 12492, 0x0061 }, | ||
301 | { 12493, 0x0011 }, | ||
302 | { 12494, 0x0401 }, | ||
303 | { 12496, 0x0050 }, | ||
304 | { 12497, 0x0003 }, | ||
305 | { 12498, 0x0102 }, | ||
306 | { 12500, 0x0061 }, | ||
307 | { 12501, 0x003b }, | ||
308 | { 12502, 0x0502 }, | ||
309 | { 12503, 0x0100 }, | ||
310 | { 12504, 0x2fff }, | ||
311 | { 12508, 0x2fff }, | ||
312 | { 12512, 0x2fff }, | ||
313 | { 12516, 0x2fff }, | ||
314 | { 12520, 0x2fff }, | ||
315 | { 12524, 0x2fff }, | ||
316 | { 12528, 0x2fff }, | ||
317 | { 12532, 0x2fff }, | ||
318 | { 12536, 0x2fff }, | ||
319 | { 12540, 0x2fff }, | ||
320 | { 12544, 0x0060 }, | ||
321 | { 12546, 0x0601 }, | ||
322 | { 12548, 0x0050 }, | ||
323 | { 12550, 0x0100 }, | ||
324 | { 12552, 0x0001 }, | ||
325 | { 12554, 0x0104 }, | ||
326 | { 12555, 0x0100 }, | ||
327 | { 12556, 0x2fff }, | ||
328 | { 12560, 0x2fff }, | ||
329 | { 12564, 0x2fff }, | ||
330 | { 12568, 0x2fff }, | ||
331 | { 12572, 0x2fff }, | ||
332 | { 12576, 0x2fff }, | ||
333 | { 12580, 0x2fff }, | ||
334 | { 12584, 0x2fff }, | ||
335 | { 12588, 0x2fff }, | ||
336 | { 12592, 0x2fff }, | ||
337 | { 12596, 0x2fff }, | ||
338 | { 12600, 0x2fff }, | ||
339 | { 12604, 0x2fff }, | ||
340 | { 12608, 0x0061 }, | ||
341 | { 12610, 0x0601 }, | ||
342 | { 12612, 0x0050 }, | ||
343 | { 12614, 0x0102 }, | ||
344 | { 12616, 0x0001 }, | ||
345 | { 12618, 0x0106 }, | ||
346 | { 12619, 0x0100 }, | ||
347 | { 12620, 0x2fff }, | ||
348 | { 12624, 0x2fff }, | ||
349 | { 12628, 0x2fff }, | ||
350 | { 12632, 0x2fff }, | ||
351 | { 12636, 0x2fff }, | ||
352 | { 12640, 0x2fff }, | ||
353 | { 12644, 0x2fff }, | ||
354 | { 12648, 0x2fff }, | ||
355 | { 12652, 0x2fff }, | ||
356 | { 12656, 0x2fff }, | ||
357 | { 12660, 0x2fff }, | ||
358 | { 12664, 0x2fff }, | ||
359 | { 12668, 0x2fff }, | ||
360 | { 12672, 0x0060 }, | ||
361 | { 12674, 0x0601 }, | ||
362 | { 12676, 0x0061 }, | ||
363 | { 12678, 0x0601 }, | ||
364 | { 12680, 0x0050 }, | ||
365 | { 12682, 0x0300 }, | ||
366 | { 12684, 0x0001 }, | ||
367 | { 12686, 0x0304 }, | ||
368 | { 12688, 0x0040 }, | ||
369 | { 12690, 0x000f }, | ||
370 | { 12692, 0x0001 }, | ||
371 | { 12695, 0x0100 }, | ||
128 | }; | 372 | }; |
129 | 373 | ||
130 | struct fll_config { | 374 | struct fll_config { |
@@ -134,7 +378,7 @@ struct fll_config { | |||
134 | }; | 378 | }; |
135 | 379 | ||
136 | struct wm8995_priv { | 380 | struct wm8995_priv { |
137 | enum snd_soc_control_type control_type; | 381 | struct regmap *regmap; |
138 | int sysclk[2]; | 382 | int sysclk[2]; |
139 | int mclk[2]; | 383 | int mclk[2]; |
140 | int aifclk[2]; | 384 | int aifclk[2]; |
@@ -156,7 +400,7 @@ static int wm8995_regulator_event_##n(struct notifier_block *nb, \ | |||
156 | struct wm8995_priv *wm8995 = container_of(nb, struct wm8995_priv, \ | 400 | struct wm8995_priv *wm8995 = container_of(nb, struct wm8995_priv, \ |
157 | disable_nb[n]); \ | 401 | disable_nb[n]); \ |
158 | if (event & REGULATOR_EVENT_DISABLE) { \ | 402 | if (event & REGULATOR_EVENT_DISABLE) { \ |
159 | wm8995->codec->cache_sync = 1; \ | 403 | regcache_mark_dirty(wm8995->regmap); \ |
160 | } \ | 404 | } \ |
161 | return 0; \ | 405 | return 0; \ |
162 | } | 406 | } |
@@ -688,8 +932,10 @@ static const struct snd_soc_dapm_widget wm8995_dapm_widgets[] = { | |||
688 | SND_SOC_DAPM_MIXER("IN1R PGA", SND_SOC_NOPM, 0, 0, | 932 | SND_SOC_DAPM_MIXER("IN1R PGA", SND_SOC_NOPM, 0, 0, |
689 | &in1r_pga, 1), | 933 | &in1r_pga, 1), |
690 | 934 | ||
691 | SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8995_POWER_MANAGEMENT_1, 8, 0), | 935 | SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8995_POWER_MANAGEMENT_1, 8, 0, |
692 | SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8995_POWER_MANAGEMENT_1, 9, 0), | 936 | NULL, 0), |
937 | SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8995_POWER_MANAGEMENT_1, 9, 0, | ||
938 | NULL, 0), | ||
693 | 939 | ||
694 | SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8995_AIF1_CLOCKING_1, 0, 0, NULL, 0), | 940 | SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8995_AIF1_CLOCKING_1, 0, 0, NULL, 0), |
695 | SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8995_AIF2_CLOCKING_1, 0, 0, NULL, 0), | 941 | SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8995_AIF2_CLOCKING_1, 0, 0, NULL, 0), |
@@ -947,31 +1193,244 @@ static const struct snd_soc_dapm_route wm8995_intercon[] = { | |||
947 | { "SPK2R", NULL, "SPK2R Driver" } | 1193 | { "SPK2R", NULL, "SPK2R Driver" } |
948 | }; | 1194 | }; |
949 | 1195 | ||
950 | static int wm8995_volatile(struct snd_soc_codec *codec, unsigned int reg) | 1196 | static bool wm8995_readable(struct device *dev, unsigned int reg) |
951 | { | 1197 | { |
952 | /* out of bounds registers are generally considered | ||
953 | * volatile to support register banks that are partially | ||
954 | * owned by something else for e.g. a DSP | ||
955 | */ | ||
956 | if (reg > WM8995_MAX_CACHED_REGISTER) | ||
957 | return 1; | ||
958 | |||
959 | switch (reg) { | 1198 | switch (reg) { |
960 | case WM8995_SOFTWARE_RESET: | 1199 | case WM8995_SOFTWARE_RESET: |
1200 | case WM8995_POWER_MANAGEMENT_1: | ||
1201 | case WM8995_POWER_MANAGEMENT_2: | ||
1202 | case WM8995_POWER_MANAGEMENT_3: | ||
1203 | case WM8995_POWER_MANAGEMENT_4: | ||
1204 | case WM8995_POWER_MANAGEMENT_5: | ||
1205 | case WM8995_LEFT_LINE_INPUT_1_VOLUME: | ||
1206 | case WM8995_RIGHT_LINE_INPUT_1_VOLUME: | ||
1207 | case WM8995_LEFT_LINE_INPUT_CONTROL: | ||
1208 | case WM8995_DAC1_LEFT_VOLUME: | ||
1209 | case WM8995_DAC1_RIGHT_VOLUME: | ||
1210 | case WM8995_DAC2_LEFT_VOLUME: | ||
1211 | case WM8995_DAC2_RIGHT_VOLUME: | ||
1212 | case WM8995_OUTPUT_VOLUME_ZC_1: | ||
1213 | case WM8995_MICBIAS_1: | ||
1214 | case WM8995_MICBIAS_2: | ||
1215 | case WM8995_LDO_1: | ||
1216 | case WM8995_LDO_2: | ||
1217 | case WM8995_ACCESSORY_DETECT_MODE1: | ||
1218 | case WM8995_ACCESSORY_DETECT_MODE2: | ||
1219 | case WM8995_HEADPHONE_DETECT1: | ||
1220 | case WM8995_HEADPHONE_DETECT2: | ||
1221 | case WM8995_MIC_DETECT_1: | ||
1222 | case WM8995_MIC_DETECT_2: | ||
1223 | case WM8995_CHARGE_PUMP_1: | ||
1224 | case WM8995_CLASS_W_1: | ||
1225 | case WM8995_DC_SERVO_1: | ||
1226 | case WM8995_DC_SERVO_2: | ||
1227 | case WM8995_DC_SERVO_3: | ||
1228 | case WM8995_DC_SERVO_5: | ||
1229 | case WM8995_DC_SERVO_6: | ||
1230 | case WM8995_DC_SERVO_7: | ||
961 | case WM8995_DC_SERVO_READBACK_0: | 1231 | case WM8995_DC_SERVO_READBACK_0: |
1232 | case WM8995_ANALOGUE_HP_1: | ||
1233 | case WM8995_ANALOGUE_HP_2: | ||
1234 | case WM8995_CHIP_REVISION: | ||
1235 | case WM8995_CONTROL_INTERFACE_1: | ||
1236 | case WM8995_CONTROL_INTERFACE_2: | ||
1237 | case WM8995_WRITE_SEQUENCER_CTRL_1: | ||
1238 | case WM8995_WRITE_SEQUENCER_CTRL_2: | ||
1239 | case WM8995_AIF1_CLOCKING_1: | ||
1240 | case WM8995_AIF1_CLOCKING_2: | ||
1241 | case WM8995_AIF2_CLOCKING_1: | ||
1242 | case WM8995_AIF2_CLOCKING_2: | ||
1243 | case WM8995_CLOCKING_1: | ||
1244 | case WM8995_CLOCKING_2: | ||
1245 | case WM8995_AIF1_RATE: | ||
1246 | case WM8995_AIF2_RATE: | ||
1247 | case WM8995_RATE_STATUS: | ||
1248 | case WM8995_FLL1_CONTROL_1: | ||
1249 | case WM8995_FLL1_CONTROL_2: | ||
1250 | case WM8995_FLL1_CONTROL_3: | ||
1251 | case WM8995_FLL1_CONTROL_4: | ||
1252 | case WM8995_FLL1_CONTROL_5: | ||
1253 | case WM8995_FLL2_CONTROL_1: | ||
1254 | case WM8995_FLL2_CONTROL_2: | ||
1255 | case WM8995_FLL2_CONTROL_3: | ||
1256 | case WM8995_FLL2_CONTROL_4: | ||
1257 | case WM8995_FLL2_CONTROL_5: | ||
1258 | case WM8995_AIF1_CONTROL_1: | ||
1259 | case WM8995_AIF1_CONTROL_2: | ||
1260 | case WM8995_AIF1_MASTER_SLAVE: | ||
1261 | case WM8995_AIF1_BCLK: | ||
1262 | case WM8995_AIF1ADC_LRCLK: | ||
1263 | case WM8995_AIF1DAC_LRCLK: | ||
1264 | case WM8995_AIF1DAC_DATA: | ||
1265 | case WM8995_AIF1ADC_DATA: | ||
1266 | case WM8995_AIF2_CONTROL_1: | ||
1267 | case WM8995_AIF2_CONTROL_2: | ||
1268 | case WM8995_AIF2_MASTER_SLAVE: | ||
1269 | case WM8995_AIF2_BCLK: | ||
1270 | case WM8995_AIF2ADC_LRCLK: | ||
1271 | case WM8995_AIF2DAC_LRCLK: | ||
1272 | case WM8995_AIF2DAC_DATA: | ||
1273 | case WM8995_AIF2ADC_DATA: | ||
1274 | case WM8995_AIF1_ADC1_LEFT_VOLUME: | ||
1275 | case WM8995_AIF1_ADC1_RIGHT_VOLUME: | ||
1276 | case WM8995_AIF1_DAC1_LEFT_VOLUME: | ||
1277 | case WM8995_AIF1_DAC1_RIGHT_VOLUME: | ||
1278 | case WM8995_AIF1_ADC2_LEFT_VOLUME: | ||
1279 | case WM8995_AIF1_ADC2_RIGHT_VOLUME: | ||
1280 | case WM8995_AIF1_DAC2_LEFT_VOLUME: | ||
1281 | case WM8995_AIF1_DAC2_RIGHT_VOLUME: | ||
1282 | case WM8995_AIF1_ADC1_FILTERS: | ||
1283 | case WM8995_AIF1_ADC2_FILTERS: | ||
1284 | case WM8995_AIF1_DAC1_FILTERS_1: | ||
1285 | case WM8995_AIF1_DAC1_FILTERS_2: | ||
1286 | case WM8995_AIF1_DAC2_FILTERS_1: | ||
1287 | case WM8995_AIF1_DAC2_FILTERS_2: | ||
1288 | case WM8995_AIF1_DRC1_1: | ||
1289 | case WM8995_AIF1_DRC1_2: | ||
1290 | case WM8995_AIF1_DRC1_3: | ||
1291 | case WM8995_AIF1_DRC1_4: | ||
1292 | case WM8995_AIF1_DRC1_5: | ||
1293 | case WM8995_AIF1_DRC2_1: | ||
1294 | case WM8995_AIF1_DRC2_2: | ||
1295 | case WM8995_AIF1_DRC2_3: | ||
1296 | case WM8995_AIF1_DRC2_4: | ||
1297 | case WM8995_AIF1_DRC2_5: | ||
1298 | case WM8995_AIF1_DAC1_EQ_GAINS_1: | ||
1299 | case WM8995_AIF1_DAC1_EQ_GAINS_2: | ||
1300 | case WM8995_AIF1_DAC1_EQ_BAND_1_A: | ||
1301 | case WM8995_AIF1_DAC1_EQ_BAND_1_B: | ||
1302 | case WM8995_AIF1_DAC1_EQ_BAND_1_PG: | ||
1303 | case WM8995_AIF1_DAC1_EQ_BAND_2_A: | ||
1304 | case WM8995_AIF1_DAC1_EQ_BAND_2_B: | ||
1305 | case WM8995_AIF1_DAC1_EQ_BAND_2_C: | ||
1306 | case WM8995_AIF1_DAC1_EQ_BAND_2_PG: | ||
1307 | case WM8995_AIF1_DAC1_EQ_BAND_3_A: | ||
1308 | case WM8995_AIF1_DAC1_EQ_BAND_3_B: | ||
1309 | case WM8995_AIF1_DAC1_EQ_BAND_3_C: | ||
1310 | case WM8995_AIF1_DAC1_EQ_BAND_3_PG: | ||
1311 | case WM8995_AIF1_DAC1_EQ_BAND_4_A: | ||
1312 | case WM8995_AIF1_DAC1_EQ_BAND_4_B: | ||
1313 | case WM8995_AIF1_DAC1_EQ_BAND_4_C: | ||
1314 | case WM8995_AIF1_DAC1_EQ_BAND_4_PG: | ||
1315 | case WM8995_AIF1_DAC1_EQ_BAND_5_A: | ||
1316 | case WM8995_AIF1_DAC1_EQ_BAND_5_B: | ||
1317 | case WM8995_AIF1_DAC1_EQ_BAND_5_PG: | ||
1318 | case WM8995_AIF1_DAC2_EQ_GAINS_1: | ||
1319 | case WM8995_AIF1_DAC2_EQ_GAINS_2: | ||
1320 | case WM8995_AIF1_DAC2_EQ_BAND_1_A: | ||
1321 | case WM8995_AIF1_DAC2_EQ_BAND_1_B: | ||
1322 | case WM8995_AIF1_DAC2_EQ_BAND_1_PG: | ||
1323 | case WM8995_AIF1_DAC2_EQ_BAND_2_A: | ||
1324 | case WM8995_AIF1_DAC2_EQ_BAND_2_B: | ||
1325 | case WM8995_AIF1_DAC2_EQ_BAND_2_C: | ||
1326 | case WM8995_AIF1_DAC2_EQ_BAND_2_PG: | ||
1327 | case WM8995_AIF1_DAC2_EQ_BAND_3_A: | ||
1328 | case WM8995_AIF1_DAC2_EQ_BAND_3_B: | ||
1329 | case WM8995_AIF1_DAC2_EQ_BAND_3_C: | ||
1330 | case WM8995_AIF1_DAC2_EQ_BAND_3_PG: | ||
1331 | case WM8995_AIF1_DAC2_EQ_BAND_4_A: | ||
1332 | case WM8995_AIF1_DAC2_EQ_BAND_4_B: | ||
1333 | case WM8995_AIF1_DAC2_EQ_BAND_4_C: | ||
1334 | case WM8995_AIF1_DAC2_EQ_BAND_4_PG: | ||
1335 | case WM8995_AIF1_DAC2_EQ_BAND_5_A: | ||
1336 | case WM8995_AIF1_DAC2_EQ_BAND_5_B: | ||
1337 | case WM8995_AIF1_DAC2_EQ_BAND_5_PG: | ||
1338 | case WM8995_AIF2_ADC_LEFT_VOLUME: | ||
1339 | case WM8995_AIF2_ADC_RIGHT_VOLUME: | ||
1340 | case WM8995_AIF2_DAC_LEFT_VOLUME: | ||
1341 | case WM8995_AIF2_DAC_RIGHT_VOLUME: | ||
1342 | case WM8995_AIF2_ADC_FILTERS: | ||
1343 | case WM8995_AIF2_DAC_FILTERS_1: | ||
1344 | case WM8995_AIF2_DAC_FILTERS_2: | ||
1345 | case WM8995_AIF2_DRC_1: | ||
1346 | case WM8995_AIF2_DRC_2: | ||
1347 | case WM8995_AIF2_DRC_3: | ||
1348 | case WM8995_AIF2_DRC_4: | ||
1349 | case WM8995_AIF2_DRC_5: | ||
1350 | case WM8995_AIF2_EQ_GAINS_1: | ||
1351 | case WM8995_AIF2_EQ_GAINS_2: | ||
1352 | case WM8995_AIF2_EQ_BAND_1_A: | ||
1353 | case WM8995_AIF2_EQ_BAND_1_B: | ||
1354 | case WM8995_AIF2_EQ_BAND_1_PG: | ||
1355 | case WM8995_AIF2_EQ_BAND_2_A: | ||
1356 | case WM8995_AIF2_EQ_BAND_2_B: | ||
1357 | case WM8995_AIF2_EQ_BAND_2_C: | ||
1358 | case WM8995_AIF2_EQ_BAND_2_PG: | ||
1359 | case WM8995_AIF2_EQ_BAND_3_A: | ||
1360 | case WM8995_AIF2_EQ_BAND_3_B: | ||
1361 | case WM8995_AIF2_EQ_BAND_3_C: | ||
1362 | case WM8995_AIF2_EQ_BAND_3_PG: | ||
1363 | case WM8995_AIF2_EQ_BAND_4_A: | ||
1364 | case WM8995_AIF2_EQ_BAND_4_B: | ||
1365 | case WM8995_AIF2_EQ_BAND_4_C: | ||
1366 | case WM8995_AIF2_EQ_BAND_4_PG: | ||
1367 | case WM8995_AIF2_EQ_BAND_5_A: | ||
1368 | case WM8995_AIF2_EQ_BAND_5_B: | ||
1369 | case WM8995_AIF2_EQ_BAND_5_PG: | ||
1370 | case WM8995_DAC1_MIXER_VOLUMES: | ||
1371 | case WM8995_DAC1_LEFT_MIXER_ROUTING: | ||
1372 | case WM8995_DAC1_RIGHT_MIXER_ROUTING: | ||
1373 | case WM8995_DAC2_MIXER_VOLUMES: | ||
1374 | case WM8995_DAC2_LEFT_MIXER_ROUTING: | ||
1375 | case WM8995_DAC2_RIGHT_MIXER_ROUTING: | ||
1376 | case WM8995_AIF1_ADC1_LEFT_MIXER_ROUTING: | ||
1377 | case WM8995_AIF1_ADC1_RIGHT_MIXER_ROUTING: | ||
1378 | case WM8995_AIF1_ADC2_LEFT_MIXER_ROUTING: | ||
1379 | case WM8995_AIF1_ADC2_RIGHT_MIXER_ROUTING: | ||
1380 | case WM8995_DAC_SOFTMUTE: | ||
1381 | case WM8995_OVERSAMPLING: | ||
1382 | case WM8995_SIDETONE: | ||
1383 | case WM8995_GPIO_1: | ||
1384 | case WM8995_GPIO_2: | ||
1385 | case WM8995_GPIO_3: | ||
1386 | case WM8995_GPIO_4: | ||
1387 | case WM8995_GPIO_5: | ||
1388 | case WM8995_GPIO_6: | ||
1389 | case WM8995_GPIO_7: | ||
1390 | case WM8995_GPIO_8: | ||
1391 | case WM8995_GPIO_9: | ||
1392 | case WM8995_GPIO_10: | ||
1393 | case WM8995_GPIO_11: | ||
1394 | case WM8995_GPIO_12: | ||
1395 | case WM8995_GPIO_13: | ||
1396 | case WM8995_GPIO_14: | ||
1397 | case WM8995_PULL_CONTROL_1: | ||
1398 | case WM8995_PULL_CONTROL_2: | ||
962 | case WM8995_INTERRUPT_STATUS_1: | 1399 | case WM8995_INTERRUPT_STATUS_1: |
963 | case WM8995_INTERRUPT_STATUS_2: | 1400 | case WM8995_INTERRUPT_STATUS_2: |
1401 | case WM8995_INTERRUPT_RAW_STATUS_2: | ||
964 | case WM8995_INTERRUPT_STATUS_1_MASK: | 1402 | case WM8995_INTERRUPT_STATUS_1_MASK: |
965 | case WM8995_INTERRUPT_STATUS_2_MASK: | 1403 | case WM8995_INTERRUPT_STATUS_2_MASK: |
966 | case WM8995_INTERRUPT_CONTROL: | 1404 | case WM8995_INTERRUPT_CONTROL: |
1405 | case WM8995_LEFT_PDM_SPEAKER_1: | ||
1406 | case WM8995_RIGHT_PDM_SPEAKER_1: | ||
1407 | case WM8995_PDM_SPEAKER_1_MUTE_SEQUENCE: | ||
1408 | case WM8995_LEFT_PDM_SPEAKER_2: | ||
1409 | case WM8995_RIGHT_PDM_SPEAKER_2: | ||
1410 | case WM8995_PDM_SPEAKER_2_MUTE_SEQUENCE: | ||
1411 | return true; | ||
1412 | default: | ||
1413 | return false; | ||
1414 | } | ||
1415 | } | ||
1416 | |||
1417 | static bool wm8995_volatile(struct device *dev, unsigned int reg) | ||
1418 | { | ||
1419 | switch (reg) { | ||
1420 | case WM8995_SOFTWARE_RESET: | ||
1421 | case WM8995_DC_SERVO_READBACK_0: | ||
1422 | case WM8995_INTERRUPT_STATUS_1: | ||
1423 | case WM8995_INTERRUPT_STATUS_2: | ||
1424 | case WM8995_INTERRUPT_CONTROL: | ||
967 | case WM8995_ACCESSORY_DETECT_MODE1: | 1425 | case WM8995_ACCESSORY_DETECT_MODE1: |
968 | case WM8995_ACCESSORY_DETECT_MODE2: | 1426 | case WM8995_ACCESSORY_DETECT_MODE2: |
969 | case WM8995_HEADPHONE_DETECT1: | 1427 | case WM8995_HEADPHONE_DETECT1: |
970 | case WM8995_HEADPHONE_DETECT2: | 1428 | case WM8995_HEADPHONE_DETECT2: |
971 | return 1; | 1429 | case WM8995_RATE_STATUS: |
1430 | return true; | ||
1431 | default: | ||
1432 | return false; | ||
972 | } | 1433 | } |
973 | |||
974 | return 0; | ||
975 | } | 1434 | } |
976 | 1435 | ||
977 | static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) | 1436 | static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) |
@@ -1526,7 +1985,7 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec, | |||
1526 | if (ret) | 1985 | if (ret) |
1527 | return ret; | 1986 | return ret; |
1528 | 1987 | ||
1529 | ret = snd_soc_cache_sync(codec); | 1988 | ret = regcache_sync(wm8995->regmap); |
1530 | if (ret) { | 1989 | if (ret) { |
1531 | dev_err(codec->dev, | 1990 | dev_err(codec->dev, |
1532 | "Failed to sync cache: %d\n", ret); | 1991 | "Failed to sync cache: %d\n", ret); |
@@ -1550,7 +2009,7 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec, | |||
1550 | } | 2009 | } |
1551 | 2010 | ||
1552 | #ifdef CONFIG_PM | 2011 | #ifdef CONFIG_PM |
1553 | static int wm8995_suspend(struct snd_soc_codec *codec, pm_message_t state) | 2012 | static int wm8995_suspend(struct snd_soc_codec *codec) |
1554 | { | 2013 | { |
1555 | wm8995_set_bias_level(codec, SND_SOC_BIAS_OFF); | 2014 | wm8995_set_bias_level(codec, SND_SOC_BIAS_OFF); |
1556 | return 0; | 2015 | return 0; |
@@ -1592,7 +2051,8 @@ static int wm8995_probe(struct snd_soc_codec *codec) | |||
1592 | wm8995 = snd_soc_codec_get_drvdata(codec); | 2051 | wm8995 = snd_soc_codec_get_drvdata(codec); |
1593 | wm8995->codec = codec; | 2052 | wm8995->codec = codec; |
1594 | 2053 | ||
1595 | ret = snd_soc_codec_set_cache_io(codec, 16, 16, wm8995->control_type); | 2054 | codec->control_data = wm8995->regmap; |
2055 | ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); | ||
1596 | if (ret < 0) { | 2056 | if (ret < 0) { |
1597 | dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); | 2057 | dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); |
1598 | return ret; | 2058 | return ret; |
@@ -1696,7 +2156,7 @@ err_reg_get: | |||
1696 | #define WM8995_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | 2156 | #define WM8995_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
1697 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | 2157 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) |
1698 | 2158 | ||
1699 | static struct snd_soc_dai_ops wm8995_aif1_dai_ops = { | 2159 | static const struct snd_soc_dai_ops wm8995_aif1_dai_ops = { |
1700 | .set_sysclk = wm8995_set_dai_sysclk, | 2160 | .set_sysclk = wm8995_set_dai_sysclk, |
1701 | .set_fmt = wm8995_set_dai_fmt, | 2161 | .set_fmt = wm8995_set_dai_fmt, |
1702 | .hw_params = wm8995_hw_params, | 2162 | .hw_params = wm8995_hw_params, |
@@ -1705,7 +2165,7 @@ static struct snd_soc_dai_ops wm8995_aif1_dai_ops = { | |||
1705 | .set_tristate = wm8995_set_tristate, | 2165 | .set_tristate = wm8995_set_tristate, |
1706 | }; | 2166 | }; |
1707 | 2167 | ||
1708 | static struct snd_soc_dai_ops wm8995_aif2_dai_ops = { | 2168 | static const struct snd_soc_dai_ops wm8995_aif2_dai_ops = { |
1709 | .set_sysclk = wm8995_set_dai_sysclk, | 2169 | .set_sysclk = wm8995_set_dai_sysclk, |
1710 | .set_fmt = wm8995_set_dai_fmt, | 2170 | .set_fmt = wm8995_set_dai_fmt, |
1711 | .hw_params = wm8995_hw_params, | 2171 | .hw_params = wm8995_hw_params, |
@@ -1714,7 +2174,7 @@ static struct snd_soc_dai_ops wm8995_aif2_dai_ops = { | |||
1714 | .set_tristate = wm8995_set_tristate, | 2174 | .set_tristate = wm8995_set_tristate, |
1715 | }; | 2175 | }; |
1716 | 2176 | ||
1717 | static struct snd_soc_dai_ops wm8995_aif3_dai_ops = { | 2177 | static const struct snd_soc_dai_ops wm8995_aif3_dai_ops = { |
1718 | .set_tristate = wm8995_set_tristate, | 2178 | .set_tristate = wm8995_set_tristate, |
1719 | }; | 2179 | }; |
1720 | 2180 | ||
@@ -1781,11 +2241,18 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8995 = { | |||
1781 | .suspend = wm8995_suspend, | 2241 | .suspend = wm8995_suspend, |
1782 | .resume = wm8995_resume, | 2242 | .resume = wm8995_resume, |
1783 | .set_bias_level = wm8995_set_bias_level, | 2243 | .set_bias_level = wm8995_set_bias_level, |
1784 | .reg_cache_size = ARRAY_SIZE(wm8995_reg_defs), | 2244 | }; |
1785 | .reg_word_size = sizeof(u16), | 2245 | |
1786 | .reg_cache_default = wm8995_reg_defs, | 2246 | static struct regmap_config wm8995_regmap = { |
1787 | .volatile_register = wm8995_volatile, | 2247 | .reg_bits = 16, |
1788 | .compress_type = SND_SOC_RBTREE_COMPRESSION | 2248 | .val_bits = 16, |
2249 | |||
2250 | .max_register = WM8995_MAX_REGISTER, | ||
2251 | .reg_defaults = wm8995_reg_defaults, | ||
2252 | .num_reg_defaults = ARRAY_SIZE(wm8995_reg_defaults), | ||
2253 | .volatile_reg = wm8995_volatile, | ||
2254 | .readable_reg = wm8995_readable, | ||
2255 | .cache_type = REGCACHE_RBTREE, | ||
1789 | }; | 2256 | }; |
1790 | 2257 | ||
1791 | #if defined(CONFIG_SPI_MASTER) | 2258 | #if defined(CONFIG_SPI_MASTER) |
@@ -1798,21 +2265,37 @@ static int __devinit wm8995_spi_probe(struct spi_device *spi) | |||
1798 | if (!wm8995) | 2265 | if (!wm8995) |
1799 | return -ENOMEM; | 2266 | return -ENOMEM; |
1800 | 2267 | ||
1801 | wm8995->control_type = SND_SOC_SPI; | ||
1802 | spi_set_drvdata(spi, wm8995); | 2268 | spi_set_drvdata(spi, wm8995); |
1803 | 2269 | ||
2270 | wm8995->regmap = regmap_init_spi(spi, &wm8995_regmap); | ||
2271 | if (IS_ERR(wm8995->regmap)) { | ||
2272 | ret = PTR_ERR(wm8995->regmap); | ||
2273 | dev_err(&spi->dev, "Failed to register regmap: %d\n", ret); | ||
2274 | goto err_alloc; | ||
2275 | } | ||
2276 | |||
1804 | ret = snd_soc_register_codec(&spi->dev, | 2277 | ret = snd_soc_register_codec(&spi->dev, |
1805 | &soc_codec_dev_wm8995, wm8995_dai, | 2278 | &soc_codec_dev_wm8995, wm8995_dai, |
1806 | ARRAY_SIZE(wm8995_dai)); | 2279 | ARRAY_SIZE(wm8995_dai)); |
1807 | if (ret < 0) | 2280 | if (ret < 0) |
1808 | kfree(wm8995); | 2281 | goto err_regmap; |
2282 | |||
2283 | return ret; | ||
2284 | |||
2285 | err_regmap: | ||
2286 | regmap_exit(wm8995->regmap); | ||
2287 | err_alloc: | ||
2288 | kfree(wm8995); | ||
2289 | |||
1809 | return ret; | 2290 | return ret; |
1810 | } | 2291 | } |
1811 | 2292 | ||
1812 | static int __devexit wm8995_spi_remove(struct spi_device *spi) | 2293 | static int __devexit wm8995_spi_remove(struct spi_device *spi) |
1813 | { | 2294 | { |
2295 | struct wm8995_priv *wm8995 = spi_get_drvdata(spi); | ||
1814 | snd_soc_unregister_codec(&spi->dev); | 2296 | snd_soc_unregister_codec(&spi->dev); |
1815 | kfree(spi_get_drvdata(spi)); | 2297 | regmap_exit(wm8995->regmap); |
2298 | kfree(wm8995); | ||
1816 | return 0; | 2299 | return 0; |
1817 | } | 2300 | } |
1818 | 2301 | ||
@@ -1837,21 +2320,40 @@ static __devinit int wm8995_i2c_probe(struct i2c_client *i2c, | |||
1837 | if (!wm8995) | 2320 | if (!wm8995) |
1838 | return -ENOMEM; | 2321 | return -ENOMEM; |
1839 | 2322 | ||
1840 | wm8995->control_type = SND_SOC_I2C; | ||
1841 | i2c_set_clientdata(i2c, wm8995); | 2323 | i2c_set_clientdata(i2c, wm8995); |
1842 | 2324 | ||
2325 | wm8995->regmap = regmap_init_i2c(i2c, &wm8995_regmap); | ||
2326 | if (IS_ERR(wm8995->regmap)) { | ||
2327 | ret = PTR_ERR(wm8995->regmap); | ||
2328 | dev_err(&i2c->dev, "Failed to register regmap: %d\n", ret); | ||
2329 | goto err_alloc; | ||
2330 | } | ||
2331 | |||
1843 | ret = snd_soc_register_codec(&i2c->dev, | 2332 | ret = snd_soc_register_codec(&i2c->dev, |
1844 | &soc_codec_dev_wm8995, wm8995_dai, | 2333 | &soc_codec_dev_wm8995, wm8995_dai, |
1845 | ARRAY_SIZE(wm8995_dai)); | 2334 | ARRAY_SIZE(wm8995_dai)); |
1846 | if (ret < 0) | 2335 | if (ret < 0) { |
1847 | kfree(wm8995); | 2336 | dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); |
2337 | goto err_regmap; | ||
2338 | } | ||
2339 | |||
2340 | return ret; | ||
2341 | |||
2342 | err_regmap: | ||
2343 | regmap_exit(wm8995->regmap); | ||
2344 | err_alloc: | ||
2345 | kfree(wm8995); | ||
2346 | |||
1848 | return ret; | 2347 | return ret; |
1849 | } | 2348 | } |
1850 | 2349 | ||
1851 | static __devexit int wm8995_i2c_remove(struct i2c_client *client) | 2350 | static __devexit int wm8995_i2c_remove(struct i2c_client *client) |
1852 | { | 2351 | { |
2352 | struct wm8995_priv *wm8995 = i2c_get_clientdata(client); | ||
2353 | |||
1853 | snd_soc_unregister_codec(&client->dev); | 2354 | snd_soc_unregister_codec(&client->dev); |
1854 | kfree(i2c_get_clientdata(client)); | 2355 | regmap_exit(wm8995->regmap); |
2356 | kfree(wm8995); | ||
1855 | return 0; | 2357 | return 0; |
1856 | } | 2358 | } |
1857 | 2359 | ||