]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/usb/dwc3/io.h
USB: add SPDX identifiers to all remaining files in drivers/usb/
[mirror_ubuntu-jammy-kernel.git] / drivers / usb / dwc3 / io.h
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 - http://www.ti.com
6 *
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 of
12 * the License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20 #ifndef __DRIVERS_USB_DWC3_IO_H
21 #define __DRIVERS_USB_DWC3_IO_H
22
23 #include <linux/io.h>
24 #include "trace.h"
25 #include "debug.h"
26 #include "core.h"
27
28 static inline u32 dwc3_readl(void __iomem *base, u32 offset)
29 {
30 u32 value;
31
32 /*
33 * We requested the mem region starting from the Globals address
34 * space, see dwc3_probe in core.c.
35 * However, the offsets are given starting from xHCI address space.
36 */
37 value = readl(base + offset - DWC3_GLOBALS_REGS_START);
38
39 /*
40 * When tracing we want to make it easy to find the correct address on
41 * documentation, so we revert it back to the proper addresses, the
42 * same way they are described on SNPS documentation
43 */
44 trace_dwc3_readl(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 /*
52 * We requested the mem region starting from the Globals address
53 * space, see dwc3_probe in core.c.
54 * However, the offsets are given starting from xHCI address space.
55 */
56 writel(value, base + offset - DWC3_GLOBALS_REGS_START);
57
58 /*
59 * When tracing we want to make it easy to find the correct address on
60 * documentation, so we revert it back to the proper addresses, the
61 * same way they are described on SNPS documentation
62 */
63 trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value);
64 }
65
66 #endif /* __DRIVERS_USB_DWC3_IO_H */