[PATCH] usb: Using correct way to clear usb3.0 device's remote wakeup feature.

2013-01-16 Thread Lan Tianyu
Usb3.0 device defines function remote wakeup which is only for interface
recipient rather than device recipient. This is different with usb2.0 device's
remote wakeup feature which is defined for device recipient. According usb3.0
spec 9.4.5, the function remote wakeup can be modified by the SetFeature()
requests using the FUNCTION_SUSPEND feature selector. This patch is to use
correct way to disable usb3.0 device's function remote wakeup after suspend
error and resuming.

Signed-off-by: Lan Tianyu 
---
 drivers/usb/core/hub.c   |   71 +++---
 include/uapi/linux/usb/ch9.h |6 
 2 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 0ef512a..08c9c04 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2852,6 +2852,24 @@ void usb_enable_ltm(struct usb_device *udev)
 }
 EXPORT_SYMBOL_GPL(usb_enable_ltm);
 
+/*
+ * usb_disable_function_remotewakeup - disable usb3.0
+ * device's function remote wakeup
+ * @udev: target device
+ *
+ * Assume there's only one function on the USB 3.0
+ * device and disable remote wake for the first
+ * interface. FIXME if the interface association
+ * descriptor shows there's more than one function.
+ */
+static int usb_disable_function_remotewakeup(struct usb_device *udev)
+{
+   return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+   USB_REQ_CLEAR_FEATURE, USB_RECIP_INTERFACE,
+   USB_INTRF_FUNC_SUSPEND, 0, NULL, 0,
+   USB_CTRL_SET_TIMEOUT);
+}
+
 #ifdef CONFIG_USB_SUSPEND
 
 /*
@@ -2968,12 +2986,19 @@ int usb_port_suspend(struct usb_device *udev, 
pm_message_t msg)
dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n",
port1, status);
/* paranoia:  "should not happen" */
-   if (udev->do_remote_wakeup)
-   (void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
-   USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
-   USB_DEVICE_REMOTE_WAKEUP, 0,
-   NULL, 0,
-   USB_CTRL_SET_TIMEOUT);
+   if (udev->do_remote_wakeup) {
+   if (!hub_is_superspeed(hub->hdev)) {
+   (void) usb_control_msg(udev,
+   usb_sndctrlpipe(udev, 0),
+   USB_REQ_CLEAR_FEATURE,
+   USB_RECIP_DEVICE,
+   USB_DEVICE_REMOTE_WAKEUP, 0,
+   NULL, 0,
+   USB_CTRL_SET_TIMEOUT);
+   } else
+   (void) usb_disable_function_remotewakeup(udev);
+
+   }
 
/* Try to enable USB2 hardware LPM again */
if (udev->usb2_hw_lpm_capable == 1)
@@ -3059,20 +3084,30 @@ static int finish_port_resume(struct usb_device *udev)
dev_dbg(&udev->dev, "gone after usb resume? status %d\n",
status);
} else if (udev->actconfig) {
-   le16_to_cpus(&devstatus);
-   if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) {
-   status = usb_control_msg(udev,
-   usb_sndctrlpipe(udev, 0),
-   USB_REQ_CLEAR_FEATURE,
+   if (!hub_is_superspeed(udev->parent)) {
+   le16_to_cpus(&devstatus);
+   if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
+   status = usb_control_msg(udev,
+   usb_sndctrlpipe(udev, 0),
+   USB_REQ_CLEAR_FEATURE,
USB_RECIP_DEVICE,
-   USB_DEVICE_REMOTE_WAKEUP, 0,
-   NULL, 0,
-   USB_CTRL_SET_TIMEOUT);
-   if (status)
-   dev_dbg(&udev->dev,
-   "disable remote wakeup, status %d\n",
-   status);
+   USB_DEVICE_REMOTE_WAKEUP, 0,
+   NULL, 0,
+   USB_CTRL_SET_TIMEOUT);
+   } else {
+   status = usb_get_status(udev, USB_RECIP_INTERFACE, 0,
+   &devstatus);
+   le16_to_cpus(&devstatus);
+   if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP
+  

Re: [PATCH] CDC_NCM adding support IFF_NOARP for infineon modem platform

2013-01-16 Thread Wei Shuai
OK, I will follow up. after add FLAG_NOARP, how should I handle
IFF_NOARP? will I do it in cdc_ncm.c or usb_net.c?

2013/1/17 Dan Williams :
> On Sat, 2013-01-12 at 19:34 +0800, Wei Shuai wrote:
>> Infineon(now Intel) HSPA Modem platform NCM cannot support ARP. so I 
>> introduce a flag CDC_NCM_DRIVER_DATA_NOARP which is defined in 
>> driver_info:data. so later on, if more such buggy devices are found, they 
>> could use same flag to handle.
>
> So given that Dave now approves of IFF_NOARP, let's change your original
> patch to add a FLAG_NOARP for the .flags structure instead of inventing
> another mechanism for .data.
>
> Dan
>
>> Signed-off-by: Wei Shuai 
>> ---
>>  drivers/net/usb/cdc_ncm.c |   29 +
>>  1 files changed, 29 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
>> index 71b6e92..6093e07 100644
>> --- a/drivers/net/usb/cdc_ncm.c
>> +++ b/drivers/net/usb/cdc_ncm.c
>> @@ -55,6 +55,9 @@
>>
>>  #define  DRIVER_VERSION  "14-Mar-2012"
>>
>> +/* Flags for driver_info::data */
>> +#define CDC_NCM_DRIVER_DATA_NOARP  1
>> +
>>  static void cdc_ncm_txpath_bh(unsigned long param);
>>  static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx);
>>  static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer);
>> @@ -573,6 +576,10 @@ static int cdc_ncm_bind(struct usbnet *dev, struct 
>> usb_interface *intf)
>>   return -ENODEV;
>>  #endif
>>
>> + if (dev->driver_info->data & CDC_NCM_DRIVER_DATA_NOARP) {
>> + /* some buggy device cannot do ARP*/
>> + dev->net->flags |= IFF_NOARP;
>> + }
>>   /* NCM data altsetting is always 1 */
>>   ret = cdc_ncm_bind_common(dev, intf, 1);
>>
>> @@ -1155,6 +1162,21 @@ static const struct driver_info wwan_info = {
>>   .tx_fixup = cdc_ncm_tx_fixup,
>>  };
>>
>> +/* Same as wwan_info, but with IFF_NOARP  */
>> +static const struct driver_info wwan_noarp_info = {
>> + .description = "Mobile Broadband Network Device (NO ARP)",
>> + .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
>> + | FLAG_WWAN,
>> + .data = CDC_NCM_DRIVER_DATA_NOARP,
>> + .bind = cdc_ncm_bind,
>> + .unbind = cdc_ncm_unbind,
>> + .check_connect = cdc_ncm_check_connect,
>> + .manage_power = usbnet_manage_power,
>> + .status = cdc_ncm_status,
>> + .rx_fixup = cdc_ncm_rx_fixup,
>> + .tx_fixup = cdc_ncm_tx_fixup,
>> +};
>> +
>>  static const struct usb_device_id cdc_devs[] = {
>>   /* Ericsson MBM devices like F5521gw */
>>   { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
>> @@ -1194,6 +1216,13 @@ static const struct usb_device_id cdc_devs[] = {
>> .driver_info = (unsigned long)&wwan_info,
>>   },
>>
>> + /* Infineon(now Intel) HSPA Modem platform */
>> + { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
>> + USB_CLASS_COMM,
>> + USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
>> +   .driver_info = (unsigned long)&wwan_noarp_info,
>> + },
>> +
>>   /* Generic CDC-NCM devices */
>>   { USB_INTERFACE_INFO(USB_CLASS_COMM,
>>   USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] Staging: usbip: usbipcommon: Fixed single line bracing issue

2013-01-16 Thread Jake Champlin
Fixed coding style issue with single line braces.

Signed-off-by: Jake Champlin 
---
 drivers/staging/usbip/usbip_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/usbip_common.c 
b/drivers/staging/usbip/usbip_common.c
index 75189fe..75aa5bf 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -672,9 +672,8 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
return 0;
 
/* my Bluetooth dongle gets ISO URBs which are np = 0 */
-   if (np == 0) {
+   if (np == 0)
return 0;
-   }
 
buff = kzalloc(size, GFP_KERNEL);
if (!buff)
-- 
1.8.1.1


-- 
Jake Champlin
jake.champlin...@gmail.com
8123742937

--
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 3.8-rc1 - another regression on USB :-(

2013-01-16 Thread Woody Suwalski

Alan Stern wrote:

On Tue, 15 Jan 2013, Woody Suwalski wrote:


Another important change is that the EHCI driver is now split into two
modules.  That can slow down loading and affect the timing.

Alan Stern


My testcase is a live initramfs + squash root.
The boot logic is as stable as can be - unchanged since 2.6.2x kernels.
And it was working fine till 3.8-rc1.

The modules are insmoded in a fixed order:
usb-common, usbcore, xhci-hcd, ehci-hcd, uhci-hcd, ohci-hcd, usbhid,
usb_storage,...

But apparently you don't insmod ehci-pci.  That could cause problems,
if your EHCI controller is PCI-based.


If all USB is built as modules - I get read errors from USB drives when
accessing squash image, boot fails.

What read errors?  What is the cause of these errors?


If usb-common and usbcore are built in, system seems to crawl with a
very slow USB, but boots. That could be caused by timing between hcd
modules.

Do have a dmesg log with timestamps so we can see where things go slow?
I suggest enabling CONFIG_PRINTK_TIME and CONFIG_USB_DEBUG.  You might
even want CONFIG_USB_STORAGE_DEBUG, although that often logs too much
information.


If usb-common, usbcore and ehci-hcd are built-in, all works OK like
"before 3.8".

What about ehci-pci?



Alan, it took me 2 times re-reading the email to notice...
You were talking about ehci-pci, not ehci-hcd... Old assumptions die hard...
Yep, that was it.
Catch22 - I would have noticed new dependency if I could boot, but to 
boot I have had needed to notice the new dependency...


Case solved 8-)

Thanks, Woody

--
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 v3 1/3] ARM i.MX6: change mxs usbphy clock usage

2013-01-16 Thread Shawn Guo
On Wed, Jan 16, 2013 at 04:59:03PM +0800, Peter Chen wrote:
> This mxs usbphy is only needs to be on after system boots
> up, and software never needs to control it anymore.
> Meanwhile, usbphy's parent needs to be notified if usb
> is suspend or not. So we design below mxs usbphy usage:
> 
> - usbphy1_gate and usbphy2_gate:
> Their parents are dummy clock, we only needs to enable
> it after system boots up.
> - usbphy1 and usbphy2
> Usage reserved bit for this clock, in that case, the refcount
> will be updated, but without hardware changing.
> 
Ok, so we change the clocks usbphy1 and ushphy2 to access a reserved bit
for gating.  Then usbphy driver can play the clocks to maintain the use
count for parent PLL, which may have other child clocks, while leaving
the actual gating control to hardware.

Meanwhile, we add new clocks usbphy1_gate and ushphy2_gate being the
children of dummy clock to accessing the real gate bit.  Then clock
initialization can call clk_prepare_enable to enable for only once.

Though I feel this is a total hack, I do not see any other better option
to fulfill the hardware requirement with the least churn to software.
So I'm fine with it.

See one minor comment below.

> Signed-off-by: Peter Chen 
> ---
> Changes for v3:
> - Add new clk for usbphy clk gate which is only used 
> at system boots up process.
> 
> Changes for v2:
> - Use reserved bit for usb phy clk control
> 
>  arch/arm/mach-imx/clk-imx6q.c |   26 ++
>  1 files changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
> index 7f2c10c..ccb24cf 100644
> --- a/arch/arm/mach-imx/clk-imx6q.c
> +++ b/arch/arm/mach-imx/clk-imx6q.c
> @@ -154,8 +154,8 @@ enum mx6q_clks {
>   usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg,
>   pll4_audio, pll5_video, pll8_mlb, pll7_usb_host, pll6_enet, ssi1_ipg,
>   ssi2_ipg, ssi3_ipg, rom, usbphy1, usbphy2, ldb_di0_div_3_5, 
> ldb_di1_div_3_5,
> - sata_ref, sata_ref_100m, pcie_ref, pcie_ref_125m, enet_ref,
> - clk_max
> + sata_ref, sata_ref_100m, pcie_ref, pcie_ref_125m, enet_ref, 
> usbphy1_gate,
> + usbphy2_gate, clk_max

usbphy1_gate and usbphy2_gate need to be numbered in binding doc.

Shawn

>  };
>  
>  static struct clk *clk[clk_max];
> @@ -208,8 +208,21 @@ int __init mx6q_clocks_init(void)
>   clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB,   
> "pll7_usb_host","osc", base + 0x20, 0x3);
>   clk[pll8_mlb]  = imx_clk_pllv3(IMX_PLLV3_MLB,   "pll8_mlb", 
> "osc", base + 0xd0, 0x0);
>  
> - clk[usbphy1] = imx_clk_gate("usbphy1", "pll3_usb_otg", base + 0x10, 6);
> - clk[usbphy2] = imx_clk_gate("usbphy2", "pll7_usb_host", base + 0x20, 6);
> + /*
> +  * Bit 20 is the reserved and read-only bit, we do this only for:
> +  * - Do nothing for usbphy clk_enable/disable
> +  * - Keep refcount when do usbphy clk_enable/disable, in that case,
> +  * the clk framework may need to enable/disable usbphy's parent
> +  */
> + clk[usbphy1] = imx_clk_gate("usbphy1", "pll3_usb_otg", base + 0x10, 20);
> + clk[usbphy2] = imx_clk_gate("usbphy2", "pll7_usb_host", base + 0x20, 
> 20);
> +
> + /*
> +  * usbphy*_gate needs to be on after system boots up, and software
> +  * never needs to control it anymore.
> +  */
> + clk[usbphy1_gate] = imx_clk_gate("usbphy1_gate", "dummy", base + 0x10, 
> 6);
> + clk[usbphy2_gate] = imx_clk_gate("usbphy2_gate", "dummy", base + 0x20, 
> 6);
>  
>   clk[sata_ref] = imx_clk_fixed_factor("sata_ref", "pll6_enet", 1, 5);
>   clk[pcie_ref] = imx_clk_fixed_factor("pcie_ref", "pll6_enet", 1, 4);
> @@ -436,6 +449,11 @@ int __init mx6q_clocks_init(void)
>   for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
>   clk_prepare_enable(clk[clks_init_on[i]]);
>  
> + if (IS_ENABLED(CONFIG_USB_MXS_PHY)) {
> + clk_prepare_enable(clk[usbphy1_gate]);
> + clk_prepare_enable(clk[usbphy2_gate]);
> + }
> +
>   np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt");
>   base = of_iomap(np, 0);
>   WARN_ON(!base);
> -- 
> 1.7.0.4
> 
> 

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


Re: [PATCH v7 0/6] solve deadlock caused by memory allocation with I/O

2013-01-16 Thread Ming Lei
On Thu, Jan 17, 2013 at 7:37 AM, Andrew Morton
 wrote:
> On Sat,  5 Jan 2013 10:25:38 +0800
> Ming Lei  wrote:
>
>> This patchset try to solve one deadlock problem which might be caused
>> by memory allocation with block I/O during runtime PM and block device
>> error handling path. Traditionly, the problem is addressed by passing
>> GFP_NOIO statically to mm, but that is not a effective solution, see
>> detailed description in patch 1's commit log.
>>
>> This patch set introduces one process flag and trys to fix the deadlock
>> problem on block device/network device during runtime PM or usb bus reset.
>
> The patchset doesn't look like the worst thing I've ever applied ;)
>
> One thing I'm wondering: during suspend and resume, why are GFP_KERNEL
> allocation attempts even getting down to the device layer?  Presumably
> the page scanner is encountering dirty pagecache or dirty swapcache
> pages?
>
> If so, I wonder if we could avoid the whole problem by appropriately
> syncing all dirty memory back to storage before starting to turn devices
> off?

The patchset is to address the probable deadlock problem by GFP_KERNEL
during runtime suspend/resume which is per block/network device. I am
wondering if syncing all dirty memory is suitable or necessary during
per-storage/network device runtime resume/suspend:

  - sys_sync is very slow and runtime pm operation is frequent

  - it is not efficient because only sync dirty memory against the affected
device is needed in theory and not necessary to sync all

 - we still need some synchronization to avoid accessing the storage
   between sys_sync and device suspend, just like system sleep case,
   pm_restrict_gfp_mask is needed even sys_sync has been done
   inside enter_state().

So looks the approach in the patch is simpler and more efficient, :-)

Also, with the patchset, we can avoid many GFP_NOIO allocation
which is fragile and not easy to use.

Thanks,
--
Ming Lei
--
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] drivers: xhci: fix incorrect bit test

2013-01-16 Thread Sarah Sharp
Hi Nickolai,

Thanks for catching this.  Don't worry about sending a new patch with
the short description for the commit, I'll fix that when I send it off.

Sarah Sharp

On Mon, Jan 07, 2013 at 10:39:31PM -0500, Nickolai Zeldovich wrote:
> Fix incorrect bit test that originally showed up in
> 4ee823b83bc9851743fab756c76b27d6a1e2472b: use '&' instead of '&&'.
> 
> Signed-off-by: Nickolai Zeldovich 
> ---
>  drivers/usb/host/xhci-ring.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index cbb44b7..06921b6 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -1698,7 +1698,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
>   faked_port_index + 1);
>   if (slot_id && xhci->devs[slot_id])
>   xhci_ring_device(xhci, slot_id);
> - if (bus_state->port_remote_wakeup && (1 << faked_port_index)) {
> + if (bus_state->port_remote_wakeup & (1 << faked_port_index)) {
>   bus_state->port_remote_wakeup &=
>   ~(1 << faked_port_index);
>   xhci_test_and_clear_bit(xhci, port_array,
> -- 
> 1.7.10.4
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type

2013-01-16 Thread Simon Horman
On Wed, Jan 16, 2013 at 08:30:59PM +0530, Kishon Vijay Abraham I wrote:
> In order to add support for multipe PHY's of the same type, the API's
> for adding PHY and getting PHY has been changed. Now the binding
> information of the PHY and controller should be done in platform file
> using usb_bind_phy API. And for getting a PHY, the device pointer of the
> USB controller and an index should be passed. Based on the binding
> information that is added in the platform file, get_phy will return the
> approappropriate PHY.
> 
> Signed-off-by: Kishon Vijay Abraham I 
> ---
>  arch/arm/mach-shmobile/board-marzen.c |2 +-

Modification to the above file:

Acked-by: Simon Horman 
--
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 2/2] xhci: Fix TD size for isochronous URBs.

2013-01-16 Thread Sarah Sharp
To calculate the TD size for a particular TRB in an isoc TD, we need
know the endpoint's max packet size.  Isochronous endpoints also encode
the number of additional service opportunities in their wMaxPacketSize
field.  The TD size calculation did not mask off those bits before using
the field.  This resulted in incorrect TD size information for
isochronous TRBs when an URB frame buffer crossed a 64KB boundary.

For example:
 - an isoc endpoint has 2 additional service opportunites and
   a max packet size of 1020 bytes
 - a frame transfer buffer contains 3060 bytes
 - one frame buffer crosses a 64KB boundary, and must be split into
   one 1276 byte TRB, and one 1784 byte TRB.

The TD size is is the number of packets that remain to be transferred
for a TD after processing all the max packet sized packets in the
current TRB and all previous TRBs.

For this TD, the number of packets to be transferred is (3060 / 1020),
or 3.  The first TRB contains 1276 bytes, which means it contains one
full packet, and a 256 byte remainder.  After processing all the max
packet-sized packets in the first TRB, the host will have 2 packets left
to transfer.

The old code would calculate the TD size for the first TRB as:

total packet count = DIV_ROUND_UP (TD length / endpoint wMaxPacketSize)
total packet count - (first TRB length / endpoint wMaxPacketSize)

The math should have been:

total packet count = DIV_ROUND_UP (3060 / 1020) = 3
3 - (1276 / 1020) = 2

Since the old code didn't mask off the additional service interval bits
from the wMaxPacketSize field, the math ended up as

total packet count = DIV_ROUND_UP (3060 / 5116) = 1
1 - (1276 / 5116) = 1

Fix this by masking off the number of additional service opportunities
in the wMaxPacketSize field.

This patch should be backported to stable kernels as old as 3.0, that
contain the commit 4da6e6f247a2601ab9f1e63424e4d944ed4124f3 "xhci 1.0:
Update TD size field format."  It may not apply well to kernels older
than 3.2 because of commit 29cc88979a8818cd8c5019426e945aed118b400e
"USB: use usb_endpoint_maxp() instead of le16_to_cpu()".

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/host/xhci-ring.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index d1ff133..80ef717 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3108,7 +3108,7 @@ static u32 xhci_v1_0_td_remainder(int running_total, int 
trb_buff_len,
 * running_total.
 */
packets_transferred = (running_total + trb_buff_len) /
-   usb_endpoint_maxp(&urb->ep->desc);
+   GET_MAX_PACKET(usb_endpoint_maxp(&urb->ep->desc));
 
if ((total_packet_count - packets_transferred) > 31)
return 31 << 17;
@@ -3642,7 +3642,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, 
gfp_t mem_flags,
td_len = urb->iso_frame_desc[i].length;
td_remain_len = td_len;
total_packet_count = DIV_ROUND_UP(td_len,
-   usb_endpoint_maxp(&urb->ep->desc));
+   GET_MAX_PACKET(
+   usb_endpoint_maxp(&urb->ep->desc)));
/* A zero-length transfer still involves at least one packet. */
if (total_packet_count == 0)
total_packet_count++;
-- 
1.7.9

--
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 1/2] xhci: Fix isoc TD encoding.

2013-01-16 Thread Sarah Sharp
An isochronous TD is comprised of one isochronous TRB chained to zero or
more normal TRBs.  Only the isoc TRB has the TBC and TLBPC fields.  The
normal TRBs must set those fields to zeroes.  The code was setting the
TBC and TLBPC fields for both isoc and normal TRBs.  Fix this.

This should be backported to stable kernels as old as 3.0, that contain
the commit b61d378f2da41c748aba6ca19d77e1e1c02bcea5 " xhci 1.0: Set
transfer burst last packet count field."

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/host/xhci-ring.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 59fb5c6..d1ff133 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3664,9 +3664,11 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, 
gfp_t mem_flags,
td = urb_priv->td[i];
for (j = 0; j < trbs_per_td; j++) {
u32 remainder = 0;
-   field = TRB_TBC(burst_count) | TRB_TLBPC(residue);
+   field = 0;
 
if (first_trb) {
+   field = TRB_TBC(burst_count) |
+   TRB_TLBPC(residue);
/* Queue the isoc TRB */
field |= TRB_TYPE(TRB_ISOC);
/* Assume URB_ISO_ASAP is set */
-- 
1.7.9

--
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] Problem in drivers/usb/serial/io_ti - Kernel oops when disconnecting an opened device

2013-01-16 Thread Wolfgang Frisch
On 14/01/13 16:37, Johan Hovold wrote:
> I've prepared a patch series which removes the custom chase_port
> function and replaces it with the corresponding generic implementations
> instead (which does not suffer from the problem you found).
>
> However, I think your solution is probably the best one for the stable
> trees as it is less intrusive.
>
> Care to resubmit your patch with a short description and perhaps the
> stack trace from your original report? Have look at
> Documentation/SubmittingPatches for details (e.g. you need to add a
> Signed-off-by line and should configure you mail client to send the patch
> as an inline attachment). Please see my notes on the patch below as
> well.
Thanks for your clarifying and helpful comments!
I just resubmitted my patch.

>
> I'll respond to this mail with my series which should also fix the
> problem (and which could later be applied on top of your patch). If you
> could test it on actual hardware it would be much appreciated.
Your patches work fine on Linux 3.7.2 with a Watchport/H sensor.

Cheers,
Wolfgang

>
> Thanks,
> Johan


>
>> On 03/01/13 00:44, Wolfgang Frisch wrote:
>>> I have a problem with my Digi Edgeport USB sensor.
>>>
>>> 1. Environment:
>>> - Digi Watchport/H USB sensor (io_ti driver)
>>> - Linux v3.7.1 on amd64
>>> Tested with v3.7.1 on 2 physical machines.
>>> Further tests were done in a virtual machine.
>>>
>>> 2. Observations:
>>> The problem was observed with Linux 3.7.1, 3.2 and 3.1.
>>> I'm not able to find a recent kernel without this problem.
>>>
>>> The sensor works until it is disconnected while its character device
>>> still being used. This causes a kernel Oops.
>>>
>>> Steps to reproduce:
>>> - Attach Watchport sensor
>>> - Connect, e.g.: minicom -D /dev/ttyUSB0
>>> - Detach the sensor
>>> - Kernel oops
>>>
>>> The dmesg log is attached.
>>>
>>
>
>> diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
>> index 60023c2..65258c1 100644
>> --- a/drivers/usb/serial/io_ti.c
>> +++ b/drivers/usb/serial/io_ti.c
>> @@ -534,6 +534,11 @@ static void chase_port(struct edgeport_port *port, 
>> unsigned long timeout,
>>  wait_queue_t wait;
>>  unsigned long flags;
>>
>> +// FIXME: chase_port is called with tty == NULL
>
> You could drop this comment.
>
>> +if (tty == NULL) {
>> +return;
>> +}
>> +
>
> and this should simply be
>
>   if (!tty)
>   return;
>
>>  if (!timeout)
>>  timeout = (HZ * EDGE_CLOSING_WAIT)/100;
>>
>
> --
> 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
>

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


[PATCH 1/1] USB: io_ti: Fix NULL dereference in chase_port()

2013-01-16 Thread Wolfgang Frisch
The tty is NULL when the port is hanging up.
chase_port() needs to check for this.

This patch is intended for stable series.
The behavior was observed and tested in Linux 3.2 and 3.7.1.

Johan Hovold submitted a more elaborate patch for the mainline kernel.


[   56.277883] usb 1-1: edge_bulk_in_callback - nonzero read bulk status 
received: -84
[   56.278811] usb 1-1: USB disconnect, device number 3
[   56.278856] usb 1-1: edge_bulk_in_callback - stopping read!
[   56.279562] BUG: unable to handle kernel NULL pointer dereference at 
01c8
[   56.280536] IP: [] _raw_spin_lock_irqsave+0x19/0x35
[   56.281212] PGD 1dc1b067 PUD 1e0f7067 PMD 0
[   56.282085] Oops: 0002 [#1] SMP
[   56.282744] Modules linked in:
[   56.283512] CPU 1
[   56.283512] Pid: 25, comm: khubd Not tainted 3.7.1 #1 innotek GmbH 
VirtualBox/VirtualBox
[   56.283512] RIP: 0010:[]  [] 
_raw_spin_lock_irqsave+0x19/0x35
[   56.283512] RSP: 0018:88001fa99ab0  EFLAGS: 00010046
[   56.283512] RAX: 0046 RBX: 01c8 RCX: 00640064
[   56.283512] RDX: 0001 RSI: 88001fa99b20 RDI: 01c8
[   56.283512] RBP: 88001fa99b20 R08:  R09: 
[   56.283512] R10:  R11: 812fcb4c R12: 88001ddf53c0
[   56.283512] R13:  R14: 01c8 R15: 88001e19b9f4
[   56.283512] FS:  () GS:88001fd0() 
knlGS:
[   56.283512] CS:  0010 DS:  ES:  CR0: 8005003b
[   56.283512] CR2: 01c8 CR3: 1dc51000 CR4: 06e0
[   56.283512] DR0:  DR1:  DR2: 
[   56.283512] DR3:  DR6: 0ff0 DR7: 0400
[   56.283512] Process khubd (pid: 25, threadinfo 88001fa98000, task 
88001fa94f80)
[   56.283512] Stack:
[   56.283512]  0046 01c8 810578ec 
812fcb4c
[   56.283512]  88001e19b980 2710 812ffe81 
0001
[   56.283512]  88001fa94f80 0202 0001 
0296
[   56.283512] Call Trace:
[   56.283512]  [] ? add_wait_queue+0x12/0x3c
[   56.283512]  [] ? usb_serial_port_work+0x28/0x28
[   56.283512]  [] ? chase_port+0x84/0x2d6
[   56.283512]  [] ? try_to_wake_up+0x199/0x199
[   56.283512]  [] ? tty_ldisc_hangup+0x222/0x298
[   56.283512]  [] ? edge_close+0x64/0x129
[   56.283512]  [] ? __wake_up+0x35/0x46
[   56.283512]  [] ? should_resched+0x5/0x23
[   56.283512]  [] ? tty_port_shutdown+0x39/0x44
[   56.283512]  [] ? usb_serial_port_work+0x28/0x28
[   56.283512]  [] ? __tty_hangup+0x307/0x351
[   56.283512]  [] ? usb_hcd_flush_endpoint+0xde/0xed
[   56.283512]  [] ? _raw_spin_lock_irqsave+0x14/0x35
[   56.283512]  [] ? usb_serial_disconnect+0x57/0xc2
[   56.283512]  [] ? usb_unbind_interface+0x5c/0x131
[   56.283512]  [] ? __device_release_driver+0x7f/0xd5
[   56.283512]  [] ? device_release_driver+0x1a/0x25
[   56.283512]  [] ? bus_remove_device+0xd2/0xe7
[   56.283512]  [] ? device_del+0x119/0x167
[   56.283512]  [] ? usb_disable_device+0x6a/0x180
[   56.283512]  [] ? usb_disconnect+0x81/0xe6
[   56.283512]  [] ? hub_thread+0x577/0xe82
[   56.283512]  [] ? __schedule+0x490/0x4be
[   56.283512]  [] ? abort_exclusive_wait+0x79/0x79
[   56.283512]  [] ? usb_remote_wakeup+0x2f/0x2f
[   56.283512]  [] ? usb_remote_wakeup+0x2f/0x2f
[   56.283512]  [] ? kthread+0x81/0x89
[   56.283512]  [] ? __kthread_parkme+0x5c/0x5c
[   56.283512]  [] ? ret_from_fork+0x7c/0xb0
[   56.283512]  [] ? __kthread_parkme+0x5c/0x5c
[   56.283512] Code: 8b 7c 24 08 e8 17 0b c3 ff 48 8b 04 24 48 83 c4 10 c3 53 
48 89 fb 41 50 e8 e0 0a c3 ff 48 89 04 24 e8 e7 0a c3 ff ba 00 00 01 00
 0f c1 13 48 8b 04 24 89 d1 c1 ea 10 66 39 d1 74 07 f3 90 66
[   56.283512] RIP  [] _raw_spin_lock_irqsave+0x19/0x35
[   56.283512]  RSP 
[   56.283512] CR2: 01c8
[   56.283512] ---[ end trace 49714df27e1679ce ]---


Signed-off-by: Wolfgang Frisch 
---
 drivers/usb/serial/io_ti.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 60023c2..ed83e7a 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -534,6 +534,9 @@ static void chase_port(struct edgeport_port *port, unsigned 
long timeout,
wait_queue_t wait;
unsigned long flags;

+   if (!tty)
+   return;
+
if (!timeout)
timeout = (HZ * EDGE_CLOSING_WAIT)/100;

--
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 v7 0/6] solve deadlock caused by memory allocation with I/O

2013-01-16 Thread Andrew Morton
On Sat,  5 Jan 2013 10:25:38 +0800
Ming Lei  wrote:

> This patchset try to solve one deadlock problem which might be caused
> by memory allocation with block I/O during runtime PM and block device
> error handling path. Traditionly, the problem is addressed by passing
> GFP_NOIO statically to mm, but that is not a effective solution, see
> detailed description in patch 1's commit log.
> 
> This patch set introduces one process flag and trys to fix the deadlock
> problem on block device/network device during runtime PM or usb bus reset.

The patchset doesn't look like the worst thing I've ever applied ;)

One thing I'm wondering: during suspend and resume, why are GFP_KERNEL
allocation attempts even getting down to the device layer?  Presumably
the page scanner is encountering dirty pagecache or dirty swapcache
pages?

If so, I wonder if we could avoid the whole problem by appropriately
syncing all dirty memory back to storage before starting to turn devices
off?

--
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/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-16 Thread Alan Stern
On Wed, 16 Jan 2013, Stephen Warren wrote:

> On 01/16/2013 08:08 AM, Alan Stern wrote:
> > On Wed, 16 Jan 2013, Venu Byravarasu wrote:
> > 
> >> As Tegra PHY driver needs to access one of the Host registers,
> >> added few APIs.
> 
> >> --- a/drivers/usb/host/ehci-tegra.c
> >> +++ b/drivers/usb/host/ehci-tegra.c
> 
> >> +void tegra_ehci_set_wakeon_events(struct usb_phy *x, bool enable)
> >> +{
> >> +  unsigned long val;
> >> +  struct usb_hcd *hcd = bus_to_hcd(x->otg->host);
> >> +  void __iomem *base = hcd->regs;
> >> +  u32 wake = USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN;
> >> +
> >> +  val = readl(base + USB_PORTSC1);
> >> +  if (enable)
> >> +  val |= wake;
> >> +  else
> >> +  val &= ~wake;
> >> +  writel(val, base + USB_PORTSC1);
> >> +}
> > 
> > Here and below, this sort of code is highly questionable.  You
> > evidently don't realize that some of the bits in the PORTSC registers
> > are R/WC.  This means writing a 1 to these bits will clear them.  
> > 
> > Consequently it is almost always wrong to read a PORTSC register and
> > then write back the same (or a slightly modified) value.
> 
> Sorry I'm not familiar with USB... Are the bits being manipulated here
> (i.e. USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN)
> standardized USBisms, or some custom Tegra stuff?

The _symbols_ are not standard (i.e., not used in the regular ehci-hcd
driver) but the _values_ are: compare with PORT_WKOC_E etc. in
include/linux/usb/ehci_defs.h.  I'm not sure about the register 
addresses, however.

> Anyway, is the solution here to do:
> 
> val = readl(addr)
> 
> // i.e. add the following line:
> val &= ~(all write-to-clear bits);
> 
> if (enable) val |= wake; else val &= ~wake;
> 
> writel(val, addr)
> 
> ... or is there more broken than just that?

Nope, that's the right way to do it.  There are loads of examples in 
drivers/usb/host/ehci-hub.c; look at usages of PORT_RWC_BITS.

> Also note that the driver is already doing exactly what is in these new
> functions; the code is just being split out so that only the EHCI driver
> touches EHCI registers, and the PHY driver only touches PHY registers.
> Still, I'll admit it's a good time to fix any mistakes in this part of
> the code.

Agreed.

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-3.7.1: kmemleak reports in comm "usb-storage"?

2013-01-16 Thread Martin Mokrejs


Sarah Sharp wrote:
> On Wed, Jan 16, 2013 at 12:22:59PM -0500, Alan Stern wrote:
>> On Wed, 16 Jan 2013, Martin Mokrejs wrote:
>>
>>> A corresponding diff of dmesg output is attached. Note that the first 
>>> kmemleak in there
>>> happened just without any prior fiddling with a USB drive. For about two 
>>> days I haven't
>>> connected a drive. However, usb-storage might be in a wrong shape since 
>>> several days
>>> when it happened for the first time. Did you want me to reboot? ;-) I did 
>>> not.
>>
>> Sarah, I looked through the xhci-hcd driver.  There does appear to be a
>> leak in xhci-ring.c:handle_tx_event().
> 
> Thanks for catching that.
> 
>> The routine looks like this:
>>
>>  /* Leave the TD around for the reset endpoint function
>>   * to use(but only if it's not a control endpoint,
>>   * since we already queued the Set TR dequeue pointer
>>   * command for stalled control endpoints).
>>   */
>>  if (usb_endpoint_xfer_control(&urb->ep->desc) ||
>>  (trb_comp_code != COMP_STALL &&
>>  trb_comp_code != COMP_BABBLE))
>>  xhci_urb_free_priv(xhci, urb_priv);
>>
>>  ...
>>
>>  /* EHCI, UHCI, and OHCI always unconditionally set the
>>   * urb->status of an isochronous endpoint to 0.
>>   */
>>  if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
>>  status = 0;
>>  usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, 
>> status);
>>
>> If the condition on the first "if" statement fails, urb_priv won't be 
>> deallocated.  It needs something like
>>
>>  if (...)
>>  xhci_urb_free_priv(xhci, urb_priv);
>> +else
>> +kfree(urb_priv);
> 
> Ok, so you're proposing freeing the urb_priv, but leaving the TD
> allocated for the Set TR dequeue functions to use?  Yes, that looks like
> the right solution, feel free to submit a patch.
> 
>> Martin, can you tell if adding these two lines fixes the problem?

Hi Alan,
  yes, the following change has helped. I managed to get twice the "error -71"
message (one case is shown here)

Jan 16 23:07:56 vostro kernel: usb 3-1.2: Device not responding to set address.
Jan 16 23:07:56 vostro kernel: usb 3-1.2: Device not responding to set address.
Jan 16 23:07:56 vostro kernel: usb 3-1.2: device not accepting address 17, 
error -71
Jan 16 23:07:56 vostro kernel: hub 3-1:1.0: unable to enumerate USB device on 
port 2

but the kmemleak did not report anything after next unplug of the disk anymore.



--- linux-3.7.1/drivers/usb/host/xhci-ring.c.ori2013-01-16 
22:51:25.0 +0100
+++ linux-3.7.1/drivers/usb/host/xhci-ring.c2013-01-16 22:53:03.0 
+0100
@@ -2580,6 +2580,8 @@
(trb_comp_code != COMP_STALL &&
trb_comp_code != COMP_BABBLE))
xhci_urb_free_priv(xhci, urb_priv);
+   else
+   kfree(urb_priv);
 
usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), 
urb);
if ((urb->actual_length != urb->transfer_buffer_length 
&&





Thanks,
Martin


P.S.: The other kmemleak is still in there but is probably not your business: 
;-)

# cat /sys/kernel/debug/kmemleak 
unreferenced object 0x88040b60a578 (size 256):
  comm "swapper/0", pid 1, jiffies 4294937575 (age 688.030s)
  hex dump (first 32 bytes):
00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00  .N..
ff ff ff ff ff ff ff ff 38 3f 5d 82 ff ff ff ff  8?].
  backtrace:
[] kmemleak_alloc+0x21/0x3e
[] slab_post_alloc_hook+0x28/0x2a
[] __kmalloc+0xf2/0x104
[] kzalloc.constprop.14+0xe/0x10
[] device_private_init+0x14/0x63
[] dev_set_drvdata+0x19/0x2f
[] i801_probe+0x5e/0x451
[] local_pci_probe+0x5b/0xa2
[] pci_device_probe+0xc8/0xf7
[] driver_probe_device+0xa9/0x1c1
[] __driver_attach+0x5a/0x7e
[] bus_for_each_dev+0x57/0x83
[] driver_attach+0x19/0x1b
[] bus_add_driver+0xa8/0x1fa
[] driver_register+0x8c/0x106
[] __pci_register_driver+0x5a/0x5e
--
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/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-16 Thread Stephen Warren
On 01/16/2013 08:08 AM, Alan Stern wrote:
> On Wed, 16 Jan 2013, Venu Byravarasu wrote:
> 
>> As Tegra PHY driver needs to access one of the Host registers,
>> added few APIs.

>> --- a/drivers/usb/host/ehci-tegra.c
>> +++ b/drivers/usb/host/ehci-tegra.c

>> +void tegra_ehci_set_wakeon_events(struct usb_phy *x, bool enable)
>> +{
>> +unsigned long val;
>> +struct usb_hcd *hcd = bus_to_hcd(x->otg->host);
>> +void __iomem *base = hcd->regs;
>> +u32 wake = USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN;
>> +
>> +val = readl(base + USB_PORTSC1);
>> +if (enable)
>> +val |= wake;
>> +else
>> +val &= ~wake;
>> +writel(val, base + USB_PORTSC1);
>> +}
> 
> Here and below, this sort of code is highly questionable.  You
> evidently don't realize that some of the bits in the PORTSC registers
> are R/WC.  This means writing a 1 to these bits will clear them.  
> 
> Consequently it is almost always wrong to read a PORTSC register and
> then write back the same (or a slightly modified) value.

Sorry I'm not familiar with USB... Are the bits being manipulated here
(i.e. USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN)
standardized USBisms, or some custom Tegra stuff?

Anyway, is the solution here to do:

val = readl(addr)

// i.e. add the following line:
val &= ~(all write-to-clear bits);

if (enable) val |= wake; else val &= ~wake;

writel(val, addr)

... or is there more broken than just that?

Also note that the driver is already doing exactly what is in these new
functions; the code is just being split out so that only the EHCI driver
touches EHCI registers, and the PHY driver only touches PHY registers.
Still, I'll admit it's a good time to fix any mistakes in this part of
the code.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] arm: tegra: Add DT nodes for Tegra USB PHY

2013-01-16 Thread Stephen Warren
On 01/16/2013 06:30 AM, Venu Byravarasu wrote:
> Add DT nodes for Tegra USB PHY along with related documentation.
> Also added a phandle property to controller DT node, for referring
> to connected PHY instance.

Just a quick reminder to Greg, Felipe, Alan: Once this series passes
review, I'll need to take it through the Tegra tree. (Sorry if I'm
belabouring that point). This patch in particular will interact with the
common clock framework changes that will very soon be in the Tegra tree.
--
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] CDC_NCM adding support IFF_NOARP for infineon modem platform

2013-01-16 Thread Dan Williams
On Sat, 2013-01-12 at 19:34 +0800, Wei Shuai wrote:
> Infineon(now Intel) HSPA Modem platform NCM cannot support ARP. so I 
> introduce a flag CDC_NCM_DRIVER_DATA_NOARP which is defined in 
> driver_info:data. so later on, if more such buggy devices are found, they 
> could use same flag to handle. 

So given that Dave now approves of IFF_NOARP, let's change your original
patch to add a FLAG_NOARP for the .flags structure instead of inventing
another mechanism for .data.

Dan

