usb: musb: cleanup
v3 cover usb: musb: cleanup
Most part of this patch series was obtained by splitting [RFC PATCH 2/3] usb: musb: omap glue: use omap-usb2 as the phy driver.
TO DO:
* dt adaptation of musb omap glue, twl4030, twl6030.
* Use control module driver API to write to control module registers (mailbox and power control of phy)
* send usb2 phy driver
* make musb omap glue use usb2 phy driver and make twl630 as a comparator driver.
Changes from v2:
* Added a condition in twl4030 to avoid spurious disconnect event message to the omap glue, on bootup if the cable is not connected.
Changes from v1:
Changed the commit log of *usb: musb: move work_struct(otg_notifier_work) from core to omap glue* as per Sergei's suggestion.
Patch series depends on
[PATCH v7 0/3] usb: multi-phy support
Developed and Tested on.git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git musb
commit 2ed9127cff9a255b7671b8d3d938109f68a87961
Author: Mantesh Sarasetti <[email protected]> Date: Fri Jun 1 14:54:30 2012 +0300
usb: musb: host: Disable MUSB DMA mode incase of DMA channel request failure
Performed device mode testing in omap4 panda and omap3 beagle.
Kishon Vijay Abraham I (5):
usb: musb: move work_struct(otg_notifier_work) from core to omap glue
usb: musb: twl: use mailbox API to send VBUS or ID events
drivers: usb: musb: move otg specific initializations from twl to
glue
usb: musb: omap: use devres API to allocate resources
drivers: usb: otg: twl: use devres API to allocate resources
drivers/usb/musb/musb_core.h | 2 - drivers/usb/musb/omap2430.c | 122 +++++++++++++++++++++++++--------------- drivers/usb/otg/twl4030-usb.c | 67 ++++++++-------------- drivers/usb/otg/twl6030-usb.c | 69 ++++++++--------------- include/linux/usb/musb-omap.h | 30 ++++++++++ 5 files changed, 155 insertions(+), 135 deletions(-) create mode 100644 include/linux/usb/musb-omap.h
Signature · 1 line
1.7.5.4
PATCH v3 1/5 usb: musb: move work_struct(otg_notifier_work) from core to omap glue
Commit 712d8e(fixes pm_runtime calls while atomic by using a work queue. musb pm_runtime_get_sync call happens in interrupt context on cable attach case. That can result in re-enabling the interrupts and cause side affect. To avoid this deferred processing is used)
While the issue and the work queue implementation is specific to omap (omap2430.c), the work_struct is defined as a member of struct musb (musb_core.h). Hence moved the work_struct from musb_core to omap glue.
--- drivers/usb/musb/musb_core.h | 2 -- drivers/usb/musb/omap2430.c | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-)
drivers/usb/musb/musb_core.h +0 -2
@@ -327,7 +327,6 @@ struct musb {irqreturn_t (*isr)(int ,void *);struct work_struct irq_work; -struct work_struct otg_notifier_work;u16 hwvers;/* this hub status bit is reserved by USB 2.0 and not seen by usbcore */
@@ -373,7 +372,6 @@ struct musb {u16 int_tx;struct usb_phy *xceiv; -u8 xceiv_event;int nIrq; unsigned irq_wake:1;
drivers/usb/musb/omap2430.c +15 -9
@@ -41,6 +41,8 @@struct omap2430_glue {struct device *dev;struct platform_device *musb; +u8 xceiv_event; +struct work_struct omap_musb_mailbox_work; };#define glue_to_musb (g) platform_get_drvdata(g->musb)
@@ -226,22 +228,26 @@ static inline void omap2430_low_level_init(struct musb *musb)static int musb_otg_notifications (struct notifier_block *nb,unsigned long event,void *unused) { - struct musb *musb = container_of(nb, struct musb, nb); + struct musb *musb = container_of(nb, struct musb, nb); +struct device *dev = musb->controller; +struct omap2430_glue *glue =dev_get_drvdata (dev->parent); - musb->xceiv_event = event; -schedule_work (&musb->otg_notifier_work); + glue->xceiv_event = event; +schedule_work (&glue->omap_musb_mailbox_work);return NOTIFY_OK ; } -static void musb_otg_notifier_work (struct work_struct *data_notifier_work) +static void omap_musb_mailbox_work (struct work_struct *data_notifier_work) { - struct musb *musb = container_of(data_notifier_work, struct musb, otg_notifier_work); +struct omap2430_glue *glue =container_of (data_notifier_work, + struct omap2430_glue, omap_musb_mailbox_work); +struct musb *musb =glue_to_musb (glue);struct device *dev = musb->controller;struct musb_hdrc_platform_data *pdata = dev->platform_data;struct omap_musb_board_data *data = pdata->board_data; -switch (musb->xceiv_event) { +switch (glue->xceiv_event) {case USB_EVENT_ID :dev_dbg (musb->controller,"ID GND\n" );
@@ -298,8 +304,6 @@ static int omap2430_musb_init(struct musb *musb)return -ENODEV ; } -INIT_WORK (&musb->otg_notifier_work, musb_otg_notifier_work); - status =pm_runtime_get_sync (dev);if (status <0 ) {dev_err (dev,"pm_runtime_get_sync FAILED %d\n" , status);
@@ -388,7 +392,6 @@ static void omap2430_musb_disable(struct musb *musb)static int omap2430_musb_exit (struct musb *musb) {del_timer_sync (&musb_idle_timer); -cancel_work_sync (&musb->otg_notifier_work);omap2430_low_level_exit (musb);usb_put_phy (musb->xceiv);
@@ -441,6 +444,8 @@ static int __devinit omap2430_probe(struct platform_device *pdev)platform_set_drvdata (pdev, glue); +INIT_WORK (&glue->omap_musb_mailbox_work, omap_musb_mailbox_work); + ret =platform_device_add_resources (musb, pdev->resource, pdev->num_resources);if (ret) {
@@ -478,6 +483,7 @@ static int __devexit omap2430_remove(struct platform_device *pdev) {struct omap2430_glue *glue =platform_get_drvdata (pdev); +cancel_work_sync (&glue->omap_musb_mailbox_work);platform_device_del (glue->musb);platform_device_put (glue->musb);kfree (glue);
Signature · 1 line
1.7.5.4
PATCH v3 2/5 usb: musb: twl: use mailbox API to send VBUS or ID events
In reply to Kishon Vijay Abraham IThe atomic notifier from twl4030/twl6030 to notifiy VBUS and ID events, is replaced by a direct call to omap musb blue.
--- drivers/usb/musb/omap2430.c | 94 +++++++++++++++++++++++++--------------- drivers/usb/otg/twl4030-usb.c | 46 ++++++++++---------- drivers/usb/otg/twl6030-usb.c | 47 +++++++++----------- include/linux/usb/musb-omap.h | 30 +++++++++++++ 4 files changed, 133 insertions(+), 84 deletions(-) create mode 100644 include/linux/usb/musb-omap.h
drivers/usb/musb/omap2430.c +59 -35
@@ -34,6 +34,7 @@#include <linux/dma-mapping.h> #include <linux/pm_runtime.h> #include <linux/err.h> +#include <linux/usb/musb-omap.h> #include "musb_core.h" #include "omap2430.h"
@@ -41,11 +42,13 @@struct omap2430_glue {struct device *dev;struct platform_device *musb; -u8 xceiv_event; +enum omap_musb_vbus_id_status status;struct work_struct omap_musb_mailbox_work; };#define glue_to_musb (g) platform_get_drvdata(g->musb) +struct omap2430_glue *_glue; +static struct timer_list musb_idle_timer;static void musb_do_idle (unsigned long _musb)
@@ -225,54 +228,58 @@ static inline void omap2430_low_level_init(struct musb *musb)musb_writel (musb->mregs,OTG_FORCESTDBY , l); } -static int musb_otg_notifications (struct notifier_block *nb, -unsigned long event,void *unused) +void omap_musb_mailbox (enum omap_musb_vbus_id_status status) { - struct musb *musb = container_of(nb, struct musb, nb); -struct device *dev = musb->controller; -struct omap2430_glue *glue =dev_get_drvdata (dev->parent); +struct omap2430_glue *glue = _glue; +struct musb *musb =glue_to_musb (glue); - glue->xceiv_event = event; -schedule_work (&glue->omap_musb_mailbox_work); + glue->status = status; +if (!musb) { +dev_err (glue->dev,"musb core is not yet ready\n" ); +return ; + } -return NOTIFY_OK ; +schedule_work (&glue->omap_musb_mailbox_work); } +EXPORT_SYMBOL_GPL (omap_musb_mailbox); -static void omap_musb_mailbox_work (struct work_struct *data_notifier_work) +static void omap_musb_set_mailbox (struct omap2430_glue *glue) { -struct omap2430_glue *glue =container_of (data_notifier_work, - struct omap2430_glue, omap_musb_mailbox_work);struct musb *musb =glue_to_musb (glue);struct device *dev = musb->controller;struct musb_hdrc_platform_data *pdata = dev->platform_data;struct omap_musb_board_data *data = pdata->board_data; -switch (glue->xceiv_event) { -case USB_EVENT_ID : -dev_dbg (musb->controller,"ID GND\n" ); +switch (glue->status) { +case OMAP_MUSB_ID_GROUND : +dev_dbg (dev,"ID GND\n" ); + musb->xceiv->last_event =USB_EVENT_ID ;if (!is_otg_enabled (musb) || musb->gadget_driver) { -pm_runtime_get_sync (musb->controller); +pm_runtime_get_sync (dev);usb_phy_init (musb->xceiv);omap2430_musb_set_vbus (musb,1 ); }break ; -case USB_EVENT_VBUS : -dev_dbg (musb->controller,"VBUS Connect\n" ); +case OMAP_MUSB_VBUS_VALID : +dev_dbg (dev,"VBUS Connect\n" ); + musb->xceiv->last_event =USB_EVENT_VBUS ;if (musb->gadget_driver) -pm_runtime_get_sync (musb->controller); +pm_runtime_get_sync (dev);usb_phy_init (musb->xceiv);break ; -case USB_EVENT_NONE : -dev_dbg (musb->controller,"VBUS Disconnect\n" ); +case OMAP_MUSB_ID_FLOAT : +case OMAP_MUSB_VBUS_OFF : +dev_dbg (dev,"VBUS Disconnect\n" ); + musb->xceiv->last_event =USB_EVENT_NONE ;if (is_otg_enabled (musb) ||is_peripheral_enabled (musb))if (musb->gadget_driver) { -pm_runtime_mark_last_busy (musb->controller); -pm_runtime_put_autosuspend (musb->controller); +pm_runtime_mark_last_busy (dev); +pm_runtime_put_autosuspend (dev); }if (data->interface_type ==MUSB_INTERFACE_UTMI ) {
@@ -282,15 +289,24 @@ static void omap_musb_mailbox_work(struct work_struct *data_notifier_work)usb_phy_shutdown (musb->xceiv);break ;default : -dev_dbg (musb->controller,"ID float\n" ); +dev_dbg (dev,"ID float\n" ); } } + +static void omap_musb_mailbox_work (struct work_struct *mailbox_work) +{ +struct omap2430_glue *glue =container_of (mailbox_work, + struct omap2430_glue, omap_musb_mailbox_work); +omap_musb_set_mailbox (glue); +} +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->platform_data;struct omap_musb_board_data *data = plat->board_data;
@@ -330,14 +346,11 @@ static int omap2430_musb_init(struct musb *musb)musb_readl (musb->mregs,OTG_INTERFSEL ), musb_readl(musb->mregs, OTG_SIMENABLE)); - musb->nb.notifier_call = musb_otg_notifications; - status =usb_register_notifier (musb->xceiv, &musb->nb); - -if (status) -dev_dbg (musb->controller,"notification register failed\n" ); -setup_timer (&musb_idle_timer, musb_do_idle, (unsigned long ) musb); +if (glue->status !=OMAP_MUSB_UNKNOWN ) +omap_musb_set_mailbox (glue); +pm_runtime_put_noidle (musb->controller);return 0 ;
@@ -350,12 +363,13 @@ 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->platform_data;struct omap_musb_board_data *data = pdata->board_data; -switch (musb->xceiv->last_event) { +switch (glue->status) { -case USB_EVENT_ID : +case OMAP_MUSB_ID_GROUND :usb_phy_init (musb->xceiv);if (data->interface_type !=MUSB_INTERFACE_UTMI )break ;
@@ -374,7 +388,7 @@ static void omap2430_musb_enable(struct musb *musb) }break ; -case USB_EVENT_VBUS : +case OMAP_MUSB_VBUS_VALID :usb_phy_init (musb->xceiv);break ;
@@ -385,7 +399,10 @@ static void omap2430_musb_enable(struct musb *musb)static void omap2430_musb_disable (struct musb *musb) { -if (musb->xceiv->last_event) +struct device *dev = musb->controller; +struct omap2430_glue *glue =dev_get_drvdata (dev->parent); + +if (glue->status !=OMAP_MUSB_UNKNOWN )usb_phy_shutdown (musb->xceiv); }
@@ -439,11 +456,18 @@ static int __devinit omap2430_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; + glue->status =OMAP_MUSB_UNKNOWN ; pdata->platform_ops = &omap2430_ops;platform_set_drvdata (pdev, glue); +/* +* REVISIT if we ever have two instances of the wrapper, we will be +* in big trouble +*/ + _glue = glue; +INIT_WORK (&glue->omap_musb_mailbox_work, omap_musb_mailbox_work); ret = platform_device_add_resources(musb, pdev->resource,
@@ -552,7 +576,7 @@ static int __init omap2430_init(void) {return platform_driver_register (&omap2430_driver); } -module_init (omap2430_init); +subsys_initcall (omap2430_init); static void __exit omap2430_exit(void) {
drivers/usb/otg/twl4030-usb.c +23 -23
131 lines not on this page · raw message
drivers/usb/otg/twl6030-usb.c +21 -26
121 lines not on this page · raw message
include/linux/usb/musb-omap.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright (C) 2011-2012 by Texas Instruments +* +* The Inventra Controller Driver for Linux is free software; you +* can redistribute it and/or modify it under the terms of the GNU +* General Public License version 2 as published by the Free Software +* Foundation. +*/ + +#ifndef __MUSB_OMAP_H__ +#define __MUSB_OMAP_H__ + +enum omap_musb_vbus_id_status { +OMAP_MUSB_UNKNOWN =0 , +OMAP_MUSB_ID_GROUND , +OMAP_MUSB_ID_FLOAT , +OMAP_MUSB_VBUS_VALID , +OMAP_MUSB_VBUS_OFF , +}; + +#if (defined(CONFIG_USB_MUSB_OMAP2PLUS ) || \ + defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE )) +void omap_musb_mailbox (enum omap_musb_vbus_id_status status); +#else +static inline void omap_musb_mailbox (enum omap_musb_vbus_id_status status) +{ +} +#endif + +#endif /* __MUSB_OMAP_H__ */
Signature · 1 line
1.7.5.4
RE: [PATCH v3 2/5] usb: musb: twl: use mailbox API to send VBUS or ID events
Quoted 8 lines
From: [email protected] [[email protected]] on behalf of ABRAHAM, KISHON VIJAY
Sent: Friday, June 22, 2012 5:10 AM
To: [email protected]; ABRAHAM, KISHON VIJAY; [email protected]; [email protected]; [email protected]; Balbi, Felipe
Subject: [PATCH v3 2/5] usb: musb: twl: use mailbox API to send VBUS or ID eventsThe atomic notifier from twl4030/twl6030 to notifiy VBUS and ID events, is replaced by a direct call to omap musb blue.
Quoted 8 lines
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
drivers/usb/musb/omap2430.c | 94 +++++++++++++++++++++++++--------------- drivers/usb/otg/twl4030-usb.c | 46 ++++++++++---------- drivers/usb/otg/twl6030-usb.c | 47 +++++++++----------- include/linux/usb/musb-omap.h | 30 +++++++++++++ 4 files changed, 133 insertions(+), 84 deletions(-)create mode 100644
include/linux/usb/musb-omap.h
.....
+enum omap_musb_vbus_id_status {
+ OMAP_MUSB_UNKNOWN = 0, + OMAP_MUSB_ID_GROUND, + OMAP_MUSB_ID_FLOAT, + OMAP_MUSB_VBUS_VALID, + OMAP_MUSB_VBUS_OFF,
+};
+
Why did you choose to introduce OMAP_MUSB specific VBUS, ID events?
IMHO, it makes more sense to introduce mailbox functionality only without extra translation layer. Same mailbox glue layer could be used for other PHY drivers, not just twl.
thanks,
Oleg
Re: [PATCH v3 2/5] usb: musb: twl: use mailbox API to send VBUS or ID events
Hi Oleg,
Quoted 26 lines · Oleg
Quoted 16 lines
From: [email protected] [[email protected]] on behalf of ABRAHAM, KISHON VIJAY
Sent: Friday, June 22, 2012 5:10 AM
To: [email protected]; ABRAHAM, KISHON VIJAY; [email protected]; [email protected]; [email protected]; Balbi, Felipe
Subject: [PATCH v3 2/5] usb: musb: twl: use mailbox API to send VBUS or ID eventsThe atomic notifier from twl4030/twl6030 to notifiy VBUS and ID events, is replaced by a direct call to omap musb blue.
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
drivers/usb/musb/omap2430.c| 94 +++++++++++++++++++++++++---------------drivers/usb/otg/twl4030-usb.c | 46 ++++++++++---------- drivers/usb/otg/twl6030-usb.c | 47 +++++++++----------- include/linux/usb/musb-omap.h | 30 +++++++++++++ 4 files changed, 133 insertions(+), 84 deletions(-)create mode 100644
include/linux/usb/musb-omap.h.....
include/linux/usb/musb-omap.h new file +8
-0+enum omap_musb_vbus_id_status { + OMAP_MUSB_UNKNOWN = 0, + OMAP_MUSB_ID_GROUND, + OMAP_MUSB_ID_FLOAT, + OMAP_MUSB_VBUS_VALID, + OMAP_MUSB_VBUS_OFF, +}; +
Quoted 3 lines
Why did you choose to introduce
OMAP_MUSBspecific VBUS, ID events?
IMHO, it makes more sense to introduce mailbox functionality only without extra translation layer. Same mailbox glue layer could be used for other PHY drivers, not just twl.
We've decided to make twl as a comparator driver since we have a separate phy driver (not yet merged). Hence we dint want twl to use usb_phy specific events. So if you have other PHY drivers, you can still use the OMAP_MUSB specific events.
Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v3 2/5] usb: musb: twl: use mailbox API to send VBUS or ID events
Hi Kishon,
Quoted 41 lines
-----Original Message-----
From: ABRAHAM, KISHON VIJAY
Sent: Tuesday, July 03, 2012 10:48 PM
To: Matcovschi, Oleg
Cc: [email protected]; [email protected]; [email protected]; [email protected]; >Balbi, Felipe
Subject: Re: [PATCH v3 2/5] usb: musb: twl: use mailbox API to send VBUS or ID eventsHi Oleg,
Quoted 31 lines · Oleg
Quoted 21 lines
From: [email protected] [[email protected]] on behalf of ABRAHAM, KISHON VIJAY
Sent: Friday, June 22, 2012 5:10 AM
To: [email protected]; ABRAHAM, KISHON VIJAY; [email protected]; [email protected]; [email protected]; Balbi, Felipe
Subject: [PATCH v3 2/5] usb: musb: twl: use mailbox API to send VBUS
or ID eventsThe atomic notifier from twl4030/twl6030 to notifiy VBUS and ID events, is replaced by a direct call to omap musb blue.
Signed-off-by Kishon Vijay Abraham I <[email protected]>---
drivers/usb/musb/omap2430.c| 94
+++++++++++++++++++++++++---------------drivers/usb/otg/twl4030-usb.c | 46 ++++++++++---------- drivers/usb/otg/twl6030-usb.c | 47 +++++++++----------- include/linux/usb/musb-omap.h | 30 +++++++++++++ 4 files changed, 133 insertions(+), 84 deletions(-) create mode100644
include/linux/usb/musb-omap.h.....
include/linux/usb/musb-omap.h new file +8
-0+enum omap_musb_vbus_id_status { + OMAP_MUSB_UNKNOWN = 0, + OMAP_MUSB_ID_GROUND, + OMAP_MUSB_ID_FLOAT, + OMAP_MUSB_VBUS_VALID, + OMAP_MUSB_VBUS_OFF, +}; +
Quoted 7 lines
Quoted 3 lines
Why did you choose to introduce
OMAP_MUSBspecific VBUS, ID events?
IMHO, it makes more sense to introduce mailbox functionality only without extra translation layer. Same mailbox glue layer could be used for other PHY drivers, not just twl.We've decided to make twl as a comparator driver since we have a separate phy driver (not yet merged). Hence we dint >want twl to use
usb_physpecific events. So if you have other PHY drivers, you can still use theOMAP_MUSBspecific >events. Thanks
Kishon
In other words: you are proposing to have 2 flavors of other phy drivers(OMAP and not-OMAP platform specific)... Do you think it is necessary?
Could you please provide full description of your original problem?
Regards,
Oleg
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 3/5 drivers: usb: musb: move otg specific initializations from twl to glue
In reply to Kishon Vijay Abraham IMoved otg specific state(OTG_STATE_B_IDLE, OTG_STATE_A_IDLE) initializations from twl to glue. These initializations are removed from twl4030 and twl6030 and moved to the mailbox API defined in glue.
This is part of the cleanup in preparation to make use of usb2 phy driver.
--- drivers/usb/musb/omap2430.c | 5 +++++ drivers/usb/otg/twl4030-usb.c | 8 -------- drivers/usb/otg/twl6030-usb.c | 6 ------ 3 files changed, 5 insertions(+), 14 deletions(-)
drivers/usb/musb/omap2430.c +5 -0
@@ -249,11 +249,14 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)struct device *dev = musb->controller;struct musb_hdrc_platform_data *pdata = dev->platform_data;struct omap_musb_board_data *data = pdata->board_data; +struct usb_otg *otg = musb->xceiv->otg;switch (glue->status) {case OMAP_MUSB_ID_GROUND :dev_dbg (dev,"ID GND\n" ); + otg->default_a = true; + musb->xceiv->state =OTG_STATE_A_IDLE ; musb->xceiv->last_event =USB_EVENT_ID ;if (!is_otg_enabled (musb) || musb->gadget_driver) {pm_runtime_get_sync (dev);
@@ -265,6 +268,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)case OMAP_MUSB_VBUS_VALID :dev_dbg (dev,"VBUS Connect\n" ); + otg->default_a = false; + musb->xceiv->state =OTG_STATE_B_IDLE ; musb->xceiv->last_event =USB_EVENT_VBUS ;if (musb->gadget_driver)pm_runtime_get_sync (dev);
drivers/usb/otg/twl4030-usb.c +0 -8
@@ -251,7 +251,6 @@ static enum omap_musb_vbus_id_status {int status;enum omap_musb_vbus_id_status linkstat =OMAP_MUSB_UNKNOWN ; -struct usb_otg *otg = twl->phy.otg; twl->vbus_supplied = false;
@@ -291,13 +290,6 @@ static enum omap_musb_vbus_id_statusspin_lock_irq (&twl->lock); twl->linkstat = linkstat; -if (linkstat ==OMAP_MUSB_ID_GROUND ) { - otg->default_a = true; - twl->phy.state =OTG_STATE_A_IDLE ; - }else { - otg->default_a = false; - twl->phy.state =OTG_STATE_B_IDLE ; - }spin_unlock_irq (&twl->lock);return linkstat;
drivers/usb/otg/twl6030-usb.c +0 -6
@@ -256,7 +256,6 @@ static DEVICE_ATTR(vbus, 0444, twl6030_usb_vbus_show, NULL);static irqreturn_t twl6030_usb_irq (int irq,void *_twl) {struct twl6030_usb *twl = _twl; -struct usb_otg *otg = twl->phy.otg;enum omap_musb_vbus_id_status status =OMAP_MUSB_UNKNOWN ;u8 vbus_state, hw_state;
@@ -269,8 +268,6 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl)regulator_enable (twl->usb3v3); twl->asleep =1 ; status =OMAP_MUSB_VBUS_VALID ; - otg->default_a = false; - twl->phy.state =OTG_STATE_B_IDLE ; twl->linkstat = status;omap_musb_mailbox (status); }else {
@@ -293,7 +290,6 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl)static irqreturn_t twl6030_usbotg_irq (int irq,void *_twl) {struct twl6030_usb *twl = _twl; -struct usb_otg *otg = twl->phy.otg;enum omap_musb_vbus_id_status status =OMAP_MUSB_UNKNOWN ;u8 hw_state;
@@ -307,8 +303,6 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl)twl6030_writeb (twl,TWL_MODULE_USB ,USB_ID_INT_EN_HI_SET ,0x10 ); status =OMAP_MUSB_ID_GROUND ; - otg->default_a = true; - twl->phy.state =OTG_STATE_A_IDLE ; twl->linkstat = status;omap_musb_mailbox (status); }else {
Signature · 1 line
1.7.5.4
PATCH v3 4/5 usb: musb: omap: use devres API to allocate resources
In reply to Kishon Vijay Abraham Iused devres API while allocating memory resource and while getting usb phy so that these resources are released automatically on driver detach.
---
This patch uses an API thats introduced in
[PATCH v7 0/3] usb: multi-phy support
drivers/usb/musb/omap2430.c | 19 +++++++------------ 1 files changed, 7 insertions(+), 12 deletions(-)
drivers/usb/musb/omap2430.c +7 -12
@@ -319,7 +319,7 @@ static int omap2430_musb_init(struct musb *musb)* up through ULPI. TWL4030-family PMICs include one, * which needs a driver, drivers aren't always needed. */ - musb->xceiv =usb_get_phy (USB_PHY_TYPE_USB2 ); + musb->xceiv =devm_usb_get_phy (dev,USB_PHY_TYPE_USB2 );if (!musb->xceiv) {pr_err ("HS USB OTG: no transceiver configured\n" );return -ENODEV ;
@@ -416,7 +416,6 @@ static int omap2430_musb_exit(struct musb *musb)del_timer_sync (&musb_idle_timer);omap2430_low_level_exit (musb); -usb_put_phy (musb->xceiv);return 0 ; }
@@ -443,7 +442,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)struct omap2430_glue *glue;int ret = -ENOMEM ; - glue =kzalloc (sizeof (*glue),GFP_KERNEL ); + glue =devm_kzalloc (&pdev->dev,sizeof (*glue),GFP_KERNEL );if (!glue) {dev_err (&pdev->dev,"failed to allocate glue context\n" ); goto err0;
@@ -452,7 +451,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev) musb =platform_device_alloc ("musb-hdrc" ,-1 );if (!musb) {dev_err (&pdev->dev,"failed to allocate musb device\n" ); - goto err1; + goto err0; } musb->dev.parent = &pdev->dev;
@@ -479,13 +478,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev) pdev->num_resources);if (ret) {dev_err (&pdev->dev,"failed to add resources\n" ); - goto err2; + goto err1; } ret =platform_device_add_data (musb, pdata,sizeof (*pdata));if (ret) {dev_err (&pdev->dev,"failed to add platform_data\n" ); - goto err2; + goto err1; }pm_runtime_enable (&pdev->dev);
@@ -493,16 +492,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev) ret =platform_device_add (musb);if (ret) {dev_err (&pdev->dev,"failed to register musb device\n" ); - goto err2; + goto err1; }return 0 ; -err2: -platform_device_put (musb); - err1: -kfree (glue); +platform_device_put (musb); err0:return ret;
@@ -515,7 +511,6 @@ static int __devexit omap2430_remove(struct platform_device *pdev)cancel_work_sync (&glue->omap_musb_mailbox_work);platform_device_del (glue->musb);platform_device_put (glue->musb); -kfree (glue);return 0 ; }
Signature · 1 line
1.7.5.4
PATCH v3 5/5 drivers: usb: otg: twl: use devres API to allocate resources
In reply to Kishon Vijay Abraham Iused devres API while allocating memory resource in twl4030 and twl6030 so that these resources are released automatically on driver detach.
--- drivers/usb/otg/twl4030-usb.c | 15 +++------------ drivers/usb/otg/twl6030-usb.c | 16 +++------------- 2 files changed, 6 insertions(+), 25 deletions(-)
drivers/usb/otg/twl4030-usb.c +3 -12
@@ -591,15 +591,13 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)return -EINVAL ; } - twl =kzalloc (sizeof *twl,GFP_KERNEL ); + twl =devm_kzalloc (&pdev->dev,sizeof *twl,GFP_KERNEL );if (!twl)return -ENOMEM ; - otg =kzalloc (sizeof *otg,GFP_KERNEL ); -if (!otg) { -kfree (twl); + otg =devm_kzalloc (&pdev->dev,sizeof *otg,GFP_KERNEL ); +if (!otg)return -ENOMEM ; - } twl->dev = &pdev->dev; twl->irq =platform_get_irq (pdev,0 );
@@ -623,8 +621,6 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) err =twl4030_usb_ldo_init (twl);if (err) {dev_err (&pdev->dev,"ldo init failed\n" ); -kfree (otg); -kfree (twl);return err; }usb_add_phy (&twl->phy,USB_PHY_TYPE_USB2 );
@@ -648,8 +644,6 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev)if (status <0 ) {dev_dbg (&pdev->dev,"can't get IRQ %d, err %d\n" , twl->irq, status); -kfree (otg); -kfree (twl);return status; }
@@ -693,9 +687,6 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev)regulator_put (twl->usb1v8);regulator_put (twl->usb3v1); -kfree (twl->phy.otg); -kfree (twl); -return 0 ; }
drivers/usb/otg/twl6030-usb.c +3 -13
@@ -395,15 +395,13 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)struct device *dev = &pdev->dev; pdata = dev->platform_data; - twl =kzalloc (sizeof *twl,GFP_KERNEL ); + twl =devm_kzalloc (dev,sizeof *twl,GFP_KERNEL );if (!twl)return -ENOMEM ; - otg =kzalloc (sizeof *otg,GFP_KERNEL ); -if (!otg) { -kfree (twl); + otg =devm_kzalloc (dev,sizeof *otg,GFP_KERNEL ); +if (!otg)return -ENOMEM ; - } twl->dev = &pdev->dev; twl->irq1 =platform_get_irq (pdev,0 );
@@ -430,8 +428,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) err =twl6030_usb_ldo_init (twl);if (err) {dev_err (&pdev->dev,"ldo init failed\n" ); -kfree (otg); -kfree (twl);return err; }usb_add_phy (&twl->phy,USB_PHY_TYPE_USB2 );
@@ -450,8 +446,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev)dev_err (&pdev->dev,"can't get IRQ %d, err %d\n" , twl->irq1, status);device_remove_file (twl->dev, &dev_attr_vbus); -kfree (otg); -kfree (twl);return status; }
@@ -463,8 +457,6 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) twl->irq2, status);free_irq (twl->irq1, twl);device_remove_file (twl->dev, &dev_attr_vbus); -kfree (otg); -kfree (twl);return status; }
@@ -495,8 +487,6 @@ static int __exit twl6030_usb_remove(struct platform_device *pdev) pdata->phy_exit (twl->dev);device_remove_file (twl->dev, &dev_attr_vbus);cancel_work_sync (&twl->set_vbus_work); -kfree (twl->phy.otg); -kfree (twl);return 0 ; }
Signature · 1 line
1.7.5.4