aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2014-11-24 14:04:59 -0500
committerFelipe Balbi <balbi@ti.com>2014-11-25 09:47:05 -0500
commit5450ac88dcf09b258d0404b45316583806799ef4 (patch)
treeb070badfee70901d4c8267e1bc04f3d3131e77ab
parentb20f3f9e8e537ee25bfb86940903cba4b5abbde6 (diff)
usb: musb: Add function pointers for IO access functions
MUSB currently breaks badly if we try to build in support for multiple platforms. This also happens if done as loadable modules, which is not nice for distros. Let's fix the issue by adding new struct musb_io for the IO access functions that the platform code can populate. Note that we don't want to use the current ops as that's really platform_data and and set as a const. This should allow eventually adding function pointers also for the DMA code to struct musb_io, but that's a whole different set of patches. For now, let's just fix the PIO access. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/musb/musb_core.h40
-rw-r--r--drivers/usb/musb/musb_io.h18
2 files changed, 58 insertions, 0 deletions
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 803a997e56d2..e5410bc67df6 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -173,8 +173,25 @@ enum musb_g_ep0_state {
173 173
174/******************************** TYPES *************************************/ 174/******************************** TYPES *************************************/
175 175
176struct musb_io;
177
176/** 178/**
177 * struct musb_platform_ops - Operations passed to musb_core by HW glue layer 179 * struct musb_platform_ops - Operations passed to musb_core by HW glue layer
180 * @quirks: flags for platform specific quirks
181 * @enable: enable device
182 * @disable: disable device
183 * @ep_offset: returns the end point offset
184 * @ep_select: selects the specified end point
185 * @fifo_mode: sets the fifo mode
186 * @fifo_offset: returns the fifo offset
187 * @readb: read 8 bits
188 * @writeb: write 8 bits
189 * @readw: read 16 bits
190 * @writew: write 16 bits
191 * @readl: read 32 bits
192 * @writel: write 32 bits
193 * @read_fifo: reads the fifo
194 * @write_fifo: writes to fifo
178 * @init: turns on clocks, sets up platform-specific registers, etc 195 * @init: turns on clocks, sets up platform-specific registers, etc
179 * @exit: undoes @init 196 * @exit: undoes @init
180 * @set_mode: forcefully changes operating mode 197 * @set_mode: forcefully changes operating mode
@@ -184,12 +201,34 @@ enum musb_g_ep0_state {
184 * @adjust_channel_params: pre check for standard dma channel_program func 201 * @adjust_channel_params: pre check for standard dma channel_program func
185 */ 202 */
186struct musb_platform_ops { 203struct musb_platform_ops {
204
205#define MUSB_DMA_UX500 BIT(6)
206#define MUSB_DMA_CPPI41 BIT(5)
207#define MUSB_DMA_CPPI BIT(4)
208#define MUSB_DMA_TUSB_OMAP BIT(3)
209#define MUSB_DMA_INVENTRA BIT(2)
210#define MUSB_IN_TUSB BIT(1)
211#define MUSB_INDEXED_EP BIT(0)
212 u32 quirks;
213
187 int (*init)(struct musb *musb); 214 int (*init)(struct musb *musb);
188 int (*exit)(struct musb *musb); 215 int (*exit)(struct musb *musb);
189 216
190 void (*enable)(struct musb *musb); 217 void (*enable)(struct musb *musb);
191 void (*disable)(struct musb *musb); 218 void (*disable)(struct musb *musb);
192 219
220 u32 (*ep_offset)(u8 epnum, u16 offset);
221 void (*ep_select)(void __iomem *mbase, u8 epnum);
222 u16 fifo_mode;
223 u32 (*fifo_offset)(u8 epnum);
224 u8 (*readb)(const void __iomem *addr, unsigned offset);
225 void (*writeb)(void __iomem *addr, unsigned offset, u8 data);
226 u16 (*readw)(const void __iomem *addr, unsigned offset);
227 void (*writew)(void __iomem *addr, unsigned offset, u16 data);
228 u32 (*readl)(const void __iomem *addr, unsigned offset);
229 void (*writel)(void __iomem *addr, unsigned offset, u32 data);
230 void (*read_fifo)(struct musb_hw_ep *hw_ep, u16 len, u8 *buf);
231 void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf);
193 int (*set_mode)(struct musb *musb, u8 mode); 232 int (*set_mode)(struct musb *musb, u8 mode);
194 void (*try_idle)(struct musb *musb, unsigned long timeout); 233 void (*try_idle)(struct musb *musb, unsigned long timeout);
195 int (*reset)(struct musb *musb); 234 int (*reset)(struct musb *musb);
@@ -292,6 +331,7 @@ struct musb {
292 /* device lock */ 331 /* device lock */
293 spinlock_t lock; 332 spinlock_t lock;
294 333
334 struct musb_io io;
295 const struct musb_platform_ops *ops; 335 const struct musb_platform_ops *ops;
296 struct musb_context_registers context; 336 struct musb_context_registers context;
297 337
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h
index eebeed78edd6..46c01c81a2a6 100644
--- a/drivers/usb/musb/musb_io.h
+++ b/drivers/usb/musb/musb_io.h
@@ -37,6 +37,24 @@
37 37
38#include <linux/io.h> 38#include <linux/io.h>
39 39
40/**
41 * struct musb_io - IO functions for MUSB
42 * @quirks: platform specific flags
43 * @ep_offset: platform specific function to get end point offset
44 * @ep_select: platform specific function to select end point
45 * @fifo_offset: platform specific function to get fifo offset
46 * @read_fifo: platform specific function to read fifo
47 * @write_fifo: platform specific function to write fifo
48 */
49struct musb_io {
50 u32 quirks;
51 u32 (*ep_offset)(u8 epnum, u16 offset);
52 void (*ep_select)(void __iomem *mbase, u8 epnum);
53 u32 (*fifo_offset)(u8 epnum);
54 void (*read_fifo)(struct musb_hw_ep *hw_ep, u16 len, u8 *buf);
55 void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf);
56};
57
40#ifndef CONFIG_BLACKFIN 58#ifndef CONFIG_BLACKFIN
41 59
42/* NOTE: these offsets are all in bytes */ 60/* NOTE: these offsets are all in bytes */