Re: [PATCH -next] usb: gadget: multi: fix error return code in rndis_do_config()

2013-04-05 Thread Felipe Balbi
On Sat, Apr 06, 2013 at 12:39:34PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun 
> 
> Fix to return a negative error code from the error handling
> case instead of 0, as returned elsewhere in this function.
> 
> Signed-off-by: Wei Yongjun 

patch looks alright, but you need to blame which commit added this
problem. Likewise for other two patches.

-- 
balbi


signature.asc
Description: Digital signature


Re: [GIT PULL] USB: changes for v3.10

2013-04-05 Thread Felipe Balbi
Hi,

On Fri, Apr 05, 2013 at 03:19:22PM -0700, Greg KH wrote:
> On Sat, Apr 06, 2013 at 12:41:02AM +0300, Felipe Balbi wrote:
> > Hi,
> > 
> > On Sat, Apr 06, 2013 at 12:21:52AM +0300, Felipe Balbi wrote:
> > > Hi Greg,
> > > 
> > > Here's a giant pull request for v3.10. All patches have been on 
> > > linux-next for
> > > quite a while and have gone through build and boot testing.
> > > 
> > > I haven't heard any complaints from Fengguang's 0-day build for some time 
> > > now,
> > > so it shouldn't add any new build warnings or build errors.
> > > 
> > > Let me know if you want/need further detail on the tag message, but given 
> > > the
> > > amount of changes in this pull request, I decided bullet points would be 
> > > easier
> > > to parse.
> > 
> > forgot to mention, there will be some conflicts; here's my suggested
> > resolution:
> 
> Thanks, that helped out a lot.  I've pulled and pushed these out now, so
> you might want to verify I got the merge right.

looks alright, thank you

-- 
balbi


signature.asc
Description: Digital signature


[PATCH -next] usb: gadget: cdc2: fix error return code in cdc_do_config()

2013-04-05 Thread Wei Yongjun
From: Wei Yongjun 

Fix to return a negative error code from the error handling
case instead of 0, as returned elsewhere in this function.

Signed-off-by: Wei Yongjun 
---
 drivers/usb/gadget/cdc2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index c6ee6f1..2c52551 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -129,8 +129,10 @@ static int __init cdc_do_config(struct usb_configuration 
*c)
return PTR_ERR(fi_serial);
 
f_acm = usb_get_function(fi_serial);
-   if (IS_ERR(f_acm))
+   if (IS_ERR(f_acm)) {
+   status = PTR_ERR(f_acm);
goto err_func_acm;
+   }
 
status = usb_add_function(c, f_acm);
if (status)

--
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 -next] usb: gadget: f_obex: fix error return code in obex_bind()

2013-04-05 Thread Wei Yongjun
From: Wei Yongjun 

Fix to return a negative error code from the error handling
case instead of 0, as returned elsewhere in this function.

Signed-off-by: Wei Yongjun 
---
 drivers/usb/gadget/f_obex.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 29a348a..8aa2be5 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -348,6 +348,7 @@ static int obex_bind(struct usb_configuration *c, struct 
usb_function *f)
 
/* allocate instance-specific endpoints */
 
+   status = -ENODEV;
ep = usb_ep_autoconfig(cdev->gadget, &obex_fs_ep_in_desc);
if (!ep)
goto fail;

--
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 -next] usb: gadget: multi: fix error return code in rndis_do_config()

2013-04-05 Thread Wei Yongjun
From: Wei Yongjun 

Fix to return a negative error code from the error handling
case instead of 0, as returned elsewhere in this function.

Signed-off-by: Wei Yongjun 
---
 drivers/usb/gadget/multi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index a74ebef..4a45e80 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -157,8 +157,10 @@ static __init int rndis_do_config(struct usb_configuration 
*c)
return ret;
 
f_acm_rndis = usb_get_function(fi_acm);
-   if (IS_ERR(f_acm_rndis))
+   if (IS_ERR(f_acm_rndis)) {
+   ret = PTR_ERR(f_acm_rndis);
goto err_func_acm;
+   }
 
ret = usb_add_function(c, f_acm_rndis);
if (ret)

--
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: [RFC PATCH 00/41] staging: dwc2: Miscellaneous cleanups and fixes

2013-04-05 Thread Paul Zimmerman
Aargh, resending as plain text.

Hi Matthijs,

Thanks for the work, this looks like a valuable set of patches.

But you really need to split this into a more manageable series of
patches. It's really difficult to review when you have so many different
things all munged together like this. It's also discouraging to potential
reviewers to see one set of 41 patches, where if it was four series of 10
patches each it seems like much less work ;)

I would suggest to split this into at least four separate series. One
for cleanups, one for fixes, one for your new struct dwc2_hw_params code,
and one for the new platform device stuff. And don't include the FYI
patches in those.

I think that would be the *minimum* number, I haven't looked that closely
so there may be more things that should be split out.

A couple of general observations:

You are using the wrong style for multi-line comments. Please read
Documentation/CodingStyle to see the right way to do it. Also, please run
all your patches thru checkpatch.pl before submitting them, that would
have caught this problem.

I see in some of the patches you don't have any commit message other than
the subject line. Apparently that is a no-no, at least Felipe objected
when I submitted some patches like that. At a minimum just rephrase the
subject line a bit in the body of the patch email.

-- 
Paul


-Original Message-
From: Matthijs Kooijman [mailto:matth...@stdin.nl] 
Sent: Friday, April 05, 2013 2:27 PM
To: linux-usb@vger.kernel.org
Cc: Paul Zimmerman; Stephen Warren
Subject: [RFC PATCH 00/41] staging: dwc2: Miscellaneous cleanups and fixes

Hi folks,

over the past two weeks, I've worked on the dwc2 driver to make it work
on the RT3052 platform. Basic mass-storage works, there are still some
unsolved problems with 3G modems I haven't looked at closely yet.

During that time, I've done some cleanups and small fixes whenever I
noticed something in the code, and this patch series is the result. A
lot of these patches are probably ok to apply as-is, but some of might
need some modifications.

It has become a bit of big patch series, but because there are a lot of
small dependencies between patches, I decided to just send it over as a
single series.

There roughly three big changes: register-related cleanups, fixing an
irq race condition and irq related cleanups, and adding a platform
driver.

These are register-related and misc cleanups:

  staging: dwc2: when dma is disabled, clear dev->dma_mask
  staging: dwc2: disable dma when no dma_mask was setup
  staging: dwc2: fix naming of register constants
  staging: dwc2: fix off-by-one in check for max_packet_count parameter
  staging: dwc2: replace some magic numbers by constants
  staging: dwc2: remove unneeded check
  staging: dwc2: use dwc2_hcd_get_frame_number where possible
  staging: dwc2: add helper variable to simplify code
  staging: dwc2: unshift non-bool register value constants
  staging: dwc2: only read the snpsid register once
  staging: dwc2: remove some device-mode related debug code
  staging: dwc2: simplify register shift expressions
  staging: dwc2: add missing shift
  staging: dwc2: simplify debug output in dwc_hc_init
  staging: dwc2: re-use hptxfsiz variable
  staging: dwc2: remove redundant register reads
  staging: dwc2: properly mask the GRXFSIZ register
  staging: dwc2: interpret all hwcfg and related register at init time
  staging: dwc2: validate the value for phy_utmi_width
  staging: dwc2: make dwc2_core_params documentation more complete

These are irq cleanups and the last one is the fix:

  staging: dwc2: do not use IRQF_DISABLED
  staging: dwc2: do not handle PRTINT in dwc2_handle_common_intr
  staging: dwc2: move some interrupt enabling around
  staging: dwc2: disable I2CINT in dwc2_disable_host_interrupts
  staging: dwc2: add dwc2_disable_common_interrupts function
  staging: dwc2: introduce GINTMSK_HOST macro
  staging: dwc2: use functions to disable interrupts
  staging: dwc2: properly separate common and host interrupt enabling
  staging: dwc2: don't pass IRQ_LEVEL to devm_request_irq
  staging: dwc2: register common irq handler in dwc2_core_init

These are platform-driver related:

  staging: dwc2: convert to devm_ioremap_resource()
  staging: dwc2: cleanup includes in pci.c
  staging: dwc2: set the driver name to "dwc2"
  staging: dwc2: Make dwc2_set_uninitialized more specific
  staging: dwc2: add platform device bindings
  staging: dwc2: load parameters from the devicetree

And these patch are just for reference. I'll send the MIPS patches to
the MIPS folks later, the raspberry pi patch isn't quite working yet.

  MIPS: ralink: use the dwc2 driver for the rt305x USB controller
  MIPS: ralink: setup dma_mask for the rt305x dwc2 usb controller
  WIP: enable dwc2 for raspberry pi

Stephen Warren (2):
  staging: dwc2: add const to handling of dwc2_core_params
  staging: dwc2: use irq_return_t for interrupt handlers

 Documentation/devicetree/bindings/staging/dwc2.txt |  51 +

Re: [PATCH 0/8] Reorganize R8A7779/Marzen USB code

2013-04-05 Thread Sergei Shtylyov

Hello.

On 04/05/2013 08:40 PM, Sergei Shtylyov wrote:



Here's the set of 4 patches against the Simon Horman's 
'renesas.git' repo,
'renesas-next-20130404v2' tag and the 2 Ether patches I've reposted 
yesterday.
It was created to fix the shortcomings in the R8A7779/Marzen USB 
platform code
and R8A7779 USB common PHY driver, and so spans both 
arch/arm/mach-shmobile/

and drivers/usb/ subtrees (some patches have to touch both subtrees).
The patches were conceived with the complete bisectability goal in 
mind.


[1/8] ARM: shmobile:Marzen: move USB EHCI, OHCI, and PHY devices to 
R8A7779 code

[2/8] ehci-platform: add init() method to platform data
[3/8] ARM: shmobile: R8A7779: setup EHCI internal buffer
[4/8] rcar-phy: remove EHCI internal buffer setup
[5/8] rcar-phy: correct base address
[6/8] rcar-phy: add platform data
[7/8] ARM: shmobile: Marzen: pass platform data to USB PHY device
[8/8] rcar-phy: handle platform data


I'm not sure thru which tree this patchset should be merged, 
however it turns
out that it's too late now to push it thru Felipe Balbi's USB tree 
for 3.10, so
maybe the patchset can be merged thru Simon's tree with Felipe's and 
Alan

Stern's ACKs.



I guess you already got request about patch style from Simon.


   It's not about style. I tried to keep the series copmpletely 
bisectable, and granting almost all requests about splitting the 
patches would have broken the bisection.


When you send v2 patch, could you please add "this patch is tested on 
 bard"

on each patch's comment area ?


   I'm not sure it's worth doing v2, although in one place I can 
indeed readily split the patch. All patches were tested on the Marzen 
board, I forgot to mention that in the cover letter.


   Well, there's gonna be version 2 now, mainly because Alan Stern 
wasn't content with the patch #2.


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: [GIT PULL] USB: changes for v3.10

2013-04-05 Thread Greg KH
On Sat, Apr 06, 2013 at 12:41:02AM +0300, Felipe Balbi wrote:
> Hi,
> 
> On Sat, Apr 06, 2013 at 12:21:52AM +0300, Felipe Balbi wrote:
> > Hi Greg,
> > 
> > Here's a giant pull request for v3.10. All patches have been on linux-next 
> > for
> > quite a while and have gone through build and boot testing.
> > 
> > I haven't heard any complaints from Fengguang's 0-day build for some time 
> > now,
> > so it shouldn't add any new build warnings or build errors.
> > 
> > Let me know if you want/need further detail on the tag message, but given 
> > the
> > amount of changes in this pull request, I decided bullet points would be 
> > easier
> > to parse.
> 
> forgot to mention, there will be some conflicts; here's my suggested
> resolution:

Thanks, that helped out a lot.  I've pulled and pushed these out now, so
you might want to verify I got the merge right.

thanks,

greg k-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


[RFC PATCH 22/41] staging: dwc2: use irq_return_t for interrupt handlers

2013-04-05 Thread Matthijs Kooijman
From: Stephen Warren 

The top-level hcd interrupt handlers already used irq_return_t, but the
functions to which it delegates the actual work and the common irq
handler returned plain ints. In addition, they used the IRQ_RETVAL in
the wrong way (but because of the values of the various constants, this
didn't result in wrong behaviour).

Signed-off-by: Stephen Warren 
[matth...@stdin.nl: Split patch from bigger patch and added commit message]
Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core_intr.c |  8 
 drivers/staging/dwc2/hcd.c   |  3 +--
 drivers/staging/dwc2/hcd.h   |  6 +++---
 drivers/staging/dwc2/hcd_intr.c  | 34 +++---
 4 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/dwc2/core_intr.c b/drivers/staging/dwc2/core_intr.c
index fde1e23..454c502 100644
--- a/drivers/staging/dwc2/core_intr.c
+++ b/drivers/staging/dwc2/core_intr.c
@@ -450,7 +450,7 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
 {
struct dwc2_hsotg *hsotg = dev;
u32 gintsts;
-   int retval = 0;
+   irqreturn_t retval = IRQ_NONE;
 
if (dwc2_check_core_status(hsotg) < 0) {
dev_warn(hsotg->dev, "Controller is disconnected");
@@ -461,7 +461,7 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
 
gintsts = dwc2_read_common_intr(hsotg);
if (gintsts & ~GINTSTS_PRTINT)
-   retval = 1;
+   retval = IRQ_HANDLED;
 
if (gintsts & GINTSTS_MODEMIS)
dwc2_handle_mode_mismatch_intr(hsotg);
@@ -494,12 +494,12 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
" --Port interrupt received in Device 
mode--\n");
gintsts = GINTSTS_PRTINT;
writel(gintsts, hsotg->regs + GINTSTS);
-   retval = 1;
+   retval = IRQ_HANDLED;
}
}
 
spin_unlock(&hsotg->lock);
 out:
-   return IRQ_RETVAL(retval);
+   return retval;
 }
 EXPORT_SYMBOL_GPL(dwc2_handle_common_intr);
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index c0a0999..1f375ac 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2531,9 +2531,8 @@ static void _dwc2_hcd_endpoint_reset(struct usb_hcd *hcd,
 static irqreturn_t _dwc2_hcd_irq(struct usb_hcd *hcd)
 {
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
-   int retval = dwc2_hcd_intr(hsotg);
 
-   return IRQ_RETVAL(retval);
+   return dwc2_hcd_intr(hsotg);
 }
 
 /*
diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h
index 8d8e20b..5d90f4c 100644
--- a/drivers/staging/dwc2/hcd.h
+++ b/drivers/staging/dwc2/hcd.h
@@ -633,10 +633,10 @@ extern void dwc2_hcd_save_data_toggle(struct dwc2_hsotg 
*hsotg,
  *
  * @hsotg: The DWC2 HCD
  *
- * Returns non zero if interrupt is handled
- * Return 0 if interrupt is not handled
+ * Returns IRQ_HANDLED if interrupt is handled
+ * Return IRQ_NONE if interrupt is not handled
  */
-extern int dwc2_hcd_intr(struct dwc2_hsotg *hsotg);
+extern irqreturn_t dwc2_hcd_intr(struct dwc2_hsotg *hsotg);
 
 /**
  * dwc2_hcd_stop() - Halts the DWC_otg host mode operation
diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c
index 5b917b1..69ce22e 100644
--- a/drivers/staging/dwc2/hcd_intr.c
+++ b/drivers/staging/dwc2/hcd_intr.c
@@ -2054,10 +2054,10 @@ static void dwc2_hc_intr(struct dwc2_hsotg *hsotg)
 }
 
 /* This function handles interrupts for the HCD */
-int dwc2_hcd_intr(struct dwc2_hsotg *hsotg)
+irqreturn_t dwc2_hcd_intr(struct dwc2_hsotg *hsotg)
 {
u32 gintsts, dbg_gintsts;
-   int retval = 0;
+   irqreturn_t retval = IRQ_NONE;
 
if (dwc2_check_core_status(hsotg) < 0) {
dev_warn(hsotg->dev, "Controller is disconnected");
@@ -2074,8 +2074,6 @@ int dwc2_hcd_intr(struct dwc2_hsotg *hsotg)
return 0;
}
 
-   retval = 1;
-
dbg_gintsts = gintsts;
 #ifndef DEBUG_SOF
dbg_gintsts &= ~GINTSTS_SOF;
@@ -2089,21 +2087,35 @@ int dwc2_hcd_intr(struct dwc2_hsotg *hsotg)
 "DWC OTG HCD Interrupt Detected 
gintsts&gintmsk=0x%08x\n",
 gintsts);
 
-   if (gintsts & GINTSTS_SOF)
+   if (gintsts & GINTSTS_SOF) {
dwc2_sof_intr(hsotg);
-   if (gintsts & GINTSTS_RXFLVL)
+   retval = IRQ_HANDLED;
+   }
+   if (gintsts & GINTSTS_RXFLVL) {
dwc2_rx_fifo_level_intr(hsotg);
-   if (gintsts & GINTSTS_NPTXFEMP)
+   retval = IRQ_HANDLED;
+   }
+   if (gintsts & GINTSTS_NPTXFEMP) {
dwc2_np_tx_fifo_empty_intr(hsotg);
-   if (gintsts & GINTSTS_I2CINT)
+   retva

[RFC PATCH 18/41] staging: dwc2: interpret all hwcfg and related register at init time

2013-04-05 Thread Matthijs Kooijman
Before, the hwcfg registers were read at device init time, but
interpreted at various parts in the code. This commit unpacks the hwcfg
register values into a struct with properly labeled variables at init
time, which makes all the other code using these values more consise and
easier to read. Some values that were previously stored in the hsotg
struct are now moved into this new struct as well.

In addition to the hwcfg registers, the contents of some fifo size
registers are also unpacked. The hwcfg registers are read-only, so they
can be safely stored. The fifo size registers are read-write registers,
but their power-on values are significant: they give the maximum depth
of the fifo they describe.

This commit mostly moves code, but also attempts to simplify some
expressions from (val >> shift) & (mask >> shift) to
(val & mask) >> shift.

Also, all of the parameters read from the hardware are debug printed
after unpacking them, so a bunch of debug prints can be removed from
other places.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c  | 320 +--
 drivers/staging/dwc2/core.h  |  96 +---
 drivers/staging/dwc2/core_intr.c |   4 +-
 drivers/staging/dwc2/hcd.c   |  79 ++
 drivers/staging/dwc2/hcd.h   |   1 +
 drivers/staging/dwc2/hcd_intr.c  |   2 +-
 6 files changed, 297 insertions(+), 205 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 0388641..4858a6b 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -90,14 +90,10 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
  */
 static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg)
 {
-   u32 hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >>
- GHWCFG2_HS_PHY_TYPE_SHIFT;
-   u32 fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >>
- GHWCFG2_FS_PHY_TYPE_SHIFT;
u32 hcfg, val;
 
-   if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&
-fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED &&
+   if ((hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&
+hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED &&
 hsotg->core_params->ulpi_fs_ls > 0) ||
hsotg->core_params->phy_type == DWC2_PHY_TYPE_PARAM_FS) {
/* Full speed PHY */
@@ -247,7 +243,7 @@ static void dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
 
 static void dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
 {
-   u32 usbcfg, hs_phy_type, fs_phy_type;
+   u32 usbcfg;
 
if (hsotg->core_params->speed == DWC2_SPEED_PARAM_FULL &&
hsotg->core_params->phy_type == DWC2_PHY_TYPE_PARAM_FS) {
@@ -258,13 +254,8 @@ static void dwc2_phy_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
dwc2_hs_phy_init(hsotg, select_phy);
}
 
-   hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >>
- GHWCFG2_HS_PHY_TYPE_SHIFT
-   fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >>
- GHWCFG2_FS_PHY_TYPE_SHIFT
-
-   if (hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&
-   fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED &&
+   if (hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&
+   hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED &&
hsotg->core_params->ulpi_fs_ls > 0) {
dev_dbg(hsotg->dev, "Setting ULPI FSLS\n");
usbcfg = readl(hsotg->regs + GUSBCFG);
@@ -283,8 +274,7 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg)
 {
u32 ahbcfg = 0;
 
-   switch ((hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >>
-   GHWCFG2_ARCHITECTURE_SHIFT) {
+   switch (hsotg->hw_params.arch) {
case GHWCFG2_EXT_DMA_ARCH:
dev_err(hsotg->dev, "External DMA Mode not supported\n");
return -EINVAL;
@@ -336,8 +326,7 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg)
usbcfg = readl(hsotg->regs + GUSBCFG);
usbcfg &= ~(GUSBCFG_HNPCAP | GUSBCFG_SRPCAP);
 
-   switch ((hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >>
-   GHWCFG_OP_MODE_SHIFT) {
+   switch (hsotg->hw_params.op_mode) {
case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE:
if (hsotg->core_params->otg_cap ==
DWC2_CAP_PARAM_HNP_SRP_CAPABLE)
@@ -397,21 +386,6 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
/* Reset the Controller */
dwc2_core_reset(hsotg);
 
-   dev_dbg(hsotg->dev, "num_dev_perio_in_ep=%d\n",
-   hsotg->hwcfg4 >> GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT &
-   GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK >>
-   GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT);
-
-   hsotg->total_fifo_size = hsotg->hwcfg3 >> GHWCFG3_DFIFO_DEPTH_SHIFT &
-  

[RFC PATCH 30/41] staging: dwc2: properly separate common and host interrupt enabling

2013-04-05 Thread Matthijs Kooijman
Before, enabling common interrupts would implicitly disable all other
interrupts and enabling host interrupts would disable all interrupts and
then enable both common and host interrupts.

Now, these two are properly separated: each enable function only enables
its own interrupts and leaves all others alone. This makes the
functions do what you'd expect them to.

In practice, both of these functions are only called together during
initialization and cleanup, so there shouldn't be any behaviour change
(though some timing changes could occur).

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index ab6844c..57b6f9a 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -69,13 +69,13 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
/* Clear any pending OTG Interrupts */
writel(0x, hsotg->regs + GOTGINT);
 
-   /* Clear any pending interrupts */
-   writel(0x, hsotg->regs + GINTSTS);
+   /* Clear any pending common interrupts */
+   writel(GINTMSK_COMMON, hsotg->regs + GINTSTS);
 
-   /* Enable the interrupts in the GINTMSK */
-   intmsk = GINTSTS_DISCONNINT | GINTSTS_MODEMIS | GINTSTS_OTGINT;
-
-   intmsk |= GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
+   /* Enable common interrupts without disturbing host mode interrupts */
+   intmsk = readl(hsotg->regs + GINTMSK);
+   intmsk |= GINTSTS_DISCONNINT | GINTSTS_MODEMIS | GINTSTS_OTGINT |
+ GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
  GINTSTS_SESSREQINT;
 
writel(intmsk, hsotg->regs + GINTMSK);
@@ -450,15 +450,11 @@ void dwc2_enable_host_interrupts(struct dwc2_hsotg *hsotg)
 
dev_dbg(hsotg->dev, "%s()\n", __func__);
 
-   /* Disable all interrupts */
-   writel(0, hsotg->regs + GINTMSK);
+   /* Disable all host channel interrupts */
writel(0, hsotg->regs + HAINTMSK);
 
-   /* Clear any pending interrupts */
-   writel(0x, hsotg->regs + GINTSTS);
-
-   /* Enable the common interrupts */
-   dwc2_enable_common_interrupts(hsotg);
+   /* Clear any pending host mode interrupts */
+   writel(GINTMSK_HOST, hsotg->regs + GINTSTS);
 
/* Enable host mode interrupts without disturbing common interrupts */
intmsk = readl(hsotg->regs + GINTMSK);
-- 
1.8.0

--
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


[RFC PATCH 07/41] staging: dwc2: use dwc2_hcd_get_frame_number where possible

2013-04-05 Thread Matthijs Kooijman
Before, there were two places that manually read the FRNUM registers,
while there is a function to do this.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 8 +---
 drivers/staging/dwc2/hcd_intr.c | 5 +
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index af5e7d9..e503aed 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -1124,16 +1124,10 @@ void dwc2_hc_cleanup(struct dwc2_hsotg *hsotg, struct 
dwc2_host_chan *chan)
 static void dwc2_hc_set_even_odd_frame(struct dwc2_hsotg *hsotg,
   struct dwc2_host_chan *chan, u32 *hcchar)
 {
-   u32 hfnum, frnum;
-
if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
chan->ep_type == USB_ENDPOINT_XFER_ISOC) {
-   hfnum = readl(hsotg->regs + HFNUM);
-   frnum = hfnum >> HFNUM_FRNUM_SHIFT &
-   HFNUM_FRNUM_MASK >> HFNUM_FRNUM_SHIFT;
-
/* 1 if _next_ frame is odd, 0 if it's even */
-   if (frnum & 0x1)
+   if (dwc2_hcd_get_frame_number(hsotg) & 0x1)
*hcchar |= HCCHAR_ODDFRM;
}
 }
diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c
index a603d9e..12b5a89 100644
--- a/drivers/staging/dwc2/hcd_intr.c
+++ b/drivers/staging/dwc2/hcd_intr.c
@@ -117,16 +117,13 @@ static void dwc2_sof_intr(struct dwc2_hsotg *hsotg)
 {
struct list_head *qh_entry;
struct dwc2_qh *qh;
-   u32 hfnum;
enum dwc2_transaction_type tr_type;
 
 #ifdef DEBUG_SOF
dev_vdbg(hsotg->dev, "--Start of Frame Interrupt--\n");
 #endif
 
-   hfnum = readl(hsotg->regs + HFNUM);
-   hsotg->frame_number = hfnum >> HFNUM_FRNUM_SHIFT &
-   HFNUM_FRNUM_MASK >> HFNUM_FRNUM_SHIFT;
+   hsotg->frame_number = dwc2_hcd_get_frame_number(hsotg);
 
dwc2_track_missed_sofs(hsotg);
 
-- 
1.8.0

--
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


[RFC PATCH 08/41] staging: dwc2: add helper variable to simplify code

2013-04-05 Thread Matthijs Kooijman
Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd_intr.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c
index 12b5a89..281c2f4 100644
--- a/drivers/staging/dwc2/hcd_intr.c
+++ b/drivers/staging/dwc2/hcd_intr.c
@@ -245,6 +245,7 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 
hprt0,
u32 usbcfg;
u32 prtspd;
u32 hcfg;
+   u32 fslspclksel;
u32 hfir;
 
dev_vdbg(hsotg->dev, "%s(%p)\n", __func__, hsotg);
@@ -276,6 +277,7 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 
hprt0,
}
 
hcfg = readl(hsotg->regs + HCFG);
+   fslspclksel = hcfg & HCFG_FSLSPCLKSEL_MASK;
 
if (prtspd == HPRT0_SPD_LOW_SPEED &&
params->host_ls_low_power_phy_clk ==
@@ -283,8 +285,7 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 
hprt0,
/* 6 MHZ */
dev_vdbg(hsotg->dev,
 "FS_PHY programming HCFG to 6 MHz\n");
-   if ((hcfg & HCFG_FSLSPCLKSEL_MASK) !=
-   HCFG_FSLSPCLKSEL_6_MHZ) {
+   if (fslspclksel != HCFG_FSLSPCLKSEL_6_MHZ) {
hcfg &= ~HCFG_FSLSPCLKSEL_MASK;
hcfg |= HCFG_FSLSPCLKSEL_6_MHZ;
writel(hcfg, hsotg->regs + HCFG);
@@ -294,8 +295,7 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 
hprt0,
/* 48 MHZ */
dev_vdbg(hsotg->dev,
 "FS_PHY programming HCFG to 48 MHz\n");
-   if ((hcfg & HCFG_FSLSPCLKSEL_MASK) !=
-   HCFG_FSLSPCLKSEL_48_MHZ) {
+   if (fslspclksel != HCFG_FSLSPCLKSEL_48_MHZ) {
hcfg &= ~HCFG_FSLSPCLKSEL_MASK;
hcfg |= HCFG_FSLSPCLKSEL_48_MHZ;
writel(hcfg, hsotg->regs + HCFG);
-- 
1.8.0

--
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


[RFC PATCH 28/41] staging: dwc2: introduce GINTMSK_HOST macro

2013-04-05 Thread Matthijs Kooijman
This simply defines a list of interrupts handled by the the host
interrupt handler.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 4 +---
 drivers/staging/dwc2/core.h | 4 
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index a3b8556..ab6844c 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -480,9 +480,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg)
u32 intmsk = readl(hsotg->regs + GINTMSK);
 
/* Disable host mode interrupts without disturbing common interrupts */
-   intmsk &= ~(GINTSTS_SOF | GINTSTS_PRTINT | GINTSTS_HCHINT |
-   GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | GINTSTS_RXFLVL |
-   GINTSTS_I2CINT);
+   intmsk &= ~(GINTMSK_HOST);
writel(intmsk, hsotg->regs + GINTMSK);
 }
 
diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index 0fa479e..aed18e1 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -757,4 +757,8 @@ extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
 GINTSTS_USBSUSP | GINTSTS_RESTOREDONE)
 
+#define GINTMSK_HOST   (GINTSTS_SOF | GINTSTS_RXFLVL | GINTSTS_NPTXFEMP | \
+GINTSTS_I2CINT | GINTSTS_PRTINT | GINTSTS_HCHINT | \
+GINTSTS_PTXFEMP)
+
 #endif /* __DWC2_CORE_H__ */
-- 
1.8.0

--
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


[RFC PATCH 25/41] staging: dwc2: move some interrupt enabling around

2013-04-05 Thread Matthijs Kooijman
Before, the DISCONNINT interrupt was enabled in
dwc2_enable_host_interrupts, but handled in dwc2_handle_common_intr,
while the RXFLVL interrupt was enabled in dwc2_enable_commont_interrupts
and handled in dwc_handle_hcd_intr.

This moves the enabling of these interrupts around to match the spot
where they are handled.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 66aa4aa..4a8caf2 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -73,10 +73,7 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
writel(0x, hsotg->regs + GINTSTS);
 
/* Enable the interrupts in the GINTMSK */
-   intmsk = GINTSTS_MODEMIS | GINTSTS_OTGINT;
-
-   if (hsotg->core_params->dma_enable <= 0)
-   intmsk |= GINTSTS_RXFLVL;
+   intmsk = GINTSTS_DISCONNINT | GINTSTS_MODEMIS | GINTSTS_OTGINT;
 
intmsk |= GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
  GINTSTS_SESSREQINT;
@@ -451,7 +448,11 @@ void dwc2_enable_host_interrupts(struct dwc2_hsotg *hsotg)
 
/* Enable host mode interrupts without disturbing common interrupts */
intmsk = readl(hsotg->regs + GINTMSK);
-   intmsk |= GINTSTS_DISCONNINT | GINTSTS_PRTINT | GINTSTS_HCHINT;
+   intmsk |= GINTSTS_PRTINT | GINTSTS_HCHINT;
+
+   if (hsotg->core_params->dma_enable <= 0)
+   intmsk |= GINTSTS_RXFLVL;
+
writel(intmsk, hsotg->regs + GINTMSK);
 }
 
@@ -466,7 +467,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg)
 
/* Disable host mode interrupts without disturbing common interrupts */
intmsk &= ~(GINTSTS_SOF | GINTSTS_PRTINT | GINTSTS_HCHINT |
-   GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP);
+   GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | GINTSTS_RXFLVL);
writel(intmsk, hsotg->regs + GINTMSK);
 }
 
-- 
1.8.0

--
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


[RFC PATCH 29/41] staging: dwc2: use functions to disable interrupts

2013-04-05 Thread Matthijs Kooijman
This piece of code manually disabled interrupts, while there are
perfectly good functions to do this.

Technically, the old code really disabled _all_ interrupts, while the
new code only disables a specific list of interrupts, but that list of
interrupts includes all interrupts that are ever enabled, so the result
should be the same.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 01e7eb1..3656a3c 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2606,7 +2606,6 @@ static struct hc_driver dwc2_hc_driver = {
  */
 static void dwc2_hcd_free(struct dwc2_hsotg *hsotg)
 {
-   u32 ahbcfg;
u32 dctl;
int i;
 
@@ -2644,12 +2643,10 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg)
hsotg->status_buf = NULL;
}
 
-   ahbcfg = readl(hsotg->regs + GAHBCFG);
-
/* Disable all interrupts */
-   ahbcfg &= ~GAHBCFG_GLBL_INTR_EN;
-   writel(ahbcfg, hsotg->regs + GAHBCFG);
-   writel(0, hsotg->regs + GINTMSK);
+   dwc2_disable_global_interrupts(hsotg);
+   dwc2_disable_host_interrupts(hsotg);
+   dwc2_disable_common_interrupts(hsotg);
 
if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a) {
dctl = readl(hsotg->regs + DCTL);
-- 
1.8.0

--
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


[RFC PATCH 31/41] staging: dwc2: don't pass IRQ_LEVEL to devm_request_irq

2013-04-05 Thread Matthijs Kooijman
It seems this flag is intended to pass to irq_set_status_flags, not
request_irq, and is not available on all architectures. Its value
corresponds to IRQF_PROBE_SHARED, which shouldn't be needed for this
driver, so removing this flag should be safe.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

See include/linux/irq.h:

 * Bits which can be modified via irq_set/clear/modify_status_flags()
[...]
IRQ_LEVEL   = (1 <<  8),

and include/linux/interrupt.h:

#define IRQF_PROBE_SHARED   0x0100

diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 63b7c1a..928298a 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -157,7 +157,7 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
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),
+ IRQF_SHARED, dev_name(&dev->dev),
  hsotg);
if (retval)
dwc2_hcd_remove(hsotg);
-- 
1.8.0

--
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


[RFC PATCH 33/41] staging: dwc2: convert to devm_ioremap_resource()

2013-04-05 Thread Matthijs Kooijman
Convert use of devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so the explicit
error code can be removed from the failure code path.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

see 75096579c (lib: devres: Introduce devm_ioremap_resource())

diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 6e4ee0f..acf2008 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -134,9 +134,9 @@ static int dwc2_driver_probe(struct pci_dev *dev,
pci_set_power_state(dev, PCI_D0);
 
hsotg->dev = &dev->dev;
-   hsotg->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]);
-   if (!hsotg->regs)
-   return -ENOMEM;
+   hsotg->regs = devm_ioremap_resource(&dev->dev, &dev->resource[0]);
+   if (IS_ERR(hsotg->regs))
+   return PTR_ERR(hsotg->regs);
 
dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
(unsigned long)pci_resource_start(dev, 0), hsotg->regs);
-- 
1.8.0

--
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


[RFC PATCH 16/41] staging: dwc2: remove redundant register reads

2013-04-05 Thread Matthijs Kooijman
For calculating FIFO offsets, the sizes of preceding fifos need to be
known. For filling the GDFIFOCFG register, these fifo sizes were read
from hardware registers. However, these values were written to these
registers just a few lines before, so we can just use the values written
instead.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

If there is some scenario possible where the FIFO size values written to
these registers are not actually applied, this patch could cause a
problem. However, given the fact that the fifo size values are validated
against the maximum values read from the hardware, this should be ok?

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 07f91e6..cc2431f 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -499,7 +499,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg)
 static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
 {
struct dwc2_core_params *params = hsotg->core_params;
-   u32 rxfsiz, nptxfsiz, hptxfsiz, dfifocfg;
+   u32 nptxfsiz, hptxfsiz, dfifocfg;
 
if (!params->enable_dynamic_fifo)
return;
@@ -547,11 +547,10 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
 * include RxFIFO, NPTXFIFO and HPTXFIFO
 */
dfifocfg = readl(hsotg->regs + GDFIFOCFG);
-   rxfsiz = readl(hsotg->regs + GRXFSIZ) & 0x;
-   nptxfsiz = readl(hsotg->regs + GNPTXFSIZ) >> 16 & 0x;
-   hptxfsiz = readl(hsotg->regs + HPTXFSIZ) >> 16 & 0x;
dfifocfg &= ~GDFIFOCFG_EPINFOBASE_MASK;
-   dfifocfg |= (rxfsiz + nptxfsiz + hptxfsiz) <<
+   dfifocfg |= (params->host_rx_fifo_size +
+params->host_nperio_tx_fifo_size +
+params->host_perio_tx_fifo_size) <<
GDFIFOCFG_EPINFOBASE_SHIFT &
GDFIFOCFG_EPINFOBASE_MASK;
writel(dfifocfg, hsotg->regs + GDFIFOCFG);
-- 
1.8.0

--
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


[RFC PATCH 24/41] staging: dwc2: do not handle PRTINT in dwc2_handle_common_intr

2013-04-05 Thread Matthijs Kooijman
For host mode, this interrupt is already handled by the hcd interrupt
handler. The common interrupt handler additionally did a noop handling
(it only cleared the flag and nothing else) when in device mode.

Since the driver currently supports only host mode, this shouldn't
result in any behaviour change in the driver. When device mode is
implemented later on, this interrupt should be properly handled by the
device interupt handler, if needed.

This change allows to make a clean cut between common interrupts and
host interrupts, since there are no longer any interrupts handled by
both.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core_intr.c | 19 ++-
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/dwc2/core_intr.c b/drivers/staging/dwc2/core_intr.c
index 454c502..3099f2d 100644
--- a/drivers/staging/dwc2/core_intr.c
+++ b/drivers/staging/dwc2/core_intr.c
@@ -403,8 +403,7 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
 #define GINTMSK_COMMON (GINTSTS_WKUPINT | GINTSTS_SESSREQINT | \
 GINTSTS_CONIDSTSCHNG | GINTSTS_OTGINT |\
 GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
-GINTSTS_USBSUSP | GINTSTS_RESTOREDONE |\
-GINTSTS_PRTINT)
+GINTSTS_USBSUSP | GINTSTS_RESTOREDONE)
 
 /*
  * This function returns the Core Interrupt register
@@ -460,7 +459,7 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
spin_lock(&hsotg->lock);
 
gintsts = dwc2_read_common_intr(hsotg);
-   if (gintsts & ~GINTSTS_PRTINT)
+   if (gintsts)
retval = IRQ_HANDLED;
 
if (gintsts & GINTSTS_MODEMIS)
@@ -484,20 +483,6 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
dev_dbg(hsotg->dev, " --Restore done interrupt received--\n");
}
 
-   if (gintsts & GINTSTS_PRTINT) {
-   /*
-* The port interrupt occurs while in device mode with HPRT0
-* Port Enable/Disable
-*/
-   if (dwc2_is_device_mode(hsotg)) {
-   dev_dbg(hsotg->dev,
-   " --Port interrupt received in Device 
mode--\n");
-   gintsts = GINTSTS_PRTINT;
-   writel(gintsts, hsotg->regs + GINTSTS);
-   retval = IRQ_HANDLED;
-   }
-   }
-
spin_unlock(&hsotg->lock);
 out:
return retval;
-- 
1.8.0

--
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


[RFC PATCH 19/41] staging: dwc2: validate the value for phy_utmi_width

2013-04-05 Thread Matthijs Kooijman
The HWCFG4 register stores the supported utmi width values (8, 16 or
both). This commit reads that value and validates the configured value
against that.

If no (valid) value is given, the parameter defaulted to 8 bits
previously.  However, the documentation for dwc2_core_params_struct
suggests that the default should be 16. Also, the pci bindings
explicitely set the value to 16, so this commit changes the default to
16 bits (if supported, 8 bits otherwise).

With the default changed, the value set in pci.c is changed to -1 to
make it autodetected as well.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 25 +
 drivers/staging/dwc2/core.h |  5 +
 drivers/staging/dwc2/hw.h   |  3 +++
 drivers/staging/dwc2/pci.c  |  2 +-
 4 files changed, 30 insertions(+), 5 deletions(-)

I'm not entirely sure if this check is really correct, since I only have
limited hardware documentation. It seems ok from the register
descriptions I have, but Peter should verify this.

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 4858a6b..e1a70de 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -2340,14 +2340,29 @@ int dwc2_set_param_phy_ulpi_ext_vbus(struct dwc2_hsotg 
*hsotg, int val)
 
 int dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val)
 {
+   int valid = 0;
int retval = 0;
 
-   if (DWC2_PARAM_TEST(val, 8, 8) && DWC2_PARAM_TEST(val, 16, 16)) {
+   switch(hsotg->hw_params.utmi_phy_data_width) {
+   case GHWCFG4_UTMI_PHY_DATA_WIDTH_8:
+   valid = (val == 8);
+   break;
+   case GHWCFG4_UTMI_PHY_DATA_WIDTH_16:
+   valid = (val == 16);
+   break;
+   case GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16:
+   valid = (val == 8 || val == 16);
+   break;
+   }
+
+   if (!valid) {
if (val >= 0) {
-   dev_err(hsotg->dev, "Wrong value for phy_utmi_width\n");
-   dev_err(hsotg->dev, "phy_utmi_width must be 8 or 16\n");
+   dev_err(hsotg->dev,
+   "%d invalid for phy_utmi_width. Check HW 
configuration.\n",
+   val);
}
-   val = 8;
+   val = (hsotg->hw_params.utmi_phy_data_width ==
+  GHWCFG4_UTMI_PHY_DATA_WIDTH_8) ? 8 : 16;
dev_dbg(hsotg->dev, "Setting phy_utmi_width to %d\n", val);
retval = -EINVAL;
}
@@ -2644,6 +2659,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
  GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT;
hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA);
hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ);
+   hw->utmi_phy_data_width = (hwcfg4 & GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK) >>
+ GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT;
 
