blob: fc758b1a4ffa98e4e9f67148ea98660cdca4a62d [file] [log] [blame]
Mark Brownd0f0b432011-08-19 22:40:07 +09001/* Speyside modules for Cragganmore - board data probing
2 *
3 * Copyright 2011 Wolfson Microelectronics plc
4 * Mark Brown <broonie@opensource.wolfsonmicro.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
Kukjin Kima69e4c22011-11-17 01:14:38 +090011#include <linux/export.h>
Mark Brownd0f0b432011-08-19 22:40:07 +090012#include <linux/interrupt.h>
13#include <linux/i2c.h>
Mark Browncda23492012-01-12 11:04:56 +090014#include <linux/spi/spi.h>
Mark Brownd0f0b432011-08-19 22:40:07 +090015
16#include <linux/mfd/wm831x/irq.h>
17#include <linux/mfd/wm831x/gpio.h>
Mark Brownc5c32c92011-12-02 14:32:32 +090018#include <linux/mfd/wm8994/pdata.h>
Mark Brown853b1eb2012-08-10 13:03:16 +090019#include <linux/mfd/arizona/pdata.h>
Mark Brownd0f0b432011-08-19 22:40:07 +090020
Mark Brown719a4242012-03-16 19:36:29 +010021#include <linux/regulator/machine.h>
22
Mark Brownc8968ad2012-10-17 17:41:08 +090023#include <sound/wm0010.h>
Mark Brown3d19f1c2011-12-02 14:29:08 +090024#include <sound/wm5100.h>
Mark Brownd0f0b432011-08-19 22:40:07 +090025#include <sound/wm8996.h>
26#include <sound/wm8962.h>
27#include <sound/wm9081.h>
28
Arnd Bergmann436d42c2012-08-24 15:22:12 +020029#include <linux/platform_data/spi-s3c64xx.h>
Mark Browncda23492012-01-12 11:04:56 +090030
Mark Brownd0f0b432011-08-19 22:40:07 +090031#include <mach/crag6410.h>
32
Mark Browncda23492012-01-12 11:04:56 +090033static struct s3c64xx_spi_csinfo wm0010_spi_csinfo = {
Mark Browncda23492012-01-12 11:04:56 +090034 .line = S3C64XX_GPC(3),
35};
36
Mark Brownc8968ad2012-10-17 17:41:08 +090037static struct wm0010_pdata wm0010_pdata = {
38 .gpio_reset = S3C64XX_GPN(6),
39 .reset_active_high = 1, /* Active high for Glenfarclas Rev 2 */
40};
41
Mark Browncda23492012-01-12 11:04:56 +090042static struct spi_board_info wm1253_devs[] = {
43 [0] = {
44 .modalias = "wm0010",
Mark Brownc8968ad2012-10-17 17:41:08 +090045 .max_speed_hz = 26 * 1000 * 1000,
Mark Browncda23492012-01-12 11:04:56 +090046 .bus_num = 0,
47 .chip_select = 0,
48 .mode = SPI_MODE_0,
Dimitris Papastamos15211092012-06-21 03:43:57 +090049 .irq = S3C_EINT(5),
Mark Browncda23492012-01-12 11:04:56 +090050 .controller_data = &wm0010_spi_csinfo,
Mark Brownc8968ad2012-10-17 17:41:08 +090051 .platform_data = &wm0010_pdata,
52 },
53};
54
55static struct spi_board_info balblair_devs[] = {
56 [0] = {
57 .modalias = "wm0010",
58 .max_speed_hz = 26 * 1000 * 1000,
59 .bus_num = 0,
60 .chip_select = 0,
61 .mode = SPI_MODE_0,
62 .irq = S3C_EINT(5),
63 .controller_data = &wm0010_spi_csinfo,
64 .platform_data = &wm0010_pdata,
Mark Browncda23492012-01-12 11:04:56 +090065 },
66};
67
Mark Brown3d19f1c2011-12-02 14:29:08 +090068static struct wm5100_pdata wm5100_pdata = {
69 .ldo_ena = S3C64XX_GPN(7),
70 .irq_flags = IRQF_TRIGGER_HIGH,
71 .gpio_base = CODEC_GPIO_BASE,
72
73 .in_mode = {
74 WM5100_IN_DIFF,
75 WM5100_IN_DIFF,
76 WM5100_IN_DIFF,
77 WM5100_IN_SE,
78 },
79
80 .hp_pol = CODEC_GPIO_BASE + 3,
81 .jack_modes = {
82 { WM5100_MICDET_MICBIAS3, 0, 0 },
83 { WM5100_MICDET_MICBIAS2, 1, 1 },
84 },
85
86 .gpio_defaults = {
87 0,
88 0,
89 0,
90 0,
91 0x2, /* IRQ: CMOS output */
92 0x3, /* CLKOUT: CMOS output */
93 },
94};
95
Mark Brownd0f0b432011-08-19 22:40:07 +090096static struct wm8996_retune_mobile_config wm8996_retune[] = {
97 {
98 .name = "Sub LPF",
99 .rate = 48000,
100 .regs = {
101 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
102 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
103 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
104 },
105 },
106 {
107 .name = "Sub HPF",
108 .rate = 48000,
109 .regs = {
110 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
111 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
112 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
113 },
114 },
115};
116
117static struct wm8996_pdata wm8996_pdata __initdata = {
118 .ldo_ena = S3C64XX_GPN(7),
119 .gpio_base = CODEC_GPIO_BASE,
120 .micdet_def = 1,
121 .inl_mode = WM8996_DIFFERRENTIAL_1,
122 .inr_mode = WM8996_DIFFERRENTIAL_1,
123
124 .irq_flags = IRQF_TRIGGER_RISING,
125
126 .gpio_default = {
127 0x8001, /* GPIO1 == ADCLRCLK1 */
128 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */
129 0x0141, /* GPIO3 == HP_SEL */
130 0x0002, /* GPIO4 == IRQ */
131 0x020e, /* GPIO5 == CLKOUT */
132 },
133
134 .retune_mobile_cfgs = wm8996_retune,
135 .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune),
136};
137
138static struct wm8962_pdata wm8962_pdata __initdata = {
139 .gpio_init = {
140 0,
141 WM8962_GPIO_FN_OPCLK,
142 WM8962_GPIO_FN_DMICCLK,
143 0,
144 0x8000 | WM8962_GPIO_FN_DMICDAT,
145 WM8962_GPIO_FN_IRQ, /* Open drain mode */
146 },
Mark Brown4b9c85f2012-01-24 21:09:15 +0000147 .in4_dc_measure = true,
Mark Brownd0f0b432011-08-19 22:40:07 +0900148};
149
150static struct wm9081_pdata wm9081_pdata __initdata = {
151 .irq_high = false,
152 .irq_cmos = false,
153};
154
155static const struct i2c_board_info wm1254_devs[] = {
156 { I2C_BOARD_INFO("wm8996", 0x1a),
157 .platform_data = &wm8996_pdata,
158 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
159 },
160 { I2C_BOARD_INFO("wm9081", 0x6c),
161 .platform_data = &wm9081_pdata, },
162};
163
Mark Brown3aa77792011-09-05 14:48:39 +0900164static const struct i2c_board_info wm1255_devs[] = {
165 { I2C_BOARD_INFO("wm5100", 0x1a),
Mark Brown3d19f1c2011-12-02 14:29:08 +0900166 .platform_data = &wm5100_pdata,
Mark Brown3aa77792011-09-05 14:48:39 +0900167 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
168 },
169 { I2C_BOARD_INFO("wm9081", 0x6c),
170 .platform_data = &wm9081_pdata, },
171};
172
Mark Brownd0f0b432011-08-19 22:40:07 +0900173static const struct i2c_board_info wm1259_devs[] = {
174 { I2C_BOARD_INFO("wm8962", 0x1a),
175 .platform_data = &wm8962_pdata,
176 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
177 },
178};
179
Mark Brownbd155d22012-03-08 11:55:07 +0000180static struct regulator_init_data wm8994_ldo1 = {
181 .supply_regulator = "WALLVDD",
182};
183
184static struct regulator_init_data wm8994_ldo2 = {
185 .supply_regulator = "WALLVDD",
186};
187
Mark Brownc5c32c92011-12-02 14:32:32 +0900188static struct wm8994_pdata wm8994_pdata = {
189 .gpio_base = CODEC_GPIO_BASE,
Mark Brownb23bc662012-10-17 17:41:08 +0900190 .micb2_delay = 150,
Mark Brownc5c32c92011-12-02 14:32:32 +0900191 .gpio_defaults = {
192 0x3, /* IRQ out, active high, CMOS */
193 },
Mark Brownc5c32c92011-12-02 14:32:32 +0900194 .ldo = {
Mark Brownb23bc662012-10-17 17:41:08 +0900195 { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, },
196 { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, },
Mark Brownc5c32c92011-12-02 14:32:32 +0900197 },
198};
199
200static const struct i2c_board_info wm1277_devs[] = {
201 { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */
202 .platform_data = &wm8994_pdata,
203 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
204 },
205};
Mark Brownd0f0b432011-08-19 22:40:07 +0900206
Mark Brownb23bc662012-10-17 17:41:08 +0900207static struct arizona_pdata wm5102_reva_pdata = {
Mark Brown853b1eb2012-08-10 13:03:16 +0900208 .ldoena = S3C64XX_GPN(7),
209 .gpio_base = CODEC_GPIO_BASE,
210 .irq_active_high = true,
211 .micd_pol_gpio = CODEC_GPIO_BASE + 4,
212 .gpio_defaults = {
213 [2] = 0x10000, /* AIF3TXLRCLK */
214 [3] = 0x4, /* OPCLK */
215 },
216};
217
Mark Brown41830ee2012-10-17 17:41:09 +0900218static struct s3c64xx_spi_csinfo codec_spi_csinfo = {
Mark Brown853b1eb2012-08-10 13:03:16 +0900219 .line = S3C64XX_GPN(5),
220};
221
Mark Brownb23bc662012-10-17 17:41:08 +0900222static struct spi_board_info wm5102_reva_spi_devs[] = {
223 [0] = {
224 .modalias = "wm5102",
225 .max_speed_hz = 10 * 1000 * 1000,
226 .bus_num = 0,
227 .chip_select = 1,
228 .mode = SPI_MODE_0,
229 .irq = GLENFARCLAS_PMIC_IRQ_BASE +
230 WM831X_IRQ_GPIO_2,
Mark Brown41830ee2012-10-17 17:41:09 +0900231 .controller_data = &codec_spi_csinfo,
Mark Brownb23bc662012-10-17 17:41:08 +0900232 .platform_data = &wm5102_reva_pdata,
233 },
234};
235
236static struct arizona_pdata wm5102_pdata = {
237 .ldoena = S3C64XX_GPN(7),
238 .gpio_base = CODEC_GPIO_BASE,
239 .irq_active_high = true,
240 .micd_pol_gpio = CODEC_GPIO_BASE + 2,
241 .gpio_defaults = {
242 [2] = 0x10000, /* AIF3TXLRCLK */
243 [3] = 0x4, /* OPCLK */
244 },
245};
246
Mark Brown853b1eb2012-08-10 13:03:16 +0900247static struct spi_board_info wm5102_spi_devs[] = {
248 [0] = {
249 .modalias = "wm5102",
250 .max_speed_hz = 10 * 1000 * 1000,
251 .bus_num = 0,
Mark Brown479535e2012-10-17 17:41:07 +0900252 .chip_select = 1,
Mark Brown853b1eb2012-08-10 13:03:16 +0900253 .mode = SPI_MODE_0,
254 .irq = GLENFARCLAS_PMIC_IRQ_BASE +
255 WM831X_IRQ_GPIO_2,
Mark Brown41830ee2012-10-17 17:41:09 +0900256 .controller_data = &codec_spi_csinfo,
Mark Brown853b1eb2012-08-10 13:03:16 +0900257 .platform_data = &wm5102_pdata,
258 },
Mark Brown9b6e1b02012-06-20 08:16:25 +0900259};
260
Mark Brown41830ee2012-10-17 17:41:09 +0900261static struct spi_board_info wm5110_spi_devs[] = {
262 [0] = {
263 .modalias = "wm5110",
264 .max_speed_hz = 10 * 1000 * 1000,
265 .bus_num = 0,
266 .chip_select = 1,
267 .mode = SPI_MODE_0,
268 .irq = GLENFARCLAS_PMIC_IRQ_BASE +
269 WM831X_IRQ_GPIO_2,
270 .controller_data = &codec_spi_csinfo,
271 .platform_data = &wm5102_reva_pdata,
272 },
273};
274
Mark Brown98dcf902012-05-16 07:00:03 +0900275static const struct i2c_board_info wm6230_i2c_devs[] = {
276 { I2C_BOARD_INFO("wm9081", 0x6c),
277 .platform_data = &wm9081_pdata, },
278};
279
Mark Brownd0f0b432011-08-19 22:40:07 +0900280static __devinitdata const struct {
281 u8 id;
Mark Brown64aecb42012-10-17 17:41:08 +0900282 u8 rev;
Mark Brownd0f0b432011-08-19 22:40:07 +0900283 const char *name;
284 const struct i2c_board_info *i2c_devs;
285 int num_i2c_devs;
Mark Browncda23492012-01-12 11:04:56 +0900286 const struct spi_board_info *spi_devs;
287 int num_spi_devs;
Mark Brownd0f0b432011-08-19 22:40:07 +0900288} gf_mods[] = {
Mark Brown64aecb42012-10-17 17:41:08 +0900289 { .id = 0x01, .rev = 0xff, .name = "1250-EV1 Springbank" },
290 { .id = 0x02, .rev = 0xff, .name = "1251-EV1 Jura" },
291 { .id = 0x03, .rev = 0xff, .name = "1252-EV1 Glenlivet" },
292 { .id = 0x06, .rev = 0xff, .name = "WM8997-6721-CS96-EV1 Lapraoig" },
Mark Brown41830ee2012-10-17 17:41:09 +0900293 { .id = 0x07, .rev = 0xff, .name = "WM5110-6271 Deanston",
294 .spi_devs = wm5110_spi_devs,
295 .num_spi_devs = ARRAY_SIZE(wm5110_spi_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900296 { .id = 0x08, .rev = 0xff, .name = "WM8903-6102 Tamdhu" },
297 { .id = 0x09, .rev = 0xff, .name = "WM1811A-6305 Adelphi" },
298 { .id = 0x0a, .rev = 0xff, .name = "WM8996-6272 Blackadder" },
299 { .id = 0x0b, .rev = 0xff, .name = "WM8994-6235 Benromach" },
300 { .id = 0x11, .rev = 0xff, .name = "6249-EV2 Glenfarclas", },
301 { .id = 0x14, .rev = 0xff, .name = "6271-EV1 Lochnagar" },
302 { .id = 0x15, .rev = 0xff, .name = "6320-EV1 Bells",
Mark Brown98dcf902012-05-16 07:00:03 +0900303 .i2c_devs = wm6230_i2c_devs,
304 .num_i2c_devs = ARRAY_SIZE(wm6230_i2c_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900305 { .id = 0x21, .rev = 0xff, .name = "1275-EV1 Mortlach" },
306 { .id = 0x25, .rev = 0xff, .name = "1274-EV1 Glencadam" },
307 { .id = 0x31, .rev = 0xff, .name = "1253-EV1 Tomatin",
Mark Browncda23492012-01-12 11:04:56 +0900308 .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900309 { .id = 0x32, .rev = 0xff, .name = "XXXX-EV1 Caol Illa" },
310 { .id = 0x33, .rev = 0xff, .name = "XXXX-EV1 Oban" },
311 { .id = 0x34, .rev = 0xff, .name = "WM0010-6320-CS42 Balblair",
Mark Brownc8968ad2012-10-17 17:41:08 +0900312 .spi_devs = balblair_devs,
313 .num_spi_devs = ARRAY_SIZE(balblair_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900314 { .id = 0x39, .rev = 0xff, .name = "1254-EV1 Dallas Dhu",
Mark Brownd0f0b432011-08-19 22:40:07 +0900315 .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900316 { .id = 0x3a, .rev = 0xff, .name = "1259-EV1 Tobermory",
Mark Brownd0f0b432011-08-19 22:40:07 +0900317 .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900318 { .id = 0x3b, .rev = 0xff, .name = "1255-EV1 Kilchoman",
Mark Brown3aa77792011-09-05 14:48:39 +0900319 .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900320 { .id = 0x3c, .rev = 0xff, .name = "1273-EV1 Longmorn" },
321 { .id = 0x3d, .rev = 0xff, .name = "1277-EV1 Littlemill",
Mark Brownc5c32c92011-12-02 14:32:32 +0900322 .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) },
Mark Brownb23bc662012-10-17 17:41:08 +0900323 { .id = 0x3e, .rev = 0, .name = "WM5102-6271-EV1-CS127 Amrut",
324 .spi_devs = wm5102_reva_spi_devs,
325 .num_spi_devs = ARRAY_SIZE(wm5102_reva_spi_devs) },
Mark Brown64aecb42012-10-17 17:41:08 +0900326 { .id = 0x3e, .rev = -1, .name = "WM5102-6271-EV1-CS127 Amrut",
Mark Brown853b1eb2012-08-10 13:03:16 +0900327 .spi_devs = wm5102_spi_devs,
328 .num_spi_devs = ARRAY_SIZE(wm5102_spi_devs) },
Mark Brownd0f0b432011-08-19 22:40:07 +0900329};
330
331static __devinit int wlf_gf_module_probe(struct i2c_client *i2c,
332 const struct i2c_device_id *i2c_id)
333{
334 int ret, i, j, id, rev;
335
336 ret = i2c_smbus_read_byte_data(i2c, 0);
337 if (ret < 0) {
338 dev_err(&i2c->dev, "Failed to read ID: %d\n", ret);
339 return ret;
340 }
341
342 id = (ret & 0xfe) >> 2;
343 rev = ret & 0x3;
344 for (i = 0; i < ARRAY_SIZE(gf_mods); i++)
Mark Brown64aecb42012-10-17 17:41:08 +0900345 if (id == gf_mods[i].id && (gf_mods[i].rev == 0xff ||
346 rev == gf_mods[i].rev))
Mark Brownd0f0b432011-08-19 22:40:07 +0900347 break;
348
349 if (i < ARRAY_SIZE(gf_mods)) {
350 dev_info(&i2c->dev, "%s revision %d\n",
351 gf_mods[i].name, rev + 1);
Mark Browncda23492012-01-12 11:04:56 +0900352
Mark Brownd0f0b432011-08-19 22:40:07 +0900353 for (j = 0; j < gf_mods[i].num_i2c_devs; j++) {
354 if (!i2c_new_device(i2c->adapter,
355 &(gf_mods[i].i2c_devs[j])))
356 dev_err(&i2c->dev,
357 "Failed to register dev: %d\n", ret);
358 }
Mark Browncda23492012-01-12 11:04:56 +0900359
360 spi_register_board_info(gf_mods[i].spi_devs,
361 gf_mods[i].num_spi_devs);
Mark Brownd0f0b432011-08-19 22:40:07 +0900362 } else {
Mark Brownfc716892011-12-02 14:29:08 +0900363 dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n",
364 id, rev + 1);
Mark Brownd0f0b432011-08-19 22:40:07 +0900365 }
366
367 return 0;
368}
369
370static const struct i2c_device_id wlf_gf_module_id[] = {
371 { "wlf-gf-module", 0 },
372 { }
373};
374
375static struct i2c_driver wlf_gf_module_driver = {
376 .driver = {
377 .name = "wlf-gf-module",
378 .owner = THIS_MODULE,
379 },
380 .probe = wlf_gf_module_probe,
381 .id_table = wlf_gf_module_id,
382};
383
384static int __init wlf_gf_module_register(void)
385{
386 return i2c_add_driver(&wlf_gf_module_driver);
387}
388module_init(wlf_gf_module_register);