Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 2 | /** |
| 3 | * io.h - DesignWare USB3 DRD IO Header |
| 4 | * |
Kishon Vijay Abraham I | 30c31d5 | 2015-02-23 18:39:52 +0530 | [diff] [blame] | 5 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 6 | * |
| 7 | * Authors: Felipe Balbi <balbi@ti.com>, |
| 8 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
| 9 | * |
Kishon Vijay Abraham I | 30c31d5 | 2015-02-23 18:39:52 +0530 | [diff] [blame] | 10 | * Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/io.h) and ported |
| 11 | * to uboot. |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 12 | * |
Kishon Vijay Abraham I | 30c31d5 | 2015-02-23 18:39:52 +0530 | [diff] [blame] | 13 | * commit 2c4cbe6e5a : usb: dwc3: add tracepoints to aid debugging |
| 14 | * |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef __DRIVERS_USB_DWC3_IO_H |
| 18 | #define __DRIVERS_USB_DWC3_IO_H |
| 19 | |
Kishon Vijay Abraham I | 9848e57 | 2015-02-23 18:39:54 +0530 | [diff] [blame] | 20 | #include <asm/io.h> |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 21 | |
Kishon Vijay Abraham I | 526a50f | 2015-02-23 18:40:13 +0530 | [diff] [blame] | 22 | #define CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 23 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) |
| 24 | { |
Michal Simek | 01c94c4 | 2015-10-30 16:24:06 +0100 | [diff] [blame] | 25 | unsigned long offs = offset - DWC3_GLOBALS_REGS_START; |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 26 | u32 value; |
| 27 | |
| 28 | /* |
| 29 | * We requested the mem region starting from the Globals address |
| 30 | * space, see dwc3_probe in core.c. |
| 31 | * However, the offsets are given starting from xHCI address space. |
| 32 | */ |
| 33 | value = readl(base + offs); |
| 34 | |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 35 | return value; |
| 36 | } |
| 37 | |
| 38 | static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) |
| 39 | { |
Michal Simek | 01c94c4 | 2015-10-30 16:24:06 +0100 | [diff] [blame] | 40 | unsigned long offs = offset - DWC3_GLOBALS_REGS_START; |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 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 + offs); |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 48 | } |
| 49 | |
Philipp Tomsich | b7bf4a9 | 2017-04-06 16:58:52 +0200 | [diff] [blame] | 50 | static inline void dwc3_flush_cache(uintptr_t addr, int length) |
Kishon Vijay Abraham I | 526a50f | 2015-02-23 18:40:13 +0530 | [diff] [blame] | 51 | { |
| 52 | flush_dcache_range(addr, addr + ROUND(length, CACHELINE_SIZE)); |
| 53 | } |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 54 | #endif /* __DRIVERS_USB_DWC3_IO_H */ |