eukrea_mbimx27-baseboard.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. * Copyright (C) 2009 Eric Benard - eric@eukrea.com
  3. *
  4. * Based on pcm970-baseboard.c which is :
  5. * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19. * MA 02110-1301, USA.
  20. */
  21. #include <linux/gpio.h>
  22. #include <linux/irq.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/ads7846.h>
  26. #include <asm/mach/arch.h>
  27. #include <mach/common.h>
  28. #include <mach/iomux.h>
  29. #include <mach/imxfb.h>
  30. #include <mach/hardware.h>
  31. #include <mach/mmc.h>
  32. #include <mach/imx-uart.h>
  33. #include "devices.h"
  34. static int eukrea_mbimx27_pins[] = {
  35. /* UART2 */
  36. PE3_PF_UART2_CTS,
  37. PE4_PF_UART2_RTS,
  38. PE6_PF_UART2_TXD,
  39. PE7_PF_UART2_RXD,
  40. /* UART3 */
  41. PE8_PF_UART3_TXD,
  42. PE9_PF_UART3_RXD,
  43. PE10_PF_UART3_CTS,
  44. PE11_PF_UART3_RTS,
  45. /* UART4 */
  46. PB26_AF_UART4_RTS,
  47. PB28_AF_UART4_TXD,
  48. PB29_AF_UART4_CTS,
  49. PB31_AF_UART4_RXD,
  50. /* SDHC1*/
  51. PE18_PF_SD1_D0,
  52. PE19_PF_SD1_D1,
  53. PE20_PF_SD1_D2,
  54. PE21_PF_SD1_D3,
  55. PE22_PF_SD1_CMD,
  56. PE23_PF_SD1_CLK,
  57. /* display */
  58. PA5_PF_LSCLK,
  59. PA6_PF_LD0,
  60. PA7_PF_LD1,
  61. PA8_PF_LD2,
  62. PA9_PF_LD3,
  63. PA10_PF_LD4,
  64. PA11_PF_LD5,
  65. PA12_PF_LD6,
  66. PA13_PF_LD7,
  67. PA14_PF_LD8,
  68. PA15_PF_LD9,
  69. PA16_PF_LD10,
  70. PA17_PF_LD11,
  71. PA18_PF_LD12,
  72. PA19_PF_LD13,
  73. PA20_PF_LD14,
  74. PA21_PF_LD15,
  75. PA22_PF_LD16,
  76. PA23_PF_LD17,
  77. PA28_PF_HSYNC,
  78. PA29_PF_VSYNC,
  79. PA30_PF_CONTRAST,
  80. PA31_PF_OE_ACD,
  81. /* SPI1 */
  82. PD28_PF_CSPI1_SS0,
  83. PD29_PF_CSPI1_SCLK,
  84. PD30_PF_CSPI1_MISO,
  85. PD31_PF_CSPI1_MOSI,
  86. };
  87. static struct gpio_led gpio_leds[] = {
  88. {
  89. .name = "led1",
  90. .default_trigger = "heartbeat",
  91. .active_low = 1,
  92. .gpio = GPIO_PORTF | 16,
  93. },
  94. {
  95. .name = "led2",
  96. .default_trigger = "none",
  97. .active_low = 1,
  98. .gpio = GPIO_PORTF | 19,
  99. },
  100. {
  101. .name = "backlight",
  102. .default_trigger = "backlight",
  103. .active_low = 0,
  104. .gpio = GPIO_PORTE | 5,
  105. },
  106. };
  107. static struct gpio_led_platform_data gpio_led_info = {
  108. .leds = gpio_leds,
  109. .num_leds = ARRAY_SIZE(gpio_leds),
  110. };
  111. static struct platform_device leds_gpio = {
  112. .name = "leds-gpio",
  113. .id = -1,
  114. .dev = {
  115. .platform_data = &gpio_led_info,
  116. },
  117. };
  118. static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
  119. {
  120. .mode = {
  121. .name = "CMO-QGVA",
  122. .refresh = 60,
  123. .xres = 320,
  124. .yres = 240,
  125. .pixclock = 156000,
  126. .hsync_len = 30,
  127. .left_margin = 38,
  128. .right_margin = 20,
  129. .vsync_len = 3,
  130. .upper_margin = 15,
  131. .lower_margin = 4,
  132. },
  133. .pcr = 0xFAD08B80,
  134. .bpp = 16,
  135. },
  136. };
  137. static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
  138. .mode = eukrea_mbimx27_modes,
  139. .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
  140. .pwmr = 0x00A903FF,
  141. .lscr1 = 0x00120300,
  142. .dmacr = 0x00040060,
  143. };
  144. static struct imxuart_platform_data uart_pdata[] = {
  145. {
  146. .flags = IMXUART_HAVE_RTSCTS,
  147. },
  148. {
  149. .flags = IMXUART_HAVE_RTSCTS,
  150. },
  151. };
  152. #if defined(CONFIG_TOUCHSCREEN_ADS7846)
  153. || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  154. #define ADS7846_PENDOWN (GPIO_PORTD | 25)
  155. static void ads7846_dev_init(void)
  156. {
  157. if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
  158. printk(KERN_ERR "can't get ads746 pen down GPIO\n");
  159. return;
  160. }
  161. gpio_direction_input(ADS7846_PENDOWN);
  162. }
  163. static int ads7846_get_pendown_state(void)
  164. {
  165. return !gpio_get_value(ADS7846_PENDOWN);
  166. }
  167. static struct ads7846_platform_data ads7846_config __initdata = {
  168. .get_pendown_state = ads7846_get_pendown_state,
  169. .keep_vref_on = 1,
  170. };
  171. static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
  172. [0] = {
  173. .modalias = "ads7846",
  174. .bus_num = 0,
  175. .chip_select = 0,
  176. .max_speed_hz = 1500000,
  177. .irq = IRQ_GPIOD(25),
  178. .platform_data = &ads7846_config,
  179. .mode = SPI_MODE_2,
  180. },
  181. };
  182. static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
  183. static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
  184. .chipselect = eukrea_mbimx27_spi_cs,
  185. .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
  186. };
  187. #endif
  188. static struct platform_device *platform_devices[] __initdata = {
  189. &leds_gpio,
  190. };
  191. /*
  192. * system init for baseboard usage. Will be called by cpuimx27 init.
  193. *
  194. * Add platform devices present on this baseboard and init
  195. * them from CPU side as far as required to use them later on
  196. */
  197. void __init eukrea_mbimx27_baseboard_init(void)
  198. {
  199. mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
  200. ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
  201. mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
  202. mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
  203. mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
  204. mxc_register_device(&mxc_sdhc_device0, NULL);
  205. #if defined(CONFIG_TOUCHSCREEN_ADS7846)
  206. || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  207. /* SPI and ADS7846 Touchscreen controler init */
  208. mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
  209. mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
  210. mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
  211. spi_register_board_info(eukrea_mbimx27_spi_board_info,
  212. ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
  213. ads7846_dev_init();
  214. #endif
  215. /* Leds configuration */
  216. mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
  217. mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
  218. /* Backlight */
  219. mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
  220. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  221. }