> Signed-off-by: Wei Shuai 
> ---
>  drivers/net/usb/cdc_ncm.c |   29 +
>  1 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index 71b6e92..6093e07 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -55,6 +55,9 @@
>  
>  #define  DRIVER_VERSION  "14-Mar-2012"
>  
> +/* Flags for driver_info::data */
> +#define CDC_NCM_DRIVER_DATA_NOARP  1
> +
>  static void cdc_ncm_txpath_bh(unsigned long param);
>  static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx);
>  static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer);
> @@ -573,6 +576,10 @@ static int cdc_ncm_bind(struct usbnet *dev, struct 
> usb_interface *intf)
>   return -ENODEV;
>  #endif
>  
> + if (dev->driver_info->data & CDC_NCM_DRIVER_DATA_NOARP) {
> + /* some buggy device cannot do ARP*/
> + dev->net->flags |= IFF_NOARP;
> + }
>   /* NCM data altsetting is always 1 */
>   ret = cdc_ncm_bind_common(dev, intf, 1);
>  
> @@ -1155,6 +1162,21 @@ static const struct driver_info wwan_info = {
>   .tx_fixup = cdc_ncm_tx_fixup,
>  };
>  
> +/* Same as wwan_info, but with IFF_NOARP  */
> +static const struct driver_info wwan_noarp_info = {
> + .description = "Mobile Broadband Network Device (NO ARP)",
> + .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
> + | FLAG_WWAN,
> + .data = CDC_NCM_DRIVER_DATA_NOARP,
> + .bind = cdc_ncm_bind,
> + .unbind = cdc_ncm_unbind,
> + .check_connect = cdc_ncm_check_connect,
> + .manage_power = usbnet_manage_power,
> + .status = cdc_ncm_status,
> + .rx_fixup = cdc_ncm_rx_fixup,
> + .tx_fixup = cdc_ncm_tx_fixup,
> +};
> +
>  static const struct usb_device_id cdc_devs[] = {
>   /* Ericsson MBM devices like F5521gw */
>   { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
> @@ -1194,6 +1216,13 @@ static const struct usb_device_id cdc_devs[] = {
> .driver_info = (unsigned long)&wwan_info,
>   },
>  
> + /* Infineon(now Intel) HSPA Modem platform */
> + { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
> + USB_CLASS_COMM,
> + USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
> +   .driver_info = (unsigned long)&wwan_noarp_info,
> + },
> +
>   /* Generic CDC-NCM devices */
>   { USB_INTERFACE_INFO(USB_CLASS_COMM,
>   USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),


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


[PATCH 2/2] block: don't request module during elevator init

2013-01-16 Thread Tejun Heo
Block layer allows selecting an elevator which is built as a module to
be selected as system default via kernel param "elevator=".  This is
achieved by automatically invoking request_module() whenever a new
block device is initialized and the elevator is not available.

This led to an interesting deadlock problem involving async and module
init.  Block device probing running off an async job invokes
request_module().  While the module is being loaded, it performs
async_synchronize_full() which ends up waiting for the async job which
is already waiting for request_module() to finish, leading to
deadlock.

Invoking request_module() from deep in block device init path is
already nasty in itself.  It seems best to avoid these situations from
the beginning by moving on-demand module loading out of block init
path.

The previous patch made sure that the default elevator module is
loaded early during boot if available.  This patch removes on-demand
loading of the default elevator from elevator init path.  As the
module would have been loaded during boot, userland-visible behavior
difference should be minimal.

For more details, please refer to the following thread.

  http://thread.gmane.org/gmane.linux.kernel/1420814

Signed-off-by: Tejun Heo 
Cc: Jens Axboe 
Cc: Arjan van de Ven 
Cc: Linus Torvalds 
Cc: Alex Riesen 
---
 block/elevator.c |   19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

--- a/block/elevator.c
+++ b/block/elevator.c
@@ -100,14 +100,14 @@ static void elevator_put(struct elevator
module_put(e->elevator_owner);
 }
 
-static struct elevator_type *elevator_get(const char *name)
+static struct elevator_type *elevator_get(const char *name, bool 
request_module)
 {
struct elevator_type *e;
 
spin_lock(&elv_list_lock);
 
e = elevator_find(name);
-   if (!e) {
+   if (!e && request_module) {
spin_unlock(&elv_list_lock);
request_module("%s-iosched", name);
spin_lock(&elv_list_lock);
@@ -207,25 +207,30 @@ int elevator_init(struct request_queue *
q->boundary_rq = NULL;
 
if (name) {
-   e = elevator_get(name);
+   e = elevator_get(name, true);
if (!e)
return -EINVAL;
}
 
+   /*
+* Use the default elevator specified by config boot param or
+* config option.  Don't try to load modules as we could be running
+* off async and request_module() isn't allowed from async.
+*/
if (!e && *chosen_elevator) {
-   e = elevator_get(chosen_elevator);
+   e = elevator_get(chosen_elevator, false);
if (!e)
printk(KERN_ERR "I/O scheduler %s not found\n",
chosen_elevator);
}
 
if (!e) {
-   e = elevator_get(CONFIG_DEFAULT_IOSCHED);
+   e = elevator_get(CONFIG_DEFAULT_IOSCHED, false);
if (!e) {
printk(KERN_ERR
"Default I/O scheduler not found. " \
"Using noop.\n");
-   e = elevator_get("noop");
+   e = elevator_get("noop", false);
}
}
 
@@ -967,7 +972,7 @@ int elevator_change(struct request_queue
return -ENXIO;
 
strlcpy(elevator_name, name, sizeof(elevator_name));
-   e = elevator_get(strstrip(elevator_name));
+   e = elevator_get(strstrip(elevator_name), true);
if (!e) {
printk(KERN_ERR "elevator: type %s not found\n", elevator_name);
return -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] init, block: try to load default elevator module early during boot

2013-01-16 Thread Tejun Heo
This patch adds default module loading and uses it to load the default
block elevator.  During boot, it's called right after initramfs or
initrd is made available and right before control is passed to
userland.  This ensures that as long as the modules are available in
the usual places in initramfs, initrd or the root filesystem, the
default modules are loaded as soon as possible.

This will replace the on-demand elevator module loading from elevator
init path.

Signed-off-by: Tejun Heo 
Cc: Jens Axboe 
Cc: Arjan van de Ven 
Cc: Linus Torvalds 
Cc: Alex Riesen 
---
 block/elevator.c |   16 
 include/linux/elevator.h |1 +
 include/linux/init.h |1 +
 init/do_mounts_initrd.c  |3 +++
 init/initramfs.c |8 +++-
 init/main.c  |   16 
 6 files changed, 44 insertions(+), 1 deletion(-)

--- a/block/elevator.c
+++ b/block/elevator.c
@@ -136,6 +136,22 @@ static int __init elevator_setup(char *s
 
 __setup("elevator=", elevator_setup);
 
+/* called during boot to load the elevator chosen by the elevator param */
+void __init load_default_elevator_module(void)
+{
+   struct elevator_type *e;
+
+   if (!chosen_elevator[0])
+   return;
+
+   spin_lock(&elv_list_lock);
+   e = elevator_find(chosen_elevator);
+   spin_unlock(&elv_list_lock);
+
+   if (!e)
+   request_module("%s-iosched", chosen_elevator);
+}
+
 static struct kobj_type elv_ktype;
 
 static struct elevator_queue *elevator_alloc(struct request_queue *q,
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -138,6 +138,7 @@ extern void elv_drain_elevator(struct re
 /*
  * io scheduler registration
  */
+extern void __init load_default_elevator_module(void);
 extern int elv_register(struct elevator_type *);
 extern void elv_unregister(struct elevator_type *);
 
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -161,6 +161,7 @@ extern unsigned int reset_devices;
 /* used by init/main.c */
 void setup_arch(char **);
 void prepare_namespace(void);
+void __init load_default_modules(void);
 
 extern void (*late_time_init)(void);
 
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -57,6 +57,9 @@ static void __init handle_initrd(void)
sys_mkdir("/old", 0700);
sys_chdir("/old");
 
+   /* try loading default modules from initrd */
+   load_default_modules();
+
/*
 * In case that a resume from disk is carried out by linuxrc or one of
 * its children, we need to tell the freezer not to wait for us.
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -592,7 +592,7 @@ static int __init populate_rootfs(void)
initrd_end - initrd_start);
if (!err) {
free_initrd();
-   return 0;
+   goto done;
} else {
clean_rootfs();
unpack_to_rootfs(__initramfs_start, __initramfs_size);
@@ -607,6 +607,7 @@ static int __init populate_rootfs(void)
sys_close(fd);
free_initrd();
}
+   done:
 #else
printk(KERN_INFO "Unpacking initramfs...\n");
err = unpack_to_rootfs((char *)initrd_start,
@@ -615,6 +616,11 @@ static int __init populate_rootfs(void)
printk(KERN_EMERG "Initramfs unpacking failed: %s\n", 
err);
free_initrd();
 #endif
+   /*
+* Try loading default modules from initramfs.  This gives
+* us a chance to load before device_initcalls.
+*/
+   load_default_modules();
}
return 0;
 }
--- a/init/main.c
+++ b/init/main.c
@@ -70,6 +70,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -794,6 +796,17 @@ static void __init do_pre_smp_initcalls(
do_one_initcall(*fn);
 }
 
+/*
+ * This function requests modules which should be loaded by default and is
+ * called twice right after initrd is mounted and right before init is
+ * exec'd.  If such modules are on either initrd or rootfs, they will be
+ * loaded before control is passed to userland.
+ */
+void __init load_default_modules(void)
+{
+   load_default_elevator_module();
+}
+
 static int run_init_process(const char *init_filename)
 {
argv_init[0] = init_filename;
@@ -900,4 +913,7 @@ static void __init kernel_init_freeable(
 * we're essentially up and running. Get rid of the
 * initmem segments and start the user-mode stuff..
 */
+
+   /* rootfs is available now, try loading default modules */
+   load_default_modules();
 }
--
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-3.7.1: kmemleak reports in comm "usb-storage"?

2013-01-16 Thread Alan Stern
On Wed, 16 Jan 2013, Sarah Sharp wrote:

> > Sarah, I looked through the xhci-hcd driver.  There does appear to be a
> > leak in xhci-ring.c:handle_tx_event().
> 
> Thanks for catching that.
> 
> > The routine looks like this:
> > 
> > /* Leave the TD around for the reset endpoint function
> >  * to use(but only if it's not a control endpoint,
> >  * since we already queued the Set TR dequeue pointer
> >  * command for stalled control endpoints).
> >  */
> > if (usb_endpoint_xfer_control(&urb->ep->desc) ||
> > (trb_comp_code != COMP_STALL &&
> > trb_comp_code != COMP_BABBLE))
> > xhci_urb_free_priv(xhci, urb_priv);
> > 
> > ...
> > 
> > /* EHCI, UHCI, and OHCI always unconditionally set the
> >  * urb->status of an isochronous endpoint to 0.
> >  */
> > if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
> > status = 0;
> > usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, 
> > status);
> > 
> > If the condition on the first "if" statement fails, urb_priv won't be 
> > deallocated.  It needs something like
> > 
> > if (...)
> > xhci_urb_free_priv(xhci, urb_priv);
> > +   else
> > +   kfree(urb_priv);
> 
> Ok, so you're proposing freeing the urb_priv, but leaving the TD
> allocated for the Set TR dequeue functions to use?  Yes, that looks like
> the right solution, feel free to submit a patch.

Okay, if Martin confirms the diagnosis.

> > Martin, can you tell if adding these two lines fixes the problem?
> > 
> > Also, the comment is wrong.  urb->status is not set to 0
> > unconditionally for isochonrous endpoints in [eou]hcd-hcd.  If any of
> > the iso packets gets a nonzero status then urb->status is set to one of
> > those values, not to 0.

My mistake -- these drivers _do_ return 0 status for all isochronous
URBs.  However, ehci-hcd and uhci-hcd set urb->error_count to the
number of packets getting an error, whereas ohci-hcd and xhci-hcd
don't.  Fixing ohci-hcd will be very easy.

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] CDC_NCM adding support IFF_NOARP for infineon modem platform

2013-01-16 Thread David Miller
From: Bjørn Mork 
Date: Tue, 15 Jan 2013 09:34:07 +0100

> The main problem is that these devices don't support ethernet.  They
> support IP (v4 and _maybe_ v6) with an ethernet header.  Many of them
> will do ARP (and IPv6 ND) as well to complete the picture, but some of
> them don't and that's what these drivers try to deal with.

Ok, in that case setting IFF_NOARP is in fact the right thing to do.
Thanks for describing the situation.

Someone please resubmit the patch to do that and I'll apply it.
--
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 net] net: qmi_wwan: add TP-LINK HSUPA Modem MA180

2013-01-16 Thread David Miller
From: Bjørn Mork 
Date: Tue, 15 Jan 2013 10:19:50 +0100

> The driver description files gives these names to the vendor specific
> functions on this modem:
> 
>  Diagnostics VID_2357&PID_0201&MI_00
>  NMEAVID_2357&PID_0201&MI_01
>  Modem   VID_2357&PID_0201&MI_03
>  Networkcard VID_2357&PID_0201&MI_04
> 
> The "Networkcard" function has been verified to support these QMI
> services:
> ctl (1.3)
> wds (1.3)
> dms (1.2)
> nas (1.0)
> 
> Reported-by: Thomas Schäfer 
> Signed-off-by: Bjørn Mork 

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


Re: [PATCH] usbnet: dm9601: Fix incorrect command

2013-01-16 Thread David Miller
From: Tushar Behera 
Date: Tue, 15 Jan 2013 11:09:01 +0530

> commit 24b1042c4eb2 ("usbnet: dm9601: apply introduced usb command
> APIs") removes the distiction between DM_WRITE_REG and DM_WRITE_REGS
> command. The distiction is reintroduced to the driver so that the
> functionality of the driver remains same.
> 
> CC: Ming Lei 
> Signed-off-by: Tushar Behera 

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


Re: linux-3.7.1: kmemleak reports in comm "usb-storage"?

2013-01-16 Thread Sarah Sharp
On Wed, Jan 16, 2013 at 12:22:59PM -0500, Alan Stern wrote:
> On Wed, 16 Jan 2013, Martin Mokrejs wrote:
> 
> > A corresponding diff of dmesg output is attached. Note that the first 
> > kmemleak in there
> > happened just without any prior fiddling with a USB drive. For about two 
> > days I haven't
> > connected a drive. However, usb-storage might be in a wrong shape since 
> > several days
> > when it happened for the first time. Did you want me to reboot? ;-) I did 
> > not.
> 
> Sarah, I looked through the xhci-hcd driver.  There does appear to be a
> leak in xhci-ring.c:handle_tx_event().

Thanks for catching that.

> The routine looks like this:
> 
>   /* Leave the TD around for the reset endpoint function
>* to use(but only if it's not a control endpoint,
>* since we already queued the Set TR dequeue pointer
>* command for stalled control endpoints).
>*/
>   if (usb_endpoint_xfer_control(&urb->ep->desc) ||
>   (trb_comp_code != COMP_STALL &&
>   trb_comp_code != COMP_BABBLE))
>   xhci_urb_free_priv(xhci, urb_priv);
> 
>   ...
> 
>   /* EHCI, UHCI, and OHCI always unconditionally set the
>* urb->status of an isochronous endpoint to 0.
>*/
>   if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
>   status = 0;
>   usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, 
> status);
> 
> If the condition on the first "if" statement fails, urb_priv won't be 
> deallocated.  It needs something like
> 
>   if (...)
>   xhci_urb_free_priv(xhci, urb_priv);
> + else
> + kfree(urb_priv);

Ok, so you're proposing freeing the urb_priv, but leaving the TD
allocated for the Set TR dequeue functions to use?  Yes, that looks like
the right solution, feel free to submit a patch.

> Martin, can you tell if adding these two lines fixes the problem?
> 
> Also, the comment is wrong.  urb->status is not set to 0
> unconditionally for isochonrous endpoints in [eou]hcd-hcd.  If any of
> the iso packets gets a nonzero status then urb->status is set to one of
> those values, not to 0.

The code needs to be fixed then.  How do you pick which iso packet
status to return?  E.g. if one frame has a babble and another has a
short packet, which error code do you return?  Whichever one occurred
first?

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


Re: [PATCH] USB: prevent overlapping access by usb-storage and usbfs

2013-01-16 Thread Sergei Shtylyov
Hello.

On 01/14/2013 11:23 PM, Greg KH wrote:

>>> Serialize usb-storage operations with usbfs and 'cat /proc/bus/usb/devices',
>>> so that they cannot disturb storage by seemingly harmless control reads.

>>> This patch was adapted from 2.4.28 patch by Pete Zaitcev -- which I even 
>>> had to
>>> reconstruct as I have never found it in its final  form.  That patch dates 
>>> back
>>> to 2004 and it unfortunately wasn't applied to 2.6 branch in the same form 
>>> back
>>> then (it was applied in another form and then immediately reverted). 
>>> Despite 8+
>>> years passing from that moment, the vendors didn't stop producing USB 
>>> devices
>>> that require this patch. Two recent examples are SanDisk Cruzer Slice 8GB 
>>> and
>>> Kingston DataTraveller 100 G2 32GB.  In the latter case, even the 
>>> enumeration
>>> fails as the INQUIRY command takes 2.8 seconds to finish, so 'udev' also 
>>> comes
>>> into action with its control requests, with neither completing normally.

>>> Signed-off-by: Sergei Shtylyov 
>>> Cc: sta...@vger.kernel.org

>>Forgot to mention the side effect of the patch: one can't submit read and
>> write URB simultaneously via USBDEVFS_BULK ioctl(). That has been dealt in 
>> 2.4
>> by later patch by Pete, which I can try to port if needed.

> That's not good, it would need to be part of this patch, we don't want
> to break that existing functionality.

  Hm... this looks more hairy that it seemed: there was another one patch in
2.4, "between" those two, dividing usbfs ioctl's into exclusive (accessing a
device and grabbing the lock) and non-exclusive (not accessing the device and
not grabbing the lock) which I'm not sure is really needed. Then there is
USBDEVFS_BULK32 which wasn't present in 2.4 and needs analogous treating to
USBDEVFS_BULK I guess... Even if I have time to plough thru this mess, I won't
be able to test the resulting patch (the current version was tested by the
customer -- they didn't give us the faulty hardware)...

> greg k-h

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/6] arm: mvebu: Enable USB controllers on Armada XP OpenBlocks AX3-4 board

2013-01-16 Thread Thomas Petazzoni
Dear Ezequiel Garcia,

On Wed, 16 Jan 2013 16:16:59 -0300, Ezequiel Garcia wrote:

> >> +   usb@d005 {
> >> +   status = "okay";
> >> +   };
> >> +   usb@d0051000 {
> >> +   status = "okay";
> >> +   };
> >> +   usb@d0052000 {
> >> +   status = "okay";
> >> +   };
> > USB2 of openblocks-ax3-4 is used as Mini-PCIE.
> > I think this is unnecessary.
> 
> Mmm... could you explain this with some more detail.
> Unfortunately, I don't have access to an Openblocks board to check on
> this, so I'd appreciate any clarification.
> 
> Is there any Openblocks datasheet or hardware schematics publicly
> available for me to look at?

As far as I know, there is no public document. I've been given access
to a PDF, in Japanese, that gives some details about the hardware.

>From what I can read, only 2 USB ports are used from the internal
Marvell EHCI controller.

Another USB port is available, but it is connected to a USB controller
that sits on the PCIe bus. And the PCIe interface on which this USB
controller is connected is not enabled in the default U-Boot shipped
with AX3-4 (at least not with the generation I have). I've been given
an U-Boot version that is supposed to enable this PCIe interface, but I
haven't tested yet.

Anyway, from a Marvell EHCI controller perspective, only two ports are
used, as Nobuhiro said. I am not sure which ports, but it seems like
the first two ones were used. One of the two physical ports is a
combined USB / eSATA port, but I don't think this makes any difference
at the software level.

I don't have the OpenBlocks AX3-4 with me right now, but I could
probably make a test on Friday.

Best regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
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/6] arm: mvebu: Enable USB controllers on Armada XP OpenBlocks AX3-4 board

2013-01-16 Thread Ezequiel Garcia
Hi Nobuhiro,

On Tue, Jan 15, 2013 at 9:01 PM, Nobuhiro Iwamatsu  wrote:
> Hi,
>
>
>
> On Tue, Jan 15, 2013 at 6:54 PM, Ezequiel Garcia
>  wrote:
>> Cc: Lior Amsalem 
>> Cc: Thomas Petazzoni 
>> Cc: Gregory CLEMENT 
>> Signed-off-by: Ezequiel Garcia 
>> ---
>>  arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts |9 +
>>  1 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts 
>> b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
>> index b24644f..55f5b6f 100644
>> --- a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
>> +++ b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
>> @@ -127,5 +127,14 @@
>> nr-ports = <2>;
>> status = "okay";
>> };
>> +   usb@d005 {
>> +   status = "okay";
>> +   };
>> +   usb@d0051000 {
>> +   status = "okay";
>> +   };
>> +   usb@d0052000 {
>> +   status = "okay";
>> +   };
> USB2 of openblocks-ax3-4 is used as Mini-PCIE.
> I think this is unnecessary.
>

Mmm... could you explain this with some more detail.
Unfortunately, I don't have access to an Openblocks board to check on this,
so I'd appreciate any clarification.

Is there any Openblocks datasheet or hardware schematics publicly
available for me to look at?

Thanks a lot,

-- 
Ezequiel
--
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 v6 03/22] mfd: omap-usb-tll: Use devm_kzalloc/ioremap and clean up error path

2013-01-16 Thread Sergei Shtylyov
Hello.

On 01/16/2013 05:43 PM, Roger Quadros wrote:

> Use devm_ variants of kzalloc() and ioremap(). Simplify the error path.

> Signed-off-by: Roger Quadros 
> ---
>  drivers/mfd/omap-usb-tll.c |   36 +++-
>  1 files changed, 11 insertions(+), 25 deletions(-)

> diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
> index 9658e18..53ed10b 100644
> --- a/drivers/mfd/omap-usb-tll.c
> +++ b/drivers/mfd/omap-usb-tll.c
[...]
> - base = ioremap(res->start, resource_size(res));
> + base = devm_request_and_ioremap(dev, res);
>   if (!base) {
> - dev_err(dev, "TLL ioremap failed\n");
>   ret = -ENOMEM;

   -EADDRNOTAVAIL as the comment to devm_request_and_ioremap() suggests.

> - goto err_usbtll_p2_fck;
> + dev_err(dev, "Resource request/ioremap failed:%d\n", ret);
> + goto err_res;
>   }

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 v6 11/22] mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap()

2013-01-16 Thread Sergei Shtylyov
Hello.

On 01/16/2013 05:43 PM, Roger Quadros wrote:

> Use devm_ variants of kzalloc and ioremap. Also clean up error path.

> Signed-off-by: Roger Quadros 
[...]

> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index 061366d..0f190b6 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -461,15 +461,20 @@ static int usbhs_omap_probe(struct platform_device 
> *pdev)
[...]
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
> + omap->uhh_base = devm_request_and_ioremap(dev, res);
> + if (!omap->uhh_base) {
> + dev_err(dev, "Resource request/ioremap failed\n");
> + return -ENOMEM;

   Should be -EADDRNOTAVAIL according to the comment to
devm_request_and_ioremap()...

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: USB device cannot be reconnected and khubd "blocked for more than 120 seconds"

2013-01-16 Thread Alan Stern
On Wed, 16 Jan 2013, Tejun Heo wrote:

> Hello, Alan.
> 
> On Wed, Jan 16, 2013 at 12:01:53PM -0500, Alan Stern wrote:
> > > The problem here is that "flush everything which comes before me" is
> > > used to order async jobs.  e.g. after async jobs probe the hardware
> > > they order themselves by flushing before registering them, so unless
> > 
> > I don't fully understand this example.  What is the point -- to make 
> > sure that asynchronously probed devices are registered in the order of 
> > their discovery?
> 
> People still want devices to be numbered to their physical ports and
> so on, so we keep the registeration order the same as natural
> (whatever that means) hardware order.
> 
> > If so, here's how to do it safely: Start up the async jobs in reverse
> > order of discovery.  Have each job acquire a cookie when it starts.  
> > Then each job needs to wait only for tasks that started after its
> > cookie was issued.
> 
> It's a bit clumsy but yeah I guess it could work.
> 
> > > There aren't too many which use async anyway so changing stuff
> > > shouldn't be too difficult but I think the simpicity or dumbness is
> > > one of major attractions of async, so it'd be nice to keep things that
> > > way and the PF_USED_ASYNC hack seems to be able to hold things
> > > together for now.
> > 
> > Nesting won't matter for the chronological approach.  I really think 
> > you should consider it more fully.  It's not a hack, and it doesn't 
> > need to be complicated.
> 
> There is benefit to the current dumb implementation in that drivers
> can use it without thinking too much, but yeah it could be that the
> flushing range limit isn't too much of restriction on top.  I don't
> know.  At this point, I'd prefer to remove request_module() from
> elevator init path for the problem at hand.  If we need something more
> involved, changing cookie usage rules definitely seems like an option.

A simpler approach might be to leave the existing synchronization 
mechanisms as they are, and use the chronological approach only for the 
case of loading a module (or wherever else someone wants to use 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: USB device cannot be reconnected and khubd "blocked for more than 120 seconds"

2013-01-16 Thread Tejun Heo
Hello, Alan.

On Wed, Jan 16, 2013 at 12:01:53PM -0500, Alan Stern wrote:
> > The problem here is that "flush everything which comes before me" is
> > used to order async jobs.  e.g. after async jobs probe the hardware
> > they order themselves by flushing before registering them, so unless
> 
> I don't fully understand this example.  What is the point -- to make 
> sure that asynchronously probed devices are registered in the order of 
> their discovery?

People still want devices to be numbered to their physical ports and
so on, so we keep the registeration order the same as natural
(whatever that means) hardware order.

> If so, here's how to do it safely: Start up the async jobs in reverse
> order of discovery.  Have each job acquire a cookie when it starts.  
> Then each job needs to wait only for tasks that started after its
> cookie was issued.

It's a bit clumsy but yeah I guess it could work.

> > There aren't too many which use async anyway so changing stuff
> > shouldn't be too difficult but I think the simpicity or dumbness is
> > one of major attractions of async, so it'd be nice to keep things that
> > way and the PF_USED_ASYNC hack seems to be able to hold things
> > together for now.
> 
> Nesting won't matter for the chronological approach.  I really think 
> you should consider it more fully.  It's not a hack, and it doesn't 
> need to be complicated.

There is benefit to the current dumb implementation in that drivers
can use it without thinking too much, but yeah it could be that the
flushing range limit isn't too much of restriction on top.  I don't
know.  At this point, I'd prefer to remove request_module() from
elevator init path for the problem at hand.  If we need something more
involved, changing cookie usage rules definitely seems like an option.

Thanks.

-- 
tejun
--
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-3.7.1: kmemleak reports in comm "usb-storage"?

2013-01-16 Thread Alan Stern
On Wed, 16 Jan 2013, Martin Mokrejs wrote:

> A corresponding diff of dmesg output is attached. Note that the first 
> kmemleak in there
> happened just without any prior fiddling with a USB drive. For about two days 
> I haven't
> connected a drive. However, usb-storage might be in a wrong shape since 
> several days
> when it happened for the first time. Did you want me to reboot? ;-) I did not.

Sarah, I looked through the xhci-hcd driver.  There does appear to be a
leak in xhci-ring.c:handle_tx_event().  The routine looks like this:

/* Leave the TD around for the reset endpoint function
 * to use(but only if it's not a control endpoint,
 * since we already queued the Set TR dequeue pointer
 * command for stalled control endpoints).
 */
if (usb_endpoint_xfer_control(&urb->ep->desc) ||
(trb_comp_code != COMP_STALL &&
trb_comp_code != COMP_BABBLE))
xhci_urb_free_priv(xhci, urb_priv);

...

/* EHCI, UHCI, and OHCI always unconditionally set the
 * urb->status of an isochronous endpoint to 0.
 */
if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
status = 0;
usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, 
status);

If the condition on the first "if" statement fails, urb_priv won't be 
deallocated.  It needs something like

if (...)
xhci_urb_free_priv(xhci, urb_priv);
+   else
+   kfree(urb_priv);

Martin, can you tell if adding these two lines fixes the problem?

Also, the comment is wrong.  urb->status is not set to 0
unconditionally for isochonrous endpoints in [eou]hcd-hcd.  If any of
the iso packets gets a nonzero status then urb->status is set to one of
those values, not to 0.

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


[PATCH] async: fix __lowest_in_progress()

2013-01-16 Thread Tejun Heo
083b804c4d3e1e3d0eace56bdbc0f674946d2847 ("async: use workqueue for
worker pool") made it possible that async jobs are moved from pending
to running out-of-order.  While pending async jobs will be queued and
dispatched for execution in the same order, nothing guarantees they'll
enter "1) move self to the running queue" of async_run_entry_fn() in
the same order.

This broke __lowest_in_progress().  running->domain may not be
properly sorted and is not guaranteed to contain lower cookies than
pending list when not empty.  Fix it by ensuring sort-inserting to the
running list and always looking at both pending and running when
trying to determine the lowest cookie.

Over time, the async synchronization implementation became quite
messy.  We better restructure it such that each async_entry is linked
to two lists - one global and one per domain - and not move it when
execution starts.  There's no reason to distinguish pending and
running.  They behave the same for synchronization purposes.

Signed-off-by: Tejun Heo 
Cc: Arjan van de Ven 
Cc: sta...@vger.kernel.org
---
And here's the fix for the breakage I mentioned earlier.  It wouldn't
happen often in the wild and the effect of it happening wouldn't be
critical for modern distros but it's still kinda surprising nobody
noticed this.

We definitely need to rewrite async synchronization.  It was already
messy and this makes it worse and there's no reason to be messy here.

Thanks.

 kernel/async.c |   27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

--- a/kernel/async.c
+++ b/kernel/async.c
@@ -86,18 +86,27 @@ static atomic_t entry_count;
  */
 static async_cookie_t  __lowest_in_progress(struct async_domain *running)
 {
+   async_cookie_t first_running = next_cookie; /* infinity value */
+   async_cookie_t first_pending = next_cookie; /* ditto */
struct async_entry *entry;
 
+   /*
+* Both running and pending lists are sorted but not disjoint.
+* Take the first cookies from both and return the min.
+*/
if (!list_empty(&running->domain)) {
entry = list_first_entry(&running->domain, typeof(*entry), 
list);
-   return entry->cookie;
+   first_running = entry->cookie;
}
 
-   list_for_each_entry(entry, &async_pending, list)
-   if (entry->running == running)
-   return entry->cookie;
+   list_for_each_entry(entry, &async_pending, list) {
+   if (entry->running == running) {
+   first_pending = entry->cookie;
+   break;
+   }
+   }
 
-   return next_cookie; /* "infinity" value */
+   return min(first_running, first_pending);
 }
 
 static async_cookie_t  lowest_in_progress(struct async_domain *running)
@@ -118,13 +127,17 @@ static void async_run_entry_fn(struct wo
 {
struct async_entry *entry =
container_of(work, struct async_entry, work);
+   struct async_entry *pos;
unsigned long flags;
ktime_t uninitialized_var(calltime), delta, rettime;
struct async_domain *running = entry->running;
 
-   /* 1) move self to the running queue */
+   /* 1) move self to the running queue, make sure it stays sorted */
spin_lock_irqsave(&async_lock, flags);
-   list_move_tail(&entry->list, &running->domain);
+   list_for_each_entry_reverse(pos, &running->domain, list)
+   if (entry->cookie < pos->cookie)
+   break;
+   list_move_tail(&entry->list, &pos->list);
spin_unlock_irqrestore(&async_lock, flags);
 
/* 2) run (and print duration) */
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: remove unused APIs from Tegra PHY.

2013-01-16 Thread Stephen Warren
On 01/16/2013 12:12 AM, Felipe Balbi wrote:
> Hi,
> 
> On Tue, Jan 15, 2013 at 11:04:51AM -0700, Stephen Warren wrote:
>> On 01/15/2013 03:19 AM, Venu Byravarasu wrote:
>>> As tegra_usb_phy_clk_disable/enable() are not being used,
>>> removing them.
>> 
>> Greg, Felipe,
>> 
>> Again if I may, I'll take this through the Tegra tree. I think
>> the next set of patches that Venu posts should actually expose
>> the dependencies between his USB patches and the Tegra clock
>> framework rework, which are why I want to do this.
> 
> that should be ok:
> 
> Acked-by: Felipe Balbi 

Thanks. I've applied this to Tegra's for-3.9/usb branch.

BTW Venu, you forgot to Cc the linux-tegra mailing list; that's
probably more useful than linux-kernel for Tegra-specific driver changes.
--
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] module, async: async_synchronize_full() on module init iff async is used

2013-01-16 Thread Linus Torvalds
On Wed, Jan 16, 2013 at 9:03 AM, Arjan van de Ven  wrote:
>
> we can even try twice
>
> the first time right after we mount the initramfs
> the second time when the initramfs code exits, and before we exec init
> (the initramfs supposedly mounted the real root fs at this point)

Yes. This, together with "don't try request_module for the default
elevator", and the "warn if somebody does request_module from async
context" would, I think, be the right thing to do.

In the meantime, I've applied Tejun's patch. It possibly speeds things
up regardless of this particular deadlock thing, and while it's not
pretty it certainly isn't horribly nasty or very invasive either, so I
don't see any reason to delay it just because there might be a better
solution some day.

  Linus
--
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] module, async: async_synchronize_full() on module init iff async is used

2013-01-16 Thread Arjan van de Ven



As Arjan suggested, trying to load the default modules right after the
initial rootfs mount could be an acceptable compromise and it would be
really nice (for both code sanity and avoiding future problems) to be
able to declare module loading nested inside async unspported.


we can even try twice

the first time right after we mount the initramfs
the second time when the initramfs code exits, and before we exec init
(the initramfs supposedly mounted the real root fs at this point)

if you want your elevator to apply to your root filesystem storage, the rule
will then be "put the module in the initramfs"... but to be honest,
that's not a restriction that is unreasonable or unexpected.


for doing a module loading from inside an async handler..we can then just make
use of the normal "load this module async" way of requesting a module.

--
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 device cannot be reconnected and khubd "blocked for more than 120 seconds"

2013-01-16 Thread Alan Stern
On Wed, 16 Jan 2013, Tejun Heo wrote:

> Hello, Alan.
> 
> On Tue, Jan 15, 2013 at 11:01:15PM -0500, Alan Stern wrote:
> > > The current domain implementation is somewhere inbetween.  It's not
> > > completely simplistic system and at the same time not developed enough
> > > to do properly stacked flushing.
> > 
> > I like your idea of chronological synchronization: Insist that anybody
> > who wants to flush async jobs must get a cookie, and then only allow
> > them to wait for async jobs started after the cookie was issued.
> > 
> > I don't know if this is possible with the current implementation.  It 
> > would require changing every call to async_synchronize_*(), and in a 
> > nontrivial way.  But it might provide a proper solution to all these 
> > problems.
> 
> The problem here is that "flush everything which comes before me" is
> used to order async jobs.  e.g. after async jobs probe the hardware
> they order themselves by flushing before registering them, so unless

I don't fully understand this example.  What is the point -- to make 
sure that asynchronously probed devices are registered in the order of 
their discovery?

If so, here's how to do it safely: Start up the async jobs in reverse
order of discovery.  Have each job acquire a cookie when it starts.  
Then each job needs to wait only for tasks that started after its
cookie was issued.

> we build accurate flushing dependencies, those dependencies will reach
> beyond the time window we're interested in and bring in deadlocks.

The flushing-dependency principle can be very simple: No async task
should ever have to wait for another async task that started before it.  
The "cookie" approach satisfies this requirement (unless an earlier 
task passes its cookie to a later task or subverts the mechanism in 
another way).

> And, as Linus pointed it out, tracking dependency through
> request_module() is tricky no matter what we do.  I think it can be
> done by matching the ones calling request_module() and the ones
> actually loading modules but it's gonna be nasty.

This shouldn't matter.  Dependencies don't need to be tracked
explicitly, because we know that any async work done by
request_module() must start _after_ request_module() is called.  Thus,
if async task A calls request_module(), which starts up async task B,
then we know that A can safely wait for B and B cannot safely wait for
A.

> There aren't too many which use async anyway so changing stuff
> shouldn't be too difficult but I think the simpicity or dumbness is
> one of major attractions of async, so it'd be nice to keep things that
> way and the PF_USED_ASYNC hack seems to be able to hold things
> together for now.

Nesting won't matter for the chronological approach.  I really think 
you should consider it more fully.  It's not a hack, and it doesn't 
need to be complicated.

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] module, async: async_synchronize_full() on module init iff async is used

2013-01-16 Thread Tejun Heo
Hey,

On Tue, Jan 15, 2013 at 07:37:42PM -0800, Linus Torvalds wrote:
> I do want the same user-visible semantics, so it's not some one-liner.
> 
> The compiled-in elevator would be easy enough to handle in the Kconfig
> file (maybe we do already, I didn't even bother to check). The real
> problem is the "chosen_elevator" one, which is dynamic with the kernel
> command line. And we could handle that one by just trying to load the
> module early (but exactly _when_?) and then instead of looking things
> up by name, just keep a pointer to the default elevator around.
> 
> But no, it's not just some trivial one-liner. Especially the question
> about "when to try to load the module that is given on the kernel
> command line" is not trivial. Do we require that the module is in the
> initrd and loadable basically immediate at boot? Do we try again after
> switching the root filesystem? Things like that..

If the current user-visible semantics is defined as "the kernel shall
try to load the default iosched if not already available on each block
device discovery", nothing can be changed ever, but I'm not sure it
needs to be pushed that far.

As Arjan suggested, trying to load the default modules right after the
initial rootfs mount could be an acceptable compromise and it would be
really nice (for both code sanity and avoiding future problems) to be
able to declare module loading nested inside async unspported.

Thanks.

-- 
tejun
--
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] module, async: async_synchronize_full() on module init iff async is used

2013-01-16 Thread Arjan van de Ven



But no, it's not just some trivial one-liner. Especially the question
about "when to try to load the module that is given on the kernel
command line" is not trivial. Do we require that the module is in the
initrd and loadable basically immediate at boot? Do we try again after
switching the root filesystem? Things like that..


to load it from the root fs you tend to need... an elevator ;-)


I think it's pretty fair to users to say that if you want something by default 
at boot time,
you need to build it in...
but for us to try a modprobe from the initrd is not too bad I suppose.
probably need to do this around the time we initialize the block layer

--
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 device cannot be reconnected and khubd "blocked for more than 120 seconds"

2013-01-16 Thread Tejun Heo
Hello, Alan.

On Tue, Jan 15, 2013 at 11:01:15PM -0500, Alan Stern wrote:
> > The current domain implementation is somewhere inbetween.  It's not
> > completely simplistic system and at the same time not developed enough
> > to do properly stacked flushing.
> 
> I like your idea of chronological synchronization: Insist that anybody
> who wants to flush async jobs must get a cookie, and then only allow
> them to wait for async jobs started after the cookie was issued.
> 
> I don't know if this is possible with the current implementation.  It 
> would require changing every call to async_synchronize_*(), and in a 
> nontrivial way.  But it might provide a proper solution to all these 
> problems.

The problem here is that "flush everything which comes before me" is
used to order async jobs.  e.g. after async jobs probe the hardware
they order themselves by flushing before registering them, so unless
we build accurate flushing dependencies, those dependencies will reach
beyond the time window we're interested in and bring in deadlocks.

And, as Linus pointed it out, tracking dependency through
request_module() is tricky no matter what we do.  I think it can be
done by matching the ones calling request_module() and the ones
actually loading modules but it's gonna be nasty.

There aren't too many which use async anyway so changing stuff
shouldn't be too difficult but I think the simpicity or dumbness is
one of major attractions of async, so it'd be nice to keep things that
way and the PF_USED_ASYNC hack seems to be able to hold things
together for now.

Thanks.

-- 
tejun
--
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 issue with kernel 3.6

2013-01-16 Thread Alan Stern
On Mon, 14 Jan 2013, Piergiorgio Sartor wrote:

> > Okay, I figured out what the problem is.  It really is a bug in 
> > ehci-hcd; the driver doesn't do what the spec requires when unlinking 
> > more than one QH at a time.
> 
> Well, I'm happy to read this. Good that you find it!
> 
> It puzzles me I'm the only one, it seems, affected by this!

I'm not sure.  Perhaps this is because you are using so many async QHs 
at the same time.

> > Although the driver could be fixed, it will be easier to stick with the
> > old approach and never unlink more than one QH.  Doing two or more at
> > once is pretty rare, so it doesn't much matter if they take a little
> > longer.  I'll send a patch that does this properly in the near future,
> > for you to test.
> 
> Cool! I'm looking forward to it.

I changed my mind -- it turns out that adding the fix is somewhat
easier than unlinking one QH at a time.

So now we're ready for some serious testing.  The patch below is based 
on the 3.7 kernel, and it doesn't include any of the debugging stuff 
you have been using.  Remove all the old patches and apply this one 
instead.  It has two changes: the increase in the schedule polling time 
and the fix for multiple unlinks.

If this causes the problem to go away then I will submit it for 
inclusion in the stable kernel series.

Alan Stern



