blob: 32b82c0b9487f1fffa42f354a4d3a23cc48a5a49 [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,
190 .gpio_defaults = {
191 0x3, /* IRQ out, active high, CMOS */
192 },
Mark Brownc5c32c92011-12-02 14:32:32 +0900193 .ldo = {
Mark Brownbd155d22012-03-08 11:55:07 +0000194 { .init_data = &wm8994_ldo1, },
195 { .init_data = &wm8994_ldo2, },
Mark Brownc5c32c92011-12-02 14:32:32 +0900196 },
197};
198
199static const struct i2c_board_info wm1277_devs[] = {
200 { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */
201 .platform_data = &wm8994_pdata,
202 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
203 },
204};
Mark Brownd0f0b432011-08-19 22:40:07 +0900205
Mark Brown853b1eb2012-08-10 13:03:16 +0900206static struct arizona_pdata wm5102_pdata = {
207 .ldoena = S3C64XX_GPN(7),
208 .gpio_base = CODEC_GPIO_BASE,
209 .irq_active_high = true,
210 .micd_pol_gpio = CODEC_GPIO_BASE + 4,
211 .gpio_defaults = {
212 [2] = 0x10000, /* AIF3TXLRCLK */
213 [3] = 0x4, /* OPCLK */
214 },
215};
216
217static struct s3c64xx_spi_csinfo wm5102_spi_csinfo = {
218 .line = S3C64XX_GPN(5),
219};
220
221static struct spi_board_info wm5102_spi_devs[] = {
222 [0] = {
223 .modalias = "wm5102",
224 .max_speed_hz = 10 * 1000 * 1000,
225 .bus_num = 0,
Mark Brown479535e2012-10-17 17:41:07 +0900226 .chip_select = 1,
Mark Brown853b1eb2012-08-10 13:03:16 +0900227 .mode = SPI_MODE_0,
228 .irq = GLENFARCLAS_PMIC_IRQ_BASE +
229 WM831X_IRQ_GPIO_2,
230 .controller_data = &wm5102_spi_csinfo,
231 .platform_data = &wm5102_pdata,
232 },
Mark Brown9b6e1b02012-06-20 08:16:25 +0900233};
234
Mark Brown98dcf902012-05-16 07:00:03 +0900235static const struct i2c_board_info wm6230_i2c_devs[] = {
236 { I2C_BOARD_INFO("wm9081", 0x6c),
237 .platform_data = &wm9081_pdata, },
238};
239
Mark Brownd0f0b432011-08-19 22:40:07 +0900240static __devinitdata const struct {
241 u8 id;
242 const char *name;
243 const struct i2c_board_info *i2c_devs;
244 int num_i2c_devs;
Mark Browncda23492012-01-12 11:04:56 +0900245 const struct spi_board_info *spi_devs;
246 int num_spi_devs;
Mark Brownd0f0b432011-08-19 22:40:07 +0900247} gf_mods[] = {
248 { .id = 0x01, .name = "1250-EV1 Springbank" },
249 { .id = 0x02, .name = "1251-EV1 Jura" },
250 { .id = 0x03, .name = "1252-EV1 Glenlivet" },
Mark Browna006aea2012-10-17 17:41:07 +0900251 { .id = 0x06, .name = "WM8997-6721-CS96-EV1 Lapraoig" },
252 { .id = 0x07, .name = "WM5110-6271 Deanston" },
253 { .id = 0x08, .name = "WM8903-6102 Tamdhu" },
254 { .id = 0x09, .name = "WM1811A-6305 Adelphi" },
255 { .id = 0x0a, .name = "WM8996-6272 Blackadder" },
256 { .id = 0x0b, .name = "WM8994-6235 Benromach" },
Mark Brownd0f0b432011-08-19 22:40:07 +0900257 { .id = 0x11, .name = "6249-EV2 Glenfarclas", },
Mark Brownf73dc3d2012-03-07 04:13:20 -0800258 { .id = 0x14, .name = "6271-EV1 Lochnagar" },
Mark Brown98dcf902012-05-16 07:00:03 +0900259 { .id = 0x15, .name = "6320-EV1 Bells",
260 .i2c_devs = wm6230_i2c_devs,
261 .num_i2c_devs = ARRAY_SIZE(wm6230_i2c_devs) },
Mark Brownd0f0b432011-08-19 22:40:07 +0900262 { .id = 0x21, .name = "1275-EV1 Mortlach" },
263 { .id = 0x25, .name = "1274-EV1 Glencadam" },
Mark Browncda23492012-01-12 11:04:56 +0900264 { .id = 0x31, .name = "1253-EV1 Tomatin",
265 .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) },
Mark Brownf73dc3d2012-03-07 04:13:20 -0800266 { .id = 0x32, .name = "XXXX-EV1 Caol Illa" },
267 { .id = 0x33, .name = "XXXX-EV1 Oban" },
Mark Brownc8968ad2012-10-17 17:41:08 +0900268 { .id = 0x34, .name = "WM0010-6320-CS42 Balblair",
269 .spi_devs = balblair_devs,
270 .num_spi_devs = ARRAY_SIZE(balblair_devs) },
Mark Brownd0f0b432011-08-19 22:40:07 +0900271 { .id = 0x39, .name = "1254-EV1 Dallas Dhu",
272 .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) },
273 { .id = 0x3a, .name = "1259-EV1 Tobermory",
274 .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) },
Mark Brown3aa77792011-09-05 14:48:39 +0900275 { .id = 0x3b, .name = "1255-EV1 Kilchoman",
276 .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) },
Mark Brownd0f0b432011-08-19 22:40:07 +0900277 { .id = 0x3c, .name = "1273-EV1 Longmorn" },
Mark Brownc5c32c92011-12-02 14:32:32 +0900278 { .id = 0x3d, .name = "1277-EV1 Littlemill",
279 .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) },
Mark Brown853b1eb2012-08-10 13:03:16 +0900280 { .id = 0x3e, .name = "WM5102-6271-EV1-CS127 Amrut",
281 .spi_devs = wm5102_spi_devs,
282 .num_spi_devs = ARRAY_SIZE(wm5102_spi_devs) },
Mark Brownd0f0b432011-08-19 22:40:07 +0900283};
284
285static __devinit int wlf_gf_module_probe(struct i2c_client *i2c,
286 const struct i2c_device_id *i2c_id)
287{
288 int ret, i, j, id, rev;
289
290 ret = i2c_smbus_read_byte_data(i2c, 0);
291 if (ret < 0) {
292 dev_err(&i2c->dev, "Failed to read ID: %d\n", ret);
293 return ret;
294 }
295
296 id = (ret & 0xfe) >> 2;
297 rev = ret & 0x3;
298 for (i = 0; i < ARRAY_SIZE(gf_mods); i++)
299 if (id == gf_mods[i].id)
300 break;
301
302 if (i < ARRAY_SIZE(gf_mods)) {
303 dev_info(&i2c->dev, "%s revision %d\n",
304 gf_mods[i].name, rev + 1);
Mark Browncda23492012-01-12 11:04:56 +0900305
Mark Brownd0f0b432011-08-19 22:40:07 +0900306 for (j = 0; j < gf_mods[i].num_i2c_devs; j++) {
307 if (!i2c_new_device(i2c->adapter,
308 &(gf_mods[i].i2c_devs[j])))
309 dev_err(&i2c->dev,
310 "Failed to register dev: %d\n", ret);
311 }
Mark Browncda23492012-01-12 11:04:56 +0900312
313 spi_register_board_info(gf_mods[i].spi_devs,
314 gf_mods[i].num_spi_devs);
Mark Brownd0f0b432011-08-19 22:40:07 +0900315 } else {
Mark Brownfc716892011-12-02 14:29:08 +0900316 dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n",
317 id, rev + 1);
Mark Brownd0f0b432011-08-19 22:40:07 +0900318 }
319
320 return 0;
321}
322
323static const struct i2c_device_id wlf_gf_module_id[] = {
324 { "wlf-gf-module", 0 },
325 { }
326};
327
328static struct i2c_driver wlf_gf_module_driver = {
329 .driver = {
330 .name = "wlf-gf-module",
331 .owner = THIS_MODULE,
332 },
333 .probe = wlf_gf_module_probe,
334 .id_table = wlf_gf_module_id,
335};
336
337static int __init wlf_gf_module_register(void)
338{
339 return i2c_add_driver(&wlf_gf_module_driver);
340}
341module_init(wlf_gf_module_register);