ehci-spear.c 1.7 KB

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