diff options
Diffstat (limited to 'arch/arm/mach-s3c64xx/mach-crag6410-module.c')
-rw-r--r-- | arch/arm/mach-s3c64xx/mach-crag6410-module.c | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c new file mode 100644 index 000000000000..66668565ee75 --- /dev/null +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /* 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 | |||
18 | #include <sound/wm8996.h> | ||
19 | #include <sound/wm8962.h> | ||
20 | #include <sound/wm9081.h> | ||
21 | |||
22 | #include <mach/crag6410.h> | ||
23 | |||
24 | static struct wm8996_retune_mobile_config wm8996_retune[] = { | ||
25 | { | ||
26 | .name = "Sub LPF", | ||
27 | .rate = 48000, | ||
28 | .regs = { | ||
29 | 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, | ||
30 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, | ||
31 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 | ||
32 | }, | ||
33 | }, | ||
34 | { | ||
35 | .name = "Sub HPF", | ||
36 | .rate = 48000, | ||
37 | .regs = { | ||
38 | 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, | ||
39 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, | ||
40 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 | ||
41 | }, | ||
42 | }, | ||
43 | }; | ||
44 | |||
45 | static struct wm8996_pdata wm8996_pdata __initdata = { | ||
46 | .ldo_ena = S3C64XX_GPN(7), | ||
47 | .gpio_base = CODEC_GPIO_BASE, | ||
48 | .micdet_def = 1, | ||
49 | .inl_mode = WM8996_DIFFERRENTIAL_1, | ||
50 | .inr_mode = WM8996_DIFFERRENTIAL_1, | ||
51 | |||
52 | .irq_flags = IRQF_TRIGGER_RISING, | ||
53 | |||
54 | .gpio_default = { | ||
55 | 0x8001, /* GPIO1 == ADCLRCLK1 */ | ||
56 | 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */ | ||
57 | 0x0141, /* GPIO3 == HP_SEL */ | ||
58 | 0x0002, /* GPIO4 == IRQ */ | ||
59 | 0x020e, /* GPIO5 == CLKOUT */ | ||
60 | }, | ||
61 | |||
62 | .retune_mobile_cfgs = wm8996_retune, | ||
63 | .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune), | ||
64 | }; | ||
65 | |||
66 | static struct wm8962_pdata wm8962_pdata __initdata = { | ||
67 | .gpio_init = { | ||
68 | 0, | ||
69 | WM8962_GPIO_FN_OPCLK, | ||
70 | WM8962_GPIO_FN_DMICCLK, | ||
71 | 0, | ||
72 | 0x8000 | WM8962_GPIO_FN_DMICDAT, | ||
73 | WM8962_GPIO_FN_IRQ, /* Open drain mode */ | ||
74 | }, | ||
75 | .irq_active_low = true, | ||
76 | }; | ||
77 | |||
78 | static struct wm9081_pdata wm9081_pdata __initdata = { | ||
79 | .irq_high = false, | ||
80 | .irq_cmos = false, | ||
81 | }; | ||
82 | |||
83 | static const struct i2c_board_info wm1254_devs[] = { | ||
84 | { I2C_BOARD_INFO("wm8996", 0x1a), | ||
85 | .platform_data = &wm8996_pdata, | ||
86 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, | ||
87 | }, | ||
88 | { I2C_BOARD_INFO("wm9081", 0x6c), | ||
89 | .platform_data = &wm9081_pdata, }, | ||
90 | }; | ||
91 | |||
92 | static const struct i2c_board_info wm1255_devs[] = { | ||
93 | { I2C_BOARD_INFO("wm5100", 0x1a), | ||
94 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, | ||
95 | }, | ||
96 | { I2C_BOARD_INFO("wm9081", 0x6c), | ||
97 | .platform_data = &wm9081_pdata, }, | ||
98 | }; | ||
99 | |||
100 | static const struct i2c_board_info wm1259_devs[] = { | ||
101 | { I2C_BOARD_INFO("wm8962", 0x1a), | ||
102 | .platform_data = &wm8962_pdata, | ||
103 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, | ||
104 | }, | ||
105 | }; | ||
106 | |||
107 | |||
108 | static __devinitdata const struct { | ||
109 | u8 id; | ||
110 | const char *name; | ||
111 | const struct i2c_board_info *i2c_devs; | ||
112 | int num_i2c_devs; | ||
113 | } gf_mods[] = { | ||
114 | { .id = 0x01, .name = "1250-EV1 Springbank" }, | ||
115 | { .id = 0x02, .name = "1251-EV1 Jura" }, | ||
116 | { .id = 0x03, .name = "1252-EV1 Glenlivet" }, | ||
117 | { .id = 0x11, .name = "6249-EV2 Glenfarclas", }, | ||
118 | { .id = 0x21, .name = "1275-EV1 Mortlach" }, | ||
119 | { .id = 0x25, .name = "1274-EV1 Glencadam" }, | ||
120 | { .id = 0x31, .name = "1253-EV1 Tomatin", }, | ||
121 | { .id = 0x39, .name = "1254-EV1 Dallas Dhu", | ||
122 | .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) }, | ||
123 | { .id = 0x3a, .name = "1259-EV1 Tobermory", | ||
124 | .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) }, | ||
125 | { .id = 0x3b, .name = "1255-EV1 Kilchoman", | ||
126 | .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) }, | ||
127 | { .id = 0x3c, .name = "1273-EV1 Longmorn" }, | ||
128 | }; | ||
129 | |||
130 | static __devinit int wlf_gf_module_probe(struct i2c_client *i2c, | ||
131 | const struct i2c_device_id *i2c_id) | ||
132 | { | ||
133 | int ret, i, j, id, rev; | ||
134 | |||
135 | ret = i2c_smbus_read_byte_data(i2c, 0); | ||
136 | if (ret < 0) { | ||
137 | dev_err(&i2c->dev, "Failed to read ID: %d\n", ret); | ||
138 | return ret; | ||
139 | } | ||
140 | |||
141 | id = (ret & 0xfe) >> 2; | ||
142 | rev = ret & 0x3; | ||
143 | for (i = 0; i < ARRAY_SIZE(gf_mods); i++) | ||
144 | if (id == gf_mods[i].id) | ||
145 | break; | ||
146 | |||
147 | if (i < ARRAY_SIZE(gf_mods)) { | ||
148 | dev_info(&i2c->dev, "%s revision %d\n", | ||
149 | gf_mods[i].name, rev + 1); | ||
150 | for (j = 0; j < gf_mods[i].num_i2c_devs; j++) { | ||
151 | if (!i2c_new_device(i2c->adapter, | ||
152 | &(gf_mods[i].i2c_devs[j]))) | ||
153 | dev_err(&i2c->dev, | ||
154 | "Failed to register dev: %d\n", ret); | ||
155 | } | ||
156 | } else { | ||
157 | dev_warn(&i2c->dev, "Unknown module ID %d revision %d\n", | ||
158 | id, rev); | ||
159 | } | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static const struct i2c_device_id wlf_gf_module_id[] = { | ||
165 | { "wlf-gf-module", 0 }, | ||
166 | { } | ||
167 | }; | ||
168 | |||
169 | static struct i2c_driver wlf_gf_module_driver = { | ||
170 | .driver = { | ||
171 | .name = "wlf-gf-module", | ||
172 | .owner = THIS_MODULE, | ||
173 | }, | ||
174 | .probe = wlf_gf_module_probe, | ||
175 | .id_table = wlf_gf_module_id, | ||
176 | }; | ||
177 | |||
178 | static int __init wlf_gf_module_register(void) | ||
179 | { | ||
180 | return i2c_add_driver(&wlf_gf_module_driver); | ||
181 | } | ||
182 | module_init(wlf_gf_module_register); | ||