[PATCH 1/1] usb,uhci: add a new tag for virtual uhci devices

2013-06-26 Thread Li, Zhen-Hua
From: Li, Zhen-Hua zhen-h...@hp.com

There's another patch trying to fix this warning:
 Controller not stopped yet!. 
It is : 997ff893603c6455da4c5e26ba1d0f81adfecdfc .

I don't think it is appropriate to avoid auto-stop for all HP uhci
devices. So add one  tag for the virtual uhci devices, it is used
to replace wait_for_hp in the auto-stop case.

Signed-off-by: Li, Zhen-Hua zhen-h...@hp.com
---
 drivers/usb/host/uhci-hcd.h |1 +
 drivers/usb/host/uhci-hub.c |2 +-
 drivers/usb/host/uhci-pci.c |   21 +
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 6f986d8..915d5df 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -425,6 +425,7 @@ struct uhci_hcd {
/* Silicon quirks */
unsigned int oc_low:1;  /* OverCurrent bit active low */
unsigned int wait_for_hp:1; /* Wait for HP port reset */
+   unsigned int virtual_device:1;  /* For some virtual devices */
unsigned int big_endian_mmio:1; /* Big endian registers */
unsigned int big_endian_desc:1; /* Big endian descriptors */
 
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index 9189bc9..da00754 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -226,7 +226,7 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char 
*buf)
if (any_ports_active(uhci))
uhci-rh_state = UHCI_RH_RUNNING;
else if (time_after_eq(jiffies, uhci-auto_stop_time) 
-   !uhci-wait_for_hp)
+   !uhci-virtual_device)
suspend_rh(uhci, UHCI_RH_AUTO_STOPPED);
break;
 
diff --git a/drivers/usb/host/uhci-pci.c b/drivers/usb/host/uhci-pci.c
index c300bd2f7..68e6d92 100644
--- a/drivers/usb/host/uhci-pci.c
+++ b/drivers/usb/host/uhci-pci.c
@@ -110,6 +110,24 @@ static int uhci_pci_global_suspend_mode_is_broken(struct 
uhci_hcd *uhci)
return 0;
 }
 
+static int uhci_virtual_device_ids[][2] = {
+   {0x103c, 0x3300},
+   {0, 0},
+};
+static int uhci_is_virtual_device(struct uhci_hcd *uhci)
+{
+   int i;
+   struct pci_dev *dev;
+
+   dev = to_pci_dev(uhci_dev(uhci));
+   for (i = 0; uhci_virtual_device_ids[i][0] != 0; i++) {
+   if (dev-vendor == uhci_virtual_device_ids[i][0]
+dev-device == uhci_virtual_device_ids[i][1])
+   return 1;
+   }
+   return 0;
+}
+
 static int uhci_pci_init(struct usb_hcd *hcd)
 {
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
@@ -129,6 +147,9 @@ static int uhci_pci_init(struct usb_hcd *hcd)
if (to_pci_dev(uhci_dev(uhci))-vendor == PCI_VENDOR_ID_HP)
uhci-wait_for_hp = 1;
 
+   if (uhci_is_virtual_device(uhci))
+   uhci-virtual_device = 1;
+
/* Set up pointers to PCI-specific functions */
uhci-reset_hc = uhci_pci_reset_hc;
uhci-check_and_reset_hc = uhci_pci_check_and_reset_hc;
-- 
1.7.10.4

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


Re: [PATCH] staging: usbip: replace pr_warning() with pr_warn()

2013-06-26 Thread navin patidar
On Tue, Jun 25, 2013, Greg KH gre...@linuxfoundation.org said:

 On Tue, Jun 25, 2013 at 04:27:18PM +0530, navin patidar wrote:
 On Tue, Jun 25, 2013, Greg KH gre...@linuxfoundation.org said:

  On Fri, Jun 21, 2013 at 03:01:04PM +0530, navin patidar wrote:
  pr_warn() is preferred over pr_warning().
 
  And dev_warn() is preferred over both of them, can you convert the code
  to use that instead?
 

 struct device is not available in usbip_start_eh()  which is required
 for dev_warn().

 usbip_device's containers struct stub_device and struct  vhci_device
 both have member structure usb_device but inside usbip_start_eh(), it
 is difficult to determine  to which container struct usbip_device
 belongs, thus container_of() can not be used here to get struct
 usb_device.

 Then the code should be reworked in order to be able to properly
 determine that.


struct usbip_device has enum type usbip_side variable which can be
used to determine container of usbip_device.
I should have looked usbip_device struct more carefully.
sorry for previous wrong info.

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


Re: [PATCH 2/4] ARM: dts: exynos4: Add node for hsotg

2013-06-26 Thread Jingoo Han
On Wednesday, June 26, 2013 12:38 AM, Tomasz Figa wrote:
 
 This patch adds device tree node for USB HSOTG controller present on
 Exynos4 SoCs.
 
 Signed-off-by: Tomasz Figa t.f...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

It looks good.

Reviewed-by: Jingoo Han jg1@samsung.com

Best regards,
Jingoo Han

 ---
  arch/arm/boot/dts/exynos4.dtsi | 9 +
  1 file changed, 9 insertions(+)
 
 diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
 index 359694c..d53b9da 100644
 --- a/arch/arm/boot/dts/exynos4.dtsi
 +++ b/arch/arm/boot/dts/exynos4.dtsi
 @@ -119,6 +119,15 @@
   status = disabled;
   };
 
 + hsotg@1248 {
 + compatible = samsung,s3c6400-hsotg;
 + reg = 0x1248 0x2;
 + interrupts = 0 71 0;
 + clocks = clock 305;
 + clock-names = otg;
 + status = disabled;
 + };
 +
   sdhci@1251 {
   compatible = samsung,exynos4210-sdhci;
   reg = 0x1251 0x100;
 --
 1.8.2.1
 


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


Re: [PATCH 3/4] ARM: dts: exynos4: Add nodes for USB PHY block

2013-06-26 Thread Jingoo Han
On Wednesday, June 26, 2013 12:38 AM, Tomasz Figa wrote:
 
 This patch adds device tree nodes for USB OTG PHYs of Exynos4210 and
 Exynos4x12 SoCs.
 
 Signed-off-by: Tomasz Figa t.f...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

It looks good.

Reviewed-by: Jingoo Han jg1@samsung.com

Best regards,
Jingoo Han


 ---
  arch/arm/boot/dts/exynos4210.dtsi | 15 +++
  arch/arm/boot/dts/exynos4x12.dtsi | 15 +++
  2 files changed, 30 insertions(+)
 
 diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
 b/arch/arm/boot/dts/exynos4210.dtsi
 index 54710de..3c71ea5 100644
 --- a/arch/arm/boot/dts/exynos4210.dtsi
 +++ b/arch/arm/boot/dts/exynos4210.dtsi
 @@ -114,6 +114,21 @@
   interrupts = 2 4;
   };
 
 + usbphy@125B {
 + compatible = samsung,exynos4210-usb2phy;
 + reg = 0x125B 0x100;
 + clocks = clock 305;
 + clock-names = otg;
 + status = disabled;
 + ranges;
 + #address-cells = 1;
 + #size-cells = 1;
 +
 + usbphy-sys {
 + reg = 0x10020704 0x8;
 + };
 + };
 +
   g2d@1280 {
   compatible = samsung,s5pv210-g2d;
   reg = 0x1280 0x1000;
 diff --git a/arch/arm/boot/dts/exynos4x12.dtsi 
 b/arch/arm/boot/dts/exynos4x12.dtsi
 index e3380a7..267ed95 100644
 --- a/arch/arm/boot/dts/exynos4x12.dtsi
 +++ b/arch/arm/boot/dts/exynos4x12.dtsi
 @@ -79,4 +79,19 @@
   interrupts = 0 89 0;
   status = disabled;
   };
 +
 + usbphy@125B {
 + compatible = samsung,exynos4x12-usb2phy;
 + reg = 0x125B 0x100;
 + clocks = clock 305;
 + clock-names = otg;
 + status = disabled;
 + ranges;
 + #address-cells = 1;
 + #size-cells = 1;
 +
 + usbphy-sys {
 + reg = 0x10020704 0x8;
 + };
 + };
  };
 --
 1.8.2.1
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-samsung-soc 
 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


[RFC] [PATCH] Debugfs support for EHCI testing modes

2013-06-26 Thread Tim Sander
Hi

I have just written a ehci testing driver which enables the testing modes used
for hw testing via a file in debugfs.  This patch is for 3.4.47 not any usb
branch. But if this driver is ready for mainline i will be happy to port it to
whatever branch you wish.

The only problem with the patch is that it is currently working on hw registers
as the usb control msg in this patch is not working. For the time beeing i just
commented out the usb_control_msg call and fiddled with the registers directly.
This is one thing which might not be mainline compatible?

The call not working is:
status = usb_control_msg(hub, usb_sndctrlpipe(hub,0),
   USB_REQ_SET_FEATURE, 
USB_RT_PORT, USB_PORT_FEAT_TEST,
   i  8 | hub-portnum, NULL, 0, 
1000);
   ^ this might be 
wrong?

I have the strong suspicion that the marked agument is wrong? The direct 
manipulation
of the portsc register works as expected. 

The testmodes array is magic in a way that the offset of the values corresponds 
directly
with the PTC field (Bits 19-16) of the Port Status Control register.

Also there is a driver which does the tests with a special usb test plug:
http://code.google.com/p/bricked/source/browse/drivers/usb/misc/ehset.c
Its also sending these usb_control_msg but these are also not working.

So if this usb_control_msg is working it would also be nice to get this driver 
mainlined.
Any hints whats needed to get this into mainline?

Best regards
Tim

Subject: [PATCH 20/23] usb-ehci: add usb testmodes to debugfs

---
 drivers/usb/host/ehci-dbg.c |  122 +++
 1 file changed, 122 insertions(+)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 680e1a3..8db727b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -18,6 +18,31 @@
 
 /* this file is part of ehci-hcd.c */
 
+#define PORTSC_OFFSET  0x184
+
+#define PTC_SHIFT  16
+#define PTC_MASK   (0xF  PTC_SHIFT)
+#define TEST_MODE_DISABLE  0
+#define J_STATE1
+#define K_STATE2
+#define SE0_NAK3
+#define PACKET 4
+#define FORCE_ENABLE_HS5
+#define FORCE_ENABLE_FS6
+#define FORCE_ENABLE_LS7
+#define TESTMODES_SIZE 8
+
+static char *testmodes[TESTMODES_SIZE] = {
+   TEST_MODE_DISABLE,
+   J_STATE,
+   K_STATE,
+   SE0,
+   PACKET,
+   FORCE_ENABLE_HS,
+   FORCE_ENABLE_FS,
+   FORCE_ENABLE_LS
+};
+
 #define ehci_dbg(ehci, fmt, args...) \
dev_dbg (ehci_to_hcd(ehci)-self.controller , fmt , ## args )
 #define ehci_err(ehci, fmt, args...) \
@@ -351,6 +376,9 @@ static inline void remove_debug_files (struct ehci_hcd 
*bus) { }
 static int debug_async_open(struct inode *, struct file *);
 static int debug_periodic_open(struct inode *, struct file *);
 static int debug_registers_open(struct inode *, struct file *);
+static int debug_testmodes_open(struct inode *, struct file *);
+static ssize_t debug_testmodes_write(struct file *file,const char __user 
*buffer,
+   size_t count, loff_t *ppos);
 static int debug_async_open(struct inode *, struct file *);
 static ssize_t debug_lpm_read(struct file *file, char __user *user_buf,
   size_t count, loff_t *ppos);
@@ -382,6 +410,14 @@ static const struct file_operations debug_registers_fops = 
{
.release= debug_close,
.llseek = default_llseek,
 };
+static const struct file_operations debug_testmodes_fops = {
+   .owner  = THIS_MODULE,
+   .open   = debug_testmodes_open,
+   .read   = debug_output,
+   .write  = debug_testmodes_write,
+   .release= debug_close,
+   .llseek = default_llseek,
+};
 static const struct file_operations debug_lpm_fops = {
.owner  = THIS_MODULE,
.open   = simple_open,
@@ -867,6 +903,32 @@ done:
return buf-alloc_size - size;
 }
 
+static ssize_t fill_testmodes_buffer(struct debug_buffer *buf) 
+{
+   struct usb_hcd  *hcd;
+   struct ehci_hcd *ehci;
+   unsigned long   flags;
+   unsignedtemp, size, i, ptc;
+   char*next;
+
+   hcd = bus_to_hcd(buf-bus);
+   ehci = hcd_to_ehci (hcd);
+   next = buf-output_buf;
+   size = buf-alloc_size;
+   spin_lock_irqsave (ehci-lock, flags);
+   ptc = (readl(hcd-regs + PORTSC_OFFSET)  PTC_MASK)  PTC_SHIFT;
+   for(i = 0; i  TESTMODES_SIZE; i++) {
+   if(ptc == i) 
+   temp = scnprintf(next,size,- %s\n,testmodes[i]);
+   else
+   temp = 

[PATCH v2] USB: check sg buffer size in usb_submit_urb

2013-06-26 Thread Ming Lei
USB spec stats that short packet can only appear at the end
of transfer. Because lost of HC(EHCI/UHCI/OHCI/...) can't
build a full packet from discontinuous buffers, we introduce
the limit in usb_submit_urb() to avoid such kind of bad sg buffers
coming from driver.

The limit might be a bit strict:
- platform has iommu to do sg list mapping
- some host controllers may support to build full packet from
discontinuous buffers.

But considered that most of HCs don't support that, and driver
need work well or keep consistent on different HCs and ARCHs, we
have to introduce the limit.

Currently, only usbtest is reported to pass such sg buffers to HC,
and other users(mass storage, usbfs) don't have the problem.

We don't check it on USB wireless device, because:
- wireless devices can't be attached to common USB
  bus(EHCI/UHCI/OHCI/...)
- the max packet size of endpoint may be odd, and often can't
devide 4KB which is a typical usage in usb mass storage application

Reported-by: Konstantin Filatov kfila...@parallels.com
Reported-by: Denis V. Lunev d...@openvz.org
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Felipe Balbi ba...@ti.com
Signed-off-by: Ming Lei ming@canonical.com
---
V2:
- don't check sg buffer size on wireless device
V1:
- avoid checking the last element in if(...) as Alan suggested
- rewrite doc according to Alan's suggestion

 drivers/usb/core/urb.c |   11 +++
 include/linux/usb.h|4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 16927fa..c76b7df 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -7,6 +7,7 @@
 #include linux/usb.h
 #include linux/wait.h
 #include linux/usb/hcd.h
+#include linux/scatterlist.h
 
 #define to_urb(d) container_of(d, struct urb, kref)
 
@@ -413,6 +414,16 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
urb-iso_frame_desc[n].status = -EXDEV;
urb-iso_frame_desc[n].actual_length = 0;
}
+   } else {
+   /* check sg buffer size */
+   if (dev-speed != USB_SPEED_WIRELESS  urb-num_sgs) {
+   struct scatterlist *sg;
+   int i;
+
+   for_each_sg(urb-sg, sg, urb-num_sgs - 1, i)
+   if (sg-length % max)
+   return -EINVAL;
+   }
}
 
/* the I/O buffer must be mapped/unmapped, except when length=0 */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index a232b7e..e99b2a1 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1258,7 +1258,9 @@ typedef void (*usb_complete_t)(struct urb *);
  * the device driver is saying that it provided this DMA address,
  * which the host controller driver should use in preference to the
  * transfer_buffer.
- * @sg: scatter gather buffer list
+ * @sg: scatter gather buffer list, the buffer size of each element in
+ * the list (except the last) must be divisible by the endpoint's
+ * max packet size
  * @num_mapped_sgs: (internal) number of mapped sg entries
  * @num_sgs: number of entries in the sg list
  * @transfer_buffer_length: How big is transfer_buffer.  The transfer may
-- 
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: [PATCH v1 1/3] usb: musb: core: added musb_restart() API to handle babble condition

2013-06-26 Thread Felipe Balbi
On Wed, May 29, 2013 at 06:37:02PM +0530, Ravi Babu wrote:
 Added musb_restart() API, used for restart of the musb controller by
 the glue layer, when there is babble condition occured on the bus.
 
 During babble condition, the musb controller will remove the session
 and no longer in host-mode. As part of recovery this API can be used
 to restart the musb controller.
 
 Signed-off-by: Ravi Babu ravib...@ti.com
 ---
  drivers/usb/musb/musb_core.c |   24 
  drivers/usb/musb/musb_core.h |1 +
  2 files changed, 25 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
 index 37a261a..ab6fa39 100644
 --- a/drivers/usb/musb/musb_core.c
 +++ b/drivers/usb/musb/musb_core.c
 @@ -1373,6 +1373,30 @@ static int ep_config_from_hw(struct musb *musb)
   return 0;
  }
  
 +/*
 + * musb_restart - restarts musb controller
 + * @param musb the controller
 + */
 +int musb_restart(struct musb *musb)
 +{
 + int status = 0;
 +
 + /* during babble condition the musb controller removes the
 +  * session bit and the fifo table initialized value get changed
 +  */
 + if (musb-dyn_fifo)
 + status = ep_config_from_table(musb);
 + else
 + status = ep_config_from_hw(musb);
 +
 + /* starts session */
 + if (!status)
 + musb_start(musb);
 +
 + return status;
 +}
 +EXPORT_SYMBOL_GPL(musb_restart);

this sort of function should never be exposed outside of MUSB core
itself. This points to a big problem somewhere else.

let me continue reading the other two patches...

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v1 2/3] usb: musb: core: added babble recovery func-ptr to musb-ops

2013-06-26 Thread Felipe Balbi
Hi,

On Wed, May 29, 2013 at 06:37:03PM +0530, Ravi Babu wrote:
 Adding babble_recovery operation as part of musb-ops, used
 to recover from babble condition during babble interrupt.
 
 Signed-off-by: Ravi Babu ravib...@ti.com
 ---
  drivers/usb/musb/musb_core.c |6 ++
  drivers/usb/musb/musb_core.h |7 +++
  2 files changed, 13 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
 index ab6fa39..411c29d 100644
 --- a/drivers/usb/musb/musb_core.c
 +++ b/drivers/usb/musb/musb_core.c
 @@ -857,6 +857,12 @@ b_host:
   }
   }
  
 + /* handle babble condition */
 + if (int_usb  MUSB_INTR_BABBLE) {
 + pr_info(babble: restarting the musb controller..);
 + musb_babble_recovery(musb);
 + }
 +
  #if 0
  /* REVISIT ... this would be for multiplexing periodic endpoints, or
   * supporting transfer phasing to prevent exceeding ISO bandwidth
 diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
 index f96e899..bf37dc9 100644
 --- a/drivers/usb/musb/musb_core.h
 +++ b/drivers/usb/musb/musb_core.h
 @@ -213,6 +213,8 @@ struct musb_platform_ops {
   int (*adjust_channel_params)(struct dma_channel *channel,
   u16 packet_sz, u8 *mode,
   dma_addr_t *dma_addr, u32 *len);
 +
 + void(*babble_recovery)(struct musb *musb);

I don't get why can't 'babble_recovery' be generic. Why do we need each
glue layer to implement it ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v1 3/3] usb: musb: dsps: handle babble condition for dsps platform

2013-06-26 Thread Felipe Balbi
Hi,

On Wed, May 29, 2013 at 06:37:04PM +0530, Ravi Babu wrote:
 @@ -428,6 +436,29 @@ static int dsps_musb_exit(struct musb *musb)
   return 0;
  }
  
 +static void dsps_musb_restart(struct musb *musb)
 +{
 + struct device *dev = musb-controller;
 + struct dsps_glue *glue = dev_get_drvdata(dev-parent);
 + const struct dsps_musb_wrapper *wrp = glue-wrp;
 + void __iomem *reg_base = musb-ctrl_base;
 +
 + /* Reset the musb */
 + dsps_writel(reg_base, wrp-control, (1  wrp-reset));
 + udelay(100);
 +
 + /* Stop the on-chip PHY and its PLL. */
 + usb_phy_vbus_off(musb-xceiv);
 + udelay(100);
 +
 + /* Start the on-chip PHY and its PLL. */
 + usb_phy_vbus_on(musb-xceiv);
 + udelay(100);
 +
 + /* reinit the endpoint fifo table and restart musb */
 + musb_restart(musb);

everything here, except for the glue reset, is generic. The thing is
that I don't really think the IP needs to be reset to recover from
babble.

Babble is a valid error condition, it's not even fatal right.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 0/2] *** SUBJECT HERE ***

2013-06-26 Thread Anders Hammarquist
In a message of Tue, 25 Jun 2013 16:39:11 -0700, Greg KH writes:
 Indeed. I'd already had some (failed) thoughts about how to handle it
 nicely. Now I've had another think through, and I have something which
 deals with it and at least complains if TI_EXTRA_VID_PID_COUNT is changed
 without changing the initializer. Patch 2/2

Why don't we just drop the extra id thing entirely?  The usb-serial
subsystem handles new device ids being added dynamically from sysfs for
a long time now.  Removing this module option would clean up the code a
lot, and prevent these errors from ever happening again.

Aha, yes, I'm all for that (had I only known I'd have done that to start
with). I'll look in to it.

/Anders
--
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 v1 2/3] usb: musb: core: added babble recovery func-ptr to musb-ops

2013-06-26 Thread B, Ravi
Felipe

 
 On Wed, May 29, 2013 at 06:37:03PM +0530, Ravi Babu wrote:
  Adding babble_recovery operation as part of musb-ops, used to recover
  from babble condition during babble interrupt.
 
  Signed-off-by: Ravi Babu ravib...@ti.com
  ---
   drivers/usb/musb/musb_core.c |6 ++
   drivers/usb/musb/musb_core.h |7 +++
   2 files changed, 13 insertions(+), 0 deletions(-)
 
  diff --git a/drivers/usb/musb/musb_core.c
  b/drivers/usb/musb/musb_core.c index ab6fa39..411c29d 100644
  --- a/drivers/usb/musb/musb_core.c
  +++ b/drivers/usb/musb/musb_core.c
  @@ -857,6 +857,12 @@ b_host:
  }
  }
 
  +   /* handle babble condition */
  +   if (int_usb  MUSB_INTR_BABBLE) {
  +   pr_info(babble: restarting the musb controller..);
  +   musb_babble_recovery(musb);
  +   }
  +
   #if 0
   /* REVISIT ... this would be for multiplexing periodic endpoints, or
* supporting transfer phasing to prevent exceeding ISO bandwidth
  diff --git a/drivers/usb/musb/musb_core.h
  b/drivers/usb/musb/musb_core.h index f96e899..bf37dc9 100644
  --- a/drivers/usb/musb/musb_core.h
  +++ b/drivers/usb/musb/musb_core.h
  @@ -213,6 +213,8 @@ struct musb_platform_ops {
  int (*adjust_channel_params)(struct dma_channel *channel,
  u16 packet_sz, u8 *mode,
  dma_addr_t *dma_addr, u32 *len);
  +
  +   void(*babble_recovery)(struct musb *musb);
 
 I don't get why can't 'babble_recovery' be generic. Why do we need each glue
 layer to implement it ?
 

Babble is generic, but recovery mechanism is nothing but reset of usbss which 
is SoC dependent and followed by generic restart of the musb controller. 
That is why musb_restart() API is exported used by all glue in babble recovery.

--
Ravi B
--
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 v1 2/3] usb: musb: core: added babble recovery func-ptr to musb-ops

2013-06-26 Thread Felipe Balbi
On Wed, Jun 26, 2013 at 10:37:39AM +0200, B, Ravi wrote:
 Felipe
 
  
  On Wed, May 29, 2013 at 06:37:03PM +0530, Ravi Babu wrote:
   Adding babble_recovery operation as part of musb-ops, used to recover
   from babble condition during babble interrupt.
  
   Signed-off-by: Ravi Babu ravib...@ti.com
   ---
drivers/usb/musb/musb_core.c |6 ++
drivers/usb/musb/musb_core.h |7 +++
2 files changed, 13 insertions(+), 0 deletions(-)
  
   diff --git a/drivers/usb/musb/musb_core.c
   b/drivers/usb/musb/musb_core.c index ab6fa39..411c29d 100644
   --- a/drivers/usb/musb/musb_core.c
   +++ b/drivers/usb/musb/musb_core.c
   @@ -857,6 +857,12 @@ b_host:
 }
 }
  
   + /* handle babble condition */
   + if (int_usb  MUSB_INTR_BABBLE) {
   + pr_info(babble: restarting the musb controller..);
   + musb_babble_recovery(musb);
   + }
   +
#if 0
/* REVISIT ... this would be for multiplexing periodic endpoints, or
 * supporting transfer phasing to prevent exceeding ISO bandwidth
   diff --git a/drivers/usb/musb/musb_core.h
   b/drivers/usb/musb/musb_core.h index f96e899..bf37dc9 100644
   --- a/drivers/usb/musb/musb_core.h
   +++ b/drivers/usb/musb/musb_core.h
   @@ -213,6 +213,8 @@ struct musb_platform_ops {
 int (*adjust_channel_params)(struct dma_channel *channel,
 u16 packet_sz, u8 *mode,
 dma_addr_t *dma_addr, u32 *len);
   +
   + void(*babble_recovery)(struct musb *musb);
  
  I don't get why can't 'babble_recovery' be generic. Why do we need each glue
  layer to implement it ?
  
 
 Babble is generic, but recovery mechanism is nothing but reset of
 usbss which is SoC dependent and followed by generic restart of the
 musb controller. 

and that's what I don't get. Why do you need to reset usbss ?

-- 
balbi


signature.asc
Description: Digital signature


[PATCH] usb: host: xhci-plat: Enable XHCI_SPURIOUS_SUCCESS quirk for xhci-plat

2013-06-26 Thread George Cherian
Synopsis xhci controllers with hci_version  0.96 gives spurious success
events on short packet completion. During webcam capture the
ERROR Transfer event TRB DMA ptr not part of current TD was observed.
The same application works fine with synopsis controllers hci_version 0.96.

Signed-off-by: George Cherian george.cher...@ti.com
---
 drivers/usb/host/xhci-plat.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 93ad67e..e63c6d3 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -25,6 +25,16 @@ static void xhci_plat_quirks(struct device *dev, struct 
xhci_hcd *xhci)
 * dev struct in order to setup MSI
 */
