ehci-exynos.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * SAMSUNG EXYNOS USB HOST EHCI Controller
  3. *
  4. * Copyright (C) 2012 Samsung Electronics Co.Ltd
  5. * Vivek Gautam <gautam.vivek@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. * MA 02110-1301 USA
  21. */
  22. #include <common.h>
  23. #include <usb.h>
  24. #include <asm/arch/cpu.h>
  25. #include <asm/arch/ehci.h>
  26. #include <asm/arch/system.h>
  27. #include <asm/arch/power.h>
  28. #include "ehci.h"
  29. #include "ehci-core.h"
  30. /* Setup the EHCI host controller. */
  31. static void setup_usb_phy(struct exynos_usb_phy *usb)
  32. {
  33. set_usbhost_mode(USB20_PHY_CFG_HOST_LINK_EN);
  34. set_usbhost_phy_ctrl(POWER_USB_HOST_PHY_CTRL_EN);
  35. clrbits_le32(&usb->usbphyctrl0,
  36. HOST_CTRL0_FSEL_MASK |
  37. HOST_CTRL0_COMMONON_N |
  38. /* HOST Phy setting */
  39. HOST_CTRL0_PHYSWRST |
  40. HOST_CTRL0_PHYSWRSTALL |
  41. HOST_CTRL0_SIDDQ |
  42. HOST_CTRL0_FORCESUSPEND |
  43. HOST_CTRL0_FORCESLEEP);
  44. setbits_le32(&usb->usbphyctrl0,
  45. /* Setting up the ref freq */
  46. (CLK_24MHZ << 16) |
  47. /* HOST Phy setting */
  48. HOST_CTRL0_LINKSWRST |
  49. HOST_CTRL0_UTMISWRST);
  50. udelay(10);
  51. clrbits_le32(&usb->usbphyctrl0,
  52. HOST_CTRL0_LINKSWRST |
  53. HOST_CTRL0_UTMISWRST);
  54. udelay(20);
  55. /* EHCI Ctrl setting */
  56. setbits_le32(&usb->ehcictrl,
  57. EHCICTRL_ENAINCRXALIGN |
  58. EHCICTRL_ENAINCR4 |
  59. EHCICTRL_ENAINCR8 |
  60. EHCICTRL_ENAINCR16);
  61. }
  62. /* Reset the EHCI host controller. */
  63. static void reset_usb_phy(struct exynos_usb_phy *usb)
  64. {
  65. /* HOST_PHY reset */
  66. setbits_le32(&usb->usbphyctrl0,
  67. HOST_CTRL0_PHYSWRST |
  68. HOST_CTRL0_PHYSWRSTALL |
  69. HOST_CTRL0_SIDDQ |
  70. HOST_CTRL0_FORCESUSPEND |
  71. HOST_CTRL0_FORCESLEEP);
  72. set_usbhost_phy_ctrl(POWER_USB_HOST_PHY_CTRL_DISABLE);
  73. }
  74. /*
  75. * EHCI-initialization
  76. * Create the appropriate control structures to manage
  77. * a new EHCI host controller.
  78. */
  79. int ehci_hcd_init(void)
  80. {
  81. struct exynos_usb_phy *usb;
  82. usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy();
  83. setup_usb_phy(usb);
  84. hccr = (struct ehci_hccr *)samsung_get_base_usb_ehci();
  85. hcor = (struct ehci_hcor *)((uint32_t) hccr
  86. + HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
  87. debug("Exynos5-ehci: init hccr %x and hcor %x hc_length %d\n",
  88. (uint32_t)hccr, (uint32_t)hcor,
  89. (uint32_t)HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
  90. return 0;
  91. }
  92. /*
  93. * Destroy the appropriate control structures corresponding
  94. * the EHCI host controller.
  95. */
  96. int ehci_hcd_stop()
  97. {
  98. struct exynos_usb_phy *usb;
  99. usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy();
  100. reset_usb_phy(usb);
  101. return 0;
  102. }