Linux Audio

Check our new training course

Loading...
v6.8
 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 */
v4.6
 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
19#ifndef __DRIVERS_USB_DWC3_IO_H
20#define __DRIVERS_USB_DWC3_IO_H
21
22#include <linux/io.h>
23#include "trace.h"
24#include "debug.h"
25#include "core.h"
26
27static inline u32 dwc3_readl(void __iomem *base, u32 offset)
28{
29	u32 offs = offset - DWC3_GLOBALS_REGS_START;
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 + offs);
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	dwc3_trace(trace_dwc3_readl, "addr %p value %08x",
45			base - DWC3_GLOBALS_REGS_START + offset, value);
46
47	return value;
48}
49
50static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
51{
52	u32 offs = offset - DWC3_GLOBALS_REGS_START;
53
54	/*
55	 * We requested the mem region starting from the Globals address
56	 * space, see dwc3_probe in core.c.
57	 * However, the offsets are given starting from xHCI address space.
58	 */
59	writel(value, base + offs);
60
61	/*
62	 * When tracing we want to make it easy to find the correct address on
63	 * documentation, so we revert it back to the proper addresses, the
64	 * same way they are described on SNPS documentation
65	 */
66	dwc3_trace(trace_dwc3_writel, "addr %p value %08x",
67			base - DWC3_GLOBALS_REGS_START + offset, value);
68}
69
70#endif /* __DRIVERS_USB_DWC3_IO_H */