1 /* SPDX-License-Identifier: GPL-2.0 */
3 * MUSB OTG driver register I/O
5 * Copyright 2005 Mentor Graphics Corporation
6 * Copyright (C) 2005-2006 by Texas Instruments
7 * Copyright (C) 2006-2007 Nokia Corporation
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.
14 #ifndef __MUSB_LINUX_PLATFORM_ARCH_H__
15 #define __MUSB_LINUX_PLATFORM_ARCH_H__
23 #if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \
24 && !defined(CONFIG_PPC32) \
25 && !defined(CONFIG_PPC64) && !defined(CONFIG_MIPS) \
26 && !defined(CONFIG_M68K)
27 static inline void readsl(const void __iomem *addr, void *buf, int len)
28 { insl((unsigned long)addr, buf, len); }
29 static inline void readsw(const void __iomem *addr, void *buf, int len)
30 { insw((unsigned long)addr, buf, len); }
31 static inline void readsb(const void __iomem *addr, void *buf, int len)
32 { insb((unsigned long)addr, buf, len); }
34 static inline void writesl(const void __iomem *addr, const void *buf, int len)
35 { outsl((unsigned long)addr, buf, len); }
36 static inline void writesw(const void __iomem *addr, const void *buf, int len)
37 { outsw((unsigned long)addr, buf, len); }
38 static inline void writesb(const void __iomem *addr, const void *buf, int len)
39 { outsb((unsigned long)addr, buf, len); }
43 /* NOTE: these offsets are all in bytes */
45 static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
46 { return __raw_readw(addr + offset); }
48 static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
49 { return __raw_readl(addr + offset); }
52 static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
53 { __raw_writew(data, addr + offset); }
55 static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
56 { __raw_writel(data, addr + offset); }
59 #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE)
62 * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum.
64 static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
69 tmp = __raw_readw(addr + (offset & ~1));
78 static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
82 tmp = __raw_readw(addr + (offset & ~1));
84 tmp = (data << 8) | (tmp & 0xff);
86 tmp = (tmp & 0xff00) | data;
88 __raw_writew(tmp, addr + (offset & ~1));
93 static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
94 { return __raw_readb(addr + offset); }
96 static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
97 { __raw_writeb(data, addr + offset); }
99 #endif /* CONFIG_USB_MUSB_TUSB6010 */