xhci-pci.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2015, Google, Inc
  3. * Written by Simon Glass <sjg@chromium.org>
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0
  7. */
  8. #include <common.h>
  9. #include <errno.h>
  10. #include <pci.h>
  11. #include <usb.h>
  12. #include "xhci.h"
  13. /*
  14. * Create the appropriate control structures to manage a new XHCI host
  15. * controller.
  16. */
  17. int xhci_hcd_init(int index, struct xhci_hccr **ret_hccr,
  18. struct xhci_hcor **ret_hcor)
  19. {
  20. struct xhci_hccr *hccr;
  21. struct xhci_hcor *hcor;
  22. pci_dev_t pdev;
  23. uint32_t cmd;
  24. int len;
  25. pdev = pci_find_class(PCI_CLASS_SERIAL_USB_XHCI, index);
  26. if (pdev < 0) {
  27. printf("XHCI host controller not found\n");
  28. return -1;
  29. }
  30. hccr = (struct xhci_hccr *)pci_map_bar(pdev,
  31. PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
  32. len = HC_LENGTH(xhci_readl(&hccr->cr_capbase));
  33. hcor = (struct xhci_hcor *)((uint32_t)hccr + len);
  34. debug("XHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n",
  35. (uint32_t)hccr, (uint32_t)hcor, len);
  36. *ret_hccr = hccr;
  37. *ret_hcor = hcor;
  38. /* enable busmaster */
  39. pci_read_config_dword(pdev, PCI_COMMAND, &cmd);
  40. cmd |= PCI_COMMAND_MASTER;
  41. pci_write_config_dword(pdev, PCI_COMMAND, cmd);
  42. return 0;
  43. }
  44. /*
  45. * Destroy the appropriate control structures corresponding * to the XHCI host
  46. * controller
  47. */
  48. void xhci_hcd_stop(int index)
  49. {
  50. }