musb patches for v5.6-rc1
Subsystems (10)
Bin Liu
maintainercover musb patches for v5.6-rc1
Hi Greg,
Here are musb patches for the v5.6 merge window. The major work is adding support of MediaTek device, jz4740 glue driver cleanup, improvement in omap2430 glue driver, and other non-critical fixes and cleanup.
Please let me know if anything change is needed.
Thanks,
-Bin.
---
Ben Dooks (Codethink) (1):
USB: musb: fix __iomem in trace functions
Bin Liu (1):
usb: musb: remove dummy driver musb_am335x.c
Linus Walleij (1):
usb: musb: davinci: Convert to use GPIO descriptor
Mans Rullgard (1):
usb: musb: sunxi: propagate devicetree node to glue pdev
Min Guo (5):
dt-bindings: usb: musb: Add support for MediaTek musb controller
usb: musb: Add get/set toggle hooks
usb: musb: Add noirq type of dma create interface
usb: musb: Add musb_clearb/w() interface
usb: musb: Add support for MediaTek musb controller
Paul Cercueil (7):
usb: musb: jz4740: Drop dependency on NOP_USB_XCEIV
usb: musb: jz4740: Suppress useless field in priv structure
usb: musb: jz4740: Add local dev variable to clean up probe
usb: musb: jz4740: Constify jz4740_musb_pdata struct
usb: musb: jz4740: Rename platform_device field in priv struct
usb: musb: jz4740: Comments fix
usb: musb: jz4740: Whitespace and indentation fixes
Peter Ujfalusi (1):
usb: musb/ux500: Use dma_request_chan() instead
dma_request_slave_channel()
Saurav Girepunje (1):
usb: musb: core: Update the function description
Tony Lindgren (7):
usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue
usb: musb: omap2430: Wait on enable to avoid babble
usb: musb: omap2430: Handle multiple ID ground interrupts
usb: musb: Add musb_set_host and peripheral and use them for omap2430
usb: musb: omap2430: Clean up enable and remove devctl tinkering
usb: musb: omap2430: Idle musb on init
usb: musb: Get rid of omap2430_musb_set_vbus()
.../devicetree/bindings/usb/mediatek,musb.txt | 57 ++ arch/arm/mach-davinci/board-dm644x-evm.c | 12 + drivers/usb/musb/Kconfig | 12 +- drivers/usb/musb/Makefile | 4 +- drivers/usb/musb/davinci.c | 57 +- drivers/usb/musb/jz4740.c | 75 ++- drivers/usb/musb/mediatek.c | 582 ++++++++++++++++++ drivers/usb/musb/musb_am335x.c | 44 -- drivers/usb/musb/musb_core.c | 188 +++++- drivers/usb/musb/musb_core.h | 20 +- drivers/usb/musb/musb_dma.h | 9 + drivers/usb/musb/musb_host.c | 46 +- drivers/usb/musb/musb_io.h | 18 +- drivers/usb/musb/musb_trace.h | 33 +- drivers/usb/musb/musbhsdma.c | 56 +- drivers/usb/musb/omap2430.c | 164 ++--- drivers/usb/musb/sunxi.c | 6 +- drivers/usb/musb/tusb6010.c | 2 +- drivers/usb/musb/ux500_dma.c | 4 +- 19 files changed, 1061 insertions(+), 328 deletions(-) create mode 100644 Documentation/devicetree/bindings/usb/mediatek,musb.txt create mode 100644 drivers/usb/musb/mediatek.c delete mode 100644 drivers/usb/musb/musb_am335x.c
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 1/25 usb: musb: core: Update the function description
From: Saurav Girepunje <[email protected]>
Update the function description of musb_stage0_irq() to remove unused parameter.
--- drivers/usb/musb/musb_core.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/musb/musb_core.c +0 -1
@@ -909,7 +909,6 @@ static void musb_handle_intr_reset(struct musb *musb)* @param musb instance pointer * @param int_usb register contents * @param devctl -* @param power */ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 2/25 usb: musb: sunxi: propagate devicetree node to glue pdev
In reply to Bin LiuFrom: Mans Rullgard <[email protected]>
In order for devicetree nodes to be correctly associated with attached devices, the controller node needs to be propagated to the glue device.
--- drivers/usb/musb/sunxi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +2 -0
@@ -781,6 +781,8 @@ static int sunxi_musb_probe(struct platform_device *pdev) pinfo.name ="musb-hdrc" ; pinfo.id =PLATFORM_DEVID_AUTO ; pinfo.parent = &pdev->dev; + pinfo.fwnode =of_fwnode_handle (pdev->dev.of_node); + pinfo.of_node_reused = true; pinfo.res = pdev->resource; pinfo.num_res = pdev->num_resources; pinfo.data = &pdata;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 3/25 usb: musb: jz4740: Drop dependency on NOP_USB_XCEIV
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
The driver does not depend directly on the NOP transceiver. It can compile and work just fine without it.
--- drivers/usb/musb/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/usb/musb/Kconfig +0 -1
@@ -111,7 +111,6 @@ config USB_MUSB_UX500 config USB_MUSB_JZ4740 tristate "JZ4740" - depends on NOP_USB_XCEIV depends on MIPS || COMPILE_TEST depends on USB_MUSB_GADGET depends on USB=n || USB_OTG_BLACKLIST_HUB
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 4/25 usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue
In reply to Bin LiuFrom: Tony Lindgren <[email protected]>
We currently have musb_set_vbus() called from two different paths. Mostly it gets called from the USB PHY via omap_musb_set_mailbox(), but in some cases it can get also called from musb_stage0_irq() rather via .set_vbus:
(musb_set_host [musb_hdrc])
(omap2430_musb_set_vbus [omap2430])
(musb_stage0_irq [musb_hdrc])
(musb_interrupt [musb_hdrc])
(omap2430_musb_interrupt [omap2430])
This is racy and will not work with introducing generic helper functions for musb_set_host() and musb_set_peripheral(). We want to get rid of the busy loops in favor of usleep_range().
Let's just get rid of .set_vbus for omap2430 glue layer and let the PHY code handle VBUS with musb_set_vbus(). Note that in the follow-up patch we can completely remove omap2430_musb_set_vbus(), but let's do it in a separate patch as this change may actually turn out to be needed as a fix.
--- drivers/usb/musb/omap2430.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/musb/omap2430.c +0 -2
@@ -361,8 +361,6 @@ static const struct musb_platform_ops omap2430_ops = { .init = omap2430_musb_init, .exit = omap2430_musb_exit, - .set_vbus = omap2430_musb_set_vbus, - .enable = omap2430_musb_enable, .disable = omap2430_musb_disable,
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 5/25 usb: musb: omap2430: Wait on enable to avoid babble
In reply to Bin LiuFrom: Tony Lindgren <[email protected]>
We can get babble interrupt if we attempt to switch to USB host mode too soon after enabling musb. Let's fix the issue by waiting a bit in runtime_resume.
--- drivers/usb/musb/omap2430.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/musb/omap2430.c +3 -0
@@ -550,6 +550,9 @@ static int omap2430_runtime_resume(struct device *dev)musb_writel (musb->mregs,OTG_INTERFSEL , musb->context.otg_interfsel); +/* Wait for musb to get oriented. Otherwise we can get babble */ +usleep_range (200000 ,250000 ); +return 0 ; }
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 6/25 usb: musb: omap2430: Handle multiple ID ground interrupts
In reply to Bin LiuFrom: Tony Lindgren <[email protected]>
We currently get "unhandled DISCONNECT transition" warnings from musb core on device disconnect as things are wrongly set to OTG_STATE_A_IDLE in host mode when enumerating devices. We can also get "Failed to write reg index" errors after enumerating.
This is happening at least with cpcap phy where we get multiple ID ground interrupts. Looks like it's VBUS keeps timing out and needs to be kicked when the phy sends multiple ID ground interrupts during host mode.
--- drivers/usb/musb/omap2430.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/usb/musb/omap2430.c +19 -6
@@ -151,13 +151,26 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)switch (glue->status) {case MUSB_ID_GROUND :dev_dbg (musb->controller,"ID GND\n" ); - - musb->xceiv->otg->state =OTG_STATE_A_IDLE ; - musb->xceiv->last_event =USB_EVENT_ID ; -if (musb->gadget_driver) { -omap_control_usb_set_mode (glue->control_otghs, -USB_MODE_HOST ); +switch (musb->xceiv->otg->state) { +case OTG_STATE_A_WAIT_VRISE : +case OTG_STATE_A_WAIT_BCON : +case OTG_STATE_A_HOST : +case OTG_STATE_A_IDLE : +/* +* On multiple ID ground interrupts just keep enabling +* VBUS. At least cpcap VBUS shuts down otherwise. +*/ omap2430_musb_set_vbus (musb,1 ); +break ; +default : + musb->xceiv->otg->state =OTG_STATE_A_IDLE ; + musb->xceiv->last_event =USB_EVENT_ID ; +if (musb->gadget_driver) { +omap_control_usb_set_mode (glue->control_otghs, +USB_MODE_HOST ); +omap2430_musb_set_vbus (musb,1 ); + } +break ; }break ;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 7/25 usb: musb: Add musb_set_host and peripheral and use them for omap2430
In reply to Bin LiuFrom: Tony Lindgren <[email protected]>
At least some revisions of musb core need to set devctl session bit in peripheral mode to force musb to host mode. And we have places clearing the devctl session bit.
Let's add a generic function to do this, and use it for omap2430. This should get us a bit closer to completely removing devctl register tinkering in the SoC glue code.
Before making use of this code for the other glue layers, things need to be tested carefully as there may be a approximately a 200 ms delay needed between powering up musb and calling musb_set_host() to avoid. Otherwise the system hangs at least with omap2430 glue layer.
--- drivers/usb/musb/musb_core.c | 103 +++++++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.h | 3 + drivers/usb/musb/omap2430.c | 71 ++++++++---------------- 3 files changed, 128 insertions(+), 49 deletions(-)
drivers/usb/musb/musb_core.c +103 -0
@@ -73,6 +73,7 @@#include <linux/prefetch.h> #include <linux/platform_device.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/dma-mapping.h> #include <linux/usb.h> #include <linux/usb/of.h>
@@ -414,6 +415,108 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)return hw_ep->musb->io.write_fifo (hw_ep, len, src); } +static u8 musb_read_devctl (struct musb *musb) +{ +return musb_readb (musb->mregs,MUSB_DEVCTL ); +} + +/** +* musb_set_host - set and initialize host mode +* @musb: musb controller driver data +* +* At least some musb revisions need to enable devctl session bit in +* peripheral mode to switch to host mode. Initializes things to host +* mode and sets A_IDLE. SoC glue needs to advance state further +* based on phy provided VBUS state. +* +* Note that the SoC glue code may need to wait for musb to settle +* on enable before calling this to avoid babble. +*/ +int musb_set_host (struct musb *musb) +{ +int error =0 ; +u8 devctl; + +if (!musb) +return -EINVAL ; + + devctl =musb_read_devctl (musb); +if (!(devctl &MUSB_DEVCTL_BDEVICE )) { +dev_info (musb->controller, +"%s: already in host mode: %02x\n" , + __func__, devctl); + goto init_data; + } + + devctl |=MUSB_DEVCTL_SESSION ; +musb_writeb (musb->mregs,MUSB_DEVCTL , devctl); + + error =readx_poll_timeout (musb_read_devctl, musb, devctl, + !(devctl &MUSB_DEVCTL_BDEVICE ),5000 , +1000000 ); +if (error) { +dev_err (musb->controller,"%s: could not set host: %02x\n" , + __func__, devctl); + +return error; + } + +init_data: + musb->is_active =1 ; + musb->xceiv->otg->state =OTG_STATE_A_IDLE ; +MUSB_HST_MODE (musb); + +return error; +} +EXPORT_SYMBOL_GPL (musb_set_host); + +/** +* musb_set_peripheral - set and initialize peripheral mode +* @musb: musb controller driver data +* +* Clears devctl session bit and initializes things for peripheral +* mode and sets B_IDLE. SoC glue needs to advance state further +* based on phy provided VBUS state. +*/ +int musb_set_peripheral (struct musb *musb) +{ +int error =0 ; +u8 devctl; + +if (!musb) +return -EINVAL ; + + devctl =musb_read_devctl (musb); +if (devctl &MUSB_DEVCTL_BDEVICE ) { +dev_info (musb->controller, +"%s: already in peripheral mode: %02x\n" , + __func__, devctl); + + goto init_data; + } + + devctl &= ~MUSB_DEVCTL_SESSION ; +musb_writeb (musb->mregs,MUSB_DEVCTL , devctl); + + error =readx_poll_timeout (musb_read_devctl, musb, devctl, + devctl &MUSB_DEVCTL_BDEVICE ,5000 , +1000000 ); +if (error) { +dev_err (musb->controller,"%s: could not set periperal: %02x\n" , + __func__, devctl); + +return error; + } + +init_data: + musb->is_active =0 ; + musb->xceiv->otg->state =OTG_STATE_B_IDLE ; +MUSB_DEV_MODE (musb); + +return error; +} +EXPORT_SYMBOL_GPL (musb_set_peripheral); +/*-------------------------------------------------------------------------*/ /* for high speed test mode; see USB 2.0 spec 7.1.20 */
drivers/usb/musb/musb_core.h +3 -0
@@ -487,6 +487,9 @@ extern void musb_start(struct musb *musb);extern void musb_write_fifo (struct musb_hw_ep *ep,u16 len,const u8 *src);extern void musb_read_fifo (struct musb_hw_ep *ep,u16 len,u8 *dst); +extern int musb_set_host (struct musb *musb); +extern int musb_set_peripheral (struct musb *musb); +extern void musb_load_testpacket (struct musb *);extern irqreturn_t musb_interrupt (struct musb *);
drivers/usb/musb/omap2430.c +22 -49
87 lines not on this page · raw message
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 8/25 usb: musb: omap2430: Clean up enable and remove devctl tinkering
In reply to Bin LiuFrom: Tony Lindgren <[email protected]>
There should be no need to tinker with devctl in enable in the SoC glue code. We have musb_start() to take care of handling it already.
--- drivers/usb/musb/omap2430.c | 20 -------------------- 1 file changed, 20 deletions(-)
drivers/usb/musb/omap2430.c +0 -20
@@ -276,33 +276,13 @@ static int omap2430_musb_init(struct musb *musb)static void omap2430_musb_enable (struct musb *musb) { -u8 devctl; -unsigned long timeout = jiffies +msecs_to_jiffies (1000 );struct device *dev = musb->controller;struct omap2430_glue *glue =dev_get_drvdata (dev->parent); -struct musb_hdrc_platform_data *pdata =dev_get_platdata (dev); -struct omap_musb_board_data *data = pdata->board_data; -switch (glue->status) {case MUSB_ID_GROUND :omap_control_usb_set_mode (glue->control_otghs,USB_MODE_HOST ); -if (data->interface_type !=MUSB_INTERFACE_UTMI ) -break ; - devctl =musb_readb (musb->mregs,MUSB_DEVCTL ); -/* start the session */ - devctl |=MUSB_DEVCTL_SESSION ; -musb_writeb (musb->mregs,MUSB_DEVCTL , devctl); -while (musb_readb (musb->mregs,MUSB_DEVCTL ) & -MUSB_DEVCTL_BDEVICE ) { -cpu_relax (); - -if (time_after (jiffies, timeout)) { -dev_err (dev,"configured as A device timeout" ); -break ; - } - }break ;case MUSB_VBUS_VALID :
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 9/25 usb: musb: omap2430: Idle musb on init
In reply to Bin LiuFrom: Tony Lindgren <[email protected]>
We want to configure musb state in omap2430_musb_enable() instead of omap2430_musb_init(). Otherwise musb may not idle properly until USB cable has been connected at least once.
And we already have omap_musb_set_mailbox() configure mode with omap_control_usb_set_mode() so we can remove those calls from omap2430_musb_enable().
--- drivers/usb/musb/omap2430.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/usb/musb/omap2430.c +3 -17
@@ -212,7 +212,6 @@ static int omap2430_musb_init(struct musb *musb)u32 l;int status =0 ;struct device *dev = musb->controller; -struct omap2430_glue *glue =dev_get_drvdata (dev->parent);struct musb_hdrc_platform_data *plat =dev_get_platdata (dev);struct omap_musb_board_data *data = plat->board_data;
@@ -268,9 +267,6 @@ static int omap2430_musb_init(struct musb *musb)musb_readl (musb->mregs,OTG_INTERFSEL ), musb_readl(musb->mregs, OTG_SIMENABLE)); -if (glue->status !=MUSB_UNKNOWN ) -omap_musb_set_mailbox (glue); -return 0 ; }
@@ -279,19 +275,9 @@ static void omap2430_musb_enable(struct musb *musb)struct device *dev = musb->controller;struct omap2430_glue *glue =dev_get_drvdata (dev->parent); -switch (glue->status) { - -case MUSB_ID_GROUND : -omap_control_usb_set_mode (glue->control_otghs,USB_MODE_HOST ); -break ; - -case MUSB_VBUS_VALID : -omap_control_usb_set_mode (glue->control_otghs,USB_MODE_DEVICE ); -break ; - -default : -break ; - } +if (glue->status ==MUSB_UNKNOWN ) + glue->status =MUSB_VBUS_OFF ; +omap_musb_set_mailbox (glue); }static void omap2430_musb_disable (struct musb *musb)
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 10/25 usb: musb: Get rid of omap2430_musb_set_vbus()
In reply to Bin LiuFrom: Tony Lindgren <[email protected]>
Now that we've removed direct calls from interrupt handler to omap2430_musb_set_vbus(), let's make things less confusing and configure VBUS directly in omap_musb_set_mailbox().
We have omap_musb_set_mailbox() called from the PHYs, and that's all we need.
Note that we can now also drop the check for MUSB_INTERFACE_UTMI, we've been already calling otg_set_vbus(musb->xceiv->otg, 0) unconditionally via omap2430_musb_set_vbus() and we should only need to call it once.
And we want to disable VBUS unconditionally on disconnect even without musb->gadget_driver, so let's drop that check too.
--- drivers/usb/musb/omap2430.c | 71 ++++++++++++------------------------- 1 file changed, 23 insertions(+), 48 deletions(-)
drivers/usb/musb/omap2430.c +23 -48
@@ -38,42 +38,6 @@ struct omap2430_glue {static struct omap2430_glue *_glue; -/* -* HDRC controls CPEN, but beware current surges during device connect. -* They can trigger transient overcurrent conditions that must be ignored. -* -* Note that we're skipping A_WAIT_VFALL -> A_IDLE and jumping right to B_IDLE -* as set by musb_set_peripheral(). -*/ -static void omap2430_musb_set_vbus (struct musb *musb,int is_on) -{ -struct usb_otg *otg = musb->xceiv->otg; -int error; - -if (is_on) { -switch (musb->xceiv->otg->state) { -case OTG_STATE_A_IDLE : - error =musb_set_host (musb); -if (!error) { - musb->xceiv->otg->state = -OTG_STATE_A_WAIT_VRISE ; -otg_set_vbus (otg,1 ); - } -break ; -default : -otg_set_vbus (otg,1 ); -break ; - } - }else { - error =musb_set_peripheral (musb); -otg_set_vbus (otg,0 ); - } - -dev_dbg (musb->controller,"VBUS %s, devctl %02x\n" , -usb_otg_state_string (musb->xceiv->otg->state), -musb_readb (musb->mregs,MUSB_DEVCTL )); -} -static inline void omap2430_low_level_exit (struct musb *musb) {u32 l;
@@ -113,27 +77,42 @@ static int omap2430_musb_mailbox(enum musb_vbus_id_status status)return 0 ; } +/* +* HDRC controls CPEN, but beware current surges during device connect. +* They can trigger transient overcurrent conditions that must be ignored. +* +* Note that we're skipping A_WAIT_VFALL -> A_IDLE and jumping right to B_IDLE +* as set by musb_set_peripheral(). +*/ static void omap_musb_set_mailbox (struct omap2430_glue *glue) {struct musb *musb =glue_to_musb (glue); -struct musb_hdrc_platform_data *pdata = -dev_get_platdata (musb->controller); -struct omap_musb_board_data *data = pdata->board_data; +int error;pm_runtime_get_sync (musb->controller); + +dev_dbg (musb->controller,"VBUS %s, devctl %02x\n" , +usb_otg_state_string (musb->xceiv->otg->state), +musb_readb (musb->mregs,MUSB_DEVCTL )); +switch (glue->status) {case MUSB_ID_GROUND :dev_dbg (musb->controller,"ID GND\n" );switch (musb->xceiv->otg->state) { +case OTG_STATE_A_IDLE : + error =musb_set_host (musb); +if (error) +break ; + musb->xceiv->otg->state =OTG_STATE_A_WAIT_VRISE ; +/* Fall through */ case OTG_STATE_A_WAIT_VRISE :case OTG_STATE_A_WAIT_BCON :case OTG_STATE_A_HOST : -case OTG_STATE_A_IDLE :/* * On multiple ID ground interrupts just keep enabling * VBUS. At least cpcap VBUS shuts down otherwise. */ -omap2430_musb_set_vbus (musb,1 ); +otg_set_vbus (musb->xceiv->otg,1 );break ;default : musb->xceiv->otg->state =OTG_STATE_A_IDLE ;
@@ -141,7 +120,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)if (musb->gadget_driver) {omap_control_usb_set_mode (glue->control_otghs,USB_MODE_HOST ); -omap2430_musb_set_vbus (musb,1 ); +otg_set_vbus (musb->xceiv->otg,1 ); }break ; }
@@ -160,12 +139,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)dev_dbg (musb->controller,"VBUS Disconnect\n" ); musb->xceiv->last_event =USB_EVENT_NONE ; -if (musb->gadget_driver) -omap2430_musb_set_vbus (musb,0 ); - -if (data->interface_type ==MUSB_INTERFACE_UTMI ) -otg_set_vbus (musb->xceiv->otg,0 ); - +musb_set_peripheral (musb); +otg_set_vbus (musb->xceiv->otg,0 );omap_control_usb_set_mode (glue->control_otghs,USB_MODE_DISCONNECT );break ;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 11/25 usb: musb: jz4740: Suppress useless field in priv structure
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
The 'dev' field was never read anywhere.
--- drivers/usb/musb/jz4740.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/musb/jz4740.c +0 -2
@@ -17,7 +17,6 @@#include "musb_core.h" struct jz4740_glue { -struct device *dev;struct platform_device *musb;struct clk *clk; };
@@ -141,7 +140,6 @@ static int jz4740_probe(struct platform_device *pdev) musb->dev.parent = &pdev->dev; - glue->dev = &pdev->dev; glue->musb = musb; glue->clk = clk;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 12/25 usb: musb: jz4740: Add local dev variable to clean up probe
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Clean up the probe function by using a local 'struct device *dev' variable, instead of referencing &pdev->dev everytime.
--- drivers/usb/musb/jz4740.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/usb/musb/jz4740.c +10 -9
@@ -109,36 +109,37 @@ static const struct musb_platform_ops jz4740_musb_ops = {static int jz4740_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct musb_hdrc_platform_data *pdata = &jz4740_musb_platform_data;struct platform_device *musb;struct jz4740_glue *glue;struct clk *clk;int ret; - glue =devm_kzalloc (&pdev->dev,sizeof (*glue),GFP_KERNEL ); + glue =devm_kzalloc (dev,sizeof (*glue),GFP_KERNEL );if (!glue)return -ENOMEM ; musb =platform_device_alloc ("musb-hdrc" ,PLATFORM_DEVID_AUTO );if (!musb) { -dev_err (&pdev->dev,"failed to allocate musb device\n" ); +dev_err (dev,"failed to allocate musb device" );return -ENOMEM ; } - clk =devm_clk_get (&pdev->dev,"udc" ); + clk =devm_clk_get (dev,"udc" );if (IS_ERR (clk)) { -dev_err (&pdev->dev,"failed to get clock\n" ); +dev_err (dev,"failed to get clock" ); ret =PTR_ERR (clk); goto err_platform_device_put; } ret =clk_prepare_enable (clk);if (ret) { -dev_err (&pdev->dev,"failed to enable clock\n" ); +dev_err (dev,"failed to enable clock" ); goto err_platform_device_put; } - musb->dev.parent = &pdev->dev; + musb->dev.parent = dev; glue->musb = musb; glue->clk = clk;
@@ -150,19 +151,19 @@ static int jz4740_probe(struct platform_device *pdev) ret =platform_device_add_resources (musb, pdev->resource, pdev->num_resources);if (ret) { -dev_err (&pdev->dev,"failed to add resources\n" ); +dev_err (dev,"failed to add resources" ); goto err_clk_disable; } ret =platform_device_add_data (musb, pdata,sizeof (*pdata));if (ret) { -dev_err (&pdev->dev,"failed to add platform_data\n" ); +dev_err (dev,"failed to add platform_data" ); goto err_clk_disable; } ret =platform_device_add (musb);if (ret) { -dev_err (&pdev->dev,"failed to register musb device\n" ); +dev_err (dev,"failed to register musb device" ); goto err_clk_disable; }
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 13/25 usb: musb: jz4740: Constify jz4740_musb_pdata struct
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
By moving around the jz4740_musb_pdata structure, we can have the .platform_ops field initialized, so that we don't have to initialize it manually in the probe function. Therefore, the struct can be const now.
--- drivers/usb/musb/jz4740.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/usb/musb/jz4740.c +7 -8
@@ -66,11 +66,6 @@ static const struct musb_hdrc_config jz4740_musb_config = { .fifo_cfg_size = ARRAY_SIZE(jz4740_musb_fifo_cfg), }; -static struct musb_hdrc_platform_data jz4740_musb_platform_data = { - .mode =MUSB_PERIPHERAL , - .config = &jz4740_musb_config, -}; -static int jz4740_musb_init (struct musb *musb) {struct device *dev = musb->controller->parent;
@@ -107,10 +102,16 @@ static const struct musb_platform_ops jz4740_musb_ops = { .init = jz4740_musb_init, }; +static const struct musb_hdrc_platform_data jz4740_musb_pdata = { + .mode =MUSB_PERIPHERAL , + .config = &jz4740_musb_config, + .platform_ops = &jz4740_musb_ops, +}; +static int jz4740_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct musb_hdrc_platform_data *pdata = &jz4740_musb_platform_data; +const struct musb_hdrc_platform_data *pdata = &jz4740_musb_pdata;struct platform_device *musb;struct jz4740_glue *glue;struct clk *clk;
@@ -144,8 +145,6 @@ static int jz4740_probe(struct platform_device *pdev) glue->musb = musb; glue->clk = clk; - pdata->platform_ops = &jz4740_musb_ops; -platform_set_drvdata (pdev, glue); ret = platform_device_add_resources(musb, pdev->resource,
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 14/25 usb: musb: jz4740: Rename platform_device field in priv struct
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Name the platform_device pointer 'pdev' instead of 'musb'. Since the driver also deal with pointers to 'struct musb', it can be very confusing to have a pointer named after this struct but with a different type.
--- drivers/usb/musb/jz4740.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/musb/jz4740.c +3 -3
@@ -17,7 +17,7 @@#include "musb_core.h" struct jz4740_glue { -struct platform_device *musb; +struct platform_device *pdev;struct clk *clk; };
@@ -142,7 +142,7 @@ static int jz4740_probe(struct platform_device *pdev) musb->dev.parent = dev; - glue->musb = musb; + glue->pdev = musb; glue->clk = clk;platform_set_drvdata (pdev, glue);
@@ -179,7 +179,7 @@ static int jz4740_remove(struct platform_device *pdev) {struct jz4740_glue *glue =platform_get_drvdata (pdev); -platform_device_unregister (glue->musb); +platform_device_unregister (glue->pdev);clk_disable_unprepare (glue->clk);return 0 ;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 15/25 usb: musb: jz4740: Comments fix
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Add a /* sentinel */ comment to the sentinel entry of the devicetree ID table, and fix a multi-line comment not having its opening token on a separate line.
--- drivers/usb/musb/jz4740.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/musb/jz4740.c +3 -2
@@ -82,7 +82,8 @@ static int jz4740_musb_init(struct musb *musb)return err; } -/* Silicon does not implement ConfigData register. +/* +* Silicon does not implement ConfigData register. * Set dyn_fifo to avoid reading EP config from hardware. */ musb->dyn_fifo = true;
@@ -188,7 +189,7 @@ static int jz4740_remove(struct platform_device *pdev)#ifdef CONFIG_OF static const struct of_device_id jz4740_musb_of_match[] = { { .compatible ="ingenic,jz4740-musb" }, - {}, + {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, jz4740_musb_of_match);#endif
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 16/25 usb: musb: jz4740: Whitespace and indentation fixes
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Fix lines with too much or not enough indentation, and lines which were indented with spaces instead of tabs.
--- drivers/usb/musb/jz4740.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/usb/musb/jz4740.c +14 -14
@@ -23,9 +23,9 @@ struct jz4740_glue {static irqreturn_t jz4740_musb_interrupt (int irq,void *__hci) { -unsigned long flags; -irqreturn_t retval =IRQ_NONE ; -struct musb *musb = __hci; +unsigned long flags; +irqreturn_t retval =IRQ_NONE ; +struct musb *musb = __hci;spin_lock_irqsave (&musb->lock, flags);
@@ -39,7 +39,7 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)* never see them set */ musb->int_usb &=MUSB_INTR_SUSPEND |MUSB_INTR_RESUME | -MUSB_INTR_RESET |MUSB_INTR_SOF ; +MUSB_INTR_RESET |MUSB_INTR_SOF ;if (musb->int_usb || musb->int_tx || musb->int_rx) retval =musb_interrupt (musb);
@@ -50,20 +50,20 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci) }static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = { -{ .hw_ep_num =1 , .style =FIFO_TX , .maxpacket =512 , }, -{ .hw_ep_num =1 , .style =FIFO_RX , .maxpacket =512 , }, -{ .hw_ep_num =2 , .style =FIFO_TX , .maxpacket =64 , }, + { .hw_ep_num =1 , .style =FIFO_TX , .maxpacket =512 , }, + { .hw_ep_num =1 , .style =FIFO_RX , .maxpacket =512 , }, + { .hw_ep_num =2 , .style =FIFO_TX , .maxpacket =64 , }, };static const struct musb_hdrc_config jz4740_musb_config = {/* Silicon does not implement USB OTG. */ - .multipoint =0 , + .multipoint =0 ,/* Max EPs scanned, driver will decide which EP can be used. */ - .num_eps =4 , + .num_eps =4 ,/* RAMbits needed to configure EPs from table */ - .ram_bits =9 , - .fifo_cfg = jz4740_musb_fifo_cfg, - .fifo_cfg_size =ARRAY_SIZE (jz4740_musb_fifo_cfg), + .ram_bits =9 , + .fifo_cfg = jz4740_musb_fifo_cfg, + .fifo_cfg_size =ARRAY_SIZE (jz4740_musb_fifo_cfg), };static int jz4740_musb_init (struct musb *musb)
@@ -115,7 +115,7 @@ static int jz4740_probe(struct platform_device *pdev)const struct musb_hdrc_platform_data *pdata = &jz4740_musb_pdata;struct platform_device *musb;struct jz4740_glue *glue; -struct clk *clk; +struct clk *clk;int ret; glue =devm_kzalloc (dev,sizeof (*glue),GFP_KERNEL );
@@ -178,7 +178,7 @@ static int jz4740_probe(struct platform_device *pdev)static int jz4740_remove (struct platform_device *pdev) { -struct jz4740_glue *glue =platform_get_drvdata (pdev); +struct jz4740_glue *glue =platform_get_drvdata (pdev);platform_device_unregister (glue->pdev);clk_disable_unprepare (glue->clk);
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 17/25 USB: musb: fix __iomem in trace functions
In reply to Bin LiuFrom: "Ben Dooks (Codethink)" <[email protected]>
The trace functions should have __iomem on the addr pointers. Add __iomem to avoid the following warnings from sparse:
drivers/usb/musb/musb_core.c:253:55: warning: incorrect type in argument 2 (different address spaces)drivers/usb/musb/musb_core.c:253:55: expected void const *addrdrivers/usb/musb/musb_core.c:253:55: got void const [noderef] <asn:2> *addrdrivers/usb/musb/musb_core.c:259:56: warning: incorrect type in argument 2 (different address spaces)drivers/usb/musb/musb_core.c:259:56: expected void const *addrdrivers/usb/musb/musb_core.c:259:56: got void [noderef] <asn:2> *addrdrivers/usb/musb/musb_core.c:267:55: warning: incorrect type in argument 2 (different address spaces)drivers/usb/musb/musb_core.c:267:55: expected void const *addrdrivers/usb/musb/musb_core.c:267:55: got void const [noderef] <asn:2> *addrdrivers/usb/musb/musb_core.c:273:56: warning: incorrect type in argument 2 (different address spaces)drivers/usb/musb/musb_core.c:273:56: expected void const *addrdrivers/usb/musb/musb_core.c:273:56: got void [noderef] <asn:2> *addrdrivers/usb/musb/musb_core.c:383:55: warning: incorrect type in argument 2 (different address spaces)drivers/usb/musb/musb_core.c:383:55: expected void const *addrdrivers/usb/musb/musb_core.c:383:55: got void const [noderef] <asn:2> *addrdrivers/usb/musb/musb_core.c:390:56: warning: incorrect type in argument 2 (different address spaces)drivers/usb/musb/musb_core.c:390:56: expected void const *addrdrivers/usb/musb/musb_core.c:390:56: got void [noderef] <asn:2> *addr
--- drivers/usb/musb/musb_trace.h | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
drivers/usb/musb/musb_trace.h +21 -12
@@ -38,11 +38,12 @@ TRACE_EVENT(musb_log, ); DECLARE_EVENT_CLASS(musb_regb, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u8 data), TP_ARGS(caller, addr, offset, data), TP_STRUCT__entry( __field(void *, caller) - __field(const void *, addr) + __field(const void __iomem *, addr) __field(unsigned int, offset) __field(u8, data) ),
@@ -57,21 +58,24 @@ DECLARE_EVENT_CLASS(musb_regb, );DEFINE_EVENT (musb_regb, musb_readb, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u8 data),TP_ARGS (caller, addr, offset, data) );DEFINE_EVENT (musb_regb, musb_writeb, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u8 data),TP_ARGS (caller, addr, offset, data) ); DECLARE_EVENT_CLASS(musb_regw, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u16 data), TP_ARGS(caller, addr, offset, data), TP_STRUCT__entry( __field(void *, caller) - __field(const void *, addr) + __field(const void __iomem *, addr) __field(unsigned int, offset) __field(u16, data) ),
@@ -86,21 +90,24 @@ DECLARE_EVENT_CLASS(musb_regw, );DEFINE_EVENT (musb_regw, musb_readw, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u16 data),TP_ARGS (caller, addr, offset, data) );DEFINE_EVENT (musb_regw, musb_writew, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u16 data),TP_ARGS (caller, addr, offset, data) ); DECLARE_EVENT_CLASS(musb_regl, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u32 data), TP_ARGS(caller, addr, offset, data), TP_STRUCT__entry( __field(void *, caller) - __field(const void *, addr) + __field(const void __iomem *, addr) __field(unsigned int, offset) __field(u32, data) ),
@@ -115,12 +122,14 @@ DECLARE_EVENT_CLASS(musb_regl, );DEFINE_EVENT (musb_regl, musb_readl, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u32 data),TP_ARGS (caller, addr, offset, data) );DEFINE_EVENT (musb_regl, musb_writel, - TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data), + TP_PROTO(void *caller, const void __iomem *addr, + unsigned int offset, u32 data),TP_ARGS (caller, addr, offset, data) );
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 18/25 usb: musb/ux500: Use dma_request_chan() instead dma_request_slave_channel()
In reply to Bin LiuFrom: Peter Ujfalusi <[email protected]>
dma_request_slave_channel() is a wrapper on top of dma_request_chan() eating up the error code.
--- drivers/usb/musb/ux500_dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/ux500_dma.c +2 -2
@@ -310,9 +310,9 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller) dma_channel->max_len =SZ_16M ; ux500_channel->dma_chan = -dma_request_slave_channel (dev, chan_names[ch_num]); +dma_request_chan (dev, chan_names[ch_num]); -if (!ux500_channel->dma_chan) +if (IS_ERR (ux500_channel->dma_chan)) ux500_channel->dma_chan = dma_request_channel(mask, data ?
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 19/25 dt-bindings: usb: musb: Add support for MediaTek musb controller
In reply to Bin LiuFrom: Min Guo <[email protected]>
This adds support for MediaTek musb controller in
host, peripheral and otg mode.
--- .../devicetree/bindings/usb/mediatek,musb.txt | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/mediatek,musb.txt
Documentation/devicetree/bindings/usb/mediatek,musb.txt new file +57 -0
@@ -0,0 +1,57 @@ +MediaTek musb DRD/OTG controller +------------------------------------------- + +Required properties: + - compatible : should be one of: + "mediatek,mt2701-musb" + ... + followed by "mediatek,mtk-musb" + - reg : specifies physical base address and size of + the registers + - interrupts : interrupt used by musb controller + - interrupt-names : must be "mc" + - phys : PHY specifier for the OTG phy + - dr_mode : should be one of "host", "peripheral" or "otg", + refer to usb/generic.txt + - clocks : a list of phandle + clock-specifier pairs, one for + each entry in clock-names + - clock-names : must contain "main", "mcu", "univpll" + for clocks of controller + +Optional properties: + - power-domains : a phandle to USB power domain node to control USB's + MTCMOS + +Required child nodes: + usb connector node as defined in bindings/connector/usb-connector.txt +Optional properties: + - id-gpios : input GPIO for USB ID pin. + - vbus-gpios : input GPIO for USB VBUS pin. + - vbus-supply : reference to the VBUS regulator, needed when supports + dual-role mode + - usb-role-switch : use USB Role Switch to support dual-role switch, see + usb/generic.txt. + +Example: + +usb2: usb@11200000 { + compatible = "mediatek,mt2701-musb", + "mediatek,mtk-musb"; + reg = <0 0x11200000 0 0x1000>; + interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "mc"; + phys = <&u2port2 PHY_TYPE_USB2>; + dr_mode = "otg"; + clocks = <&pericfg CLK_PERI_USB0>, + <&pericfg CLK_PERI_USB0_MCU>, + <&pericfg CLK_PERI_USB_SLV>; + clock-names = "main","mcu","univpll"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>; + usb-role-switch; + connector{ + compatible = "gpio-usb-b-connector", "usb-b-connector"; + type = "micro"; + id-gpios = <&pio 44 GPIO_ACTIVE_HIGH>; + vbus-supply = <&usb_vbus>; + }; +};
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 20/25 usb: musb: Add get/set toggle hooks
In reply to Bin LiuFrom: Min Guo <[email protected]>
Add get/set toggle hooks in struct musb_io and struct musb_platform_ops for special platform; remove function musb_save_toggle, use the set/get callback to handle toggle.
--- drivers/usb/musb/musb_core.c | 42 ++++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.h | 5 ++++ drivers/usb/musb/musb_host.c | 46 ++++++++---------------------------- drivers/usb/musb/musb_io.h | 4 ++++ 4 files changed, 61 insertions(+), 36 deletions(-)
drivers/usb/musb/musb_core.c +42 -0
@@ -275,6 +275,38 @@ static void musb_default_writew(void __iomem *addr, unsigned offset, u16 data)__raw_writew (data, addr + offset); } +static u16 musb_default_get_toggle (struct musb_qh *qh,int is_out) +{ +void __iomem *epio = qh->hw_ep->regs; +u16 csr; + +if (is_out) + csr =musb_readw (epio,MUSB_TXCSR ) &MUSB_TXCSR_H_DATATOGGLE ; +else + csr =musb_readw (epio,MUSB_RXCSR ) &MUSB_RXCSR_H_DATATOGGLE ; + +return csr; +} + +static u16 musb_default_set_toggle (struct musb_qh *qh,int is_out, +struct urb *urb) +{ +u16 csr; +u16 toggle; + + toggle =usb_gettoggle (urb->dev, qh->epnum, is_out); + +if (is_out) + csr = toggle ? (MUSB_TXCSR_H_WR_DATATOGGLE + |MUSB_TXCSR_H_DATATOGGLE ) + :MUSB_TXCSR_CLRDATATOG ; +else + csr = toggle ? (MUSB_RXCSR_H_WR_DATATOGGLE + |MUSB_RXCSR_H_DATATOGGLE ) :0 ; + +return csr; +} +/* * Load an endpoint's FIFO */
@@ -2381,6 +2413,16 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)else musb->io.write_fifo = musb_default_write_fifo; +if (musb->ops->get_toggle) + musb->io.get_toggle = musb->ops->get_toggle; +else + musb->io.get_toggle = musb_default_get_toggle; + +if (musb->ops->set_toggle) + musb->io.set_toggle = musb->ops->set_toggle; +else + musb->io.set_toggle = musb_default_set_toggle; +if (!musb->xceiv->io_ops) { musb->xceiv->io_dev = musb->controller; musb->xceiv->io_priv = musb->mregs;
drivers/usb/musb/musb_core.h +5 -0
@@ -27,6 +27,7 @@struct musb ;struct musb_hw_ep ;struct musb_ep ; +struct musb_qh ;/* Helper defines for struct musb->hwvers */ #define MUSB_HWVERS_MAJOR (x) ((x >> 10) & 0x1f)
@@ -123,6 +124,8 @@ struct musb_io;* @writew: write 16 bits * @read_fifo: reads the fifo * @write_fifo: writes to fifo +* @get_toggle: platform specific get toggle function +* @set_toggle: platform specific set toggle function * @dma_init: platform specific dma init function * @dma_exit: platform specific dma exit function * @init: turns on clocks, sets up platform-specific registers, etc
@@ -167,6 +170,8 @@ struct musb_platform_ops {void (*writew)(void __iomem *addr,unsigned offset,u16 data);void (*read_fifo)(struct musb_hw_ep *hw_ep,u16 len,u8 *buf);void (*write_fifo)(struct musb_hw_ep *hw_ep,u16 len,const u8 *buf); +u16 (*get_toggle)(struct musb_qh *qh,int is_out); +u16 (*set_toggle)(struct musb_qh *qh,int is_out,struct urb *urb);struct dma_controller * (*dma_init) (struct musb *musb,void __iomem *base);void (*dma_exit)(struct dma_controller *c);
drivers/usb/musb/musb_host.c +10 -36
92 lines not on this page · raw message
drivers/usb/musb/musb_io.h +4 -0
@@ -22,6 +22,8 @@* @read_fifo: platform specific function to read fifo * @write_fifo: platform specific function to write fifo * @busctl_offset: platform specific function to get busctl offset +* @get_toggle: platform specific function to get toggle +* @set_toggle: platform specific function to set toggle */ struct musb_io {u32 (*ep_offset)(u8 epnum,u16 offset);
@@ -30,6 +32,8 @@ struct musb_io {void (*read_fifo)(struct musb_hw_ep *hw_ep,u16 len,u8 *buf);void (*write_fifo)(struct musb_hw_ep *hw_ep,u16 len,const u8 *buf);u32 (*busctl_offset)(u8 epnum,u16 offset); +u16 (*get_toggle)(struct musb_qh *qh,int is_out); +u16 (*set_toggle)(struct musb_qh *qh,int is_out,struct urb *urb); };/* Do not add new entries here, add them the struct musb_io instead */
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 21/25 usb: musb: Add noirq type of dma create interface
In reply to Bin LiuFrom: Min Guo <[email protected]>
Add noirq type of dma create interface for platform which do not have dedicated DMA interrupt line, move musbhsdma macro definition to musb_dma.h
--- drivers/usb/musb/musb_dma.h | 9 ++++++ drivers/usb/musb/musbhsdma.c | 54 ++++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 17 deletions(-)
drivers/usb/musb/musb_dma.h +9 -0
@@ -35,6 +35,12 @@ struct musb_hw_ep;* whether shared with the Inventra core or separate. */ +#define MUSB_HSDMA_BASE 0x200 +#define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0) +#define MUSB_HSDMA_CONTROL 0x4 +#define MUSB_HSDMA_ADDRESS 0x8 +#define MUSB_HSDMA_COUNT 0xc +#define DMA_ADDR_INVALID (~(dma_addr_t)0)#ifdef CONFIG_MUSB_PIO_ONLY
@@ -191,6 +197,9 @@ extern void (*musb_dma_controller_destroy)(struct dma_controller *);extern struct dma_controller *musbhs_dma_controller_create (struct musb *musb,void __iomem *base);extern void musbhs_dma_controller_destroy (struct dma_controller *c); +extern struct dma_controller * +musbhs_dma_controller_create_noirq (struct musb *musb,void __iomem *base); +extern irqreturn_t dma_controller_irq (int irq,void *private_data);extern struct dma_controller *tusb_dma_controller_create (struct musb *musb,void __iomem *base);
drivers/usb/musb/musbhsdma.c +37 -17
89 lines not on this page · raw message
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 22/25 usb: musb: Add musb_clearb/w() interface
In reply to Bin LiuFrom: Min Guo <[email protected]>
Delete the const attribute of addr parameter in readb/w/l hooks, these changes are for implementing clearing W1C registers. Replace musb_readb/w with musb_clearb/w to clear the interrupt status.
While at here, change some unsigned type to u32 to fix checkpatch.pl warnings.
--- drivers/usb/musb/musb_core.c | 42 ++++++++++++++++++++++++------------ drivers/usb/musb/musb_core.h | 12 +++++++---- drivers/usb/musb/musb_io.h | 14 ++++++------ drivers/usb/musb/musbhsdma.c | 2 +- drivers/usb/musb/sunxi.c | 4 ++-- drivers/usb/musb/tusb6010.c | 2 +- 6 files changed, 48 insertions(+), 28 deletions(-)
drivers/usb/musb/musb_core.c +28 -14
@@ -247,7 +247,7 @@ static u32 musb_default_busctl_offset(u8 epnum, u16 offset)return 0x80 + (0x08 * epnum) + offset; } -static u8 musb_default_readb (const void __iomem *addr,unsigned offset) +static u8 musb_default_readb (void __iomem *addr,u32 offset) {u8 data =__raw_readb (addr + offset);
@@ -255,13 +255,13 @@ static u8 musb_default_readb(const void __iomem *addr, unsigned offset)return data; } -static void musb_default_writeb (void __iomem *addr,unsigned offset,u8 data) +static void musb_default_writeb (void __iomem *addr,u32 offset,u8 data) {trace_musb_writeb (__builtin_return_address (0 ), addr, offset, data);__raw_writeb (data, addr + offset); } -static u16 musb_default_readw (const void __iomem *addr,unsigned offset) +static u16 musb_default_readw (void __iomem *addr,u32 offset) {u16 data =__raw_readw (addr + offset);
@@ -269,7 +269,7 @@ static u16 musb_default_readw(const void __iomem *addr, unsigned offset)return data; } -static void musb_default_writew (void __iomem *addr,unsigned offset,u16 data) +static void musb_default_writew (void __iomem *addr,u32 offset,u16 data) {trace_musb_writew (__builtin_return_address (0 ), addr, offset, data);__raw_writew (data, addr + offset);
@@ -397,19 +397,25 @@ static void musb_default_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)/* * Old style IO functions */ -u8 (*musb_readb)(const void __iomem *addr,unsigned offset); +u8 (*musb_readb)(void __iomem *addr,u32 offset);EXPORT_SYMBOL_GPL (musb_readb); -void (*musb_writeb)(void __iomem *addr,unsigned offset,u8 data); +void (*musb_writeb)(void __iomem *addr,u32 offset,u8 data);EXPORT_SYMBOL_GPL (musb_writeb); -u16 (*musb_readw)(const void __iomem *addr,unsigned offset); +u8 (*musb_clearb)(void __iomem *addr,u32 offset); +EXPORT_SYMBOL_GPL (musb_clearb); + +u16 (*musb_readw)(void __iomem *addr,u32 offset);EXPORT_SYMBOL_GPL (musb_readw); -void (*musb_writew)(void __iomem *addr,unsigned offset,u16 data); +void (*musb_writew)(void __iomem *addr,u32 offset,u16 data);EXPORT_SYMBOL_GPL (musb_writew); -u32 musb_readl (const void __iomem *addr,unsigned offset) +u16 (*musb_clearw)(void __iomem *addr,u32 offset); +EXPORT_SYMBOL_GPL (musb_clearw); + +u32 musb_readl (void __iomem *addr,u32 offset) {u32 data =__raw_readl (addr + offset);
@@ -418,7 +424,7 @@ u32 musb_readl(const void __iomem *addr, unsigned offset) }EXPORT_SYMBOL_GPL (musb_readl); -void musb_writel (void __iomem *addr,unsigned offset,u32 data) +void musb_writel (void __iomem *addr,u32 offset,u32 data) {trace_musb_writel (__builtin_return_address (0 ), addr, offset, data);__raw_writel (data, addr + offset);
@@ -1149,7 +1155,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,static void musb_disable_interrupts (struct musb *musb) {void __iomem *mbase = musb->mregs; -u16 temp;/* disable interrupts */ musb_writeb (mbase,MUSB_INTRUSBE ,0 );
@@ -1159,9 +1164,9 @@ static void musb_disable_interrupts(struct musb *musb)musb_writew (mbase,MUSB_INTRRXE ,0 );/* flush pending interrupts */ - temp =musb_readb (mbase,MUSB_INTRUSB ); - temp =musb_readw (mbase,MUSB_INTRTX ); - temp =musb_readw (mbase,MUSB_INTRRX ); +musb_clearb (mbase,MUSB_INTRUSB ); +musb_clearw (mbase,MUSB_INTRTX ); +musb_clearw (mbase,MUSB_INTRRX ); }static void musb_enable_interrupts (struct musb *musb)
@@ -2388,10 +2393,19 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) musb_readb = musb->ops->readb;if (musb->ops->writeb) musb_writeb = musb->ops->writeb; +if (musb->ops->clearb) + musb_clearb = musb->ops->clearb; +else + musb_clearb = musb_readb; +if (musb->ops->readw) musb_readw = musb->ops->readw;if (musb->ops->writew) musb_writew = musb->ops->writew; +if (musb->ops->clearw) + musb_clearw = musb->ops->clearw; +else + musb_clearw = musb_readw;#ifndef CONFIG_MUSB_PIO_ONLY if (!musb->ops->dma_init || !musb->ops->dma_exit) {
drivers/usb/musb/musb_core.h +8 -4
@@ -120,8 +120,10 @@ struct musb_io;* @fifo_offset: returns the fifo offset * @readb: read 8 bits * @writeb: write 8 bits +* @clearb: could be clear-on-readb or W1C * @readw: read 16 bits * @writew: write 16 bits +* @clearw: could be clear-on-readw or W1C * @read_fifo: reads the fifo * @write_fifo: writes to fifo * @get_toggle: platform specific get toggle function
@@ -164,10 +166,12 @@ struct musb_platform_ops {u16 fifo_mode;u32 (*fifo_offset)(u8 epnum);u32 (*busctl_offset)(u8 epnum,u16 offset); -u8 (*readb)(const void __iomem *addr,unsigned offset); -void (*writeb)(void __iomem *addr,unsigned offset,u8 data); -u16 (*readw)(const void __iomem *addr,unsigned offset); -void (*writew)(void __iomem *addr,unsigned offset,u16 data); +u8 (*readb)(void __iomem *addr,u32 offset); +void (*writeb)(void __iomem *addr,u32 offset,u8 data); +u8 (*clearb)(void __iomem *addr,u32 offset); +u16 (*readw)(void __iomem *addr,u32 offset); +void (*writew)(void __iomem *addr,u32 offset,u16 data); +u16 (*clearw)(void __iomem *addr,u32 offset);void (*read_fifo)(struct musb_hw_ep *hw_ep,u16 len,u8 *buf);void (*write_fifo)(struct musb_hw_ep *hw_ep,u16 len,const u8 *buf);u16 (*get_toggle)(struct musb_qh *qh,int is_out);
drivers/usb/musb/musb_io.h +8 -6
@@ -37,11 +37,13 @@ struct musb_io { };/* Do not add new entries here, add them the struct musb_io instead */ -extern u8 (*musb_readb)(const void __iomem *addr,unsigned offset); -extern void (*musb_writeb)(void __iomem *addr,unsigned offset,u8 data); -extern u16 (*musb_readw)(const void __iomem *addr,unsigned offset); -extern void (*musb_writew)(void __iomem *addr,unsigned offset,u16 data); -extern u32 musb_readl (const void __iomem *addr,unsigned offset); -extern void musb_writel (void __iomem *addr,unsigned offset,u32 data); +extern u8 (*musb_readb)(void __iomem *addr,u32 offset); +extern void (*musb_writeb)(void __iomem *addr,u32 offset,u8 data); +extern u8 (*musb_clearb)(void __iomem *addr,u32 offset); +extern u16 (*musb_readw)(void __iomem *addr,u32 offset); +extern void (*musb_writew)(void __iomem *addr,u32 offset,u16 data); +extern u16 (*musb_clearw)(void __iomem *addr,u32 offset); +extern u32 musb_readl (void __iomem *addr,u32 offset); +extern void musb_writel (void __iomem *addr,u32 offset,u32 data);#endif
drivers/usb/musb/musbhsdma.c +1 -1
@@ -284,7 +284,7 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)spin_lock_irqsave (&musb->lock, flags); - int_hsdma =musb_readb (mbase,MUSB_HSDMA_INTR ); + int_hsdma =musb_clearb (mbase,MUSB_HSDMA_INTR );if (!int_hsdma) {musb_dbg (musb,"spurious DMA irq" );
drivers/usb/musb/sunxi.c +2 -2
@@ -407,7 +407,7 @@ static u32 sunxi_musb_busctl_offset(u8 epnum, u16 offset)return SUNXI_MUSB_TXFUNCADDR + offset; } -static u8 sunxi_musb_readb (const void __iomem *addr,unsigned offset) +static u8 sunxi_musb_readb (void __iomem *addr,u32 offset) {struct sunxi_glue *glue;
@@ -520,7 +520,7 @@ static void sunxi_musb_writeb(void __iomem *addr, unsigned offset, u8 data) (int)(addr - sunxi_musb->mregs)); } -static u16 sunxi_musb_readw (const void __iomem *addr,unsigned offset) +static u16 sunxi_musb_readw (void __iomem *addr,u32 offset) {if (addr == sunxi_musb->mregs) {/* generic control or fifo control reg access */
drivers/usb/musb/tusb6010.c +1 -1
@@ -142,7 +142,7 @@ static void tusb_ep_select(void __iomem *mbase, u8 epnum)/* * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. */ -static u8 tusb_readb (const void __iomem *addr,unsigned offset) +static u8 tusb_readb (void __iomem *addr,u32 offset) {u16 tmp;u8 val;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 23/25 usb: musb: Add support for MediaTek musb controller
In reply to Bin LiuFrom: Min Guo <[email protected]>
This adds support for MediaTek musb controller in host, peripheral and otg mode.
There are some quirk of MediaTek musb controller, such as:
-W1C interrupt status registers
-Private data toggle registers
-No dedicated DMA interrupt line
--- drivers/usb/musb/Kconfig | 9 +- drivers/usb/musb/Makefile | 1 + drivers/usb/musb/mediatek.c | 582 ++++++++++++++++++++++++++++++++++++ 3 files changed, 591 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb/mediatek.c
drivers/usb/musb/Kconfig +8 -1
@@ -115,6 +115,13 @@ config USB_MUSB_JZ4740 depends on USB_MUSB_GADGET depends on USB=n || USB_OTG_BLACKLIST_HUB +config USB_MUSB_MEDIATEK + tristate "MediaTek platforms" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on NOP_USB_XCEIV + depends on GENERIC_PHY + select USB_ROLE_SWITCH + config USB_MUSB_AM335X_CHILD tristate
@@ -141,7 +148,7 @@ config USB_UX500_DMA config USB_INVENTRA_DMA bool 'Inventra' - depends on USB_MUSB_OMAP2PLUS + depends on USB_MUSB_OMAP2PLUS || USB_MUSB_MEDIATEK help Enable DMA transfers using Mentor's engine.
drivers/usb/musb/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o obj-$(CONFIG_USB_MUSB_UX500) += ux500.o obj-$(CONFIG_USB_MUSB_JZ4740) += jz4740.o obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o +obj-$(CONFIG_USB_MUSB_MEDIATEK) += mediatek.o obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o
drivers/usb/musb/mediatek.c new file +582 -0
582 lines not on this page · raw message
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 24/25 usb: musb: davinci: Convert to use GPIO descriptor
In reply to Bin LiuFrom: Linus Walleij <[email protected]>
The DaVinci MUSB glue contains an optional GPIO line to control VBUS power, convert this to use a GPIO descriptor and augment the EVM board file to provide this descriptor.
I can't get this driver to compile properly and it depends on broken but when I didn get it to compile brokenly, it did at least not complain about THIS code being broken so I don't think I broke the driver any more than what it already is.
I did away with the ifdefs that do not work with multiplatform anyway so the day someone decides to resurrect the code, the path to get it working should be easier as well since DaVinci is now multiplatform.
--- arch/arm/mach-davinci/board-dm644x-evm.c | 12 +++++ drivers/usb/musb/davinci.c | 57 ++++++++++++++---------- 2 files changed, 45 insertions(+), 24 deletions(-)
arch/arm/mach-davinci/board-dm644x-evm.c +12 -0
@@ -823,6 +823,17 @@ static int davinci_phy_fixup(struct phy_device *phydev)#define HAS_NAND IS_ENABLED(CONFIG_MTD_NAND_DAVINCI) +#define GPIO_nVBUS_DRV 160 + +static struct gpiod_lookup_table dm644evm_usb_gpio_table = { + .dev_id ="musb-davinci" , + .table = { +GPIO_LOOKUP ("davinci_gpio" , GPIO_nVBUS_DRV,NULL , +GPIO_ACTIVE_HIGH ), + { } + }, +}; +static __init void davinci_evm_init (void ) {int ret;
@@ -875,6 +886,7 @@ static __init void davinci_evm_init(void)dm644x_init_asp ();/* irlml6401 switches over 1A, in under 8 msec */ +gpiod_add_lookup_table (&dm644evm_usb_gpio_table);davinci_setup_usb (1000 ,8 );if (IS_BUILTIN (CONFIG_PHYLIB )) {
drivers/usb/musb/davinci.c +33 -24
105 lines not on this page · raw message
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 25/25 usb: musb: remove dummy driver musb_am335x.c
In reply to Bin LiuSince commit 0782e8572ce4 ("ARM: dts: Probe am335x musb with ti-sysc"), the dummy driver musb_am335x.c is no longer needed, let's drop it.
--- drivers/usb/musb/Kconfig | 4 ---- drivers/usb/musb/Makefile | 3 --- drivers/usb/musb/musb_am335x.c | 44 ---------------------------------- 3 files changed, 51 deletions(-) delete mode 100644 drivers/usb/musb/musb_am335x.c
drivers/usb/musb/Kconfig +0 -4
@@ -101,7 +101,6 @@ config USB_MUSB_AM35X config USB_MUSB_DSPS tristate "TI DSPS platforms" - select USB_MUSB_AM335X_CHILD depends on ARCH_OMAP2PLUS || COMPILE_TEST depends on OF_IRQ
@@ -122,9 +121,6 @@ config USB_MUSB_MEDIATEK depends on GENERIC_PHY select USB_ROLE_SWITCH -config USB_MUSB_AM335X_CHILD - tristate - comment "MUSB DMA mode" config MUSB_PIO_ONLY
drivers/usb/musb/Makefile +0 -3
@@ -26,9 +26,6 @@ obj-$(CONFIG_USB_MUSB_JZ4740) += jz4740.o obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o obj-$(CONFIG_USB_MUSB_MEDIATEK) += mediatek.o - -obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o - # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... # PIO only, or DMA (several potential schemes).
drivers/usb/musb/musb_am335x.c deleted +0 -44
44 lines not on this page · raw message
Signature · 1 line
2.17.1