io.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 offs = offset - DWC3_GLOBALS_REGS_START;
  27. u32 value;
  28. /*
  29. * We requested the mem region starting from the Globals address
  30. * space, see dwc3_probe in core.c.
  31. * However, the offsets are given starting from xHCI address space.
  32. */
  33. value = readl(base + offs);
  34. /*
  35. * When tracing we want to make it easy to find the correct address on
  36. * documentation, so we revert it back to the proper addresses, the
  37. * same way they are described on SNPS documentation
  38. */
  39. dwc3_trace(trace_dwc3_readl, "addr %p value %08x",
  40. base - DWC3_GLOBALS_REGS_START + offset, value);
  41. return value;
  42. }
  43. static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
  44. {
  45. u32 offs = offset - DWC3_GLOBALS_REGS_START;
  46. /*
  47. * We requested the mem region starting from the Globals address
  48. * space, see dwc3_probe in core.c.
  49. * However, the offsets are given starting from xHCI address space.
  50. */
  51. writel(value, base + offs);
  52. /*
  53. * When tracing we want to make it easy to find the correct address on
  54. * documentation, so we revert it back to the proper addresses, the
  55. * same way they are described on SNPS documentation
  56. */
  57. dwc3_trace(trace_dwc3_writel, "addr %p value %08x",
  58. base - DWC3_GLOBALS_REGS_START + offset, value);
  59. }
  60. #endif /* __DRIVERS_USB_DWC3_IO_H */