ehci-spear.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010
  4. * Armando Visconti, ST Micoelectronics, <armando.visconti@st.com>.
  5. *
  6. * (C) Copyright 2009
  7. * Marvell Semiconductor <www.marvell.com>
  8. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  9. */
  10. #include <common.h>
  11. #include <asm/io.h>
  12. #include <usb.h>
  13. #include "ehci.h"
  14. #include <asm/arch/hardware.h>
  15. #include <asm/arch/spr_misc.h>
  16. static void spear6xx_usbh_stop(void)
  17. {
  18. struct misc_regs *const misc_p =
  19. (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
  20. u32 periph1_rst = readl(misc_p->periph1_rst);
  21. periph1_rst |= PERIPH_USBH1 | PERIPH_USBH2;
  22. writel(periph1_rst, misc_p->periph1_rst);
  23. udelay(1000);
  24. periph1_rst &= ~(PERIPH_USBH1 | PERIPH_USBH2);
  25. writel(periph1_rst, misc_p->periph1_rst);
  26. }
  27. /*
  28. * Create the appropriate control structures to manage
  29. * a new EHCI host controller.
  30. */
  31. int ehci_hcd_init(int index, enum usb_init_type init,
  32. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  33. {
  34. u32 ehci = 0;
  35. switch (index) {
  36. case 0:
  37. ehci = CONFIG_SYS_UHC0_EHCI_BASE;
  38. break;
  39. case 1:
  40. ehci = CONFIG_SYS_UHC1_EHCI_BASE;
  41. break;
  42. default:
  43. printf("ERROR: wrong controller index!\n");
  44. break;
  45. };
  46. *hccr = (struct ehci_hccr *)(ehci + 0x100);
  47. *hcor = (struct ehci_hcor *)((uint32_t) *hccr +
  48. HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  49. debug("SPEAr-ehci: init hccr %x and hcor %x hc_length %d\n",
  50. (uint32_t)*hccr, (uint32_t)*hcor,
  51. (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  52. return 0;
  53. }
  54. /*
  55. * Destroy the appropriate control structures corresponding
  56. * the the EHCI host controller.
  57. */
  58. int ehci_hcd_stop(int index)
  59. {
  60. #if defined(CONFIG_SPEAR600)
  61. spear6xx_usbh_stop();
  62. #endif
  63. return 0;
  64. }