mach-pcm037_eet.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Copyright (C) 2009
  3. * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/gpio.h>
  10. #include <linux/input.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/spi/spi.h>
  13. #include <asm/mach-types.h>
  14. #include "pcm037.h"
  15. #include "common.h"
  16. #include "devices-imx31.h"
  17. #include "iomux-mx3.h"
  18. static unsigned int pcm037_eet_pins[] = {
  19. /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */
  20. IOMUX_MODE(MX31_PIN_KEY_COL7, IOMUX_CONFIG_GPIO),
  21. /* GPIO keys */
  22. IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO), /* 0 */
  23. IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO), /* 1 */
  24. IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO), /* 2 */
  25. IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO), /* 3 */
  26. IOMUX_MODE(MX31_PIN_SVEN0, IOMUX_CONFIG_GPIO), /* 32 */
  27. IOMUX_MODE(MX31_PIN_STX0, IOMUX_CONFIG_GPIO), /* 33 */
  28. IOMUX_MODE(MX31_PIN_SRX0, IOMUX_CONFIG_GPIO), /* 34 */
  29. IOMUX_MODE(MX31_PIN_SIMPD0, IOMUX_CONFIG_GPIO), /* 35 */
  30. IOMUX_MODE(MX31_PIN_RTS1, IOMUX_CONFIG_GPIO), /* 38 */
  31. IOMUX_MODE(MX31_PIN_CTS1, IOMUX_CONFIG_GPIO), /* 39 */
  32. IOMUX_MODE(MX31_PIN_KEY_ROW4, IOMUX_CONFIG_GPIO), /* 50 */
  33. IOMUX_MODE(MX31_PIN_KEY_ROW5, IOMUX_CONFIG_GPIO), /* 51 */
  34. IOMUX_MODE(MX31_PIN_KEY_ROW6, IOMUX_CONFIG_GPIO), /* 52 */
  35. IOMUX_MODE(MX31_PIN_KEY_ROW7, IOMUX_CONFIG_GPIO), /* 53 */
  36. /* LEDs */
  37. IOMUX_MODE(MX31_PIN_DTR_DTE1, IOMUX_CONFIG_GPIO), /* 44 */
  38. IOMUX_MODE(MX31_PIN_DSR_DTE1, IOMUX_CONFIG_GPIO), /* 45 */
  39. IOMUX_MODE(MX31_PIN_KEY_COL5, IOMUX_CONFIG_GPIO), /* 55 */
  40. IOMUX_MODE(MX31_PIN_KEY_COL6, IOMUX_CONFIG_GPIO), /* 56 */
  41. };
  42. /* SPI */
  43. static struct spi_board_info pcm037_spi_dev[] = {
  44. {
  45. .modalias = "dac124s085",
  46. .max_speed_hz = 400000,
  47. .bus_num = 0,
  48. .chip_select = 0, /* Index in pcm037_spi1_cs[] */
  49. .mode = SPI_CPHA,
  50. },
  51. };
  52. /* Platform Data for MXC CSPI */
  53. static int pcm037_spi1_cs[] = {MXC_SPI_CS(1), IOMUX_TO_GPIO(MX31_PIN_KEY_COL7)};
  54. static const struct spi_imx_master pcm037_spi1_pdata __initconst = {
  55. .chipselect = pcm037_spi1_cs,
  56. .num_chipselect = ARRAY_SIZE(pcm037_spi1_cs),
  57. };
  58. /* GPIO-keys input device */
  59. static struct gpio_keys_button pcm037_gpio_keys[] = {
  60. {
  61. .type = EV_KEY,
  62. .code = KEY_L,
  63. .gpio = 0,
  64. .desc = "Wheel Manual",
  65. .wakeup = 0,
  66. }, {
  67. .type = EV_KEY,
  68. .code = KEY_A,
  69. .gpio = 1,
  70. .desc = "Wheel AF",
  71. .wakeup = 0,
  72. }, {
  73. .type = EV_KEY,
  74. .code = KEY_V,
  75. .gpio = 2,
  76. .desc = "Wheel View",
  77. .wakeup = 0,
  78. }, {
  79. .type = EV_KEY,
  80. .code = KEY_M,
  81. .gpio = 3,
  82. .desc = "Wheel Menu",
  83. .wakeup = 0,
  84. }, {
  85. .type = EV_KEY,
  86. .code = KEY_UP,
  87. .gpio = 32,
  88. .desc = "Nav Pad Up",
  89. .wakeup = 0,
  90. }, {
  91. .type = EV_KEY,
  92. .code = KEY_RIGHT,
  93. .gpio = 33,
  94. .desc = "Nav Pad Right",
  95. .wakeup = 0,
  96. }, {
  97. .type = EV_KEY,
  98. .code = KEY_DOWN,
  99. .gpio = 34,
  100. .desc = "Nav Pad Down",
  101. .wakeup = 0,
  102. }, {
  103. .type = EV_KEY,
  104. .code = KEY_LEFT,
  105. .gpio = 35,
  106. .desc = "Nav Pad Left",
  107. .wakeup = 0,
  108. }, {
  109. .type = EV_KEY,
  110. .code = KEY_ENTER,
  111. .gpio = 38,
  112. .desc = "Nav Pad Ok",
  113. .wakeup = 0,
  114. }, {
  115. .type = EV_KEY,
  116. .code = KEY_O,
  117. .gpio = 39,
  118. .desc = "Wheel Off",
  119. .wakeup = 0,
  120. }, {
  121. .type = EV_KEY,
  122. .code = BTN_FORWARD,
  123. .gpio = 50,
  124. .desc = "Focus Forward",
  125. .wakeup = 0,
  126. }, {
  127. .type = EV_KEY,
  128. .code = BTN_BACK,
  129. .gpio = 51,
  130. .desc = "Focus Backward",
  131. .wakeup = 0,
  132. }, {
  133. .type = EV_KEY,
  134. .code = BTN_MIDDLE,
  135. .gpio = 52,
  136. .desc = "Release Half",
  137. .wakeup = 0,
  138. }, {
  139. .type = EV_KEY,
  140. .code = BTN_EXTRA,
  141. .gpio = 53,
  142. .desc = "Release Full",
  143. .wakeup = 0,
  144. },
  145. };
  146. static const struct gpio_keys_platform_data
  147. pcm037_gpio_keys_platform_data __initconst = {
  148. .buttons = pcm037_gpio_keys,
  149. .nbuttons = ARRAY_SIZE(pcm037_gpio_keys),
  150. .rep = 0, /* No auto-repeat */
  151. };
  152. int __init pcm037_eet_init_devices(void)
  153. {
  154. if (pcm037_variant() != PCM037_EET)
  155. return 0;
  156. mxc_iomux_setup_multiple_pins(pcm037_eet_pins,
  157. ARRAY_SIZE(pcm037_eet_pins), "pcm037_eet");
  158. /* SPI */
  159. spi_register_board_info(pcm037_spi_dev, ARRAY_SIZE(pcm037_spi_dev));
  160. imx31_add_spi_imx0(&pcm037_spi1_pdata);
  161. imx_add_gpio_keys(&pcm037_gpio_keys_platform_data);
  162. return 0;
  163. }