1 /* Speyside modules for Cragganmore - board data probing
3 * Copyright 2011 Wolfson Microelectronics plc
4 * Mark Brown <broonie@opensource.wolfsonmicro.com>
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.
11 #include <linux/export.h>
12 #include <linux/interrupt.h>
13 #include <linux/i2c.h>
14 #include <linux/spi/spi.h>
16 #include <linux/mfd/wm831x/irq.h>
17 #include <linux/mfd/wm831x/gpio.h>
18 #include <linux/mfd/wm8994/pdata.h>
20 #include <linux/regulator/machine.h>
22 #include <sound/wm5100.h>
23 #include <sound/wm8996.h>
24 #include <sound/wm8962.h>
25 #include <sound/wm9081.h>
27 #include <plat/s3c64xx-spi.h>
29 #include <mach/crag6410.h>
31 static struct s3c64xx_spi_csinfo wm0010_spi_csinfo
= {
32 .set_level
= gpio_set_value
,
33 .line
= S3C64XX_GPC(3),
36 static struct spi_board_info wm1253_devs
[] = {
43 .controller_data
= &wm0010_spi_csinfo
,
47 static struct wm5100_pdata wm5100_pdata
= {
48 .ldo_ena
= S3C64XX_GPN(7),
49 .irq_flags
= IRQF_TRIGGER_HIGH
,
50 .gpio_base
= CODEC_GPIO_BASE
,
59 .hp_pol
= CODEC_GPIO_BASE
+ 3,
61 { WM5100_MICDET_MICBIAS3
, 0, 0 },
62 { WM5100_MICDET_MICBIAS2
, 1, 1 },
70 0x2, /* IRQ: CMOS output */
71 0x3, /* CLKOUT: CMOS output */
75 static struct wm8996_retune_mobile_config wm8996_retune
[] = {
80 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
81 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
82 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
89 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
90 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
91 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
96 static struct wm8996_pdata wm8996_pdata __initdata
= {
97 .ldo_ena
= S3C64XX_GPN(7),
98 .gpio_base
= CODEC_GPIO_BASE
,
100 .inl_mode
= WM8996_DIFFERRENTIAL_1
,
101 .inr_mode
= WM8996_DIFFERRENTIAL_1
,
103 .irq_flags
= IRQF_TRIGGER_RISING
,
106 0x8001, /* GPIO1 == ADCLRCLK1 */
107 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */
108 0x0141, /* GPIO3 == HP_SEL */
109 0x0002, /* GPIO4 == IRQ */
110 0x020e, /* GPIO5 == CLKOUT */
113 .retune_mobile_cfgs
= wm8996_retune
,
114 .num_retune_mobile_cfgs
= ARRAY_SIZE(wm8996_retune
),
117 static struct wm8962_pdata wm8962_pdata __initdata
= {
120 WM8962_GPIO_FN_OPCLK
,
121 WM8962_GPIO_FN_DMICCLK
,
123 0x8000 | WM8962_GPIO_FN_DMICDAT
,
124 WM8962_GPIO_FN_IRQ
, /* Open drain mode */
126 .in4_dc_measure
= true,
129 static struct wm9081_pdata wm9081_pdata __initdata
= {
134 static const struct i2c_board_info wm1254_devs
[] = {
135 { I2C_BOARD_INFO("wm8996", 0x1a),
136 .platform_data
= &wm8996_pdata
,
137 .irq
= GLENFARCLAS_PMIC_IRQ_BASE
+ WM831X_IRQ_GPIO_2
,
139 { I2C_BOARD_INFO("wm9081", 0x6c),
140 .platform_data
= &wm9081_pdata
, },
143 static const struct i2c_board_info wm1255_devs
[] = {
144 { I2C_BOARD_INFO("wm5100", 0x1a),
145 .platform_data
= &wm5100_pdata
,
146 .irq
= GLENFARCLAS_PMIC_IRQ_BASE
+ WM831X_IRQ_GPIO_2
,
148 { I2C_BOARD_INFO("wm9081", 0x6c),
149 .platform_data
= &wm9081_pdata
, },
152 static const struct i2c_board_info wm1259_devs
[] = {
153 { I2C_BOARD_INFO("wm8962", 0x1a),
154 .platform_data
= &wm8962_pdata
,
155 .irq
= GLENFARCLAS_PMIC_IRQ_BASE
+ WM831X_IRQ_GPIO_2
,
159 static struct regulator_init_data wm8994_ldo1
= {
160 .supply_regulator
= "WALLVDD",
163 static struct regulator_init_data wm8994_ldo2
= {
164 .supply_regulator
= "WALLVDD",
167 static struct wm8994_pdata wm8994_pdata
= {
168 .gpio_base
= CODEC_GPIO_BASE
,
170 0x3, /* IRQ out, active high, CMOS */
173 { .init_data
= &wm8994_ldo1
, },
174 { .init_data
= &wm8994_ldo2
, },
178 static const struct i2c_board_info wm1277_devs
[] = {
179 { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */
180 .platform_data
= &wm8994_pdata
,
181 .irq
= GLENFARCLAS_PMIC_IRQ_BASE
+ WM831X_IRQ_GPIO_2
,
185 static const struct i2c_board_info wm5102_devs
[] = {
186 { I2C_BOARD_INFO("wm5102", 0x1a),
187 .irq
= GLENFARCLAS_PMIC_IRQ_BASE
+ WM831X_IRQ_GPIO_2
, },
190 static const struct i2c_board_info wm6230_i2c_devs
[] = {
191 { I2C_BOARD_INFO("wm9081", 0x6c),
192 .platform_data
= &wm9081_pdata
, },
195 static __devinitdata
const struct {
198 const struct i2c_board_info
*i2c_devs
;
200 const struct spi_board_info
*spi_devs
;
203 { .id
= 0x01, .name
= "1250-EV1 Springbank" },
204 { .id
= 0x02, .name
= "1251-EV1 Jura" },
205 { .id
= 0x03, .name
= "1252-EV1 Glenlivet" },
206 { .id
= 0x11, .name
= "6249-EV2 Glenfarclas", },
207 { .id
= 0x14, .name
= "6271-EV1 Lochnagar" },
208 { .id
= 0x15, .name
= "6320-EV1 Bells",
209 .i2c_devs
= wm6230_i2c_devs
,
210 .num_i2c_devs
= ARRAY_SIZE(wm6230_i2c_devs
) },
211 { .id
= 0x21, .name
= "1275-EV1 Mortlach" },
212 { .id
= 0x25, .name
= "1274-EV1 Glencadam" },
213 { .id
= 0x31, .name
= "1253-EV1 Tomatin",
214 .spi_devs
= wm1253_devs
, .num_spi_devs
= ARRAY_SIZE(wm1253_devs
) },
215 { .id
= 0x32, .name
= "XXXX-EV1 Caol Illa" },
216 { .id
= 0x33, .name
= "XXXX-EV1 Oban" },
217 { .id
= 0x34, .name
= "WM0010-6320-CS42 Balblair" },
218 { .id
= 0x39, .name
= "1254-EV1 Dallas Dhu",
219 .i2c_devs
= wm1254_devs
, .num_i2c_devs
= ARRAY_SIZE(wm1254_devs
) },
220 { .id
= 0x3a, .name
= "1259-EV1 Tobermory",
221 .i2c_devs
= wm1259_devs
, .num_i2c_devs
= ARRAY_SIZE(wm1259_devs
) },
222 { .id
= 0x3b, .name
= "1255-EV1 Kilchoman",
223 .i2c_devs
= wm1255_devs
, .num_i2c_devs
= ARRAY_SIZE(wm1255_devs
) },
224 { .id
= 0x3c, .name
= "1273-EV1 Longmorn" },
225 { .id
= 0x3d, .name
= "1277-EV1 Littlemill",
226 .i2c_devs
= wm1277_devs
, .num_i2c_devs
= ARRAY_SIZE(wm1277_devs
) },
227 { .id
= 0x3e, .name
= "WM5102-6271-EV1-CS127",
228 .i2c_devs
= wm5102_devs
, .num_i2c_devs
= ARRAY_SIZE(wm5102_devs
) },
231 static __devinit
int wlf_gf_module_probe(struct i2c_client
*i2c
,
232 const struct i2c_device_id
*i2c_id
)
234 int ret
, i
, j
, id
, rev
;
236 ret
= i2c_smbus_read_byte_data(i2c
, 0);
238 dev_err(&i2c
->dev
, "Failed to read ID: %d\n", ret
);
242 id
= (ret
& 0xfe) >> 2;
244 for (i
= 0; i
< ARRAY_SIZE(gf_mods
); i
++)
245 if (id
== gf_mods
[i
].id
)
248 if (i
< ARRAY_SIZE(gf_mods
)) {
249 dev_info(&i2c
->dev
, "%s revision %d\n",
250 gf_mods
[i
].name
, rev
+ 1);
252 for (j
= 0; j
< gf_mods
[i
].num_i2c_devs
; j
++) {
253 if (!i2c_new_device(i2c
->adapter
,
254 &(gf_mods
[i
].i2c_devs
[j
])))
256 "Failed to register dev: %d\n", ret
);
259 spi_register_board_info(gf_mods
[i
].spi_devs
,
260 gf_mods
[i
].num_spi_devs
);
262 dev_warn(&i2c
->dev
, "Unknown module ID 0x%x revision %d\n",
269 static const struct i2c_device_id wlf_gf_module_id
[] = {
270 { "wlf-gf-module", 0 },
274 static struct i2c_driver wlf_gf_module_driver
= {
276 .name
= "wlf-gf-module",
277 .owner
= THIS_MODULE
,
279 .probe
= wlf_gf_module_probe
,
280 .id_table
= wlf_gf_module_id
,
283 static int __init
wlf_gf_module_register(void)
285 return i2c_add_driver(&wlf_gf_module_driver
);
287 module_init(wlf_gf_module_register
);