mach-crag6410-module.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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/mfd/wm831x/irq.h>
  14. #include <linux/mfd/wm831x/gpio.h>
  15. #include <sound/wm8996.h>
  16. #include <sound/wm8962.h>
  17. #include <sound/wm9081.h>
  18. #include <mach/crag6410.h>
  19. static struct wm8996_retune_mobile_config wm8996_retune[] = {
  20. {
  21. .name = "Sub LPF",
  22. .rate = 48000,
  23. .regs = {
  24. 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
  25. 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
  26. 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
  27. },
  28. },
  29. {
  30. .name = "Sub HPF",
  31. .rate = 48000,
  32. .regs = {
  33. 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000,
  34. 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000,
  35. 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000
  36. },
  37. },
  38. };
  39. static struct wm8996_pdata wm8996_pdata __initdata = {
  40. .ldo_ena = S3C64XX_GPN(7),
  41. .gpio_base = CODEC_GPIO_BASE,
  42. .micdet_def = 1,
  43. .inl_mode = WM8996_DIFFERRENTIAL_1,
  44. .inr_mode = WM8996_DIFFERRENTIAL_1,
  45. .irq_flags = IRQF_TRIGGER_RISING,
  46. .gpio_default = {
  47. 0x8001, /* GPIO1 == ADCLRCLK1 */
  48. 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */
  49. 0x0141, /* GPIO3 == HP_SEL */
  50. 0x0002, /* GPIO4 == IRQ */
  51. 0x020e, /* GPIO5 == CLKOUT */
  52. },
  53. .retune_mobile_cfgs = wm8996_retune,
  54. .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune),
  55. };
  56. static struct wm8962_pdata wm8962_pdata __initdata = {
  57. .gpio_init = {
  58. 0,
  59. WM8962_GPIO_FN_OPCLK,
  60. WM8962_GPIO_FN_DMICCLK,
  61. 0,
  62. 0x8000 | WM8962_GPIO_FN_DMICDAT,
  63. WM8962_GPIO_FN_IRQ, /* Open drain mode */
  64. },
  65. .irq_active_low = true,
  66. };
  67. static struct wm9081_pdata wm9081_pdata __initdata = {
  68. .irq_high = false,
  69. .irq_cmos = false,
  70. };
  71. static const struct i2c_board_info wm1254_devs[] = {
  72. { I2C_BOARD_INFO("wm8996", 0x1a),
  73. .platform_data = &wm8996_pdata,
  74. .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
  75. },
  76. { I2C_BOARD_INFO("wm9081", 0x6c),
  77. .platform_data = &wm9081_pdata, },
  78. };
  79. static const struct i2c_board_info wm1255_devs[] = {
  80. { I2C_BOARD_INFO("wm5100", 0x1a),
  81. .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
  82. },
  83. { I2C_BOARD_INFO("wm9081", 0x6c),
  84. .platform_data = &wm9081_pdata, },
  85. };
  86. static const struct i2c_board_info wm1259_devs[] = {
  87. { I2C_BOARD_INFO("wm8962", 0x1a),
  88. .platform_data = &wm8962_pdata,
  89. .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2,
  90. },
  91. };
  92. static __devinitdata const struct {
  93. u8 id;
  94. const char *name;
  95. const struct i2c_board_info *i2c_devs;
  96. int num_i2c_devs;
  97. } gf_mods[] = {
  98. { .id = 0x01, .name = "1250-EV1 Springbank" },
  99. { .id = 0x02, .name = "1251-EV1 Jura" },
  100. { .id = 0x03, .name = "1252-EV1 Glenlivet" },
  101. { .id = 0x11, .name = "6249-EV2 Glenfarclas", },
  102. { .id = 0x21, .name = "1275-EV1 Mortlach" },
  103. { .id = 0x25, .name = "1274-EV1 Glencadam" },
  104. { .id = 0x31, .name = "1253-EV1 Tomatin", },
  105. { .id = 0x39, .name = "1254-EV1 Dallas Dhu",
  106. .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) },
  107. { .id = 0x3a, .name = "1259-EV1 Tobermory",
  108. .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) },
  109. { .id = 0x3b, .name = "1255-EV1 Kilchoman",
  110. .i2c_devs = wm1255_devs, .num_i2c_devs = ARRAY_SIZE(wm1255_devs) },
  111. { .id = 0x3c, .name = "1273-EV1 Longmorn" },
  112. };
  113. static __devinit int wlf_gf_module_probe(struct i2c_client *i2c,
  114. const struct i2c_device_id *i2c_id)
  115. {
  116. int ret, i, j, id, rev;
  117. ret = i2c_smbus_read_byte_data(i2c, 0);
  118. if (ret < 0) {
  119. dev_err(&i2c->dev, "Failed to read ID: %d\n", ret);
  120. return ret;
  121. }
  122. id = (ret & 0xfe) >> 2;
  123. rev = ret & 0x3;
  124. for (i = 0; i < ARRAY_SIZE(gf_mods); i++)
  125. if (id == gf_mods[i].id)
  126. break;
  127. if (i < ARRAY_SIZE(gf_mods)) {
  128. dev_info(&i2c->dev, "%s revision %d\n",
  129. gf_mods[i].name, rev + 1);
  130. for (j = 0; j < gf_mods[i].num_i2c_devs; j++) {
  131. if (!i2c_new_device(i2c->adapter,
  132. &(gf_mods[i].i2c_devs[j])))
  133. dev_err(&i2c->dev,
  134. "Failed to register dev: %d\n", ret);
  135. }
  136. } else {
  137. dev_warn(&i2c->dev, "Unknown module ID %d revision %d\n",
  138. id, rev);
  139. }
  140. return 0;
  141. }
  142. static const struct i2c_device_id wlf_gf_module_id[] = {
  143. { "wlf-gf-module", 0 },
  144. { }
  145. };
  146. static struct i2c_driver wlf_gf_module_driver = {
  147. .driver = {
  148. .name = "wlf-gf-module",
  149. .owner = THIS_MODULE,
  150. },
  151. .probe = wlf_gf_module_probe,
  152. .id_table = wlf_gf_module_id,
  153. };
  154. static int __init wlf_gf_module_register(void)
  155. {
  156. return i2c_add_driver(&wlf_gf_module_driver);
  157. }
  158. module_init(wlf_gf_module_register);