ehci-uniphier.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2014 Panasonic Corporation
  3. * Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <linux/err.h>
  9. #include <usb.h>
  10. #include <asm/arch/ehci-uniphier.h>
  11. #include "ehci.h"
  12. #ifdef CONFIG_OF_CONTROL
  13. #include <fdtdec.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. #define FDT gd->fdt_blob
  16. #define COMPAT "panasonic,uniphier-ehci"
  17. static int get_uniphier_ehci_base(int index, struct ehci_hccr **base)
  18. {
  19. int offset;
  20. for (offset = fdt_node_offset_by_compatible(FDT, 0, COMPAT);
  21. offset >= 0;
  22. offset = fdt_node_offset_by_compatible(FDT, offset, COMPAT)) {
  23. if (index == 0) {
  24. *base = (struct ehci_hccr *)
  25. fdtdec_get_addr(FDT, offset, "reg");
  26. return 0;
  27. }
  28. index--;
  29. }
  30. return -ENODEV; /* not found */
  31. }
  32. #else
  33. static int get_uniphier_ehci_base(int index, struct ehci_hccr **base)
  34. {
  35. *base = (struct ehci_hccr *)uniphier_ehci_platdata[index].base;
  36. return 0;
  37. }
  38. #endif
  39. /*
  40. * Create the appropriate control structures to manage
  41. * a new EHCI host controller.
  42. */
  43. int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
  44. struct ehci_hcor **hcor)
  45. {
  46. int ret;
  47. struct ehci_hccr *cr;
  48. struct ehci_hcor *or;
  49. uniphier_ehci_reset(index, 0);
  50. ret = get_uniphier_ehci_base(index, &cr);
  51. if (ret < 0)
  52. return ret;
  53. or = (void *)cr + HC_LENGTH(ehci_readl(&cr->cr_capbase));
  54. *hccr = cr;
  55. *hcor = or;
  56. return 0;
  57. }
  58. int ehci_hcd_stop(int index)
  59. {
  60. uniphier_ehci_reset(index, 1);
  61. return 0;
  62. }