Re: [PATCH 2/4] USB: dwc3: Adjust runtime pm the dwc3 driver to allow runtime suspend

2013-02-27 Thread Felipe Balbi
Hi,

sorry for the delay

On Mon, Jan 28, 2013 at 07:06:56PM +0530, Vivek Gautam wrote:
> Hi Felipe,
> 
> 
> On Mon, Jan 28, 2013 at 5:15 PM, Felipe Balbi  wrote:
> > On Mon, Jan 28, 2013 at 05:12:26PM +0530, Vivek Gautam wrote:
> >> The current code in the dwc3 probe effectively disables runtime pm
> >> from ever working because it calls a get() that was never put() until
> >> device removal.  Change the runtime pm code to match the standard
> >> formula and allow runtime pm to function.
> >>
> >> Note that this doesn't enable full runtime pm on the DWC3 device in
> >> that the port isn't put into a lower power mode when not used.
> >> However it does allow users of dwc3 (like dwc3-exynos) to do some
> >> amount of runtime power management.
> >>
> >> Signed-off-by: Vivek Gautam 
> >> Signed-off-by: Doug Anderson 
> >> ---
> >>  drivers/usb/dwc3/core.c |4 +++-
> >>  1 files changed, 3 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> >> index 3a4004a..59c2494 100644
> >> --- a/drivers/usb/dwc3/core.c
> >> +++ b/drivers/usb/dwc3/core.c
> >> @@ -453,6 +453,7 @@ static int dwc3_probe(struct platform_device *pdev)
> >>   if (of_get_property(node, "tx-fifo-resize", NULL))
> >>   dwc->needs_fifo_resize = true;
> >>
> >> + pm_runtime_set_active(dev);
> >
> > this usage of pm_runtime_set_active() actually makes me a bit scared. At
> > least OMAP starts with the device switched off, so this will probably
> > break OMAP at least.
> 
> I am fine with dropping pm_runtime_set_active(), actually thought
> to put device in active state so that as and when system finds it idle,
> force into suspend state.
> 
> I fact should i drop  pm_runtime_set_active() calls from other places too
> (xhci-plat, dwc3-exynos, and samsung-usb3 phy) and call get_sync() alongwith
> enable() ?

that's correct, make sure it works fine for you ;-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v10 6/8] usb: chipidea: imx: add internal vbus regulator control

2013-02-27 Thread Sascha Hauer
On Wed, Feb 27, 2013 at 09:55:10AM +0200, Felipe Balbi wrote:
> Hi,
> 
> On Wed, Feb 27, 2013 at 02:33:17PM +0800, Peter Chen wrote:
> > - For host, the vbus should always be on.
> > - For otg, the vbus is off defaultly, the vbus needs to be
> > turned on/off when usb role switches.
> > 
> > Signed-off-by: Peter Chen 
> 
> one quick question, if chipidea already has an imx glue layer, can I
> delete the broken imx_udc ? It doesn't even compile and it's including
> headers which don't exist.

This driver handles i.MX1. This one has a gadget only core which is not
chipidea compatible. You should ping Darius Augulis 
if he is willing to put some love into the driver.

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: musb: set TXMAXP and AUTOSET for full speed bulk in device mode

2013-02-27 Thread Felipe Balbi
Hi,

On Mon, Feb 11, 2013 at 09:51:07PM +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 12/06/2012 08:42 AM, Supriya Karanth wrote:
> 
> > From: supriya karanth 
> 
> > The TXMAXP register is not set correctly for full speed bulk case
> > when the can_bulk_split() is used. Without this PIO transfers will
> > not take place correctly
> 
> > The "mult" factor needs to be updated correctly for the
> > can_bulk_split() case
> 
> > The AUTOSET bit in the TXCSR is not being set if the "mult"
> > factor is greater than 0 for the High Bandwidth ISO case.
> > But the "mult" factor is also greater than 0 in case of Full speed
> > bulk transfers with the packet splitting in TXMAXP register
> 
> > Without the AUTOSET the DMA transfers will not progress in mode1
> 
> > Signed-off-by: supriya karanth 
> > Signed-off-by: Praveena NADAHALLY 
> > Acked-by: Linus Walleij 
> 
>I think CC: sta...@vger.kernel.org was missing here...
> 
> > ---
> >  drivers/usb/musb/musb_gadget.c |   20 ++--
> >  1 files changed, 18 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> > index b6b84da..8fb0c1f 100644
> > --- a/drivers/usb/musb/musb_gadget.c
> > +++ b/drivers/usb/musb/musb_gadget.c
> [...]
> > @@ -1113,9 +1125,13 @@ static int musb_gadget_enable(struct usb_ep *ep,
> >  */
> > if (musb->double_buffer_not_ok)
> > musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx);
> > -   else
> > +   else {
> > +   if (can_bulk_split(musb, musb_ep->type))
> > +   musb_ep->hb_mult = (hw_ep->max_packet_sz_tx /
> > +   musb_ep->packet_s
> 
>Actually, I'm having troubles without this right now (in the Arago based
> tree), so not sure why you deferred this to 3.9, Felipe...

because it falls into 'has never worked before' and it didn't seem to be
that big of a deal, now that I can see my judgement was wrong, just send
the backport to the stable folks and they'll take it for the stable
trees which are still being maintained.

cheers

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v2 01/37] usb/gadget: use consistent naming scheme for usb function modules

2013-02-27 Thread Andrzej Pietrasiewicz
On Tuesday, February 26, 2013 7:27 PM Sebastian Andrzej Siewior wrote:

> >> e.g. f_mass_storage_usb.ko, f_ss_lb_usb.ko, f_rndis_usb.ko etc.
> >
> > IMHO each function should be a separate module, so this f_ss_lb_usb.ko
> > is wrong. We should have f_sourcesink.ko and f_loopback.ko.
> 
> This is true for most functions. I made serial a separate module and I
> believe all other functions can be done as well. I would probably strip
> _usb from the module name

Did you read my explanation why I introduced it? Any better ideas to prevent
circular dependency are welcome.

> the function name
> is BOT and not mass_storage

Can you explain the "BOT"?

@Michal: Would you name the f_mass_storage "f_bot"?

AP


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] USB mxs-phy: Register phy with framework

2013-02-27 Thread Felipe Balbi
On Thu, Feb 14, 2013 at 07:43:54PM +0100, Sascha Hauer wrote:
> On Thu, Feb 14, 2013 at 08:00:11PM +0200, Felipe Balbi wrote:
> > Hi,
> > 
> > On Thu, Feb 14, 2013 at 05:23:37PM +0100, Sascha Hauer wrote:
> > > On Thu, Feb 14, 2013 at 12:37:29PM +0200, Felipe Balbi wrote:
> > > > Hi,
> > > > 
> > > > On Thu, Jan 31, 2013 at 12:32:16PM +0100, Sascha Hauer wrote:
> > > > > We now have usb_add_phy_dev(), so use it to register with the 
> > > > > framework
> > > > > to be able to find the phy from the USB driver.
> > > > > 
> > > > > Signed-off-by: Sascha Hauer 
> > > > 
> > > > Sascha, are you taking this through your tree or you want me to queue it
> > > > up ?
> > > 
> > > I would prefer if either you could take it or Alexander Shishkin along
> > > with the other patches in:
> > > 
> > > [PATCH v4] USB: add devicetree helpers for determining dr_mode and 
> > > phy_type
> > > 
> > > Could you have a look at them? Alexander is asking for an ack for 1/9,
> > > 2/9, 3/9, 8/9. I just realized you are not on Cc for these. I could
> > > bounce you the patches in case you don't have them in your mailbox.
> > 
> > Ok, I'll look at them, no need to bounce. You _do_ realize, however,
> > that Greg has already closed all his trees for v3.9, right ? So anything
> > from now on will be queued for v3.10.
> 
> I'm fine with that. I'm just a bit insistent because the chipidea patches are
> floating around for half a year now. Once I have the warm feeling that
> the patches are handled I have time ;)

I'm getting ready to queue patches but, when looking at this thread, it
seems like another version should've been sent. I'll skip this and look
at the other chipidea threads,

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v10 6/8] usb: chipidea: imx: add internal vbus regulator control

2013-02-27 Thread Peter Chen
On Wed, Feb 27, 2013 at 09:07:35AM +0100, Sascha Hauer wrote:
> On Wed, Feb 27, 2013 at 09:55:10AM +0200, Felipe Balbi wrote:
> > Hi,
> > 
> > On Wed, Feb 27, 2013 at 02:33:17PM +0800, Peter Chen wrote:
> > > - For host, the vbus should always be on.
> > > - For otg, the vbus is off defaultly, the vbus needs to be
> > > turned on/off when usb role switches.
> > > 
> > > Signed-off-by: Peter Chen 
> > 
> > one quick question, if chipidea already has an imx glue layer, can I
> > delete the broken imx_udc ? It doesn't even compile and it's including
> > headers which don't exist.
> 
> This driver handles i.MX1. This one has a gadget only core which is not
> chipidea compatible. You should ping Darius Augulis 
> if he is willing to put some love into the driver.

Sascha is correct.

-- 

Best Regards,
Peter Chen

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v9 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2013-02-27 Thread Felipe Balbi
Hi,

On Fri, Jan 18, 2013 at 02:30:21PM +0530, Praveen Paneri wrote:
> Changes from v8:
> Resending this patch series after rebasing to the latest usb-next branch.
> Rewording inline comments for better readability.
> Removed IS_ENABLED(CONFIG_OF) as pdev->dev.of_node is enough to check for dt 
> support.
> Using of_match_ptr to add of_match_table to platform_driver structure.
> Removed unnecessary variables.

trying applying these but it doesn't apply unfortunately.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH V2] usb:musb: musbhsdma: change the number of dma channels according to hardware configuration

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 03:54:18PM +0800, Yingchun Li wrote:
> Hi, Felipe
>  Does the following patch still break your editor? I have fix the patch
> and resend it again, but I didn't find the patch in your 'big patch
> bomb' for v3.10,
> should I fix something?

patching file drivers/usb/musb/musbhsdma.c
patch:  malformed patch at line 36: *dma_channel_allocate(struct 
dma_controller *c,

still doesn't apply. Try to use git send-email.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] drivers/usb/gadget: using strlcpy instead of strncpy

2013-02-27 Thread Felipe Balbi
On Sat, Feb 02, 2013 at 03:48:54PM +0800, Chen Gang wrote:
> 
>   for NUL terminated string, better notice '\0' in the end.
> 
> Signed-off-by: Chen Gang 

Laurent, are you taking this patch or should I ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [RESEND PATCH v9 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2013-02-27 Thread Vivek Gautam
Hi Balbi,


On Wed, Feb 27, 2013 at 1:45 PM, Felipe Balbi  wrote:
> Hi,
>
> On Fri, Jan 18, 2013 at 02:30:21PM +0530, Praveen Paneri wrote:
>> Changes from v8:
>> Resending this patch series after rebasing to the latest usb-next branch.
>> Rewording inline comments for better readability.
>> Removed IS_ENABLED(CONFIG_OF) as pdev->dev.of_node is enough to check for dt 
>> support.
>> Using of_match_ptr to add of_match_table to platform_driver structure.
>> Removed unnecessary variables.
>
> trying applying these but it doesn't apply unfortunately.
>

Already present in 3.8.0 ? ;-)


-- 
Thanks & Regards
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v9 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 02:00:25PM +0530, Vivek Gautam wrote:
> Hi Balbi,
> 
> 
> On Wed, Feb 27, 2013 at 1:45 PM, Felipe Balbi  wrote:
> > Hi,
> >
> > On Fri, Jan 18, 2013 at 02:30:21PM +0530, Praveen Paneri wrote:
> >> Changes from v8:
> >> Resending this patch series after rebasing to the latest usb-next branch.
> >> Rewording inline comments for better readability.
> >> Removed IS_ENABLED(CONFIG_OF) as pdev->dev.of_node is enough to check for 
> >> dt support.
> >> Using of_match_ptr to add of_match_table to platform_driver structure.
> >> Removed unnecessary variables.
> >
> > trying applying these but it doesn't apply unfortunately.
> >
> 
> Already present in 3.8.0 ? ;-)

heh, my bad. For whatever reason it was still marked as unread.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v10 6/8] usb: chipidea: imx: add internal vbus regulator control

2013-02-27 Thread Felipe Balbi
Hi Darius,

On Wed, Feb 27, 2013 at 04:13:14PM +0800, Peter Chen wrote:
> On Wed, Feb 27, 2013 at 09:07:35AM +0100, Sascha Hauer wrote:
> > On Wed, Feb 27, 2013 at 09:55:10AM +0200, Felipe Balbi wrote:
> > > Hi,
> > > 
> > > On Wed, Feb 27, 2013 at 02:33:17PM +0800, Peter Chen wrote:
> > > > - For host, the vbus should always be on.
> > > > - For otg, the vbus is off defaultly, the vbus needs to be
> > > > turned on/off when usb role switches.
> > > > 
> > > > Signed-off-by: Peter Chen 
> > > 
> > > one quick question, if chipidea already has an imx glue layer, can I
> > > delete the broken imx_udc ? It doesn't even compile and it's including
> > > headers which don't exist.
> > 
> > This driver handles i.MX1. This one has a gadget only core which is not
> > chipidea compatible. You should ping Darius Augulis 
> > 
> > if he is willing to put some love into the driver.
> 
> Sascha is correct.

do you plan to put any work on drivers/usb/gadget/imx_udc.c ? It doesn't
even compile since it includes headers which don't exist (and no,
simply removing the include doesn't help).

If nobody is going to work on that driver, I'm thinking about scheduling
it for removal. We can't keep such drivers that nobody cares (and just
break tree compilation) around.

-- 
balbi


signature.asc
Description: Digital signature


Re: [RESEND PATCH v9 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2013-02-27 Thread Tomasz Figa
On Wednesday 27 of February 2013 14:00:25 Vivek Gautam wrote:
> Hi Balbi,
> 
> On Wed, Feb 27, 2013 at 1:45 PM, Felipe Balbi  wrote:
> > Hi,
> > 
> > On Fri, Jan 18, 2013 at 02:30:21PM +0530, Praveen Paneri wrote:
> >> Changes from v8:
> >> Resending this patch series after rebasing to the latest usb-next
> >> branch. Rewording inline comments for better readability.
> >> Removed IS_ENABLED(CONFIG_OF) as pdev->dev.of_node is enough to check
> >> for dt support. Using of_match_ptr to add of_match_table to
> >> platform_driver structure. Removed unnecessary variables.
> > 
> > trying applying these but it doesn't apply unfortunately.
> 
> Already present in 3.8.0 ? ;-)

That's great. I will send my patch adding Exynos 4x12 support in next 
days.

Best regards,
Tomasz

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 8/8] usb: chipidea: udc: fix the oops when plugs in usb cable after rmmod gadget

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 11:10:03AM +0800, Peter Chen wrote:
> On Tue, Feb 26, 2013 at 08:21:41PM +0200, Felipe Balbi wrote:
> > Hi,
> > 
> > On Sun, Feb 17, 2013 at 11:09:53AM +0800, Peter Chen wrote:
> > > @@ -1373,6 +1375,8 @@ static int ci13xxx_vbus_session(struct usb_gadget 
> > > *_gadget, int is_active)
> > >   hw_device_state(ci, ci->ep0out->qh.dma);
> > >   dev_dbg(ci->dev, "Connected to host\n");
> > >   } else {
> > > + if (ci->driver)
> > > + ci->driver->disconnect(&ci->gadget);
> > 
> > This looks wrong. Why do you need to call ->disconnect() here ?
> 
> When we disconnect usb cable from the host, we need to notify gadget module 
> disconnection occurs, the gadget module may not be unloaded in future.

ok, I get it now, after reading the code I see that this gets called
from your VBUS IRQ handler (actually you queue an unnecessary workqueue
for that).

> If the disconnection is not notified, the gadget module may still call
> struct usb_ep_ops's API to visit hardware at its thread but the controller 
> may already enter low power mode.
> 
> In fact, a common problem is how can we make sure the gadget will not
> visit register if the controller enters low power mode, currently,
> there is no prefect solution.  

yeah, I have an idea for that, but won't happen for v3.10 I'm afraid...

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/4] USB: dwc3: Adjust runtime pm the dwc3 driver to allow runtime suspend

2013-02-27 Thread Vivek Gautam
Hi Felipe,


On Wed, Feb 27, 2013 at 1:36 PM, Felipe Balbi  wrote:
> Hi,
>
> sorry for the delay
>

That's alright ;-)

> On Mon, Jan 28, 2013 at 07:06:56PM +0530, Vivek Gautam wrote:
>> Hi Felipe,
>>
>>
>> On Mon, Jan 28, 2013 at 5:15 PM, Felipe Balbi  wrote:
>> > On Mon, Jan 28, 2013 at 05:12:26PM +0530, Vivek Gautam wrote:
>> >> The current code in the dwc3 probe effectively disables runtime pm
>> >> from ever working because it calls a get() that was never put() until
>> >> device removal.  Change the runtime pm code to match the standard
>> >> formula and allow runtime pm to function.
>> >>
>> >> Note that this doesn't enable full runtime pm on the DWC3 device in
>> >> that the port isn't put into a lower power mode when not used.
>> >> However it does allow users of dwc3 (like dwc3-exynos) to do some
>> >> amount of runtime power management.
>> >>
>> >> Signed-off-by: Vivek Gautam 
>> >> Signed-off-by: Doug Anderson 
>> >> ---
>> >>  drivers/usb/dwc3/core.c |4 +++-
>> >>  1 files changed, 3 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> >> index 3a4004a..59c2494 100644
>> >> --- a/drivers/usb/dwc3/core.c
>> >> +++ b/drivers/usb/dwc3/core.c
>> >> @@ -453,6 +453,7 @@ static int dwc3_probe(struct platform_device *pdev)
>> >>   if (of_get_property(node, "tx-fifo-resize", NULL))
>> >>   dwc->needs_fifo_resize = true;
>> >>
>> >> + pm_runtime_set_active(dev);
>> >
>> > this usage of pm_runtime_set_active() actually makes me a bit scared. At
>> > least OMAP starts with the device switched off, so this will probably
>> > break OMAP at least.
>>
>> I am fine with dropping pm_runtime_set_active(), actually thought
>> to put device in active state so that as and when system finds it idle,
>> force into suspend state.
>>
>> I fact should i drop  pm_runtime_set_active() calls from other places too
>> (xhci-plat, dwc3-exynos, and samsung-usb3 phy) and call get_sync() alongwith
>> enable() ?
>
> that's correct, make sure it works fine for you ;-)
>
Yeah sure.


-- 
Thanks & Regards
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 1/6] usb: common: add a routine to print the OTG state

2013-02-27 Thread Felipe Balbi
Hi,

On Tue, Feb 26, 2013 at 07:23:01PM -0800, Paul Zimmerman wrote:
> Add a usb_otg_state_string() routine to print the OTG state for
> debugging
> 
> Signed-off-by: Paul Zimmerman 
> ---
>  drivers/usb/usb-common.c | 26 ++
>  include/linux/usb/phy.h  |  8 
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
> index d29503e..6499c1f 100644
> --- a/drivers/usb/usb-common.c
> +++ b/drivers/usb/usb-common.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  const char *usb_speed_string(enum usb_device_speed speed)
>  {
> @@ -32,4 +33,29 @@ const char *usb_speed_string(enum usb_device_speed speed)
>  }
>  EXPORT_SYMBOL_GPL(usb_speed_string);
>  
> +const char *usb_otg_state_string(enum usb_otg_state state)
> +{
> + static const char *const names[] = {
> + [OTG_STATE_UNDEFINED] = "UNDEFINED",
> + [OTG_STATE_B_IDLE] = "B_IDLE",
> + [OTG_STATE_B_SRP_INIT] = "B_SRP_INIT",
> + [OTG_STATE_B_PERIPHERAL] = "B_PERIPHERAL",
> + [OTG_STATE_B_WAIT_ACON] = "B_WAIT_ACON",
> + [OTG_STATE_B_HOST] = "B_HOST",
> + [OTG_STATE_A_IDLE] = "A_IDLE",
> + [OTG_STATE_A_WAIT_VRISE] = "A_WAIT_VRISE",
> + [OTG_STATE_A_WAIT_BCON] = "A_WAIT_BCON",
> + [OTG_STATE_A_HOST] = "A_HOST",
> + [OTG_STATE_A_SUSPEND] = "A_SUSPEND",
> + [OTG_STATE_A_PERIPHERAL] = "A_PERIPHERAL",
> + [OTG_STATE_A_WAIT_VFALL] = "A_WAIT_VFALL",
> + [OTG_STATE_A_VBUS_ERR] = "A_VBUS_ERR",

please follow the convention of the other functions and print lower case
except for UNDEFINED.

other than that:

Acked-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v5 6/6] Hook the DWC2 driver into the build system

2013-02-27 Thread Felipe Balbi
On Tue, Feb 26, 2013 at 07:23:06PM -0800, Paul Zimmerman wrote:
> Add the DWC2 Kconfig and Makefile, and modify the USB Kconfig and
> Makefile to include them
> 
> Signed-off-by: Paul Zimmerman 

thanks:

Acked-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v8 8/8] usb: chipidea: udc: fix the oops when plugs in usb cable after rmmod gadget

