board-am3517evm.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 int lcd_enabled;
  36. static int dvi_enabled;
  37. static void __init am3517_evm_display_init(void)
  38. {
  39. int r;
  40. omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
  41. omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
  42. omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
  43. /*
  44. * Enable GPIO 182 = LCD Backlight Power
  45. */
  46. r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
  47. if (r) {
  48. printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
  49. return;
  50. }
  51. gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
  52. /*
  53. * Enable GPIO 181 = LCD Panel PWM
  54. */
  55. r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
  56. if (r) {
  57. printk(KERN_ERR "failed to get lcd_pwm\n");
  58. goto err_1;
  59. }
  60. gpio_direction_output(LCD_PANEL_PWM, 1);
  61. /*
  62. * Enable GPIO 176 = LCD Panel Power enable pin
  63. */
  64. r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
  65. if (r) {
  66. printk(KERN_ERR "failed to get lcd_panel_pwr\n");
  67. goto err_2;
  68. }
  69. gpio_direction_output(LCD_PANEL_PWR, 1);
  70. printk(KERN_INFO "Display initialized successfully\n");
  71. return;
  72. err_2:
  73. gpio_free(LCD_PANEL_PWM);
  74. err_1:
  75. gpio_free(LCD_PANEL_BKLIGHT_PWR);
  76. }
  77. static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
  78. {
  79. if (dvi_enabled) {
  80. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  81. return -EINVAL;
  82. }
  83. gpio_set_value(LCD_PANEL_PWR, 1);
  84. lcd_enabled = 1;
  85. return 0;
  86. }
  87. static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
  88. {
  89. gpio_set_value(LCD_PANEL_PWR, 0);
  90. lcd_enabled = 0;
  91. }
  92. static struct omap_dss_device am3517_evm_lcd_device = {
  93. .type = OMAP_DISPLAY_TYPE_DPI,
  94. .name = "lcd",
  95. .driver_name = "sharp_lq_panel",
  96. .phy.dpi.data_lines = 16,
  97. .platform_enable = am3517_evm_panel_enable_lcd,
  98. .platform_disable = am3517_evm_panel_disable_lcd,
  99. };
  100. static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
  101. {
  102. return 0;
  103. }
  104. static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
  105. {
  106. }
  107. static struct omap_dss_device am3517_evm_tv_device = {
  108. .type = OMAP_DISPLAY_TYPE_VENC,
  109. .name = "tv",
  110. .driver_name = "venc",
  111. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  112. .platform_enable = am3517_evm_panel_enable_tv,
  113. .platform_disable = am3517_evm_panel_disable_tv,
  114. };
  115. static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
  116. {
  117. if (lcd_enabled) {
  118. printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
  119. return -EINVAL;
  120. }
  121. dvi_enabled = 1;
  122. return 0;
  123. }
  124. static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
  125. {
  126. dvi_enabled = 0;
  127. }
  128. static struct omap_dss_device am3517_evm_dvi_device = {
  129. .type = OMAP_DISPLAY_TYPE_DPI,
  130. .name = "dvi",
  131. .driver_name = "generic_panel",
  132. .phy.dpi.data_lines = 24,
  133. .platform_enable = am3517_evm_panel_enable_dvi,
  134. .platform_disable = am3517_evm_panel_disable_dvi,
  135. };
  136. static struct omap_dss_device *am3517_evm_dss_devices[] = {
  137. &am3517_evm_lcd_device,
  138. &am3517_evm_tv_device,
  139. &am3517_evm_dvi_device,
  140. };
  141. static struct omap_dss_board_info am3517_evm_dss_data = {
  142. .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
  143. .devices = am3517_evm_dss_devices,
  144. .default_device = &am3517_evm_lcd_device,
  145. };
  146. struct platform_device am3517_evm_dss_device = {
  147. .name = "omapdss",
  148. .id = -1,
  149. .dev = {
  150. .platform_data = &am3517_evm_dss_data,
  151. },
  152. };
  153. /*
  154. * Board initialization
  155. */
  156. static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
  157. };
  158. static struct platform_device *am3517_evm_devices[] __initdata = {
  159. &am3517_evm_dss_device,
  160. };
  161. static void __init am3517_evm_init_irq(void)
  162. {
  163. omap_board_config = am3517_evm_config;
  164. omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
  165. omap2_init_common_hw(NULL, NULL);
  166. omap_init_irq();
  167. omap_gpio_init();
  168. }
  169. static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
  170. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  171. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  172. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  173. .phy_reset = true,
  174. .reset_gpio_port[0] = 57,
  175. .reset_gpio_port[1] = -EINVAL,
  176. .reset_gpio_port[2] = -EINVAL
  177. };
  178. #ifdef CONFIG_OMAP_MUX
  179. static struct omap_board_mux board_mux[] __initdata = {
  180. { .reg_offset = OMAP_MUX_TERMINATOR },
  181. };
  182. #else
  183. #define board_mux NULL
  184. #endif
  185. static void __init am3517_evm_init(void)
  186. {
  187. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  188. platform_add_devices(am3517_evm_devices,
  189. ARRAY_SIZE(am3517_evm_devices));
  190. omap_serial_init();
  191. usb_ehci_init(&ehci_pdata);
  192. /* DSS */
  193. am3517_evm_display_init();
  194. }
  195. static void __init am3517_evm_map_io(void)
  196. {
  197. omap2_set_globals_343x();
  198. omap34xx_map_common_io();
  199. }
  200. MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
  201. .phys_io = 0x48000000,
  202. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  203. .boot_params = 0x80000100,
  204. .map_io = am3517_evm_map_io,
  205. .init_irq = am3517_evm_init_irq,
  206. .init_machine = am3517_evm_init,
  207. .timer = &omap_timer,
  208. MACHINE_END