board.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * board.c
  3. *
  4. * Common board functions for AM33XX based boards
  5. *
  6. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <common.h>
  19. #include <errno.h>
  20. #include <spl.h>
  21. #include <asm/arch/cpu.h>
  22. #include <asm/arch/hardware.h>
  23. #include <asm/arch/omap.h>
  24. #include <asm/arch/ddr_defs.h>
  25. #include <asm/arch/clock.h>
  26. #include <asm/arch/gpio.h>
  27. #include <asm/arch/mmc_host_def.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <asm/io.h>
  30. #include <asm/emif.h>
  31. #include <asm/gpio.h>
  32. #include <i2c.h>
  33. #include <miiphy.h>
  34. #include <cpsw.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 <asm/omap_musb.h>
  40. DECLARE_GLOBAL_DATA_PTR;
  41. static const struct gpio_bank gpio_bank_am33xx[4] = {
  42. { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX },
  43. { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX },
  44. { (void *)AM33XX_GPIO2_BASE, METHOD_GPIO_24XX },
  45. { (void *)AM33XX_GPIO3_BASE, METHOD_GPIO_24XX },
  46. };
  47. const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
  48. #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
  49. int cpu_mmc_init(bd_t *bis)
  50. {
  51. int ret;
  52. ret = omap_mmc_init(0, 0, 0);
  53. if (ret)
  54. return ret;
  55. return omap_mmc_init(1, 0, 0);
  56. }
  57. #endif
  58. void setup_clocks_for_console(void)
  59. {
  60. /* Not yet implemented */
  61. return;
  62. }
  63. /* AM33XX has two MUSB controllers which can be host or gadget */
  64. #if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) && \
  65. (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1))
  66. static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
  67. /* USB 2.0 PHY Control */
  68. #define CM_PHY_PWRDN (1 << 0)
  69. #define CM_PHY_OTG_PWRDN (1 << 1)
  70. #define OTGVDET_EN (1 << 19)
  71. #define OTGSESSENDEN (1 << 20)
  72. static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr)
  73. {
  74. if (on) {
  75. clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN,
  76. OTGVDET_EN | OTGSESSENDEN);
  77. } else {
  78. clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
  79. }
  80. }
  81. static struct musb_hdrc_config musb_config = {
  82. .multipoint = 1,
  83. .dyn_fifo = 1,
  84. .num_eps = 16,
  85. .ram_bits = 12,
  86. };
  87. #ifdef CONFIG_AM335X_USB0
  88. static void am33xx_otg0_set_phy_power(u8 on)
  89. {
  90. am33xx_usb_set_phy_power(on, &cdev->usb_ctrl0);
  91. }
  92. struct omap_musb_board_data otg0_board_data = {
  93. .set_phy_power = am33xx_otg0_set_phy_power,
  94. };
  95. static struct musb_hdrc_platform_data otg0_plat = {
  96. .mode = CONFIG_AM335X_USB0_MODE,
  97. .config = &musb_config,
  98. .power = 50,
  99. .platform_ops = &musb_dsps_ops,
  100. .board_data = &otg0_board_data,
  101. };
  102. #endif
  103. #ifdef CONFIG_AM335X_USB1
  104. static void am33xx_otg1_set_phy_power(u8 on)
  105. {
  106. am33xx_usb_set_phy_power(on, &cdev->usb_ctrl1);
  107. }
  108. struct omap_musb_board_data otg1_board_data = {
  109. .set_phy_power = am33xx_otg1_set_phy_power,
  110. };
  111. static struct musb_hdrc_platform_data otg1_plat = {
  112. .mode = CONFIG_AM335X_USB1_MODE,
  113. .config = &musb_config,
  114. .power = 50,
  115. .platform_ops = &musb_dsps_ops,
  116. .board_data = &otg1_board_data,
  117. };
  118. #endif
  119. #endif
  120. int arch_misc_init(void)
  121. {
  122. #ifdef CONFIG_AM335X_USB0
  123. musb_register(&otg0_plat, &otg0_board_data,
  124. (void *)AM335X_USB0_OTG_BASE);
  125. #endif
  126. #ifdef CONFIG_AM335X_USB1
  127. musb_register(&otg1_plat, &otg1_board_data,
  128. (void *)AM335X_USB1_OTG_BASE);
  129. #endif
  130. return 0;
  131. }