Re: [PATCH 4/9] usb: gadget/uvc: free buffers after streamoff

2013-06-05 Thread Michael Olbrich
On Tue, Jun 04, 2013 at 05:08:23PM +0200, Michael Grzeschik wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de
 
 The current approach is to keep the device open and request buffers on
 REQBUFS. These buffers will not be freed until device close. The device
 close on the other hand will disconnect the device from the USB host.
 
 This way its not possible to change the buffers capabilities while still
 being connected. Thus, the device can not stream different buffer types.
 
 That patch clears the buffers on STREAMOFF. This way it will allways
 be needed to alloc new buffers before STREAMON.

No, this is wrong. The buffers must still exist after a STREAMON. From the
documentation: I/O returns to the same state as after calling
VIDIOC_REQBUFS and can be restarted accordingly.

The correct solution is for the userspace to call VIDIOC_REQBUFS with
count=0 before calling VIDIOC_S_FMT.

Regards,
Michael

 Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 ---
  drivers/usb/gadget/uvc_v4l2.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c
 index 4d806b0..9fe2725 100644
 --- a/drivers/usb/gadget/uvc_v4l2.c
 +++ b/drivers/usb/gadget/uvc_v4l2.c
 @@ -290,7 +290,10 @@ uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, 
 void *arg)
   if (*type != video-queue.queue.type)
   return -EINVAL;
  
 - return uvc_video_enable(video, 0);
 + ret = uvc_video_enable(video, 0);
 + uvc_free_buffers(video-queue);
 +
 + return ret;
   }
  
   /* Events */
 -- 
 1.8.2.rc2
 
 

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


Re: [PATCH 3/6] staging: octeon-usb: cvmx-usbcx-defs.h: avoid long lines in CVMX_USBCX macros

2013-06-05 Thread Dan Carpenter
On Wed, Jun 05, 2013 at 12:31:32AM +0300, Aaro Koskinen wrote:
 -#define CVMX_USBCX_DAINT(block_id) (CVMX_ADD_IO_SEG(0x00016F001818ull) + 
 ((block_id)  1) * 0x1000ull)

There should be a few helper macros.  I don't know the names for
these:
#define bid_to_xxx1(block_id) ((block_id)  1) ? 0x1000ull : 0)
#define bid_to_xxx4(block_id) ((block_id)  1) ? 0x400ull : 0)
#define bid_to_xxx8(block_id) ((block_id)  1) ? 0x80ull : 0)

#define SEG_PREFIX 0x00016F001000ull  15
#define CVMX_ADD(addr) CVMX_ADD_IO_SEG(SEG_PREFIX | (addr))

Then CVMX_USBCX_DAINTMSK() becomes:

#define CVMX_USBCX_DAINT(block_id) (CVMX_ADD(0x0818) + bid_to_xxx1(block_id))

It fits on one line and it uses words instead of magic numbers.

regards,
dan carpenter


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


Re: [PATCH v2 0/2] USB: PHY: Improve PHY selection logic

2013-06-05 Thread Roger Quadros
On 06/04/2013 11:26 PM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Jun 04, 2013 at 10:16:50AM +0300, Roger Quadros wrote:
 On 06/03/2013 08:47 PM, Greg KH wrote:
 On Fri, May 31, 2013 at 02:29:01PM +0300, Roger Quadros wrote:
 Hi,

 Improve Kconfig so that the relevant PHY driver can be explicitely
 selected by the controller driver instead of relying on the user
 to do so.

 Detailed description in patch 1.

 Felipe needs to take these, not I.


 Felipe,

 Could you please take these if appropriate? Thanks.
 
 it's for v3.11 merge window, right ? I think I'll enjoy the rest of my
 vacations before taking these patches ;-)
 
 I'll be back on office next monday, cheers
 

Yes these are for 3.11 so no hurry :). Didn't mean to interrupt your vacations.

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


[PATCH] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Johan Hovold
Fix regression introduced by commit 143d9d9616 (USB: serial: add
tiocmiwait subdriver operation) which made the ioctl operation return
ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
implementation is missing.

Cc: sta...@vger.kernel.org
Signed-off-by: Johan Hovold jhov...@gmail.com
---

Greg,

Here's one more fix for v3.10.

Thanks,
Johan


 drivers/usb/serial/usb-serial.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 4753c00..5f6b1ff 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -408,7 +408,7 @@ static int serial_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
 {
struct usb_serial_port *port = tty-driver_data;
-   int retval = -ENODEV;
+   int retval = -ENOIOCTLCMD;
 
dev_dbg(tty-dev, %s - cmd 0x%.4x\n, __func__, cmd);
 
@@ -420,8 +420,6 @@ static int serial_ioctl(struct tty_struct *tty,
default:
if (port-serial-type-ioctl)
retval = port-serial-type-ioctl(tty, cmd, arg);
-   else
-   retval = -ENOIOCTLCMD;
}
 
return 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


Re: [PATCH V2 0/6] USB: make ehci-tegra its own module

2013-06-05 Thread Arnd Bergmann
On Wednesday 05 June 2013, Stephen Warren wrote:
 
 Today 01:53:28
 From: Stephen Warren swar...@nvidia.com
 
 ehci-tegra is currently built into the main ehci-hcd driver, rather than
 being a separate module. This causes issues with multi-platform ARM
 kernels. This series separates ehci-tegra into its own module to avoid
 those problems.
 
 Manjunath Goudar originally wrote most of this series. I've since cleaned
 it up, rebased it on Venu's recent changes to the Tegra USB driver, and
 tested it.
 
 Note that I expect this series will need to go through the USB PHY tree,
 since it builds upon Venu's recent changes to the Tegra USB driver, which
 were applied there.

Thanks for following up on this!

Acked-by: Arnd Bergmann a...@arndb.de
--
To unsubscribe from this list: send the line unsubscribe 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: wusbcore: add HWA-specific fields to usb_rpipe_descriptor

2013-06-05 Thread Thomas Pugliese


On Tue, 4 Jun 2013, Thomas Pugliese wrote:

 This patch adds the HWA-specific RPIPE fields to usb_rpipe_descriptor and 
 sets the appropriate values in usb/wusbcore/wa-rpipe.c:rpipe_aim.
 
 Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
 
 diff --git a/drivers/usb/wusbcore/wa-rpipe.c b/drivers/usb/wusbcore/wa-rpipe.c
 index f0d546c..ed77ec7 100644
 --- a/drivers/usb/wusbcore/wa-rpipe.c
 +++ b/drivers/usb/wusbcore/wa-rpipe.c
 @@ -317,6 +317,7 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc 
 *wa,
   struct device *dev = wa-usb_iface-dev;
   struct usb_device *usb_dev = urb-dev;
   struct usb_wireless_ep_comp_descriptor *epcd;
 + u32 ack_window;
   u8 unauth;
  
   epcd = rpipe_epc_find(dev, ep);
 @@ -333,8 +334,18 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc 
 *wa,
   rpipe-descr.wBlocks = cpu_to_le16(16); /* given */
   /* ep0 maxpktsize is 0x200 (WUSB1.0[4.8.1]) */
   rpipe-descr.wMaxPacketSize = cpu_to_le16(ep-desc.wMaxPacketSize);
 - rpipe-descr.bHSHubAddress = 0; /* reserved: zero */
 - rpipe-descr.bHSHubPort = wusb_port_no_to_idx(urb-dev-portnum);
 +
 + /* Set burst length based on endopint type.
 +  *  Use max allowed burst length for bulk and isoc. */
 + if (usb_endpoint_xfer_int((ep-desc)) ||
 +  usb_endpoint_xfer_control((ep-desc))) {
 + rpipe-descr.hwa_bMaxBurst = 1;
 + } else {
 + rpipe-descr.hwa_bMaxBurst = 16;
 + }
 +
 + rpipe-descr.hwa_bDeviceInfoIndex =
 + wusb_port_no_to_idx(urb-dev-portnum);
   /* FIXME: use maximum speed as supported or recommended by device */
   rpipe-descr.bSpeed = usb_pipeendpoint(urb-pipe) == 0 ?
   UWB_PHY_RATE_53 : UWB_PHY_RATE_200;
 @@ -344,23 +355,23 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct 
 wahc *wa,
   le16_to_cpu(rpipe-descr.wRPipeIndex),
   usb_pipeendpoint(urb-pipe), rpipe-descr.bSpeed);
  
 - /* see security.c:wusb_update_address() */
 - if (unlikely(urb-dev-devnum == 0x80))
 - rpipe-descr.bDeviceAddress = 0;
 - else
 - rpipe-descr.bDeviceAddress = urb-dev-devnum | unauth;
 + rpipe-descr.hwa_reserved = 0;
 +
   rpipe-descr.bEndpointAddress = ep-desc.bEndpointAddress;
   /* FIXME: bDataSequence */
   rpipe-descr.bDataSequence = 0;
 - /* FIXME: dwCurrentWindow */
 - rpipe-descr.dwCurrentWindow = cpu_to_le32(1);
 +
 + ack_window = 0x  (32 - rpipe-descr.hwa_bMaxBurst);
 + ack_window = (rpipe-descr.bDataSequence);
 + rpipe-descr.dwCurrentWindow = cpu_to_le32(ack_window);
   /* FIXME: bMaxDataSequence */
   rpipe-descr.bMaxDataSequence = epcd-bMaxSequence - 1;
   rpipe-descr.bInterval = ep-desc.bInterval;
   /* FIXME: bOverTheAirInterval */
   rpipe-descr.bOverTheAirInterval = 0;   /* 0 if not isoc */
   /* FIXME: xmit power  preamble blah blah */
 - rpipe-descr.bmAttribute = ep-desc.bmAttributes  0x03;
 + rpipe-descr.bmAttribute = (ep-desc.bmAttributes 
 + USB_ENDPOINT_XFERTYPE_MASK);
   /* rpipe-descr.bmCharacteristics RO */
   /* FIXME: bmRetryOptions */
   rpipe-descr.bmRetryOptions = 15;
 @@ -387,10 +398,8 @@ static int rpipe_check_aim(const struct wa_rpipe *rpipe, 
 const struct wahc *wa,
  const struct usb_host_endpoint *ep,
  const struct urb *urb, gfp_t gfp)
  {
 - int result = 0; /* better code for lack of companion? */
 + int result = 0;
   struct device *dev = wa-usb_iface-dev;
 - struct usb_device *usb_dev = urb-dev;
 - u8 unauth = (usb_dev-wusb  !usb_dev-authenticated) ? 0x80 : 0;
   u8 portnum = wusb_port_no_to_idx(urb-dev-portnum);
  
  #define AIM_CHECK(rdf, val, text)\
 @@ -403,13 +412,10 @@ static int rpipe_check_aim(const struct wa_rpipe 
 *rpipe, const struct wahc *wa,
   WARN_ON(1); \
   }   \
   } while (0)
 - AIM_CHECK(wMaxPacketSize, cpu_to_le16(ep-desc.wMaxPacketSize),
 -   (%u vs %u));
 - AIM_CHECK(bHSHubPort, portnum, (%u vs %u));
 + AIM_CHECK(hwa_bDeviceInfoIndex, portnum, (%u vs %u));
   AIM_CHECK(bSpeed, usb_pipeendpoint(urb-pipe) == 0 ?
   UWB_PHY_RATE_53 : UWB_PHY_RATE_200,
 (%u vs %u));
 - AIM_CHECK(bDeviceAddress, urb-dev-devnum | unauth, (%u vs %u));
   AIM_CHECK(bEndpointAddress, ep-desc.bEndpointAddress, (%u vs %u));
   AIM_CHECK(bInterval, ep-desc.bInterval, (%u vs %u));
   AIM_CHECK(bmAttribute, ep-desc.bmAttributes  0x03, (%u vs %u));
 diff --git a/include/linux/usb/wusb-wa.h b/include/linux/usb/wusb-wa.h
 index f9dec37..6be985b 100644
 --- a/include/linux/usb/wusb-wa.h
 +++ 

Re: [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function

2013-06-05 Thread Michael Grzeschik
Hi Alexander,

On Fri, May 31, 2013 at 08:38:44PM +0200, Michael Grzeschik wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de
 
 The pdata structure gets copied anyway inside ci13xxx_add_device
 by platform_device_add. We don't need to have it static.
 
 Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 Reviewed-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/chipidea/ci13xxx_imx.c | 19 +--
  1 file changed, 9 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
 b/drivers/usb/chipidea/ci13xxx_imx.c
 index 73f9d5f..4d64541 100644
 --- a/drivers/usb/chipidea/ci13xxx_imx.c
 +++ b/drivers/usb/chipidea/ci13xxx_imx.c
 @@ -88,17 +88,16 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
  
  /* End of common functions shared by usbmisc drivers*/
  
 -static struct ci13xxx_platform_data ci13xxx_imx_platdata  = {
 - .name   = ci13xxx_imx,
 - .flags  = CI13XXX_REQUIRE_TRANSCEIVER |
 -   CI13XXX_PULLUP_ON_VBUS |
 -   CI13XXX_DISABLE_STREAMING,
 - .capoffset  = DEF_CAPOFFSET,
 -};
 -
  static int ci13xxx_imx_probe(struct platform_device *pdev)
  {
   struct ci13xxx_imx_data *data;
 + struct ci13xxx_platform_data pdata = {
 + .name   = ci13xxx_imx,
 + .capoffset  = DEF_CAPOFFSET,
 + .flags  = CI13XXX_REQUIRE_TRANSCEIVER |
 +   CI13XXX_PULLUP_ON_VBUS |
 +   CI13XXX_DISABLE_STREAMING,
 + };
   struct platform_device *plat_ci, *phy_pdev;
   struct device_node *phy_np;
   struct resource *res;
 @@ -171,7 +170,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
   reg_vbus = NULL;
   }
  
 - ci13xxx_imx_platdata.phy = data-phy;
 + pdata.phy = data-phy;
  
   if (!pdev-dev.dma_mask)
   pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
 @@ -189,7 +188,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
  
   plat_ci = ci13xxx_add_device(pdev-dev,
   pdev-resource, pdev-num_resources,
 - ci13xxx_imx_platdata);
 + pdata);
   if (IS_ERR(plat_ci)) {
   ret = PTR_ERR(plat_ci);
   dev_err(pdev-dev,

This and Patch 5, 6 and 7 of this series doesn't got much to do with
the the dr_mode/phy_type features. I will repost them in another series.
Beside the others, this one is missing any comments. If it's already good
to be taken, will you directly apply it?

Regards,
Michael

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


Re: [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function

2013-06-05 Thread Alexander Shishkin
Michael Grzeschik m...@pengutronix.de writes:

 Hi Alexander,

 On Fri, May 31, 2013 at 08:38:44PM +0200, Michael Grzeschik wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de
 
 The pdata structure gets copied anyway inside ci13xxx_add_device
 by platform_device_add. We don't need to have it static.
 
 Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 Reviewed-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/chipidea/ci13xxx_imx.c | 19 +--
  1 file changed, 9 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
 b/drivers/usb/chipidea/ci13xxx_imx.c
 index 73f9d5f..4d64541 100644
 --- a/drivers/usb/chipidea/ci13xxx_imx.c
 +++ b/drivers/usb/chipidea/ci13xxx_imx.c
 @@ -88,17 +88,16 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
  
  /* End of common functions shared by usbmisc drivers*/
  
 -static struct ci13xxx_platform_data ci13xxx_imx_platdata  = {
 -.name   = ci13xxx_imx,
 -.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
 -  CI13XXX_PULLUP_ON_VBUS |
 -  CI13XXX_DISABLE_STREAMING,
 -.capoffset  = DEF_CAPOFFSET,
 -};
 -
  static int ci13xxx_imx_probe(struct platform_device *pdev)
  {
  struct ci13xxx_imx_data *data;
 +struct ci13xxx_platform_data pdata = {
 +.name   = ci13xxx_imx,
 +.capoffset  = DEF_CAPOFFSET,
 +.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
 +  CI13XXX_PULLUP_ON_VBUS |
 +  CI13XXX_DISABLE_STREAMING,
 +};
  struct platform_device *plat_ci, *phy_pdev;
  struct device_node *phy_np;
  struct resource *res;
 @@ -171,7 +170,7 @@ static int ci13xxx_imx_probe(struct platform_device 
 *pdev)
  reg_vbus = NULL;
  }
  
 -ci13xxx_imx_platdata.phy = data-phy;
 +pdata.phy = data-phy;
  
  if (!pdev-dev.dma_mask)
  pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
 @@ -189,7 +188,7 @@ static int ci13xxx_imx_probe(struct platform_device 
 *pdev)
  
  plat_ci = ci13xxx_add_device(pdev-dev,
  pdev-resource, pdev-num_resources,
 -ci13xxx_imx_platdata);
 +pdata);
  if (IS_ERR(plat_ci)) {
  ret = PTR_ERR(plat_ci);
  dev_err(pdev-dev,

 This and Patch 5, 6 and 7 of this series doesn't got much to do with
 the the dr_mode/phy_type features. I will repost them in another series.
 Beside the others, this one is missing any comments. If it's already good
 to be taken, will you directly apply it?

Ok, I'll take those. I'll let you know if there are any conflicts. :)

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 3/6] USB: EHCI: export ehci_handshake for ehci-hcd sub-drivers

2013-06-05 Thread Alan Stern
On Tue, 4 Jun 2013, Stephen Warren wrote:

 From: Manjunath Goudar manjunath.gou...@linaro.org
 
 In order to split ehci-hcd.c into separate modules, handshake() must be
 exported. Rename the symbol to add an ehci_ prefix, to avoid any naming
 clashes.
 
 Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org
 [swarren, split Manjunath's patches more logically, limit this change
 to export just handshake()]
 Signed-off-by: Stephen Warren swar...@nvidia.com
 ---
 v2: Only export handshake(), not reset/tdi_reset/halt.

Acked-by: Alan Stern st...@rowland.harvard.edu

--
To unsubscribe from this list: send the line unsubscribe 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 4/6] USB: EHCI: tegra: remove all power management

2013-06-05 Thread Alan Stern
On Tue, 4 Jun 2013, Stephen Warren wrote:

 From: Stephen Warren swar...@nvidia.com
 
 The PM routines in ehci-tegra.c use APIs such as ehci_reset(),
 ehci_halt(), and ehci_tdi_reset() that would need to be exported to
 convert ehci-tegra.c into a separate module from ehci-hcd.c. However,
 we'd prefer not to export them.
 
 Instead, simply remove all power management functionality. Runtime PM
 was disabled since it didn't work correctly, and system suspend isn't
 yet supported in a meaningful way. So, this change doesn't lose any
 functionality.
 
 Hopefully the power management logic can be reimplemented in a cleaner
 way in the future.
 
 Signed-off-by: Stephen Warren swar...@nvidia.com
 ---
 NOTE: This could do with a little more testing on a few more boards. If
 Alan is OK with this series, I'll go through and do that, and let you
 know when I've tested it enough to be applied. I saw no issues on the one
 board I tested with though.
 
 I'd appreciate any hints if this patch is actually removing more
 functionality than I think, and is going to break something horribly.

This is a good way to break the logjam.  It needs just a couple of
improvements:

 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 index 289b9b8..8f42b3a 100644
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c
 @@ -61,15 +61,6 @@ static void tegra_ehci_power_up(struct usb_hcd *hcd)
   tegra-host_resumed = 1;
  }
  
 -static void tegra_ehci_power_down(struct usb_hcd *hcd)
 -{
 - struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
 -
 - tegra-host_resumed = 0;
 - usb_phy_set_suspend(hcd-phy, 1);
 - clk_disable_unprepare(tegra-clk);
 -}
 -