xhci-quirks |= XHCI_BROKEN_MSI;
+
+   /*
+* In some xhci controllers which follows xhci 1.0 spec gives a spurious
+* success event after a short transfer. This quirk will ignore such
+* spurious event. Hit this issue in synopsis xhci controllers with
+* hci_version  0.96
+*/
+
+   if (xhci-hci_version  0x96)
+   xhci-quirks |= XHCI_SPURIOUS_SUCCESS;
 }
 
 /* called during probe() after chip reset completes */
-- 
1.8.1.4

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


Re: [PATCH] usb: host: xhci-plat: Enable XHCI_SPURIOUS_SUCCESS quirk for xhci-plat

2013-06-26 Thread Felipe Balbi
Hi,

On Wed, Jun 26, 2013 at 02:28:57PM +0530, George Cherian wrote:
 Synopsis xhci controllers with hci_version  0.96 gives spurious success
 events on short packet completion. During webcam capture the
 ERROR Transfer event TRB DMA ptr not part of current TD was observed.
 The same application works fine with synopsis controllers hci_version 0.96.
 
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
  drivers/usb/host/xhci-plat.c | 10 ++
  1 file changed, 10 insertions(+)
 
 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index 93ad67e..e63c6d3 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
 @@ -25,6 +25,16 @@ static void xhci_plat_quirks(struct device *dev, struct 
 xhci_hcd *xhci)
* dev struct in order to setup MSI
*/
   xhci-quirks |= XHCI_BROKEN_MSI;
 +
 + /*
 +  * In some xhci controllers which follows xhci 1.0 spec gives a spurious
 +  * success event after a short transfer. This quirk will ignore such
 +  * spurious event. Hit this issue in synopsis xhci controllers with
 +  * hci_version  0.96
 +  */
 +
 + if (xhci-hci_version  0x96)
 + xhci-quirks |= XHCI_SPURIOUS_SUCCESS;
  }

doesn't look like the correct way to do this. What if enabling that
quirk on hosts which don't have the quirk cause problems ?

I would suggest adding a platform_data which (in our case) dwc3 will
pass to xhci-plat. Then you can do proper revision detection of the
synopsys controller and set the quirk only on the failing hosts.

BTW, do you have the STARS number for this errata ?

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v1 2/3] usb: musb: core: added babble recovery func-ptr to musb-ops

2013-06-26 Thread B, Ravi
Hi Felipe

@@ -213,6 +213,8 @@ struct musb_platform_ops {
int (*adjust_channel_params)(struct dma_channel *channel,
u16 packet_sz, u8 *mode,
dma_addr_t *dma_addr, u32 *len);
+
+   void(*babble_recovery)(struct musb *musb);
  
   I don't get why can't 'babble_recovery' be generic. Why do we need
   each glue layer to implement it ?
  
 
  Babble is generic, but recovery mechanism is nothing but reset of
  usbss which is SoC dependent and followed by generic restart of the
  musb controller.
 
 and that's what I don't get. Why do you need to reset usbss ?

On babble condition, the session bit is removed by mentor, hence to make musb 
work
1) setting the session alone will not help.
2) restart the usbss and setting session also not helped.
3) musb works only after usbss reset followed by epfifo table init and 
re-enable all interrupts, then set the session. 

The mentor IP guys (synopsis) confirmed that during babble condition, 
controller is stopped. Only recover is to restart completely, usbss reset,  
reinit epfifo table,  set the session. 

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


[PATCH] usb: dwc3: core: continue probe even if usb3 phy is not available

2013-06-26 Thread George Cherian
There can be configurations in which DWC3 is hoooked up only to USB2 PHY.
In such cases we should not return -EPROBE_DEFER, rather continue probe
even if there is no USB3 PHY.

Signed-off-by: George Cherian george.cher...@ti.com
---
 drivers/usb/dwc3/core.c | 31 ---
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c35d49d..d5e6f3e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -100,7 +100,9 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
dwc3_writel(dwc-regs, DWC3_GUSB2PHYCFG(0), reg);
 
usb_phy_init(dwc-usb2_phy);
-   usb_phy_init(dwc-usb3_phy);
+
+   if (dwc-usb3_phy)
+   usb_phy_init(dwc-usb3_phy);
mdelay(100);
 
/* Clear USB3 PHY reset */
@@ -360,7 +362,9 @@ err0:
 static void dwc3_core_exit(struct dwc3 *dwc)
 {
usb_phy_shutdown(dwc-usb2_phy);
-   usb_phy_shutdown(dwc-usb3_phy);
+
+   if (dwc-usb3_phy)
+   usb_phy_shutdown(dwc-usb3_phy);
 }
 
 #define DWC3_ALIGN_MASK(16 - 1)
@@ -460,12 +464,19 @@ static int dwc3_probe(struct platform_device *pdev)
if (ret == -ENXIO)
return ret;
 
+   /*
+* In  some cases we wont have a USB3 PHY, in such cases
+* if we return EPROBE_DEFER we would never complete the
+* probe. Just print error and continue.
+*/
dev_err(dev, no usb3 phy configured\n);
-   return -EPROBE_DEFER;
+   dwc-usb3_phy = NULL;
}
 
usb_phy_set_suspend(dwc-usb2_phy, 0);
-   usb_phy_set_suspend(dwc-usb3_phy, 0);
+
+   if (dwc-usb3_phy)
+   usb_phy_set_suspend(dwc-usb3_phy, 0);
 
spin_lock_init(dwc-lock);
platform_set_drvdata(pdev, dwc);
@@ -604,7 +615,9 @@ static int dwc3_remove(struct platform_device *pdev)
struct dwc3 *dwc = platform_get_drvdata(pdev);
 
usb_phy_set_suspend(dwc-usb2_phy, 1);
-   usb_phy_set_suspend(dwc-usb3_phy, 1);
+
+   if (dwc-usb3_phy)
+   usb_phy_set_suspend(dwc-usb3_phy, 1);
 
pm_runtime_put(pdev-dev);
pm_runtime_disable(pdev-dev);
@@ -700,7 +713,9 @@ static int dwc3_suspend(struct device *dev)
dwc-gctl = dwc3_readl(dwc-regs, DWC3_GCTL);
spin_unlock_irqrestore(dwc-lock, flags);
 
-   usb_phy_shutdown(dwc-usb3_phy);
+   if (dwc-usb3_phy)
+   usb_phy_shutdown(dwc-usb3_phy);
+
usb_phy_shutdown(dwc-usb2_phy);
 
return 0;
@@ -711,7 +726,9 @@ static int dwc3_resume(struct device *dev)
struct dwc3 *dwc = dev_get_drvdata(dev);
unsigned long   flags;
 
-   usb_phy_init(dwc-usb3_phy);
+   if (dwc-usb3_phy)
+   usb_phy_init(dwc-usb3_phy);
+
usb_phy_init(dwc-usb2_phy);
msleep(100);
 
-- 
1.8.1.4

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


[PATCH v2] staging: usbip: replace pr_warning() with dev_warn().

2013-06-26 Thread navin patidar
dev_warn() is preferred over pr_warning().

container_of() is used to get usb_driver pointer from usbip_device container
(stub_device or vhci_device), to get device structure required for dev_warn().

Signed-off-by: navin patidar nav...@cdac.in
---
 drivers/staging/usbip/usbip_event.c |   14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/usbip/usbip_event.c 
b/drivers/staging/usbip/usbip_event.c
index 82123be..3bd1b94 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -21,6 +21,8 @@
 #include linux/export.h

 #include usbip_common.h
+#include stub.h
+#include vhci.h

 static int event_handler(struct usbip_device *ud)
 {
@@ -85,7 +87,17 @@ int usbip_start_eh(struct usbip_device *ud)

ud-eh = kthread_run(event_handler_loop, ud, usbip_eh);
if (IS_ERR(ud-eh)) {
-   pr_warning(Unable to start control thread\n);
+   struct device dev;
+   if (ud-side == USBIP_STUB) {
+   struct stub_device *sdev;
+   sdev = container_of(ud, struct stub_device, ud);
+   dev = sdev-udev-dev;
+   } else {
+   struct vhci_device *vdev;
+   vdev = container_of(ud, struct vhci_device, ud);
+   dev = vdev-udev-dev;
+   }
+   dev_warn(dev, Unable to start control thread\n);
return PTR_ERR(ud-eh);
}

--
1.7.10.4

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


[PATCH 1/4] usb: phy: tegra: Add support for device tree-based vbus regulator control

2013-06-26 Thread Mikko Perttunen
After this patch, usb vbus regulators for tegra usb phy devices can be specified
with the device tree attribute vbus-supply = x where x is a regulator defined
in the device tree.

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 drivers/usb/phy/phy-tegra-usb.c   | 24 
 include/linux/usb/tegra_usb_phy.h |  1 +
 2 files changed, 25 insertions(+)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index d7d6bd7..6122590 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -34,6 +34,7 @@
 #include asm/mach-types.h
 #include linux/usb/ehci_def.h
 #include linux/usb/tegra_usb_phy.h
+#include linux/regulator/consumer.h
 
 #define ULPI_VIEWPORT  0x170
 
@@ -250,12 +251,24 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
return PTR_ERR(phy-pad_clk);
}
 
+   phy-vbus = devm_regulator_get(phy-dev, vbus);
+   /* On some boards, the VBUS regulator doesn't need to be controlled */
+   if (IS_ERR(phy-vbus)) {
+   if (PTR_ERR(phy-vbus) == -ENODEV) {
+   dev_notice(phy-dev, no vbus regulator);
+   phy-vbus = NULL;
+   } else {
+   return PTR_ERR(phy-vbus);
+   }
+   }
+
return 0;
 }
 
 static void utmip_pad_power_on(struct tegra_usb_phy *phy)
 {
unsigned long val, flags;
+   int err;
void __iomem *base = phy-pad_regs;
 
clk_prepare_enable(phy-pad_clk);
@@ -280,6 +293,14 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy)
spin_unlock_irqrestore(utmip_pad_lock, flags);
 
clk_disable_unprepare(phy-pad_clk);
+
+   if (phy-vbus) {
+   err = regulator_enable(phy-vbus);
+   if (err)
+   dev_err(phy-dev,
+   failed to enable usb vbus regulator: %d\n,
+   err);
+   }
 }
 
 static int utmip_pad_power_off(struct tegra_usb_phy *phy)
@@ -306,6 +327,9 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy)
 
clk_disable_unprepare(phy-pad_clk);
 
+   if (phy-vbus)
+   regulator_disable(phy-vbus);
+
return 0;
 }
 
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index d2ca919..2b5fa94 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -55,6 +55,7 @@ struct tegra_usb_phy {
struct clk *clk;
struct clk *pll_u;
struct clk *pad_clk;
+   struct regulator *vbus;
enum tegra_usb_phy_mode mode;
void *config;
struct usb_phy *ulpi;
-- 
1.8.1.5

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


[PATCH 0/4] usb: tegra: Replace nvidia,vbus-gpio property with vbus-supply

2013-06-26 Thread Mikko Perttunen
This patchset removes the ehci-tegra device tree property nvidia,vbus-gpio
and adds support for the vbus-supply property to phy-tegra-usb.

Mikko Perttunen (4):
  usb: phy: tegra: Add support for device tree-based vbus regulator
control
  usb: host: tegra: Remove direct vbus regulator control using GPIOs
  Documentation: devicetree: phy-tegra-usb: Add vbus-supply property for
host mode PHYs
  ARM: dts: tegra20: Remove obsolete vbus-gpio properties

 .../bindings/usb/nvidia,tegra20-usb-phy.txt|  3 ++
 arch/arm/boot/dts/tegra20-seaboard.dts |  1 -
 arch/arm/boot/dts/tegra20-trimslice.dts|  1 -
 arch/arm/boot/dts/tegra20-whistler.dts |  2 --
 drivers/usb/host/ehci-tegra.c  | 34 +-
 drivers/usb/phy/phy-tegra-usb.c| 24 +++
 include/linux/usb/tegra_usb_phy.h  |  1 +
 7 files changed, 29 insertions(+), 37 deletions(-)

-- 
1.8.1.5

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


[PATCH 4/4] ARM: dts: tegra20: Remove obsolete vbus-gpio properties

2013-06-26 Thread Mikko Perttunen
USB VBUS regulators are now specified with the vbus-supply property
instead of vbus-gpio, so remove the obsolete properties.

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 arch/arm/boot/dts/tegra20-seaboard.dts  | 1 -
 arch/arm/boot/dts/tegra20-trimslice.dts | 1 -
 arch/arm/boot/dts/tegra20-whistler.dts  | 2 --
 3 files changed, 4 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
b/arch/arm/boot/dts/tegra20-seaboard.dts
index ab177b4..2ab4775 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -566,7 +566,6 @@
 
usb@c500 {
status = okay;
-   nvidia,vbus-gpio = gpio TEGRA_GPIO(D, 0) GPIO_ACTIVE_HIGH;
dr_mode = otg;
};
 
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts 
b/arch/arm/boot/dts/tegra20-trimslice.dts
index 1701599..bea4aaa 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -312,7 +312,6 @@
 
usb@c500 {
status = okay;
-   nvidia,vbus-gpio = gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH;
};
 
usb-phy@c500 {
diff --git a/arch/arm/boot/dts/tegra20-whistler.dts 
b/arch/arm/boot/dts/tegra20-whistler.dts
index ea078ab..e07f210 100644
--- a/arch/arm/boot/dts/tegra20-whistler.dts
+++ b/arch/arm/boot/dts/tegra20-whistler.dts
@@ -509,7 +509,6 @@
 
usb@c500 {
status = okay;
-   nvidia,vbus-gpio = tca6416 0 GPIO_ACTIVE_HIGH;
};
 
usb-phy@c500 {
@@ -519,7 +518,6 @@
 
usb@c5008000 {
status = okay;
-   nvidia,vbus-gpio = tca6416 1 GPIO_ACTIVE_HIGH;
};
 
usb-phy@c5008000 {
-- 
1.8.1.5

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


[PATCH 3/4] Documentation: devicetree: phy-tegra-usb: Add vbus-supply property for host mode PHYs

2013-06-26 Thread Mikko Perttunen
Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
index c4c9e9e..92348c9 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
@@ -48,5 +48,8 @@ Optional properties:
   peripheral means it is device controller
   otg means it can operate as either (on the go)
 
+Optional properties for dr_mode == host:
+  - vbus-supply: regulator for VBUS
+
 Required properties for dr_mode == otg:
   - vbus-supply: regulator for VBUS
-- 
1.8.1.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: Proposed modification to PL2303 driver

2013-06-26 Thread Reinhard Max

On Tue, 25 Jun 2013 at 19:14, Greg KH wrote:


On Tue, Jun 25, 2013 at 11:54:37AM +0200, Reinhard Max wrote:

So, how about starting to get rid of the baud rate list by skipping 
it for HX chips only until someone with a type_0 or type_1 devices 
can confirm that it works there as well?


How about getting some of those devices and testing it? That's the 
best way to do it, right?  After that, patches are always gladly 
accepted.


Well, I do have a HX based device and I tested it and it does support 
arbitrary baud rates. But as I have no idea where to get type_0 or 
type_1 devices (if such are still available at all), I'd leave that 
part up to those who have such devices and want to run them at 
non-standard speeds.


So, would you accept a patch that removes the constraint for HX only?

OTOH, why should a driver impose such a limit at all instead of 
leaving it up to the hardware whether it supports non-standard baud 
rates or (according to the comment in the driver) falls back to 9600 
Baud if an unsupported one is requested? Rounding a non-standard baud 
rate such as 250kBd for DMX to the nearest standard value will let the 
communication fail just as much as letting the hardware fall back to 
9600.


Can you imagine scenarios where the current rounding algorithm isn't 
either unneeded (because a standard baud rate was used anyway) or 
obstructive (because the user intentionally uses a non-standard rate)?


cu
Reinhard
--
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: host: tegra: Remove direct vbus regulator control using GPIOs

2013-06-26 Thread Mikko Perttunen
The tegra ehci driver has enabled USB vbus regulators directly using
GPIOs and the device tree attribute nvidia,vbus-gpio. This is ugly
and causes error messages on boot when both the regulator driver
and the ehci driver want access to the same GPIO.

This patch removes this mechanism of vbus control, so that an actual
regulator interface can be used by the phy layer to control the
usb vbus regulator.

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 drivers/usb/host/ehci-tegra.c | 34 +-
 1 file changed, 1 insertion(+), 33 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index a1cec77..51cf1d2 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -328,33 +328,6 @@ static void tegra_ehci_unmap_urb_for_dma(struct usb_hcd 
*hcd, struct urb *urb)
free_dma_aligned_buffer(urb);
 }
 
-static int setup_vbus_gpio(struct platform_device *pdev,
-  struct tegra_ehci_platform_data *pdata)
-{
-   int err = 0;
-   int gpio;
-
-   gpio = pdata-vbus_gpio;
-   if (!gpio_is_valid(gpio))
-   gpio = of_get_named_gpio(pdev-dev.of_node,
-nvidia,vbus-gpio, 0);
-   if (!gpio_is_valid(gpio))
-   return 0;
-
-   err = gpio_request(gpio, vbus_gpio);
-   if (err) {
-   dev_err(pdev-dev, can't request vbus gpio %d, gpio);
-   return err;
-   }
-   err = gpio_direction_output(gpio, 1);
-   if (err) {
-   dev_err(pdev-dev, can't enable vbus\n);
-   return err;
-   }
-
-   return err;
-}
-
 static int tegra_ehci_probe(struct platform_device *pdev)
 {
struct resource *res;
@@ -382,14 +355,11 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!pdev-dev.coherent_dma_mask)
pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
 
-   setup_vbus_gpio(pdev, pdata);
-
hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
dev_name(pdev-dev));
if (!hcd) {
dev_err(pdev-dev, Unable to create HCD\n);
-   err = -ENOMEM;
-   goto cleanup_vbus_gpio;
+   return -ENOMEM;
}
platform_set_drvdata(pdev, hcd);
ehci = hcd_to_ehci(hcd);
@@ -505,8 +475,6 @@ cleanup_clk_get:
clk_put(tegra-clk);
 cleanup_hcd_create:
usb_put_hcd(hcd);
-cleanup_vbus_gpio:
-   /* FIXME: Undo setup_vbus_gpio() here */
return err;
 }
 
-- 
1.8.1.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: [PATCH] usb: dwc3: core: continue probe even if usb3 phy is not available

2013-06-26 Thread Felipe Balbi
Hi,

On Wed, Jun 26, 2013 at 02:59:14PM +0530, George Cherian wrote:
 There can be configurations in which DWC3 is hoooked up only to USB2 PHY.
 In such cases we should not return -EPROBE_DEFER, rather continue probe
 even if there is no USB3 PHY.
 
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
  drivers/usb/dwc3/core.c | 31 ---
  1 file changed, 24 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index c35d49d..d5e6f3e 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -100,7 +100,9 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
   dwc3_writel(dwc-regs, DWC3_GUSB2PHYCFG(0), reg);
  
   usb_phy_init(dwc-usb2_phy);
 - usb_phy_init(dwc-usb3_phy);
 +
 + if (dwc-usb3_phy)
 + usb_phy_init(dwc-usb3_phy);

I would feel more comfortable if you would move our maximum_speed module
parameter to DT with a property such as:

snps,maximum_speed = highspeed;

then on driver you could:

ret = of_property_read_string(np, snps,maximum_speed, maximum_speed);
if (ret  0)
bailout();

if (strncmp(maximum_speed, superspeed, 10) == 0) {
/* grab USB3 PHY, return EPROBE_DEFER if not found */
grab_usb3_phy();
}

if ((strncmp(maximum_speed, highspeed, 9) == 0) ||
(strncmp(maximum_speed, fullspeed, 9) == 0) ||
(strncmp(maximum_speed, lowspeed, 8) == 0)) {
/* grab USB2 PHY, return EPROBE_DEFER if not found */
grab_usb2_phy();
}

this way, we depend solely on setting maximum_speed to highspeed for
AM437x :-)

ps: don't forget to default to superspeed in case no property is passed.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/4] ARM: dts: tegra20: Remove obsolete vbus-gpio properties

2013-06-26 Thread Felipe Balbi
On Wed, Jun 26, 2013 at 12:59:41PM +0300, Mikko Perttunen wrote:
 USB VBUS regulators are now specified with the vbus-supply property
 instead of vbus-gpio, so remove the obsolete properties.
 
 Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
 ---
  arch/arm/boot/dts/tegra20-seaboard.dts  | 1 -
  arch/arm/boot/dts/tegra20-trimslice.dts | 1 -
  arch/arm/boot/dts/tegra20-whistler.dts  | 2 --
  3 files changed, 4 deletions(-)
 
 diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
 b/arch/arm/boot/dts/tegra20-seaboard.dts
 index ab177b4..2ab4775 100644
 --- a/arch/arm/boot/dts/tegra20-seaboard.dts
 +++ b/arch/arm/boot/dts/tegra20-seaboard.dts
 @@ -566,7 +566,6 @@
  
   usb@c500 {
   status = okay;
 - nvidia,vbus-gpio = gpio TEGRA_GPIO(D, 0) GPIO_ACTIVE_HIGH;

silly question but don't you need to put a phandle to the VBUS regulator
here ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/4] ARM: dts: tegra20: Remove obsolete vbus-gpio properties

2013-06-26 Thread Mikko Perttunen

On Wed, 26 Jun 2013 13:17:58 +0300, Felipe Balbi ba...@ti.com wrote:


* PGP Signed by an unknown key

On Wed, Jun 26, 2013 at 12:59:41PM +0300, Mikko Perttunen wrote:

USB VBUS regulators are now specified with the vbus-supply property
instead of vbus-gpio, so remove the obsolete properties.

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 arch/arm/boot/dts/tegra20-seaboard.dts  | 1 -
 arch/arm/boot/dts/tegra20-trimslice.dts | 1 -
 arch/arm/boot/dts/tegra20-whistler.dts  | 2 --
 3 files changed, 4 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts  
b/arch/arm/boot/dts/tegra20-seaboard.dts

index ab177b4..2ab4775 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -566,7 +566,6 @@

usb@c500 {
status = okay;
-   nvidia,vbus-gpio = gpio TEGRA_GPIO(D, 0) GPIO_ACTIVE_HIGH;


silly question but don't you need to put a phandle to the VBUS regulator
here ?



It's already there in the corresponding usb-phy node. They were added by
Venu Byravarasu in commit 4c94c8b5 ARM: tegra: update device trees for
USB binding rework.
--
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] ARM: dts: tegra20: Remove obsolete vbus-gpio properties

2013-06-26 Thread Felipe Balbi
Hi,

On Wed, Jun 26, 2013 at 01:22:07PM +0300, Mikko Perttunen wrote:
 On Wed, 26 Jun 2013 13:17:58 +0300, Felipe Balbi ba...@ti.com wrote:
 
 * PGP Signed by an unknown key
 
 On Wed, Jun 26, 2013 at 12:59:41PM +0300, Mikko Perttunen wrote:
 USB VBUS regulators are now specified with the vbus-supply property
 instead of vbus-gpio, so remove the obsolete properties.
 
 Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
 ---
  arch/arm/boot/dts/tegra20-seaboard.dts  | 1 -
  arch/arm/boot/dts/tegra20-trimslice.dts | 1 -
  arch/arm/boot/dts/tegra20-whistler.dts  | 2 --
  3 files changed, 4 deletions(-)
 
 diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts
 b/arch/arm/boot/dts/tegra20-seaboard.dts
 index ab177b4..2ab4775 100644
 --- a/arch/arm/boot/dts/tegra20-seaboard.dts
 +++ b/arch/arm/boot/dts/tegra20-seaboard.dts
 @@ -566,7 +566,6 @@
 
 usb@c500 {
 status = okay;
 -   nvidia,vbus-gpio = gpio TEGRA_GPIO(D, 0) GPIO_ACTIVE_HIGH;
 
 silly question but don't you need to put a phandle to the VBUS regulator
 here ?
 
 
 It's already there in the corresponding usb-phy node. They were added by
 Venu Byravarasu in commit 4c94c8b5 ARM: tegra: update device trees for
 USB binding rework.

aaa alright, my bad :-)

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 0/2] *** SUBJECT HERE ***

2013-06-26 Thread Johan Hovold
On Wed, Jun 26, 2013 at 10:29:59AM +0200, Anders Hammarquist wrote:
 In a message of Tue, 25 Jun 2013 16:39:11 -0700, Greg KH writes:
  Indeed. I'd already had some (failed) thoughts about how to handle it
  nicely. Now I've had another think through, and I have something which
  deals with it and at least complains if TI_EXTRA_VID_PID_COUNT is changed
  without changing the initializer. Patch 2/2
 
 Why don't we just drop the extra id thing entirely?  The usb-serial
 subsystem handles new device ids being added dynamically from sysfs for
 a long time now.  Removing this module option would clean up the code a
 lot, and prevent these errors from ever happening again.
 
 Aha, yes, I'm all for that (had I only known I'd have done that to start
 with). I'll look in to it.

I already have a few patches here (part of a larger 3.11 clean-up series)
which removes the vid/pid module parameters from all usb-serial modules
including ti_usb_3410_5052.

I hope to be able to submit the whole series a later tonight, but here's
the ti_usb_3410_5052 part if anyone's interested.

Thanks,
Johan


From: Johan Hovold jhov...@gmail.com
Subject: [PATCH] USB: ti_usb_3410_5052: remove vendor/product module parameters

Remove the vendor and product module parameters which were added a long
time ago when we did not have the dynamic sysfs interface to add
new device ids (and which isn't limited to five new vid/pid pair).

A vid/pid pair can be added dynamically using sysfs, for example:

  echo 0451 1234 /sys/bus/usb-serial/drivers/ti_usb_3410_5052_1/new_id

for 1-port adapters, or

  echo 0451 1234 /sys/bus/usb-serial/drivers/ti_usb_3410_5052_2/new_id

for 2-port adapters.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/ti_usb_3410_5052.c | 72 ---
 1 file changed, 7 insertions(+), 65 deletions(-)

diff --git a/drivers/usb/serial/ti_usb_3410_5052.c 
b/drivers/usb/serial/ti_usb_3410_5052.c
index f3e21f5..5585b20 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -141,20 +141,9 @@ static int ti_download_firmware(struct ti_device *tdev);
 
 /* module parameters */
 static int closing_wait = TI_DEFAULT_CLOSING_WAIT;
-static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT];
-static unsigned int vendor_3410_count;
-static ushort product_3410[TI_EXTRA_VID_PID_COUNT];
-static unsigned int product_3410_count;
-static ushort vendor_5052[TI_EXTRA_VID_PID_COUNT];
-static unsigned int vendor_5052_count;
-static ushort product_5052[TI_EXTRA_VID_PID_COUNT];
-static unsigned int product_5052_count;
 
 /* supported devices */
