diff options
Diffstat (limited to 'drivers/usb/musb/musb_io.h')
-rw-r--r-- | drivers/usb/musb/musb_io.h | 106 |
1 files changed, 26 insertions, 80 deletions
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h index eebeed78edd6..8a57a6f4b3a6 100644 --- a/drivers/usb/musb/musb_io.h +++ b/drivers/usb/musb/musb_io.h | |||
@@ -37,86 +37,32 @@ | |||
37 | 37 | ||
38 | #include <linux/io.h> | 38 | #include <linux/io.h> |
39 | 39 | ||
40 | #ifndef CONFIG_BLACKFIN | 40 | #define musb_ep_select(_mbase, _epnum) musb->io.ep_select((_mbase), (_epnum)) |
41 | 41 | ||
42 | /* NOTE: these offsets are all in bytes */ | 42 | /** |
43 | 43 | * struct musb_io - IO functions for MUSB | |
44 | static inline u16 musb_readw(const void __iomem *addr, unsigned offset) | 44 | * @quirks: platform specific flags |
45 | { return __raw_readw(addr + offset); } | 45 | * @ep_offset: platform specific function to get end point offset |
46 | 46 | * @ep_select: platform specific function to select end point | |
47 | static inline u32 musb_readl(const void __iomem *addr, unsigned offset) | 47 | * @fifo_offset: platform specific function to get fifo offset |
48 | { return __raw_readl(addr + offset); } | 48 | * @read_fifo: platform specific function to read fifo |
49 | 49 | * @write_fifo: platform specific function to write fifo | |
50 | |||
51 | static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data) | ||
52 | { __raw_writew(data, addr + offset); } | ||
53 | |||
54 | static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data) | ||
55 | { __raw_writel(data, addr + offset); } | ||
56 | |||
57 | |||
58 | #if defined(CONFIG_USB_MUSB_TUSB6010) || defined (CONFIG_USB_MUSB_TUSB6010_MODULE) | ||
59 | |||
60 | /* | ||
61 | * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. | ||
62 | */ | 50 | */ |
63 | static inline u8 musb_readb(const void __iomem *addr, unsigned offset) | 51 | struct musb_io { |
64 | { | 52 | u32 quirks; |
65 | u16 tmp; | 53 | u32 (*ep_offset)(u8 epnum, u16 offset); |
66 | u8 val; | 54 | void (*ep_select)(void __iomem *mbase, u8 epnum); |
67 | 55 | u32 (*fifo_offset)(u8 epnum); | |
68 | tmp = __raw_readw(addr + (offset & ~1)); | 56 | void (*read_fifo)(struct musb_hw_ep *hw_ep, u16 len, u8 *buf); |
69 | if (offset & 1) | 57 | void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf); |
70 | val = (tmp >> 8); | 58 | }; |
71 | else | 59 | |
72 | val = tmp & 0xff; | 60 | /* Do not add new entries here, add them the struct musb_io instead */ |
73 | 61 | extern u8 (*musb_readb)(const void __iomem *addr, unsigned offset); | |
74 | return val; | 62 | extern void (*musb_writeb)(void __iomem *addr, unsigned offset, u8 data); |
75 | } | 63 | extern u16 (*musb_readw)(const void __iomem *addr, unsigned offset); |
76 | 64 | extern void (*musb_writew)(void __iomem *addr, unsigned offset, u16 data); | |
77 | static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) | 65 | extern u32 (*musb_readl)(const void __iomem *addr, unsigned offset); |
78 | { | 66 | extern void (*musb_writel)(void __iomem *addr, unsigned offset, u32 data); |
79 | u16 tmp; | ||
80 | |||
81 | tmp = __raw_readw(addr + (offset & ~1)); | ||
82 | if (offset & 1) | ||
83 | tmp = (data << 8) | (tmp & 0xff); | ||
84 | else | ||
85 | tmp = (tmp & 0xff00) | data; | ||
86 | |||
87 | __raw_writew(tmp, addr + (offset & ~1)); | ||
88 | } | ||
89 | |||
90 | #else | ||
91 | |||
92 | static inline u8 musb_readb(const void __iomem *addr, unsigned offset) | ||
93 | { return __raw_readb(addr + offset); } | ||
94 | |||
95 | static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) | ||
96 | { __raw_writeb(data, addr + offset); } | ||
97 | |||
98 | #endif /* CONFIG_USB_MUSB_TUSB6010 */ | ||
99 | |||
100 | #else | ||
101 | |||
102 | static inline u8 musb_readb(const void __iomem *addr, unsigned offset) | ||
103 | { return (u8) (bfin_read16(addr + offset)); } | ||
104 | |||
105 | static inline u16 musb_readw(const void __iomem *addr, unsigned offset) | ||
106 | { return bfin_read16(addr + offset); } | ||
107 | |||
108 | static inline u32 musb_readl(const void __iomem *addr, unsigned offset) | ||
109 | { return (u32) (bfin_read16(addr + offset)); } | ||
110 | |||
111 | static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) | ||
112 | { bfin_write16(addr + offset, (u16) data); } | ||
113 | |||
114 | static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data) | ||
115 | { bfin_write16(addr + offset, data); } | ||
116 | |||
117 | static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data) | ||
118 | { bfin_write16(addr + offset, (u16) data); } | ||
119 | |||
120 | #endif /* CONFIG_BLACKFIN */ | ||
121 | 67 | ||
122 | #endif | 68 | #endif |