blob: 2407f826c161bad92f4a4f5ad11f3b583f94bc48 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +05302/**
3 * io.h - DesignWare USB3 DRD IO Header
4 *
Kishon Vijay Abraham I30c31d52015-02-23 18:39:52 +05305 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +05306 *
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9 *
Kishon Vijay Abraham I30c31d52015-02-23 18:39:52 +053010 * Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/io.h) and ported
11 * to uboot.
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053012 *
Kishon Vijay Abraham I30c31d52015-02-23 18:39:52 +053013 * commit 2c4cbe6e5a : usb: dwc3: add tracepoints to aid debugging
14 *
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053015 */
16
17#ifndef __DRIVERS_USB_DWC3_IO_H
18#define __DRIVERS_USB_DWC3_IO_H
19
Simon Glass1eb69ae2019-11-14 12:57:39 -070020#include <cpu_func.h>
Kishon Vijay Abraham I9848e572015-02-23 18:39:54 +053021#include <asm/io.h>
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053022
Kishon Vijay Abraham I526a50f2015-02-23 18:40:13 +053023#define CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053024static inline u32 dwc3_readl(void __iomem *base, u32 offset)
25{
Michal Simek01c94c42015-10-30 16:24:06 +010026 unsigned long offs = offset - DWC3_GLOBALS_REGS_START;
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053027 u32 value;
28
29 /*
30 * We requested the mem region starting from the Globals address
31 * space, see dwc3_probe in core.c.
32 * However, the offsets are given starting from xHCI address space.
33 */
34 value = readl(base + offs);
35
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053036 return value;
37}
38
39static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
40{
Michal Simek01c94c42015-10-30 16:24:06 +010041 unsigned long offs = offset - DWC3_GLOBALS_REGS_START;
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053042
43 /*
44 * We requested the mem region starting from the Globals address
45 * space, see dwc3_probe in core.c.
46 * However, the offsets are given starting from xHCI address space.
47 */
48 writel(value, base + offs);
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053049}
50
Philipp Tomsichb7bf4a92017-04-06 16:58:52 +020051static inline void dwc3_flush_cache(uintptr_t addr, int length)
Kishon Vijay Abraham I526a50f2015-02-23 18:40:13 +053052{
53 flush_dcache_range(addr, addr + ROUND(length, CACHELINE_SIZE));
54}
Kishon Vijay Abraham I85d5e702015-02-23 18:39:50 +053055#endif /* __DRIVERS_USB_DWC3_IO_H */