// fifo sizes
hw->host_rx_fifo_size = (grxfsiz & GRXFSIZ_RXF_DEP_MASK) >>
diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index c55985f..710de03 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -234,6 +234,10 @@ struct dwc2_core_params {
  *   2 - FS pins shared with UTMI+ pins
  *   3 - FS pins shared with ULPI pins
  * @total_fifo_size:Total internal RAM for FIFOs (bytes)
+ * @utmi_phy_data_width UTMI+ PHY data width
+ *   0 - 8 bits
+ *   1 - 16 bits
+ *   2 - 8 or 16 bits
  * @snpsid: Value from SNPSID register
  */
 struct dwc2_hw_params {
@@ -258,6 +262,7 @@ struct dwc2_hw_params {
unsigned num_dev_perio_in_ep:4;
unsigned total_fifo_size:16;
unsigned power_optimized:1;
+   unsigned utmi_phy_data_width:2;
u32 snpsid;
 };
 
diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h
index 4f813b8..278d887 100644
--- a/drivers/staging/dwc2/hw.h
+++ b/drivers/staging/dwc2/hw.h
@@ -305,6 +305,9 @@
 #define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT 16
 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK   (0x3 << 14)
 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT  14
+#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8  0
+#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1
+#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_162
 #define GHWCFG4_XHIBER (1 << 7)
 #define GHWCFG4_HIBER  (1 << 6)
 #define GHWCFG4_MIN_AHB_FREQ   (1 << 5)
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 0825eef..63b7c1a 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -74,7 +74,7 @@ static struct dwc2_core_params dwc2_module_params = {
.max_packet_count   = 511,
.host_channels  = -1,
.phy_type   = -1,
-   .phy_utmi_width  

[RFC PATCH 39/41] MIPS: ralink: use the dwc2 driver for the rt305x USB controller

2013-04-05 Thread Matthijs Kooijman
---
 arch/mips/ralink/dts/rt3050.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

This patch is just FYI.

diff --git a/arch/mips/ralink/dts/rt3050.dtsi b/arch/mips/ralink/dts/rt3050.dtsi
index 5aede8d..2b7ab42 100644
--- a/arch/mips/ralink/dts/rt3050.dtsi
+++ b/arch/mips/ralink/dts/rt3050.dtsi
@@ -161,7 +161,7 @@
};
 
otg@101c {
-   compatible = "ralink,rt3050-otg";
+   compatible = "ralink,rt3050-otg", "snps,dwc2";
reg = <0x101c 4>;
 
interrupt-parent = <&intc>;
-- 
1.8.0

--
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


[RFC PATCH 26/41] staging: dwc2: disable I2CINT in dwc2_disable_host_interrupts

2013-04-05 Thread Matthijs Kooijman
This interrupt is currently not enabled anywhere, but there is some
(dummy) handling for it in the host interrupt handler. This marks it as
a host mode interrupt, so it makes sense to disable it when disabling
the other host mode interrupts.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 4a8caf2..1cadb93 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -467,7 +467,8 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg)
 
/* Disable host mode interrupts without disturbing common interrupts */
intmsk &= ~(GINTSTS_SOF | GINTSTS_PRTINT | GINTSTS_HCHINT |
-   GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | GINTSTS_RXFLVL);
+   GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | GINTSTS_RXFLVL |
+   GINTSTS_I2CINT);
writel(intmsk, hsotg->regs + GINTMSK);
 }
 
-- 
1.8.0

--
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


[RFC PATCH 00/41] staging: dwc2: Miscellaneous cleanups and fixes

2013-04-05 Thread Matthijs Kooijman
Hi folks,

over the past two weeks, I've worked on the dwc2 driver to make it work
on the RT3052 platform. Basic mass-storage works, there are still some
unsolved problems with 3G modems I haven't looked at closely yet.

During that time, I've done some cleanups and small fixes whenever I
noticed something in the code, and this patch series is the result. A
lot of these patches are probably ok to apply as-is, but some of might
need some modifications.

It has become a bit of big patch series, but because there are a lot of
small dependencies between patches, I decided to just send it over as a
single series.

There roughly three big changes: register-related cleanups, fixing an
irq race condition and irq related cleanups, and adding a platform
driver.

These are register-related and misc cleanups:

  staging: dwc2: when dma is disabled, clear dev->dma_mask
  staging: dwc2: disable dma when no dma_mask was setup
  staging: dwc2: fix naming of register constants
  staging: dwc2: fix off-by-one in check for max_packet_count parameter
  staging: dwc2: replace some magic numbers by constants
  staging: dwc2: remove unneeded check
  staging: dwc2: use dwc2_hcd_get_frame_number where possible
  staging: dwc2: add helper variable to simplify code
  staging: dwc2: unshift non-bool register value constants
  staging: dwc2: only read the snpsid register once
  staging: dwc2: remove some device-mode related debug code
  staging: dwc2: simplify register shift expressions
  staging: dwc2: add missing shift
  staging: dwc2: simplify debug output in dwc_hc_init
  staging: dwc2: re-use hptxfsiz variable
  staging: dwc2: remove redundant register reads
  staging: dwc2: properly mask the GRXFSIZ register
  staging: dwc2: interpret all hwcfg and related register at init time
  staging: dwc2: validate the value for phy_utmi_width
  staging: dwc2: make dwc2_core_params documentation more complete

These are irq cleanups and the last one is the fix:

  staging: dwc2: do not use IRQF_DISABLED
  staging: dwc2: do not handle PRTINT in dwc2_handle_common_intr
  staging: dwc2: move some interrupt enabling around
  staging: dwc2: disable I2CINT in dwc2_disable_host_interrupts
  staging: dwc2: add dwc2_disable_common_interrupts function
  staging: dwc2: introduce GINTMSK_HOST macro
  staging: dwc2: use functions to disable interrupts
  staging: dwc2: properly separate common and host interrupt enabling
  staging: dwc2: don't pass IRQ_LEVEL to devm_request_irq
  staging: dwc2: register common irq handler in dwc2_core_init

These are platform-driver related:

  staging: dwc2: convert to devm_ioremap_resource()
  staging: dwc2: cleanup includes in pci.c
  staging: dwc2: set the driver name to "dwc2"
  staging: dwc2: Make dwc2_set_uninitialized more specific
  staging: dwc2: add platform device bindings
  staging: dwc2: load parameters from the devicetree

And these patch are just for reference. I'll send the MIPS patches to
the MIPS folks later, the raspberry pi patch isn't quite working yet.

  MIPS: ralink: use the dwc2 driver for the rt305x USB controller
  MIPS: ralink: setup dma_mask for the rt305x dwc2 usb controller
  WIP: enable dwc2 for raspberry pi

Stephen Warren (2):
  staging: dwc2: add const to handling of dwc2_core_params
  staging: dwc2: use irq_return_t for interrupt handlers

 Documentation/devicetree/bindings/staging/dwc2.txt |  51 ++
 arch/arm/Kconfig   |   1 +
 arch/arm/boot/dts/bcm2835.dtsi |   6 +
 arch/arm/configs/bcm2835_defconfig |  20 +-
 arch/mips/ralink/dts/rt3050.dtsi   |   2 +-
 arch/mips/ralink/rt305x-usb.c  |   5 +
 drivers/staging/dwc2/Kconfig   |   6 +-
 drivers/staging/dwc2/Makefile  |   2 +
 drivers/staging/dwc2/core.c| 522 -
 drivers/staging/dwc2/core.h| 198 ++--
 drivers/staging/dwc2/core_intr.c   |  32 +-
 drivers/staging/dwc2/hcd.c | 204 +++-
 drivers/staging/dwc2/hcd.h |  30 +-
 drivers/staging/dwc2/hcd_ddma.c|   8 +-
 drivers/staging/dwc2/hcd_intr.c|  88 ++--
 drivers/staging/dwc2/hcd_queue.c   |   2 +-
 drivers/staging/dwc2/hw.h  | 147 +++---
 drivers/staging/dwc2/pci.c |  24 +-
 drivers/staging/dwc2/platform.c| 218 +
 19 files changed, 997 insertions(+), 569 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/staging/dwc2.txt
 create mode 100644 drivers/staging/dwc2/platform.c

-- 
1.8.0

--
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


[RFC PATCH 11/41] staging: dwc2: remove some device-mode related debug code

2013-04-05 Thread Matthijs Kooijman
This code appears to be partially incorrect. Since this is only debug
code and only applies to device mode, it seems better to remove this
code for now than to invest time fixing it.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index e9f091c..90f4d58 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -1788,8 +1788,6 @@ void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg)
 {
 #ifdef DEBUG
u32 __iomem *addr;
-   int i, ep_num;
-   char *txfsiz;
 
dev_dbg(hsotg->dev, "Core Global Registers\n");
addr = hsotg->regs + GOTGCTL;
@@ -1865,23 +1863,6 @@ void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg)
dev_dbg(hsotg->dev, "HPTXFSIZ@0x%08lX : 0x%08X\n",
(unsigned long)addr, readl(addr));
 
-   if (hsotg->core_params->en_multiple_tx_fifo <= 0) {
-   ep_num = hsotg->hwcfg4 >> GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT &
-GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK >>
-GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT;
-   txfsiz = "DPTXFSIZ";
-   } else {
-   ep_num = hsotg->hwcfg4 >> GHWCFG4_NUM_IN_EPS_SHIFT &
-GHWCFG4_NUM_IN_EPS_MASK >> GHWCFG4_NUM_IN_EPS_SHIFT;
-   txfsiz = "DIENPTXF";
-   }
-
-   for (i = 0; i < ep_num; i++) {
-   addr = hsotg->regs + DPTXFSIZN(i + 1);
-   dev_dbg(hsotg->dev, "%s[%d] @0x%08lX : 0x%08X\n", txfsiz, i + 1,
-   (unsigned long)addr, readl(addr));
-   }
-
addr = hsotg->regs + PCGCTL;
dev_dbg(hsotg->dev, "PCGCTL  @0x%08lX : 0x%08X\n",
(unsigned long)addr, readl(addr));
-- 
1.8.0

--
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


[RFC PATCH 37/41] staging: dwc2: add platform device bindings

2013-04-05 Thread Matthijs Kooijman
This adds a dwc_platform.ko module that can be loaded by using
compatible = "snps,dwc2" in a device tree.

Signed-off-by: Matthijs Kooijman 
---
 Documentation/devicetree/bindings/staging/dwc2.txt |  15 +++
 drivers/staging/dwc2/Kconfig   |   6 +-
 drivers/staging/dwc2/Makefile  |   2 +
 drivers/staging/dwc2/platform.c| 150 +
 4 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/staging/dwc2.txt
 create mode 100644 drivers/staging/dwc2/platform.c

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
new file mode 100644
index 000..3649c88
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -0,0 +1,15 @@
+Platform DesignWare HS OTG USB 2.0 controller
+-
+
+Required properties:
+- compatible : "snps,dwc2"
+- reg : Should contain 1 register range (address and length)
+- interrupts : Should contain 1 interrupt
+
+Example:
+
+otg@101c {
+compatible = "ralink,rt3050-otg, snps,dwc2";
+reg = <0x101c 4>;
+interrupts = <18>;
+};
diff --git a/drivers/staging/dwc2/Kconfig b/drivers/staging/dwc2/Kconfig
index 2f75be7..f0b4739 100644
--- a/drivers/staging/dwc2/Kconfig
+++ b/drivers/staging/dwc2/Kconfig
@@ -8,9 +8,11 @@ config USB_DWC2
  USB controller based on the DesignWare HSOTG IP Core.
 
  If you choose to build this driver as dynamically linked
- modules, the core module will be called dwc2.ko, and the
+ modules, the core module will be called dwc2.ko, the
  PCI bus interface module (if you have a PCI bus system)
- will be called dwc2_pci.ko.
+ will be called dwc2_pci.ko and the platform interface module
+ (for controllers directly connected to the CPU) will be called
+ dwc2_platform.ko.
 
  NOTE: This driver at present only implements the Host mode
  of the controller. The existing s3c-hsotg driver supports
diff --git a/drivers/staging/dwc2/Makefile b/drivers/staging/dwc2/Makefile
index 6dccf46..11529d3 100644
--- a/drivers/staging/dwc2/Makefile
+++ b/drivers/staging/dwc2/Makefile
@@ -19,5 +19,7 @@ dwc2-y+= hcd_queue.o 
hcd_ddma.o
 ifneq ($(CONFIG_PCI),)
obj-$(CONFIG_USB_DWC2)  += dwc2_pci.o
 endif
+obj-$(CONFIG_USB_DWC2) += dwc2_platform.o
 
 dwc2_pci-y += pci.o
+dwc2_platform-y+= platform.o
diff --git a/drivers/staging/dwc2/platform.c b/drivers/staging/dwc2/platform.c
new file mode 100644
index 000..0ffb1b3
--- /dev/null
+++ b/drivers/staging/dwc2/platform.c
@@ -0,0 +1,150 @@
+/*
+ * platform.c - DesignWare HS OTG Controller platform driver
+ *
+ * Copyright (C) 2004-2013 Synopsys, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions, and the following disclaimer,
+ *without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The names of the above-listed copyright holders may not be used
+ *to endorse or promote products derived from this software without
+ *specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "hcd.h"
+
+static const char dwc2_driver_name[] = "dwc2";
+
+/**
+ * dwc2_driver_remove() - Called when the DWC

[RFC PATCH 15/41] staging: dwc2: re-use hptxfsiz variable

2013-04-05 Thread Matthijs Kooijman
For some reason, the value of the HPTXFSIZ register was built in the
ptxfsiz variable, while there was also a hptxfsiz variable availble.
Better just use that.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 4068dd5..07f91e6 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -499,7 +499,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg)
 static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
 {
struct dwc2_core_params *params = hsotg->core_params;
-   u32 rxfsiz, nptxfsiz, ptxfsiz, hptxfsiz, dfifocfg;
+   u32 rxfsiz, nptxfsiz, hptxfsiz, dfifocfg;
 
if (!params->enable_dynamic_fifo)
return;
@@ -531,12 +531,12 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
/* Periodic Tx FIFO */
dev_dbg(hsotg->dev, "initial hptxfsiz=%08x\n",
readl(hsotg->regs + HPTXFSIZ));
-   ptxfsiz = params->host_perio_tx_fifo_size <<
- HPTXFSIZ_P_TXF_DEP_SHIFT & HPTXFSIZ_P_TXF_DEP_MASK;
-   ptxfsiz |= (params->host_rx_fifo_size +
+   hptxfsiz = params->host_perio_tx_fifo_size <<
+  HPTXFSIZ_P_TXF_DEP_SHIFT & HPTXFSIZ_P_TXF_DEP_MASK;
+   hptxfsiz |= (params->host_rx_fifo_size +
params->host_nperio_tx_fifo_size) <<
-  HPTXFSIZ_P_TXF_ST_ADDR_SHIFT & HPTXFSIZ_P_TXF_ST_ADDR_MASK;
-   writel(ptxfsiz, hsotg->regs + HPTXFSIZ);
+   HPTXFSIZ_P_TXF_ST_ADDR_SHIFT & HPTXFSIZ_P_TXF_ST_ADDR_MASK;
+   writel(hptxfsiz, hsotg->regs + HPTXFSIZ);
dev_dbg(hsotg->dev, "new hptxfsiz=%08x\n",
readl(hsotg->regs + HPTXFSIZ));
 
-- 
1.8.0

--
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


[RFC PATCH 32/41] staging: dwc2: register common irq handler in dwc2_core_init

2013-04-05 Thread Matthijs Kooijman
Before, this was initialized in pci.c, after the dwc2_hcd_init was
called and the interrupts were enabled. This opened up a small time
window where common interrupts could be triggered, but there was no
handler for them, causing them to keep triggering infinitely and locking
up the machine.

On my RT3052 board this bug could be easily reproduced by hardcoding
the console log level to 8, so that a bunch of debug output from the dwc2
driver was generated inside this time window. This caused the interrupt
lockup to occur almost every time.

By requesting the irq inside dwc2_core_init and by disabling interrupts
before calling dwc2_core_init instead of after, we can be sure the
handler is registered before the interrupts are enabled, which should
close this window.

Reported-by: Stephen Warren 
Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 12 +++-
 drivers/staging/dwc2/core.h |  2 +-
 drivers/staging/dwc2/hcd.c  | 14 +++---
 drivers/staging/dwc2/pci.c  |  7 ---
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 57b6f9a..4bf26dd 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -371,8 +371,9 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg)
  *
  * @hsotg:  Programming view of the DWC_otg controller
  * @select_phy: If true then also set the Phy type
