eukrea_mbimx27-baseboard.c 8.4 KB

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