-/* the array dimension is the number of default entries plus */
-/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
-/* null entry */
-static struct usb_device_id ti_id_table_3410[15+TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_3410[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
{ USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -171,16 +160,18 @@ static struct usb_device_id 
ti_id_table_3410[15+TI_EXTRA_VID_PID_COUNT+1] = {
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STEREO_PLUG_ID) },
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
+   { } /* terminator */
 };
 
-static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_5052[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
+   { } /* terminator */
 };
 
-static struct usb_device_id 
ti_id_table_combined[19+2*TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_combined[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
{ USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -200,7 +191,7 @@ static struct usb_device_id 
ti_id_table_combined[19+2*TI_EXTRA_VID_PID_COUNT+1]
{ USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
-   { }
+   { } /* terminator */
 };
 
 static struct usb_serial_driver ti_1port_device = {
@@ -289,61 +280,12 @@ module_param(closing_wait, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(closing_wait,
 Maximum wait for data to drain in close, in .01 secs, default is 4000);
 
-module_param_array(vendor_3410, ushort, vendor_3410_count, S_IRUGO);
-MODULE_PARM_DESC(vendor_3410,
-   Vendor ids for 3410 based devices, 1-5 short integers);
-module_param_array(product_3410, ushort, product_3410_count, S_IRUGO);

[PATCH v9 8/8] usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops

2013-06-26 Thread Kishon Vijay Abraham I
Now that twl4030-usb is adapted to the new generic PHY framework,
*set_suspend* and *phy_init* ops can be removed from twl4030-usb driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/usb/phy/phy-twl4030-usb.c |   57 +
 1 file changed, 13 insertions(+), 44 deletions(-)

diff --git a/drivers/usb/phy/phy-twl4030-usb.c 
b/drivers/usb/phy/phy-twl4030-usb.c
index 437ba30..2148e2b 100644
--- a/drivers/usb/phy/phy-twl4030-usb.c
+++ b/drivers/usb/phy/phy-twl4030-usb.c
@@ -422,25 +422,20 @@ static void twl4030_phy_power(struct twl4030_usb *twl, 
int on)
}
 }
 
-static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off)
+static int twl4030_phy_power_off(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (twl-asleep)
-   return;
+   return 0;
 
twl4030_phy_power(twl, 0);
twl-asleep = 1;
dev_dbg(twl-dev, %s\n, __func__);
-}
-
-static int twl4030_phy_power_off(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_suspend(twl, 0);
return 0;
 }
 
-static void __twl4030_phy_resume(struct twl4030_usb *twl)
+static void __twl4030_phy_power_on(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
twl4030_i2c_access(twl, 1);
@@ -449,11 +444,13 @@ static void __twl4030_phy_resume(struct twl4030_usb *twl)
twl4030_i2c_access(twl, 0);
 }
 
-static void twl4030_phy_resume(struct twl4030_usb *twl)
+static int twl4030_phy_power_on(struct phy *phy)
 {
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
if (!twl-asleep)
-   return;
-   __twl4030_phy_resume(twl);
+   return 0;
+   __twl4030_phy_power_on(twl);
twl-asleep = 0;
dev_dbg(twl-dev, %s\n, __func__);
 
@@ -466,13 +463,6 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
cancel_delayed_work(twl-id_workaround_work);
schedule_delayed_work(twl-id_workaround_work, HZ);
}
-}
-
-static int twl4030_phy_power_on(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   twl4030_phy_resume(twl);
return 0;
 }
 
@@ -604,9 +594,9 @@ static void twl4030_id_workaround_work(struct work_struct 
*work)
}
 }
 
-static int twl4030_usb_phy_init(struct usb_phy *phy)
+static int twl4030_phy_init(struct phy *phy)
 {
-   struct twl4030_usb *twl = phy_to_twl(phy);
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
enum omap_musb_vbus_id_status status;
 
/*
@@ -621,32 +611,13 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
 
if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
-   twl4030_phy_resume(twl);
+   twl4030_phy_power_on(phy);
}
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
-static int twl4030_phy_init(struct phy *phy)
-{
-   struct twl4030_usb *twl = phy_get_drvdata(phy);
-
-   return twl4030_usb_phy_init(twl-phy);
-}
-
-static int twl4030_set_suspend(struct usb_phy *x, int suspend)
-{
-   struct twl4030_usb *twl = phy_to_twl(x);
-
-   if (suspend)
-   twl4030_phy_suspend(twl, 1);
-   else
-   twl4030_phy_resume(twl);
-
-   return 0;
-}
-
 static int twl4030_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget)
 {
@@ -717,8 +688,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl-phy.label  = twl4030;
twl-phy.otg= otg;
twl-phy.type   = USB_PHY_TYPE_USB2;
-   twl-phy.set_suspend= twl4030_set_suspend;
-   twl-phy.init   = twl4030_usb_phy_init;
 
otg-phy= twl-phy;
otg-set_host   = twl4030_set_host;
-- 
1.7.10.4

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


[PATCH v9 5/8] ARM: dts: omap: update usb_otg_hs data

2013-06-26 Thread Kishon Vijay Abraham I
Updated the usb_otg_hs dt data to include the *phy* and *phy-names*
binding in order for the driver to use the new generic PHY framework.
Also updated the Documentation to include the binding information.
The PHY binding information can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |5 +
 Documentation/devicetree/bindings/usb/usb-phy.txt  |6 ++
 arch/arm/boot/dts/omap3-beagle-xm.dts  |2 ++
 arch/arm/boot/dts/omap3-evm.dts|2 ++
 arch/arm/boot/dts/omap3-overo.dtsi |2 ++
 arch/arm/boot/dts/omap4.dtsi   |3 +++
 arch/arm/boot/dts/twl4030.dtsi |1 +
 7 files changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index d4769f3..c0871a7 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -19,6 +19,9 @@ OMAP MUSB GLUE
  - 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
+ - phys : the phandle for the PHY device (used by generic PHY framework)
+ - phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phy* phandle.
 
 Optional properties:
  - ctrl-module : phandle of the control module this glue uses to write to
@@ -33,6 +36,8 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
num-eps = 16;
ram-bits = 12;
ctrl-module = omap_control_usb;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
 };
 
 Board specific device node entry
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 61496f5..c0245c8 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -5,6 +5,8 @@ OMAP USB2 PHY
 Required properties:
  - compatible: Should be ti,omap-usb2
  - reg : Address and length of the register set for the device.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -16,6 +18,7 @@ usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
 
 OMAP USB3 PHY
@@ -25,6 +28,8 @@ Required properties:
  - reg : Address and length of the register set for the device.
  - reg-names: The names of the register addresses corresponding to the 
registers
filled in reg.
+ - #phy-cells: determine the number of cells that should be given in the
+   phandle while referencing this phy.
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -39,4 +44,5 @@ usb3phy@4a084400 {
  0x4a084c00 0x40;
reg-names = phy_rx, phy_tx, pll_ctrl;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
 };
diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts 
b/arch/arm/boot/dts/omap3-beagle-xm.dts
index 3046d1f..023596e 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -123,6 +123,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
index 96d1c20..f2b8314 100644
--- a/arch/arm/boot/dts/omap3-evm.dts
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -69,6 +69,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap3-overo.dtsi 
b/arch/arm/boot/dts/omap3-overo.dtsi
index a626c50..b65916e 100644
--- a/arch/arm/boot/dts/omap3-overo.dtsi
+++ b/arch/arm/boot/dts/omap3-overo.dtsi
@@ -74,6 +74,8 @@
 usb_otg_hs {
interface-type = 0;
usb-phy = usb2_phy;
+   phys = usb2_phy;
+   phy-names = usb2-phy;
mode = 3;
power = 50;
 };
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 2a56428..dae620b 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -517,6 +517,7 @@
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58;
ctrl-module = omap_control_usb;
+   #phy-cells = 0;
};
};
 
@@ -655,6 +656,8 @@
interrupt-names = mc, dma;
 

[PATCH v9 7/8] usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2

2013-06-26 Thread Kishon Vijay Abraham I
Now that omap-usb2 is adapted to the new generic PHY framework,
*set_suspend* ops can be removed from omap-usb2 driver.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/usb/phy/phy-omap-usb2.c |   25 -
 1 file changed, 25 deletions(-)

diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/usb/phy/phy-omap-usb2.c
index 751b30f..3f2b125 100644
--- a/drivers/usb/phy/phy-omap-usb2.c
+++ b/drivers/usb/phy/phy-omap-usb2.c
@@ -97,29 +97,6 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
return 0;
 }
 
-static int omap_usb2_suspend(struct usb_phy *x, int suspend)
-{
-   u32 ret;
-   struct omap_usb *phy = phy_to_omapusb(x);
-
-   if (suspend  !phy-is_suspended) {
-   omap_control_usb_phy_power(phy-control_dev, 0);
-   pm_runtime_put_sync(phy-dev);
-   phy-is_suspended = 1;
-   } else if (!suspend  phy-is_suspended) {
-   ret = pm_runtime_get_sync(phy-dev);
-   if (ret  0) {
-   dev_err(phy-dev, get_sync failed with err %d\n,
-   ret);
-   return ret;
-   }
-   omap_control_usb_phy_power(phy-control_dev, 1);
-   phy-is_suspended = 0;
-   }
-
-   return 0;
-}
-
 static int omap_usb_power_off(struct phy *x)
 {
struct omap_usb *phy = phy_get_drvdata(x);
@@ -167,7 +144,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
phy-phy.dev= phy-dev;
phy-phy.label  = omap-usb2;
-   phy-phy.set_suspend= omap_usb2_suspend;
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
@@ -182,7 +158,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   phy-is_suspended   = 1;
omap_control_usb_phy_power(phy-control_dev, 0);
 
otg-set_host   = omap_usb_set_host;
-- 
1.7.10.4

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


[PATCH v9 4/8] ARM: OMAP: USB: Add phy binding information

2013-06-26 Thread Kishon Vijay Abraham I
In order for controllers to get PHY in case of non dt boot, the phy
binding information (phy device name) should be added in the platform
data of the controller.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 arch/arm/mach-omap2/usb-musb.c |6 +-
 include/linux/usb/musb.h   |3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 3242a55..284ba51 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -85,8 +85,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;
+   musb_plat.phy_label = omap-usb2;
+   } else if (cpu_is_omap34xx()) {
+   musb_plat.phy_label = twl4030;
+   }
 
if (soc_is_am35xx()) {
oh_name = am35x_otg_hs;
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index 053c268..596f8c8 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -104,6 +104,9 @@ struct musb_hdrc_platform_data {
/* for clk_get() */
const char  *clock;
 
+   /* phy label */
+   const char  *phy_label;
+
/* (HOST or OTG) switch VBUS on/off */
int (*set_vbus)(struct device *dev, int is_on);
 
-- 
1.7.10.4

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


[PATCH v9 6/8] usb: musb: omap2430: use the new generic PHY framework

2013-06-26 Thread Kishon Vijay Abraham I
Use the generic PHY framework API to get the PHY. The usb_phy_set_resume
and usb_phy_set_suspend is replaced with power_on and
power_off to align with the new PHY framework.

musb-xceiv can't be removed as of now because musb core uses xceiv.state and
xceiv.otg. Once there is a separate state machine to handle otg, these can be
moved out of xceiv and then we can start using the generic PHY framework.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/musb/Kconfig |1 +
 drivers/usb/musb/musb_core.c |1 +
 drivers/usb/musb/musb_core.h |3 +++
 drivers/usb/musb/omap2430.c  |   26 --
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 06f8d29..6ef595a 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -47,6 +47,7 @@ config USB_MUSB_TUSB6010
 config USB_MUSB_OMAP2PLUS
tristate OMAP2430 and onwards
depends on ARCH_OMAP2PLUS
+   depends on GENERIC_PHY
 
 config USB_MUSB_AM35X
tristate AM35x
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 37a261a..f732bcc 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1864,6 +1864,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-board_set_power = plat-set_power;
musb-min_power = plat-min_power;
musb-ops = plat-platform_ops;
+   musb-phy_label = plat-phy_label;
 
/* The musb_platform_init() call:
 *   - adjusts musb-mregs
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7fb4819..498ae21 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -46,6 +46,7 @@
 #include linux/usb.h
 #include linux/usb/otg.h
 #include linux/usb/musb.h
+#include linux/phy/phy.h
 
 struct musb;
 struct musb_hw_ep;
@@ -357,6 +358,7 @@ struct musb {
u16 int_tx;
 
struct usb_phy  *xceiv;
+   struct phy  *phy;
 
int nIrq;
unsignedirq_wake:1;
@@ -434,6 +436,7 @@ struct musb {
unsigneddouble_buffer_not_ok:1;
 
struct musb_hdrc_config *config;
+   const char  *phy_label;
 
 #ifdef MUSB_CONFIG_PROC_FS
struct proc_dir_entry *proc_entry;
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 628b93f..12b94da 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -348,11 +348,21 @@ 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.
 */
-   if (dev-parent-of_node)
+   if (dev-parent-of_node) {
+   musb-phy = devm_phy_get(dev-parent, usb2-phy);
+
+   /* We can't totally remove musb-xceiv as of now because
+* musb core uses xceiv.state and xceiv.otg. Once we have
+* a separate state machine to handle otg, these can be moved
+* out of xceiv and then we can start using the generic PHY
+* framework
+*/
musb-xceiv = devm_usb_get_phy_by_phandle(dev-parent,
usb-phy, 0);
-   else
+   } else {
musb-xceiv = devm_usb_get_phy_dev(dev, 0);
+   musb-phy = devm_phy_get(dev, musb-phy_label);
+   }
 
if (IS_ERR(musb-xceiv)) {
status = PTR_ERR(musb-xceiv);
@@ -364,6 +374,10 @@ static int omap2430_musb_init(struct musb *musb)
return -EPROBE_DEFER;
}
 
+   if (IS_ERR(musb-phy)) {
+   pr_err(HS USB OTG: no PHY configured\n);
+   return PTR_ERR(musb-phy);
+   }
musb-isr = omap2430_musb_interrupt;
 
status = pm_runtime_get_sync(dev);
@@ -397,7 +411,7 @@ static int omap2430_musb_init(struct musb *musb)
if (glue-status != OMAP_MUSB_UNKNOWN)
omap_musb_set_mailbox(glue);
 
-   usb_phy_init(musb-xceiv);
+   phy_init(musb-phy);
 
pm_runtime_put_noidle(musb-controller);
return 0;
@@ -460,6 +474,7 @@ static int omap2430_musb_exit(struct musb *musb)
del_timer_sync(musb_idle_timer);
 
omap2430_low_level_exit(musb);
+   phy_exit(musb-phy);
 
return 0;
 }
@@ -619,7 +634,7 @@ static int omap2430_runtime_suspend(struct device *dev)
OTG_INTERFSEL);
 
omap2430_low_level_exit(musb);
-   usb_phy_set_suspend(musb-xceiv, 1);
+   phy_power_off(musb-phy);
}
 
return 0;
@@ -634,8 +649,7 @@ static int omap2430_runtime_resume(struct device *dev)
omap2430_low_level_init(musb);
musb_writel(musb-mregs, OTG_INTERFSEL,
  

[PATCH v9 1/8] drivers: phy: add generic PHY framework

2013-06-26 Thread Kishon Vijay Abraham I
The PHY framework provides a set of APIs for the PHY drivers to
create/destroy a PHY and APIs for the PHY users to obtain a reference to the
PHY with or without using phandle. For dt-boot, the PHY drivers should
also register *PHY provider* with the framework.

PHY drivers should create the PHY by passing id and ops like init, exit,
power_on and power_off. This framework is also pm runtime enabled.

The documentation for the generic PHY framework is added in
Documentation/phy.txt and the documentation for dt binding can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Tested-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 .../devicetree/bindings/phy/phy-bindings.txt   |   66 +++
 Documentation/phy.txt  |  129 +
 MAINTAINERS|7 +
 drivers/Kconfig|2 +
 drivers/Makefile   |2 +
 drivers/phy/Kconfig|   13 +
 drivers/phy/Makefile   |5 +
 drivers/phy/phy-core.c |  544 
 include/linux/phy/phy.h|  344 +
 9 files changed, 1112 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-bindings.txt
 create mode 100644 Documentation/phy.txt
 create mode 100644 drivers/phy/Kconfig
 create mode 100644 drivers/phy/Makefile
 create mode 100644 drivers/phy/phy-core.c
 create mode 100644 include/linux/phy/phy.h

diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt 
b/Documentation/devicetree/bindings/phy/phy-bindings.txt
new file mode 100644
index 000..8ae844f
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
@@ -0,0 +1,66 @@
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt
+
+PHY device node
+===
+
+Required Properties:
+#phy-cells:Number of cells in a PHY specifier;  The meaning of all those
+   cells is defined by the binding for the phy node. The PHY
+   provider can use the values in cells to find the appropriate
+   PHY.
+
+For example:
+
+phys: phy {
+compatible = xxx;
+reg = ...;
+.
+.
+#phy-cells = 1;
+.
+.
+};
+
+That node describes an IP block (PHY provider) that implements 2 different 
PHYs.
+In order to differentiate between these 2 PHYs, an additonal specifier should 
be
+given while trying to get a reference to it.
+
+PHY user node
+=
+
+Required Properties:
+phys : the phandle for the PHY device (used by the PHY subsystem)
+phy-names : the names of the PHY corresponding to the PHYs present in the
+   *phys* phandle
+
+Example 1:
+usb1: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = usb2_phy, usb3_phy;
+phy-names = usb2phy, usb3phy;
+.
+.
+};
+
+This node represents a controller that uses two PHYs, one for usb2 and one for
+usb3.
+
+Example 2:
+usb2: usb_otg_ss@xxx {
+compatible = xxx;
+reg = xxx;
+.
+.
+phys = phys 1;
+phy-names = usbphy;
+.
+.
+};
+
+This node represents a controller that uses one of the PHYs of the PHY provider
+device defined previously. Note that the phy handle has an additional specifier
+1 to differentiate between the two PHYs.
diff --git a/Documentation/phy.txt b/Documentation/phy.txt
new file mode 100644
index 000..05f8fda
--- /dev/null
+++ b/Documentation/phy.txt
@@ -0,0 +1,129 @@
+   PHY SUBSYSTEM
+ Kishon Vijay Abraham I kis...@ti.com
+
+This document explains the Generic PHY Framework along with the APIs provided,
+and how-to-use.
+
+1. Introduction
+
+*PHY* is the abbreviation for physical layer. It is used to connect a device
+to the physical medium e.g., the USB controller has a PHY to provide functions
+such as serialization, de-serialization, encoding, decoding and is responsible
+for obtaining the required data transmission rate. Note that some USB
+controllers have PHY functionality embedded into it and others use an external
+PHY. Other peripherals that use PHY include Wireless LAN, Ethernet,
+SATA etc.
+
+The intention of creating this framework is to bring the PHY drivers spread
+all over the Linux kernel to drivers/phy to increase code re-use and for
+better code maintainability.
+
+This framework will be of use only to devices that use external PHY (PHY
+functionality is not embedded within the controller).
+
+2. Registering/Unregistering the PHY provider
+
+PHY provider refers to an entity that implements one or more PHY instances.
+For the simple case where the PHY provider implements only a single instance of
+the PHY, the framework provides its own implementation of of_xlate in
+of_phy_simple_xlate. If the PHY provider 

[PATCH v9 2/8] usb: phy: omap-usb2: use the new generic PHY framework

2013-06-26 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. Now the power off and
power on are done in omap_usb_power_off and omap_usb_power_on respectively.

However using the old USB PHY library cannot be completely removed
because OTG is intertwined with PHY and moving to the new framework
will break OTG. Once we have a separate OTG state machine, we
can get rid of the USB PHY library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/phy/Kconfig |1 +
 drivers/usb/phy/phy-omap-usb2.c |   45 +++
 2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7ef3eb8..5caeafd 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -69,6 +69,7 @@ config OMAP_CONTROL_USB
 config OMAP_USB2
tristate OMAP USB2 PHY Driver
depends on ARCH_OMAP2PLUS
+   depends on GENERIC_PHY
select OMAP_CONTROL_USB
help
  Enable this to support the transceiver that is part of SOC. This
diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/usb/phy/phy-omap-usb2.c
index 844ab68..751b30f 100644
--- a/drivers/usb/phy/phy-omap-usb2.c
+++ b/drivers/usb/phy/phy-omap-usb2.c
@@ -28,6 +28,7 @@
 #include linux/pm_runtime.h
 #include linux/delay.h
 #include linux/usb/omap_control_usb.h
+#include linux/phy/phy.h
 
 /**
  * omap_usb2_set_comparator - links the comparator present in the sytem with
@@ -119,10 +120,36 @@ static int omap_usb2_suspend(struct usb_phy *x, int 
suspend)
return 0;
 }
 
+static int omap_usb_power_off(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 0);
+
+   return 0;
+}
+
+static int omap_usb_power_on(struct phy *x)
+{
+   struct omap_usb *phy = phy_get_drvdata(x);
+
+   omap_control_usb_phy_power(phy-control_dev, 1);
+
+   return 0;
+}
+
+static struct phy_ops ops = {
+   .power_on   = omap_usb_power_on,
+   .power_off  = omap_usb_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int omap_usb2_probe(struct platform_device *pdev)
 {
struct omap_usb *phy;
+   struct phy  *generic_phy;
struct usb_otg  *otg;
+   struct phy_provider *phy_provider;
 
phy = devm_kzalloc(pdev-dev, sizeof(*phy), GFP_KERNEL);
if (!phy) {
@@ -144,6 +171,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
phy-phy.otg= otg;
phy-phy.type   = USB_PHY_TYPE_USB2;
 
+   phy_provider = devm_of_phy_provider_register(phy-dev,
+   of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   return PTR_ERR(phy_provider);
+
phy-control_dev = omap_get_control_dev();
if (IS_ERR(phy-control_dev)) {
dev_dbg(pdev-dev, Failed to get control device\n);
@@ -159,6 +191,15 @@ static int omap_usb2_probe(struct platform_device *pdev)
otg-start_srp  = omap_usb_start_srp;
otg-phy= phy-phy;
 
+   platform_set_drvdata(pdev, phy);
+   pm_runtime_enable(phy-dev);
+
+   generic_phy = devm_phy_create(phy-dev, 0, ops, omap-usb2);
+   if (IS_ERR(generic_phy))
+   return PTR_ERR(generic_phy);
+
+   phy_set_drvdata(generic_phy, phy);
+
phy-wkupclk = devm_clk_get(phy-dev, usb_phy_cm_clk32k);
if (IS_ERR(phy-wkupclk)) {
dev_err(pdev-dev, unable to get usb_phy_cm_clk32k\n);
@@ -174,10 +215,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
usb_add_phy_dev(phy-phy);
 
-   platform_set_drvdata(pdev, phy);
-
-   pm_runtime_enable(phy-dev);
-
return 0;
 }
 
-- 
1.7.10.4

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


[PATCH v9 3/8] usb: phy: twl4030: use the new generic PHY framework

2013-06-26 Thread Kishon Vijay Abraham I
Used the generic PHY framework API to create the PHY. For powering on
and powering off the PHY, power_on and power_off ops are used. Once the
MUSB OMAP glue is adapted to the new framework, the suspend and resume
ops of usb phy library will be removed.

However using the old usb phy library cannot be completely removed
because otg is intertwined with phy and moving to the new
framework completely will break otg. Once we have a separate otg state machine,
we can get rid of the usb phy library.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 drivers/usb/phy/phy-twl4030-usb.c |   50 -
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-twl4030-usb.c 
b/drivers/usb/phy/phy-twl4030-usb.c
index 8fbe2d9..437ba30 100644
--- a/drivers/usb/phy/phy-twl4030-usb.c
+++ b/drivers/usb/phy/phy-twl4030-usb.c
@@ -33,6 +33,7 @@
 #include linux/io.h
 #include linux/delay.h
 #include linux/usb/otg.h
+#include linux/phy/phy.h
 #include linux/usb/musb-omap.h
 #include linux/usb/ulpi.h
 #include linux/i2c/twl.h
@@ -431,6 +432,14 @@ static void twl4030_phy_suspend(struct twl4030_usb *twl, 
int controller_off)
dev_dbg(twl-dev, %s\n, __func__);
 }
 
+static int twl4030_phy_power_off(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_suspend(twl, 0);
+   return 0;
+}
+
 static void __twl4030_phy_resume(struct twl4030_usb *twl)
 {
twl4030_phy_power(twl, 1);
@@ -459,6 +468,14 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
}
 }
 
+static int twl4030_phy_power_on(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   twl4030_phy_resume(twl);
+   return 0;
+}
+
 static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
 {
/* Enable writing to power configuration registers */
@@ -602,13 +619,22 @@ static int twl4030_usb_phy_init(struct usb_phy *phy)
status = twl4030_usb_linkstat(twl);
twl-linkstat = status;
 
-   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID)
+   if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID) {
omap_musb_mailbox(twl-linkstat);
+   twl4030_phy_resume(twl);
+   }
 
sysfs_notify(twl-dev-kobj, NULL, vbus);
return 0;
 }
 
+static int twl4030_phy_init(struct phy *phy)
+{
+   struct twl4030_usb *twl = phy_get_drvdata(phy);
+
+   return twl4030_usb_phy_init(twl-phy);
+}
+
 static int twl4030_set_suspend(struct usb_phy *x, int suspend)
 {
struct twl4030_usb *twl = phy_to_twl(x);
@@ -646,13 +672,22 @@ static int twl4030_set_host(struct usb_otg *otg, struct 
usb_bus *host)
return 0;
 }
 
