Loading...
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 - https://www.ti.com
6 *
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9 */
10
11#ifndef __DRIVERS_USB_DWC3_IO_H
12#define __DRIVERS_USB_DWC3_IO_H
13
14#include <linux/io.h>
15#include "trace.h"
16#include "debug.h"
17#include "core.h"
18
19static inline u32 dwc3_readl(void __iomem *base, u32 offset)
20{
21 u32 value;
22
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 */
28 value = readl(base + offset - DWC3_GLOBALS_REGS_START);
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 */
35 trace_dwc3_readl(base - DWC3_GLOBALS_REGS_START, offset, value);
36
37 return value;
38}
39
40static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
41{
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 */
47 writel(value, base + offset - DWC3_GLOBALS_REGS_START);
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 */
54 trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value);
55}
56
57#endif /* __DRIVERS_USB_DWC3_IO_H */
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 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions, and the following disclaimer,
14 * without modification.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The names of the above-listed copyright holders may not be used
19 * to endorse or promote products derived from this software without
20 * specific prior written permission.
21 *
22 * ALTERNATIVELY, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") version 2, as published by the Free
24 * Software Foundation.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
27 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef __DRIVERS_USB_DWC3_IO_H
40#define __DRIVERS_USB_DWC3_IO_H
41
42#include <linux/io.h>
43
44#include "core.h"
45
46static inline u32 dwc3_readl(void __iomem *base, u32 offset)
47{
48 /*
49 * We requested the mem region starting from the Globals address
50 * space, see dwc3_probe in core.c.
51 * However, the offsets are given starting from xHCI address space.
52 */
53 return readl(base + (offset - DWC3_GLOBALS_REGS_START));
54}
55
56static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
57{
58 /*
59 * We requested the mem region starting from the Globals address
60 * space, see dwc3_probe in core.c.
61 * However, the offsets are given starting from xHCI address space.
62 */
63 writel(value, base + (offset - DWC3_GLOBALS_REGS_START));
64}
65
66#endif /* __DRIVERS_USB_DWC3_IO_H */