2013-02-27 Thread Chen Peter-B29397
 
> > > > } else {
> > > > +   if (ci->driver)
> > > > +   ci->driver->disconnect(&ci->gadget);
> > >
> > > This looks wrong. Why do you need to call ->disconnect() here ?
> >
> > When we disconnect usb cable from the host, we need to notify gadget
> module
> > disconnection occurs, the gadget module may not be unloaded in future.
> 
Sorry, can you point that?

Peter,

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/6] Core files for the DWC2 driver

2013-02-27 Thread Felipe Balbi
Hi,

On Tue, Feb 26, 2013 at 07:23:02PM -0800, Paul Zimmerman wrote:
> The core code provides basic services for accessing and managing
> the DWC_otg hardware. These services are used by both the Host
> Controller Driver and (in future) the Peripheral Controller Driver.
> 
> Signed-off-by: Paul Zimmerman 
> ---

just a two comments below, besides them you can add:

Reviewed-by: Felipe Balbi 

> + if (hsotg->snpsid < DWC2_CORE_REV_2_90a ||
> + !(hsotg->hwcfg4 & GHWCFG4_DESC_DMA) ||
> + op_mode == GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE ||
> + op_mode == GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE ||
> + op_mode == GHWCFG2_OP_MODE_UNDEFINED) {
> + dev_err(hsotg->dev,
> + "Hardware does not support descriptor DMA mode 
> -\n"
> + "falling back to buffer DMA mode.\n");

one nit-pick here. You shouldn't break the line like that, instead you
should (also making error message a little shorter):

dev_err(hsotg->dev,
"No support for descriptor DMA mode\n");
dev_err(hsotg->dev,
"falling back to buffer DMA mode.\n");

> + dev_err(hsotg->dev,
> + "%s: Unable to clear enable on 
> channel %d\n",
> + __func__, i);

__func__ isn't necessary here since this is the only message of its
kind.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb/net/asix_devices: Add USBNET HG20F9 ethernet dongle

2013-02-27 Thread Bjørn Mork
David Miller  writes:

>> Applied, thanks Glen.
>
> Actually, I had to revert, this doesn't even compile against
> current sources:
>
>   CC [M]  drivers/net/usb/asix_devices.o
> drivers/net/usb/asix_devices.c:941:14: error: ‘asix_rx_fixup’ undeclared here 
> (not in a function)
> make[1]: *** [drivers/net/usb/asix_devices.o] Error 1
> make: *** [drivers/net/usb/asix_devices.o] Error 2

I believe this patch will make checkpatch cry

  ERROR: do not use C99 // comments

as well.  It would be nice if that was fixed as well before resending.
But please keep the commit message :)


Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 4/6] HCD descriptor DMA support for the DWC2 driver

2013-02-27 Thread Felipe Balbi
Hi,

On Tue, Feb 26, 2013 at 07:23:04PM -0800, Paul Zimmerman wrote:
> + qh->n_bytes = kzalloc(sizeof(u32) * dwc2_max_desc_num(qh), flags);
> + if (!qh->n_bytes) {
> + dev_err(hsotg->dev,
> + "%s: Failed to allocate array for descriptors' size 
> actual values\n",

you don't need to print anything here since out-of-memory messages are
already printed for you.

other than that:

Reviewed-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v5 5/6] PCI bus interface for the DWC2 driver

2013-02-27 Thread Felipe Balbi
Hi,

On Tue, Feb 26, 2013 at 07:23:05PM -0800, Paul Zimmerman wrote:
> + retval = dwc2_hcd_init(&dev->dev, hsotg, dev->irq, &dwc2_module_params);
> + if (retval)

still leaving pci device enabled.

> + return retval;
> +
> + /*
> +  * WARNING: dwc2_hcd_init() calls usb_create_hcd(), which overwrites
> +  * the pci_dev drvdata, so we must reset it here
> +  */
> + pci_set_drvdata(dev, hsotg);
> + dev_dbg(&dev->dev, "hsotg=%p\n", hsotg);
> +
> + /* Install the interrupt handler for the common interrupts */
> + dev_dbg(&dev->dev, "registering common handler for irq%d\n", dev->irq);
> + retval = devm_request_irq(&dev->dev, dev->irq, dwc2_handle_common_intr,
> +   IRQF_SHARED | IRQ_LEVEL, dev_name(&dev->dev),
> +   hsotg);
> + if (retval)

and here.

fix this and you can add:

Reviewied-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v5 0/6] DWC2 DesignWare HS OTG driver

2013-02-27 Thread Felipe Balbi
Hi Paul,

On Tue, Feb 26, 2013 at 07:23:00PM -0800, Paul Zimmerman wrote:
> Here is v5 of the DWC2 patch set. I think I made all of the changes we
> agreed on after your last review.
> 
> You'll be happy to hear that I removed all of the module parameters. I
> realized it is easy enough for me to maintain a local patch here to add
> them back when we need to do driver/RTL testing. I did keep the
> infrastructure for setting all of the values, so they can be tweaked at
> compile time if necessary, and so patching the module parameters back in
> is easy.

ok, good. Thanks for that

> I also added some verbiage to both the Kconfig and Makefile, explaining
> that this is a host-only driver for the time being. Please check that and
> see if it looks OK.

sure, looks alright.

> If these patches looks acceptable to you now, will you take them in through
> your tree, or would you like Greg to take them?

Greg should take them directly as this isn't related to gadget framework
(at least not yet).

> Paul Zimmerman (6):
>   usb: common: add a routine to print the OTG state
>   Core files for the DWC2 driver
>   HCD files for the DWC2 driver
>   HCD descriptor DMA support for the DWC2 driver
>   PCI bus interface for the DWC2 driver
>   Hook the DWC2 driver into the build system

please add a patch listing yourself as maintainer for this driver. We
will need someone to maintain it when more people start contributing.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/2] USB mxs-phy: Register phy with framework

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 09:10 AM, Felipe Balbi wrote:
> On Thu, Feb 14, 2013 at 07:43:54PM +0100, Sascha Hauer wrote:
>> On Thu, Feb 14, 2013 at 08:00:11PM +0200, Felipe Balbi wrote:
>>> Hi,
>>>
>>> On Thu, Feb 14, 2013 at 05:23:37PM +0100, Sascha Hauer wrote:
 On Thu, Feb 14, 2013 at 12:37:29PM +0200, Felipe Balbi wrote:
> Hi,
>
> On Thu, Jan 31, 2013 at 12:32:16PM +0100, Sascha Hauer wrote:
>> We now have usb_add_phy_dev(), so use it to register with the framework
>> to be able to find the phy from the USB driver.
>>
>> Signed-off-by: Sascha Hauer 
>
> Sascha, are you taking this through your tree or you want me to queue it
> up ?

 I would prefer if either you could take it or Alexander Shishkin along
 with the other patches in:

 [PATCH v4] USB: add devicetree helpers for determining dr_mode and phy_type

 Could you have a look at them? Alexander is asking for an ack for 1/9,
 2/9, 3/9, 8/9. I just realized you are not on Cc for these. I could
 bounce you the patches in case you don't have them in your mailbox.
>>>
>>> Ok, I'll look at them, no need to bounce. You _do_ realize, however,
>>> that Greg has already closed all his trees for v3.9, right ? So anything
>>> from now on will be queued for v3.10.
>>
>> I'm fine with that. I'm just a bit insistent because the chipidea patches are
>> floating around for half a year now. Once I have the warm feeling that
>> the patches are handled I have time ;)
> 
> I'm getting ready to queue patches but, when looking at this thread, it
> seems like another version should've been sent. I'll skip this and look
> at the other chipidea threads,

I'm currently rebasing Saschas patches to Greg's usb-net.

Marc

---
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: test procedure for cdc-wdm

2013-02-27 Thread Bjørn Mork
Oliver Neukum  writes:

> On Tuesday 26 February 2013 14:59:23 Bjørn Mork wrote:
>> Oliver Neukum  writes:
>> 
>> > @@ -185,9 +187,17 @@ static void wdm_in_callback(struct urb *urb)
>> >}
>> >  
>> >desc->rerr = status;
>> > -  desc->reslength = urb->actual_length;
>> > -  memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
>> > -  desc->length += desc->reslength;
>> > +  if (length + desc->length > desc->wMaxCommand) {
>> > +  /* The buffer would overflow */
>> > +  set_bit(WDM_OVERFLOW, &desc->flags);
>> > +  } else {
>> > +  /* we may already be in overflow */
>> > +  if (!test_bit(WDM_OVERFLOW, &desc->flags)) {
>> > +  memmove(desc->ubuf + desc->length, desc->inbuf, 
>> > desc->reslength);
>> > +  desc->length += length;
>> > +  desc->reslength = length;
>> > +  }
>> 
>> 
>> This is not OK.  Should probably be
>
> Thank you!
> The tests failed and I couldn't find out why. Sometimes I am blind.

You're welcome. More than 2 eyes always help :)

I believe we could drop the reslength field altogether, avoiding this
confusion. The field is only use to test for a 0 length read in a
context where desc->length is known to be 0.  In fact, we are really
interested in the total desc->length anyway.  The length of the last
read is completely irrelevant.

If we don't drop it, then I believe you should set it to 0 on overflow.


Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cdc-wdm: fix buffer overflow

2013-02-27 Thread oliver
From: Oliver Neukum 

The buffer for responses must not overflow.
If this would happen, set a flag, drop the data and return
an error after user space has read all remaining data.

Signed-off-by: Oliver Neukum 
CC: sta...@kernel.org
---
 drivers/usb/class/cdc-wdm.c |   23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 5f0cb41..122d056 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -56,6 +56,7 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
 #define WDM_RESPONDING 7
 #define WDM_SUSPENDING 8
 #define WDM_RESETTING  9
+#define WDM_OVERFLOW   10
 
 #define WDM_MAX16
 
@@ -155,6 +156,7 @@ static void wdm_in_callback(struct urb *urb)
 {
struct wdm_device *desc = urb->context;
int status = urb->status;
+   int length = urb->actual_length;
 
spin_lock(&desc->iuspin);
clear_bit(WDM_RESPONDING, &desc->flags);
@@ -185,9 +187,17 @@ static void wdm_in_callback(struct urb *urb)
}
 
desc->rerr = status;
-   desc->reslength = urb->actual_length;
-   memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
-   desc->length += desc->reslength;
+   if (length + desc->length > desc->wMaxCommand) {
+   /* The buffer would overflow */
+   set_bit(WDM_OVERFLOW, &desc->flags);
+   } else {
+   /* we may already be in overflow */
+   if (!test_bit(WDM_OVERFLOW, &desc->flags)) {
+   memmove(desc->ubuf + desc->length, desc->inbuf, length);
+   desc->length += length;
+   desc->reslength = length;
+   }
+   }
 skip_error:
wake_up(&desc->wait);
 
@@ -435,6 +445,11 @@ retry:
rv = -ENODEV;
goto err;
}
+   if (test_bit(WDM_OVERFLOW, &desc->flags)) {
+   clear_bit(WDM_OVERFLOW, &desc->flags);
+   rv = -ENOBUFS;
+   goto err;
+   }
i++;
if (file->f_flags & O_NONBLOCK) {
if (!test_bit(WDM_READ, &desc->flags)) {
@@ -478,6 +493,7 @@ retry:
spin_unlock_irq(&desc->iuspin);
goto retry;
}
+
if (!desc->reslength) { /* zero length read */
dev_dbg(&desc->intf->dev, "%s: zero length - clearing 
WDM_READ\n", __func__);
clear_bit(WDM_READ, &desc->flags);
@@ -1004,6 +1020,7 @@ static int wdm_post_reset(struct usb_interface *intf)
struct wdm_device *desc = wdm_find_device(intf);
int rv;
 
+   clear_bit(WDM_OVERFLOW, &desc->flags);
clear_bit(WDM_RESETTING, &desc->flags);
rv = recover_from_urb_loss(desc);
mutex_unlock(&desc->wlock);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: test procedure for cdc-wdm

2013-02-27 Thread Oliver Neukum
On Wednesday 27 February 2013 10:27:32 Bjørn Mork wrote:

> I believe we could drop the reslength field altogether, avoiding this
> confusion. The field is only use to test for a 0 length read in a
> context where desc->length is known to be 0.  In fact, we are really
> interested in the total desc->length anyway.  The length of the last
> read is completely irrelevant.
> 
> If we don't drop it, then I believe you should set it to 0 on overflow.

But we want user space to read and notice the error condition.

Regards
Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Samsung SCX-3205 scanner does not work with Toshiba Satellite L855

2013-02-27 Thread Michal Nowak
Hi,

re http://article.gmane.org/gmane.linux.usb.general/71002 I was
wondering if any progress have been made and if those log were OK.

Thanks,
Michal

On 09/20/2012 11:44 PM, Sarah Sharp wrote:
> On Wed, Sep 12, 2012 at 04:36:53PM -0700, Sarah Sharp wrote:
>> Would you be willing to run some tests for me?  In particular, I need
>> the dmesg with CONFIG_USB_DEBUG and CONFIG_USB_XHCI_HCD_DEBUGGING turned
>> on, along with a usbmon trace of the scanner running twice under one of
>> your EHCI-only systems, and a trace of two scans under xHCI.  The
>> documentation for how to capture a usbmon trace is in the kernel source
>> directory in Documentation/usb/usbmon.txt.
> 
> Hi Michal, any chance of you sending me these logs and usbmon traces?
> If you have any questions about how to capture them, let me know.
> 
> Thanks,
> Sarah Sharp
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/9] USB: chipidea: add PTW and PTS handling

2013-02-27 Thread Marc Kleine-Budde
On 02/14/2013 02:07 PM, Alexander Shishkin wrote:
> Sascha Hauer  writes:
> 
>> From: Michael Grzeschik 
>>
>> This patch makes it possible to configure the PTW and PTS bits inside
>> the portsc register for host and device mode before the driver starts
>> and the phy can be addressed as hardware implementation is designed.
>>
>> Signed-off-by: Michael Grzeschik 
>> Signed-off-by: Marc Kleine-Budde 
>> Signed-off-by: Sascha Hauer 
>> ---
>>  .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +++
>>  drivers/usb/chipidea/bits.h|   14 ++-
>>  drivers/usb/chipidea/ci13xxx_imx.c |3 ++
>>  drivers/usb/chipidea/core.c|   39 
>> 
>>  include/linux/usb/chipidea.h   |1 +
>>  5 files changed, 61 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
>> b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
>> index 5778b9c..dd42ccd 100644
>> --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
>> +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
>> @@ -5,6 +5,11 @@ Required properties:
>>  - reg: Should contain registers location and length
>>  - interrupts: Should contain controller interrupt
>>  
>> +Recommended properies:
>> +- phy_type: the type of the phy connected to the core. Should be one
>> +  of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
>> +  property the PORTSC register won't be touched
>> +
> 
> Looks like this bit belongs to patch 3/9, where you're adding devicetree
> hooks. Otherwise looks good.

Nope. Patch 3/9 adds the device tree helper code. But this patch adds
the functionality to the chipidea imx glue code, so the update of the
devicetree docs belongs into this patch.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 6/9] USB chipidea: introduce dual role mode pdata flags

2013-02-27 Thread Marc Kleine-Budde
On 02/22/2013 03:09 AM, Peter Chen wrote:
> On Mon, Feb 04, 2013 at 02:24:32PM +0100, Sascha Hauer wrote:
>> Even if a chipidea core is otg capable the board may not. This allows
>> to explicitly set the core to host/peripheral mode. Without these
>> flags the driver falls back to the old behaviour.
>>
>> Signed-off-by: Sascha Hauer 
>> ---
>>  drivers/usb/chipidea/core.c  |   21 +++--
>>  include/linux/usb/chipidea.h |2 +-
>>  2 files changed, 16 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> index 04d68cb..c89f2aa 100644
>> --- a/drivers/usb/chipidea/core.c
>> +++ b/drivers/usb/chipidea/core.c
>> @@ -435,6 +435,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>>  struct resource *res;
>>  void __iomem*base;
>>  int ret;
>> +enum usb_dr_mode dr_mode;
>>  
>>  if (!dev->platform_data) {
>>  dev_err(dev, "platform data missing\n");
>> @@ -487,14 +488,22 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>>  return -ENODEV;
>>  }
>>  
>> -ret = ci_hdrc_gadget_init(ci);
>> -if (ret)
>> -dev_info(dev, "doesn't support gadget\n");
>> +if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
> 
> Can we change "USB_DR_MODE_PERIPHERAL" to "USB_DR_MODE_GADGET", since we 
> always
> use gadget to stands for device or peripheral mode at code (like below
> CI_ROLE_GADGET), it may make code uniform.

Peripheral mode seems to be the more official name compared to gadget. I
vote for keeping peripheral in the DT and changing the chipidea to use
peripheral instead of gadget (in a later patch(es)).

Marc


-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH] usb: phy: samsung: let it be built as a module

2013-02-27 Thread Felipe Balbi
There's no reason not to allow samsung PHY
drivers be built as modules. This patch changes
Kconfig to allow that.

Signed-off-by: Felipe Balbi 
---

Hi,

I will take your patches but I'm planning to add this on top
as there is no reason not to allow these drivers being built
as modules.

cheers

 drivers/usb/phy/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 723d7b1..4f696d0 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -67,7 +67,7 @@ config USB_RCAR_PHY
  module will be called rcar-phy.
 
 config SAMSUNG_USB2PHY
-   bool "Samsung USB 2.0 PHY controller Driver"
+   tristate "Samsung USB 2.0 PHY controller Driver"
select SAMSUNG_USBPHY
select USB_OTG_UTILS
help
@@ -75,7 +75,7 @@ config SAMSUNG_USB2PHY
  driver for Samsung SoCs.
 
 config SAMSUNG_USB3PHY
-   bool "Samsung USB 3.0 PHY controller Driver"
+   tristate "Samsung USB 3.0 PHY controller Driver"
select SAMSUNG_USBPHY
select USB_OTG_UTILS
help
@@ -83,7 +83,7 @@ config SAMSUNG_USB3PHY
  for samsung SoCs.
 
 config SAMSUNG_USBPHY
-   bool "Samsung USB PHY Driver"
+   tristate "Samsung USB PHY Driver"
help
  Enable this to support Samsung USB phy helper driver for Samsung SoCs.
  This driver provides common interface to interact, for Samsung USB 
2.0 PHY
-- 
1.8.1.rc1.5.g7e0651a

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [usb gadget] WARNING: at kernel/mutex.c:198 __mutex_lock_common()

2013-02-27 Thread Felipe Balbi
Hi,

On Wed, Feb 06, 2013 at 10:04:24AM +0800, Fengguang Wu wrote:
> Greetings,
> 
> I got the below warning and the first bad commit is

can you send a fixup patch ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/4] usb: musb: Enable DMA Mode1 for device mode RX

2013-02-27 Thread Felipe Balbi
On Fri, Feb 08, 2013 at 01:59:41PM +0530, Supriya Karanth wrote:
> From: supriya karanth 
> 
> Generic changes for enabling DMA Mode1.
> Cleanup of rxtsate function making programming
> same for all platforms
> 
> Handles:
> 1) Known transfer length
>   a) Non multiple of packet size
>   b) Multiple of packet size
> 
> 2) Unknown transfer lengths
>   - Short packet indicates end of transfer
> 
> ---> OUT Endpoint interrupt recieved
> |  |
> |  |_
> |  | |
> | -> No ongoing transfer   ->DMA Transfer ongoing and RXPKTRDY set?
> |  |   ->Short Packet recieved
> |  request queued? ->PAUSE DMA transfer, Read Residue
> |  ||
> |  |||
> |  |   residue!=0 residue=0
> |  |-> abort DMA->Resume DMA
> |  |->Update request->actual_len->Wait for DMA
> |  |-> Clear DMA bits in CSRcompletion
> |  |-> Read Short Packet   |
> |  |__||__
> |  |  |
> | call rxstate|
> |->RXPKTRDY set? Read RXCOUNT |
> |  _| |
> |  |  |   |
> | ->RXCOUNT == EP MAX packet Size   ->RXCOUNT < EP MAX packet Size|
> | ->Program DMA in Mode1 for length -> Program in PIO / Mode0 |
> |which is multiple of packet-> Read Short packet from FIFO|
> |size   -> Update request->actual_len |
> |   |   -> call musb_giveback |
> |   |||
> |||
> |||
> |||
> |   |
> |   DMA completion interrupt recieved
> |___|_
> |||
> |  ->req->len = req->actual->req->len < req->actual
> |  ->Clear DMA bits-> Short packet expected
> |  ->Call musb_giveback->Clear DMA bits
> |   |  ->wait for next OUT
> |   |_|
> |___|
> 
> Signed-off-by: Supriya Karanth 
> Signed-off-by: Praveena NADAHALLY 
> Acked-by: Linus Walleij 
> ---

