mach-crag6410-module.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. #include <linux/export.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/i2c.h>
  13. #include <linux/spi/spi.h>
  14. #include <linux/mfd/wm831x/irq.h>
  15. #include <linux/mfd/wm831x/gpio.h>
  16. #include <linux/mfd/wm8994/pdata.h>
  17. #include <linux/mfd/arizona/pdata.h>
  18. #include <linux/regulator/machine.h>
  19. #include <sound/wm0010.h>
  20. #include <sound/wm2200.h>
  21. #include <sound/wm5100.h>
  22. #include <sound/wm8996.h>
  23. #include <sound/wm8962.h>
  24. #include <sound/wm9081.h>
  25. #include <linux/platform_data/spi-s3c64xx.h>
  26. #include <plat/cpu.h>
  27. #include <mach/irqs.h>
  28. #include "crag6410.h"
  29. static struct s3c64xx_spi_csinfo wm0010_spi_csinfo = {
  30. .line = S3C64XX_GPC(3),
  31. };
  32. static struct wm0010_pdata wm0010_pdata = {
  33. .gpio_reset = S3C64XX_GPN(6),
  34. .reset_active_high = 1, /* Active high for Glenfarclas Rev 2 */
  35. };
  36. static struct spi_board_info wm1253_devs[] = {
  37. [0] = {
  38. .modalias = "wm0010",
  39. .max_speed_hz = 26 * 1000 * 1000,
  40. .bus_num = 0,
  41. .chip_select = 0,
  42. .mode = SPI_MODE_0,
  43. .irq = S3C_EINT(4),
  44. .controller_data = &wm0010_spi_csinfo,
  45. .platform_data = &wm0010_pdata,
  46. },
  47. };
  48. static struct spi_board_info balblair_devs[] = {
  49. [0] = {
  50. .modalias = "wm0010",
  51. .max_speed_hz = 26 * 1000 * 1000,
  52. .bus_num = 0,
  53. .chip_select = 0,
  54. .mode = SPI_MODE_0,
  55. .irq = S3C_EINT(4),
  56. .controller_data = &wm0010_spi_csinfo,
  57. .platform_data = &wm0010_pdata,
  58. },
  59. };
  60. static struct wm5100_pdata wm5100_pdata = {
  61. .ldo_ena = S3C64XX_GPN(7),
  62. .irq_flags = IRQF_TRIGGER_HIGH,
  63. .gpio_base = CODEC_GPIO_BASE,
  64. .in_mode = {
  65. WM5100_IN_DIFF,
  66. WM5100_IN_DIFF,
  67. WM5100_IN_DIFF,
  68. WM5100_IN_SE,
  69. },
  70. .hp_pol = CODEC_GPIO_BASE + 3,
  71. .jack_modes = {
  72. { WM5100_MICDET_MICBIAS3, 0, 0 },
  73. { WM5100_MICDET_MICBIAS2, 1, 1 },
  74. },
  75. .gpio_defaults = {
  76. 0,
  77. 0,
  78. 0,
  79. 0,
  80. 0x2, /* IRQ: CMOS output */
  81. 0x3, /* CLKOUT: CMOS output */
  82. },
  83. };
  84. static struct wm8996_retune_mobile_config wm8996_retune[] = {
  85. {
  86. .name = "Sub LPF",
  87. .rate = 48000,
  88. .regs = {
  89. 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
  90. 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
  91. 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
  92. },
  93. },
  94. {
  95. .name = "Sub HPF",
  96. .rate = 48000,
  97. .regs = {
  98. 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
  99. 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
  100. 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
  101. },
  102. },
  103. };
  104. static struct wm8996_pdata wm8996_pdata __initdata = {
  105. .ldo_ena = S3C64XX_GPN(7),
  106. .gpio_base = CODEC_GPIO_BASE,
  107. .micdet_def = 1,
  108. .inl_mode = WM8996_DIFFERRENTIAL_1,
  109. .inr_mode = WM8996_DIFFERRENTIAL_1,
  110. .irq_flags = IRQF_TRIGGER_RISING,
  111. .gpio_default = {
  112. 0x8001, /* GPIO1 == ADCLRCLK1 */
  113. 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */
  114. 0x0141, /* GPIO3 == HP_SEL */
  115. 0x0002, /* GPIO4 == IRQ */
  116. 0x020e, /* GPIO5 == CLKOUT */
  117. },
  118. .retune_mobile_cfgs = wm8996_retune,
  119. .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune),
  120. };
  121. static struct wm8962_pdata wm8962_pdata __initdata = {
  122. .gpio_init = {
  123. 0,
  124. WM8962_GPIO_FN_OPCLK,
  125. WM8962_GPIO_FN_DMICCLK,
  126. 0,
  127. 0x8000 | WM8962_GPIO_FN_DMICDAT,
  128. WM8962_GPIO_FN_IRQ, /* Open drain mode */
  129. },
  130. .in4_dc_measure = true,
  131. };
  132. static struct wm9081_pdata wm9081_pdata __initdata = {
  133. .irq_high = false,
  134. .irq_cmos = false,
  135. };
  136. static const struct i2c_board_info wm1254_devs[] = {
  137. { I2C_BOARD_INFO("wm8996", 0x1a),
  138. .platform_data = &wm8996_pdata,
  139. .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
  140. },
  141. { I2C_BOARD_INFO("wm9081", 0x6c),
  142. .platform_data = &wm9081_pdata, },
  143. };
  144. static const struct i2c_board_info wm1255_devs[] = {
  145. { I2C_BOARD_INFO("wm5100", 0x1a),
  146. .platform_data = &wm5100_pdata,
  147. .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
  148. },
  149. { I2C_BOARD_INFO("wm9081", 0x6c),
  150. .platform_data = &wm9081_pdata, },
  151. };
  152. static const struct i2c_board_info wm1259_devs[] = {
  153. { I2C_BOARD_INFO("wm8962", 0x1a),
  154. .platform_data = &wm8962_pdata,
  155. .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
  156. },
  157. };
  158. static struct regulator_init_data wm8994_ldo1 = {
  159. .supply_regulator = "WALLVDD",
  160. };
  161. static struct regulator_init_data wm8994_ldo2 = {
  162. .supply_regulator = "WALLVDD",
  163. };
  164. static struct wm8994_pdata wm8994_pdata = {
  165. .gpio_base = CODEC_GPIO_BASE,
  166. .micb2_delay = 150,
  167. .gpio_defaults = {
  168. 0x3, /* IRQ out, active high, CMOS */
  169. },
  170. .ldo = {
  171. { .enable = S3C64XX_GPN(6), .init_data = &wm8994_ldo1, },
  172. { .enable = S3C64XX_GPN(4), .init_data = &wm8994_ldo2, },
  173. },
  174. };
  175. static const struct i2c_board_info wm1277_devs[] = {
  176. { I2C_BOARD_INFO("wm8958", 0x1a), /* WM8958 is the superset */
  177. .platform_data = &wm8994_pdata,
  178. .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
  179. },
  180. };
  181. static struct arizona_pdata wm5102_reva_pdata = {
  182. .ldoena = S3C64XX_GPN(7),
  183. .gpio_base = CODEC_GPIO_BASE,
  184. .irq_flags = IRQF_TRIGGER_HIGH,
  185. .micd_pol_gpio = CODEC_GPIO_BASE + 4,
  186. .micd_rate = 6,
  187. .gpio_defaults = {
  188. [2] = 0x10000, /* AIF3TXLRCLK */
  189. [3] = 0x4, /* OPCLK */
  190. },
  191. };
  192. static struct s3c64xx_spi_csinfo codec_spi_csinfo = {
  193. .line = S3C64XX_GPN(5),
  194. };
  195. static struct spi_board_info wm5102_reva_spi_devs[] = {
  196. [0] = {
  197. .modalias = "wm5102",
  198. .max_speed_hz = 10 * 1000 * 1000,
  199. .bus_num = 0,
  200. .chip_select = 1,
  201. .mode = SPI_MODE_0,
  202. .irq = GLENFARCLAS_PMIC_IRQ_BASE +
  203. WM831X_IRQ_GPIO_2,
  204. .controller_data = &codec_spi_csinfo,
  205. .platform_data = &wm5102_reva_pdata,
  206. },
  207. };
  208. static struct arizona_pdata wm5102_pdata = {
  209. .ldoena = S3C64XX_GPN(7),
  210. .gpio_base = CODEC_GPIO_BASE,
  211. .irq_flags = IRQF_TRIGGER_HIGH,
  212. .micd_pol_gpio = CODEC_GPIO_BASE + 2,
  213. .gpio_defaults = {
  214. [2] = 0x10000, /* AIF3TXLRCLK */
  215. [3] = 0x4, /* OPCLK */
  216. },
  217. };
  218. static struct spi_board_info wm5102_spi_devs[] = {
  219. [0] = {
  220. .modalias = "wm5102",
  221. .max_speed_hz = 10 * 1000 * 1000,
  222. .bus_num = 0,
  223. .chip_select = 1,
  224. .mode = SPI_MODE_0,
  225. .irq = GLENFARCLAS_PMIC_IRQ_BASE +
  226. WM831X_IRQ_GPIO_2,
  227. .controller_data = &codec_spi_csinfo,
  228. .platform_data = &wm5102_pdata,
  229. },
  230. };
  231. static struct spi_board_info wm5110_spi_devs[] = {
  232. [0] = {
  233. .modalias = "wm5110",
  234. .max_speed_hz = 10 * 1000 * 1000,
  235. .bus_num = 0,
  236. .chip_select = 1,
  237. .mode = SPI_MODE_0,
  238. .irq = GLENFARCLAS_PMIC_IRQ_BASE +
  239. WM831X_IRQ_GPIO_2,
  240. .controller_data = &codec_spi_csinfo,
  241. .platform_data = &wm5102_reva_pdata,
  242. },
  243. };
  244. static const struct i2c_board_info wm6230_i2c_devs[] = {
  245. { I2C_BOARD_INFO("wm9081", 0x6c),
  246. .platform_data = &wm9081_pdata, },
  247. };
  248. static struct wm2200_pdata wm2200_pdata = {
  249. .ldo_ena = S3C64XX_GPN(7),
  250. .gpio_defaults = {
  251. [2] = 0x0005, /* GPIO3 24.576MHz output clock */
  252. },
  253. };
  254. static const struct i2c_board_info wm2200_i2c[] = {
  255. { I2C_BOARD_INFO("wm2200", 0x3a),
  256. .platform_data = &wm2200_pdata, },
  257. };
  258. static const struct {
  259. u8 id;
  260. u8 rev;
  261. const char *name;
  262. const struct i2c_board_info *i2c_devs;
  263. int num_i2c_devs;
  264. const struct spi_board_info *spi_devs;
  265. int num_spi_devs;
  266. } gf_mods[] = {
  267. { .id = 0x01, .rev = 0xff, .name = "1250-EV1 Springbank" },
  268. { .id = 0x02, .rev = 0xff, .name = "1251-EV1 Jura" },
  269. { .id = 0x03, .rev = 0xff, .name = "1252-EV1 Glenlivet" },
  270. { .id = 0x06, .rev = 0xff, .name = "WM8997-6721-CS96-EV1 Lapraoig" },
  271. { .id = 0x07, .rev = 0xff, .name = "WM5110-6271 Deanston",
  272. .spi_devs = wm5110_spi_devs,
  273. .num_spi_devs = ARRAY_SIZE(wm5110_spi_devs) },
  274. { .id = 0x08, .rev = 0xff, .name = "WM8903-6102 Tamdhu" },
  275. { .id = 0x09, .rev = 0xff, .name = "WM1811A-6305 Adelphi" },
  276. { .id = 0x0a, .rev = 0xff, .name = "WM8996-6272 Blackadder" },
  277. { .id = 0x0b, .rev = 0xff, .name = "WM8994-6235 Benromach" },
  278. { .id = 0x11, .rev = 0xff, .name = "6249-EV2 Glenfarclas", },
  279. { .id = 0x14, .rev = 0xff, .name = "6271-EV1 Lochnagar" },
  280. { .id = 0x15, .rev = 0xff, .name = "6320-EV1 Bells",
  281. .i2c_devs = wm6230_i2c_devs,
  282. .num_i2c_devs = ARRAY_SIZE(wm6230_i2c_devs) },
  283. { .id = 0x21, .rev = 0xff, .name = "1275-EV1 Mortlach" },
  284. { .id = 0x25, .rev = 0xff, .name = "1274-EV1 Glencadam" },
  285. { .id = 0x31, .rev = 0xff, .name = "1253-EV1 Tomatin",
  286. .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) },
  287. { .id = 0x32, .rev = 0xff, .name = "XXXX-EV1 Caol Illa" },
  288. { .id = 0x33, .rev = 0xff, .name = "XXXX-EV1 Oban" },
  289. { .id = 0x34, .rev = 0xff, .name = "WM0010-6320-CS42 Balblair",
  290. .spi_devs = balblair_devs,
  291. .num_spi_devs = ARRAY_SIZE(balblair_devs) },
  292. { .id = 0x39, .rev = 0xff, .name = "1254-EV1 Dallas Dhu",
  293. .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) },
  294. { .id = 0x3a, .rev = 0xff, .name = "1259-EV1 Tobermory",
  295. .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) },
  296. { .id = 0x3b, .rev = 0xff, .name = "1255-EV1 Kilchoman",
  297. .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) },
  298. { .id = 0x3c, .rev = 0xff, .name = "1273-EV1 Longmorn" },
  299. { .id = 0x3d, .rev = 0xff, .name = "1277-EV1 Littlemill",
  300. .i2c_devs = wm1277_devs, .num_i2c_devs = ARRAY_SIZE(wm1277_devs) },
  301. { .id = 0x3e, .rev = 0, .name = "WM5102-6271-EV1-CS127 Amrut",
  302. .spi_devs = wm5102_reva_spi_devs,
  303. .num_spi_devs = ARRAY_SIZE(wm5102_reva_spi_devs) },
  304. { .id = 0x3e, .rev = -1, .name = "WM5102-6271-EV1-CS127 Amrut",
  305. .spi_devs = wm5102_spi_devs,
  306. .num_spi_devs = ARRAY_SIZE(wm5102_spi_devs) },
  307. { .id = 0x3f, .rev = -1, .name = "WM2200-6271-CS90-M-REV1",
  308. .i2c_devs = wm2200_i2c, .num_i2c_devs = ARRAY_SIZE(wm2200_i2c) },
  309. };
  310. static int wlf_gf_module_probe(struct i2c_client *i2c,
  311. const struct i2c_device_id *i2c_id)
  312. {
  313. int ret, i, j, id, rev;
  314. ret = i2c_smbus_read_byte_data(i2c, 0);
  315. if (ret < 0) {
  316. dev_err(&i2c->dev, "Failed to read ID: %d\n", ret);
  317. return ret;
  318. }
  319. id = (ret & 0xfe) >> 2;
  320. rev = ret & 0x3;
  321. for (i = 0; i < ARRAY_SIZE(gf_mods); i++)
  322. if (id == gf_mods[i].id && (gf_mods[i].rev == 0xff ||
  323. rev == gf_mods[i].rev))
  324. break;
  325. if (i < ARRAY_SIZE(gf_mods)) {
  326. dev_info(&i2c->dev, "%s revision %d\n",
  327. gf_mods[i].name, rev + 1);
  328. for (j = 0; j < gf_mods[i].num_i2c_devs; j++) {
  329. if (!i2c_new_device(i2c->adapter,
  330. &(gf_mods[i].i2c_devs[j])))
  331. dev_err(&i2c->dev,
  332. "Failed to register dev: %d\n", ret);
  333. }
  334. spi_register_board_info(gf_mods[i].spi_devs,
  335. gf_mods[i].num_spi_devs);
  336. } else {
  337. dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n",
  338. id, rev + 1);
  339. }
  340. return 0;
  341. }
  342. static const struct i2c_device_id wlf_gf_module_id[] = {
  343. { "wlf-gf-module", 0 },
  344. { }
  345. };
  346. static struct i2c_driver wlf_gf_module_driver = {
  347. .driver = {
  348. .name = "wlf-gf-module"
  349. },
  350. .probe = wlf_gf_module_probe,
  351. .id_table = wlf_gf_module_id,
  352. };
  353. static int __init wlf_gf_module_register(void)
  354. {
  355. if (!soc_is_s3c64xx())
  356. return 0;
  357. return i2c_add_driver(&wlf_gf_module_driver);
  358. }
  359. device_initcall(wlf_gf_module_register);