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 | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 19 | |
Mark Brown | 719a424 | 2012-03-16 19:36:29 +0100 | [diff] [blame] | 20 | #include <linux/regulator/machine.h> |
| 21 | |
Mark Brown | 3d19f1c | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 22 | #include <sound/wm5100.h> |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 23 | #include <sound/wm8996.h> |
| 24 | #include <sound/wm8962.h> |
| 25 | #include <sound/wm9081.h> |
| 26 | |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 27 | #include <plat/s3c64xx-spi.h> |
| 28 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 29 | #include <mach/crag6410.h> |
| 30 | |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 31 | static struct s3c64xx_spi_csinfo wm0010_spi_csinfo = { |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 32 | .line = S3C64XX_GPC(3), |
| 33 | }; |
| 34 | |
| 35 | static struct spi_board_info wm1253_devs[] = { |
| 36 | [0] = { |
| 37 | .modalias = "wm0010", |
| 38 | .bus_num = 0, |
| 39 | .chip_select = 0, |
| 40 | .mode = SPI_MODE_0, |
Dimitris Papastamos | 1521109 | 2012-06-21 03:43:57 +0900 | [diff] [blame] | 41 | .irq = S3C_EINT(5), |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 42 | .controller_data = &wm0010_spi_csinfo, |
| 43 | }, |
| 44 | }; |
| 45 | |
Mark Brown | 3d19f1c | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 46 | static struct wm5100_pdata wm5100_pdata = { |
| 47 | .ldo_ena = S3C64XX_GPN(7), |
| 48 | .irq_flags = IRQF_TRIGGER_HIGH, |
| 49 | .gpio_base = CODEC_GPIO_BASE, |
| 50 | |
| 51 | .in_mode = { |
| 52 | WM5100_IN_DIFF, |
| 53 | WM5100_IN_DIFF, |
| 54 | WM5100_IN_DIFF, |
| 55 | WM5100_IN_SE, |
| 56 | }, |
| 57 | |
| 58 | .hp_pol = CODEC_GPIO_BASE + 3, |
| 59 | .jack_modes = { |
| 60 | { WM5100_MICDET_MICBIAS3, 0, 0 }, |
| 61 | { WM5100_MICDET_MICBIAS2, 1, 1 }, |
| 62 | }, |
| 63 | |
| 64 | .gpio_defaults = { |
| 65 | 0, |
| 66 | 0, |
| 67 | 0, |
| 68 | 0, |
| 69 | 0x2, /* IRQ: CMOS output */ |
| 70 | 0x3, /* CLKOUT: CMOS output */ |
| 71 | }, |
| 72 | }; |
| 73 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 74 | static struct wm8996_retune_mobile_config wm8996_retune[] = { |
| 75 | { |
| 76 | .name = "Sub LPF", |
| 77 | .rate = 48000, |
| 78 | .regs = { |
| 79 | 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, |
| 80 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, |
| 81 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 |
| 82 | }, |
| 83 | }, |
| 84 | { |
| 85 | .name = "Sub HPF", |
| 86 | .rate = 48000, |
| 87 | .regs = { |
| 88 | 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, |
| 89 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, |
| 90 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 |
| 91 | }, |
| 92 | }, |
| 93 | }; |
| 94 | |
| 95 | static struct wm8996_pdata wm8996_pdata __initdata = { |
| 96 | .ldo_ena = S3C64XX_GPN(7), |
| 97 | .gpio_base = CODEC_GPIO_BASE, |
| 98 | .micdet_def = 1, |
| 99 | .inl_mode = WM8996_DIFFERRENTIAL_1, |
| 100 | .inr_mode = WM8996_DIFFERRENTIAL_1, |
| 101 | |
| 102 | .irq_flags = IRQF_TRIGGER_RISING, |
| 103 | |
| 104 | .gpio_default = { |
| 105 | 0x8001, /* GPIO1 == ADCLRCLK1 */ |
| 106 | 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */ |
| 107 | 0x0141, /* GPIO3 == HP_SEL */ |
| 108 | 0x0002, /* GPIO4 == IRQ */ |
| 109 | 0x020e, /* GPIO5 == CLKOUT */ |
| 110 | }, |
| 111 | |
| 112 | .retune_mobile_cfgs = wm8996_retune, |
| 113 | .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune), |
| 114 | }; |
| 115 | |
| 116 | static struct wm8962_pdata wm8962_pdata __initdata = { |
| 117 | .gpio_init = { |
| 118 | 0, |
| 119 | WM8962_GPIO_FN_OPCLK, |
| 120 | WM8962_GPIO_FN_DMICCLK, |
| 121 | 0, |
| 122 | 0x8000 | WM8962_GPIO_FN_DMICDAT, |
| 123 | WM8962_GPIO_FN_IRQ, /* Open drain mode */ |
| 124 | }, |
Mark Brown | 4b9c85f | 2012-01-24 21:09:15 +0000 | [diff] [blame] | 125 | .in4_dc_measure = true, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | static struct wm9081_pdata wm9081_pdata __initdata = { |
| 129 | .irq_high = false, |
| 130 | .irq_cmos = false, |
| 131 | }; |
| 132 | |
| 133 | static const struct i2c_board_info wm1254_devs[] = { |
| 134 | { I2C_BOARD_INFO("wm8996", 0x1a), |
| 135 | .platform_data = &wm8996_pdata, |
| 136 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, |
| 137 | }, |
| 138 | { I2C_BOARD_INFO("wm9081", 0x6c), |
| 139 | .platform_data = &wm9081_pdata, }, |
| 140 | }; |
| 141 | |
Mark Brown | 3aa7779 | 2011-09-05 14:48:39 +0900 | [diff] [blame] | 142 | static const struct i2c_board_info wm1255_devs[] = { |
| 143 | { I2C_BOARD_INFO("wm5100", 0x1a), |
Mark Brown | 3d19f1c | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 144 | .platform_data = &wm5100_pdata, |
Mark Brown | 3aa7779 | 2011-09-05 14:48:39 +0900 | [diff] [blame] | 145 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, |
| 146 | }, |
| 147 | { I2C_BOARD_INFO("wm9081", 0x6c), |
| 148 | .platform_data = &wm9081_pdata, }, |
| 149 | }; |
| 150 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 151 | static const struct i2c_board_info wm1259_devs[] = { |
| 152 | { I2C_BOARD_INFO("wm8962", 0x1a), |
| 153 | .platform_data = &wm8962_pdata, |
| 154 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, |
| 155 | }, |
| 156 | }; |
| 157 | |
Mark Brown | bd155d2 | 2012-03-08 11:55:07 +0000 | [diff] [blame] | 158 | static struct regulator_init_data wm8994_ldo1 = { |
| 159 | .supply_regulator = "WALLVDD", |
| 160 | }; |
| 161 | |
| 162 | static struct regulator_init_data wm8994_ldo2 = { |
| 163 | .supply_regulator = "WALLVDD", |
| 164 | }; |
| 165 | |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 166 | static struct wm8994_pdata wm8994_pdata = { |
| 167 | .gpio_base = CODEC_GPIO_BASE, |
| 168 | .gpio_defaults = { |
| 169 | 0x3, /* IRQ out, active high, CMOS */ |
| 170 | }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 171 | .ldo = { |
Mark Brown | bd155d2 | 2012-03-08 11:55:07 +0000 | [diff] [blame] | 172 | { .init_data = &wm8994_ldo1, }, |
| 173 | { .init_data = &wm8994_ldo2, }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 174 | }, |
| 175 | }; |
| 176 | |
| 177 | static const struct i2c_board_info wm1277_devs[] = { |
| 178 | { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */ |
| 179 | .platform_data = &wm8994_pdata, |
| 180 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, |
| 181 | }, |
| 182 | }; |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 183 | |
Mark Brown | 9b6e1b0 | 2012-06-20 08:16:25 +0900 | [diff] [blame] | 184 | static const struct i2c_board_info wm5102_devs[] = { |
| 185 | { I2C_BOARD_INFO("wm5102", 0x1a), |
| 186 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, }, |
| 187 | }; |
| 188 | |
Mark Brown | 98dcf90 | 2012-05-16 07:00:03 +0900 | [diff] [blame] | 189 | static const struct i2c_board_info wm6230_i2c_devs[] = { |
| 190 | { I2C_BOARD_INFO("wm9081", 0x6c), |
| 191 | .platform_data = &wm9081_pdata, }, |
| 192 | }; |
| 193 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 194 | static __devinitdata const struct { |
| 195 | u8 id; |
| 196 | const char *name; |
| 197 | const struct i2c_board_info *i2c_devs; |
| 198 | int num_i2c_devs; |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 199 | const struct spi_board_info *spi_devs; |
| 200 | int num_spi_devs; |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 201 | } gf_mods[] = { |
| 202 | { .id = 0x01, .name = "1250-EV1 Springbank" }, |
| 203 | { .id = 0x02, .name = "1251-EV1 Jura" }, |
| 204 | { .id = 0x03, .name = "1252-EV1 Glenlivet" }, |
| 205 | { .id = 0x11, .name = "6249-EV2 Glenfarclas", }, |
Mark Brown | f73dc3d | 2012-03-07 04:13:20 -0800 | [diff] [blame] | 206 | { .id = 0x14, .name = "6271-EV1 Lochnagar" }, |
Mark Brown | 98dcf90 | 2012-05-16 07:00:03 +0900 | [diff] [blame] | 207 | { .id = 0x15, .name = "6320-EV1 Bells", |
| 208 | .i2c_devs = wm6230_i2c_devs, |
| 209 | .num_i2c_devs = ARRAY_SIZE(wm6230_i2c_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 210 | { .id = 0x21, .name = "1275-EV1 Mortlach" }, |
| 211 | { .id = 0x25, .name = "1274-EV1 Glencadam" }, |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 212 | { .id = 0x31, .name = "1253-EV1 Tomatin", |
| 213 | .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) }, |
Mark Brown | f73dc3d | 2012-03-07 04:13:20 -0800 | [diff] [blame] | 214 | { .id = 0x32, .name = "XXXX-EV1 Caol Illa" }, |
| 215 | { .id = 0x33, .name = "XXXX-EV1 Oban" }, |
Mark Brown | 58f8c05 | 2012-06-20 08:16:19 +0900 | [diff] [blame] | 216 | { .id = 0x34, .name = "WM0010-6320-CS42 Balblair" }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 217 | { .id = 0x39, .name = "1254-EV1 Dallas Dhu", |
| 218 | .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) }, |
| 219 | { .id = 0x3a, .name = "1259-EV1 Tobermory", |
| 220 | .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) }, |
Mark Brown | 3aa7779 | 2011-09-05 14:48:39 +0900 | [diff] [blame] | 221 | { .id = 0x3b, .name = "1255-EV1 Kilchoman", |
| 222 | .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 223 | { .id = 0x3c, .name = "1273-EV1 Longmorn" }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 224 | { .id = 0x3d, .name = "1277-EV1 Littlemill", |
| 225 | .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) }, |
Mark Brown | 9b6e1b0 | 2012-06-20 08:16:25 +0900 | [diff] [blame] | 226 | { .id = 0x3e, .name = "WM5102-6271-EV1-CS127", |
| 227 | .i2c_devs = wm5102_devs, .num_i2c_devs = ARRAY_SIZE(wm5102_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | static __devinit int wlf_gf_module_probe(struct i2c_client *i2c, |
| 231 | const struct i2c_device_id *i2c_id) |
| 232 | { |
| 233 | int ret, i, j, id, rev; |
| 234 | |
| 235 | ret = i2c_smbus_read_byte_data(i2c, 0); |
| 236 | if (ret < 0) { |
| 237 | dev_err(&i2c->dev, "Failed to read ID: %d\n", ret); |
| 238 | return ret; |
| 239 | } |
| 240 | |
| 241 | id = (ret & 0xfe) >> 2; |
| 242 | rev = ret & 0x3; |
| 243 | for (i = 0; i < ARRAY_SIZE(gf_mods); i++) |
| 244 | if (id == gf_mods[i].id) |
| 245 | break; |
| 246 | |
| 247 | if (i < ARRAY_SIZE(gf_mods)) { |
| 248 | dev_info(&i2c->dev, "%s revision %d\n", |
| 249 | gf_mods[i].name, rev + 1); |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 250 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 251 | for (j = 0; j < gf_mods[i].num_i2c_devs; j++) { |
| 252 | if (!i2c_new_device(i2c->adapter, |
| 253 | &(gf_mods[i].i2c_devs[j]))) |
| 254 | dev_err(&i2c->dev, |
| 255 | "Failed to register dev: %d\n", ret); |
| 256 | } |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 257 | |
| 258 | spi_register_board_info(gf_mods[i].spi_devs, |
| 259 | gf_mods[i].num_spi_devs); |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 260 | } else { |
Mark Brown | fc71689 | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 261 | dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n", |
| 262 | id, rev + 1); |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | static const struct i2c_device_id wlf_gf_module_id[] = { |
| 269 | { "wlf-gf-module", 0 }, |
| 270 | { } |
| 271 | }; |
| 272 | |
| 273 | static struct i2c_driver wlf_gf_module_driver = { |
| 274 | .driver = { |
| 275 | .name = "wlf-gf-module", |
| 276 | .owner = THIS_MODULE, |
| 277 | }, |
| 278 | .probe = wlf_gf_module_probe, |
| 279 | .id_table = wlf_gf_module_id, |
| 280 | }; |
| 281 | |
| 282 | static int __init wlf_gf_module_register(void) |
| 283 | { |
| 284 | return i2c_add_driver(&wlf_gf_module_driver); |
| 285 | } |
| 286 | module_init(wlf_gf_module_register); |