+ * @irq:If >= 0, the irq to register
  */
-int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy)
+int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq)
 {
u32 usbcfg, otgctl;
int retval;
@@ -421,6 +422,15 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
/* Clear the SRP success bit for FS-I2c */
hsotg->srp_success = 0;
 
+   if (irq >= 0) {
+   dev_dbg(hsotg->dev, "registering common handler for irq%d\n", 
irq);
+   retval = devm_request_irq(hsotg->dev, irq, 
dwc2_handle_common_intr,
+ IRQF_SHARED, dev_name(hsotg->dev),
+ hsotg);
+   if (retval)
+   return retval;
+   }
+
/* Enable common interrupts */
dwc2_enable_common_interrupts(hsotg);
 
diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index aed18e1..e9acbf1 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -541,7 +541,7 @@ extern void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 
*dest, u16 bytes);
 extern void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num);
 extern void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
 
-extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy);
+extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq);
 extern void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
 extern void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
 extern void dwc2_disable_common_interrupts(struct dwc2_hsotg *hsotg);
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 3656a3c..2e1e145 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -1315,7 +1315,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
dev_err(hsotg->dev,
"Connection id status change timed out");
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
-   dwc2_core_init(hsotg, false);
+   dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
} else {
/* A-Device connector (Host Mode) */
@@ -1334,7 +1334,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
hsotg->op_state = OTG_STATE_A_HOST;
 
/* Initialize the Core for Host mode */
-   dwc2_core_init(hsotg, false);
+   dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
dwc2_hcd_start(hsotg);
}
@@ -2765,17 +2765,17 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg;
hsotg->priv = hcd;
 
-   /* Initialize the DWC_otg core, and select the Phy type */
-   retval = dwc2_core_init(hsotg, true);
-   if (retval)
-   goto error2;
-
/*
 * Disable the global interrupt until all the interrupt handlers are
 * installed
 */
dwc2_disable_global_interrupts(hsotg);
 
+   /* Initialize the DWC_otg core, and select the Phy type */
+   retval = dwc2_core_init(hsotg, true, irq);
+   if (retval)
+   goto error2;
+
/* Create new workqueue and init work */
hsotg->wq_otg = create_singlethread_workqueue("dwc_otg");
if (!hsotg->wq_otg) {
diff --git a/drivers/staging/dwc2/pci.c b/driv

[RFC PATCH 40/41] MIPS: ralink: setup dma_mask for the rt305x dwc2 usb controller

2013-04-05 Thread Matthijs Kooijman
---
 arch/mips/ralink/rt305x-usb.c | 5 +
 1 file changed, 5 insertions(+)

This patch is just FYI.

diff --git a/arch/mips/ralink/rt305x-usb.c b/arch/mips/ralink/rt305x-usb.c
index 793fc82..7d87740 100644
--- a/arch/mips/ralink/rt305x-usb.c
+++ b/arch/mips/ralink/rt305x-usb.c
@@ -108,6 +108,7 @@ error_out:
 
 static u64 rt3352_ohci_dmamask = DMA_BIT_MASK(32);
 static u64 rt3352_ehci_dmamask = DMA_BIT_MASK(32);
+static u64 rt3050_dwc2_dmamask = DMA_BIT_MASK(32);
 
 void ralink_usb_platform(void)
 {
@@ -117,4 +118,8 @@ void ralink_usb_platform(void)
ralink_add_usb("ehci-platform",
&rt3352_ehci_data, &rt3352_ehci_dmamask);
}
+   if (soc_is_rt305x() || soc_is_rt3350()) {
+   ralink_add_usb("ralink,rt3050-otg",
+   NULL, &rt3050_dwc2_dmamask);
+   }
 }
-- 
1.8.0

--
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


[RFC PATCH 13/41] staging: dwc2: add missing shift

2013-04-05 Thread Matthijs Kooijman
This line extracted the available queue space without properly shifting
it. Since the code only cared wether it was zero or not, it worked as
expected without the shift, but adding shift makes the code cleaner.

While we're here, store the result in a helper variable that was already
declared to increase readability a bit more.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 29f9911..458669b 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -1021,7 +1021,9 @@ static void dwc2_process_periodic_channels(struct 
dwc2_hsotg *hsotg)
qh_ptr = hsotg->periodic_sched_assigned.next;
while (qh_ptr != &hsotg->periodic_sched_assigned) {
tx_status = readl(hsotg->regs + HPTXSTS);
-   if ((tx_status & TXSTS_QSPCAVAIL_MASK) == 0) {
+   qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >>
+   TXSTS_QSPCAVAIL_SHIFT;
+   if (qspcavail == 0) {
no_queue_space = 1;
break;
}
-- 
1.8.0

--
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


[RFC PATCH 12/41] staging: dwc2: simplify register shift expressions

2013-04-05 Thread Matthijs Kooijman
This commit changes expressions from (val >> shift) & (mask >> shift) to
(val & mask) >> shift.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 20 ++---
 drivers/staging/dwc2/hcd.c  | 62 +++--
 drivers/staging/dwc2/hcd_ddma.c |  8 +++---
 drivers/staging/dwc2/hcd_intr.c | 22 ++-
 4 files changed, 50 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 90f4d58..e64eb95 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -1367,14 +1367,14 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
dev_vdbg(hsotg->dev, "%s: Channel %d\n", __func__, 
chan->hc_num);
dev_vdbg(hsotg->dev, "   Xfer Size: %d\n",
-hctsiz >> TSIZ_XFERSIZE_SHIFT &
-TSIZ_XFERSIZE_MASK >> TSIZ_XFERSIZE_SHIFT);
+(hctsiz & TSIZ_XFERSIZE_MASK) >>
+TSIZ_XFERSIZE_SHIFT);
dev_vdbg(hsotg->dev, "   Num Pkts: %d\n",
-hctsiz >> TSIZ_PKTCNT_SHIFT &
-TSIZ_PKTCNT_MASK >> TSIZ_PKTCNT_SHIFT);
+(hctsiz & TSIZ_PKTCNT_MASK) >>
+TSIZ_PKTCNT_SHIFT);
dev_vdbg(hsotg->dev, "   Start PID: %d\n",
-hctsiz >> TSIZ_SC_MC_PID_SHIFT &
-TSIZ_SC_MC_PID_MASK >> TSIZ_SC_MC_PID_SHIFT);
+(hctsiz & TSIZ_SC_MC_PID_MASK) >>
+TSIZ_SC_MC_PID_SHIFT);
}
 
if (hsotg->core_params->dma_enable > 0) {
@@ -1418,8 +1418,8 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "   Multi Cnt: %d\n",
-hcchar >> HCCHAR_MULTICNT_SHIFT &
-HCCHAR_MULTICNT_MASK >> HCCHAR_MULTICNT_SHIFT);
+(hcchar & HCCHAR_MULTICNT_MASK) >>
+HCCHAR_MULTICNT_SHIFT);
 
writel(hcchar, hsotg->regs + HCCHAR(chan->hc_num));
if (dbg_hc(chan))
@@ -1504,8 +1504,8 @@ void dwc2_hc_start_transfer_ddma(struct dwc2_hsotg *hsotg,
 
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "   Multi Cnt: %d\n",
-hcchar >> HCCHAR_MULTICNT_SHIFT &
-HCCHAR_MULTICNT_MASK >> HCCHAR_MULTICNT_SHIFT);
+(hcchar & HCCHAR_MULTICNT_MASK) >>
+HCCHAR_MULTICNT_SHIFT);
 
writel(hcchar, hsotg->regs + HCCHAR(chan->hc_num));
if (dbg_hc(chan))
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 98827b9..29f9911 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -1007,10 +1007,10 @@ static void dwc2_process_periodic_channels(struct 
dwc2_hsotg *hsotg)
#endif
 
tx_status = readl(hsotg->regs + HPTXSTS);
-   qspcavail = tx_status >> TXSTS_QSPCAVAIL_SHIFT &
-   TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT;
-   fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT &
-   TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT;
+   qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >>
+   TXSTS_QSPCAVAIL_SHIFT;
+   fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >>
+   TXSTS_FSPCAVAIL_SHIFT;
#ifdef CONFIG_USB_DWC2_DEBUG_PERIODIC
dev_vdbg(hsotg->dev, "  P Tx Req Queue Space Avail (before queue): 
%d\n",
 qspcavail);
@@ -1047,8 +1047,8 @@ static void dwc2_process_periodic_channels(struct 
dwc2_hsotg *hsotg)
qh->channel->multi_count > 1)
hsotg->queuing_high_bandwidth = 1;
 
-   fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT &
-   TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT;
+   fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >>
+   TXSTS_FSPCAVAIL_SHIFT;
status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail);
if (status < 0) {
no_fifo_space = 1;
@@ -1079,10 +1079,10 @@ static void dwc2_process_periodic_channels(struct 
dwc2_hsotg *hsotg)
 
if (hsotg->core_params->dma_enable <= 0) {
tx_status = readl(hsotg->regs + HPTXSTS);
-   qspcavail = tx_status >> TXSTS_QSPCAVAIL_SHIFT &
-   TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT;
-   fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT &
-   TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT;
+   qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >>
+   TXSTS_QSPCAVAIL_SHIFT;
+   fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >>
+   TXSTS_FSPCAVAIL_SHIFT;
#ifdef CONFIG_USB_DWC2_DEBUG_PERIOD

[RFC PATCH 41/41] WIP: enable dwc2 for raspberry pi

2013-04-05 Thread Matthijs Kooijman
---
 arch/arm/Kconfig   |  1 +
 arch/arm/boot/dts/bcm2835.dtsi |  6 ++
 arch/arm/configs/bcm2835_defconfig | 20 ++--
 3 files changed, 21 insertions(+), 6 deletions(-)

This patch is just FYI.

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 13b7394..7607200 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -377,6 +377,7 @@ config ARCH_BCM2835
select PINCTRL_BCM2835
select SPARSE_IRQ
select USE_OF
+   select VIRT_TO_BUS
help
  This enables support for the Broadcom BCM2835 SoC. This SoC is
  use in the Raspberry Pi, and Roku 2 devices.
diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi
index 7e0481e..000def4 100644
--- a/arch/arm/boot/dts/bcm2835.dtsi
+++ b/arch/arm/boot/dts/bcm2835.dtsi
@@ -87,6 +87,12 @@
clocks = <&clk_mmc>;
status = "disabled";
};
+
+   usb {
+   compatible = "brcm,bcm2835-usb", "snps,dwc2";
+   reg = <0x7e98 0x1>;
+   interrupts = <1 9>;
+   };
};
 
clocks {
diff --git a/arch/arm/configs/bcm2835_defconfig 
b/arch/arm/configs/bcm2835_defconfig
index af472e4..1fa601e 100644
--- a/arch/arm/configs/bcm2835_defconfig
+++ b/arch/arm/configs/bcm2835_defconfig
@@ -29,6 +29,8 @@ CONFIG_EMBEDDED=y
 CONFIG_PROFILING=y
 CONFIG_OPROFILE=y
 CONFIG_JUMP_LABEL=y
+CONFIG_ARCH_MULTI_V6=y
+# CONFIG_ARCH_MULTI_V7 is not set
 CONFIG_ARCH_BCM2835=y
 CONFIG_PREEMPT_VOLUNTARY=y
 CONFIG_AEABI=y
@@ -45,10 +47,12 @@ CONFIG_NET=y
 CONFIG_UNIX=y
 CONFIG_INET=y
 CONFIG_NETWORK_SECMARK=y
-# CONFIG_WIRELESS is not set
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_STANDALONE is not set
+CONFIG_NETDEVICES=y
+CONFIG_ENC28J60=y
+CONFIG_ENC28J60_WRITEVERIFY=y
 # CONFIG_INPUT_MOUSEDEV is not set
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
@@ -63,13 +67,21 @@ CONFIG_TTY_PRINTK=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_BCM2835=y
+CONFIG_SPI=y
+CONFIG_SPI_DEBUG=y
+CONFIG_SPI_BCM2835=y
 CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
-# CONFIG_USB_SUPPORT is not set
+CONFIG_USB=y
+CONFIG_USB_DEBUG=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
 CONFIG_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_BCM2835=y
+CONFIG_STAGING=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_DWC2_DEBUG=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
@@ -108,9 +120,5 @@ CONFIG_TEST_KSTRTOX=y
 CONFIG_STRICT_DEVMEM=y
 CONFIG_DEBUG_LL=y
 CONFIG_EARLY_PRINTK=y
-# CONFIG_XZ_DEC_X86 is not set
-# CONFIG_XZ_DEC_POWERPC is not set
-# CONFIG_XZ_DEC_IA64 is not set
 # CONFIG_XZ_DEC_ARM is not set
 # CONFIG_XZ_DEC_ARMTHUMB is not set
-# CONFIG_XZ_DEC_SPARC is not set
-- 
1.8.0

--
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


[RFC PATCH 06/41] staging: dwc2: remove unneeded check

2013-04-05 Thread Matthijs Kooijman
The value in params->enable_dynamic_fifo can only be true if the
corresponding bit in hwcfg2 is set, this is already checked by
dwc2_set_param_enable_dynamic_fifo.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 9a34ac7..af5e7d9 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -495,8 +495,7 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
struct dwc2_core_params *params = hsotg->core_params;
u32 rxfsiz, nptxfsiz, ptxfsiz, hptxfsiz, dfifocfg;
 
-   if (!(hsotg->hwcfg2 & GHWCFG2_DYNAMIC_FIFO) ||
-   !params->enable_dynamic_fifo)
+   if (!params->enable_dynamic_fifo)
return;
 
dev_dbg(hsotg->dev, "Total FIFO Size=%d\n", hsotg->total_fifo_size);
-- 
1.8.0

--
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


[RFC PATCH 23/41] staging: dwc2: do not use IRQF_DISABLED

2013-04-05 Thread Matthijs Kooijman
This flag is a deprecated NOOP, interrupt handlers are always run
with interupts disabled.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

See include/linux/interrupt.h and 6932bf37 (genirq: Remove IRQF_DISABLED
from core code).

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 1f375ac..01e7eb1 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2857,7 +2857,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 * allocates the DMA buffer pool, registers the USB bus, requests the
 * IRQ line, and calls hcd_start method.
 */
-   retval = usb_add_hcd(hcd, irq, IRQF_SHARED | IRQF_DISABLED);
+   retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (retval < 0)
goto error3;
 
-- 
1.8.0

--
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


[RFC PATCH 02/41] staging: dwc2: disable dma when no dma_mask was setup

2013-04-05 Thread Matthijs Kooijman
If the platform driver failed to setup a dma_mask, but the hardware
advertises support for DMA, before DMA would be enabled in dwc2, but
disabled in the usb core, making all connectivity break.

With this commit, the dwc2 driver will emit a warning and fall back to
slave mode in this case.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 0eb4a3b..c73ddf2 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2797,6 +2797,16 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
/* Validate parameter values */
dwc2_set_parameters(hsotg, params);
 
+   /* Check if the bus driver or platform code has setup a
+* dma_mask for us. */
+   if (hsotg->core_params->dma_enable > 0 &&
+   hsotg->dev->dma_mask == NULL) {
+   dev_warn(hsotg->dev,
+"dma_mask not set, disabling DMA\n");
+   hsotg->core_params->dma_enable = 0;
+   hsotg->core_params->dma_desc_enable = 0;
+   }
+
/* Set device flags indicating whether the HCD supports DMA */
if (hsotg->core_params->dma_enable > 0) {
if (dma_set_mask(hsotg->dev, DMA_BIT_MASK(31)) < 0)
-- 
1.8.0

--
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


[RFC PATCH 35/41] staging: dwc2: set the driver name to "dwc2"

2013-04-05 Thread Matthijs Kooijman
Previously, it was "dwc_otg", but this does not correspond to the
directory name and might cause confusion with the old out-of-tree
dwc_otg driver of which many versions circulate.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd.c | 2 +-
 drivers/staging/dwc2/pci.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 2e1e145..409e5e5 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2777,7 +2777,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
goto error2;
 
/* Create new workqueue and init work */
-   hsotg->wq_otg = create_singlethread_workqueue("dwc_otg");
+   hsotg->wq_otg = create_singlethread_workqueue("dwc2");
if (!hsotg->wq_otg) {
dev_err(hsotg->dev, "Failed to create workqueue\n");
goto error2;
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index a1d2ede..2b251c6 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -50,7 +50,7 @@
 #define PCI_VENDOR_ID_SYNOPSYS 0x16c3
 #define PCI_PRODUCT_ID_HAPS_HSOTG  0xabc0
 
-static const char dwc2_driver_name[] = "dwc_otg";
+static const char dwc2_driver_name[] = "dwc2";
 
 static struct dwc2_core_params dwc2_module_params = {
.otg_cap= -1,
-- 
1.8.0

--
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


[RFC PATCH 27/41] staging: dwc2: add dwc2_disable_common_interrupts function

2013-04-05 Thread Matthijs Kooijman
This function disables all "common interrupts", i.e., those that are
handled by the common interrupt handler.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c  | 14 ++
 drivers/staging/dwc2/core.h  |  6 ++
 drivers/staging/dwc2/core_intr.c |  5 -
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 1cadb93..a3b8556 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -81,6 +81,20 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
writel(intmsk, hsotg->regs + GINTMSK);
 }
 
+/**
+ * dwc2_disable_common_interrupts() - Disables the common interrupts
+ *
+ * @hsotg: Programming view of DWC_otg controller
+ */
+void dwc2_disable_common_interrupts(struct dwc2_hsotg *hsotg)
+{
+   u32 intmsk = readl(hsotg->regs + GINTMSK);
+
+   /* Disable common interrupts without disturbing host mode interrupts */
+   intmsk &= ~(GINTMSK_COMMON);
+   writel(intmsk, hsotg->regs + GINTMSK);
+}
+
 /*
  * Initializes the FSLSPClkSel field of the HCFG register depending on the
  * PHY type
diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index 2817b60..0fa479e 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -544,6 +544,7 @@ extern void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
 extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy);
 extern void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
 extern void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
+extern void dwc2_disable_common_interrupts(struct dwc2_hsotg *hsotg);
 
 /* This function should be called on every hardware interrupt. */
 extern irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
@@ -751,4 +752,9 @@ extern void dwc2_dump_global_registers(struct dwc2_hsotg 
*hsotg);
  */
 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 
+#define GINTMSK_COMMON (GINTSTS_WKUPINT | GINTSTS_SESSREQINT | \
+GINTSTS_CONIDSTSCHNG | GINTSTS_OTGINT | \
+GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
+GINTSTS_USBSUSP | GINTSTS_RESTOREDONE)
+
 #endif /* __DWC2_CORE_H__ */
diff --git a/drivers/staging/dwc2/core_intr.c b/drivers/staging/dwc2/core_intr.c
index 3099f2d..c0f0272 100644
--- a/drivers/staging/dwc2/core_intr.c
+++ b/drivers/staging/dwc2/core_intr.c
@@ -400,11 +400,6 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
writel(GINTSTS_USBSUSP, hsotg->regs + GINTSTS);
 }
 
-#define GINTMSK_COMMON (GINTSTS_WKUPINT | GINTSTS_SESSREQINT | \
-GINTSTS_CONIDSTSCHNG | GINTSTS_OTGINT |\
-GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
-GINTSTS_USBSUSP | GINTSTS_RESTOREDONE)
-
 /*
  * This function returns the Core Interrupt register
  */
-- 
1.8.0

--
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


[RFC PATCH 05/41] staging: dwc2: replace some magic numbers by constants

2013-04-05 Thread Matthijs Kooijman
Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 9162bed..9a34ac7 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -1667,7 +1667,7 @@ u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg)
GHWCFG2_FS_PHY_TYPE_DEDICATED)
clock = 48;
 
-   if ((hprt0 & HPRT0_SPD_MASK) == 0)
+   if ((hprt0 & HPRT0_SPD_MASK) == HPRT0_SPD_HIGH_SPEED)
/* High speed case */
return 125 * clock;
else
@@ -2269,7 +2269,7 @@ int dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int 
val)
 #ifndef NO_FS_PHY_HW_CHECKS
valid = 0;
 #else
-   val = 0;
+   val = DWC2_PHY_TYPE_PARAM_FS;
dev_dbg(hsotg->dev, "Setting phy_type to %d\n", val);
retval = -EINVAL;
 #endif
@@ -2296,7 +2296,7 @@ int dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int 
val)
dev_err(hsotg->dev,
"%d invalid for phy_type. Check HW 
configuration.\n",
val);
-   val = 0;
+   val = DWC2_PHY_TYPE_PARAM_FS;
if (hs_phy_type != GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED) {
if (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI ||
hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI)
@@ -2331,8 +2331,8 @@ int dwc2_set_param_speed(struct dwc2_hsotg *hsotg, int 
val)
valid = 0;
}
 
-   if (val == 0 && dwc2_get_param_phy_type(hsotg) ==
-   DWC2_PHY_TYPE_PARAM_FS)
+   if (val == DWC2_SPEED_PARAM_HIGH &&
+   dwc2_get_param_phy_type(hsotg) == DWC2_PHY_TYPE_PARAM_FS)
valid = 0;
 
if (!valid) {
@@ -2341,7 +2341,7 @@ int dwc2_set_param_speed(struct dwc2_hsotg *hsotg, int 
val)
"%d invalid for speed parameter. Check HW 
configuration.\n",
val);
val = dwc2_get_param_phy_type(hsotg) == DWC2_PHY_TYPE_PARAM_FS ?
-   1 : 0;
+   DWC2_SPEED_PARAM_FULL : DWC2_SPEED_PARAM_HIGH;
dev_dbg(hsotg->dev, "Setting speed to %d\n", val);
retval = -EINVAL;
}
-- 
1.8.0

--
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


[RFC PATCH 14/41] staging: dwc2: simplify debug output in dwc_hc_init

2013-04-05 Thread Matthijs Kooijman
Before, the value of the hcchar register was shifted and masked and then
the debug output extracted the individual values out of the complete
hcchar register again. This commit makes the debug prints directly use
the original values instead.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 29 -
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index e64eb95..4068dd5 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -881,24 +881,13 @@ void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct 
dwc2_host_chan *chan)
dev_vdbg(hsotg->dev, "set HCCHAR(%d) to %08x\n", hc_num, 
hcchar);
 
dev_vdbg(hsotg->dev, "%s: Channel %d\n", __func__, hc_num);
-   dev_vdbg(hsotg->dev, "   Dev Addr: %d\n",
-hcchar >> HCCHAR_DEVADDR_SHIFT &
-HCCHAR_DEVADDR_MASK >> HCCHAR_DEVADDR_SHIFT);
-   dev_vdbg(hsotg->dev, "   Ep Num: %d\n",
-hcchar >> HCCHAR_EPNUM_SHIFT &
-HCCHAR_EPNUM_MASK >> HCCHAR_EPNUM_SHIFT);
-   dev_vdbg(hsotg->dev, "   Is In: %d\n", !!(hcchar & 
HCCHAR_EPDIR));
-   dev_vdbg(hsotg->dev, "   Is Low Speed: %d\n",
-!!(hcchar & HCCHAR_LSPDDEV));
-   dev_vdbg(hsotg->dev, "   Ep Type: %d\n",
-hcchar >> HCCHAR_EPTYPE_SHIFT &
-HCCHAR_EPTYPE_MASK >> HCCHAR_EPTYPE_SHIFT);
-   dev_vdbg(hsotg->dev, "   Max Pkt: %d\n",
-hcchar >> HCCHAR_MPS_SHIFT &
-HCCHAR_MPS_MASK >> HCCHAR_MPS_SHIFT);
-   dev_vdbg(hsotg->dev, "   Multi Cnt: %d\n",
-hcchar >> HCCHAR_MULTICNT_SHIFT &
-HCCHAR_MULTICNT_MASK >> HCCHAR_MULTICNT_SHIFT);
+   dev_vdbg(hsotg->dev, "   Dev Addr: %d\n", chan->dev_addr);
+   dev_vdbg(hsotg->dev, "   Ep Num: %d\n", chan->ep_num);
+   dev_vdbg(hsotg->dev, "   Is In: %d\n", chan->ep_is_in);
+   dev_vdbg(hsotg->dev, "   Is Low Speed: %d\n", chan->speed == 
USB_SPEED_LOW);
+   dev_vdbg(hsotg->dev, "   Ep Type: %d\n", chan->ep_type);
+   dev_vdbg(hsotg->dev, "   Max Pkt: %d\n", chan->max_packet);
+   dev_vdbg(hsotg->dev, "   Multi Cnt: %d\n", 0);
}
 
/* Program the HCSPLT register for SPLITs */
@@ -921,9 +910,7 @@ void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct 
dwc2_host_chan *chan)
dev_vdbg(hsotg->dev, "hub addr %d\n", 
chan->hub_addr);
dev_vdbg(hsotg->dev, "hub port %d\n", 
chan->hub_port);
dev_vdbg(hsotg->dev, "is_in %d\n", chan->ep_is_in);
-   dev_vdbg(hsotg->dev, "Max Pkt %d\n",
-hcchar >> HCCHAR_MPS_SHIFT &
-HCCHAR_MPS_MASK >> HCCHAR_MPS_SHIFT);
+   dev_vdbg(hsotg->dev, "Max Pkt %d\n", 
chan->max_packet);
dev_vdbg(hsotg->dev, "xferlen %d\n", 
chan->xfer_len);
}
}
-- 
1.8.0

--
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


[RFC PATCH 34/41] staging: dwc2: cleanup includes in pci.c

2013-04-05 Thread Matthijs Kooijman
Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/pci.c | 7 ---
 1 file changed, 7 deletions(-)

This is just the minimal list of includes that made the compile work.
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index acf2008..a1d2ede 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -40,16 +40,9 @@
  */
 #include 
 #include 
-#include 
-#include 
 #include 
-#include 
 #include 
 #include 
-#include 
-
-#include 
-#include 
 
 #include "core.h"
 #include "hcd.h"
-- 
1.8.0

--
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


[RFC PATCH 36/41] staging: dwc2: Make dwc2_set_uninitialized more specific

2013-04-05 Thread Matthijs Kooijman
Before, it was a function that would set all members of a given struct
containing only int members to -1. Now, it is renamed to
dwc_set_all_params and it works only on the dwc2_core_params struct.
This makes sure that all of the slightly dubious casting and assumptions
happen inside the function instead of by the caller.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.h |  2 ++
 drivers/staging/dwc2/hcd.c  | 12 +---
 drivers/staging/dwc2/hcd.h  |  1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index e9acbf1..a60de0f 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -193,6 +193,8 @@ enum dwc2_lx_state {
  * default described above.
  */
 struct dwc2_core_params {
+   /* Don't add any non-int members here, this will break
+* dwc2_set_all_params! */
int otg_cap;
int otg_ver;
int dma_enable;
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 409e5e5..747e787 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2673,8 +2673,15 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg)
dwc2_hcd_free(hsotg);
 }
 
