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