+static const struct phy_ops ops = {
+   .init   = twl4030_phy_init,
+   .power_on   = twl4030_phy_power_on,
+   .power_off  = twl4030_phy_power_off,
+   .owner  = THIS_MODULE,
+};
+
 static int twl4030_usb_probe(struct platform_device *pdev)
 {
struct twl4030_usb_data *pdata = pdev-dev.platform_data;
struct twl4030_usb  *twl;
+   struct phy  *phy;
int status, err;
struct usb_otg  *otg;
struct device_node  *np = pdev-dev.of_node;
+   struct phy_provider *phy_provider;
 
twl = devm_kzalloc(pdev-dev, sizeof *twl, GFP_KERNEL);
if (!twl)
@@ -689,6 +724,19 @@ static int twl4030_usb_probe(struct platform_device *pdev)
otg-set_host   = twl4030_set_host;
otg-set_peripheral = twl4030_set_peripheral;
 
+   phy_provider = devm_of_phy_provider_register(twl-dev,
+   of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   return PTR_ERR(phy_provider);
+
+   phy = devm_phy_create(twl-dev, 0, ops, twl4030);
+   if (IS_ERR(phy)) {
+   dev_dbg(pdev-dev, Failed to create PHY\n);
+   return PTR_ERR(phy);
+   }
+
+   phy_set_drvdata(phy, twl);
+
/* init spinlock for workqueue */
spin_lock_init(twl-lock);
 
-- 
1.7.10.4

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


[PATCH v9 0/8] Generic PHY Framework

2013-06-26 Thread Kishon Vijay Abraham I
Added a generic PHY framework that provides a set of APIs for the PHY drivers
to create/destroy a PHY and APIs for the PHY users to obtain a reference to
the PHY with or without using phandle.

This framework will be of use only to devices that uses external PHY (PHY
functionality is not embedded within the controller).

The intention of creating this framework is to bring the phy drivers spread
all over the Linux kernel to drivers/phy to increase code re-use and to
increase code maintainability.

Comments to make PHY as bus wasn't done because PHY devices can be part of
other bus and making a same device attached to multiple bus leads to bad
design.

If the PHY driver has to send notification on connect/disconnect, the PHY
driver should make use of the extcon framework. Using this susbsystem 
to use extcon framwork will have to be analysed.

Making omap-usb2 and twl4030 to use this framework is provided as a sample.

This patch series is developed on linux mainline tree.

This framework is already being used by display PHYs
http://www.spinics.net/lists/arm-kernel/msg251666.html

These patches are hosted in git://gitorious.org/linuxphy/linuxphy.git testing

Changes from v8:
* Added phy_set_drvdata and phy_get_drvdata in phy.h.
* Changed phy_create API not to take void *priv. private data should now be set
using phy_set_drvdata now.

Changes from v7:
* Fixed Documentation
* Added to_phy, of_phy_provider_register and devm_of_phy_provider_register
* modified runtime_pm usage in phy_init, phy_exit, phy_power_on and
phy_power_off. Now phy_power_on will enable the clocks and phy_power_off will
disable the clocks.
* pm_runtime_no_callbacks() is added so that pm_runtime_get_sync doesn't fail
* modified other patches to adhere to the changes in the PHY framework
* removed usb: phy: twl4030: twl4030 shouldn't be subsys_initcall as it will
be merged separately.
* reference counting has been added to protect phy ops when the PHY is shared
by multiple consumers.

Changes from v6
* corrected few typos in Documentation
* Changed PHY Subsystem to *bool* in Kconfig (to avoid compilation errors when
  PHY Subsystem is kept as module and the dependent modules are built-in)
* Added if pm_runtime_enabled check before runtime pm calls.

Changes from v5:
* removed the new sysfs entries as it dint have any new information other than
  what is already there in /sys/devices/...
* removed a bunch of APIs added to get the PHY and now only phy_get and
  devm_phy_get are used.
* Added new APIs to register/unregister the PHY provider. This is needed for
  dt boot case.
* Enabled pm runtime and incorporated the comments given by Alan Stern in a
  different patch series by Gautam.
* Removed the *phy_bind* API. Now the phy binding information should be passed
  using the platform data to the controller devices.
* Fixed a few typos.

Changes from v4:
* removed of_phy_get_with_args/devm_of_phy_get_with_args. Now the *phy 
providers*
  should use their custom implementation of of_xlate or use of_phy_xlate to get
  *phy instance* from *phy providers*.
* Added of_phy_xlate to be used by *phy providers* if it provides only one PHY.
* changed phy_core from having subsys_initcall to module_init.
* other minor fixes.

Changes from v3:
* Changed the return value of PHY APIs to ENOSYS
* Added APIs of_phy_get_with_args/devm_of_phy_get_with_args to support getting
  PHYs if the same IP implements multiple PHYs.
* modified phy_bind API so that the binding information can now be _updated_.
  In effect of this removed the binding information added in board files and
  added only in usb-musb.c. If a particular board uses a different phy binding,
  it can update it in board file after usb_musb_init().
* Added Documentation/devicetree/bindings/phy/phy-bindings.txt for dt binding
  information.

Changes from v2:
* removed phy_descriptor structure completely so changed the APIs which were
  taking phy_descriptor as parameters
* Added 2 more APIs *of_phy_get_byname* and *devm_of_phy_get_byname* to be used
  by PHY user drivers which has *phy* and *phy-names* binding in the dt data
* Fixed a few typos
* Removed phy_list and we now use class_dev_iter_init, class_dev_iter_next and
  class_dev_iter_exit for traversing through the phy list. (Note we still need
  phy_bind list and phy_bind_mutex).
* Changed the sysfs entry name from *bind* to *phy_bind*.

Changes from v1:
* Added Documentation for the PHY framework
* Added few more APIs mostly w.r.t devres
* Modified omap-usb2 and twl4030 to make use of the new framework

Did USB enumeration testing in panda and beagle.

Kishon Vijay Abraham I (8):
  drivers: phy: add generic PHY framework
  usb: phy: omap-usb2: use the new generic PHY framework
  usb: phy: twl4030: use the new generic PHY framework
  ARM: OMAP: USB: Add phy binding information
  ARM: dts: omap: update usb_otg_hs data
  usb: musb: omap2430: use the new generic PHY framework
  usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2
  usb: 

Re: [PATCH] staging: ozwpan: Use normal Makefile, convert oz_trace to oz_dbg

2013-06-26 Thread Rupesh Gujare

On 26/06/13 02:00, Joe Perches wrote:

Use a normal Makefile.
Convert oz_trace and oz_trace2 to a more normal oz_dbg.
Consolidate oztrace and ozconfig files to ozdbg.h
Update #include files.
Reflow modified lines, fit to 80 cols, align arguments.

Add a couple more oz_foo_dbg macros to show how more
verbose device specific debugging could be added when a
struct device * or struct netdevice * is available.


Isn't this patch doing too many changes in single patch? Can we split 
this patch into smaller patch series ?

In addition to above, it also :-
1. Removes few unwanted logs.
2. Changes macro definition for oz_remember_urb()  oz_forget_urb() to 
static inline function when WANT_URB_PARANOIA is not defined.



Signed-off-by: Joe Perches j...@perches.com
---
  drivers/staging/ozwpan/{Kbuild = Makefile} |   6 +-
  drivers/staging/ozwpan/ozcdev.c |  52 +++--
  drivers/staging/ozwpan/ozconfig.h   |  26 ---
  drivers/staging/ozwpan/ozdbg.h  |  54 +
  drivers/staging/ozwpan/ozeltbuf.c   |  32 ++-
  drivers/staging/ozwpan/ozhcd.c  | 296 +---
  drivers/staging/ozwpan/ozmain.c |   7 +-
  drivers/staging/ozwpan/ozpd.c   |  67 +++
  drivers/staging/ozwpan/ozproto.c|  60 +++---
  drivers/staging/ozwpan/ozproto.h|   2 +-
  drivers/staging/ozwpan/oztrace.c|  36 
  drivers/staging/ozwpan/oztrace.h|  35 
  drivers/staging/ozwpan/ozurbparanoia.c  |  14 +-
  drivers/staging/ozwpan/ozurbparanoia.h  |   4 +-
  drivers/staging/ozwpan/ozusbsvc.c   |  25 +--
  drivers/staging/ozwpan/ozusbsvc1.c  |  19 +-
  16 files changed, 334 insertions(+), 401 deletions(-)
  rename drivers/staging/ozwpan/{Kbuild = Makefile} (93%)
  delete mode 100644 drivers/staging/ozwpan/ozconfig.h
  create mode 100644 drivers/staging/ozwpan/ozdbg.h
  delete mode 100644 drivers/staging/ozwpan/oztrace.c
  delete mode 100644 drivers/staging/ozwpan/oztrace.h

snip...


diff --git a/drivers/staging/ozwpan/ozdbg.h b/drivers/staging/ozwpan/ozdbg.h
new file mode 100644
index 000..976c33b
--- /dev/null
+++ b/drivers/staging/ozwpan/ozdbg.h
@@ -0,0 +1,54 @@
+/* 
-
+ * Copyright (c) 2011 Ozmo Inc
+ * Released under the GNU General Public License Version 2 (GPLv2).
+ * 
---*/
+
+#ifndef _OZDBG_H
+#define _OZDBG_H
+
+#define OZ_WANT_DBG 0
+#define OZ_WANT_VERBOSE_DBG 1
+
+#define OZ_DBG_ON  0x0
+#define OZ_DBG_STREAM  0x1
+#define OZ_DBG_URB 0x2
+#define OZ_DBG_CTRL_DETAIL 0x4
+#define OZ_DBG_HUB 0x8
+#define OZ_DBG_RX_FRAMES   0x10
+#define OZ_DBG_TX_FRAMES   0x20
+
+#define OZ_DEFAULT_DBG_MASK\
+   (   \
+   /* OZ_DBG_STREAM | */   \
+   /* OZ_DBG_URB | */  \
+   /* OZ_DBG_CTRL_DETAIL | */  \
+   OZ_DBG_HUB |\
+   /* OZ_DBG_RX_FRAMES | */\
+   /* OZ_DBG_TX_FRAMES | */\
+   0)
+
+extern unsigned int oz_dbg_mask;
+
+#define oz_want_dbg(mask)  \
+   ((OZ_WANT_DBG  (OZ_DBG_##mask == OZ_DBG_ON)) ||   \
+(OZ_WANT_VERBOSE_DBG  (OZ_DBG_##mask  oz_dbg_mask)))
+
+#define oz_dbg(mask, fmt, ...) \
+do {   \
+   if (oz_want_dbg(mask))  \
+   pr_debug(fmt, ##__VA_ARGS__);   \
+} while (0)
+
+#define oz_cdev_dbg(cdev, mask, fmt, ...)  \
+do {   \
+   if (oz_want_dbg(mask))  \
+   netdev_dbg((cdev)-dev, fmt, ##__VA_ARGS__); \
+} while (0)
+
+#define oz_pd_dbg(pd, mask, fmt, ...)  \
+do {   \
+   if (oz_want_dbg(mask))  \
+   pr_debug(fmt, ##__VA_ARGS__);   \
+} while (0)
+


Above macros look good, however Greg have objection to define new macros 
 he had suggested to use dev_dbg()  pr_debug().
I will leave it to him, if he is all right to accept new macros for 
debug logs.


Greg,
Your comments please.

snip...

+#endif /* _OZCONFIG_H */


Need to change to -
#endif  /* _OZDBG_H */



--
Regards,
Rupesh Gujare

--
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] ARM: dts: tegra20: Rename USB UTMI parameters according to new definitions

2013-06-26 Thread Mikko Perttunen
Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 arch/arm/boot/dts/tegra20.dtsi | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 9653fd8..e457083 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -477,13 +477,13 @@
 tegra_car TEGRA20_CLK_USBD;
clock-names = reg, pll_u, timer, utmi-pads;
nvidia,has-legacy-mode;
-   hssync_start_delay = 9;
-   idle_wait_delay = 17;
-   elastic_limit = 16;
-   term_range_adj = 6;
-   xcvr_setup = 9;
-   xcvr_lsfslew = 1;
-   xcvr_lsrslew = 1;
+   nvidia,hssync-start-delay = 9;
+   nvidia,idle-wait-delay = 17;
+   nvidia,elastic-limit = 16;
+   nvidia,term-range-adj = 6;
+   nvidia,xcvr-setup = 9;
+   nvidia,xcvr-lsfslew = 1;
+   nvidia,xcvr-lsrslew = 1;
status = disabled;
};
 
@@ -527,13 +527,13 @@
 tegra_car TEGRA20_CLK_CLK_M,
 tegra_car TEGRA20_CLK_USBD;
clock-names = reg, pll_u, timer, utmi-pads;
-   hssync_start_delay = 9;
-   idle_wait_delay = 17;
-   elastic_limit = 16;
-   term_range_adj = 6;
-   xcvr_setup = 9;
-   xcvr_lsfslew = 2;
-   xcvr_lsrslew = 2;
+   nvidia,hssync-start-delay = 9;
+   nvidia,idle-wait-delay = 17;
+   nvidia,elastic-limit = 16;
+   nvidia,term-range-adj = 6;
+   nvidia,xcvr-setup = 9;
+   nvidia,xcvr-lsfslew = 2;
+   nvidia,xcvr-lsrslew = 2;
status = disabled;
};
 
-- 
1.8.1.5

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


[PATCH 2/2] usb: phy: tegra: Read UTMIP parameters from device tree

2013-06-26 Thread Mikko Perttunen
UTMIP parameters used to be hardcoded into tables in the
PHY driver. This patch moves them into the device tree
in accordance with the phy-tegra-usb DT documentation.

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 drivers/usb/phy/phy-tegra-usb.c | 129 +++-
 1 file changed, 87 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index b3b4809..0352886c 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -185,27 +185,6 @@ static const struct tegra_xtal_freq tegra_freq_table[] = {
},
 };
 
-static struct tegra_utmip_config utmip_default[] = {
-   [0] = {
-   .hssync_start_delay = 9,
-   .idle_wait_delay = 17,
-   .elastic_limit = 16,
-   .term_range_adj = 6,
-   .xcvr_setup = 9,
-   .xcvr_lsfslew = 1,
-   .xcvr_lsrslew = 1,
-   },
-   [2] = {
-   .hssync_start_delay = 9,
-   .idle_wait_delay = 17,
-   .elastic_limit = 16,
-   .term_range_adj = 6,
-   .xcvr_setup = 9,
-   .xcvr_lsfslew = 2,
-   .xcvr_lsrslew = 2,
-   },
-};
-
 static void set_pts(struct tegra_usb_phy *phy, u8 pts_val)
 {
void __iomem *base = phy-regs;
@@ -727,13 +706,6 @@ static int tegra_usb_phy_init(struct tegra_usb_phy *phy)
int i;
int err;
 
-   if (!phy-is_ulpi_phy) {
-   if (phy-is_legacy_phy)
-   phy-config = utmip_default[0];
-   else
-   phy-config = utmip_default[2];
-   }
-
phy-pll_u = devm_clk_get(phy-dev, pll_u);
if (IS_ERR(phy-pll_u)) {
pr_err(Can't get pll_u clock\n);
@@ -808,6 +780,88 @@ void tegra_ehci_phy_restore_end(struct usb_phy *x)
 }
 EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
 
+static int read_utmi_param(struct platform_device *pdev, const char *param,
+  u8 *dest)
+{
+   u32 value;
+   int err = of_property_read_u32(pdev-dev.of_node, param, value);
+   *dest = (u8)value;
+   if (err  0)
+   dev_err(pdev-dev, Failed to read USB UTMI parameter %s: 
%d\n,
+   param, err);
+   return err;
+}
+
+static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
+ struct platform_device *pdev)
+{
+   struct resource *res;
+   int err;
+   struct tegra_utmip_config *config;
+
+   tegra_phy-is_ulpi_phy = false;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+   if (!res) {
+   dev_err(pdev-dev, Failed to get UTMI Pad regs\n);
+   return  -ENXIO;
+   }
+
+   tegra_phy-pad_regs = devm_ioremap(pdev-dev, res-start,
+   resource_size(res));
+   if (!tegra_phy-regs) {
+   dev_err(pdev-dev, Failed to remap UTMI Pad regs\n);
+   return -ENOMEM;
+   }
+
+   tegra_phy-config = devm_kzalloc(pdev-dev,
+   sizeof(*tegra_phy-config), GFP_KERNEL);
+   if (!tegra_phy-config) {
+   dev_err(pdev-dev,
+   unable to allocate memory for USB UTMIP config\n);
+   return -ENOMEM;
+   }
+
+   config = tegra_phy-config;
+
+   err = read_utmi_param(pdev, nvidia,hssync-start-delay,
+   config-hssync_start_delay);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,elastic-limit,
+   config-elastic_limit);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,idle-wait-delay,
+   config-idle_wait_delay);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,term-range-adj,
+   config-term_range_adj);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,xcvr-setup,
+   config-xcvr_setup);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,xcvr-lsfslew,
+   config-xcvr_lsfslew);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,xcvr-lsrslew,
+   config-xcvr_lsrslew);
+   if (err  0)
+   return err;
+
+   return 0;
+}
+
 static int tegra_usb_phy_probe(struct platform_device *pdev)
 {
struct resource *res;
@@ -839,20 +893,9 @@ static int tegra_usb_phy_probe(struct platform_device 
*pdev)
 
err = of_property_match_string(np, phy_type, ulpi);
if (err  0) {
-   tegra_phy-is_ulpi_phy = false;
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   if (!res) {
-   dev_err(pdev-dev, Failed to get UTMI Pad regs\n);
-   return  -ENXIO;
-   }
-
-   

Re: [PATCH] usb: dwc3: core: continue probe even if usb3 phy is not available

2013-06-26 Thread George Cherian

On 6/26/2013 3:46 PM, Felipe Balbi wrote:

Hi,

On Wed, Jun 26, 2013 at 02:59:14PM +0530, George Cherian wrote:

There can be configurations in which DWC3 is hoooked up only to USB2 PHY.
In such cases we should not return -EPROBE_DEFER, rather continue probe
even if there is no USB3 PHY.

Signed-off-by: George Cherian george.cher...@ti.com
---
  drivers/usb/dwc3/core.c | 31 ---
  1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c35d49d..d5e6f3e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -100,7 +100,9 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
dwc3_writel(dwc-regs, DWC3_GUSB2PHYCFG(0), reg);
  
  	usb_phy_init(dwc-usb2_phy);

-   usb_phy_init(dwc-usb3_phy);
+
+   if (dwc-usb3_phy)
+   usb_phy_init(dwc-usb3_phy);

I would feel more comfortable if you would move our maximum_speed module
parameter to DT with a property such as:

snps,maximum_speed = highspeed;

then on driver you could:

okay

ret = of_property_read_string(np, snps,maximum_speed, maximum_speed);
if (ret  0)
bailout();

if (strncmp(maximum_speed, superspeed, 10) == 0) {
/* grab USB3 PHY, return EPROBE_DEFER if not found */
grab_usb3_phy();
}

if ((strncmp(maximum_speed, highspeed, 9) == 0) ||
(strncmp(maximum_speed, fullspeed, 9) == 0) ||
(strncmp(maximum_speed, lowspeed, 8) == 0)) {
/* grab USB2 PHY, return EPROBE_DEFER if not found */
grab_usb2_phy();
}

this way, we depend solely on setting maximum_speed to highspeed for
AM437x :-)

In dra7xx one instance is superspeed and one instance highspeed.


ps: don't forget to default to superspeed in case no property is passed.

okay
Regards
-George
--
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 1/8] drivers: phy: add generic PHY framework

2013-06-26 Thread Felipe Balbi
On Wed, Jun 26, 2013 at 05:17:29PM +0530, Kishon Vijay Abraham I wrote:
 The PHY framework provides a set of APIs for the PHY drivers to
 create/destroy a PHY and APIs for the PHY users to obtain a reference to the
 PHY with or without using phandle. For dt-boot, the PHY drivers should
 also register *PHY provider* with the framework.
 
 PHY drivers should create the PHY by passing id and ops like init, exit,
 power_on and power_off. This framework is also pm runtime enabled.
 
 The documentation for the generic PHY framework is added in
 Documentation/phy.txt and the documentation for dt binding can be found at
 Documentation/devicetree/bindings/phy/phy-bindings.txt
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 Tested-by: Sylwester Nawrocki s.nawro...@samsung.com

looks great to my eyes

Acked-by: Felipe Balbi ba...@ti.com

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: dwc3: core: continue probe even if usb3 phy is not available

2013-06-26 Thread Felipe Balbi
On Wed, Jun 26, 2013 at 05:37:19PM +0530, George Cherian wrote:
 On 6/26/2013 3:46 PM, Felipe Balbi wrote:
 Hi,
 
 On Wed, Jun 26, 2013 at 02:59:14PM +0530, George Cherian wrote:
 There can be configurations in which DWC3 is hoooked up only to USB2 PHY.
 In such cases we should not return -EPROBE_DEFER, rather continue probe
 even if there is no USB3 PHY.
 
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
   drivers/usb/dwc3/core.c | 31 ---
   1 file changed, 24 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index c35d49d..d5e6f3e 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -100,7 +100,9 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
 dwc3_writel(dwc-regs, DWC3_GUSB2PHYCFG(0), reg);
 usb_phy_init(dwc-usb2_phy);
 -   usb_phy_init(dwc-usb3_phy);
 +
 +   if (dwc-usb3_phy)
 +   usb_phy_init(dwc-usb3_phy);
 I would feel more comfortable if you would move our maximum_speed module
 parameter to DT with a property such as:
 
 snps,maximum_speed = highspeed;
 
 then on driver you could:
 okay
 ret = of_property_read_string(np, snps,maximum_speed, maximum_speed);
 if (ret  0)
  bailout();
 
 if (strncmp(maximum_speed, superspeed, 10) == 0) {
  /* grab USB3 PHY, return EPROBE_DEFER if not found */
  grab_usb3_phy();
 }
 
 if ((strncmp(maximum_speed, highspeed, 9) == 0) ||
  (strncmp(maximum_speed, fullspeed, 9) == 0) ||
  (strncmp(maximum_speed, lowspeed, 8) == 0)) {
  /* grab USB2 PHY, return EPROBE_DEFER if not found */
  grab_usb2_phy();
 }
 
 this way, we depend solely on setting maximum_speed to highspeed for
 AM437x :-)
 In dra7xx one instance is superspeed and one instance highspeed.

right, but in DT you will define both instances and each instance will
have a seaparate snps,maximum_speed attribute :-)

I'm now considering if we should make maximum_speed a generic attribute,
Kishon ? Alex ? Alan ?

anyone else needs such thing ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: host: xhci-plat: Enable XHCI_SPURIOUS_SUCCESS quirk for xhci-plat

2013-06-26 Thread George Cherian

On 6/26/2013 2:32 PM, Felipe Balbi wrote:

Hi,

On Wed, Jun 26, 2013 at 02:28:57PM +0530, George Cherian wrote:

Synopsis xhci controllers with hci_version  0.96 gives spurious success
events on short packet completion. During webcam capture the
ERROR Transfer event TRB DMA ptr not part of current TD was observed.
The same application works fine with synopsis controllers hci_version 0.96.

Signed-off-by: George Cheriangeorge.cher...@ti.com
---
  drivers/usb/host/xhci-plat.c | 10 ++
  1 file changed, 10 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 93ad67e..e63c6d3 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -25,6 +25,16 @@ static void xhci_plat_quirks(struct device *dev, struct 
xhci_hcd *xhci)
 * dev struct in order to setup MSI
 */
xhci-quirks |= XHCI_BROKEN_MSI;
+
+   /*
+* In some xhci controllers which follows xhci 1.0 spec gives a spurious
+* success event after a short transfer. This quirk will ignore such
+* spurious event. Hit this issue in synopsis xhci controllers with
+* hci_version  0.96
+*/
+
+   if (xhci-hci_version  0x96)
+   xhci-quirks |= XHCI_SPURIOUS_SUCCESS;
  }

doesn't look like the correct way to do this. What if enabling that
quirk on hosts which don't have the quirk cause problems ?
For a controller which does not have this issue will never get a 
spurious success for short packet ( and that too for only ISOCH).


per this commit ad808333d Intel xhci: Ignore spurious successful event.

This spurious successful event behavior isn't technically disallowed by
the xHCI specification, so make the xHCI driver just ignore the spurious
completion event.

I would suggest adding a platform_data which (in our case) dwc3 will
pass to xhci-plat. Then you can do proper revision detection of the
synopsys controller and set the quirk only on the failing hosts.

BTW, do you have the STARS number for this errata ?

No STARS number yet.


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


Re: [PATCH 1/2] ARM: dts: tegra20: Rename USB UTMI parameters according to new definitions

2013-06-26 Thread Mikko Perttunen

On Wed, 26 Jun 2013 15:14:42 +0300, Felipe Balbi ba...@ti.com wrote:


* PGP Signed by an unknown key

On Wed, Jun 26, 2013 at 02:58:46PM +0300, Mikko Perttunen wrote:

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com


you need a commit log, sorry. Even if obvious



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


build warning on chipidea core

2013-06-26 Thread Felipe Balbi
Hi,

just below warnings when building greg/usb-next for x86:

drivers/usb/chipidea/core.c: In function ‘hw_phymode_configure’:
drivers/usb/chipidea/core.c:226:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]
drivers/usb/chipidea/core.c:230:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]
drivers/usb/chipidea/core.c:243:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]
drivers/usb/chipidea/core.c:246:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: host: xhci-plat: Enable XHCI_SPURIOUS_SUCCESS quirk for xhci-plat

2013-06-26 Thread Felipe Balbi
Hi,

On Wed, Jun 26, 2013 at 05:46:29PM +0530, George Cherian wrote:
 @@ -25,6 +25,16 @@ static void xhci_plat_quirks(struct device *dev, struct 
 xhci_hcd *xhci)
  * dev struct in order to setup MSI
  */
 xhci-quirks |= XHCI_BROKEN_MSI;
 +
 +   /*
 +* In some xhci controllers which follows xhci 1.0 spec gives a spurious
 +* success event after a short transfer. This quirk will ignore such
 +* spurious event. Hit this issue in synopsis xhci controllers with
 +* hci_version  0.96
 +*/
 +
 +   if (xhci-hci_version  0x96)
 +   xhci-quirks |= XHCI_SPURIOUS_SUCCESS;
   }
 doesn't look like the correct way to do this. What if enabling that
 quirk on hosts which don't have the quirk cause problems ?
 For a controller which does not have this issue will never get a
 spurious success for short packet ( and that too for only ISOCH).
 
 per this commit ad808333d Intel xhci: Ignore spurious successful event.
 
 This spurious successful event behavior isn't technically disallowed by
 the xHCI specification, so make the xHCI driver just ignore the spurious
 completion event.

still we don't want to enable quirks for devices which aren't quirky :-)

Now how Sarah correctly enables the quirk flag only for the known bad
Panther Point device.

 I would suggest adding a platform_data which (in our case) dwc3 will
 pass to xhci-plat. Then you can do proper revision detection of the
 synopsys controller and set the quirk only on the failing hosts.
 
 BTW, do you have the STARS number for this errata ?
 No STARS number yet.

