io.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * io.h - DesignWare USB3 DRD IO Header
  3. *
  4. * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
  5. *
  6. * Authors: Felipe Balbi <balbi@ti.com>,
  7. * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 of
  11. * the License as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef __DRIVERS_USB_DWC3_IO_H
  19. #define __DRIVERS_USB_DWC3_IO_H
  20. #include <linux/io.h>
  21. #include "trace.h"
  22. #include "debug.h"
  23. #include "core.h"
  24. static inline u32 dwc3_readl(void __iomem *base, u32 offset)
  25. {
  26. u32 value;
  27. /*
  28. * We requested the mem region starting from the Globals address
  29. * space, see dwc3_probe in core.c.
  30. * However, the offsets are given starting from xHCI address space.
  31. */
  32. value = readl(base + offset - DWC3_GLOBALS_REGS_START);
  33. /*
  34. * When tracing we want to make it easy to find the correct address on
  35. * documentation, so we revert it back to the proper addresses, the
  36. * same way they are described on SNPS documentation
  37. */
  38. trace_dwc3_readl(base - DWC3_GLOBALS_REGS_START, offset, value);
  39. return value;
  40. }
  41. static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
  42. {
  43. /*
  44. * We requested the mem region starting from the Globals address
  45. * space, see dwc3_probe in core.c.
  46. * However, the offsets are given starting from xHCI address space.
  47. */
  48. writel(value, base + offset - DWC3_GLOBALS_REGS_START);
  49. /*
  50. * When tracing we want to make it easy to find the correct address on
  51. * documentation, so we revert it back to the proper addresses, the
  52. * same way they are described on SNPS documentation
  53. */
  54. trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value);
  55. }
  56. #endif /* __DRIVERS_USB_DWC3_IO_H */