ehci-spear.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <log.h>
  12. #include <asm/io.h>
  13. #include <usb.h>
  14. #include <linux/delay.h>
  15. #include "ehci.h"
  16. #include <asm/arch/hardware.h>
  17. #include <asm/arch/spr_misc.h>
  18. static void spear6xx_usbh_stop(void)
  19. {
  20. struct misc_regs *const misc_p =
  21. (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
  22. u32 periph1_rst = readl(misc_p->periph1_rst);
  23. periph1_rst |= PERIPH_USBH1 | PERIPH_USBH2;
  24. writel(periph1_rst, misc_p->periph1_rst);
  25. udelay(1000);
  26. periph1_rst &= ~(PERIPH_USBH1 | PERIPH_USBH2);
  27. writel(periph1_rst, misc_p->periph1_rst);
  28. }
  29. /*
  30. * Create the appropriate control structures to manage
  31. * a new EHCI host controller.
  32. */
  33. int ehci_hcd_init(int index, enum usb_init_type init,
  34. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  35. {
  36. u32 ehci = 0;
  37. switch (index) {
  38. case 0:
  39. ehci = CONFIG_SYS_UHC0_EHCI_BASE;
  40. break;
  41. case 1:
  42. ehci = CONFIG_SYS_UHC1_EHCI_BASE;
  43. break;
  44. default:
  45. printf("ERROR: wrong controller index!\n");
  46. break;
  47. };
  48. *hccr = (struct ehci_hccr *)(ehci + 0x100);
  49. *hcor = (struct ehci_hcor *)((uint32_t) *hccr +
  50. HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  51. debug("SPEAr-ehci: init hccr %x and hcor %x hc_length %d\n",
  52. (uint32_t)*hccr, (uint32_t)*hcor,
  53. (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  54. return 0;
  55. }
  56. /*
  57. * Destroy the appropriate control structures corresponding
  58. * the the EHCI host controller.
  59. */
  60. int ehci_hcd_stop(int index)
  61. {
  62. #if defined(CONFIG_SPEAR600)
  63. spear6xx_usbh_stop();
  64. #endif
  65. return 0;
  66. }