board-am3517evm.c 5.7 KB

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