once we have it, let's make sure to follow what we do on the dwc3 and
list it in a comment. You already that you found the bug with a Synopsys
controller anyway, might as well point to the fact that there is a
ticket with synopsys to track this issue.

cheers

-- 
balbi


signature.asc
Description: Digital signature


[PATCH v2 2/2] usb: phy: tegra: Read UTMIP parameters from device tree

2013-06-26 Thread Mikko Perttunen
UTMIP parameters used to be hardcoded into tables in the
PHY driver. This patch reads them from the device tree instead
in accordance with the phy-tegra-usb DT documentation.

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 drivers/usb/phy/phy-tegra-usb.c | 129 +++-
 1 file changed, 87 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index b3b4809..0352886c 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -185,27 +185,6 @@ static const struct tegra_xtal_freq tegra_freq_table[] = {
},
 };
 
-static struct tegra_utmip_config utmip_default[] = {
-   [0] = {
-   .hssync_start_delay = 9,
-   .idle_wait_delay = 17,
-   .elastic_limit = 16,
-   .term_range_adj = 6,
-   .xcvr_setup = 9,
-   .xcvr_lsfslew = 1,
-   .xcvr_lsrslew = 1,
-   },
-   [2] = {
-   .hssync_start_delay = 9,
-   .idle_wait_delay = 17,
-   .elastic_limit = 16,
-   .term_range_adj = 6,
-   .xcvr_setup = 9,
-   .xcvr_lsfslew = 2,
-   .xcvr_lsrslew = 2,
-   },
-};
-
 static void set_pts(struct tegra_usb_phy *phy, u8 pts_val)
 {
void __iomem *base = phy-regs;
@@ -727,13 +706,6 @@ static int tegra_usb_phy_init(struct tegra_usb_phy *phy)
int i;
int err;
 
-   if (!phy-is_ulpi_phy) {
-   if (phy-is_legacy_phy)
-   phy-config = utmip_default[0];
-   else
-   phy-config = utmip_default[2];
-   }
-
phy-pll_u = devm_clk_get(phy-dev, pll_u);
if (IS_ERR(phy-pll_u)) {
pr_err(Can't get pll_u clock\n);
@@ -808,6 +780,88 @@ void tegra_ehci_phy_restore_end(struct usb_phy *x)
 }
 EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
 
+static int read_utmi_param(struct platform_device *pdev, const char *param,
+  u8 *dest)
+{
+   u32 value;
+   int err = of_property_read_u32(pdev-dev.of_node, param, value);
+   *dest = (u8)value;
+   if (err  0)
+   dev_err(pdev-dev, Failed to read USB UTMI parameter %s: 
%d\n,
+   param, err);
+   return err;
+}
+
+static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
+ struct platform_device *pdev)
+{
+   struct resource *res;
+   int err;
+   struct tegra_utmip_config *config;
+
+   tegra_phy-is_ulpi_phy = false;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+   if (!res) {
+   dev_err(pdev-dev, Failed to get UTMI Pad regs\n);
+   return  -ENXIO;
+   }
+
+   tegra_phy-pad_regs = devm_ioremap(pdev-dev, res-start,
+   resource_size(res));
+   if (!tegra_phy-regs) {
+   dev_err(pdev-dev, Failed to remap UTMI Pad regs\n);
+   return -ENOMEM;
+   }
+
+   tegra_phy-config = devm_kzalloc(pdev-dev,
+   sizeof(*tegra_phy-config), GFP_KERNEL);
+   if (!tegra_phy-config) {
+   dev_err(pdev-dev,
+   unable to allocate memory for USB UTMIP config\n);
+   return -ENOMEM;
+   }
+
+   config = tegra_phy-config;
+
+   err = read_utmi_param(pdev, nvidia,hssync-start-delay,
+   config-hssync_start_delay);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,elastic-limit,
+   config-elastic_limit);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,idle-wait-delay,
+   config-idle_wait_delay);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,term-range-adj,
+   config-term_range_adj);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,xcvr-setup,
+   config-xcvr_setup);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,xcvr-lsfslew,
+   config-xcvr_lsfslew);
+   if (err  0)
+   return err;
+
+   err = read_utmi_param(pdev, nvidia,xcvr-lsrslew,
+   config-xcvr_lsrslew);
+   if (err  0)
+   return err;
+
+   return 0;
+}
+
 static int tegra_usb_phy_probe(struct platform_device *pdev)
 {
struct resource *res;
@@ -839,20 +893,9 @@ static int tegra_usb_phy_probe(struct platform_device 
*pdev)
 
err = of_property_match_string(np, phy_type, ulpi);
if (err  0) {
-   tegra_phy-is_ulpi_phy = false;
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   if (!res) {
-   dev_err(pdev-dev, Failed to get UTMI Pad regs\n);
-   return  -ENXIO;
-   }
-
-   

[PATCH v2 1/2] ARM: dts: tegra20: Rename USB UTMI parameters according to new definitions

2013-06-26 Thread Mikko Perttunen
This patch changes the Tegra20 USB PHY nodes to use the UTMI configuration
parameter names as specified in the device tree binding documentation
after patch ARM: tegra: finalize USB EHCI and PHY bindings.

Signed-off-by: Mikko Perttunen mperttu...@nvidia.com
---
 arch/arm/boot/dts/tegra20.dtsi | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 9653fd8..e457083 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -477,13 +477,13 @@
 tegra_car TEGRA20_CLK_USBD;
clock-names = reg, pll_u, timer, utmi-pads;
nvidia,has-legacy-mode;
-   hssync_start_delay = 9;
-   idle_wait_delay = 17;
-   elastic_limit = 16;
-   term_range_adj = 6;
-   xcvr_setup = 9;
-   xcvr_lsfslew = 1;
-   xcvr_lsrslew = 1;
+   nvidia,hssync-start-delay = 9;
+   nvidia,idle-wait-delay = 17;
+   nvidia,elastic-limit = 16;
+   nvidia,term-range-adj = 6;
+   nvidia,xcvr-setup = 9;
+   nvidia,xcvr-lsfslew = 1;
+   nvidia,xcvr-lsrslew = 1;
status = disabled;
};
 
@@ -527,13 +527,13 @@
 tegra_car TEGRA20_CLK_CLK_M,
 tegra_car TEGRA20_CLK_USBD;
clock-names = reg, pll_u, timer, utmi-pads;
-   hssync_start_delay = 9;
-   idle_wait_delay = 17;
-   elastic_limit = 16;
-   term_range_adj = 6;
-   xcvr_setup = 9;
-   xcvr_lsfslew = 2;
-   xcvr_lsrslew = 2;
+   nvidia,hssync-start-delay = 9;
+   nvidia,idle-wait-delay = 17;
+   nvidia,elastic-limit = 16;
+   nvidia,term-range-adj = 6;
+   nvidia,xcvr-setup = 9;
+   nvidia,xcvr-lsfslew = 2;
+   nvidia,xcvr-lsrslew = 2;
status = disabled;
};
 
-- 
1.8.1.5

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


[PATCH v2 0/2] usb: phy: tegra: Read UTMI parameters from device tree

2013-06-26 Thread Mikko Perttunen
This patchset moves the USB UTMI interface parameters from hardcoded tables
in the PHY driver to device tree and adds code to read them from there.

Mikko Perttunen (2):
  ARM: dts: tegra20: Rename USB UTMI parameters according to new
definitions
  usb: phy: tegra: Read UTMIP parameters from device tree

 arch/arm/boot/dts/tegra20.dtsi  |  28 -
 drivers/usb/phy/phy-tegra-usb.c | 129 +++-
 2 files changed, 101 insertions(+), 56 deletions(-)

-- 
1.8.1.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] usb: dwc3: make glue layers selectable

2013-06-26 Thread Felipe Balbi
Glue layers are starting to have separate
requirements. For example, OMAP's glue layer
is starting to use extcon framework which
no one else needs.

In order to make it clear the proper dependencies,
we are now allowing glue layers to be selectable
so that each glue layer can list their own dependencies
without messing with the core IP driver.

Signed-off-by: Felipe Balbi ba...@ti.com
---

Note that this will require defconfig changes unless someone
knows about a choice-like Kconfig construct which allows defaults.

cheers

 drivers/usb/dwc3/Kconfig  | 29 +
 drivers/usb/dwc3/Makefile | 13 +++--
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 757aa18..2d12909 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -40,6 +40,35 @@ config USB_DWC3_DUAL_ROLE
 
 endchoice
 
+choice
+   prompt Platform Glue Driver Support
+
+config USB_DWC3_OMAP
+   tristate Texas Instruments OMAP5 and similar Platforms
+   depends on EXTCON
+   help
+ Some platforms from Texas Instruments like OMAP5, DRA7xxx and
+ AM437x use this IP for USB2/3 functionality.
+
+ Say 'Y' or 'M' here if you have one such device
+
+config USB_DWC3_EXYNOS
+   tristate Samsung Exynos Platform
+   help
+ Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside,
+ say 'Y' or 'M' if you have one such device.
+
+config USB_DWC3_PCI
+   tristate PCIe-based Platforms
+   depends on PCI
+   help
+ If you're using the DesignWare Core IP with a PCIe, please say
+ 'Y' or 'M' here.
+
+ One such PCIe-based platform is Synopsys' PCIe HAPS model of
+ this IP.
+endchoice
+
 config USB_DWC3_DEBUG
bool Enable Debugging Messages
help
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 0c7ac925..dd17601 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -27,15 +27,8 @@ endif
 # the entire driver (with all its glue layers) on several architectures
 # and make sure it compiles fine. This will also help with allmodconfig
 # and allyesconfig builds.
-#
-# The only exception is the PCI glue layer, but that's only because
-# PCI doesn't provide nops if CONFIG_PCI isn't enabled.
 ##
 
-obj-$(CONFIG_USB_DWC3) += dwc3-omap.o
-obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o
-
-ifneq ($(CONFIG_PCI),)
-   obj-$(CONFIG_USB_DWC3)  += dwc3-pci.o
-endif
-
+obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o
+obj-$(CONFIG_USB_DWC3_EXYNOS)  += dwc3-exynos.o
+obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o
-- 
1.8.2.1

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


Re: [PATCH] usb: dwc3: core: continue probe even if usb3 phy is not available

2013-06-26 Thread Alexander Shishkin
Felipe Balbi ba...@ti.com writes:

 On Wed, Jun 26, 2013 at 05:37:19PM +0530, George Cherian wrote:
 On 6/26/2013 3:46 PM, Felipe Balbi wrote:
 Hi,
 
 On Wed, Jun 26, 2013 at 02:59:14PM +0530, George Cherian wrote:
 There can be configurations in which DWC3 is hoooked up only to USB2 PHY.
 In such cases we should not return -EPROBE_DEFER, rather continue probe
 even if there is no USB3 PHY.
 
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
   drivers/usb/dwc3/core.c | 31 ---
   1 file changed, 24 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index c35d49d..d5e6f3e 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -100,7 +100,9 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
dwc3_writel(dwc-regs, DWC3_GUSB2PHYCFG(0), reg);
usb_phy_init(dwc-usb2_phy);
 -  usb_phy_init(dwc-usb3_phy);
 +
 +  if (dwc-usb3_phy)
 +  usb_phy_init(dwc-usb3_phy);
 I would feel more comfortable if you would move our maximum_speed module
 parameter to DT with a property such as:
 
 snps,maximum_speed = highspeed;
 
 then on driver you could:
 okay
 ret = of_property_read_string(np, snps,maximum_speed, maximum_speed);
 if (ret  0)
 bailout();
 
 if (strncmp(maximum_speed, superspeed, 10) == 0) {
 /* grab USB3 PHY, return EPROBE_DEFER if not found */
 grab_usb3_phy();
 }
 
 if ((strncmp(maximum_speed, highspeed, 9) == 0) ||
 (strncmp(maximum_speed, fullspeed, 9) == 0) ||
 (strncmp(maximum_speed, lowspeed, 8) == 0)) {
 /* grab USB2 PHY, return EPROBE_DEFER if not found */
 grab_usb2_phy();
 }
 
 this way, we depend solely on setting maximum_speed to highspeed for
 AM437x :-)
 In dra7xx one instance is superspeed and one instance highspeed.

 right, but in DT you will define both instances and each instance will
 have a seaparate snps,maximum_speed attribute :-)

 I'm now considering if we should make maximum_speed a generic attribute,
 Kishon ? Alex ? Alan ?

 anyone else needs such thing ?

We have a force-full-speed attibute for chipidea on the way. This
maximum_speed looks like a more generic alternative. Michael, what say
you?

Regards,
--
Alex
--
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 v2] staging: usbip: replace pr_warning() with dev_warn().

2013-06-26 Thread Sergei Shtylyov

Hello.

On 26-06-2013 13:41, navin patidar wrote:


dev_warn() is preferred over pr_warning().



container_of() is used to get usb_driver pointer from usbip_device container
(stub_device or vhci_device), to get device structure required for dev_warn().



Signed-off-by: navin patidar nav...@cdac.in
---
  drivers/staging/usbip/usbip_event.c |   14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)



diff --git a/drivers/staging/usbip/usbip_event.c 
b/drivers/staging/usbip/usbip_event.c
index 82123be..3bd1b94 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -21,6 +21,8 @@
  #include linux/export.h

  #include usbip_common.h
+#include stub.h
+#include vhci.h

  static int event_handler(struct usbip_device *ud)
  {
@@ -85,7 +87,17 @@ int usbip_start_eh(struct usbip_device *ud)

ud-eh = kthread_run(event_handler_loop, ud, usbip_eh);
if (IS_ERR(ud-eh)) {
-   pr_warning(Unable to start control thread\n);
+   struct device dev;


   Empty line after declaration wouldn't hurt here...


+   if (ud-side == USBIP_STUB) {
+   struct stub_device *sdev;


   ... and here.


+   sdev = container_of(ud, struct stub_device, ud);
+   dev = sdev-udev-dev;
+   } else {
+   struct vhci_device *vdev;


   ... and here.


+   vdev = container_of(ud, struct vhci_device, ud);
+   dev = vdev-udev-dev;
+   }
+   dev_warn(dev, Unable to start control thread\n);


   Patch looks clumsy...

WBR, Sergei

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


Re: [RFC/PATCH] usb: dwc3: make glue layers selectable

2013-06-26 Thread Sebastian Andrzej Siewior
On 06/26/2013 02:41 PM, Felipe Balbi wrote:

 Note that this will require defconfig changes unless someone
 knows about a choice-like Kconfig construct which allows defaults.

You can default y so it will be always selected if it is possible
which was the default and drop it after a few kernel releases so
everyone doing oldconfig picked up the change.

Sebastian
--
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] usb: dwc3: make glue layers selectable

2013-06-26 Thread George Cherian

On 6/26/2013 6:11 PM, Felipe Balbi wrote:

Glue layers are starting to have separate
requirements. For example, OMAP's glue layer
is starting to use extcon framework which
no one else needs.

In order to make it clear the proper dependencies,
we are now allowing glue layers to be selectable
so that each glue layer can list their own dependencies
without messing with the core IP driver.

Signed-off-by: Felipe Balbi ba...@ti.com
---

Note that this will require defconfig changes unless someone
knows about a choice-like Kconfig construct which allows defaults.

cheers

  drivers/usb/dwc3/Kconfig  | 29 +
  drivers/usb/dwc3/Makefile | 13 +++--
  2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 757aa18..2d12909 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -40,6 +40,35 @@ config USB_DWC3_DUAL_ROLE
  
  endchoice
  
+choice

+   prompt Platform Glue Driver Support
+
+config USB_DWC3_OMAP
+   tristate Texas Instruments OMAP5 and similar Platforms
+   depends on EXTCON
+   help
+ Some platforms from Texas Instruments like OMAP5, DRA7xxx and
+ AM437x use this IP for USB2/3 functionality.

Do we really need the depends on EXTCON for AM437x and DRA7xx ?
We are using utmi_mode = HW in AM437x.

Regards
-George
--
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 4/6] USB: ehci-omap: Suspend the controller during bus suspend

2013-06-26 Thread Roger Quadros
On 06/25/2013 08:38 PM, Alan Stern wrote:
 On Tue, 25 Jun 2013, Roger Quadros wrote:
 
 On 06/24/2013 10:34 PM, Alan Stern wrote:
 On Mon, 24 Jun 2013, Roger Quadros wrote:

 OK I've tried to handle all this in an alternate way. Now the controller 
 suspend/resume
 and runtime suspend/resume is independent of bus suspend.

 The controller now runtime suspends when all devices on the bus have 
 suspended and
 the hub auto suspends. NOTE: HW_ACCESSIBLE is still set on runtime_suspend.
 The challenge here is to process the interrupt in this state.

 The situation is a little peculiar.  Does the hardware really use the
 same IRQ for reporting wakeup events when the controller is suspended
 and for reporting normal I/O events?

 No and yes :). Actually the Pad wakeup comes as a separate IRQ from hardware.
 The omap pinctrl driver captures that, determines which pad caused the 
 wakeup and
 routes it to the appropriate interrupt based on the mapping provided in the 
 device tree.
 In the ehci-omap case we provide the EHCI IRQ number in the mapping for the 
 USB host pads.
 
 Could the mapping be changed so that a different interrupt vector was 
 used for wakeups and normal I/O?  That would make this a little easier, 
 although it wouldn't solve the general problem.

I'm not sure which IRQ we can map it to, but it could be mapped to some
free IRQ number. Since it doesn't make things easier, I think we can leave
it as it is for now.

 
if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd)))
rc = IRQ_NONE;
 +  else if (pm_runtime_status_suspended(hcd-self.controller)) {
 +  /*
 +   * We can't handle it yet so disable IRQ, make note of it
 +   * and resume root hub (i.e. controller as well)
 +   */
 +  disable_irq_nosync(hcd-irq);
 +  set_bit(HCD_FLAG_IRQ_DISABLED, hcd-flags);
 +  usb_hcd_resume_root_hub(hcd);
 +  rc = IRQ_HANDLED;
 +  }

 This part will have to be different.

 Certainly if HCD_DEAD(hcd) then we want to return IRQ_NONE.  Likewise
 if (!HCD_HW_ACCESSIBLE(hcd)  !hcd-has_wakeup_interrupts).  In all
 other cases we have to call the HCD's interrupt handler.
 
 There's still a race problem.  Suppose a normal wakeup interrupt occurs
 just before or as the controller gets suspended.  By the time the code
 here runs, HCD_HW_ACCESSIBLE may have been cleared by the suspend
 routine.  The interrupt would be lost.  Depending on the design of the
 controller, the entire wakeup signal could end up getting lost as well.

But if I call ehci_suspend() in the runtime_suspend handler, this race
won't happen right?

 
 Do you know how the OMAP EHCI controller behaves?  Under what 
 conditions does it send the wakeup IRQ?  How do you tell it to turn off 
 the wakeup IRQ?

Once the controller is suspended, the wakeup IRQ comes out-of-band. i.e. through
pad wakeup and pinctrl subsystem.
The only way to turn that wakeup off is to disable the wakeup enable bit on the 
pad.
This could be done by not putting the pins in the IDLE_WAKEUP state during
suspend.

ff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
 index d53547d..24e21a2 100644
 --- a/drivers/usb/core/hcd.c
 +++ b/drivers/usb/core/hcd.c
 @@ -2136,6 +2136,11 @@ static void hcd_resume_work(struct work_struct *work)
  usb_lock_device(udev);
  usb_remote_wakeup(udev);
  usb_unlock_device(udev);
 +if (HCD_IRQ_DISABLED(hcd)) {
 +/* Interrupt was disabled */
 +clear_bit(HCD_FLAG_IRQ_DISABLED, hcd-flags);
 +enable_irq(hcd-irq);
 +}
  }
  
  /**
 @@ -2223,7 +2228,9 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd)
   */
  local_irq_save(flags);
  
 -if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd)))
 +if (unlikely(HCD_DEAD(hcd)))
 +rc = IRQ_NONE;
 +else if (!HCD_HW_ACCESSIBLE(hcd)  !hcd-has_wakeup_irq)
  rc = IRQ_NONE;
 
 Add an unlikely() here too.
 
OK.

  else if (hcd-driver-irq(hcd) == IRQ_NONE)
  rc = IRQ_NONE;
 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
 index 246e124..1844e31 100644
 --- a/drivers/usb/host/ehci-hcd.c
 +++ b/drivers/usb/host/ehci-hcd.c
 @@ -689,6 +689,21 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
  
  spin_lock (ehci-lock);
  
 +if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) {
 +/*
 + * We got a wakeup interrupt while the controller was
 + * suspending or suspended.  We can't handle it now, so
 + * disable the IRQ and resume the root hub (and hence
 + * the controller too).
 + */
 +disable_irq_nosync(hcd-irq);
 +set_bit(HCD_FLAG_IRQ_DISABLED, hcd-flags);
 
 To be safe, let's put these two statements inside
 
   if (hcd-has_wakeup_irq) { ... }
 
 I think if the right sort of race occurs, we could end up here even 
 when hcd-has_wakeup_irq is clear.  So this test is needed.  We don't 
 want to disable a 

Re: [RFC/PATCH] usb: dwc3: make glue layers selectable

2013-06-26 Thread Felipe Balbi
On Wed, Jun 26, 2013 at 06:40:22PM +0530, George Cherian wrote:
 On 6/26/2013 6:11 PM, Felipe Balbi wrote:
 Glue layers are starting to have separate
 requirements. For example, OMAP's glue layer
 is starting to use extcon framework which
 no one else needs.
 
 In order to make it clear the proper dependencies,
 we are now allowing glue layers to be selectable
 so that each glue layer can list their own dependencies
 without messing with the core IP driver.
 
 Signed-off-by: Felipe Balbi ba...@ti.com
 ---
 
 Note that this will require defconfig changes unless someone
 knows about a choice-like Kconfig construct which allows defaults.
 
 cheers
 
   drivers/usb/dwc3/Kconfig  | 29 +
   drivers/usb/dwc3/Makefile | 13 +++--
   2 files changed, 32 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index 757aa18..2d12909 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -40,6 +40,35 @@ config USB_DWC3_DUAL_ROLE
   endchoice
 +choice
 +prompt Platform Glue Driver Support
 +
 +config USB_DWC3_OMAP
 +tristate Texas Instruments OMAP5 and similar Platforms
 +depends on EXTCON
 +help
 +  Some platforms from Texas Instruments like OMAP5, DRA7xxx and
 +  AM437x use this IP for USB2/3 functionality.
 Do we really need the depends on EXTCON for AM437x and DRA7xx ?
 We are using utmi_mode = HW in AM437x.

there's no way to make conditional depends like that, unfortunately.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] staging: ozwpan: Use normal Makefile, convert oz_trace to oz_dbg

2013-06-26 Thread Joe Perches
On Wed, 2013-06-26 at 12:53 +0100, Rupesh Gujare wrote:
 On 26/06/13 02:00, Joe Perches wrote:
  Use a normal Makefile.
  Convert oz_trace and oz_trace2 to a more normal oz_dbg.
  Consolidate oztrace and ozconfig files to ozdbg.h
  Update #include files.
  Reflow modified lines, fit to 80 cols, align arguments.
 
  Add a couple more oz_foo_dbg macros to show how more
  verbose device specific debugging could be added when a
  struct device * or struct netdevice * is available.
 
 Isn't this patch doing too many changes in single patch? Can we split 
 this patch into smaller patch series ?
 In addition to above, it also :-
 1. Removes few unwanted logs.
 2. Changes macro definition for oz_remember_urb()  oz_forget_urb() to 
 static inline function when WANT_URB_PARANOIA is not defined.

Yeah, sure, please do.
It was intended more to inform than be applied.
staging is closed for at least a few weeks.
Resubmit something like it in as many pieces
as you choose later.

 Above macros look good, however Greg have objection to define new macros 
  he had suggested to use dev_dbg()  pr_debug().
 I will leave it to him, if he is all right to accept new macros for 
 debug logs.
 
 Greg,
 Your comments please.


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


Re: URB completion order, normal behavior or bug?

2013-06-26 Thread Daniel Santos

On 06/25/2013 05:42 PM, Daniel Santos wrote:

On 06/25/2013 09:45 AM, Alan Stern wrote:

static __always_inline int init_endpoint(struct mcp2210_device *dev,
   const struct usb_host_endpoint *ep)
{
  int is_dir_in = !!usb_endpoint_dir_in(ep-desc);
  struct mcp2210_endpoint_proxy *dest;
  unsigned int pipe;
  usb_complete_t complete_fn;
  struct urb *urb;

  if (is_dir_in) {
  dest = dev-in;
  pipe = usb_sndintpipe(dev-udev, ep-desc.bEndpointAddress);
  complete_fn = urb_complete_in;
  } else {
  dest = dev-out;
  pipe = usb_rcvintpipe(dev-udev, ep-desc.bEndpointAddress);
  complete_fn = urb_complete_out;
  }
  dest-is_dir_in = is_dir_in;

So you're assigning an OUT pipe value to the in proxy and vice versa.
But the OUT pipe uses the endpoint number of the IN endpoint, and vice
versa.

This might work if the two endpoints have the same number (for example,
if the OUT endpoint's address is 0x02 and the IN endpoint's address is
0x82).  However, it certainly isn't what you should be doing!

I guess we should add a check to the debugging code, to make sure the
pipe's direction matches the endpoint's direction.


Very interesting, since the inverse doesn't work -- well at least on 
the Pi.  That's making me suspect that it wasn't working because I 
simply encountered another bug in the USB host controller driver -- 
that's very, very, very, weird.  I'll re-test this on my workstation.


Ahh well, it works both ways on the pi  my workstation, so I must have 
screwed something else up on those early tests.  Thanks for the help on 
this!!


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


Re: [RFC/PATCH] usb: dwc3: make glue layers selectable

2013-06-26 Thread Sebastian Andrzej Siewior
On 06/26/2013 03:34 PM, Felipe Balbi wrote:
 adding any default to any of those choices gives Kconfig warnings:

Wait but why is it a choice in the first place? Why not making a plain
tristate symbol? You still want to enable all of them at once, don't
you?

Sebastian
--
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] staging: ozwpan: Use normal Makefile, convert oz_trace to oz_dbg

2013-06-26 Thread Joe Perches
On Wed, 2013-06-26 at 06:56 -0700, Joe Perches wrote:
 On Wed, 2013-06-26 at 12:53 +0100, Rupesh Gujare wrote:
  Above macros look good, however Greg have objection to define new macros 
   he had suggested to use dev_dbg()  pr_debug().

These macros already use pr_debug and should
use dev_dbg and netdev_dbg where appropriate
and possible.  These uses also don't depend
on a single saved global struct device *.

The grouping/verbose flags are just as you
use them now, but a lot simpler and allow
an easy conversion to a runtime module_param.


--
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 12/24] USB: oti6858: do not call set_termios with uninitialised data

