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 | |
| 27 | |
| 28 | static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data) |
| 29 | { __raw_writew(data, addr + offset); } |
| 30 | |
| 31 | static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data) |
| 32 | { __raw_writel(data, addr + offset); } |
| 33 | |
| 34 | |
| 35 | #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE) |
| 36 | |
| 37 | /* |
| 38 | * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. |
| 39 | */ |
| 40 | static inline u8 musb_readb(const void __iomem *addr, unsigned offset) |
| 41 | { |
| 42 | u16 tmp; |
| 43 | u8 val; |
| 44 | |
| 45 | tmp = __raw_readw(addr + (offset & ~1)); |
| 46 | if (offset & 1) |
| 47 | val = (tmp >> 8); |
| 48 | else |
| 49 | val = tmp & 0xff; |
| 50 | |
| 51 | return val; |
| 52 | } |
| 53 | |
| 54 | static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) |
| 55 | { |
| 56 | u16 tmp; |
| 57 | |
| 58 | tmp = __raw_readw(addr + (offset & ~1)); |
| 59 | if (offset & 1) |
| 60 | tmp = (data << 8) | (tmp & 0xff); |
| 61 | else |
| 62 | tmp = (tmp & 0xff00) | data; |
| 63 | |
| 64 | __raw_writew(tmp, addr + (offset & ~1)); |
| 65 | } |
| 66 | |
| 67 | #else |
| 68 | |
| 69 | static inline u8 musb_readb(const void __iomem *addr, unsigned offset) |
| 70 | { return __raw_readb(addr + offset); } |
| 71 | |
| 72 | static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) |
| 73 | { __raw_writeb(data, addr + offset); } |
| 74 | |
| 75 | #endif /* CONFIG_USB_MUSB_TUSB6010 */ |
| 76 | |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 77 | #endif |