board-am3517evm.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. /*
  2. * linux/arch/arm/mach-omap2/board-am3517evm.c
  3. *
  4. * Copyright (C) 2009 Texas Instruments Incorporated
  5. * Author: Ranjith Lohithakshan <ranjithl@ti.com>
  6. *
  7. * Based on mach-omap2/board-omap3evm.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation version 2.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
  14. * whether express or implied; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/gpio.h>
  22. #include <linux/i2c/pca953x.h>
  23. #include <linux/can/platform/ti_hecc.h>
  24. #include <mach/hardware.h>
  25. #include <mach/am35xx.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <plat/board.h>
  30. #include <plat/common.h>
  31. #include <plat/usb.h>
  32. #include <plat/display.h>
  33. #include "mux.h"
  34. #define LCD_PANEL_PWR 176
  35. #define LCD_PANEL_BKLIGHT_PWR 182
  36. #define LCD_PANEL_PWM 181
  37. static struct i2c_board_info __initdata am3517evm_i2c_boardinfo[] = {
  38. {
  39. I2C_BOARD_INFO("s35390a", 0x30),
  40. .type = "s35390a",
  41. },
  42. };
  43. /*
  44. * RTC - S35390A
  45. */
  46. #define GPIO_RTCS35390A_IRQ 55
  47. static void __init am3517_evm_rtc_init(void)
  48. {
  49. int r;
  50. omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
  51. r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
  52. if (r < 0) {
  53. printk(KERN_WARNING "failed to request GPIO#%d\n",
  54. GPIO_RTCS35390A_IRQ);
  55. return;
  56. }
  57. r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
  58. if (r < 0) {
  59. printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
  60. GPIO_RTCS35390A_IRQ);
  61. gpio_free(GPIO_RTCS35390A_IRQ);
  62. return;
  63. }
  64. am3517evm_i2c_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
  65. }
  66. /*
  67. * I2C GPIO Expander - TCA6416
  68. */
  69. /* Mounted on Base-Board */
  70. static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
  71. .gpio_base = OMAP_MAX_GPIO_LINES,
  72. };
  73. static struct i2c_board_info __initdata am3517evm_tca6416_info_0[] = {
  74. {
  75. I2C_BOARD_INFO("tca6416", 0x21),
  76. .platform_data = &am3517evm_gpio_expander_info_0,
  77. },
  78. };
  79. /* Mounted on UI Card */
  80. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
  81. .gpio_base = OMAP_MAX_GPIO_LINES + 16,
  82. };
  83. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
  84. .gpio_base = OMAP_MAX_GPIO_LINES + 32,
  85. };
  86. static struct i2c_board_info __initdata am3517evm_ui_tca6416_info[] = {
  87. {
  88. I2C_BOARD_INFO("tca6416", 0x20),
  89. .platform_data = &am3517evm_ui_gpio_expander_info_1,
  90. },
  91. {
  92. I2C_BOARD_INFO("tca6416", 0x21),
  93. .platform_data = &am3517evm_ui_gpio_expander_info_2,
  94. },
  95. };
  96. static int __init am3517_evm_i2c_init(void)
  97. {
  98. omap_register_i2c_bus(1, 400, NULL, 0);
  99. omap_register_i2c_bus(2, 400, am3517evm_tca6416_info_0,
  100. ARRAY_SIZE(am3517evm_tca6416_info_0));
  101. omap_register_i2c_bus(3, 400, am3517evm_ui_tca6416_info,
  102. ARRAY_SIZE(am3517evm_ui_tca6416_info));
  103. return 0;
  104. }
  105. static int lcd_enabled;
  106. static int dvi_enabled;
  107. static void __init am3517_evm_display_init(void)
  108. {
  109. int r;
  110. omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
  111. omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
  112. omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
  113. /*
  114. * Enable GPIO 182 = LCD Backlight Power
  115. */
  116. r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
  117. if (r) {
  118. printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
  119. return;
  120. }
  121. gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
  122. /*
  123. * Enable GPIO 181 = LCD Panel PWM
  124. */
  125. r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
  126. if (r) {
  127. printk(KERN_ERR "failed to get lcd_pwm\n");
  128. goto err_1;
  129. }
  130. gpio_direction_output(LCD_PANEL_PWM, 1);
  131. /*
  132. * Enable GPIO 176 = LCD Panel Power enable pin
  133. */
  134. r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
  135. if (r) {
  136. printk(KERN_ERR "failed to get lcd_panel_pwr\n");
  137. goto err_2;
  138. }
  139. gpio_direction_output(LCD_PANEL_PWR, 1);
  140. printk(KERN_INFO "Display initialized successfully\n");
  141. return;
  142. err_2:
  143. gpio_free(LCD_PANEL_PWM);
  144. err_1:
  145. gpio_free(LCD_PANEL_BKLIGHT_PWR);
  146. }
  147. static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
  148. {
  149. if (dvi_enabled) {
  150. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  151. return -EINVAL;
  152. }
  153. gpio_set_value(LCD_PANEL_PWR, 1);
  154. lcd_enabled = 1;
  155. return 0;
  156. }
  157. static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
  158. {
  159. gpio_set_value(LCD_PANEL_PWR, 0);
  160. lcd_enabled = 0;
  161. }
  162. static struct omap_dss_device am3517_evm_lcd_device = {
  163. .type = OMAP_DISPLAY_TYPE_DPI,
  164. .name = "lcd",
  165. .driver_name = "sharp_lq_panel",
  166. .phy.dpi.data_lines = 16,
  167. .platform_enable = am3517_evm_panel_enable_lcd,
  168. .platform_disable = am3517_evm_panel_disable_lcd,
  169. };
  170. static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
  171. {
  172. return 0;
  173. }
  174. static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
  175. {
  176. }
  177. static struct omap_dss_device am3517_evm_tv_device = {
  178. .type = OMAP_DISPLAY_TYPE_VENC,
  179. .name = "tv",
  180. .driver_name = "venc",
  181. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  182. .platform_enable = am3517_evm_panel_enable_tv,
  183. .platform_disable = am3517_evm_panel_disable_tv,
  184. };
  185. static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
  186. {
  187. if (lcd_enabled) {
  188. printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
  189. return -EINVAL;
  190. }
  191. dvi_enabled = 1;
  192. return 0;
  193. }
  194. static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
  195. {
  196. dvi_enabled = 0;
  197. }
  198. static struct omap_dss_device am3517_evm_dvi_device = {
  199. .type = OMAP_DISPLAY_TYPE_DPI,
  200. .name = "dvi",
  201. .driver_name = "generic_panel",
  202. .phy.dpi.data_lines = 24,
  203. .platform_enable = am3517_evm_panel_enable_dvi,
  204. .platform_disable = am3517_evm_panel_disable_dvi,
  205. };
  206. static struct omap_dss_device *am3517_evm_dss_devices[] = {
  207. &am3517_evm_lcd_device,
  208. &am3517_evm_tv_device,
  209. &am3517_evm_dvi_device,
  210. };
  211. static struct omap_dss_board_info am3517_evm_dss_data = {
  212. .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
  213. .devices = am3517_evm_dss_devices,
  214. .default_device = &am3517_evm_lcd_device,
  215. };
  216. struct platform_device am3517_evm_dss_device = {
  217. .name = "omapdss",
  218. .id = -1,
  219. .dev = {
  220. .platform_data = &am3517_evm_dss_data,
  221. },
  222. };
  223. /*
  224. * Board initialization
  225. */
  226. static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
  227. };
  228. static struct platform_device *am3517_evm_devices[] __initdata = {
  229. &am3517_evm_dss_device,
  230. };
  231. static void __init am3517_evm_init_irq(void)
  232. {
  233. omap_board_config = am3517_evm_config;
  234. omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
  235. omap2_init_common_hw(NULL, NULL);
  236. omap_init_irq();
  237. omap_gpio_init();
  238. }
  239. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  240. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  241. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  242. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  243. .phy_reset = true,
  244. .reset_gpio_port[0] = 57,
  245. .reset_gpio_port[1] = -EINVAL,
  246. .reset_gpio_port[2] = -EINVAL
  247. };
  248. #ifdef CONFIG_OMAP_MUX
  249. static struct omap_board_mux board_mux[] __initdata = {
  250. { .reg_offset = OMAP_MUX_TERMINATOR },
  251. };
  252. #else
  253. #define board_mux NULL
  254. #endif
  255. static struct resource am3517_hecc_resources[] = {
  256. {
  257. .start = AM35XX_IPSS_HECC_BASE,
  258. .end = AM35XX_IPSS_HECC_BASE + 0x3FFF,
  259. .flags = IORESOURCE_MEM,
  260. },
  261. {
  262. .start = INT_35XX_HECC0_IRQ,
  263. .end = INT_35XX_HECC0_IRQ,
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. };
  267. static struct platform_device am3517_hecc_device = {
  268. .name = "ti_hecc",
  269. .id = -1,
  270. .num_resources = ARRAY_SIZE(am3517_hecc_resources),
  271. .resource = am3517_hecc_resources,
  272. };
  273. static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
  274. .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
  275. .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
  276. .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
  277. .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
  278. .int_line = AM35XX_HECC_INT_LINE,
  279. .version = AM35XX_HECC_VERSION,
  280. };
  281. static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
  282. {
  283. am3517_hecc_device.dev.platform_data = pdata;
  284. platform_device_register(&am3517_hecc_device);
  285. }
  286. static void __init am3517_evm_init(void)
  287. {
  288. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  289. am3517_evm_i2c_init();
  290. platform_add_devices(am3517_evm_devices,
  291. ARRAY_SIZE(am3517_evm_devices));
  292. omap_serial_init();
  293. /* Configure GPIO for EHCI port */
  294. omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
  295. usb_ehci_init(&ehci_pdata);
  296. am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
  297. /* DSS */
  298. am3517_evm_display_init();
  299. /* RTC - S35390A */
  300. am3517_evm_rtc_init();
  301. i2c_register_board_info(1, am3517evm_i2c_boardinfo,
  302. ARRAY_SIZE(am3517evm_i2c_boardinfo));
  303. }
  304. static void __init am3517_evm_map_io(void)
  305. {
  306. omap2_set_globals_343x();
  307. omap34xx_map_common_io();
  308. }
  309. MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
  310. .phys_io = 0x48000000,
  311. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  312. .boot_params = 0x80000100,
  313. .map_io = am3517_evm_map_io,
  314. .init_irq = am3517_evm_init_irq,
  315. .init_machine = am3517_evm_init,
  316. .timer = &omap_timer,
  317. MACHINE_END