-static void dwc2_set_uninitialized(int *p, int size)
+/*
+ * Sets all parameters to the given value.
+ *
+ * Assumes that the dwc2_core_params struct contains only integers.
+ */
+void dwc2_set_all_params(struct dwc2_core_params *params, int value)
 {
+   int *p = (int*)params;
+   size_t size = sizeof(*params) / sizeof(*p);
int i;
 
for (i = 0; i < size; i++)
@@ -2726,8 +2733,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
if (!hsotg->core_params)
goto error1;
 
-   dwc2_set_uninitialized((int *)hsotg->core_params,
-  sizeof(*hsotg->core_params) / sizeof(int));
+   dwc2_set_all_params(hsotg->core_params, -1);
 
/* Validate parameter values */
dwc2_set_parameters(hsotg, params);
diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h
index 5d90f4c..8b648e7 100644
--- a/drivers/staging/dwc2/hcd.h
+++ b/drivers/staging/dwc2/hcd.h
@@ -453,6 +453,7 @@ extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
 extern int dwc2_set_parameters(struct dwc2_hsotg *hsotg,
   const struct dwc2_core_params *params);
 extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
+extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
 
 /* Transaction Execution Functions */
 extern enum dwc2_transaction_type dwc2_hcd_select_transactions(
-- 
1.8.0

--
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


[RFC PATCH 09/41] staging: dwc2: unshift non-bool register value constants

2013-04-05 Thread Matthijs Kooijman
Various register fields wider than one bit have constants defined for
their value. Previously, these registers would define the values as they
appear in the register, so shifted to the right to the position the
value appears in the register.

This commit changes those constants to their natural values (e.g, 0, 1,
2, etc.), as they are after shifting the register value to the right.
This also changes all relevant code to shift the values before comparing
them with constants.

This has the advantage that the values can be stored in smaller
variables (now they always require a u32) and makes the handling of
these values more consistent with other register fields that represent
natural numbers instead of enumerations (e.g., number of host channels).

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c  |  52 ++--
 drivers/staging/dwc2/hcd.c   |   2 +-
 drivers/staging/dwc2/hcd.h   |  18 +++---
 drivers/staging/dwc2/hcd_intr.c  |  19 +++---
 drivers/staging/dwc2/hcd_queue.c |   2 +-
 drivers/staging/dwc2/hw.h| 128 +++
 6 files changed, 117 insertions(+), 104 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index e503aed..e9f091c 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -90,8 +90,10 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
  */
 static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg)
 {
-   u32 hs_phy_type = hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK;
-   u32 fs_phy_type = hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK;
+   u32 hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >>
+ GHWCFG2_HS_PHY_TYPE_SHIFT;
+   u32 fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >>
+ GHWCFG2_FS_PHY_TYPE_SHIFT;
u32 hcfg, val;
 
if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&
@@ -108,7 +110,7 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg 
*hsotg)
dev_dbg(hsotg->dev, "Initializing HCFG.FSLSPClkSel to %08x\n", val);
hcfg = readl(hsotg->regs + HCFG);
hcfg &= ~HCFG_FSLSPCLKSEL_MASK;
-   hcfg |= val;
+   hcfg |= val << HCFG_FSLSPCLKSEL_SHIFT;
writel(hcfg, hsotg->regs + HCFG);
 }
 
@@ -256,8 +258,10 @@ static void dwc2_phy_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
dwc2_hs_phy_init(hsotg, select_phy);
}
 
-   hs_phy_type = hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK;
-   fs_phy_type = hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK;
+   hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >>
+ GHWCFG2_HS_PHY_TYPE_SHIFT
+   fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >>
+ GHWCFG2_FS_PHY_TYPE_SHIFT
 
if (hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&
fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED &&
@@ -279,7 +283,8 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg)
 {
u32 ahbcfg = 0;
 
-   switch (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) {
+   switch ((hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >>
+   GHWCFG2_ARCHITECTURE_SHIFT) {
case GHWCFG2_EXT_DMA_ARCH:
dev_err(hsotg->dev, "External DMA Mode not supported\n");
return -EINVAL;
@@ -290,7 +295,7 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg)
 * Old value was GAHBCFG_HBSTLEN_INCR - done for
 * Host mode ISOC in issue fix - vahrama
 */
-   ahbcfg |= GAHBCFG_HBSTLEN_INCR4;
+   ahbcfg |= GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT;
break;
 
case GHWCFG2_SLAVE_ONLY_ARCH:
@@ -331,7 +336,8 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg)
usbcfg = readl(hsotg->regs + GUSBCFG);
usbcfg &= ~(GUSBCFG_HNPCAP | GUSBCFG_SRPCAP);
 
-   switch (hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) {
+   switch ((hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >>
+   GHWCFG_OP_MODE_SHIFT) {
case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE:
if (hsotg->core_params->otg_cap ==
DWC2_CAP_PARAM_HNP_SRP_CAPABLE)
@@ -591,7 +597,8 @@ void dwc2_core_host_init(struct dwc2_hsotg *hsotg)
}
 
if (hsotg->core_params->dma_desc_enable > 0) {
-   u32 op_mode = hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK;
+   u32 op_mode = (hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >>
+ GHCFG2_OP_MODE_SHIFT;
 
if (hsotg->snpsid < DWC2_CORE_REV_2_90a ||
!(hsotg->hwcfg4 & GHWCFG4_DESC_DMA) ||
@@ -1640,7 +1647,8 @@ u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg)
if (!(usbcfg & GUSBCFG_PHYSEL) && (usbcfg & GUSBCFG_ULPI_UTMI_SEL) &&
!(usbcfg & GUSBCFG_PHYIF16))
clock = 60;
-   if ((usbcfg & GUSBCFG_PHYSEL) && (hwcfg2 & GHWCFG2_

[RFC PATCH 21/41] staging: dwc2: add const to handling of dwc2_core_params

2013-04-05 Thread Matthijs Kooijman
From: Stephen Warren 

Signed-off-by: Stephen Warren 
[matth...@stdin.nl: Split patch from bigger patch and added commit message]
Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 2 +-
 drivers/staging/dwc2/hcd.c  | 2 +-
 drivers/staging/dwc2/hcd.h  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index e1a70de..66aa4aa 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -2723,7 +2723,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
  * for the DWC_otg core. It returns non-0 if any parameters are invalid.
  */
 int dwc2_set_parameters(struct dwc2_hsotg *hsotg,
-   struct dwc2_core_params *params)
+   const struct dwc2_core_params *params)
 {
int retval = 0;
 
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 6a9174d..c0a0999 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2692,7 +2692,7 @@ static void dwc2_set_uninitialized(int *p, int size)
  * a negative error on failure.
  */
 int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
- struct dwc2_core_params *params)
+ const struct dwc2_core_params *params)
 {
struct usb_hcd *hcd;
struct dwc2_host_chan *channel;
diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h
index dbae0c4..8d8e20b 100644
--- a/drivers/staging/dwc2/hcd.h
+++ b/drivers/staging/dwc2/hcd.h
@@ -448,10 +448,10 @@ static inline u8 dwc2_hcd_is_pipe_out(struct 
dwc2_hcd_pipe_info *pipe)
 }
 
 extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
-struct dwc2_core_params *params);
+const struct dwc2_core_params *params);
 extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
 extern int dwc2_set_parameters(struct dwc2_hsotg *hsotg,
-  struct dwc2_core_params *params);
+  const struct dwc2_core_params *params);
 extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
 
 /* Transaction Execution Functions */
-- 
1.8.0

--
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


[RFC PATCH 10/41] staging: dwc2: only read the snpsid register once

2013-04-05 Thread Matthijs Kooijman
This (read-only) register was read twice, storing it for later use the
second time. Now it is only read once, storing it right away.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 84c3c56..98827b9 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2700,7 +2700,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 {
struct usb_hcd *hcd;
struct dwc2_host_chan *channel;
-   u32 snpsid, gusbcfg, hcfg;
+   u32 gusbcfg, hcfg;
int i, num_channels;
int retval = -ENOMEM;
 
@@ -2712,10 +2712,10 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 * 0x45f42xxx or 0x45f43xxx, which corresponds to either "OT2" or "OT3",
 * as in "OTG version 2.xx" or "OTG version 3.xx".
 */
-   snpsid = readl(hsotg->regs + GSNPSID);
-   if ((snpsid & 0xf000) != 0x4f542000 &&
-   (snpsid & 0xf000) != 0x4f543000) {
-   dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", snpsid);
+   hsotg->snpsid = readl(hsotg->regs + GSNPSID);
+   if ((hsotg->snpsid & 0xf000) != 0x4f542000 &&
+   (hsotg->snpsid & 0xf000) != 0x4f543000) {
+   dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", 
hsotg->snpsid);
retval = -ENODEV;
goto error1;
}
@@ -2849,7 +2849,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
}
INIT_WORK(&hsotg->wf_otg, dwc2_conn_id_status_change);
 
-   hsotg->snpsid = readl(hsotg->regs + GSNPSID);
dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x\n",
hsotg->snpsid >> 12 & 0xf, hsotg->snpsid >> 8 & 0xf,
hsotg->snpsid >> 4 & 0xf, hsotg->snpsid & 0xf);
-- 
1.8.0

--
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


[RFC PATCH 01/41] staging: dwc2: when dma is disabled, clear dev->dma_mask

2013-04-05 Thread Matthijs Kooijman
Instead of just setting the dma_mask to the empty mask, the pointer to
the mask is cleared altogether. This is needed because
usb_create_shared_hcd sets hcd->self.uses_dma based on
dev->dma_mask != NULL, not by looking at the actual mask itself.

This change thus makes hcd->self.uses_dma have the correct value when
not using dma even though a dma_mask was set up by the platform or pci
driver (which in practice should only occur when manually disabling
dma, assuming that a dma_mask is normally only setup when dma is
supported and enabled). This in turn prevents usb core from doing some
dma-specific stuff that isn't needed (though everything seemed to work
with the wrong value of uses_dma as well).

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 5b55649..0eb4a3b 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2806,7 +2806,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
dev_warn(hsotg->dev,
 "can't enable workaround for >2GB RAM\n");
} else {
-   dma_set_mask(hsotg->dev, 0);
+   hsotg->dev->dma_mask = NULL;
dma_set_coherent_mask(hsotg->dev, 0);
}
 
-- 
1.8.0

--
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


[RFC PATCH 03/41] staging: dwc2: fix naming of register constants

2013-04-05 Thread Matthijs Kooijman
A generic set of FIFOSIZE_* constants was used for both the GNPTXFSIZ
and HPTXFSIZ registers, even where a specific set of constants was a
available for the GNPTXFSIZ register. This change adds specific
constants for the HPTXFSIZ register as well, changes the code to use
those specific constants and removes the generic constants.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c |  8 
 drivers/staging/dwc2/hw.h   | 14 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 609129d..5d6f9fa 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -516,9 +516,9 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
dev_dbg(hsotg->dev, "initial gnptxfsiz=%08x\n",
readl(hsotg->regs + GNPTXFSIZ));
nptxfsiz = params->host_nperio_tx_fifo_size <<
-  FIFOSIZE_DEPTH_SHIFT & FIFOSIZE_DEPTH_MASK;
+  GNPTXFSIZ_NP_TXF_DEP_SHIFT & GNPTXFSIZ_NP_TXF_DEP_MASK;
nptxfsiz |= params->host_rx_fifo_size <<
-   FIFOSIZE_STARTADDR_SHIFT & FIFOSIZE_STARTADDR_MASK;
+   GNPTXFSIZ_NP_TXF_ST_ADDR_SHIFT & 
GNPTXFSIZ_NP_TXF_ST_ADDR_MASK;
writel(nptxfsiz, hsotg->regs + GNPTXFSIZ);
dev_dbg(hsotg->dev, "new gnptxfsiz=%08x\n",
readl(hsotg->regs + GNPTXFSIZ));
@@ -527,10 +527,10 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
dev_dbg(hsotg->dev, "initial hptxfsiz=%08x\n",
readl(hsotg->regs + HPTXFSIZ));
ptxfsiz = params->host_perio_tx_fifo_size <<
- FIFOSIZE_DEPTH_SHIFT & FIFOSIZE_DEPTH_MASK;
+ HPTXFSIZ_P_TXF_DEP_SHIFT & HPTXFSIZ_P_TXF_DEP_MASK;
ptxfsiz |= (params->host_rx_fifo_size +
params->host_nperio_tx_fifo_size) <<
-  FIFOSIZE_STARTADDR_SHIFT & FIFOSIZE_STARTADDR_MASK;
+  HPTXFSIZ_P_TXF_ST_ADDR_SHIFT & HPTXFSIZ_P_TXF_ST_ADDR_MASK;
writel(ptxfsiz, hsotg->regs + HPTXFSIZ);
dev_dbg(hsotg->dev, "new hptxfsiz=%08x\n",
readl(hsotg->regs + HPTXFSIZ));
diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h
index 382a1d7..fd56963 100644
--- a/drivers/staging/dwc2/hw.h
+++ b/drivers/staging/dwc2/hw.h
@@ -392,6 +392,13 @@
 
 #define HPTXFSIZ   HSOTG_REG(0x100)
 
+#define HPTXFSIZ_P_TXF_DEP_MASK(0x << 16)
+#define HPTXFSIZ_P_TXF_DEP_SHIFT   16
+#define HPTXFSIZ_P_TXF_ST_ADDR_MASK(0x << 0)
+#define HPTXFSIZ_P_TXF_ST_ADDR_SHIFT   0
+
+/* Device mode registers */
+
 #define DPTXFSIZN(_a)  HSOTG_REG(0x104 + (((_a) - 1) * 4))
 #define DPTXFSIZN_DP_TXF_SIZE_MASK (0x << 16)
 #define DPTXFSIZN_DP_TXF_SIZE_SHIFT16
@@ -401,13 +408,6 @@
 #define DPTXFSIZN_DP_TXF_ST_ADDR_MASK  (0x << 0)
 #define DPTXFSIZN_DP_TXF_ST_ADDR_SHIFT 0
 
-#define FIFOSIZE_DEPTH_MASK(0x << 16)
-#define FIFOSIZE_DEPTH_SHIFT   16
-#define FIFOSIZE_STARTADDR_MASK(0x << 0)
-#define FIFOSIZE_STARTADDR_SHIFT   0
-
-/* Device mode registers */
-
 #define DCFG   HSOTG_REG(0x800)
 #define DCFG_EPMISCNT_MASK (0x1f << 18)
 #define DCFG_EPMISCNT_SHIFT18
-- 
1.8.0

--
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


[RFC PATCH 04/41] staging: dwc2: fix off-by-one in check for max_packet_count parameter

2013-04-05 Thread Matthijs Kooijman
Previously, the max_packet_count could be set to 1 << x, where x is the
number of bits available (width + 4 in the code). Since 1 << x requires
x + 1 bits to represent, this will not work. The real maximum value is
(1 << x) - 1. This value is already used the default when the set value
is invalid, but the upper limit for the set value was off-by-one.

This change makes the check the same as the one for max_transfer_size,
which was already correct.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 5d6f9fa..9162bed 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -2209,7 +2209,7 @@ int dwc2_set_param_max_packet_count(struct dwc2_hsotg 
*hsotg, int val)
GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK >>
GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT;
 
-   if (val < 15 || val > (1 << (width + 4)))
+   if (val < 15 || val >= (1 << (width + 4)))
valid = 0;
 
if (!valid) {
-- 
1.8.0

--
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


[RFC PATCH 20/41] staging: dwc2: make dwc2_core_params documentation more complete

2013-04-05 Thread Matthijs Kooijman
Some of the defaults were missing or unclear. In particular, I suspect
the defaults were documented assuming there were still module parameters
and taking the default module parameters into account. Now, the defaults
are the values that will get chosen when the params passed to
dwc2_hcd_init are all -1.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.h | 83 +++--
 1 file changed, 57 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index 710de03..2817b60 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -68,16 +68,15 @@ enum dwc2_lx_state {
 /**
  * struct dwc2_core_params - Parameters for configuring the core
  *
- * @otg_cap:Specifies the OTG capabilities. The driver will
- *  automatically detect the value for this parameter if
- *  none is specified.
- *   0 - HNP and SRP capable (default)
+ * @otg_cap:Specifies the OTG capabilities.
+ *   0 - HNP and SRP capable
  *   1 - SRP Only capable
- *   2 - No HNP/SRP capable
+ *   2 - No HNP/SRP capable (always available)
+ *  Defaults to best available option (0, 1, then 2)
  * @dma_enable: Specifies whether to use slave or DMA mode for 
accessing
  *  the data FIFOs. The driver will automatically detect 
the
  *  value for this parameter if none is specified.
- *   0 - Slave
+ *   0 - Slave (always available)
  *   1 - DMA (default, if available)
  * @dma_desc_enable:When DMA mode is enabled, specifies whether to use
  *  address DMA mode or descriptor DMA mode for accessing
@@ -88,39 +87,58 @@ enum dwc2_lx_state {
  * @speed:  Specifies the maximum speed of operation in host and
  *  device mode. The actual speed depends on the speed of
  *  the attached device and the value of phy_type.
- *   0 - High Speed (default)
+ *   0 - High Speed
+ *   (default when phy_type is UTMI+ or ULPI)
  *   1 - Full Speed
+ *   (default when phy_type is Full Speed)
  * @host_support_fs_ls_low_power: Specifies whether low power mode is supported
  *  when attached to a Full Speed or Low Speed device in
  *  host mode.
  *   0 - Don't support low power mode (default)
  *   1 - Support low power mode
  * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode
- *  when connected to a Low Speed device in host mode. This
- *  parameter is applicable only if
- *  host_support_fs_ls_low_power is enabled. If phy_type is
- *  set to FS then defaults to 6 MHZ otherwise 48 MHZ.
+ *  when connected to a Low Speed device in host
+ *  mode. This parameter is applicable only if
+ *  host_support_fs_ls_low_power is enabled.
  *   0 - 48 MHz
+ *   (default when phy_type is UTMI+ or ULPI)
  *   1 - 6 MHz
+ *   (default when phy_type is Full Speed)
  * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters
- *   1 - Allow dynamic FIFO sizing (default)
+ *   1 - Allow dynamic FIFO sizing (default, if available)
  * @host_rx_fifo_size:  Number of 4-byte words in the Rx FIFO in host mode when
  *  dynamic FIFO sizing is enabled
- *   16 to 32768 (default 1024)
+ *   16 to 32768
+ *  Actual maximum value is autodetected and also
+ *  the default.
  * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx 
FIFO
  *  in host mode when dynamic FIFO sizing is enabled
- *   16 to 32768 (default 1024)
+ *   16 to 32768
+ *  Actual maximum value is autodetected and also
+ *  the default.
  * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in
  *  host mode when dynamic FIFO sizing is enabled
- *   16 to 32768 (default 1024)
+ *   16 to 32768
+ *  Actual maximum value is autodetected and also
+ *  the default.
  * @max_transfer_size:  The maximum transfer size supported, in bytes
- *   2047 to 65,535 (default 65,535)
+ *   2047 to 65,535
+ *   

[RFC PATCH 17/41] staging: dwc2: properly mask the GRXFSIZ register

2013-04-05 Thread Matthijs Kooijman
Bits 16-31 are reserved, so the old code just reads the whole register to
get bits 0-15, assuming the reserved bits would be 0 (which seems true
on current hardware, but who knows...).

This commit properly masks out the reserved bits when reading and
doesn't touch the reserved bits while writing.

Signed-off-by: Matthijs Kooijman 
---
 drivers/staging/dwc2/core.c | 17 ++---
 drivers/staging/dwc2/hw.h   |  2 ++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index cc2431f..0388641 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -404,7 +404,7 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
 
hsotg->total_fifo_size = hsotg->hwcfg3 >> GHWCFG3_DFIFO_DEPTH_SHIFT &
GHWCFG3_DFIFO_DEPTH_MASK >> GHWCFG3_DFIFO_DEPTH_SHIFT;
-   hsotg->rx_fifo_size = readl(hsotg->regs + GRXFSIZ);
+   hsotg->rx_fifo_size = (readl(hsotg->regs + GRXFSIZ) & 
GRXFSIZ_RXF_DEP_MASK) >> GRXFSIZ_RXF_DEP_SHIFT;
hsotg->nperio_tx_fifo_size =
readl(hsotg->regs + GNPTXFSIZ) >> 16 & 0x;
 
@@ -499,7 +499,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg)
 static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
 {
struct dwc2_core_params *params = hsotg->core_params;
-   u32 nptxfsiz, hptxfsiz, dfifocfg;
+   u32 nptxfsiz, hptxfsiz, dfifocfg, grxfsiz;
 
if (!params->enable_dynamic_fifo)
return;
@@ -512,9 +512,12 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
params->host_perio_tx_fifo_size);
 
/* Rx FIFO */
-   dev_dbg(hsotg->dev, "initial grxfsiz=%08x\n",
-   readl(hsotg->regs + GRXFSIZ));
-   writel(params->host_rx_fifo_size, hsotg->regs + GRXFSIZ);
+   grxfsiz = readl(hsotg->regs + GRXFSIZ);
+   dev_dbg(hsotg->dev, "initial grxfsiz=%08x\n", grxfsiz);
+   grxfsiz &= ~GRXFSIZ_RXF_DEP_MASK;
+   grxfsiz |= params->host_rx_fifo_size <<
+ GRXFSIZ_RXF_DEP_SHIFT & GRXFSIZ_RXF_DEP_MASK;
+   writel(grxfsiz, hsotg->regs + GRXFSIZ);
dev_dbg(hsotg->dev, "new grxfsiz=%08x\n", readl(hsotg->regs + GRXFSIZ));
 
/* Non-periodic Tx FIFO */
@@ -2083,7 +2086,7 @@ int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg 
*hsotg, int val)
int valid = 1;
int retval = 0;
 
-   if (val < 16 || val > readl(hsotg->regs + GRXFSIZ))
+   if (val < 16 || val > (readl(hsotg->regs + GRXFSIZ) & 
GRXFSIZ_RXF_DEP_MASK) >> GRXFSIZ_RXF_DEP_SHIFT)
valid = 0;
 
if (!valid) {
@@ -2091,7 +2094,7 @@ int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg 
*hsotg, int val)
dev_err(hsotg->dev,
"%d invalid for host_rx_fifo_size. Check HW 
configuration.\n",
val);
-   val = readl(hsotg->regs + GRXFSIZ);
+   val = (readl(hsotg->regs + GRXFSIZ) & GRXFSIZ_RXF_DEP_MASK) >> 
GRXFSIZ_RXF_DEP_SHIFT;
dev_dbg(hsotg->dev, "Setting host_rx_fifo_size to %d\n", val);
retval = -EINVAL;
}
diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h
index b5268882..4f813b8 100644
--- a/drivers/staging/dwc2/hw.h
+++ b/drivers/staging/dwc2/hw.h
@@ -184,6 +184,8 @@
 #define GRXSTS_EPNUM_SHIFT 0
 
 #define GRXFSIZHSOTG_REG(0x024)
+#define GRXFSIZ_RXF_DEP_MASK   (0x << 0)
+#define GRXFSIZ_RXF_DEP_SHIFT  0
 
 #define GNPTXFSIZ  HSOTG_REG(0x028)
 #define GNPTXFSIZ_NP_TXF_DEP_MASK  (0x << 16)
-- 
1.8.0

--
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


[RFC PATCH 38/41] staging: dwc2: load parameters from the devicetree

2013-04-05 Thread Matthijs Kooijman
Each of the parameters in the dwc2_core_params struct can now be changed
using devicetree parameters.

Signed-off-by: Matthijs Kooijman 
---
 Documentation/devicetree/bindings/staging/dwc2.txt | 36 
 drivers/staging/dwc2/platform.c| 68 ++
 2 files changed, 104 insertions(+)

Does it make sense to set all these properties in the devicetree?

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 3649c88..05d9c08 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,39 @@ Required properties:
 - compatible : "snps,dwc2"
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+Optional properties:
+ - dma-enable
+ - otg-cap
+ - otg-ver
+ - dma-enable
+ - dma-desc-enable
+ - speed
+ - enable-dynamic-fifo
+ - en-multiple-tx-fifo
+ - host-rx-fifo-size
+ - host-nperio-tx-fifo-size
+ - host-perio-tx-fifo-size
+ - max-transfer-size
+ - max-packet-count
+ - host-channels
+ - phy-type
+ - phy-utmi-width
+ - phy-ulpi-ddr
+ - phy-ulpi-ext-vbus
+ - i2c-enable
+ - ulpi-fs-ls
+ - host-support-fs-ls-low-power
+ - host-ls-low-power-phy-clk
+ - ts-dline
+ - reload-ctl
+ - ahb-single
+
+Each of the above properties take a single cell containing an integer. See
+struct dwc2_core_params in dwc2/core.h for their meanings and possible values.
+
+If absent, these values have either a driver default or are autodetected.
+Where possible, the values set through the devicetree are checked against
+hardware limits and automatically capped or adjusted as needed.
 
 Example:
 
@@ -12,4 +45,7 @@ Example:
 compatible = "ralink,rt3050-otg, snps,dwc2";
 reg = <0x101c 4>;
 interrupts = <18>;
+
+   # Force slave mode, even when dma is advertised to work
+   dma-enable = <0>;
 };
diff --git a/drivers/staging/dwc2/platform.c b/drivers/staging/dwc2/platform.c
index 0ffb1b3..be5df0c 100644
--- a/drivers/staging/dwc2/platform.c
+++ b/drivers/staging/dwc2/platform.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "core.h"
 #include "hcd.h"
@@ -69,6 +70,70 @@ static int dwc2_driver_remove(struct platform_device *dev)
 }
 
 /**
+ * dwc2_load_property() - Load a single property from the devicetree
+ * node into the given variable.
+ *
+ * @dev: Platform device
+ * @res: The variable to put the loaded value into
+ * @name: The name of the devicetree property to load
+ */
+static void dwc2_load_property(struct platform_device *dev, int *res, const 
char *name)
+{
+   int len;
+   const u32 *val;
+
+   val = of_get_property(dev->dev.of_node, name, &len);
+   if (!val)
+   return;
+
+   if (len != sizeof(*val)) {
+   dev_warn(&dev->dev, "Invalid value in devicetree for %s 
property, should be a single integer\n", name);
+   return;
+   }
+
+   *res = be32_to_cpu(*val);
+
+   dev_dbg(&dev->dev, "Loaded %s parameter from devicetree: %d\n", name, 
*res);
+}
+
+/**
+ * dwc2_load_properties() - Load all devicetree properties into the core
+ * params.
+ *
+ * @dev: Platform device
+ * @params: The core parameters to load the values into
+ */
+static void dwc2_load_properties(struct platform_device *dev, struct 
dwc2_core_params *params)
+{
+   dev_dbg(&dev->dev, "Loading parameters from devicetree node %s\n", 
dev->dev.of_node->name);
+   dwc2_load_property(dev, Âļms->dma_enable, "dma-enable");
+   dwc2_load_property(dev, Âļms->otg_cap, "otg-cap");
+   dwc2_load_property(dev, Âļms->otg_ver, "otg-ver");
+   dwc2_load_property(dev, Âļms->dma_enable, "dma-enable");
+   dwc2_load_property(dev, Âļms->dma_desc_enable, "dma-desc-enable");
+   dwc2_load_property(dev, Âļms->speed, "speed");
+   dwc2_load_property(dev, Âļms->enable_dynamic_fifo, 
"enable-dynamic-fifo");
+   dwc2_load_property(dev, Âļms->en_multiple_tx_fifo, 
"en-multiple-tx-fifo");
+   dwc2_load_property(dev, Âļms->host_rx_fifo_size, 
"host-rx-fifo-size");
+   dwc2_load_property(dev, Âļms->host_nperio_tx_fifo_size, 
"host-nperio-tx-fifo-size");
+   dwc2_load_property(dev, Âļms->host_perio_tx_fifo_size, 
"host-perio-tx-fifo-size");
+   dwc2_load_property(dev, Âļms->max_transfer_size, 
"max-transfer-size");
+   dwc2_load_property(dev, Âļms->max_packet_count, "max-packet-count");
+   dwc2_load_property(dev, Âļms->host_channels, "host-channels");
+   dwc2_load_property(dev, Âļms->phy_type, "phy-type");
+   dwc2_load_property(dev, Âļms->phy_utmi_width, "phy-utmi-width");
+   dwc2_load_property(dev, Âļms->phy_ulpi_ddr, "phy-ulpi-ddr");
+   dwc2_load_property(dev, Âļms->phy_ulpi_ext_vbus, 
"phy-ulpi-ext-vbus");
+   dwc2_load_property(dev, Âļms->i2c_enable, "i2c-enable");
+   dwc2_load_property(dev, Âļms->ulpi_fs_ls, "ulpi-fs-ls

Re: [GIT PULL] USB: changes for v3.10

2013-04-05 Thread Felipe Balbi
Hi,

On Sat, Apr 06, 2013 at 12:21:52AM +0300, Felipe Balbi wrote:
> Hi Greg,
> 
> Here's a giant pull request for v3.10. All patches have been on linux-next for
> quite a while and have gone through build and boot testing.
> 
> I haven't heard any complaints from Fengguang's 0-day build for some time now,
> so it shouldn't add any new build warnings or build errors.
> 
> Let me know if you want/need further detail on the tag message, but given the
> amount of changes in this pull request, I decided bullet points would be 
> easier
> to parse.

forgot to mention, there will be some conflicts; here's my suggested
resolution:

diff --cc drivers/usb/chipidea/udc.c
index 3d90e61,9bddf3f..519ead2
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@@ -1708,19 -1742,18 +1692,13 @@@ static int udc_start(struct ci13xxx *ci
retval = hw_device_reset(ci, USBMODE_CM_DC);
if (retval)
goto put_transceiver;
 -  hw_enable_vbus_intr(ci);
}
  
-   retval = device_register(&ci->gadget.dev);
-   if (retval) {
-   put_device(&ci->gadget.dev);
-   goto put_transceiver;
-   }
- 
 -  retval = dbg_create_files(ci->dev);
 -  if (retval)
 -  goto put_transceiver;
 -
if (!IS_ERR_OR_NULL(ci->transceiver)) {
retval = otg_set_peripheral(ci->transceiver->otg,
&ci->gadget);
if (retval)
-   goto unreg_device;
 -  goto remove_dbg;
++  goto put_transceiver;
}
  
retval = usb_add_gadget_udc(dev, &ci->gadget);
@@@ -1740,8 -1773,8 +1718,6 @@@ remove_trans
}
  
dev_err(dev, "error = %i\n", retval);
- unreg_device:
-   device_unregister(&ci->gadget.dev);
 -remove_dbg:
 -  dbg_remove_files(ci->dev);
  put_transceiver:
if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy)
usb_put_phy(ci->transceiver);
@@@ -1776,7 -1812,7 +1752,6 @@@ static void udc_stop(struct ci13xxx *ci
if (ci->global_phy)
usb_put_phy(ci->transceiver);
}
-   device_unregister(&ci->gadget.dev);
 -  dbg_remove_files(ci->dev);
/* my kobject is dynamic, I swear! */
memset(&ci->gadget, 0, sizeof(ci->gadget));
  }
