eukrea_mbimxsd-baseboard.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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/types.h>
  22. #include <linux/init.h>
  23. #include <linux/gpio.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/leds.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/gpio_keys.h>
  28. #include <linux/input.h>
  29. #include <video/platform_lcd.h>
  30. #include <linux/i2c.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/time.h>
  34. #include <asm/mach/map.h>
  35. #include <mach/hardware.h>
  36. #include <mach/common.h>
  37. #include <mach/imx-uart.h>
  38. #include <mach/iomux-mx35.h>
  39. #include <mach/ipu.h>
  40. #include <mach/mx3fb.h>
  41. #include <mach/audmux.h>
  42. #include <mach/ssi.h>
  43. #include "devices-imx35.h"
  44. #include "devices.h"
  45. static const struct fb_videomode fb_modedb[] = {
  46. {
  47. .name = "CMO_QVGA",
  48. .refresh = 60,
  49. .xres = 320,
  50. .yres = 240,
  51. .pixclock = KHZ2PICOS(6500),
  52. .left_margin = 68,
  53. .right_margin = 20,
  54. .upper_margin = 15,
  55. .lower_margin = 4,
  56. .hsync_len = 30,
  57. .vsync_len = 3,
  58. .sync = 0,
  59. .vmode = FB_VMODE_NONINTERLACED,
  60. .flag = 0,
  61. },
  62. };
  63. static struct ipu_platform_data mx3_ipu_data = {
  64. .irq_base = MXC_IPU_IRQ_START,
  65. };
  66. static struct mx3fb_platform_data mx3fb_pdata = {
  67. .dma_dev = &mx3_ipu.dev,
  68. .name = "CMO_QVGA",
  69. .mode = fb_modedb,
  70. .num_modes = ARRAY_SIZE(fb_modedb),
  71. };
  72. static struct pad_desc eukrea_mbimxsd_pads[] = {
  73. /* LCD */
  74. MX35_PAD_LD0__IPU_DISPB_DAT_0,
  75. MX35_PAD_LD1__IPU_DISPB_DAT_1,
  76. MX35_PAD_LD2__IPU_DISPB_DAT_2,
  77. MX35_PAD_LD3__IPU_DISPB_DAT_3,
  78. MX35_PAD_LD4__IPU_DISPB_DAT_4,
  79. MX35_PAD_LD5__IPU_DISPB_DAT_5,
  80. MX35_PAD_LD6__IPU_DISPB_DAT_6,
  81. MX35_PAD_LD7__IPU_DISPB_DAT_7,
  82. MX35_PAD_LD8__IPU_DISPB_DAT_8,
  83. MX35_PAD_LD9__IPU_DISPB_DAT_9,
  84. MX35_PAD_LD10__IPU_DISPB_DAT_10,
  85. MX35_PAD_LD11__IPU_DISPB_DAT_11,
  86. MX35_PAD_LD12__IPU_DISPB_DAT_12,
  87. MX35_PAD_LD13__IPU_DISPB_DAT_13,
  88. MX35_PAD_LD14__IPU_DISPB_DAT_14,
  89. MX35_PAD_LD15__IPU_DISPB_DAT_15,
  90. MX35_PAD_LD16__IPU_DISPB_DAT_16,
  91. MX35_PAD_LD17__IPU_DISPB_DAT_17,
  92. MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC,
  93. MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK,
  94. MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY,
  95. MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC,
  96. /* Backlight */
  97. MX35_PAD_CONTRAST__IPU_DISPB_CONTR,
  98. /* LCD_PWR */
  99. MX35_PAD_D3_CLS__GPIO1_4,
  100. /* LED */
  101. MX35_PAD_LD23__GPIO3_29,
  102. /* SWITCH */
  103. MX35_PAD_LD19__GPIO3_25,
  104. /* UART2 */
  105. MX35_PAD_CTS2__UART2_CTS,
  106. MX35_PAD_RTS2__UART2_RTS,
  107. MX35_PAD_TXD2__UART2_TXD_MUX,
  108. MX35_PAD_RXD2__UART2_RXD_MUX,
  109. /* I2S */
  110. MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS,
  111. MX35_PAD_STXD4__AUDMUX_AUD4_TXD,
  112. MX35_PAD_SRXD4__AUDMUX_AUD4_RXD,
  113. MX35_PAD_SCK4__AUDMUX_AUD4_TXC,
  114. };
  115. #define GPIO_LED1 (2 * 32 + 29)
  116. #define GPIO_SWITCH1 (2 * 32 + 25)
  117. #define GPIO_LCDPWR (4)
  118. static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
  119. unsigned int power)
  120. {
  121. if (power)
  122. gpio_direction_output(GPIO_LCDPWR, 1);
  123. else
  124. gpio_direction_output(GPIO_LCDPWR, 0);
  125. }
  126. static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
  127. .set_power = eukrea_mbimxsd_lcd_power_set,
  128. };
  129. static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
  130. .name = "platform-lcd",
  131. .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
  132. };
  133. static struct gpio_led eukrea_mbimxsd_leds[] = {
  134. {
  135. .name = "led1",
  136. .default_trigger = "heartbeat",
  137. .active_low = 1,
  138. .gpio = GPIO_LED1,
  139. },
  140. };
  141. static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
  142. .leds = eukrea_mbimxsd_leds,
  143. .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
  144. };
  145. static struct platform_device eukrea_mbimxsd_leds_gpio = {
  146. .name = "leds-gpio",
  147. .id = -1,
  148. .dev = {
  149. .platform_data = &eukrea_mbimxsd_led_info,
  150. },
  151. };
  152. static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
  153. {
  154. .gpio = GPIO_SWITCH1,
  155. .code = BTN_0,
  156. .desc = "BP1",
  157. .active_low = 1,
  158. .wakeup = 1,
  159. },
  160. };
  161. static struct gpio_keys_platform_data eukrea_mbimxsd_button_data = {
  162. .buttons = eukrea_mbimxsd_gpio_buttons,
  163. .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
  164. };
  165. static struct platform_device eukrea_mbimxsd_button_device = {
  166. .name = "gpio-keys",
  167. .id = -1,
  168. .num_resources = 0,
  169. .dev = {
  170. .platform_data = &eukrea_mbimxsd_button_data,
  171. }
  172. };
  173. static struct platform_device *platform_devices[] __initdata = {
  174. &eukrea_mbimxsd_leds_gpio,
  175. &eukrea_mbimxsd_button_device,
  176. &eukrea_mbimxsd_lcd_powerdev,
  177. };
  178. static const struct imxuart_platform_data uart_pdata __initconst = {
  179. .flags = IMXUART_HAVE_RTSCTS,
  180. };
  181. static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
  182. {
  183. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  184. },
  185. };
  186. struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata = {
  187. .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
  188. };
  189. /*
  190. * system init for baseboard usage. Will be called by cpuimx35 init.
  191. *
  192. * Add platform devices present on this baseboard and init
  193. * them from CPU side as far as required to use them later on
  194. */
  195. void __init eukrea_mbimxsd35_baseboard_init(void)
  196. {
  197. if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
  198. ARRAY_SIZE(eukrea_mbimxsd_pads)))
  199. printk(KERN_ERR "error setting mbimxsd pads !\n");
  200. #if defined(CONFIG_SND_SOC_EUKREA_TLV320)
  201. /* SSI unit master I2S codec connected to SSI_AUD4 */
  202. mxc_audmux_v2_configure_port(0,
  203. MXC_AUDMUX_V2_PTCR_SYN |
  204. MXC_AUDMUX_V2_PTCR_TFSDIR |
  205. MXC_AUDMUX_V2_PTCR_TFSEL(3) |
  206. MXC_AUDMUX_V2_PTCR_TCLKDIR |
  207. MXC_AUDMUX_V2_PTCR_TCSEL(3),
  208. MXC_AUDMUX_V2_PDCR_RXDSEL(3)
  209. );
  210. mxc_audmux_v2_configure_port(3,
  211. MXC_AUDMUX_V2_PTCR_SYN,
  212. MXC_AUDMUX_V2_PDCR_RXDSEL(0)
  213. );
  214. #endif
  215. imx35_add_imx_uart1(&uart_pdata);
  216. mxc_register_device(&mx3_ipu, &mx3_ipu_data);
  217. mxc_register_device(&mx3_fb, &mx3fb_pdata);
  218. mxc_register_device(&imx_ssi_device0, &eukrea_mbimxsd_ssi_pdata);
  219. gpio_request(GPIO_LED1, "LED1");
  220. gpio_direction_output(GPIO_LED1, 1);
  221. gpio_free(GPIO_LED1);
  222. gpio_request(GPIO_SWITCH1, "SWITCH1");
  223. gpio_direction_input(GPIO_SWITCH1);
  224. gpio_free(GPIO_SWITCH1);
  225. gpio_request(GPIO_LCDPWR, "LCDPWR");
  226. gpio_direction_output(GPIO_LCDPWR, 1);
  227. gpio_free(GPIO_SWITCH1);
  228. i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
  229. ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
  230. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  231. }