Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 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 | |
Kukjin Kim | a69e4c2 | 2011-11-17 01:14:38 +0900 | [diff] [blame] | 11 | #include <linux/export.h> |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
| 13 | #include <linux/i2c.h> |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 14 | #include <linux/spi/spi.h> |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 15 | |
| 16 | #include <linux/mfd/wm831x/irq.h> |
| 17 | #include <linux/mfd/wm831x/gpio.h> |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 18 | #include <linux/mfd/wm8994/pdata.h> |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 19 | #include <linux/mfd/arizona/pdata.h> |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 20 | |
Mark Brown | 719a424 | 2012-03-16 19:36:29 +0100 | [diff] [blame] | 21 | #include <linux/regulator/machine.h> |
| 22 | |
Mark Brown | c8968ad | 2012-10-17 17:41:08 +0900 | [diff] [blame^] | 23 | #include <sound/wm0010.h> |
Mark Brown | 3d19f1c | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 24 | #include <sound/wm5100.h> |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 25 | #include <sound/wm8996.h> |
| 26 | #include <sound/wm8962.h> |
| 27 | #include <sound/wm9081.h> |
| 28 | |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 29 | #include <linux/platform_data/spi-s3c64xx.h> |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 30 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 31 | #include <mach/crag6410.h> |
| 32 | |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 33 | static struct s3c64xx_spi_csinfo wm0010_spi_csinfo = { |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 34 | .line = S3C64XX_GPC(3), |
| 35 | }; |
| 36 | |
Mark Brown | c8968ad | 2012-10-17 17:41:08 +0900 | [diff] [blame^] | 37 | static 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 Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 42 | static struct spi_board_info wm1253_devs[] = { |
| 43 | [0] = { |
| 44 | .modalias = "wm0010", |
Mark Brown | c8968ad | 2012-10-17 17:41:08 +0900 | [diff] [blame^] | 45 | .max_speed_hz = 26 * 1000 * 1000, |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 46 | .bus_num = 0, |
| 47 | .chip_select = 0, |
| 48 | .mode = SPI_MODE_0, |
Dimitris Papastamos | 1521109 | 2012-06-21 03:43:57 +0900 | [diff] [blame] | 49 | .irq = S3C_EINT(5), |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 50 | .controller_data = &wm0010_spi_csinfo, |
Mark Brown | c8968ad | 2012-10-17 17:41:08 +0900 | [diff] [blame^] | 51 | .platform_data = &wm0010_pdata, |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | static 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 Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 65 | }, |
| 66 | }; |
| 67 | |
Mark Brown | 3d19f1c | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 68 | static 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 Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 96 | static 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 | |
| 117 | static 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 | |
| 138 | static 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 Brown | 4b9c85f | 2012-01-24 21:09:15 +0000 | [diff] [blame] | 147 | .in4_dc_measure = true, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | static struct wm9081_pdata wm9081_pdata __initdata = { |
| 151 | .irq_high = false, |
| 152 | .irq_cmos = false, |
| 153 | }; |
| 154 | |
| 155 | static 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 Brown | 3aa7779 | 2011-09-05 14:48:39 +0900 | [diff] [blame] | 164 | static const struct i2c_board_info wm1255_devs[] = { |
| 165 | { I2C_BOARD_INFO("wm5100", 0x1a), |
Mark Brown | 3d19f1c | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 166 | .platform_data = &wm5100_pdata, |
Mark Brown | 3aa7779 | 2011-09-05 14:48:39 +0900 | [diff] [blame] | 167 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, |
| 168 | }, |
| 169 | { I2C_BOARD_INFO("wm9081", 0x6c), |
| 170 | .platform_data = &wm9081_pdata, }, |
| 171 | }; |
| 172 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 173 | static 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 Brown | bd155d2 | 2012-03-08 11:55:07 +0000 | [diff] [blame] | 180 | static struct regulator_init_data wm8994_ldo1 = { |
| 181 | .supply_regulator = "WALLVDD", |
| 182 | }; |
| 183 | |
| 184 | static struct regulator_init_data wm8994_ldo2 = { |
| 185 | .supply_regulator = "WALLVDD", |
| 186 | }; |
| 187 | |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 188 | static struct wm8994_pdata wm8994_pdata = { |
| 189 | .gpio_base = CODEC_GPIO_BASE, |
| 190 | .gpio_defaults = { |
| 191 | 0x3, /* IRQ out, active high, CMOS */ |
| 192 | }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 193 | .ldo = { |
Mark Brown | bd155d2 | 2012-03-08 11:55:07 +0000 | [diff] [blame] | 194 | { .init_data = &wm8994_ldo1, }, |
| 195 | { .init_data = &wm8994_ldo2, }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 196 | }, |
| 197 | }; |
| 198 | |
| 199 | static 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 Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 205 | |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 206 | static 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 | |
| 217 | static struct s3c64xx_spi_csinfo wm5102_spi_csinfo = { |
| 218 | .line = S3C64XX_GPN(5), |
| 219 | }; |
| 220 | |
| 221 | static struct spi_board_info wm5102_spi_devs[] = { |
| 222 | [0] = { |
| 223 | .modalias = "wm5102", |
| 224 | .max_speed_hz = 10 * 1000 * 1000, |
| 225 | .bus_num = 0, |
Mark Brown | 479535e | 2012-10-17 17:41:07 +0900 | [diff] [blame] | 226 | .chip_select = 1, |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 227 | .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 Brown | 9b6e1b0 | 2012-06-20 08:16:25 +0900 | [diff] [blame] | 233 | }; |
| 234 | |
Mark Brown | 98dcf90 | 2012-05-16 07:00:03 +0900 | [diff] [blame] | 235 | static const struct i2c_board_info wm6230_i2c_devs[] = { |
| 236 | { I2C_BOARD_INFO("wm9081", 0x6c), |
| 237 | .platform_data = &wm9081_pdata, }, |
| 238 | }; |
| 239 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 240 | static __devinitdata const struct { |
| 241 | u8 id; |
| 242 | const char *name; |
| 243 | const struct i2c_board_info *i2c_devs; |
| 244 | int num_i2c_devs; |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 245 | const struct spi_board_info *spi_devs; |
| 246 | int num_spi_devs; |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 247 | } gf_mods[] = { |
| 248 | { .id = 0x01, .name = "1250-EV1 Springbank" }, |
| 249 | { .id = 0x02, .name = "1251-EV1 Jura" }, |
| 250 | { .id = 0x03, .name = "1252-EV1 Glenlivet" }, |
Mark Brown | a006aea | 2012-10-17 17:41:07 +0900 | [diff] [blame] | 251 | { .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 Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 257 | { .id = 0x11, .name = "6249-EV2 Glenfarclas", }, |
Mark Brown | f73dc3d | 2012-03-07 04:13:20 -0800 | [diff] [blame] | 258 | { .id = 0x14, .name = "6271-EV1 Lochnagar" }, |
Mark Brown | 98dcf90 | 2012-05-16 07:00:03 +0900 | [diff] [blame] | 259 | { .id = 0x15, .name = "6320-EV1 Bells", |
| 260 | .i2c_devs = wm6230_i2c_devs, |
| 261 | .num_i2c_devs = ARRAY_SIZE(wm6230_i2c_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 262 | { .id = 0x21, .name = "1275-EV1 Mortlach" }, |
| 263 | { .id = 0x25, .name = "1274-EV1 Glencadam" }, |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 264 | { .id = 0x31, .name = "1253-EV1 Tomatin", |
| 265 | .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) }, |
Mark Brown | f73dc3d | 2012-03-07 04:13:20 -0800 | [diff] [blame] | 266 | { .id = 0x32, .name = "XXXX-EV1 Caol Illa" }, |
| 267 | { .id = 0x33, .name = "XXXX-EV1 Oban" }, |
Mark Brown | c8968ad | 2012-10-17 17:41:08 +0900 | [diff] [blame^] | 268 | { .id = 0x34, .name = "WM0010-6320-CS42 Balblair", |
| 269 | .spi_devs = balblair_devs, |
| 270 | .num_spi_devs = ARRAY_SIZE(balblair_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 271 | { .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 Brown | 3aa7779 | 2011-09-05 14:48:39 +0900 | [diff] [blame] | 275 | { .id = 0x3b, .name = "1255-EV1 Kilchoman", |
| 276 | .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 277 | { .id = 0x3c, .name = "1273-EV1 Longmorn" }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 278 | { .id = 0x3d, .name = "1277-EV1 Littlemill", |
| 279 | .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) }, |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 280 | { .id = 0x3e, .name = "WM5102-6271-EV1-CS127 Amrut", |
| 281 | .spi_devs = wm5102_spi_devs, |
| 282 | .num_spi_devs = ARRAY_SIZE(wm5102_spi_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | static __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 Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 305 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 306 | 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 Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 312 | |
| 313 | spi_register_board_info(gf_mods[i].spi_devs, |
| 314 | gf_mods[i].num_spi_devs); |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 315 | } else { |
Mark Brown | fc71689 | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 316 | dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n", |
| 317 | id, rev + 1); |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | return 0; |
| 321 | } |
| 322 | |
| 323 | static const struct i2c_device_id wlf_gf_module_id[] = { |
| 324 | { "wlf-gf-module", 0 }, |
| 325 | { } |
| 326 | }; |
| 327 | |
| 328 | static 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 | |
| 337 | static int __init wlf_gf_module_register(void) |
| 338 | { |
| 339 | return i2c_add_driver(&wlf_gf_module_driver); |
| 340 | } |
| 341 | module_init(wlf_gf_module_register); |