blob: c492f75a6b3204b13973c66bc23afea3a3d4be0e [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
11#include <linux/module.h>
12#include <linux/interrupt.h>
13#include <linux/i2c.h>
14
15#include <linux/mfd/wm831x/irq.h>
16#include <linux/mfd/wm831x/gpio.h>
17
Mark Brown3d19f1c2011-12-02 14:29:08 +090018#include <sound/wm5100.h>
Mark Brownd0f0b432011-08-19 22:40:07 +090019#include <sound/wm8996.h>
20#include <sound/wm8962.h>
21#include <sound/wm9081.h>
22
23#include <mach/crag6410.h>
24
Mark Brown3d19f1c2011-12-02 14:29:08 +090025static struct wm5100_pdata wm5100_pdata = {
26 .ldo_ena = S3C64XX_GPN(7),
27 .irq_flags = IRQF_TRIGGER_HIGH,
28 .gpio_base = CODEC_GPIO_BASE,
29
30 .in_mode = {
31 WM5100_IN_DIFF,
32 WM5100_IN_DIFF,
33 WM5100_IN_DIFF,
34 WM5100_IN_SE,
35 },
36
37 .hp_pol = CODEC_GPIO_BASE + 3,
38 .jack_modes = {
39 { WM5100_MICDET_MICBIAS3, 0, 0 },
40 { WM5100_MICDET_MICBIAS2, 1, 1 },
41 },
42
43 .gpio_defaults = {
44 0,
45 0,
46 0,
47 0,
48 0x2, /* IRQ: CMOS output */
49 0x3, /* CLKOUT: CMOS output */
50 },
51};
52
Mark Brownd0f0b432011-08-19 22:40:07 +090053static struct wm8996_retune_mobile_config wm8996_retune[] = {
54 {
55 .name = "Sub LPF",
56 .rate = 48000,
57 .regs = {
58 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
59 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
60 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
61 },
62 },
63 {
64 .name = "Sub HPF",
65 .rate = 48000,
66 .regs = {
67 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
68 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
69 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
70 },
71 },
72};
73
74static struct wm8996_pdata wm8996_pdata __initdata = {
75 .ldo_ena = S3C64XX_GPN(7),
76 .gpio_base = CODEC_GPIO_BASE,
77 .micdet_def = 1,
78 .inl_mode = WM8996_DIFFERRENTIAL_1,
79 .inr_mode = WM8996_DIFFERRENTIAL_1,
80
81 .irq_flags = IRQF_TRIGGER_RISING,
82
83 .gpio_default = {
84 0x8001, /* GPIO1 == ADCLRCLK1 */
85 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */
86 0x0141, /* GPIO3 == HP_SEL */
87 0x0002, /* GPIO4 == IRQ */
88 0x020e, /* GPIO5 == CLKOUT */
89 },
90
91 .retune_mobile_cfgs = wm8996_retune,
92 .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune),
93};
94
95static struct wm8962_pdata wm8962_pdata __initdata = {
96 .gpio_init = {
97 0,
98 WM8962_GPIO_FN_OPCLK,
99 WM8962_GPIO_FN_DMICCLK,
100 0,
101 0x8000 | WM8962_GPIO_FN_DMICDAT,
102 WM8962_GPIO_FN_IRQ, /* Open drain mode */
103 },
Mark Brownd0f0b432011-08-19 22:40:07 +0900104};
105
106static struct wm9081_pdata wm9081_pdata __initdata = {
107 .irq_high = false,
108 .irq_cmos = false,
109};
110
111static const struct i2c_board_info wm1254_devs[] = {
112 { I2C_BOARD_INFO("wm8996", 0x1a),
113 .platform_data = &wm8996_pdata,
114 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
115 },
116 { I2C_BOARD_INFO("wm9081", 0x6c),
117 .platform_data = &wm9081_pdata, },
118};
119
Mark Brown3aa77792011-09-05 14:48:39 +0900120static const struct i2c_board_info wm1255_devs[] = {
121 { I2C_BOARD_INFO("wm5100", 0x1a),
Mark Brown3d19f1c2011-12-02 14:29:08 +0900122 .platform_data = &wm5100_pdata,
Mark Brown3aa77792011-09-05 14:48:39 +0900123 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
124 },
125 { I2C_BOARD_INFO("wm9081", 0x6c),
126 .platform_data = &wm9081_pdata, },
127};
128
Mark Brownd0f0b432011-08-19 22:40:07 +0900129static const struct i2c_board_info wm1259_devs[] = {
130 { I2C_BOARD_INFO("wm8962", 0x1a),
131 .platform_data = &wm8962_pdata,
132 .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
133 },
134};
135
136
137static __devinitdata const struct {
138 u8 id;
139 const char *name;
140 const struct i2c_board_info *i2c_devs;
141 int num_i2c_devs;
142} gf_mods[] = {
143 { .id = 0x01, .name = "1250-EV1 Springbank" },
144 { .id = 0x02, .name = "1251-EV1 Jura" },
145 { .id = 0x03, .name = "1252-EV1 Glenlivet" },
146 { .id = 0x11, .name = "6249-EV2 Glenfarclas", },
147 { .id = 0x21, .name = "1275-EV1 Mortlach" },
148 { .id = 0x25, .name = "1274-EV1 Glencadam" },
149 { .id = 0x31, .name = "1253-EV1 Tomatin", },
150 { .id = 0x39, .name = "1254-EV1 Dallas Dhu",
151 .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) },
152 { .id = 0x3a, .name = "1259-EV1 Tobermory",
153 .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) },
Mark Brown3aa77792011-09-05 14:48:39 +0900154 { .id = 0x3b, .name = "1255-EV1 Kilchoman",
155 .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) },
Mark Brownd0f0b432011-08-19 22:40:07 +0900156 { .id = 0x3c, .name = "1273-EV1 Longmorn" },
157};
158
159static __devinit int wlf_gf_module_probe(struct i2c_client *i2c,
160 const struct i2c_device_id *i2c_id)
161{
162 int ret, i, j, id, rev;
163
164 ret = i2c_smbus_read_byte_data(i2c, 0);
165 if (ret < 0) {
166 dev_err(&i2c->dev, "Failed to read ID: %d\n", ret);
167 return ret;
168 }
169
170 id = (ret & 0xfe) >> 2;
171 rev = ret & 0x3;
172 for (i = 0; i < ARRAY_SIZE(gf_mods); i++)
173 if (id == gf_mods[i].id)
174 break;
175
176 if (i < ARRAY_SIZE(gf_mods)) {
177 dev_info(&i2c->dev, "%s revision %d\n",
178 gf_mods[i].name, rev + 1);
179 for (j = 0; j < gf_mods[i].num_i2c_devs; j++) {
180 if (!i2c_new_device(i2c->adapter,
181 &(gf_mods[i].i2c_devs[j])))
182 dev_err(&i2c->dev,
183 "Failed to register dev: %d\n", ret);
184 }
185 } else {
Mark Brownfc716892011-12-02 14:29:08 +0900186 dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n",
187 id, rev + 1);
Mark Brownd0f0b432011-08-19 22:40:07 +0900188 }
189
190 return 0;
191}
192
193static const struct i2c_device_id wlf_gf_module_id[] = {
194 { "wlf-gf-module", 0 },
195 { }
196};
197
198static struct i2c_driver wlf_gf_module_driver = {
199 .driver = {
200 .name = "wlf-gf-module",
201 .owner = THIS_MODULE,
202 },
203 .probe = wlf_gf_module_probe,
204 .id_table = wlf_gf_module_id,
205};
206
207static int __init wlf_gf_module_register(void)
208{
209 return i2c_add_driver(&wlf_gf_module_driver);
210}
211module_init(wlf_gf_module_register);