am35x_musb.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * This file configures the internal USB PHY in AM35X.
  3. *
  4. * Copyright (C) 2012 Ilya Yanok <ilya.yanok@gmail.com>
  5. *
  6. * Based on omap_phy_internal.c code from Linux by
  7. * Hema HK <hemahk@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc.
  22. *
  23. */
  24. #include <common.h>
  25. #include <asm/io.h>
  26. #include <asm/arch/am35x_def.h>
  27. void am35x_musb_reset(void)
  28. {
  29. /* Reset the musb interface */
  30. clrsetbits_le32(&am35x_scm_general_regs->ip_sw_reset,
  31. 0, USBOTGSS_SW_RST);
  32. clrsetbits_le32(&am35x_scm_general_regs->ip_sw_reset,
  33. USBOTGSS_SW_RST, 0);
  34. }
  35. void am35x_musb_phy_power(u8 on)
  36. {
  37. unsigned long start = get_timer(0);
  38. if (on) {
  39. /*
  40. * Start the on-chip PHY and its PLL.
  41. */
  42. clrsetbits_le32(&am35x_scm_general_regs->devconf2,
  43. CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN,
  44. CONF2_PHY_PLLON);
  45. debug("Waiting for PHY clock good...\n");
  46. while (!(readl(&am35x_scm_general_regs->devconf2)
  47. & CONF2_PHYCLKGD)) {
  48. if (get_timer(start) > CONFIG_SYS_HZ / 10) {
  49. printf("musb PHY clock good timed out\n");
  50. break;
  51. }
  52. }
  53. } else {
  54. /*
  55. * Power down the on-chip PHY.
  56. */
  57. clrsetbits_le32(&am35x_scm_general_regs->devconf2,
  58. CONF2_PHY_PLLON,
  59. CONF2_PHYPWRDN | CONF2_OTGPWRDN);
  60. }
  61. }
  62. void am35x_musb_clear_irq(void)
  63. {
  64. clrsetbits_le32(&am35x_scm_general_regs->lvl_intr_clr,
  65. 0, USBOTGSS_INT_CLR);
  66. readl(&am35x_scm_general_regs->lvl_intr_clr);
  67. }