am3517evm.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <common.h>
  26. #include <asm/io.h>
  27. #include <asm/omap_musb.h>
  28. #include <asm/arch/am35x_def.h>
  29. #include <asm/arch/mem.h>
  30. #include <asm/arch/mux.h>
  31. #include <asm/arch/sys_proto.h>
  32. #include <asm/arch/mmc_host_def.h>
  33. #include <asm/arch/musb.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/errno.h>
  36. #include <linux/usb/ch9.h>
  37. #include <linux/usb/gadget.h>
  38. #include <linux/usb/musb.h>
  39. #include <i2c.h>
  40. #include <netdev.h>
  41. #include "am3517evm.h"
  42. DECLARE_GLOBAL_DATA_PTR;
  43. /*
  44. * Routine: board_init
  45. * Description: Early hardware init.
  46. */
  47. int board_init(void)
  48. {
  49. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  50. /* board id for Linux */
  51. gd->bd->bi_arch_number = MACH_TYPE_OMAP3517EVM;
  52. /* boot param addr */
  53. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  54. return 0;
  55. }
  56. #ifdef CONFIG_USB_MUSB_AM35X
  57. static struct musb_hdrc_config musb_config = {
  58. .multipoint = 1,
  59. .dyn_fifo = 1,
  60. .num_eps = 16,
  61. .ram_bits = 12,
  62. };
  63. static struct omap_musb_board_data musb_board_data = {
  64. .set_phy_power = am35x_musb_phy_power,
  65. .clear_irq = am35x_musb_clear_irq,
  66. .reset = am35x_musb_reset,
  67. };
  68. static struct musb_hdrc_platform_data musb_plat = {
  69. #if defined(CONFIG_MUSB_HOST)
  70. .mode = MUSB_HOST,
  71. #elif defined(CONFIG_MUSB_GADGET)
  72. .mode = MUSB_PERIPHERAL,
  73. #else
  74. #error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET"
  75. #endif
  76. .config = &musb_config,
  77. .power = 250,
  78. .platform_ops = &am35x_ops,
  79. .board_data = &musb_board_data,
  80. };
  81. static void am3517_evm_musb_init(void)
  82. {
  83. /*
  84. * Set up USB clock/mode in the DEVCONF2 register.
  85. * USB2.0 PHY reference clock is 13 MHz
  86. */
  87. clrsetbits_le32(&am35x_scm_general_regs->devconf2,
  88. CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE,
  89. CONF2_REFFREQ_13MHZ | CONF2_SESENDEN |
  90. CONF2_VBDTCTEN | CONF2_DATPOL);
  91. musb_register(&musb_plat, &musb_board_data,
  92. (void *)AM35XX_IPSS_USBOTGSS_BASE);
  93. }
  94. #else
  95. #define am3517_evm_musb_init() do {} while (0)
  96. #endif
  97. /*
  98. * Routine: misc_init_r
  99. * Description: Init i2c, ethernet, etc... (done here so udelay works)
  100. */
  101. int misc_init_r(void)
  102. {
  103. #ifdef CONFIG_DRIVER_OMAP34XX_I2C
  104. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  105. #endif
  106. dieid_num_r();
  107. am3517_evm_musb_init();
  108. return 0;
  109. }
  110. /*
  111. * Routine: set_muxconf_regs
  112. * Description: Setting up the configuration Mux registers specific to the
  113. * hardware. Many pins need to be moved from protect to primary
  114. * mode.
  115. */
  116. void set_muxconf_regs(void)
  117. {
  118. MUX_AM3517EVM();
  119. }
  120. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  121. int board_mmc_init(bd_t *bis)
  122. {
  123. omap_mmc_init(0, 0, 0);
  124. return 0;
  125. }
  126. #endif
  127. #if defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)
  128. int board_eth_init(bd_t *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