eukrea_mbimxsd-baseboard.c 6.5 KB

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