Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 2 | /* |
| 3 | * MUSB OTG driver register I/O |
| 4 | * |
| 5 | * Copyright 2005 Mentor Graphics Corporation |
| 6 | * Copyright (C) 2005-2006 by Texas Instruments |
| 7 | * Copyright (C) 2006-2007 Nokia Corporation |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * version 2 as published by the Free Software Foundation. |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #ifndef __MUSB_LINUX_PLATFORM_ARCH_H__ |
| 15 | #define __MUSB_LINUX_PLATFORM_ARCH_H__ |
| 16 | |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 17 | #include <linux/io.h> |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 18 | |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 19 | /* NOTE: these offsets are all in bytes */ |
| 20 | |
| 21 | static inline u16 musb_readw(const void __iomem *addr, unsigned offset) |
| 22 | { return __raw_readw(addr + offset); } |
| 23 | |
| 24 | static inline u32 musb_readl(const void __iomem *addr, unsigned offset) |
| 25 | { return __raw_readl(addr + offset); } |
| 26 | |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 27 | static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data) |
| 28 | { __raw_writew(data, addr + offset); } |
| 29 | |
| 30 | static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data) |
| 31 | { __raw_writel(data, addr + offset); } |
| 32 | |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 33 | #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE) |
| 34 | |
| 35 | /* |
| 36 | * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. |
| 37 | */ |
| 38 | static inline u8 musb_readb(const void __iomem *addr, unsigned offset) |
| 39 | { |
| 40 | u16 tmp; |
| 41 | u8 val; |
| 42 | |
| 43 | tmp = __raw_readw(addr + (offset & ~1)); |
| 44 | if (offset & 1) |
| 45 | val = (tmp >> 8); |
| 46 | else |
| 47 | val = tmp & 0xff; |
| 48 | |
| 49 | return val; |
| 50 | } |
| 51 | |
| 52 | static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) |
| 53 | { |
| 54 | u16 tmp; |
| 55 | |
| 56 | tmp = __raw_readw(addr + (offset & ~1)); |
| 57 | if (offset & 1) |
| 58 | tmp = (data << 8) | (tmp & 0xff); |
| 59 | else |
| 60 | tmp = (tmp & 0xff00) | data; |
| 61 | |
| 62 | __raw_writew(tmp, addr + (offset & ~1)); |
| 63 | } |
| 64 | |
| 65 | #else |
| 66 | |
| 67 | static inline u8 musb_readb(const void __iomem *addr, unsigned offset) |
| 68 | { return __raw_readb(addr + offset); } |
| 69 | |
| 70 | static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) |
| 71 | { __raw_writeb(data, addr + offset); } |
| 72 | |
| 73 | #endif /* CONFIG_USB_MUSB_TUSB6010 */ |
| 74 | |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 75 | #endif |