board-am3517evm.c 6.8 KB

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