am3517evm.c 3.7 KB

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