blob: 1e96ea339d48d03036391c8c04a74898b66f8ace [file] [log] [blame]
Nishad Kamdarb33f69f2020-03-28 15:34:46 +05301/* SPDX-License-Identifier: GPL-2.0 */
Aditya Srivastava27088e002021-03-29 19:21:08 +05302/*
Felipe Balbi72246da2011-08-19 18:10:58 +03003 * io.h - DesignWare USB3 DRD IO Header
4 *
Alexander A. Klimov10623b82020-07-11 15:58:04 +02005 * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com
Felipe Balbi72246da2011-08-19 18:10:58 +03006 *
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Felipe Balbi72246da2011-08-19 18:10:58 +03009 */
10
11#ifndef __DRIVERS_USB_DWC3_IO_H
12#define __DRIVERS_USB_DWC3_IO_H
13
Felipe Balbi25b8ff62011-11-04 12:32:47 +020014#include <linux/io.h>
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050015#include "trace.h"
16#include "debug.h"
Ido Shayevitz51249dc2012-04-24 14:18:39 +030017#include "core.h"
18
Felipe Balbi72246da2011-08-19 18:10:58 +030019static inline u32 dwc3_readl(void __iomem *base, u32 offset)
20{
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050021 u32 value;
22
Ido Shayevitz51249dc2012-04-24 14:18:39 +030023 /*
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 */
Felipe Balbi2eb88012016-04-12 16:53:39 +030028 value = readl(base + offset - DWC3_GLOBALS_REGS_START);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050029
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 */
Felipe Balbi4dd5a692016-09-30 15:52:19 +030035 trace_dwc3_readl(base - DWC3_GLOBALS_REGS_START, offset, value);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050036
37 return value;
Felipe Balbi72246da2011-08-19 18:10:58 +030038}
39
40static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
41{
Ido Shayevitz51249dc2012-04-24 14:18:39 +030042 /*
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 */
Felipe Balbi2eb88012016-04-12 16:53:39 +030047 writel(value, base + offset - DWC3_GLOBALS_REGS_START);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050048
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 */
Felipe Balbi4dd5a692016-09-30 15:52:19 +030054 trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value);
Felipe Balbi72246da2011-08-19 18:10:58 +030055}
56
57#endif /* __DRIVERS_USB_DWC3_IO_H */