]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - drivers/usb/dwc3/io.h
usb: dwc3: Modify the file headers to u-boot format
[karo-tx-uboot.git] / drivers / usb / dwc3 / io.h
1 /**
2  * io.h - DesignWare USB3 DRD IO Header
3  *
4  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
5  *
6  * Authors: Felipe Balbi <balbi@ti.com>,
7  *          Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8  *
9  * Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/io.h) and ported
10  * to uboot.
11  *
12  * commit 2c4cbe6e5a : usb: dwc3: add tracepoints to aid debugging
13  *
14  * SPDX-License-Identifier:     GPL-2.0
15  *
16  */
17
18 #ifndef __DRIVERS_USB_DWC3_IO_H
19 #define __DRIVERS_USB_DWC3_IO_H
20
21 #include <linux/io.h>
22 #include "trace.h"
23 #include "debug.h"
24 #include "core.h"
25
26 static inline u32 dwc3_readl(void __iomem *base, u32 offset)
27 {
28         u32 offs = offset - DWC3_GLOBALS_REGS_START;
29         u32 value;
30
31         /*
32          * We requested the mem region starting from the Globals address
33          * space, see dwc3_probe in core.c.
34          * However, the offsets are given starting from xHCI address space.
35          */
36         value = readl(base + offs);
37
38         /*
39          * When tracing we want to make it easy to find the correct address on
40          * documentation, so we revert it back to the proper addresses, the
41          * same way they are described on SNPS documentation
42          */
43         dwc3_trace(trace_dwc3_readl, "addr %p value %08x",
44                         base - DWC3_GLOBALS_REGS_START + offset, value);
45
46         return value;
47 }
48
49 static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
50 {
51         u32 offs = offset - DWC3_GLOBALS_REGS_START;
52
53         /*
54          * We requested the mem region starting from the Globals address
55          * space, see dwc3_probe in core.c.
56          * However, the offsets are given starting from xHCI address space.
57          */
58         writel(value, base + offs);
59
60         /*
61          * When tracing we want to make it easy to find the correct address on
62          * documentation, so we revert it back to the proper addresses, the
63          * same way they are described on SNPS documentation
64          */
65         dwc3_trace(trace_dwc3_writel, "addr %p value %08x",
66                         base - DWC3_GLOBALS_REGS_START + offset, value);
67 }
68
69 #endif /* __DRIVERS_USB_DWC3_IO_H */