eukrea_mbimxsd25-baseboard.c 7.0 KB

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