am3517evm.c 3.4 KB

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