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