diff --cc drivers/usb/gadget/g_ffs.c
index 3b343b2,a07dd17..787a78e
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@@ -410,10 -416,10 +416,10 @@@ static int gfs_unbind(struct usb_compos
 * do...?
 */
if (gfs_ether_setup)
-   gether_cleanup();
+   gether_cleanup(the_dev);
gfs_ether_setup = false;
  
 -  for (i = func_num; --i; )
 +  for (i = func_num; i--; )
if (ffs_tab[i].ffs_data)
functionfs_unbind(ffs_tab[i].ffs_data);
  
diff --cc drivers/usb/gadget/net2272.c
index 32524b63,ce450a1..f1e50a3
--- a/drivers/usb/gadget/net2272.c
+++ b/drivers/usb/gadget/net2272.c
@@@ -58,8 -58,7 +58,7 @@@ static const char * const ep_name[] = 
"ep-a", "ep-b", "ep-c",
  };
  
- #define DMA_ADDR_INVALID  (~(dma_addr_t)0)
 -#ifdef CONFIG_USB_GADGET_NET2272_DMA
 +#ifdef CONFIG_USB_NET2272_DMA
  /*
   * use_dma: the NET2272 can use an external DMA controller.
   * Note that since there is no generic DMA api, some functions,
diff --cc drivers/usb/gadget/net2280.c
index 3bd0f99,e869188..fbd006a
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@@ -1924,7 -1920,7 +1920,6 @@@ static int net2280_start(struct usb_gad
  err_func:
device_remove_file (&dev->pdev->dev, &dev_attr_function);
  err_unbind:
-   dev->gadget.dev.driver = NULL;
 -  driver->unbind (&dev->gadget);
dev->driver = NULL;
return retval;
  }
diff --cc drivers/usb/host/ehci-tegra.c
index 4f3cfb8,1d2488c..ed201ae
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@@ -770,19 -765,15 +770,17 @@@ static int tegra_ehci_probe(struct plat
if (!irq) {
dev_err(&pdev->dev, "Failed to get IRQ\n");
err = -ENODEV;
 -  goto fail;
 +  goto fail_phy;
}
  
if (pdata->operating_mode == TEGRA_USB_OTG) {
tegra->transceiver =
devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
-   if (!IS_ERR_OR_NULL(tegra->transceiver))
+   if (!IS_ERR(tegra->transceiver))
otg_set_host(tegra->transceiver->otg, &hcd->self);
 +  } else {
 +  tegra->transceiver = ERR_PTR(-ENODEV);
}
- #endif
  
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err) {
@@@ -801,11 -792,8 +799,9 @@@
return err;
  
  fail:
- #ifdef CONFIG_USB_OTG_UTILS
-   if (!IS_ERR_OR_NULL(tegra->transceiver))
+   if (!IS_ERR(tegra->transceiver))
otg_set

Re: [PATCH 13/15] staging: usbip: userspace: libsrc: cleanup parsing

2013-04-05 Thread Greg KH
On Thu, Apr 04, 2013 at 04:03:14PM +0200, Stefan Reif wrote:
> From: Kurt Kanzenbach 
> 
> Since the names.c/names.h are taken from another project, some
> functions which names.c provides aren't used by usbipd.
> This patch fixes:
>  - removed useless comments
>  - unified debug/error messages by using the macros
>provided by usbip_common.h
>  - removed unnused code
> 
> The code cleanup includes:
>  - remove unused data structures
>  - remove code to create them
>  - remove code to access them
> 
> The file names.c is used to parse the `usb.ids' file. The parser
> stores a lot of information about usb devices that is never used.
> 
> The `usb.ids' file has several sections. Some variables (like
> `lasthut') store the ID of the current section, and those variables
> are used to decide which section is currently being parsed (i.e. in
> which data structure the current line will be  stored).
> 
> We removed the code to read those IDs because they are never used
> anyway. We replaced them by the pseudo-ID `1' (instead of reading the
> ID from the file) to indicate that the parser is in a section that
> can be ignored. If the parser is in such a section, the current line
> (which contains sub-items for this section) is discarded.

I'm not objecting to this patch, but you might want to switch to start
using the library that systemd/udev provides for this same type of
functionality, instead of using the usb.ids file, as that is going away
soon from systems.

thanks,

greg k-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


[GIT PULL] USB: changes for v3.10

2013-04-05 Thread Felipe Balbi
Hi Greg,

Here's a giant pull request for v3.10. All patches have been on linux-next for
quite a while and have gone through build and boot testing.

I haven't heard any complaints from Fengguang's 0-day build for some time now,
so it shouldn't add any new build warnings or build errors.

Let me know if you want/need further detail on the tag message, but given the
amount of changes in this pull request, I decided bullet points would be easier
to parse.

cheers.

The following changes since commit a937536b868b8369b98967929045f1df54234323:

  Linux 3.9-rc3 (2013-03-17 15:59:32 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git tags/usb-for-v3.10

for you to fetch changes up to 9b192de60b5a584ee4ed967fb6758773c75e4643:

  usb: gadget: nokia: include f_ecm.c (2013-04-03 21:02:47 +0300)


usb: patches for v3.10 merge window

Here is the big Gadget & PHY pull request. Many of us have
been really busy lately getting multiple drivers to a better
position.

Since this pull request is so large, I will divide it in sections
so it's easier to grasp what's included.

- cleanups:
. UDC drivers no longer touch gadget->dev, that's now udc-core
responsibility
. Many more UDC drivers converted to usb_gadget_map/unmap_request()
. UDC drivers no longer initialize DMA-related fields from gadget's
device structure
. UDC drivers don't touch gadget.dev.driver directly
. UDC drivers don't assign gadget.dev.release directly
. Removal of some unused DMA_ADDR_INVALID
. Introduction of CONFIG_USB_PHY
. All phy drivers have been moved to drivers/usb/phy and renamed to
a common naming scheme
. Fix PHY layer so it never returns a NULL pointer, also fix all
callers to avoid using IS_ERR_OR_NULL()
. Sparse fixes all over the place
. drivers/usb/otg/ has been deleted
. Marvel drivers (mv_udc, ehci-mv, mv_otg and mv_u3d) improved clock
usage

- new features:
. UDC core now provides a generic way for tracking and reporting
UDC's state (not attached, resuming, suspended, addressed,
default, etc)
. twl4030-usb learned that it shouldn't be enabled during init
. Full DT support for DWC3 has been implemented
. ab8500-usb learned about pinctrl framework
. nop PHY learned about DeviceTree and regulators
. DWC3 learned about suspend/resume
. DWC3 can now be compiled in host-only and gadget-only (as well as
DRD) configurations
. UVC now enables streaming endpoint based on negotiated speed
. isp1301 now implements the PHY API properly
. configfs-based interface for gadget drivers which will lead to
the removal of all code which just combines functions together
to build functional gadget drivers.
. f_serial and f_obex were converted to new configfs interface while
maintaining old interface around.

- non-critical fixes:
. UVC gadget driver got fixes for Endpoint usage and stream calculation
. ab8500-usb fixed unbalanced clock and regulator API usage
. twl4030-usb got a fix for when OMAP3 is booted with cable connected
. fusb300_udc got a fix for DMA usage
. UVC got fixes for two assertions of the USB Video Class Compliance
specification revision 1.1
. build warning issues caused by recent addition of __must_check to
regulator API

These are all changes which deserve a mention, all other changes are related
to these one or minor spelling fixes and other similar tasks.

Signed-of-by: Felipe Balbi 


Andrzej Pietrasiewicz (9):
  usb: gadget: use consistent naming scheme for usb function modules
  usb: gadget: nokia: remove unused include
  usb: gadget: f_serial: convert to new function interface with backward 
compatibility
  usb: gadget: serial: convert to new interface of f_serial
  usb: gadget: f_serial: remove compatibility layer
  usb: gadget: f_serial: add configfs support
  usb: gadget: f_obex: convert to new function interface with backward 
compatibility
  usb: gadget: serial: convert to new interface of f_obex
  usb: gadget: f_obex: add configfs support

Bhupesh Sharma (6):
  usb: gadget: uvc: Add fix for UVC compliance test suite assertion 6.3.90 
failure
  usb: gadget: uvc: Add fix for UVC compliance test suite's assertion 
6.1.25 failure
  usb: gadget: uvc: Delay the status stage when setting alternate setting 1
  usb: gadget: uvc: Make video streaming buffer size comply with USB3.0 SS
  usb: gadget/uvc: Port UVC webcam gadget to use videobuf2 framework
  usb: gadget/

Re: [PATCH 2/8] ehci-platform: add init() method to platform data

2013-04-05 Thread Alan Stern
On Sat, 6 Apr 2013, Sergei Shtylyov wrote:

> On 04/06/2013 12:56 AM, Alan Stern wrote:
> 
>  And instead of passing hcd->regs, wouldn't it be better to pass hcd?
> >>> I really don't know.
> >>>
>  Other users of this interface might need to initialize something other
>  than a non-standard register.
> >>> Hm, maybe... if passing 'struct usb_hcd *' would indeed help here.
> >>> Do you think it's
> >>> worth passing 'struct platform_device *' along with it?
> >>  Probably not as it can be extracted from 'hcd->self.controller'...
> > It's up to you.  Generally I think it's easier to pass an extra
> > argument than to force the function being called to dig it out.
> 
> Note that in our use case we don't even need this argument.

Okay, then don't pass it.

Alan Stern

--
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 2/8] ehci-platform: add init() method to platform data

2013-04-05 Thread Sergei Shtylyov

On 04/06/2013 12:56 AM, Alan Stern wrote:


And instead of passing hcd->regs, wouldn't it be better to pass hcd?

I really don't know.


Other users of this interface might need to initialize something other
than a non-standard register.

Hm, maybe... if passing 'struct usb_hcd *' would indeed help here.
Do you think it's
worth passing 'struct platform_device *' along with it?

 Probably not as it can be extracted from 'hcd->self.controller'...

It's up to you.  Generally I think it's easier to pass an extra
argument than to force the function being called to dig it out.


   Note that in our use case we don't even need this argument.


Alan Stern


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 2/8] ehci-platform: add init() method to platform data

2013-04-05 Thread Alan Stern
On Sat, 6 Apr 2013, Sergei Shtylyov wrote:

> On 04/06/2013 12:40 AM, Sergei Shtylyov wrote:
> 
> >
> >> And instead of passing hcd->regs, wouldn't it be better to pass hcd?
> >
> >I really don't know.
> >
> >> Other users of this interface might need to initialize something other
> >> than a non-standard register.
> >
> >Hm, maybe... if passing 'struct usb_hcd *' would indeed help here. 
> > Do you think it's
> > worth passing 'struct platform_device *' along with it?
> 
> Probably not as it can be extracted from 'hcd->self.controller'...

It's up to you.  Generally I think it's easier to pass an extra 
argument than to force the function being called to dig it out.

Alan Stern

--
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 2/8] ehci-platform: add init() method to platform data

2013-04-05 Thread Alan Stern
On Sat, 6 Apr 2013, Sergei Shtylyov wrote:

> > And instead of passing hcd->regs, wouldn't it be better to pass hcd?
> 
> I really don't know.
> 
> > Other users of this interface might need to initialize something other
> > than a non-standard register.
> 
> Hm, maybe... if passing 'struct usb_hcd *' would indeed help here. 
> Do you think it's
> worth passing 'struct platform_device *' along with it?

Yes.  After all, the routine being called is part of the platform code.

Alan Stern

--
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 2/8] ehci-platform: add init() method to platform data

2013-04-05 Thread Sergei Shtylyov

On 04/06/2013 12:40 AM, Sergei Shtylyov wrote:




And instead of passing hcd->regs, wouldn't it be better to pass hcd?


   I really don't know.


Other users of this interface might need to initialize something other
than a non-standard register.


   Hm, maybe... if passing 'struct usb_hcd *' would indeed help here. 
Do you think it's

worth passing 'struct platform_device *' along with it?


   Probably not as it can be extracted from 'hcd->self.controller'...

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 2/8] ehci-platform: add init() method to platform data

2013-04-05 Thread Sergei Shtylyov

Hello.

On 04/05/2013 06:43 PM, Alan Stern wrote:




Sometimes there is a need to initialize some non-standard registers mapped to
the EHCI region before accessing the standard EHCI registers.  Add the init()
method to the 'ehci-platform' platform data for this purpose.

"init" isn't such a good name for this.  It's too vague; there are
already a lot of initialization steps here.  How about "pre_setup"
instead?


Quite vague too. :-)
But can't think of a better name...




--- renesas.orig/drivers/usb/host/ehci-platform.c
+++ renesas/drivers/usb/host/ehci-platform.c
@@ -110,6 +110,13 @@ static int ehci_platform_probe(struct pl
err = PTR_ERR(hcd->regs);
goto err_put_hcd;
}
+
+   if (pdata->init) {
+   err = pdata->init(dev, hcd->regs);
+   if (err < 0)
+   goto err_put_hcd;
+   }

Also, I think this code should go in the ehci_platform_reset() routine,
just before the call to ehci_setup().  That way more of the setup will
already have been carried out.


You're right, of course.


And instead of passing hcd->regs, wouldn't it be better to pass hcd?


   I really don't know.


Other users of this interface might need to initialize something other
than a non-standard register.


   Hm, maybe... if passing 'struct usb_hcd *' would indeed help here. 
Do you think it's

worth passing 'struct platform_device *' along with it?


Alan Stern



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 0/2] usb: chipidea: fixes for v3.9-rc5

2013-04-05 Thread Greg KH
On Thu, Apr 04, 2013 at 01:13:45PM +0300, Alexander Shishkin wrote:
> Hi,
> 
> This series contains two fixes, both of which are also applicable to
> -stable.
> 
> Michael Grzeschik (2):
>   usb: chipidea: udc: fix memory access of shared memory on armv5
> machines
>   usb: chipidea: udc: fix memory leak in _ep_nuke

As these have been buggy for so long now (almost a year), I'm going to
put them in my -next tree and push them to Linus for 3.10-rc1, which
means they will show up in 3.9.1, ok?

thanks,

greg k-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 v2] xhci - clarify compliance mode debug messages

2013-04-05 Thread Tony Camuso
There are no functional changes in this patch. However, because the
compliance mode timer can be deleted in more than one function, it
seemed expedient to include the function name in the debug strings.

Also limited the use of capitals to the first word in the compliance
mode debug messages, except after a function name where all words
start with lower case, in keeping with the style prevalent elsewhere
in xhci.c.

Signed-off-by: Tony Camuso 
---
 drivers/usb/host/xhci.c |   14 +-
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 53b8f89..5bb1a6a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -417,9 +417,9 @@ static void compliance_mode_recovery(unsigned long arg)
 * Compliance Mode Detected. Letting USB Core
 * handle the Warm Reset
 */
