io.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * io.h - DesignWare USB3 DRD IO Header
  4. *
  5. * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com
  6. *
  7. * Authors: Felipe Balbi <balbi@ti.com>,
  8. * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
  9. */
  10. #ifndef __DRIVERS_USB_DWC3_IO_H
  11. #define __DRIVERS_USB_DWC3_IO_H
  12. #include <linux/io.h>
  13. #include "trace.h"
  14. #include "debug.h"
  15. #include "core.h"
  16. static inline u32 dwc3_readl(struct dwc3 *dwc, u32 offset)
  17. {
  18. u32 value;
  19. void __iomem *base = dwc->regs;
  20. /*
  21. * We requested the mem region starting from the Globals address
  22. * space, see dwc3_probe in core.c.
  23. * However, the offsets are given starting from xHCI address space.
  24. */
  25. value = readl(base + offset - DWC3_GLOBALS_REGS_START);
  26. /*
  27. * When tracing we want to make it easy to find the correct address on
  28. * documentation, so we revert it back to the proper addresses, the
  29. * same way they are described on SNPS documentation
  30. */
  31. trace_dwc3_readl(dwc, base - DWC3_GLOBALS_REGS_START, offset, value);
  32. return value;
  33. }
  34. static inline void dwc3_writel(struct dwc3 *dwc, u32 offset, u32 value)
  35. {
  36. void __iomem *base = dwc->regs;
  37. /*
  38. * We requested the mem region starting from the Globals address
  39. * space, see dwc3_probe in core.c.
  40. * However, the offsets are given starting from xHCI address space.
  41. */
  42. writel(value, base + offset - DWC3_GLOBALS_REGS_START);
  43. /*
  44. * When tracing we want to make it easy to find the correct address on
  45. * documentation, so we revert it back to the proper addresses, the
  46. * same way they are described on SNPS documentation
  47. */
  48. trace_dwc3_writel(dwc, base - DWC3_GLOBALS_REGS_START, offset, value);
  49. }
  50. #endif /* __DRIVERS_USB_DWC3_IO_H */