eukrea_mbimx51-baseboard.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. *
  3. * Copyright (C) 2010 Eric Bénard <eric@eukrea.com>
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/serial_8250.h>
  15. #include <linux/i2c.h>
  16. #include <linux/gpio.h>
  17. #include <linux/io.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/irq.h>
  20. #include <linux/fsl_devices.h>
  21. #include <linux/i2c/tsc2007.h>
  22. #include <linux/leds.h>
  23. #include <linux/input/matrix_keypad.h>
  24. #include <mach/common.h>
  25. #include <mach/hardware.h>
  26. #include <mach/imx-uart.h>
  27. #include <mach/iomux-mx51.h>
  28. #include <asm/mach/arch.h>
  29. #include "devices.h"
  30. #define MBIMX51_TSC2007_GPIO (2*32 + 30)
  31. #define MBIMX51_TSC2007_IRQ (MXC_INTERNAL_IRQS + MBIMX51_TSC2007_GPIO)
  32. #define MBIMX51_LED0 (2*32 + 5)
  33. #define MBIMX51_LED1 (2*32 + 6)
  34. #define MBIMX51_LED2 (2*32 + 7)
  35. #define MBIMX51_LED3 (2*32 + 8)
  36. static struct gpio_led mbimx51_leds[] = {
  37. {
  38. .name = "led0",
  39. .default_trigger = "heartbeat",
  40. .active_low = 1,
  41. .gpio = MBIMX51_LED0,
  42. },
  43. {
  44. .name = "led1",
  45. .default_trigger = "nand-disk",
  46. .active_low = 1,
  47. .gpio = MBIMX51_LED1,
  48. },
  49. {
  50. .name = "led2",
  51. .default_trigger = "mmc0",
  52. .active_low = 1,
  53. .gpio = MBIMX51_LED2,
  54. },
  55. {
  56. .name = "led3",
  57. .default_trigger = "default-on",
  58. .active_low = 1,
  59. .gpio = MBIMX51_LED3,
  60. },
  61. };
  62. static struct gpio_led_platform_data mbimx51_leds_info = {
  63. .leds = mbimx51_leds,
  64. .num_leds = ARRAY_SIZE(mbimx51_leds),
  65. };
  66. static struct platform_device mbimx51_leds_gpio = {
  67. .name = "leds-gpio",
  68. .id = -1,
  69. .dev = {
  70. .platform_data = &mbimx51_leds_info,
  71. },
  72. };
  73. static struct platform_device *devices[] __initdata = {
  74. &mbimx51_leds_gpio,
  75. };
  76. static struct pad_desc mbimx51_pads[] = {
  77. /* UART2 */
  78. MX51_PAD_UART2_RXD__UART2_RXD,
  79. MX51_PAD_UART2_TXD__UART2_TXD,
  80. /* UART3 */
  81. MX51_PAD_UART3_RXD__UART3_RXD,
  82. MX51_PAD_UART3_TXD__UART3_TXD,
  83. MX51_PAD_KEY_COL4__UART3_RTS,
  84. MX51_PAD_KEY_COL5__UART3_CTS,
  85. /* TSC2007 IRQ */
  86. MX51_PAD_NANDF_D10__GPIO_3_30,
  87. /* LEDS */
  88. MX51_PAD_DISPB2_SER_DIN__GPIO_3_5,
  89. MX51_PAD_DISPB2_SER_DIO__GPIO_3_6,
  90. MX51_PAD_DISPB2_SER_CLK__GPIO_3_7,
  91. MX51_PAD_DISPB2_SER_RS__GPIO_3_8,
  92. /* KPP */
  93. MX51_PAD_KEY_ROW0__KEY_ROW0,
  94. MX51_PAD_KEY_ROW1__KEY_ROW1,
  95. MX51_PAD_KEY_ROW2__KEY_ROW2,
  96. MX51_PAD_KEY_ROW3__KEY_ROW3,
  97. MX51_PAD_KEY_COL0__KEY_COL0,
  98. MX51_PAD_KEY_COL1__KEY_COL1,
  99. MX51_PAD_KEY_COL2__KEY_COL2,
  100. MX51_PAD_KEY_COL3__KEY_COL3,
  101. };
  102. static struct imxuart_platform_data uart_pdata = {
  103. .flags = IMXUART_HAVE_RTSCTS,
  104. };
  105. static int mbimx51_keymap[] = {
  106. KEY(0, 0, KEY_1),
  107. KEY(0, 1, KEY_2),
  108. KEY(0, 2, KEY_3),
  109. KEY(0, 3, KEY_UP),
  110. KEY(1, 0, KEY_4),
  111. KEY(1, 1, KEY_5),
  112. KEY(1, 2, KEY_6),
  113. KEY(1, 3, KEY_LEFT),
  114. KEY(2, 0, KEY_7),
  115. KEY(2, 1, KEY_8),
  116. KEY(2, 2, KEY_9),
  117. KEY(2, 3, KEY_RIGHT),
  118. KEY(3, 0, KEY_0),
  119. KEY(3, 1, KEY_DOWN),
  120. KEY(3, 2, KEY_ESC),
  121. KEY(3, 3, KEY_ENTER),
  122. };
  123. static struct matrix_keymap_data mbimx51_map_data = {
  124. .keymap = mbimx51_keymap,
  125. .keymap_size = ARRAY_SIZE(mbimx51_keymap),
  126. };
  127. static int tsc2007_get_pendown_state(void)
  128. {
  129. return !gpio_get_value(MBIMX51_TSC2007_GPIO);
  130. }
  131. struct tsc2007_platform_data tsc2007_data = {
  132. .model = 2007,
  133. .x_plate_ohms = 180,
  134. .get_pendown_state = tsc2007_get_pendown_state,
  135. };
  136. static struct i2c_board_info mbimx51_i2c_devices[] = {
  137. {
  138. I2C_BOARD_INFO("tsc2007", 0x48),
  139. .irq = MBIMX51_TSC2007_IRQ,
  140. .platform_data = &tsc2007_data,
  141. },
  142. };
  143. /*
  144. * baseboard initialization.
  145. */
  146. void __init eukrea_mbimx51_baseboard_init(void)
  147. {
  148. mxc_iomux_v3_setup_multiple_pads(mbimx51_pads,
  149. ARRAY_SIZE(mbimx51_pads));
  150. mxc_register_device(&mxc_uart_device1, NULL);
  151. mxc_register_device(&mxc_uart_device2, &uart_pdata);
  152. gpio_request(MBIMX51_LED0, "LED0");
  153. gpio_direction_output(MBIMX51_LED0, 1);
  154. gpio_free(MBIMX51_LED0);
  155. gpio_request(MBIMX51_LED1, "LED1");
  156. gpio_direction_output(MBIMX51_LED1, 1);
  157. gpio_free(MBIMX51_LED1);
  158. gpio_request(MBIMX51_LED2, "LED2");
  159. gpio_direction_output(MBIMX51_LED2, 1);
  160. gpio_free(MBIMX51_LED2);
  161. gpio_request(MBIMX51_LED3, "LED3");
  162. gpio_direction_output(MBIMX51_LED3, 1);
  163. gpio_free(MBIMX51_LED3);
  164. platform_add_devices(devices, ARRAY_SIZE(devices));
  165. mxc_register_device(&mxc_keypad_device, &mbimx51_map_data);
  166. gpio_request(MBIMX51_TSC2007_GPIO, "tsc2007_irq");
  167. gpio_direction_input(MBIMX51_TSC2007_GPIO);
  168. set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING);
  169. i2c_register_board_info(1, mbimx51_i2c_devices,
  170. ARRAY_SIZE(mbimx51_i2c_devices));
  171. }