am3517evm.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * am3517evm.c - board file for TI's AM3517 family of devices.
  4. *
  5. * Author: Vaibhav Hiremath <hvaibhav@ti.com>
  6. *
  7. * Based on ti/evm/evm.c
  8. *
  9. * Copyright (C) 2010
  10. * Texas Instruments Incorporated - http://www.ti.com/
  11. */
  12. #include <common.h>
  13. #include <dm.h>
  14. #include <init.h>
  15. #include <net.h>
  16. #include <ns16550.h>
  17. #include <serial.h>
  18. #include <asm/global_data.h>
  19. #include <asm/io.h>
  20. #include <asm/omap_musb.h>
  21. #include <asm/arch/am35x_def.h>
  22. #include <asm/arch/mem.h>
  23. #include <asm/arch/mux.h>
  24. #include <asm/arch/sys_proto.h>
  25. #include <asm/arch/mmc_host_def.h>
  26. #include <asm/arch/musb.h>
  27. #include <asm/mach-types.h>
  28. #include <linux/errno.h>
  29. #include <asm/gpio.h>
  30. #include <linux/usb/ch9.h>
  31. #include <linux/usb/gadget.h>
  32. #include <linux/usb/musb.h>
  33. #include <i2c.h>
  34. #include "am3517evm.h"
  35. DECLARE_GLOBAL_DATA_PTR;
  36. #define AM3517_IP_SW_RESET 0x48002598
  37. #define CPGMACSS_SW_RST (1 << 1)
  38. #define PHY_GPIO 30
  39. #if defined(CONFIG_SPL_BUILD)
  40. #if defined(CONFIG_SPL_OS_BOOT)
  41. int spl_start_uboot(void)
  42. {
  43. /* break into full u-boot on 'c' */
  44. return serial_tstc() && serial_getc() == 'c';
  45. }
  46. #endif
  47. #endif
  48. /*
  49. * Routine: board_init
  50. * Description: Early hardware init.
  51. */
  52. int board_init(void)
  53. {
  54. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  55. /* board id for Linux */
  56. gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
  57. /* boot param addr */
  58. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  59. return 0;
  60. }
  61. #ifdef CONFIG_USB_MUSB_AM35X
  62. static struct musb_hdrc_config musb_config = {
  63. .multipoint = 1,
  64. .dyn_fifo = 1,
  65. .num_eps = 16,
  66. .ram_bits = 12,
  67. };
  68. static struct omap_musb_board_data musb_board_data = {
  69. .set_phy_power = am35x_musb_phy_power,
  70. .clear_irq = am35x_musb_clear_irq,
  71. .reset = am35x_musb_reset,
  72. };
  73. static struct musb_hdrc_platform_data musb_plat = {
  74. #if defined(CONFIG_USB_MUSB_HOST)
  75. .mode = MUSB_HOST,
  76. #elif defined(CONFIG_USB_MUSB_GADGET)
  77. .mode = MUSB_PERIPHERAL,
  78. #else
  79. #error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
  80. #endif
  81. .config = &musb_config,
  82. .power = 250,
  83. .platform_ops = &am35x_ops,
  84. .board_data = &musb_board_data,
  85. };
  86. static void am3517_evm_musb_init(void)
  87. {
  88. /*
  89. * Set up USB clock/mode in the DEVCONF2 register.
  90. * USB2.0 PHY reference clock is 13 MHz
  91. */
  92. clrsetbits_le32(&am35x_scm_general_regs->devconf2,
  93. CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
  94. CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
  95. CONF2_VBDTCTEN | CONF2_DATPOL);
  96. musb_register(&musb_plat, &musb_board_data,
  97. (void *)AM35XX_IPSS_USBOTGSS_BASE);
  98. }
  99. #else
  100. #define am3517_evm_musb_init() do {} while (0)
  101. #endif
  102. /*
  103. * Routine: misc_init_r
  104. * Description: Init i2c, ethernet, etc... (done here so udelay works)
  105. */
  106. int misc_init_r(void)
  107. {
  108. u32 reset;
  109. omap_die_id_display();
  110. am3517_evm_musb_init();
  111. /* ensure that the Ethernet module is out of reset */
  112. reset = readl(AM3517_IP_SW_RESET);
  113. reset &= (~CPGMACSS_SW_RST);
  114. writel(reset, AM3517_IP_SW_RESET);
  115. return 0;
  116. }
  117. /*
  118. * Routine: set_muxconf_regs
  119. * Description: Setting up the configuration Mux registers specific to the
  120. * hardware. Many pins need to be moved from protect to primary
  121. * mode.
  122. */
  123. void set_muxconf_regs(void)
  124. {
  125. MUX_AM3517EVM();
  126. }
  127. #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
  128. int board_eth_init(struct bd_info *bis)
  129. {
  130. int rv, n = 0;
  131. rv = cpu_eth_init(bis);
  132. if (rv > 0)
  133. n += rv;
  134. rv = usb_eth_initialize(bis);
  135. if (rv > 0)
  136. n += rv;
  137. return n;
  138. }
  139. #endif