Index: 3.7/drivers/usb/host/ehci-timer.c
===
--- 3.7.orig/drivers/usb/host/ehci-timer.c
+++ 3.7/drivers/usb/host/ehci-timer.c
@@ -113,21 +113,22 @@ static void ehci_poll_ASS(struct ehci_hc
 
if (want != actual) {
 
-   /* Poll again later, but give up after about 20 ms */
-   if (ehci->ASS_poll_count++ < 20) {
-   ehci_enable_event(ehci, EHCI_HRTIMER_POLL_ASS, true);
-   return;
-   }
-   ehci_dbg(ehci, "Waited too long for the async schedule status 
(%x/%x), giving up\n",
-   want, actual);
+   /* Poll again later */
+   ehci_enable_event(ehci, EHCI_HRTIMER_POLL_ASS, true);
+   ++ehci->ASS_poll_count;
+   return;
}
+
+   if (ehci->ASS_poll_count > 20)
+   ehci_dbg(ehci, "ASS poll count reached %d\n",
+   ehci->ASS_poll_count);
ehci->ASS_poll_count = 0;
 
/* The status is up-to-date; restart or stop the schedule as needed */
if (want == 0) {/* Stopped */
-   if (ehci->async_count > 0)
+   if (ehci->async_count > 0) {
ehci_set_command_bit(ehci, CMD_ASE);
-
+   }
} else {/* Running */
if (ehci->async_count == 0) {
 
@@ -159,14 +160,14 @@ static void ehci_poll_PSS(struct ehci_hc
 
if (want != actual) {
 
-   /* Poll again later, but give up after about 20 ms */
-   if (ehci->PSS_poll_count++ < 20) {
-   ehci_enable_event(ehci, EHCI_HRTIMER_POLL_PSS, true);
-   return;
-   }
-   ehci_dbg(ehci, "Waited too long for the periodic schedule 
status (%x/%x), giving up\n",
-   want, actual);
+   /* Poll again later */
+   ehci_enable_event(ehci, EHCI_HRTIMER_POLL_PSS, true);
+   return;
}
+
+   if (ehci->PSS_poll_count > 20)
+   ehci_dbg(ehci, "PSS poll count reached %d\n",
+   ehci->PSS_poll_count);
ehci->PSS_poll_count = 0;
 
/* The status is up-to-date; restart or stop the schedule as needed */
Index: 3.7/drivers/usb/host/ehci-q.c
===
--- 3.7.orig/drivers/usb/host/ehci-q.c
+++ 3.7/drivers/usb/host/ehci-q.c
@@ -1174,6 +1174,18 @@ submit_async (
 static void single_unlink_async(struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
struct ehci_qh  *prev;
+   __hc32  dma = QH_NEXT(ehci, qh->qh_dma);
+   __hc32  dma_next = qh->hw->hw_next;
+
+   /* No QH on the unlink lists should point to qh */
+   for (prev = ehci->async_unlink; prev; prev = prev->unlink_next) {
+   if (prev->hw->hw_next == dma)
+   prev->hw->hw_next = dma_next;
+   }
+   for (prev = ehci->async_iaa; prev; prev = prev->unlink_next) {
+   if (prev->hw->hw_next == dma)
+   prev->hw->hw_next = dma_next;
+   }
 
/* Add to the end of the list of QHs waiting for the next IAAD */
qh->qh_state = QH_STATE_UNLINK;
@@ -1188,7 +1200,7 @@ static void single_unlink_async(struct e
while (prev->qh_next.qh != qh)
prev = prev->qh_next.qh;
 
-   prev->hw->hw_next = qh->hw->hw_next;
+   prev->hw->hw_next = dma_next;
prev->qh_next = qh->qh_next;
if (ehci->qh_scan_n

Re: [Resend PATCH V4 0/10] usb: usb port power off mechanism anc expose usb port connect type

2013-01-16 Thread Alan Stern
On Tue, 15 Jan 2013, Lan Tianyu wrote:

> Hi Greg&Alan:
>   Do you have some more comments about this patchset? Thanks.

I don't have any more comments at this point.  It looks okay to me.

Acked-by: Alan Stern 

By the way, have you checked whether the auto-power-off mechanism works 
correctly when you do a system suspend?

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 v4 2/4] ARM: Exynos5250: Enabling ohci-exynos driver

2013-01-16 Thread Vivek Gautam
Hi Tomasz,


On Wed, Jan 16, 2013 at 1:14 PM, Tomasz Figa  wrote:
> Hi Vivek,
>
> On Tuesday 15 of January 2013 19:08:30 Vivek Gautam wrote:
>> Adding OHCI device tree node for Exynos5250 along with
>> the device base address.
>>
>> Signed-off-by: Vivek Gautam 
>> Acked-by: Jingoo Han 
>> Acked-by: Grant Likely 
>> ---
>>  .../devicetree/bindings/usb/exynos-usb.txt |   15
>> +++ arch/arm/boot/dts/exynos5250.dtsi  |
>> 6 ++ 2 files changed, 21 insertions(+), 0 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt
>> b/Documentation/devicetree/bindings/usb/exynos-usb.txt index
>> e8bbb47..f66fcdd 100644
>> --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt
>> +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt
>> @@ -23,3 +23,18 @@ Example:
>>   interrupts = <0 71 0>;
>>   samsung,vbus-gpio = <&gpx2 6 1 3 3>;
>>   };
>> +
>> +OHCI
>> +Required properties:
>> + - compatible: should be "samsung,exynos4210-ohci" for USB 2.0
>> +   OHCI companion controller in host mode.
>> + - reg: physical base address of the controller and length of memory
>> mapped +   region.
>> + - interrupts: interrupt number to the cpu.
>> +
>> +Example:
>> + usb@1212 {
>> + compatible = "samsung,exynos4210-ohci";
>> + reg = <0x1212 0x100>;
>> + interrupts = <0 71 0>;
>> + };
>> diff --git a/arch/arm/boot/dts/exynos5250.dtsi
>> b/arch/arm/boot/dts/exynos5250.dtsi index 2cbe53e..ebb0907 100644
>> --- a/arch/arm/boot/dts/exynos5250.dtsi
>> +++ b/arch/arm/boot/dts/exynos5250.dtsi
>> @@ -281,6 +281,12 @@
>>   interrupts = <0 71 0>;
>>   };
>>
>> + usb@1212 {
>> + compatible = "samsung,exynos4210-ohci";
>> + reg = <0x1212 0x100>;
>> + interrupts = <0 71 0>;
>
> For Samsung platforms we decided per board enabling of nodes and so this
> node should also contain:
>
> status = "disabled";
>
> while in dts file of board using ohci there would be an overriding entry:
>
> usb@1212 {
> status = "okay";
> };
>

Yes, i could see that for exynos4x dt.

> I know that Exynos5250 has not been yet converted into this convention,
> but using it when adding new devices will simplify the process.
>

Sure, will change this and other patches for usb as suggested.
Thanks for the review. :-)



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


Re: [PATCH 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-16 Thread Alan Stern
On Wed, 16 Jan 2013, Venu Byravarasu wrote:

> As Tegra PHY driver needs to access one of the Host registers,
> added few APIs.
> 
> Signed-off-by: Venu Byravarasu 

> --- a/drivers/usb/host/ehci-tegra.c
> +++ b/drivers/usb/host/ehci-tegra.c

> @@ -605,6 +619,50 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
>  
>  #endif
>  
> +void tegra_ehci_set_wakeon_events(struct usb_phy *x, bool enable)
> +{
> + unsigned long val;
> + struct usb_hcd *hcd = bus_to_hcd(x->otg->host);
> + void __iomem *base = hcd->regs;
> + u32 wake = USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN;
> +
> + val = readl(base + USB_PORTSC1);
> + if (enable)
> + val |= wake;
> + else
> + val &= ~wake;
> + writel(val, base + USB_PORTSC1);
> +}

Here and below, this sort of code is highly questionable.  You
evidently don't realize that some of the bits in the PORTSC registers
are R/WC.  This means writing a 1 to these bits will clear them.  

Consequently it is almost always wrong to read a PORTSC register and
then write back the same (or a slightly modified) value.

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 v6 04/22] mfd: omap-usb-tll: Clean up clock handling

2013-01-16 Thread Roger Quadros
On 01/16/2013 04:55 PM, Russell King - ARM Linux wrote:
> On Wed, Jan 16, 2013 at 04:43:35PM +0200, Roger Quadros wrote:
>> +spin_lock_irqsave(&tll->lock, flags);
>> +
>> +for (i = 0; i < tll->nch; i++) {
>> +char clkname[] = "usb_tll_hs_usb_chx_clk";
>> +struct clk *fck;
>> +
>> +snprintf(clkname, sizeof(clkname),
>> +"usb_tll_hs_usb_ch%d_clk", i);
>> +fck = clk_get(dev, clkname);
> 
> NAK.  Why are you doing this under a spinlock?
> 
> clk_get() takes a mutex.  You must not be in an atomic region (iow, you
> must not be holding a spinlock, and you must not have IRQs disabled)
> when you call clk_get().
> 
Right. Good catch :).

--
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 v4 3/4] ARM: Exynos5250: Add clock information for dwc3-exynos

2013-01-16 Thread Vivek Gautam
Hi Tomasz,


On Wed, Jan 16, 2013 at 1:19 PM, Tomasz Figa  wrote:
> Hi Vivek,
>
> Don't you need also some clkdev lookup entry to make the clock available
> in the driver?
>

This clock source we added with a motive of completion, however it's
not being used as of now.
As far as i could see the lookup structure contains clocks for devices
having multiple instances.
Do you feel that i should be adding an entry in clk_lookup structure ?
May be i am missing here something. Can you please elaborate on the
use-case of clk_lookup
entries.

>
> On Tuesday 15 of January 2013 19:08:31 Vivek Gautam wrote:
>> Adding necessary device clock to exynos5 needed for
>> the DWC3 controller.
>>
>> Signed-off-by: Vivek Gautam 
>> ---
>>  arch/arm/mach-exynos/clock-exynos5.c |   24 
>>  1 files changed, 24 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-exynos/clock-exynos5.c
>> b/arch/arm/mach-exynos/clock-exynos5.c index 0208c3a..13af020 100644
>> --- a/arch/arm/mach-exynos/clock-exynos5.c
>> +++ b/arch/arm/mach-exynos/clock-exynos5.c
>> @@ -757,6 +757,11 @@ static struct clk exynos5_init_clocks_off[] = {
>>   .enable = exynos5_clk_ip_fsys_ctrl ,
>>   .ctrlbit= (1 << 18),
>>   }, {
>> + .name   = "usbdrd30",
>> + .parent = &exynos5_clk_aclk_200.clk,
>> + .enable = exynos5_clk_ip_fsys_ctrl,
>> + .ctrlbit= (1 << 19),
>> + }, {
>>   .name   = "usbotg",
>>   .enable = exynos5_clk_ip_fsys_ctrl,
>>   .ctrlbit= (1 << 7),
>> @@ -1035,6 +1040,16 @@ static struct clksrc_sources exynos5_clkset_group
>> = { .nr_sources   = ARRAY_SIZE(exynos5_clkset_group_list),
>>  };
>>
>> +struct clk *exynos5_clkset_usbdrd30_list[] = {
>> + [0] = &exynos5_clk_mout_mpll.clk,
>> + [1] = &exynos5_clk_mout_cpll.clk,
>> +};
>> +
>> +struct clksrc_sources exynos5_clkset_usbdrd30 = {
>> + .sources= exynos5_clkset_usbdrd30_list,
>> + .nr_sources = ARRAY_SIZE(exynos5_clkset_usbdrd30_list),
>> +};
>> +
>>  /* Possible clock sources for aclk_266_gscl_sub Mux */
>>  static struct clk *clk_src_gscl_266_list[] = {
>>   [0] = &clk_ext_xtal_mux,
>> @@ -1329,6 +1344,15 @@ static struct clksrc_clk exynos5_clksrcs[] = {
>>   .parent = &exynos5_clk_mout_cpll.clk,
>>   },
>>   .reg_div = { .reg = EXYNOS5_CLKDIV_GEN, .shift = 4, .size = 3
> },
>> + }, {
>> + .clk= {
>> + .name   = "sclk_usbdrd30",
>> + .enable = exynos5_clksrc_mask_fsys_ctrl,
>> + .ctrlbit= (1 << 28),
>> + },
>> + .sources = &exynos5_clkset_usbdrd30,
>> + .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 28, .size =
> 1 },
>> + .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS0, .shift = 24, .size =
> 4 },
>>   },
>>  };


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


[RFC PATCH 6/6] USB: MUSB: OMAP: get PHY by phandle for dt boot

2013-01-16 Thread Kishon Vijay Abraham I
The OMAP glue has been modified to get PHY by phandle for dt boot.

Signed-off-by: Kishon Vijay Abraham I 
---
 drivers/usb/musb/omap2430.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3628a50..08709cf 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -346,7 +346,12 @@ static int omap2430_musb_init(struct musb *musb)
 * up through ULPI.  TWL4030-family PMICs include one,
 * which needs a driver, drivers aren't always needed.
 */
-   musb->xceiv = devm_usb_get_phy(dev, 0);
+   if (dev->parent->of_node)
+   musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent,
+   "usb_phy", 0);
+   else
+   musb->xceiv = devm_usb_get_phy(dev, 0);
+
if (IS_ERR_OR_NULL(musb->xceiv)) {
pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV;
-- 
1.7.9.5

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


[RFC PATCH 1/6] usb: otg: Add an API to bind the USB controller and PHY

2013-01-16 Thread Kishon Vijay Abraham I
New platforms are added which has multiple PHY's (of same type) and
which has multiple USB controllers. The binding information has to be
present in the PHY library (otg.c) in order for it to return the
appropriate PHY whenever the USB controller request for the PHY. So
added a new API to pass the binding information. This API should be
called by platform specific initialization code.

Signed-off-by: Kishon Vijay Abraham I 
---
 drivers/usb/otg/otg.c   |   37 +
 include/linux/usb/phy.h |   22 ++
 2 files changed, 59 insertions(+)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index a30c041..492ba2f 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -18,6 +18,7 @@
 #include 
 
 static LIST_HEAD(phy_list);
+static LIST_HEAD(phy_bind_list);
 static DEFINE_SPINLOCK(phy_lock);
 
 static struct usb_phy *__usb_find_phy(struct list_head *list,
@@ -201,6 +202,42 @@ void usb_remove_phy(struct usb_phy *x)
 }
 EXPORT_SYMBOL(usb_remove_phy);
 
+/**
+ * usb_bind_phy - bind the phy and the controller that uses the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @index: index to specify the port number
+ * @phy_dev_name: the device name of the phy
+ *
+ * Fills the phy_bind structure with the dev_name and phy_dev_name. This will
+ * be used when the phy driver registers the phy and when the controller
+ * requests this phy.
+ *
+ * To be used by platform specific initialization code.
+ */
+struct usb_phy_bind __init *usb_bind_phy(const char *dev_name, u8 index,
+   const char *phy_dev_name)
+{
+   struct usb_phy_bind *phy_bind;
+   unsigned long flags;
+
+   phy_bind = kzalloc(sizeof(*phy_bind), GFP_KERNEL);
+   if (!phy_bind) {
+   pr_err("phy_bind(): No memory for phy_bind");
+   return ERR_PTR(-ENOMEM);
+   }
+
+   phy_bind->dev_name = dev_name;
+   phy_bind->phy_dev_name = phy_dev_name;
+   phy_bind->index = index;
+
+   spin_lock_irqsave(&phy_lock, flags);
+   list_add_tail(&phy_bind->list, &phy_bind_list);
+   spin_unlock_irqrestore(&phy_lock, flags);
+
+   return phy_bind;
+}
+EXPORT_SYMBOL_GPL(usb_bind_phy);
+
 const char *otg_state_string(enum usb_otg_state state)
 {
switch (state) {
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index a29ae1e..fbeab1a 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -106,6 +106,21 @@ struct usb_phy {
enum usb_device_speed speed);
 };
 
+/**
+ * struct usb_phy_bind - represent the binding for the phy
+ * @dev_name: the device name of the device that will bind to the phy
+ * @phy_dev_name: the device name of the phy
+ * @index: used if a single controller uses multiple phys
+ * @phy: reference to the phy
+ * @list: to maintain a linked list of the binding information
+ */
+struct usb_phy_bind {
+   const char  *dev_name;
+   const char  *phy_dev_name;
+   u8  index;
+   struct usb_phy  *phy;
+   struct list_head list;
+};
 
 /* for board-specific init logic */
 extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type);
@@ -151,6 +166,8 @@ extern struct usb_phy *devm_usb_get_phy(struct device *dev,
enum usb_phy_type type);
 extern void usb_put_phy(struct usb_phy *);
 extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
+extern struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
+   const char *phy_dev_name);
 #else
 static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
 {
@@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device *dev, 
struct usb_phy *x)
 {
 }
 
+static inline struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
+   const char *phy_dev_name)
+{
+   return NULL;
+}
 #endif
 
 static inline int
-- 
1.7.9.5

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


[RFC PATCH 0/6] USB: Add multiple PHYs of same type

2013-01-16 Thread Kishon Vijay Abraham I
New platforms are being added which has multiple PHY's (of same type) and
which has multiple USB controllers. The binding information has to be
present in the PHY library (otg.c) in order for it to return the
appropriate PHY whenever the USB controller request for the PHY. So
added a new API to pass the binding information. This API should be
called by platform specific initialization code.

So the binding should be done something like
usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto"); specifying the USB
controller device name, index, and the PHY device name.
I have done this binding for OMAP platforms, but it should be done for
all the platforms.

After this design, the phy can be got by passing the USB controller device
pointer and the index.

Developed this patch series on
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv
after applying "usb: musb: add driver for control module" patch series.

Did basic enumeration testing in omap4 panda, omap4 sdp and omap3 beagle.

Kishon Vijay Abraham I (6):
  usb: otg: Add an API to bind the USB controller and PHY
  ARM: OMAP: USB: Add phy binding information
  usb: otg: utils: change the phy lib to support multiple PHYs of same
type
  ARM: dts: OMAP: Add phandle to bind PHY with USB controller
  usb: otg: add device tree support to otg library
  USB: MUSB: OMAP: get PHY by phandle for dt boot

 Documentation/devicetree/bindings/usb/omap-usb.txt |2 +
 arch/arm/boot/dts/omap3.dtsi   |1 +
 arch/arm/boot/dts/omap4.dtsi   |3 +-
 arch/arm/boot/dts/twl4030.dtsi |2 +-
 arch/arm/mach-omap2/usb-musb.c |7 +-
 arch/arm/mach-shmobile/board-marzen.c  |2 +-
 drivers/power/ab8500_charger.c |2 +-
 drivers/power/isp1704_charger.c|2 +-
 drivers/power/pda_power.c  |2 +-
 drivers/power/twl4030_charger.c|2 +-
 drivers/usb/chipidea/udc.c |2 +-
 drivers/usb/dwc3/core.c|4 +-
 drivers/usb/gadget/fsl_udc_core.c  |2 +-
 drivers/usb/gadget/mv_udc_core.c   |2 +-
 drivers/usb/gadget/omap_udc.c  |2 +-
 drivers/usb/gadget/pxa25x_udc.c|2 +-
 drivers/usb/gadget/pxa27x_udc.c|2 +-
 drivers/usb/gadget/s3c-hsudc.c |2 +-
 drivers/usb/host/ehci-fsl.c|2 +-
 drivers/usb/host/ehci-msm.c|2 +-
 drivers/usb/host/ehci-mv.c |2 +-
 drivers/usb/host/ehci-tegra.c  |2 +-
 drivers/usb/host/ohci-omap.c   |2 +-
 drivers/usb/musb/am35x.c   |2 +-
 drivers/usb/musb/blackfin.c|2 +-
 drivers/usb/musb/da8xx.c   |2 +-
 drivers/usb/musb/davinci.c |2 +-
 drivers/usb/musb/musb_dsps.c   |2 +-
 drivers/usb/musb/omap2430.c|7 +-
 drivers/usb/musb/tusb6010.c|2 +-
 drivers/usb/musb/ux500.c   |2 +-
 drivers/usb/otg/ab8500-usb.c   |3 +-
 drivers/usb/otg/fsl_otg.c  |5 +-
 drivers/usb/otg/gpio_vbus.c|3 +-
 drivers/usb/otg/isp1301_omap.c |3 +-
 drivers/usb/otg/msm_otg.c  |3 +-
 drivers/usb/otg/mv_otg.c   |3 +-
 drivers/usb/otg/nop-usb-xceiv.c|3 +-
 drivers/usb/otg/otg.c  |  175 
 drivers/usb/otg/twl4030-usb.c  |3 +-
 drivers/usb/phy/mv_u3d_phy.c   |3 +-
 drivers/usb/phy/omap-usb2.c|   11 +-
 drivers/usb/phy/rcar-phy.c |3 +-
 include/linux/usb/phy.h|   42 -
 44 files changed, 245 insertions(+), 89 deletions(-)

-- 
1.7.9.5

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


[RFC PATCH 3/6] usb: otg: utils: change the phy lib to support multiple PHYs of same type

2013-01-16 Thread Kishon Vijay Abraham I
In order to add support for multipe PHY's of the same type, the API's
for adding PHY and getting PHY has been changed. Now the binding
information of the PHY and controller should be done in platform file
using usb_bind_phy API. And for getting a PHY, the device pointer of the
USB controller and an index should be passed. Based on the binding
information that is added in the platform file, get_phy will return the
approappropriate PHY.

Signed-off-by: Kishon Vijay Abraham I 
---
 arch/arm/mach-shmobile/board-marzen.c |2 +-
 drivers/power/ab8500_charger.c|2 +-
 drivers/power/isp1704_charger.c   |2 +-
 drivers/power/pda_power.c |2 +-
 drivers/power/twl4030_charger.c   |2 +-
 drivers/usb/chipidea/udc.c|2 +-
 drivers/usb/dwc3/core.c   |4 +-
 drivers/usb/gadget/fsl_udc_core.c |2 +-
 drivers/usb/gadget/mv_udc_core.c  |2 +-
 drivers/usb/gadget/omap_udc.c |2 +-
 drivers/usb/gadget/pxa25x_udc.c   |2 +-
 drivers/usb/gadget/pxa27x_udc.c   |2 +-
 drivers/usb/gadget/s3c-hsudc.c|2 +-
 drivers/usb/host/ehci-fsl.c   |2 +-
 drivers/usb/host/ehci-msm.c   |2 +-
 drivers/usb/host/ehci-mv.c|2 +-
 drivers/usb/host/ehci-tegra.c |2 +-
 drivers/usb/host/ohci-omap.c  |2 +-
 drivers/usb/musb/am35x.c  |2 +-
 drivers/usb/musb/blackfin.c   |2 +-
 drivers/usb/musb/da8xx.c  |2 +-
 drivers/usb/musb/davinci.c|2 +-
 drivers/usb/musb/musb_dsps.c  |2 +-
 drivers/usb/musb/omap2430.c   |2 +-
 drivers/usb/musb/tusb6010.c   |2 +-
 drivers/usb/musb/ux500.c  |2 +-
 drivers/usb/otg/ab8500-usb.c  |3 +-
 drivers/usb/otg/fsl_otg.c |5 ++-
 drivers/usb/otg/gpio_vbus.c   |3 +-
 drivers/usb/otg/isp1301_omap.c|3 +-
 drivers/usb/otg/msm_otg.c |3 +-
 drivers/usb/otg/mv_otg.c  |3 +-
 drivers/usb/otg/nop-usb-xceiv.c   |3 +-
 drivers/usb/otg/otg.c |   67 +++--
 drivers/usb/otg/twl4030-usb.c |3 +-
 drivers/usb/phy/mv_u3d_phy.c  |3 +-
 drivers/usb/phy/omap-usb2.c   |   11 ++
 drivers/usb/phy/rcar-phy.c|3 +-
 include/linux/usb/phy.h   |   12 +++---
 39 files changed, 87 insertions(+), 89 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-marzen.c 
