blob: 6a79c8e66bbcce87ae1b0d7f38bd345687504894 [file] [log] [blame]
Felipe Balbi72246da2011-08-19 18:10:58 +03001/**
2 * io.h - DesignWare USB3 DRD IO Header
3 *
4 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
Felipe Balbi72246da2011-08-19 18:10:58 +03005 *
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
Felipe Balbi5945f782013-06-30 14:15:11 +03009 * 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 Balbi72246da2011-08-19 18:10:58 +030012 *
Felipe Balbi5945f782013-06-30 14:15:11 +030013 * 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 Balbi72246da2011-08-19 18:10:58 +030017 */
18
19#ifndef __DRIVERS_USB_DWC3_IO_H
20#define __DRIVERS_USB_DWC3_IO_H
21
Felipe Balbi25b8ff62011-11-04 12:32:47 +020022#include <linux/io.h>
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050023#include "trace.h"
24#include "debug.h"
Ido Shayevitz51249dc2012-04-24 14:18:39 +030025#include "core.h"
26
Felipe Balbi72246da2011-08-19 18:10:58 +030027static inline u32 dwc3_readl(void __iomem *base, u32 offset)
28{
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050029 u32 offs = offset - DWC3_GLOBALS_REGS_START;
30 u32 value;
31
Ido Shayevitz51249dc2012-04-24 14:18:39 +030032 /*
33 * We requested the mem region starting from the Globals address
34 * space, see dwc3_probe in core.c.
35 * However, the offsets are given starting from xHCI address space.
36 */
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050037 value = readl(base + offs);
38
39 /*
40 * When tracing we want to make it easy to find the correct address on
41 * documentation, so we revert it back to the proper addresses, the
42 * same way they are described on SNPS documentation
43 */
44 dwc3_trace(trace_dwc3_readl, "addr %p value %08x",
45 base - DWC3_GLOBALS_REGS_START + offset, value);
46
47 return value;
Felipe Balbi72246da2011-08-19 18:10:58 +030048}
49
50static inline void dwc3_writel(void __iomem *base, u32 offset, u32 value)
51{
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050052 u32 offs = offset - DWC3_GLOBALS_REGS_START;
53
Ido Shayevitz51249dc2012-04-24 14:18:39 +030054 /*
55 * We requested the mem region starting from the Globals address
56 * space, see dwc3_probe in core.c.
57 * However, the offsets are given starting from xHCI address space.
58 */
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050059 writel(value, base + offs);
60
61 /*
62 * When tracing we want to make it easy to find the correct address on
63 * documentation, so we revert it back to the proper addresses, the
64 * same way they are described on SNPS documentation
65 */
66 dwc3_trace(trace_dwc3_writel, "addr %p value %08x",
67 base - DWC3_GLOBALS_REGS_START + offset, value);
Felipe Balbi72246da2011-08-19 18:10:58 +030068}
69
70#endif /* __DRIVERS_USB_DWC3_IO_H */