eukrea_mbimxsd-baseboard.c 6.6 KB

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