eukrea_mbimxsd-baseboard.c 6.5 KB

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