eukrea_mbimxsd35-baseboard.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * Copyright (C) 2010 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/types.h>
  22. #include <linux/init.h>
  23. #include <linux/gpio.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/leds.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/input.h>
  28. #include <video/platform_lcd.h>
  29. #include <linux/i2c.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/time.h>
  33. #include <asm/mach/map.h>
  34. #include <mach/hardware.h>
  35. #include <mach/common.h>
  36. #include <mach/iomux-mx35.h>
  37. #include <mach/audmux.h>
  38. #include "devices-imx35.h"
  39. static const struct fb_videomode fb_modedb[] = {
  40. {
  41. .name = "CMO-QVGA",
  42. .refresh = 60,
  43. .xres = 320,
  44. .yres = 240,
  45. .pixclock = KHZ2PICOS(6500),
  46. .left_margin = 68,
  47. .right_margin = 20,
  48. .upper_margin = 15,
  49. .lower_margin = 4,
  50. .hsync_len = 30,
  51. .vsync_len = 3,
  52. .sync = 0,
  53. .vmode = FB_VMODE_NONINTERLACED,
  54. .flag = 0,
  55. },
  56. {
  57. .name = "DVI-VGA",
  58. .refresh = 60,
  59. .xres = 640,
  60. .yres = 480,
  61. .pixclock = 32000,
  62. .left_margin = 100,
  63. .right_margin = 100,
  64. .upper_margin = 7,
  65. .lower_margin = 100,
  66. .hsync_len = 7,
  67. .vsync_len = 7,
  68. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT |
  69. FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT,
  70. .vmode = FB_VMODE_NONINTERLACED,
  71. .flag = 0,
  72. },
  73. {
  74. .name = "DVI-SVGA",
  75. .refresh = 60,
  76. .xres = 800,
  77. .yres = 600,
  78. .pixclock = 25000,
  79. .left_margin = 75,
  80. .right_margin = 75,
  81. .upper_margin = 7,
  82. .lower_margin = 75,
  83. .hsync_len = 7,
  84. .vsync_len = 7,
  85. .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT |
  86. FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT,
  87. .vmode = FB_VMODE_NONINTERLACED,
  88. .flag = 0,
  89. },
  90. };
  91. static const struct ipu_platform_data mx3_ipu_data __initconst = {
  92. .irq_base = MXC_IPU_IRQ_START,
  93. };
  94. static struct mx3fb_platform_data mx3fb_pdata __initdata = {
  95. .name = "CMO-QVGA",
  96. .mode = fb_modedb,
  97. .num_modes = ARRAY_SIZE(fb_modedb),
  98. };
  99. static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
  100. /* LCD */
  101. MX35_PAD_LD0__IPU_DISPB_DAT_0,
  102. MX35_PAD_LD1__IPU_DISPB_DAT_1,
  103. MX35_PAD_LD2__IPU_DISPB_DAT_2,
  104. MX35_PAD_LD3__IPU_DISPB_DAT_3,
  105. MX35_PAD_LD4__IPU_DISPB_DAT_4,
  106. MX35_PAD_LD5__IPU_DISPB_DAT_5,
  107. MX35_PAD_LD6__IPU_DISPB_DAT_6,
  108. MX35_PAD_LD7__IPU_DISPB_DAT_7,
  109. MX35_PAD_LD8__IPU_DISPB_DAT_8,
  110. MX35_PAD_LD9__IPU_DISPB_DAT_9,
  111. MX35_PAD_LD10__IPU_DISPB_DAT_10,
  112. MX35_PAD_LD11__IPU_DISPB_DAT_11,
  113. MX35_PAD_LD12__IPU_DISPB_DAT_12,
  114. MX35_PAD_LD13__IPU_DISPB_DAT_13,
  115. MX35_PAD_LD14__IPU_DISPB_DAT_14,
  116. MX35_PAD_LD15__IPU_DISPB_DAT_15,
  117. MX35_PAD_LD16__IPU_DISPB_DAT_16,
  118. MX35_PAD_LD17__IPU_DISPB_DAT_17,
  119. MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC,
  120. MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK,
  121. MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY,
  122. MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC,
  123. /* Backlight */
  124. MX35_PAD_CONTRAST__IPU_DISPB_CONTR,
  125. /* LCD_PWR */
  126. MX35_PAD_D3_CLS__GPIO1_4,
  127. /* LED */
  128. MX35_PAD_LD23__GPIO3_29,
  129. /* SWITCH */
  130. MX35_PAD_LD19__GPIO3_25,
  131. /* UART2 */
  132. MX35_PAD_CTS2__UART2_CTS,
  133. MX35_PAD_RTS2__UART2_RTS,
  134. MX35_PAD_TXD2__UART2_TXD_MUX,
  135. MX35_PAD_RXD2__UART2_RXD_MUX,
  136. /* I2S */
  137. MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS,
  138. MX35_PAD_STXD4__AUDMUX_AUD4_TXD,
  139. MX35_PAD_SRXD4__AUDMUX_AUD4_RXD,
  140. MX35_PAD_SCK4__AUDMUX_AUD4_TXC,
  141. /* CAN2 */
  142. MX35_PAD_TX5_RX0__CAN2_TXCAN,
  143. MX35_PAD_TX4_RX1__CAN2_RXCAN,
  144. /* SDCARD */
  145. MX35_PAD_SD1_CMD__ESDHC1_CMD,
  146. MX35_PAD_SD1_CLK__ESDHC1_CLK,
  147. MX35_PAD_SD1_DATA0__ESDHC1_DAT0,
  148. MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
  149. MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
  150. MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
  151. /* SD1 CD */
  152. MX35_PAD_LD18__GPIO3_24,
  153. };
  154. #define GPIO_LED1 IMX_GPIO_NR(3, 29)
  155. #define GPIO_SWITCH1 IMX_GPIO_NR(3, 25)
  156. #define GPIO_LCDPWR IMX_GPIO_NR(1, 4)
  157. #define GPIO_SD1CD IMX_GPIO_NR(3, 24)
  158. static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
  159. unsigned int power)
  160. {
  161. if (power)
  162. gpio_direction_output(GPIO_LCDPWR, 1);
  163. else
  164. gpio_direction_output(GPIO_LCDPWR, 0);
  165. }
  166. static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
  167. .set_power = eukrea_mbimxsd_lcd_power_set,
  168. };
  169. static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
  170. .name = "platform-lcd",
  171. .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
  172. };
  173. static struct gpio_led eukrea_mbimxsd_leds[] = {
  174. {
  175. .name = "led1",
  176. .default_trigger = "heartbeat",
  177. .active_low = 1,
  178. .gpio = GPIO_LED1,
  179. },
  180. };
  181. static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
  182. .leds = eukrea_mbimxsd_leds,
  183. .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
  184. };
  185. static struct platform_device eukrea_mbimxsd_leds_gpio = {
  186. .name = "leds-gpio",
  187. .id = -1,
  188. .dev = {
  189. .platform_data = &eukrea_mbimxsd_led_info,
  190. },
  191. };
  192. static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
  193. {
  194. .gpio = GPIO_SWITCH1,
  195. .code = BTN_0,
  196. .desc = "BP1",
  197. .active_low = 1,
  198. .wakeup = 1,
  199. },
  200. };
  201. static const struct gpio_keys_platform_data
  202. eukrea_mbimxsd_button_data __initconst = {
  203. .buttons = eukrea_mbimxsd_gpio_buttons,
  204. .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
  205. };
  206. static struct platform_device *platform_devices[] __initdata = {
  207. &eukrea_mbimxsd_leds_gpio,
  208. &eukrea_mbimxsd_lcd_powerdev,
  209. };
  210. static const struct imxuart_platform_data uart_pdata __initconst = {
  211. .flags = IMXUART_HAVE_RTSCTS,
  212. };
  213. static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
  214. {
  215. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  216. },
  217. };
  218. static const
  219. struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
  220. .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
  221. };
  222. static struct esdhc_platform_data sd1_pdata = {
  223. .cd_gpio = GPIO_SD1CD,
  224. .wp_gpio = -EINVAL,
  225. };
  226. /*
  227. * system init for baseboard usage. Will be called by cpuimx35 init.
  228. *
  229. * Add platform devices present on this baseboard and init
  230. * them from CPU side as far as required to use them later on
  231. */
  232. void __init eukrea_mbimxsd35_baseboard_init(void)
  233. {
  234. if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
  235. ARRAY_SIZE(eukrea_mbimxsd_pads)))
  236. printk(KERN_ERR "error setting mbimxsd pads !\n");
  237. #if defined(CONFIG_SND_SOC_EUKREA_TLV320)
  238. /* SSI unit master I2S codec connected to SSI_AUD4 */
  239. mxc_audmux_v2_configure_port(0,
  240. MXC_AUDMUX_V2_PTCR_SYN |
  241. MXC_AUDMUX_V2_PTCR_TFSDIR |
  242. MXC_AUDMUX_V2_PTCR_TFSEL(3) |
  243. MXC_AUDMUX_V2_PTCR_TCLKDIR |
  244. MXC_AUDMUX_V2_PTCR_TCSEL(3),
  245. MXC_AUDMUX_V2_PDCR_RXDSEL(3)
  246. );
  247. mxc_audmux_v2_configure_port(3,
  248. MXC_AUDMUX_V2_PTCR_SYN,
  249. MXC_AUDMUX_V2_PDCR_RXDSEL(0)
  250. );
  251. #endif
  252. imx35_add_imx_uart1(&uart_pdata);
  253. imx35_add_ipu_core(&mx3_ipu_data);
  254. imx35_add_mx3_sdc_fb(&mx3fb_pdata);
  255. imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
  256. imx35_add_flexcan1(NULL);
  257. imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
  258. gpio_request(GPIO_LED1, "LED1");
  259. gpio_direction_output(GPIO_LED1, 1);
  260. gpio_free(GPIO_LED1);
  261. gpio_request(GPIO_SWITCH1, "SWITCH1");
  262. gpio_direction_input(GPIO_SWITCH1);
  263. gpio_free(GPIO_SWITCH1);
  264. gpio_request(GPIO_LCDPWR, "LCDPWR");
  265. gpio_direction_output(GPIO_LCDPWR, 1);
  266. i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
  267. ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
  268. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  269. imx_add_gpio_keys(&eukrea_mbimxsd_button_data);
  270. }