How have you tested this ?

This should survive a week or so running testusb with its companion
test.sh.

You should also run my msc.c [1] with its companion msc.sh [2] with a
mass storage device and it should pass all tests. Mode1 DMA has the
tendency to break very, very easily.

Also, the way you implemented isn't the best possible way. You shouldn't
need all those extra fields added to struct dma_channel or struct
dma_controller.

If you want to add Mode1 DMA, first thing that needs to be done is
cleanup current code. Here's a quick list off the top of my head:

- split txstate()/rxstate() into DMA and PIO counterparts
- remove all if (dma_is_*()) checks by sticking to the programming model
  layed out in MUSB's Programming Guide document
- Modify ->channel_abort() to update channel->actual_len
- Start adding Mode1 support

Note that this is not an exaustive list and that each patch should be
tested for at least a couple of days with testusb/test.sh plus full
msc.c/msc.sh.

[1] http://gitorious.org/usb/usb-tools/blobs/master/msc.c
[2] http://gitorious.org/usb/usb-tools/blobs/master/msc.sh

You might want to look at Jolla's kernel which is a fork of the Nokia
kernel where mode1 support was originally added.

You might want to have a look at this kernel which is a fork of the
original Nokia kernel where mode1 was first added:

https://github.com/nemomobile/kernel-adaptation-n950-n9/blob/mer-n9-2.6.32-20121301/drivers/usb/musb/musb_gadget.c

-- 
balbi


signature.asc
Description: Digital signature


Re: test procedure for cdc-wdm

2013-02-27 Thread Bjørn Mork
Oliver Neukum  writes:
> On Wednesday 27 February 2013 10:27:32 Bjørn Mork wrote:
>
>> I believe we could drop the reslength field altogether, avoiding this
>> confusion. The field is only use to test for a 0 length read in a
>> context where desc->length is known to be 0.  In fact, we are really
>> interested in the total desc->length anyway.  The length of the last
>> read is completely irrelevant.
>> 
>> If we don't drop it, then I believe you should set it to 0 on overflow.
>
> But we want user space to read and notice the error condition.

It's unlikely, but if we overflow while waiting for data in wdm_read
then wdm_read will return success unless we set desc->reslength to 0.
The next read will return the error, so it probably does not matter
much.

But as I said, I believe the reslength field is meaningless.  Testing
for it is wrong in the only place where it is ever tested.  We are
really interested in knowing whether there are any data in the buffer,
not how much of it was returned by the last read.

And looking at this I also notice the desc->read field.  We seem to set
it to 0 in wdm_read, but that is the only time it is ever accessed.
So it should also be dropped.



Bjørn

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Not enough resource for old configuration after USB bus reset

2013-02-27 Thread Soar Hung
>> Maybe I can try this with the mouse.
>> As far as I know, most HDD and pendrive do not use periodic tranfer.
>> So they can not produce the issue.
> 
> few emails back you said it had nothing to do with periodic
> transfers. -ECONFUSED 
> 

I try two experiment,

1. Test it on general desktop, the device will enum as CDC_ECM( 1 control, 2 
bulk, 1 interrupt), 
and CDC_ECM driver will use interupt to polling link status.

2. Test it on embedded system, the device will controlled by a custom driver ( 
1 control, 2 bulk, 1 interrupt).
The configure endpoint will allocate bandwith for interrupt endpoint.
But the driver nevery use interrupt endpoint.

In previous mail, I reply the experiment 2 as you suggest try not sending any 
periodic transfer.

The real issue is related to xHC(hardware) allocate bandwidth to periodic 
endpoint.

Hope this explanation clearify your question. Thanks.--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: samsung: let it be built as a module

2013-02-27 Thread Vivek Gautam
Hi Felipe,


On Wed, Feb 27, 2013 at 4:18 PM, Felipe Balbi  wrote:
> There's no reason not to allow samsung PHY
> drivers be built as modules. This patch changes
> Kconfig to allow that.
>
> Signed-off-by: Felipe Balbi 
> ---
>
> Hi,
>
> I will take your patches but I'm planning to add this on top
> as there is no reason not to allow these drivers being built
> as modules.
>

aargh !! my bad :-(
actually missed exporting the symbols in drivers/usb/phy/samsung-usbphy.c
Getting compile errors.
Shall i just update the patch [PATCH v5 0/2] Adding USB 3.0 DRD-phy
support for exynos5250
or send a separate patch on top so that you can squash this change
along with. ;-)

> cheers
>
>  drivers/usb/phy/Kconfig | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 723d7b1..4f696d0 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -67,7 +67,7 @@ config USB_RCAR_PHY
>   module will be called rcar-phy.
>
>  config SAMSUNG_USB2PHY
> -   bool "Samsung USB 2.0 PHY controller Driver"
> +   tristate "Samsung USB 2.0 PHY controller Driver"
> select SAMSUNG_USBPHY
> select USB_OTG_UTILS
> help
> @@ -75,7 +75,7 @@ config SAMSUNG_USB2PHY
>   driver for Samsung SoCs.
>
>  config SAMSUNG_USB3PHY
> -   bool "Samsung USB 3.0 PHY controller Driver"
> +   tristate "Samsung USB 3.0 PHY controller Driver"
> select SAMSUNG_USBPHY
> select USB_OTG_UTILS
> help
> @@ -83,7 +83,7 @@ config SAMSUNG_USB3PHY
>   for samsung SoCs.
>
>  config SAMSUNG_USBPHY
> -   bool "Samsung USB PHY Driver"
> +   tristate "Samsung USB PHY Driver"
> help
>   Enable this to support Samsung USB phy helper driver for Samsung 
> SoCs.
>   This driver provides common interface to interact, for Samsung USB 
> 2.0 PHY
> --
> 1.8.1.rc1.5.g7e0651a
>


-- 
Thanks & Regards
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-02-27 Thread Freddy Xin
From: Freddy Xin 

This is a resubmission.
Fixed endianness issue on big endian systems and verified this driver on iBook 
G4.
Removed steps that change net->features in ax88179_set_features function.
Added "const" to ethtool_ops structure and fixed the coding style of 
AX88179_BULKIN_SIZE array.
Fixed the issue that the default MTU is not 1500.
Added ax88179_change_mtu function and enabled the hardware jumbo frame function 
to support an
MTU higher than 1500.
Fixed indentation and empty line coding style errors.
The _nopm version usb functions were added to access register in suspend and 
resume functions.
Serveral variables allocted dynamically were removed and replaced by stack 
variables.
ax88179_get_eeprom were modified from asix_get_eeprom in asix_common.

This patch adds a driver for ASIX's AX88179 family of USB 3.0/2.0
to gigabit ethernet adapters. It's based on the AX88xxx driver but
the usb commands used to access registers for AX88179 are completely different.
This driver had been verified on x86 system with AX88179/AX88178A and
Sitcomm LN-032 USB dongles.

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/Kconfig|   18 +
 drivers/net/usb/Makefile   |1 +
 drivers/net/usb/ax88179_178a.c | 1455 
 3 files changed, 1474 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c

diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index da92ed3..21e084d 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -156,6 +156,24 @@ config USB_NET_AX8817X
  This driver creates an interface named "ethX", where X depends on
  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+   tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+   depends on USB_USBNET
+   select CRC32
+   select PHYLIB
+   default y
+   help
+ This option adds support for ASIX AX88179 based USB 3.0/2.0
+ to Gigabit Ethernet adapters.
+
+ This driver should work with at least the following devices:
+   * ASIX AX88179
+   * ASIX AX88178A
+   * Sitcomm LN-032
+
+ This driver creates an interface named "ethX", where X depends on
+ what other networking devices you have in use.
+
 config USB_NET_CDCETHER
tristate "CDC Ethernet support (smart devices such as cable modems)"
depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 4786913..119b06c 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)   += rtl8150.o
 obj-$(CONFIG_USB_HSO)  += hso.o
 obj-$(CONFIG_USB_NET_AX8817X)  += asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A)  += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)  += cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)   += dm9601.o
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
new file mode 100644
index 000..ed1ab2f
--- /dev/null
+++ b/drivers/net/usb/ax88179_178a.c
@@ -0,0 +1,1455 @@
+/*
+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices
+ *
+ * Copyright (C) 2011-2013 ASIX
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AX88179_PHY_ID 0x03
+#define AX_EEPROM_LEN  0x100
+#define AX88179_EEPROM_MAGIC   0x17900b95
+#define AX_MCAST_FLTSIZE   8
+#define AX_MAX_MCAST   64
+#define AX_INT_PPLS_LINK   ((u32)BIT(16))
+#define AX_RXHDR_L4_TYPE_MASK  0x1c
+#define AX_RXHDR_L4_TYPE_UDP   4
+#define AX_RXHDR_L4_TYPE_TCP   16
+#define AX_RXHDR_L3CSUM_ERR2
+#define AX_RXHDR_L4CSUM_ERR1
+#define AX_RXHDR_CRC_ERR   ((u32)BIT(31))
+#define AX_RXHDR_DROP_ERR  ((u32)BIT(30))
+#define AX_ACCESS_MAC  0x01
+#define AX_ACCESS_PHY  0x02
+#define AX_ACCESS_EEPROM   0x04
+#define AX_ACCESS_EFUS  

Re: [PATCH v9 8/9] usb: chipidea: tell platform layer the ci core probe's result

2013-02-27 Thread Felipe Balbi
Hi,

On Wed, Feb 27, 2013 at 10:22:03AM +0800, Peter Chen wrote:
> On Tue, Feb 26, 2013 at 11:42:34AM +0200, Felipe Balbi wrote:
> > On Sun, Feb 17, 2013 at 05:24:42PM +0800, Peter Chen wrote:
> > > If the probe fails, the ci13xxx_add_device will not return error,
> > > (bus_probe_device doesn't has return value)
> > > therefore, the platform layer can't know whether core's probe
> > > is successful or not, if platform layer goes on using core's struct
> > > which is initialized at core's probe, the error will occur.
> > > 
> > > This error is showed when I only compile gadget, the host-only
> > > controller reports "no supported roles", and fails probe, but imx
> > > platform code doesn't know it, and goes on using core's private data.
> > > 
> > > Signed-off-by: Peter Chen 
> > 
> > this just tells you that platform code shouldn't be using the driver
> > directly. passing probe_retval via platform_data is an abomination, fix
> > the real problem instead, whatever it is.
> 
> So you suggest the platform glue layer should not use core driver's data
> directly, eg, for your dwc3, the platform glue layer should not use
> struct dwc3 *dwc directly? 

yes, and it doesn't. Ever.

> At dwc3-exynos.c,  it has code "exynos->dwc3= dwc3;", so the exynos
> platform code may will use struct dwc3 in future. Besides, if the dwc3

nonsense. That's a structure platform_device which was created by the
glue, it has nothing to do with struct dwc3. struct platform_device
belongs to the glue, but there's an easy way to prevent that by using
device_for_each_child() on your ->remove() method.

> core driver's probe fails, the exynos platform code will not know it,
> the usb clk will be on on the usb can't be used.

so ? If the clock belongs to the glue, then the glue should enable it in
order to have access to its registers; if the clock belongs to the dwc3
core, then the glue is buggy; if the clock is shared between glue and
dwc3 core, then that's another bug, since nobody added clk handling code
to dwc3.

> If you suggest like above, we may need to add lots of notify function at

wrong. There's no need for any notification at all. A driver failing to
probe is just normal life. DWC3 is releasing all resources it allocated,
but the glue still needs the clock, then that's just the way it is.

There are many error messages which will tell the user that e.g. dwc3
failed to probe and user will just try again. If clocks are left
enabled, that's a bug in either core driver or glue layer which needs
fixing.

> core driver as there are many platform specific things, eg, special init/
> shutdown, suspend/resume, board layer gpio setting for vbus control (used

gpio handling should be done at board-file, that's a bug. You need to
add a fixed regulator which is toggled by a GPIO.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: phy: samsung: let it be built as a module

2013-02-27 Thread Felipe Balbi
Hi,

On Wed, Feb 27, 2013 at 05:31:53PM +0530, Vivek Gautam wrote:
> Hi Felipe,
> 
> 
> On Wed, Feb 27, 2013 at 4:18 PM, Felipe Balbi  wrote:
> > There's no reason not to allow samsung PHY
> > drivers be built as modules. This patch changes
> > Kconfig to allow that.
> >
> > Signed-off-by: Felipe Balbi 
> > ---
> >
> > Hi,
> >
> > I will take your patches but I'm planning to add this on top
> > as there is no reason not to allow these drivers being built
> > as modules.
> >
> 
> aargh !! my bad :-(
> actually missed exporting the symbols in drivers/usb/phy/samsung-usbphy.c
> Getting compile errors.
> Shall i just update the patch [PATCH v5 0/2] Adding USB 3.0 DRD-phy
> support for exynos5250
> or send a separate patch on top so that you can squash this change
> along with. ;-)

there's still time to update the original. I'll drop all 3 patches for
now (both of yours and mine).

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: phy: samsung: let it be built as a module

2013-02-27 Thread Vivek Gautam
On Wed, Feb 27, 2013 at 5:43 PM, Felipe Balbi  wrote:
> Hi,
>
> On Wed, Feb 27, 2013 at 05:31:53PM +0530, Vivek Gautam wrote:
>> Hi Felipe,
>>
>>
>> On Wed, Feb 27, 2013 at 4:18 PM, Felipe Balbi  wrote:
>> > There's no reason not to allow samsung PHY
>> > drivers be built as modules. This patch changes
>> > Kconfig to allow that.
>> >
>> > Signed-off-by: Felipe Balbi 
>> > ---
>> >
>> > Hi,
>> >
>> > I will take your patches but I'm planning to add this on top
>> > as there is no reason not to allow these drivers being built
>> > as modules.
>> >
>>
>> aargh !! my bad :-(
>> actually missed exporting the symbols in drivers/usb/phy/samsung-usbphy.c
>> Getting compile errors.
>> Shall i just update the patch [PATCH v5 0/2] Adding USB 3.0 DRD-phy
>> support for exynos5250
>> or send a separate patch on top so that you can squash this change
>> along with. ;-)
>
> there's still time to update the original. I'll drop all 3 patches for
> now (both of yours and mine).
>

Alright, i shall update the original patches and resend them after
adding this change for
EXPORT_SYMBOL_GPL() and also squashing your change for "modules".


-- 
Thanks & Regards
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: samsung: let it be built as a module

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 05:47:29PM +0530, Vivek Gautam wrote:
> On Wed, Feb 27, 2013 at 5:43 PM, Felipe Balbi  wrote:
> > Hi,
> >
> > On Wed, Feb 27, 2013 at 05:31:53PM +0530, Vivek Gautam wrote:
> >> Hi Felipe,
> >>
> >>
> >> On Wed, Feb 27, 2013 at 4:18 PM, Felipe Balbi  wrote:
> >> > There's no reason not to allow samsung PHY
> >> > drivers be built as modules. This patch changes
> >> > Kconfig to allow that.
> >> >
> >> > Signed-off-by: Felipe Balbi 
> >> > ---
> >> >
> >> > Hi,
> >> >
> >> > I will take your patches but I'm planning to add this on top
> >> > as there is no reason not to allow these drivers being built
> >> > as modules.
> >> >
> >>
> >> aargh !! my bad :-(
> >> actually missed exporting the symbols in drivers/usb/phy/samsung-usbphy.c
> >> Getting compile errors.
> >> Shall i just update the patch [PATCH v5 0/2] Adding USB 3.0 DRD-phy
> >> support for exynos5250
> >> or send a separate patch on top so that you can squash this change
> >> along with. ;-)
> >
> > there's still time to update the original. I'll drop all 3 patches for
> > now (both of yours and mine).
> >
> 
> Alright, i shall update the original patches and resend them after
> adding this change for
> EXPORT_SYMBOL_GPL() and also squashing your change for "modules".

k, thanks

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 7/9] USB chipidea i.MX: introduce dr_mode property

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

The dr_mode devicetree property allows to explicitly specify the
host/peripheral/otg mode. This is necessary for boards without proper
ID pin handling.

Reviewed-by: Peter Chen 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 Documentation/devicetree/bindings/usb/ci13xxx-imx.txt |1 +
 drivers/usb/chipidea/ci13xxx_imx.c|1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index dd42ccd..493a414 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -9,6 +9,7 @@ Recommended properies:
 - phy_type: the type of the phy connected to the core. Should be one
   of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
   property the PORTSC register won't be touched
+- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index ebc1148..b598bb8 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -114,6 +114,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
   CI13XXX_DISABLE_STREAMING;
 
pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);
+   pdata->dr_mode = of_usb_get_dr_mode(pdev->dev.of_node);
 
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/9] USB chipidea: ci13xxx-imx: create dynamic platformdata

2013-02-27 Thread Marc Kleine-Budde
From: Michael Grzeschik 

This patch removes the limitation of having only one instance of the
ci13xxx-imx platformdata and makes different configurations possible.

Reviewed-by: Peter Chen 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/ci13xxx_imx.c |   25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 8c29122..69024e0 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
 
 /* End of common functions shared by usbmisc drivers*/
 
-static struct ci13xxx_platform_data ci13xxx_imx_platdata  = {
-   .name   = "ci13xxx_imx",
-   .flags  = CI13XXX_REQUIRE_TRANSCEIVER |
- CI13XXX_PULLUP_ON_VBUS |
- CI13XXX_DISABLE_STREAMING,
-   .capoffset  = DEF_CAPOFFSET,
-};
-
 static int ci13xxx_imx_probe(struct platform_device *pdev)
 {
struct ci13xxx_imx_data *data;
+   struct ci13xxx_platform_data *pdata;
struct platform_device *plat_ci, *phy_pdev;
struct device_node *phy_np;
struct resource *res;
@@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
&& !usbmisc_ops)
return -EPROBE_DEFER;
 
+   pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata) {
+   dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n");
+   return -ENOMEM;
+   }
+
+   pdata->name = "ci13xxx_imx";
+   pdata->capoffset = DEF_CAPOFFSET;
+   pdata->flags = CI13XXX_REQUIRE_TRANSCEIVER |
+  CI13XXX_PULLUP_ON_VBUS |
+  CI13XXX_DISABLE_STREAMING;
+
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n");
@@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
reg_vbus = NULL;
}
 
-   ci13xxx_imx_platdata.phy = data->phy;
+   pdata->phy = data->phy;
 