2013-06-26 Thread Johan Hovold
Make sure set_termios is not called with uninitialised data at open. The
old termios struct is currently not used, but pass NULL instead to avoid
future problems (e.g. stack data leak).

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/oti6858.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index baa2ea5..a2080ac 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -508,7 +508,6 @@ static void oti6858_set_termios(struct tty_struct *tty,
 static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port)
 {
struct oti6858_private *priv = usb_get_serial_port_data(port);
-   struct ktermios tmp_termios;
struct usb_serial *serial = port-serial;
struct oti6858_control_pkt *buf;
unsigned long flags;
@@ -559,7 +558,7 @@ static int oti6858_open(struct tty_struct *tty, struct 
usb_serial_port *port)
 
/* setup termios */
if (tty)
-   oti6858_set_termios(tty, port, tmp_termios);
+   oti6858_set_termios(tty, port, NULL);
 
return 0;
 }
-- 
1.8.2.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 07/24] USB: console: remove unnecessary operations test

2013-06-26 Thread Johan Hovold
Remove unnecessary tests for open and write operations as these are set
to the generic implementations by usb-serial core if left unset by a
subdriver.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/console.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index bfad2cd..c69bb50 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -151,11 +151,7 @@ static int usb_console_setup(struct console *co, char 
*options)
 
/* only call the device specific open if this
 * is the first time the port is opened */
-   if (serial-type-open)
-   retval = serial-type-open(NULL, port);
-   else
-   retval = usb_serial_generic_open(NULL, port);
-
+   retval = serial-type-open(NULL, port);
if (retval) {
dev_err(port-dev, could not open USB console 
port\n);
goto fail;
@@ -230,20 +226,12 @@ static void usb_console_write(struct console *co,
}
/* pass on to the driver specific version of this function if
   it is available */
-   if (serial-type-write)
-   retval = serial-type-write(NULL, port, buf, i);
-   else
-   retval = usb_serial_generic_write(NULL, port, buf, i);
+   retval = serial-type-write(NULL, port, buf, i);
dev_dbg(port-dev, %s - write: %d\n, __func__, retval);
if (lf) {
/* append CR after LF */
unsigned char cr = 13;
-   if (serial-type-write)
-   retval = serial-type-write(NULL,
-   port, cr, 1);
-   else
-   retval = usb_serial_generic_write(NULL,
-   port, cr, 1);
+   retval = serial-type-write(NULL, port, cr, 1);
dev_dbg(port-dev, %s - write cr: %d\n,
__func__, retval);
}
-- 
1.8.2.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 05/24] USB: serial: remove generic vendor/product module parameters

2013-06-26 Thread Johan Hovold
Remove the vendor and product module parameters which were added a long
time ago when we did not have the dynamic sysfs interface to add new
device ids (and which isn't limited to a single new vid/pid pair).

A vid/pid pair can be added dynamically using sysfs, for example:

  echo 1234 5678 /sys/bus/usb-serial/drivers/generic/new_id

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/generic.c | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 1f31e6b..0416575 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -25,17 +25,7 @@
 #include linux/serial.h
 
 #ifdef CONFIG_USB_SERIAL_GENERIC
-
-static __u16 vendor  = 0x05f9;
-static __u16 product = 0x;
-
-module_param(vendor, ushort, 0);
-MODULE_PARM_DESC(vendor, User specified USB idVendor);
-
-module_param(product, ushort, 0);
-MODULE_PARM_DESC(product, User specified USB idProduct);
-
-static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */
+static struct usb_device_id generic_device_ids[1]; /* terminator only */
 
 /* All of the device info needed for the Generic Serial Converter */
 struct usb_serial_driver usb_serial_generic_device = {
@@ -61,11 +51,6 @@ int usb_serial_generic_register(void)
int retval = 0;
 
 #ifdef CONFIG_USB_SERIAL_GENERIC
-   generic_device_ids[0].idVendor = vendor;
-   generic_device_ids[0].idProduct = product;
-   generic_device_ids[0].match_flags =
-   USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT;
-
/* register our generic driver with ourselves */
retval = usb_serial_register_drivers(serial_drivers,
usbserial_generic, generic_device_ids);
-- 
1.8.2.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 08/24] USB: pl2303: refactor baud-rate handling

2013-06-26 Thread Johan Hovold
Break out baud-rate handling from set_termios.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/pl2303.c | 127 
 1 file changed, 69 insertions(+), 58 deletions(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ed9edb2..c15d64d 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -263,68 +263,21 @@ static int pl2303_set_control_lines(struct 
usb_serial_port *port, u8 value)
return retval;
 }
 
-static void pl2303_set_termios(struct tty_struct *tty,
-   struct usb_serial_port *port, struct ktermios *old_termios)
+static void pl2303_encode_baudrate(struct tty_struct *tty,
+   struct usb_serial_port *port,
+   u8 buf[4])
 {
-   struct usb_serial *serial = port-serial;
-   struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
-   struct pl2303_private *priv = usb_get_serial_port_data(port);
-   unsigned long flags;
-   unsigned int cflag;
-   unsigned char *buf;
-   int baud;
-   int i;
-   u8 control;
const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600,
 4800, 7200, 9600, 14400, 19200, 28800, 38400,
 57600, 115200, 230400, 460800, 50, 614400,
 921600, 1228800, 2457600, 300, 600 };
+
+   struct usb_serial *serial = port-serial;
+   struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
+   int baud;
int baud_floor, baud_ceil;
int k;
 
-   /* The PL2303 is reported to lose bytes if you change
-  serial settings even to the same values as before. Thus
-  we actually need to filter in this specific case */
-
-   if (old_termios  !tty_termios_hw_change(tty-termios, old_termios))
-   return;
-
-   cflag = tty-termios.c_cflag;
-
-   buf = kzalloc(7, GFP_KERNEL);
-   if (!buf) {
-   dev_err(port-dev, %s - out of memory.\n, __func__);
-   /* Report back no change occurred */
-   if (old_termios)
-   tty-termios = *old_termios;
-   return;
-   }
-
-   i = usb_control_msg(serial-dev, usb_rcvctrlpipe(serial-dev, 0),
-   GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
-   0, 0, buf, 7, 100);
-   dev_dbg(port-dev, 0xa1:0x21:0:0  %d - %7ph\n, i, buf);
-
-   if (cflag  CSIZE) {
-   switch (cflag  CSIZE) {
-   case CS5:
-   buf[6] = 5;
-   break;
-   case CS6:
-   buf[6] = 6;
-   break;
-   case CS7:
-   buf[6] = 7;
-   break;
-   default:
-   case CS8:
-   buf[6] = 8;
-   break;
-   }
-   dev_dbg(port-dev, data bits = %d\n, buf[6]);
-   }
-
-   /* For reference buf[0]:buf[3] baud rate value */
/* NOTE: Only the values defined in baud_sup are supported !
 *   = if unsupported values are set, the PL2303 seems to use
 *  9600 baud (at least my PL2303X always does)
@@ -378,6 +331,68 @@ static void pl2303_set_termios(struct tty_struct *tty,
}
}
 
+   /* Save resulting baud rate */
+   if (baud)
+   tty_encode_baud_rate(tty, baud, baud);
+}
+
+static void pl2303_set_termios(struct tty_struct *tty,
+   struct usb_serial_port *port, struct ktermios *old_termios)
+{
+   struct usb_serial *serial = port-serial;
+   struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
+   struct pl2303_private *priv = usb_get_serial_port_data(port);
+   unsigned long flags;
+   unsigned int cflag;
+   unsigned char *buf;
+   int i;
+   u8 control;
+
+   /* The PL2303 is reported to lose bytes if you change
+  serial settings even to the same values as before. Thus
+  we actually need to filter in this specific case */
+
+   if (old_termios  !tty_termios_hw_change(tty-termios, old_termios))
+   return;
+
+   cflag = tty-termios.c_cflag;
+
+   buf = kzalloc(7, GFP_KERNEL);
+   if (!buf) {
+   dev_err(port-dev, %s - out of memory.\n, __func__);
+   /* Report back no change occurred */
+   if (old_termios)
+   tty-termios = *old_termios;
+   return;
+   }
+
+   i = usb_control_msg(serial-dev, usb_rcvctrlpipe(serial-dev, 0),
+   GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
+   0, 0, buf, 7, 100);
+   dev_dbg(port-dev, 0xa1:0x21:0:0  %d - %7ph\n, i, buf);
+
+   if (cflag  CSIZE) {
+   

[PATCH 09/24] USB: pl2303: clean up baud-rate handling

2013-06-26 Thread Johan Hovold
Clean up baud-rate handling somewhat.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/pl2303.c | 90 +
 1 file changed, 41 insertions(+), 49 deletions(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index c15d64d..dd59c64 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -29,6 +29,7 @@
 #include linux/uaccess.h
 #include linux/usb.h
 #include linux/usb/serial.h
+#include asm/unaligned.h
 #include pl2303.h
 
 /*
@@ -275,65 +276,56 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
struct usb_serial *serial = port-serial;
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
int baud;
-   int baud_floor, baud_ceil;
-   int k;
+   int i;
 
-   /* NOTE: Only the values defined in baud_sup are supported !
+   /*
+* NOTE: Only the values defined in baud_sup are supported!
 *   = if unsupported values are set, the PL2303 seems to use
 *  9600 baud (at least my PL2303X always does)
 */
baud = tty_get_baud_rate(tty);
dev_dbg(port-dev, baud requested = %d\n, baud);
-   if (baud) {
-   /* Set baudrate to nearest supported value */
-   for (k=0; kARRAY_SIZE(baud_sup); k++) {
-   if (baud_sup[k] / baud) {
-   baud_ceil = baud_sup[k];
-   if (k==0) {
-   baud = baud_ceil;
-   } else {
-   baud_floor = baud_sup[k-1];
-   if ((baud_ceil % baud)
-(baud % baud_floor))
-   baud = baud_floor;
-   else
-   baud = baud_ceil;
-   }
-   break;
-   }
-   }
-   if (baud  1228800) {
-   /* type_0, type_1 only support up to 1228800 baud */
-   if (spriv-type != HX)
-   baud = 1228800;
-   else if (baud  600)
-   baud = 600;
-   }
-   dev_dbg(port-dev, baud set = %d\n, baud);
-   if (baud = 115200) {
-   buf[0] = baud  0xff;
-   buf[1] = (baud  8)  0xff;
-   buf[2] = (baud  16)  0xff;
-   buf[3] = (baud  24)  0xff;
-   } else {
-   /* apparently the formula for higher speeds is:
-* baudrate = 12M * 32 / (2^buf[1]) / buf[0]
-*/
-   unsigned tmp = 12*1000*1000*32 / baud;
-   buf[3] = 0x80;
-   buf[2] = 0;
-   buf[1] = (tmp = 256);
-   while (tmp = 256) {
-   tmp = 2;
-   buf[1] = 1;
-   }
-   buf[0] = tmp;
+   if (!baud)
+   return;
+
+   /* Set baudrate to nearest supported value */
+   for (i = 0; i  ARRAY_SIZE(baud_sup); ++i) {
+   if (baud_sup[i]  baud)
+   break;
+   }
+
+   if (i == ARRAY_SIZE(baud_sup))
+   baud = baud_sup[i - 1];
+   else if (i  0  (baud_sup[i] - baud)  (baud - baud_sup[i - 1]))
+   baud = baud_sup[i - 1];
+   else
+   baud = baud_sup[i];
+
+   /* type_0, type_1 only support up to 1228800 baud */
+   if (spriv-type != HX)
+   baud = max_t(int, baud, 1228800);
+
+   if (baud = 115200) {
+   put_unaligned_le32(baud, buf);
+   } else {
+   /*
+* Apparently the formula for higher speeds is:
+* baudrate = 12M * 32 / (2^buf[1]) / buf[0]
+*/
+   unsigned tmp = 1200 * 32 / baud;
+   buf[3] = 0x80;
+   buf[2] = 0;
+   buf[1] = (tmp = 256);
+   while (tmp = 256) {
+   tmp = 2;
+   buf[1] = 1;
}
+   buf[0] = tmp;
}
 
/* Save resulting baud rate */
-   if (baud)
-   tty_encode_baud_rate(tty, baud, baud);
+   tty_encode_baud_rate(tty, baud, baud);
+   dev_dbg(port-dev, baud set = %d\n, baud);
 }
 
 static void pl2303_set_termios(struct tty_struct *tty,
-- 
1.8.2.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 06/24] USB: console: use dev_dbg

2013-06-26 Thread Johan Hovold
Use dev_dbg for debugging.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/console.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index afb50ea..bfad2cd 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -210,10 +210,10 @@ static void usb_console_write(struct console *co,
if (count == 0)
return;
 
-   pr_debug(%s - minor %d, %d byte(s)\n, __func__, port-minor, count);
+   dev_dbg(port-dev, %s - %d byte(s)\n, __func__, count);
 
if (!port-port.console) {
-   pr_debug(%s - port not opened\n, __func__);
+   dev_dbg(port-dev, %s - port not opened\n, __func__);
return;
}
 
@@ -234,7 +234,7 @@ static void usb_console_write(struct console *co,
retval = serial-type-write(NULL, port, buf, i);
else
retval = usb_serial_generic_write(NULL, port, buf, i);
-   pr_debug(%s - return value : %d\n, __func__, retval);
+   dev_dbg(port-dev, %s - write: %d\n, __func__, retval);
if (lf) {
/* append CR after LF */
unsigned char cr = 13;
@@ -244,7 +244,8 @@ static void usb_console_write(struct console *co,
else
retval = usb_serial_generic_write(NULL,
port, cr, 1);
-   pr_debug(%s - return value : %d\n, __func__, retval);
+   dev_dbg(port-dev, %s - write cr: %d\n,
+   __func__, retval);
}
buf += i;
count -= i;
-- 
1.8.2.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 01/24] USB: serial: remove defensive test from set_termios

2013-06-26 Thread Johan Hovold
Remove defensive test from set_termios which is never called with a NULL
tty.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/cp210x.c  | 3 ---
 drivers/usb/serial/oti6858.c | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index d6ef2f8..5627058 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -666,9 +666,6 @@ static void cp210x_set_termios(struct tty_struct *tty,
unsigned int bits;
unsigned int modem_ctl[4];
 
-   if (!tty)
-   return;
-
cflag = tty-termios.c_cflag;
old_cflag = old_termios-c_cflag;
 
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 7e3e078..cf509c8 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -411,9 +411,6 @@ static void oti6858_set_termios(struct tty_struct *tty,
__le16 divisor;
int br;
 
-   if (!tty)
-   return;
-
cflag = tty-termios.c_cflag;
 
spin_lock_irqsave(priv-lock, flags);
-- 
1.8.2.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 04/24] USB: serial: set drain delay at port probe

2013-06-26 Thread Johan Hovold
The port drain delay is constant and should be set at port probe rather
than open.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/cypress_m8.c   | 4 +++-
 drivers/usb/serial/f81232.c   | 3 ++-
 drivers/usb/serial/io_ti.c| 3 +--
 drivers/usb/serial/oti6858.c  | 4 +++-
 drivers/usb/serial/pl2303.c   | 3 ++-
 drivers/usb/serial/spcp8x5.c  | 4 ++--
 drivers/usb/serial/ti_usb_3410_5052.c | 4 ++--
 7 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index e948dc0..558605d 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -495,6 +495,8 @@ static int cypress_generic_port_probe(struct 
usb_serial_port *port)
}
usb_set_serial_port_data(port, priv);
 
+   port-port.drain_delay = 256;
+
return 0;
 }
 
@@ -625,7 +627,7 @@ static int cypress_open(struct tty_struct *tty, struct 
usb_serial_port *port)
__func__, result);
cypress_set_dead(port);
}
-   port-port.drain_delay = 256;
+
return result;
 } /* cypress_open */
 
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 75e85cb..639a18f 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -207,7 +207,6 @@ static int f81232_open(struct tty_struct *tty, struct 
usb_serial_port *port)
return result;
}
 
-   port-port.drain_delay = 256;
return 0;
 }
 
@@ -322,6 +321,8 @@ static int f81232_port_probe(struct usb_serial_port *port)
 
usb_set_serial_port_data(port, priv);
 
+   port-port.drain_delay = 256;
+
return 0;
 }
 
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 60054e7..d43adc0 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1872,8 +1872,6 @@ static int edge_open(struct tty_struct *tty, struct 
usb_serial_port *port)
 
++edge_serial-num_ports_open;
 
-   port-port.drain_delay = 1;
-
goto release_es_lock;
 
 unlink_int_urb:
@@ -2473,6 +2471,7 @@ static int edge_port_probe(struct usb_serial_port *port)
}
 
port-port.closing_wait = msecs_to_jiffies(closing_wait * 10);
+   port-port.drain_delay = 1;
 
return 0;
 }
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index cf509c8..baa2ea5 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -343,6 +343,8 @@ static int oti6858_port_probe(struct usb_serial_port *port)
 
usb_set_serial_port_data(port, priv);
 
+   port-port.drain_delay = 256;   /* FIXME: check the FIFO length */
+
return 0;
 }
 
@@ -558,7 +560,7 @@ static int oti6858_open(struct tty_struct *tty, struct 
usb_serial_port *port)
/* setup termios */
if (tty)
oti6858_set_termios(tty, port, tmp_termios);
-   port-port.drain_delay = 256;   /* FIXME: check the FIFO length */
+
return 0;
 }
 
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index cb6bbed..ed9edb2 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -235,6 +235,8 @@ static int pl2303_port_probe(struct usb_serial_port *port)
 
usb_set_serial_port_data(port, priv);
 
+   port-port.drain_delay = 256;
+
return 0;
 }
 
@@ -521,7 +523,6 @@ static int pl2303_open(struct tty_struct *tty, struct 
usb_serial_port *port)
return result;
}
 
-   port-port.drain_delay = 256;
return 0;
 }
 
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index ddf6c47..4abac28 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -169,6 +169,8 @@ static int spcp8x5_port_probe(struct usb_serial_port *port)
 
usb_set_serial_port_data(port, priv);
 
+   port-port.drain_delay = 256;
+
return 0;
 }
 
@@ -411,8 +413,6 @@ static int spcp8x5_open(struct tty_struct *tty, struct 
usb_serial_port *port)
if (tty)
spcp8x5_set_termios(tty, port, NULL);
 
-   port-port.drain_delay = 256;
-
return usb_serial_generic_open(tty, port);
 }
 
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c 
b/drivers/usb/serial/ti_usb_3410_5052.c
index 7182bb7..18db7b3 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -441,6 +441,8 @@ static int ti_port_probe(struct usb_serial_port *port)
 
usb_set_serial_port_data(port, tport);
 
+   port-port.drain_delay = 3;
+
return 0;
 }
 
@@ -582,8 +584,6 @@ static int ti_open(struct tty_struct *tty, struct 
usb_serial_port *port)
tport-tp_is_open = 1;
++tdev-td_open_port_count;
 
-   port-port.drain_delay = 3;
-
goto release_lock;
 
 unlink_int_urb:
-- 
1.8.2.1

--
To unsubscribe from this list: send the line 

[PATCH 24/24] USB: ti_usb_3410_5052: remove vendor/product module parameters

2013-06-26 Thread Johan Hovold
Remove the vendor and product module parameters which were added a long
time ago when we did not have the dynamic sysfs interface to add
new device ids (and which isn't limited to five new vid/pid pair).

A vid/pid pair can be added dynamically using sysfs, for example:

  echo 0451 1234 /sys/bus/usb-serial/drivers/ti_usb_3410_5052_1/new_id

for 1-port adapters, or

  echo 0451 1234 /sys/bus/usb-serial/drivers/ti_usb_3410_5052_2/new_id

for 2-port adapters.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/ti_usb_3410_5052.c | 72 ---
 1 file changed, 7 insertions(+), 65 deletions(-)

diff --git a/drivers/usb/serial/ti_usb_3410_5052.c 
b/drivers/usb/serial/ti_usb_3410_5052.c
index f3e21f5..5585b20 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -141,20 +141,9 @@ static int ti_download_firmware(struct ti_device *tdev);
 
 /* module parameters */
 static int closing_wait = TI_DEFAULT_CLOSING_WAIT;
-static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT];
-static unsigned int vendor_3410_count;
-static ushort product_3410[TI_EXTRA_VID_PID_COUNT];
-static unsigned int product_3410_count;
-static ushort vendor_5052[TI_EXTRA_VID_PID_COUNT];
-static unsigned int vendor_5052_count;
-static ushort product_5052[TI_EXTRA_VID_PID_COUNT];
-static unsigned int product_5052_count;
 
 /* supported devices */