b/arch/arm/mach-shmobile/board-marzen.c
index 449f928..abe482d 100644
--- a/arch/arm/mach-shmobile/board-marzen.c
+++ b/arch/arm/mach-shmobile/board-marzen.c
@@ -320,7 +320,7 @@ static struct platform_device *marzen_late_devices[] 
__initdata = {
 void __init marzen_init_late(void)
 {
/* get usb phy */
-   phy = usb_get_phy(USB_PHY_TYPE_USB2);
+   phy = usb_get_phy(&ehci0_device.dev, 0);
 
shmobile_init_late();
platform_add_devices(marzen_late_devices,
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 3be9c0e..d20561a 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -2694,7 +2694,7 @@ static int ab8500_charger_probe(struct platform_device 
*pdev)
goto free_ac;
}
 
-   di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
+   di->usb_phy = usb_get_phy(di->dev, 0);
if (IS_ERR_OR_NULL(di->usb_phy)) {
dev_err(di->dev, "failed to get usb transceiver\n");
ret = -EINVAL;
diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c
index 176ad59..dfbe597 100644
--- a/drivers/power/isp1704_charger.c
+++ b/drivers/power/isp1704_charger.c
@@ -415,7 +415,7 @@ static int isp1704_charger_probe(struct platform_device 
*pdev)
if (!isp)
return -ENOMEM;
 
-   isp->phy = usb_get_phy(USB_PHY_TYPE_USB2);
+   isp->phy = usb_get_phy(&pdev->dev, 0);
if (IS_ERR_OR_NULL(isp->phy))
goto fail0;
 
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
index 7df7c5f..64d79f7 100644
--- a/drivers/power/pda_power.c
+++ b/drivers/power/pda_power.c
@@ -316,7 +316,7 @@ static int pda_power_probe(struct platform_device *pdev)
}
 
 #ifdef CONFIG_USB_OTG_UTILS
-   transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+   transceiver = usb_get_phy(&pdev->dev, 0);
if (!IS_ERR_OR_NULL(transceiver)) {
if (!pdata->is_usb_online)
pdata->is_usb_online = otg_is_usb_online;
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index a69d0d1..f53b417 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -552,7 +552,7 @@ static int __init twl4030_bci_probe(struct platform_device 
*pdev)
 
INIT_WORK(&bci->work, twl4030_bci_usb_work);
 
-   bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+  

[RFC PATCH 5/6] usb: otg: add device tree support to otg library

2013-01-16 Thread Kishon Vijay Abraham I
Added an API devm_usb_get_phy_by_phandle(), to get usb phy by passing a
device node phandle value. This function will return a pointer to
the phy on success, -EPROBE_DEFER if there is a device_node for the phandle,
but the phy has not been added, or a ERR_PTR() otherwise.

Cc: Marc Kleine-Budde 
Signed-off-by: Kishon Vijay Abraham I 
---
 drivers/usb/otg/otg.c   |   77 +++
 include/linux/usb/phy.h |8 +
 2 files changed, 85 insertions(+)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index dbf2043..e9799bb 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -13,7 +13,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 #include 
 
@@ -34,6 +36,20 @@ static struct usb_phy *__usb_find_phy(struct device *dev, u8 
index)
return ERR_PTR(-ENODEV);
 }
 
+static struct usb_phy *__of_usb_find_phy(struct device_node *node)
+{
+   struct usb_phy  *phy;
+
+   list_for_each_entry(phy, &phy_list, head) {
+   if (node != phy->dev->of_node)
+   continue;
+
+   return phy;
+   }
+
+   return ERR_PTR(-ENODEV);
+}
+
 static void devm_usb_phy_release(struct device *dev, void *res)
 {
struct usb_phy *phy = *(struct usb_phy **)res;
@@ -109,6 +125,67 @@ err0:
 }
 EXPORT_SYMBOL(usb_get_phy);
 
+ /**
+ * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
+ * @dev - device that requests this phy
+ * @phandle - name of the property holding the phy phandle value
+ * @index - the index of the phy
+ *
+ * Returns the phy driver associated with the given phandle value,
+ * after getting a refcount to it, -ENODEV if there is no such phy or
+ * -EPROBE_DEFER if there is a phandle to the phy, but the device is
+ * not yet loaded. While at that, it also associates the device with
+ * the phy using devres. On driver detach, release function is invoked
+ * on the devres data, then, devres data is freed.
+ *
+ * For use by USB host and peripheral drivers.
+ */
+struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+   const char *phandle, u8 index)
+{
+   struct usb_phy  *phy = NULL, **ptr;
+   unsigned long   flags;
+   struct device_node *node;
+
+   if (!dev->of_node) {
+   dev_dbg(dev, "device does not have a device node entry\n");
+   return ERR_PTR(-EINVAL);
+   }
+
+   node = of_parse_phandle(dev->of_node, phandle, index);
+   if (!node) {
+   dev_dbg(dev, "failed to get %s phandle in %s node\n", phandle,
+   dev->of_node->full_name);
+   return ERR_PTR(-ENODEV);
+   }
+
+   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr) {
+   dev_dbg(dev, "failed to allocate memory for devres\n");
+   return ERR_PTR(-ENOMEM);
+   }
+
+   spin_lock_irqsave(&phy_lock, flags);
+
+   phy = __of_usb_find_phy(node);
+   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
+   phy = ERR_PTR(-EPROBE_DEFER);
+   devres_free(ptr);
+   goto err0;
+   }
+
+   *ptr = phy;
+   devres_add(dev, ptr);
+
+   get_device(phy->dev);
+
+err0:
+   spin_unlock_irqrestore(&phy_lock, flags);
+
+   return phy;
+}
+EXPORT_SYMBOL(devm_usb_get_phy_by_phandle);
+
 /**
  * devm_usb_put_phy - release the USB PHY
  * @dev - device that wants to release this phy
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index d133c8b..5836b6d 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -163,6 +163,8 @@ usb_phy_shutdown(struct usb_phy *x)
 #ifdef CONFIG_USB_OTG_UTILS
 extern struct usb_phy *usb_get_phy(struct device *dev, u8 index);
 extern struct usb_phy *devm_usb_get_phy(struct device *dev, u8 index);
+extern struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+   const char *phandle, u8 index);
 extern void usb_put_phy(struct usb_phy *);
 extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
 extern struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 index,
@@ -178,6 +180,12 @@ static inline struct usb_phy *devm_usb_get_phy(struct 
device *dev, u8 index)
return NULL;
 }
 
+static inline struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+   const char *phandle, u8 index)
+{
+   return NULL;
+}
+
 static inline void usb_put_phy(struct usb_phy *x)
 {
 }
-- 
1.7.9.5

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


[RFC PATCH 2/6] ARM: OMAP: USB: Add phy binding information

2013-01-16 Thread Kishon Vijay Abraham I
This is in preparation for the changes in PHY library to support adding
and getting multiple PHYs of the same type. In the new design, the
binding information between the PHY and the USB controller should be
specified in the platform specific initialization code. So it's been
done for OMAP platforms here.

Signed-off-by: Kishon Vijay Abraham I 
---
This kind-of binding should be done in all the platforms (I've done only
for OMAP platform). 
 arch/arm/mach-omap2/usb-musb.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 9d27e3f..bbe2fa5 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "omap_device.h"
 #include "soc.h"
@@ -85,8 +86,12 @@ void __init usb_musb_init(struct omap_musb_board_data 
*musb_board_data)
musb_plat.mode = board_data->mode;
musb_plat.extvbus = board_data->extvbus;
 
-   if (cpu_is_omap44xx())
+   if (cpu_is_omap44xx()) {
musb_plat.has_mailbox = true;
+   usb_bind_phy("musb-hdrc.0.auto", 0, "omap-usb2.1.auto");
+   } else if (cpu_is_omap34xx()) {
+   usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
+   }
 
if (soc_is_am35xx()) {
oh_name = "am35x_otg_hs";
-- 
1.7.9.5

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


[RFC PATCH 4/6] ARM: dts: OMAP: Add phandle to bind PHY with USB controller

2013-01-16 Thread Kishon Vijay Abraham I
Added a phandle in the dt node for usb_otg to bind the PHY with the USB
controller and also updated the documentation with the binding information.

Signed-off-by: Kishon Vijay Abraham I 
---
I'll add this patch in this series "usb: musb: add driver for control module"
which contains the dt data to get MUSB working in dt boot in OMAP platforms.
 Documentation/devicetree/bindings/usb/omap-usb.txt |2 ++
 arch/arm/boot/dts/omap3.dtsi   |1 +
 arch/arm/boot/dts/omap4.dtsi   |3 ++-
 arch/arm/boot/dts/twl4030.dtsi |2 +-
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 3f0152b..591c4fc 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -18,6 +18,7 @@ OMAP MUSB GLUE
represents PERIPHERAL.
  - power : Should be "50". This signifies the controller can supply upto
100mA when operating in host mode.
+ - usb_phy : the phandle for the PHY device
 
 SOC specific device node entry
 usb_otg_hs: usb_otg_hs@4a0ab000 {
@@ -27,6 +28,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
multipoint = <1>;
num_eps = <16>;
ram_bits = <12>;
+   usb_phy = <&phy>;
 };
 
 Board specific device node entry
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 8d03736..ebbf596 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -404,6 +404,7 @@
interrupts = <0 92 0x4>, <0 93 0x4>;
interrupt-names = "mc", "dma";
ti,hwmods = "usb_otg_hs";
+   usb_phy = <&phy>;
multipoint = <1>;
num_eps = <16>;
ram_bits = <12>;
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 5d770be..531cb2d 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -438,7 +438,7 @@
#size-cells = <1>;
ranges;
ti,hwmods = "ocp2scp_usb_phy";
-   usb2phy@4a0ad080 {
+   phy: usb2phy@4a0ad080 {
compatible = "ti,omap-usb2";
reg = <0x4a0ad080 0x58>;
};
@@ -540,6 +540,7 @@
interrupts = <0 92 0x4>, <0 93 0x4>;
interrupt-names = "mc", "dma";
ti,hwmods = "usb_otg_hs";
+   usb_phy = <&phy>;
multipoint = <1>;
num_eps = <16>;
ram_bits = <12>;
diff --git a/arch/arm/boot/dts/twl4030.dtsi b/arch/arm/boot/dts/twl4030.dtsi
index ed0bc95..80f7c2b 100644
--- a/arch/arm/boot/dts/twl4030.dtsi
+++ b/arch/arm/boot/dts/twl4030.dtsi
@@ -67,7 +67,7 @@
#interrupt-cells = <1>;
};
 
-   twl4030-usb {
+   phy: twl4030-usb {
compatible = "ti,twl4030-usb";
interrupts = <10>, <4>;
usb1v5-supply = <&vusb1v5>;
-- 
1.7.9.5

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


Re: Linux 3.8-rc1 - another regression on USB :-(

2013-01-16 Thread Alan Stern
On Tue, 15 Jan 2013, Woody Suwalski wrote:

> > Another important change is that the EHCI driver is now split into two
> > modules.  That can slow down loading and affect the timing.
> >
> > Alan Stern
> >
> My testcase is a live initramfs + squash root.
> The boot logic is as stable as can be - unchanged since 2.6.2x kernels.
> And it was working fine till 3.8-rc1.
> 
> The modules are insmoded in a fixed order:
> usb-common, usbcore, xhci-hcd, ehci-hcd, uhci-hcd, ohci-hcd, usbhid, 
> usb_storage,...

But apparently you don't insmod ehci-pci.  That could cause problems, 
if your EHCI controller is PCI-based.

> If all USB is built as modules - I get read errors from USB drives when 
> accessing squash image, boot fails.

What read errors?  What is the cause of these errors?

> If usb-common and usbcore are built in, system seems to crawl with a 
> very slow USB, but boots. That could be caused by timing between hcd 
> modules.

Do have a dmesg log with timestamps so we can see where things go slow?  
I suggest enabling CONFIG_PRINTK_TIME and CONFIG_USB_DEBUG.  You might
even want CONFIG_USB_STORAGE_DEBUG, although that often logs too much
information.

> If usb-common, usbcore and ehci-hcd are built-in, all works OK like 
> "before 3.8".

What about ehci-pci?

> I was testing on machines  without xhci or ohci hardware, so these 
> drivers probably are not playing any role.
> I have retried initramfs with a 1s sleep between insmods to verify if it 
> is timing - still the same read errors - so the main issue is _not_ timing.
> The read errors problem is 100% reproducible for me, the blocks where 
> read fails are not fixed - every (failed) boot errors start appearing in 
> a bit different location.
> Just selecting a differently - configured  kernel image makes the boot 
> work, so it is not a problem of squash image, USB drive, squashfs driver.

Without knowing what these read errors are, it's hard to say anything 
about them.

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 v6 04/22] mfd: omap-usb-tll: Clean up clock handling

2013-01-16 Thread Russell King - ARM Linux
On Wed, Jan 16, 2013 at 04:43:35PM +0200, Roger Quadros wrote:
> + spin_lock_irqsave(&tll->lock, flags);
> +
> + for (i = 0; i < tll->nch; i++) {
> + char clkname[] = "usb_tll_hs_usb_chx_clk";
> + struct clk *fck;
> +
> + snprintf(clkname, sizeof(clkname),
> + "usb_tll_hs_usb_ch%d_clk", i);
> + fck = clk_get(dev, clkname);

NAK.  Why are you doing this under a spinlock?

clk_get() takes a mutex.  You must not be in an atomic region (iow, you
must not be holding a spinlock, and you must not have IRQs disabled)
when you call clk_get().
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 02/22] mfd: omap-usb-tll: Fix channel count detection

2013-01-16 Thread Roger Quadros
Fix channel count detecion for REV2. Also, don't give up
if we don't recognize the IP Revision. We assume the default
number of channels (i.e. 3) for unrecognized IPs.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index e459489..9658e18 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -98,6 +98,7 @@
 struct usbtll_omap {
struct clk  *usbtll_p1_fck;
struct clk  *usbtll_p2_fck;
+   int nch;/* num. of channels */
struct usbhs_omap_platform_data *pdata;
/* secure the register updates */
spinlock_t  lock;
@@ -210,7 +211,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
unsignedreg;
unsigned long   flags;
int ret = 0;
-   int i, ver, count;
+   int i, ver;
 
dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
 
@@ -262,16 +263,18 @@ static int usbtll_omap_probe(struct platform_device *pdev)
ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
-   case OMAP_USBTLL_REV2:
-   count = OMAP_TLL_CHANNEL_COUNT;
+   tll->nch = OMAP_TLL_CHANNEL_COUNT;
break;
+   case OMAP_USBTLL_REV2:
case OMAP_USBTLL_REV3:
-   count = OMAP_REV2_TLL_CHANNEL_COUNT;
+   tll->nch = OMAP_REV2_TLL_CHANNEL_COUNT;
break;
default:
-   dev_err(dev, "TLL version failed\n");
-   ret = -ENODEV;
-   goto err_ioremap;
+   tll->nch = OMAP_TLL_CHANNEL_COUNT;
+   dev_dbg(dev,
+"USB TLL Rev : 0x%x not recognized, assuming %d channels\n",
+   ver, tll->nch);
+   break;
}
 
if (is_ehci_tll_mode(pdata->port_mode[0]) ||
@@ -291,7 +294,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
usbtll_write(base, OMAP_TLL_SHARED_CONF, reg);
 
/* Enable channels now */
-   for (i = 0; i < count; i++) {
+   for (i = 0; i < tll->nch; i++) {
reg = usbtll_read(base, OMAP_TLL_CHANNEL_CONF(i));
 
if (is_ohci_port(pdata->port_mode[i])) {
@@ -319,7 +322,6 @@ static int usbtll_omap_probe(struct platform_device *pdev)
}
}
 
-err_ioremap:
spin_unlock_irqrestore(&tll->lock, flags);
iounmap(base);
pm_runtime_put_sync(dev);
-- 
1.7.4.1

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


[PATCH v6 01/22] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data

2013-01-16 Thread Roger Quadros
Let's have a single platform data structure for the OMAP's High-Speed
USB host subsystem instead of having 3 separate ones i.e. one for
board data, one for USB Host (UHH) module and one for USB-TLL module.

This makes the code much simpler and avoids creating multiple copies of
platform data.

Signed-off-by: Roger Quadros 
---
 arch/arm/mach-omap2/board-3430sdp.c|2 +-
 arch/arm/mach-omap2/board-3630sdp.c|2 +-
 arch/arm/mach-omap2/board-am3517crane.c|2 +-
 arch/arm/mach-omap2/board-am3517evm.c  |2 +-
 arch/arm/mach-omap2/board-cm-t35.c |2 +-
 arch/arm/mach-omap2/board-cm-t3517.c   |2 +-
 arch/arm/mach-omap2/board-devkit8000.c |2 +-
 arch/arm/mach-omap2/board-igep0020.c   |4 +-
 arch/arm/mach-omap2/board-omap3beagle.c|2 +-
 arch/arm/mach-omap2/board-omap3evm.c   |2 +-
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +-
 arch/arm/mach-omap2/board-omap3stalker.c   |2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c |2 +-
 arch/arm/mach-omap2/board-overo.c  |2 +-
 arch/arm/mach-omap2/board-zoom.c   |2 +-
 arch/arm/mach-omap2/usb-host.c |   29 ++---
 arch/arm/mach-omap2/usb.h  |   20 +
 drivers/mfd/omap-usb-host.c|   63 +++
 drivers/mfd/omap-usb-tll.c |   11 ++---
 drivers/usb/host/ehci-omap.c   |8 ++--
 include/linux/platform_data/usb-omap.h |   23 ++
 22 files changed, 62 insertions(+), 126 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index bb73afc..46147c8 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -424,7 +424,7 @@ static void enable_board_wakeup_source(void)
OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
 }
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-3630sdp.c 
b/arch/arm/mach-omap2/board-3630sdp.c
index 050aaa7..78b1724 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -53,7 +53,7 @@ static void enable_board_wakeup_source(void)
OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
 }
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-am3517crane.c 
b/arch/arm/mach-omap2/board-am3517crane.c
index 51b96a1..26f1916 100644
--- a/arch/arm/mach-omap2/board-am3517crane.c
+++ b/arch/arm/mach-omap2/board-am3517crane.c
@@ -40,7 +40,7 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct usbhs_omap_board_data usbhs_bdata __initdata = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index f81a303..c76725d 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -274,7 +274,7 @@ static __init void am3517_evm_mcbsp1_init(void)
omap_ctrl_writel(devconf0, OMAP2_CONTROL_DEVCONF0);
 }
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index b3102c2..cdf1d6e 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -418,7 +418,7 @@ static struct omap2_hsmmc_info mmc[] = {
{}  /* Terminator */
 };
 
-static struct usbhs_omap_board_data usbhs_bdata __initdata = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-cm-t3517.c 
b/arch/arm/mach-omap2/board-cm-t3517.c
index ebbc2ad..cfa9098 100644
--- a/arch/arm/mach-omap2/board-cm-t3517.c
+++ b/arch/arm/mach-omap2/board-cm-t3517.c
@@ -166,7 +166,7 @@ static inline void cm_t3517_init_rtc(void) {}
 #define HSUSB2_RESET_GPIO  (147)
 #define USB_HUB_RESET_GPIO (152)
 
-static struct usbhs_omap_board_data cm_t3517_ehci_pdata __initdata = {
+s

[PATCH v6 04/22] mfd: omap-usb-tll: Clean up clock handling

2013-01-16 Thread Roger Quadros
Every channel has a functional clock that is similarly named.
It makes sense to use a for loop to manage these clocks as OMAPs
can come with up to 3 channels.

Dynamically allocate and get channel clocks depending on the
number of clocks avaiable on the platform.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   89 +++
 1 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 53ed10b..8f45322 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -96,10 +96,9 @@
 #define is_ehci_tll_mode(x)(x == OMAP_EHCI_PORT_MODE_TLL)
 
 struct usbtll_omap {
-   struct clk  *usbtll_p1_fck;
-   struct clk  *usbtll_p2_fck;
int nch;/* num. of channels */
struct usbhs_omap_platform_data *pdata;
+   struct clk  **ch_clk;
/* secure the register updates */
spinlock_t  lock;
 };
@@ -225,26 +224,12 @@ static int usbtll_omap_probe(struct platform_device *pdev)
 
tll->pdata = pdata;
 
-   tll->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk");
-   if (IS_ERR(tll->usbtll_p1_fck)) {
-   ret = PTR_ERR(tll->usbtll_p1_fck);
-   dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret);
-   return ret;
-   }
-
-   tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk");
-   if (IS_ERR(tll->usbtll_p2_fck)) {
-   ret = PTR_ERR(tll->usbtll_p2_fck);
-   dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret);
-   goto err_p2_fck;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_request_and_ioremap(dev, res);
if (!base) {
ret = -ENOMEM;
dev_err(dev, "Resource request/ioremap failed:%d\n", ret);
-   goto err_res;
+   return ret;
}
 
platform_set_drvdata(pdev, tll);
@@ -270,6 +255,32 @@ static int usbtll_omap_probe(struct platform_device *pdev)
break;
}
 
+   spin_unlock_irqrestore(&tll->lock, flags);
+
+   tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]),
+   GFP_KERNEL);
+   if (!tll->ch_clk) {
+   ret = -ENOMEM;
+   dev_err(dev, "Couldn't allocate memory for channel clocks\n");
+   goto err_clk_alloc;
+   }
+
+   spin_lock_irqsave(&tll->lock, flags);
+
+   for (i = 0; i < tll->nch; i++) {
+   char clkname[] = "usb_tll_hs_usb_chx_clk";
+   struct clk *fck;
+
+   snprintf(clkname, sizeof(clkname),
+   "usb_tll_hs_usb_ch%d_clk", i);
+   fck = clk_get(dev, clkname);
+
+   if (IS_ERR(fck))
+   dev_dbg(dev, "can't get clock : %s\n", clkname);
+   else
+   tll->ch_clk[i] = fck;
+   }
+
if (is_ehci_tll_mode(pdata->port_mode[0]) ||
is_ehci_tll_mode(pdata->port_mode[1]) ||
is_ehci_tll_mode(pdata->port_mode[2]) ||
@@ -321,11 +332,9 @@ static int usbtll_omap_probe(struct platform_device *pdev)
 
return 0;
 
-err_res:
-   clk_put(tll->usbtll_p2_fck);
-
-err_p2_fck:
-   clk_put(tll->usbtll_p1_fck);
+err_clk_alloc:
+   pm_runtime_put_sync(dev);
+   pm_runtime_disable(dev);
 
return ret;
 }
@@ -339,9 +348,11 @@ err_p2_fck:
 static int usbtll_omap_remove(struct platform_device *pdev)
 {
struct usbtll_omap *tll = platform_get_drvdata(pdev);
+   int i;
+
+   for (i = 0; i < tll->nch; i++)
+   clk_put(tll->ch_clk[i]);
 
-   clk_put(tll->usbtll_p2_fck);
-   clk_put(tll->usbtll_p1_fck);
pm_runtime_disable(&pdev->dev);
return 0;
 }
@@ -351,6 +362,7 @@ static int usbtll_runtime_resume(struct device *dev)
struct usbtll_omap  *tll = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = tll->pdata;
unsigned long   flags;
+   int i;
 
dev_dbg(dev, "usbtll_runtime_resume\n");
 
@@ -361,11 +373,20 @@ static int usbtll_runtime_resume(struct device *dev)
 
spin_lock_irqsave(&tll->lock, flags);
 
-   if (is_ehci_tll_mode(pdata->port_mode[0]))
-   clk_enable(tll->usbtll_p1_fck);
+   for (i = 0; i < tll->nch; i++) {
+   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   int r;
+
+   if (!tll->ch_clk[i])
+   continue;
 
-   if (is_ehci_tll_mode(pdata->port_mode[1]))
-   clk_enable(tll->usbtll_p2_fck);
+   r = clk_enable(tll->ch_clk[i]);
+   if (r) {

[PATCH v6 03/22] mfd: omap-usb-tll: Use devm_kzalloc/ioremap and clean up error path

2013-01-16 Thread Roger Quadros
Use devm_ variants of kzalloc() and ioremap(). Simplify the error path.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   36 +++-
 1 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 9658e18..53ed10b 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -215,11 +215,10 @@ static int usbtll_omap_probe(struct platform_device *pdev)
 
dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
 
-   tll = kzalloc(sizeof(struct usbtll_omap), GFP_KERNEL);
+   tll = devm_kzalloc(dev, sizeof(struct usbtll_omap), GFP_KERNEL);
if (!tll) {
dev_err(dev, "Memory allocation failed\n");
-   ret = -ENOMEM;
-   goto end;
+   return -ENOMEM;
}
 
spin_lock_init(&tll->lock);
@@ -230,28 +229,22 @@ static int usbtll_omap_probe(struct platform_device *pdev)
if (IS_ERR(tll->usbtll_p1_fck)) {
ret = PTR_ERR(tll->usbtll_p1_fck);
dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret);
-   goto err_tll;
+   return ret;
}
 
tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk");
if (IS_ERR(tll->usbtll_p2_fck)) {
ret = PTR_ERR(tll->usbtll_p2_fck);
dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret);
-   goto err_usbtll_p1_fck;
+   goto err_p2_fck;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(dev, "usb tll get resource failed\n");
-   ret = -ENODEV;
-   goto err_usbtll_p2_fck;
-   }
-
-   base = ioremap(res->start, resource_size(res));
+   base = devm_request_and_ioremap(dev, res);
if (!base) {
-   dev_err(dev, "TLL ioremap failed\n");
ret = -ENOMEM;
-   goto err_usbtll_p2_fck;
+   dev_err(dev, "Resource request/ioremap failed:%d\n", ret);
+   goto err_res;
}
 
platform_set_drvdata(pdev, tll);
@@ -323,23 +316,17 @@ static int usbtll_omap_probe(struct platform_device *pdev)
}
 
spin_unlock_irqrestore(&tll->lock, flags);
-   iounmap(base);
pm_runtime_put_sync(dev);
tll_pdev = pdev;
-   if (!ret)
-   goto end;
-   pm_runtime_disable(dev);
 
-err_usbtll_p2_fck:
+   return 0;
+
+err_res:
clk_put(tll->usbtll_p2_fck);
 
-err_usbtll_p1_fck:
+err_p2_fck:
clk_put(tll->usbtll_p1_fck);
 
-err_tll:
-   kfree(tll);
-
-end:
return ret;
 }
 
@@ -356,7 +343,6 @@ static int usbtll_omap_remove(struct platform_device *pdev)
clk_put(tll->usbtll_p2_fck);
clk_put(tll->usbtll_p1_fck);
pm_runtime_disable(&pdev->dev);
-   kfree(tll);
return 0;
 }
 
-- 
1.7.4.1

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


[PATCH v6 00/22] OMAP USB Host cleanup

2013-01-16 Thread Roger Quadros
Hi,

This patchset addresses the following

- Consolidate USB Host platform data.
- Avoid addressing clocks one by one by name and use a for loop + bunch
  of cleanups.
- Get number of channels/ports dynamically either from revision register
  or from platform data. Avoids getting clocks that are not present.
- Add OMAP5 and HSIC mode (Not tested)

v6:
- Added USB Host platform data consolidation patch as the first patch
  based on request from Tony.
- Rebased on v3.8-rc3

v5:
- Rebased on top of todays arm-soc/for-next
- Removed the clock merging patch from the list.
- Updated patches 14, 19 and 20 to accomodate the above change.
- Added patch 22 to fix a build warning.

v4:
- Added appropriate maintainers in to/cc
- minor print message fix in patch 23 to maintain consistency

v3:
- Rebased on arm-soc/for-next commit f979306c4d38d213c6977aaf3b1115e8ded71e3a
- Rearranged patch that get rids of cpu_is_omap..() macros
- Coding style fixes

v2:
- Clocks are allocated dynamically based on number of ports available
  on the platform
- Reduced console spam if non critical clocks are not found on the platform.
- Get rid of cpu_is_.. macros from USB host driver.

cheers,
-roger

The following changes since commit 9931faca02c604c22335f5a935a501bb2ace6e20:

  Linux 3.8-rc3 (2013-01-09 18:59:55 -0800)

are available in the git repository at:
  g...@github.com:rogerq/linux.git linux-usbhost11-part

Roger Quadros (22):
  mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  mfd: omap-usb-tll: Fix channel count detection
  mfd: omap-usb-tll: Use devm_kzalloc/ioremap and clean up error path
  mfd: omap-usb-tll: Clean up clock handling
  mfd: omap-usb-tll: introduce and use mode_needs_tll()
  mfd: omap-usb-tll: Check for missing platform data in probe
  mfd: omap-usb-tll: Fix error message
  mfd: omap-usb-tll: serialize access to TLL device
  mfd: omap-usb-tll: Add OMAP5 revision and HSIC support
  mfd: omap_usb_host: Avoid missing platform data checks in
suspend/resume
  mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap()
  mfd: omap-usb-host: know about number of ports from revision register
  mfd: omap-usb-host: override number of ports from platform data
  mfd: omap-usb-host: cleanup clock management code
  mfd: omap-usb-host: Manage HSIC clocks for HSIC mode
  mfd: omap-usb-host: Get rid of unnecessary spinlock
  mfd: omap-usb-host: clean up omap_usbhs_init()
  USB: ehci-omap: Don't free gpios that we didn't request
  ARM: OMAP3: clock data: get rid of unused USB host clock aliases and
dummies
  ARM: OMAP4: clock data: get rid of unused USB host clock aliases
  mfd: omap-usb-host: Don't spam console on clk_set_parent failure
  mdf: omap-usb-host: get rid of build warning

 arch/arm/mach-omap2/board-3430sdp.c|2 +-
 arch/arm/mach-omap2/board-3630sdp.c|2 +-
 arch/arm/mach-omap2/board-am3517crane.c|2 +-
 arch/arm/mach-omap2/board-am3517evm.c  |2 +-
 arch/arm/mach-omap2/board-cm-t35.c |2 +-
 arch/arm/mach-omap2/board-cm-t3517.c   |2 +-
 arch/arm/mach-omap2/board-devkit8000.c |2 +-
 arch/arm/mach-omap2/board-igep0020.c   |4 +-
 arch/arm/mach-omap2/board-omap3beagle.c|2 +-
 arch/arm/mach-omap2/board-omap3evm.c   |2 +-
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +-
 arch/arm/mach-omap2/board-omap3stalker.c   |2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c |2 +-
 arch/arm/mach-omap2/board-overo.c  |2 +-
 arch/arm/mach-omap2/board-zoom.c   |2 +-
 arch/arm/mach-omap2/cclock3xxx_data.c  |   11 -
 arch/arm/mach-omap2/cclock44xx_data.c  |7 -
 arch/arm/mach-omap2/usb-host.c |   29 +--
 arch/arm/mach-omap2/usb.h  |   20 +-
 drivers/mfd/omap-usb-host.c|  543 
 drivers/mfd/omap-usb-tll.c |  243 +++--
 drivers/usb/host/ehci-omap.c   |   14 +-
 include/linux/platform_data/usb-omap.h |   24 +-
 24 files changed, 484 insertions(+), 441 deletions(-)

-- 
1.7.4.1

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


[PATCH v6 07/22] mfd: omap-usb-tll: Fix error message

2013-01-16 Thread Roger Quadros
omap_enable/disable_tll() can fail if TLL device is not
initialized. It could be due to multiple reasons and not only
due to missing platform data.

