evm.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010
  4. * Texas Instruments Incorporated, <www.ti.com>
  5. * Aneesh V <aneesh@ti.com>
  6. * Steve Sakoman <steve@sakoman.com>
  7. */
  8. #include <common.h>
  9. #include <init.h>
  10. #include <net.h>
  11. #include <palmas.h>
  12. #include <asm/arch/omap.h>
  13. #include <asm/arch/sys_proto.h>
  14. #include <asm/arch/mmc_host_def.h>
  15. #include <serial.h>
  16. #include <tca642x.h>
  17. #include <usb.h>
  18. #include <asm/global_data.h>
  19. #include <linux/delay.h>
  20. #include <linux/usb/gadget.h>
  21. #include <dwc3-uboot.h>
  22. #include <dwc3-omap-uboot.h>
  23. #include <ti-usb-phy-uboot.h>
  24. #include "mux_data.h"
  25. #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_XHCI_OMAP)
  26. #include <sata.h>
  27. #include <usb.h>
  28. #include <asm/gpio.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/arch/clock.h>
  31. #include <asm/arch/ehci.h>
  32. #include <asm/ehci-omap.h>
  33. #include <asm/arch/sata.h>
  34. #define DIE_ID_REG_BASE (OMAP54XX_L4_CORE_BASE + 0x2000)
  35. #define DIE_ID_REG_OFFSET 0x200
  36. #endif
  37. DECLARE_GLOBAL_DATA_PTR;
  38. const struct omap_sysinfo sysinfo = {
  39. "Board: OMAP5432 uEVM\n"
  40. };
  41. /**
  42. * @brief tca642x_init - uEVM default values for the GPIO expander
  43. * input reg, output reg, polarity reg, configuration reg
  44. */
  45. struct tca642x_bank_info tca642x_init[] = {
  46. { .input_reg = 0x00,
  47. .output_reg = 0x04,
  48. .polarity_reg = 0x00,
  49. .configuration_reg = 0x80 },
  50. { .input_reg = 0x00,
  51. .output_reg = 0x00,
  52. .polarity_reg = 0x00,
  53. .configuration_reg = 0xff },
  54. { .input_reg = 0x00,
  55. .output_reg = 0x00,
  56. .polarity_reg = 0x00,
  57. .configuration_reg = 0x40 },
  58. };
  59. #ifdef CONFIG_USB_DWC3
  60. static struct dwc3_device usb_otg_ss = {
  61. .maximum_speed = USB_SPEED_SUPER,
  62. .base = OMAP5XX_USB_OTG_SS_BASE,
  63. .tx_fifo_resize = false,
  64. .index = 0,
  65. };
  66. static struct dwc3_omap_device usb_otg_ss_glue = {
  67. .base = (void *)OMAP5XX_USB_OTG_SS_GLUE_BASE,
  68. .utmi_mode = DWC3_OMAP_UTMI_MODE_SW,
  69. .index = 0,
  70. };
  71. static struct ti_usb_phy_device usb_phy_device = {
  72. .pll_ctrl_base = (void *)OMAP5XX_USB3_PHY_PLL_CTRL,
  73. .usb2_phy_power = (void *)OMAP5XX_USB2_PHY_POWER,
  74. .usb3_phy_power = (void *)OMAP5XX_USB3_PHY_POWER,
  75. .index = 0,
  76. };
  77. int board_usb_init(int index, enum usb_init_type init)
  78. {
  79. if (index) {
  80. printf("Invalid Controller Index\n");
  81. return -EINVAL;
  82. }
  83. if (init == USB_INIT_DEVICE) {
  84. usb_otg_ss.dr_mode = USB_DR_MODE_PERIPHERAL;
  85. usb_otg_ss_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID;
  86. } else {
  87. usb_otg_ss.dr_mode = USB_DR_MODE_HOST;
  88. usb_otg_ss_glue.vbus_id_status = OMAP_DWC3_ID_GROUND;
  89. }
  90. enable_usb_clocks(index);
  91. ti_usb_phy_uboot_init(&usb_phy_device);
  92. dwc3_omap_uboot_init(&usb_otg_ss_glue);
  93. dwc3_uboot_init(&usb_otg_ss);
  94. return 0;
  95. }
  96. int board_usb_cleanup(int index, enum usb_init_type init)
  97. {
  98. if (index) {
  99. printf("Invalid Controller Index\n");
  100. return -EINVAL;
  101. }
  102. ti_usb_phy_uboot_exit(index);
  103. dwc3_uboot_exit(index);
  104. dwc3_omap_uboot_exit(index);
  105. disable_usb_clocks(index);
  106. return 0;
  107. }
  108. int usb_gadget_handle_interrupts(int index)
  109. {
  110. u32 status;
  111. status = dwc3_omap_uboot_interrupt_status(index);
  112. if (status)
  113. dwc3_uboot_handle_interrupt(index);
  114. return 0;
  115. }
  116. #endif
  117. /**
  118. * @brief board_init
  119. *
  120. * @return 0
  121. */
  122. int board_init(void)
  123. {
  124. gpmc_init();
  125. gd->bd->bi_arch_number = MACH_TYPE_OMAP5_SEVM;
  126. gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */
  127. tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init);
  128. return 0;
  129. }
  130. #if defined(CONFIG_SPL_OS_BOOT)
  131. int spl_start_uboot(void)
  132. {
  133. /* break into full u-boot on 'c' */
  134. if (serial_tstc() && serial_getc() == 'c')
  135. return 1;
  136. return 0;
  137. }
  138. #endif /* CONFIG_SPL_OS_BOOT */
  139. int board_eth_init(struct bd_info *bis)
  140. {
  141. return 0;
  142. }
  143. /**
  144. * @brief misc_init_r - Configure EVM board specific configurations
  145. * such as power configurations, ethernet initialization as phase2 of
  146. * boot sequence
  147. *
  148. * @return 0
  149. */
  150. int misc_init_r(void)
  151. {
  152. #ifdef CONFIG_PALMAS_POWER
  153. palmas_init_settings();
  154. #endif
  155. omap_die_id_usbethaddr();
  156. return 0;
  157. }
  158. void set_muxconf_regs(void)
  159. {
  160. do_set_mux((*ctrl)->control_padconf_core_base,
  161. core_padconf_array_essential,
  162. sizeof(core_padconf_array_essential) /
  163. sizeof(struct pad_conf_entry));
  164. do_set_mux((*ctrl)->control_padconf_wkup_base,
  165. wkup_padconf_array_essential,
  166. sizeof(wkup_padconf_array_essential) /
  167. sizeof(struct pad_conf_entry));
  168. }
  169. #if defined(CONFIG_MMC)
  170. int board_mmc_init(struct bd_info *bis)
  171. {
  172. omap_mmc_init(0, 0, 0, -1, -1);
  173. omap_mmc_init(1, 0, 0, -1, -1);
  174. return 0;
  175. }
  176. #endif
  177. #ifdef CONFIG_USB_XHCI_OMAP
  178. /**
  179. * @brief board_usb_init - Configure EVM board specific configurations
  180. * for the LDO's and clocks for the USB blocks.
  181. *
  182. * @return 0
  183. */
  184. int board_usb_init(int index, enum usb_init_type init)
  185. {
  186. int ret;
  187. #ifdef CONFIG_PALMAS_USB_SS_PWR
  188. ret = palmas_enable_ss_ldo();
  189. #endif
  190. return 0;
  191. }
  192. #endif