-/* the array dimension is the number of default entries plus */
-/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
-/* null entry */
-static struct usb_device_id ti_id_table_3410[15+TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_3410[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
{ USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -171,16 +160,18 @@ static struct usb_device_id 
ti_id_table_3410[15+TI_EXTRA_VID_PID_COUNT+1] = {
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STEREO_PLUG_ID) },
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
+   { } /* terminator */
 };
 
-static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_5052[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
+   { } /* terminator */
 };
 
-static struct usb_device_id 
ti_id_table_combined[19+2*TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_combined[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
{ USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -200,7 +191,7 @@ static struct usb_device_id 
ti_id_table_combined[19+2*TI_EXTRA_VID_PID_COUNT+1]
{ USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
-   { }
+   { } /* terminator */
 };
 
 static struct usb_serial_driver ti_1port_device = {
@@ -289,61 +280,12 @@ module_param(closing_wait, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(closing_wait,
 Maximum wait for data to drain in close, in .01 secs, default is 4000);
 
-module_param_array(vendor_3410, ushort, vendor_3410_count, S_IRUGO);
-MODULE_PARM_DESC(vendor_3410,
-   Vendor ids for 3410 based devices, 1-5 short integers);
-module_param_array(product_3410, ushort, product_3410_count, S_IRUGO);
-MODULE_PARM_DESC(product_3410,
-   Product ids for 3410 based devices, 1-5 short integers);
-module_param_array(vendor_5052, ushort, vendor_5052_count, S_IRUGO);
-MODULE_PARM_DESC(vendor_5052,
-   Vendor ids for 5052 based devices, 1-5 short integers);
-module_param_array(product_5052, ushort, product_5052_count, S_IRUGO);
-MODULE_PARM_DESC(product_5052,
-   Product ids for 5052 based devices, 1-5 short integers);
-
 MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
 
+module_usb_serial_driver(serial_drivers, ti_id_table_combined);
 
 /* Functions */
 
-static int __init ti_init(void)
-{
-   int i, j, c;
-
-   /* insert extra vendor and product ids */
-   c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1;
-   j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
-   for (i = 0; i  min(vendor_3410_count, product_3410_count); i++, j++, 
c++) {
-   ti_id_table_3410[j].idVendor = vendor_3410[i];
-   ti_id_table_3410[j].idProduct = product_3410[i];
-   ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
-   ti_id_table_combined[c].idVendor = vendor_3410[i];
-   

[PATCH 20/24] USB: mos7840: remove broken chase implementation

2013-06-26 Thread Johan Hovold
Remove broken chase implementation which was supposed to be used to
drain the write buffers at break.

The chase implementation slept on a wait queue which was never woken up
(i.e. no hardware buffers were queried), and thus amounted to nothing
more than polling chars_in_buffer, something which has already been
taken care of by the tty layer.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/mos7840.c | 48 
 1 file changed, 48 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 0a818b2..dff27e6 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -218,7 +218,6 @@ struct moschip_port {
__u8 shadowMCR; /* last MCR value received */
char open;
char open_ports;
-   wait_queue_head_t wait_chase;   /* for handling sleeping while waiting 
for chase to finish */
struct usb_serial_port *port;   /* loop back to the owner of this 
object */
 
/* Offsets */
@@ -1092,9 +1091,6 @@ static int mos7840_open(struct tty_struct *tty, struct 
usb_serial_port *port)
mos7840_port-read_urb_busy = false;
}
 
-   /* initialize our wait queues */
-   init_waitqueue_head(mos7840_port-wait_chase);
-
/* initialize our port settings */
/* Must set to enable ints! */
mos7840_port-shadowMCR = MCR_MASTER_IE;
@@ -1211,47 +1207,6 @@ static void mos7840_close(struct usb_serial_port *port)
mos7840_port-open = 0;
 }
 
-/
- *
- * mos7840_block_until_chase_response
- *
- * This function will block the close until one of the following:
- * 1. Response to our Chase comes from mos7840
- * 2. A timeout of 10 seconds without activity has expired
- *(1K of mos7840 data @ 2400 baud == 4 sec to empty)
- *
- /
-
-static void mos7840_block_until_chase_response(struct tty_struct *tty,
-   struct moschip_port *mos7840_port)
-{
-   int timeout = msecs_to_jiffies(1000);
-   int wait = 10;
-   int count;
-
-   while (1) {
-   count = mos7840_chars_in_buffer(tty);
-
-   /* Check for Buffer status */
-   if (count = 0)
-   return;
-
-   /* Block the thread for a while */
-   interruptible_sleep_on_timeout(mos7840_port-wait_chase,
-  timeout);
-   /* No activity.. count down section */
-   wait--;
-   if (wait == 0) {
-   dev_dbg(mos7840_port-port-dev, %s - TIMEOUT\n, 
__func__);
-   return;
-   } else {
-   /* Reset timeout value back to seconds */
-   wait = 10;
-   }
-   }
-
-}
-
 /*
  * mos7840_break
  * this function sends a break to the port
@@ -1275,9 +1230,6 @@ static void mos7840_break(struct tty_struct *tty, int 
break_state)
if (mos7840_port == NULL)
return;
 
-   /* flush and block until tx is empty */
-   mos7840_block_until_chase_response(tty, mos7840_port);
-
if (break_state == -1)
data = mos7840_port-shadowLCR | LCR_SET_BREAK;
else
-- 
1.8.2.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 00/24] USB: serial: patches for v3.12

2013-06-26 Thread Johan Hovold
Here's a first round of patches for v3.12 (which I did not get ready in
time for 3.11...).

Note that I'm dropping the vendor/product parameters from all usb-serial
modules which had them (generic, ftdi_sio, safe_serial and
ti_usb_3410_5052) in favour of the more flexible sysfs interface.

Thanks,
Johan


Johan Hovold (24):
  USB: serial: remove defensive test from set_termios
  USB: serial: remove hupping check from tiocmiwait
  USB: serial: clean up dtr_rts
  USB: serial: set drain delay at port probe
  USB: serial: remove generic vendor/product module parameters
  USB: console: use dev_dbg
  USB: console: remove unnecessary operations test
  USB: pl2303: refactor baud-rate handling
  USB: pl2303: clean up baud-rate handling
  USB: pl2303: clean up set_termios
  USB: pl2303: remove debugging noise
  USB: oti6858: do not call set_termios with uninitialised data
  USB: ftdi_sio: clean up device initialisation
  USB: ftdi_sio: remove redundant raise of DTR/RTS at open
  USB: ftdi_sio: remove vendor/product module parameters
  USB: ftdi_sio: remove unused defines
  USB: io_edgeport: remove unused defines
  USB: io_ti: kill private fifo
  USB: io_ti: move port initialisation to probe
  USB: mos7840: remove broken chase implementation
  USB: safe_serial: remove vendor/product module parameters
  USB: ti_usb_3410_5052: kill private fifo
  USB: ti_usb_3410_5052: remove unused wait queue
  USB: ti_usb_3410_5052: remove vendor/product module parameters

 drivers/usb/serial/console.c  |  27 ++
 drivers/usb/serial/cp210x.c   |   3 -
 drivers/usb/serial/cypress_m8.c   |   4 +-
 drivers/usb/serial/f81232.c   |   3 +-
 drivers/usb/serial/ftdi_sio.c |  52 ++
 drivers/usb/serial/generic.c  |  30 +-
 drivers/usb/serial/io_edgeport.c  |   2 -
 drivers/usb/serial/io_ti.c|  71 +++---
 drivers/usb/serial/mos7840.c  |  48 --
 drivers/usb/serial/oti6858.c  |  10 +-
 drivers/usb/serial/pl2303.c   | 175 +-
 drivers/usb/serial/safe_serial.c  |  51 +++---
 drivers/usb/serial/spcp8x5.c  |   4 +-
 drivers/usb/serial/ti_usb_3410_5052.c | 103 +++-
 drivers/usb/serial/usb-serial.c   |  14 +--
 15 files changed, 180 insertions(+), 417 deletions(-)

-- 
1.8.2.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 13/24] USB: ftdi_sio: clean up device initialisation

2013-06-26 Thread Johan Hovold
Do not use zeroed termios data to determine when to unconditionally
configure the device at open.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/ftdi_sio.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 7260ec6..abcaeaf 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1842,7 +1842,6 @@ static int ftdi_sio_port_remove(struct usb_serial_port 
*port)
 
 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
 {
-   struct ktermios dummy;
struct usb_device *dev = port-serial-dev;
struct ftdi_private *priv = usb_get_serial_port_data(port);
 
@@ -1858,10 +1857,8 @@ static int ftdi_open(struct tty_struct *tty, struct 
usb_serial_port *port)
   This is same behaviour as serial.c/rs_open() - Kuba */
 
/* ftdi_set_termios  will send usb control messages */
-   if (tty) {
-   memset(dummy, 0, sizeof(dummy));
-   ftdi_set_termios(tty, port, dummy);
-   }
+   if (tty)
+   ftdi_set_termios(tty, port, NULL);
 
return usb_serial_generic_open(tty, port);
 }
-- 
1.8.2.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 02/24] USB: serial: remove hupping check from tiocmiwait

2013-06-26 Thread Johan Hovold
Since commit 31ca020b (TTY: wake up processes last at hangup) there no
longer any need to check the hupping flag in the generic tiocmiwait
implementation, so remove it.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/generic.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index ba45170..1f31e6b 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -460,12 +460,7 @@ static bool usb_serial_generic_msr_changed(struct 
tty_struct *tty,
/*
 * Use tty-port initialised flag to detect all hangups including the
 * one generated at USB-device disconnect.
-*
-* FIXME: Remove hupping check once tty_port_hangup calls shutdown
-*(which clears the initialised flag) before wake up.
 */
-   if (test_bit(TTY_HUPPING, tty-flags))
-   return true;
if (!test_bit(ASYNCB_INITIALIZED, port-port.flags))
return true;
 
@@ -496,12 +491,8 @@ int usb_serial_generic_tiocmiwait(struct tty_struct *tty, 
unsigned long arg)
 
ret = wait_event_interruptible(port-port.delta_msr_wait,
usb_serial_generic_msr_changed(tty, arg, cnow));
-   if (!ret) {
-   if (test_bit(TTY_HUPPING, tty-flags))
-   ret = -EIO;
-   if (!test_bit(ASYNCB_INITIALIZED, port-port.flags))
-   ret = -EIO;
-   }
+   if (!ret  !test_bit(ASYNCB_INITIALIZED, port-port.flags))
+   ret = -EIO;
 
return ret;
 }
-- 
1.8.2.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 23/24] USB: ti_usb_3410_5052: remove unused wait queue

2013-06-26 Thread Johan Hovold
The write wait queue is never added to since commit f1175daa5 (USB:
ti_usb_3410_5052: kill custom closing_wait). Remove it completely.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/ti_usb_3410_5052.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/usb/serial/ti_usb_3410_5052.c 
b/drivers/usb/serial/ti_usb_3410_5052.c
index d2c6196..f3e21f5 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -69,7 +69,6 @@ struct ti_port {
__u8tp_uart_mode;   /* 232 or 485 modes */
unsigned inttp_uart_base_addr;
int tp_flags;
-   wait_queue_head_t   tp_write_wait;
struct ti_device*tp_tdev;
struct usb_serial_port  *tp_port;
spinlock_t  tp_lock;
@@ -427,7 +426,6 @@ static int ti_port_probe(struct usb_serial_port *port)
else
tport-tp_uart_base_addr = TI_UART2_BASE_ADDR;
port-port.closing_wait = msecs_to_jiffies(10 * closing_wait);
-   init_waitqueue_head(tport-tp_write_wait);
tport-tp_port = port;
tport-tp_tdev = usb_get_serial_data(port-serial);
tport-tp_uart_mode = 0;/* default is RS232 */
@@ -1082,13 +1080,11 @@ static void ti_bulk_in_callback(struct urb *urb)
case -ESHUTDOWN:
dev_dbg(dev, %s - urb shutting down, %d\n, __func__, status);
tport-tp_tdev-td_urb_error = 1;
-   wake_up_interruptible(tport-tp_write_wait);
return;
default:
dev_err(dev, %s - nonzero urb status, %d\n,
__func__, status);
tport-tp_tdev-td_urb_error = 1;
-   wake_up_interruptible(tport-tp_write_wait);
}
 
if (status == -EPIPE)
@@ -1144,13 +1140,11 @@ static void ti_bulk_out_callback(struct urb *urb)
case -ESHUTDOWN:
dev_dbg(port-dev, %s - urb shutting down, %d\n, __func__, 
status);
tport-tp_tdev-td_urb_error = 1;
-   wake_up_interruptible(tport-tp_write_wait);
return;
default:
dev_err_console(port, %s - nonzero urb status, %d\n,
__func__, status);
tport-tp_tdev-td_urb_error = 1;
-   wake_up_interruptible(tport-tp_write_wait);
}
 
/* send any buffered data */
@@ -1224,7 +1218,6 @@ static void ti_send(struct ti_port *tport)
/* more room in the buffer for new writes, wakeup */
tty_port_tty_wakeup(port-port);
 
-   wake_up_interruptible(tport-tp_write_wait);
return;
 unlock:
spin_unlock_irqrestore(tport-tp_lock, flags);
-- 
1.8.2.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 03/24] USB: serial: clean up dtr_rts

2013-06-26 Thread Johan Hovold
Since commit 957dacae (TTY: fix DTR not being dropped on hang up)
dtr_rts is no longer called for uninitialised ports (e.g. after
a disconnect), which removes the need to grab the disconnect mutex.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/usb-serial.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index cb27fcb..6091bd5 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -681,20 +681,10 @@ static int serial_port_carrier_raised(struct tty_port 
*port)
 static void serial_port_dtr_rts(struct tty_port *port, int on)
 {
struct usb_serial_port *p = container_of(port, struct usb_serial_port, 
port);
-   struct usb_serial *serial = p-serial;
-   struct usb_serial_driver *drv = serial-type;
+   struct usb_serial_driver *drv = p-serial-type;
 
-   if (!drv-dtr_rts)
-   return;
-   /*
-* Work-around bug in the tty-layer which can result in dtr_rts
-* being called after a disconnect (and tty_unregister_device
-* has returned). Remove once bug has been squashed.
-*/
-   mutex_lock(serial-disc_mutex);
-   if (!serial-disconnected)
+   if (drv-dtr_rts)
drv-dtr_rts(p, on);
-   mutex_unlock(serial-disc_mutex);
 }
 
 static const struct tty_port_operations serial_port_ops = {
-- 
1.8.2.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 19/24] USB: io_ti: move port initialisation to probe

2013-06-26 Thread Johan Hovold
Move port initialisation code from open to probe where it belongs.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/io_ti.c | 46 ++
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index f48e90a..9c18f59 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1729,22 +1729,6 @@ static int edge_open(struct tty_struct *tty, struct 
usb_serial_port *port)
return -ENODEV;
 
port_number = port-port_number;
-   switch (port_number) {
-   case 0:
-   edge_port-uart_base = UMPMEM_BASE_UART1;
-   edge_port-dma_address = UMPD_OEDB1_ADDRESS;
-   break;
-   case 1:
-   edge_port-uart_base = UMPMEM_BASE_UART2;
-   edge_port-dma_address = UMPD_OEDB2_ADDRESS;
-   break;
-   default:
-   dev_err(port-dev, Unknown port number!!!\n);
-   return -ENODEV;
-   }
-
-   dev_dbg(port-dev, %s - port_number = %d, uart_base = %04x, 
dma_address = %04x\n,
-   __func__, port_number, edge_port-uart_base, 
edge_port-dma_address);
 
dev = port-serial-dev;
 
@@ -2451,18 +2435,40 @@ static int edge_port_probe(struct usb_serial_port *port)
edge_port-edge_serial = usb_get_serial_data(port-serial);
edge_port-bUartMode = default_uart_mode;
 
+   switch (port-port_number) {
+   case 0:
+   edge_port-uart_base = UMPMEM_BASE_UART1;
+   edge_port-dma_address = UMPD_OEDB1_ADDRESS;
+   break;
+   case 1:
+   edge_port-uart_base = UMPMEM_BASE_UART2;
+   edge_port-dma_address = UMPD_OEDB2_ADDRESS;
+   break;
+   default:
+   dev_err(port-dev, unknown port number\n);
+   ret = -ENODEV;
+   goto err;
+   }
+
+   dev_dbg(port-dev,
+   %s - port_number = %d, uart_base = %04x, dma_address = %04x\n,
+   __func__, port-port_number, edge_port-uart_base,
+   edge_port-dma_address);
+
usb_set_serial_port_data(port, edge_port);
 
ret = edge_create_sysfs_attrs(port);
-   if (ret) {
-   kfree(edge_port);
-   return ret;
-   }
+   if (ret)
+   goto err;
 
port-port.closing_wait = msecs_to_jiffies(closing_wait * 10);
port-port.drain_delay = 1;
 
return 0;
+err:
+   kfree(edge_port);
+
+   return ret;
 }
 
 static int edge_port_remove(struct usb_serial_port *port)
-- 
1.8.2.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 10/24] USB: pl2303: clean up set_termios

