Linux Audio

Check our new training course

Loading...
v3.1
  1/*
  2 * MUSB OTG driver register I/O
  3 *
  4 * Copyright 2005 Mentor Graphics Corporation
  5 * Copyright (C) 2005-2006 by Texas Instruments
  6 * Copyright (C) 2006-2007 Nokia Corporation
  7 *
  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.
 11 *
 12 * This program is distributed in the hope that it will be useful, but
 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15 * General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program; if not, write to the Free Software
 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20 * 02110-1301 USA
 21 *
 22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32 *
 33 */
 34
 35#ifndef __MUSB_LINUX_PLATFORM_ARCH_H__
 36#define __MUSB_LINUX_PLATFORM_ARCH_H__
 37
 38#include <linux/io.h>
 39
 40#if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \
 41	&& !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \
 42	&& !defined(CONFIG_PPC64) && !defined(CONFIG_BLACKFIN)
 
 43static inline void readsl(const void __iomem *addr, void *buf, int len)
 44	{ insl((unsigned long)addr, buf, len); }
 45static inline void readsw(const void __iomem *addr, void *buf, int len)
 46	{ insw((unsigned long)addr, buf, len); }
 47static inline void readsb(const void __iomem *addr, void *buf, int len)
 48	{ insb((unsigned long)addr, buf, len); }
 49
 50static inline void writesl(const void __iomem *addr, const void *buf, int len)
 51	{ outsl((unsigned long)addr, buf, len); }
 52static inline void writesw(const void __iomem *addr, const void *buf, int len)
 53	{ outsw((unsigned long)addr, buf, len); }
 54static inline void writesb(const void __iomem *addr, const void *buf, int len)
 55	{ outsb((unsigned long)addr, buf, len); }
 56
 57#endif
 58
 59#ifndef CONFIG_BLACKFIN
 60
 61/* NOTE:  these offsets are all in bytes */
 62
 63static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
 64	{ return __raw_readw(addr + offset); }
 65
 66static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
 67	{ return __raw_readl(addr + offset); }
 68
 69
 70static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
 71	{ __raw_writew(data, addr + offset); }
 72
 73static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
 74	{ __raw_writel(data, addr + offset); }
 75
 76
 77#ifdef CONFIG_USB_MUSB_TUSB6010
 78
 79/*
 80 * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum.
 81 */
 82static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
 83{
 84	u16 tmp;
 85	u8 val;
 86
 87	tmp = __raw_readw(addr + (offset & ~1));
 88	if (offset & 1)
 89		val = (tmp >> 8);
 90	else
 91		val = tmp & 0xff;
 92
 93	return val;
 94}
 95
 96static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
 97{
 98	u16 tmp;
 99
100	tmp = __raw_readw(addr + (offset & ~1));
101	if (offset & 1)
102		tmp = (data << 8) | (tmp & 0xff);
103	else
104		tmp = (tmp & 0xff00) | data;
105
106	__raw_writew(tmp, addr + (offset & ~1));
107}
108
109#else
110
111static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
112	{ return __raw_readb(addr + offset); }
113
114static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
115	{ __raw_writeb(data, addr + offset); }
116
117#endif	/* CONFIG_USB_MUSB_TUSB6010 */
118
119#else
120
121static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
122	{ return (u8) (bfin_read16(addr + offset)); }
123
124static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
125	{ return bfin_read16(addr + offset); }
126
127static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
128	{ return (u32) (bfin_read16(addr + offset)); }
129
130static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
131	{ bfin_write16(addr + offset, (u16) data); }
132
133static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
134	{ bfin_write16(addr + offset, data); }
135
136static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
137	{ bfin_write16(addr + offset, (u16) data); }
138
139#endif /* CONFIG_BLACKFIN */
140
141#endif
v3.5.6
  1/*
  2 * MUSB OTG driver register I/O
  3 *
  4 * Copyright 2005 Mentor Graphics Corporation
  5 * Copyright (C) 2005-2006 by Texas Instruments
  6 * Copyright (C) 2006-2007 Nokia Corporation
  7 *
  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.
 11 *
 12 * This program is distributed in the hope that it will be useful, but
 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15 * General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program; if not, write to the Free Software
 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20 * 02110-1301 USA
 21 *
 22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32 *
 33 */
 34
 35#ifndef __MUSB_LINUX_PLATFORM_ARCH_H__
 36#define __MUSB_LINUX_PLATFORM_ARCH_H__
 37
 38#include <linux/io.h>
 39
 40#if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \
 41	&& !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \
 42	&& !defined(CONFIG_PPC64) && !defined(CONFIG_BLACKFIN) \
 43	&& !defined(CONFIG_MIPS) && !defined(CONFIG_M68K)
 44static inline void readsl(const void __iomem *addr, void *buf, int len)
 45	{ insl((unsigned long)addr, buf, len); }
 46static inline void readsw(const void __iomem *addr, void *buf, int len)
 47	{ insw((unsigned long)addr, buf, len); }
 48static inline void readsb(const void __iomem *addr, void *buf, int len)
 49	{ insb((unsigned long)addr, buf, len); }
 50
 51static inline void writesl(const void __iomem *addr, const void *buf, int len)
 52	{ outsl((unsigned long)addr, buf, len); }
 53static inline void writesw(const void __iomem *addr, const void *buf, int len)
 54	{ outsw((unsigned long)addr, buf, len); }
 55static inline void writesb(const void __iomem *addr, const void *buf, int len)
 56	{ outsb((unsigned long)addr, buf, len); }
 57
 58#endif
 59
 60#ifndef CONFIG_BLACKFIN
 61
 62/* NOTE:  these offsets are all in bytes */
 63
 64static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
 65	{ return __raw_readw(addr + offset); }
 66
 67static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
 68	{ return __raw_readl(addr + offset); }
 69
 70
 71static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
 72	{ __raw_writew(data, addr + offset); }
 73
 74static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
 75	{ __raw_writel(data, addr + offset); }
 76
 77
 78#if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE)
 79
 80/*
 81 * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum.
 82 */
 83static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
 84{
 85	u16 tmp;
 86	u8 val;
 87
 88	tmp = __raw_readw(addr + (offset & ~1));
 89	if (offset & 1)
 90		val = (tmp >> 8);
 91	else
 92		val = tmp & 0xff;
 93
 94	return val;
 95}
 96
 97static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
 98{
 99	u16 tmp;
100
101	tmp = __raw_readw(addr + (offset & ~1));
102	if (offset & 1)
103		tmp = (data << 8) | (tmp & 0xff);
104	else
105		tmp = (tmp & 0xff00) | data;
106
107	__raw_writew(tmp, addr + (offset & ~1));
108}
109
110#else
111
112static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
113	{ return __raw_readb(addr + offset); }
114
115static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
116	{ __raw_writeb(data, addr + offset); }
117
118#endif	/* CONFIG_USB_MUSB_TUSB6010 */
119
120#else
121
122static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
123	{ return (u8) (bfin_read16(addr + offset)); }
124
125static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
126	{ return bfin_read16(addr + offset); }
127
128static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
129	{ return (u32) (bfin_read16(addr + offset)); }
130
131static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
132	{ bfin_write16(addr + offset, (u16) data); }
133
134static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
135	{ bfin_write16(addr + offset, data); }
136
137static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
138	{ bfin_write16(addr + offset, (u16) data); }
139
140#endif /* CONFIG_BLACKFIN */
141
142#endif