io.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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(void __iomem *base, u32 offset)
  17. {
  18. u32 value;
  19. /*
  20. * We requested the mem region starting from the Globals address
  21. * space, see dwc3_probe in core.c.
  22. * However, the offsets are given starting from xHCI address space.
  23. */
  24. value = readl(base + offset - DWC3_GLOBALS_REGS_START);
  25. /*
  26. * When tracing we want to make it easy to find the correct address on
  27. * documentation, so we revert it back to the proper addresses, the
  28. * same way they are described on SNPS documentation
  29. */
  30. trace_dwc3_readl(base - DWC3_GLOBALS_REGS_START, offset, value);
  31. return value;
  32. }
  33. static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
  34. {
  35. /*
  36. * We requested the mem region starting from the Globals address
  37. * space, see dwc3_probe in core.c.
  38. * However, the offsets are given starting from xHCI address space.
  39. */
  40. writel(value, base + offset - DWC3_GLOBALS_REGS_START);
  41. /*
  42. * When tracing we want to make it easy to find the correct address on
  43. * documentation, so we revert it back to the proper addresses, the
  44. * same way they are described on SNPS documentation
  45. */
  46. trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value);
  47. }
  48. #endif /* __DRIVERS_USB_DWC3_IO_H */