-   xhci_dbg(xhci, "Compliance Mode Detected->Port %d!\n",
+   xhci_dbg(xhci, "Compliance mode detected->port %d\n",
i + 1);
-   xhci_dbg(xhci, "Attempting Recovery routine!\n");
+   xhci_dbg(xhci, "Attempting compliance mode recovery\n");
hcd = xhci->shared_hcd;
 
if (hcd->state == HC_STATE_SUSPENDED)
@@ -457,7 +457,7 @@ static void compliance_mode_recovery_timer_init(struct 
xhci_hcd *xhci)
set_timer_slack(&xhci->comp_mode_recovery_timer,
msecs_to_jiffies(COMP_MODE_RCVRY_MSECS));
add_timer(&xhci->comp_mode_recovery_timer);
-   xhci_dbg(xhci, "Compliance Mode Recovery Timer Initialized.\n");
+   xhci_dbg(xhci, "Compliance mode recovery timer initialized\n");
 }
 
 /*
@@ -733,8 +733,11 @@ void xhci_stop(struct usb_hcd *hcd)
 
/* Deleting Compliance Mode Recovery Timer */
if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
-   (!(xhci_all_ports_seen_u0(xhci
+   (!(xhci_all_ports_seen_u0(xhci {
del_timer_sync(&xhci->comp_mode_recovery_timer);
+   xhci_dbg(xhci, "%s: compliance mode recovery timer deleted\n",
+   __func__);
+   }
 
if (xhci->quirks & XHCI_AMD_PLL_FIX)
usb_amd_dev_put();
@@ -930,7 +933,8 @@ int xhci_suspend(struct xhci_hcd *xhci)
if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
(!(xhci_all_ports_seen_u0(xhci {
del_timer_sync(&xhci->comp_mode_recovery_timer);
-   xhci_dbg(xhci, "Compliance Mode Recovery Timer Deleted!\n");
+   xhci_dbg(xhci, "%s: compliance mode recovery timer deleted\n",
+   __func__);
}
 
/* step 5: remove core well power */
-- 
1.7.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: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-05 Thread Grygorii Strashko

On 04/04/2013 07:41 PM, Tony Lindgren wrote:

* Roger Quadros  [130404 00:39]:

On 04/04/2013 02:42 AM, Tony Lindgren wrote:

--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -27,6 +27,7 @@
  #include 
  #include 
  #include 
+#include 
  
  #include "soc.h"

  #include "iomap.h"
@@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "cpufreq_ck", &dpll_mpu_ck,   CK_443X),
  };
  
+static struct clk *scrm_clks[] = {

+   &auxclk0_ck,
+   &auxclk1_ck,
+   &auxclk2_ck,
+   &auxclk3_ck,
+   &auxclk4_ck,
+   &auxclk5_ck,
+};

Hmm I don't like the idea of specifying the auxclk both in the
cclock44xx_data.c and in DT..

Right, but till we have all clocks moved to DT we only need this
approach for general purpose clocks that are not mapped to devices
by hwmod.

For v3.10, let's just make sure that USB works with DT as then
after v3.10 we can make omap4 DT only and get rid of estimated
7K lines of code and data. I guess this is the last piece missing
for that, or are we also missing something else?

Can't you set up a clock alias for your device so it can find the
auxclk when requesting it with the dev entry?

For the DT clock driver if needed for v3.10, how about just do a
minimal drivers/clock/omap/ that uses the standard binding?
Then that driver can just do clk_get() from cclock44xx_data.c
for now? And then later on we'll just move all the clocks to a
combination of DT + /lib/firmware.


Hi Roger, Rajendra, All

Sorry that disturbing you.

I'm supporting Android OMAP4 kernels (K3.0/K3.4) and like to clarify few
points regarding this approach (having into account possible future 
migrations

on newer Kernels and OMAP5).
If I understand everything right, this patch series allows to create 
clock binding

in DT using following syntax: clocks = <&aux_clks 3>
 - does it means that in worst case there will be ~200 clock IDs defined?
 - does it means that clock nodes binding using phandles 
(human-friendly notation)

isn't going to be supported?
for example:
clocks = <&sys_clkin_ck>
clocks = <&dss_sys_clk &dss_tv_clk &dss_dss_clk>)

I was horrified to think about the problems of this approach support
(in case if there would be more then ~30 IDs) - just miss with on digit
and weeks of debugging would be guaranteed.

Please, say me that i'm wrong.
And why clock DT data can't be auto-generated like all other OMAP data
to close this questions?

Thanks.


e.g. auxclk are required to be specified in DT nodes for USB PHY.
Without this we can't get USB host working on Panda.

OK. So if the USB PHY has a dev entry, can't you just set up a
clock alias in struct omap_clk omap44xx_clks[] for it?
  

As Rajendra points out, it seems moving entire clock data to DT is not
going to happen soon. So this is the simplistic way things can work.

Right but seems like we can get started there without moving
them all at once.

Regards,

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


--
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: Active URB submitted twice in pegasus driver

2013-04-05 Thread Petko Manolov

On Wed, 27 Mar 2013, Petko Manolov wrote:


On Tue, 26 Mar 2013, Sarah Sharp wrote:


ctrl_callback is still reading the URB status, and using it in the
switch statement.  It's also using the urb->context as well, to dig out
a pointer (pegasus_t) that the pegasus_set_multicast already has access
to.  What happens if an URB to get the registers completes at the same
time pegasus_set_multicast calls ctrl_callback?  If the URB failed for
some reason (e.g. bad cable, stall), you'll miss that if statement.  I
don't think that's what you intended to do.

I think the fix should be to just to move the if block into a new
function, and call it both in ctrl_callback() and
pegasus_set_multicast().


The _real_ fix would be to rework the whole callback mechanism, but this is a 
different story.  It is in my todo list.


Attached you'll find two patches against Linus' 3.9.0-rc5.  These should 
effectively cure the broken control requests callback logic.  The patch is 
so big because i also cleaned up a lot of old cruft.


The new driver actually compiles and runs fine with Pegasus-II based 
device.  Please let me know if you run into problems.



cheers,
Petkodiff --git a/drivers/net/usb/pegasus.h b/drivers/net/usb/pegasus.h
index 65b78b3..aada2fa 100644
--- a/drivers/net/usb/pegasus.h
+++ b/drivers/net/usb/pegasus.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999-2003 Petko Manolov - Petkan (pet...@users.sourceforge.net)
+ * Copyright (c) 1999-2013 Petko Manolov - Petkan (pet...@nucleusys.com)
  *
  * 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
@@ -34,8 +34,6 @@
 #define	CTRL_URB_SLEEP		0x0020
 #define	PEGASUS_UNPLUG		0x0040
 #define	PEGASUS_RX_URB_FAIL	0x0080
-#define	ETH_REGS_CHANGE		0x4000
-#define	ETH_REGS_CHANGED	0x8000
 
 #define	RX_MULTICAST		2
 #define	RX_PROMISCUOUS		4
@@ -96,12 +94,9 @@ typedef struct pegasus {
 	int			intr_interval;
 	struct tasklet_struct	rx_tl;
 	struct delayed_work	carrier_check;
-	struct urb		*ctrl_urb, *rx_urb, *tx_urb, *intr_urb;
-	struct sk_buff		*rx_pool[RX_SKBS];
+	struct urb		*rx_urb, *tx_urb, *intr_urb;
 	struct sk_buff		*rx_skb;
 	struct usb_ctrlrequest	dr;
-	wait_queue_head_t	ctrl_wait;
-	spinlock_t		rx_pool_lock;
 	int			chip;
 	unsigned char		intr_buff[8];
 	__u8			tx_buff[PEGASUS_MTU];
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index 73051d1..64b7a04 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 1999-2005 Petko Manolov (pet...@users.sourceforge.net)
+ *  Copyright (c) 1999-2013 Petko Manolov (pet...@nucleusys.com)
  *
  * 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
@@ -26,6 +26,9 @@
  *		v0.5.1	ethtool support added
  *		v0.5.5	rx socket buffers are in a pool and the their allocation
  *			is out of the interrupt routine.
+ *		...
+ *		v0.9.1	simplified [get|set]_register(s), async update registers
+ *			logic revisited, receive skb_pool removed.
  */
 
 #include 
@@ -45,8 +48,8 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.6.14 (2006/09/27)"
-#define DRIVER_AUTHOR "Petko Manolov "
+#define DRIVER_VERSION "v0.9.1 (2013/04/04)"
+#define DRIVER_AUTHOR "Petko Manolov "
 #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
 
 static const char driver_name[] = "pegasus";
@@ -108,88 +111,43 @@ MODULE_PARM_DESC(msg_level, "Override default message level");
 MODULE_DEVICE_TABLE(usb, pegasus_ids);
 static const struct net_device_ops pegasus_netdev_ops;
 
-static int update_eth_regs_async(pegasus_t *);
-/* Aargh!!! I _really_ hate such tweaks */
-static void ctrl_callback(struct urb *urb)
+
+static void async_ctrl_callback(struct urb *urb)
 {
 	pegasus_t *pegasus = urb->context;
 	int status = urb->status;
 
 	if (!pegasus)
-		return;
+		goto out;
 
 	switch (status) {
 	case 0:
-		if (pegasus->flags & ETH_REGS_CHANGE) {
-			pegasus->flags &= ~ETH_REGS_CHANGE;
-			pegasus->flags |= ETH_REGS_CHANGED;
-			update_eth_regs_async(pegasus);
-			return;
-		}
 		break;
 	case -EINPROGRESS:
-		return;
+		goto out;
 	case -ENOENT:
 		break;
 	default:
 		if (net_ratelimit())
 			netif_dbg(pegasus, drv, pegasus->net,
-  "%s, status %d\n", __func__, status);
+			  "%s, status %d\n", __func__, status);
 		break;
 	}
-	pegasus->flags &= ~ETH_REGS_CHANGED;
-	wake_up(&pegasus->ctrl_wait);
+out:
+	usb_free_urb(urb);
 }
 
 static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
 			 void *data)
 {
 	int ret;
-	char *buffer;
-	DECLARE_WAITQUEUE(wait, current);
-
-	buffer = kmalloc(size, GFP_KERNEL);
-	if (!buffer)
-		return -ENOMEM;
-
-	add_wait_queue(&pegasus->ctrl_wait, &wait);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	while (pegasus->flags & ETH_REGS_CHANGED)
-		schedule();
-	remove_wait_queue(&pegasus->ctrl_wait, &wait);
-	set_current_state(TASK_RU

Re: [PATCH 0/8] Reorganize R8A7779/Marzen USB code

2013-04-05 Thread Sergei Shtylyov

Hello.

On 05-04-2013 6:01, Kuninori Morimoto wrote:


Here's the set of 4 patches against the Simon Horman's 'renesas.git' repo,
'renesas-next-20130404v2' tag and the 2 Ether patches I've reposted yesterday.
It was created to fix the shortcomings in the R8A7779/Marzen USB platform code
and R8A7779 USB common PHY driver, and so spans both arch/arm/mach-shmobile/
and drivers/usb/ subtrees (some patches have to touch both subtrees).
The patches were conceived with the complete bisectability goal in mind.



[1/8] ARM: shmobile:Marzen: move USB EHCI, OHCI, and PHY devices to R8A7779 code
[2/8] ehci-platform: add init() method to platform data
[3/8] ARM: shmobile: R8A7779: setup EHCI internal buffer
[4/8] rcar-phy: remove EHCI internal buffer setup
[5/8] rcar-phy: correct base address
[6/8] rcar-phy: add platform data
[7/8] ARM: shmobile: Marzen: pass platform data to USB PHY device
[8/8] rcar-phy: handle platform data



I'm not sure thru which tree this patchset should be merged, however it 
turns
out that it's too late now to push it thru Felipe Balbi's USB tree for 3.10, so
maybe the patchset can be merged thru Simon's tree with Felipe's and Alan
Stern's ACKs.



I guess you already got request about patch style from Simon.


   It's not about style. I tried to keep the series copmpletely bisectable, 
and granting almost all requests about splitting the patches would have broken 
the bisection.



When you send v2 patch, could you please add "this patch is tested on  bard"
on each patch's comment area ?


   I'm not sure it's worth doing v2, although in one place I can indeed 
readily split the patch. All patches were tested on the Marzen board, I forgot 
to mention that in the cover letter.



Then,
for all patches



Acked-by: Kuninori Morimoto 


   Thanks.

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 7/8] ARM: shmobile: Marzen: pass platform data to USB PHY device

2013-04-05 Thread Sergei Shtylyov

Hello.

On 05-04-2013 4:44, Simon Horman wrote:


Since we're now going to setup the USBPCTRL0 register using the USB PHY device's
platform data, we now need a way to pass those platform data from the board file
to the device which is situated in setup-r8a7779.c -- and what I'm suggesting is
r8a7779_add_usb_phy_device() that will register USB PHY platform device with the
passed platform data using platform_device_register_resndata() call; creating
this function involves deletion of 'usb_phy_device' from r8a7779_devices_dt[],
so that it will no longer be registered for the generic R8A7779 machine (where
we can't provide the platform data anyway), hence EHCI/OHCI drivers will fail
to load as well.



For the Marzen board, this new function will be called from marzen_init() to
register the USB PHY device early enough.



As per my comment regarding patch 1, I wonder if this could
be split into an SoC patch and a board patch.


   No, that'll break bisection as it will cause the PHY driver to not be 
registered after the SoC patch, and hence EHCI/OHCI drivers won't load too.



Signed-off-by: Sergei Shtylyov 


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 5/8] rcar-phy: correct base address

2013-04-05 Thread Sergei Shtylyov

Hello.

On 05-04-2013 4:43, Simon Horman wrote:


The memory region that is used by the driver overlaps EHCI and OHCI register
regions for absolutely no reason now  -- fix it by adding offset of 0x800 to
the base address, changing the register #define's accordingly. This has extra
positive effect that we now can use devm_ioremap_resource().



Signed-off-by: Sergei Shtylyov 



As per my comment regarding patch 4, I wonder if this
could be split into a driver patch and an SoC patch.


   Absolutely not. That'll break bisection.

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 4/8] rcar-phy: remove EHCI internal buffer setup

2013-04-05 Thread Sergei Shtylyov

Hello.

On 05-04-2013 4:43, Simon Horman wrote:


Now that the EHCI internal buffer setup is done by the platform code, we  can
remove  such code from this driver as it never really belonged here.  We also
no longer need the 2nd memory region now (2nd EHCI controller is simply missing
in e.g. R8A7778 SoC).



I wonder if this patch could be split into a driver patch
followed by an SoC patch. Or vice versa.


   This one indeed can, I just tried to somewhat save on patches. But not 
vice versa, of course, that'll break bisection. :-)



Signed-off-by: Sergei Shtylyov 


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: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-05 Thread Tony Lindgren
* Roger Quadros  [130405 03:44]:
> On 04/04/2013 07:41 PM, Tony Lindgren wrote:
> > * Roger Quadros  [130404 00:39]:
> >> On 04/04/2013 02:42 AM, Tony Lindgren wrote:
> > For v3.10, let's just make sure that USB works with DT as then
> > after v3.10 we can make omap4 DT only and get rid of estimated
> > 7K lines of code and data. I guess this is the last piece missing
> > for that, or are we also missing something else?
> 
> For panda we just need a way to map the auxclk to the USB PHY device
> and the relevant dts data to get USB host working with DT.
> Beagle USB host should work already with DT without any changes.
> 
> > 
> > Can't you set up a clock alias for your device so it can find the
> > auxclk when requesting it with the dev entry?
> > 
> 
> which clock is mapped to which PHY device depends on board design
> and that cannot be per-determined at one place. This information
> needs to come from the board.dts file.

OK that makes sense.
 
> There was an earlier attempt to provide a way of building clock aliases
> at runtime from device tree [1], but the current approach is way better
> 
> [1]
> https://lkml.org/lkml/2013/3/12/241
> 
> > For the DT clock driver if needed for v3.10, how about just do a
> > minimal drivers/clock/omap/ that uses the standard binding?
> > Then that driver can just do clk_get() from cclock44xx_data.c
> 
> I don't understand how to do it and why it is better than the current
> approach.

Well your approach is fine as a first step moving all the clock
code, but it needs to be a real driver under drivers/clock/omap.
And the DT binding needs to stay the same for the driver(s) in the
long term as we start moving clocks to DT + /lib/firmware.

If this all is too late for v3.10, I suggest you just set up the
right clock alias for panda with machine_is_compatible flag in
board-generic.c so we get EHCI working with DT for v3.10. Then
it's easy to to deal with it properly for v3.11.

> How can that driver do clk_get() from cclock44xx_data.c?
> from where does it get the clk_id to pass into clk_get()?

Can't you just use the clock name there to get it?
 
> > for now? And then later on we'll just move all the clocks to a
> > combination of DT + /lib/firmware.
> 
> What is the benefit of moving clock data to /lib/firmware? We could
> as well just move it to DT only, no?

DT only clocks option is naturally available with this too. It
just gets easily inefficient with such a huge number of clocks.
 
> >> e.g. auxclk are required to be specified in DT nodes for USB PHY.
> >> Without this we can't get USB host working on Panda.
> > 
> > OK. So if the USB PHY has a dev entry, can't you just set up a
> > clock alias in struct omap_clk omap44xx_clks[] for it?
> 
> I've explained why this can't be done above.

Yes I understand now, the clock is board specific. 
  
> >> As Rajendra points out, it seems moving entire clock data to DT is not
> >> going to happen soon. So this is the simplistic way things can work.
> > 
> > Right but seems like we can get started there without moving
> > them all at once.
> > 
> What if we provide a complete clock list instead of only auxclks in
> dt_clks[]?
> 
> This approach is similar to arch/arm/mach-imx/clk-imx35.c
> 
> Device drivers can then use them as they migrate to DT. Then later
> we could migrate clock data to DT, without impacting device drivers.

As long as the binding stays the same in the long run too, this
clock remapping approach is just fine as a starting point. And
the driver needs to go to drivers/clock/omap. But in the long run
we just want to get the huge amounts static data out of the kernel
for clocks and hwmod data to fix things for good.

Regards,

Tony
--
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] xhci: fix list access before init

2013-04-05 Thread Aguirre Rodriguez, Sergio A
On Fri, Apr 05, 2013 at 06:51:21AM +0400, Vladimir Murzin wrote:
> On Thu, Apr 04, 2013 at 12:29:25PM -0700, Sarah Sharp wrote:
> > Someone else is already working on a patch to fix part of this:
> > 
> > http://marc.info/?l=linux-usb&m=136509667003716&w=2
> > 
> > Please coordinate with them.
> > 
> > Also, two people trying to solve the same simple bug and using almost
> > exactly the same commit messages seems like too much of a coincidence.
> > Are you working on the same project or did you both happen to run the
> > same static code checking tool at the same time, or ?
> 
> This problem was met by chance while trying buggy out-of-tree USB
> stuff. So, we wanted to bypass xhci initialization gracefully instead
> of being stuck with null pointer dereference while list traversing in
> xhci_mem_cleanup(). It is why patch addressed not only initialization
> of cancel_cmd_list and lpm_failed_devs, but bw tables too. With
> proposed patch normal boot sequence is progressing.
> 
> I've never heard of Sergio's patch, and never met him before :)
> 
> What about picking up Sergio's patch and bw table part of this patch
> as separate commits?

I'm ok to take your patch instead too, since is already addressing what
I'm doing. It's basically, my patch + similar change for bw tables, so
it's an improvement :)

Sarah,

I'll propose to ignore my patch, and take this one instead.

Regards,
Sergio

> 
> Best wishes
> Vladimir Murzin
> > 
> > Sarah Sharp
> > 
> > On Thu, Apr 04, 2013 at 08:31:26PM +0400, Vladimir Murzin wrote:
> > > Commits
> > >   9574323 xHCI: test USB2 software LPM
> > >   b92cc66 xHCI: add aborting command ring function
> > > introduce useful functions which involves lists manipulations.
> > > 
> > > If for whatever reason we fall into fail path in xhci_mem_init() we
> > > may access the lists in xhci_mem_cleanup() before they get
> > > initialized.
> > > 
> > > The same init-fail-cleanup case is applicable to bw tables too.
> > > 
> > > Fix this by moving list initialization code to the beginning of
> > > xhci_mem_init()
> > > 
> > > Reported-by: Sergey Dyasly 
> > > Tested-by: Sergey Dyasly 
> > > Signed-off-by: Vladimir Murzin 
> > > ---
> > >  drivers/usb/host/xhci-mem.c |   37 -
> > >  1 file changed, 20 insertions(+), 17 deletions(-)
> > > 
> > > diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> > > index 6dc238c..7b5d2f5 100644
> > > --- a/drivers/usb/host/xhci-mem.c
> > > +++ b/drivers/usb/host/xhci-mem.c
> > > @@ -2123,7 +2123,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd 
> > > *xhci, gfp_t flags)
> > >   __le32 __iomem *addr;
> > >   u32 offset;
> > >   unsigned int num_ports;
> > > - int i, j, port_index;
> > > + int i, port_index;
> > >  
> > >   addr = &xhci->cap_regs->hcc_params;
> > >   offset = XHCI_HCC_EXT_CAPS(xhci_readl(xhci, addr));
> > > @@ -2138,18 +2138,6 @@ static int xhci_setup_port_arrays(struct xhci_hcd 
> > > *xhci, gfp_t flags)
> > >   if (!xhci->port_array)
> > >   return -ENOMEM;
> > >  
> > > - xhci->rh_bw = kzalloc(sizeof(*xhci->rh_bw)*num_ports, flags);
> > > - if (!xhci->rh_bw)
> > > - return -ENOMEM;
> > > - for (i = 0; i < num_ports; i++) {
> > > - struct xhci_interval_bw_table *bw_table;
> > > -
> > > - INIT_LIST_HEAD(&xhci->rh_bw[i].tts);
> > > - bw_table = &xhci->rh_bw[i].bw_table;
> > > - for (j = 0; j < XHCI_MAX_INTERVAL; j++)
> > > - INIT_LIST_HEAD(&bw_table->interval_bw[j].endpoints);
> > > - }
> > > -
> > >   /*
> > >* For whatever reason, the first capability offset is from the
> > >* capability register base, not from the HCCPARAMS register.
> > > @@ -2253,7 +2241,25 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t 
> > > flags)
> > >   u64 val_64;
> > >   struct xhci_segment *seg;
> > >   u32 page_size, temp;
> > > - int i;
> > > + int i, j, num_ports;
> > > +
> > > + INIT_LIST_HEAD(&xhci->cancel_cmd_list);
> > > + INIT_LIST_HEAD(&xhci->lpm_failed_devs);
> > > +
> > > + num_ports = HCS_MAX_PORTS(xhci_readl(xhci, 
> > > &xhci->cap_regs->hcs_params1));
> > > +
> > > + xhci->rh_bw = kzalloc(sizeof(*xhci->rh_bw)*num_ports, flags);
> > > + if (!xhci->rh_bw)
> > > + return -ENOMEM;
> > > +
> > > + for (i = 0; i < num_ports; i++) {
> > > + struct xhci_interval_bw_table *bw_table;
> > > +
> > > + INIT_LIST_HEAD(&xhci->rh_bw[i].tts);
> > > + bw_table = &xhci->rh_bw[i].bw_table;
> > > + for (j = 0; j < XHCI_MAX_INTERVAL; j++)
> > > + INIT_LIST_HEAD(&bw_table->interval_bw[j].endpoints);
> > > + }
> > >  
> > >   page_size = xhci_readl(xhci, &xhci->op_regs->page_size);
> > >   xhci_dbg(xhci, "Supported page size register = 0x%x\n", page_size);
> > > @@ -2333,7 +2339,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t 
> > > flags)
> > >   xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags);
> > >   if (!xhci->cmd_ring)
> > >   goto f

Re: [PATCH v4 00/21] ARM: OMAP2+: Adapt to ehci-omap changes for 3.10

2013-04-05 Thread Tony Lindgren
* Benoit Cousson  [130405 03:00]:
> On 04/05/2013 10:30 AM, Benoit Cousson wrote:
> 
> ...
> 
> >>   ARM: dts: OMAP4: Add HS USB Host IP nodes
> >>   ARM: dts: OMAP3: Add HS USB Host IP nodes
> >>   ARM: dts: omap3-beagle: Add USB Host support
> > 
> > These 3 DTS patches are good to me, but I cannot applied them on top of
> > the already existing patches I queued for 3.10.
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/bcousson/linux-omap-dt.git
> > for_3.10/dts
> > 
> > Could you rebase these 3 ones only, and I will applied them.
> 
> Mmm, in fact, I've just seen the pull request from Tony :-(
> 
> 
> Tony,
> 
> Don't you want to remove these DTS patches from the pull-request?

Oops sorry :( Looks like I applied them mistakenly as I saved all
the patches into a mbox, then applied it. Anyways, too late to start
messing with it now.
 
> Otherwise, I will have to rebase the whole DTS series on top of yours.
> That being said, if the branch is not supposed to be rebased, it is doable.

I pulled in your for_3.10/dts for testing, and to me it looks like
it's just overlapping additions. So that should be OK to resolve while
pulling it in.

It seems there's no need to add omap-for-v3.10/usb as a dependency for
your for_3.10/dts unless the conflict gets non-trivial with some
additional patches.

Regards,

Tony
--
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 v2 10/11] usb: musb: use musb->port_mode

2013-04-05 Thread Daniel Mack
Initialize the host and gagdet subsystems of the musb driver only when
the appropriate mode is selected from platform data, or device-tree
information, respectively.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c| 22 +-
 drivers/usb/musb/musb_virthub.c |  3 ++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2640d25..b3b9873 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb->xceiv->state = OTG_STATE_B_IDLE;
}
 
-   status = musb_host_setup(musb, plat->power);
-   if (status < 0)
-   goto fail3;
-
-   status = musb_gadget_setup(musb);
+   switch (musb->port_mode) {
+   case MUSB_PORT_MODE_HOST:
+   status = musb_host_setup(musb, plat->power);
+   break;
+   case MUSB_PORT_MODE_GADGET:
+   status = musb_gadget_setup(musb);
+   break;
+   case MUSB_PORT_MODE_DUAL_ROLE:
+   status = musb_host_setup(musb, plat->power);
+   if (status < 0)
+   goto fail3;
+   status = musb_gadget_setup(musb);
+   break;
+   default:
+   dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
+   break;
+   }
 
if (status < 0)
goto fail3;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 1e17c20..8d92ba2 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 * (b) vbus present/connect IRQ, peripheral mode;
 * (c) peripheral initiates, using SRP
 */
-   if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+   if (musb->port_mode != MUSB_PORT_MODE_HOST &&
+   (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
musb->is_active = 1;
} else {
devctl |= MUSB_DEVCTL_SESSION;
-- 
1.8.1.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 v2 11/11] usb: musb: eliminate musb_to_hcd

2013-04-05 Thread Daniel Mack
With the hcd is now a direct member of struct musb, we can now simply
eliminate the musb_to_hcd() macro. There aren't that many users left
anyway, as some where already fixed up when parts were factored out to
musb_host.c

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c| 4 ++--
 drivers/usb/musb/musb_host.c| 8 
 drivers/usb/musb/musb_virthub.c | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b3b9873..57b7a17 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -389,7 +389,7 @@ static void musb_otg_timer_func(unsigned long data)
  */
 void musb_hnp_stop(struct musb *musb)
 {
-   struct usb_hcd  *hcd = musb_to_hcd(musb);
+   struct usb_hcd  *hcd = musb->hcd;
void __iomem*mbase = musb->mregs;
u8  reg;
 
@@ -686,7 +686,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
}
 
if (int_usb & MUSB_INTR_CONNECT) {
-   struct usb_hcd *hcd = musb_to_hcd(musb);
+   struct usb_hcd *hcd = musb->hcd;
 
handled = IRQ_HANDLED;
musb->is_active = 1;
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index b6a840e..d3cbaa3 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -320,9 +320,9 @@ __acquires(musb->lock)
urb->actual_length, urb->transfer_buffer_length
);
 
-   usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb);
+   usb_hcd_unlink_urb_from_ep(musb->hcd, urb);
spin_unlock(&musb->lock);
-   usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status);
+   usb_hcd_giveback_urb(musb->hcd, urb, status);
spin_lock(&musb->lock);
 }
 
@@ -1465,7 +1465,7 @@ done:
if (length > qh->maxpacket)
length = qh->maxpacket;
/* Unmap the buffer so that CPU can use it */
-   usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
+   usb_hcd_unmap_urb_for_dma(musb->hcd, urb);
 
/*
 * We need to map sg if the transfer_buffer is
@@ -1880,7 +1880,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
unsigned int received_len;
 
/* Unmap the buffer so that CPU can use it */
-   usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
+   usb_hcd_unmap_urb_for_dma(musb->hcd, urb);
 
/*
 * We need to map sg if the transfer_buffer is
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 8d92ba2..5a101fe 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -215,7 +215,7 @@ static void musb_port_reset(struct musb *musb, bool 
do_reset)
musb->port1_status |= USB_PORT_STAT_ENABLE
| (USB_PORT_STAT_C_RESET << 16)
| (USB_PORT_STAT_C_ENABLE << 16);
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb->hcd);
 
musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
}
@@ -228,7 +228,7 @@ void musb_root_disconnect(struct musb *musb)
musb->port1_status = USB_PORT_STAT_POWER
| (USB_PORT_STAT_C_CONNECTION << 16);
 
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb->hcd);
musb->is_active = 0;
 
switch (musb->xceiv->state) {
@@ -382,7 +382,7 @@ int musb_hub_control(
musb->port1_status &= ~(USB_PORT_STAT_SUSPEND
| MUSB_PORT_STAT_RESUME);
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
-   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */
musb->xceiv->state = OTG_STATE_A_HOST;
}
-- 
1.8.1.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 v2 09/11] usb: musb: re-introduce musb->port_mode

2013-04-05 Thread Daniel Mack
Define MUSB_PORT_MODE_{HOST,GADGET,DUAL_ROLE} and store the
platform-specified value in struct musb.

Note that MUSB_PORT_MODE_HOST has to be set to 1 in order to match
existing device tree bindings which are already documented but in fact
unusued.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c | 1 +
 drivers/usb/musb/musb_core.h | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fbcf5cb..2640d25 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1821,6 +1821,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb->board_set_power = plat->set_power;
musb->min_power = plat->min_power;
musb->ops = plat->platform_ops;
+   musb->port_mode = plat->mode;
 
/* The musb_platform_init() call:
 *   - adjusts musb->mregs
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 6b65847..174c097 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -77,6 +77,12 @@ struct musb_ep;
 #define is_peripheral_active(m)(!(m)->is_host)
 #define is_host_active(m)  ((m)->is_host)
 
+enum {
+   MUSB_PORT_MODE_HOST = 1,
+   MUSB_PORT_MODE_GADGET,
+   MUSB_PORT_MODE_DUAL_ROLE,
+};
+
 #ifdef CONFIG_PROC_FS
 #include 
 #define MUSB_CONFIG_PROC_FS
@@ -356,6 +362,7 @@ struct musb {
 
u8  min_power;  /* vbus for periph, in mA/2 */
 
+   int port_mode;  /* MUSB_PORT_MODE_* */
boolis_host;
 
int a_wait_bcon;/* VBUS timeout in msecs */
-- 
1.8.1.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 v2 06/11] usb: musb: factor out hcd initalization

2013-04-05 Thread Daniel Mack
The musb struct is currently allocated along with the hcd, which makes
it difficult to build a driver that only acts as gadget device.

Fix this by allocating musb directly, and keep the hcd around as
a pointer in the musb struct.

struct hc_driver musb_hc_driver can now also be static to musb_host.c,
and the macro musb_to_hcd() is just a pointer dereferencer for now, and
will be elminiated later.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c | 40 
 drivers/usb/musb/musb_core.h |  1 +
 drivers/usb/musb/musb_host.c | 54 ++--
 drivers/usb/musb/musb_host.h | 19 +++-
 4 files changed, 75 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index adf069d..f3519d3 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -404,7 +404,8 @@ void musb_hnp_stop(struct musb *musb)
break;
case OTG_STATE_B_HOST:
dev_dbg(musb->controller, "HNP: Disabling HR\n");
-   hcd->self.is_b_host = 0;
+   if (hcd)
+   hcd->self.is_b_host = 0;
musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
reg = musb_readb(mbase, MUSB_POWER);
@@ -726,7 +727,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
 b_host:
musb->xceiv->state = OTG_STATE_B_HOST;
-   hcd->self.is_b_host = 1;
+   if (hcd)
+   hcd->self.is_b_host = 1;
musb->ignore_disconnect = 0;
del_timer(&musb->otg_timer);
break;
@@ -768,7 +770,8 @@ b_host:
 * in hnp_stop() is currently not used...
 */
musb_root_disconnect(musb);
-   musb_to_hcd(musb)->self.is_b_host = 0;
+   if (musb->hcd)
+   musb->hcd->self.is_b_host = 0;
musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
MUSB_DEV_MODE(musb);
musb_g_disconnect(musb);
@@ -1714,24 +1717,18 @@ static struct musb *allocate_instance(struct device 
*dev,
struct musb *musb;
struct musb_hw_ep   *ep;
int epnum;
-   struct usb_hcd  *hcd;
+   int ret;
 
-   hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev));
-   if (!hcd)
+   musb = devm_kzalloc(dev, sizeof(*musb), GFP_KERNEL);
+   if (!musb)
return NULL;
-   /* usbcore sets dev->driver_data to hcd, and sometimes uses that... */
 
-   musb = hcd_to_musb(hcd);
INIT_LIST_HEAD(&musb->control);
INIT_LIST_HEAD(&musb->in_bulk);
INIT_LIST_HEAD(&musb->out_bulk);
 
-   hcd->uses_new_polling = 1;
-   hcd->has_tt = 1;
-
musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON;
-   dev_set_drvdata(dev, musb);
musb->mregs = mbase;
musb->ctrl_base = mbase;
musb->nIrq = -ENODEV;
@@ -1746,7 +1743,16 @@ static struct musb *allocate_instance(struct device *dev,
 
musb->controller = dev;
 
+   ret = musb_host_alloc(musb);
+   if (ret < 0)
+   goto err_free;
+
+   dev_set_drvdata(dev, musb);
+
return musb;
+
+err_free:
+   return NULL;
 }
 
 static void musb_free(struct musb *musb)
@@ -1772,7 +1778,7 @@ static void musb_free(struct musb *musb)
dma_controller_destroy(c);
}
 
-   usb_put_hcd(musb_to_hcd(musb));
+   musb_host_free(musb);
 }
 
 /*
@@ -1789,7 +1795,6 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
int status;
struct musb *musb;
struct musb_hdrc_platform_data *plat = dev->platform_data;
-   struct usb_hcd  *hcd;
 
/* The driver might handle more features than the board; OK.
 * Fail when the board needs a feature that's not enabled.
@@ -1890,13 +1895,6 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb->irq_wake = 0;
}
 
-   /* host side needs more setup */
-   hcd = musb_to_hcd(musb);
-   otg_set_host(musb->xceiv->otg, &hcd->self);
-   hcd->self.otg_port = 1;
-   musb->xceiv->otg->host = &hcd->self;
-   hcd->power_budget = 2 * (plat->power ? : 250);
-
/* program PHY to use external vBus if required */
if (plat->extvbus) {
u8 busctl = musb_read_ulpi_buscontrol(musb->mregs);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 87da041..6b65847 100644
--- a/drivers/usb/musb/musb_

[PATCH v2 08/11] usb: musb: add musb_host_setup() and musb_host_cleanup()

2013-04-05 Thread Daniel Mack
This patch re-introduces the bits that are necessary to use the musb
controller in host mode.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c |  5 +
 drivers/usb/musb/musb_host.c | 21 +
 drivers/usb/musb/musb_host.h |  8 
 3 files changed, 34 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index f3519d3..fbcf5cb 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -961,6 +961,7 @@ static void musb_shutdown(struct platform_device *pdev)
 
pm_runtime_get_sync(musb->controller);
 
+   musb_host_cleanup(musb);
musb_gadget_cleanup(musb);
 
spin_lock_irqsave(&musb->lock, flags);
@@ -1910,6 +1911,10 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb->xceiv->state = OTG_STATE_B_IDLE;
}
 
+   status = musb_host_setup(musb, plat->power);
+   if (status < 0)
+   goto fail3;
+
status = musb_gadget_setup(musb);
 
if (status < 0)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 38834b2..b6a840e 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2648,6 +2648,27 @@ void musb_host_free(struct musb *musb)
usb_put_hcd(musb->hcd);
 }
 
+int musb_host_setup(struct musb *musb, int power_budget)
+{
+   int ret;
+   struct usb_hcd *hcd = musb->hcd;
+
+   MUSB_HST_MODE(musb);
+   musb->xceiv->otg->default_a = 1;
+   musb->xceiv->state = OTG_STATE_A_IDLE;
+
+   otg_set_host(musb->xceiv->otg, &hcd->self);
+   hcd->self.otg_port = 1;
+   musb->xceiv->otg->host = &hcd->self;
+   hcd->power_budget = 2 * (power_budget ? : 250);
+
+   ret = usb_add_hcd(hcd, 0, 0);
+   if (ret < 0)
+   return ret;
+
+   return 0;
+}
+
 void musb_host_resume_root_hub(struct musb *musb)
 {
usb_hcd_resume_root_hub(musb->hcd);
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 1ce6e4e..48a4bdd 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -81,6 +81,8 @@ static inline struct musb_qh *first_qh(struct list_head *q)
 extern struct musb *hcd_to_musb(struct usb_hcd *);
 extern irqreturn_t musb_h_ep0_irq(struct musb *);
 extern int musb_host_alloc(struct musb *);
+extern int musb_host_setup(struct musb *, int);
+extern void musb_host_cleanup(struct musb *);
 extern void musb_host_tx(struct musb *, u8);
 extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
@@ -107,6 +109,12 @@ static inline int musb_host_alloc(struct musb *musb)
return 0;
 }
 
+static inline int musb_host_setup(struct musb *musb, int power_budget)
+{
+   return 0;
+}
+
+static inline void musb_host_cleanup(struct musb *musb){}
 static inline void musb_host_free(struct musb *musb)   {}
 static inline void musb_host_tx(struct musb *musb, u8 epnum)   {}
 static inline void musb_host_rx(struct musb *musb, u8 epnum)   {}
-- 
1.8.1.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 v2 07/11] usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes

2013-04-05 Thread Daniel Mack
This makes building the actual object files optional to the selected
mode, which saves users who know which kind of USB mode support they
need some binary size.

Unimplemented functions are stubbed out with static inline functions.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/Kconfig   | 29 +
 drivers/usb/musb/Makefile  | 10 --
 drivers/usb/musb/musb_gadget.h | 21 +
 drivers/usb/musb/musb_host.h   | 29 +++--
 4 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 47442d3..aab1568 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -28,6 +28,35 @@ config USB_MUSB_HDRC
 if USB_MUSB_HDRC
 
 choice
+   bool "MUSB Mode Selection"
+   default USB_MUSB_DUAL_ROLE if (USB && USB_GADGET)
+   default USB_MUSB_HOST if (USB && !USB_GADGET)
+   default USB_MUSB_GADGET if (!USB && USB_GADGET)
+
+config USB_MUSB_HOST
+   bool "Host only mode"
+   depends on USB
+   help
+ Select this when you want to use MUSB in host mode only,
+ thereby the gadget feature will be regressed.
+
+config USB_MUSB_GADGET
+   bool "Gadget only mode"
+   depends on USB_GADGET
+   help
+ Select this when you want to use MUSB in gadget mode only,
+ thereby the host feature will be regressed.
+
+config USB_MUSB_DUAL_ROLE
+   bool "Dual Role mode"
+   depends on (USB && USB_GADGET)
+   help
+ This is the default mode of working of MUSB controller where
+ both host and gadget features are enabled.
+
+endchoice
+
+choice
prompt "Platform Glue Layer"
 
 config USB_MUSB_DAVINCI
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 3b85871..6b13a53 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -6,10 +6,16 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
 
 musb_hdrc-y := musb_core.o
 