Also make local variables static and use 'struct device *'
instead of 'struct platform_device *' for global reference.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   21 -
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index b9f372d..8628313 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -109,8 +109,8 @@ struct usbtll_omap {
 
 /*-*/
 
-const char usbtll_driver_name[] = USBTLL_DRIVER_NAME;
-struct platform_device *tll_pdev;
+static const char usbtll_driver_name[] = USBTLL_DRIVER_NAME;
+static struct device   *tll_dev;
 
 /*-*/
 
@@ -337,7 +337,8 @@ static int usbtll_omap_probe(struct platform_device *pdev)
 
spin_unlock_irqrestore(&tll->lock, flags);
pm_runtime_put_sync(dev);
-   tll_pdev = pdev;
+   /* only after this can omap_tll_enable/disable work */
+   tll_dev = dev;
 
return 0;
 
@@ -359,6 +360,8 @@ static int usbtll_omap_remove(struct platform_device *pdev)
struct usbtll_omap *tll = platform_get_drvdata(pdev);
int i;
 
+   tll_dev = NULL;
+
for (i = 0; i < tll->nch; i++)
clk_put(tll->ch_clk[i]);
 
@@ -438,21 +441,21 @@ static struct platform_driver usbtll_omap_driver = {
 
 int omap_tll_enable(void)
 {
-   if (!tll_pdev) {
-   pr_err("missing omap usbhs tll platform_data\n");
+   if (!tll_dev) {
+   pr_err("%s: OMAP USB TLL not initialized\n", __func__);
return  -ENODEV;
}
-   return pm_runtime_get_sync(&tll_pdev->dev);
+   return pm_runtime_get_sync(tll_dev);
 }
 EXPORT_SYMBOL_GPL(omap_tll_enable);
 
 int omap_tll_disable(void)
 {
-   if (!tll_pdev) {
-   pr_err("missing omap usbhs tll platform_data\n");
+   if (!tll_dev) {
+   pr_err("%s: OMAP USB TLL not initialized\n", __func__);
return  -ENODEV;
}
-   return pm_runtime_put_sync(&tll_pdev->dev);
+   return pm_runtime_put_sync(tll_dev);
 }
 EXPORT_SYMBOL_GPL(omap_tll_disable);
 
-- 
1.7.4.1

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


[PATCH v6 06/22] mfd: omap-usb-tll: Check for missing platform data in probe

2013-01-16 Thread Roger Quadros
No need to check for missing platform data in runtime_suspend/resume
as it makes more sense to do it in the probe function.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   15 +--
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 7e55a83..b9f372d 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -225,6 +225,11 @@ static int usbtll_omap_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
+   if (!pdata) {
+   dev_err(dev, "Platform data missing\n");
+   return -ENODEV;
+   }
+
spin_lock_init(&tll->lock);
 
tll->pdata = pdata;
@@ -370,11 +375,6 @@ static int usbtll_runtime_resume(struct device *dev)
 
dev_dbg(dev, "usbtll_runtime_resume\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
spin_lock_irqsave(&tll->lock, flags);
 
for (i = 0; i < tll->nch; i++) {
@@ -406,11 +406,6 @@ static int usbtll_runtime_suspend(struct device *dev)
 
dev_dbg(dev, "usbtll_runtime_suspend\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
spin_lock_irqsave(&tll->lock, flags);
 
for (i = 0; i < tll->nch; i++) {
-- 
1.7.4.1

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


[PATCH v6 10/22] mfd: omap_usb_host: Avoid missing platform data checks in suspend/resume

2013-01-16 Thread Roger Quadros
Get rid of the unnecessary missing platform data checks
in runtime_suspend/resume. We are already checking for missing
platform data in probe.

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index d6e6b8c..061366d 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -277,11 +277,6 @@ static int usbhs_runtime_resume(struct device *dev)
 
dev_dbg(dev, "usbhs_runtime_resume\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
omap_tll_enable();
spin_lock_irqsave(&omap->lock, flags);
 
@@ -309,11 +304,6 @@ static int usbhs_runtime_suspend(struct device *dev)
 
dev_dbg(dev, "usbhs_runtime_suspend\n");
 
-   if (!pdata) {
-   dev_dbg(dev, "missing platform_data\n");
-   return  -ENODEV;
-   }
-
spin_lock_irqsave(&omap->lock, flags);
 
if (is_ehci_tll_mode(pdata->port_mode[0]))
-- 
1.7.4.1

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


[PATCH v6 13/22] mfd: omap-usb-host: override number of ports from platform data

2013-01-16 Thread Roger Quadros
Both OMAP4 and 5 exhibit the same revision ID in the REVISION register
but they have different number of ports i.e. 2 and 3 respectively.
So we can't rely on REVISION register for number of ports on OMAP5
and depend on platform data (or device tree) instead.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-host.c|   34 +++
 include/linux/platform_data/usb-omap.h |1 +
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 0ab6801..65d2ab4 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -493,19 +493,27 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 */
pm_runtime_put_sync(dev);
 
-   switch (omap->usbhs_rev) {
-   case OMAP_USBHS_REV1:
-   omap->nports = 3;
-   break;
-   case OMAP_USBHS_REV2:
-   omap->nports = 2;
-   break;
-   default:
-   omap->nports = OMAP3_HS_USB_PORTS;
-   dev_dbg(dev,
- "USB HOST Rev : 0x%d not recognized, assuming %d ports\n",
-  omap->usbhs_rev, omap->nports);
-   break;
+   /*
+* If platform data contains nports then use that
+* else make out number of ports from USBHS revision
+*/
+   if (pdata->nports) {
+   omap->nports = pdata->nports;
+   } else {
+   switch (omap->usbhs_rev) {
+   case OMAP_USBHS_REV1:
+   omap->nports = 3;
+   break;
+   case OMAP_USBHS_REV2:
+   omap->nports = 2;
+   break;
+   default:
+   omap->nports = OMAP3_HS_USB_PORTS;
+   dev_dbg(dev,
+"USB HOST Rev:0x%d not recognized, assuming %d 
ports\n",
+omap->usbhs_rev, omap->nports);
+   break;
+   }
}
 
for (i = 0; i < omap->nports; i++)
diff --git a/include/linux/platform_data/usb-omap.h 
b/include/linux/platform_data/usb-omap.h
index 04c7537..925a4a7 100644
--- a/include/linux/platform_data/usb-omap.h
+++ b/include/linux/platform_data/usb-omap.h
@@ -39,6 +39,7 @@ enum usbhs_omap_port_mode {
 };
 
 struct usbhs_omap_platform_data {
+   int nports;
enum usbhs_omap_port_mode   port_mode[OMAP3_HS_USB_PORTS];
int reset_gpio_port[OMAP3_HS_USB_PORTS];
struct regulator*regulator[OMAP3_HS_USB_PORTS];
-- 
1.7.4.1

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


[PATCH v6 12/22] mfd: omap-usb-host: know about number of ports from revision register

2013-01-16 Thread Roger Quadros
The revision register should tell us how many ports are present.

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 0f190b6..0ab6801 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -91,6 +91,8 @@
 
 
 struct usbhs_hcd_omap {
+   int nports;
+
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
struct clk  *utmi_p1_fck;
@@ -347,8 +349,6 @@ static void omap_usbhs_init(struct device *dev)
 
pm_runtime_get_sync(dev);
spin_lock_irqsave(&omap->lock, flags);
-   omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
-   dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
 
reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
/* setup ULPI bypass and burst configurations */
@@ -483,7 +483,32 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
pm_runtime_enable(dev);
 
-   for (i = 0; i < OMAP3_HS_USB_PORTS; i++)
+   platform_set_drvdata(pdev, omap);
+   pm_runtime_get_sync(dev);
+
+   omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
+
+   /* we need to call runtime suspend before we update omap->nports
+* to prevent unbalanced clk_disable()
+*/
+   pm_runtime_put_sync(dev);
+
+   switch (omap->usbhs_rev) {
+   case OMAP_USBHS_REV1:
+   omap->nports = 3;
+   break;
+   case OMAP_USBHS_REV2:
+   omap->nports = 2;
+   break;
+   default:
+   omap->nports = OMAP3_HS_USB_PORTS;
+   dev_dbg(dev,
+ "USB HOST Rev : 0x%d not recognized, assuming %d ports\n",
+  omap->usbhs_rev, omap->nports);
+   break;
+   }
+
+   for (i = 0; i < omap->nports; i++)
if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) ||
is_ehci_hsic_mode(i)) {
omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck");
@@ -573,8 +598,6 @@ static int usbhs_omap_probe(struct platform_device *pdev)
"failed error:%d\n", ret);
}
 
-   platform_set_drvdata(pdev, omap);
-
omap_usbhs_init(dev);
ret = omap_usbhs_alloc_children(pdev);
if (ret) {
-- 
1.7.4.1

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


[PATCH v6 11/22] mfd: omap-usb-host: Use devm_kzalloc() and devm_request_and_ioremap()

2013-01-16 Thread Roger Quadros
Use devm_ variants of kzalloc and ioremap. Also clean up error path.

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 061366d..0f190b6 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -461,15 +461,20 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
if (!pdata) {
dev_err(dev, "Missing platform data\n");
-   ret = -ENOMEM;
-   goto end_probe;
+   return -ENODEV;
}
 
-   omap = kzalloc(sizeof(*omap), GFP_KERNEL);
+   omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL);
if (!omap) {
dev_err(dev, "Memory allocation failed\n");
-   ret = -ENOMEM;
-   goto end_probe;
+   return -ENOMEM;
+   }
+
+   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
+   omap->uhh_base = devm_request_and_ioremap(dev, res);
+   if (!omap->uhh_base) {
+   dev_err(dev, "Resource request/ioremap failed\n");
+   return -ENOMEM;
}
 
spin_lock_init(&omap->lock);
@@ -568,20 +573,6 @@ static int usbhs_omap_probe(struct platform_device *pdev)
"failed error:%d\n", ret);
}
 
-   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "uhh");
-   if (!res) {
-   dev_err(dev, "UHH EHCI get resource failed\n");
-   ret = -ENODEV;
-   goto err_init_60m_fclk;
-   }
-
-   omap->uhh_base = ioremap(res->start, resource_size(res));
-   if (!omap->uhh_base) {
-   dev_err(dev, "UHH ioremap failed\n");
-   ret = -ENOMEM;
-   goto err_init_60m_fclk;
-   }
-
platform_set_drvdata(pdev, omap);
 
omap_usbhs_init(dev);
@@ -591,13 +582,10 @@ static int usbhs_omap_probe(struct platform_device *pdev)
goto err_alloc;
}
 
-   goto end_probe;
+   return 0;
 
 err_alloc:
omap_usbhs_deinit(&pdev->dev);
-   iounmap(omap->uhh_base);
-
-err_init_60m_fclk:
clk_put(omap->init_60m_fclk);
 
 err_usbhost_p2_fck:
@@ -621,9 +609,7 @@ err_utmi_p1_fck:
 err_end:
clk_put(omap->ehci_logic_fck);
pm_runtime_disable(dev);
-   kfree(omap);
 
-end_probe:
return ret;
 }
 
@@ -638,7 +624,6 @@ static int usbhs_omap_remove(struct platform_device *pdev)
struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
 
omap_usbhs_deinit(&pdev->dev);
-   iounmap(omap->uhh_base);
clk_put(omap->init_60m_fclk);
clk_put(omap->usbhost_p2_fck);
clk_put(omap->usbhost_p1_fck);
@@ -648,7 +633,6 @@ static int usbhs_omap_remove(struct platform_device *pdev)
clk_put(omap->utmi_p1_fck);
clk_put(omap->ehci_logic_fck);
pm_runtime_disable(&pdev->dev);
-   kfree(omap);
 
return 0;
 }
-- 
1.7.4.1

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


[PATCH v6 09/22] mfd: omap-usb-tll: Add OMAP5 revision and HSIC support

2013-01-16 Thread Roger Quadros
The TLL module on OMAP5 has 3 channels.
HSIC mode requires the TLL channel to be in Transparent UTMI mode.

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

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 031f4fd..c5ac8c2 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -54,10 +54,13 @@
 
 #defineOMAP_TLL_CHANNEL_CONF(num)  (0x040 + 0x004 
* num)
 #define OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT   24
+#define OMAP_TLL_CHANNEL_CONF_DRVVBUS  (1 << 16)
+#define OMAP_TLL_CHANNEL_CONF_CHRGVBUS (1 << 15)
 #defineOMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF(1 << 11)
 #defineOMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10)
 #defineOMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE  (1 << 9)
 #defineOMAP_TLL_CHANNEL_CONF_ULPIDDRMODE   (1 << 8)
+#define OMAP_TLL_CHANNEL_CONF_MODE_TRANSPARENT_UTMI(2 << 1)
 #define OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS(1 << 1)
 #defineOMAP_TLL_CHANNEL_CONF_CHANEN(1 << 0)
 
@@ -92,6 +95,7 @@
 #define OMAP_USBTLL_REV1   0x0015  /* OMAP3 */
 #define OMAP_USBTLL_REV2   0x0018  /* OMAP 3630 */
 #define OMAP_USBTLL_REV3   0x0004  /* OMAP4 */
+#define OMAP_USBTLL_REV4   0x0006  /* OMAP5 */
 
 #define is_ehci_tll_mode(x)(x == OMAP_EHCI_PORT_MODE_TLL)
 
@@ -245,6 +249,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
+   case OMAP_USBTLL_REV4:
tll->nch = OMAP_TLL_CHANNEL_COUNT;
break;
case OMAP_USBTLL_REV2:
@@ -313,6 +318,15 @@ static int usbtll_omap_probe(struct platform_device *pdev)
reg &= ~(OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE
| OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF
| OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE);
+   } else if (pdata->port_mode[i] ==
+   OMAP_EHCI_PORT_MODE_HSIC) {
+   /*
+* HSIC Mode requires UTMI port configurations
+*/
+   reg |= OMAP_TLL_CHANNEL_CONF_DRVVBUS
+| OMAP_TLL_CHANNEL_CONF_CHRGVBUS
+| OMAP_TLL_CHANNEL_CONF_MODE_TRANSPARENT_UTMI
+| OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF;
} else {
continue;
}
-- 
1.7.4.1

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


[PATCH v6 08/22] mfd: omap-usb-tll: serialize access to TLL device

2013-01-16 Thread Roger Quadros
Get rid of the unnecessary spin_lock_irqsave/restore() as there is
no interrupt handler for this driver. Instead we serialize access
to tll_dev using a global spinlock.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   53 ++-
 1 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 8628313..031f4fd 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -103,14 +103,13 @@ struct usbtll_omap {
int nch;/* num. of channels */
struct usbhs_omap_platform_data *pdata;
struct clk  **ch_clk;
-   /* secure the register updates */
-   spinlock_t  lock;
 };
 
 /*-*/
 
 static const char usbtll_driver_name[] = USBTLL_DRIVER_NAME;
 static struct device   *tll_dev;
+static DEFINE_SPINLOCK(tll_lock);  /* serialize access to tll_dev */
 
 /*-*/
 
@@ -212,7 +211,6 @@ static int usbtll_omap_probe(struct platform_device *pdev)
struct resource *res;
struct usbtll_omap  *tll;
unsignedreg;
-   unsigned long   flags;
int ret = 0;
int i, ver;
bool needs_tll;
@@ -230,8 +228,6 @@ static int usbtll_omap_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   spin_lock_init(&tll->lock);
-
tll->pdata = pdata;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -246,8 +242,6 @@ static int usbtll_omap_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
 
-   spin_lock_irqsave(&tll->lock, flags);
-
ver =  usbtll_read(base, OMAP_USBTLL_REVISION);
switch (ver) {
case OMAP_USBTLL_REV1:
@@ -265,8 +259,6 @@ static int usbtll_omap_probe(struct platform_device *pdev)
break;
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
-
tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]),
GFP_KERNEL);
if (!tll->ch_clk) {
@@ -275,8 +267,6 @@ static int usbtll_omap_probe(struct platform_device *pdev)
goto err_clk_alloc;
}
 
-   spin_lock_irqsave(&tll->lock, flags);
-
for (i = 0; i < tll->nch; i++) {
char clkname[] = "usb_tll_hs_usb_chx_clk";
struct clk *fck;
@@ -335,10 +325,11 @@ static int usbtll_omap_probe(struct platform_device *pdev)
}
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
pm_runtime_put_sync(dev);
/* only after this can omap_tll_enable/disable work */
+   spin_lock(&tll_lock);
tll_dev = dev;
+   spin_unlock(&tll_lock);
 
return 0;
 
@@ -360,7 +351,9 @@ static int usbtll_omap_remove(struct platform_device *pdev)
struct usbtll_omap *tll = platform_get_drvdata(pdev);
int i;
 
+   spin_lock(&tll_lock);
tll_dev = NULL;
+   spin_unlock(&tll_lock);
 
for (i = 0; i < tll->nch; i++)
clk_put(tll->ch_clk[i]);
@@ -373,13 +366,10 @@ static int usbtll_runtime_resume(struct device *dev)
 {
struct usbtll_omap  *tll = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = tll->pdata;
-   unsigned long   flags;
int i;
 
dev_dbg(dev, "usbtll_runtime_resume\n");
 
-   spin_lock_irqsave(&tll->lock, flags);
-
for (i = 0; i < tll->nch; i++) {
if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
int r;
@@ -395,8 +385,6 @@ static int usbtll_runtime_resume(struct device *dev)
}
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
-
return 0;
 }
 
@@ -404,13 +392,10 @@ static int usbtll_runtime_suspend(struct device *dev)
 {
struct usbtll_omap  *tll = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = tll->pdata;
-   unsigned long   flags;
int i;
 
dev_dbg(dev, "usbtll_runtime_suspend\n");
 
-   spin_lock_irqsave(&tll->lock, flags);
-
for (i = 0; i < tll->nch; i++) {
if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
if (tll->ch_clk[i])
@@ -418,8 +403,6 @@ static int usbtll_runtime_suspend(struct device *dev)
}
}
 
-   spin_unlock_irqrestore(&tll->lock, flags);
-
return 0;
 }
 
@@ -441,21 +424,39 @@ static struct platform_driver usbtll_oma

[PATCH v6 16/22] mfd: omap-usb-host: Get rid of unnecessary spinlock

2013-01-16 Thread Roger Quadros
The driver does not have an interrupt handler and
we don't really need a spinlock, so get rid of it.

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 2925d57..844d1b2 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -23,7 +23,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -108,7 +107,6 @@ struct usbhs_hcd_omap {
struct usbhs_omap_platform_data *pdata;
 
u32 usbhs_rev;
-   spinlock_t  lock;
 };
 /*-*/
 
@@ -276,13 +274,11 @@ static int usbhs_runtime_resume(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap->pdata;
-   unsigned long   flags;
int i, r;
 
dev_dbg(dev, "usbhs_runtime_resume\n");
 
omap_tll_enable();
-   spin_lock_irqsave(&omap->lock, flags);
 
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_enable(omap->ehci_logic_fck);
@@ -324,8 +320,6 @@ static int usbhs_runtime_resume(struct device *dev)
}
}
 
-   spin_unlock_irqrestore(&omap->lock, flags);
-
return 0;
 }
 
