2 * MUSB OTG driver register I/O
4 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * SPDX-License-Identifier: GPL-2.0
15 #ifndef __MUSB_LINUX_PLATFORM_ARCH_H__
16 #define __MUSB_LINUX_PLATFORM_ARCH_H__
24 #if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \
25 && !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \
26 && !defined(CONFIG_PPC64) && !defined(CONFIG_BLACKFIN) \
27 && !defined(CONFIG_MIPS) && !defined(CONFIG_M68K)
28 static inline void readsl(const void __iomem *addr, void *buf, int len)
29 { insl((unsigned long)addr, buf, len); }
30 static inline void readsw(const void __iomem *addr, void *buf, int len)
31 { insw((unsigned long)addr, buf, len); }
32 static inline void readsb(const void __iomem *addr, void *buf, int len)
33 { insb((unsigned long)addr, buf, len); }
35 static inline void writesl(const void __iomem *addr, const void *buf, int len)
36 { outsl((unsigned long)addr, buf, len); }
37 static inline void writesw(const void __iomem *addr, const void *buf, int len)
38 { outsw((unsigned long)addr, buf, len); }
39 static inline void writesb(const void __iomem *addr, const void *buf, int len)
40 { outsb((unsigned long)addr, buf, len); }
44 #ifndef CONFIG_BLACKFIN
46 /* NOTE: these offsets are all in bytes */
48 static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
49 { return __raw_readw(addr + offset); }
51 static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
52 { return __raw_readl(addr + offset); }
55 static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
56 { __raw_writew(data, addr + offset); }
58 static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
59 { __raw_writel(data, addr + offset); }
62 #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE)
65 * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum.
67 static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
72 tmp = __raw_readw(addr + (offset & ~1));
81 static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
85 tmp = __raw_readw(addr + (offset & ~1));
87 tmp = (data << 8) | (tmp & 0xff);
89 tmp = (tmp & 0xff00) | data;
91 __raw_writew(tmp, addr + (offset & ~1));
96 static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
97 { return __raw_readb(addr + offset); }
99 static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
100 { __raw_writeb(data, addr + offset); }
102 #endif /* CONFIG_USB_MUSB_TUSB6010 */
106 static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
107 { return (u8) (bfin_read16(addr + offset)); }
109 static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
110 { return bfin_read16(addr + offset); }
112 static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
113 { return (u32) (bfin_read16(addr + offset)); }
115 static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
116 { bfin_write16(addr + offset, (u16) data); }
118 static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
119 { bfin_write16(addr + offset, data); }
121 static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
122 { bfin_write16(addr + offset, (u16) data); }
124 #endif /* CONFIG_BLACKFIN */