tegra_ehci_power_up() shouldn't be retained either.  And with these
functions removed, there's no need to keep the tegra-host_resumed
field.

Related to this, the tegra_ehci_shutdown() routine should be removed,
and the .shutdown entry in tegra_ehci_hc_driver should point to
ehci_shutdown.

 @@ -399,10 +369,6 @@ static const struct hc_driver tegra_ehci_hc_driver = {
   .map_urb_for_dma= tegra_ehci_map_urb_for_dma,
   .unmap_urb_for_dma  = tegra_ehci_unmap_urb_for_dma,
   .hub_control= tegra_ehci_hub_control,
 -#ifdef CONFIG_PM
 - .bus_suspend= ehci_bus_suspend,
 - .bus_resume = ehci_bus_resume,
 -#endif
  };

These two entries should be retained.  They refer to USB bus suspend
rather than controller suspend, and they don't use any Tegra-specific
code.

Alan Stern

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


Re: [PATCH V2 5/6] USB: EHCI: tegra: fix circular module dependencies

2013-06-05 Thread Alan Stern
On Tue, 4 Jun 2013, Stephen Warren wrote:

 From: Stephen Warren swar...@nvidia.com
 
 The Tegra EHCI driver directly calls various functions in the Tegra USB
 PHY driver. The reverse is also true; the PHY driver calls into the EHCI
 driver. This is problematic when the two are built as modules.
 
 The calls from the PHY to EHCI driver were originally added in commit
 bbdabdb usb: add APIs to access host registers from Tegra PHY, for the
 following reasons:
 
 1) The register being touched is an EHCI register, so logically only the
EHCI driver should touch it.
 2) (1) implies that some locking may be needed to correctly implement the
r/m/w access to this shared register.
 3) We were expecting to pass only the PHY register space to the Tegra PHY
driver, and hence it would not have access to touch the shared
registers.
 
 To solve this, that commit added functions in the EHCI driver to touch the
 shared register on behalf of the PHY driver.
 
 In practice, we ended up not having any locking in the implementaiton of
 those functions, and I've been led to believe this is safe. Equally, (3)
 did not happen either. Hence, it is possible for the PHY driver to touch
 the shared register directly.
 
 Given that, this patch moves the code to touch the shared register back
 into the PHY driver, to eliminate the module problems. If we actually
 need locking or co-ordination in the future, I propose we put the lock
 support into some pre-existing core module, or into a third separate
 module, in order to avoid the circular dependencies.
 
 I apologize for my contribution to code churn here.
 
 Signed-off-by: Stephen Warren swar...@nvidia.com
 ---
 v2: No change; just rebased on new versions of earlier patches.

I didn't bother to look in detail for possible future conflicts.  
Presumably we will be able to handle them as they arise.  Assuming the 
PHY needs adjustment only during probe, removal, suspend, and resume, 
we should be okay without locking.

Acked-by: Alan Stern st...@rowland.harvard.edu

--
To unsubscribe from this list: send the line unsubscribe 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 6/6] USB: EHCI: make ehci-tegra a separate driver

2013-06-05 Thread Alan Stern
On Tue, 4 Jun 2013, Stephen Warren wrote:

 From: Manjunath Goudar manjunath.gou...@linaro.org
 
 Separate the Tegra on-chip host controller driver from
 ehci-hcd host code so that it can be built as a separate driver module.
 This work is part of enabling multi-platform kernels on ARM.
 
 Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org
 [swarren, reworked Manjunath's patches to split them more logically,
 minor re-order of added lines to better match layout of other split-up
 HCD drivers and existing code, add MODULE_DEVICE_TABLE, fix
 MODULE_LICENSE.]
 Signed-off-by: Stephen Warren swar...@nvidia.com
 ---
 v2:
 * Set non-standard fields in tegra_ehci_hc_driver manually, rather than
   relying on an expanded struct ehci_driver_overrides.
 * Save orig_hub_control rather than relying on ehci_hub_control being
   exported.
 * Rebased on new versions of earlier patches.

Considering the changes recommended for the 4/6 patch, this needs a few 
updates too.

 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 index c8dc687..b164757 100644
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c

  struct tegra_ehci_hcd {
   struct ehci_hcd *ehci;
   struct tegra_usb_phy *phy;

Since you're doing the conversion, it makes sense also to convert this
structure from being separately allocated to using the private area at
the end of ehci_hcd.  (As part of that, the platform_set/get_drvdata
calls would store/retrieve the address of the ehci_hcd structure
instead of the tegra_ehci_hcd.)  Manjunath has already done this for
other drivers.

I suppose this could be added on in a separate patch.

 -static void tegra_ehci_shutdown(struct usb_hcd *hcd)
 -{
 - struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
 -
 - /* ehci_shutdown touches the USB controller registers, make sure
 -  * controller has clocks to it */
 - if (!tegra-host_resumed)
 - tegra_ehci_power_up(hcd);
 -
 - ehci_shutdown(hcd);
 -}

Of course, this routine should already be gone.

 @@ -462,6 +429,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
   err = -ENOMEM;
   goto cleanup_clk;
   }
 + tegra-ehci = hcd_to_ehci(hcd);

When the private data structure is moved to the private area, there 
will be no need for this back-pointer.  The ehci field can be 
eliminated.

 @@ -563,6 +533,12 @@ static void tegra_ehci_hcd_shutdown(struct 
 platform_device *pdev)
   struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
   struct usb_hcd *hcd = ehci_to_hcd(tegra-ehci);
  
 + /*
 +  * ehci_shutdown touches the USB controller registers, make sure
 +  * controller has clocks to it
 +  */
 + if (!tegra-host_resumed)
 + tegra_ehci_power_up(hcd);

This doesn't need to go here.  Since all the power management has been 
removed, the controller will never be suspended or powered down.  Hence 
there's no need to check or to power it back up.

 +static struct ehci_driver_overrides tegra_overrides __initdata = {
 + .extra_priv_size= sizeof(struct tegra_ehci_hcd),
 +};

The annotation should be __initconst rather than __initdata.

 +
 +static int __init ehci_tegra_init(void)
 +{
 + if (usb_disabled())
 + return -ENODEV;
 +
 + pr_info(DRV_NAME :  DRIVER_DESC \n);
 +
 + ehci_init_driver(tegra_ehci_hc_driver, tegra_overrides);
 +
 + orig_hub_control = tegra_ehci_hc_driver.hub_control;
 +
 + tegra_ehci_hc_driver.map_urb_for_dma = tegra_ehci_map_urb_for_dma;
 + tegra_ehci_hc_driver.unmap_urb_for_dma = tegra_ehci_unmap_urb_for_dma;
 + tegra_ehci_hc_driver.hub_control = tegra_ehci_hub_control;

You might want to add a comment explaining the reason for these manual 
overrides.  It's up to you.

Alan Stern

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


Re: [RFC PATCH v3 0/4] Add usb2 link powermanagement BESL support

2013-06-05 Thread Alan Stern
On Tue, 4 Jun 2013, Sarah Sharp wrote:

 Alan, Greg, any more comments on this patchset?
 
 It looks fine to me, and we've been testing it internally within Intel,
 so I'll queue it up for 3.11 if you don't have any more objections.

No objections to any of the parts touching the USB core.

Alan Stern

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


Re: [PATCH] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Greg Kroah-Hartman
On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
 Fix regression introduced by commit 143d9d9616 (USB: serial: add
 tiocmiwait subdriver operation) which made the ioctl operation return
 ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
 implementation is missing.

Ah, maybe this is the problem I've been trying to track down, I'll queue
it up and test it out now, 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] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Greg Kroah-Hartman
On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
 Fix regression introduced by commit 143d9d9616 (USB: serial: add
 tiocmiwait subdriver operation) which made the ioctl operation return
 ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
 implementation is missing.
 
 Cc: sta...@vger.kernel.org

As 143d9d9616 showed up in 3.10-rc1, this shouldn't go to stable, right?

thanks,

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


Re: [RFC PATCH v3 0/4] Add usb2 link powermanagement BESL support

2013-06-05 Thread Greg KH
On Wed, Jun 05, 2013 at 10:51:38AM -0400, Alan Stern wrote:
 On Tue, 4 Jun 2013, Sarah Sharp wrote:
 
  Alan, Greg, any more comments on this patchset?
  
  It looks fine to me, and we've been testing it internally within Intel,
  so I'll queue it up for 3.11 if you don't have any more objections.
 
 No objections to any of the parts touching the USB core.

None from me either.

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] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Johan Hovold
On Wed, Jun 05, 2013 at 08:34:29AM -0700, Greg KH wrote:
 On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
  Fix regression introduced by commit 143d9d9616 (USB: serial: add
  tiocmiwait subdriver operation) which made the ioctl operation return
  ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
  implementation is missing.
  
  Cc: sta...@vger.kernel.org
 
 As 143d9d9616 showed up in 3.10-rc1, this shouldn't go to stable, right?

You're right. Did a quick git log and misinterpreted the result.

Thanks,
Johan
--
To unsubscribe from this list: send the line unsubscribe 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: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Johan Hovold
On Wed, Jun 05, 2013 at 08:33:56AM -0700, Greg KH wrote:
 On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
  Fix regression introduced by commit 143d9d9616 (USB: serial: add
  tiocmiwait subdriver operation) which made the ioctl operation return
  ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
  implementation is missing.
 
 Ah, maybe this is the problem I've been trying to track down, I'll queue
 it up and test it out now, thanks.

What problem would that be? Let me know if it helps.

Thanks,
Johan
--
To unsubscribe from this list: send the line unsubscribe 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: wusbcore: add HWA-specific fields to usb_rpipe_descriptor

2013-06-05 Thread Thomas Pugliese


On Wed, 5 Jun 2013, Thomas Pugliese wrote:

 
 
 On Tue, 4 Jun 2013, Thomas Pugliese wrote:
 
  This patch adds the HWA-specific RPIPE fields to usb_rpipe_descriptor and 
  sets the appropriate values in usb/wusbcore/wa-rpipe.c:rpipe_aim.
  
  Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
  
  diff --git a/drivers/usb/wusbcore/wa-rpipe.c 
  b/drivers/usb/wusbcore/wa-rpipe.c
  index f0d546c..ed77ec7 100644
  --- a/drivers/usb/wusbcore/wa-rpipe.c
  +++ b/drivers/usb/wusbcore/wa-rpipe.c
  @@ -317,6 +317,7 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct 
  wahc *wa,
 
 Actually, the maxburst and maxsequence values should be assigned from the 
 wireless endpoint companion descriptor.  I will send out a corrected patch 
 shortly.
 
 Tom
 

This updated patch adds the HWA specific members and sets them correctly 
based on the wireless endpoint compananion descriptor.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com

diff --git a/drivers/usb/wusbcore/wa-rpipe.c b/drivers/usb/wusbcore/wa-rpipe.c
index f0d546c..9ea12a0 100644
--- a/drivers/usb/wusbcore/wa-rpipe.c
+++ b/drivers/usb/wusbcore/wa-rpipe.c
@@ -251,8 +251,8 @@ static int __rpipe_reset(struct wahc *wa, unsigned index)
 static struct usb_wireless_ep_comp_descriptor epc0 = {
.bLength = sizeof(epc0),
.bDescriptorType = USB_DT_WIRELESS_ENDPOINT_COMP,
-/* .bMaxBurst = 1, */
-   .bMaxSequence = 31,
+   .bMaxBurst = 1,
+   .bMaxSequence = 2,
 };
 
 /*
@@ -317,6 +317,7 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc 
*wa,
struct device *dev = wa-usb_iface-dev;
struct usb_device *usb_dev = urb-dev;
struct usb_wireless_ep_comp_descriptor *epcd;
+   u32 ack_window, epcd_max_sequence;
u8 unauth;
 
epcd = rpipe_epc_find(dev, ep);
@@ -333,8 +334,11 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc 
*wa,
rpipe-descr.wBlocks = cpu_to_le16(16); /* given */
/* ep0 maxpktsize is 0x200 (WUSB1.0[4.8.1]) */
rpipe-descr.wMaxPacketSize = cpu_to_le16(ep-desc.wMaxPacketSize);
-   rpipe-descr.bHSHubAddress = 0; /* reserved: zero */
-   rpipe-descr.bHSHubPort = wusb_port_no_to_idx(urb-dev-portnum);
+
+   rpipe-descr.hwa_bMaxBurst = max(min_t(unsigned int,
+   epcd-bMaxBurst, 16U), 1U);
+   rpipe-descr.hwa_bDeviceInfoIndex =
+   wusb_port_no_to_idx(urb-dev-portnum);
/* FIXME: use maximum speed as supported or recommended by device */
rpipe-descr.bSpeed = usb_pipeendpoint(urb-pipe) == 0 ?
UWB_PHY_RATE_53 : UWB_PHY_RATE_200;
@@ -344,23 +348,38 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc 
*wa,
le16_to_cpu(rpipe-descr.wRPipeIndex),
usb_pipeendpoint(urb-pipe), rpipe-descr.bSpeed);
 
