Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1 | /** |
| 2 | * io.h - DesignWare USB3 DRD IO Header |
| 3 | * |
| 4 | * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 5 | * |
| 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
| 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
| 8 | * |
Felipe Balbi | 5945f78 | 2013-06-30 14:15:11 +0300 | [diff] [blame] | 9 | * This program is free software: you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 of |
| 11 | * the License as published by the Free Software Foundation. |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 12 | * |
Felipe Balbi | 5945f78 | 2013-06-30 14:15:11 +0300 | [diff] [blame] | 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #ifndef __DRIVERS_USB_DWC3_IO_H |
| 20 | #define __DRIVERS_USB_DWC3_IO_H |
| 21 | |
Felipe Balbi | 25b8ff6 | 2011-11-04 12:32:47 +0200 | [diff] [blame] | 22 | #include <linux/io.h> |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 23 | #include "trace.h" |
| 24 | #include "debug.h" |
Ido Shayevitz | 51249dc | 2012-04-24 14:18:39 +0300 | [diff] [blame] | 25 | #include "core.h" |
| 26 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 27 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) |
| 28 | { |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 29 | u32 value; |
| 30 | |
Ido Shayevitz | 51249dc | 2012-04-24 14:18:39 +0300 | [diff] [blame] | 31 | /* |
| 32 | * We requested the mem region starting from the Globals address |
| 33 | * space, see dwc3_probe in core.c. |
| 34 | * However, the offsets are given starting from xHCI address space. |
| 35 | */ |
Felipe Balbi | 2eb8801 | 2016-04-12 16:53:39 +0300 | [diff] [blame] | 36 | value = readl(base + offset - DWC3_GLOBALS_REGS_START); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 37 | |
| 38 | /* |
| 39 | * When tracing we want to make it easy to find the correct address on |
| 40 | * documentation, so we revert it back to the proper addresses, the |
| 41 | * same way they are described on SNPS documentation |
| 42 | */ |
Felipe Balbi | 4dd5a69 | 2016-09-30 15:52:19 +0300 | [diff] [blame] | 43 | trace_dwc3_readl(base - DWC3_GLOBALS_REGS_START, offset, value); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 44 | |
| 45 | return value; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) |
| 49 | { |
Ido Shayevitz | 51249dc | 2012-04-24 14:18:39 +0300 | [diff] [blame] | 50 | /* |
| 51 | * We requested the mem region starting from the Globals address |
| 52 | * space, see dwc3_probe in core.c. |
| 53 | * However, the offsets are given starting from xHCI address space. |
| 54 | */ |
Felipe Balbi | 2eb8801 | 2016-04-12 16:53:39 +0300 | [diff] [blame] | 55 | writel(value, base + offset - DWC3_GLOBALS_REGS_START); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 56 | |
| 57 | /* |
| 58 | * When tracing we want to make it easy to find the correct address on |
| 59 | * documentation, so we revert it back to the proper addresses, the |
| 60 | * same way they are described on SNPS documentation |
| 61 | */ |
Felipe Balbi | 4dd5a69 | 2016-09-30 15:52:19 +0300 | [diff] [blame] | 62 | trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | #endif /* __DRIVERS_USB_DWC3_IO_H */ |