mx31lilly-db.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * LILLY-1131 development board support
  3. *
  4. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  5. *
  6. * based on code for other MX31 boards,
  7. *
  8. * Copyright 2005-2007 Freescale Semiconductor
  9. * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
  10. * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #include <linux/kernel.h>
  27. #include <linux/types.h>
  28. #include <linux/init.h>
  29. #include <linux/gpio.h>
  30. #include <linux/platform_device.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <mach/hardware.h>
  35. #include <mach/common.h>
  36. #include <mach/imx-uart.h>
  37. #include <mach/iomux-mx3.h>
  38. #include <mach/board-mx31lilly.h>
  39. #include <mach/mmc.h>
  40. #include <mach/mx3fb.h>
  41. #include <mach/ipu.h>
  42. #include "devices.h"
  43. /*
  44. * This file contains board-specific initialization routines for the
  45. * LILLY-1131 development board. If you design an own baseboard for the
  46. * module, use this file as base for support code.
  47. */
  48. static unsigned int lilly_db_board_pins[] __initdata = {
  49. MX31_PIN_CTS1__CTS1,
  50. MX31_PIN_RTS1__RTS1,
  51. MX31_PIN_TXD1__TXD1,
  52. MX31_PIN_RXD1__RXD1,
  53. MX31_PIN_CTS2__CTS2,
  54. MX31_PIN_RTS2__RTS2,
  55. MX31_PIN_TXD2__TXD2,
  56. MX31_PIN_RXD2__RXD2,
  57. MX31_PIN_CSPI3_MOSI__RXD3,
  58. MX31_PIN_CSPI3_MISO__TXD3,
  59. MX31_PIN_CSPI3_SCLK__RTS3,
  60. MX31_PIN_CSPI3_SPI_RDY__CTS3,
  61. MX31_PIN_SD1_DATA3__SD1_DATA3,
  62. MX31_PIN_SD1_DATA2__SD1_DATA2,
  63. MX31_PIN_SD1_DATA1__SD1_DATA1,
  64. MX31_PIN_SD1_DATA0__SD1_DATA0,
  65. MX31_PIN_SD1_CLK__SD1_CLK,
  66. MX31_PIN_SD1_CMD__SD1_CMD,
  67. MX31_PIN_LD0__LD0,
  68. MX31_PIN_LD1__LD1,
  69. MX31_PIN_LD2__LD2,
  70. MX31_PIN_LD3__LD3,
  71. MX31_PIN_LD4__LD4,
  72. MX31_PIN_LD5__LD5,
  73. MX31_PIN_LD6__LD6,
  74. MX31_PIN_LD7__LD7,
  75. MX31_PIN_LD8__LD8,
  76. MX31_PIN_LD9__LD9,
  77. MX31_PIN_LD10__LD10,
  78. MX31_PIN_LD11__LD11,
  79. MX31_PIN_LD12__LD12,
  80. MX31_PIN_LD13__LD13,
  81. MX31_PIN_LD14__LD14,
  82. MX31_PIN_LD15__LD15,
  83. MX31_PIN_LD16__LD16,
  84. MX31_PIN_LD17__LD17,
  85. MX31_PIN_VSYNC3__VSYNC3,
  86. MX31_PIN_HSYNC__HSYNC,
  87. MX31_PIN_FPSHIFT__FPSHIFT,
  88. MX31_PIN_DRDY0__DRDY0,
  89. MX31_PIN_CONTRAST__CONTRAST,
  90. };
  91. /* UART */
  92. static struct imxuart_platform_data uart_pdata __initdata = {
  93. .flags = IMXUART_HAVE_RTSCTS,
  94. };
  95. /* MMC support */
  96. static int mxc_mmc1_get_ro(struct device *dev)
  97. {
  98. return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_LCS0));
  99. }
  100. static int gpio_det, gpio_wp;
  101. #define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  102. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  103. static int mxc_mmc1_init(struct device *dev,
  104. irq_handler_t detect_irq, void *data)
  105. {
  106. int ret;
  107. gpio_det = IOMUX_TO_GPIO(MX31_PIN_GPIO1_1);
  108. gpio_wp = IOMUX_TO_GPIO(MX31_PIN_LCS0);
  109. mxc_iomux_set_pad(MX31_PIN_SD1_DATA0, MMC_PAD_CFG);
  110. mxc_iomux_set_pad(MX31_PIN_SD1_DATA1, MMC_PAD_CFG);
  111. mxc_iomux_set_pad(MX31_PIN_SD1_DATA2, MMC_PAD_CFG);
  112. mxc_iomux_set_pad(MX31_PIN_SD1_DATA3, MMC_PAD_CFG);
  113. mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG);
  114. mxc_iomux_set_pad(MX31_PIN_SD1_CMD, MMC_PAD_CFG);
  115. ret = gpio_request(gpio_det, "MMC detect");
  116. if (ret)
  117. return ret;
  118. ret = gpio_request(gpio_wp, "MMC w/p");
  119. if (ret)
  120. goto exit_free_det;
  121. gpio_direction_input(gpio_det);
  122. gpio_direction_input(gpio_wp);
  123. ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), detect_irq,
  124. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  125. "MMC detect", data);
  126. if (ret)
  127. goto exit_free_wp;
  128. return 0;
  129. exit_free_wp:
  130. gpio_free(gpio_wp);
  131. exit_free_det:
  132. gpio_free(gpio_det);
  133. return ret;
  134. }
  135. static void mxc_mmc1_exit(struct device *dev, void *data)
  136. {
  137. gpio_free(gpio_det);
  138. gpio_free(gpio_wp);
  139. free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), data);
  140. }
  141. static struct imxmmc_platform_data mmc_pdata = {
  142. .get_ro = mxc_mmc1_get_ro,
  143. .init = mxc_mmc1_init,
  144. .exit = mxc_mmc1_exit,
  145. };
  146. /* Framebuffer support */
  147. static struct ipu_platform_data ipu_data __initdata = {
  148. .irq_base = MXC_IPU_IRQ_START,
  149. };
  150. static const struct fb_videomode fb_modedb = {
  151. /* 640x480 TFT panel (IPS-056T) */
  152. .name = "CRT-VGA",
  153. .refresh = 64,
  154. .xres = 640,
  155. .yres = 480,
  156. .pixclock = 30000,
  157. .left_margin = 200,
  158. .right_margin = 2,
  159. .upper_margin = 2,
  160. .lower_margin = 2,
  161. .hsync_len = 3,
  162. .vsync_len = 1,
  163. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH,
  164. .vmode = FB_VMODE_NONINTERLACED,
  165. .flag = 0,
  166. };
  167. static struct mx3fb_platform_data fb_pdata __initdata = {
  168. .dma_dev = &mx3_ipu.dev,
  169. .name = "CRT-VGA",
  170. .mode = &fb_modedb,
  171. .num_modes = 1,
  172. };
  173. #define LCD_VCC_EN_GPIO (7)
  174. static void __init mx31lilly_init_fb(void)
  175. {
  176. if (gpio_request(LCD_VCC_EN_GPIO, "LCD enable") != 0) {
  177. printk(KERN_WARNING "unable to request LCD_VCC_EN pin.\n");
  178. return;
  179. }
  180. mxc_register_device(&mx3_ipu, &ipu_data);
  181. mxc_register_device(&mx3_fb, &fb_pdata);
  182. gpio_direction_output(LCD_VCC_EN_GPIO, 1);
  183. }
  184. void __init mx31lilly_db_init(void)
  185. {
  186. mxc_iomux_setup_multiple_pins(lilly_db_board_pins,
  187. ARRAY_SIZE(lilly_db_board_pins),
  188. "development board pins");
  189. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  190. mxc_register_device(&mxc_uart_device1, &uart_pdata);
  191. mxc_register_device(&mxc_uart_device2, &uart_pdata);
  192. mxc_register_device(&mxcsdhc_device0, &mmc_pdata);
  193. mx31lilly_init_fb();
  194. }