@@ -333,13 +327,10 @@ static int usbhs_runtime_suspend(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap->pdata;
-   unsigned long   flags;
int i;
 
dev_dbg(dev, "usbhs_runtime_suspend\n");
 
-   spin_lock_irqsave(&omap->lock, flags);
-
for (i = 0; i < omap->nports; i++) {
switch (pdata->port_mode[i]) {
case OMAP_EHCI_PORT_MODE_HSIC:
@@ -362,7 +353,6 @@ static int usbhs_runtime_suspend(struct device *dev)
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_disable(omap->ehci_logic_fck);
 
-   spin_unlock_irqrestore(&omap->lock, flags);
omap_tll_disable();
 
return 0;
@@ -372,7 +362,6 @@ static void omap_usbhs_init(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap->pdata;
-   unsigned long   flags;
unsignedreg;
 
dev_dbg(dev, "starting TI HSUSB Controller\n");
@@ -391,7 +380,6 @@ static void omap_usbhs_init(struct device *dev)
}
 
pm_runtime_get_sync(dev);
-   spin_lock_irqsave(&omap->lock, flags);
 
reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
/* setup ULPI bypass and burst configurations */
@@ -454,8 +442,6 @@ static void omap_usbhs_init(struct device *dev)
usbhs_write(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg);
dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg);
 
-   spin_unlock_irqrestore(&omap->lock, flags);
-
pm_runtime_put_sync(dev);
if (pdata->phy_reset) {
/* Hold the PHY in RESET for enough time till
@@ -521,8 +507,6 @@ static int usbhs_omap_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   spin_lock_init(&omap->lock);
-
omap->pdata = pdata;
 
pm_runtime_enable(dev);
-- 
1.7.4.1

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


[PATCH v6 17/22] mfd: omap-usb-host: clean up omap_usbhs_init()

2013-01-16 Thread Roger Quadros
We split initializing revision 1 and revision 2 into different
functions. Initialization is now done dynamically so that only
the number of ports available on the system are initialized.

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 844d1b2..38ec73d 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -358,6 +358,75 @@ static int usbhs_runtime_suspend(struct device *dev)
return 0;
 }
 
+static unsigned omap_usbhs_rev1_hostconfig(struct usbhs_hcd_omap *omap,
+   unsigned reg)
+{
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
+   int i;
+
+   for (i = 0; i < omap->nports; i++) {
+   switch (pdata->port_mode[i]) {
+   case OMAP_USBHS_PORT_MODE_UNUSED:
+   reg &= ~(OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS << i);
+   break;
+   case OMAP_EHCI_PORT_MODE_PHY:
+   if (pdata->single_ulpi_bypass)
+   break;
+
+   if (i == 0)
+   reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
+   else
+   reg &= ~(OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS
+   << (i-1));
+   break;
+   default:
+   if (pdata->single_ulpi_bypass)
+   break;
+
+   if (i == 0)
+   reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
+   else
+   reg |= OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS
+   << (i-1);
+   break;
+   }
+   }
+
+   if (pdata->single_ulpi_bypass) {
+   /* bypass ULPI only if none of the ports use PHY mode */
+   reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
+
+   for (i = 0; i < omap->nports; i++) {
+   if (is_ehci_phy_mode(pdata->port_mode[i])) {
+   reg &= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
+   break;
+   }
+   }
+   }
+
+   return reg;
+}
+
+static unsigned omap_usbhs_rev2_hostconfig(struct usbhs_hcd_omap *omap,
+   unsigned reg)
+{
+   struct usbhs_omap_platform_data *pdata = omap->pdata;
+   int i;
+
+   for (i = 0; i < omap->nports; i++) {
+   /* Clear port mode fields for PHY mode */
+   reg &= ~(OMAP4_P1_MODE_CLEAR << 2 * i);
+
+   if (is_ehci_tll_mode(pdata->port_mode[i]) ||
+   (is_ohci_port(pdata->port_mode[i])))
+   reg |= OMAP4_P1_MODE_TLL << 2 * i;
+   else if (is_ehci_hsic_mode(pdata->port_mode[i]))
+   reg |= OMAP4_P1_MODE_HSIC << 2 * i;
+   }
+
+   return reg;
+}
+
 static void omap_usbhs_init(struct device *dev)
 {
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
@@ -389,55 +458,10 @@ static void omap_usbhs_init(struct device *dev)
reg |= OMAP4_UHH_HOSTCONFIG_APP_START_CLK;
reg &= ~OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN;
 
-   if (is_omap_usbhs_rev1(omap)) {
-   if (pdata->port_mode[0] == OMAP_USBHS_PORT_MODE_UNUSED)
-   reg &= ~OMAP_UHH_HOSTCONFIG_P1_CONNECT_STATUS;
-   if (pdata->port_mode[1] == OMAP_USBHS_PORT_MODE_UNUSED)
-   reg &= ~OMAP_UHH_HOSTCONFIG_P2_CONNECT_STATUS;
-   if (pdata->port_mode[2] == OMAP_USBHS_PORT_MODE_UNUSED)
-   reg &= ~OMAP_UHH_HOSTCONFIG_P3_CONNECT_STATUS;
-
-   /* Bypass the TLL module for PHY mode operation */
-   if (pdata->single_ulpi_bypass) {
-   dev_dbg(dev, "OMAP3 ES version <= ES2.1\n");
-   if (is_ehci_phy_mode(pdata->port_mode[0]) ||
-   is_ehci_phy_mode(pdata->port_mode[1]) ||
-   is_ehci_phy_mode(pdata->port_mode[2]))
-   reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
-   else
-   reg |= OMAP_UHH_HOSTCONFIG_ULPI_BYPASS;
-   } else {
-   dev_dbg(dev, "OMAP3 ES version > ES2.1\n");
-   if (is_ehci_phy_mode(pdata->port_mode[0]))
-   reg &= ~OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
-   else
-   reg |= OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS;
-   if (is_ehci_phy_mode(pdata->port_mode[1]))
- 

[PATCH v6 15/22] mfd: omap-usb-host: Manage HSIC clocks for HSIC mode

2013-01-16 Thread Roger Quadros
Enable the optional HSIC clocks (60MHz and 480MHz) for the ports
that are configured in HSIC mode.

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 9c45bbc..2925d57 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -93,6 +93,8 @@
 struct usbhs_hcd_omap {
int nports;
struct clk  **utmi_clk;
+   struct clk  **hsic60m_clk;
+   struct clk  **hsic480m_clk;
 
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
@@ -286,7 +288,28 @@ static int usbhs_runtime_resume(struct device *dev)
clk_enable(omap->ehci_logic_fck);
 
for (i = 0; i < omap->nports; i++) {
-   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   switch (pdata->port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (omap->hsic60m_clk[i]) {
+   r = clk_enable(omap->hsic60m_clk[i]);
+   if (r) {
+   dev_err(dev,
+"Can't enable port %d hsic60m 
clk:%d\n",
+i, r);
+   }
+   }
+
+   if (omap->hsic480m_clk[i]) {
+   r = clk_enable(omap->hsic480m_clk[i]);
+   if (r) {
+   dev_err(dev,
+"Can't enable port %d hsic480m 
clk:%d\n",
+i, r);
+   }
+   }
+   /* Fall through as HSIC mode needs utmi_clk */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
if (omap->utmi_clk[i]) {
r = clk_enable(omap->utmi_clk[i]);
if (r) {
@@ -295,6 +318,9 @@ static int usbhs_runtime_resume(struct device *dev)
 i, r);
}
}
+   break;
+   default:
+   break;
}
}
 
@@ -315,9 +341,21 @@ static int usbhs_runtime_suspend(struct device *dev)
spin_lock_irqsave(&omap->lock, flags);
 
for (i = 0; i < omap->nports; i++) {
-   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   switch (pdata->port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (omap->hsic60m_clk[i])
+   clk_disable(omap->hsic60m_clk[i]);
+
+   if (omap->hsic480m_clk[i])
+   clk_disable(omap->hsic480m_clk[i]);
+   /* Fall through as utmi_clks were used in HSIC mode */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
if (omap->utmi_clk[i])
clk_disable(omap->utmi_clk[i]);
+   break;
+   default:
+   break;
}
}
 
@@ -524,7 +562,10 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
i = sizeof(struct clk *) * omap->nports;
omap->utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
-   if (!omap->utmi_clk) {
+   omap->hsic480m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+   omap->hsic60m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+
+   if (!omap->utmi_clk || !omap->hsic480m_clk || !omap->hsic60m_clk) {
dev_err(dev, "Memory allocation failed\n");
ret = -ENOMEM;
goto err_mem;
@@ -582,7 +623,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
for (i = 0; i < omap->nports; i++) {
struct clk *pclk;
-   char clkname[] = "usb_host_hs_utmi_px_clk";
+   char clkname[] = "usb_host_hs_hsic480m_px_clk";
 
/* clock names are indexed from 1*/
snprintf(clkname, sizeof(clkname),
@@ -598,6 +639,24 @@ static int usbhs_omap_probe(struct platform_device *pdev)
clkname, PTR_ERR(pclk));
else
omap->utmi_clk[i] = pclk;
+
+   snprintf(clkname, sizeof(clkname),
+   "usb_host_hs_hsic480m_p%d_clk", i + 1);
+   pclk = clk_get(dev, clkname);
+   if (IS_ERR(pclk))
+   dev_dbg(dev, "Failed to get clock : %s : %ld\n",
+   clkname, PTR_ERR(pclk));
+   else
+   omap->hsic480m_clk[i] = pclk;
+
+   snprintf(cl

[PATCH v6 21/22] mfd: omap-usb-host: Don't spam console on clk_set_parent failure

2013-01-16 Thread Roger Quadros
clk_set_parent is expected to fail on OMAP3 platforms. We don't
consider that as fatal so don't spam console.

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 38ec73d..56b6f69 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -668,32 +668,32 @@ static int usbhs_omap_probe(struct platform_device *pdev)
}
 
if (is_ehci_phy_mode(pdata->port_mode[0])) {
-   /* for OMAP3 , the clk set paretn fails */
+   /* for OMAP3, clk_set_parent fails */
ret = clk_set_parent(omap->utmi_p1_gfclk,
omap->xclk60mhsp1_ck);
if (ret != 0)
-   dev_err(dev, "xclk60mhsp1_ck set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "xclk60mhsp1_ck set parent failed: %d\n",
+   ret);
} else if (is_ehci_tll_mode(pdata->port_mode[0])) {
ret = clk_set_parent(omap->utmi_p1_gfclk,
omap->init_60m_fclk);
if (ret != 0)
-   dev_err(dev, "init_60m_fclk set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "P0 init_60m_fclk set parent failed: %d\n",
+   ret);
}
 
if (is_ehci_phy_mode(pdata->port_mode[1])) {
ret = clk_set_parent(omap->utmi_p2_gfclk,
omap->xclk60mhsp2_ck);
if (ret != 0)
-   dev_err(dev, "xclk60mhsp2_ck set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "xclk60mhsp2_ck set parent failed: %d\n",
+   ret);
} else if (is_ehci_tll_mode(pdata->port_mode[1])) {
ret = clk_set_parent(omap->utmi_p2_gfclk,
omap->init_60m_fclk);
if (ret != 0)
-   dev_err(dev, "init_60m_fclk set parent"
-   "failed error:%d\n", ret);
+   dev_dbg(dev, "P1 init_60m_fclk set parent failed: %d\n",
+   ret);
}
 
omap_usbhs_init(dev);
-- 
1.7.4.1

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


[PATCH v6 18/22] USB: ehci-omap: Don't free gpios that we didn't request

2013-01-16 Thread Roger Quadros
This driver does not request any gpios so don't free them.
Fixes L3 bus error on multiple modprobe/rmmod of ehci_hcd
with ehci-omap in use.

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

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 134c789..b96a4bf 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -288,7 +288,6 @@ static int ehci_hcd_omap_remove(struct platform_device 
*pdev)
 {
struct device *dev  = &pdev->dev;
struct usb_hcd *hcd = dev_get_drvdata(dev);
-   struct usbhs_omap_platform_data *pdata  = dev->platform_data;
 
usb_remove_hcd(hcd);
disable_put_regulator(dev->platform_data);
@@ -298,13 +297,6 @@ static int ehci_hcd_omap_remove(struct platform_device 
*pdev)
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
 
-   if (pdata->phy_reset) {
-   if (gpio_is_valid(pdata->reset_gpio_port[0]))
-   gpio_free(pdata->reset_gpio_port[0]);
-
-   if (gpio_is_valid(pdata->reset_gpio_port[1]))
-   gpio_free(pdata->reset_gpio_port[1]);
-   }
return 0;
 }
 
-- 
1.7.4.1

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


[PATCH v6 14/22] mfd: omap-usb-host: cleanup clock management code

2013-01-16 Thread Roger Quadros
All ports have similarly named port clocks so we can
bunch them into a port data structure and use for loop
to enable/disable the clocks.

Dynamically allocate and get clocks based on number of ports
available on the platform

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 65d2ab4..9c45bbc 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -92,13 +92,12 @@
 
 struct usbhs_hcd_omap {
int nports;
+   struct clk  **utmi_clk;
 
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
-   struct clk  *utmi_p1_fck;
-   struct clk  *usbhost_p1_fck;
-   struct clk  *utmi_p2_fck;
-   struct clk  *usbhost_p2_fck;
+   struct clk  *utmi_p1_gfclk;
+   struct clk  *utmi_p2_gfclk;
struct clk  *init_60m_fclk;
struct clk  *ehci_logic_fck;
 
@@ -276,6 +275,7 @@ static int usbhs_runtime_resume(struct device *dev)
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap->pdata;
unsigned long   flags;
+   int i, r;
 
dev_dbg(dev, "usbhs_runtime_resume\n");
 
@@ -285,13 +285,18 @@ static int usbhs_runtime_resume(struct device *dev)
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_enable(omap->ehci_logic_fck);
 
-   if (is_ehci_tll_mode(pdata->port_mode[0]))
-   clk_enable(omap->usbhost_p1_fck);
-   if (is_ehci_tll_mode(pdata->port_mode[1]))
-   clk_enable(omap->usbhost_p2_fck);
-
-   clk_enable(omap->utmi_p1_fck);
-   clk_enable(omap->utmi_p2_fck);
+   for (i = 0; i < omap->nports; i++) {
+   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   if (omap->utmi_clk[i]) {
+   r = clk_enable(omap->utmi_clk[i]);
+   if (r) {
+   dev_err(dev,
+"Can't enable port %d clk : %d\n",
+i, r);
+   }
+   }
+   }
+   }
 
spin_unlock_irqrestore(&omap->lock, flags);
 
@@ -303,18 +308,18 @@ static int usbhs_runtime_suspend(struct device *dev)
struct usbhs_hcd_omap   *omap = dev_get_drvdata(dev);
struct usbhs_omap_platform_data *pdata = omap->pdata;
unsigned long   flags;
+   int i;
 
dev_dbg(dev, "usbhs_runtime_suspend\n");
 
spin_lock_irqsave(&omap->lock, flags);
 
-   if (is_ehci_tll_mode(pdata->port_mode[0]))
-   clk_disable(omap->usbhost_p1_fck);
-   if (is_ehci_tll_mode(pdata->port_mode[1]))
-   clk_disable(omap->usbhost_p2_fck);
-
-   clk_disable(omap->utmi_p2_fck);
-   clk_disable(omap->utmi_p1_fck);
+   for (i = 0; i < omap->nports; i++) {
+   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   if (omap->utmi_clk[i])
+   clk_disable(omap->utmi_clk[i]);
+   }
+   }
 
if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck))
clk_disable(omap->ehci_logic_fck);
@@ -458,6 +463,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
struct resource *res;
int ret = 0;
int i;
+   boolneed_logic_fck;
 
if (!pdata) {
dev_err(dev, "Missing platform data\n");
@@ -516,76 +522,93 @@ static int usbhs_omap_probe(struct platform_device *pdev)
}
}
 
-   for (i = 0; i < omap->nports; i++)
+   i = sizeof(struct clk *) * omap->nports;
+   omap->utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+   if (!omap->utmi_clk) {
+   dev_err(dev, "Memory allocation failed\n");
+   ret = -ENOMEM;
+   goto err_mem;
+   }
+
+   need_logic_fck = false;
+   for (i = 0; i < omap->nports; i++) {
if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) ||
-   is_ehci_hsic_mode(i)) {
-   omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck");
-   if (IS_ERR(omap->ehci_logic_fck)) {
-   ret = PTR_ERR(omap->ehci_logic_fck);
-   dev_warn(dev, "ehci_logic_fck failed:%d\n",
-ret);
- 

[PATCH v6 19/22] ARM: OMAP3: clock data: get rid of unused USB host clock aliases and dummies

2013-01-16 Thread Roger Quadros
We don't need multiple aliases for the OMAP USB host clocks and neither
the dummy clocks so remove them.

CC: Paul Walmsley 
CC: Rajendra Nayak 
CC: Benoit Cousson 
CC: Mike Turquette 

Signed-off-by: Roger Quadros 
Acked-by: Paul Walmsley 
---
 arch/arm/mach-omap2/cclock3xxx_data.c |   11 ---
 1 files changed, 0 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c 
b/arch/arm/mach-omap2/cclock3xxx_data.c
index 6ef8758..b58ec96 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -3291,8 +3291,6 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL,   "cpefuse_fck",  &cpefuse_fck,   CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "ts_fck",   &ts_fck,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "usbtll_fck",   &usbtll_fck,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
-   CLK("usbhs_omap",   "usbtll_fck",   &usbtll_fck,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
-   CLK("usbhs_tll","usbtll_fck",   &usbtll_fck,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
CLK(NULL,   "core_96m_fck", &core_96m_fck,  CK_3XXX),
CLK(NULL,   "mmchs3_fck",   &mmchs3_fck,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "mmchs2_fck",   &mmchs2_fck,CK_3XXX),
@@ -3329,8 +3327,6 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL,   "pka_ick",  &pka_ick,   CK_34XX | CK_36XX),
CLK(NULL,   "core_l4_ick",  &core_l4_ick,   CK_3XXX),
CLK(NULL,   "usbtll_ick",   &usbtll_ick,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
-   CLK("usbhs_omap",   "usbtll_ick",   &usbtll_ick,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
-   CLK("usbhs_tll","usbtll_ick",   &usbtll_ick,CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
CLK("omap_hsmmc.2", "ick",  &mmchs3_ick,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "mmchs3_ick",   &mmchs3_ick,CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "icr_ick",  &icr_ick,   CK_34XX | CK_36XX),
@@ -3393,17 +3389,10 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL,   "usbhost_120m_fck", &usbhost_120m_fck, CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "usbhost_48m_fck", &usbhost_48m_fck, CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
CLK(NULL,   "usbhost_ick",  &usbhost_ick,   CK_3430ES2PLUS | 
CK_AM35XX | CK_36XX),
-   CLK("usbhs_omap",   "usbhost_ick",  &usbhost_ick,   CK_3430ES2PLUS 
| CK_AM35XX | CK_36XX),
CLK(NULL,   "utmi_p1_gfclk",&dummy_ck,  CK_3XXX),
CLK(NULL,   "utmi_p2_gfclk",&dummy_ck,  CK_3XXX),
CLK(NULL,   "xclk60mhsp1_ck",   &dummy_ck,  CK_3XXX),
CLK(NULL,   "xclk60mhsp2_ck",   &dummy_ck,  CK_3XXX),
-   CLK(NULL,   "usb_host_hs_utmi_p1_clk",  &dummy_ck,  
CK_3XXX),
-   CLK(NULL,   "usb_host_hs_utmi_p2_clk",  &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_omap",   "usb_tll_hs_usb_ch0_clk",   &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_omap",   "usb_tll_hs_usb_ch1_clk",   &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_tll","usb_tll_hs_usb_ch0_clk",   &dummy_ck,  
CK_3XXX),
-   CLK("usbhs_tll","usb_tll_hs_usb_ch1_clk",   &dummy_ck,  
CK_3XXX),
CLK(NULL,   "init_60m_fclk",&dummy_ck,  CK_3XXX),
CLK(NULL,   "usim_fck", &usim_fck,  CK_3430ES2PLUS | 
CK_36XX),
CLK(NULL,   "gpt1_fck", &gpt1_fck,  CK_3XXX),
-- 
1.7.4.1

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


[PATCH v6 22/22] mdf: omap-usb-host: get rid of build warning

2013-01-16 Thread Roger Quadros
Fixes the below build warning when driver is built-in.

drivers/mfd/omap-usb-host.c:750:12: warning:
‘usbhs_omap_remove’ defined but not used [-Wunused-function]

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

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 56b6f69..151034f 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -778,7 +778,7 @@ static struct platform_driver usbhs_omap_driver = {
.owner  = THIS_MODULE,
.pm = &usbhsomap_dev_pm_ops,
},
-   .remove = __exit_p(usbhs_omap_remove),
+   .remove = usbhs_omap_remove,
 };
 
 MODULE_AUTHOR("Keshava Munegowda ");
-- 
1.7.4.1

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


[PATCH v6 20/22] ARM: OMAP4: clock data: get rid of unused USB host clock aliases

2013-01-16 Thread Roger Quadros
We don't need multiple aliases for the OMAP USB host clocks so remove them.

CC: Paul Walmsley 
CC: Rajendra Nayak 
CC: Benoit Cousson 
CC: Mike Turquette 

Signed-off-by: Roger Quadros 
Acked-by: Paul Walmsley 
---
 arch/arm/mach-omap2/cclock44xx_data.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/cclock44xx_data.c 
b/arch/arm/mach-omap2/cclock44xx_data.c
index 5789a5e..5ee78f3 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -1875,7 +1875,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "uart3_fck",&uart3_fck, 
CK_443X),
CLK(NULL,   "uart4_fck",&uart4_fck, 
CK_443X),
CLK(NULL,   "usb_host_fs_fck",  &usb_host_fs_fck,   
CK_443X),
-   CLK("usbhs_omap",   "fs_fck",   &usb_host_fs_fck,   
CK_443X),
CLK(NULL,   "utmi_p1_gfclk",&utmi_p1_gfclk, 
CK_443X),
CLK(NULL,   "usb_host_hs_utmi_p1_clk",  
&usb_host_hs_utmi_p1_clk,   CK_443X),
CLK(NULL,   "utmi_p2_gfclk",&utmi_p2_gfclk, 
CK_443X),
@@ -1887,7 +1886,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "usb_host_hs_hsic480m_p2_clk",  
&usb_host_hs_hsic480m_p2_clk,   CK_443X),
CLK(NULL,   "usb_host_hs_func48mclk",   
&usb_host_hs_func48mclk,CK_443X),
CLK(NULL,   "usb_host_hs_fck",  &usb_host_hs_fck,   
CK_443X),
-   CLK("usbhs_omap",   "hs_fck",   &usb_host_hs_fck,   
CK_443X),
CLK(NULL,   "otg_60m_gfclk",&otg_60m_gfclk, 
CK_443X),
CLK(NULL,   "usb_otg_hs_xclk",  &usb_otg_hs_xclk,   
CK_443X),
CLK(NULL,   "usb_otg_hs_ick",   &usb_otg_hs_ick,
CK_443X),
@@ -1897,8 +1895,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "usb_tll_hs_usb_ch0_clk",   
&usb_tll_hs_usb_ch0_clk,CK_443X),
CLK(NULL,   "usb_tll_hs_usb_ch1_clk",   
&usb_tll_hs_usb_ch1_clk,CK_443X),
CLK(NULL,   "usb_tll_hs_ick",   &usb_tll_hs_ick,
CK_443X),
-   CLK("usbhs_omap",   "usbtll_ick",   &usb_tll_hs_ick,
CK_443X),
-   CLK("usbhs_tll","usbtll_ick",   &usb_tll_hs_ick,
CK_443X),
CLK(NULL,   "usim_ck",  &usim_ck,   
CK_443X),
CLK(NULL,   "usim_fclk",&usim_fclk, 
CK_443X),
CLK(NULL,   "usim_fck", &usim_fck,  
CK_443X),
@@ -1949,9 +1945,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   "uart2_ick",&dummy_ck,  
CK_443X),
CLK(NULL,   "uart3_ick",&dummy_ck,  
CK_443X),
CLK(NULL,   "uart4_ick",&dummy_ck,  
CK_443X),
-   CLK("usbhs_omap",   "usbhost_ick",  &dummy_ck,  
CK_443X),
-   CLK("usbhs_omap",   "usbtll_fck",   &dummy_ck,  
CK_443X),
-   CLK("usbhs_tll","usbtll_fck",   &dummy_ck,  
CK_443X),
CLK("omap_wdt", "ick",  &dummy_ck,  
CK_443X),
CLK(NULL,   "timer_32k_ck", &sys_32k_ck,CK_443X),
/* TODO: Remove "omap_timer.X" aliases once DT migration is complete */
-- 
1.7.4.1

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


[PATCH v6 05/22] mfd: omap-usb-tll: introduce and use mode_needs_tll()

2013-01-16 Thread Roger Quadros
This is a handy macro to check if the port requires the
USB TLL module or not. Use it to Enable the TLL module and manage
the clocks.

Signed-off-by: Roger Quadros 
---
 drivers/mfd/omap-usb-tll.c |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index 8f45322..7e55a83 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -95,6 +95,10 @@
 
 #define is_ehci_tll_mode(x)(x == OMAP_EHCI_PORT_MODE_TLL)
 
+/* only PHY and UNUSED modes don't need TLL */
+#define omap_usb_mode_needs_tll(x) ((x != OMAP_USBHS_PORT_MODE_UNUSED) &&\
+(x != OMAP_EHCI_PORT_MODE_PHY))
+
 struct usbtll_omap {
int nch;/* num. of channels */
struct usbhs_omap_platform_data *pdata;
@@ -211,6 +215,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
unsigned long   flags;
int ret = 0;
int i, ver;
+   bool needs_tll;
 
dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
 
@@ -281,12 +286,11 @@ static int usbtll_omap_probe(struct platform_device *pdev)
tll->ch_clk[i] = fck;
}
 
-   if (is_ehci_tll_mode(pdata->port_mode[0]) ||
-   is_ehci_tll_mode(pdata->port_mode[1]) ||
-   is_ehci_tll_mode(pdata->port_mode[2]) ||
-   is_ohci_port(pdata->port_mode[0]) ||
-   is_ohci_port(pdata->port_mode[1]) ||
-   is_ohci_port(pdata->port_mode[2])) {
+   needs_tll = false;
+   for (i = 0; i < tll->nch; i++)
+   needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]);
+
+   if (needs_tll) {
 
/* Program Common TLL register */
reg = usbtll_read(base, OMAP_TLL_SHARED_CONF);
@@ -374,7 +378,7 @@ static int usbtll_runtime_resume(struct device *dev)
spin_lock_irqsave(&tll->lock, flags);
 
for (i = 0; i < tll->nch; i++) {
-   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
int r;
 
if (!tll->ch_clk[i])
@@ -410,7 +414,7 @@ static int usbtll_runtime_suspend(struct device *dev)
spin_lock_irqsave(&tll->lock, flags);
 
for (i = 0; i < tll->nch; i++) {
-   if (is_ehci_tll_mode(pdata->port_mode[i])) {
+   if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
if (tll->ch_clk[i])
clk_disable(tll->ch_clk[i]);
}
-- 
1.7.4.1

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


[PATCH v3 1/2] net: asix: init ASIX AX88772B MAC from EEPROM

2013-01-16 Thread Lucas Stach
The device comes up with a MAC address of all zeros. We need to read the
initial device MAC from EEPROM so it can be set properly later.

Signed-off-by: Lucas Stach 
---
A similar fix was added into U-Boot:
http://patchwork.ozlabs.org/patch/179409/

v2: pass flag in the data field instead of clobbering the global flags
space
v3: no change
---
 drivers/net/usb/asix.h |  3 +++
 drivers/net/usb/asix_devices.c | 30 +++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h
index e889631..7afe8ac 100644
--- a/drivers/net/usb/asix.h
+++ b/drivers/net/usb/asix.h
@@ -167,6 +167,9 @@ struct asix_data {
u8 res;
 };
 
+/* ASIX specific flags */
+#define FLAG_EEPROM_MAC(1UL << 0)  /* init device MAC from 
eeprom */
+
 int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
  u16 size, void *data);
 
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 7a6e758..0ecc3bc 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -422,14 +422,25 @@ static const struct net_device_ops ax88772_netdev_ops = {
 
 static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 {
-   int ret, embd_phy;
+   int ret, embd_phy, i;
u8 buf[ETH_ALEN];
u32 phyid;
 
usbnet_get_endpoints(dev,intf);
 
/* Get the MAC address */
-   ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
+   if (dev->driver_info->data & FLAG_EEPROM_MAC) {
+   for (i = 0; i < (ETH_ALEN >> 1); i++) {
+   ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i,
+   0, 2, buf + i * 2);
+   if (ret < 0)
+   break;
+   }
+   } else {
+   ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
+   0, 0, ETH_ALEN, buf);
+   }
+
if (ret < 0) {
netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
return ret;
@@ -872,6 +883,19 @@ static const struct driver_info ax88772_info = {
.tx_fixup = asix_tx_fixup,
 };
 
+static const struct driver_info ax88772b_info = {
+   .description = "ASIX AX88772B USB 2.0 Ethernet",
+   .bind = ax88772_bind,
+   .status = asix_status,
+   .link_reset = ax88772_link_reset,
+   .reset = ax88772_reset,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |
+FLAG_MULTI_PACKET,
+   .rx_fixup = asix_rx_fixup,
+   .tx_fixup = asix_tx_fixup,
+   .data = FLAG_EEPROM_MAC,
+};
+
 static const struct driver_info ax88178_info = {
.description = "ASIX AX88178 USB 2.0 Ethernet",
.bind = ax88178_bind,
@@ -953,7 +977,7 @@ static const struct usb_device_id   products [] = {
 }, {
// ASIX AX88772B 10/100
USB_DEVICE (0x0b95, 0x772b),
-   .driver_info = (unsigned long) &ax88772_info,
+   .driver_info = (unsigned long) &ax88772b_info,
 }, {
// ASIX AX88772 10/100
USB_DEVICE (0x0b95, 0x7720),
-- 
1.8.0.2

--
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 v3 2/2] net: asix: handle packets crossing URB boundaries

2013-01-16 Thread Lucas Stach
ASIX AX88772B started to pack data even more tightly. Packets and the ASIX 
packet
header may now cross URB boundaries. To handle this we have to introduce
some state between individual calls to asix_rx_fixup().

Signed-off-by: Lucas Stach 
---
I've running this patch for some weeks already now and it gets rid of all
the commonly seen rx failures with AX88772B.

v2: don't forget to free driver_private
v3: don't break ax88172a. Generates a bit churn, but cleaner than the
alternative of playing pointer casting tricks.
---
 drivers/net/usb/asix.h | 15 ++-
 drivers/net/usb/asix_common.c  | 90 ++
 drivers/net/usb/asix_devices.c | 23 +--
 drivers/net/usb/ax88172a.c | 11 +-
 4 files changed, 109 insertions(+), 30 deletions(-)

diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h
index 7afe8ac..346c032 100644
--- a/drivers/net/usb/asix.h
+++ b/drivers/net/usb/asix.h
@@ -167,6 +167,17 @@ struct asix_data {
u8 res;
 };
 
+struct asix_rx_fixup_info {
+   struct sk_buff *ax_skb;
+   u32 header;
+   u16 size;
+   bool split_head;
+};
+
+struct asix_common_private {
+   struct asix_rx_fixup_info rx_fixup_info;
+};
+
 /* ASIX specific flags */
 #define FLAG_EEPROM_MAC(1UL << 0)  /* init device MAC from 
eeprom */
 
@@ -179,7 +190,9 @@ int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, 
u16 index,
 void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
  u16 index, u16 size, void *data);
 
-int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
+int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
+  struct asix_rx_fixup_info *rx);
+int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb);
 
 struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
  gfp_t flags);
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 50d1673..15450dc 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -51,49 +51,89 @@ void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 
value, u16 index,
   value, index, data, size);
 }
 