-   /* see security.c:wusb_update_address() */
-   if (unlikely(urb-dev-devnum == 0x80))
-   rpipe-descr.bDeviceAddress = 0;
-   else
-   rpipe-descr.bDeviceAddress = urb-dev-devnum | unauth;
+   rpipe-descr.hwa_reserved = 0;
+
rpipe-descr.bEndpointAddress = ep-desc.bEndpointAddress;
/* FIXME: bDataSequence */
rpipe-descr.bDataSequence = 0;
-   /* FIXME: dwCurrentWindow */
-   rpipe-descr.dwCurrentWindow = cpu_to_le32(1);
-   /* FIXME: bMaxDataSequence */
-   rpipe-descr.bMaxDataSequence = epcd-bMaxSequence - 1;
+
+   /* start with base window of hwa_bMaxBurst bits starting at 0. */
+   ack_window = 0x  (32 - rpipe-descr.hwa_bMaxBurst);
+   /* shift window up to start at bDataSequence. */
+   ack_window = (rpipe-descr.bDataSequence);
+   /* mask off any bits that exceed epcd-bMaxSequence and
+* account for window shift wraparound. */
+   epcd_max_sequence = max(min_t(unsigned int,
+   epcd-bMaxSequence, 32U), 2U);
+   if ((rpipe-descr.hwa_bMaxBurst + rpipe-descr.bDataSequence) 
+   epcd_max_sequence) {
+   /* mask off any high bits past epcd_max_sequence. */
+   ack_window = 0x  (32 - epcd_max_sequence);
+   /* shift in wraparound bits. */
+   ack_window |= 0x  (32 -
+   ((rpipe-descr.hwa_bMaxBurst +
+   rpipe-descr.bDataSequence) -
+   epcd_max_sequence));
+   }
+   rpipe-descr.dwCurrentWindow = cpu_to_le32(ack_window);
+   rpipe-descr.bMaxDataSequence = epcd_max_sequence - 1;
rpipe-descr.bInterval = ep-desc.bInterval;
/* FIXME: bOverTheAirInterval */
rpipe-descr.bOverTheAirInterval = 0;   /* 0 if not isoc */
/* FIXME: xmit power  preamble blah blah */
-   rpipe-descr.bmAttribute = ep-desc.bmAttributes  0x03;
+   rpipe-descr.bmAttribute = (ep-desc.bmAttributes 
+   USB_ENDPOINT_XFERTYPE_MASK);
/* 

Re: [PATCH] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Greg Kroah-Hartman
On Wed, Jun 05, 2013 at 05:44:44PM +0200, Johan Hovold wrote:
 On Wed, Jun 05, 2013 at 08:33:56AM -0700, Greg KH wrote:
  On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
   Fix regression introduced by commit 143d9d9616 (USB: serial: add
   tiocmiwait subdriver operation) which made the ioctl operation return
   ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
   implementation is missing.
  
  Ah, maybe this is the problem I've been trying to track down, I'll queue
  it up and test it out now, thanks.
 
 What problem would that be? Let me know if it helps.

Hm, no, I think we have bigger problems here.  Can you use more than one
usb-serial device in the system right now on 3.10-rc4, with your
patches?  I plug in a 4 port edgeport device, and a 1 port pl2303
device, and no matter what /dev/ node I access (ttyUSB0-USB4), all the
data is sent to the port assigned to /dev/ttyUSB0.

I think I have all of my changes backed out of my kernel, that I have
been messing with in this area, but it would be good to get verification
from someone else right now, as I've been working on this for a few
hours now...

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] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Greg Kroah-Hartman
On Wed, Jun 05, 2013 at 10:12:19AM -0700, Greg Kroah-Hartman wrote:
 On Wed, Jun 05, 2013 at 05:44:44PM +0200, Johan Hovold wrote:
  On Wed, Jun 05, 2013 at 08:33:56AM -0700, Greg KH wrote:
   On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
Fix regression introduced by commit 143d9d9616 (USB: serial: add
tiocmiwait subdriver operation) which made the ioctl operation return
ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
implementation is missing.
   
   Ah, maybe this is the problem I've been trying to track down, I'll queue
   it up and test it out now, thanks.
  
  What problem would that be? Let me know if it helps.
 
 Hm, no, I think we have bigger problems here.  Can you use more than one
 usb-serial device in the system right now on 3.10-rc4, with your
 patches?  I plug in a 4 port edgeport device, and a 1 port pl2303
 device, and no matter what /dev/ node I access (ttyUSB0-USB4), all the
 data is sent to the port assigned to /dev/ttyUSB0.
 
 I think I have all of my changes backed out of my kernel, that I have
 been messing with in this area, but it would be good to get verification
 from someone else right now, as I've been working on this for a few
 hours now...

Ok, I can duplicate this with a 3.9.4 kernel from openSUSE, so something
has been broken for a while now.

Time to start bisecting...

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] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Greg Kroah-Hartman
On Wed, Jun 05, 2013 at 10:16:47AM -0700, Greg Kroah-Hartman wrote:
 On Wed, Jun 05, 2013 at 10:12:19AM -0700, Greg Kroah-Hartman wrote:
  On Wed, Jun 05, 2013 at 05:44:44PM +0200, Johan Hovold wrote:
   On Wed, Jun 05, 2013 at 08:33:56AM -0700, Greg KH wrote:
On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
 Fix regression introduced by commit 143d9d9616 (USB: serial: add
 tiocmiwait subdriver operation) which made the ioctl operation return
 ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
 implementation is missing.

Ah, maybe this is the problem I've been trying to track down, I'll queue
it up and test it out now, thanks.
   
   What problem would that be? Let me know if it helps.
  
  Hm, no, I think we have bigger problems here.  Can you use more than one
  usb-serial device in the system right now on 3.10-rc4, with your
  patches?  I plug in a 4 port edgeport device, and a 1 port pl2303
  device, and no matter what /dev/ node I access (ttyUSB0-USB4), all the
  data is sent to the port assigned to /dev/ttyUSB0.
  
  I think I have all of my changes backed out of my kernel, that I have
  been messing with in this area, but it would be good to get verification
  from someone else right now, as I've been working on this for a few
  hours now...
 
 Ok, I can duplicate this with a 3.9.4 kernel from openSUSE, so something
 has been broken for a while now.
 
 Time to start bisecting...

Ugh, it's a broken test script.  Nevermind, it's one of those weeks it
seems...

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] USB: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Johan Hovold
On Wed, Jun 05, 2013 at 10:12:19AM -0700, Greg KH wrote:
 On Wed, Jun 05, 2013 at 05:44:44PM +0200, Johan Hovold wrote:
  On Wed, Jun 05, 2013 at 08:33:56AM -0700, Greg KH wrote:
   On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
Fix regression introduced by commit 143d9d9616 (USB: serial: add
tiocmiwait subdriver operation) which made the ioctl operation return
ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
implementation is missing.
   
   Ah, maybe this is the problem I've been trying to track down, I'll queue
   it up and test it out now, thanks.
  
  What problem would that be? Let me know if it helps.
 
 Hm, no, I think we have bigger problems here.  Can you use more than one
 usb-serial device in the system right now on 3.10-rc4, with your
 patches?  I plug in a 4 port edgeport device, and a 1 port pl2303
 device, and no matter what /dev/ node I access (ttyUSB0-USB4), all the
 data is sent to the port assigned to /dev/ttyUSB0.
 
 I think I have all of my changes backed out of my kernel, that I have
 been messing with in this area, but it would be good to get verification
 from someone else right now, as I've been working on this for a few
 hours now...

I just verified that usb-linus and v3.10-rc4 are working with an ftdi
and a pl2303 device and a loop back test.

Johan
--
To unsubscribe from this list: send the line unsubscribe 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: serial: fix TIOCMIWAIT return value

2013-06-05 Thread Johan Hovold
On Wed, Jun 05, 2013 at 10:19:20AM -0700, Greg KH wrote:
 On Wed, Jun 05, 2013 at 10:16:47AM -0700, Greg Kroah-Hartman wrote:
  On Wed, Jun 05, 2013 at 10:12:19AM -0700, Greg Kroah-Hartman wrote:
   On Wed, Jun 05, 2013 at 05:44:44PM +0200, Johan Hovold wrote:
On Wed, Jun 05, 2013 at 08:33:56AM -0700, Greg KH wrote:
 On Wed, Jun 05, 2013 at 12:21:11PM +0200, Johan Hovold wrote:
  Fix regression introduced by commit 143d9d9616 (USB: serial: add
  tiocmiwait subdriver operation) which made the ioctl operation 
  return
  ENODEV rather than ENOIOCTLCMD when a subdriver TIOCMIWAIT
  implementation is missing.
 
 Ah, maybe this is the problem I've been trying to track down, I'll 
 queue
 it up and test it out now, thanks.

What problem would that be? Let me know if it helps.
   
   Hm, no, I think we have bigger problems here.  Can you use more than one
   usb-serial device in the system right now on 3.10-rc4, with your
   patches?  I plug in a 4 port edgeport device, and a 1 port pl2303
   device, and no matter what /dev/ node I access (ttyUSB0-USB4), all the
   data is sent to the port assigned to /dev/ttyUSB0.
   
   I think I have all of my changes backed out of my kernel, that I have
   been messing with in this area, but it would be good to get verification
   from someone else right now, as I've been working on this for a few
   hours now...
  
  Ok, I can duplicate this with a 3.9.4 kernel from openSUSE, so something
  has been broken for a while now.
  
  Time to start bisecting...
 
 Ugh, it's a broken test script.  Nevermind, it's one of those weeks it
 seems...

Hehe. Good to hear. ;)

Johan
--
To unsubscribe from this list: send the line unsubscribe 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/3] USB: serial: increase the number of devices we support

2013-06-05 Thread Greg KH
From: Greg Kroah-Hartman gre...@linuxfoundation.org

We had the limit of 255 USB to serial devices on one system for almost
15 years, with no complaints.  But now it's time to move on from these
tiny baby systems, and bump the number up to 3000, which should last
us a few more years.

Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

---
 drivers/usb/serial/usb-serial.c |8 ++--
 include/linux/usb/serial.h  |4 
 2 files changed, 6 insertions(+), 6 deletions(-)

--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -43,6 +43,10 @@
 #define DRIVER_AUTHOR Greg Kroah-Hartman gre...@linuxfoundation.org
 #define DRIVER_DESC USB Serial Driver core
 
+#define SERIAL_TTY_MAJOR   188
+#define SERIAL_TTY_MINORS  3000/* should be enough for a while */
+#define SERIAL_TTY_NO_MINOR(SERIAL_TTY_MINORS + 1)
+
 /* There is no MODULE_DEVICE_TABLE for usbserial.c.  Instead
the MODULE_DEVICE_TABLE declarations in each serial driver
cause the hotplug program to pull in whatever module is necessary
@@ -105,12 +109,12 @@ static int get_free_serial(struct usb_se
 
dev_dbg(serial-interface-dev, %s %d\n, __func__, num_ports);
 
-   *minor = 0x;
+   *minor = SERIAL_TTY_NO_MINOR;
for (i = 0; i  num_ports; ++i) {
x = get_free_port(serial-port[i]);
if (x  0)
goto error;
-   if (*minor == 0x)
+   if (*minor == SERIAL_TTY_NO_MINOR)
*minor = x;
serial-port[i]-port_number = i;
}
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -19,10 +19,6 @@
 #include linux/sysrq.h
 #include linux/kfifo.h
 
-#define SERIAL_TTY_MAJOR   188 /* Nice legal number now */
-#define SERIAL_TTY_MINORS  254 /* loads of devices :) */
-#define SERIAL_TTY_NO_MINOR0x  /* No minor was assigned */
-
 /* The maximum number of ports one device can grab at once */
 #define MAX_NUM_PORTS  8
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] USB: serial: make minor allocation dynamic

2013-06-05 Thread Greg KH
From: Greg Kroah-Hartman gre...@linuxfoundation.org

This moves the allocation of minor device numbers from a static array to
be dynamic, using the idr interface.  This means that you could
potentially get gaps in a minor number range for a single USB serial
device with multiple ports, but all should still work properly.

Note, we still have the limitation of 255 USB to serial devices in the
system, as that is all we are registering with the TTY layer at this
point in time.

Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

---
 drivers/usb/serial/usb-serial.c |   97 
 include/linux/usb/serial.h  |4 -
 2 files changed, 51 insertions(+), 50 deletions(-)

--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -37,6 +37,7 @@
 #include linux/usb.h
 #include linux/usb/serial.h
 #include linux/kfifo.h
+#include linux/idr.h
 #include pl2303.h
 
 #define DRIVER_AUTHOR Greg Kroah-Hartman gre...@linuxfoundation.org
@@ -49,7 +50,7 @@
drivers depend on it.
 */
 
-static struct usb_serial *serial_table[SERIAL_TTY_MINORS];
+static DEFINE_IDR(serial_minors);
 static DEFINE_MUTEX(table_lock);
 static LIST_HEAD(usb_serial_driver_list);
 
