board-cm-t3517.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * linux/arch/arm/mach-omap2/board-cm-t3517.c
  3. *
  4. * Support for the CompuLab CM-T3517 modules
  5. *
  6. * Copyright (C) 2010 CompuLab, Ltd.
  7. * Author: Igor Grinberg <grinberg@compulab.co.il>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; 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. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #include <linux/kernel.h>
  25. #include <linux/init.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/delay.h>
  28. #include <linux/gpio.h>
  29. #include <linux/leds.h>
  30. #include <linux/rtc-v3020.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <plat/board.h>
  35. #include <plat/common.h>
  36. #include <plat/control.h>
  37. #include <plat/usb.h>
  38. #include "mux.h"
  39. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  40. static struct gpio_led cm_t3517_leds[] = {
  41. [0] = {
  42. .gpio = 186,
  43. .name = "cm-t3517:green",
  44. .default_trigger = "heartbeat",
  45. .active_low = 0,
  46. },
  47. };
  48. static struct gpio_led_platform_data cm_t3517_led_pdata = {
  49. .num_leds = ARRAY_SIZE(cm_t3517_leds),
  50. .leds = cm_t3517_leds,
  51. };
  52. static struct platform_device cm_t3517_led_device = {
  53. .name = "leds-gpio",
  54. .id = -1,
  55. .dev = {
  56. .platform_data = &cm_t3517_led_pdata,
  57. },
  58. };
  59. static void __init cm_t3517_init_leds(void)
  60. {
  61. platform_device_register(&cm_t3517_led_device);
  62. }
  63. #else
  64. static inline void cm_t3517_init_leds(void) {}
  65. #endif
  66. #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
  67. #define RTC_IO_GPIO (153)
  68. #define RTC_WR_GPIO (154)
  69. #define RTC_RD_GPIO (160)
  70. #define RTC_CS_GPIO (163)
  71. struct v3020_platform_data cm_t3517_v3020_pdata = {
  72. .use_gpio = 1,
  73. .gpio_cs = RTC_CS_GPIO,
  74. .gpio_wr = RTC_WR_GPIO,
  75. .gpio_rd = RTC_RD_GPIO,
  76. .gpio_io = RTC_IO_GPIO,
  77. };
  78. static struct platform_device cm_t3517_rtc_device = {
  79. .name = "v3020",
  80. .id = -1,
  81. .dev = {
  82. .platform_data = &cm_t3517_v3020_pdata,
  83. }
  84. };
  85. static void __init cm_t3517_init_rtc(void)
  86. {
  87. platform_device_register(&cm_t3517_rtc_device);
  88. }
  89. #else
  90. static inline void cm_t3517_init_rtc(void) {}
  91. #endif
  92. #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
  93. #define HSUSB1_RESET_GPIO (146)
  94. #define HSUSB2_RESET_GPIO (147)
  95. #define USB_HUB_RESET_GPIO (152)
  96. static struct ehci_hcd_omap_platform_data cm_t3517_ehci_pdata __initdata = {
  97. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  98. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  99. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  100. .phy_reset = true,
  101. .reset_gpio_port[0] = HSUSB1_RESET_GPIO,
  102. .reset_gpio_port[1] = HSUSB2_RESET_GPIO,
  103. .reset_gpio_port[2] = -EINVAL,
  104. };
  105. static int cm_t3517_init_usbh(void)
  106. {
  107. int err;
  108. err = gpio_request(USB_HUB_RESET_GPIO, "usb hub rst");
  109. if (err) {
  110. pr_err("CM-T3517: usb hub rst gpio request failed: %d\n", err);
  111. } else {
  112. gpio_direction_output(USB_HUB_RESET_GPIO, 0);
  113. udelay(10);
  114. gpio_set_value(USB_HUB_RESET_GPIO, 1);
  115. msleep(1);
  116. }
  117. usb_ehci_init(&cm_t3517_ehci_pdata);
  118. return 0;
  119. }
  120. #else
  121. static inline int cm_t3517_init_usbh(void)
  122. {
  123. return 0;
  124. }
  125. #endif
  126. static struct omap_board_config_kernel cm_t3517_config[] __initdata = {
  127. };
  128. static void __init cm_t3517_init_irq(void)
  129. {
  130. omap_board_config = cm_t3517_config;
  131. omap_board_config_size = ARRAY_SIZE(cm_t3517_config);
  132. omap2_init_common_hw(NULL, NULL);
  133. omap_init_irq();
  134. omap_gpio_init();
  135. }
  136. static struct omap_board_mux board_mux[] __initdata = {
  137. /* GPIO186 - Green LED */
  138. OMAP3_MUX(SYS_CLKOUT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
  139. /* RTC GPIOs: IO, WR#, RD#, CS# */
  140. OMAP3_MUX(MCBSP4_DR, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
  141. OMAP3_MUX(MCBSP4_DX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
  142. OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
  143. OMAP3_MUX(UART3_CTS_RCTX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
  144. /* HSUSB1 RESET */
  145. OMAP3_MUX(UART2_TX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
  146. /* HSUSB2 RESET */
  147. OMAP3_MUX(UART2_RX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
  148. /* CM-T3517 USB HUB nRESET */
  149. OMAP3_MUX(MCBSP4_CLKX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
  150. { .reg_offset = OMAP_MUX_TERMINATOR },
  151. };
  152. static void __init cm_t3517_init(void)
  153. {
  154. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  155. omap_serial_init();
  156. cm_t3517_init_leds();
  157. cm_t3517_init_rtc();
  158. cm_t3517_init_usbh();
  159. }
  160. MACHINE_START(CM_T3517, "Compulab CM-T3517")
  161. .phys_io = 0x48000000,
  162. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  163. .boot_params = 0x80000100,
  164. .map_io = omap3_map_io,
  165. .reserve = omap_reserve,
  166. .init_irq = cm_t3517_init_irq,
  167. .init_machine = cm_t3517_init,
  168. .timer = &omap_timer,
  169. MACHINE_END