if (!pdev->dev.dma_mask) {
pdev->dev.dma_mask = devm_kzalloc(&pdev->dev,
@@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 
plat_ci = ci13xxx_add_device(&pdev->dev,
pdev->resource, pdev->num_resources,
-   &ci13xxx_imx_platdata);
+   pdata);
if (IS_ERR(plat_ci)) {
ret = PTR_ERR(plat_ci);
dev_err(&pdev->dev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 9/9] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

This patch replaces the hand crafted code to retrieve the phy's phandle from
the DT by the helper function devm_usb_get_phy_by_phandle() which has been
added in commit:

"5d3c28b usb: otg: add device tree support to otg library"

Reviewed-by: Kishon Vijay Abraham I 
Reviewed-by: Peter Chen 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/ci13xxx_imx.c |   38 
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index b598bb8..6e720ce 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -30,7 +30,6 @@
((struct usb_phy *)platform_get_drvdata(pdev))
 
 struct ci13xxx_imx_data {
-   struct device_node *phy_np;
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
@@ -90,12 +89,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 {
struct ci13xxx_imx_data *data;
struct ci13xxx_platform_data *pdata;
-   struct platform_device *plat_ci, *phy_pdev;
-   struct device_node *phy_np;
+   struct platform_device *plat_ci;
struct resource *res;
struct regulator *reg_vbus;
struct pinctrl *pinctrl;
int ret;
+   struct usb_phy *phy;
 
if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL)
&& !usbmisc_ops)
@@ -147,19 +146,20 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
return ret;
}
 
-   phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0);
-   if (phy_np) {
-   data->phy_np = phy_np;
-   phy_pdev = of_find_device_by_node(phy_np);
-   if (phy_pdev) {
-   struct usb_phy *phy;
-   phy = pdev_to_phy(phy_pdev);
-   if (phy &&
-   try_module_get(phy_pdev->dev.driver->owner)) {
-   usb_phy_init(phy);
-   data->phy = phy;
-   }
+   phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0);
+   if (PTR_ERR(phy) == -EPROBE_DEFER) {
+   ret = -EPROBE_DEFER;
+   goto err_clk;
+   }
+
+   if (!IS_ERR(phy)) {
+   ret = usb_phy_init(phy);
+   if (ret) {
+   dev_err(&pdev->dev, "unable to init phy: %d\n", ret);
+   goto err_clk;
}
+
+   data->phy = phy;
}
 
/* we only support host now, so enable vbus here */
@@ -170,7 +170,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"Failed to enable vbus regulator, err=%d\n",
ret);
-   goto put_np;
+   goto err_clk;
}
data->reg_vbus = reg_vbus;
} else {
@@ -222,9 +222,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 err:
if (reg_vbus)
regulator_disable(reg_vbus);
-put_np:
-   if (phy_np)
-   of_node_put(phy_np);
+err_clk:
clk_disable_unprepare(data->clk);
return ret;
 }
@@ -244,8 +242,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)
module_put(data->phy->dev->driver->owner);
}
 
-   of_node_put(data->phy_np);
-
clk_disable_unprepare(data->clk);
 
platform_set_drvdata(pdev, NULL);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/9] USB chipidea: add PTW and PTS handling

2013-02-27 Thread Marc Kleine-Budde
From: Michael Grzeschik 

This patch makes it possible to configure the PTW and PTS bits inside
the portsc register for host and device mode before the driver starts
and the phy can be addressed as hardware implementation is designed.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +++
 drivers/usb/chipidea/bits.h|   14 ++-
 drivers/usb/chipidea/ci13xxx_imx.c |3 ++
 drivers/usb/chipidea/core.c|   39 
 include/linux/usb/chipidea.h   |1 +
 5 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 5778b9c..dd42ccd 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -5,6 +5,11 @@ Required properties:
 - reg: Should contain registers location and length
 - interrupts: Should contain controller interrupt
 
+Recommended properies:
+- phy_type: the type of the phy connected to the core. Should be one
+  of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
+  property the PORTSC register won't be touched
+
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
 - fsl,usbmisc: phandler of non-core register device, with one argument
diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 050de85..d8ffc2f 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -48,10 +48,22 @@
 #define PORTSC_SUSP   BIT(7)
 #define PORTSC_HSPBIT(9)
 #define PORTSC_PTC(0x0FUL << 16)
+/* PTS and PTW for non lpm version only */
+#define PORTSC_PTS(d) d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 
0))
+#define PORTSC_PTWBIT(28)
 
 /* DEVLC */
 #define DEVLC_PSPD(0x03UL << 25)
-#defineDEVLC_PSPD_HS  (0x02UL << 25)
+#define DEVLC_PSPD_HS (0x02UL << 25)
+#define DEVLC_PTW BIT(27)
+#define DEVLC_STS BIT(28)
+#define DEVLC_PTS(d)  (((d) & 0x7) << 29)
+
+/* Encoding for DEVLC_PTS and PORTSC_PTS */
+#define PTS_UTMI  0
+#define PTS_ULPI  2
+#define PTS_SERIAL3
+#define PTS_HSIC  4
 
 /* OTGSC */
 #define OTGSC_IDPU   BIT(5)
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 69024e0..ebc1148 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ci.h"
 #include "ci13xxx_imx.h"
@@ -112,6 +113,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
   CI13XXX_PULLUP_ON_VBUS |
   CI13XXX_DISABLE_STREAMING;
 
+   pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);
+
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n");
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 57cae1f..04d68cb 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -67,6 +67,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "ci.h"
 #include "udc.h"
@@ -211,6 +213,41 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem 
*base)
return 0;
 }
 
+static void hw_phymode_configure(struct ci13xxx *ci)
+{
+   u32 portsc, lpm;
+
+   switch (ci->platdata->phy_mode) {
+   case USBPHY_INTERFACE_MODE_UTMI:
+   portsc = PORTSC_PTS(PTS_UTMI);
+   lpm = DEVLC_PTS(PTS_UTMI);
+   break;
+   case USBPHY_INTERFACE_MODE_UTMIW:
+   portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW;
+   lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW;
+   break;
+   case USBPHY_INTERFACE_MODE_ULPI:
+   portsc = PORTSC_PTS(PTS_ULPI);
+   lpm = DEVLC_PTS(PTS_ULPI);
+   break;
+   case USBPHY_INTERFACE_MODE_SERIAL:
+   portsc = PORTSC_PTS(PTS_SERIAL);
+   lpm = DEVLC_PTS(PTS_SERIAL);
+   break;
+   case USBPHY_INTERFACE_MODE_HSIC:
+   portsc = PORTSC_PTS(PTS_HSIC);
+   lpm = DEVLC_PTS(PTS_HSIC);
+   break;
+   default:
+   return;
+   }
+
+   if (ci->hw_bank.lpm)
+   hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
+   else
+   hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
+}
+
 /**
  * hw_device_reset: resets chip (execute without interruption)
  * @ci: the controller
@@ -476,6 +513,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
: CI_ROLE_GADG

[PATCH 8/9] USB mxs-phy: Register phy with framework

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

We now have usb_add_phy_dev(), so use it to register with the framework
to be able to find the phy from the USB driver.

Reviewed-by: Kishon Vijay Abraham I 
Reviewed-by: Peter Chen 
Acked-by: Felipe Balbi 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/otg/mxs-phy.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index b0d9f11..aa40325 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -127,6 +127,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
void __iomem *base;
struct clk *clk;
struct mxs_phy *mxs_phy;
+   int ret;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
@@ -166,11 +167,19 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, &mxs_phy->phy);
 
+   ret = usb_add_phy_dev(&mxs_phy->phy);
+   if (ret)
+   return ret;
+
return 0;
 }
 
 static int mxs_phy_remove(struct platform_device *pdev)
 {
+   struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
+
+   usb_remove_phy(&mxs_phy->phy);
+
platform_set_drvdata(pdev, NULL);
 
return 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/9] USB chipidea: introduce dual role mode pdata flags

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

Even if a chipidea core is otg capable the board may not. This allows
to explicitly set the core to host/peripheral mode. Without these
flags the driver falls back to the old behaviour.

Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/core.c  |   22 --
 include/linux/usb/chipidea.h |2 +-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 04d68cb..ec27060 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -435,6 +435,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
struct resource *res;
void __iomem*base;
int ret;
+   enum usb_dr_mode dr_mode;
 
if (!dev->platform_data) {
dev_err(dev, "platform data missing\n");
@@ -487,14 +488,23 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+   /* For now we treat dual-role as otg */
+   dr_mode = ci->platdata->dr_mode;
+   if (dr_mode == USB_DR_MODE_UNKNOWN || dr_mode == USB_DR_MODE_DUAL_ROLE)
+   dr_mode = USB_DR_MODE_OTG;
+
/* initialize role(s) before the interrupt is requested */
-   ret = ci_hdrc_host_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support host\n");
+   if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
+   ret = ci_hdrc_host_init(ci);
+   if (ret)
+   dev_info(dev, "doesn't support host\n");
+   }
 
-   ret = ci_hdrc_gadget_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support gadget\n");
+   if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
+   ret = ci_hdrc_gadget_init(ci);
+   if (ret)
+   dev_info(dev, "doesn't support gadget\n");
+   }
 
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
dev_err(dev, "no supported roles\n");
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 1a2aa18..b314647 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -20,7 +20,7 @@ struct ci13xxx_platform_data {
 #define CI13XXX_REQUIRE_TRANSCEIVERBIT(1)
 #define CI13XXX_PULLUP_ON_VBUS BIT(2)
 #define CI13XXX_DISABLE_STREAMING  BIT(3)
-
+   enum usb_dr_modedr_mode;
 #define CI13XXX_CONTROLLER_RESET_EVENT 0
 #define CI13XXX_CONTROLLER_STOPPED_EVENT   1
void(*notify_event) (struct ci13xxx *ci, unsigned event);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Marc Kleine-Budde
In patch "5d3c28b usb: otg: add device tree support to otg library"
devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
phy driver in memory. The corresponding module_put() is missing in that patch.

This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
Further the missing module_put() is added to usb_put_phy().

Reviewed-by: Kishon Vijay Abraham I 
Acked-by: Felipe Balbi 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Michael Grzeschik 
---
 drivers/usb/otg/otg.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index e181439..2bd03d2 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -130,7 +130,7 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type)
spin_lock_irqsave(&phy_lock, flags);
 
phy = __usb_find_phy(&phy_list, type);
-   if (IS_ERR(phy)) {
+   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
pr_err("unable to find transceiver of type %s\n",
usb_phy_type_string(type));
goto err0;
@@ -228,7 +228,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 
index)
spin_lock_irqsave(&phy_lock, flags);
 
phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
-   if (IS_ERR(phy)) {
+   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
pr_err("unable to find transceiver\n");
goto err0;
}
@@ -301,8 +301,12 @@ EXPORT_SYMBOL(devm_usb_put_phy);
  */
 void usb_put_phy(struct usb_phy *x)
 {
-   if (x)
+   if (x) {
+   struct module *owner = x->dev->driver->owner;
+
put_device(x->dev);
+   module_put(owner);
+   }
 }
 EXPORT_SYMBOL(usb_put_phy);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/9] USB: move bulk of otg/otg.c to phy/phy.c

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

Most of otg/otg.c is not otg specific, but phy specific, so move it
to the phy directory.

Cc: Felipe Balbi 
Reported-by: Kishon Vijay Abraham I 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/otg/otg.c|  427 
 drivers/usb/phy/Makefile |1 +
 drivers/usb/phy/phy.c|  438 ++
 3 files changed, 439 insertions(+), 427 deletions(-)
 create mode 100644 drivers/usb/phy/phy.c

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 2bd03d2..358cfd9 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -8,436 +8,9 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  */
-
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include 
 
-static LIST_HEAD(phy_list);
-static LIST_HEAD(phy_bind_list);
-static DEFINE_SPINLOCK(phy_lock);
-
-static struct usb_phy *__usb_find_phy(struct list_head *list,
-   enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-
-   list_for_each_entry(phy, list, head) {
-   if (phy->type != type)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static struct usb_phy *__usb_find_phy_dev(struct device *dev,
-   struct list_head *list, u8 index)
-{
-   struct usb_phy_bind *phy_bind = NULL;
-
-   list_for_each_entry(phy_bind, list, list) {
-   if (!(strcmp(phy_bind->dev_name, dev_name(dev))) &&
-   phy_bind->index == index) {
-   if (phy_bind->phy)
-   return phy_bind->phy;
-   else
-   return ERR_PTR(-EPROBE_DEFER);
-   }
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static struct usb_phy *__of_usb_find_phy(struct device_node *node)
-{
-   struct usb_phy  *phy;
-
-   list_for_each_entry(phy, &phy_list, head) {
-   if (node != phy->dev->of_node)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static void devm_usb_phy_release(struct device *dev, void *res)
-{
-   struct usb_phy *phy = *(struct usb_phy **)res;
-
-   usb_put_phy(phy);
-}
-
-static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
-{
-   return res == match_data;
-}
-
-/**
- * devm_usb_get_phy - find the USB PHY
- * @dev - device that requests this phy
- * @type - the type of the phy the controller requires
- *
- * Gets the phy using usb_get_phy(), and associates a device with it using
- * devres. On driver detach, release function is invoked on the devres data,
- * then, devres data is freed.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
-{
-   struct usb_phy **ptr, *phy;
-
-   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
-   if (!ptr)
-   return NULL;
-
-   phy = usb_get_phy(type);
-   if (!IS_ERR(phy)) {
-   *ptr = phy;
-   devres_add(dev, ptr);
-   } else
-   devres_free(ptr);
-
-   return phy;
-}
-EXPORT_SYMBOL(devm_usb_get_phy);
-
-/**
- * usb_get_phy - find the USB PHY
- * @type - the type of the phy the controller requires
- *
- * Returns the phy driver, after getting a refcount to it; or
- * -ENODEV if there is no such phy.  The caller is responsible for
- * calling usb_put_phy() to release that count.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *usb_get_phy(enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-   unsigned long   flags;
-
-   spin_lock_irqsave(&phy_lock, flags);
-
-   phy = __usb_find_phy(&phy_list, type);
-   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
-   pr_err("unable to find transceiver of type %s\n",
-   usb_phy_type_string(type));
-   goto err0;
-   }
-
-   get_device(phy->dev);
-
-err0:
-   spin_unlock_irqrestore(&phy_lock, flags);
-
-   return phy;
-}
-EXPORT_SYMBOL(usb_get_phy);
-
- /**
- * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
- * @dev - device that requests this phy
- * @phandle - name of the property holding the phy phandle value
- * @index - the index of the phy
- *
- * Returns the phy driver associated with the given phandle value,
- * after getting a refcount to it, -ENODEV if there is no such phy or
- * -EPROBE_DEFER if there is a phandle to the phy, but the device is
- * not yet loaded. While at that, it also associates the device with
- * the phy using devres. On driver detach, release function is invoked
- * on the devres data, then, devres data is freed.
- *
- * For use by USB host and peripheral drivers.
- */
-struc

[PATCH v5 0/9] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Marc Kleine-Budde
Hello, this is the 5th round of Sascha's patch series, rebased to Greg's
usb-next.

Please consider to apply.

regards,
Marc

changes since v4:
- add support for USB_DR_MODE_DUAL_ROLE in dt helper

changes since v3:

- add phy patches (which were accidently already part of v2)
- Use OP_DEVLC instead of OP_PORTSC for lpm case
- Use enum usb_dr_mode ub ci_hdrc_probe()

changes since v2:

- fix adding of GPL Header was in wrong patch
- add missing hunk for new file of.c

changes since v1:
- move phy specific of helper to drivers/usb/phy/of.c
- use strcmp instead of strcasecmp for matching property values
- change usb_phy_dr_mode to usb_dr_mode
- change USBPHY_INTERFACE_MODE_NA to USBPHY_INTERFACE_MODE_UNKNOWN
- add copyright header to new files
- chipidea: drop mdelay at end of PTS/PTW setup
- chipidea: implement lpm core type handling for PTS/PTW


The following changes since commit 74e1a2a39355b2d3ae8c60c78d8add162c6d7183:

  Merge tag 'usb-3.9-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb (2013-02-21 12:20:00 
-0800)

are available in the git repository at:


  git://git.pengutronix.de/git/mkl/linux.git tags/usb-chipidea-for-next-v5

for you to fetch changes up to 1065bb064c06565cc0b86337d52977ab5afc3e90:

  USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy (2013-02-27 
12:54:13 +0100)


USB: chipidea patches for v3.10

These add OF helpers for handling the dr_mode and phy_type property and makes
use of them in the chipidea driver.


Marc Kleine-Budde (1):
  USB otg: use try_module_get in all usb_get_phy functions and add missing 
module_put

Michael Grzeschik (3):
  USB: add devicetree helpers for determining dr_mode and phy_type
  USB chipidea: ci13xxx-imx: create dynamic platformdata
  USB chipidea: add PTW and PTS handling

Sascha Hauer (5):
  USB: move bulk of otg/otg.c to phy/phy.c
  USB chipidea: introduce dual role mode pdata flags
  USB chipidea i.MX: introduce dr_mode property
  USB mxs-phy: Register phy with framework
  USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

 .../devicetree/bindings/usb/ci13xxx-imx.txt|6 +
 drivers/usb/chipidea/bits.h|   14 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   67 +--
 drivers/usb/chipidea/core.c|   61 ++-
 drivers/usb/otg/mxs-phy.c  |9 +
 drivers/usb/otg/otg.c  |  423 ---
 drivers/usb/phy/Makefile   |2 +
 drivers/usb/phy/of.c   |   47 +++
 drivers/usb/phy/phy.c  |  438 
 drivers/usb/usb-common.c   |   37 ++
 include/linux/usb/chipidea.h   |3 +-
 include/linux/usb/of.h |   27 ++
 include/linux/usb/otg.h|8 +
 include/linux/usb/phy.h|9 +
 14 files changed, 689 insertions(+), 462 deletions(-)
 create mode 100644 drivers/usb/phy/of.c
 create mode 100644 drivers/usb/phy/phy.c
 create mode 100644 include/linux/usb/of.h

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/9] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Marc Kleine-Budde
From: Michael Grzeschik 

This adds two little devicetree helper functions for determining the dr_mode
(host, peripheral, otg, dual-role) and phy_type (utmi, ulpi,...) from the
devicetree.

Cc: Felipe Balbi 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/phy/Makefile |1 +
 drivers/usb/phy/of.c |   47 ++
 drivers/usb/usb-common.c |   37 
 include/linux/usb/of.h   |   27 ++
 include/linux/usb/otg.h  |8 
 include/linux/usb/phy.h  |9 +
 6 files changed, 129 insertions(+)
 create mode 100644 drivers/usb/phy/of.c
 create mode 100644 include/linux/usb/of.h

diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 9fa6327..e1be1e8 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,6 +5,7 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_OTG_UTILS)+= phy.o
+obj-$(CONFIG_OF)   += of.o
 obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o
 obj-$(CONFIG_OMAP_USB3)+= omap-usb3.o
 obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o
diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
new file mode 100644
index 000..e6f3b74
--- /dev/null
+++ b/drivers/usb/phy/of.c
@@ -0,0 +1,47 @@
+/*
+ * USB of helper code
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char *usbphy_modes[] = {
+   [USBPHY_INTERFACE_MODE_UNKNOWN] = "",
+   [USBPHY_INTERFACE_MODE_UTMI]= "utmi",
+   [USBPHY_INTERFACE_MODE_UTMIW]   = "utmi_wide",
+   [USBPHY_INTERFACE_MODE_ULPI]= "ulpi",
+   [USBPHY_INTERFACE_MODE_SERIAL]  = "serial",
+   [USBPHY_INTERFACE_MODE_HSIC]= "hsic",
+};
+
+/**
+ * of_usb_get_phy_mode - Get phy mode for given device_node
+ * @np:Pointer to the given device_node
+ *
+ * The function gets phy interface string from property 'phy_type',
+ * and returns the correspondig enum usb_phy_interface
+ */
+enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
+{
+   const char *phy_type;
+   int err, i;
+
+   err = of_property_read_string(np, "phy_type", &phy_type);
+   if (err < 0)
+   return USBPHY_INTERFACE_MODE_UNKNOWN;
+
+   for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
+   if (!strcmp(phy_type, usbphy_modes[i]))
+   return i;
+
+   return USBPHY_INTERFACE_MODE_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
index d29503e..18b994b 100644
--- a/drivers/usb/usb-common.c
+++ b/drivers/usb/usb-common.c
@@ -14,6 +14,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 const char *usb_speed_string(enum usb_device_speed speed)
 {
@@ -32,4 +35,38 @@ const char *usb_speed_string(enum usb_device_speed speed)
 }
 EXPORT_SYMBOL_GPL(usb_speed_string);
 
+#ifdef CONFIG_OF
+static const char *usb_dr_modes[] = {
+   [USB_DR_MODE_UNKNOWN]   = "",
+   [USB_DR_MODE_HOST]  = "host",
+   [USB_DR_MODE_PERIPHERAL]= "peripheral",
+   [USB_DR_MODE_OTG]   = "otg",
+   [USB_DR_MODE_DUAL_ROLE] = "dual-role",
+};
+
+/**
+ * of_usb_get_dr_mode - Get dual role mode for given device_node
+ * @np:Pointer to the given device_node
+ *
+ * The function gets phy interface string from property 'dr_mode',
+ * and returns the correspondig enum usb_dr_mode
+ */
+enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
+{
+   const char *dr_mode;
+   int err, i;
+
+   err = of_property_read_string(np, "dr_mode", &dr_mode);
+   if (err < 0)
+   return USB_DR_MODE_UNKNOWN;
+
+   for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
+   if (!strcmp(dr_mode, usb_dr_modes[i]))
+   return i;
+
+   return USB_DR_MODE_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
+#endif
+
 MODULE_LICENSE("GPL");
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
new file mode 100644
index 000..4681a20
--- /dev/null
+++ b/include/linux/usb/of.h
@@ -0,0 +1,27 @@
+/*
+ * OF helpers for usb devices.
+ *
+ * This file is released under the GPLv2
+ */
+
+#ifndef __LINUX_USB_OF_H
+#define __LINUX_USB_OF_H
+
+#include 
+
+#ifdef CONFIG_OF
+enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
+enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
+#else
+static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node 
*np)
+{
+   return USBPHY_INTERFACE_MODE_UNKNOWN;
+}
+
+static inline enum

Re: [PATCH 2/9] USB: move bulk of otg/otg.c to phy/phy.c

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 01:27 PM, Marc Kleine-Budde wrote:
> From: Sascha Hauer 
> 
> Most of otg/otg.c is not otg specific, but phy specific, so move it
> to the phy directory.
> 
> Cc: Felipe Balbi 
> Reported-by: Kishon Vijay Abraham I 
> Signed-off-by: Sascha Hauer 
> Signed-off-by: Marc Kleine-Budde 

Felipe, can you please review this patch and give us your Acked-by?

regards, Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 3/9] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 01:27 PM, Marc Kleine-Budde wrote:
> From: Michael Grzeschik 
> 
> This adds two little devicetree helper functions for determining the dr_mode
> (host, peripheral, otg, dual-role) and phy_type (utmi, ulpi,...) from the
> devicetree.
> 
> Cc: Felipe Balbi 
> Signed-off-by: Michael Grzeschik 
> Signed-off-by: Sascha Hauer 
> Signed-off-by: Marc Kleine-Budde 

Felipe, same here. Your Acked-by is appreciated.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 2/9] USB: move bulk of otg/otg.c to phy/phy.c

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 01:29:40PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:27 PM, Marc Kleine-Budde wrote:
> > From: Sascha Hauer 
> > 
> > Most of otg/otg.c is not otg specific, but phy specific, so move it
> > to the phy directory.
> > 
> > Cc: Felipe Balbi 
> > Reported-by: Kishon Vijay Abraham I 
> > Signed-off-by: Sascha Hauer 
> > Signed-off-by: Marc Kleine-Budde 
> 
> Felipe, can you please review this patch and give us your Acked-by?

I will take it through my tree

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
> In patch "5d3c28b usb: otg: add device tree support to otg library"
> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
> phy driver in memory. The corresponding module_put() is missing in that patch.
> 
> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
> Further the missing module_put() is added to usb_put_phy().
> 
> Reviewed-by: Kishon Vijay Abraham I 
> Acked-by: Felipe Balbi 
> Signed-off-by: Marc Kleine-Budde 
> Signed-off-by: Michael Grzeschik 

this one doesn't apply to my tree. What did you use as a base ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/9] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 01:27:09PM +0100, Marc Kleine-Budde wrote:
> From: Michael Grzeschik 
> 
> This adds two little devicetree helper functions for determining the dr_mode

it looks to me that "mode" is enough. s/dr_mode/mode/

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/9] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 01:31:02PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:27 PM, Marc Kleine-Budde wrote:
> > From: Michael Grzeschik 
> > 
> > This adds two little devicetree helper functions for determining the dr_mode
> > (host, peripheral, otg, dual-role) and phy_type (utmi, ulpi,...) from the
> > devicetree.
> > 
> > Cc: Felipe Balbi 
> > Signed-off-by: Michael Grzeschik 
> > Signed-off-by: Sascha Hauer 
> > Signed-off-by: Marc Kleine-Budde 
> 
> Felipe, same here. Your Acked-by is appreciated.

likewise, I'll take it through my tree

-- 
balbi


signature.asc
Description: Digital signature


re: [PATCH] USB Storage: add support for Maxtor One-Touch button

2013-02-27 Thread Dan Carpenter
Hello Matthew Dharm,

This is an old warning but it looks like it might be valid.

The patch 34008dbfe8c0: "[PATCH] USB Storage: add support for Maxtor 
One-Touch button" from Jul 28, 2005, leads to the following Smatch
warning:
"drivers/usb/storage/onetouch.c:248 onetouch_connect_input()
 error: usb_fill_int_urb() 'onetouch->data' too small (2 vs 9)"

[ This requires some database configuration to get this warning ].


drivers/usb/storage/onetouch.c
   197  maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));