@@ -60,61 +61,65 @@ static LIST_HEAD(usb_serial_driver_list)
  */
 struct usb_serial *usb_serial_get_by_index(unsigned index)
 {
-   struct usb_serial *serial;
+   struct usb_serial *serial = NULL;
+   struct usb_serial_port *port;
 
mutex_lock(table_lock);
-   serial = serial_table[index];
+   port = idr_find(serial_minors, index);
+   if (!port)
+   goto exit;
 
-   if (serial) {
-   mutex_lock(serial-disc_mutex);
-   if (serial-disconnected) {
-   mutex_unlock(serial-disc_mutex);
-   serial = NULL;
-   } else {
-   kref_get(serial-kref);
-   }
+   serial = port-serial;
+   mutex_lock(serial-disc_mutex);
+   if (serial-disconnected) {
+   mutex_unlock(serial-disc_mutex);
+   serial = NULL;
+   } else {
+   kref_get(serial-kref);
}
+exit:
mutex_unlock(table_lock);
return serial;
 }
 
-static struct usb_serial *get_free_serial(struct usb_serial *serial,
-   int num_ports, unsigned int *minor)
+static int get_free_port(struct usb_serial_port *port)
 {
-   unsigned int i, j;
-   int good_spot;
-
-   dev_dbg(serial-interface-dev, %s %d\n, __func__, num_ports);
+   int i;
 
-   *minor = 0;
mutex_lock(table_lock);
-   for (i = 0; i  SERIAL_TTY_MINORS; ++i) {
-   if (serial_table[i])
-   continue;
+   i = idr_alloc(serial_minors, port, 0, 0, GFP_KERNEL);
+   if (i  0)
+   goto exit;
+   port-minor = i;
+exit:
+   mutex_unlock(table_lock);
+   return i;
+}
 
-   good_spot = 1;
-   for (j = 1; j = num_ports-1; ++j)
-   if ((i+j = SERIAL_TTY_MINORS) || (serial_table[i+j])) {
-   good_spot = 0;
-   i += j;
-   break;
-   }
-   if (good_spot == 0)
-   continue;
+static int get_free_serial(struct usb_serial *serial, int num_ports,
+  unsigned int *minor)
+{
+   unsigned int i;
+   unsigned int j;
+   int x;
 
-   *minor = i;
-   j = 0;
-   dev_dbg(serial-interface-dev, %s - minor base = %d\n, 
__func__, *minor);
-   for (i = *minor; (i  (*minor + num_ports))  (i  
SERIAL_TTY_MINORS); ++i, ++j) {
-   serial_table[i] = serial;
-   serial-port[j]-minor = i;
-   serial-port[j]-port_number = i - *minor;
-   }
-   mutex_unlock(table_lock);
-   return serial;
+   dev_dbg(serial-interface-dev, %s %d\n, __func__, num_ports);
+
+   *minor = 0x;
+   for (i = 0; i  num_ports; ++i) {
+   x = get_free_port(serial-port[i]);
+   if (x  0)
+   goto error;
+   if (*minor == 0x)
+   *minor = x;
+   serial-port[i]-port_number = i;
}
-   mutex_unlock(table_lock);
-   return NULL;
+   return 0;
+error:
+   /* unwind the already allocated minors */
+   for (j = 0; j  i; ++j)
+   idr_remove(serial_minors, serial-port[j]-minor);
+   return x;
 }
 
 static void return_serial(struct usb_serial *serial)
@@ -123,7 +128,7 @@ static void return_serial(struct usb_ser
 
mutex_lock(table_lock);
for (i = 0; i  serial-num_ports; ++i)
-   serial_table[serial-minor + i] = NULL;
+   idr_remove(serial_minors, serial-port[i]-minor);

[PATCH 0/3] Increase the number of USB to serial devices we can support at once

2013-06-05 Thread Greg KH
Here are 3 patches that I've tested out on my system with only a small
number of devices, but it seems to work, so why not let others try it
out...

These patches make the USB to serial core have the ability to support up
to 3000 devices at once now.  We do this in the following steps:
- adding the minor number to the usb_serial_port structure
- removing the static array of ports, and use idr instead
- increasing the number

Now, if you pay attention, we end up taking up more runtime memory than
before, because we are asking the tty layer to reserve a bunch more tty
devices for us, negating the potential savings of getting rid of our
original static array.  I'll work on fixing up the tty layer calls to
properly allocate the tty devices only when we need them, much like the
pty layer does.  When that's done, we can bump the number of usb to
serial devices up to 16k with no memory problems.

This series is based on my usb-linus branch on my usb.git tree on
git.kernel.org, as I needed some of the usb-serial fixes that are in
that branch already.

Testing / review is most welcome.

thanks,

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


[PATCH 1/3] USB: serial: ports: add minor and port number

2013-06-05 Thread Greg KH
From: Greg Kroah-Hartman gre...@linuxfoundation.org

The usb_serial_port structure had the number field, which was the minor
number for the port, which almost no one really cared about.  They
really wanted the number of the port within the device, which you had to
subtract from the minor of the parent usb_serial_device structure.  To
clean this up, provide the real minor number of the port, and the number
of the port within the serial device separately, as these numbers might
not be related in the future.

Bonus is that this cleans up a lot of logic in the drivers, and saves
lines overall.

Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

--
 drivers/staging/serqt_usb2/serqt_usb2.c |   21 +++
 drivers/usb/serial/ark3116.c|2 -
 drivers/usb/serial/bus.c|6 +--
 drivers/usb/serial/console.c|2 -
 drivers/usb/serial/cp210x.c |2 -
 drivers/usb/serial/cypress_m8.c |4 +-
 drivers/usb/serial/digi_acceleport.c|6 ---
 drivers/usb/serial/f81232.c |5 +-
 drivers/usb/serial/garmin_gps.c |6 +--
 drivers/usb/serial/io_edgeport.c|   60 
 drivers/usb/serial/io_ti.c  |   21 ---
 drivers/usb/serial/keyspan.c|   29 ++-
 drivers/usb/serial/metro-usb.c  |4 +-
 drivers/usb/serial/mos7720.c|   37 +--
 drivers/usb/serial/mos7840.c|   52 +--
 drivers/usb/serial/opticon.c|2 -
 drivers/usb/serial/pl2303.c |2 -
 drivers/usb/serial/quatech2.c   |7 +--
 drivers/usb/serial/sierra.c |2 -
 drivers/usb/serial/ti_usb_3410_5052.c   |   10 ++---
 drivers/usb/serial/usb-serial.c |7 ++-
 drivers/usb/serial/usb_wwan.c   |2 -
 drivers/usb/serial/whiteheat.c  |   20 +-
 include/linux/usb/serial.h  |6 ++-
 24 files changed, 134 insertions(+), 181 deletions(-)

--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -873,7 +873,7 @@ static int qt_open(struct tty_struct *tt
result = qt_get_device(serial, port0-DeviceData);
 
/* Port specific setups */
-   result = qt_open_channel(serial, port-number, ChannelData);
+   result = qt_open_channel(serial, port-port_number, ChannelData);
if (result  0) {
dev_dbg(port-dev, qt_open_channel failed\n);
return result;
@@ -888,7 +888,7 @@ static int qt_open(struct tty_struct *tt
(SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_CD);
 
/* Set Baud rate to default and turn off (default)flow control here */
-   result = qt_setuart(serial, port-number, DEFAULT_DIVISOR, DEFAULT_LCR);
+   result = qt_setuart(serial, port-port_number, DEFAULT_DIVISOR, 
DEFAULT_LCR);
if (result  0) {
dev_dbg(port-dev, qt_setuart failed\n);
return result;
@@ -906,7 +906,6 @@ static int qt_open(struct tty_struct *tt
qt_submit_urb_from_open(serial, port);
}
 
-   dev_dbg(port-dev, port number is %d\n, port-number);
dev_dbg(port-dev, serial number is %d\n, port-serial-minor);
dev_dbg(port-dev,
Bulkin endpoint is %d\n, port-bulk_in_endpointAddress);
@@ -1022,14 +1021,11 @@ static void qt_close(struct usb_serial_p
/* Close uart channel */
status = qt_close_channel(serial, index);
if (status  0)
-   dev_dbg(port-dev,
-   %s - port %d qt_close_channel failed.\n,
-   __func__, port-number);
+   dev_dbg(port-dev, %s - qt_close_channel failed.\n, 
__func__);
 
port0-open_ports--;
 
-   dev_dbg(port-dev, qt_num_open_ports in close%d:in port%d\n,
-   port0-open_ports, port-number);
+   dev_dbg(port-dev, qt_num_open_ports in close%d\n, 
port0-open_ports);
 
if (port0-open_ports == 0) {
if (serial-port[0]-interrupt_in_urb) {
@@ -1169,8 +1165,7 @@ static int qt_ioctl(struct tty_struct *t
return 0;
}
 
-   dev_dbg(port-dev, %s -No ioctl for that one.  port = %d\n,
-   __func__, port-number);
+   dev_dbg(port-dev, %s -No ioctl for that one.\n, __func__);
return -ENOIOCTLCMD;
 }
 
@@ -1245,8 +1240,7 @@ static void qt_set_termios(struct tty_st
 
/* Now determine flow control */
if (cflag  CRTSCTS) {
-   dev_dbg(port-dev, %s - Enabling HW flow control port %d\n,
-   __func__, port-number);
+   dev_dbg(port-dev, %s - Enabling HW flow control\n, 
__func__);
 
/* Enable RTS/CTS flow control */
status = BoxSetHW_FlowCtrl(port-serial, index, 1);
@@ -1258,8 +1252,7 @@ static void qt_set_termios(struct tty_st
} else {
   

[PATCH V3 5/7] USB: EHCI: tegra: fix circular module dependencies

2013-06-05 Thread Stephen Warren
From: Stephen Warren swar...@nvidia.com

The Tegra EHCI driver directly calls various functions in the Tegra USB
PHY driver. The reverse is also true; the PHY driver calls into the EHCI
driver. This is problematic when the two are built as modules.

The calls from the PHY to EHCI driver were originally added in commit
bbdabdb usb: add APIs to access host registers from Tegra PHY, for the
following reasons:

1) The register being touched is an EHCI register, so logically only the
   EHCI driver should touch it.
2) (1) implies that some locking may be needed to correctly implement the
   r/m/w access to this shared register.
3) We were expecting to pass only the PHY register space to the Tegra PHY
   driver, and hence it would not have access to touch the shared
   registers.

To solve this, that commit added functions in the EHCI driver to touch the
shared register on behalf of the PHY driver.

In practice, we ended up not having any locking in the implementaiton of
those functions, and I've been led to believe this is safe. Equally, (3)
did not happen either. Hence, it is possible for the PHY driver to touch
the shared register directly.

Given that, this patch moves the code to touch the shared register back
into the PHY driver, to eliminate the module problems. If we actually
need locking or co-ordination in the future, I propose we put the lock
support into some pre-existing core module, or into a third separate
module, in order to avoid the circular dependencies.

I apologize for my contribution to code churn here.

Signed-off-by: Stephen Warren swar...@nvidia.com
Acked-by: Alan Stern st...@rowland.harvard.edu
Acked-by: Arnd Bergmann a...@arndb.de
---
v3: No change.
v2: No change; just rebased on new versions of earlier patches.
---
 drivers/usb/host/ehci-tegra.c | 36 
 drivers/usb/phy/phy-tegra-usb.c   | 39 ---
 include/linux/usb/tegra_usb_phy.h |  4 
 3 files changed, 36 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index dde5189..8063429 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -34,11 +34,6 @@
 #define TEGRA_USB2_BASE0xC5004000
 #define TEGRA_USB3_BASE0xC5008000
 
-/* PORTSC registers */
-#define TEGRA_USB_PORTSC1  0x184
-#define TEGRA_USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
-#define TEGRA_USB_PORTSC1_PHCD (1  23)
-
 #define TEGRA_USB_DMA_ALIGN 32
 
 struct tegra_ehci_hcd {
@@ -380,37 +375,6 @@ static int setup_vbus_gpio(struct platform_device *pdev,
return err;
 }
 
-/* Bits of PORTSC1, which will get cleared by writing 1 into them */
-#define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
-
-void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
-{
-   unsigned long val;
-   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
-   void __iomem *base = hcd-regs;
-
-   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
-   val = ~TEGRA_USB_PORTSC1_PTS(3);
-   val |= TEGRA_USB_PORTSC1_PTS(pts_val  3);
-   writel(val, base + TEGRA_USB_PORTSC1);
-}
-EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
-
-void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
-{
-   unsigned long val;
-   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
-   void __iomem *base = hcd-regs;
-
-   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
-   if (enable)
-   val |= TEGRA_USB_PORTSC1_PHCD;
-   else
-   val = ~TEGRA_USB_PORTSC1_PHCD;
-   writel(val, base + TEGRA_USB_PORTSC1);
-}
-EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
-
 static int tegra_ehci_probe(struct platform_device *pdev)
 {
struct resource *res;
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index f0727f2..3446245 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -32,11 +32,20 @@
 #include linux/usb/otg.h
 #include linux/usb/ulpi.h
 #include asm/mach-types.h
+#include linux/usb/ehci_def.h
 #include linux/usb/tegra_usb_phy.h
 #include linux/module.h
 
 #define ULPI_VIEWPORT  0x170
 
+/* PORTSC registers */
+#define TEGRA_USB_PORTSC1  0x184
+#define TEGRA_USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
+#define TEGRA_USB_PORTSC1_PHCD (1  23)
+
+/* Bits of PORTSC1, which will get cleared by writing 1 into them */
+#define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
+
 #define USB_SUSP_CTRL  0x400
 #define   USB_WAKE_ON_CNNT_EN_DEV  (1  3)
 #define   USB_WAKE_ON_DISCON_EN_DEV(1  4)
@@ -197,6 +206,30 @@ static struct tegra_utmip_config utmip_default[] = {
},
 };
 
+static void set_pts(struct tegra_usb_phy *phy, u8 pts_val)
+{
+   void __iomem *base = phy-regs;
+   unsigned long val;
+
+   val = readl(base + TEGRA_USB_PORTSC1)  

[PATCH V3 1/7] usb: phy: export ulpi_viewport_access_ops

2013-06-05 Thread Stephen Warren
From: Manjunath Goudar manjunath.gou...@linaro.org

In order to build a ULPI PHY driver as a module, this symbol needs to
be exported.

Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org
[swarren, reworked Manjunath's patches to split them more logically]
Signed-off-by: Stephen Warren swar...@nvidia.com
Acked-by: Arnd Bergmann a...@arndb.de
---
v3: No change.
v2: Include export.h not module.h
---
 drivers/usb/phy/phy-ulpi-viewport.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/phy/phy-ulpi-viewport.c 
b/drivers/usb/phy/phy-ulpi-viewport.c
index c5ba7e5..7c22a539 100644
--- a/drivers/usb/phy/phy-ulpi-viewport.c
+++ b/drivers/usb/phy/phy-ulpi-viewport.c
@@ -12,6 +12,7 @@
  *
  */
 
+#include linux/export.h
 #include linux/kernel.h
 #include linux/usb.h
 #include linux/io.h
@@ -78,3 +79,4 @@ struct usb_phy_io_ops ulpi_viewport_access_ops = {
.read   = ulpi_viewport_read,
.write  = ulpi_viewport_write,
 };
+EXPORT_SYMBOL_GPL(ulpi_viewport_access_ops);
-- 
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 V3 2/7] usb: phy: add MODULE_LICENSE to phy-tegra-usb.c

2013-06-05 Thread Stephen Warren
From: Stephen Warren swar...@nvidia.com

When this file is built as a module, it needs a MODULE_LICENSE in order
to access many exported symbols.

Signed-off-by: Stephen Warren swar...@nvidia.com
Acked-by: Arnd Bergmann a...@arndb.de
---
v3: No change.
v2: No change.
---
 drivers/usb/phy/phy-tegra-usb.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 5d9af11..f0727f2 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -23,6 +23,7 @@
 #include linux/slab.h
 #include linux/err.h
 #include linux/export.h
+#include linux/module.h
 #include linux/platform_device.h
 #include linux/io.h
 #include linux/gpio.h
@@ -869,3 +870,6 @@ struct usb_phy *tegra_usb_get_phy(struct device_node *dn)
return tegra_phy-u_phy;
 }
 EXPORT_SYMBOL_GPL(tegra_usb_get_phy);
+
+MODULE_DESCRIPTION(Tegra USB PHY driver);
+MODULE_LICENSE(GPL v2);
-- 
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 V3 0/7] USB: make ehci-tegra its own module

2013-06-05 Thread Stephen Warren
From: Stephen Warren swar...@nvidia.com

ehci-tegra is currently built into the main ehci-hcd driver, rather than
being a separate module. This causes issues with multi-platform ARM
kernels. This series separates ehci-tegra into its own module to avoid
those problems.

Manjunath Goudar originally wrote most of this series. I've since cleaned
it up, rebased it on Venu's recent changes to the Tegra USB driver, and
tested it.

Note that I expect this series will need to go through the USB PHY tree,
since it builds upon Venu's recent changes to the Tegra USB driver, which
were applied there.

Manjunath Goudar (3):
  usb: phy: export ulpi_viewport_access_ops
  USB: EHCI: export ehci_handshake for ehci-hcd sub-drivers
  USB: EHCI: make ehci-tegra a separate driver

Stephen Warren (4):
  usb: phy: add MODULE_LICENSE to phy-tegra-usb.c
  USB: EHCI: tegra: remove all power management
  USB: EHCI: tegra: fix circular module dependencies
  USB: EHCI: tegra: make use of ehci-priv

 drivers/usb/host/Kconfig|   2 +-
 drivers/usb/host/Makefile   |   1 +
 drivers/usb/host/ehci-hcd.c |  22 +-
 drivers/usb/host/ehci-hub.c |   4 +-
 drivers/usb/host/ehci-tegra.c   | 474 
 drivers/usb/host/ehci.h |   2 +
 drivers/usb/phy/phy-tegra-usb.c |  43 +++-
 drivers/usb/phy/phy-ulpi-viewport.c |   2 +
 include/linux/usb/tegra_usb_phy.h   |   4 -
 9 files changed, 165 insertions(+), 389 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 V3 3/7] USB: EHCI: export ehci_handshake for ehci-hcd sub-drivers

2013-06-05 Thread Stephen Warren
From: Manjunath Goudar manjunath.gou...@linaro.org

In order to split ehci-hcd.c into separate modules, handshake() must be
exported. Rename the symbol to add an ehci_ prefix, to avoid any naming
clashes.

Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org
[swarren, split Manjunath's patches more logically, limit this change
to export just handshake()]
Signed-off-by: Stephen Warren swar...@nvidia.com
Acked-by: Alan Stern st...@rowland.harvard.edu
Acked-by: Arnd Bergmann a...@arndb.de
---
v3: No change.
v2: Only export handshake(), not reset/tdi_reset/halt.
---
 drivers/usb/host/ehci-hcd.c   | 17 ++---
 drivers/usb/host/ehci-hub.c   |  4 ++--
 drivers/usb/host/ehci-tegra.c | 12 ++--
 drivers/usb/host/ehci.h   |  2 ++
 4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 246e124..e8a6f3d 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -139,7 +139,7 @@ static inline unsigned ehci_read_frame_index(struct 
ehci_hcd *ehci)
 /*-*/
 
 /*
- * handshake - spin reading hc until handshake completes or fails
+ * ehci_handshake - spin reading hc until handshake completes or fails
  * @ptr: address of hc register to be read
  * @mask: bits to look at in result of read
  * @done: value of those bits when handshake succeeds
@@ -155,8 +155,8 @@ static inline unsigned ehci_read_frame_index(struct 
ehci_hcd *ehci)
  * before driver shutdown. But it also seems to be caused by bugs in cardbus
  * bridge shutdown:  shutting down the bridge before the devices using it.
  */
-static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
- u32 mask, u32 done, int usec)
+int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr,
+  u32 mask, u32 done, int usec)
 {
u32 result;
 
@@ -172,6 +172,7 @@ static int handshake (struct ehci_hcd *ehci, void __iomem 
*ptr,
} while (usec  0);
return -ETIMEDOUT;
 }
+EXPORT_SYMBOL_GPL(ehci_handshake);
 
 /* check TDI/ARC silicon is in host mode */
 static int tdi_in_host_mode (struct ehci_hcd *ehci)
@@ -212,7 +213,7 @@ static int ehci_halt (struct ehci_hcd *ehci)
spin_unlock_irq(ehci-lock);
synchronize_irq(ehci_to_hcd(ehci)-irq);
 
-   return handshake(ehci, ehci-regs-status,
+   return ehci_handshake(ehci, ehci-regs-status,
  STS_HALT, STS_HALT, 16 * 125);
 }
 
@@ -251,7 +252,7 @@ static int ehci_reset (struct ehci_hcd *ehci)
ehci_writel(ehci, command, ehci-regs-command);
ehci-rh_state = EHCI_RH_HALTED;
ehci-next_statechange = jiffies;
-   retval = handshake (ehci, ehci-regs-command,
+   retval = ehci_handshake(ehci, ehci-regs-command,
CMD_RESET, 0, 250 * 1000);
 
if (ehci-has_hostpc) {
@@ -286,7 +287,8 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
 
/* wait for any schedule enables/disables to take effect */
temp = (ehci-command  10)  (STS_ASS | STS_PSS);
-   handshake(ehci, ehci-regs-status, STS_ASS | STS_PSS, temp, 16 * 125);
+   ehci_handshake(ehci, ehci-regs-status, STS_ASS | STS_PSS, temp,
+   16 * 125);
 
/* then disable anything that's still active */
spin_lock_irq(ehci-lock);
@@ -295,7 +297,8 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
spin_unlock_irq(ehci-lock);
 
/* hardware can take 16 microframes to turn off ... */
-   handshake(ehci, ehci-regs-status, STS_ASS | STS_PSS, 0, 16 * 125);
+   ehci_handshake(ehci, ehci-regs-status, STS_ASS | STS_PSS, 0,
+   16 * 125);
 }
 
 /*-*/
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index b2f6450..2b70277 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -892,7 +892,7 @@ static int ehci_hub_control (
PORT_SUSPEND | PORT_RESUME);
ehci_writel(ehci, temp, status_reg);
clear_bit(wIndex, ehci-resuming_ports);
-   retval = handshake(ehci, status_reg,
+   retval = ehci_handshake(ehci, status_reg,
   PORT_RESUME, 0, 2000 /* 2msec */);
if (retval != 0) {
ehci_err(ehci,
@@ -918,7 +918,7 @@ static int ehci_hub_control (
/* REVISIT:  some hardware needs 550+ usec to clear
 * this bit; seems too long to spin routinely...
 */
-   retval = handshake(ehci, status_reg,
+   retval = ehci_handshake(ehci, status_reg,
   

[PATCH V3 4/7] USB: EHCI: tegra: remove all power management

2013-06-05 Thread Stephen Warren
From: Stephen Warren swar...@nvidia.com

The PM routines in ehci-tegra.c use APIs such as ehci_reset(),
ehci_halt(), and ehci_tdi_reset() that would need to be exported to
convert ehci-tegra.c into a separate module from ehci-hcd.c. However,
we'd prefer not to export them.

Instead, simply remove all power management functionality. Runtime PM
was disabled since it didn't work correctly, and system suspend isn't
yet supported in a meaningful way. So, this change doesn't lose any
functionality.

Hopefully the power management logic can be reimplemented in a cleaner
way in the future.

Signed-off-by: Stephen Warren swar...@nvidia.com
Acked-by: Arnd Bergmann a...@arndb.de
---
v3:
* Also remove tegra_ehci_power_up(), tegra_ehci_shutdown(), struct
  tegra_ehci_hcd.host_resumed.
* Add back .bus_{suspend,resume} entries in tegra_ehci_hc_driver.
v2: New patch.
---
 drivers/usb/host/ehci-tegra.c | 246 +-
 1 file changed, 1 insertion(+), 245 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 289b9b8..dde5189 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -46,30 +46,11 @@ struct tegra_ehci_hcd {
struct tegra_usb_phy *phy;
struct clk *clk;
struct usb_phy *transceiver;
-   int host_resumed;
int port_resuming;
bool needs_double_reset;
enum tegra_usb_phy_port_speed port_speed;
 };
 
-static void tegra_ehci_power_up(struct usb_hcd *hcd)
-{
-   struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
-
-   clk_prepare_enable(tegra-clk);
-   usb_phy_set_suspend(hcd-phy, 0);
-   tegra-host_resumed = 1;
-}
-
-static void tegra_ehci_power_down(struct usb_hcd *hcd)
-{
-   struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
-
-   tegra-host_resumed = 0;
-   usb_phy_set_suspend(hcd-phy, 1);
-   clk_disable_unprepare(tegra-clk);
-}
-
 static int tegra_ehci_internal_port_reset(
struct ehci_hcd *ehci,
u32 __iomem *portsc_reg
@@ -248,39 +229,6 @@ done:
return retval;
 }
 
-static void tegra_ehci_restart(struct usb_hcd *hcd)
-{
-   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-
-   ehci_reset(ehci);
-
-   /* setup the frame list and Async q heads */
-   ehci_writel(ehci, ehci-periodic_dma, ehci-regs-frame_list);
-   ehci_writel(ehci, (u32)ehci-async-qh_dma, ehci-regs-async_next);
-   /* setup the command register and set the controller in RUN mode */
-   ehci-command = ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
-   ehci-command |= CMD_RUN;
-   ehci_writel(ehci, ehci-command, ehci-regs-command);
-
-   down_write(ehci_cf_port_reset_rwsem);
-   ehci_writel(ehci, FLAG_CF, ehci-regs-configured_flag);
-   /* flush posted writes */
-   ehci_readl(ehci, ehci-regs-command);
-   up_write(ehci_cf_port_reset_rwsem);
-}
-
-static void tegra_ehci_shutdown(struct usb_hcd *hcd)
-{
-   struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
-
-   /* ehci_shutdown touches the USB controller registers, make sure
-* controller has clocks to it */
-   if (!tegra-host_resumed)
-   tegra_ehci_power_up(hcd);
-
-   ehci_shutdown(hcd);
-}
-
 static int tegra_ehci_setup(struct usb_hcd *hcd)
 {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
@@ -395,7 +343,7 @@ static const struct hc_driver tegra_ehci_hc_driver = {
 
/* modified ehci functions for tegra */
.reset  = tegra_ehci_setup,
-   .shutdown   = tegra_ehci_shutdown,
+   .shutdown   = ehci_shutdown,
.map_urb_for_dma= tegra_ehci_map_urb_for_dma,
.unmap_urb_for_dma  = tegra_ehci_unmap_urb_for_dma,
.hub_control= tegra_ehci_hub_control,
@@ -432,182 +380,6 @@ static int setup_vbus_gpio(struct platform_device *pdev,
return err;
 }
 
-#ifdef CONFIG_PM
-
-static int controller_suspend(struct device *dev)
-{
-   struct tegra_ehci_hcd *tegra =
-   platform_get_drvdata(to_platform_device(dev));
-   struct ehci_hcd *ehci = tegra-ehci;
-   struct usb_hcd *hcd = ehci_to_hcd(ehci);
-   struct ehci_regs __iomem *hw = ehci-regs;
-   unsigned long flags;
-
-   if (time_before(jiffies, ehci-next_statechange))
-   msleep(10);
-
-   ehci_halt(ehci);
-
-   spin_lock_irqsave(ehci-lock, flags);
-   tegra-port_speed = (readl(hw-port_status[0])  26)  0x3;
-   clear_bit(HCD_FLAG_HW_ACCESSIBLE, hcd-flags);
-   spin_unlock_irqrestore(ehci-lock, flags);
-
-   tegra_ehci_power_down(hcd);
-   return 0;
-}
-
-static int controller_resume(struct device *dev)
-{
-   struct tegra_ehci_hcd *tegra =
-   platform_get_drvdata(to_platform_device(dev));
-   struct ehci_hcd *ehci = tegra-ehci;
-   struct usb_hcd *hcd = ehci_to_hcd(ehci);
-   struct 

[PATCH V3 7/7] USB: EHCI: tegra: make use of ehci-priv

2013-06-05 Thread Stephen Warren
From: Stephen Warren swar...@nvidia.com

Rather than allocating struct tegra_ehci_hcd separately, use struct
ehci_hcd's priv field instead.

Signed-off-by: Stephen Warren swar...@nvidia.com
---
v3: New patch.
---
 drivers/usb/host/ehci-tegra.c | 70 +--
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 338c8a5..8dac5e4 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -56,7 +56,6 @@ static int (*orig_hub_control)(struct usb_hcd *hcd,
char *buf, u16 wLength);
 
 struct tegra_ehci_hcd {
-   struct ehci_hcd *ehci;
struct tegra_usb_phy *phy;
struct clk *clk;
struct usb_phy *transceiver;
@@ -139,8 +138,8 @@ static int tegra_ehci_hub_control(
u16 wLength
 )
 {
-   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-   struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
+   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   struct tegra_ehci_hcd *tegra = (struct tegra_ehci_hcd *)ehci-priv;
u32 __iomem *status_reg;
u32 temp;
unsigned long   flags;
@@ -354,6 +353,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 {
struct resource *res;
struct usb_hcd *hcd;
+   struct ehci_hcd *ehci;
struct tegra_ehci_hcd *tegra;
struct tegra_ehci_platform_data *pdata;
int err = 0;
@@ -378,20 +378,29 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
setup_vbus_gpio(pdev, pdata);
 
-   tegra = devm_kzalloc(pdev-dev, sizeof(struct tegra_ehci_hcd),
-GFP_KERNEL);
-   if (!tegra)
-   return -ENOMEM;
+   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;
+   }
+   platform_set_drvdata(pdev, hcd);
+   ehci = hcd_to_ehci(hcd);
+   tegra = (struct tegra_ehci_hcd *)ehci-priv;
+
+   hcd-has_tt = 1;
 
tegra-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(tegra-clk)) {
dev_err(pdev-dev, Can't get ehci clock\n);
-   return PTR_ERR(tegra-clk);
+   err = PTR_ERR(tegra-clk);
+   goto cleanup_hcd_create;
}
 
err = clk_prepare_enable(tegra-clk);
if (err)
-   return err;
+   goto cleanup_clk_get;
 
tegra_periph_reset_assert(tegra-clk);
udelay(1);
@@ -400,35 +409,24 @@ static int tegra_ehci_probe(struct platform_device *pdev)
np_phy = of_parse_phandle(pdev-dev.of_node, nvidia,phy, 0);
if (!np_phy) {
err = -ENODEV;
-   goto cleanup_clk;
+   goto cleanup_clk_en;
}
 
u_phy = tegra_usb_get_phy(np_phy);
if (IS_ERR(u_phy)) {
err = PTR_ERR(u_phy);
-   goto cleanup_clk;
+   goto cleanup_clk_en;
}
+   hcd-phy = u_phy;
 
tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
nvidia,needs-double-reset);
 
-   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_clk;
-   }
-   tegra-ehci = hcd_to_ehci(hcd);
-
-   hcd-has_tt = 1;
-   hcd-phy = u_phy;
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(pdev-dev, Failed to get I/O memory\n);
err = -ENXIO;
-   goto cleanup_hcd_create;
+   goto cleanup_clk_en;
}
hcd-rsrc_start = res-start;
hcd-rsrc_len = resource_size(res);
@@ -436,14 +434,14 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!hcd-regs) {
dev_err(pdev-dev, Failed to remap I/O memory\n);
err = -ENOMEM;
-   goto cleanup_hcd_create;
+   goto cleanup_clk_en;
}
-   tegra-ehci-caps = hcd-regs + 0x100;
+   ehci-caps = hcd-regs + 0x100;
 
err = usb_phy_init(hcd-phy);
if (err) {
dev_err(pdev-dev, Failed to initialize phy\n);
-   goto cleanup_hcd_create;
+   goto cleanup_clk_en;
}
 
u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
@@ -477,8 +475,6 @@ static int tegra_ehci_probe(struct platform_device *pdev)
tegra-transceiver = ERR_PTR(-ENODEV);
}
 
-   platform_set_drvdata(pdev, tegra);
-
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err) {
dev_err(pdev-dev, 

[PATCH V3 6/7] USB: EHCI: make ehci-tegra a separate driver

2013-06-05 Thread Stephen Warren
From: Manjunath Goudar manjunath.gou...@linaro.org

Separate the Tegra on-chip host controller driver from
ehci-hcd host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM.

Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org
[swarren, reworked Manjunath's patches to split them more logically,
minor re-order of added lines to better match layout of other split-up
HCD drivers and existing code, add MODULE_DEVICE_TABLE, fix
MODULE_LICENSE, adapted to change in earlier patches which removed the
ehci_driver_overrides addition, removed all PM code and solved circular
dependencies.]
Signed-off-by: Stephen Warren swar...@nvidia.com
Acked-by: Arnd Bergmann a...@arndb.de
---
v3:
* Removed use of tegra_ehci_power_up() from egra_ehci_hcd_shutdown().
* Made tegra_overrides const/initconst not initdata.
* Added comment re: need for overrides in ehci_tegra_init().
v2:
* Set non-standard fields in tegra_ehci_hc_driver manually, rather than
  relying on an expanded struct ehci_driver_overrides.
* Save orig_hub_control rather than relying on ehci_hub_control being
  exported.
* Rebased on new versions of earlier patches.
---
 drivers/usb/host/Kconfig  |   2 +-
 drivers/usb/host/Makefile |   1 +
 drivers/usb/host/ehci-hcd.c   |   5 --
 drivers/usb/host/ehci-tegra.c | 128 --
 4 files changed, 76 insertions(+), 60 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index cb4b83b..5c049eb 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -200,7 +200,7 @@ config USB_EHCI_MSM
  has an external PHY.
 
 config USB_EHCI_TEGRA
-   boolean NVIDIA Tegra HCD support
+   tristate NVIDIA Tegra HCD support
depends on ARCH_TEGRA
select USB_EHCI_ROOT_HUB_TT
select USB_PHY
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index b41fa5f..bea7112 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_USB_EHCI_HCD_SPEAR)  += ehci-spear.o
 obj-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o
 obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
 obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o
+obj-$(CONFIG_USB_EHCI_TEGRA)   += ehci-tegra.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index e8a6f3d..7abf1ce 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1269,11 +1269,6 @@ MODULE_LICENSE (GPL);
 #definePLATFORM_DRIVER ehci_hcd_msp_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_TEGRA
-#include ehci-tegra.c
-#define PLATFORM_DRIVERtegra_ehci_driver
-#endif
-
 #ifdef CONFIG_SPARC_LEON
 #include ehci-grlib.c
 #define PLATFORM_DRIVERehci_grlib_driver
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 8063429..338c8a5 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -17,25 +17,44 @@
  */
 
 #include linux/clk.h
+#include linux/clk/tegra.h
+#include linux/dma-mapping.h
 #include linux/err.h
-#include linux/platform_device.h
-#include linux/platform_data/tegra_usb.h
-#include linux/irq.h
-#include linux/usb/otg.h
 #include linux/gpio.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/module.h
 #include linux/of.h
 #include linux/of_gpio.h
+#include linux/platform_device.h
+#include linux/platform_data/tegra_usb.h
 #include linux/pm_runtime.h
+#include linux/slab.h
 #include linux/usb/ehci_def.h
 #include linux/usb/tegra_usb_phy.h
-#include linux/clk/tegra.h
+#include linux/usb.h
+#include linux/usb/hcd.h
+#include linux/usb/otg.h
+
+#include ehci.h
 
 #define TEGRA_USB_BASE 0xC500
 #define TEGRA_USB2_BASE0xC5004000
 #define TEGRA_USB3_BASE0xC5008000
 
+#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
+
 #define TEGRA_USB_DMA_ALIGN 32
 
+#define DRIVER_DESC Tegra EHCI driver
+#define DRV_NAME tegra-ehci
+
+static struct hc_driver __read_mostly tegra_ehci_hc_driver;
+
+static int (*orig_hub_control)(struct usb_hcd *hcd,
+   u16 typeReq, u16 wValue, u16 wIndex,
+   char *buf, u16 wLength);
+
 struct tegra_ehci_hcd {
struct ehci_hcd *ehci;
struct tegra_usb_phy *phy;
@@ -218,25 +237,13 @@ static int tegra_ehci_hub_control(
spin_unlock_irqrestore(ehci-lock, flags);
 
/* Handle the hub control events here */
-   return ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
+   return orig_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
+
 done:
spin_unlock_irqrestore(ehci-lock, flags);
return retval;
 }
 
-static int tegra_ehci_setup(struct usb_hcd *hcd)
-{
-   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-
-   /* EHCI 

Re: [PATCH V3 4/7] USB: EHCI: tegra: remove all power management

2013-06-05 Thread Alan Stern
On Wed, 5 Jun 2013, Stephen Warren wrote:

 From: Stephen Warren swar...@nvidia.com
 
 The PM routines in ehci-tegra.c use APIs such as ehci_reset(),
 ehci_halt(), and ehci_tdi_reset() that would need to be exported to
 convert ehci-tegra.c into a separate module from ehci-hcd.c. However,
 we'd prefer not to export them.
 
 Instead, simply remove all power management functionality. Runtime PM
 was disabled since it didn't work correctly, and system suspend isn't
 yet supported in a meaningful way. So, this change doesn't lose any
 functionality.
 
 Hopefully the power management logic can be reimplemented in a cleaner
 way in the future.
 
 Signed-off-by: Stephen Warren swar...@nvidia.com
 Acked-by: Arnd Bergmann a...@arndb.de
 ---
 v3:
 * Also remove tegra_ehci_power_up(), tegra_ehci_shutdown(), struct
   tegra_ehci_hcd.host_resumed.
 * Add back .bus_{suspend,resume} entries in tegra_ehci_hc_driver.
 v2: New patch.

Acked-by: Alan Stern st...@rowland.harvard.edu

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


Re: [PATCH V3 6/7] USB: EHCI: make ehci-tegra a separate driver

2013-06-05 Thread Alan Stern
On Wed, 5 Jun 2013, Stephen Warren wrote:

 From: Manjunath Goudar manjunath.gou...@linaro.org
 
 Separate the Tegra on-chip host controller driver from
 ehci-hcd host code so that it can be built as a separate driver module.
 This work is part of enabling multi-platform kernels on ARM.
 
 Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org
 [swarren, reworked Manjunath's patches to split them more logically,
 minor re-order of added lines to better match layout of other split-up
 HCD drivers and existing code, add MODULE_DEVICE_TABLE, fix
 MODULE_LICENSE, adapted to change in earlier patches which removed the
 ehci_driver_overrides addition, removed all PM code and solved circular
 dependencies.]
 Signed-off-by: Stephen Warren swar...@nvidia.com
 Acked-by: Arnd Bergmann a...@arndb.de
 ---
 v3:
 * Removed use of tegra_ehci_power_up() from egra_ehci_hcd_shutdown().
 * Made tegra_overrides const/initconst not initdata.
 * Added comment re: need for overrides in ehci_tegra_init().
 v2:
 * Set non-standard fields in tegra_ehci_hc_driver manually, rather than
   relying on an expanded struct ehci_driver_overrides.
 * Save orig_hub_control rather than relying on ehci_hub_control being
   exported.
 * Rebased on new versions of earlier patches.

Acked-by: Alan Stern st...@rowland.harvard.edu

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


Re: [PATCH V3 7/7] USB: EHCI: tegra: make use of ehci-priv

2013-06-05 Thread Alan Stern
On Wed, 5 Jun 2013, Stephen Warren wrote:

 From: Stephen Warren swar...@nvidia.com
 
 Rather than allocating struct tegra_ehci_hcd separately, use struct
 ehci_hcd's priv field instead.
 
 Signed-off-by: Stephen Warren swar...@nvidia.com
 ---
 v3: New patch.

Acked-by: Alan Stern st...@rowland.harvard.edu

--
To unsubscribe from this list: send the line unsubscribe 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] option,zte_ev: move most ZTE CDMA devices to zte_ev

2013-06-05 Thread Dan Williams
Per some ZTE Linux drivers I found for the AC2716, the following patch
moves most ZTE CDMA devices from option to zte_ev.  The blacklist stuff
that option does is not required with zte_ev, because it doesn't
implement any of the send_setup hooks which the blacklist suppressed.

I did not move the 2718 over because I could not find any ZTE Linux
drivers for that device, nor even any Windows drivers.

Signed-off-by: Dan Williams d...@redhat.com
---
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 7343728..94dbddd 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -249,13 +249,7 @@ static void option_instat_callback(struct urb *urb);
 #define ZTE_PRODUCT_MF622  0x0001
 #define ZTE_PRODUCT_MF628  0x0015
 #define ZTE_PRODUCT_MF626  0x0031
-#define ZTE_PRODUCT_CDMA_TECH  0xfffe
-#define ZTE_PRODUCT_AC8710 0xfff1
-#define ZTE_PRODUCT_AC2726 0xfff5
-#define ZTE_PRODUCT_AC8710T0x
 #define ZTE_PRODUCT_MC2718 0xffe8
-#define ZTE_PRODUCT_AD3812 0xffeb
-#define ZTE_PRODUCT_MC2716 0xffed
 
 #define BENQ_VENDOR_ID 0x04a5
 #define BENQ_PRODUCT_H10   0x4068
@@ -494,18 +488,10 @@ static const struct option_blacklist_info 
zte_k3765_z_blacklist = {
.reserved = BIT(4),
 };
 
-static const struct option_blacklist_info zte_ad3812_z_blacklist = {
-   .sendsetup = BIT(0) | BIT(1) | BIT(2),
-};
-
 static const struct option_blacklist_info zte_mc2718_z_blacklist = {
.sendsetup = BIT(1) | BIT(2) | BIT(3) | BIT(4),
 };
 
-static const struct option_blacklist_info zte_mc2716_z_blacklist = {
-   .sendsetup = BIT(1) | BIT(2) | BIT(3),
-};
-
 static const struct option_blacklist_info huawei_cdc12_blacklist = {
.reserved = BIT(1) | BIT(2),
 };
@@ -795,7 +781,6 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 
0xff) },
{ USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
{ USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
-   { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB  
BP3-EXT HSDPA */
@@ -1195,16 +1180,9 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 
0xff),
.driver_info = (kernel_ulong_t)net_intf3_blacklist },
 
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 
0xff, 0xff, 0xff) },
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 
0xff, 0xff, 0xff) },
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 
0xff, 0xff, 0xff) },
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 
0xff, 0xff, 0xff) },
+   /* NOTE: most ZTE CDMA devices should be driven by zte_ev, not option */
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2718, 
0xff, 0xff, 0xff),
 .driver_info = (kernel_ulong_t)zte_mc2718_z_blacklist },
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AD3812, 
0xff, 0xff, 0xff),
-.driver_info = (kernel_ulong_t)zte_ad3812_z_blacklist },
-   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MC2716, 
0xff, 0xff, 0xff),
-.driver_info = (kernel_ulong_t)zte_mc2716_z_blacklist },
{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) },
{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c
index 39ee737..71be022 100644
--- a/drivers/usb/serial/zte_ev.c
+++ b/drivers/usb/serial/zte_ev.c
@@ -279,11 +273,29 @@ static void zte_ev_usb_serial_close(struct 
usb_serial_port *port)
 }
 
 static const struct usb_device_id id_table[] = {
-   { USB_DEVICE(0x19d2, 0x) }, /* AC8700 */
-   { USB_DEVICE(0x19d2, 0xfffe) },
-   { USB_DEVICE(0x19d2, 0xfffd) }, /* MG880 */
+   /* AC8710, AC8710T */
+   { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0x, 0xff, 0xff, 0xff) },
+/* AC8700 */
+   { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfffe, 0xff, 0xff, 0xff) },
+   /* MG880 */
+   { USB_DEVICE(0x19d2, 0xfffd) },
+   { USB_DEVICE(0x19d2, 0xfffc) },
+   { USB_DEVICE(0x19d2, 0xfffb) },
+   /* AC2726, AC8710_V3 */
+   { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfff1, 0xff, 0xff, 0xff) },
+   { USB_DEVICE(0x19d2, 0xfff6) },
+   { USB_DEVICE(0x19d2, 0xfff7) },
+   { 

Re: [PATCH 3/6] staging: octeon-usb: cvmx-usbcx-defs.h: avoid long lines in CVMX_USBCX macros

2013-06-05 Thread Aaro Koskinen
Hi,

On Wed, Jun 05, 2013 at 11:36:46AM +0300, Dan Carpenter wrote:
 On Wed, Jun 05, 2013 at 12:31:32AM +0300, Aaro Koskinen wrote:
  -#define CVMX_USBCX_DAINT(block_id) (CVMX_ADD_IO_SEG(0x00016F001818ull) 
  + ((block_id)  1) * 0x1000ull)
 
 There should be a few helper macros.