-musb_hdrc-y+= musb_gadget_ep0.o 
musb_gadget.o
-musb_hdrc-y+= musb_virthub.o musb_host.o
 musb_hdrc-$(CONFIG_DEBUG_FS)   += musb_debugfs.o
 
+ifneq ($(filter y,$(CONFIG_USB_MUSB_HOST) $(CONFIG_USB_MUSB_DUAL_ROLE)),)
+   musb_hdrc-y += musb_virthub.o musb_host.o
+endif
+
+ifneq ($(filter y,$(CONFIG_USB_MUSB_GADGET) $(CONFIG_USB_MUSB_DUAL_ROLE)),)
+   musb_hdrc-y += musb_gadget_ep0.o 
musb_gadget.o
+endif
+
 # Hardware Glue Layer
 obj-$(CONFIG_USB_MUSB_OMAP2PLUS)   += omap2430.o
 obj-$(CONFIG_USB_MUSB_AM35X)   += am35x.o
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 75f821c..0314dfc 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -37,6 +37,7 @@
 
 #include 
 
+#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
 extern irqreturn_t musb_g_ep0_irq(struct musb *);
 extern void musb_g_tx(struct musb *, u8);
 extern void musb_g_rx(struct musb *, u8);
@@ -48,6 +49,26 @@ extern void musb_g_disconnect(struct musb *);
 extern void musb_gadget_cleanup(struct musb *);
 extern int musb_gadget_setup(struct musb *);
 
+#else
+static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
+{
+   return 0;
+}
+
+static inline void musb_g_tx(struct musb *musb, u8 epnum)  {}
+static inline void musb_g_rx(struct musb *musb, u8 epnum)  {}
+static inline void musb_g_reset(struct musb *musb) {}
+static inline void musb_g_suspend(struct musb *musb)   {}
+static inline void musb_g_resume(struct musb *musb){}
+static inline void musb_g_wakeup(struct musb *musb){}
+static inline void musb_g_disconnect(struct musb *musb){}
+static inline void musb_gadget_cleanup(struct musb *musb)  {}
+static inline int musb_gadget_setup(struct musb *musb)
+{
+   return 0;
+}
+#endif
+
 enum buffer_map_state {
UN_MAPPED = 0,
PRE_MAPPED,
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index e47035e..1ce6e4e 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -39,8 +39,6 @@
 
 #define musb_to_hcd(MUSB) ((MUSB)->hcd)
 
-extern struct musb *hcd_to_musb(struct usb_hcd *);
-
 /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
 struct musb_qh {
struct usb_host_endpoint *hep;  /* usbcore info */
@@ -78,6 +76,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
return list_entry(q->next, struct musb_qh, ring);
 }
 
+
+#if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
+extern struct musb *hcd_to_musb(struct usb_hcd *);
 extern irqreturn_t musb_h_ep0_irq(struct musb *);
 extern int musb_host_alloc(struct musb *);
 extern void musb_host_tx(struct musb *, u8);
@@ -90,6 +91,30 @@ extern void musb_host_rx(st

[PATCH v2 05/11] usb: musb: move musb_start to musb_virthub.c

2013-04-05 Thread Daniel Mack
This function has its only user in musb_virthub.c, so let's move it
there and make it static.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c| 45 -
 drivers/usb/musb/musb_core.h|  1 -
 drivers/usb/musb/musb_virthub.c | 44 
 3 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 13341c6..adf069d 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -905,51 +905,6 @@ b_host:
 
 /*-*/
 
-/*
-* Program the HDRC to start (enable interrupts, dma, etc.).
-*/
-void musb_start(struct musb *musb)
-{
-   void __iomem*regs = musb->mregs;
-   u8  devctl = musb_readb(regs, MUSB_DEVCTL);
-
-   dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
-
-   /*  Set INT enable registers, enable interrupts */
-   musb->intrtxe = musb->epmask;
-   musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
-   musb->intrrxe = musb->epmask & 0xfffe;
-   musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
-   musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
-
-   musb_writeb(regs, MUSB_TESTMODE, 0);
-
-   /* put into basic highspeed mode and start session */
-   musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
-   | MUSB_POWER_HSENAB
-   /* ENSUSPEND wedges tusb */
-   /* | MUSB_POWER_ENSUSPEND */
-   );
-
-   musb->is_active = 0;
-   devctl = musb_readb(regs, MUSB_DEVCTL);
-   devctl &= ~MUSB_DEVCTL_SESSION;
-
-   /* session started after:
-* (a) ID-grounded irq, host mode;
-* (b) vbus present/connect IRQ, peripheral mode;
-* (c) peripheral initiates, using SRP
-*/
-   if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
-   musb->is_active = 1;
-   else
-   devctl |= MUSB_DEVCTL_SESSION;
-
-   musb_platform_enable(musb);
-   musb_writeb(regs, MUSB_DEVCTL, devctl);
-}
-
-
 static void musb_generic_disable(struct musb *musb)
 {
void __iomem*mbase = musb->mregs;
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 04d8974..87da041 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -503,7 +503,6 @@ static inline void musb_configure_ep0(struct musb *musb)
 
 extern const char musb_driver_name[];
 
-extern void musb_start(struct musb *musb);
 extern void musb_stop(struct musb *musb);
 
 extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index ef7d110..1e17c20 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -44,6 +44,50 @@
 
 #include "musb_core.h"
 
+/*
+* Program the HDRC to start (enable interrupts, dma, etc.).
+*/
+static void musb_start(struct musb *musb)
+{
+   void __iomem*regs = musb->mregs;
+   u8  devctl = musb_readb(regs, MUSB_DEVCTL);
+
+   dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
+
+   /*  Set INT enable registers, enable interrupts */
+   musb->intrtxe = musb->epmask;
+   musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
+   musb->intrrxe = musb->epmask & 0xfffe;
+   musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
+   musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
+
+   musb_writeb(regs, MUSB_TESTMODE, 0);
+
+   /* put into basic highspeed mode and start session */
+   musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
+   | MUSB_POWER_HSENAB
+   /* ENSUSPEND wedges tusb */
+   /* | MUSB_POWER_ENSUSPEND */
+   );
+
+   musb->is_active = 0;
+   devctl = musb_readb(regs, MUSB_DEVCTL);
+   devctl &= ~MUSB_DEVCTL_SESSION;
+
+   /* session started after:
+* (a) ID-grounded irq, host mode;
+* (b) vbus present/connect IRQ, peripheral mode;
+* (c) peripheral initiates, using SRP
+*/
+   if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
+   musb->is_active = 1;
+   } else {
+   devctl |= MUSB_DEVCTL_SESSION;
+   }
+
+   musb_platform_enable(musb);
+   musb_writeb(regs, MUSB_DEVCTL, devctl);
+}
 
 static void musb_port_suspend(struct musb *musb, bool do_suspend)
 {
-- 
1.8.1.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 v2 03/11] usb: musb: factor some host-specific functions

2013-04-05 Thread Daniel Mack
In particular, this introduces musb_host_resume_root_hub()and
musb_host_poke_root_hub() which will be stubbed out later.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.c | 18 +++---
 drivers/usb/musb/musb_host.c | 15 ++-
 drivers/usb/musb/musb_host.h |  3 +++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 37a261a..13341c6 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -484,7 +484,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
 
musb->xceiv->state = OTG_STATE_A_HOST;
musb->is_active = 1;
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
@@ -501,7 +501,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
case OTG_STATE_A_SUSPEND:
/* possibly DISCONNECT is upcoming */
musb->xceiv->state = OTG_STATE_A_HOST;
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
break;
case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_PERIPHERAL:
@@ -643,7 +643,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
 * undesired detour through A_WAIT_BCON.
 */
musb_hnp_stop(musb);
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
musb_root_disconnect(musb);
musb_platform_try_idle(musb, jiffies
+ msecs_to_jiffies(musb->a_wait_bcon
@@ -734,17 +734,13 @@ b_host:
if ((devctl & MUSB_DEVCTL_VBUS)
== (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
musb->xceiv->state = OTG_STATE_A_HOST;
-   hcd->self.is_b_host = 0;
+   if (hcd)
+   hcd->self.is_b_host = 0;
}
break;
}
 
-   /* poke the root hub */
-   MUSB_HST_MODE(musb);
-   if (hcd->status_urb)
-   usb_hcd_poll_rh_status(hcd);
-   else
-   usb_hcd_resume_root_hub(hcd);
+   musb_host_poke_root_hub(musb);
 
dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
usb_otg_state_string(musb->xceiv->state), 
devctl);
@@ -759,7 +755,7 @@ b_host:
switch (musb->xceiv->state) {
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
-   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+   musb_host_resume_root_hub(musb);
musb_root_disconnect(musb);
if (musb->a_wait_bcon != 0)
musb_platform_try_idle(musb, jiffies
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 8914dec..8b977d2 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -46,7 +46,6 @@
 #include "musb_core.h"
 #include "musb_host.h"
 
-
 /* MUSB HOST status 22-mar-2006
  *
  * - There's still lots of partial code duplication for fault paths, so
@@ -2608,3 +2607,17 @@ const struct hc_driver musb_hc_driver = {
/* .start_port_reset= NULL, */
/* .hub_irq_enable  = NULL, */
 };
+
+void musb_host_resume_root_hub(struct musb *musb)
+{
+   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+}
+
+void musb_host_poke_root_hub(struct musb *musb)
+{
+   MUSB_HST_MODE(musb);
+   if (musb_to_hcd(musb)->status_urb)
+   usb_hcd_poll_rh_status(musb_to_hcd(musb));
+   else
+   usb_hcd_resume_root_hub(musb_to_hcd(musb));
+}
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 9670269..c63e585 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -89,6 +89,9 @@ extern void musb_host_tx(struct musb *, u8);
 extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 
+extern void musb_host_resume_root_hub(struct musb *musb);
+extern void musb_host_poke_root_hub(struct musb *musb);
+
 struct usb_hcd;
 
 extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
-- 
1.8.1.4

--
To unsubscribe from this list: send the 

[PATCH v2 04/11] usb: musb: gadget: remove hcd initialization

2013-04-05 Thread Daniel Mack
This will be done from a more appropriate location and as it doesn't
work anyway, it can safely be removed before the other changes.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_gadget.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index ba70923..0414bc1 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1820,7 +1820,6 @@ static int musb_gadget_start(struct usb_gadget *g,
 {
struct musb *musb = gadget_to_musb(g);
struct usb_otg  *otg = musb->xceiv->otg;
-   struct usb_hcd  *hcd = musb_to_hcd(musb);
unsigned long   flags;
int retval = 0;
 
@@ -1847,17 +1846,9 @@ static int musb_gadget_start(struct usb_gadget *g,
 * handles power budgeting ... this way also
 * ensures HdrcStart is indirectly called.
 */
-   retval = usb_add_hcd(hcd, 0, 0);
-   if (retval < 0) {
-   dev_dbg(musb->controller, "add_hcd failed, %d\n", retval);
-   goto err;
-   }
-
if (musb->xceiv->last_event == USB_EVENT_ID)
musb_platform_set_vbus(musb, 1);
 
-   hcd->self.uses_pio_for_control = 1;
-
if (musb->xceiv->last_event == USB_EVENT_NONE)
pm_runtime_put(musb->controller);
 
@@ -1942,7 +1933,6 @@ static int musb_gadget_stop(struct usb_gadget *g,
musb_platform_try_idle(musb, 0);
spin_unlock_irqrestore(&musb->lock, flags);
 
-   usb_remove_hcd(musb_to_hcd(musb));
/*
 * FIXME we need to be able to register another
 * gadget driver here and have everything work;
-- 
1.8.1.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 v2 02/11] usb: musb: move function declarations to musb_{host,gadget}.h

2013-04-05 Thread Daniel Mack
Let the function declarations live in the header files they belong to,
which makes it easier to stub them out later.

Signed-off-by: Daniel Mack 
---
 drivers/usb/musb/musb_core.h   | 17 -
 drivers/usb/musb/musb_gadget.h | 17 +++--
 drivers/usb/musb/musb_host.h   |  4 +++-
 3 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7fb4819..04d8974 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -82,23 +82,6 @@ struct musb_ep;
 #define MUSB_CONFIG_PROC_FS
 #endif
 
-/** PERIPHERAL ROLE */
-
-extern irqreturn_t musb_g_ep0_irq(struct musb *);
-extern void musb_g_tx(struct musb *, u8);
-extern void musb_g_rx(struct musb *, u8);
-extern void musb_g_reset(struct musb *);
-extern void musb_g_suspend(struct musb *);
-extern void musb_g_resume(struct musb *);
-extern void musb_g_wakeup(struct musb *);
-extern void musb_g_disconnect(struct musb *);
-
-/** HOST ROLE ***/
-
-extern irqreturn_t musb_h_ep0_irq(struct musb *);
-extern void musb_host_tx(struct musb *, u8);
-extern void musb_host_rx(struct musb *, u8);
-
 /** CONSTANTS /
 
 #ifndef MUSB_C_NUM_EPS
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 66b7c5e..75f821c 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -37,6 +37,17 @@
 
 #include 
 
+extern irqreturn_t musb_g_ep0_irq(struct musb *);
+extern void musb_g_tx(struct musb *, u8);
+extern void musb_g_rx(struct musb *, u8);
+extern void musb_g_reset(struct musb *);
+extern void musb_g_suspend(struct musb *);
+extern void musb_g_resume(struct musb *);
+extern void musb_g_wakeup(struct musb *);
+extern void musb_g_disconnect(struct musb *);
+extern void musb_gadget_cleanup(struct musb *);
+extern int musb_gadget_setup(struct musb *);
+
 enum buffer_map_state {
UN_MAPPED = 0,
PRE_MAPPED,
@@ -106,14 +117,8 @@ static inline struct musb_request *next_request(struct 
musb_ep *ep)
return container_of(queue->next, struct musb_request, list);
 }
 
-extern void musb_g_tx(struct musb *musb, u8 epnum);
-extern void musb_g_rx(struct musb *musb, u8 epnum);
-
 extern const struct usb_ep_ops musb_g_ep0_ops;
 
-extern int musb_gadget_setup(struct musb *);
-extern void musb_gadget_cleanup(struct musb *);
-
 extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
 
 extern void musb_ep_restart(struct musb *, struct musb_request *);
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index 5a9c8fe..9670269 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -84,7 +84,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
return list_entry(q->next, struct musb_qh, ring);
 }
 
-
+extern irqreturn_t musb_h_ep0_irq(struct musb *);
+extern void musb_host_tx(struct musb *, u8);
+extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 
 struct usb_hcd;
-- 
1.8.1.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 v2 01/11] usb: gadget: drop unused USB_GADGET_MUSB_HDRC

2013-04-05 Thread Daniel Mack
The functionality meant to be represented by this symbol will be
re-added later, but for now, USB_GADGET_MUSB_HDRC is in fact unused and
can be dropped.

Signed-off-by: Daniel Mack 
---
 drivers/usb/gadget/Kconfig | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a61d981..0702fa0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -333,14 +333,6 @@ config USB_MV_U3D
 # Controllers available in both integrated and discrete versions
 #
 
-# musb builds in ../musb along with host support
-config USB_GADGET_MUSB_HDRC
-   tristate "Inventra HDRC USB Peripheral (TI, ADI, ...)"
-   depends on USB_MUSB_HDRC
-   help
- This OTG-capable silicon IP is used in dual designs including
- the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin
-
 config USB_M66592
tristate "Renesas M66592 USB Peripheral Controller"
help
-- 
1.8.1.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 v2 00/11] usb: musb: add back support for host mode

2013-04-05 Thread Daniel Mack
Hi all,

here are some patches to separate the HCD and gadget part of the musb
driver so they can be deselected in Kconfig. They also make the driver
keep track of the configured port mode that is set from DT, so the
actual runtime configuration can be selected dynamically.

One thing that is still broken is that once pm_suspend() was called on
a musb device on a USB disconnect, the port won't wake up again when a
device is plugged back in. I doubt this is related to my patches, but I
might be wrong. If that effect rings a bell to anyone, please let me
know.

Thanks,
Daniel


Changes from v1:
* fixed some typos in commit logs
* factor out musb_host_resume_root_hub and
  musb_host_poke_root_hub()
* split some changes into separate patches
* some minor cosmetics fixed

Daniel Mack (11):
  usb: gadget: drop unused USB_GADGET_MUSB_HDRC
  usb: musb: move function declarations to musb_{host,gadget}.h
  usb: musb: factor some host-specific functions
  usb: musb: gadget: remove hcd initialization
  usb: musb: move musb_start to musb_virthub.c
  usb: musb: factor out hcd initalization
  usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
  usb: musb: add musb_host_setup() and musb_host_cleanup()
  usb: musb: re-introduce musb->port_mode
  usb: musb: use musb->port_mode
  usb: musb: eliminate musb_to_hcd

 drivers/usb/gadget/Kconfig  |   8 ---
 drivers/usb/musb/Kconfig|  29 +
 drivers/usb/musb/Makefile   |  10 +++-
 drivers/usb/musb/musb_core.c| 127 +++-
 drivers/usb/musb/musb_core.h|  26 +++-
 drivers/usb/musb/musb_gadget.c  |  10 
 drivers/usb/musb/musb_gadget.h  |  38 ++--
 drivers/usb/musb/musb_host.c|  90 +---
 drivers/usb/musb/musb_host.h|  57 ++
 drivers/usb/musb/musb_virthub.c |  51 +++-
 10 files changed, 300 insertions(+), 146 deletions(-)

-- 
1.8.1.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: usb-storage causes hibernation to freeze before snapshotting image

2013-04-05 Thread Alan Stern
On Fri, 5 Apr 2013, Paul Menzel wrote:

> Dear Linux USB folks,
> 
> 
> using Debian Wheezy/testing with Linux 3.2.39-2 and
> uswsusp 1.0+20110509-3, I see the following problem similar to the one
> described in some Ubuntu forum from 2009 [1] or a question from 2012 to
> Ask Ubuntu [2].
> 
> Running `pm-hibernate` and `s2disk`, sometimes everything works, but
> very often, it does not snapshot the system but just stalls.
> 
> Looking for splash system... none 
> s2disk: Snapshotting system
> 
> Comparing the loaded modules listed in `/var/log/pm-suspend.log`, it
> turns out that the module `usb-storage` is the problem. Unloading this
> before hibernating, by doing for example
> 
> $ echo "MODULES_SUSPEND=usb-storage" >> /etc/pm/config.d/60-modules
> 
> the problem cannot be reproduced anymore.
> 
> I attach some more information at the end of the message.
> 
> Do you know if such a problem was fixed in later Linux kernels? How
> should that be debugged?

You should start by running a later Linux kernel; that will answer your 
first question right away.

For further testing, you should build the kernel with 
CONFIG_USB_DEBUGGING enabled and see what the dmesg log says following 
a failed attempt to hibernate.

You may also want to try running usbmon (see
Documentation/usb/usbmon.txt) during the hibernation attempt.  It might
provide some useful information.

Alan Stern

--
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 2/8] ehci-platform: add init() method to platform data

2013-04-05 Thread Alan Stern
On Fri, 5 Apr 2013, Sergei Shtylyov wrote:

> Sometimes there is a need to initialize some non-standard registers mapped to
> the EHCI region before accessing the standard EHCI registers.  Add the init()
> method to the 'ehci-platform' platform data for this purpose.

"init" isn't such a good name for this.  It's too vague; there are
already a lot of initialization steps here.  How about "pre_setup"
instead?

> --- renesas.orig/drivers/usb/host/ehci-platform.c
> +++ renesas/drivers/usb/host/ehci-platform.c
> @@ -110,6 +110,13 @@ static int ehci_platform_probe(struct pl
>   err = PTR_ERR(hcd->regs);
>   goto err_put_hcd;
>   }
> +
> + if (pdata->init) {
> + err = pdata->init(dev, hcd->regs);
> + if (err < 0)
> + goto err_put_hcd;
> + }

Also, I think this code should go in the ehci_platform_reset() routine, 
just before the call to ehci_setup().  That way more of the setup will 
already have been carried out.

And instead of passing hcd->regs, wouldn't it be better to pass hcd?  
Other users of this interface might need to initialize something other 
than a non-standard register.

Alan Stern

--
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: Linux USB file storage gadget with new UDC

2013-04-05 Thread Alan Stern
On Fri, 5 Apr 2013, victor yeo wrote:

> Now i insmod g_file_storage gadget with file=/mnt/sd/backing_file, the
> SCSI_READ_10 command is still not working properly.

What makes you think that?

> See the gadget log below. The g_file_storage gadget receives "SCSI
> command: Unknown xa1" from the Linux host near the end of the log.

0xA1 is not READ(10); 0x28 is.  Why do you think the READ(10) command
isn't working properly?

> Something is wrong.

...
> g_file_storage gadget: bulk-out, length 31:
> : 55 53 42 43 12 00 00 00 00 02 00 00 80 00 0c a1
> 0010: 08 2e 00 01 00 00 00 00 ec 00 00 00 13 00 00
> g_file_storage gadget: SCSI command: Unknown xa1;  Dc=12, Du=0;  Hc=12, Hi=512
> g_file_storage gadget: bulk-in, length 0:
> g_file_storage gadget: bulk-in set halt
> g_file_storage gadget: sending command-failure status
> g_file_storage gadget:   sense data: SK x05, ASC x20, ASCQ x00;  info x0
> g_file_storage gadget: bulk-in, length 13:
> : 55 53 42 53 12 00 00 00 00 02 00 00 01

There's nothing wrong with this.  The host is allowed to send commands 
that the gadget doesn't understand.  That's what SK 5, ASC 0x20 means; 
it tells the host that the gadget didn't understand the previous 
command.

> g_file_storage gadget: ep0-setup, length 8:
> : 80 06 00 01 00 00 40 00
> g_file_storage gadget: get device descriptor

But something is definitely wrong here.  Before sending this
Get-Device-Descriptor request, the host should have done a USB port
reset.  Either the host isn't performing the reset correctly or else
your UDC driver didn't inform g_file_storage when the reset occurred.

Alan Stern

--
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 0/7] usb: musb: add support for host support back

2013-04-05 Thread Felipe Balbi
Hi,

On Fri, Apr 05, 2013 at 02:40:45PM +0200, Daniel Mack wrote:
> >> Hi all,
> >>
> >> here are some patches to separate the HCD and gadget part of the musb
> >> driver so they can be deselected in Kconfig. They also make the driver
> >> keep track of the configured port mode that is set from DT, so the
> >> actual runtime configuration can be selected dynamically.
> >>
> >> One thing that is still broken is that once pm_suspend() was called on
> >> a musb device on a USB disconnect, the port won't wake up again when a
> >> device is plugged back in. I doubt this is related to my patches, but I
> >> might be wrong. If that effect rings a bell to anyone, please let me
> >> know.
> >>
> >>
> >> Thanks,
> >> Daniel
> >>
> >>
> >> Daniel Mack (7):
> >>   usb: gadget: drop unused USB_GADGET_MUSB_HDRC
> >>   usb: musb: move function declarations to musb_{host,gadget}.h
> >>   usb: musb: factor out hcd initalization
> >>   usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
> >>   usb: musb: add musb_host_setup() and musb_host_cleanup()
> >>   usb: musb: re-introduce musb->port_mode
> >>   usb: musb: eliminate musb_to_hcd
> > 
> > pretty good, getting there. Here's what I'd to see though:
> > 
> > introduce musb_gadget_init() and musb_host_init(). Those two should
> > contain everything necessary to initialize each side of the API.
> > 
> > Then we can simply:
> > 
> > switch(mode) {
> > case HOST:
> > musb_host_init();
> > break;
> > case PERIPHERAL:
> > musb_gadget_init();
> > break;
> > case OTG:
> > /* it's important to initialize gadget side first */
> > musb_gadget_init();
> > musb_host_init();
> > break;
> > }
> 
> Sorry, I read over the code again and I want to be sure I understand
> what you mean here. The _init() functions you mention are called
> _setup() in my case, because there was already a musb_gadget_setup(), so
> I called the host side accordingly.
> 
> Including the check of the return value, I ended up with these lines:
> 
> if (musb->port_mode == MUSB_PORT_MODE_HOST ||
> musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) {
> status = musb_host_setup(musb, plat->power);
> if (status < 0)
> goto fail3;
> }
> 
> if (musb->port_mode == MUSB_PORT_MODE_GADGET ||
> musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) {
> status = musb_gadget_setup(musb);
> if (status < 0)
> goto fail3;
> }
> 
> ... and that's part of the result of my patch set. What exactly do you
> want me to change? Is it that musb_gadget_setup() is be called before
> musb_host_setup()? Or is it about their names?
> 
> > code will look cleaner and initialization will be straight forward and a
> > lot easier to understand.
> 
> Compared to what exactly?
> 
> > This means that the call to usb_add_hcd() from musb_gadget_start()
> > should be removed.
> 
> As stated in a previous mail, this is already done.

I replied to each patch what needs to be changed.

> Any idea about the host port not waking up after the device was
> unplugged once?

Bad PM ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 7/7] usb: musb: eliminate musb_to_hcd

2013-04-05 Thread Felipe Balbi
On Thu, Apr 04, 2013 at 09:50:13PM +0200, Daniel Mack wrote:
> With the hcd is now a direct member of struct musb, we can now simply
> eliminate the musb_to_hcd() macro. There aren't that many users left
> anyway, as some where already fixed up when parts were factored out to
> musb_host.c
> 
> Signed-off-by: Daniel Mack 

looks alright.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 6/7] usb: musb: re-introduce musb->port_mode

2013-04-05 Thread Felipe Balbi
Hi,

On Thu, Apr 04, 2013 at 09:50:12PM +0200, Daniel Mack wrote:
> Initialize the host and gagdet subsystems of the musb driver only when
> the appropriate mode is selected from platform data, or device-tree
> information, respectively.
> 
> Refuse to start the gadget part if the port is in host-only mode.
> 
> Signed-off-by: Daniel Mack 
> ---
>  drivers/usb/musb/musb_core.c   | 25 +
>  drivers/usb/musb/musb_core.h   |  7 +++
>  drivers/usb/musb/musb_gadget.c |  5 +
>  3 files changed, 29 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index cb1631e..c021058 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -943,10 +943,12 @@ void musb_start(struct musb *musb)
>* (b) vbus present/connect IRQ, peripheral mode;
>* (c) peripheral initiates, using SRP
>*/
> - if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
> + if (musb->port_mode != MUSB_PORT_MODE_HOST &&
> + (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
>   musb->is_active = 1;
> - else
> + } else {
>   devctl |= MUSB_DEVCTL_SESSION;
> + }

this is the kind of code which shouldn't exist in musb_core.c. This file
should only know about calling musb_host_setup() and
musb_gadget_cleanup(). Those two functions should take care of checking
details such as VBUS.

The only thing this file should do is, as stated before:

switch(mode)
case host:
musb_host_setup();
break;
case peripheral:
musb_peripheral_setup();
break;
case otg:
musb_peripheral_setup();
musb_host_setup();
break;
default:
bail_out();
}

> @@ -1868,6 +1870,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
> __iomem *ctrl)
>   musb->board_set_power = plat->set_power;
>   musb->min_power = plat->min_power;
>   musb->ops = plat->platform_ops;
> + musb->port_mode = plat->mode;
>  
>   /* The musb_platform_init() call:
>*   - adjusts musb->mregs
> @@ -1958,13 +1961,19 @@ musb_init_controller(struct device *dev, int nIrq, 
> void __iomem *ctrl)
>   musb->xceiv->state = OTG_STATE_B_IDLE;
>   }
>  
> - status = musb_host_setup(musb, plat->power);
> - if (status < 0)
> - goto fail3;
> + if (musb->port_mode == MUSB_PORT_MODE_HOST ||
> + musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) {
> + status = musb_host_setup(musb, plat->power);
> + if (status < 0)
> + goto fail3;
> + }
>  
> - status = musb_gadget_setup(musb);
> - if (status < 0)
> - goto fail3;
> + if (musb->port_mode == MUSB_PORT_MODE_GADGET ||
> + musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) {
> + status = musb_gadget_setup(musb);
> + if (status < 0)
> + goto fail3;
> + }

this is quite convoluted, to me at least. A switch statement, as I
suggested before, looks a lot cleaner.

> diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
> index ef5b4e6..ed1644f 100644
> --- a/drivers/usb/musb/musb_core.h
> +++ b/drivers/usb/musb/musb_core.h
> @@ -77,6 +77,12 @@ struct musb_ep;
>  #define is_peripheral_active(m)  (!(m)->is_host)
>  #define is_host_active(m)((m)->is_host)
>  
> +enum {
> + MUSB_PORT_MODE_HOST = 1,
> + MUSB_PORT_MODE_GADGET   = 2,
> + MUSB_PORT_MODE_DUAL_ROLE= 3,

no need to assign numbers yourself. You can let the compiler do it.

should be part of a separate patch, btw.

> @@ -356,6 +362,7 @@ struct musb {
>  
>   u8  min_power;  /* vbus for periph, in mA/2 */
>  
> + int port_mode;  /* MUSB_PORT_MODE_* */

should be part of a separate patch. First you add what you need, then
you use it.

It helps keeping patches very small, which makes my review time a lot
better as I can quickly look over patches adding fields to structures
and focus review on the actual meat.

> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index 0414bc1..c606088 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -1823,6 +1823,11 @@ static int musb_gadget_start(struct usb_gadget *g,
>   unsigned long   flags;
>   int retval = 0;
>  
> + if (musb->port_mode == MUSB_PORT_MODE_HOST) {
> + retval = -EINVAL;
> + goto err;
> + }

why ? You won't start the gadget side unless port mode is gadget or otg,
this should *NEVER* be true.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 5/7] usb: musb: add musb_host_setup() and musb_host_cleanup()

2013-04-05 Thread Daniel Mack
On 05.04.2013 15:07, Felipe Balbi wrote:
> Hi,
> 
> On Thu, Apr 04, 2013 at 09:50:11PM +0200, Daniel Mack wrote:
>> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
>> index d564580..d298be7 100644
>> --- a/drivers/usb/musb/musb_host.c
>> +++ b/drivers/usb/musb/musb_host.c
>> @@ -2649,6 +2649,27 @@ void musb_host_free(struct musb *musb)
>>  usb_put_hcd(musb->hcd);
>>  }
>>  
>> +int musb_host_setup(struct musb *musb, int power_budget)
>> +{
>> +int ret;
>> +struct usb_hcd *hcd = musb->hcd;
>> +
>> +MUSB_HST_MODE(musb);
>> +musb->xceiv->otg->default_a = 1;
>> +musb->xceiv->state = OTG_STATE_A_IDLE;
>> +
>> +otg_set_host(musb->xceiv->otg, &hcd->self);
> 
> you don't want to do these by default. You might screw things up for OTG
> builds where you *must* start in b_idle state.

Which is why my initialitation code calls musb_gadget_setup() *after*
musb_host_setup(), so things are configured properly for OTG. Any better
idea on how to solve that?

>> +hcd->self.otg_port = 1;
>> +musb->xceiv->otg->host = &hcd->self;
>> +hcd->power_budget = 2 * (power_budget ? : 250);
> 
> not sure you should default to 500mA budget. you might burn some boards
> which aren't passing proper power_budget here.

These values were taken from the original implementation, I just copied
them over.


Daniel


--
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/7] usb: musb: add musb_host_setup() and musb_host_cleanup()

2013-04-05 Thread Felipe Balbi
Hi,

On Thu, Apr 04, 2013 at 09:50:11PM +0200, Daniel Mack wrote:
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index d564580..d298be7 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -2649,6 +2649,27 @@ void musb_host_free(struct musb *musb)
>   usb_put_hcd(musb->hcd);
>  }
>  
> +int musb_host_setup(struct musb *musb, int power_budget)
> +{
> + int ret;
> + struct usb_hcd *hcd = musb->hcd;
> +
> + MUSB_HST_MODE(musb);
> + musb->xceiv->otg->default_a = 1;
> + musb->xceiv->state = OTG_STATE_A_IDLE;
> +
> + otg_set_host(musb->xceiv->otg, &hcd->self);

you don't want to do these by default. You might screw things up for OTG
builds where you *must* start in b_idle state.

> + hcd->self.otg_port = 1;
> + musb->xceiv->otg->host = &hcd->self;
> + hcd->power_budget = 2 * (power_budget ? : 250);

not sure you should default to 500mA budget. you might burn some boards
which aren't passing proper power_budget here.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/7] usb: musb: factor out hcd initalization

2013-04-05 Thread Daniel Mack
On 05.04.2013 15:03, Felipe Balbi wrote:
> On Thu, Apr 04, 2013 at 09:50:09PM +0200, Daniel Mack wrote:
>> The musb struct is currently allocated along with the hcd, which makes
>> it difficult to build a driver that only acts as gadget device.
>>
>> Fix this by allocation musb directly, and keep the hcd around as pointer.
> 
> Fix this by *allocating*
> 
>> struct hc_driver musb_hc_driver can now also be static to musb_host.c,
>> and the macro musb_to_hcd() is just a pointer dereferencer for now, and
>> will be elminiated later.
>>
>> Signed-off-by: Daniel Mack 
>> ---
>>  drivers/usb/musb/musb_core.c   | 60 ++
>>  drivers/usb/musb/musb_core.h   |  1 +
>>  drivers/usb/musb/musb_gadget.c | 10 ---
>>  drivers/usb/musb/musb_host.c   | 65 
>> --
>>  drivers/usb/musb/musb_host.h   | 21 +++---
>>  5 files changed, 102 insertions(+), 55 deletions(-)
>>
>> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
>> index 37a261a..d5e9794 100644
>> --- a/drivers/usb/musb/musb_core.c
>> +++ b/drivers/usb/musb/musb_core.c
>> @@ -404,7 +404,8 @@ void musb_hnp_stop(struct musb *musb)
>>  break;
>>  case OTG_STATE_B_HOST:
>>  dev_dbg(musb->controller, "HNP: Disabling HR\n");
>> -hcd->self.is_b_host = 0;
>> +if (hcd)
>> +hcd->self.is_b_host = 0;
>>  musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
>>  MUSB_DEV_MODE(musb);
>>  reg = musb_readb(mbase, MUSB_POWER);
>> @@ -484,7 +485,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
>> int_usb,
>>  
>>  musb->xceiv->state = OTG_STATE_A_HOST;
>>  musb->is_active = 1;
>> -usb_hcd_resume_root_hub(musb_to_hcd(musb));
>> +musb_host_resume_root_hub(musb);
> 
> this small re-factoring should be done in a separate patch coming before
> $subject.
> 
>> @@ -734,17 +736,13 @@ b_host:
>>  if ((devctl & MUSB_DEVCTL_VBUS)
>>  == (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
>>  musb->xceiv->state = OTG_STATE_A_HOST;
>> -hcd->self.is_b_host = 0;
>> +if (hcd)
>> +hcd->self.is_b_host = 0;
>>  }
>>  break;
>>  }
>>  
>> -/* poke the root hub */
>> -MUSB_HST_MODE(musb);
>> -if (hcd->status_urb)
>> -usb_hcd_poll_rh_status(hcd);
>> -else
>> -usb_hcd_resume_root_hub(hcd);
>> +musb_host_poke_root_hub(musb);
> 
> likewise for this one.
> 
>> @@ -1763,24 +1762,18 @@ static struct musb *allocate_instance(struct device 
>> *dev,
>>  struct musb *musb;
>>  struct musb_hw_ep   *ep;
>>  int epnum;
>> -struct usb_hcd  *hcd;
>> +int ret;
>>  
>> -hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev));
>> -if (!hcd)
>> +musb = kzalloc(sizeof(*musb), GFP_KERNEL);
> 
> devm_* ? Or perhaps in a later patch.
> 
>> +void musb_host_cleanup(struct musb *musb)
>> +{
>> +usb_remove_hcd(musb->hcd);
>> +musb->hcd = NULL;
>> +}
>> +
>> +void musb_host_free(struct musb *musb)
>> +{
>> +usb_put_hcd(musb->hcd);
>> +}
>> +
>> +void musb_host_resume_root_hub(struct musb *musb)
>> +{
>> +usb_hcd_resume_root_hub(musb->hcd);
>> +}
>> +
>> +void musb_host_poll_rh_status(struct musb *musb)
>> +{
>> +usb_hcd_poll_rh_status(musb->hcd);
>> +}
>> +
>> +void musb_host_poke_root_hub(struct musb *musb)
>> +{
>> +MUSB_HST_MODE(musb);
>> +if (musb->hcd->status_urb)
>> +usb_hcd_poll_rh_status(musb->hcd);
>> +else
>> +usb_hcd_resume_root_hub(musb->hcd);
>> +}
> 
> no need to check for NULL hcd in any of these ? I guess you're relying
> on those being stubbed out when Host isn't compiled in, am I right ?

Yes, exactly. musb->hcd will be a NULL pointer then, which is unused by
the static inline function.

Thanks for the review though, prepare a new series.



Daniel


> 
> just being sure...
> 
>> diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
>> index 9670269..fb24422 100644
>> --- a/drivers/usb/musb/musb_host.h
>> +++ b/drivers/usb/musb/musb_host.h
>> @@ -37,15 +37,9 @@
>>  
>>  #include 
>>  
>> -static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
>> -{
>> -return container_of((void *) musb, struct usb_hcd, hcd_priv);
>> -}
>> +#define musb_to_hcd(MUSB) ((MUSB)->hcd)
> 
> all lower cases, please.
> 

--
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 4/7] usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes

2013-04-05 Thread Felipe Balbi
Hi

On Thu, Apr 04, 2013 at 09:50:10PM +0200, Daniel Mack wrote:
> This makes building the actual object files optional to the selected
> mode, which saves users who know which kind of USB mode support they
> need some binary size.
> 
> Unimplemented functions are stubbed out with static inline functions.
> 
> Signed-off-by: Daniel Mack 
> ---
>  drivers/usb/musb/Kconfig   | 29 +
>  drivers/usb/musb/Makefile  | 10 --
>  drivers/usb/musb/musb_core.c   |  1 -
>  drivers/usb/musb/musb_gadget.h | 21 +
>  drivers/usb/musb/musb_host.h   | 29 +++--
>  5 files changed, 85 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
> index 47442d3..aab1568 100644
> --- a/drivers/usb/musb/Kconfig
> +++ b/drivers/usb/musb/Kconfig
> @@ -28,6 +28,35 @@ config USB_MUSB_HDRC
>  if USB_MUSB_HDRC
>  
>  choice
> + bool "MUSB Mode Selection"
> + default USB_MUSB_DUAL_ROLE if (USB && USB_GADGET)
> + default USB_MUSB_HOST if (USB && !USB_GADGET)
> + default USB_MUSB_GADGET if (!USB && USB_GADGET)
> +
> +config USB_MUSB_HOST
> + bool "Host only mode"
> + depends on USB
> + help
> +   Select this when you want to use MUSB in host mode only,
> +   thereby the gadget feature will be regressed.
> +
> +config USB_MUSB_GADGET
> + bool "Gadget only mode"
> + depends on USB_GADGET
> + help
> +   Select this when you want to use MUSB in gadget mode only,
> +   thereby the host feature will be regressed.
> +
> +config USB_MUSB_DUAL_ROLE
> + bool "Dual Role mode"
> + depends on (USB && USB_GADGET)
> + help
> +   This is the default mode of working of MUSB controller where
> +   both host and gadget features are enabled.
> +
> +endchoice
> +
> +choice
>   prompt "Platform Glue Layer"
>  
>  config USB_MUSB_DAVINCI
> diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
> index 3b85871..6b13a53 100644
> --- a/drivers/usb/musb/Makefile
> +++ b/drivers/usb/musb/Makefile
> @@ -6,10 +6,16 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
>  
>  musb_hdrc-y := musb_core.o
>  
> -musb_hdrc-y  += musb_gadget_ep0.o 
> musb_gadget.o
> -musb_hdrc-y  += musb_virthub.o musb_host.o
>  musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o
>  
> +ifneq ($(filter y,$(CONFIG_USB_MUSB_HOST) $(CONFIG_USB_MUSB_DUAL_ROLE)),)
> + musb_hdrc-y += musb_virthub.o musb_host.o
> +endif
> +
> +ifneq ($(filter y,$(CONFIG_USB_MUSB_GADGET) $(CONFIG_USB_MUSB_DUAL_ROLE)),)
> + musb_hdrc-y += musb_gadget_ep0.o 
> musb_gadget.o
> +endif
> +
>  # Hardware Glue Layer
>  obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o
>  obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index d5e9794..c637d36 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -1958,7 +1958,6 @@ musb_init_controller(struct device *dev, int nIrq, void 
> __iomem *ctrl)
>   }
>  
>   status = musb_gadget_setup(musb);
> -

trailing change.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/7] usb: musb: factor out hcd initalization

2013-04-05 Thread Felipe Balbi
On Thu, Apr 04, 2013 at 09:50:09PM +0200, Daniel Mack wrote:
> The musb struct is currently allocated along with the hcd, which makes
> it difficult to build a driver that only acts as gadget device.
> 
> Fix this by allocation musb directly, and keep the hcd around as pointer.

Fix this by *allocating*

> struct hc_driver musb_hc_driver can now also be static to musb_host.c,
> and the macro musb_to_hcd() is just a pointer dereferencer for now, and
> will be elminiated later.
> 
> Signed-off-by: Daniel Mack 
> ---
>  drivers/usb/musb/musb_core.c   | 60 ++
>  drivers/usb/musb/musb_core.h   |  1 +
>  drivers/usb/musb/musb_gadget.c | 10 ---
>  drivers/usb/musb/musb_host.c   | 65 
> --
>  drivers/usb/musb/musb_host.h   | 21 +++---
>  5 files changed, 102 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 37a261a..d5e9794 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -404,7 +404,8 @@ void musb_hnp_stop(struct musb *musb)
>   break;
>   case OTG_STATE_B_HOST:
>   dev_dbg(musb->controller, "HNP: Disabling HR\n");
> - hcd->self.is_b_host = 0;
> + if (hcd)
> + hcd->self.is_b_host = 0;
>   musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
>   MUSB_DEV_MODE(musb);
>   reg = musb_readb(mbase, MUSB_POWER);
> @@ -484,7 +485,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
> int_usb,
>  
>   musb->xceiv->state = OTG_STATE_A_HOST;
>   musb->is_active = 1;
> - usb_hcd_resume_root_hub(musb_to_hcd(musb));
> + musb_host_resume_root_hub(musb);

this small re-factoring should be done in a separate patch coming before
$subject.

> @@ -734,17 +736,13 @@ b_host:
>   if ((devctl & MUSB_DEVCTL_VBUS)
>   == (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
>   musb->xceiv->state = OTG_STATE_A_HOST;
> - hcd->self.is_b_host = 0;
> + if (hcd)
> + hcd->self.is_b_host = 0;
>   }
>   break;
>   }
>  
> - /* poke the root hub */
> - MUSB_HST_MODE(musb);
> - if (hcd->status_urb)
> - usb_hcd_poll_rh_status(hcd);
> - else
> - usb_hcd_resume_root_hub(hcd);
> + musb_host_poke_root_hub(musb);

likewise for this one.

> @@ -1763,24 +1762,18 @@ static struct musb *allocate_instance(struct device 
> *dev,
>   struct musb *musb;
>   struct musb_hw_ep   *ep;
>   int epnum;
> - struct usb_hcd  *hcd;
> + int ret;
>  
> - hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev));
> - if (!hcd)
> + musb = kzalloc(sizeof(*musb), GFP_KERNEL);

devm_* ? Or perhaps in a later patch.

> +void musb_host_cleanup(struct musb *musb)
> +{
> + usb_remove_hcd(musb->hcd);
> + musb->hcd = NULL;
> +}
> +
> +void musb_host_free(struct musb *musb)
> +{
> + usb_put_hcd(musb->hcd);
> +}
> +
> +void musb_host_resume_root_hub(struct musb *musb)
> +{
> + usb_hcd_resume_root_hub(musb->hcd);
> +}
> +
> +void musb_host_poll_rh_status(struct musb *musb)
> +{
> + usb_hcd_poll_rh_status(musb->hcd);
> +}
> +
> +void musb_host_poke_root_hub(struct musb *musb)
> +{
> + MUSB_HST_MODE(musb);
> + if (musb->hcd->status_urb)
> + usb_hcd_poll_rh_status(musb->hcd);
> + else
> + usb_hcd_resume_root_hub(musb->hcd);
> +}

no need to check for NULL hcd in any of these ? I guess you're relying
on those being stubbed out when Host isn't compiled in, am I right ?

just being sure...

> diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
> index 9670269..fb24422 100644
> --- a/drivers/usb/musb/musb_host.h
> +++ b/drivers/usb/musb/musb_host.h
> @@ -37,15 +37,9 @@
>  
>  #include 
>  
> -static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
> -{
> - return container_of((void *) musb, struct usb_hcd, hcd_priv);
> -}
> +#define musb_to_hcd(MUSB) ((MUSB)->hcd)

all lower cases, please.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/7] usb: musb: move function declarations to musb_{host,gadget}.h

2013-04-05 Thread Felipe Balbi
On Thu, Apr 04, 2013 at 09:50:08PM +0200, Daniel Mack wrote:
> Let the function declarations live in the header file the belong to,

header file *they* belong to. Typo there.

other than that, patch looks alright.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/7] usb: gadget: drop unused USB_GADGET_MUSB_HDRC

2013-04-05 Thread Felipe Balbi
On Thu, Apr 04, 2013 at 09:50:07PM +0200, Daniel Mack wrote:
> The functionality meant to be represented by this symbol will be
> re-added later, but for now, USB_GADGET_MUSB_HDRC is in fact unused and
> can be dropped.
> 
> Signed-off-by: Daniel Mack 

this one is good to go for v3.11

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 0/7] usb: musb: add support for host support back

2013-04-05 Thread Daniel Mack
Hi,

On 05.04.2013 11:58, Felipe Balbi wrote:
> On Thu, Apr 04, 2013 at 09:50:06PM +0200, Daniel Mack wrote:
>> Hi all,
>>
>> here are some patches to separate the HCD and gadget part of the musb
>> driver so they can be deselected in Kconfig. They also make the driver
>> keep track of the configured port mode that is set from DT, so the
>> actual runtime configuration can be selected dynamically.
>>
>> One thing that is still broken is that once pm_suspend() was called on
>> a musb device on a USB disconnect, the port won't wake up again when a
>> device is plugged back in. I doubt this is related to my patches, but I
>> might be wrong. If that effect rings a bell to anyone, please let me
>> know.
>>
>>
>> Thanks,
>> Daniel
>>
>>
>> Daniel Mack (7):
>>   usb: gadget: drop unused USB_GADGET_MUSB_HDRC
>>   usb: musb: move function declarations to musb_{host,gadget}.h
>>   usb: musb: factor out hcd initalization
>>   usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
>>   usb: musb: add musb_host_setup() and musb_host_cleanup()
>>   usb: musb: re-introduce musb->port_mode
>>   usb: musb: eliminate musb_to_hcd
> 
> pretty good, getting there. Here's what I'd to see though:
> 
> introduce musb_gadget_init() and musb_host_init(). Those two should
> contain everything necessary to initialize each side of the API.
> 
> Then we can simply:
> 
> switch(mode) {
> case HOST:
>   musb_host_init();
>   break;
> case PERIPHERAL:
>   musb_gadget_init();
>   break;
> case OTG:
>   /* it's important to initialize gadget side first */
>   musb_gadget_init();
>   musb_host_init();
>   break;
> }

Sorry, I read over the code again and I want to be sure I understand
what you mean here. The _init() functions you mention are called
_setup() in my case, because there was already a musb_gadget_setup(), so
I called the host side accordingly.

Including the check of the return value, I ended up with these lines:

if (musb->port_mode == MUSB_PORT_MODE_HOST ||
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) {
status = musb_host_setup(musb, plat->power);
if (status < 0)
goto fail3;
}

if (musb->port_mode == MUSB_PORT_MODE_GADGET ||
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) {
status = musb_gadget_setup(musb);
if (status < 0)
goto fail3;
}

... and that's part of the result of my patch set. What exactly do you
want me to change? Is it that musb_gadget_setup() is be called before
musb_host_setup()? Or is it about their names?

> code will look cleaner and initialization will be straight forward and a
> lot easier to understand.

Compared to what exactly?

> This means that the call to usb_add_hcd() from musb_gadget_start()
> should be removed.

As stated in a previous mail, this is already done.


Any idea about the host port not waking up after the device was
unplugged once?



Thanks,
Daniel

--
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 ehci suspend/resume on beagleboard

2013-04-05 Thread Roger Quadros
On 04/05/2013 02:11 PM, Grazvydas Ignotas wrote:
> On Thu, Apr 4, 2013 at 2:50 PM, Roger Quadros  wrote:
>> correcting misleading subject line.
>> was (Re: MUSB regression in linux next at least for pandboard)
>>
>> On 04/04/2013 02:36 PM, Roger Quadros wrote:
>>> Hi,
>>>
>>> On 02/07/2013 04:10 PM, Grazvydas Ignotas wrote:
 On Thu, Feb 7, 2013 at 11:16 AM, Roger Quadros  wrote:
 
> It seems the beagleboard problem is related to OMAP silicon errata [1].
> Apparently, remote wakeup as well as host issued wakeup break omap-ehci 
> and have
> nothing to do with the hub or it's driver.
>
> I'll work on this issue after I'm done with device tree migration.

 Looking forward to this, mainline has been suffering from this since
 almost forever..


>>>
>>> Unfortunately, there is another errata [2] that makes it impossible to
>>> support suspend/resume on the beagleboard.
> 
> You could fix it for BeagleBoard-xM at least, I think it is not
> affected by this as it has DM3730 (only early revisions with 1.0
> silicon of that are affected with [2]). This would also fix it for
> DM3730-based pandoras.
> 

Yes you are right. I need to get a beagleboard-xM.

cheers,
-roger

>>>
>>> [2] Advisory 3.1.1.195 HSUSB Interoperability Issue With SMSC USB3320 PHY
>>> http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sprz278f&fileType=pdf


--
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 ehci suspend/resume on beagleboard

2013-04-05 Thread Grazvydas Ignotas
On Thu, Apr 4, 2013 at 2:50 PM, Roger Quadros  wrote:
> correcting misleading subject line.
> was (Re: MUSB regression in linux next at least for pandboard)
>
> On 04/04/2013 02:36 PM, Roger Quadros wrote:
>> Hi,
>>
>> On 02/07/2013 04:10 PM, Grazvydas Ignotas wrote:
>>> On Thu, Feb 7, 2013 at 11:16 AM, Roger Quadros  wrote:
>>> 
 It seems the beagleboard problem is related to OMAP silicon errata [1].
 Apparently, remote wakeup as well as host issued wakeup break omap-ehci 
 and have
 nothing to do with the hub or it's driver.

 I'll work on this issue after I'm done with device tree migration.
>>>
>>> Looking forward to this, mainline has been suffering from this since
>>> almost forever..
>>>
>>>
>>
>> Unfortunately, there is another errata [2] that makes it impossible to
>> support suspend/resume on the beagleboard.

You could fix it for BeagleBoard-xM at least, I think it is not
affected by this as it has DM3730 (only early revisions with 1.0
silicon of that are affected with [2]). This would also fix it for
DM3730-based pandoras.

>>
>> cheers,
>> -roger
>>
>> [2] Advisory 3.1.1.195 HSUSB Interoperability Issue With SMSC USB3320 PHY
>> http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sprz278f&fileType=pdf
>>
>

--
GraÅžvydas
--
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: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-05 Thread Roger Quadros
On 04/04/2013 07:41 PM, Tony Lindgren wrote:
> * Roger Quadros  [130404 00:39]:
>> On 04/04/2013 02:42 AM, Tony Lindgren wrote:
 --- a/arch/arm/mach-omap2/cclock44xx_data.c
 +++ b/arch/arm/mach-omap2/cclock44xx_data.c
 @@ -27,6 +27,7 @@
  #include 
  #include 
  #include 
 +#include 
  
  #include "soc.h"
  #include "iomap.h"
 @@ -1663,6 +1664,40 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "cpufreq_ck",   &dpll_mpu_ck,   CK_443X),
  };
  
 +static struct clk *scrm_clks[] = {
 +  &auxclk0_ck,
 +  &auxclk1_ck,
 +  &auxclk2_ck,
 +  &auxclk3_ck,
 +  &auxclk4_ck,
 +  &auxclk5_ck,
 +};
>>>
>>> Hmm I don't like the idea of specifying the auxclk both in the
>>> cclock44xx_data.c and in DT..
>>
>> Right, but till we have all clocks moved to DT we only need this
>> approach for general purpose clocks that are not mapped to devices
>> by hwmod.
> 
> For v3.10, let's just make sure that USB works with DT as then
> after v3.10 we can make omap4 DT only and get rid of estimated
> 7K lines of code and data. I guess this is the last piece missing
> for that, or are we also missing something else?

For panda we just need a way to map the auxclk to the USB PHY device
and the relevant dts data to get USB host working with DT.
Beagle USB host should work already with DT without any changes.

> 
> Can't you set up a clock alias for your device so it can find the
> auxclk when requesting it with the dev entry?
> 

which clock is mapped to which PHY device depends on board design
and that cannot be per-determined at one place. This information
needs to come from the board.dts file.

There was an earlier attempt to provide a way of building clock aliases
at runtime from device tree [1], but the current approach is way better

[1]
https://lkml.org/lkml/2013/3/12/241

> For the DT clock driver if needed for v3.10, how about just do a
> minimal drivers/clock/omap/ that uses the standard binding?
> Then that driver can just do clk_get() from cclock44xx_data.c

I don't understand how to do it and why it is better than the current
approach.

How can that driver do clk_get() from cclock44xx_data.c?
from where does it get the clk_id to pass into clk_get()?

> for now? And then later on we'll just move all the clocks to a
> combination of DT + /lib/firmware.

What is the benefit of moving clock data to /lib/firmware? We could
as well just move it to DT only, no?

> 
>> e.g. auxclk are required to be specified in DT nodes for USB PHY.
>> Without this we can't get USB host working on Panda.
> 
> OK. So if the USB PHY has a dev entry, can't you just set up a
> clock alias in struct omap_clk omap44xx_clks[] for it?

I've explained why this can't be done above.

>  
>> As Rajendra points out, it seems moving entire clock data to DT is not
>> going to happen soon. So this is the simplistic way things can work.
> 
> Right but seems like we can get started there without moving
> them all at once.
> 
What if we provide a complete clock list instead of only auxclks in
dt_clks[]?

This approach is similar to arch/arm/mach-imx/clk-imx35.c

Device drivers can then use them as they migrate to DT. Then later
we could migrate clock data to DT, without impacting device drivers.

cheers,
-roger
--
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 0/7] usb: musb: add support for host support back

2013-04-05 Thread Daniel Mack
Hi,

On 05.04.2013 11:58, Felipe Balbi wrote:
> On Thu, Apr 04, 2013 at 09:50:06PM +0200, Daniel Mack wrote:
>> Hi all,
>>
>> here are some patches to separate the HCD and gadget part of the musb
>> driver so they can be deselected in Kconfig. They also make the driver
>> keep track of the configured port mode that is set from DT, so the
>> actual runtime configuration can be selected dynamically.
>>
>> One thing that is still broken is that once pm_suspend() was called on
>> a musb device on a USB disconnect, the port won't wake up again when a
>> device is plugged back in. I doubt this is related to my patches, but I
>> might be wrong. If that effect rings a bell to anyone, please let me
>> know.
>>
>>
>> Thanks,
>> Daniel
>>
>>
>> Daniel Mack (7):
>>   usb: gadget: drop unused USB_GADGET_MUSB_HDRC
>>   usb: musb: move function declarations to musb_{host,gadget}.h
>>   usb: musb: factor out hcd initalization
>>   usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
>>   usb: musb: add musb_host_setup() and musb_host_cleanup()
>>   usb: musb: re-introduce musb->port_mode
>>   usb: musb: eliminate musb_to_hcd
> 
> pretty good, getting there. Here's what I'd to see though:
> 
> introduce musb_gadget_init() and musb_host_init(). Those two should
> contain everything necessary to initialize each side of the API.
> 
> Then we can simply:
> 
> switch(mode) {
> case HOST:
>   musb_host_init();
>   break;
> case PERIPHERAL:
>   musb_gadget_init();
>   break;
> case OTG:
>   /* it's important to initialize gadget side first */
>   musb_gadget_init();
>   musb_host_init();
>   break;
> }
> 
> code will look cleaner and initialization will be straight forward and a
> lot easier to understand.

Ok, thanks. I'll see how I can respin this.

> This means that the call to usb_add_hcd() from musb_gadget_start()
> should be removed.

That's already done in "usb: musb: factor out hcd initalization". Or do
I miss anything?



Daniel

--
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   >