am3517evm.c 3.8 KB

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