eukrea_mbimxsd25-baseboard.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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/gpio.h>
  22. #include <linux/leds.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/input.h>
  26. #include <video/platform_lcd.h>
  27. #include <mach/hardware.h>
  28. #include <mach/iomux-mx25.h>
  29. #include <mach/common.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <mach/mx25.h>
  33. #include <mach/imx-uart.h>
  34. #include <mach/audmux.h>
  35. #include "devices-imx25.h"
  36. static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
  37. /* LCD */
  38. MX25_PAD_LD0__LD0,
  39. MX25_PAD_LD1__LD1,
  40. MX25_PAD_LD2__LD2,
  41. MX25_PAD_LD3__LD3,
  42. MX25_PAD_LD4__LD4,
  43. MX25_PAD_LD5__LD5,
  44. MX25_PAD_LD6__LD6,
  45. MX25_PAD_LD7__LD7,
  46. MX25_PAD_LD8__LD8,
  47. MX25_PAD_LD9__LD9,
  48. MX25_PAD_LD10__LD10,
  49. MX25_PAD_LD11__LD11,
  50. MX25_PAD_LD12__LD12,
  51. MX25_PAD_LD13__LD13,
  52. MX25_PAD_LD14__LD14,
  53. MX25_PAD_LD15__LD15,
  54. MX25_PAD_GPIO_E__LD16,
  55. MX25_PAD_GPIO_F__LD17,
  56. MX25_PAD_HSYNC__HSYNC,
  57. MX25_PAD_VSYNC__VSYNC,
  58. MX25_PAD_LSCLK__LSCLK,
  59. MX25_PAD_OE_ACD__OE_ACD,
  60. MX25_PAD_CONTRAST__CONTRAST,
  61. /* LCD_PWR */
  62. MX25_PAD_PWM__GPIO_1_26,
  63. /* LED */
  64. MX25_PAD_POWER_FAIL__GPIO_3_19,
  65. /* SWITCH */
  66. MX25_PAD_VSTBY_ACK__GPIO_3_18,
  67. /* UART2 */
  68. MX25_PAD_UART2_RTS__UART2_RTS,
  69. MX25_PAD_UART2_CTS__UART2_CTS,
  70. MX25_PAD_UART2_TXD__UART2_TXD,
  71. MX25_PAD_UART2_RXD__UART2_RXD,
  72. /* SD1 */
  73. MX25_PAD_SD1_CMD__SD1_CMD,
  74. MX25_PAD_SD1_CLK__SD1_CLK,
  75. MX25_PAD_SD1_DATA0__SD1_DATA0,
  76. MX25_PAD_SD1_DATA1__SD1_DATA1,
  77. MX25_PAD_SD1_DATA2__SD1_DATA2,
  78. MX25_PAD_SD1_DATA3__SD1_DATA3,
  79. /* SD1 CD */
  80. MX25_PAD_DE_B__GPIO_2_20,
  81. /* I2S */
  82. MX25_PAD_KPP_COL3__AUD5_TXFS,
  83. MX25_PAD_KPP_COL2__AUD5_TXC,
  84. MX25_PAD_KPP_COL1__AUD5_RXD,
  85. MX25_PAD_KPP_COL0__AUD5_TXD,
  86. /* CAN */
  87. MX25_PAD_GPIO_D__CAN2_RX,
  88. MX25_PAD_GPIO_C__CAN2_TX,
  89. };
  90. #define GPIO_LED1 83
  91. #define GPIO_SWITCH1 82
  92. #define GPIO_SD1CD 52
  93. #define GPIO_LCDPWR 26
  94. static struct imx_fb_videomode eukrea_mximxsd_modes[] = {
  95. {
  96. .mode = {
  97. .name = "CMO-QVGA",
  98. .refresh = 60,
  99. .xres = 320,
  100. .yres = 240,
  101. .pixclock = KHZ2PICOS(6500),
  102. .left_margin = 30,
  103. .right_margin = 38,
  104. .upper_margin = 20,
  105. .lower_margin = 3,
  106. .hsync_len = 15,
  107. .vsync_len = 4,
  108. },
  109. .bpp = 16,
  110. .pcr = 0xCAD08B80,
  111. }, {
  112. .mode = {
  113. .name = "DVI-VGA",
  114. .refresh = 60,
  115. .xres = 640,
  116. .yres = 480,
  117. .pixclock = 32000,
  118. .hsync_len = 7,
  119. .left_margin = 100,
  120. .right_margin = 100,
  121. .vsync_len = 7,
  122. .upper_margin = 7,
  123. .lower_margin = 100,
  124. },
  125. .pcr = 0xFA208B80,
  126. .bpp = 16,
  127. }, {
  128. .mode = {
  129. .name = "DVI-SVGA",
  130. .refresh = 60,
  131. .xres = 800,
  132. .yres = 600,
  133. .pixclock = 25000,
  134. .hsync_len = 7,
  135. .left_margin = 75,
  136. .right_margin = 75,
  137. .vsync_len = 7,
  138. .upper_margin = 7,
  139. .lower_margin = 75,
  140. },
  141. .pcr = 0xFA208B80,
  142. .bpp = 16,
  143. },
  144. };
  145. static const struct imx_fb_platform_data eukrea_mximxsd_fb_pdata __initconst = {
  146. .mode = eukrea_mximxsd_modes,
  147. .num_modes = ARRAY_SIZE(eukrea_mximxsd_modes),
  148. .pwmr = 0x00A903FF,
  149. .lscr1 = 0x00120300,
  150. .dmacr = 0x00040060,
  151. };
  152. static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
  153. unsigned int power)
  154. {
  155. if (power)
  156. gpio_direction_output(GPIO_LCDPWR, 1);
  157. else
  158. gpio_direction_output(GPIO_LCDPWR, 0);
  159. }
  160. static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
  161. .set_power = eukrea_mbimxsd_lcd_power_set,
  162. };
  163. static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
  164. .name = "platform-lcd",
  165. .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
  166. };
  167. static struct gpio_led eukrea_mbimxsd_leds[] = {
  168. {
  169. .name = "led1",
  170. .default_trigger = "heartbeat",
  171. .active_low = 1,
  172. .gpio = GPIO_LED1,
  173. },
  174. };
  175. static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
  176. .leds = eukrea_mbimxsd_leds,
  177. .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
  178. };
  179. static struct platform_device eukrea_mbimxsd_leds_gpio = {
  180. .name = "leds-gpio",
  181. .id = -1,
  182. .dev = {
  183. .platform_data = &eukrea_mbimxsd_led_info,
  184. },
  185. };
  186. static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
  187. {
  188. .gpio = GPIO_SWITCH1,
  189. .code = BTN_0,
  190. .desc = "BP1",
  191. .active_low = 1,
  192. .wakeup = 1,
  193. },
  194. };
  195. static struct gpio_keys_platform_data eukrea_mbimxsd_button_data = {
  196. .buttons = eukrea_mbimxsd_gpio_buttons,
  197. .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
  198. };
  199. static struct platform_device eukrea_mbimxsd_button_device = {
  200. .name = "gpio-keys",
  201. .id = -1,
  202. .num_resources = 0,
  203. .dev = {
  204. .platform_data = &eukrea_mbimxsd_button_data,
  205. }
  206. };
  207. static struct platform_device *platform_devices[] __initdata = {
  208. &eukrea_mbimxsd_leds_gpio,
  209. &eukrea_mbimxsd_button_device,
  210. &eukrea_mbimxsd_lcd_powerdev,
  211. };
  212. static const struct imxuart_platform_data uart_pdata __initconst = {
  213. .flags = IMXUART_HAVE_RTSCTS,
  214. };
  215. static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
  216. {
  217. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  218. },
  219. };
  220. static const
  221. struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
  222. .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
  223. };
  224. /*
  225. * system init for baseboard usage. Will be called by cpuimx25 init.
  226. *
  227. * Add platform devices present on this baseboard and init
  228. * them from CPU side as far as required to use them later on
  229. */
  230. void __init eukrea_mbimxsd25_baseboard_init(void)
  231. {
  232. if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
  233. ARRAY_SIZE(eukrea_mbimxsd_pads)))
  234. printk(KERN_ERR "error setting mbimxsd pads !\n");
  235. #if defined(CONFIG_SND_SOC_EUKREA_TLV320)
  236. /* SSI unit master I2S codec connected to SSI_AUD5*/
  237. mxc_audmux_v2_configure_port(0,
  238. MXC_AUDMUX_V2_PTCR_SYN |
  239. MXC_AUDMUX_V2_PTCR_TFSDIR |
  240. MXC_AUDMUX_V2_PTCR_TFSEL(4) |
  241. MXC_AUDMUX_V2_PTCR_TCLKDIR |
  242. MXC_AUDMUX_V2_PTCR_TCSEL(4),
  243. MXC_AUDMUX_V2_PDCR_RXDSEL(4)
  244. );
  245. mxc_audmux_v2_configure_port(4,
  246. MXC_AUDMUX_V2_PTCR_SYN,
  247. MXC_AUDMUX_V2_PDCR_RXDSEL(0)
  248. );
  249. #endif
  250. imx25_add_imx_uart1(&uart_pdata);
  251. imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata);
  252. imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
  253. imx25_add_flexcan1(NULL);
  254. imx25_add_sdhci_esdhc_imx(0, NULL);
  255. gpio_request(GPIO_LED1, "LED1");
  256. gpio_direction_output(GPIO_LED1, 1);
  257. gpio_free(GPIO_LED1);
  258. gpio_request(GPIO_SWITCH1, "SWITCH1");
  259. gpio_direction_input(GPIO_SWITCH1);
  260. gpio_free(GPIO_SWITCH1);
  261. gpio_request(GPIO_LCDPWR, "LCDPWR");
  262. gpio_direction_output(GPIO_LCDPWR, 1);
  263. gpio_free(GPIO_SWITCH1);
  264. i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
  265. ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
  266. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  267. }