board-am3517evm.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 <mach/hardware.h>
  24. #include <mach/am35xx.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <plat/board.h>
  29. #include <plat/common.h>
  30. #include <plat/usb.h>
  31. #include <plat/display.h>
  32. #include "mux.h"
  33. #define LCD_PANEL_PWR 176
  34. #define LCD_PANEL_BKLIGHT_PWR 182
  35. #define LCD_PANEL_PWM 181
  36. static struct i2c_board_info __initdata am3517evm_i2c_boardinfo[] = {
  37. {
  38. I2C_BOARD_INFO("s35390a", 0x30),
  39. .type = "s35390a",
  40. },
  41. };
  42. /*
  43. * RTC - S35390A
  44. */
  45. #define GPIO_RTCS35390A_IRQ 55
  46. static void __init am3517_evm_rtc_init(void)
  47. {
  48. int r;
  49. omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
  50. r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
  51. if (r < 0) {
  52. printk(KERN_WARNING "failed to request GPIO#%d\n",
  53. GPIO_RTCS35390A_IRQ);
  54. return;
  55. }
  56. r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
  57. if (r < 0) {
  58. printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
  59. GPIO_RTCS35390A_IRQ);
  60. gpio_free(GPIO_RTCS35390A_IRQ);
  61. return;
  62. }
  63. am3517evm_i2c_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
  64. }
  65. /*
  66. * I2C GPIO Expander - TCA6416
  67. */
  68. /* Mounted on Base-Board */
  69. static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
  70. .gpio_base = OMAP_MAX_GPIO_LINES,
  71. };
  72. static struct i2c_board_info __initdata am3517evm_tca6416_info_0[] = {
  73. {
  74. I2C_BOARD_INFO("tca6416", 0x21),
  75. .platform_data = &am3517evm_gpio_expander_info_0,
  76. },
  77. };
  78. /* Mounted on UI Card */
  79. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
  80. .gpio_base = OMAP_MAX_GPIO_LINES + 16,
  81. };
  82. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
  83. .gpio_base = OMAP_MAX_GPIO_LINES + 32,
  84. };
  85. static struct i2c_board_info __initdata am3517evm_ui_tca6416_info[] = {
  86. {
  87. I2C_BOARD_INFO("tca6416", 0x20),
  88. .platform_data = &am3517evm_ui_gpio_expander_info_1,
  89. },
  90. {
  91. I2C_BOARD_INFO("tca6416", 0x21),
  92. .platform_data = &am3517evm_ui_gpio_expander_info_2,
  93. },
  94. };
  95. static int __init am3517_evm_i2c_init(void)
  96. {
  97. omap_register_i2c_bus(1, 400, NULL, 0);
  98. omap_register_i2c_bus(2, 400, am3517evm_tca6416_info_0,
  99. ARRAY_SIZE(am3517evm_tca6416_info_0));
  100. omap_register_i2c_bus(3, 400, am3517evm_ui_tca6416_info,
  101. ARRAY_SIZE(am3517evm_ui_tca6416_info));
  102. return 0;
  103. }
  104. static int lcd_enabled;
  105. static int dvi_enabled;
  106. static void __init am3517_evm_display_init(void)
  107. {
  108. int r;
  109. omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
  110. omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
  111. omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
  112. /*
  113. * Enable GPIO 182 = LCD Backlight Power
  114. */
  115. r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
  116. if (r) {
  117. printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
  118. return;
  119. }
  120. gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
  121. /*
  122. * Enable GPIO 181 = LCD Panel PWM
  123. */
  124. r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
  125. if (r) {
  126. printk(KERN_ERR "failed to get lcd_pwm\n");
  127. goto err_1;
  128. }
  129. gpio_direction_output(LCD_PANEL_PWM, 1);
  130. /*
  131. * Enable GPIO 176 = LCD Panel Power enable pin
  132. */
  133. r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
  134. if (r) {
  135. printk(KERN_ERR "failed to get lcd_panel_pwr\n");
  136. goto err_2;
  137. }
  138. gpio_direction_output(LCD_PANEL_PWR, 1);
  139. printk(KERN_INFO "Display initialized successfully\n");
  140. return;
  141. err_2:
  142. gpio_free(LCD_PANEL_PWM);
  143. err_1:
  144. gpio_free(LCD_PANEL_BKLIGHT_PWR);
  145. }
  146. static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
  147. {
  148. if (dvi_enabled) {
  149. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  150. return -EINVAL;
  151. }
  152. gpio_set_value(LCD_PANEL_PWR, 1);
  153. lcd_enabled = 1;
  154. return 0;
  155. }
  156. static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
  157. {
  158. gpio_set_value(LCD_PANEL_PWR, 0);
  159. lcd_enabled = 0;
  160. }
  161. static struct omap_dss_device am3517_evm_lcd_device = {
  162. .type = OMAP_DISPLAY_TYPE_DPI,
  163. .name = "lcd",
  164. .driver_name = "sharp_lq_panel",
  165. .phy.dpi.data_lines = 16,
  166. .platform_enable = am3517_evm_panel_enable_lcd,
  167. .platform_disable = am3517_evm_panel_disable_lcd,
  168. };
  169. static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
  170. {
  171. return 0;
  172. }
  173. static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
  174. {
  175. }
  176. static struct omap_dss_device am3517_evm_tv_device = {
  177. .type = OMAP_DISPLAY_TYPE_VENC,
  178. .name = "tv",
  179. .driver_name = "venc",
  180. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  181. .platform_enable = am3517_evm_panel_enable_tv,
  182. .platform_disable = am3517_evm_panel_disable_tv,
  183. };
  184. static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
  185. {
  186. if (lcd_enabled) {
  187. printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
  188. return -EINVAL;
  189. }
  190. dvi_enabled = 1;
  191. return 0;
  192. }
  193. static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
  194. {
  195. dvi_enabled = 0;
  196. }
  197. static struct omap_dss_device am3517_evm_dvi_device = {
  198. .type = OMAP_DISPLAY_TYPE_DPI,
  199. .name = "dvi",
  200. .driver_name = "generic_panel",
  201. .phy.dpi.data_lines = 24,
  202. .platform_enable = am3517_evm_panel_enable_dvi,
  203. .platform_disable = am3517_evm_panel_disable_dvi,
  204. };
  205. static struct omap_dss_device *am3517_evm_dss_devices[] = {
  206. &am3517_evm_lcd_device,
  207. &am3517_evm_tv_device,
  208. &am3517_evm_dvi_device,
  209. };
  210. static struct omap_dss_board_info am3517_evm_dss_data = {
  211. .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
  212. .devices = am3517_evm_dss_devices,
  213. .default_device = &am3517_evm_lcd_device,
  214. };
  215. struct platform_device am3517_evm_dss_device = {
  216. .name = "omapdss",
  217. .id = -1,
  218. .dev = {
  219. .platform_data = &am3517_evm_dss_data,
  220. },
  221. };
  222. /*
  223. * Board initialization
  224. */
  225. static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
  226. };
  227. static struct platform_device *am3517_evm_devices[] __initdata = {
  228. &am3517_evm_dss_device,
  229. };
  230. static void __init am3517_evm_init_irq(void)
  231. {
  232. omap_board_config = am3517_evm_config;
  233. omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
  234. omap2_init_common_hw(NULL, NULL);
  235. omap_init_irq();
  236. omap_gpio_init();
  237. }
  238. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  239. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  240. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  241. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  242. .phy_reset = true,
  243. .reset_gpio_port[0] = 57,
  244. .reset_gpio_port[1] = -EINVAL,
  245. .reset_gpio_port[2] = -EINVAL
  246. };
  247. #ifdef CONFIG_OMAP_MUX
  248. static struct omap_board_mux board_mux[] __initdata = {
  249. { .reg_offset = OMAP_MUX_TERMINATOR },
  250. };
  251. #else
  252. #define board_mux NULL
  253. #endif
  254. static void __init am3517_evm_init(void)
  255. {
  256. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  257. am3517_evm_i2c_init();
  258. platform_add_devices(am3517_evm_devices,
  259. ARRAY_SIZE(am3517_evm_devices));
  260. omap_serial_init();
  261. /* Configure GPIO for EHCI port */
  262. omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
  263. usb_ehci_init(&ehci_pdata);
  264. /* DSS */
  265. am3517_evm_display_init();
  266. /* RTC - S35390A */
  267. am3517_evm_rtc_init();
  268. i2c_register_board_info(1, am3517evm_i2c_boardinfo,
  269. ARRAY_SIZE(am3517evm_i2c_boardinfo));
  270. }
  271. static void __init am3517_evm_map_io(void)
  272. {
  273. omap2_set_globals_343x();
  274. omap34xx_map_common_io();
  275. }
  276. MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
  277. .phys_io = 0x48000000,
  278. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  279. .boot_params = 0x80000100,
  280. .map_io = am3517_evm_map_io,
  281. .init_irq = am3517_evm_init_irq,
  282. .init_machine = am3517_evm_init,
  283. .timer = &omap_timer,
  284. MACHINE_END