2013-06-26 Thread Johan Hovold
Clean up set_termios somewhat.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/pl2303.c | 39 ++-
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index dd59c64..91f14c6 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -335,20 +335,18 @@ static void pl2303_set_termios(struct tty_struct *tty,
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
-   unsigned int cflag;
unsigned char *buf;
int i;
u8 control;
 
-   /* The PL2303 is reported to lose bytes if you change
-  serial settings even to the same values as before. Thus
-  we actually need to filter in this specific case */
-
+   /*
+* The PL2303 is reported to lose bytes if you change serial settings
+* even to the same values as before. Thus we actually need to filter
+* in this specific case.
+*/
if (old_termios  !tty_termios_hw_change(tty-termios, old_termios))
return;
 
-   cflag = tty-termios.c_cflag;
-
buf = kzalloc(7, GFP_KERNEL);
if (!buf) {
dev_err(port-dev, %s - out of memory.\n, __func__);
@@ -363,8 +361,8 @@ static void pl2303_set_termios(struct tty_struct *tty,
0, 0, buf, 7, 100);
dev_dbg(port-dev, 0xa1:0x21:0:0  %d - %7ph\n, i, buf);
 
-   if (cflag  CSIZE) {
-   switch (cflag  CSIZE) {
+   if (C_CSIZE(tty)) {
+   switch (C_CSIZE(tty)) {
case CS5:
buf[6] = 5;
break;
@@ -377,7 +375,6 @@ static void pl2303_set_termios(struct tty_struct *tty,
default:
case CS8:
buf[6] = 8;
-   break;
}
dev_dbg(port-dev, data bits = %d\n, buf[6]);
}
@@ -388,11 +385,12 @@ static void pl2303_set_termios(struct tty_struct *tty,
/* For reference buf[4]=0 is 1 stop bits */
/* For reference buf[4]=1 is 1.5 stop bits */
/* For reference buf[4]=2 is 2 stop bits */
-   if (cflag  CSTOPB) {
-   /* NOTE: Comply with real UARTs / RS232:
+   if (C_CSTOPB(tty)) {
+   /*
+* NOTE: Comply with real UARTs / RS232:
 *   use 1.5 instead of 2 stop bits with 5 data bits
 */
-   if ((cflag  CSIZE) == CS5) {
+   if (C_CSIZE(tty) == CS5) {
buf[4] = 1;
dev_dbg(port-dev, stop bits = 1.5\n);
} else {
@@ -404,14 +402,14 @@ static void pl2303_set_termios(struct tty_struct *tty,
dev_dbg(port-dev, stop bits = 1\n);
}
 
-   if (cflag  PARENB) {
+   if (C_PARENB(tty)) {
/* For reference buf[5]=0 is none parity */
/* For reference buf[5]=1 is odd parity */
/* For reference buf[5]=2 is even parity */
/* For reference buf[5]=3 is mark parity */
/* For reference buf[5]=4 is space parity */
-   if (cflag  PARODD) {
-   if (cflag  CMSPAR) {
+   if (C_PARODD(tty)) {
+   if (tty-termios.c_cflag  CMSPAR) {
buf[5] = 3;
dev_dbg(port-dev, parity = mark\n);
} else {
@@ -419,7 +417,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
dev_dbg(port-dev, parity = odd\n);
}
} else {
-   if (cflag  CMSPAR) {
+   if (tty-termios.c_cflag  CMSPAR) {
buf[5] = 4;
dev_dbg(port-dev, parity = space\n);
} else {
@@ -440,7 +438,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
/* change control lines if we are switching to or from B0 */
spin_lock_irqsave(priv-lock, flags);
control = priv-line_control;
-   if ((cflag  CBAUD) == B0)
+   if (C_BAUD(tty) == B0)
priv-line_control = ~(CONTROL_DTR | CONTROL_RTS);
else if (old_termios  (old_termios-c_cflag  CBAUD) == B0)
priv-line_control |= (CONTROL_DTR | CONTROL_RTS);
@@ -452,14 +450,13 @@ static void pl2303_set_termios(struct tty_struct *tty,
spin_unlock_irqrestore(priv-lock, flags);
}
 
-   buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0;
-
+   memset(buf, 0, 7);
i = usb_control_msg(serial-dev, usb_rcvctrlpipe(serial-dev, 0),
GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
0, 

[PATCH 18/24] USB: io_ti: kill private fifo

2013-06-26 Thread Johan Hovold
Kill private write fifo and use the already allocated port write fifo
instead.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/io_ti.c | 22 +-
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index d43adc0..f48e90a 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -64,8 +64,6 @@
 
 #define EDGE_CLOSING_WAIT  4000/* in .01 sec */
 
-#define EDGE_OUT_BUF_SIZE  1024
-
 
 /* Product information read from the Edgeport */
 struct product_info {
@@ -93,7 +91,6 @@ struct edgeport_port {
spinlock_t ep_lock;
int ep_read_urb_state;
int ep_write_urb_in_use;
-   struct kfifo write_fifo;
 };
 
 struct edgeport_serial {
@@ -1903,7 +1900,7 @@ static void edge_close(struct usb_serial_port *port)
usb_kill_urb(port-write_urb);
edge_port-ep_write_urb_in_use = 0;
spin_lock_irqsave(edge_port-ep_lock, flags);
-   kfifo_reset_out(edge_port-write_fifo);
+   kfifo_reset_out(port-write_fifo);
spin_unlock_irqrestore(edge_port-ep_lock, flags);
 
dev_dbg(port-dev, %s - send umpc_close_port\n, __func__);
@@ -1937,7 +1934,7 @@ static int edge_write(struct tty_struct *tty, struct 
usb_serial_port *port,
if (edge_port-close_pending == 1)
return -ENODEV;
 
-   count = kfifo_in_locked(edge_port-write_fifo, data, count,
+   count = kfifo_in_locked(port-write_fifo, data, count,
edge_port-ep_lock);
edge_send(port, tty);
 
@@ -1957,7 +1954,7 @@ static void edge_send(struct usb_serial_port *port, 
struct tty_struct *tty)
return;
}
 
-   count = kfifo_out(edge_port-write_fifo,
+   count = kfifo_out(port-write_fifo,
port-write_urb-transfer_buffer,
port-bulk_out_size);
 
@@ -2005,7 +2002,7 @@ static int edge_write_room(struct tty_struct *tty)
return 0;
 
spin_lock_irqsave(edge_port-ep_lock, flags);
-   room = kfifo_avail(edge_port-write_fifo);
+   room = kfifo_avail(port-write_fifo);
spin_unlock_irqrestore(edge_port-ep_lock, flags);
 
dev_dbg(port-dev, %s - returns %d\n, __func__, room);
@@ -2022,7 +2019,7 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
return 0;
 
spin_lock_irqsave(edge_port-ep_lock, flags);
-   chars = kfifo_len(edge_port-write_fifo);
+   chars = kfifo_len(port-write_fifo);
spin_unlock_irqrestore(edge_port-ep_lock, flags);
 
dev_dbg(port-dev, %s - returns %d\n, __func__, chars);
@@ -2449,13 +2446,6 @@ static int edge_port_probe(struct usb_serial_port *port)
if (!edge_port)
return -ENOMEM;
 
-   ret = kfifo_alloc(edge_port-write_fifo, EDGE_OUT_BUF_SIZE,
-   GFP_KERNEL);
-   if (ret) {
-   kfree(edge_port);
-   return -ENOMEM;
-   }
-
spin_lock_init(edge_port-ep_lock);
edge_port-port = port;
edge_port-edge_serial = usb_get_serial_data(port-serial);
@@ -2465,7 +2455,6 @@ static int edge_port_probe(struct usb_serial_port *port)
 
ret = edge_create_sysfs_attrs(port);
if (ret) {
-   kfifo_free(edge_port-write_fifo);
kfree(edge_port);
return ret;
}
@@ -2482,7 +2471,6 @@ static int edge_port_remove(struct usb_serial_port *port)
 
edge_port = usb_get_serial_port_data(port);
edge_remove_sysfs_attrs(port);
-   kfifo_free(edge_port-write_fifo);
kfree(edge_port);
 
return 0;
-- 
1.8.2.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 15/24] USB: ftdi_sio: remove vendor/product module parameters

2013-06-26 Thread Johan Hovold
Remove the vendor and product module parameters which were added a long
time ago when we did not have the dynamic sysfs interface to add
new device ids (and which isn't limited to a single new vid/pid pair).

A vid/pid pair can be added dynamically using sysfs, for example:

echo 0403 1234 /sys/bus/usb-serial/drivers/ftdi_sio/new_id

Also fix up the in-code comment that got the sysfs path wrong.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/ftdi_sio.c | 36 +++-
 1 file changed, 3 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 86f6dfe..9bd1f6f 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -51,8 +51,6 @@
 #define DRIVER_AUTHOR Greg Kroah-Hartman g...@kroah.com, Bill Ryder 
bry...@sgi.com, Kuba Ober k...@mareimbrium.org, Andreas Mohr, Johan Hovold 
jhov...@gmail.com
 #define DRIVER_DESC USB FTDI Serial Converters Driver
 
-static __u16 vendor = FTDI_VID;
-static __u16 product;
 
 struct ftdi_private {
enum ftdi_chip_type chip_type;
@@ -144,8 +142,8 @@ static struct ftdi_sio_quirk ftdi_8u2232c_quirk = {
 
 
 /*
- * Device ID not listed? Test via module params product/vendor or
- * /sys/bus/usb/ftdi_sio/new_id, then send patch/report!
+ * Device ID not listed? Test it using
+ * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report.
  */
 static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) },
@@ -881,7 +879,6 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) },
/* Crucible Devices */
{ USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) },
-   { },/* Optional parameter entry */
{ } /* Terminating entry */
 };
 
@@ -2377,38 +2374,11 @@ static int ftdi_ioctl(struct tty_struct *tty,
return -ENOIOCTLCMD;
 }
 
-static int __init ftdi_init(void)
-{
-   if (vendor  0  product  0) {
-   /* Add user specified VID/PID to reserved element of table. */
-   int i;
-   for (i = 0; id_table_combined[i].idVendor; i++)
-   ;
-   id_table_combined[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
-   id_table_combined[i].idVendor = vendor;
-   id_table_combined[i].idProduct = product;
-   }
-   return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, 
id_table_combined);
-}
-
-static void __exit ftdi_exit(void)
-{
-   usb_serial_deregister_drivers(serial_drivers);
-}
-
-
-module_init(ftdi_init);
-module_exit(ftdi_exit);
+module_usb_serial_driver(serial_drivers, id_table_combined);
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE(GPL);
 
-module_param(vendor, ushort, 0);
-MODULE_PARM_DESC(vendor, User specified vendor ID (default=
-   __MODULE_STRING(FTDI_VID)));
-module_param(product, ushort, 0);
-MODULE_PARM_DESC(product, User specified product ID);
-
 module_param(ndi_latency_timer, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(ndi_latency_timer, NDI device latency timer override);
-- 
1.8.2.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 22/24] USB: ti_usb_3410_5052: kill private fifo

2013-06-26 Thread Johan Hovold
Kill private write fifo and use the already allocated port write fifo
instead.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/ti_usb_3410_5052.c | 20 ++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/serial/ti_usb_3410_5052.c 
b/drivers/usb/serial/ti_usb_3410_5052.c
index 18db7b3..d2c6196 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -45,8 +45,6 @@
 
 #define TI_FIRMWARE_BUF_SIZE   16284
 
-#define TI_WRITE_BUF_SIZE  1024
-
 #define TI_TRANSFER_TIMEOUT2
 
 #define TI_DEFAULT_CLOSING_WAIT4000/* in .01 secs */
@@ -77,7 +75,6 @@ struct ti_port {
spinlock_t  tp_lock;
int tp_read_urb_state;
int tp_write_urb_in_use;
-   struct kfifowrite_fifo;
 };
 
 struct ti_device {
@@ -431,10 +428,6 @@ static int ti_port_probe(struct usb_serial_port *port)
tport-tp_uart_base_addr = TI_UART2_BASE_ADDR;
port-port.closing_wait = msecs_to_jiffies(10 * closing_wait);
init_waitqueue_head(tport-tp_write_wait);
-   if (kfifo_alloc(tport-write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) {
-   kfree(tport);
-   return -ENOMEM;
-   }
tport-tp_port = port;
tport-tp_tdev = usb_get_serial_data(port-serial);
tport-tp_uart_mode = 0;/* default is RS232 */
@@ -451,7 +444,6 @@ static int ti_port_remove(struct usb_serial_port *port)
struct ti_port *tport;
 
tport = usb_get_serial_port_data(port);
-   kfifo_free(tport-write_fifo);
kfree(tport);
 
return 0;
@@ -616,7 +608,7 @@ static void ti_close(struct usb_serial_port *port)
usb_kill_urb(port-write_urb);
tport-tp_write_urb_in_use = 0;
spin_lock_irqsave(tport-tp_lock, flags);
-   kfifo_reset_out(tport-write_fifo);
+   kfifo_reset_out(port-write_fifo);
spin_unlock_irqrestore(tport-tp_lock, flags);
 
port_number = port-port_number;
@@ -655,7 +647,7 @@ static int ti_write(struct tty_struct *tty, struct 
usb_serial_port *port,
if (tport == NULL || !tport-tp_is_open)
return -ENODEV;
 
-   count = kfifo_in_locked(tport-write_fifo, data, count,
+   count = kfifo_in_locked(port-write_fifo, data, count,
tport-tp_lock);
ti_send(tport);
 
@@ -674,7 +666,7 @@ static int ti_write_room(struct tty_struct *tty)
return 0;
 
spin_lock_irqsave(tport-tp_lock, flags);
-   room = kfifo_avail(tport-write_fifo);
+   room = kfifo_avail(port-write_fifo);
spin_unlock_irqrestore(tport-tp_lock, flags);
 
dev_dbg(port-dev, %s - returns %d\n, __func__, room);
@@ -693,7 +685,7 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
return 0;
 
spin_lock_irqsave(tport-tp_lock, flags);
-   chars = kfifo_len(tport-write_fifo);
+   chars = kfifo_len(port-write_fifo);
spin_unlock_irqrestore(tport-tp_lock, flags);
 
dev_dbg(port-dev, %s - returns %d\n, __func__, chars);
@@ -1197,7 +1189,7 @@ static void ti_send(struct ti_port *tport)
if (tport-tp_write_urb_in_use)
goto unlock;
 
-   count = kfifo_out(tport-write_fifo,
+   count = kfifo_out(port-write_fifo,
port-write_urb-transfer_buffer,
port-bulk_out_size);
 
@@ -1312,7 +1304,7 @@ static int ti_get_serial_info(struct ti_port *tport,
ret_serial.line = port-minor;
ret_serial.port = port-port_number;
ret_serial.flags = tport-tp_flags;
-   ret_serial.xmit_fifo_size = TI_WRITE_BUF_SIZE;
+   ret_serial.xmit_fifo_size = kfifo_size(port-write_fifo);
ret_serial.baud_base = tport-tp_tdev-td_is_3410 ? 921600 : 460800;
ret_serial.closing_wait = cwait;
 
-- 
1.8.2.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 21/24] USB: safe_serial: remove vendor/product module parameters

2013-06-26 Thread Johan Hovold
Remove the vendor and product module parameters which were added a long
time ago when we did not have the dynamic sysfs interface to add
new device ids (and which isn't limited to a single new vid/pid pair).

A vid/pid pair can be added dynamically using sysfs, for example:

  echo 04dd 1234 /sys/bus/usb-serial/drivers/safe_serial/new_id

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/safe_serial.c | 51 +++-
 1 file changed, 14 insertions(+), 37 deletions(-)

diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 21cd7bf..ba89598 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -92,13 +92,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE(GPL);
 
-static __u16 vendor;   /* no default */
-static __u16 product;  /* no default */
-module_param(vendor, ushort, 0);
-MODULE_PARM_DESC(vendor, User specified USB idVendor (required));
-module_param(product, ushort, 0);
-MODULE_PARM_DESC(product, User specified USB idProduct (required));
-
 module_param(safe, bool, 0);
 MODULE_PARM_DESC(safe, Turn Safe Encapsulation On/Off);
 
@@ -140,8 +133,6 @@ static struct usb_device_id id_table[] = {
{MY_USB_DEVICE(0x4dd, 0x8003, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, 
LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Collie */
{MY_USB_DEVICE(0x4dd, 0x8004, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, 
LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Collie */
{MY_USB_DEVICE(0x5f9, 0x, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, 
LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Sharp tmp */
-   /* extra null entry for module vendor/produc parameters */
-   {MY_USB_DEVICE(0, 0, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, 
LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},
{}  /* terminating entry  */
 };
 
@@ -272,7 +263,19 @@ static int safe_prepare_write_buffer(struct 
usb_serial_port *port,
 
 static int safe_startup(struct usb_serial *serial)
 {
-   switch (serial-interface-cur_altsetting-desc.bInterfaceProtocol) {
+   struct usb_interface_descriptor *desc;
+
+   if (serial-dev-descriptor.bDeviceClass != CDC_DEVICE_CLASS)
+   return -ENODEV;
+
+   desc = serial-interface-cur_altsetting-desc;
+
+   if (desc-bInterfaceClass != LINEO_INTERFACE_CLASS)
+   return -ENODEV;
+   if (desc-bInterfaceSubClass != LINEO_INTERFACE_SUBCLASS_SAFESERIAL)
+   return -ENODEV;
+
+   switch (desc-bInterfaceProtocol) {
case LINEO_SAFESERIAL_CRC:
break;
case LINEO_SAFESERIAL_CRC_PADDED:
@@ -300,30 +303,4 @@ static struct usb_serial_driver * const serial_drivers[] = 
{
safe_device, NULL
 };
 
-static int __init safe_init(void)
-{
-   int i;
-
-   /* if we have vendor / product parameters patch them into id list */
-   if (vendor || product) {
-   pr_info(vendor: %x product: %x\n, vendor, product);
-
-   for (i = 0; i  ARRAY_SIZE(id_table); i++) {
-   if (!id_table[i].idVendor  !id_table[i].idProduct) {
-   id_table[i].idVendor = vendor;
-   id_table[i].idProduct = product;
-   break;
-   }
-   }
-   }
-
-   return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, 
id_table);
-}
-
-static void __exit safe_exit(void)
-{
-   usb_serial_deregister_drivers(serial_drivers);
-}
-
-module_init(safe_init);
-module_exit(safe_exit);
+module_usb_serial_driver(serial_drivers, id_table);
-- 
1.8.2.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 11/24] USB: pl2303: remove debugging noise

2013-06-26 Thread Johan Hovold
Only log the tty_flags in process_read_urb on errors.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/pl2303.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 91f14c6..299a0ff 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -790,8 +790,10 @@ static void pl2303_process_read_urb(struct urb *urb)
tty_flag = TTY_PARITY;
else if (line_status  UART_FRAME_ERROR)
tty_flag = TTY_FRAME;
-   dev_dbg(port-dev, %s - tty_flag = %d\n, __func__, tty_flag);
 
+   if (tty_flag != TTY_NORMAL)
+   dev_dbg(port-dev, %s - tty_flag = %d\n, __func__,
+   tty_flag);
/* overrun is special, not associated with a char */
if (line_status  UART_OVERRUN_ERROR)
tty_insert_flip_char(port-port, 0, TTY_OVERRUN);
-- 
1.8.2.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 16/24] USB: ftdi_sio: remove unused defines

2013-06-26 Thread Johan Hovold
Remove some unused defines.

Signed-off-by: Johan Hovold jhov...@gmail.com
---
 drivers/usb/serial/ftdi_sio.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 9bd1f6f..bebf3ef 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -902,9 +902,6 @@ static const char *ftdi_chip_name[] = {
 #define FTDI_STATUS_B1_MASK(FTDI_RS_BI)
 /* End TIOCMIWAIT */
 
-#define FTDI_IMPL_ASYNC_FLAGS = (ASYNC_SPD_HI | ASYNC_SPD_VHI \
- | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP)
-
 /* function prototypes for a FTDI serial converter */
 static int  ftdi_sio_probe(struct usb_serial *serial,
const struct usb_device_id *id);
@@ -971,10 +968,6 @@ static struct usb_serial_driver * const serial_drivers[] = 
{
 #define WDR_TIMEOUT 5000 /* default urb timeout */
 #define WDR_SHORT_TIMEOUT 1000 /* shorter urb timeout */
 
-/* High and low are for DTR, RTS etc etc */
-#define HIGH 1
-#define LOW 0
-
 /*
  * ***
  * Utility functions
-- 
1.8.2.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


[RFC] am33xx: create child nodes for the two musb controllers

2013-06-26 Thread Sebastian Andrzej Siewior
I've been thinkig about creating two child nodes for the independent musb
controllers on the am33. I've been thinking about the following:

diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 8e1248f..6aa9506 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -326,21 +326,78 @@
status = disabled;
};
 
usb@4740 {
compatible = ti,musb-am33xx;
-   reg = 0x4740 0x1000/* usbss */
-  0x47401000 0x800 /* musb instance 0 */
-  0x47401800 0x800;   /* musb instance 1 */
-   interrupts = 17/* usbss */
- 18/* musb instance 0 */
- 19;  /* musb instance 1 */
-   multipoint = 1;
-   num-eps = 16;
-   ram-bits = 12;
-   port0-mode = 3;
-   port1-mode = 3;
-   power = 250;
+   reg = 0x4740 0x1000;  /* usbss */
+   interrupts = 17;  /* usbss */
ti,hwmods = usb_otg_hs;
+
+   usb0@0x47401000 {
+   reg = 0x47401000 0x800;   /* musb 
instance 0 */
+   interrupts = 18;  /* musb 
instance 0 */
+   multipoint = 1;
+   num-eps = 16;
+   ram-bits = 12;
+   port-mode = 3;
+   power = 250;
+
+   phys = nopphy0;
+   dmas = cppi41dma 0
+   cppi41dma 1
+   cppi41dma 2
+   cppi41dma 3
+   cppi41dma 4
+   cppi41dma 32
+   cppi41dma 34
+   cppi41dma 36
+   cppi41dma 38
+   cppi41dma 40;
+   dma-names = rx1, rx2, rx3, rx4, rx5,
+   tx1, tx2, tx3, tx4, tx5;
+   };
+
+   usb0@0x47401800 {
+   reg = 0x47401800 0x800;   /* musb 
instance 1 */
+   interrupts = 19;  /* musb 
instance 1 */
+   multipoint = 1;
+   num-eps = 16;
+   ram-bits = 12;
+   port-mode = 3;
+   power = 250;
+
+   phys = nopphy1;
+   dmas = cppi41dma 0
+   cppi41dma 1
+   cppi41dma 2
+   cppi41dma 3
+   cppi41dma 4
+   cppi41dma 62
+   cppi41dma 64
+   cppi41dma 66
+   cppi41dma 68
+   cppi41dma 70;
+   dma-names = rx1, rx2, rx3, rx4, rx5,
+   tx1, tx2, tx3, tx4, tx5;
+   };
+   };

Please keep in mind that his is not a proper patch it should point out
what I have in mind.
This would easy the for instance the dma channel assignment. Also, it will
move back to the port-mode property instead of portX-mode one which it has
now. This is kind of confusing since it is not a root hub or anything like
that it is a complete musb controller. Plus for the phys property could
easily take the one avaible and would not require which instance it
really it is.

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


Re: Linux USB file storage gadget with new UDC

2013-06-26 Thread victor yeo
Hi,

 I re-attach the usbmon log. If possible, please show me which line
 indicates that usb_ep_set_wedge routine is not working, or how to look
 for the clue. Is it from the control transfer line?

 Here's an example:

 f4148f80 308532 S Bo:1:011:1 -115 31 = 55534243 0600 c000 
 861a 003f00c0   00
 f4148f80 308652 C Bo:1:011:1 0 31 
 f14c5600 308676 S Bi:1:011:1 -115 192 
 f14c5600 3087787651 C Bi:1:011:1 -121 16 = 0f00 080a0400  
 f4148f80 3087787674 S Bi:1:011:1 -115 13 
 f4148f80 3087803018 C Bi:1:011:1 0 13 = 55534253 0600 b000 00

 The last line should have failed with a -32 error code, because the IN
 endpoint is supposed to be halted at this point.

  I think the GET_STATUS request is not handled by the gadget driver. Isn't 
  it so?
 
  That's right.  Get-Status, Set-Feature, and Clear-Feature requests must
  be handled by the UDC driver.
 
  Alan Stern

The fsg-state in gadget driver,  is used for exception handling. Is
there any variable to track the USB device state of Figure 9-1 of the
USB 2.0 Spec? Now the gadget driver does not pass the USB2.0 CV - Get
Device Descriptor - Address State test. So i am trying to find more
information.

Thanks,
victor
--
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: host: xhci-plat: Enable XHCI_SPURIOUS_SUCCESS quirk for xhci-plat

2013-06-26 Thread Sarah Sharp
On Wed, Jun 26, 2013 at 02:28:57PM +0530, George Cherian wrote:
 Synopsis xhci controllers with hci_version  0.96 gives spurious success
 events on short packet completion. During webcam capture the
 ERROR Transfer event TRB DMA ptr not part of current TD was observed.
 The same application works fine with synopsis controllers hci_version 0.96.

It's a known issue.  The xHCI 1.0 spec changed how hardware handles
short packets.  The HW will notify SW of the TRB where the short packet,
and it will also give a successful status for the last TRB in a TD (the
one with the IOC flag set).  On the second successful status, that
warning will be triggered in the driver.

Software is now supposed to not assume the TD as done until it gets that
last successful status.  That means we have a slight race condition,
although it should have little practical impact.  This patch papers over
that issue.

I will take this patch, but will add the note that is on my long-term
to-do list to fix this issue.

Sarah Sharp

 
 Signed-off-by: George Cherian george.cher...@ti.com
 ---
  drivers/usb/host/xhci-plat.c | 10 ++
  1 file changed, 10 insertions(+)
 
 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index 93ad67e..e63c6d3 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
 @@ -25,6 +25,16 @@ static void xhci_plat_quirks(struct device *dev, struct 
 xhci_hcd *xhci)
* dev struct in order to setup MSI
*/
   xhci-quirks |= XHCI_BROKEN_MSI;
 +
 + /*
 +  * In some xhci controllers which follows xhci 1.0 spec gives a spurious
 +  * success event after a short transfer. This quirk will ignore such
 +  * spurious event. Hit this issue in synopsis xhci controllers with
 +  * hci_version  0.96
 +  */
 +
 + if (xhci-hci_version  0x96)
 + xhci-quirks |= XHCI_SPURIOUS_SUCCESS;
  }
  
  /* called during probe() after chip reset completes */
 -- 
 1.8.1.4
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] usb: dwc3: clean up redundant parameter comment

2013-06-26 Thread Huang Rui
@list is not as a parameter of dwc3_event_buffer, so remove it in
comments.

Signed-off-by: Huang Rui ray.hu...@amd.com
---
 drivers/usb/dwc3/core.h |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index b69d322..c4b5127 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -367,7 +367,6 @@ struct dwc3_trb;
 
 /**
  * struct dwc3_event_buffer - Software event buffer representation
- * @list: a list of event buffers
  * @buf: _THE_ buffer
  * @length: size of this buffer
  * @lpos: event offset
-- 
1.7.10.4


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


Re: [PATCH 1/4] usb: phy: tegra: Add support for device tree-based vbus regulator control

2013-06-26 Thread Stephen Warren
On 06/26/2013 03:59 AM, Mikko Perttunen wrote:
 After this patch, usb vbus regulators for tegra usb phy devices can be 
 specified
 with the device tree attribute vbus-supply = x where x is a regulator 
 defined
 in the device tree.

 diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c

 @@ -250,12 +251,24 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
   return PTR_ERR(phy-pad_clk);
   }
  
 + phy-vbus = devm_regulator_get(phy-dev, vbus);
 + /* On some boards, the VBUS regulator doesn't need to be controlled */
 + if (IS_ERR(phy-vbus)) {
 + if (PTR_ERR(phy-vbus) == -ENODEV) {
 + dev_notice(phy-dev, no vbus regulator);
 + phy-vbus = NULL;
 + } else {
 + return PTR_ERR(phy-vbus);
 + }
 + }

I think this code should be added to some more core initialization
function; IIRC, there are separate utmip_pad_open() and some other
function for ULPI mode, and in the future there may be more for HSIC, etc.

For the error-handling, I think it'd be better to do:

* If property doesn't exist, set phy-vbus to some error value, e.g.
ERR_PTR(-ENODEV).
* If property does exist, call devm_regulator_get().
** If devm_regulator_get() returned any error, return it.

Or, does devm_regulator_get() return -ENODEV if-and-only-if the
vbus-supply DT property does not exist?

and ...

 @@ -280,6 +293,14 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy)
   spin_unlock_irqrestore(utmip_pad_lock, flags);
  
   clk_disable_unprepare(phy-pad_clk);
 +
 + if (phy-vbus) {

Here, check if (IS_ERR(phy-vbus) instead. The reason is if
devm_regulator_get() returns either a valid value or an error-pointer,
then NULL could in theory be a valid value (it's up the the regulator
API to determine that), and hence this code shouldn't assume that it can
use NULL to represent no regulator.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] usb: host: tegra: Remove direct vbus regulator control using GPIOs

2013-06-26 Thread Stephen Warren
On 06/26/2013 03:59 AM, Mikko Perttunen wrote:
 The tegra ehci driver has enabled USB vbus regulators directly using
 GPIOs and the device tree attribute nvidia,vbus-gpio. This is ugly
 and causes error messages on boot when both the regulator driver
 and the ehci driver want access to the same GPIO.
 
 This patch removes this mechanism of vbus control, so that an actual
 regulator interface can be used by the phy layer to control the
 usb vbus regulator.

This should be squashed into patch 1/4. The reason is that if just patch
1/4 is applied, then both ehci-tegra.c's legacy raw GPIO handling and
phy-tegra-usb.c's new regulator-based code will attempt to
gpio_request() the same GPIO, and one will fail, which will likely cause
the driver to fail to probe().
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] Documentation: devicetree: phy-tegra-usb: Add vbus-supply property for host mode PHYs

2013-06-26 Thread Stephen Warren
On 06/26/2013 03:59 AM, Mikko Perttunen wrote:

Patch description?

 diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt 
 b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt

 +Optional properties for dr_mode == host:
 +  - vbus-supply: regulator for VBUS
 +
  Required properties for dr_mode == otg:
- vbus-supply: regulator for VBUS

I would define the property only once. Perhaps:

VBUS control (required dr_mode==otg, optional for dr_mode==host):
- vbus-supply: regulator for VBUS

--
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] usb: dwc3: fix wrong bit mask in dwc3_event_type

2013-06-26 Thread Huang Rui
Per dwc3 2.50a spec, the is_devspec bit is used to distinguish the
Device Endpoint-Specific Event or Device-Specific Event (DEVT). If the
bit is 1, the event is represented Device-Specific Event, then use
[7:1] bits as Device Specific Event to marked the type. It has 7 bits,
and we can see the reserved8_31 variable name which means from 8 to 31
bits marked reserved, actually there are 24 bits not 25 bits between
that. And 1 + 7 + 24 = 32, the event size is 4 byes.

So in dwc3_event_type, the bit mask should be:
is_devspec  [0] 1  bit
type[7:1]   7  bits
reserved8_31[31:8]  24 bits

This patch should be backported to kernels as old as 3.2, that contain
the commit 72246da40f3719af3bfd104a2365b32537c27d83 usb: Introduce
DesignWare USB3 DRD Driver.

Signed-off-by: Huang Rui ray.hu...@amd.com
Cc: sta...@vger.kernel.org
---
 drivers/usb/dwc3/core.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index c4b5127..00a72e3 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -758,8 +758,8 @@ struct dwc3 {
 
 struct dwc3_event_type {
u32 is_devspec:1;
-   u32 type:6;
-   u32 reserved8_31:25;
+   u32 type:7;
+   u32 reserved8_31:24;
 } __packed;
 
 #define DWC3_DEPEVT_XFERCOMPLETE   0x01
-- 
1.7.10.4


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


Re: [PATCH 4/4] ARM: dts: tegra20: Remove obsolete vbus-gpio properties

2013-06-26 Thread Stephen Warren
On 06/26/2013 03:59 AM, Mikko Perttunen wrote:
 USB VBUS regulators are now specified with the vbus-supply property
 instead of vbus-gpio, so remove the obsolete properties.

As far as patch scheduling goes, I might be simpler to send one series
to convert the driver to the new properties, then once that has been
merged into a kernel release, we can apply patches to remove all the
legacy properties from DT in a later kernel release. That will save the
requirement for any cross-subsystem merges.

Although, if the USB maintainers are OK with doing it all at once, and
we can make sure this series gets merged into a separate topic branch so
that I can take it into the Tegra tree to resolve any merge conflicts
with any other Tegra DT modifications if needed, then applying this all
at once is fine.
--
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] Debugfs support for EHCI testing modes

2013-06-26 Thread Greg KH
On Wed, Jun 26, 2013 at 09:32:47AM +0200, Tim Sander wrote:
 Hi
 
 I have just written a ehci testing driver which enables the testing modes used
 for hw testing via a file in debugfs.  This patch is for 3.4.47 not any usb
 branch. But if this driver is ready for mainline i will be happy to port it to
 whatever branch you wish.
 
 The only problem with the patch is that it is currently working on hw 
 registers
 as the usb control msg in this patch is not working. For the time beeing i 
 just
 commented out the usb_control_msg call and fiddled with the registers 
 directly.
 This is one thing which might not be mainline compatible?
 
 The call not working is:
 status = usb_control_msg(hub, usb_sndctrlpipe(hub,0),
USB_REQ_SET_FEATURE, 
 USB_RT_PORT, USB_PORT_FEAT_TEST,
i  8 | hub-portnum, NULL, 
 0, 1000);
^ this might 
 be wrong?

Where is this call you are referring to?  I don't see it in the patch
you have below.

 I have the strong suspicion that the marked agument is wrong? The direct 
 manipulation
 of the portsc register works as expected. 
 
 The testmodes array is magic in a way that the offset of the values 
 corresponds directly
 with the PTC field (Bits 19-16) of the Port Status Control register.
 
 Also there is a driver which does the tests with a special usb test plug:
 http://code.google.com/p/bricked/source/browse/drivers/usb/misc/ehset.c
 Its also sending these usb_control_msg but these are also not working.
 
 So if this usb_control_msg is working it would also be nice to get this 
 driver mainlined.

I agree, care to make it up into a patch we could apply?

thanks,

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


Re: [PATCH 1/2] ARM: dts: tegra20: Rename USB UTMI parameters according to new definitions

2013-06-26 Thread Stephen Warren
On 06/26/2013 05:58 AM, Mikko Perttunen wrote:
 Signed-off-by: Mikko Perttunen mperttu...@nvidia.com

Damn. I thought that Venu had converted the *.dts files completely to
match the new binding definition in the last series he sent. I guess he
missed these because the driver doesn't use them yet and he wasn't
paying attention. Grrr.

So, this change is fine (modulo missing description as Felipe pointed
out), but will again mean that the USB tree needs to take some Tegra
*.dts changes:-( I don't expect this will cause any conflicts, so it
probably won't require any cross-subsystem merge, but it'd be best to
apply all these Tegra changes in a separate topic branch just in case...

Felipe, let me know if you want me to actually do the patch application
for that topic branch to save you the hassle.
--
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] staging: ozwpan: Convert printk to dev_dbg()

2013-06-26 Thread Jason Baron
On 06/25/2013 01:29 PM, Joe Perches wrote:
 On Tue, 2013-06-25 at 10:02 -0700, Greg KH wrote:
 On Tue, Jun 25, 2013 at 05:30:02PM +0100, Rupesh Gujare wrote:
 convert all debug messages from printk to dev_dbg()  add kernel config to
 enable/disable these messages during compilation.
 No, just use the built-in dynamic debug code in the kernel, no need to
 provide any new macros or functions or most importantly, no new Kconfig
 options.
 I think the Kconfig option is pretty poor too but a
 long needed extension to dev_dbg is to enable classes
 of messages by level or mask.

 There are many existing macros like

 #define module_dbg(level, fmt, ...)
 do {
   if (level = some_module_var)
   debug_something(...);
 } while (0)

 and

 #define module_dbg(mask, fmt, ...)
 do {
   if (mask  some_module_var)
   debug_something(...)
 } while (0)

 It'd be nice to consolidate those in dev_dbg

 I'll get 'round to it one day if Jason doesn't.


Hi,

I've been a bit reluctant to add these 'flag' and 'level' to dynamic
debug b/c the debug statements can already be controlled individually,
and thus one could implement something pretty similar in userspace.
Also, it keeps things simpler.

That said, this has come up several times and might be a nice extension
for both the dynamic debug and non-dynamic debug case.

I think the interface could look something like:

pr_debug_level(control_var, level, fmt, ...);
pr_debug_mask(control_var, mask, fmt, ...);

and then you could do something like:

echo grouping control_var level N +p  /debugfs/dynamic_debug/control

or

echo grouping control_var mask 0xN +p  /debugfs/dynamic_debug/control

So we can think of the 'control_var' as 'grouping' debug statements
together. So it would provide a nice way of associating statements
together other than the existing: module, func, file, format, and line
selectors.

Thanks,

-Jason

























--
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] staging: ozwpan: Convert printk to dev_dbg()

2013-06-26 Thread Jason Baron
On 06/25/2013 02:03 PM, Joe Perches wrote:
 (Using Jason Baron's most current email address)

 On Tue, 2013-06-25 at 10:56 -0700, Joe Perches wrote:
 On Tue, 2013-06-25 at 10:38 -0700, Greg KH wrote:
 On Tue, Jun 25, 2013 at 10:29:50AM -0700, Joe Perches wrote:
 a long needed extension to dev_dbg is to enable classes
 of messages by level or mask.

 There are many existing macros like

 #define module_dbg(level, fmt, ...)
 do {
if (level = some_module_var)
debug_something(...);
 } while (0)

 and

 #define module_dbg(mask, fmt, ...)
 do {
if (mask  some_module_var)
debug_something(...)
 } while (0)

 It'd be nice to consolidate those in dev_dbg
 I'd almost recommend that all of them just be removed, because most of
 them were only used for debugging the code the first time it was
 developed, right?  Only for very limited usages would this type of thing
 be needed.
 Maybe, though that's hard to know with certainty.
 How often module options are used isn't easy to find out.

 These forms are sometimes used to reduce object size.
 Hey Jason.  Your redhat.com address is out of date.

 If you're still interested in dynamic_debug, you should
 update your MAINTAINERS entry.



Hi Joe,

Thanks for asking - I'll send out a patch to update it.

Thanks,

-Jason



--
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 v2 2/2] usb: phy: tegra: Read UTMIP parameters from device tree

2013-06-26 Thread Stephen Warren
On 06/26/2013 06:34 AM, Mikko Perttunen wrote:
 UTMIP parameters used to be hardcoded into tables in the
 PHY driver. This patch reads them from the device tree instead
 in accordance with the phy-tegra-usb DT documentation.

This looks fine, although I'd like to have a chance to test all these
patches before actually ack'ing them.
--
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] chipidea: bits: Cast PORTSC_PTS and DEVLC_PTS macros

2013-06-26 Thread Fabio Estevam
Fix the following build warnings on x86:

drivers/usb/chipidea/core.c: In function 'hw_phymode_configure':
drivers/usb/chipidea/core.c:226:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]
drivers/usb/chipidea/core.c:230:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]
drivers/usb/chipidea/core.c:243:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]
drivers/usb/chipidea/core.c:246:3: warning: large integer implicitly truncated 
to unsigned type [-Woverflow]

Reported-by: Felipe Balbi ba...@ti.com
Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/usb/chipidea/bits.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index aefa026..1b23e35 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -50,7 +50,7 @@
 #define PORTSC_PTC(0x0FUL  16)
 /* PTS and PTW for non lpm version only */
 #define PORTSC_PTS(d)  \
-   d)  0x3)  30) | (((d)  0x4) ? BIT(25) : 0))
+   (u32)d)  0x3)  30) | (((d)  0x4) ? BIT(25) : 0))
 #define PORTSC_PTWBIT(28)
 #define PORTSC_STSBIT(29)
 
@@ -59,7 +59,7 @@
 #define DEVLC_PSPD_HS (0x02UL  25)
 #define DEVLC_PTW BIT(27)
 #define DEVLC_STS BIT(28)
-#define DEVLC_PTS(d)  (((d)  0x7)  29)
+#define DEVLC_PTS(d)  (u32)(((d)  0x7)  29)
 
 /* Encoding for DEVLC_PTS and PORTSC_PTS */
 #define PTS_UTMI  0
-- 
1.8.1.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


Re: [PATCH] staging: dwc2: fix thinko in dwc2_hc_set_even_odd_frame()

2013-06-26 Thread Stephen Warren
On 06/24/2013 12:34 PM, Paul Zimmerman wrote:
 I screwed up the sense of this if() statement while porting our
 vendor driver to create the dwc2 driver. This caused frame overrun
 errors on periodic transfers when there were other transfers
 active in the same (micro)frame.
 
 With this fix, the dwc2 driver now works on the Raspberry Pi
 platform even with the USB Ethernet controller enabled, where
 before that would cause all USB devices to stop working.

Ooh, that sounds exciting. Does it work in the upstream/mainline kernel,
or just the Raspberry Pi Foundation's downstream kernel though?
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >