Nishad Kamdar | b33f69f | 2020-03-28 15:34:46 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Aditya Srivastava | 27088e00 | 2021-03-29 19:21:08 +0530 | [diff] [blame] | 2 | /* |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 3 | * io.h - DesignWare USB3 DRD IO Header |
| 4 | * |
Alexander A. Klimov | 10623b8 | 2020-07-11 15:58:04 +0200 | [diff] [blame] | 5 | * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 6 | * |
| 7 | * Authors: Felipe Balbi <balbi@ti.com>, |
| 8 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef __DRIVERS_USB_DWC3_IO_H |
| 12 | #define __DRIVERS_USB_DWC3_IO_H |
| 13 | |
Felipe Balbi | 25b8ff6 | 2011-11-04 12:32:47 +0200 | [diff] [blame] | 14 | #include <linux/io.h> |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 15 | #include "trace.h" |
| 16 | #include "debug.h" |
Ido Shayevitz | 51249dc | 2012-04-24 14:18:39 +0300 | [diff] [blame] | 17 | #include "core.h" |
| 18 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 19 | static inline u32 dwc3_readl(void __iomem *base, u32 offset) |
| 20 | { |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 21 | u32 value; |
| 22 | |
Ido Shayevitz | 51249dc | 2012-04-24 14:18:39 +0300 | [diff] [blame] | 23 | /* |
| 24 | * We requested the mem region starting from the Globals address |
| 25 | * space, see dwc3_probe in core.c. |
| 26 | * However, the offsets are given starting from xHCI address space. |
| 27 | */ |
Felipe Balbi | 2eb8801 | 2016-04-12 16:53:39 +0300 | [diff] [blame] | 28 | value = readl(base + offset - DWC3_GLOBALS_REGS_START); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 29 | |
| 30 | /* |
| 31 | * When tracing we want to make it easy to find the correct address on |
| 32 | * documentation, so we revert it back to the proper addresses, the |
| 33 | * same way they are described on SNPS documentation |
| 34 | */ |
Felipe Balbi | 4dd5a69 | 2016-09-30 15:52:19 +0300 | [diff] [blame] | 35 | trace_dwc3_readl(base - DWC3_GLOBALS_REGS_START, offset, value); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 36 | |
| 37 | return value; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value) |
| 41 | { |
Ido Shayevitz | 51249dc | 2012-04-24 14:18:39 +0300 | [diff] [blame] | 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 | */ |
Felipe Balbi | 2eb8801 | 2016-04-12 16:53:39 +0300 | [diff] [blame] | 47 | writel(value, base + offset - DWC3_GLOBALS_REGS_START); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * When tracing we want to make it easy to find the correct address on |
| 51 | * documentation, so we revert it back to the proper addresses, the |
| 52 | * same way they are described on SNPS documentation |
| 53 | */ |
Felipe Balbi | 4dd5a69 | 2016-09-30 15:52:19 +0300 | [diff] [blame] | 54 | trace_dwc3_writel(base - DWC3_GLOBALS_REGS_START, offset, value); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | #endif /* __DRIVERS_USB_DWC3_IO_H */ |