ehci-atmel.c 846 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * (C) Copyright 2012
  3. * Atmel Semiconductor <www.atmel.com>
  4. * Written-by: Bo Shen <voice.shen@atmel.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <usb.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/clk.h>
  12. #include "ehci.h"
  13. int ehci_hcd_init(int index, enum usb_init_type init,
  14. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  15. {
  16. /* Enable UTMI PLL */
  17. if (at91_upll_clk_enable())
  18. return -1;
  19. /* Enable USB Host clock */
  20. at91_periph_clk_enable(ATMEL_ID_UHPHS);
  21. *hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI;
  22. *hcor = (struct ehci_hcor *)((uint32_t)*hccr +
  23. HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  24. return 0;
  25. }
  26. int ehci_hcd_stop(int index)
  27. {
  28. /* Disable USB Host Clock */
  29. at91_periph_clk_disable(ATMEL_ID_UHPHS);
  30. /* Disable UTMI PLL */
  31. if (at91_upll_clk_disable())
  32. return -1;
  33. return 0;
  34. }