-int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
+int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
+  struct asix_rx_fixup_info *rx)
 {
int offset = 0;
 
-   while (offset + sizeof(u32) < skb->len) {
-   struct sk_buff *ax_skb;
-   u16 size;
-   u32 header = get_unaligned_le32(skb->data + offset);
-
-   offset += sizeof(u32);
-
-   /* get the packet length */
-   size = (u16) (header & 0x7ff);
-   if (size != ((~header >> 16) & 0x07ff)) {
-   netdev_err(dev->net, "asix_rx_fixup() Bad Header 
Length\n");
-   return 0;
+   while (offset + sizeof(u16) <= skb->len) {
+   u16 remaining = 0;
+   unsigned char *data;
+
+   if (!rx->size) {
+   if ((skb->len - offset == sizeof(u16)) ||
+   rx->split_head) {
+   if(!rx->split_head) {
+   rx->header = get_unaligned_le16(
+   skb->data + offset);
+   rx->split_head = true;
+   offset += sizeof(u16);
+   break;
+   } else {
+   rx->header |= (get_unaligned_le16(
+   skb->data + offset)
+   << 16);
+   rx->split_head = false;
+   offset += sizeof(u16);
+   }
+   } else {
+   rx->header = get_unaligned_le32(skb->data +
+   offset);
+   offset += sizeof(u32);
+   }
+
+   /* get the packet length */
+   rx->size = (u16) (rx->header & 0x7ff);
+   if (rx->size != ((~rx->header >> 16) & 0x7ff)) {
+   netdev_err(dev->net, "asix_rx_fixup() Bad 
Header Length 0x%x, offset %d\n",
+  rx->header, offset);
+   rx->size = 0;
+   return 0;
+   }
+   rx->ax_skb = netdev_alloc_skb_ip_align(dev->net,
+  rx->size);
+   if (!rx->ax_skb)
+   

[PATCH 3/4] USB: PHY: Tegra: Get rid of instance number to differentiate PHY type

2013-01-16 Thread Venu Byravarasu
Tegra20 USB has 3 PHY instances:
Instance 1 and 3 are UTMI. Instance 2 is ULPI.

As instance number was used to differentiate ULPI from UTMI,
used DT param to get this info and processed accordingly.

Signed-off-by: Venu Byravarasu 
---
 drivers/usb/phy/tegra_usb_phy.c   |   23 +--
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 79280fe..ce1ff2a 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -209,11 +209,6 @@ static struct tegra_utmip_config utmip_default[] = {
},
 };
 
-static inline bool phy_is_ulpi(struct tegra_usb_phy *phy)
-{
-   return (phy->instance == 1);
-}
-
 static int utmip_pad_open(struct tegra_usb_phy *phy)
 {
phy->pad_clk = clk_get_sys("utmip-pad", NULL);
@@ -655,7 +650,7 @@ static int  tegra_phy_init(struct usb_phy *x)
struct tegra_ulpi_config *ulpi_config;
int err;
 
-   if (phy_is_ulpi(phy)) {
+   if (phy->is_ulpi_phy) {
ulpi_config = phy->config;
phy->clk = clk_get_sys(NULL, ulpi_config->clk);
if (IS_ERR(phy->clk)) {
@@ -693,7 +688,7 @@ static void tegra_usb_phy_close(struct usb_phy *x)
 {
struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, 
u_phy);
 
-   if (phy_is_ulpi(phy))
+   if (phy->is_ulpi_phy)
clk_put(phy->clk);
else
utmip_pad_close(phy);
@@ -704,7 +699,7 @@ static void tegra_usb_phy_close(struct usb_phy *x)
 
 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
 {
-   if (phy_is_ulpi(phy))
+   if (phy->is_ulpi_phy)
return ulpi_phy_power_on(phy);
else
return utmi_phy_power_on(phy);
@@ -712,7 +707,7 @@ static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
 
 static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
 {
-   if (phy_is_ulpi(phy))
+   if (phy->is_ulpi_phy)
return ulpi_phy_power_off(phy);
else
return utmi_phy_power_off(phy);
@@ -749,7 +744,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
of_property_read_bool(np, "nvidia,has-legacy-mode");
 
if (!phy->config) {
-   if (phy_is_ulpi(phy)) {
+   if (phy->is_ulpi_phy) {
pr_err("%s: ulpi phy configuration missing", __func__);
err = -EINVAL;
goto err0;
@@ -796,14 +791,14 @@ EXPORT_SYMBOL_GPL(tegra_usb_phy_open);
 
 void tegra_usb_phy_preresume(struct tegra_usb_phy *phy)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy->is_ulpi_phy)
utmi_phy_preresume(phy);
 }
 EXPORT_SYMBOL_GPL(tegra_usb_phy_preresume);
 
 void tegra_usb_phy_postresume(struct tegra_usb_phy *phy)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy->is_ulpi_phy)
utmi_phy_postresume(phy);
 }
 EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume);
@@ -811,14 +806,14 @@ EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume);
 void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy,
 enum tegra_usb_phy_port_speed port_speed)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy->is_ulpi_phy)
utmi_phy_restore_start(phy, port_speed);
 }
 EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_start);
 
 void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy->is_ulpi_phy)
utmi_phy_restore_end(phy);
 }
 EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index f03e157..a6a89d4 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -60,6 +60,7 @@ struct tegra_usb_phy {
struct usb_phy u_phy;
struct device *dev;
bool is_legacy_phy;
+   bool is_ulpi_phy;
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-- 
1.7.0.4

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


[PATCH 2/4] USB: PHY: Get rid of instance number to differentiate legacy controller

2013-01-16 Thread Venu Byravarasu
Tegra20 USB has 3 PHY instances. Instance 0 is based on
legacy PHY interface and other two are standard interfaces.

As instance number was used to differentiate legacy from
standard interfaces, used DT param to get this info and
processed accordingly.

Signed-off-by: Venu Byravarasu 
---
 drivers/usb/phy/tegra_usb_phy.c   |   32 +++-
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 3059384..79280fe 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -221,7 +222,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
return PTR_ERR(phy->pad_clk);
}
 
-   if (phy->instance == 0) {
+   if (phy->is_legacy_phy) {
phy->pad_regs = phy->regs;
} else {
phy->pad_regs = ioremap(TEGRA_USB_BASE, TEGRA_USB_SIZE);
@@ -236,7 +237,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
 
 static void utmip_pad_close(struct tegra_usb_phy *phy)
 {
-   if (phy->instance != 0)
+   if (!phy->is_legacy_phy)
iounmap(phy->pad_regs);
clk_put(phy->pad_clk);
 }
@@ -305,7 +306,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy->regs;
 
-   if (phy->instance == 0) {
+   if (phy->is_legacy_phy) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
@@ -315,9 +316,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
val = readl(base + USB_SUSP_CTRL);
val &= ~USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
-   }
-
-   if (phy->instance == 2) {
+   } else {
val = readl(base + USB_PORTSC1);
val |= USB_PORTSC1_PHCD;
writel(val, base + USB_PORTSC1);
@@ -332,7 +331,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy->regs;
 
-   if (phy->instance == 0) {
+   if (phy->is_legacy_phy) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_CLR;
writel(val, base + USB_SUSP_CTRL);
@@ -342,9 +341,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
val = readl(base + USB_SUSP_CTRL);
val &= ~USB_SUSP_CLR;
writel(val, base + USB_SUSP_CTRL);
-   }
-
-   if (phy->instance == 2) {
+   } else {
val = readl(base + USB_PORTSC1);
val &= ~USB_PORTSC1_PHCD;
writel(val, base + USB_PORTSC1);
@@ -365,7 +362,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
val |= UTMIP_RESET;
writel(val, base + USB_SUSP_CTRL);
 
-   if (phy->instance == 0) {
+   if (phy->is_legacy_phy) {
val = readl(base + USB1_LEGACY_CTRL);
val |= USB1_NO_LEGACY_MODE;
writel(val, base + USB1_LEGACY_CTRL);
@@ -440,16 +437,14 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
val |= UTMIP_BIAS_PDTRK_COUNT(0x5);
writel(val, base + UTMIP_BIAS_CFG1);
 
-   if (phy->instance == 0) {
+   if (phy->is_legacy_phy) {
val = readl(base + UTMIP_SPARE_CFG0);
if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE)
val &= ~FUSE_SETUP_SEL;
else
val |= FUSE_SETUP_SEL;
writel(val, base + UTMIP_SPARE_CFG0);
-   }
-
-   if (phy->instance == 2) {
+   } else {
val = readl(base + USB_SUSP_CTRL);
val |= UTMIP_PHY_ENABLE;
writel(val, base + USB_SUSP_CTRL);
@@ -459,7 +454,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
val &= ~UTMIP_RESET;
writel(val, base + USB_SUSP_CTRL);
 
-   if (phy->instance == 0) {
+   if (phy->is_legacy_phy) {
val = readl(base + USB1_LEGACY_CTRL);
val &= ~USB1_VBUS_SENSE_CTL_MASK;
val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD;
@@ -472,7 +467,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
 
utmi_phy_clk_enable(phy);
 
-   if (phy->instance == 2) {
+   if (!phy->is_legacy_phy) {
val = readl(base + USB_PORTSC1);
val &= ~USB_PORTSC1_PTS(~0);
writel(val, base + USB_PORTSC1);
@@ -739,6 +734,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
unsigned long parent_rate;
int i;
int err;
+   struct device_node *np = dev->of_node;
 
phy = kzalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL);
if (!phy)
@@ 

[PATCH 1/4] arm: tegra: Add DT nodes for Tegra USB PHY

2013-01-16 Thread Venu Byravarasu
Add DT nodes for Tegra USB PHY along with related documentation.
Also added a phandle property to controller DT node, for referring
to connected PHY instance.

Signed-off-by: Venu Byravarasu 
---
 .../bindings/usb/nvidia,tegra20-ehci.txt   |1 +
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   14 
 arch/arm/boot/dts/tegra20.dtsi |   22 
 3 files changed, 37 insertions(+), 0 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
index 6ea765a..34c9528 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
@@ -11,6 +11,7 @@ Required properties :
  - phy_type : Should be one of "ulpi" or "utmi".
  - nvidia,vbus-gpio : If present, specifies a gpio that needs to be
activated for the bus to be powered.
+ - nvidia,phy : phandle of the PHY instance, the controller is connected to.
 
 Required properties for phy_type == ulpi:
   - nvidia,phy-reset-gpio : The GPIO used to reset the PHY.
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
new file mode 100644
index 000..84a4c12
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
@@ -0,0 +1,14 @@
+Tegra SOC USB PHY
+
+The device node for Tegra SOC USB PHY:
+
+Required properties :
+ - compatible : Should be "nvidia,tegra20-usb-phy".
+ - reg : Address and length of the register set for the USB PHY interface.
+ - phy_type : Should be one of "ulpi" or "utmi".
+
+Optional properties:
+  - nvidia,has-legacy-mode : boolean indicates whether this controller can
+operate in legacy mode (as APX 2500 / 2600). In legacy mode some
+registers are accessed through the APB_MISC base address instead of
+the USB controller.
\ No newline at end of file
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index b4c13b6..96251b0 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -394,6 +394,25 @@
#size-cells = <0>;
};
 
+   phy1: usb-phy@c5000400 {
+   compatible = "nvidia,tegra20-usb-phy";
+   reg = <0xc5000400 0x3c00>;
+   phy_type = "utmi";
+   nvidia,has-legacy-mode;
+   };
+
+   phy2: usb-phy@c5004400 {
+   compatible = "nvidia,tegra20-usb-phy";
+   reg = <0xc5004400 0x3c00>;
+   phy_type = "ulpi";
+   };
+
+   phy3: usb-phy@c5008400 {
+   compatible = "nvidia,tegra20-usb-phy";
+   reg = <0xc5008400 0x3C00>;
+   phy_type = "utmi";
+   };
+
usb@c500 {
compatible = "nvidia,tegra20-ehci", "usb-ehci";
reg = <0xc500 0x4000>;
@@ -402,6 +421,7 @@
nvidia,has-legacy-mode;
status = "disabled";
nvidia,needs-double-reset;
+   nvidia,phy = <&phy1>;
};
 
usb@c5004000 {
@@ -410,6 +430,7 @@
interrupts = <0 21 0x04>;
phy_type = "ulpi";
status = "disabled";
+   nvidia,phy = <&phy2>;
};
 
usb@c5008000 {
@@ -418,6 +439,7 @@
interrupts = <0 97 0x04>;
phy_type = "utmi";
status = "disabled";
+   nvidia,phy = <&phy3>;
};
 
sdhci@c800 {
-- 
1.7.0.4

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


[PATCH 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-16 Thread Venu Byravarasu
As Tegra PHY driver needs to access one of the Host registers,
added few APIs.

Signed-off-by: Venu Byravarasu 
---
 drivers/usb/host/ehci-tegra.c |   71 -
 drivers/usb/phy/tegra_usb_phy.c   |   51 +++
 include/linux/usb/tegra_usb_phy.h |6 +++
 3 files changed, 89 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 55a9cde..5299b01 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -2,7 +2,7 @@
  * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
  *
  * Copyright (C) 2010 Google, Inc.
- * Copyright (C) 2009 NVIDIA Corporation
+ * Copyright (C) 2009 - 2013 NVIDIA Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -33,6 +33,20 @@
 #define TEGRA_USB2_BASE0xC5004000
 #define TEGRA_USB3_BASE0xC5008000
 
+/* PORTSC registers */
+#define USB_PORTSC10x184
+#define USB_PORTSC1_PTS(x) (((x) & 0x3) << 30)
+#define USB_PORTSC1_PSPD(x)(((x) & 0x3) << 26)
+#define USB_PORTSC1_PHCD   (1 << 23)
+#define USB_PORTSC1_WKOC   (1 << 22)
+#define USB_PORTSC1_WKDS   (1 << 21)
+#define USB_PORTSC1_WKCN   (1 << 20)
+#define USB_PORTSC1_PTC(x) (((x) & 0xf) << 16)
+#define USB_PORTSC1_PP (1 << 12)
+#define USB_PORTSC1_SUSP   (1 << 7)
+#define USB_PORTSC1_PE (1 << 2)
+#define USB_PORTSC1_CCS(1 << 0)
+
 #define TEGRA_USB_DMA_ALIGN 32
 
 struct tegra_ehci_hcd {
@@ -605,6 +619,50 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
 
 #endif
 
+void tegra_ehci_set_wakeon_events(struct usb_phy *x, bool enable)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x->otg->host);
+   void __iomem *base = hcd->regs;
+   u32 wake = USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN;
+
+   val = readl(base + USB_PORTSC1);
+   if (enable)
+   val |= wake;
+   else
+   val &= ~wake;
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_wakeon_events);
+
+void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x->otg->host);
+   void __iomem *base = hcd->regs;
+
+   val = readl(base + USB_PORTSC1);
+   val &= ~USB_PORTSC1_PTS(3);
+   val |= USB_PORTSC1_PTS(pts_val & 3);
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
+
+void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x->otg->host);
+   void __iomem *base = hcd->regs;
+
+   val = readl(base + USB_PORTSC1);
+   if (enable)
+   val |= USB_PORTSC1_PHCD;
+   else
+   val &= ~USB_PORTSC1_PHCD;
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
+
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
 static int tegra_ehci_probe(struct platform_device *pdev)
@@ -616,6 +674,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev->id;
+   struct usb_phy *u_phy;
 
pdata = pdev->dev.platform_data;
if (!pdata) {
@@ -718,6 +777,16 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
usb_phy_init(&tegra->phy->u_phy);
 
+   hcd->phy = u_phy = &tegra->phy->u_phy;
+   u_phy->otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
+GFP_KERNEL);
+   if (!u_phy->otg) {
+   dev_err(&pdev->dev, "Failed to alloc memory for otg\n");
+   err = -ENOMEM;
+   goto fail_io;
+   }
+   u_phy->otg->host = hcd_to_bus(hcd);
+
err = usb_phy_set_suspend(&tegra->phy->u_phy, 0);
if (err) {
dev_err(&pdev->dev, "Failed to power on the phy\n");
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index ce1ff2a..f3b73b3 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -36,19 +36,6 @@
 
 #define ULPI_VIEWPORT  0x170
 
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x) & 0x3) << 30)
-#define   USB_PORTSC1_PSPD(x)  (((x) & 0x3) << 26)
-#define   USB_PORTSC1_PHCD (1 << 23)
-#define   USB_PORTSC1_WKOC (1 << 22)
-#define   USB_PORTSC1_WKDS (1 << 21)
-#define   USB_PORTSC1_WKCN (1 << 20)
-#define   USB_PORTSC1_PTC(x)   (((x) & 0xf) << 16)
-#define   USB_PORTSC1_PP   (1 << 12)
-#define   USB_PORTSC1_SUSP (1 << 7)
-#define   USB_PORTSC1_PE   (1 << 2)
-#define   USB_PORTSC1_CCS  (1 << 0)
-
 #define USB_SUSP_CTRL  0x400
 #define   USB_WAKE_ON_CNNT_EN_DEV  (1 << 3)
 #define   USB_WAKE_ON_DISCON_EN_DEV(1 << 4

[PATCH 0/4] usb: Supporting patches for registering Tegra USB PHY as a platform driver

2013-01-16 Thread Venu Byravarasu
As part of registering tegra USB PHY as platform driver, prepared
patches to add separate DT nodes describing Tegra USB PHY properties.
Modified instance number based processing to make use of the added
DT properties. As PHY will be registered as separate driver, removed
ehci register access from PHY driver and added APIs to ehci driver for
this purpose.

Venu Byravarasu (4):
  arm: tegra: Add DT nodes for Tegra USB PHY
  USB: PHY: Get rid of instance number to differentiate legacy
controller
  USB: PHY: Tegra: Get rid of instance number to differentiate PHY type
  usb: Add APIs to access host registers from Tegra PHY

 .../bindings/usb/nvidia,tegra20-ehci.txt   |1 +
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   14 +++
 arch/arm/boot/dts/tegra20.dtsi |   22 +
 drivers/usb/host/ehci-tegra.c  |   71 ++-
 drivers/usb/phy/tegra_usb_phy.c|  100 +++-
 include/linux/usb/tegra_usb_phy.h  |8 ++
 6 files changed, 149 insertions(+), 67 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt

--
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] module, async: async_synchronize_full() on module init iff async is used

2013-01-16 Thread Alex Riesen
On Wed, Jan 16, 2013 at 3:52 AM, Tejun Heo  wrote:
> This avoids the described deadlock because iosched module doesn't use
> async and thus wouldn't invoke async_synchronize_full().  This is
> hacky and incomplete.  It will deadlock if async module loading nests;
> however, this works around the known problem case and seems to be the
> best of bad options.

I confirm it fixes the original problem.

Tested-by: Alex Riesen 

[   27.594951] hub 1-1:1.0: state 7 ports 6 chg  evt 0004
[   27.595245] hub 1-1:1.0: port 2, status 0101, change 0001, 12 Mb/s
[   27.698995] hub 1-1:1.0: debounce: port 2: total 100ms stable 100ms
status 0x101
[   27.709977] hub 1-1:1.0: port 2 not reset yet, waiting 10ms
[   27.771888] usb 1-1.2: new high-speed USB device number 3 using ehci-pci
[   27.782871] hub 1-1:1.0: port 2 not reset yet, waiting 10ms
[   27.857503] usb 1-1.2: default language 0x0409
[   27.858248] usb 1-1.2: udev 3, busnum 1, minor = 2
[   27.858258] usb 1-1.2: New USB device found, idVendor=0781, idProduct=5408
[   27.858263] usb 1-1.2: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[   27.858267] usb 1-1.2: Product: U3 Titanium
[   27.858271] usb 1-1.2: Manufacturer: SanDisk Corporation
[   27.858275] usb 1-1.2: SerialNumber: 187A3A60F1E9
[   27.858800] usb 1-1.2: usb_probe_device
[   27.858815] usb 1-1.2: configuration #1 chosen from 1 choice
[   27.858940] usb 1-1.2: adding 1-1.2:1.0 (config #1, interface 0)
[   27.859246] usb-storage 1-1.2:1.0: usb_probe_interface
[   27.859258] usb-storage 1-1.2:1.0: usb_probe_interface - got id
[   27.859516] scsi6 : usb-storage 1-1.2:1.0
[   28.865771] io scheduler deadline registered (default)
[   28.866705] scsi 6:0:0:0: Direct-Access SanDisk  U3 Titanium
  2.18 PQ: 0 ANSI: 2
[   28.869483] sd 6:0:0:0: Attached scsi generic sg1 type 0
[   28.869700] sd 6:0:0:0: [sdb] 4013713 512-byte logical blocks:
(2.05 GB/1.91 GiB)
[   28.870197] sd 6:0:0:0: [sdb] Write Protect is off
[   28.870204] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[   28.870692] sd 6:0:0:0: [sdb] No Caching mode page present
[   28.870697] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[   28.873565] sd 6:0:0:0: [sdb] No Caching mode page present
[   28.873575] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[   28.883895]  sdb: sdb1
[   28.887775] sd 6:0:0:0: [sdb] No Caching mode page present
[   28.887783] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[   28.887789] sd 6:0:0:0: [sdb] Attached SCSI removable disk

The filesystem can be mounted and files can be read.
--
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: Does USB isochronous mode work on EHCI port?

2013-01-16 Thread Roger Quadros
On 01/04/2013 02:20 PM, Gary Thomas wrote:
> 
> 
> On Thursday, January 3, 2013 9:21:19 AM UTC-7, Felipe Balbi wrote:
> 
> Hi,
> 
> On Wednesday, January 2, 2013 10:44:50 PM UTC+2, Gary Thomas wrote:
> 
> I have a video adapter attached to my EHCI port which runs full
> speed (480Mb/s) isochronous mode.  Sadly, I never get any data
> from the device (it uses the EM28xx driver).
> This same device + driver works fine on my laptop and from what
> I can tell looking at the module debug, it's failing when
> waiting for the ISOC frame data to arrive.
> 
> Should this work?  I recall lots of discussion in the past about
> ISOC transfers not working on certain OMAP devices...
> 
> 
> which kernel are you using ? Have you tested mainline kernel ?
> 
> 
> I'm using the TI/Ubuntu kernel ( ti-ubuntu-3.4.0-1489.17)
> 
> Using the mainline would be hard as there is a lot in this kernel that
> isn't in the mainline.
> 

+Xavier, Nicolas, Herve

Finally got a chance to try this out. I used uvccapture and luvcview for
my tests.

There is a problem with the TI/Ubuntu kernel. uvccapture works but
luvcview segfaults after a few VIDEOC_QBUF operations (see log in the
end). I don't see anything wrong with the USB traces though.

After disabling all CONFIG_VIDEOBUF options in kernel config (except
CONFIG_VIDEOBUF2_CORE=m, CONFIG_VIDEOBUF2_MEMOPS=m,
CONFIG_VIDEOBUF2_VMALLOC=m) and recompiling the kernel, I could get
luvcview to work.

So the problem is not in USB EHCI but in the DMA/DMAbuf implementation
of VIDEOBUF.

cheers,
-roger

--log--
> luvcview 
> luvcview 0.2.6
> 
> init kbd.
> SDL information:[   37.955749] uvcvideo: uvc_v4l2_open
> 
>   Video driver: fbcon
>   Hardware surfaces are available (3072k video memory)
> Device information:
>   Device path:  /dev/video0
> [   38.105346] usb 1-1.3: reset high-speed USB device number 4 using ehci-omap
> [   38.439178] uvcvideo: Resuming interface 0
> [   38.443542] uvcvideo: Resuming interface 1
> [   38.456970] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCAP)
> [   38.462310] uvcvideo: uvc_v4l2_ioctl(VIDIOC_G_FMT)
> [   38.467407] uvcvideo: uvc_v4l2_ioctl(VIDIOC_G_PARM)
> [   38.472717] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FMT)
> [   38.478057] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.484100] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.490112] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.496124] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.502075] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.508117] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.514129] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.520141] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.526092] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.532135] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.538146] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.544158] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.550140] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.556152] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.562164] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.568328] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.574340] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.580291] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.586334] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.592346] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.598358] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FMT)
> [   38.603698] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.609710] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.615753] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.621765] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.627716] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.633758] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.639770] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.645782] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.651763] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.657806] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.663940] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.669952] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.675964] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.681915] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.687927] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.693939] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.699951] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.705932] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.711975] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.717987] uvcvideo: uvc_v4l2_ioctl(VIDIOC_ENUM_FRAMESIZES)
> [   38.723999] uvcvideo: uvc_v4l

Re: [PATCH v2] HID: add support for Sony RF receiver with USB product id 0x0374

2013-01-16 Thread Jiri Kosina
On Wed, 16 Jan 2013, Fernando Luis Vazquez Cao wrote:

> I noticed that the patch was tagged "for-3.9". Does this mean
> that it is too late to get it merged during the current release
> cycle?

I currently don't have anything queued for 3.8, and this particular patch 
doesn't justify a separate pull request.

Once it's in Linus' tree, it can be easily pushed out to all existing 
-stable branches (including 3.8-stable, once it's created).

If I am gfoing to be sending pull request for 3.8 to Linus still due to 
some important bugfix, I will be including this.

> If possible, I would like to get it backported to 3.7-stable (and 
> possibly 3.2 stable), since without it a whole family of Sony desktop 
> computers is unusable under Linux out of the box. Should I do it myself 
> or do you have a process in place for HID stable patches?

If the patch had

Cc: sta...@vger.kernel.org

in it, it'd be picked for -stable queue automatically. Otherwise, anyone 
is free to take it once it's in Linus' tree and sent to to 
sta...@vger.kernel.org for inclusion.

Hope this helps,

-- 
Jiri Kosina
SUSE Labs
--
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 v3 3/3] usb: chipidea: imx: Add system suspend/resume API

2013-01-16 Thread Peter Chen
During the system suspend/resume procedure, the USB also
needs to go suspend/resume procedure, this patch adds
related APIs. It is tested at i.mx6q sabrelite. Meanwhile,
it fixes the bug that the USB will out of work after
system suspend/resume.

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

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index ba9c6ef..d1467bb 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -47,6 +47,7 @@
 #define PORTSC_FPRBIT(6)
 #define PORTSC_SUSP   BIT(7)
 #define PORTSC_HSPBIT(9)
+#define PORTSC_PHCD   BIT(23) /* phy suspend mode */
 #define PORTSC_PTC(0x0FUL << 16)
 
 /* DEVLC */
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 342eab0..dd257b1 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -25,6 +25,7 @@
 #include 
 
 #include "ci.h"
+#include "bits.h"
 #include "ci13xxx_imx.h"
 
 #define pdev_to_phy(pdev) \
@@ -321,6 +322,63 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int ci13xxx_imx_suspend(struct device *dev)
+{
+   struct ci13xxx_imx_data *data =
+   platform_get_drvdata(to_platform_device(dev));
+   struct platform_device *plat_ci;
+   struct ci13xxx  *ci;
+
+   plat_ci = data->ci_pdev;
+   ci = platform_get_drvdata(plat_ci);
+
+   hw_write(ci, OP_PORTSC, PORTSC_PHCD, 1);
+
+   if (data->phy)
+   usb_phy_set_suspend(data->phy, 1);
+
+   clk_disable_unprepare(data->clk);
+
+   return 0;
+}
+
+static int ci13xxx_imx_resume(struct device *dev)
+{
+   int ret;
+   struct ci13xxx_imx_data *data =
+   platform_get_drvdata(to_platform_device(dev));
+   struct platform_device *plat_ci;
+   struct ci13xxx  *ci;
+
+   plat_ci = data->ci_pdev;
+   ci = platform_get_drvdata(plat_ci);
+
+   ret = clk_prepare_enable(data->clk);
+   if (ret) {
+   dev_err(dev,
+   "Failed to prepare or enable clock, err=%d\n", ret);
+   return ret;
+   }
+
+   if (hw_read(ci, OP_PORTSC, PORTSC_PHCD)) {
+   hw_write(ci, OP_PORTSC, PORTSC_PHCD, 0);
+   /* Some clks sync between Controller and USB PHY */
+   mdelay(1);
+   }
+
+   if (data->phy)
+   usb_phy_set_suspend(data->phy, 0);
+
+   return ret;
+}
+
+static const struct dev_pm_ops ci13xxx_imx_pm_ops = {
+   .suspend= ci13xxx_imx_suspend,
+   .resume = ci13xxx_imx_resume,
+};
+#endif
+
 static const struct of_device_id ci13xxx_imx_dt_ids[] = {
{ .compatible = "fsl,imx27-usb", },
{ /* sentinel */ }
@@ -334,6 +392,9 @@ static struct platform_driver ci13xxx_imx_driver = {
.name = "imx_usb",
.owner = THIS_MODULE,
.of_match_table = ci13xxx_imx_dt_ids,
+#ifdef CONFIG_PM
+   .pm = &ci13xxx_imx_pm_ops,
+#endif
 },
 };
 
-- 
1.7.0.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 v3 2/3] usb: mxs-phy: add set_suspend API

2013-01-16 Thread Peter Chen
It needs to call set_suspend during USB suspend/resume

Signed-off-by: Peter Chen 
---
 drivers/usb/otg/mxs-phy.c |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index 7630272..5158332 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -76,6 +76,25 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
clk_disable_unprepare(mxs_phy->clk);
 }
 
+static int mxs_phy_suspend(struct usb_phy *x, int suspend)
+{
+   struct mxs_phy *mxs_phy = to_mxs_phy(x);
+
+   if (suspend) {
+   writel_relaxed(0x, x->io_priv + HW_USBPHY_PWD);
+   writel_relaxed(BM_USBPHY_CTRL_CLKGATE,
+   x->io_priv + HW_USBPHY_CTRL_SET);
+   clk_disable_unprepare(mxs_phy->clk);
+   } else {
+   clk_prepare_enable(mxs_phy->clk);
+   writel_relaxed(BM_USBPHY_CTRL_CLKGATE,
+   x->io_priv + HW_USBPHY_CTRL_CLR);
+   writel_relaxed(0, x->io_priv + HW_USBPHY_PWD);
+   }
+
+   return 0;
+}
+
 static int mxs_phy_on_connect(struct usb_phy *phy,
enum usb_device_speed speed)
 {
@@ -137,6 +156,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
mxs_phy->phy.label  = DRIVER_NAME;
mxs_phy->phy.init   = mxs_phy_init;
mxs_phy->phy.shutdown   = mxs_phy_shutdown;
+   mxs_phy->phy.set_suspend= mxs_phy_suspend;
mxs_phy->phy.notify_connect = mxs_phy_on_connect;
mxs_phy->phy.notify_disconnect  = mxs_phy_on_disconnect;
 
-- 
1.7.0.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 v3 1/3] ARM i.MX6: change mxs usbphy clock usage

2013-01-16 Thread Peter Chen
This mxs usbphy is only needs to be on after system boots
up, and software never needs to control it anymore.
Meanwhile, usbphy's parent needs to be notified if usb
is suspend or not. So we design below mxs usbphy usage:

- usbphy1_gate and usbphy2_gate:
Their parents are dummy clock, we only needs to enable
it after system boots up.
- usbphy1 and usbphy2
Usage reserved bit for this clock, in that case, the refcount
will be updated, but without hardware changing.

Signed-off-by: Peter Chen 
---
Changes for v3:
- Add new clk for usbphy clk gate which is only used 
at system boots up process.

Changes for v2:
- Use reserved bit for usb phy clk control

 arch/arm/mach-imx/clk-imx6q.c |   26 ++
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 7f2c10c..ccb24cf 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -154,8 +154,8 @@ enum mx6q_clks {
usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg,
pll4_audio, pll5_video, pll8_mlb, pll7_usb_host, pll6_enet, ssi1_ipg,
ssi2_ipg, ssi3_ipg, rom, usbphy1, usbphy2, ldb_di0_div_3_5, 
ldb_di1_div_3_5,
-   sata_ref, sata_ref_100m, pcie_ref, pcie_ref_125m, enet_ref,
-   clk_max
+   sata_ref, sata_ref_100m, pcie_ref, pcie_ref_125m, enet_ref, 
usbphy1_gate,
+   usbphy2_gate, clk_max
 };
 
 static struct clk *clk[clk_max];
@@ -208,8 +208,21 @@ int __init mx6q_clocks_init(void)
clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB,   
"pll7_usb_host","osc", base + 0x20, 0x3);
clk[pll8_mlb]  = imx_clk_pllv3(IMX_PLLV3_MLB,   "pll8_mlb", 
"osc", base + 0xd0, 0x0);
 
-   clk[usbphy1] = imx_clk_gate("usbphy1", "pll3_usb_otg", base + 0x10, 6);
-   clk[usbphy2] = imx_clk_gate("usbphy2", "pll7_usb_host", base + 0x20, 6);
+   /*
+* Bit 20 is the reserved and read-only bit, we do this only for:
+* - Do nothing for usbphy clk_enable/disable
+* - Keep refcount when do usbphy clk_enable/disable, in that case,
+* the clk framework may need to enable/disable usbphy's parent
+*/
+   clk[usbphy1] = imx_clk_gate("usbphy1", "pll3_usb_otg", base + 0x10, 20);
+   clk[usbphy2] = imx_clk_gate("usbphy2", "pll7_usb_host", base + 0x20, 
20);
+
+   /*
+* usbphy*_gate needs to be on after system boots up, and software
+* never needs to control it anymore.
+*/
+   clk[usbphy1_gate] = imx_clk_gate("usbphy1_gate", "dummy", base + 0x10, 
6);
+   clk[usbphy2_gate] = imx_clk_gate("usbphy2_gate", "dummy", base + 0x20, 
6);
 
clk[sata_ref] = imx_clk_fixed_factor("sata_ref", "pll6_enet", 1, 5);
clk[pcie_ref] = imx_clk_fixed_factor("pcie_ref", "pll6_enet", 1, 4);
@@ -436,6 +449,11 @@ int __init mx6q_clocks_init(void)
for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
clk_prepare_enable(clk[clks_init_on[i]]);
 
+   if (IS_ENABLED(CONFIG_USB_MXS_PHY)) {
+   clk_prepare_enable(clk[usbphy1_gate]);
+   clk_prepare_enable(clk[usbphy2_gate]);
+   }
+
np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt");
base = of_iomap(np, 0);
WARN_ON(!base);
-- 
1.7.0.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: Linux 3.8-rc1 - another regression on USB :-(

2013-01-16 Thread Oliver Neukum
On Tuesday 15 January 2013 23:26:20 Woody Suwalski wrote:

> The modules are insmoded in a fixed order:
> usb-common, usbcore, xhci-hcd, ehci-hcd, uhci-hcd, ohci-hcd, usbhid, 
> usb_storage,...
> 
> If all USB is built as modules - I get read errors from USB drives when 
> accessing squash image, boot fails.
> If usb-common and usbcore are built in, system seems to crawl with a 
> very slow USB, but boots. That could be caused by timing between hcd 
> modules.

Have you checked which bus the storage device is on?
If it is attached to a companion controller that would explain the speed
issue.

> If usb-common, usbcore and ehci-hcd are built-in, all works OK like 
> "before 3.8".
> I was testing on machines  without xhci or ohci hardware, so these 
> drivers probably are not playing any role.
> I have retried initramfs with a 1s sleep between insmods to verify if it 
> is timing - still the same read errors - so the main issue is _not_ timing.
> The read errors problem is 100% reproducible for me, the blocks where 
> read fails are not fixed - every (failed) boot errors start appearing in 
> a bit different location.

Do you get read errors on the SCSI level only or also errors on the USB level?

Regards
Oliver

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


Re: [PATCH v9] usb_8dev: Add support for USB2CAN interface from 8 devices

2013-01-16 Thread Bernd Krumböck
Hi Oliver!

> When detaching the device from the CAN bus when sending/receiving CAN
> traffic
> i got these dmesg infos:
>
> [  960.047130] usb_8dev 2-1.4:1.0 can2: Unknown status/error message (0)
> [  976.544343] usb_8dev 2-1.4:1.0 can2: Unknown status/error message (0)
>

Sorry, I can't do this sort of tests myself, because my second can device
is an expensive device, without developer/test mode. ;-)

Gerd helped me with the can tests so far. (Thank you!)

The messages you see mean "Normal condition" and shouldn't be displayed.
I'll fix them in the next version.

regards,
Bernd

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