blob: f9f22b0ea451631177b6a993a4caa113081db136 [file] [log] [blame]
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +05301/**
2 * io.h - DesignWare USB3 DRD IO Header
3 *
Kishon Vijay Abraham I30c31d52015-02-23 18:39:52 +05304 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +05305 *
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
Kishon Vijay Abraham I30c31d52015-02-23 18:39:52 +05309 * Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/io.h) and ported
10 * to uboot.
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053011 *
Kishon Vijay Abraham I30c31d52015-02-23 18:39:52 +053012 * commit 2c4cbe6e5a : usb: dwc3: add tracepoints to aid debugging
13 *
14 * SPDX-License-Identifier: GPL-2.0
15 *
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053016 */
17
18#ifndef __DRIVERS_USB_DWC3_IO_H
19#define __DRIVERS_USB_DWC3_IO_H
20
21#include <linux/io.h>
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053022#include "debug.h"
23#include "core.h"
24
25static inline u32 dwc3_readl(void __iomem *base, u32 offset)
26{
27 u32 offs = offset - DWC3_GLOBALS_REGS_START;
28 u32 value;
29
30 /*
31 * We requested the mem region starting from the Globals address
32 * space, see dwc3_probe in core.c.
33 * However, the offsets are given starting from xHCI address space.
34 */
35 value = readl(base + offs);
36
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053037 return value;
38}
39
40static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
41{
42 u32 offs = offset - DWC3_GLOBALS_REGS_START;
43
44 /*
45 * We requested the mem region starting from the Globals address
46 * space, see dwc3_probe in core.c.
47 * However, the offsets are given starting from xHCI address space.
48 */
49 writel(value, base + offs);
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053050}
51
52#endif /* __DRIVERS_USB_DWC3_IO_H */