eukrea_mbimx27-baseboard.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. /*
  2. * Copyright (C) 2009-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/irq.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/ads7846.h>
  26. #include <linux/backlight.h>
  27. #include <video/platform_lcd.h>
  28. #include <linux/input/matrix_keypad.h>
  29. #include <asm/mach/arch.h>
  30. #include <mach/common.h>
  31. #include <mach/iomux-mx27.h>
  32. #include <mach/imxfb.h>
  33. #include <mach/hardware.h>
  34. #include <mach/mmc.h>
  35. #include <mach/imx-uart.h>
  36. #include <mach/spi.h>
  37. #include <mach/ssi.h>
  38. #include <mach/audmux.h>
  39. #include "devices.h"
  40. static int eukrea_mbimx27_pins[] = {
  41. /* UART2 */
  42. PE3_PF_UART2_CTS,
  43. PE4_PF_UART2_RTS,
  44. PE6_PF_UART2_TXD,
  45. PE7_PF_UART2_RXD,
  46. /* UART3 */
  47. PE8_PF_UART3_TXD,
  48. PE9_PF_UART3_RXD,
  49. PE10_PF_UART3_CTS,
  50. PE11_PF_UART3_RTS,
  51. /* UART4 */
  52. #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
  53. PB26_AF_UART4_RTS,
  54. PB28_AF_UART4_TXD,
  55. PB29_AF_UART4_CTS,
  56. PB31_AF_UART4_RXD,
  57. #endif
  58. /* SDHC1*/
  59. PE18_PF_SD1_D0,
  60. PE19_PF_SD1_D1,
  61. PE20_PF_SD1_D2,
  62. PE21_PF_SD1_D3,
  63. PE22_PF_SD1_CMD,
  64. PE23_PF_SD1_CLK,
  65. /* display */
  66. PA5_PF_LSCLK,
  67. PA6_PF_LD0,
  68. PA7_PF_LD1,
  69. PA8_PF_LD2,
  70. PA9_PF_LD3,
  71. PA10_PF_LD4,
  72. PA11_PF_LD5,
  73. PA12_PF_LD6,
  74. PA13_PF_LD7,
  75. PA14_PF_LD8,
  76. PA15_PF_LD9,
  77. PA16_PF_LD10,
  78. PA17_PF_LD11,
  79. PA18_PF_LD12,
  80. PA19_PF_LD13,
  81. PA20_PF_LD14,
  82. PA21_PF_LD15,
  83. PA22_PF_LD16,
  84. PA23_PF_LD17,
  85. PA28_PF_HSYNC,
  86. PA29_PF_VSYNC,
  87. PA30_PF_CONTRAST,
  88. PA31_PF_OE_ACD,
  89. /* SPI1 */
  90. PD29_PF_CSPI1_SCLK,
  91. PD30_PF_CSPI1_MISO,
  92. PD31_PF_CSPI1_MOSI,
  93. /* SSI4 */
  94. #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
  95. || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
  96. PC16_PF_SSI4_FS,
  97. PC17_PF_SSI4_RXD | GPIO_PUEN,
  98. PC18_PF_SSI4_TXD | GPIO_PUEN,
  99. PC19_PF_SSI4_CLK,
  100. #endif
  101. };
  102. static const uint32_t eukrea_mbimx27_keymap[] = {
  103. KEY(0, 0, KEY_UP),
  104. KEY(0, 1, KEY_DOWN),
  105. KEY(1, 0, KEY_RIGHT),
  106. KEY(1, 1, KEY_LEFT),
  107. };
  108. static struct matrix_keymap_data eukrea_mbimx27_keymap_data = {
  109. .keymap = eukrea_mbimx27_keymap,
  110. .keymap_size = ARRAY_SIZE(eukrea_mbimx27_keymap),
  111. };
  112. static struct gpio_led gpio_leds[] = {
  113. {
  114. .name = "led1",
  115. .default_trigger = "heartbeat",
  116. .active_low = 1,
  117. .gpio = GPIO_PORTF | 16,
  118. },
  119. {
  120. .name = "led2",
  121. .default_trigger = "none",
  122. .active_low = 1,
  123. .gpio = GPIO_PORTF | 19,
  124. },
  125. };
  126. static struct gpio_led_platform_data gpio_led_info = {
  127. .leds = gpio_leds,
  128. .num_leds = ARRAY_SIZE(gpio_leds),
  129. };
  130. static struct platform_device leds_gpio = {
  131. .name = "leds-gpio",
  132. .id = -1,
  133. .dev = {
  134. .platform_data = &gpio_led_info,
  135. },
  136. };
  137. static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
  138. {
  139. .mode = {
  140. .name = "CMO-QVGA",
  141. .refresh = 60,
  142. .xres = 320,
  143. .yres = 240,
  144. .pixclock = 156000,
  145. .hsync_len = 30,
  146. .left_margin = 38,
  147. .right_margin = 20,
  148. .vsync_len = 3,
  149. .upper_margin = 15,
  150. .lower_margin = 4,
  151. },
  152. .pcr = 0xFAD08B80,
  153. .bpp = 16,
  154. }, {
  155. .mode = {
  156. .name = "DVI-VGA",
  157. .refresh = 60,
  158. .xres = 640,
  159. .yres = 480,
  160. .pixclock = 32000,
  161. .hsync_len = 1,
  162. .left_margin = 35,
  163. .right_margin = 0,
  164. .vsync_len = 1,
  165. .upper_margin = 7,
  166. .lower_margin = 0,
  167. },
  168. .pcr = 0xFA208B80,
  169. .bpp = 16,
  170. }, {
  171. .mode = {
  172. .name = "DVI-SVGA",
  173. .refresh = 60,
  174. .xres = 800,
  175. .yres = 600,
  176. .pixclock = 25000,
  177. .hsync_len = 1,
  178. .left_margin = 35,
  179. .right_margin = 0,
  180. .vsync_len = 1,
  181. .upper_margin = 7,
  182. .lower_margin = 0,
  183. },
  184. .pcr = 0xFA208B80,
  185. .bpp = 16,
  186. },
  187. };
  188. static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
  189. .mode = eukrea_mbimx27_modes,
  190. .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
  191. .pwmr = 0x00A903FF,
  192. .lscr1 = 0x00120300,
  193. .dmacr = 0x00040060,
  194. };
  195. static void eukrea_mbimx27_bl_set_intensity(int intensity)
  196. {
  197. if (intensity)
  198. gpio_direction_output(GPIO_PORTE | 5, 1);
  199. else
  200. gpio_direction_output(GPIO_PORTE | 5, 0);
  201. }
  202. static struct generic_bl_info eukrea_mbimx27_bl_info = {
  203. .name = "eukrea_mbimx27-bl",
  204. .max_intensity = 0xff,
  205. .default_intensity = 0xff,
  206. .set_bl_intensity = eukrea_mbimx27_bl_set_intensity,
  207. };
  208. static struct platform_device eukrea_mbimx27_bl_dev = {
  209. .name = "generic-bl",
  210. .id = 1,
  211. .dev = {
  212. .platform_data = &eukrea_mbimx27_bl_info,
  213. },
  214. };
  215. static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd,
  216. unsigned int power)
  217. {
  218. if (power)
  219. gpio_direction_output(GPIO_PORTA | 25, 1);
  220. else
  221. gpio_direction_output(GPIO_PORTA | 25, 0);
  222. }
  223. static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
  224. .set_power = eukrea_mbimx27_lcd_power_set,
  225. };
  226. static struct platform_device eukrea_mbimx27_lcd_powerdev = {
  227. .name = "platform-lcd",
  228. .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
  229. };
  230. static struct imxuart_platform_data uart_pdata[] = {
  231. {
  232. .flags = IMXUART_HAVE_RTSCTS,
  233. },
  234. {
  235. .flags = IMXUART_HAVE_RTSCTS,
  236. },
  237. {
  238. .flags = IMXUART_HAVE_RTSCTS,
  239. },
  240. };
  241. #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
  242. || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  243. #define ADS7846_PENDOWN (GPIO_PORTD | 25)
  244. static void ads7846_dev_init(void)
  245. {
  246. if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
  247. printk(KERN_ERR "can't get ads746 pen down GPIO\n");
  248. return;
  249. }
  250. gpio_direction_input(ADS7846_PENDOWN);
  251. }
  252. static int ads7846_get_pendown_state(void)
  253. {
  254. return !gpio_get_value(ADS7846_PENDOWN);
  255. }
  256. static struct ads7846_platform_data ads7846_config __initdata = {
  257. .get_pendown_state = ads7846_get_pendown_state,
  258. .keep_vref_on = 1,
  259. };
  260. #endif
  261. #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
  262. static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
  263. [0] = {
  264. .modalias = "ads7846",
  265. .bus_num = 0,
  266. .chip_select = 0,
  267. .max_speed_hz = 1500000,
  268. .irq = IRQ_GPIOD(25),
  269. .platform_data = &ads7846_config,
  270. .mode = SPI_MODE_2,
  271. },
  272. };
  273. static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = {
  274. {
  275. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  276. },
  277. };
  278. static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
  279. static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
  280. .chipselect = eukrea_mbimx27_spi_cs,
  281. .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
  282. };
  283. #endif
  284. static struct platform_device *platform_devices[] __initdata = {
  285. &leds_gpio,
  286. };
  287. static struct imxmmc_platform_data sdhc_pdata = {
  288. .dat3_card_detect = 1,
  289. };
  290. struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata = {
  291. .flags = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE,
  292. };
  293. /*
  294. * system init for baseboard usage. Will be called by cpuimx27 init.
  295. *
  296. * Add platform devices present on this baseboard and init
  297. * them from CPU side as far as required to use them later on
  298. */
  299. void __init eukrea_mbimx27_baseboard_init(void)
  300. {
  301. mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
  302. ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
  303. #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
  304. || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
  305. /* SSI unit master I2S codec connected to SSI_PINS_4*/
  306. mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
  307. MXC_AUDMUX_V1_PCR_SYN |
  308. MXC_AUDMUX_V1_PCR_TFSDIR |
  309. MXC_AUDMUX_V1_PCR_TCLKDIR |
  310. MXC_AUDMUX_V1_PCR_RFSDIR |
  311. MXC_AUDMUX_V1_PCR_RCLKDIR |
  312. MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
  313. MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
  314. MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4)
  315. );
  316. mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4,
  317. MXC_AUDMUX_V1_PCR_SYN |
  318. MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
  319. );
  320. #endif
  321. mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
  322. mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
  323. #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
  324. mxc_register_device(&mxc_uart_device3, &uart_pdata[2]);
  325. #endif
  326. mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
  327. mxc_register_device(&mxc_sdhc_device0, &sdhc_pdata);
  328. i2c_register_board_info(0, eukrea_mbimx27_i2c_devices,
  329. ARRAY_SIZE(eukrea_mbimx27_i2c_devices));
  330. mxc_register_device(&imx_ssi_device0, &eukrea_mbimx27_ssi_pdata);
  331. #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
  332. || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  333. /* ADS7846 Touchscreen controller init */
  334. mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
  335. ads7846_dev_init();
  336. #endif
  337. #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
  338. /* SPI_CS0 init */
  339. mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
  340. mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
  341. spi_register_board_info(eukrea_mbimx27_spi_board_info,
  342. ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
  343. #endif
  344. /* Leds configuration */
  345. mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
  346. mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
  347. /* Backlight */
  348. mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
  349. gpio_request(GPIO_PORTE | 5, "backlight");
  350. platform_device_register(&eukrea_mbimx27_bl_dev);
  351. /* LCD Reset */
  352. mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
  353. gpio_request(GPIO_PORTA | 25, "lcd_enable");
  354. platform_device_register(&eukrea_mbimx27_lcd_powerdev);
  355. mxc_register_device(&imx_kpp_device, &eukrea_mbimx27_keymap_data);
  356. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  357. }