OK, I'll try to fix this.

A.
--
To unsubscribe from this list: send the line unsubscribe 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: fix PTR_ERR translation in init_usb_class()

2013-06-05 Thread Alexey Khoroshilov
There is a misprint in init_usb_class():
IS_ERR is used to get error code instead of PTR_ERR.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov khoroshi...@ispras.ru
---
 drivers/usb/core/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index e5387a4..6a4c407 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -94,7 +94,7 @@ static int init_usb_class(void)
kref_init(usb_class-kref);
usb_class-class = class_create(THIS_MODULE, usbmisc);
if (IS_ERR(usb_class-class)) {
-   result = IS_ERR(usb_class-class);
+   result = PTR_ERR(usb_class-class);
printk(KERN_ERR class_create failed for usb devices\n);
kfree(usb_class);
usb_class = NULL;
-- 
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


[Application RFC PATCH] ptp-gadget: move from gadgetfs to functionfs

2013-06-05 Thread Michael Grzeschik
This patch moves the ptp-gadget to use functionfs for the endpoint
handling. With functionfs, this patch is deleting a lot of control ep0
code, which is now handled by the framework.

Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
---
 Makefile|   9 +-
 README  |   6 +-
 ptp.c   | 820 +---
 usbstring.c | 142 ---
 usbstring.h |  38 ---
 5 files changed, 179 insertions(+), 836 deletions(-)
 delete mode 100644 usbstring.c
 delete mode 100644 usbstring.h

diff --git a/Makefile b/Makefile
index d56d320..b1f9652 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,15 @@
 CPPFLAGS   := -Wall -I$(KERNEL_SRC)/include
 
-ptp:   ptp.o usbstring.o
+ptp:   ptp.o
$(CROSS_COMPILE)gcc -lpthread -o $@ $^
 
-ptp.o: ptp.c usbstring.h
-   $(CROSS_COMPILE)gcc $(CPPFLAGS) -c -o $@ $
-
-usbstring.o:   usbstring.c usbstring.h
+ptp.o: ptp.c
$(CROSS_COMPILE)gcc $(CPPFLAGS) -c -o $@ $
 
 all:   ptp
 
 clean:
-   rm -f ptp ptp.o usbstring.o
+   rm -f ptp ptp.o
 
 install:   ptp
install -m 0755 -t $(DESTDIR)/usr/local/bin/ ptp
diff --git a/README b/README
index ff12403..57757e3 100644
--- a/README
+++ b/README
@@ -7,13 +7,9 @@ This is an open-source project, licensed under GPL v3, hence 
the author is
 hoping, that it will be useful to others, and that others will contribute to 
it,
 eventually making it a complete implementation of the standard.
 
-The driver works completely in user-space and uses gadgetfs to communicate with
+The driver works completely in user-space and uses functionfs to communicate 
with
 USB gadget hardware.
 
-The code is based on the gadgetfs examples from
-http://www.linux-usb.org/gadget/usb.c and uses unchanged
-http://www.linux-usb.org/gadget/usbstring.[ch].
-
 As of v0.2 only the minimal compulsory set of PTP requests, as specified in the
 standard, is supported. Supported are downloading of images and generation of
 thumbnails, using the convert utility from the ImageMagick package. Several
diff --git a/ptp.c b/ptp.c
index 7785efe..e3302d1 100644
--- a/ptp.c
+++ b/ptp.c
@@ -32,10 +32,13 @@
 #include asm/byteorder.h
 
 #include linux/types.h
-#include linux/usb/gadgetfs.h
+#include linux/usb/functionfs.h
 #include linux/usb/ch9.h
 
-#include usbstring.h
+#define cpu_to_le16(x) htole16(x)
+#define cpu_to_le32(x) htole32(x)
+#define le32_to_cpu(x) le32toh(x)
+#define le16_to_cpu(x) le16toh(x)
 
 #define min(a,b) ({ typeof(a) __a = (a); typeof(b) __b = (b); __a  __b ? __a 
: __b; })
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -70,156 +73,120 @@ static int verbose;
 
 /* these descriptors are modified based on what controller we find */
 