maxp depends on the end point.

   198  
   199  onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL);
   200  input_dev = input_allocate_device();
   201  if (!onetouch || !input_dev)
   202  goto fail1;
   203  
   204  onetouch->data = usb_alloc_coherent(udev, ONETOUCH_PKT_LEN,
^^
ONETOUCH_PKT_LEN is 0x02 so we are ->data is 2 bytes.

   205  GFP_KERNEL, 
&onetouch->data_dma);
   206  if (!onetouch->data)
   207  goto fail1;
   208  

[ snip ].

   245  input_dev->open = usb_onetouch_open;
   246  input_dev->close = usb_onetouch_close;
   247  
   248  usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data,
   249   (maxp > 8 ? 8 : maxp),
  ^^^
If we use 8 as the transfer size and ->data is only 2 bytes then it
could corrupt memory.  (Smatch incorrectly thinks this parameter can
be 9, but even 8 would be too high).

   250   usb_onetouch_irq, onetouch, 
endpoint->bInterval);
   251  onetouch->irq->transfer_dma = onetouch->data_dma;
   252  onetouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
   253  

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/9] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 01:32 PM, Felipe Balbi wrote:
> On Wed, Feb 27, 2013 at 01:27:09PM +0100, Marc Kleine-Budde wrote:
>> From: Michael Grzeschik 
>>
>> This adds two little devicetree helper functions for determining the dr_mode
> 
> it looks to me that "mode" is enough. s/dr_mode/mode/

There already is that DT binding, we just created a helper function for
that.

git grep -e dr_mode\ *: linus/master Documentation/
linus/master:Documentation/devicetree/bindings/usb/fsl-usb.txt: - dr_mode : 
indicates the working mode for "fsl-usb2-dr" compatible
linus/master:Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt:  - 
dr_mode : dual role mode. Indicates the working mode for

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v10 8/8] usb: chipidea: imx: fix the error that using uninitialized pointer

2013-02-27 Thread Sergei Shtylyov

Hello.

On 27-02-2013 10:33, Peter Chen wrote:


If the core's probe fails, the platform layer may not get core's
private data, if the platform tries to use struct ci13xxx, it will
use uninitialized pointer. Besides, if the core's probe fails,
the platform layer should know it, and let its probe fail too.



Signed-off-by: Peter Chen 
---
  drivers/usb/chipidea/ci13xxx_imx.c |7 +++
  1 files changed, 7 insertions(+), 0 deletions(-)



diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 5499cf8..720ea92 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -239,6 +239,13 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data);

ci = platform_get_drvdata(plat_ci);
+


   No need for empty line here...


+   if (!ci) {
+   ret = -ENODEV;
+   dev_err(&pdev->dev,
+   "some wrong at ci core's initialization\n");
+   goto err_clk;
+   }


   It'd be better to put it here.


/*
 * Internal vbus on/off policy
 * - Always on for host only function


WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
>> In patch "5d3c28b usb: otg: add device tree support to otg library"
>> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
>> phy driver in memory. The corresponding module_put() is missing in that 
>> patch.
>>
>> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
>> Further the missing module_put() is added to usb_put_phy().
>>
>> Reviewed-by: Kishon Vijay Abraham I 
>> Acked-by: Felipe Balbi 
>> Signed-off-by: Marc Kleine-Budde 
>> Signed-off-by: Michael Grzeschik 
> 
> this one doesn't apply to my tree. What did you use as a base ?

As stated in the cover letter: Greg's usb-next.

git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

I'd really appreciate if this series goes into a single tree. So that
other chipidea developers can base their work on this.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 3/9] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 01:38:41PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:32 PM, Felipe Balbi wrote:
> > On Wed, Feb 27, 2013 at 01:27:09PM +0100, Marc Kleine-Budde wrote:
> >> From: Michael Grzeschik 
> >>
> >> This adds two little devicetree helper functions for determining the 
> >> dr_mode
> > 
> > it looks to me that "mode" is enough. s/dr_mode/mode/
> 
> There already is that DT binding, we just created a helper function for
> that.
> 
> git grep -e dr_mode\ *: linus/master Documentation/
> linus/master:Documentation/devicetree/bindings/usb/fsl-usb.txt: - dr_mode : 
> indicates the working mode for "fsl-usb2-dr" compatible
> linus/master:Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt:  
> - dr_mode : dual role mode. Indicates the working mode for

fair enough, then there's nothing we can do :-p

I'll take it soonish.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Felipe Balbi
Hi,

On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> > On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
> >> In patch "5d3c28b usb: otg: add device tree support to otg library"
> >> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock 
> >> the
> >> phy driver in memory. The corresponding module_put() is missing in that 
> >> patch.
> >>
> >> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
> >> Further the missing module_put() is added to usb_put_phy().
> >>
> >> Reviewed-by: Kishon Vijay Abraham I 
> >> Acked-by: Felipe Balbi 
> >> Signed-off-by: Marc Kleine-Budde 
> >> Signed-off-by: Michael Grzeschik 
> > 
> > this one doesn't apply to my tree. What did you use as a base ?
> 
> As stated in the cover letter: Greg's usb-next.
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
> 
> I'd really appreciate if this series goes into a single tree. So that
> other chipidea developers can base their work on this.

it eventually will all go through Greg's queue, but drivers/usb/phy and
drivers/usb/otg/ needs to go through my tree so we avoid conflicts
later, sorry.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 01:43 PM, Felipe Balbi wrote:
> Hi,
> 
> On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
>> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
>>> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
 In patch "5d3c28b usb: otg: add device tree support to otg library"
 devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock 
 the
 phy driver in memory. The corresponding module_put() is missing in that 
 patch.

 This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
 Further the missing module_put() is added to usb_put_phy().

 Reviewed-by: Kishon Vijay Abraham I 
 Acked-by: Felipe Balbi 
 Signed-off-by: Marc Kleine-Budde 
 Signed-off-by: Michael Grzeschik 
>>>
>>> this one doesn't apply to my tree. What did you use as a base ?
>>
>> As stated in the cover letter: Greg's usb-next.
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
>>
>> I'd really appreciate if this series goes into a single tree. So that
>> other chipidea developers can base their work on this.
> 
> it eventually will all go through Greg's queue, but drivers/usb/phy and
> drivers/usb/otg/ needs to go through my tree so we avoid conflicts
> later, sorry.

Oh - this is going to be complicated. I'll rip the series into 3 parts
and repost.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Felipe Balbi
On Wed, Feb 27, 2013 at 01:46:21PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:43 PM, Felipe Balbi wrote:
> > Hi,
> > 
> > On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
> >> On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> >>> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
>  In patch "5d3c28b usb: otg: add device tree support to otg library"
>  devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to 
>  lock the
>  phy driver in memory. The corresponding module_put() is missing in that 
>  patch.
> 
>  This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
>  Further the missing module_put() is added to usb_put_phy().
> 
>  Reviewed-by: Kishon Vijay Abraham I 
>  Acked-by: Felipe Balbi 
>  Signed-off-by: Marc Kleine-Budde 
>  Signed-off-by: Michael Grzeschik 
> >>>
> >>> this one doesn't apply to my tree. What did you use as a base ?
> >>
> >> As stated in the cover letter: Greg's usb-next.
> >>
> >> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
> >>
> >> I'd really appreciate if this series goes into a single tree. So that
> >> other chipidea developers can base their work on this.
> > 
> > it eventually will all go through Greg's queue, but drivers/usb/phy and
> > drivers/usb/otg/ needs to go through my tree so we avoid conflicts
> > later, sorry.
> 
> Oh - this is going to be complicated. I'll rip the series into 3 parts
> and repost.

let's try like this:

drivers/usb/otg and drivers/usb/phy which don't create dependencies for
chipidea and other patches which create dependencies.

Then we can figure out how to handle the dependencies.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH resend 0/5] USB: fixes for 3.9-rc

2013-02-27 Thread Johan Hovold
My patch bomb of yesterday is hardly managable. I'm resending the fixes
separately now and then the remaining usb-next patches that depend on them once
the fixes are in.

I apologise for the noise,
Johan


Johan Hovold (5):
  USB: cdc-acm: fix device unregistration
  USB: ftdi_sio: fix use after free in TIOCMIWAIT
  USB: garmin_gps: fix memory leak on disconnect
  USB: io_ti: fix get_icount for two port adapters
  USB: serial: fix interface refcounting

 drivers/usb/class/cdc-acm.c |  3 ++-
 drivers/usb/serial/ftdi_sio.c   | 11 +--
 drivers/usb/serial/garmin_gps.c |  7 +--
 drivers/usb/serial/io_ti.c  |  1 +
 drivers/usb/serial/usb-serial.c |  3 ++-
 5 files changed, 11 insertions(+), 14 deletions(-)

-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] USB: garmin_gps: fix memory leak on disconnect

2013-02-27 Thread Johan Hovold
Remove bogus disconnect test introduced by 95bef012e ("USB: more serial
drivers writing after disconnect") which prevented queued data from
being freed on disconnect.

The possible IO it was supposed to prevent is long gone.

Cc: stable 
Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/garmin_gps.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 1a07b12..81caf56 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -956,10 +956,7 @@ static void garmin_close(struct usb_serial_port *port)
if (!serial)
return;
 
-   mutex_lock(&port->serial->disc_mutex);
-
-   if (!port->serial->disconnected)
-   garmin_clear(garmin_data_p);
+   garmin_clear(garmin_data_p);
 
/* shutdown our urbs */
usb_kill_urb(port->read_urb);
@@ -968,8 +965,6 @@ static void garmin_close(struct usb_serial_port *port)
/* keep reset state so we know that we must start a new session */
if (garmin_data_p->state != STATE_RESET)
garmin_data_p->state = STATE_DISCONNECTED;
-
-   mutex_unlock(&port->serial->disc_mutex);
 }
 
 
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] USB: cdc-acm: fix device unregistration

2013-02-27 Thread Johan Hovold
Unregister tty device in disconnect as is required by the USB stack.

By deferring unregistration to when the last tty reference is dropped,
the parent interface device can get unregistered before the child
resulting in broken hotplug events being generated when the tty is
finally closed:

KERNEL[2290.798128] remove   /devices/pci:00/:00:1d.7/usb2/2-1/2-1:3.1 
(usb)
KERNEL[2290.804589] remove   /devices/pci:00/:00:1d.7/usb2/2-1 (usb)
KERNEL[2294.554799] remove   /2-1:3.1/tty/ttyACM0 (tty)

The driver must deal with tty callbacks after disconnect by checking the
disconnected flag. Specifically, further opens must be prevented and
this is already implemented.

Cc: stable 
Signed-off-by: Johan Hovold 
---
 drivers/usb/class/cdc-acm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 8ac25ad..e18e9a8 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -593,7 +593,6 @@ static void acm_port_destruct(struct tty_port *port)
 
dev_dbg(&acm->control->dev, "%s\n", __func__);
 
-   tty_unregister_device(acm_tty_driver, acm->minor);
acm_release_minor(acm);
usb_put_intf(acm->control);
kfree(acm->country_codes);
@@ -1411,6 +1410,8 @@ static void acm_disconnect(struct usb_interface *intf)
 
stop_data_traffic(acm);
 
+   tty_unregister_device(acm_tty_driver, acm->minor);
+
usb_free_urb(acm->ctrlurb);
for (i = 0; i < ACM_NW; i++)
usb_free_urb(acm->wb[i].urb);
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] USB: ftdi_sio: fix use after free in TIOCMIWAIT

2013-02-27 Thread Johan Hovold
Make sure to check the serial disconnected flag before accessing port
private data after waking up.

This fixes a use after free in the ftdi_sio introduced by commit
876ae50d94b ("USB: ftdi_sio: fix race condition in TIOCMIWAIT, and abort
of TIOCMIWAIT when the device is removed").

When switching to tty ports, some lifetime assumptions where changed.
Specifically, close can now be called before the final tty reference is
dropped as part of hangup at device disconnect. Even with the ftdi
private-data refcounting this means that the port private data can be
freed while a process is sleeping on modem-status changes and thus
cannot be relied on to detect disconnects when woken up.

Cc: stable 
Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/ftdi_sio.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index edd162d..83dd0b9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -71,7 +71,6 @@ struct ftdi_private {
struct async_icount icount;
wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
char prev_status;/* Used for TIOCMIWAIT */
-   bool dev_gone;/* Used to abort TIOCMIWAIT */
char transmit_empty;/* If transmitter is empty or not */
__u16 interface;/* FT2232C, FT2232H or FT4232H port interface
   (0 for FT232/245) */
@@ -1694,7 +1693,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port 
*port)
init_waitqueue_head(&priv->delta_msr_wait);
 
priv->flags = ASYNC_LOW_LATENCY;
-   priv->dev_gone = false;
 
if (quirk && quirk->port_probe)
quirk->port_probe(priv);
@@ -1840,7 +1838,6 @@ static int ftdi_sio_port_remove(struct usb_serial_port 
*port)
 {
struct ftdi_private *priv = usb_get_serial_port_data(port);
 
-   priv->dev_gone = true;
wake_up_interruptible_all(&priv->delta_msr_wait);
 
remove_sysfs_attrs(port);
@@ -2440,11 +2437,15 @@ static int ftdi_ioctl(struct tty_struct *tty,
 */
case TIOCMIWAIT:
cprev = priv->icount;
-   while (!priv->dev_gone) {
+   for (;;) {
interruptible_sleep_on(&priv->delta_msr_wait);
/* see if a signal did it */
if (signal_pending(current))
return -ERESTARTSYS;
+
+   if (port->serial->disconnected)
+   return -EIO;
+
cnow = priv->icount;
if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
@@ -2454,8 +2455,6 @@ static int ftdi_ioctl(struct tty_struct *tty,
}
cprev = cnow;
}
-   return -EIO;
-   break;
case TIOCSERGETLSR:
return get_lsr_info(port, (struct serial_struct __user *)arg);
break;
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] USB: serial: fix interface refcounting

2013-02-27 Thread Johan Hovold
Make sure the interface is not released before our serial device.

Note that drivers are still not allowed to access the interface in
any way that may interfere with another driver that may have gotten
bound to the same interface after disconnect returns.

Cc: stable 
Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/usb-serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a19ed74..2e70efa 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -151,6 +151,7 @@ static void destroy_serial(struct kref *kref)
}
}
 
+   usb_put_intf(serial->interface);
usb_put_dev(serial->dev);
kfree(serial);
 }
@@ -620,7 +621,7 @@ static struct usb_serial *create_serial(struct usb_device 
*dev,
}
serial->dev = usb_get_dev(dev);
serial->type = driver;
-   serial->interface = interface;
+   serial->interface = usb_get_intf(interface);
kref_init(&serial->kref);
mutex_init(&serial->disc_mutex);
serial->minor = SERIAL_TTY_NO_MINOR;
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] USB: io_ti: fix get_icount for two port adapters

2013-02-27 Thread Johan Hovold
Add missing get_icount field to two-port driver.

