Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 1 | /** |
| 2 | * io.h - DesignWare USB3 DRD IO Header |
| 3 | * |
Kishon Vijay Abraham I | 30c31d5 | 2015-02-23 18:39:52 +0530 | [diff] [blame] | 4 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 5 | * |
| 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
| 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
| 8 | * |
Kishon Vijay Abraham I | 30c31d5 | 2015-02-23 18:39:52 +0530 | [diff] [blame] | 9 | * Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/io.h) and ported |
| 10 | * to uboot. |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 11 | * |
Kishon Vijay Abraham I | 30c31d5 | 2015-02-23 18:39:52 +0530 | [diff] [blame] | 12 | * commit 2c4cbe6e5a : usb: dwc3: add tracepoints to aid debugging |
| 13 | * |
| 14 | * SPDX-License-Identifier: GPL-2.0 |
| 15 | * |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #ifndef __DRIVERS_USB_DWC3_IO_H |
| 19 | #define __DRIVERS_USB_DWC3_IO_H |
| 20 | |
Kishon Vijay Abraham I | 9848e57 | 2015-02-23 18:39:54 +0530 | [diff] [blame] | 21 | #include <asm/io.h> |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 22 | |
Kishon Vijay Abraham I | 526a50f | 2015-02-23 18:40:13 +0530 | [diff] [blame] | 23 | #define CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 24 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) |
| 25 | { |
Michal Simek | 01c94c4 | 2015-10-30 16:24:06 +0100 | [diff] [blame] | 26 | unsigned long offs = offset - DWC3_GLOBALS_REGS_START; |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 27 | 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 I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 36 | return value; |
| 37 | } |
| 38 | |
| 39 | static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) |
| 40 | { |
Michal Simek | 01c94c4 | 2015-10-30 16:24:06 +0100 | [diff] [blame] | 41 | unsigned long offs = offset - DWC3_GLOBALS_REGS_START; |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 42 | |
| 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 I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 49 | } |
| 50 | |
Kishon Vijay Abraham I | 526a50f | 2015-02-23 18:40:13 +0530 | [diff] [blame] | 51 | static inline void dwc3_flush_cache(int addr, int length) |
| 52 | { |
| 53 | flush_dcache_range(addr, addr + ROUND(length, CACHELINE_SIZE)); |
| 54 | } |
Kishon Vijay Abraham I | 85d5e70 | 2015-02-23 18:39:50 +0530 | [diff] [blame] | 55 | #endif /* __DRIVERS_USB_DWC3_IO_H */ |