From: Ming Lei <tom.leiming@xxxxxxxxx> This patch introduces MUSB_GLUE_TUSB_STYLE flag, which can be used to handle tusb dependent things by runtime method instead of previous static method. This patch handles tusb fifo style according to the flag of MUSB_GLUE_TUSB_STYLE passed from hw glue drivers. Signed-off-by: Ming Lei <tom.leiming@xxxxxxxxx> --- drivers/usb/musb/musb_core.c | 26 ++++++++++++++------------ drivers/usb/musb/musb_core.h | 15 ++++++++------- drivers/usb/musb/musb_regs.h | 7 +------ drivers/usb/musb/tusb6010.c | 1 + 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 2f73002..dba20f8 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1481,18 +1481,20 @@ static int __devinit musb_core_init(u16 musb_type, struct musb *musb) for (i = 0; i < musb->nr_endpoints; i++) { struct musb_hw_ep *hw_ep = musb->endpoints + i; - hw_ep->fifo = MUSB_FIFO_OFFSET(i) + mbase; -#ifdef CONFIG_USB_MUSB_TUSB6010 - hw_ep->fifo_async = musb->async + 0x400 + MUSB_FIFO_OFFSET(i); - hw_ep->fifo_sync = musb->sync + 0x400 + MUSB_FIFO_OFFSET(i); - hw_ep->fifo_sync_va = - musb->sync_va + 0x400 + MUSB_FIFO_OFFSET(i); - - if (i == 0) - hw_ep->conf = mbase - 0x400 + TUSB_EP0_CONF; - else - hw_ep->conf = mbase + 0x400 + (((i - 1) & 0xf) << 2); -#endif + if (musb->ops->flags & MUSB_GLUE_TUSB_STYLE) { + hw_ep->fifo = MUSB_TUSB_FIFO_OFFSET(i) + mbase; + hw_ep->fifo_async = musb->async + 0x400 + MUSB_TUSB_FIFO_OFFSET(i); + hw_ep->fifo_sync = musb->sync + 0x400 + MUSB_TUSB_FIFO_OFFSET(i); + hw_ep->fifo_sync_va = + musb->sync_va + 0x400 + MUSB_TUSB_FIFO_OFFSET(i); + + if (i == 0) + hw_ep->conf = mbase - 0x400 + TUSB_EP0_CONF; + else + hw_ep->conf = mbase + 0x400 + (((i - 1) & 0xf) << 2); + } else { + hw_ep->fifo = MUSB_FIFO_OFFSET(i) + mbase; + } hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase; #ifdef CONFIG_USB_MUSB_HDRC_HCD diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 38d6a6e..aeca586 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -253,6 +253,8 @@ enum musb_g_ep0_state { /******************************** TYPES *************************************/ +#define MUSB_GLUE_TUSB_STYLE 0x0001 + /** * struct musb_platform_ops - Operations passed to musb_core by HW glue layer * @fifo_mode: which fifo_mode is taken by me @@ -297,9 +299,8 @@ struct musb_hw_ep { void __iomem *fifo; void __iomem *regs; -#ifdef CONFIG_USB_MUSB_TUSB6010 + /*Fixme: the following field is only used by tusb*/ void __iomem *conf; -#endif /* index in musb->endpoints[] */ u8 epnum; @@ -314,12 +315,13 @@ struct musb_hw_ep { struct dma_channel *tx_channel; struct dma_channel *rx_channel; -#ifdef CONFIG_USB_MUSB_TUSB6010 - /* TUSB has "asynchronous" and "synchronous" dma modes */ + /* + * TUSB has "asynchronous" and "synchronous" dma modes + * Fixme: the following three fields are only valid for TUSB. + * */ dma_addr_t fifo_async; dma_addr_t fifo_sync; void __iomem *fifo_sync_va; -#endif #ifdef CONFIG_USB_MUSB_HDRC_HCD void __iomem *target_regs; @@ -429,11 +431,10 @@ struct musb { void __iomem *ctrl_base; void __iomem *mregs; -#ifdef CONFIG_USB_MUSB_TUSB6010 + /*Fixme: the three fields below are only used by tusb*/ dma_addr_t async; dma_addr_t sync; void __iomem *sync_va; -#endif /* passed down from chip/board specific irq handlers */ u8 int_usb; diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h index 8241070..edc0cca 100644 --- a/drivers/usb/musb/musb_regs.h +++ b/drivers/usb/musb/musb_regs.h @@ -234,11 +234,8 @@ #define MUSB_TESTMODE 0x0F /* 8 bit */ /* Get offset for a given FIFO from musb->mregs */ -#ifdef CONFIG_USB_MUSB_TUSB6010 -#define MUSB_FIFO_OFFSET(epnum) (0x200 + ((epnum) * 0x20)) -#else +#define MUSB_TUSB_FIFO_OFFSET(epnum) (0x200 + ((epnum) * 0x20)) #define MUSB_FIFO_OFFSET(epnum) (0x20 + ((epnum) * 4)) -#endif /* * Additional Control Registers @@ -295,12 +292,10 @@ #define MUSB_FLAT_OFFSET(_epnum, _offset) \ (0x100 + (0x10*(_epnum)) + (_offset)) -#ifdef CONFIG_USB_MUSB_TUSB6010 /* TUSB6010 EP0 configuration register is special */ #define MUSB_TUSB_OFFSET(_epnum, _offset) \ (0x10 + _offset) #include "tusb6010.h" /* Needed "only" for TUSB_EP0_CONF */ -#endif #define MUSB_TXCSR_MODE 0x2000 diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 926c6b4..f3318ba 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -1165,6 +1165,7 @@ static int tusb_musb_exit(struct musb *musb) static const struct musb_platform_ops tusb_ops = { .fifo_mode = 4, + .flags = MUSB_GLUE_TUSB_STYLE, .init = tusb_musb_init, .exit = tusb_musb_exit, -- 1.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html