mx31lilly-db.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. #include <linux/kernel.h>
  23. #include <linux/types.h>
  24. #include <linux/init.h>
  25. #include <linux/gpio.h>
  26. #include <linux/platform_device.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include "board-mx31lilly.h"
  31. #include "common.h"
  32. #include "devices-imx31.h"
  33. #include "hardware.h"
  34. #include "iomux-mx3.h"
  35. /*
  36. * This file contains board-specific initialization routines for the
  37. * LILLY-1131 development board. If you design an own baseboard for the
  38. * module, use this file as base for support code.
  39. */
  40. static unsigned int lilly_db_board_pins[] __initdata = {
  41. MX31_PIN_SD1_DATA3__SD1_DATA3,
  42. MX31_PIN_SD1_DATA2__SD1_DATA2,
  43. MX31_PIN_SD1_DATA1__SD1_DATA1,
  44. MX31_PIN_SD1_DATA0__SD1_DATA0,
  45. MX31_PIN_SD1_CLK__SD1_CLK,
  46. MX31_PIN_SD1_CMD__SD1_CMD,
  47. MX31_PIN_LD0__LD0,
  48. MX31_PIN_LD1__LD1,
  49. MX31_PIN_LD2__LD2,
  50. MX31_PIN_LD3__LD3,
  51. MX31_PIN_LD4__LD4,
  52. MX31_PIN_LD5__LD5,
  53. MX31_PIN_LD6__LD6,
  54. MX31_PIN_LD7__LD7,
  55. MX31_PIN_LD8__LD8,
  56. MX31_PIN_LD9__LD9,
  57. MX31_PIN_LD10__LD10,
  58. MX31_PIN_LD11__LD11,
  59. MX31_PIN_LD12__LD12,
  60. MX31_PIN_LD13__LD13,
  61. MX31_PIN_LD14__LD14,
  62. MX31_PIN_LD15__LD15,
  63. MX31_PIN_LD16__LD16,
  64. MX31_PIN_LD17__LD17,
  65. MX31_PIN_VSYNC3__VSYNC3,
  66. MX31_PIN_HSYNC__HSYNC,
  67. MX31_PIN_FPSHIFT__FPSHIFT,
  68. MX31_PIN_DRDY0__DRDY0,
  69. MX31_PIN_CONTRAST__CONTRAST,
  70. };
  71. /* MMC support */
  72. static int mxc_mmc1_get_ro(struct device *dev)
  73. {
  74. return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_LCS0));
  75. }
  76. static int gpio_det, gpio_wp;
  77. #define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
  78. PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
  79. static int mxc_mmc1_init(struct device *dev,
  80. irq_handler_t detect_irq, void *data)
  81. {
  82. int ret;
  83. gpio_det = IOMUX_TO_GPIO(MX31_PIN_GPIO1_1);
  84. gpio_wp = IOMUX_TO_GPIO(MX31_PIN_LCS0);
  85. mxc_iomux_set_pad(MX31_PIN_SD1_DATA0, MMC_PAD_CFG);
  86. mxc_iomux_set_pad(MX31_PIN_SD1_DATA1, MMC_PAD_CFG);
  87. mxc_iomux_set_pad(MX31_PIN_SD1_DATA2, MMC_PAD_CFG);
  88. mxc_iomux_set_pad(MX31_PIN_SD1_DATA3, MMC_PAD_CFG);
  89. mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG);
  90. mxc_iomux_set_pad(MX31_PIN_SD1_CMD, MMC_PAD_CFG);
  91. ret = gpio_request(gpio_det, "MMC detect");
  92. if (ret)
  93. return ret;
  94. ret = gpio_request(gpio_wp, "MMC w/p");
  95. if (ret)
  96. goto exit_free_det;
  97. gpio_direction_input(gpio_det);
  98. gpio_direction_input(gpio_wp);
  99. ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)),
  100. detect_irq, IRQF_TRIGGER_FALLING,
  101. "MMC detect", data);
  102. if (ret)
  103. goto exit_free_wp;
  104. return 0;
  105. exit_free_wp:
  106. gpio_free(gpio_wp);
  107. exit_free_det:
  108. gpio_free(gpio_det);
  109. return ret;
  110. }
  111. static void mxc_mmc1_exit(struct device *dev, void *data)
  112. {
  113. gpio_free(gpio_det);
  114. gpio_free(gpio_wp);
  115. free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)), data);
  116. }
  117. static const struct imxmmc_platform_data mmc_pdata __initconst = {
  118. .get_ro = mxc_mmc1_get_ro,
  119. .init = mxc_mmc1_init,
  120. .exit = mxc_mmc1_exit,
  121. };
  122. /* Framebuffer support */
  123. static const struct fb_videomode fb_modedb = {
  124. /* 640x480 TFT panel (IPS-056T) */
  125. .name = "CRT-VGA",
  126. .refresh = 64,
  127. .xres = 640,
  128. .yres = 480,
  129. .pixclock = 30000,
  130. .left_margin = 200,
  131. .right_margin = 2,
  132. .upper_margin = 2,
  133. .lower_margin = 2,
  134. .hsync_len = 3,
  135. .vsync_len = 1,
  136. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH,
  137. .vmode = FB_VMODE_NONINTERLACED,
  138. .flag = 0,
  139. };
  140. static struct mx3fb_platform_data fb_pdata __initdata = {
  141. .name = "CRT-VGA",
  142. .mode = &fb_modedb,
  143. .num_modes = 1,
  144. };
  145. #define LCD_VCC_EN_GPIO (7)
  146. static void __init mx31lilly_init_fb(void)
  147. {
  148. if (gpio_request(LCD_VCC_EN_GPIO, "LCD enable") != 0) {
  149. printk(KERN_WARNING "unable to request LCD_VCC_EN pin.\n");
  150. return;
  151. }
  152. imx31_add_ipu_core();
  153. imx31_add_mx3_sdc_fb(&fb_pdata);
  154. gpio_direction_output(LCD_VCC_EN_GPIO, 1);
  155. }
  156. void __init mx31lilly_db_init(void)
  157. {
  158. mxc_iomux_setup_multiple_pins(lilly_db_board_pins,
  159. ARRAY_SIZE(lilly_db_board_pins),
  160. "development board pins");
  161. imx31_add_mxc_mmc(0, &mmc_pdata);
  162. mx31lilly_init_fb();
  163. }