The two-port driver was not updated when switching to the new icount
interface in commit 0bca1b913aff ("tty: Convert the USB drivers to the
new icount interface").

Cc: stable 
Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/io_ti.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index c237766..d7d3c0e 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2649,6 +2649,7 @@ static struct usb_serial_driver edgeport_2port_device = {
.set_termios= edge_set_termios,
.tiocmget   = edge_tiocmget,
.tiocmset   = edge_tiocmset,
+   .get_icount = edge_get_icount,
.write  = edge_write,
.write_room = edge_write_room,
.chars_in_buffer= edge_chars_in_buffer,
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 01:47 PM, Felipe Balbi wrote:
> On Wed, Feb 27, 2013 at 01:46:21PM +0100, Marc Kleine-Budde wrote:
>> On 02/27/2013 01:43 PM, Felipe Balbi wrote:
>>> Hi,
>>>
>>> On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
 On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
>> In patch "5d3c28b usb: otg: add device tree support to otg library"
>> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to 
>> lock the
>> phy driver in memory. The corresponding module_put() is missing in that 
>> patch.
>>
>> This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
>> Further the missing module_put() is added to usb_put_phy().
>>
>> Reviewed-by: Kishon Vijay Abraham I 
>> Acked-by: Felipe Balbi 
>> Signed-off-by: Marc Kleine-Budde 
>> Signed-off-by: Michael Grzeschik 
>
> this one doesn't apply to my tree. What did you use as a base ?

 As stated in the cover letter: Greg's usb-next.

 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

 I'd really appreciate if this series goes into a single tree. So that
 other chipidea developers can base their work on this.
>>>
>>> it eventually will all go through Greg's queue, but drivers/usb/phy and
>>> drivers/usb/otg/ needs to go through my tree so we avoid conflicts
>>> later, sorry.
>>
>> Oh - this is going to be complicated. I'll rip the series into 3 parts
>> and repost.
> 
> let's try like this:
> 
> drivers/usb/otg and drivers/usb/phy which don't create dependencies for
> chipidea and other patches which create dependencies.
> 
> Then we can figure out how to handle the dependencies.
> 

That'll be these 3 branches then:

otg-for-v3.9 (bugfix for v3.9):
6bef020 USB otg: use try_module_get in all usb_get_phy functions and add 
missing module_put

otg-for-v3.10 (depends on otg-for-v3.9):
a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
8a4c9f8 USB mxs-phy: Register phy with framework

chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
9466e85 USB chipidea: add PTW and PTS handling
ad2cc0d USB chipidea: introduce dual role mode pdata flags
8e7f1bb USB chipidea i.MX: introduce dr_mode property
5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH] net: cdc_ncm: tag Huawei devices (e.g. E5331) with FLAG_WWAN

2013-02-27 Thread Bjørn Mork
Tag all Huawei NCM devices as WWAN modems, as we don't know of any which
are not.  This is necessary for userspace clients to know that the device
requires further setup on e.g. an AT-capable serial ports before
connectivity is available.

Signed-off-by: Bjørn Mork 
---
 drivers/net/usb/cdc_ncm.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4a8c25a..61b74a2 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1213,6 +1213,14 @@ static const struct usb_device_id cdc_devs[] = {
  .driver_info = (unsigned long) &wwan_info,
},
 
+   /* tag Huawei devices as wwan */
+   { USB_VENDOR_AND_INTERFACE_INFO(0x12d1,
+   USB_CLASS_COMM,
+   USB_CDC_SUBCLASS_NCM,
+   USB_CDC_PROTO_NONE),
+ .driver_info = (unsigned long)&wwan_info,
+   },
+
/* Huawei NCM devices disguised as vendor specific */
{ USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16),
  .driver_info = (unsigned long)&wwan_info,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] USB: cdc-acm: fix device unregistration

2013-02-27 Thread Oliver Neukum
On Wednesday 27 February 2013 13:52:26 Johan Hovold wrote:
> Unregister tty device in disconnect as is required by the USB stack.
> 
> By deferring unregistration to when the last tty reference is dropped,
> the parent interface device can get unregistered before the child
> resulting in broken hotplug events being generated when the tty is
> finally closed:
> 
> KERNEL[2290.798128] remove   
> /devices/pci:00/:00:1d.7/usb2/2-1/2-1:3.1 (usb)
> KERNEL[2290.804589] remove   /devices/pci:00/:00:1d.7/usb2/2-1 (usb)
> KERNEL[2294.554799] remove   /2-1:3.1/tty/ttyACM0 (tty)
> 
> The driver must deal with tty callbacks after disconnect by checking the
> disconnected flag. Specifically, further opens must be prevented and
> this is already implemented.
> 
> Cc: stable 
> Signed-off-by: Johan Hovold 
Acked-by: Oliver Neukum 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Felipe Balbi
Hi,

On Wed, Feb 27, 2013 at 01:55:35PM +0100, Marc Kleine-Budde wrote:
> On 02/27/2013 01:47 PM, Felipe Balbi wrote:
> > On Wed, Feb 27, 2013 at 01:46:21PM +0100, Marc Kleine-Budde wrote:
> >> On 02/27/2013 01:43 PM, Felipe Balbi wrote:
> >>> Hi,
> >>>
> >>> On Wed, Feb 27, 2013 at 01:40:51PM +0100, Marc Kleine-Budde wrote:
>  On 02/27/2013 01:31 PM, Felipe Balbi wrote:
> > On Wed, Feb 27, 2013 at 01:27:07PM +0100, Marc Kleine-Budde wrote:
> >> In patch "5d3c28b usb: otg: add device tree support to otg library"
> >> devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to 
> >> lock the
> >> phy driver in memory. The corresponding module_put() is missing in 
> >> that patch.
> >>
> >> This patch adds try_module_get() to usb_get_phy() and 
> >> usb_get_phy_dev().
> >> Further the missing module_put() is added to usb_put_phy().
> >>
> >> Reviewed-by: Kishon Vijay Abraham I 
> >> Acked-by: Felipe Balbi 
> >> Signed-off-by: Marc Kleine-Budde 
> >> Signed-off-by: Michael Grzeschik 
> >
> > this one doesn't apply to my tree. What did you use as a base ?
> 
>  As stated in the cover letter: Greg's usb-next.
> 
>  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
> 
>  I'd really appreciate if this series goes into a single tree. So that
>  other chipidea developers can base their work on this.
> >>>
> >>> it eventually will all go through Greg's queue, but drivers/usb/phy and
> >>> drivers/usb/otg/ needs to go through my tree so we avoid conflicts
> >>> later, sorry.
> >>
> >> Oh - this is going to be complicated. I'll rip the series into 3 parts
> >> and repost.
> > 
> > let's try like this:
> > 
> > drivers/usb/otg and drivers/usb/phy which don't create dependencies for
> > chipidea and other patches which create dependencies.
> > 
> > Then we can figure out how to handle the dependencies.
> > 
> 
> That'll be these 3 branches then:
> 
> otg-for-v3.9 (bugfix for v3.9):
> 6bef020 USB otg: use try_module_get in all usb_get_phy functions and add 
> missing module_put
> 
> otg-for-v3.10 (depends on otg-for-v3.9):
> a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
> a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
> 8a4c9f8 USB mxs-phy: Register phy with framework
> 
> chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
> 15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
> 9466e85 USB chipidea: add PTW and PTS handling
> ad2cc0d USB chipidea: introduce dual role mode pdata flags
> 8e7f1bb USB chipidea i.MX: introduce dr_mode property
> 5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

sounds good to me, please make sure to always split your series like
this. You can't expect me (or any maintainer for that matter) to pick
patches to proper branches based on your commit logs alone.

remeber that every single maintainer needs to handle hundreds of emails
a week (if not a day) and if patches are properly split and cleanly
mention if it's a bugfix or not, things will go wrong.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 02:42 PM, Felipe Balbi wrote:
>> That'll be these 3 branches then:
>>
>> otg-for-v3.9 (bugfix for v3.9):
>> 6bef020 USB otg: use try_module_get in all usb_get_phy functions and add 
>> missing module_put
>>
>> otg-for-v3.10 (depends on otg-for-v3.9):
>> a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
>> a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
>> 8a4c9f8 USB mxs-phy: Register phy with framework
>>
>> chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
>> 15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
>> 9466e85 USB chipidea: add PTW and PTS handling
>> ad2cc0d USB chipidea: introduce dual role mode pdata flags
>> 8e7f1bb USB chipidea i.MX: introduce dr_mode property
>> 5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
> 
> sounds good to me, please make sure to always split your series like
> this. You can't expect me (or any maintainer for that matter) to pick
> patches to proper branches based on your commit logs alone.
> 
> remeber that every single maintainer needs to handle hundreds of emails
> a week (if not a day) and if patches are properly split and cleanly
> mention if it's a bugfix or not, things will go wrong.

That was just a proposal. You'll find these series in your inbox in a
few minutes.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


mfd: omap-usb-host: bug fix for 3.9

2013-02-27 Thread Roger Quadros
Hi Samuel,

One of my patch that I sent for 3.9 introduces a bug that fails to
update the port mode hostconfig register. Because of that, the port modes will
always be 0 (i.e. EHCI PHY mode) and other modes will not work. PHY mode will
work, so beagle/panda have no issues.

Since my hardware setup uses only PHY mode, I couldn't catch this problem 
earlier.

Below is the fix.

>From 82466757a212bd8b54d806c9d56b1acccbd4d464 Mon Sep 17 00:00:00 2001
From: Roger Quadros 
Date: Wed, 27 Feb 2013 15:19:24 +0200
Subject: [PATCH] mfd: omap-usb-host: Actually update hostconfig

The helper functions omap_usbhs_rev1_hostconfig()
and omap_usbhs_rev2_hostconfig() don't write into
the hostconfig register. Make sure that we write
the return value into the hostconfig register.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 6b5edf6..4febc5c 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -460,15 +460,15 @@ static void omap_usbhs_init(struct device *dev)
 
switch (omap->usbhs_rev) {
case OMAP_USBHS_REV1:
-   omap_usbhs_rev1_hostconfig(omap, reg);
+   reg = omap_usbhs_rev1_hostconfig(omap, reg);
break;
 
case OMAP_USBHS_REV2:
-   omap_usbhs_rev2_hostconfig(omap, reg);
+   reg = omap_usbhs_rev2_hostconfig(omap, reg);
break;
 
default:/* newer revisions */
-   omap_usbhs_rev2_hostconfig(omap, reg);
+   reg = omap_usbhs_rev2_hostconfig(omap, reg);
break;
}
 
-- 
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: option: use vendor match for Huawei "ACM" devices

2013-02-27 Thread Bjørn Mork
There seem to be an "infinite" number of these devices.  Replacing
the individual device entry with a vendor rule to catch them all,
adding a safeguard test to the probe function in case the same
vendor ID is used for e.g. RNDIS devices.

This adds support for the Huawei E5331 and an unknown number of
similar devices.

Cc: stable 
Signed-off-by: Bjørn Mork 
---
 drivers/usb/serial/option.c |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index f7d339d..0ee8b8d 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -578,18 +578,15 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) },
{ USB_DEVICE(QUANTA_VENDOR_ID, 0xea42),
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
-   { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c05, 
USB_CLASS_COMM, 0x02, 0xff) },
-   { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, 
USB_CLASS_COMM, 0x02, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 
0xff, 0xff, 0xff),
.driver_info = (kernel_ulong_t) &net_intf1_blacklist },
-   { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, 
USB_CLASS_COMM, 0x02, 0xff) },
-   { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1442, 
USB_CLASS_COMM, 0x02, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 
0xff, 0xff, 0xff),
.driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 
0xff, 0xff, 0xff),
.driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4605, 
0xff, 0xff, 0xff),
.driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_COMM, 0x02, 
0xff) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0xff, 0xff) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x01) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x02) },
@@ -1447,6 +1444,19 @@ static int option_probe(struct usb_serial *serial,
iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
return -ENODEV;
 
+   /*
+* CDC ACM with vendor specific protocol may signify RNDIS or
+* serial or something else.  A number of Huawei devices use
+* it for serial functions having only 2 endpoints, which
+* cannot possibly be RNDIS or supported by the cdc-acm driver.
+*/
+   if (dev_desc->idVendor == cpu_to_le16(HUAWEI_VENDOR_ID) &&
+   iface_desc->bInterfaceClass == USB_CLASS_COMM &&
+   iface_desc->bInterfaceSubClass == 0x02 &&
+   iface_desc->bInterfaceProtocol == 0xff &&
+   iface_desc->bNumEndpoints != 2)
+   return -ENODEV;
+
/* Store device id so we can use it during attach. */
usb_set_serial_data(serial, (void *)id);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Marc Kleine-Budde
In patch "5d3c28b usb: otg: add device tree support to otg library"
devm_usb_get_phy_by_phandle() was added. It uses try_module_get() to lock the
phy driver in memory. The corresponding module_put() is missing in that patch.

This patch adds try_module_get() to usb_get_phy() and usb_get_phy_dev().
Further the missing module_put() is added to usb_put_phy().

Reviewed-by: Kishon Vijay Abraham I 
Acked-by: Felipe Balbi 
Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Michael Grzeschik 
---
 drivers/usb/otg/otg.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index e181439..2bd03d2 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -130,7 +130,7 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type)
spin_lock_irqsave(&phy_lock, flags);
 
phy = __usb_find_phy(&phy_list, type);
-   if (IS_ERR(phy)) {
+   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
pr_err("unable to find transceiver of type %s\n",
usb_phy_type_string(type));
goto err0;
@@ -228,7 +228,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 
index)
spin_lock_irqsave(&phy_lock, flags);
 
phy = __usb_find_phy_dev(dev, &phy_bind_list, index);
-   if (IS_ERR(phy)) {
+   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
pr_err("unable to find transceiver\n");
goto err0;
}
@@ -301,8 +301,12 @@ EXPORT_SYMBOL(devm_usb_put_phy);
  */
 void usb_put_phy(struct usb_phy *x)
 {
-   if (x)
+   if (x) {
+   struct module *owner = x->dev->driver->owner;
+
put_device(x->dev);
+   module_put(owner);
+   }
 }
 EXPORT_SYMBOL(usb_put_phy);
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] otg-for-v3.9-v1: USB otg: fix usage of try_module_get() and module_put()

2013-02-27 Thread Marc Kleine-Budde
Hello,

this patch is intended for v3.9 and applies to Greg's usb/master tree. If fixes
the use of try_module_get() and module_put() in all usb_get_phy functions.

regards,
Marc


The following changes since commit 74e1a2a39355b2d3ae8c60c78d8add162c6d7183:

  Merge tag 'usb-3.9-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb (2013-02-21 12:20:00 
-0800)

are available in the git repository at:


  git://git.pengutronix.de/git/mkl/linux.git tags/otg-for-v3.9-v1

for you to fetch changes up to 6bef020b4aebd7886281fb7fb37c788d5a365eea:

  USB otg: use try_module_get in all usb_get_phy functions and add missing 
module_put (2013-02-27 12:53:15 +0100)


USB otg: add missing try_module_get and module_put

Add try_module_get() to usb_get_phy() and usb_get_phy_dev().  Further the
missing module_put() is added to usb_put_phy()


Marc Kleine-Budde (1):
  USB otg: use try_module_get in all usb_get_phy functions and add missing 
module_put

 drivers/usb/otg/otg.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Build break on usb-next with exynos_defconfig

2013-02-27 Thread Vivek Gautam
Hi,


Trying to compile 'usb-next' branch with exynos_defconfig, but hit
upon compilation error.

arch/arm/plat-samsung/dma-ops.c: In function 'samsung_dmadev_request':
arch/arm/plat-samsung/dma-ops.c:39: error: implicit declaration of
function 'dma_request_slave_channel'
make[1]: *** [arch/arm/plat-samsung/dma-ops.o] Error 1
make[1]: *** Waiting for unfinished jobs

Anyone noticed this ?

I tried git bisecting and get following result.

e7ba5f1d0f6292e1b99c63cc4bb74c70232e9065 is the first bad commit
commit e7ba5f1d0f6292e1b99c63cc4bb74c70232e9065
Author: Padmavathi Venna 
Date:   Fri Jan 18 17:17:02 2013 +0530

ARM: SAMSUNG: Make dma request compatible to generic dma bindings.

This patch make the dma dev request operation compatible for both
DT and non-DT cases. It takes the all the arguments required for
dma_request_slave_channel and dma_request_channel. If the driver
is initiated via DT or non-DT the corresponding call will be made.

Signed-off-by: Padmavathi Venna 
Signed-off-by: Mark Brown 

:04 04 3a6948e1d7fee3cfa84a3cf4b0065d87301b79f2
b4ee1e9354a7bd9b223ea78c4c98950504951cb3 M  arch



-- 
Thanks & Regards
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] otg-for-v3.10-v1: separate phy code and add DT helper

2013-02-27 Thread Marc Kleine-Budde
Hello,

this series depends on the bugfix patch "USB otg: use try_module_get in all
usb_get_phy functions and add missing module_put" (a.k.a tags/otg-for-v3.9-v1)
posted earlier and is inteded for v3.10. It separates the phy from the otg code
and adds DT helper functions. Further mxs-phy uses the new usb_add_phy_dev()
function to register it's phy.

regards,
Marc


The following changes since commit 6bef020b4aebd7886281fb7fb37c788d5a365eea:

  USB otg: use try_module_get in all usb_get_phy functions and add missing 
module_put (2013-02-27 12:53:15 +0100)

are available in the git repository at:

  git://git.pengutronix.de/git/mkl/linux.git tags/otg-for-v3.10-v1

for you to fetch changes up to 8a4c9f8489b2fce9e7bf0eb43fdb160ab51adc2c:

  USB mxs-phy: Register phy with framework (2013-02-27 13:48:21 +0100)


USB otg, phy: separate phy and add DT helper

Move phy related code into separate file and add device tree helper functions.


Michael Grzeschik (1):
  USB: add devicetree helpers for determining dr_mode and phy_type

Sascha Hauer (2):
  USB: move bulk of otg/otg.c to phy/phy.c
  USB mxs-phy: Register phy with framework

 drivers/usb/otg/mxs-phy.c |9 +
 drivers/usb/otg/otg.c |  427 ---
 drivers/usb/phy/Makefile  |2 +
 drivers/usb/phy/of.c  |   47 +
 drivers/usb/phy/phy.c |  438 +
 drivers/usb/usb-common.c  |   37 
 include/linux/usb/of.h|   27 +++
 include/linux/usb/otg.h   |8 +
 include/linux/usb/phy.h   |9 +
 9 files changed, 577 insertions(+), 427 deletions(-)
 create mode 100644 drivers/usb/phy/of.c
 create mode 100644 drivers/usb/phy/phy.c
 create mode 100644 include/linux/usb/of.h


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] USB: add devicetree helpers for determining dr_mode and phy_type

2013-02-27 Thread Marc Kleine-Budde
From: Michael Grzeschik 

This adds two little devicetree helper functions for determining the dr_mode
(host, peripheral, otg, dual-role) and phy_type (utmi, ulpi,...) from the
devicetree.

Cc: Felipe Balbi 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/phy/Makefile |1 +
 drivers/usb/phy/of.c |   47 ++
 drivers/usb/usb-common.c |   37 
 include/linux/usb/of.h   |   27 ++
 include/linux/usb/otg.h  |8 
 include/linux/usb/phy.h  |9 +
 6 files changed, 129 insertions(+)
 create mode 100644 drivers/usb/phy/of.c
 create mode 100644 include/linux/usb/of.h

diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 9fa6327..e1be1e8 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,6 +5,7 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_OTG_UTILS)+= phy.o
+obj-$(CONFIG_OF)   += of.o
 obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o
 obj-$(CONFIG_OMAP_USB3)+= omap-usb3.o
 obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o
diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
new file mode 100644
index 000..e6f3b74
--- /dev/null
+++ b/drivers/usb/phy/of.c
@@ -0,0 +1,47 @@
+/*
+ * USB of helper code
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static const char *usbphy_modes[] = {
+   [USBPHY_INTERFACE_MODE_UNKNOWN] = "",
+   [USBPHY_INTERFACE_MODE_UTMI]= "utmi",
+   [USBPHY_INTERFACE_MODE_UTMIW]   = "utmi_wide",
+   [USBPHY_INTERFACE_MODE_ULPI]= "ulpi",
+   [USBPHY_INTERFACE_MODE_SERIAL]  = "serial",
+   [USBPHY_INTERFACE_MODE_HSIC]= "hsic",
+};
+
+/**
+ * of_usb_get_phy_mode - Get phy mode for given device_node
+ * @np:Pointer to the given device_node
+ *
+ * The function gets phy interface string from property 'phy_type',
+ * and returns the correspondig enum usb_phy_interface
+ */
+enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
+{
+   const char *phy_type;
+   int err, i;
+
+   err = of_property_read_string(np, "phy_type", &phy_type);
+   if (err < 0)
+   return USBPHY_INTERFACE_MODE_UNKNOWN;
+
+   for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
+   if (!strcmp(phy_type, usbphy_modes[i]))
+   return i;
+
+   return USBPHY_INTERFACE_MODE_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
index d29503e..18b994b 100644
--- a/drivers/usb/usb-common.c
+++ b/drivers/usb/usb-common.c
@@ -14,6 +14,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 const char *usb_speed_string(enum usb_device_speed speed)
 {
@@ -32,4 +35,38 @@ const char *usb_speed_string(enum usb_device_speed speed)
 }
 EXPORT_SYMBOL_GPL(usb_speed_string);
 
+#ifdef CONFIG_OF
+static const char *usb_dr_modes[] = {
+   [USB_DR_MODE_UNKNOWN]   = "",
+   [USB_DR_MODE_HOST]  = "host",
+   [USB_DR_MODE_PERIPHERAL]= "peripheral",
+   [USB_DR_MODE_OTG]   = "otg",
+   [USB_DR_MODE_DUAL_ROLE] = "dual-role",
+};
+
+/**
+ * of_usb_get_dr_mode - Get dual role mode for given device_node
+ * @np:Pointer to the given device_node
+ *
+ * The function gets phy interface string from property 'dr_mode',
+ * and returns the correspondig enum usb_dr_mode
+ */
+enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
+{
+   const char *dr_mode;
+   int err, i;
+
+   err = of_property_read_string(np, "dr_mode", &dr_mode);
+   if (err < 0)
+   return USB_DR_MODE_UNKNOWN;
+
+   for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
+   if (!strcmp(dr_mode, usb_dr_modes[i]))
+   return i;
+
+   return USB_DR_MODE_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
+#endif
+
 MODULE_LICENSE("GPL");
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
new file mode 100644
index 000..4681a20
--- /dev/null
+++ b/include/linux/usb/of.h
@@ -0,0 +1,27 @@
+/*
+ * OF helpers for usb devices.
+ *
+ * This file is released under the GPLv2
+ */
+
+#ifndef __LINUX_USB_OF_H
+#define __LINUX_USB_OF_H
+
+#include 
+
+#ifdef CONFIG_OF
+enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
+enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
+#else
+static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node 
*np)
+{
+   return USBPHY_INTERFACE_MODE_UNKNOWN;
+}
+
+static inline enum

[PATCH 1/3] USB: move bulk of otg/otg.c to phy/phy.c

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

Most of otg/otg.c is not otg specific, but phy specific, so move it
to the phy directory.

Cc: Felipe Balbi 
Reported-by: Kishon Vijay Abraham I 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/otg/otg.c|  427 
 drivers/usb/phy/Makefile |1 +
 drivers/usb/phy/phy.c|  438 ++
 3 files changed, 439 insertions(+), 427 deletions(-)
 create mode 100644 drivers/usb/phy/phy.c

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 2bd03d2..358cfd9 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -8,436 +8,9 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  */
-
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include 
 
-static LIST_HEAD(phy_list);
-static LIST_HEAD(phy_bind_list);
-static DEFINE_SPINLOCK(phy_lock);
-
-static struct usb_phy *__usb_find_phy(struct list_head *list,
-   enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-
-   list_for_each_entry(phy, list, head) {
-   if (phy->type != type)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static struct usb_phy *__usb_find_phy_dev(struct device *dev,
-   struct list_head *list, u8 index)
-{
-   struct usb_phy_bind *phy_bind = NULL;
-
-   list_for_each_entry(phy_bind, list, list) {
-   if (!(strcmp(phy_bind->dev_name, dev_name(dev))) &&
-   phy_bind->index == index) {
-   if (phy_bind->phy)
-   return phy_bind->phy;
-   else
-   return ERR_PTR(-EPROBE_DEFER);
-   }
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static struct usb_phy *__of_usb_find_phy(struct device_node *node)
-{
-   struct usb_phy  *phy;
-
-   list_for_each_entry(phy, &phy_list, head) {
-   if (node != phy->dev->of_node)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static void devm_usb_phy_release(struct device *dev, void *res)
-{
-   struct usb_phy *phy = *(struct usb_phy **)res;
-
-   usb_put_phy(phy);
-}
-
-static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
-{
-   return res == match_data;
-}
-
-/**
- * devm_usb_get_phy - find the USB PHY
- * @dev - device that requests this phy
- * @type - the type of the phy the controller requires
- *
- * Gets the phy using usb_get_phy(), and associates a device with it using
- * devres. On driver detach, release function is invoked on the devres data,
- * then, devres data is freed.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
-{
-   struct usb_phy **ptr, *phy;
-
-   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
-   if (!ptr)
-   return NULL;
-
-   phy = usb_get_phy(type);
-   if (!IS_ERR(phy)) {
-   *ptr = phy;
-   devres_add(dev, ptr);
-   } else
-   devres_free(ptr);
-
-   return phy;
-}
-EXPORT_SYMBOL(devm_usb_get_phy);
-
-/**
- * usb_get_phy - find the USB PHY
- * @type - the type of the phy the controller requires
- *
- * Returns the phy driver, after getting a refcount to it; or
- * -ENODEV if there is no such phy.  The caller is responsible for
- * calling usb_put_phy() to release that count.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *usb_get_phy(enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-   unsigned long   flags;
-
-   spin_lock_irqsave(&phy_lock, flags);
-
-   phy = __usb_find_phy(&phy_list, type);
-   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
-   pr_err("unable to find transceiver of type %s\n",
-   usb_phy_type_string(type));
-   goto err0;
-   }
-
-   get_device(phy->dev);
-
-err0:
-   spin_unlock_irqrestore(&phy_lock, flags);
-
-   return phy;
-}
-EXPORT_SYMBOL(usb_get_phy);
-
- /**
- * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
- * @dev - device that requests this phy
- * @phandle - name of the property holding the phy phandle value
- * @index - the index of the phy
- *
- * Returns the phy driver associated with the given phandle value,
- * after getting a refcount to it, -ENODEV if there is no such phy or
- * -EPROBE_DEFER if there is a phandle to the phy, but the device is
- * not yet loaded. While at that, it also associates the device with
- * the phy using devres. On driver detach, release function is invoked
- * on the devres data, then, devres data is freed.
- *
- * For use by USB host and peripheral drivers.
- */
-struc

[PATCH 3/3] USB mxs-phy: Register phy with framework

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

We now have usb_add_phy_dev(), so use it to register with the framework
to be able to find the phy from the USB driver.

Reviewed-by: Kishon Vijay Abraham I 
Reviewed-by: Peter Chen 
Acked-by: Felipe Balbi 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/otg/mxs-phy.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index b0d9f11..aa40325 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -127,6 +127,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
void __iomem *base;
struct clk *clk;
struct mxs_phy *mxs_phy;
+   int ret;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
@@ -166,11 +167,19 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, &mxs_phy->phy);
 
+   ret = usb_add_phy_dev(&mxs_phy->phy);
+   if (ret)
+   return ret;
+
return 0;
 }
 
 static int mxs_phy_remove(struct platform_device *pdev)
 {
+   struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
+
+   usb_remove_phy(&mxs_phy->phy);
+
platform_set_drvdata(pdev, NULL);
 
return 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: option: use vendor match for Huawei "ACM" devices

2013-02-27 Thread Bjørn Mork
Bjørn Mork  writes:

> +  * CDC ACM with vendor specific protocol may signify RNDIS or
> +  * serial or something else.  A number of Huawei devices use
> +  * it for serial functions having only 2 endpoints, 

Arrgh. Please drop this patch.

I thought I had verified this over and over again for a couple of weeks,
but I do of course discover the problem minutes after posting...

The 2 endpoint assumption is not always true:

$ lsusb -v -d 12d1:1c05

Bus 002 Device 005: ID 12d1:1c05 Huawei Technologies Co., Ltd.
Couldn't open device, some information will be missing
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize064
  idVendor   0x12d1 Huawei Technologies Co., Ltd.
  idProduct  0x1c05
  bcdDevice1.02
  iManufacturer   2
  iProduct1
  iSerial 0
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength  142
bNumInterfaces  3
bConfigurationValue 1
iConfiguration  0
bmAttributes 0x80
  (Bus Powered)
MaxPower  500mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   3
  bInterfaceClass 2 Communications
  bInterfaceSubClass  2 Abstract (modem)
  bInterfaceProtocol255 Vendor Specific (MSFT RNDIS?)
  iInterface  0
  CDC Header:
bcdCDC   1.10
  CDC ACM:
bmCapabilities   0x03
  line coding and serial state
  get/set/clear comm features



Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] USB chipidea: add PTW and PTS handling

2013-02-27 Thread Marc Kleine-Budde
From: Michael Grzeschik 

This patch makes it possible to configure the PTW and PTS bits inside
the portsc register for host and device mode before the driver starts
and the phy can be addressed as hardware implementation is designed.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +++
 drivers/usb/chipidea/bits.h|   14 ++-
 drivers/usb/chipidea/ci13xxx_imx.c |3 ++
 drivers/usb/chipidea/core.c|   39 
 include/linux/usb/chipidea.h   |1 +
 5 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 5778b9c..dd42ccd 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -5,6 +5,11 @@ Required properties:
 - reg: Should contain registers location and length
 - interrupts: Should contain controller interrupt
 
+Recommended properies:
+- phy_type: the type of the phy connected to the core. Should be one
+  of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
+  property the PORTSC register won't be touched
+
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
 - fsl,usbmisc: phandler of non-core register device, with one argument
diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 050de85..d8ffc2f 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -48,10 +48,22 @@
 #define PORTSC_SUSP   BIT(7)
 #define PORTSC_HSPBIT(9)
 #define PORTSC_PTC(0x0FUL << 16)
+/* PTS and PTW for non lpm version only */
+#define PORTSC_PTS(d) d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 
0))
+#define PORTSC_PTWBIT(28)
 
 /* DEVLC */
 #define DEVLC_PSPD(0x03UL << 25)
-#defineDEVLC_PSPD_HS  (0x02UL << 25)
+#define DEVLC_PSPD_HS (0x02UL << 25)
+#define DEVLC_PTW BIT(27)
+#define DEVLC_STS BIT(28)
+#define DEVLC_PTS(d)  (((d) & 0x7) << 29)
+
+/* Encoding for DEVLC_PTS and PORTSC_PTS */
+#define PTS_UTMI  0
+#define PTS_ULPI  2
+#define PTS_SERIAL3
+#define PTS_HSIC  4
 
 /* OTGSC */
 #define OTGSC_IDPU   BIT(5)
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 69024e0..ebc1148 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ci.h"
 #include "ci13xxx_imx.h"
@@ -112,6 +113,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
   CI13XXX_PULLUP_ON_VBUS |
   CI13XXX_DISABLE_STREAMING;
 
+   pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);
+
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n");
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 57cae1f..04d68cb 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -67,6 +67,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "ci.h"
 #include "udc.h"
@@ -211,6 +213,41 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem 
*base)
return 0;
 }
 
+static void hw_phymode_configure(struct ci13xxx *ci)
+{
+   u32 portsc, lpm;
+
+   switch (ci->platdata->phy_mode) {
+   case USBPHY_INTERFACE_MODE_UTMI:
+   portsc = PORTSC_PTS(PTS_UTMI);
+   lpm = DEVLC_PTS(PTS_UTMI);
+   break;
+   case USBPHY_INTERFACE_MODE_UTMIW:
+   portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW;
+   lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW;
+   break;
+   case USBPHY_INTERFACE_MODE_ULPI:
+   portsc = PORTSC_PTS(PTS_ULPI);
+   lpm = DEVLC_PTS(PTS_ULPI);
+   break;
+   case USBPHY_INTERFACE_MODE_SERIAL:
+   portsc = PORTSC_PTS(PTS_SERIAL);
+   lpm = DEVLC_PTS(PTS_SERIAL);
+   break;
+   case USBPHY_INTERFACE_MODE_HSIC:
+   portsc = PORTSC_PTS(PTS_HSIC);
+   lpm = DEVLC_PTS(PTS_HSIC);
+   break;
+   default:
+   return;
+   }
+
+   if (ci->hw_bank.lpm)
+   hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
+   else
+   hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
+}
+
 /**
  * hw_device_reset: resets chip (execute without interruption)
  * @ci: the controller
@@ -476,6 +513,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
: CI_ROLE_GADG

[PATCH 4/5] USB chipidea i.MX: introduce dr_mode property

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

The dr_mode devicetree property allows to explicitly specify the
host/peripheral/otg mode. This is necessary for boards without proper
ID pin handling.

Reviewed-by: Peter Chen 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 Documentation/devicetree/bindings/usb/ci13xxx-imx.txt |1 +
 drivers/usb/chipidea/ci13xxx_imx.c|1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index dd42ccd..493a414 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -9,6 +9,7 @@ Recommended properies:
 - phy_type: the type of the phy connected to the core. Should be one
   of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
   property the PORTSC register won't be touched
+- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index ebc1148..b598bb8 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -114,6 +114,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
   CI13XXX_DISABLE_STREAMING;
 
pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);
+   pdata->dr_mode = of_usb_get_dr_mode(pdev->dev.of_node);
 
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver

2013-02-27 Thread Marc Kleine-Budde
Hello,

this series depends on the series "[PATCH 0/3] otg-for-v3.10-v1: separate phy
code and add DT helper" (a.k.a. tags/otg-for-v3.10-v1) posted earlier and is
intended for v3.10. The chipidea driver is converted to make use of the DT
helper functions.

regards,
Marc


The following changes since commit 8a4c9f8489b2fce9e7bf0eb43fdb160ab51adc2c:

  USB mxs-phy: Register phy with framework (2013-02-27 13:48:21 +0100)

are available in the git repository at:

  git://git.pengutronix.de/git/mkl/linux.git tags/chipidea-for-v3.10-v1

for you to fetch changes up to 5d837224ea36da50f3e744a65fb23af1fa0a480d:

  USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy (2013-02-27 
13:49:07 +0100)


USB chipidea: make use of DT helpers in chipidea driver

Make use of DT helper functions for handling the dr_mode and phy_type property.


Michael Grzeschik (2):
  USB chipidea: ci13xxx-imx: create dynamic platformdata
  USB chipidea: add PTW and PTS handling

Sascha Hauer (3):
  USB chipidea: introduce dual role mode pdata flags
  USB chipidea i.MX: introduce dr_mode property
  USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

 .../devicetree/bindings/usb/ci13xxx-imx.txt|6 ++
 drivers/usb/chipidea/bits.h|   14 +++-
 drivers/usb/chipidea/ci13xxx_imx.c |   67 +++-
 drivers/usb/chipidea/core.c|   61 --
 include/linux/usb/chipidea.h   |3 +-
 5 files changed, 112 insertions(+), 39 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata

2013-02-27 Thread Marc Kleine-Budde
From: Michael Grzeschik 

This patch removes the limitation of having only one instance of the
ci13xxx-imx platformdata and makes different configurations possible.

Reviewed-by: Peter Chen 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/ci13xxx_imx.c |   25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 8c29122..69024e0 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
 
 /* End of common functions shared by usbmisc drivers*/
 
-static struct ci13xxx_platform_data ci13xxx_imx_platdata  = {
-   .name   = "ci13xxx_imx",
-   .flags  = CI13XXX_REQUIRE_TRANSCEIVER |
- CI13XXX_PULLUP_ON_VBUS |
- CI13XXX_DISABLE_STREAMING,
-   .capoffset  = DEF_CAPOFFSET,
-};
-
 static int ci13xxx_imx_probe(struct platform_device *pdev)
 {
struct ci13xxx_imx_data *data;
+   struct ci13xxx_platform_data *pdata;
struct platform_device *plat_ci, *phy_pdev;
struct device_node *phy_np;
struct resource *res;
@@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
&& !usbmisc_ops)
return -EPROBE_DEFER;
 
+   pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata) {
+   dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n");
+   return -ENOMEM;
+   }
+
+   pdata->name = "ci13xxx_imx";
+   pdata->capoffset = DEF_CAPOFFSET;
+   pdata->flags = CI13XXX_REQUIRE_TRANSCEIVER |
+  CI13XXX_PULLUP_ON_VBUS |
+  CI13XXX_DISABLE_STREAMING;
+
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n");
@@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
reg_vbus = NULL;
}
 
-   ci13xxx_imx_platdata.phy = data->phy;
+   pdata->phy = data->phy;
 
if (!pdev->dev.dma_mask) {
pdev->dev.dma_mask = devm_kzalloc(&pdev->dev,
@@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 
plat_ci = ci13xxx_add_device(&pdev->dev,
pdev->resource, pdev->num_resources,
-   &ci13xxx_imx_platdata);
+   pdata);
if (IS_ERR(plat_ci)) {
ret = PTR_ERR(plat_ci);
dev_err(&pdev->dev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

This patch replaces the hand crafted code to retrieve the phy's phandle from
the DT by the helper function devm_usb_get_phy_by_phandle() which has been
added in commit:

"5d3c28b usb: otg: add device tree support to otg library"

Reviewed-by: Kishon Vijay Abraham I 
Reviewed-by: Peter Chen 
Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/ci13xxx_imx.c |   38 
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index b598bb8..6e720ce 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -30,7 +30,6 @@
((struct usb_phy *)platform_get_drvdata(pdev))
 
 struct ci13xxx_imx_data {
-   struct device_node *phy_np;
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
@@ -90,12 +89,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 {
struct ci13xxx_imx_data *data;
struct ci13xxx_platform_data *pdata;
-   struct platform_device *plat_ci, *phy_pdev;
-   struct device_node *phy_np;
+   struct platform_device *plat_ci;
struct resource *res;
struct regulator *reg_vbus;
struct pinctrl *pinctrl;
int ret;
+   struct usb_phy *phy;
 
if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL)
&& !usbmisc_ops)
@@ -147,19 +146,20 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
return ret;
}
 
-   phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0);
-   if (phy_np) {
-   data->phy_np = phy_np;
-   phy_pdev = of_find_device_by_node(phy_np);
-   if (phy_pdev) {
-   struct usb_phy *phy;
-   phy = pdev_to_phy(phy_pdev);
-   if (phy &&
-   try_module_get(phy_pdev->dev.driver->owner)) {
-   usb_phy_init(phy);
-   data->phy = phy;
-   }
+   phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0);
+   if (PTR_ERR(phy) == -EPROBE_DEFER) {
+   ret = -EPROBE_DEFER;
+   goto err_clk;
+   }
+
+   if (!IS_ERR(phy)) {
+   ret = usb_phy_init(phy);
+   if (ret) {
+   dev_err(&pdev->dev, "unable to init phy: %d\n", ret);
+   goto err_clk;
}
+
+   data->phy = phy;
}
 
/* we only support host now, so enable vbus here */
@@ -170,7 +170,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"Failed to enable vbus regulator, err=%d\n",
ret);
-   goto put_np;
+   goto err_clk;
}
data->reg_vbus = reg_vbus;
} else {
@@ -222,9 +222,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 err:
if (reg_vbus)
regulator_disable(reg_vbus);
-put_np:
-   if (phy_np)
-   of_node_put(phy_np);
+err_clk:
clk_disable_unprepare(data->clk);
return ret;
 }
@@ -244,8 +242,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)
module_put(data->phy->dev->driver->owner);
}
 
-   of_node_put(data->phy_np);
-
clk_disable_unprepare(data->clk);
 
platform_set_drvdata(pdev, NULL);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] USB chipidea: introduce dual role mode pdata flags

2013-02-27 Thread Marc Kleine-Budde
From: Sascha Hauer 

Even if a chipidea core is otg capable the board may not. This allows
to explicitly set the core to host/peripheral mode. Without these
flags the driver falls back to the old behaviour.

Signed-off-by: Sascha Hauer 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/core.c  |   22 --
 include/linux/usb/chipidea.h |2 +-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 04d68cb..ec27060 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -435,6 +435,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
struct resource *res;
void __iomem*base;
int ret;
+   enum usb_dr_mode dr_mode;
 
if (!dev->platform_data) {
dev_err(dev, "platform data missing\n");
@@ -487,14 +488,23 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+   /* For now we treat dual-role as otg */
+   dr_mode = ci->platdata->dr_mode;
+   if (dr_mode == USB_DR_MODE_UNKNOWN || dr_mode == USB_DR_MODE_DUAL_ROLE)
+   dr_mode = USB_DR_MODE_OTG;
+
/* initialize role(s) before the interrupt is requested */
-   ret = ci_hdrc_host_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support host\n");
+   if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
+   ret = ci_hdrc_host_init(ci);
+   if (ret)
+   dev_info(dev, "doesn't support host\n");
+   }
 
-   ret = ci_hdrc_gadget_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support gadget\n");
+   if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
+   ret = ci_hdrc_gadget_init(ci);
+   if (ret)
+   dev_info(dev, "doesn't support gadget\n");
+   }
 
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
dev_err(dev, "no supported roles\n");
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 1a2aa18..b314647 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -20,7 +20,7 @@ struct ci13xxx_platform_data {
 #define CI13XXX_REQUIRE_TRANSCEIVERBIT(1)
 #define CI13XXX_PULLUP_ON_VBUS BIT(2)
 #define CI13XXX_DISABLE_STREAMING  BIT(3)
-
+   enum usb_dr_modedr_mode;
 #define CI13XXX_CONTROLLER_RESET_EVENT 0
 #define CI13XXX_CONTROLLER_STOPPED_EVENT   1
void(*notify_event) (struct ci13xxx *ci, unsigned event);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] USB otg: use try_module_get in all usb_get_phy functions and add missing module_put

