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, |
Mark Brown | b23bc66 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 190 | .micb2_delay = 150, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 191 | .gpio_defaults = { |
| 192 | 0x3, /* IRQ out, active high, CMOS */ |
| 193 | }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 194 | .ldo = { |
Mark Brown | b23bc66 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 195 | { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, }, |
| 196 | { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, }, |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 197 | }, |
| 198 | }; |
| 199 | |
| 200 | static const struct i2c_board_info wm1277_devs[] = { |
| 201 | { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */ |
| 202 | .platform_data = &wm8994_pdata, |
| 203 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, |
| 204 | }, |
| 205 | }; |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 206 | |
Mark Brown | b23bc66 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 207 | static struct arizona_pdata wm5102_reva_pdata = { |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 208 | .ldoena = S3C64XX_GPN(7), |
| 209 | .gpio_base = CODEC_GPIO_BASE, |
| 210 | .irq_active_high = true, |
| 211 | .micd_pol_gpio = CODEC_GPIO_BASE + 4, |
| 212 | .gpio_defaults = { |
| 213 | [2] = 0x10000, /* AIF3TXLRCLK */ |
| 214 | [3] = 0x4, /* OPCLK */ |
| 215 | }, |
| 216 | }; |
| 217 | |
Mark Brown | 41830ee | 2012-10-17 17:41:09 +0900 | [diff] [blame^] | 218 | static struct s3c64xx_spi_csinfo codec_spi_csinfo = { |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 219 | .line = S3C64XX_GPN(5), |
| 220 | }; |
| 221 | |
Mark Brown | b23bc66 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 222 | static struct spi_board_info wm5102_reva_spi_devs[] = { |
| 223 | [0] = { |
| 224 | .modalias = "wm5102", |
| 225 | .max_speed_hz = 10 * 1000 * 1000, |
| 226 | .bus_num = 0, |
| 227 | .chip_select = 1, |
| 228 | .mode = SPI_MODE_0, |
| 229 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + |
| 230 | WM831X_IRQ_GPIO_2, |
Mark Brown | 41830ee | 2012-10-17 17:41:09 +0900 | [diff] [blame^] | 231 | .controller_data = &codec_spi_csinfo, |
Mark Brown | b23bc66 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 232 | .platform_data = &wm5102_reva_pdata, |
| 233 | }, |
| 234 | }; |
| 235 | |
| 236 | static struct arizona_pdata wm5102_pdata = { |
| 237 | .ldoena = S3C64XX_GPN(7), |
| 238 | .gpio_base = CODEC_GPIO_BASE, |
| 239 | .irq_active_high = true, |
| 240 | .micd_pol_gpio = CODEC_GPIO_BASE + 2, |
| 241 | .gpio_defaults = { |
| 242 | [2] = 0x10000, /* AIF3TXLRCLK */ |
| 243 | [3] = 0x4, /* OPCLK */ |
| 244 | }, |
| 245 | }; |
| 246 | |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 247 | static struct spi_board_info wm5102_spi_devs[] = { |
| 248 | [0] = { |
| 249 | .modalias = "wm5102", |
| 250 | .max_speed_hz = 10 * 1000 * 1000, |
| 251 | .bus_num = 0, |
Mark Brown | 479535e | 2012-10-17 17:41:07 +0900 | [diff] [blame] | 252 | .chip_select = 1, |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 253 | .mode = SPI_MODE_0, |
| 254 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + |
| 255 | WM831X_IRQ_GPIO_2, |
Mark Brown | 41830ee | 2012-10-17 17:41:09 +0900 | [diff] [blame^] | 256 | .controller_data = &codec_spi_csinfo, |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 257 | .platform_data = &wm5102_pdata, |
| 258 | }, |
Mark Brown | 9b6e1b0 | 2012-06-20 08:16:25 +0900 | [diff] [blame] | 259 | }; |
| 260 | |
Mark Brown | 41830ee | 2012-10-17 17:41:09 +0900 | [diff] [blame^] | 261 | static struct spi_board_info wm5110_spi_devs[] = { |
| 262 | [0] = { |
| 263 | .modalias = "wm5110", |
| 264 | .max_speed_hz = 10 * 1000 * 1000, |
| 265 | .bus_num = 0, |
| 266 | .chip_select = 1, |
| 267 | .mode = SPI_MODE_0, |
| 268 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + |
| 269 | WM831X_IRQ_GPIO_2, |
| 270 | .controller_data = &codec_spi_csinfo, |
| 271 | .platform_data = &wm5102_reva_pdata, |
| 272 | }, |
| 273 | }; |
| 274 | |
Mark Brown | 98dcf90 | 2012-05-16 07:00:03 +0900 | [diff] [blame] | 275 | static const struct i2c_board_info wm6230_i2c_devs[] = { |
| 276 | { I2C_BOARD_INFO("wm9081", 0x6c), |
| 277 | .platform_data = &wm9081_pdata, }, |
| 278 | }; |
| 279 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 280 | static __devinitdata const struct { |
| 281 | u8 id; |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 282 | u8 rev; |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 283 | const char *name; |
| 284 | const struct i2c_board_info *i2c_devs; |
| 285 | int num_i2c_devs; |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 286 | const struct spi_board_info *spi_devs; |
| 287 | int num_spi_devs; |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 288 | } gf_mods[] = { |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 289 | { .id = 0x01, .rev = 0xff, .name = "1250-EV1 Springbank" }, |
| 290 | { .id = 0x02, .rev = 0xff, .name = "1251-EV1 Jura" }, |
| 291 | { .id = 0x03, .rev = 0xff, .name = "1252-EV1 Glenlivet" }, |
| 292 | { .id = 0x06, .rev = 0xff, .name = "WM8997-6721-CS96-EV1 Lapraoig" }, |
Mark Brown | 41830ee | 2012-10-17 17:41:09 +0900 | [diff] [blame^] | 293 | { .id = 0x07, .rev = 0xff, .name = "WM5110-6271 Deanston", |
| 294 | .spi_devs = wm5110_spi_devs, |
| 295 | .num_spi_devs = ARRAY_SIZE(wm5110_spi_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 296 | { .id = 0x08, .rev = 0xff, .name = "WM8903-6102 Tamdhu" }, |
| 297 | { .id = 0x09, .rev = 0xff, .name = "WM1811A-6305 Adelphi" }, |
| 298 | { .id = 0x0a, .rev = 0xff, .name = "WM8996-6272 Blackadder" }, |
| 299 | { .id = 0x0b, .rev = 0xff, .name = "WM8994-6235 Benromach" }, |
| 300 | { .id = 0x11, .rev = 0xff, .name = "6249-EV2 Glenfarclas", }, |
| 301 | { .id = 0x14, .rev = 0xff, .name = "6271-EV1 Lochnagar" }, |
| 302 | { .id = 0x15, .rev = 0xff, .name = "6320-EV1 Bells", |
Mark Brown | 98dcf90 | 2012-05-16 07:00:03 +0900 | [diff] [blame] | 303 | .i2c_devs = wm6230_i2c_devs, |
| 304 | .num_i2c_devs = ARRAY_SIZE(wm6230_i2c_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 305 | { .id = 0x21, .rev = 0xff, .name = "1275-EV1 Mortlach" }, |
| 306 | { .id = 0x25, .rev = 0xff, .name = "1274-EV1 Glencadam" }, |
| 307 | { .id = 0x31, .rev = 0xff, .name = "1253-EV1 Tomatin", |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 308 | .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 309 | { .id = 0x32, .rev = 0xff, .name = "XXXX-EV1 Caol Illa" }, |
| 310 | { .id = 0x33, .rev = 0xff, .name = "XXXX-EV1 Oban" }, |
| 311 | { .id = 0x34, .rev = 0xff, .name = "WM0010-6320-CS42 Balblair", |
Mark Brown | c8968ad | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 312 | .spi_devs = balblair_devs, |
| 313 | .num_spi_devs = ARRAY_SIZE(balblair_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 314 | { .id = 0x39, .rev = 0xff, .name = "1254-EV1 Dallas Dhu", |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 315 | .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 316 | { .id = 0x3a, .rev = 0xff, .name = "1259-EV1 Tobermory", |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 317 | .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 318 | { .id = 0x3b, .rev = 0xff, .name = "1255-EV1 Kilchoman", |
Mark Brown | 3aa7779 | 2011-09-05 14:48:39 +0900 | [diff] [blame] | 319 | .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 320 | { .id = 0x3c, .rev = 0xff, .name = "1273-EV1 Longmorn" }, |
| 321 | { .id = 0x3d, .rev = 0xff, .name = "1277-EV1 Littlemill", |
Mark Brown | c5c32c9 | 2011-12-02 14:32:32 +0900 | [diff] [blame] | 322 | .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) }, |
Mark Brown | b23bc66 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 323 | { .id = 0x3e, .rev = 0, .name = "WM5102-6271-EV1-CS127 Amrut", |
| 324 | .spi_devs = wm5102_reva_spi_devs, |
| 325 | .num_spi_devs = ARRAY_SIZE(wm5102_reva_spi_devs) }, |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 326 | { .id = 0x3e, .rev = -1, .name = "WM5102-6271-EV1-CS127 Amrut", |
Mark Brown | 853b1eb | 2012-08-10 13:03:16 +0900 | [diff] [blame] | 327 | .spi_devs = wm5102_spi_devs, |
| 328 | .num_spi_devs = ARRAY_SIZE(wm5102_spi_devs) }, |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 329 | }; |
| 330 | |
| 331 | static __devinit int wlf_gf_module_probe(struct i2c_client *i2c, |
| 332 | const struct i2c_device_id *i2c_id) |
| 333 | { |
| 334 | int ret, i, j, id, rev; |
| 335 | |
| 336 | ret = i2c_smbus_read_byte_data(i2c, 0); |
| 337 | if (ret < 0) { |
| 338 | dev_err(&i2c->dev, "Failed to read ID: %d\n", ret); |
| 339 | return ret; |
| 340 | } |
| 341 | |
| 342 | id = (ret & 0xfe) >> 2; |
| 343 | rev = ret & 0x3; |
| 344 | for (i = 0; i < ARRAY_SIZE(gf_mods); i++) |
Mark Brown | 64aecb4 | 2012-10-17 17:41:08 +0900 | [diff] [blame] | 345 | if (id == gf_mods[i].id && (gf_mods[i].rev == 0xff || |
| 346 | rev == gf_mods[i].rev)) |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 347 | break; |
| 348 | |
| 349 | if (i < ARRAY_SIZE(gf_mods)) { |
| 350 | dev_info(&i2c->dev, "%s revision %d\n", |
| 351 | gf_mods[i].name, rev + 1); |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 352 | |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 353 | for (j = 0; j < gf_mods[i].num_i2c_devs; j++) { |
| 354 | if (!i2c_new_device(i2c->adapter, |
| 355 | &(gf_mods[i].i2c_devs[j]))) |
| 356 | dev_err(&i2c->dev, |
| 357 | "Failed to register dev: %d\n", ret); |
| 358 | } |
Mark Brown | cda2349 | 2012-01-12 11:04:56 +0900 | [diff] [blame] | 359 | |
| 360 | spi_register_board_info(gf_mods[i].spi_devs, |
| 361 | gf_mods[i].num_spi_devs); |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 362 | } else { |
Mark Brown | fc71689 | 2011-12-02 14:29:08 +0900 | [diff] [blame] | 363 | dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n", |
| 364 | id, rev + 1); |
Mark Brown | d0f0b43 | 2011-08-19 22:40:07 +0900 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | static const struct i2c_device_id wlf_gf_module_id[] = { |
| 371 | { "wlf-gf-module", 0 }, |
| 372 | { } |
| 373 | }; |
| 374 | |
| 375 | static struct i2c_driver wlf_gf_module_driver = { |
| 376 | .driver = { |
| 377 | .name = "wlf-gf-module", |
| 378 | .owner = THIS_MODULE, |
| 379 | }, |
| 380 | .probe = wlf_gf_module_probe, |
| 381 | .id_table = wlf_gf_module_id, |
| 382 | }; |
| 383 | |
| 384 | static int __init wlf_gf_module_register(void) |
| 385 | { |
| 386 | return i2c_add_driver(&wlf_gf_module_driver); |
| 387 | } |
| 388 | module_init(wlf_gf_module_register); |