-#defineSTRINGID_MFGR   1
-#defineSTRINGID_PRODUCT2
-#defineSTRINGID_CONFIG 3
-#defineSTRINGID_INTERFACE  4
-
-static struct usb_device_descriptor device_desc = {
-   .bLength =  sizeof device_desc,
-   .bDescriptorType =  USB_DT_DEVICE,
-
-   .bcdUSB =   __constant_cpu_to_le16(0x0200),
-   .bcdDevice =__constant_cpu_to_le16(DRIVER_VERSION),
-   .bDeviceClass = USB_CLASS_PER_INTERFACE,
-   .bDeviceSubClass =  0,
-   .bDeviceProtocol =  0,
-   /* .bMaxPacketSize0 ... set by gadgetfs */
-   .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM),
-   .idProduct =__constant_cpu_to_le16(DRIVER_PRODUCT_NUM),
-   .iManufacturer =STRINGID_MFGR,
-   .iProduct = STRINGID_PRODUCT,
-   .bNumConfigurations =   1,
-};
-
 #defineMAX_USB_POWER   1
 
 #defineCONFIG_VALUE1
 
-static const struct usb_config_descriptor config = {
-   .bLength =  sizeof config,
-   .bDescriptorType =  USB_DT_CONFIG,
-
-   /* must compute wTotalLength ... */
-   .bNumInterfaces =   1,
-   .bConfigurationValue =  CONFIG_VALUE,
-   .iConfiguration =   STRINGID_CONFIG,
-   .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
-   .bMaxPower =(MAX_USB_POWER + 1) / 2,
-};
-
 /* USB subclass value = the protocol encapsulation */
 #define USB_SC_IMAGE_CAPTURE   0x01/* Still Image Capture Subclass 
*/
 #define USB_PR_CB  0x01/* Control/Bulk w/o interrupt */
 
-static struct usb_interface_descriptor source_sink_intf = {
-   .bLength =  sizeof source_sink_intf,
-   .bDescriptorType =  USB_DT_INTERFACE,
-
-   .bInterfaceClass =  USB_CLASS_STILL_IMAGE,
-   .bInterfaceSubClass =   USB_SC_IMAGE_CAPTURE,
-   .bInterfaceProtocol =   USB_PR_CB,
-   .iInterface =   STRINGID_INTERFACE,
-};
-
 #define MAX_PACKET_SIZE_FS 64
 #define MAX_PACKET_SIZE_HS 512
 
-/* Full speed configurations are used for full-speed only devices as
- * well as 

Re: USB 3 webcam stop captures

2013-06-05 Thread Sarah Sharp
On Wed, Jun 05, 2013 at 11:07:46AM -0700, Oleg Rombakh wrote:
 Sarah,
 
 I found an issue where a USB camera connected to USB3 port might stop 
 capturing frames.
 Steps to reproduce:
 
 1.   Attach a USB camera to USB3 port (any camera will do but in my case 
 used Logitech camers)
 
 2.   Run the following script
 
 while true; do
 
 gst-launch-0.10 v4l2src ! xvimagesink 
 
 sleep 2
 
 pkill gst-l
 
 done
 
 
 3.   After some time camera will no longer work
 
 The issue was traced to xhci driver, where replacing 
 wait_for_completion_interruptible_timeout() to wait_for_completion_timeout() 
 will fix the above use case.
 
 Please see attached patch.
 
 Please let me know if this is an acceptable solution to the problem.

This is a known issue.  Your patch is just a work-around though, and we
should fix the underlying issue, rather than papering over it by
changing it to an uninterruptible sleep.

The chromium team ran into a similar issue, and we're having a
conversation about the right way to fix it:

http://marc.info/?l=linux-kernelm=136944610123147w=2

We'll try to Cc you on that conversation as it moves forward.

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


Re: [PATCH] lsusb: Fix bug in USB 2.0 extended caps descriptor.

2013-06-05 Thread Sarah Sharp
Ping.  Greg, do you want to take this bug fix?

Sarah

On Thu, May 16, 2013 at 02:04:42PM -0700, Sarah Sharp wrote:
 The upper bits of the USB 2.0 extended capability BOS descriptor weren't
 being shifted into the right byte position.  That didn't matter much
 before now, but some USB 2.1 devices will soon have a modified BOS
 descriptor that has BESL values in those upper bits.
 
 Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
 ---
  lsusb.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/lsusb.c b/lsusb.c
 index d9c7908..fda772a 100644
 --- a/lsusb.c
 +++ b/lsusb.c
 @@ -3613,7 +3613,7 @@ static void dump_usb2_device_capability_desc(unsigned 
 char *buf)
   unsigned int wide;
  
   wide = buf[3] + (buf[4]  8) +
 - (buf[5]  8) + (buf[6]  8);
 + (buf[5]  16) + (buf[6]  24);
   printf(  USB 2.0 Extension Device Capability:\n
   bLength %5u\n
   bDescriptorType %5u\n
 -- 
 1.7.9
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe 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] xhci: fix dma mask setup in xhci.c

2013-06-05 Thread Sarah Sharp
Hi Xenia,

I get a checkpatch warning when I attempt to commit this change:

Applying: xhci: fix dma mask setup in xhci.c
WARNING: line over 80 characters
#23: FILE: drivers/usb/host/xhci.c:4686:
+   if (dma_set_mask(hcd-self.controller, 
DMA_BIT_MASK(32)))

Can you fix that up by adding a newline after the comma and resubmit?

Thanks,
Sarah Sharp

On Sun, May 26, 2013 at 01:08:14PM +0300, Xenia Ragiadakou wrote:
 This patch adds a check on whether the host machine
 supports the xHC DMA address mask and sets the DMA
 mask for coherent DMA address allocation via an
 explicit call to dma_set_coherent_mask().
 
 According to DMA-API-HOWTO, if coherent DMA address
 mask has not been set explicitly via dma_set_coherent_mask(),
 and the driver calls dma_alloc_coherent() or
 dma_pool_create() to allocate consistent DMA memory
 blocks, the consistent DMA mapping interface will
 return by default DMA addresses which are 32-bit
 addressable.
 
 Hence, if 64-bit DMA mapping is supported, it
 is appropriate to call dma_set_coherent_mask()
 with DMA_BIT_MASK(64) to take advantage of it.
 
 Also, according to DMA-API-HOWTO, dma_set_coherent_mask()
 is guaranteed to set successfully the same or a smaller
 mask as dma_set_mask().
 
 Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
 ---
 
 After this change, (i have a 64-bit machine) the
 consistent_dma_mask_bits entry for xhci controller
 that appears under:
 /sys/devices/pci:00/:00:device.function/
 changed from 32 to 64.
 I did not find another way to test this change.
 
  drivers/usb/host/xhci.c |   32 ++--
  1 file changed, 26 insertions(+), 6 deletions(-)
 
 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
 index b4aa79d..887db65 100644
 --- a/drivers/usb/host/xhci.c
 +++ b/drivers/usb/host/xhci.c
 @@ -4662,11 +4662,21 @@ int xhci_gen_setup(struct usb_hcd *hcd, 
 xhci_get_quirks_t get_quirks)
*/
   xhci = hcd_to_xhci(hcd);
   temp = xhci_readl(xhci, xhci-cap_regs-hcc_params);
 - if (HCC_64BIT_ADDR(temp)) {
 + /*
 +  * Check if host machine supports 64 bit DMA address mask
 +  * and enable it for both streaming and coherent DMA transfers.
 +  * Otherwise, use 32bit DMA mask, if it is supported.
 +  */
 + if (HCC_64BIT_ADDR(temp) 
 + !dma_set_mask(hcd-self.controller, DMA_BIT_MASK(64))) {
   xhci_dbg(xhci, Enabling 64-bit DMA addresses.\n);
 - dma_set_mask(hcd-self.controller, DMA_BIT_MASK(64));
 + dma_set_coherent_mask(hcd-self.controller,
 +   DMA_BIT_MASK(64));
   } else {
 - dma_set_mask(hcd-self.controller, DMA_BIT_MASK(32));
 + if (dma_set_mask(hcd-self.controller, 
 DMA_BIT_MASK(32)))
 + goto error;
 + dma_set_coherent_mask(hcd-self.controller,
 +   DMA_BIT_MASK(32));
   }
   return 0;
   }
 @@ -4700,11 +4710,21 @@ int xhci_gen_setup(struct usb_hcd *hcd, 
 xhci_get_quirks_t get_quirks)
   xhci_dbg(xhci, Reset complete\n);
  
   temp = xhci_readl(xhci, xhci-cap_regs-hcc_params);
 - if (HCC_64BIT_ADDR(temp)) {
 + /*
 +  * Check if host machine supports 64 bit DMA address mask
 +  * and enable it for both streaming and coherent DMA transfers.
 +  * Otherwise, use 32bit DMA mask, if it is supported.
 +  */
 + if (HCC_64BIT_ADDR(temp) 
 + !dma_set_mask(hcd-self.controller, DMA_BIT_MASK(64))) {
   xhci_dbg(xhci, Enabling 64-bit DMA addresses.\n);
 - dma_set_mask(hcd-self.controller, DMA_BIT_MASK(64));
 + dma_set_coherent_mask(hcd-self.controller,
 +   DMA_BIT_MASK(64));
   } else {
 - dma_set_mask(hcd-self.controller, DMA_BIT_MASK(32));
 + if (dma_set_mask(hcd-self.controller, DMA_BIT_MASK(32)))
 + goto error;
 + dma_set_coherent_mask(hcd-self.controller,
 +   DMA_BIT_MASK(32));
   }
  
   xhci_dbg(xhci, Calling HCD init\n);
 -- 
 1.7.10.4
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/7] Common Clock Framework support for Samsung S3C64xx

2013-06-05 Thread Tomasz Figa
This series is an attempt to move clock support on Samsung S3C64xx SoCs
to Common Clock Framework.

First, support for PLL types present on S3C64xx SoCs is added to Samsung
Common Clock Framework driver. Then the main clock driver for mentioned
SoCs is introduced. Further patches contain fixes for drivers to make them
compliant with CCF semantics, migration of platform code to use the new
clock driver and removal of old clock management code.

Depends on:
 - [PATCH 0/6] Samsung watchdog support clean-up
   http://thread.gmane.org/gmane.linux.kernel.samsung-soc/18736/focus=18989
 - [PATCH 00/15] Final Samsung PWM support cleanup
   http://www.spinics.net/lists/arm-kernel/msg248725.html

On S3C6410-based Tiny6410 board (Mini6410-compatible):

Tested-by: Tomasz Figa tomasz.f...@gmail.com

Tomasz Figa (7):
  clk: samsung: pll: Add support for PLL6552 and PLL6553
  clk: samsung: Add clock driver for S3C64xx SoCs
  ARM: SAMSUNG: Add soc_is_s3c6400/s3c6410 macros
  ARM: s3c64xx: dma: Use clk_prepare_enable/clk_disable_unprepare
  usb: host: ohci-s3c2410 Use clk_prepare_enable/clk_disable_unprepare
  ARM: s3c64xx: Migrate clock handling to Common Clock Framework
  ARM: s3c64xx: Remove old clock management code

 .../bindings/clock/samsung,s3c64xx-clock.txt   |   48 +
 arch/arm/Kconfig   |2 +-
 arch/arm/mach-s3c64xx/Makefile |2 +-
 arch/arm/mach-s3c64xx/clock.c  | 1007 
 arch/arm/mach-s3c64xx/common.c |   21 +-
 arch/arm/mach-s3c64xx/common.h |   12 +-
 arch/arm/mach-s3c64xx/dma.c|4 +-
 arch/arm/mach-s3c64xx/include/mach/regs-clock.h|  132 +--
 arch/arm/mach-s3c64xx/mach-anw6410.c   |2 +-
 arch/arm/mach-s3c64xx/mach-crag6410.c  |2 +-
 arch/arm/mach-s3c64xx/mach-hmt.c   |2 +-
 arch/arm/mach-s3c64xx/mach-mini6410.c  |2 +-
 arch/arm/mach-s3c64xx/mach-ncp.c   |2 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|   11 +-
 arch/arm/mach-s3c64xx/mach-smdk6400.c  |2 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |2 +-
 arch/arm/mach-s3c64xx/pm.c |   21 -
 arch/arm/mach-s3c64xx/s3c6400.c|6 -
 arch/arm/mach-s3c64xx/s3c6410.c|7 -
 arch/arm/plat-samsung/include/plat/cpu.h   |4 +
 drivers/clk/samsung/Makefile   |1 +
 drivers/clk/samsung/clk-pll.c  |  160 
 drivers/clk/samsung/clk-pll.h  |4 +
 drivers/clk/samsung/clk-s3c64xx.c  |  503 ++
 drivers/usb/host/ohci-s3c2410.c|8 +-
 include/dt-bindings/clock/samsung,s3c64xx-clock.h  |  144 +++
 26 files changed, 907 insertions(+), 1204 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/clock/samsung,s3c64xx-clock.txt
 delete mode 100644 arch/arm/mach-s3c64xx/clock.c
 create mode 100644 drivers/clk/samsung/clk-s3c64xx.c
 create mode 100644 include/dt-bindings/clock/samsung,s3c64xx-clock.h

-- 
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 1/7] clk: samsung: pll: Add support for PLL6552 and PLL6553

2013-06-05 Thread Tomasz Figa
This patch adds support for PLL6552 and PLL6553 PLLs present on Samsung
S3C64xx SoCs.

Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
---
 drivers/clk/samsung/clk-pll.c | 160 ++
 drivers/clk/samsung/clk-pll.h |   4 ++
 2 files changed, 164 insertions(+)

diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c
index 89135f6..cef0bb9 100644
--- a/drivers/clk/samsung/clk-pll.c
+++ b/drivers/clk/samsung/clk-pll.c
@@ -336,6 +336,166 @@ struct clk * __init samsung_clk_register_pll46xx(const 
char *name,
 }
 
 /*
+ * PLL6552 Clock Type
+ */
+
+#define PLL6552_LOCK_REG   0x00
+#define PLL6552_CON_REG0x0c
+
+#define PLL6552_MDIV_MASK  0x3ff
+#define PLL6552_PDIV_MASK  0x3f
+#define PLL6552_SDIV_MASK  0x7
+#define PLL6552_MDIV_SHIFT 16
+#define PLL6552_PDIV_SHIFT 8
+#define PLL6552_SDIV_SHIFT 0
+
+struct samsung_clk_pll6552 {
+   struct clk_hw hw;
+   void __iomem *reg_base;
+};
+
+#define to_clk_pll6552(_hw) container_of(_hw, struct samsung_clk_pll6552, hw)
+
+static unsigned long samsung_pll6552_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct samsung_clk_pll6552 *pll = to_clk_pll6552(hw);
+   u32 mdiv, pdiv, sdiv, pll_con;
+   u64 fvco = parent_rate;
+
+   pll_con = __raw_readl(pll-reg_base + PLL6552_CON_REG);
+   mdiv = (pll_con  PLL6552_MDIV_SHIFT)  PLL6552_MDIV_MASK;
+   pdiv = (pll_con  PLL6552_PDIV_SHIFT)  PLL6552_PDIV_MASK;
+   sdiv = (pll_con  PLL6552_SDIV_SHIFT)  PLL6552_SDIV_MASK;
+
+   fvco *= mdiv;
+   do_div(fvco, (pdiv  sdiv));
+
+   return (unsigned long)fvco;
+}
+
+static const struct clk_ops samsung_pll6552_clk_ops = {
+   .recalc_rate = samsung_pll6552_recalc_rate,
+};
+
+struct clk * __init samsung_clk_register_pll6552(const char *name,
+   const char *pname, void __iomem *base)
+{
+   struct samsung_clk_pll6552 *pll;
+   struct clk *clk;
+   struct clk_init_data init;
+
+   pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+   if (!pll) {
+   pr_err(%s: could not allocate pll clk %s\n, __func__, name);
+   return NULL;
+   }
+
+   init.name = name;
+   init.ops = samsung_pll6552_clk_ops;
+   init.parent_names = pname;
+   init.num_parents = 1;
+
+   pll-hw.init = init;
+   pll-reg_base = base;
+
+   clk = clk_register(NULL, pll-hw);
+   if (IS_ERR(clk)) {
+   pr_err(%s: failed to register pll clock %s\n, __func__,
+   name);
+   kfree(pll);
+   }
+
+   if (clk_register_clkdev(clk, name, NULL))
+   pr_err(%s: failed to register lookup for %s, __func__, name);
+
+   return clk;
+}
+
+/*
+ * PLL6553 Clock Type
+ */
+
+#define PLL6553_LOCK_REG   0x00
+#define PLL6553_CON0_REG   0x0c
+#define PLL6553_CON1_REG   0x10
+
+#define PLL6553_MDIV_MASK  0xff
+#define PLL6553_PDIV_MASK  0x3f
+#define PLL6553_SDIV_MASK  0x7
+#define PLL6553_KDIV_MASK  0x
+#define PLL6553_MDIV_SHIFT 16
+#define PLL6553_PDIV_SHIFT 8
+#define PLL6553_SDIV_SHIFT 0
+#define PLL6553_KDIV_SHIFT 0
+
+struct samsung_clk_pll6553 {
+   struct clk_hw hw;
+   void __iomem *reg_base;
+};
+
+#define to_clk_pll6553(_hw) container_of(_hw, struct samsung_clk_pll6553, hw)
+
+static unsigned long samsung_pll6553_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct samsung_clk_pll6553 *pll = to_clk_pll6553(hw);
+   u32 mdiv, pdiv, sdiv, kdiv, pll_con0, pll_con1;
+   u64 fvco = parent_rate;
+
+   pll_con0 = __raw_readl(pll-reg_base + PLL6553_CON0_REG);
+   pll_con1 = __raw_readl(pll-reg_base + PLL6553_CON1_REG);
+   mdiv = (pll_con0  PLL6553_MDIV_SHIFT)  PLL6553_MDIV_MASK;
+   pdiv = (pll_con0  PLL6553_PDIV_SHIFT)  PLL6553_PDIV_MASK;
+   sdiv = (pll_con0  PLL6553_SDIV_SHIFT)  PLL6553_SDIV_MASK;
+   kdiv = (pll_con1  PLL6553_KDIV_SHIFT)  PLL6553_KDIV_MASK;
+
+   fvco *= (mdiv  16) + kdiv;
+   do_div(fvco, (pdiv  sdiv));
+   fvco = 16;
+
+   return (unsigned long)fvco;
+}
+
+static const struct clk_ops samsung_pll6553_clk_ops = {
+   .recalc_rate = samsung_pll6553_recalc_rate,
+};
+
+struct clk * __init samsung_clk_register_pll6553(const char *name,
+   const char *pname, void __iomem *base)
+{
+   struct samsung_clk_pll6553 *pll;
+   struct clk *clk;
+   struct clk_init_data init;
+
+   pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+   if (!pll) {
+   pr_err(%s: could not allocate pll clk %s\n, __func__, name);
+   return NULL;
+   }
+
+   init.name = name;
+   init.ops = samsung_pll6553_clk_ops;
+   init.parent_names = pname;
+   init.num_parents = 1;
+
+   pll-hw.init = 

[PATCH 6/7] ARM: s3c64xx: Migrate clock handling to Common Clock Framework

2013-06-05 Thread Tomasz Figa
This patch migrates the s3c64xx platform to use the new clock driver
using Common Clock Framework.

Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
---
 arch/arm/Kconfig  |  2 +-
 arch/arm/mach-s3c64xx/Makefile|  2 +-
 arch/arm/mach-s3c64xx/common.c| 21 +
 arch/arm/mach-s3c64xx/common.h| 10 +-
 arch/arm/mach-s3c64xx/mach-anw6410.c  |  2 +-
 arch/arm/mach-s3c64xx/mach-crag6410.c |  2 +-
 arch/arm/mach-s3c64xx/mach-hmt.c  |  2 +-
 arch/arm/mach-s3c64xx/mach-mini6410.c |  2 +-
 arch/arm/mach-s3c64xx/mach-ncp.c  |  2 +-
 arch/arm/mach-s3c64xx/mach-smartq.c   | 11 ++-
 arch/arm/mach-s3c64xx/mach-smdk6400.c |  2 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c |  2 +-
 arch/arm/mach-s3c64xx/s3c6400.c   |  6 --
 arch/arm/mach-s3c64xx/s3c6410.c   |  7 ---
 drivers/clk/samsung/Makefile  |  2 --
 15 files changed, 33 insertions(+), 42 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 64d3ff9..5d29ae9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -717,6 +717,7 @@ config ARCH_S3C64XX
select ARM_VIC
select CLKDEV_LOOKUP
select CLKSRC_MMIO
+   select COMMON_CLK
select CPU_V6
select GENERIC_CLOCKEVENTS
select HAVE_CLK
@@ -728,7 +729,6 @@ config ARCH_S3C64XX
select PLAT_SAMSUNG
select S3C_DEV_NAND
select S3C_GPIO_TRACK
-   select SAMSUNG_CLKSRC
select SAMSUNG_GPIOLIB_4BIT
select SAMSUNG_WDT_RESET
select USB_ARCH_HAS_OHCI
diff --git a/arch/arm/mach-s3c64xx/Makefile b/arch/arm/mach-s3c64xx/Makefile
index 31d0c91..645a8fe 100644
--- a/arch/arm/mach-s3c64xx/Makefile
+++ b/arch/arm/mach-s3c64xx/Makefile
@@ -12,7 +12,7 @@ obj-  :=
 
 # Core
 
-obj-y  += common.o clock.o
+obj-y  += common.o
 
 # Core support
 
diff --git a/arch/arm/mach-s3c64xx/common.c b/arch/arm/mach-s3c64xx/common.c
index 0b33683..bf00e60 100644
--- a/arch/arm/mach-s3c64xx/common.c
+++ b/arch/arm/mach-s3c64xx/common.c
@@ -17,6 +17,7 @@
 #include linux/kernel.h
 #include linux/init.h
 #include linux/module.h
+#include linux/clk-provider.h
 #include linux/interrupt.h
 #include linux/ioport.h
 #include linux/serial_core.h
@@ -37,7 +38,6 @@
 #include mach/regs-gpio.h
 
 #include plat/cpu.h
-#include plat/clock.h
 #include plat/devs.h
 #include plat/pm.h
 #include plat/gpio-cfg.h
@@ -49,6 +49,19 @@
 
 #include common.h
 
+/* External clock frequency */
+static unsigned long xtal_f = 1200, xusbxti_f = 4800;
+
+void __init s3c64xx_set_xtal_freq(unsigned long freq)
+{
+   xtal_f = freq;
+}
+
+void __init s3c64xx_set_xusbxti_freq(unsigned long freq)
+{
+   xusbxti_f = freq;
+}
+
 /* uart registration process */
 
 static void __init s3c64xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
@@ -66,7 +79,6 @@ static struct cpu_table cpu_ids[] __initdata = {
.idcode = S3C6400_CPU_ID,
.idmask = S3C64XX_CPU_MASK,
.map_io = s3c6400_map_io,
-   .init_clocks= s3c6400_init_clocks,
.init_uarts = s3c64xx_init_uarts,
.init   = s3c6400_init,
.name   = name_s3c6400,
@@ -74,7 +86,6 @@ static struct cpu_table cpu_ids[] __initdata = {
.idcode = S3C6410_CPU_ID,
.idmask = S3C64XX_CPU_MASK,
.map_io = s3c6410_map_io,
-   .init_clocks= s3c6410_init_clocks,
.init_uarts = s3c64xx_init_uarts,
.init   = s3c6410_init,
.name   = name_s3c6410,
@@ -212,8 +223,10 @@ void __init s3c64xx_init_irq(u32 vic0_valid, u32 
vic1_valid)
 {
/*
 * FIXME: there is no better place to put this at the moment
-* (samsung_wdt_reset_init needs clocks)
+* (s3c64xx_clk_init needs ioremap and must happen before init_time
+* samsung_wdt_reset_init needs clocks)
 */
+   s3c64xx_clk_init(NULL, xtal_f, xusbxti_f, soc_is_s3c6400(), S3C_VA_SYS);
samsung_wdt_reset_init(S3C_VA_WATCHDOG);
 
printk(KERN_DEBUG %s: initialising interrupts\n, __func__);
diff --git a/arch/arm/mach-s3c64xx/common.h b/arch/arm/mach-s3c64xx/common.h
index 6cfc99b..76ce4fe 100644
--- a/arch/arm/mach-s3c64xx/common.h
+++ b/arch/arm/mach-s3c64xx/common.h
@@ -20,18 +20,19 @@
 void s3c64xx_init_irq(u32 vic0, u32 vic1);
 void s3c64xx_init_io(struct map_desc *mach_desc, int size);
 
-void s3c64xx_register_clocks(unsigned long xtal, unsigned armclk_limit);
-void s3c64xx_setup_clocks(void);
-
 void s3c64xx_restart(char mode, const char *cmd);
 void s3c64xx_init_late(void);
 
+void s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,
+   unsigned long xusbxti_f, bool is_s3c6400, void __iomem *reg_base);
+void s3c64xx_set_xtal_freq(unsigned long freq);
+void 

[PATCH 5/7] usb: host: ohci-s3c2410 Use clk_prepare_enable/clk_disable_unprepare

2013-06-05 Thread Tomasz Figa
This patch modifies the ohci-s3c2410 driver to prepare and unprepare
clocks in addition to enabling and disabling, since it is required
by common clock framework.

Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
---
 drivers/usb/host/ohci-s3c2410.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index e125770..db096bf 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -47,10 +47,10 @@ static void s3c2410_start_hc(struct platform_device *dev, 
struct usb_hcd *hcd)
 
dev_dbg(dev-dev, s3c2410_start_hc:\n);
 
-   clk_enable(usb_clk);
+   clk_prepare_enable(usb_clk);
mdelay(2);  /* let the bus clock stabilise */
 
-   clk_enable(clk);
+   clk_prepare_enable(clk);
 
if (info != NULL) {
info-hcd   = hcd;
@@ -75,8 +75,8 @@ static void s3c2410_stop_hc(struct platform_device *dev)
(info-enable_oc)(info, 0);
}
 
-   clk_disable(clk);
-   clk_disable(usb_clk);
+   clk_disable_unprepare(clk);
+   clk_disable_unprepare(usb_clk);
 }
 
 /* ohci_s3c2410_hub_status_data
-- 
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 2/7] clk: samsung: Add clock driver for S3C64xx SoCs

2013-06-05 Thread Tomasz Figa
This patch adds new, Common Clock Framework-based clock driver for Samsung
S3C64xx SoCs. The driver is just added, without actually letting the
platforms use it yet, since this requires more intermediate steps.

Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
---
 .../bindings/clock/samsung,s3c64xx-clock.txt   |  48 ++
 drivers/clk/samsung/Makefile   |   3 +
 drivers/clk/samsung/clk-s3c64xx.c  | 503 +
 include/dt-bindings/clock/samsung,s3c64xx-clock.h  | 144 ++
 4 files changed, 698 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/clock/samsung,s3c64xx-clock.txt
 create mode 100644 drivers/clk/samsung/clk-s3c64xx.c
 create mode 100644 include/dt-bindings/clock/samsung,s3c64xx-clock.h

diff --git a/Documentation/devicetree/bindings/clock/samsung,s3c64xx-clock.txt 
b/Documentation/devicetree/bindings/clock/samsung,s3c64xx-clock.txt
new file mode 100644
index 000..278ab6e
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/samsung,s3c64xx-clock.txt
@@ -0,0 +1,48 @@
+* Samsung S3C64xx Clock Controller
+
+The S3C64xx clock controller generates and supplies clock to various 
controllers
+within the SoC. The clock binding described here is applicable to all SoCs in
+the S3C64xx family.
+
+Required Properties:
+
+- comptible: should be one of the following.
+  - samsung,s3c6400-clock - controller compatible with S3C6400 SoC.
+  - samsung,s3c6410-clock - controller compatible with S3C6410 SoC.
+
+- reg: physical base address of the controller and length of memory mapped
+  region.
+
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier and client nodes can use this identifier
+to specify the clock which they consume. Some of the clocks are available only
+on a particular S3C64xx SoC and this is specified where applicable.
+
+All available clocks are defined as preprocessor macros in
+dt-bindings/clock/samsung,s3c64xx-clock.h header and can be used in device
+tree sources.
+
+Example: Clock controller node:
+
+   clocks: clock-controller@7e00f000 {
+   compatible = samsung,s3c6410-clock;
+   reg = 0x7e00f000 0x1000;
+   #clock-cells = 1;
+   };
+
+Example: UART controller node that consumes the clock generated by the clock
+  controller (refer to the standard clock bindings for information about
+  clocks and clock-names properties):
+
+   uart0: serial@7f005000 {
+   compatible = samsung,s3c6400-uart;
+   reg = 0x7f005000 0x100;
+   interrupt-parent = vic1;
+   interrupts = 5;
+   clock-names = uart, clk_uart_baud2,
+   clk_uart_baud3;
+   clocks = clocks PCLK_UART0, clocks PCLK_UART0,
+   clocks SCLK_UART;
+   status = disabled;
+   };
diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile
index b7c232e..c023474 100644
--- a/drivers/clk/samsung/Makefile
+++ b/drivers/clk/samsung/Makefile
@@ -6,3 +6,6 @@ obj-$(CONFIG_COMMON_CLK)+= clk.o clk-pll.o
 obj-$(CONFIG_ARCH_EXYNOS4) += clk-exynos4.o
 obj-$(CONFIG_SOC_EXYNOS5250)   += clk-exynos5250.o
 obj-$(CONFIG_SOC_EXYNOS5440)   += clk-exynos5440.o
+ifdef CONFIG_COMMON_CLK
+obj-$(CONFIG_ARCH_S3C64XX) += clk-s3c64xx.o
+endif
diff --git a/drivers/clk/samsung/clk-s3c64xx.c 
b/drivers/clk/samsung/clk-s3c64xx.c
new file mode 100644
index 000..253a972
--- /dev/null
+++ b/drivers/clk/samsung/clk-s3c64xx.c
@@ -0,0 +1,503 @@
+/*
+ * Copyright (c) 2013 Tomasz Figa tomasz.figa at gmail.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Common Clock Framework support for all S3C64xx SoCs.
+*/
+
+#include linux/clk.h
+#include linux/clkdev.h
+#include linux/clk-provider.h
+#include linux/of.h
+#include linux/of_address.h
+
+#include dt-bindings/clock/samsung,s3c64xx-clock.h
+
+#include clk.h
+#include clk-pll.h
+
+/* S3C64xx clock controller register offsets. */
+#define APLL_LOCK  0x000
+#define MPLL_LOCK  0x004
+#define EPLL_LOCK  0x008
+#define APLL_CON   0x00c
+#define MPLL_CON   0x010
+#define EPLL_CON0  0x014
+#define EPLL_CON1  0x018
+#define CLK_SRC0x01c
+#define CLK_DIV0   0x020
+#define CLK_DIV1   0x024
+#define CLK_DIV2   0x028
+#define HCLK_GATE  0x030
+#define PCLK_GATE  0x034
+#define SCLK_GATE  0x038
+#define MEM0_GATE  0x03c
+#define CLK_SRC2   0x10c
+#define OTHERS 0x900
+
+/* Special bitfields used in the driver. */
+#define OTHERS_SYNCMUXSEL  (1  6)
+
+/* Helper macros 

[PATCH 3/7] ARM: SAMSUNG: Add soc_is_s3c6400/s3c6410 macros

2013-06-05 Thread Tomasz Figa
This patch adds soc_is_s3c6400() and soc_is_s3c6410() macros that allow
to distinguish between specific SoCs from s3c64xx series that is needed
to handle differences between them.

Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
---
 arch/arm/plat-samsung/include/plat/cpu.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/plat-samsung/include/plat/cpu.h 
b/arch/arm/plat-samsung/include/plat/cpu.h
index 989fefe..8e55196 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -85,8 +85,12 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, 
EXYNOS5_SOC_MASK)
 #endif
 
 #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410)
+# define soc_is_s3c6400()  is_samsung_s3c6400()
+# define soc_is_s3c6410()  is_samsung_s3c6410()
 # define soc_is_s3c64xx()  (is_samsung_s3c6400() || is_samsung_s3c6410())
 #else
+# define soc_is_s3c6400()  0
+# define soc_is_s3c6410()  0
 # define soc_is_s3c64xx()  0
 #endif
 
-- 
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 7/7] ARM: s3c64xx: Remove old clock management code

2013-06-05 Thread Tomasz Figa
This patch removes old clock management code of S3C64xx, since the
platform has been already moved to the new clock driver using Common
Clock Framework.

Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
---
 arch/arm/mach-s3c64xx/clock.c   | 1007 ---
 arch/arm/mach-s3c64xx/common.h  |2 -
 arch/arm/mach-s3c64xx/include/mach/regs-clock.h |  132 +--
 arch/arm/mach-s3c64xx/pm.c  |   21 -
 4 files changed, 4 insertions(+), 1158 deletions(-)
 delete mode 100644 arch/arm/mach-s3c64xx/clock.c

diff --git a/arch/arm/mach-s3c64xx/clock.c b/arch/arm/mach-s3c64xx/clock.c
deleted file mode 100644
index c1bcc4a..000
diff --git a/arch/arm/mach-s3c64xx/common.h b/arch/arm/mach-s3c64xx/common.h
index 76ce4fe..0184abf 100644
--- a/arch/arm/mach-s3c64xx/common.h
+++ b/arch/arm/mach-s3c64xx/common.h
@@ -35,7 +35,6 @@ extern void s3c6400_init_irq(void);
 extern void s3c6400_map_io(void);
 
 #else
-#define s3c6400_init_clocks NULL
 #define s3c6400_map_io NULL
 #define s3c6400_init NULL
 #endif
@@ -47,7 +46,6 @@ extern void s3c6410_init_irq(void);
 extern void s3c6410_map_io(void);
 
 #else
-#define s3c6410_init_clocks NULL
 #define s3c6410_map_io NULL
 #define s3c6410_init NULL
 #endif
diff --git a/arch/arm/mach-s3c64xx/include/mach/regs-clock.h 
b/arch/arm/mach-s3c64xx/include/mach/regs-clock.h
index 05332b9..4f44aac 100644
--- a/arch/arm/mach-s3c64xx/include/mach/regs-clock.h
+++ b/arch/arm/mach-s3c64xx/include/mach/regs-clock.h
@@ -15,145 +15,21 @@
 #ifndef __PLAT_REGS_CLOCK_H
 #define __PLAT_REGS_CLOCK_H __FILE__
 
+/*
+ * FIXME: Remove remaining definitions
+ */
+
 #define S3C_CLKREG(x)  (S3C_VA_SYS + (x))
 
-#define S3C_APLL_LOCK  S3C_CLKREG(0x00)
-#define S3C_MPLL_LOCK  S3C_CLKREG(0x04)
-#define S3C_EPLL_LOCK  S3C_CLKREG(0x08)
-#define S3C_APLL_CON   S3C_CLKREG(0x0C)
-#define S3C_MPLL_CON   S3C_CLKREG(0x10)
-#define S3C_EPLL_CON0  S3C_CLKREG(0x14)
-#define S3C_EPLL_CON1  S3C_CLKREG(0x18)
-#define S3C_CLK_SRCS3C_CLKREG(0x1C)
-#define S3C_CLK_DIV0   S3C_CLKREG(0x20)
-#define S3C_CLK_DIV1   S3C_CLKREG(0x24)
-#define S3C_CLK_DIV2   S3C_CLKREG(0x28)
-#define S3C_CLK_OUTS3C_CLKREG(0x2C)
-#define S3C_HCLK_GATE  S3C_CLKREG(0x30)
 #define S3C_PCLK_GATE  S3C_CLKREG(0x34)
-#define S3C_SCLK_GATE  S3C_CLKREG(0x38)
-#define S3C_MEM0_GATE  S3C_CLKREG(0x3C)
 #define S3C6410_CLK_SRC2   S3C_CLKREG(0x10C)
 #define S3C_MEM_SYS_CFGS3C_CLKREG(0x120)
 
-/* CLKDIV0 */
-#define S3C6400_CLKDIV0_PCLK_MASK  (0xf  12)
-#define S3C6400_CLKDIV0_PCLK_SHIFT (12)
-#define S3C6400_CLKDIV0_HCLK2_MASK (0x7  9)
-#define S3C6400_CLKDIV0_HCLK2_SHIFT(9)
-#define S3C6400_CLKDIV0_HCLK_MASK  (0x1  8)
-#define S3C6400_CLKDIV0_HCLK_SHIFT (8)
-#define S3C6400_CLKDIV0_MPLL_MASK  (0x1  4)
-#define S3C6400_CLKDIV0_MPLL_SHIFT (4)
-
-#define S3C6400_CLKDIV0_ARM_MASK   (0x7  0)
-#define S3C6410_CLKDIV0_ARM_MASK   (0xf  0)
-#define S3C6400_CLKDIV0_ARM_SHIFT  (0)
-
-/* HCLK GATE Registers */
-#define S3C_CLKCON_HCLK_3DSE   (131)
-#define S3C_CLKCON_HCLK_UHOST  (129)
-#define S3C_CLKCON_HCLK_SECUR  (128)
-#define S3C_CLKCON_HCLK_SDMA1  (127)
-#define S3C_CLKCON_HCLK_SDMA0  (126)
-#define S3C_CLKCON_HCLK_IROM   (125)
-#define S3C_CLKCON_HCLK_DDR1   (124)
-#define S3C_CLKCON_HCLK_DDR0   (123)
-#define S3C_CLKCON_HCLK_MEM1   (122)
-#define S3C_CLKCON_HCLK_MEM0   (121)
-#define S3C_CLKCON_HCLK_USB(120)
-#define S3C_CLKCON_HCLK_HSMMC2 (119)
-#define S3C_CLKCON_HCLK_HSMMC1 (118)
-#define S3C_CLKCON_HCLK_HSMMC0 (117)
-#define S3C_CLKCON_HCLK_MDP(116)
-#define S3C_CLKCON_HCLK_DHOST  (115)
-#define S3C_CLKCON_HCLK_IHOST  (114)
-#define S3C_CLKCON_HCLK_DMA1   (113)
-#define S3C_CLKCON_HCLK_DMA0   (112)
-#define S3C_CLKCON_HCLK_JPEG   (111)
-#define S3C_CLKCON_HCLK_CAMIF  (110)
-#define S3C_CLKCON_HCLK_SCALER (19)
-#define S3C_CLKCON_HCLK_2D (18)
-#define S3C_CLKCON_HCLK_TV (17)
-#define S3C_CLKCON_HCLK_POST0  (15)
-#define S3C_CLKCON_HCLK_ROT(14)
-#define S3C_CLKCON_HCLK_LCD(13)
-#define S3C_CLKCON_HCLK_TZIC   (12)
-#define S3C_CLKCON_HCLK_INTC   (11)
-#define S3C_CLKCON_HCLK_MFC(10)
-
 /* PCLK GATE Registers */
-#define S3C6410_CLKCON_PCLK_I2C1   (127)
-#define S3C6410_CLKCON_PCLK_IIS2   (126)
-#define S3C_CLKCON_PCLK_SKEY   (124)
-#define S3C_CLKCON_PCLK_CHIPID (123)
-#define S3C_CLKCON_PCLK_SPI1   (122)
-#define S3C_CLKCON_PCLK_SPI0   (121)
-#define S3C_CLKCON_PCLK_HSIRX  (120)
-#define S3C_CLKCON_PCLK_HSITX  (119)
-#define S3C_CLKCON_PCLK_GPIO   (118)
-#define S3C_CLKCON_PCLK_IIC(117)
-#define S3C_CLKCON_PCLK_IIS1   (116)
-#define S3C_CLKCON_PCLK_IIS0   (115)
-#define S3C_CLKCON_PCLK_AC97   (114)
-#define S3C_CLKCON_PCLK_TZPC   (113)
-#define S3C_CLKCON_PCLK_TSADC  

[PATCH 4/7] ARM: s3c64xx: dma: Use clk_prepare_enable/clk_disable_unprepare

2013-06-05 Thread Tomasz Figa
This patch modifies s3c64xx DMA driver to prepare and unprepare clocks
in addition to enableind and disabling, since it is required by common
clock framework.

Signed-off-by: Tomasz Figa tomasz.f...@gmail.com
---
 arch/arm/mach-s3c64xx/dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/dma.c b/arch/arm/mach-s3c64xx/dma.c
index 759846c..c511dfa 100644
--- a/arch/arm/mach-s3c64xx/dma.c
+++ b/arch/arm/mach-s3c64xx/dma.c
@@ -677,7 +677,7 @@ static int s3c64xx_dma_init1(int chno, enum dma_ch chbase,
goto err_map;
}
 
-   clk_enable(dmac-clk);
+   clk_prepare_enable(dmac-clk);
 
dmac-regs = regs;
dmac-chanbase = chbase;
@@ -711,7 +711,7 @@ static int s3c64xx_dma_init1(int chno, enum dma_ch chbase,
return 0;
 
 err_clk:
-   clk_disable(dmac-clk);
+   clk_disable_unprepare(dmac-clk);
clk_put(dmac-clk);
 err_map:
iounmap(regs);
-- 
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


Fwd: [PATCH] usb: phy: samsung: Add support for EXYNOS4210

2013-06-05 Thread Praveen Paneri
Hi,

On Tue, May 28, 2013 at 2:34 PM, Jingoo Han jg1@samsung.com wrote:
 Add support for EXYNOS4210 that includes USB EHCI/OHCI.
 Previous PHY initialization code is not correct; thus, it is modifed
 ^ You might
want to say previous PHY init code does not support HOST and HSIC
PHY.

 to support EXYNOS4210 PHY. Also, after common clock framework for
 Samsung is added, clock name is defined as 'usb_device'.

 Signed-off-by: Jingoo Han jg1@samsung.com
 ---
 Tested on Exynos4210.

  drivers/usb/phy/phy-samsung-usb.h  |   35 ++---
  drivers/usb/phy/phy-samsung-usb2.c |   74 
 +---
  2 files changed, 98 insertions(+), 11 deletions(-)

 diff --git a/drivers/usb/phy/phy-samsung-usb.h 
 b/drivers/usb/phy/phy-samsung-usb.h
 index 70a9cae..34c35e8 100644
 --- a/drivers/usb/phy/phy-samsung-usb.h
 +++ b/drivers/usb/phy/phy-samsung-usb.h
 @@ -22,13 +22,22 @@

  #define SAMSUNG_PHYPWR (0x00)

 +#define PHYPWR_PHY1_HSIC_NORMAL_MASK   (0xf  9)
 +#define PHYPWR_PHY1_HSIC1_SLEEP(1  12)
 +#define PHYPWR_PHY1_HSIC1_FORCE_SUSPEND(1  11)
 +#define PHYPWR_PHY1_HSIC0_SLEEP(1  10)
 +#define PHYPWR_PHY1_HSIC0_FORCE_SUSPEND(1  9)
 +#define PHYPWR_PHY1_STD_NORMAL_MASK(0x7  6)
 +#define PHYPWR_PHY1_STD_SLEEP  (1  8)
 +#define PHYPWR_PHY1_STD_ANALOG_POWERDOWN   (1  7)
 +#define PHYPWR_PHY1_STD_FORCE_SUSPEND  (1  6)
  #define PHYPWR_NORMAL_MASK (0x19  0)
  #define PHYPWR_OTG_DISABLE (0x1  4)
  #define PHYPWR_ANALOG_POWERDOWN(0x1  3)
  #define PHYPWR_FORCE_SUSPEND   (0x1  1)
  /* For Exynos4 */
This comment is misplaced?

 -#define PHYPWR_NORMAL_MASK_PHY0(0x39  0)
 -#define PHYPWR_SLEEP_PHY0  (0x1  5)
 +#define PHYPWR_PHY0_NORMAL_MASK(0x39  0)
 +#define PHYPWR_PHY0_SLEEP  (0x1  5)

  #define SAMSUNG_PHYCLK (0x04)

 @@ -43,9 +52,25 @@

  #define SAMSUNG_RSTCON (0x08)

 -#define RSTCON_PHYLINK_SWRST   (0x1  2)
 -#define RSTCON_HLINK_SWRST (0x1  1)
 -#define RSTCON_SWRST   (0x1  0)
 +#define RSTCON_HOST_LINK_PORT_SWRST_MASK   (0xf  6)
 +#define RSTCON_HOST_LINK_PORT2_SWRST   (0x1  9)
 +#define RSTCON_HOST_LINK_PORT1_SWRST   (0x1  8)
 +#define RSTCON_HOST_LINK_PORT0_SWRST   (0x1  7)
 +#define RSTCON_HOST_LINK_ALL_SWRST (0x1  6)
 +#define RSTCON_PHY1_SWRST_MASK (0x7  3)
 +#define RSTCON_PHY1_HSIC_SWRST (0x1  5)
 +#define RSTCON_PHY1_STD_SWRST  (0x1  4)
 +#define RSTCON_PHY1_ALL_SWRST  (0x1  3)
 +#define RSTCON_PHY0_SWRST_MASK (0x7  0)
 +#define RSTCON_PHY0_PHYLINK_SWRST  (0x1  2)
 +#define RSTCON_PHY0_HLINK_SWRST(0x1  1)
 +#define RSTCON_PHY0_SWRST  (0x1  0)
 +
 +/* EXYNOS4 */
 +#define EXYNOS4_PHY1CON(0x34)
 +
 +#define PHY1CON_FPENABLEN  (0x1  0)
 +

  /* EXYNOS5 */
  #define EXYNOS5_PHY_HOST_CTRL0 (0x00)
 diff --git a/drivers/usb/phy/phy-samsung-usb2.c 
 b/drivers/usb/phy/phy-samsung-usb2.c
 index 9d5e273..4f93d84 100644
 --- a/drivers/usb/phy/phy-samsung-usb2.c
 +++ b/drivers/usb/phy/phy-samsung-usb2.c
 @@ -158,6 +158,15 @@ static void samsung_exynos5_usb2phy_enable(struct 
 samsung_usbphy *sphy)
 writel(ohcictrl, regs + EXYNOS5_PHY_HOST_OHCICTRL);
  }

 +static bool exynos4_phyhost_is_on(void __iomem *regs)
 +{
 +   u32 reg;
 +
 +   reg = readl(regs + SAMSUNG_PHYPWR);
 +
 +   return !(reg  PHYPWR_PHY1_STD_ANALOG_POWERDOWN);
 +}
 +
  static void samsung_usb2phy_enable(struct samsung_usbphy *sphy)
  {
 void __iomem *regs = sphy-regs;
 @@ -165,6 +174,18 @@ static void samsung_usb2phy_enable(struct samsung_usbphy 
 *sphy)
 u32 phyclk;
 u32 rstcon;

 +   switch (sphy-drv_data-cpu_type) {
 +   case TYPE_EXYNOS4210:
 +   atomic_inc(sphy-phy_usage);
 +
 +   if (exynos4_phyhost_is_on(regs)) {
 +   dev_info(sphy-dev, Already power on PHY\n);
 +   return;
 +   }
 +   default:
 +   break;
 +   }
 +
 /* set clock frequency for PLL */
 phyclk = sphy-ref_clk_freq;
 phypwr = readl(regs + SAMSUNG_PHYPWR);
 @@ -174,22 +195,48 @@ static void samsung_usb2phy_enable(struct 
 samsung_usbphy *sphy)
 case TYPE_S3C64XX:
 phyclk = ~PHYCLK_COMMON_ON_N;
 phypwr = ~PHYPWR_NORMAL_MASK;
 -   rstcon |= RSTCON_SWRST;
 +   rstcon |= RSTCON_PHY0_SWRST;
 break;