2013-02-27 Thread Marc Kleine-Budde
On 02/27/2013 02:55 PM, Marc Kleine-Budde wrote:
> On 02/27/2013 02:42 PM, Felipe Balbi wrote:
>>> That'll be these 3 branches then:
>>>
>>> otg-for-v3.9 (bugfix for v3.9):
>>> 6bef020 USB otg: use try_module_get in all usb_get_phy functions and add 
>>> missing module_put
>>>
>>> otg-for-v3.10 (depends on otg-for-v3.9):
>>> a0e17f5 USB: move bulk of otg/otg.c to phy/phy.c
>>> a6fc0d1 USB: add devicetree helpers for determining dr_mode and phy_type
>>> 8a4c9f8 USB mxs-phy: Register phy with framework
>>>
>>> chipidea-for-v3.10 (most patches depend on otg-for-v3.10):
>>> 15c930e USB chipidea: ci13xxx-imx: create dynamic platformdata
>>> 9466e85 USB chipidea: add PTW and PTS handling
>>> ad2cc0d USB chipidea: introduce dual role mode pdata flags
>>> 8e7f1bb USB chipidea i.MX: introduce dr_mode property
>>> 5d83722 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
>>
>> sounds good to me, please make sure to always split your series like
>> this. You can't expect me (or any maintainer for that matter) to pick
>> patches to proper branches based on your commit logs alone.
>>
>> remeber that every single maintainer needs to handle hundreds of emails
>> a week (if not a day) and if patches are properly split and cleanly
>> mention if it's a bugfix or not, things will go wrong.
> 
> That was just a proposal. You'll find these series in your inbox in a
> few minutes.

Done.

regards,
Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCHv2] usb/net/asix_devices: Add USBNET HG20F9 ethernet dongle

2013-02-27 Thread Glen Turner
This USB ethernet adapter was purchased in anodyne packaging
from the computer store adjacent to linux.conf.au 2013 in
Canberra (Australia). A web search shows other recent
purchasers in Lancaster (UK) and Seattle (USA). Just like an
emergent virus, our age of e-commerce and airmail allows
underdocumented hardware to spread around the world instantly
using the vector of ridiculously low prices.

Paige Thompson, infected via eBay, discovered that the HG20F9
is a copy of the Asix 88772B; many viruses copy the RNA of
other viruses. See Paige's work at
.
This patch uses her discovery to update the restructured Asix
driver in the current kernel.

Just as some viruses inhabit seemingly-healthy cells, the
HG20F9 uses the Vendor ID 0x066b assigned to Linksys Inc.
For the present there is no clash of Product ID 0x20f9.

Signed-off-by: Glen Turner 
---
David,

My apologies for the patch failing to compile. I worked off Linus' GIT tree
from a week ago, which I now realise was ignorant. Today I downloaded
,
modified the patch to suit, compiled with a distributor's .config (ten hours
on my EeePC 901), and re-tested against a range of switches and traffic.

Thanks to Bjørn Mork for the heads-up about comment coding style. I had
copied the style used throughout asix_devices.c but one never knows where
being on the bad side of an automated tool can lead, now that the creator
of the Daleks can no longer protect us from robots with rigid notions
of the acceptable and the exterminatable.

-glen

 drivers/net/usb/asix_devices.c |   31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 2205dbc..7097534 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -924,6 +924,29 @@ static const struct driver_info ax88178_info = {
.tx_fixup = asix_tx_fixup,
 };
 
+/*
+ * USBLINK 20F9 "USB 2.0 LAN" USB ethernet adapter, typically found in
+ * no-name packaging.
+ * USB device strings are:
+ *   1: Manufacturer: USBLINK
+ *   2: Product: HG20F9 USB2.0
+ *   3: Serial: 03
+ * Appears to be compatible with Asix 88772B.
+ */
+static const struct driver_info hg20f9_info = {
+   .description = "HG20F9 USB 2.0 Ethernet",
+   .bind = ax88772_bind,
+   .unbind = ax88772_unbind,
+   .status = asix_status,
+   .link_reset = ax88772_link_reset,
+   .reset = ax88772_reset,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |
+FLAG_MULTI_PACKET,
+   .rx_fixup = asix_rx_fixup_common,
+   .tx_fixup = asix_tx_fixup,
+   .data = FLAG_EEPROM_MAC,
+};
+
 extern const struct driver_info ax88172a_info;
 
 static const struct usb_device_id  products [] = {
@@ -1063,6 +1086,14 @@ static const struct usb_device_idproducts [] = {
/* ASIX 88172a demo board */
USB_DEVICE(0x0b95, 0x172a),
.driver_info = (unsigned long) &ax88172a_info,
+}, {
+   /*
+* USBLINK HG20F9 "USB 2.0 LAN"
+* Appears to have gazumped Linksys's manufacturer ID but
+* doesn't (yet) conflict with any known Linksys product.
+*/
+   USB_DEVICE(0x066b, 0x20f9),
+   .driver_info = (unsigned long) &hg20f9_info,
 },
{ },// END
 };
-- 
1.7.10.4



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v10 6/8] usb: chipidea: imx: add internal vbus regulator control

2013-02-27 Thread Darius Augulis
Hi balbi,

actually no. I don't work with this hardware any more and don't have
free time to support it.
Please feel free to remove it if it breaks other things.

Darius.


On Wed, Feb 27, 2013 at 10:36 AM, Felipe Balbi  wrote:
> Hi Darius,
>
> On Wed, Feb 27, 2013 at 04:13:14PM +0800, Peter Chen wrote:
>> On Wed, Feb 27, 2013 at 09:07:35AM +0100, Sascha Hauer wrote:
>> > On Wed, Feb 27, 2013 at 09:55:10AM +0200, Felipe Balbi wrote:
>> > > Hi,
>> > >
>> > > On Wed, Feb 27, 2013 at 02:33:17PM +0800, Peter Chen wrote:
>> > > > - For host, the vbus should always be on.
>> > > > - For otg, the vbus is off defaultly, the vbus needs to be
>> > > > turned on/off when usb role switches.
>> > > >
>> > > > Signed-off-by: Peter Chen 
>> > >
>> > > one quick question, if chipidea already has an imx glue layer, can I
>> > > delete the broken imx_udc ? It doesn't even compile and it's including
>> > > headers which don't exist.
>> >
>> > This driver handles i.MX1. This one has a gadget only core which is not
>> > chipidea compatible. You should ping Darius Augulis 
>> > 
>> > if he is willing to put some love into the driver.
>>
>> Sascha is correct.
>
> do you plan to put any work on drivers/usb/gadget/imx_udc.c ? It doesn't
> even compile since it includes headers which don't exist (and no,
> simply removing the include doesn't help).
>
> If nobody is going to work on that driver, I'm thinking about scheduling
> it for removal. We can't keep such drivers that nobody cares (and just
> break tree compilation) around.
>
> --
> balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 0/2] Adding USB 3.0 DRD-phy support for exynos5250

2013-02-27 Thread Vivek Gautam
Based on 'usb-next'

Changes from v5:
 - Squashed the following change from Felipe in this patch-set:
   [PATCH] usb: phy: samsung: let it be built as a module
 - Using EXPORT_SYMBOL_GPL() to export symbols in "samsung-usbphy.c"
   to allow module builds of these samsung PHY drivers.

Vivek Gautam (2):
  usb: phy: samsung: Common out the generic stuff
  usb: phy: samsung: Add PHY support for USB 3.0 controller

 drivers/usb/phy/Kconfig   |   25 +-
 drivers/usb/phy/Makefile  |2 +
 drivers/usb/phy/samsung-usb2phy.c |  511 ++
 drivers/usb/phy/samsung-usb3phy.c |  349 ++
 drivers/usb/phy/samsung-usbphy.c  |  722 +
 drivers/usb/phy/samsung-usbphy.h  |  328 +
 6 files changed, 1224 insertions(+), 713 deletions(-)
 create mode 100644 drivers/usb/phy/samsung-usb2phy.c
 create mode 100644 drivers/usb/phy/samsung-usb3phy.c
 create mode 100644 drivers/usb/phy/samsung-usbphy.h

-- 
1.7.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/2] usb: phy: samsung: Common out the generic stuff

2013-02-27 Thread Vivek Gautam
Moving register and structure definitions to header file,
and keeping the generic functions to be used across
multiple PHYs in common phy helper driver under SAMSUNG_USBPHY,
and moving USB 2.0 PHY driver under SAMSUNG_USB2PHY.

Also allowing samsung PHY drivers be built as modules.

Signed-off-by: Vivek Gautam 
Signed-off-by: Felipe Balbi 
Acked-by: Kukjin Kim 
---
 drivers/usb/phy/Kconfig   |   17 +-
 drivers/usb/phy/Makefile  |1 +
 drivers/usb/phy/samsung-usb2phy.c |  511 ++
 drivers/usb/phy/samsung-usbphy.c  |  722 +
 drivers/usb/phy/samsung-usbphy.h  |  247 +
 5 files changed, 785 insertions(+), 713 deletions(-)
 create mode 100644 drivers/usb/phy/samsung-usb2phy.c
 create mode 100644 drivers/usb/phy/samsung-usbphy.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 65217a5..4d72962 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -66,10 +66,17 @@ config USB_RCAR_PHY
  To compile this driver as a module, choose M here: the
  module will be called rcar-phy.
 
-config SAMSUNG_USBPHY
-   bool "Samsung USB PHY controller Driver"
-   depends on USB_S3C_HSOTG || USB_EHCI_S5P || USB_OHCI_EXYNOS
+config SAMSUNG_USB2PHY
+   tristate "Samsung USB 2.0 PHY controller Driver"
+   select SAMSUNG_USBPHY
select USB_OTG_UTILS
help
- Enable this to support Samsung USB phy controller for samsung
- SoCs.
+ Enable this to support Samsung USB 2.0 (High Speed) PHY controller
+ driver for Samsung SoCs.
+
+config SAMSUNG_USBPHY
+   tristate "Samsung USB PHY Driver"
+   help
+ Enable this to support Samsung USB phy helper driver for Samsung SoCs.
+ This driver provides common interface to interact, for Samsung USB 
2.0 PHY
+ driver and later for Samsung USB 3.0 PHY driver.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b13faa1..1efa174 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
 obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
+obj-$(CONFIG_SAMSUNG_USB2PHY)  += samsung-usb2phy.o
diff --git a/drivers/usb/phy/samsung-usb2phy.c 
b/drivers/usb/phy/samsung-usb2phy.c
new file mode 100644
index 000..55ac3a8
--- /dev/null
+++ b/drivers/usb/phy/samsung-usb2phy.c
@@ -0,0 +1,511 @@
+/* linux/drivers/usb/phy/samsung-usb2phy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 PHY transceiver; talks to S3C HS OTG controller, EHCI-S5P and
+ * OHCI-EXYNOS controllers.
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "samsung-usbphy.h"
+
+int samsung_usb2phy_set_host(struct usb_otg *otg, struct usb_bus *host)
+{
+   if (!otg)
+   return -ENODEV;
+
+   if (!otg->host)
+   otg->host = host;
+
+   return 0;
+}
+
+static bool exynos5_phyhost_is_on(void *regs)
+{
+   u32 reg;
+
+   reg = readl(regs + EXYNOS5_PHY_HOST_CTRL0);
+
+   return !(reg & HOST_CTRL0_SIDDQ);
+}
+
+static void samsung_exynos5_usb2phy_enable(struct samsung_usbphy *sphy)
+{
+   void __iomem *regs = sphy->regs;
+   u32 phyclk = sphy->ref_clk_freq;
+   u32 phyhost;
+   u32 phyotg;
+   u32 phyhsic;
+   u32 ehcictrl;
+   u32 ohcictrl;
+
+   /*
+* phy_usage helps in keeping usage count for phy
+* so that the first consumer enabling the phy is also
+* the last consumer to disable it.
+*/
+
+   atomic_inc(&sphy->phy_usage);
+
+   if (exynos5_phyhost_is_on(regs)) {
+   dev_info(sphy->dev, "Already power on PHY\n");
+   return;
+   }
+
+   /* Host configuration */
+   phyhost = readl(regs + EXYNOS5_PHY_HOST_CTRL0);
+
+   /* phy reference clock configuration */
+   phyhost &= ~HOST_CTRL0_FSEL_MASK;
+   phyhost |= HOST_CTRL0_FSEL(phyclk);
+
+   /* host phy reset */
+   phyhost &= ~(HOST_CTRL0_PHYSWRST |
+   HOST_CTRL0_PHYSWRSTALL |
+   HOST_CTRL0_SIDDQ |
+   /* Enable normal mode of operation */
+   HOST_CTRL0_FORCESUSPEND |
+

[PATCH v6 2/2] usb: phy: samsung: Add PHY support for USB 3.0 controller

2013-02-27 Thread Vivek Gautam
Adding PHY driver support for USB 3.0 controller for Samsung's
SoCs.

Signed-off-by: Vivek Gautam 
Signed-off-by: Felipe Balbi 
Acked-by: Kukjin Kim 
---
 drivers/usb/phy/Kconfig   |8 +
 drivers/usb/phy/Makefile  |1 +
 drivers/usb/phy/samsung-usb3phy.c |  349 +
 drivers/usb/phy/samsung-usbphy.h  |   81 +
 4 files changed, 439 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/phy/samsung-usb3phy.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 4d72962..4f696d0 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -74,6 +74,14 @@ config SAMSUNG_USB2PHY
  Enable this to support Samsung USB 2.0 (High Speed) PHY controller
  driver for Samsung SoCs.
 
+config SAMSUNG_USB3PHY
+   tristate "Samsung USB 3.0 PHY controller Driver"
+   select SAMSUNG_USBPHY
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB 3.0 (Super Speed) phy controller
+ for samsung SoCs.
+
 config SAMSUNG_USBPHY
tristate "Samsung USB PHY Driver"
help
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1efa174..77f0b2e 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
 obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
 obj-$(CONFIG_SAMSUNG_USB2PHY)  += samsung-usb2phy.o
+obj-$(CONFIG_SAMSUNG_USB3PHY)  += samsung-usb3phy.o
diff --git a/drivers/usb/phy/samsung-usb3phy.c 
b/drivers/usb/phy/samsung-usb3phy.c
new file mode 100644
index 000..70e2c7b
--- /dev/null
+++ b/drivers/usb/phy/samsung-usb3phy.c
@@ -0,0 +1,349 @@
+/* linux/drivers/usb/phy/samsung-usb3phy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Vivek Gautam 
+ *
+ * Samsung USB 3.0 PHY transceiver; talks to DWC3 controller.
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "samsung-usbphy.h"
+
+/*
+ * Sets the phy clk as EXTREFCLK (XXTI) which is internal clock from clock 
core.
+ */
+static u32 samsung_usb3phy_set_refclk(struct samsung_usbphy *sphy)
+{
+   u32 reg;
+   u32 refclk;
+
+   refclk = sphy->ref_clk_freq;
+
+   reg = PHYCLKRST_REFCLKSEL_EXT_REFCLK |
+   PHYCLKRST_FSEL(refclk);
+
+   switch (refclk) {
+   case FSEL_CLKSEL_50M:
+   reg |= (PHYCLKRST_MPLL_MULTIPLIER_50M_REF |
+   PHYCLKRST_SSC_REFCLKSEL(0x00));
+   break;
+   case FSEL_CLKSEL_20M:
+   reg |= (PHYCLKRST_MPLL_MULTIPLIER_20MHZ_REF |
+   PHYCLKRST_SSC_REFCLKSEL(0x00));
+   break;
+   case FSEL_CLKSEL_19200K:
+   reg |= (PHYCLKRST_MPLL_MULTIPLIER_19200KHZ_REF |
+   PHYCLKRST_SSC_REFCLKSEL(0x88));
+   break;
+   case FSEL_CLKSEL_24M:
+   default:
+   reg |= (PHYCLKRST_MPLL_MULTIPLIER_24MHZ_REF |
+   PHYCLKRST_SSC_REFCLKSEL(0x88));
+   break;
+   }
+
+   return reg;
+}
+
+static int samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy)
+{
+   void __iomem *regs = sphy->regs;
+   u32 phyparam0;
+   u32 phyparam1;
+   u32 linksystem;
+   u32 phybatchg;
+   u32 phytest;
+   u32 phyclkrst;
+
+   /* Reset USB 3.0 PHY */
+   writel(0x0, regs + EXYNOS5_DRD_PHYREG0);
+
+   phyparam0 = readl(regs + EXYNOS5_DRD_PHYPARAM0);
+   /* Select PHY CLK source */
+   phyparam0 &= ~PHYPARAM0_REF_USE_PAD;
+   /* Set Loss-of-Signal Detector sensitivity */
+   phyparam0 &= ~PHYPARAM0_REF_LOSLEVEL_MASK;
+   phyparam0 |= PHYPARAM0_REF_LOSLEVEL;
+   writel(phyparam0, regs + EXYNOS5_DRD_PHYPARAM0);
+
+   writel(0x0, regs + EXYNOS5_DRD_PHYRESUME);
+
+   /*
+* Setting the Frame length Adj value[6:1] to default 0x20
+* See xHCI 1.0 spec, 5.2.4
+*/
+   linksystem = LINKSYSTEM_XHCI_VERSION_CONTROL |
+   LINKSYSTEM_FLADJ(0x20);
+   writel(linksystem, regs + EXYNOS5_DRD_LINKSYSTEM);
+
+   phyparam1 = readl(regs + EXYNOS5_DRD_PHYPARAM1);
+   /* Set Tx De-Emphasis level */
+   phyparam1 &= ~PHYPARAM1_PCS_TXDEEMPH_MASK;
+   phyparam1 |= PHYPARAM1_PCS_TXDEEMPH;
+   writel(phyparam1, regs + EXYNOS5_DRD_PHYPARAM1);
+
+   

[PATCH] USB: option: add Huawei E5331

2013-02-27 Thread Bjørn Mork
Another device using CDC ACM with vendor specific protocol to mark
serial functions.

Cc: stable 
Signed-off-by: Bjørn Mork 
---
This replaces the patch titled

  'USB: option: use vendor match for Huawei "ACM" devices'

by adding a new device specific entry instead.

I still think we should create some generic rule for these, but it
will havt to be more complex than just testing for the number of
endpoints.  A combination of endpoint count and testing
acm->bmCapabilities will probably do.  To be considered the next
time a new device appears...


 drivers/usb/serial/option.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index f7d339d..b6266bd 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -579,6 +579,7 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(QUANTA_VENDOR_ID, 0xea42),
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c05, 
USB_CLASS_COMM, 0x02, 0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c1f, 
USB_CLASS_COMM, 0x02, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, 
USB_CLASS_COMM, 0x02, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 
0xff, 0xff, 0xff),
.driver_info = (kernel_ulong_t) &net_intf1_blacklist },
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


mx28 usb host fails on 3.8

2013-02-27 Thread Fabio Estevam
Hi,

I noticed that USB host is no longer functional on mx28evk running 3.8
kernel. It worked well until 3.7.9:

3.7.9 kernel:

[1.19] usbcore: registered new interface driver usb-storage
[1.20] USB Mass Storage support registered.
[1.20] imx_usb 8008.usb: pinctrl get/select failed, err=-19
[1.21] ci_hdrc ci_hdrc.0: doesn't support gadget
[1.22] ci_hdrc ci_hdrc.0: ChipIdea HDRC EHCI
[1.22] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[1.28] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[1.29] hub 1-0:1.0: USB hub found
[1.29] hub 1-0:1.0: 1 port detected
[1.30] imx_usb 8009.usb: pinctrl get/select failed, err=-19
[1.31] ci_hdrc ci_hdrc.1: doesn't support gadget
[1.32] ci_hdrc ci_hdrc.1: ChipIdea HDRC EHCI
[1.32] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 2
[1.38] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
[1.38] hub 2-0:1.0: USB hub found
[1.39] hub 2-0:1.0: 1 port detected


3.8 kernel:

[1.386656] usbcore: registered new interface driver usb-storage
[1.392843] USB Mass Storage support registered.
[1.398906] imx_usb 8008.usb: pinctrl get/select failed, err=-19
[1.408781] ci_hdrc ci_hdrc.0: doesn't support host
[1.413906] ci_hdrc ci_hdrc.0: doesn't support gadget
[1.419000] ci_hdrc ci_hdrc.0: no supported roles
[1.426250] imx_usb 8009.usb: pinctrl get/select failed, err=-19
[1.435093] ci_hdrc ci_hdrc.1: doesn't support host
[1.440218] ci_hdrc ci_hdrc.1: doesn't support gadget
[1.445312] ci_hdrc ci_hdrc.1: no supported roles

Before I dig into this issue, just wanted to know if this is a known
issue and if there are any pending patch to fix it.

Thanks,

Fabio Estevam
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >