[PATCH] esd_usb2: Do not do dma on the stack

2013-01-18 Thread Olivier Sobrie
smatch reports the following warnings:
drivers/net/can/usb/esd_usb2.c:640 esd_usb2_start() error: doing dma on the 
stack (msg)
drivers/net/can/usb/esd_usb2.c:846 esd_usb2_close() error: doing dma on the 
stack (msg)
drivers/net/can/usb/esd_usb2.c:855 esd_usb2_close() error: doing dma on the 
stack (msg)
drivers/net/can/usb/esd_usb2.c:923 esd_usb2_set_bittiming() error: doing dma on 
the stack (msg)
drivers/net/can/usb/esd_usb2.c:1047 esd_usb2_probe() error: doing dma on the 
stack (msg)
drivers/net/can/usb/esd_usb2.c:1053 esd_usb2_probe() error: doing dma on the 
stack (msg)

See Documentation/DMA-API-HOWTO.txt section What memory is DMA'able?

Signed-off-by: Olivier Sobrie oliv...@sobrie.be
Cc: Matthias Fuchs matthias.fu...@esd.eu
---
 drivers/net/can/usb/esd_usb2.c |  127 
 1 file changed, 76 insertions(+), 51 deletions(-)

diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index 9b74d1e..6aa7b32 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -612,9 +612,15 @@ static int esd_usb2_start(struct esd_usb2_net_priv *priv)
 {
struct esd_usb2 *dev = priv-usb2;
struct net_device *netdev = priv-netdev;
-   struct esd_usb2_msg msg;
+   struct esd_usb2_msg *msg;
int err, i;
 
+   msg = kmalloc(sizeof(*msg), GFP_KERNEL);
+   if (!msg) {
+   err = -ENOMEM;
+   goto out;
+   }
+
/*
 * Enable all IDs
 * The IDADD message takes up to 64 32 bit bitmasks (2048 bits).
@@ -628,33 +634,32 @@ static int esd_usb2_start(struct esd_usb2_net_priv *priv)
 * the number of the starting bitmask (0..64) to the filter.option
 * field followed by only some bitmasks.
 */
-   msg.msg.hdr.cmd = CMD_IDADD;
-   msg.msg.hdr.len = 2 + ESD_MAX_ID_SEGMENT;
-   msg.msg.filter.net = priv-index;
-   msg.msg.filter.option = ESD_ID_ENABLE; /* start with segment 0 */
+   msg-msg.hdr.cmd = CMD_IDADD;
+   msg-msg.hdr.len = 2 + ESD_MAX_ID_SEGMENT;
+   msg-msg.filter.net = priv-index;
+   msg-msg.filter.option = ESD_ID_ENABLE; /* start with segment 0 */
for (i = 0; i  ESD_MAX_ID_SEGMENT; i++)
-   msg.msg.filter.mask[i] = cpu_to_le32(0x);
+   msg-msg.filter.mask[i] = cpu_to_le32(0x);
/* enable 29bit extended IDs */
-   msg.msg.filter.mask[ESD_MAX_ID_SEGMENT] = cpu_to_le32(0x0001);
+   msg-msg.filter.mask[ESD_MAX_ID_SEGMENT] = cpu_to_le32(0x0001);
 
-   err = esd_usb2_send_msg(dev, msg);
+   err = esd_usb2_send_msg(dev, msg);
if (err)
-   goto failed;
+   goto out;
 
err = esd_usb2_setup_rx_urbs(dev);
if (err)
-   goto failed;
+   goto out;
 
priv-can.state = CAN_STATE_ERROR_ACTIVE;
 
-   return 0;
-
-failed:
+out:
if (err == -ENODEV)
netif_device_detach(netdev);
+   if (err)
+   netdev_err(netdev, couldn't start device: %d\n, err);
 
-   netdev_err(netdev, couldn't start device: %d\n, err);
-
+   kfree(msg);
return err;
 }
 
@@ -833,26 +838,30 @@ nourbmem:
 static int esd_usb2_close(struct net_device *netdev)
 {
struct esd_usb2_net_priv *priv = netdev_priv(netdev);
-   struct esd_usb2_msg msg;
+   struct esd_usb2_msg *msg;
int i;
 
+   msg = kmalloc(sizeof(*msg), GFP_KERNEL);
+   if (!msg)
+   return -ENOMEM;
+
/* Disable all IDs (see esd_usb2_start()) */
-   msg.msg.hdr.cmd = CMD_IDADD;
-   msg.msg.hdr.len = 2 + ESD_MAX_ID_SEGMENT;
-   msg.msg.filter.net = priv-index;
-   msg.msg.filter.option = ESD_ID_ENABLE; /* start with segment 0 */
+   msg-msg.hdr.cmd = CMD_IDADD;
+   msg-msg.hdr.len = 2 + ESD_MAX_ID_SEGMENT;
+   msg-msg.filter.net = priv-index;
+   msg-msg.filter.option = ESD_ID_ENABLE; /* start with segment 0 */
for (i = 0; i = ESD_MAX_ID_SEGMENT; i++)
-   msg.msg.filter.mask[i] = 0;
-   if (esd_usb2_send_msg(priv-usb2, msg)  0)
+   msg-msg.filter.mask[i] = 0;
+   if (esd_usb2_send_msg(priv-usb2, msg)  0)
netdev_err(netdev, sending idadd message failed\n);
 
/* set CAN controller to reset mode */
-   msg.msg.hdr.len = 2;
-   msg.msg.hdr.cmd = CMD_SETBAUD;
-   msg.msg.setbaud.net = priv-index;
-   msg.msg.setbaud.rsvd = 0;
-   msg.msg.setbaud.baud = cpu_to_le32(ESD_USB2_NO_BAUDRATE);
-   if (esd_usb2_send_msg(priv-usb2, msg)  0)
+   msg-msg.hdr.len = 2;
+   msg-msg.hdr.cmd = CMD_SETBAUD;
+   msg-msg.setbaud.net = priv-index;
+   msg-msg.setbaud.rsvd = 0;
+   msg-msg.setbaud.baud = cpu_to_le32(ESD_USB2_NO_BAUDRATE);
+   if (esd_usb2_send_msg(priv-usb2, msg)  0)
netdev_err(netdev, sending setbaud message failed\n);
 
priv-can.state = CAN_STATE_STOPPED;
@@ -861,6 +870,8 @@ 

Re: [patch] USB: c67x00-ll-hpi.c: signedness bug in ll_recv_msg()

2013-01-18 Thread Peter Korsgaard
 Dan == Dan Carpenter dan.carpen...@oracle.com writes:

 Dan The callers expect this function to return zero on success or -EIO if it
 Dan times out.  The type should be int instead of unsigned short.

 Dan Signed-off-by: Dan Carpenter dan.carpen...@oracle.com

Acked-by: Peter Korsgaard jac...@sunsite.dk


 Dan diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c 
b/drivers/usb/c67x00/c67x00-ll-hpi.c
 Dan index a9636f4..3a1ca4d 100644
 Dan --- a/drivers/usb/c67x00/c67x00-ll-hpi.c
 Dan +++ b/drivers/usb/c67x00/c67x00-ll-hpi.c
 Dan @@ -237,7 +237,7 @@ void c67x00_ll_hpi_disable_sofeop(struct c67x00_sie 
*sie)
 Dan  /* 
-- */
 Dan  /* Transactions */
 
 Dan -static inline u16 ll_recv_msg(struct c67x00_device *dev)
 Dan +static inline int ll_recv_msg(struct c67x00_device *dev)
 Dan  {
 Dan   u16 res;
 


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


[RESEND PATCH v9 2/2] usb: s3c-hsotg: Adding phy driver support

2013-01-18 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri p.pan...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 439c3f9..c8ed7f1 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
+#include linux/usb/phy.h
 #include linux/platform_data/s3c-hsotg.h
 
 #include mach/map.h
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
-   if (hsotg-plat-phy_init)
+
+   if (hsotg-phy)
+   usb_phy_init(hsotg-phy);
+   else if (hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
-   if (hsotg-plat-phy_exit)
+   if (hsotg-phy)
+   usb_phy_shutdown(hsotg-phy);
+   else if (hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
 }
 
@@ -3492,6 +3501,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev-dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = pdev-dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3500,20 +3510,27 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
int ret;
int i;
 
-   plat = pdev-dev.platform_data;
-   if (!plat) {
-   dev_err(pdev-dev, no platform data defined\n);
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(pdev-dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, cannot get memory\n);
return -ENOMEM;
}
 
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   /* Fallback for pdata */
+   plat = pdev-dev.platform_data;
+   if (!plat) {
+   dev_err(pdev-dev, no platform data or transceiver 
defined\n);
+   return -EPROBE_DEFER;
+   } else {
+   hsotg-plat = plat;
+   }
+   } else {
+   hsotg-phy = phy;
+   }
+
hsotg-dev = dev;
-   hsotg-plat = plat;
 
hsotg-clk = devm_clk_get(pdev-dev, otg);
if (IS_ERR(hsotg-clk)) {
-- 
1.7.1

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


Re: Wake on LAN for USB ethernet?

2013-01-18 Thread Petko Manolov
The code in the driver is based on the specs from ADMTek (later, 
Infineon).  Since i never suspend my machines this feature has not been 
tested by me.


However, if the proposed patch is the right thing to do i'd be happy to 
see it applied.



cheers,
Petko


On Fri, 18 Jan 2013, Ming Lei wrote:


On Fri, Jan 18, 2013 at 8:12 AM, Sarah Sharp
sarah.a.sh...@linux.intel.com wrote:

Is it reasonable to expect that Wake on LAN works if the target box is
connected via a USB-to-ethernet adapter?


It is surely reasonable, and seems SMSC75xx or SMSC95xx can
bring system out of suspend.



One of my validation testers has a USB ethernet device that successfully
wakes up Windows from hibernate (S4), but it doesn't work under Linux.
Wake on LAN works fine with the hardwired ethernet port.  USB remote
wakeup from S3/S4 works fine with a USB keyboard.

So I need to figure out if it's an issue with the kernel, their test
suite, or the USB host controller.


I've experimented with USB ethernet devices with the pegasus driver with
no success.  Here's what I've tried:

1. Connect the USB to ethernet adapter to the rootport under the xHCI
(USB 3.0) host controller. (lsusb for the two devices I've tried is
attached)

2. Enable remote wakeup for all devices (including the PCI host) by
echoing 'enabled' to power/wakeup. (script for that attached)

3. Use ethtool to turn on WOL:
   sudo ethtool -s ethX wol g


Could you check here if the attribute 'power/wakeup' of the USB device
has been enabled?  If so, and step 6 still can't wakeup system, the
problem may be in the set_wol stetting on hardware of the driver since
your USB wakeup works.

Also, the wakeup enabling is missed in the pegasus_set_wol(), and
the below patch is needed:

diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index a0b5807..d5304f1 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -1096,6 +1096,7 @@ pegasus_set_wol(struct net_device *dev, struct
ethtool_wolinfo *wol)
{
pegasus_t   *pegasus = netdev_priv(dev);
u8  reg78 = 0x04;
+   int ret;

if (wol-wolopts  ~WOL_SUPPORTED)
return -EINVAL;
@@ -1110,7 +,11 @@ pegasus_set_wol(struct net_device *dev, struct
ethtool_wolinfo *wol)
else
pegasus-eth_regs[0] = ~0x10;
pegasus-wolopts = wol-wolopts;
-   return set_register(pegasus, WakeupControl, reg78);
+
+   ret = set_register(pegasus, WakeupControl, reg78);
+   if (!ret)
+   ret = device_set_wakeup_enable(pegasus-usb-dev, 1);
+   return ret;
}

static inline void pegasus_reset_wol(struct net_device *dev)




4. Find the MAC address by running ifconfig and looking at the HWaddr
field.

5. Verify with wireshark that I can see the Magic WOL packet when I run
this command on another machine:
   sudo etherwake -i ethX macaddr

6. Suspend or hibernate the target machine, and then send the Magic WOL
packet from a second machine.


Am I missing any steps in testing this?  Does WOL just not work for USB
ethernet devices under Linux?  Perhaps just the pegasus driver doesn't
support WOL?


Probably the set_wol of pegasus is broken if wakeup has been enabled
on the USB device.

Thanks,
--
Ming Lei


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


[PATCH 1/4] drivers: usb: phy: add a new driver for usb part of control module

2013-01-18 Thread Kishon Vijay Abraham I
Added a new driver for the usb part of control module. This has an API
to power on the USB2 phy and an API to write to the mailbox depending on
whether MUSB has to act in host mode or in device mode.

Writing to control module registers for doing the above task which was
previously done in omap glue and in omap-usb2 phy will be removed.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |   26 ++-
 Documentation/devicetree/bindings/usb/usb-phy.txt  |5 +
 drivers/usb/phy/Kconfig|9 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/omap-control-usb.c |  204 
 include/linux/usb/omap_control_usb.h   |   72 +++
 6 files changed, 316 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/phy/omap-control-usb.c
 create mode 100644 include/linux/usb/omap_control_usb.h

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 29a043e..ead6ba9 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -1,4 +1,4 @@
-OMAP GLUE
+OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
 
 OMAP MUSB GLUE
  - compatible : Should be ti,omap4-musb or ti,omap3-musb
@@ -16,6 +16,10 @@ OMAP MUSB GLUE
  - power : Should be 50. This signifies the controller can supply upto
100mA when operating in host mode.
 
+Optional properties:
+ - ctrl_module : phandle of the control module this glue uses to write to
+   mailbox
+
 SOC specific device node entry
 usb_otg_hs: usb_otg_hs@4a0ab000 {
compatible = ti,omap4-musb;
@@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
multipoint = 1;
num_eps = 16;
ram_bits = 12;
+   ctrl_module = omap_control_usb;
 };
 
 Board specific device node entry
@@ -31,3 +36,22 @@ Board specific device node entry
mode = 3;
power = 50;
 };
+
+OMAP CONTROL USB
+
+Required properties:
+ - compatible: Should be ti,omap-control-usb
+ - reg : Address and length of the register set for the device. It contains
+   the address of control_dev_conf and otghs_control.
+ - reg-names: The names of the register addresses corresponding to the 
registers
+   filled in reg.
+ - ti,has_mailbox: This is used to specify if the platform has mailbox in
+   control module.
+
+omap_control_usb: omap-control-usb@4a002300 {
+   compatible = ti,omap-control-usb;
+   reg = 0x4a002300 0x4,
+ 0x4a00233c 0x4;
+   reg-names = control_dev_conf, otghs_control;
+   ti,has_mailbox;
+};
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 80d4148..2466b6f 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -8,10 +8,15 @@ Required properties:
 add the address of control module dev conf register until a driver for
 control module is added
 
+Optional properties:
+ - ctrl_module : phandle of the control module used by PHY driver to power on
+   the PHY.
+
 This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58,
  0x4a002300 0x4;
+   ctrl_module = omap_control_usb;
 };
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 5de6e7f..a7277ee 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -14,6 +14,15 @@ config OMAP_USB2
  The USB OTG controller communicates with the comparator using this
  driver.
 
+config OMAP_CONTROL_USB
+   tristate OMAP CONTROL USB Driver
+   depends on ARCH_OMAP2PLUS
+   help
+ Enable this to add support for the USB part present in the control
+ module. This driver has API to power on the PHY and to write to the
+ mailbox. The mailbox is present only in omap4 and the register to
+ power on the PHY is present in omap4 and omap5.
+
 config USB_ISP1301
tristate NXP ISP1301 USB transceiver support
depends on USB || USB_GADGET
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1a579a8..0dea4d2 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,6 +5,7 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_OMAP_USB2)+= omap-usb2.o
+obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
diff --git a/drivers/usb/phy/omap-control-usb.c 
b/drivers/usb/phy/omap-control-usb.c
new file mode 100644
index 000..7edeb41
--- /dev/null
+++ b/drivers/usb/phy/omap-control-usb.c
@@ -0,0 +1,204 @@
+/*
+ * omap-control-usb.c - The USB part of control module.
+ *
+ * Copyright (C) 

[PATCH 0/4] usb: musb: add driver for control module

2013-01-18 Thread Kishon Vijay Abraham I
Added a new driver for the usb part of control module. This has an API
to power on the USB2 phy and an API to write to the mailbox depending on
whether MUSB has to act in host mode or in device mode.

Writing to control module registers for doing the above task which was
previously done in omap glue and in omap-usb2 phy is removed.

Changes from RFC:
* Used #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB) instead of 
  #if (defined(CONFIG_OMAP_CONTROL_USB) || \
defined(CONFIG_OMAP_CONTROL_USB_MODULE))

* return -EADDRNOTAVAIL if devm_request_and_ioremap fails.

* Removed the dt data from this patch series (I'll send that as a separate
series).

* added ctrl_module binding to usb otg glue and usb phy in the Documentaion.
  This binding is not planned to be used until an actual requirement for
  it arises.

This series was developed on
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv

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

Kishon Vijay Abraham I (4):
  drivers: usb: phy: add a new driver for usb part of control module
  ARM: OMAP: devices: create device for usb part of control module
  ARM: OMAP2: MUSB: Specify omap4 has mailbox
  drivers: usb: start using the control module driver

 Documentation/devicetree/bindings/usb/omap-usb.txt |   30 ++-
 Documentation/devicetree/bindings/usb/usb-phy.txt  |   12 +-
 arch/arm/mach-omap2/devices.c  |   48 +
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   13 --
 arch/arm/mach-omap2/usb-musb.c |3 +
 drivers/usb/musb/Kconfig   |1 +
 drivers/usb/musb/omap2430.c|   64 +++---
 drivers/usb/musb/omap2430.h|9 -
 drivers/usb/phy/Kconfig|   10 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/omap-control-usb.c |  204 
 drivers/usb/phy/omap-usb2.c|   38 +---
 include/linux/usb/musb.h   |2 +
 include/linux/usb/omap_control_usb.h   |   72 +++
 include/linux/usb/omap_usb.h   |4 +-
 15 files changed, 411 insertions(+), 100 deletions(-)
 create mode 100644 drivers/usb/phy/omap-control-usb.c
 create mode 100644 include/linux/usb/omap_control_usb.h

-- 
1.7.9.5

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


[PATCH 4/4] drivers: usb: start using the control module driver

2013-01-18 Thread Kishon Vijay Abraham I
Start using the control module driver for powering on the PHY and for
writing to the mailbox instead of writing to the control module
registers on their own.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |4 ++
 Documentation/devicetree/bindings/usb/usb-phy.txt  |7 +--
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   13 
 drivers/usb/musb/Kconfig   |1 +
 drivers/usb/musb/omap2430.c|   64 
 drivers/usb/musb/omap2430.h|9 ---
 drivers/usb/phy/Kconfig|1 +
 drivers/usb/phy/omap-usb2.c|   38 +++-
 include/linux/usb/omap_usb.h   |4 +-
 9 files changed, 42 insertions(+), 99 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index ead6ba9..8bedbba 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -3,6 +3,9 @@ OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
 OMAP MUSB GLUE
  - compatible : Should be ti,omap4-musb or ti,omap3-musb
  - ti,hwmods : must be usb_otg_hs
+ - ti,has_mailbox : to specify that omap uses an external mailbox
+   (in control module) to communicate with the musb core during device connect
+   and disconnect.
  - multipoint : Should be 1 indicating the musb controller supports
multipoint. This is a MUSB configuration-specific setting.
  - num_eps : Specifies the number of endpoints. This is also a
@@ -24,6 +27,7 @@ SOC specific device node entry
 usb_otg_hs: usb_otg_hs@4a0ab000 {
compatible = ti,omap4-musb;
ti,hwmods = usb_otg_hs;
+   ti,has_mailbox;
multipoint = 1;
num_eps = 16;
ram_bits = 12;
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 2466b6f..48761a2 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -4,9 +4,7 @@ OMAP USB2 PHY
 
 Required properties:
  - compatible: Should be ti,omap-usb2
- - reg : Address and length of the register set for the device. Also
-add the address of control module dev conf register until a driver for
-control module is added
+ - reg : Address and length of the register set for the device.
 
 Optional properties:
  - ctrl_module : phandle of the control module used by PHY driver to power on
@@ -16,7 +14,6 @@ This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
-   reg = 0x4a0ad080 0x58,
- 0x4a002300 0x4;
+   reg = 0x4a0ad080 0x58;
ctrl_module = omap_control_usb;
 };
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 129d508..103f4ba 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2698,13 +2698,6 @@ static struct resource omap44xx_usb_phy_and_pll_addrs[] 
= {
.end= 0x4a0ae000,
.flags  = IORESOURCE_MEM,
},
-   {
-   /* XXX: Remove this once control module driver is in place */
-   .name   = ctrl_dev,
-   .start  = 0x4a002300,
-   .end= 0x4a002303,
-   .flags  = IORESOURCE_MEM,
-   },
{ }
 };
 
@@ -6152,12 +6145,6 @@ static struct omap_hwmod_addr_space 
omap44xx_usb_otg_hs_addrs[] = {
.pa_end = 0x4a0ab7ff,
.flags  = ADDR_TYPE_RT
},
-   {
-   /* XXX: Remove this once control module driver is in place */
-   .pa_start   = 0x4a00233c,
-   .pa_end = 0x4a00233f,
-   .flags  = ADDR_TYPE_RT
-   },
{ }
 };
 
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 23a0b7f..de6e5ce 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -11,6 +11,7 @@ config USB_MUSB_HDRC
select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX)
select TWL4030_USB if MACH_OMAP_3430SDP
select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
+   select OMAP_CONTROL_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
select USB_OTG_UTILS
help
  Say Y here if your system has a dual role high speed USB
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index da00af4..3e7ceef 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -37,6 +37,7 @@
 #include linux/err.h
 #include linux/delay.h
 #include linux/usb/musb-omap.h
+#include linux/usb/omap_control_usb.h
 
 #include musb_core.h
 #include omap2430.h
@@ -46,7 +47,7 @@ struct omap2430_glue {
struct 

[PATCH 3/4] ARM: OMAP2: MUSB: Specify omap4 has mailbox

2013-01-18 Thread Kishon Vijay Abraham I
Added has_mailbox to the musb platform data to specify that omap uses
an external mailbox (in control module) to communicate with the musb
core during device connect and disconnect.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/usb-musb.c |3 +++
 include/linux/usb/musb.h   |2 ++
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 7b33b37..9d27e3f 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -85,6 +85,9 @@ void __init usb_musb_init(struct omap_musb_board_data 
*musb_board_data)
musb_plat.mode = board_data-mode;
musb_plat.extvbus = board_data-extvbus;
 
+   if (cpu_is_omap44xx())
+   musb_plat.has_mailbox = true;
+
if (soc_is_am35xx()) {
oh_name = am35x_otg_hs;
name = musb-am35x;
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index eb50525..053c268 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -99,6 +99,8 @@ struct musb_hdrc_platform_data {
/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
u8  mode;
 
+   u8  has_mailbox:1;
+
/* for clk_get() */
const char  *clock;
 
-- 
1.7.9.5

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


[PATCH 2/4] ARM: OMAP: devices: create device for usb part of control module

2013-01-18 Thread Kishon Vijay Abraham I
A seperate driver has been added to handle the usb part of control
module. A device for the above driver is created here, using the register
address information to be used by the driver for powering on the PHY and
for writing to the mailbox.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/mach-omap2/devices.c |   48 +
 1 file changed, 48 insertions(+)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 5e304d0..a58b0ce 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -20,6 +20,7 @@
 #include linux/pinctrl/machine.h
 #include linux/platform_data/omap4-keypad.h
 #include linux/platform_data/omap_ocp2scp.h
+#include linux/usb/omap_control_usb.h
 
 #include asm/mach-types.h
 #include asm/mach/map.h
@@ -254,6 +255,52 @@ static inline void omap_init_camera(void)
 #endif
 }
 
+#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
+static struct omap_control_usb_platform_data omap4_control_usb_pdata = {
+   .has_mailbox = true,
+};
+
+struct resource omap4_control_usb_res[] = {
+   {
+   .name   = control_dev_conf,
+   .start  = 0x4a002300,
+   .end= 0x4a002303,
+   .flags  = IORESOURCE_MEM,
+   },
+   {
+   .name   = otghs_control,
+   .start  = 0x4a00233c,
+   .end= 0x4a00233f,
+   .flags  = IORESOURCE_MEM,
+   },
+};
+
+static struct platform_device omap4_control_usb = {
+   .name   = omap-control-usb,
+   .id = -1,
+   .dev = {
+   .platform_data = omap4_control_usb_pdata,
+   },
+   .num_resources = 2,
+   .resource = omap4_control_usb_res,
+};
+
+static inline void __init omap_init_control_usb(void)
+{
+   int ret = 0;
+
+   if (cpu_is_omap44xx()) {
+   ret = platform_device_register(omap4_control_usb);
+   if (ret)
+   pr_err(Error registering omap_control_usb device:%d\n,
+   ret);
+   }
+}
+
+#else
+static inline void omap_init_control_usb(void) { }
+#endif /* CONFIG_OMAP_CONTROL_USB */
+
 int __init omap4_keyboard_init(struct omap4_keypad_platform_data
*sdp4430_keypad_data, struct omap_board_data *bdata)
 {
@@ -721,6 +768,7 @@ static int __init omap2_init_devices(void)
omap_init_mbox();
/* If dtb is there, the devices will be created dynamically */
if (!of_have_populated_dt()) {
+   omap_init_control_usb();
omap_init_dmic();
omap_init_mcpdm();
omap_init_mcspi();
-- 
1.7.9.5

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


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

2013-01-18 Thread Roger Quadros
On 01/17/2013 06:59 PM, Tony Lindgren wrote:
 * Alan Stern st...@rowland.harvard.edu [130117 07:19]:
 On Thu, 17 Jan 2013, Roger Quadros wrote:

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

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

 CC: Alan Stern st...@rowland.harvard.edu

 Signed-off-by: Roger Quadros rog...@ti.com

 For the ehci-omap.c part:

 Acked-by: Alan Stern st...@rowland.harvard.edu
 
 If Samuel acks this patch, I can apply just this patch alone on v3.8-rc3
 into an immutable branch omap-for-v3.9/board-usb so we all merge it in
 as needed.
 

I'll be sending a v8 of this series with one stable patch candidate
before this patch and Felipe's comments addressed.

--
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 0/3] ARM: dts: omap: add dt data for MUSB

2013-01-18 Thread Kishon Vijay Abraham I
This patch series adds dt data to get MUSB working in omap4 and omap3.
Long time back a patch series with the same title was sent but only
a part of it got merged. The rest of it wasn't merged because of
adding omap control usb data to glue and usb phy.

Now there exists a separate driver for control usb and hence added a
separate dt node for control usb.

This series was developed on
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv
+ usb: musb: add driver for control module patch series

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

Kishon Vijay Abraham I (3):
  ARM: dts: omap: Add omap control usb data
  ARM: dts: omap: Add omap-usb2 dt data
  ARM: dts: omap: Add usb_otg and glue data

 Documentation/devicetree/bindings/usb/omap-usb.txt |2 ++
 arch/arm/boot/dts/omap3-beagle-xm.dts  |6 +
 arch/arm/boot/dts/omap3-evm.dts|6 +
 arch/arm/boot/dts/omap3-overo.dtsi |6 +
 arch/arm/boot/dts/omap3.dtsi   |   12 ++
 arch/arm/boot/dts/omap4-panda.dts  |6 +
 arch/arm/boot/dts/omap4-sdp.dts|6 +
 arch/arm/boot/dts/omap4.dtsi   |   25 
 arch/arm/boot/dts/twl4030.dtsi |2 +-
 9 files changed, 70 insertions(+), 1 deletion(-)

-- 
1.7.9.5

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


[PATCH 1/3] ARM: dts: omap: Add omap control usb data

2013-01-18 Thread Kishon Vijay Abraham I
Add omap control usb data in omap4 device tree file. This will have the
register address of registers to power on the PHY and to write to
mailbox.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 arch/arm/boot/dts/omap4.dtsi |8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 739bb79..ad837e6 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -529,5 +529,13 @@
ti,hwmods = timer11;
ti,timer-pwm;
};
+
+   omap_control_usb: omap-control-usb@4a002300 {
+   compatible = ti,omap-control-usb;
+   reg = 0x4a002300 0x4,
+ 0x4a00233c 0x4;
+   reg-names = control_dev_conf, otghs_control;
+   ti,has_mailbox;
+   };
};
 };
-- 
1.7.9.5

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


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

2013-01-18 Thread Ming Lei
On Fri, Jan 18, 2013 at 5:57 AM, Andrew Morton
a...@linux-foundation.org wrote:

 Fair enough, thanks.

 I grabbed the patches for 3.9-rc1.  It is good that the page
 allocator's newly-added test of current-flags is not on the fastpath.


Andrew, great thanks, :-)

Also thank Alan, Oliver, Minchan, Rafael, Greg and other guys who
reviewed and gave suggestions on this patch set.

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


Re: usb3.0 device recognized as usb2.1

2013-01-18 Thread kishon

Hi,

On Friday 18 January 2013 03:25 AM, Richard Genoud wrote:

Hi,
I've got an usb3.0 HDD dock ( http://www.icydock.com/goods.php?id=130
) wich uses JMicron JMS539 chipset and an USB3.0 board based on VIA
VL800 B3 ( http://www.ldlc.com/fiche/PB00130847.html )
When I plug the dock in an UBS3.0 port, it's recognized as an usb2.1 device.

I'm on debian unstable (3.2), and I tried with the 3.8-rc2 kernel.
The following logs are all on vanilla 3.8-rc2.

lsusb -v

Bus 001 Device 002: ID 2109:0811
Device Descriptor:
   bLength18
   bDescriptorType 1
   bcdUSB   2.00
   bDeviceClass9 Hub
   bDeviceSubClass 0 Unused
   bDeviceProtocol 1 Single TT
   bMaxPacketSize064
   idVendor   0x2109
   idProduct  0x0811
   bcdDevice2.00
   iManufacturer   0
   iProduct1 USB2.0 Hub
   iSerial 0
   bNumConfigurations  1
   Configuration Descriptor:
 bLength 9
 bDescriptorType 2
 wTotalLength   25
 bNumInterfaces  1
 bConfigurationValue 1
 iConfiguration  0
 bmAttributes 0xe0
   Self Powered
   Remote Wakeup
 MaxPower  100mA
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber0
   bAlternateSetting   0
   bNumEndpoints   1
   bInterfaceClass 9 Hub
   bInterfaceSubClass  0 Unused
   bInterfaceProtocol  0 Full speed (or root) hub
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x81  EP 1 IN
 bmAttributes3
   Transfer TypeInterrupt
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0001  1x 1 bytes
 bInterval  12
Hub Descriptor:
   bLength   9
   bDescriptorType  41
   nNbrPorts 4
   wHubCharacteristic 0x00e9
 Per-port power switching
 Per-port overcurrent protection
 TT think time 32 FS bits
 Port indicators
   bPwrOn2PwrGood   50 * 2 milli seconds
   bHubContrCurrent100 milli Ampere
   DeviceRemovable0x00
   PortPwrCtrlMask0xff
  Hub Port Status:
Port 1: .0100 power
Port 2: .0100 power
Port 3: .0100 power
Port 4: .0503 highspeed power enable connect
Device Qualifier (for other device speed):
   bLength10
   bDescriptorType 6
   bcdUSB   2.00
   bDeviceClass9 Hub
   bDeviceSubClass 0 Unused
   bDeviceProtocol 0 Full speed (or root) hub
   bMaxPacketSize064
   bNumConfigurations  1
Device Status: 0x060a
   (Bus Powered)
   Remote Wakeup Enabled

Bus 003 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Device Descriptor:
   bLength18
   bDescriptorType 1
   bcdUSB   2.00
   bDeviceClass9 Hub
   bDeviceSubClass 0 Unused
   bDeviceProtocol 1 Single TT
   bMaxPacketSize064
   idVendor   0x8087 Intel Corp.
   idProduct  0x0020 Integrated Rate Matching Hub
   bcdDevice0.00
   iManufacturer   0
   iProduct0
   iSerial 0
   bNumConfigurations  1
   Configuration Descriptor:
 bLength 9
 bDescriptorType 2
 wTotalLength   25
 bNumInterfaces  1
 bConfigurationValue 1
 iConfiguration  0
 bmAttributes 0xe0
   Self Powered
   Remote Wakeup
 MaxPower0mA
 Interface Descriptor:
   bLength 9
   bDescriptorType 4
   bInterfaceNumber0
   bAlternateSetting   0
   bNumEndpoints   1
   bInterfaceClass 9 Hub
   bInterfaceSubClass  0 Unused
   bInterfaceProtocol  0 Full speed (or root) hub
   iInterface  0
   Endpoint Descriptor:
 bLength 7
 bDescriptorType 5
 bEndpointAddress 0x81  EP 1 IN
 bmAttributes3
   Transfer TypeInterrupt
   Synch Type   None
   Usage Type   Data
 wMaxPacketSize 0x0001  1x 1 bytes
 bInterval  12
Hub Descriptor:
   bLength   9
   bDescriptorType  41
   nNbrPorts 6
   wHubCharacteristic 0x0089
 Per-port power switching
 Per-port overcurrent protection
 TT think time 8 FS bits
 Port indicators
   bPwrOn2PwrGood   50 * 2 milli seconds
   bHubContrCurrent  0 milli Ampere
   DeviceRemovable0x00
   PortPwrCtrlMask0xff
  Hub Port Status:
Port 1: .0100 power
 

[LINKING BREAKAGE] mv_udc_core has unmet dependencies

2013-01-18 Thread Felipe Balbi
Hi Chao,

You latest patches caused another breakage for x86. Please fix it asap
or I will have to drop all your changes from my pull request.

ERROR: mv_usb2_unregister_notifier [drivers/usb/gadget/mv_udc.ko] undefined!
ERROR: mv_usb2_register_notifier [drivers/usb/gadget/mv_udc.ko] undefined!
ERROR: mv_usb2_get_phy [drivers/usb/gadget/mv_udc.ko] undefined!
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2

-- 
balbi


signature.asc
Description: Digital signature


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

2013-01-18 Thread Lan Tianyu
On 2013年01月16日 23:45, Alan Stern wrote:
 On Tue, 15 Jan 2013, Lan Tianyu wrote:
 
 Hi GregAlan:
  Do you have some more comments about this patchset? Thanks.
 
 I don't have any more comments at this point.  It looks okay to me.
 
 Acked-by: Alan Stern st...@rowland.harvard.edu
 
 By the way, have you checked whether the auto-power-off mechanism works 
 correctly when you do a system suspend?
 
Thanks for reminder. I test this today and find an issue. If usb device
was powered off during runtime, pm_runtime_get_sync() in the
usb_port_resume() will return -EACCES when do system resume. This is
because port's runtime pm was disabled during system suspend. Following
are some log. The device's runtime pm will be enabled after system
suspend. The port device is advance to be inserted in the dpm_list than
usb device(port device is created before creating usb device). So the
resume sequence is that resume usb device firstly and then usb port. In
the result, pm_runtime_get_sync() doesn't work.

[   70.448028] power LNXPOWER:03: driver resume
[   70.448029] usb usb4: runtime enable
[   70.448031] usb 3-1: can't resume usb port, status -13
[   70.448032] usb usb4: type resume
[   70.448039] dpm_run_callback(): usb_dev_resume+0x0/0x15 returns -13
[   70.448040] usb usb4: usb resume
[   70.448041] usb 3-2: can't resume usb port, status -13
[   70.448043] PM: Device 3-1 failed to resume async: error -13
[   70.448047] dpm_run_callback(): usb_dev_resume+0x0/0x15 returns -13
[   70.448048] PM: Device 3-2 failed to resume async: error -13
[   70.448056] hub 4-0:1.0: hub_resume
[   70.448088] acpi device:49: runtime enable

I found one solution of adding pm_runtime_enable/disable() in the
usb_port_resume(). This is simple sovlution.

if (port_dev-did_runtime_put) {
if (!PMSG_IS_AUTO(msg)) {
pm_runtime_enable(port_dev-dev);
status = pm_runtime_get_sync(port_dev-dev);
pm_runtime_disable(port_dev-dev);
} else
status = pm_runtime_get_sync(port_dev-dev);

port_dev-did_runtime_put = false;
if (status  0) {
dev_dbg(udev-dev, can't resume usb port, status %d\n,
status);
return status;
}
}

This can work but I am not sure that it is safe to do system resume() in
the system resume().

Another proposal is to export usb_port_runtime_resume() or do a wrapper.
Call it in the usb_port_resume() with pm_runtime_get_noresume() and
pm_runtime_set_active(). This also work.

if (port_dev-did_runtime_put) {
if (!PMSG_IS_AUTO(msg)) {
status = usb_port_runtime_resume(port_dev-dev);
pm_runtime_get_noresume(port_dev-dev);
pm_runtime_set_active(udev-dev);
} else
status = pm_runtime_get_sync(port_dev-dev);

port_dev-did_runtime_put = false;
if (status  0) {
dev_dbg(udev-dev, can't resume usb port, status %d\n,
status);
return status;
}
}





 Alan Stern
 


-- 
Best regards
Tianyu Lan
--
To unsubscribe from this list: send the line unsubscribe 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: gadget: fix two sparse warnings

2013-01-18 Thread Felipe Balbi
drivers/usb/gadget/u_serial.c:1291:5: sparse: symbol \
'userial_init' was not declared. Should it be static?
drivers/usb/gadget/zero.c:66:25: sparse: symbol \
'gzero_options' was not declared. Should it be static?

Reported-by: Fengguang Wu fengguang...@intel.com
Signed-off-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/gadget/u_serial.c | 2 +-
 drivers/usb/gadget/zero.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index ea360fd..9e14079 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -1288,7 +1288,7 @@ void gserial_disconnect(struct gserial *gser)
 }
 EXPORT_SYMBOL_GPL(gserial_disconnect);
 
-int userial_init(void)
+static int userial_init(void)
 {
unsignedi;
int status;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index a331ab1..685fa68 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -63,7 +63,7 @@ static const char longname[] = Gadget Zero;
 static bool loopdefault = 0;
 module_param(loopdefault, bool, S_IRUGO|S_IWUSR);
 
-struct usb_zero_options gzero_options = {
+static struct usb_zero_options gzero_options = {
.isoc_interval = 4,
.isoc_maxpacket = 1024,
.bulk_buflen = 4096,
-- 
1.8.1.rc1.5.g7e0651a

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


[PATCH V2] usb/dwc3: fix ep-maxburst for ep0

2013-01-18 Thread Pratyush Anand
dwc3_gadget_set_ep_config expects maxburst as incremented by 1. So, by
default initialize ep-maxburst to 1 for ep0.

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
 drivers/usb/dwc3/gadget.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 66d854b..1516f1a 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1634,6 +1634,7 @@ static int __devinit dwc3_gadget_init_endpoints(struct 
dwc3 *dwc)
 
if (epnum == 0 || epnum == 1) {
dep-endpoint.maxpacket = 512;
+   dep-endpoint.maxburst = 1;
dep-endpoint.ops = dwc3_gadget_ep0_ops;
if (!epnum)
dwc-gadget.ep0 = dep-endpoint;
-- 
1.7.5.4

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


Re: [RFC PATCH 0/7] usb: musb: add driver for control module

2013-01-18 Thread Felipe Balbi
Hi,

On Tue, Jan 15, 2013 at 02:12:51PM +0530, Kishon Vijay Abraham I wrote:
 Added a new driver for the usb part of control module. This has an API
 to power on the USB2 phy and an API to write to the mailbox depending on
 whether MUSB has to act in host mode or in device mode.
 
 Writing to control module registers for doing the above task which was
 previously done in omap glue and in omap-usb2 phy is removed.
 
 Also added the dt data to get MUSB working in OMAP platforms.
 This series has patches for both drivers and ARCH folders, so If it has to
 be split I'll do it.
 
 This series was developed on
 git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv
 
 Did basic enumeration testing in omap4 beagle, omap4 sdp and omap3 beagle.

can you resend without RFC tag so I can apply ?

Thank you

-- 
balbi


signature.asc
Description: Digital signature


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

2013-01-18 Thread Felipe Balbi
On Thu, Jan 17, 2013 at 04:44:52PM +0530, kishon wrote:
 @@ -171,6 +188,11 @@ static inline void devm_usb_put_phy(struct device 
 *dev, struct usb_phy *x)
   {
   }
 
 +static inline struct usb_phy_bind *usb_bind_phy(const char *dev_name, u8 
 index,
 +   const char *phy_dev_name)
 +{
 +   return NULL;
 +}
   #endif
 
   static inline int
 
 
 Controllers like ehci-omap which don't need OTG functionality would
 benefit from this API. Can we make these PHY APIs not dependent on OTG /
 OTG_UTILS?
 
 Actually much of whatever is in otg.c can be used by controllers
 which don't have OTG functionality (except otg_state_string). I
 vaguely remember, there was a patch that renamed otg.c to phy.c etc..
 I'm not sure what happened to that.

right, that has to be done eventually ;-)

-- 
balbi


signature.asc
Description: Digital signature


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

2013-01-18 Thread Felipe Balbi
On Wed, Jan 16, 2013 at 08:30:56PM +0530, Kishon Vijay Abraham I wrote:
 New platforms are being added which has multiple PHY's (of same type) and
 which has multiple USB controllers. The binding information has to be
 present in the PHY library (otg.c) in order for it to return the
 appropriate PHY whenever the USB controller request for the PHY. So
 added a new API to pass the binding information. This API should be
 called by platform specific initialization code.
 
 So the binding should be done something like
 usb_bind_phy(musb-hdrc.0.auto, 0, omap-usb2.1.auto); specifying the USB
 controller device name, index, and the PHY device name.
 I have done this binding for OMAP platforms, but it should be done for
 all the platforms.
 
 After this design, the phy can be got by passing the USB controller device
 pointer and the index.
 
 Developed this patch series on
 git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv
 after applying usb: musb: add driver for control module patch series.
 
 Did basic enumeration testing in omap4 panda, omap4 sdp and omap3 beagle.

please resend without RFC so I can apply.

-- 
balbi


signature.asc
Description: Digital signature


[balbi-usb:gadget 19/61] drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct mv_usb_platform_data' has no member named 'phy_init'

2013-01-18 Thread kbuild test robot
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git gadget
head:   7620f5f22e9317ab26c0fdbdd15c5e9ed972ef89
commit: 84b140524c107fb4f4fe618509bc067245c9d878 [19/61] usb: phy: mv_usb2: add 
PHY driver for marvell usb2 controller
config: make ARCH=x86_64 allmodconfig

All error/warnings:

   drivers/usb/gadget/mv_udc_core.c: In function 'mv_udc_enable_internal':
 drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct 
 mv_usb_platform_data' has no member named 'phy_init'
   drivers/usb/gadget/mv_udc_core.c:1125:22: error: 'struct 
mv_usb_platform_data' has no member named 'phy_init'
   drivers/usb/gadget/mv_udc_core.c: In function 'mv_udc_disable_internal':
 drivers/usb/gadget/mv_udc_core.c:1150:17: error: 'struct 
 mv_usb_platform_data' has no member named 'phy_deinit'
   drivers/usb/gadget/mv_udc_core.c:1151:14: error: 'struct 
mv_usb_platform_data' has no member named 'phy_deinit'
--
   drivers/usb/phy/mv_usb2_phy.c: In function 'u2o_set':
   drivers/usb/phy/mv_usb2_phy.c:151:2: error: implicit declaration of function 
'writel_relaxed' [-Werror=implicit-function-declaration]
   drivers/usb/phy/mv_usb2_phy.c: In function 'usb_phy_parse_dt':
 drivers/usb/phy/mv_usb2_phy.c:350:17: warning: cast from pointer to integer 
 of different size [-Wpointer-to-int-cast]
   cc1: some warnings being treated as errors

vim +1124 drivers/usb/gadget/mv_udc_core.c

  1118  
  1119  if (udc-active)
  1120  return 0;
  1121  
  1122  dev_dbg(udc-dev-dev, enable udc\n);
  1123  udc_clock_enable(udc);
 1124  if (udc-pdata-phy_init) {
  1125  retval = udc-pdata-phy_init(udc-phy_regs);
  1126  if (retval) {
  1127  dev_err(udc-dev-dev,
  1128  init phy error %d\n, retval);
  1129  udc_clock_disable(udc);
  1130  return retval;
  1131  }
  1132  }
  1133  udc-active = 1;
  1134  
  1135  return 0;
  1136  }
  1137  
  1138  static int mv_udc_enable(struct mv_udc *udc)
  1139  {
  1140  if (udc-clock_gating)
  1141  return mv_udc_enable_internal(udc);
  1142  
  1143  return 0;
  1144  }
  1145  
  1146  static void mv_udc_disable_internal(struct mv_udc *udc)
  1147  {
  1148  if (udc-active) {
  1149  dev_dbg(udc-dev-dev, disable udc\n);
  1150  if (udc-pdata-phy_deinit)
  1151  udc-pdata-phy_deinit(udc-phy_regs);
  1152  udc_clock_disable(udc);
  1153  udc-active = 0;

---
0-DAY kernel build testing backend  Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
--
To unsubscribe from this list: send the line unsubscribe 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 0/6] USB: Add multiple PHYs of same type

2013-01-18 Thread kishon

On Friday 18 January 2013 05:18 PM, Felipe Balbi wrote:

On Wed, Jan 16, 2013 at 08:30:56PM +0530, Kishon Vijay Abraham I wrote:

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

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

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

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

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


please resend without RFC so I can apply.


I'll resend after addressing Roger's comments in a while.

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


Re: [PATCH 1/4] drivers: usb: phy: add a new driver for usb part of control module

2013-01-18 Thread Felipe Balbi
Hi,

On Fri, Jan 18, 2013 at 03:10:42PM +0530, Kishon Vijay Abraham I wrote:
 Added a new driver for the usb part of control module. This has an API
 to power on the USB2 phy and an API to write to the mailbox depending on
 whether MUSB has to act in host mode or in device mode.
 
 Writing to control module registers for doing the above task which was
 previously done in omap glue and in omap-usb2 phy will be removed.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/omap-usb.txt |   26 ++-
  Documentation/devicetree/bindings/usb/usb-phy.txt  |5 +
  drivers/usb/phy/Kconfig|9 +
  drivers/usb/phy/Makefile   |1 +
  drivers/usb/phy/omap-control-usb.c |  204 
 
  include/linux/usb/omap_control_usb.h   |   72 +++
  6 files changed, 316 insertions(+), 1 deletion(-)
  create mode 100644 drivers/usb/phy/omap-control-usb.c
  create mode 100644 include/linux/usb/omap_control_usb.h
 
 diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
 b/Documentation/devicetree/bindings/usb/omap-usb.txt
 index 29a043e..ead6ba9 100644
 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt
 +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
 @@ -1,4 +1,4 @@
 -OMAP GLUE
 +OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
  
  OMAP MUSB GLUE
   - compatible : Should be ti,omap4-musb or ti,omap3-musb
 @@ -16,6 +16,10 @@ OMAP MUSB GLUE
   - power : Should be 50. This signifies the controller can supply upto
 100mA when operating in host mode.
  
 +Optional properties:
 + - ctrl_module : phandle of the control module this glue uses to write to
 +   mailbox
 +
  SOC specific device node entry
  usb_otg_hs: usb_otg_hs@4a0ab000 {
   compatible = ti,omap4-musb;
 @@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
   multipoint = 1;
   num_eps = 16;
   ram_bits = 12;
 + ctrl_module = omap_control_usb;
  };
  
  Board specific device node entry
 @@ -31,3 +36,22 @@ Board specific device node entry
   mode = 3;
   power = 50;
  };
 +
 +OMAP CONTROL USB
 +
 +Required properties:
 + - compatible: Should be ti,omap-control-usb
 + - reg : Address and length of the register set for the device. It contains
 +   the address of control_dev_conf and otghs_control.
 + - reg-names: The names of the register addresses corresponding to the 
 registers
 +   filled in reg.
 + - ti,has_mailbox: This is used to specify if the platform has mailbox in
 +   control module.
 +
 +omap_control_usb: omap-control-usb@4a002300 {
 + compatible = ti,omap-control-usb;
 + reg = 0x4a002300 0x4,
 +   0x4a00233c 0x4;
 + reg-names = control_dev_conf, otghs_control;
 + ti,has_mailbox;
 +};
 diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
 b/Documentation/devicetree/bindings/usb/usb-phy.txt
 index 80d4148..2466b6f 100644
 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt
 +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
 @@ -8,10 +8,15 @@ Required properties:
  add the address of control module dev conf register until a driver for
  control module is added
  
 +Optional properties:
 + - ctrl_module : phandle of the control module used by PHY driver to power on
 +   the PHY.
 +
  This is usually a subnode of ocp2scp to which it is connected.
  
  usb2phy@4a0ad080 {
   compatible = ti,omap-usb2;
   reg = 0x4a0ad080 0x58,
 0x4a002300 0x4;
 + ctrl_module = omap_control_usb;
  };
 diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
 index 5de6e7f..a7277ee 100644
 --- a/drivers/usb/phy/Kconfig
 +++ b/drivers/usb/phy/Kconfig
 @@ -14,6 +14,15 @@ config OMAP_USB2
 The USB OTG controller communicates with the comparator using this
 driver.
  
 +config OMAP_CONTROL_USB
 + tristate OMAP CONTROL USB Driver
 + depends on ARCH_OMAP2PLUS
 + help
 +   Enable this to add support for the USB part present in the control
 +   module. This driver has API to power on the PHY and to write to the
 +   mailbox. The mailbox is present only in omap4 and the register to
 +   power on the PHY is present in omap4 and omap5.
 +
  config USB_ISP1301
   tristate NXP ISP1301 USB transceiver support
   depends on USB || USB_GADGET
 diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
 index 1a579a8..0dea4d2 100644
 --- a/drivers/usb/phy/Makefile
 +++ b/drivers/usb/phy/Makefile
 @@ -5,6 +5,7 @@
  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
  
  obj-$(CONFIG_OMAP_USB2)  += omap-usb2.o
 +obj-$(CONFIG_OMAP_CONTROL_USB)   += omap-control-usb.o
  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
  obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
 diff --git a/drivers/usb/phy/omap-control-usb.c 
 b/drivers/usb/phy/omap-control-usb.c
 new file mode 100644
 index 000..7edeb41
 --- 

Re: [PATCH 4/4] drivers: usb: start using the control module driver

2013-01-18 Thread Felipe Balbi
Hi,

On Fri, Jan 18, 2013 at 03:10:45PM +0530, Kishon Vijay Abraham I wrote:
 Start using the control module driver for powering on the PHY and for
 writing to the mailbox instead of writing to the control module
 registers on their own.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/omap-usb.txt |4 ++
  Documentation/devicetree/bindings/usb/usb-phy.txt  |7 +--
  arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   13 
  drivers/usb/musb/Kconfig   |1 +
  drivers/usb/musb/omap2430.c|   64 
 
  drivers/usb/musb/omap2430.h|9 ---
  drivers/usb/phy/Kconfig|1 +
  drivers/usb/phy/omap-usb2.c|   38 +++-
  include/linux/usb/omap_usb.h   |4 +-
  9 files changed, 42 insertions(+), 99 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
 b/Documentation/devicetree/bindings/usb/omap-usb.txt
 index ead6ba9..8bedbba 100644
 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt
 +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
 @@ -3,6 +3,9 @@ OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
  OMAP MUSB GLUE
   - compatible : Should be ti,omap4-musb or ti,omap3-musb
   - ti,hwmods : must be usb_otg_hs
 + - ti,has_mailbox : to specify that omap uses an external mailbox
 +   (in control module) to communicate with the musb core during device 
 connect
 +   and disconnect.
   - multipoint : Should be 1 indicating the musb controller supports
 multipoint. This is a MUSB configuration-specific setting.
   - num_eps : Specifies the number of endpoints. This is also a
 @@ -24,6 +27,7 @@ SOC specific device node entry
  usb_otg_hs: usb_otg_hs@4a0ab000 {
   compatible = ti,omap4-musb;
   ti,hwmods = usb_otg_hs;
 + ti,has_mailbox;
   multipoint = 1;
   num_eps = 16;
   ram_bits = 12;
 diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
 b/Documentation/devicetree/bindings/usb/usb-phy.txt
 index 2466b6f..48761a2 100644
 --- a/Documentation/devicetree/bindings/usb/usb-phy.txt
 +++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
 @@ -4,9 +4,7 @@ OMAP USB2 PHY
  
  Required properties:
   - compatible: Should be ti,omap-usb2
 - - reg : Address and length of the register set for the device. Also
 -add the address of control module dev conf register until a driver for
 -control module is added
 + - reg : Address and length of the register set for the device.
  
  Optional properties:
   - ctrl_module : phandle of the control module used by PHY driver to power on
 @@ -16,7 +14,6 @@ This is usually a subnode of ocp2scp to which it is 
 connected.
  
  usb2phy@4a0ad080 {
   compatible = ti,omap-usb2;
 - reg = 0x4a0ad080 0x58,
 -   0x4a002300 0x4;
 + reg = 0x4a0ad080 0x58;
   ctrl_module = omap_control_usb;
  };
 diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c 
 b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
 index 129d508..103f4ba 100644
 --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
 +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
 @@ -2698,13 +2698,6 @@ static struct resource 
 omap44xx_usb_phy_and_pll_addrs[] = {
   .end= 0x4a0ae000,
   .flags  = IORESOURCE_MEM,
   },
 - {
 - /* XXX: Remove this once control module driver is in place */
 - .name   = ctrl_dev,
 - .start  = 0x4a002300,
 - .end= 0x4a002303,
 - .flags  = IORESOURCE_MEM,
 - },
   { }
  };
  
 @@ -6152,12 +6145,6 @@ static struct omap_hwmod_addr_space 
 omap44xx_usb_otg_hs_addrs[] = {
   .pa_end = 0x4a0ab7ff,
   .flags  = ADDR_TYPE_RT
   },
 - {
 - /* XXX: Remove this once control module driver is in place */
 - .pa_start   = 0x4a00233c,
 - .pa_end = 0x4a00233f,
 - .flags  = ADDR_TYPE_RT
 - },
   { }
  };
  
 diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
 index 23a0b7f..de6e5ce 100644
 --- a/drivers/usb/musb/Kconfig
 +++ b/drivers/usb/musb/Kconfig
 @@ -11,6 +11,7 @@ config USB_MUSB_HDRC
   select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX)
   select TWL4030_USB if MACH_OMAP_3430SDP
   select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
 + select OMAP_CONTROL_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
   select USB_OTG_UTILS
   help
 Say Y here if your system has a dual role high speed USB
 diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
 index da00af4..3e7ceef 100644
 --- a/drivers/usb/musb/omap2430.c
 +++ b/drivers/usb/musb/omap2430.c
 @@ -37,6 +37,7 @@
  #include linux/err.h
  #include linux/delay.h
  #include linux/usb/musb-omap.h
 +#include 

Re: [balbi-usb:gadget 19/61] drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct mv_usb_platform_data' has no member named 'phy_init'

2013-01-18 Thread Felipe Balbi
On Fri, Jan 18, 2013 at 07:48:14PM +0800, kbuild test robot wrote:
 tree:   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git gadget
 head:   7620f5f22e9317ab26c0fdbdd15c5e9ed972ef89
 commit: 84b140524c107fb4f4fe618509bc067245c9d878 [19/61] usb: phy: mv_usb2: 
 add PHY driver for marvell usb2 controller
 config: make ARCH=x86_64 allmodconfig
 
 All error/warnings:
 
drivers/usb/gadget/mv_udc_core.c: In function 'mv_udc_enable_internal':
  drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct 
  mv_usb_platform_data' has no member named 'phy_init'
drivers/usb/gadget/mv_udc_core.c:1125:22: error: 'struct 
 mv_usb_platform_data' has no member named 'phy_init'
drivers/usb/gadget/mv_udc_core.c: In function 'mv_udc_disable_internal':
  drivers/usb/gadget/mv_udc_core.c:1150:17: error: 'struct 
  mv_usb_platform_data' has no member named 'phy_deinit'
drivers/usb/gadget/mv_udc_core.c:1151:14: error: 'struct 
 mv_usb_platform_data' has no member named 'phy_deinit'
 --
drivers/usb/phy/mv_usb2_phy.c: In function 'u2o_set':
drivers/usb/phy/mv_usb2_phy.c:151:2: error: implicit declaration of 
 function 'writel_relaxed' [-Werror=implicit-function-declaration]
drivers/usb/phy/mv_usb2_phy.c: In function 'usb_phy_parse_dt':
  drivers/usb/phy/mv_usb2_phy.c:350:17: warning: cast from pointer to 
  integer of different size [-Wpointer-to-int-cast]
cc1: some warnings being treated as errors

Chao ? Next week's friday I will send my pull request to Greg with or
without your commits.

cheers

-- 
balbi


signature.asc
Description: Digital signature


[balbi-usb:gadget 43/61] make[4]: *** No rule to make target `drivers/usb/gadget/functions.o', needed by `drivers/usb/gadget/libcomposite.o'.

2013-01-18 Thread kbuild test robot
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git gadget
head:   7620f5f22e9317ab26c0fdbdd15c5e9ed972ef89
commit: 2f06f18d080955b07c05cb2792708250f1f522e4 [43/61] usb: gadget: add some 
infracture to register/unregister functions
config: make ARCH=x86_64 allmodconfig

Note: the balbi-usb/gadget HEAD 7620f5f builds fine.
  It only hurts bisectibility.

All error/warnings:

 make[4]: *** No rule to make target `drivers/usb/gadget/functions.o', needed 
 by `drivers/usb/gadget/libcomposite.o'.
   make[4]: Target `__build' not remade because of errors.

---
0-DAY kernel build testing backend  Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
--
To unsubscribe from this list: send the line unsubscribe 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: usb3.0 device recognized as usb2.1

2013-01-18 Thread Oliver Neukum
On Friday 18 January 2013 16:36:29 kishon wrote:
  Bus 001 Device 004: ID 152d:2509 JMicron Technology Corp. / JMicron
  USA Technology Corp. JMS539 SuperSpeed SATA II 3.0G Bridge
  Device Descriptor:
 
 You are connecting to the wrong port.
 
 Try connecting to bus2 which seems to have usb3.
 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub.
 .
 .
 bcdUSB   3.00

No. Look closer.

 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Device Descriptor:
bLength18
bDescriptorType 1
bcdUSB   2.00
bDeviceClass9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 1 Single TT
bMaxPacketSize064
idVendor   0x1d6b Linux Foundation
idProduct  0x0002 2.0 root hub
bcdDevice3.06
iManufacturer   3 Linux 3.8.0-rc2 xhci_hcd
iProduct2 xHCI Host Controller
iSerial 1 :05:00.0
bNumConfigurations  1

This is the virtual root hub of the XHCI controller, to which the device is 
connected.
This is exactly what is supposed to happen if you connect a non-SS device
to an XHCI.

The question is, what goes wrong, if indeed the device is SS.

In this particular case a usbmon trace is likely not as useful as usually.
Could you compile a kernel with DEBUG for USB and XHCI enabled?

Regards
Oliver

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


Re: [PATCH 1/4] drivers: usb: phy: add a new driver for usb part of control module

2013-01-18 Thread kishon

Hi,

On Friday 18 January 2013 05:29 PM, Felipe Balbi wrote:

Hi,

On Fri, Jan 18, 2013 at 03:10:42PM +0530, Kishon Vijay Abraham I wrote:

Added a new driver for the usb part of control module. This has an API
to power on the USB2 phy and an API to write to the mailbox depending on
whether MUSB has to act in host mode or in device mode.

Writing to control module registers for doing the above task which was
previously done in omap glue and in omap-usb2 phy will be removed.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
  Documentation/devicetree/bindings/usb/omap-usb.txt |   26 ++-
  Documentation/devicetree/bindings/usb/usb-phy.txt  |5 +
  drivers/usb/phy/Kconfig|9 +
  drivers/usb/phy/Makefile   |1 +
  drivers/usb/phy/omap-control-usb.c |  204 
  include/linux/usb/omap_control_usb.h   |   72 +++
  6 files changed, 316 insertions(+), 1 deletion(-)
  create mode 100644 drivers/usb/phy/omap-control-usb.c
  create mode 100644 include/linux/usb/omap_control_usb.h

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt 
b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 29a043e..ead6ba9 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -1,4 +1,4 @@
-OMAP GLUE
+OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS

  OMAP MUSB GLUE
   - compatible : Should be ti,omap4-musb or ti,omap3-musb
@@ -16,6 +16,10 @@ OMAP MUSB GLUE
   - power : Should be 50. This signifies the controller can supply upto
 100mA when operating in host mode.

+Optional properties:
+ - ctrl_module : phandle of the control module this glue uses to write to
+   mailbox
+
  SOC specific device node entry
  usb_otg_hs: usb_otg_hs@4a0ab000 {
compatible = ti,omap4-musb;
@@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs@4a0ab000 {
multipoint = 1;
num_eps = 16;
ram_bits = 12;
+   ctrl_module = omap_control_usb;
  };

  Board specific device node entry
@@ -31,3 +36,22 @@ Board specific device node entry
mode = 3;
power = 50;
  };
+
+OMAP CONTROL USB
+
+Required properties:
+ - compatible: Should be ti,omap-control-usb
+ - reg : Address and length of the register set for the device. It contains
+   the address of control_dev_conf and otghs_control.
+ - reg-names: The names of the register addresses corresponding to the 
registers
+   filled in reg.
+ - ti,has_mailbox: This is used to specify if the platform has mailbox in
+   control module.
+
+omap_control_usb: omap-control-usb@4a002300 {
+   compatible = ti,omap-control-usb;
+   reg = 0x4a002300 0x4,
+ 0x4a00233c 0x4;
+   reg-names = control_dev_conf, otghs_control;
+   ti,has_mailbox;
+};
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt 
b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 80d4148..2466b6f 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -8,10 +8,15 @@ Required properties:
  add the address of control module dev conf register until a driver for
  control module is added

+Optional properties:
+ - ctrl_module : phandle of the control module used by PHY driver to power on
+   the PHY.
+
  This is usually a subnode of ocp2scp to which it is connected.

  usb2phy@4a0ad080 {
compatible = ti,omap-usb2;
reg = 0x4a0ad080 0x58,
  0x4a002300 0x4;
+   ctrl_module = omap_control_usb;
  };
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 5de6e7f..a7277ee 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -14,6 +14,15 @@ config OMAP_USB2
  The USB OTG controller communicates with the comparator using this
  driver.

+config OMAP_CONTROL_USB
+   tristate OMAP CONTROL USB Driver
+   depends on ARCH_OMAP2PLUS
+   help
+ Enable this to add support for the USB part present in the control
+ module. This driver has API to power on the PHY and to write to the
+ mailbox. The mailbox is present only in omap4 and the register to
+ power on the PHY is present in omap4 and omap5.
+
  config USB_ISP1301
tristate NXP ISP1301 USB transceiver support
depends on USB || USB_GADGET
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1a579a8..0dea4d2 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,6 +5,7 @@
  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

  obj-$(CONFIG_OMAP_USB2)   += omap-usb2.o
+obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o
  obj-$(CONFIG_USB_ISP1301) += isp1301.o
  obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
  obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
diff --git a/drivers/usb/phy/omap-control-usb.c 
b/drivers/usb/phy/omap-control-usb.c
new file mode 100644
index 000..7edeb41

RE: [PATCH 2/2] usb: chipidea: imx: Add system suspend/resume API

2013-01-18 Thread Chen Peter-B29397
 
 
 On Fri, Jan 18, 2013 at 10:50:28AM +0800, Peter Chen wrote:
  +#ifdef CONFIG_PM
  +static int ci13xxx_imx_suspend(struct device *dev)
  +{
  +   struct ci13xxx_imx_data *data =
  +   platform_get_drvdata(to_platform_device(dev));
 
 Is there a reason not to use dev_get_drvdata() here?  Hint:
 

It is my careless, I will change. Thanks.

 #define to_platform_device(x) container_of((x), struct platform_device,
 dev)
 
 static inline void *platform_get_drvdata(const struct platform_device
 *pdev)
 {
 return dev_get_drvdata(pdev-dev);
 }
 
 So, you're going from a dev = platform device = the same dev again.
 
 It's perfectly valid to use dev_get_drvdata() here because we're not
 going
 to separate these two (it makes absolutely no sense to.)


--
To unsubscribe from this list: send the line unsubscribe 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 v8 14/22] mfd: omap-usb-host: override number of ports from platform data

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

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

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

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


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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-host.c |  129 +++
 1 files changed, 81 insertions(+), 48 deletions(-)

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

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

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

CC: Paul Walmsley p...@pwsan.com
CC: Rajendra Nayak rna...@ti.com
CC: Benoit Cousson b-cous...@ti.com
CC: Mike Turquette mturque...@linaro.com

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
Acked-by: Paul Walmsley p...@pwsan.com
---
 arch/arm/mach-omap2/cclock3xxx_data.c |   11 ---
 1 files changed, 0 insertions(+), 11 deletions(-)

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

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


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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-host.c |   16 
 1 files changed, 0 insertions(+), 16 deletions(-)

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

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


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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-host.c |   97 --
 1 files changed, 83 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 1fc03f8..d9a242b 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -93,6 +93,8 @@
 struct usbhs_hcd_omap {
int nports;
struct clk  **utmi_clk;
+   struct clk  **hsic60m_clk;
+   struct clk  **hsic480m_clk;
 
struct clk  *xclk60mhsp1_ck;
struct clk  *xclk60mhsp2_ck;
@@ -286,13 +288,40 @@ static int usbhs_runtime_resume(struct device *dev)
clk_enable(omap-ehci_logic_fck);
 
for (i = 0; i  omap-nports; i++) {
-   if (!is_ehci_tll_mode(pdata-port_mode[i]) ||
-   !omap-utmi_clk[i])
-   continue;
-
-   r = clk_enable(omap-utmi_clk[i]);
-   if (r)
-   dev_err(dev, Can't enable port %d clk : %d\n, i, r);
+   switch (pdata-port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (omap-hsic60m_clk[i]) {
+   r = clk_enable(omap-hsic60m_clk[i]);
+   if (r) {
+   dev_err(dev,
+Can't enable port %d hsic60m 
clk:%d\n,
+i, r);
+   }
+   }
+
+   if (omap-hsic480m_clk[i]) {
+   r = clk_enable(omap-hsic480m_clk[i]);
+   if (r) {
+   dev_err(dev,
+Can't enable port %d hsic480m 
clk:%d\n,
+i, r);
+   }
+   }
+   /* Fall through as HSIC mode needs utmi_clk */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
+   if (omap-utmi_clk[i]) {
+   r = clk_enable(omap-utmi_clk[i]);
+   if (r) {
+   dev_err(dev,
+Can't enable port %d clk : %d\n,
+i, r);
+   }
+   }
+   break;
+   default:
+   break;
+   }
}
 
spin_unlock_irqrestore(omap-lock, flags);
@@ -312,9 +341,22 @@ static int usbhs_runtime_suspend(struct device *dev)
spin_lock_irqsave(omap-lock, flags);
 
for (i = 0; i  omap-nports; i++) {
-   if (is_ehci_tll_mode(pdata-port_mode[i]) 
-   omap-utmi_clk[i])
-   clk_disable(omap-utmi_clk[i]);
+   switch (pdata-port_mode[i]) {
+   case OMAP_EHCI_PORT_MODE_HSIC:
+   if (omap-hsic60m_clk[i])
+   clk_disable(omap-hsic60m_clk[i]);
+
+   if (omap-hsic480m_clk[i])
+   clk_disable(omap-hsic480m_clk[i]);
+   /* Fall through as utmi_clks were used in HSIC mode */
+
+   case OMAP_EHCI_PORT_MODE_TLL:
+   if (omap-utmi_clk[i])
+   clk_disable(omap-utmi_clk[i]);
+   break;
+   default:
+   break;
+   }
}
 
if (omap-ehci_logic_fck  !IS_ERR(omap-ehci_logic_fck))
@@ -520,7 +562,10 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
i = sizeof(struct clk *) * omap-nports;
omap-utmi_clk = devm_kzalloc(dev, i, GFP_KERNEL);
-   if (!omap-utmi_clk) {
+   omap-hsic480m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+   omap-hsic60m_clk = devm_kzalloc(dev, i, GFP_KERNEL);
+
+   if (!omap-utmi_clk || !omap-hsic480m_clk || !omap-hsic60m_clk) {
dev_err(dev, Memory allocation failed\n);
ret = -ENOMEM;
goto err_mem;
@@ -578,7 +623,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 
for (i = 0; i  omap-nports; i++) {
struct clk *pclk;
-   char clkname[] = usb_host_hs_utmi_px_clk;
+   char clkname[] = usb_host_hs_hsic480m_px_clk;
 
/* clock names are indexed from 1*/
snprintf(clkname, sizeof(clkname),
@@ -594,6 +639,24 @@ static int usbhs_omap_probe(struct platform_device *pdev)
clkname, 

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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   15 +--
 1 files changed, 5 insertions(+), 10 deletions(-)

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

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


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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-host.c |   10 --
 1 files changed, 0 insertions(+), 10 deletions(-)

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

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


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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-host.c |   38 +++---
 1 files changed, 11 insertions(+), 27 deletions(-)

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

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


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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

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

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


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

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

Without this patch, EHCI will break on repeated insmod/rmmod
of ehci_hcd for all OMAP2+ platforms that use EHCI and
set 'phy_reset = true' in usbhs_omap_board_data.
i.e.

board-3430sdp.c:.phy_reset  = true,
board-3630sdp.c:.phy_reset  = true,
board-am3517crane.c:.phy_reset  = true,
board-am3517evm.c:  .phy_reset  = true,
board-cm-t3517.c:   .phy_reset  = true,
board-cm-t35.c: .phy_reset  = true,
board-devkit8000.c: .phy_reset  = true,
board-igep0020.c:   .phy_reset = true,
board-igep0020.c:   .phy_reset = true,
board-omap3beagle.c:.phy_reset  = true,
board-omap3evm.c:   .phy_reset  = true,
board-omap3pandora.c:   .phy_reset  = true,
board-omap3stalker.c:   .phy_reset = true,
board-omap3touchbook.c: .phy_reset  = true,
board-omap4panda.c: .phy_reset  = false,
board-overo.c:  .phy_reset  = true,
board-zoom.c:   .phy_reset  = true,

CC: Alan Stern st...@rowland.harvard.edu
Cc: sta...@kernel.org

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-omap.c |8 
 1 files changed, 0 insertions(+), 8 deletions(-)

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

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


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

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

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

CC: Alan Stern st...@rowland.harvard.edu

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
For the ehci-omap.c part:
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 arch/arm/mach-omap2/board-3430sdp.c|2 +-
 arch/arm/mach-omap2/board-3630sdp.c|2 +-
 arch/arm/mach-omap2/board-am3517crane.c|2 +-
 arch/arm/mach-omap2/board-am3517evm.c  |2 +-
 arch/arm/mach-omap2/board-cm-t35.c |2 +-
 arch/arm/mach-omap2/board-cm-t3517.c   |2 +-
 arch/arm/mach-omap2/board-devkit8000.c |2 +-
 arch/arm/mach-omap2/board-igep0020.c   |4 +-
 arch/arm/mach-omap2/board-omap3beagle.c|2 +-
 arch/arm/mach-omap2/board-omap3evm.c   |2 +-
 arch/arm/mach-omap2/board-omap3pandora.c   |2 +-
 arch/arm/mach-omap2/board-omap3stalker.c   |2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c |2 +-
 arch/arm/mach-omap2/board-overo.c  |2 +-
 arch/arm/mach-omap2/board-zoom.c   |2 +-
 arch/arm/mach-omap2/usb-host.c |   29 ++---
 arch/arm/mach-omap2/usb.h  |   20 +
 drivers/mfd/omap-usb-host.c|   63 +++
 drivers/mfd/omap-usb-tll.c |   11 ++---
 drivers/usb/host/ehci-omap.c   |6 +-
 include/linux/platform_data/usb-omap.h |   23 ++
 22 files changed, 61 insertions(+), 125 deletions(-)

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

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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   53 ++-
 1 files changed, 27 insertions(+), 26 deletions(-)

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

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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

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

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


[PATCH v8 08/22] mfd: omap-usb-tll: Fix error message

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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   21 -
 1 files changed, 12 insertions(+), 9 deletions(-)

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

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


[PATCH v8 05/22] mfd: omap-usb-tll: Clean up clock handling

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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   89 +++
 1 files changed, 56 insertions(+), 33 deletions(-)

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

[PATCH v8 03/22] mfd: omap-usb-tll: Fix channel count detection

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

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

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


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

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

Signed-off-by: Roger Quadros rog...@ti.com
Reviewed-by: Felipe Balbi ba...@ti.com
---
 drivers/mfd/omap-usb-tll.c |   38 --
 1 files changed, 12 insertions(+), 26 deletions(-)

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

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


[PATCH v8 00/22] OMAP USB Host cleanup

2013-01-18 Thread Roger Quadros
Hi,

This patchset addresses the following

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

v8:
- Re-arranged patch USB-ehci-omap-Don-t-free-gpios-that-we-didn-t-reques.patch
  to be the first since it is a candidate for stable.
- Fixed issues raised by Felipe, i.e. indentation and use of switch ()

v7:
- Updated patch 4 to not hold a spinlock when using clk_get().
- Updated patches 3 and 11 to return -EADDRNOTAVAIL on failure of
  demv_request_and_ioremap().

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

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

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

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

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

cheers,
-roger

The following changes since commit 9931faca02c604c22335f5a935a501bb2ace6e20:

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

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

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

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

-- 
1.7.4.1

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


Re: [PATCH v8 01/22] USB: ehci-omap: Don't free gpios that we didn't request

2013-01-18 Thread Roger Quadros
On 01/18/2013 02:17 PM, Roger Quadros wrote:
 This driver does not request any gpios so don't free them.
 Fixes L3 bus error on multiple modprobe/rmmod of ehci_hcd
 with ehci-omap in use.
 
 Without this patch, EHCI will break on repeated insmod/rmmod
 of ehci_hcd for all OMAP2+ platforms that use EHCI and
 set 'phy_reset = true' in usbhs_omap_board_data.
 i.e.
 
 board-3430sdp.c:  .phy_reset  = true,
 board-3630sdp.c:  .phy_reset  = true,
 board-am3517crane.c:  .phy_reset  = true,
 board-am3517evm.c:.phy_reset  = true,
 board-cm-t3517.c: .phy_reset  = true,
 board-cm-t35.c:   .phy_reset  = true,
 board-devkit8000.c:   .phy_reset  = true,
 board-igep0020.c: .phy_reset = true,
 board-igep0020.c: .phy_reset = true,
 board-omap3beagle.c:  .phy_reset  = true,
 board-omap3evm.c: .phy_reset  = true,
 board-omap3pandora.c: .phy_reset  = true,
 board-omap3stalker.c: .phy_reset = true,
 board-omap3touchbook.c:   .phy_reset  = true,
 board-omap4panda.c:   .phy_reset  = false,
 board-overo.c:.phy_reset  = true,
 board-zoom.c: .phy_reset  = true,
 
 CC: Alan Stern st...@rowland.harvard.edu
 Cc: sta...@kernel.org

I messed up with the stable list id, so will resend just this one
and update the git repo.

 
 Signed-off-by: Roger Quadros rog...@ti.com
 Reviewed-by: Felipe Balbi ba...@ti.com
 Acked-by: Alan Stern st...@rowland.harvard.edu

cheers,
-roger

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


Re: Wake on LAN for USB ethernet?

2013-01-18 Thread Ming Lei
On Fri, Jan 18, 2013 at 4:53 PM, Petko Manolov pet...@nucleusys.com wrote:
 The code in the driver is based on the specs from ADMTek (later, Infineon).
 Since i never suspend my machines this feature has not been tested by me.

 However, if the proposed patch is the right thing to do i'd be happy to see
 it applied.

I think it is the right thing, at least many network drivers do that, such as
smsc usbnet drivers and many of PCI ethernet drivers.

So I will prepare one formal version for merge.

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


Re: [PATCH v6 3/4] USB: ehci-s5p: Add phy driver support

2013-01-18 Thread Felipe Balbi
On Fri, Jan 11, 2013 at 08:32:29PM +0530, Vivek Gautam wrote:
 Adding the phy driver to ehci-s5p. Keeping the platform data
 for continuing the smooth operation for boards which still uses it
 
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 Acked-by: Jingoo Han jg1@samsung.com

Missing Alan's Acked-by here.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v7 2/4] usb: phy: samsung: Add host phy support to samsung-phy driver

2013-01-18 Thread Felipe Balbi
Hi,

On Mon, Jan 14, 2013 at 05:52:15PM +0530, Vivek Gautam wrote:
 This patch adds host phy support to samsung-usbphy driver and
 further adds support for samsung's exynos5250 usb-phy.
 
 Signed-off-by: Praveen Paneri p.pan...@samsung.com
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com

Missing Kukjim's Acked-by here

-- 
balbi


signature.asc
Description: Digital signature


Re: ehci-hcd compile error

2013-01-18 Thread Roger Quadros
On 01/17/2013 06:10 PM, Alan Stern wrote:
 On Thu, 17 Jan 2013, Roger Quadros wrote:
 
 Alan,

 What tree is your patch based off?
 
 Roughly speaking, 3.7 plus Greg KH's usb-next branch as of the 3.7
 release.  This should be pretty much the same as 3.8-rc1 as far as the
 USB stack is concerned.  I haven't tried applying the patch to 3.8-rc3,
 but any merge problems should be minimal.
 
  Also, could you please send me your
 updated patch for ehci-omap.c? I'll then base my work on top of that.
 
 Attached are two patches: one to convert ehci-omap to the new library
 scheme (based on the stuff I just sent Felipe), and a second (based on
 the first) to illustrate how to allocate additional private space for
 the PHY values.  Thanks to your latest set of changes, you may not need
 to use the second patch.
 

Thanks. I used the below code (also attached) and could reproduce
corruption on the first byte at ehci-priv. This is from the the kernel log.

 [   30.381774] ehci-omap ehci-omap.0: ehci_hcd_omap_probe a 0x1234abcd, b 
 0x5679efba

 [  122.523468] ehci-omap ehci-omap.0: ehci_hcd_omap_remove a 0x1234abe0, b 
 0x5679efba

NOTE: EHCI needs to be running and you need to enumerate some device for
the corruption to happen.

If I disable CONFIG_USB_DEBUG, then there is no corruption.

From f29533ed9f9c81c9ea2e99397db65222d73069da Mon Sep 17 00:00:00 2001
From: Roger Quadros rog...@ti.com
Date: Fri, 18 Jan 2013 15:29:08 +0200
Subject: [PATCH] test ehci-priv corruption

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

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index fd2f5450..ee1746d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -70,6 +70,10 @@ static const char hcd_name[] = ehci-omap;

 /*-*/

+struct omap_hcd {
+   int a;
+   int b;
+};

 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -179,6 +183,7 @@ static struct hc_driver __read_mostly
ehci_omap_hc_driver;

 static const struct ehci_driver_overrides ehci_omap_overrides
__initdata = {
.reset =omap_ehci_init,
+   .extra_priv_size= sizeof (struct omap_hcd),
 };

 /**
@@ -194,6 +199,7 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
struct usbhs_omap_platform_data *pdata = dev-platform_data;
struct resource *res;
struct usb_hcd  *hcd;
+   struct omap_hcd *omap;
void __iomem*regs;
int ret = -ENODEV;
int irq;
@@ -232,6 +238,10 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
hcd-rsrc_start = res-start;
hcd-rsrc_len = resource_size(res);
hcd-regs = regs;
+   omap = (struct omap_hcd *)hcd_to_ehci(hcd)-priv;
+   omap-a = 0x1234abcd;
+   omap-b = 0x5679efba;
+   dev_info(dev, %s a 0x%x, b 0x%x\n, __func__, omap-a, omap-b);

/* get ehci regulator and enable */
for (i = 0 ; i  OMAP3_HS_USB_PORTS ; i++) {
@@ -295,7 +305,9 @@ static int ehci_hcd_omap_remove(struct
platform_device *pdev)
 {
struct device *dev  = pdev-dev;
struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct omap_hcd *omap = (struct omap_hcd *)hcd_to_ehci(hcd)-priv;

+   dev_info(dev, %s a 0x%x, b 0x%x\n, __func__, omap-a, omap-b);
usb_remove_hcd(hcd);
disable_put_regulator(dev-platform_data);
usb_put_hcd(hcd);
-- 
1.7.4.1


From f29533ed9f9c81c9ea2e99397db65222d73069da Mon Sep 17 00:00:00 2001
From: Roger Quadros rog...@ti.com
Date: Fri, 18 Jan 2013 15:29:08 +0200
Subject: [PATCH] test ehci-priv corruption

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

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index fd2f5450..ee1746d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -70,6 +70,10 @@ static const char hcd_name[] = ehci-omap;
 
 /*-*/
 
+struct omap_hcd {
+	int a;
+	int b;
+};
 
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -179,6 +183,7 @@ static struct hc_driver __read_mostly ehci_omap_hc_driver;
 
 static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
 	.reset =		omap_ehci_init,
+	.extra_priv_size	= sizeof (struct omap_hcd),
 };
 
 /**
@@ -194,6 +199,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	struct usbhs_omap_platform_data		*pdata = dev-platform_data;
 	struct resource*res;
 	

Re: [PATCH v7 2/4] usb: phy: samsung: Add host phy support to samsung-phy driver

2013-01-18 Thread Felipe Balbi
On Fri, Jan 18, 2013 at 07:51:08PM +0530, Vivek Gautam wrote:
 Hi Felipe,
 
 
 On Fri, Jan 18, 2013 at 6:46 PM, Felipe Balbi ba...@ti.com wrote:
  Hi,
 
  On Mon, Jan 14, 2013 at 05:52:15PM +0530, Vivek Gautam wrote:
  This patch adds host phy support to samsung-usbphy driver and
  further adds support for samsung's exynos5250 usb-phy.
 
  Signed-off-by: Praveen Paneri p.pan...@samsung.com
  Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 
  Missing Kukjim's Acked-by here
 
 
 Hope you are fine with the changes happened after discussion in thread:
 [PATCH v5 2/4] usb: phy: samsung: Add host phy support to samsung-phy driver
 
 Is it something you want me to modify in this patch ?

please send the final patch and we shall see. After quickly browsing
that thread, I didn't see anything scary, but I'd like to see your final
version before giving my final answer ;-)

-- 
balbi


signature.asc
Description: Digital signature


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

2013-01-18 Thread Bernd Krumboeck
Add device driver for USB2CAN interface from 8 devices 
(http://www.8devices.com).

changes since v9:
* fixed syslog messages
* fixed crc error number
* increased MAX_RX_URBS and MAX_TX_URBS

changes since v8:
* remove all sysfs files

changes since v7:
* add sysfs documentation
* fix minor styling issue
* fixed can state for passive mode
* changed handling for crc errors

changes since v6:
* changed some variable types to big endian equivalent
* small cleanups

changes since v5:
* unlock mutex on error

changes since v4:
* removed FSF address
* renamed struct usb_8dev
* removed unused variable free_slots
* replaced some _to_cpu functions with pointer equivalent
* fix return value for usb_8dev_set_mode
* handle can errors with separate function
* fix overrun error handling
* rewrite error handling for usb_8dev_start_xmit
* fix urb submit in usb_8dev_start
* various small fixes

Signed-off-by: Bernd Krumboeck krumbo...@universalnet.at
Acked-by: Wolfgang Grandegger w...@grandegger.com
---
 drivers/net/can/usb/Kconfig|6 +
 drivers/net/can/usb/Makefile   |1 +
 drivers/net/can/usb/usb_8dev.c | 1037 
 3 files changed, 1044 insertions(+)
 create mode 100644 drivers/net/can/usb/usb_8dev.c

diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig
index a4e4bee..2162233 100644
--- a/drivers/net/can/usb/Kconfig
+++ b/drivers/net/can/usb/Kconfig
@@ -48,4 +48,10 @@ config CAN_PEAK_USB
  This driver supports the PCAN-USB and PCAN-USB Pro adapters
  from PEAK-System Technik (http://www.peak-system.com).
 
+config CAN_8DEV_USB
+   tristate 8 devices USB2CAN interface
+   ---help---
+ This driver supports the USB2CAN interface
+ from 8 devices (http://www.8devices.com).
+
 endmenu
diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile
index 80a2ee4..becef46 100644
--- a/drivers/net/can/usb/Makefile
+++ b/drivers/net/can/usb/Makefile
@@ -6,5 +6,6 @@ obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
 obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
 obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
 obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
+obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
 
 ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
new file mode 100644
index 000..1c6d5ef
--- /dev/null
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -0,0 +1,1037 @@
+/*
+ * CAN driver for 8 devices USB2CAN converter
+ *
+ * Copyright (C) 2012 Bernd Krumboeck (krumbo...@universalnet.at)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.
+ *
+ * This driver is inspired by the 3.2.0 version of 
drivers/net/can/usb/ems_usb.c
+ * and drivers/net/can/usb/esd_usb2.c
+ *
+ * Many thanks to Gerhard Bertelsmann (i...@gerhard-bertelsmann.de)
+ * for testing and fixing this driver. Also many thanks to 8 devices,
+ * who were very cooperative and answered my questions.
+ */
+
+#include linux/init.h
+#include linux/signal.h
+#include linux/slab.h
+#include linux/module.h
+#include linux/netdevice.h
+#include linux/usb.h
+
+#include linux/can.h
+#include linux/can/dev.h
+#include linux/can/error.h
+
+/* driver constants */
+#define MAX_RX_URBS20
+#define MAX_TX_URBS20
+#define RX_BUFFER_SIZE 64
+
+/* vendor and product id */
+#define USB_8DEV_VENDOR_ID 0x0483
+#define USB_8DEV_PRODUCT_ID0x1234
+
+/* endpoints */
+enum usb_8dev_endpoint {
+   USB_8DEV_ENDP_DATA_RX = 1,
+   USB_8DEV_ENDP_DATA_TX,
+   USB_8DEV_ENDP_CMD_RX,
+   USB_8DEV_ENDP_CMD_TX
+};
+
+/* bittiming constants */
+#define USB_8DEV_ABP_CLOCK 3200
+#define USB_8DEV_BAUD_MANUAL   0x09
+#define USB_8DEV_TSEG1_MIN 1
+#define USB_8DEV_TSEG1_MAX 16
+#define USB_8DEV_TSEG2_MIN 1
+#define USB_8DEV_TSEG2_MAX 8
+#define USB_8DEV_SJW_MAX   4
+#define USB_8DEV_BRP_MIN   1
+#define USB_8DEV_BRP_MAX   1024
+#define USB_8DEV_BRP_INC   1
+
+/* setup flags */
+#define USB_8DEV_SILENT0x01
+#define USB_8DEV_LOOPBACK  0x02
+#define USB_8DEV_DISABLE_AUTO_RESTRANS 0x04
+#define USB_8DEV_STATUS_FRAME  0x08
+
+/* commands */
+enum usb_8dev_cmd {
+   USB_8DEV_RESET = 1,
+   USB_8DEV_OPEN,
+   USB_8DEV_CLOSE,
+   USB_8DEV_SET_SPEED,
+   USB_8DEV_SET_MASK_FILTER,
+   

[PATCH net] net: cdc_ncm: workaround for missing CDC Union

2013-01-18 Thread Bjørn Mork
Adding support for the MBIM mode in some Sierra Wireless devices.

Some Sierra Wireless firmwares support CDC MBIM but have no CDC
Union funtional descriptor. This violates the MBIM specification,
but we can easily work around the bug by looking at the Interface
Association Descriptor instead.  This is most likely what
Windows uses too, which explains how the firmware bug has gone
unnoticed until now.

This change will not affect any currently supported device
conforming to the NCM or MBIM specifications, as they must have
the CDC Union descriptor.

Cc: Greg Suarez gsua...@smithmicro.com
Cc: Alexey Orishko alexey.oris...@stericsson.com
Signed-off-by: Bjørn Mork bj...@mork.no
---
 drivers/net/usb/cdc_ncm.c |   25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92..5c1210f 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -344,6 +344,21 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
.nway_reset = usbnet_nway_reset,
 };
 
+/* return first slave interface if an IAD matches the given master */
+static struct usb_interface *get_iad_slave(struct usb_device *udev,
+  struct usb_interface *master) {
+   int i;
+   struct usb_interface_assoc_descriptor *iad;
+   u8 mnum = master-cur_altsetting-desc.bInterfaceNumber;
+
+   for (i = 0; i  USB_MAXIADS; i++) {
+   iad = udev-actconfig-intf_assoc[i];
+   if (iad-bFirstInterface == mnum  iad-bInterfaceCount == 2)
+   return usb_ifnum_to_if(udev, mnum + 1);
+   }
+   return NULL;
+}
+
 int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 
data_altsetting)
 {
struct cdc_ncm_ctx *ctx;
@@ -435,6 +450,16 @@ advance:
len -= temp;
}
 
+   /* some buggy devices have an IAD but no CDC Union */
+   if (!ctx-union_desc) {
+   dev_dbg(intf-dev, missing CDC Union descriptor\n);
+   ctx-data = get_iad_slave(dev-udev, intf);
+   if (ctx-data) {
+   ctx-control = intf;
+   dev_dbg(intf-dev, got slave from IAD\n);
+   }
+   }
+
/* check if we got everything */
if ((ctx-control == NULL) || (ctx-data == NULL) ||
((!ctx-mbim_desc)  ((ctx-ether_desc == NULL) || (ctx-control 
!= intf
-- 
1.7.10.4

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


Re: [PATCH v7 2/4] usb: phy: samsung: Add host phy support to samsung-phy driver

2013-01-18 Thread Vivek Gautam
HI Balbi,


On Fri, Jan 18, 2013 at 7:52 PM, Felipe Balbi ba...@ti.com wrote:
 On Fri, Jan 18, 2013 at 07:51:08PM +0530, Vivek Gautam wrote:
 Hi Felipe,


 On Fri, Jan 18, 2013 at 6:46 PM, Felipe Balbi ba...@ti.com wrote:
  Hi,
 
  On Mon, Jan 14, 2013 at 05:52:15PM +0530, Vivek Gautam wrote:
  This patch adds host phy support to samsung-usbphy driver and
  further adds support for samsung's exynos5250 usb-phy.
 
  Signed-off-by: Praveen Paneri p.pan...@samsung.com
  Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 
  Missing Kukjim's Acked-by here
 

 Hope you are fine with the changes happened after discussion in thread:
 [PATCH v5 2/4] usb: phy: samsung: Add host phy support to samsung-phy driver

 Is it something you want me to modify in this patch ?

 please send the final patch and we shall see. After quickly browsing
 that thread, I didn't see anything scary, but I'd like to see your final
 version before giving my final answer ;-)


this series of patch is the final version from my side unless Doug or
you have any further comments
on the thread :
https://lkml.org/lkml/2013/1/14/481

Seems like Doug wanted to know your opinion in this regard. ;-)



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


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

2013-01-18 Thread Bernd Krumböck
 On 16.01.2013 09:07, Bernd Krumböck wrote:

 Hi Oliver!

 When detaching the device from the CAN bus when sending/receiving CAN
traffic
 i got these dmesg infos:

 [  960.047130] usb_8dev 2-1.4:1.0 can2: Unknown status/error message (0)
 [  976.544343] usb_8dev 2-1.4:1.0 can2: Unknown status/error message (0)


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

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

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



 Here some more dmesg outputs:

 [  308.198354] ems_pcmcia 0.0 can0: setting BTR0=0x00 BTR1=0x14
 [  315.208555] can: raw protocol (rev 20120528)
 [  328.579107] usb 2-1.2: new full-speed USB device number 6 using ehci-pci
 [  328.673540] usb 2-1.2: New USB device found, idVendor=0483,
 idProduct=1234
 [  328.673548] usb 2-1.2: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
 [  328.673553] usb 2-1.2: Product: USB2CAN converter
 [  328.673557] usb 2-1.2: Manufacturer: edevices
 [  328.673561] usb 2-1.2: SerialNumber: ED000212
 [  328.708127] usb_8dev 2-1.2:1.0 can2: firmware: 1.4, hardware: 255.255
[  328.708209] usbcore: registered new interface driver usb_8dev [ 
432.319047] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [ 
439.522380] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [ 
449.324727] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [ 
574.442663] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [ 
639.810998] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (39)
- CAN plug out / plug in ?

 I correctly get an error message frame which is displayed by candump
can2,0~0,# -e
 Very nice.

 But i think there's no additional kernel message needed for that.

It's a bug. Will be fixed in the next version.


 [  640.066949] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  643.669320] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  645.703327] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  659.652396] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  667.130633] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  682.904587] usb_8dev 2-1.2:1.0 can2: Unknown status/error message
(39) - CAN plug out / plug in ?
 [  683.115139] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  692.402507] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  754.103247] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[  813.887344] usb 2-1.4: new full-speed USB device number 7 using
ehci-pci - USB plug in of PEAK adapter
 [  813.985254] usb 2-1.4: New USB device found, idVendor=0c72,
 idProduct=000c
 [  813.985258] usb 2-1.4: New USB device strings: Mfr=0, Product=3,
SerialNumber=0
 [  813.985261] usb 2-1.4: Product: VER1:PEAK
 [  813.985261] VER2:02.8.01
 [  813.985261] DAT :06.05.2004
 [  813.985261] TIME:09:35:37
 [  813.985261]  ...
 [  814.007847] peak_usb 2-1.4:1.0: PEAK-System PCAN-USB adapter hwrev 28
serial  (1 channel)
 [  814.008347] peak_usb 2-1.4:1.0 can3: attached to PCAN-USB channel 0
(device 37)
 [  814.008400] usbcore: registered new interface driver peak_usb [ 
836.196103] peak_usb 2-1.4:1.0 can3: setting BTR0=0x00 BTR1=0x14 [ 
858.676730] usb_8dev 2-1.2:1.0 can2: couldn't find free context
- some 100% load tests
 [  900.211646] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 1007.075674] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 1007.083660] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 1012.947678] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 1012.947684] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 3542.360315] usb_8dev 2-1.2:1.0 can2: couldn't find free context [
3775.350727] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [
4019.272711] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [
4019.276510] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [
4034.787824] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [
4036.305381] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0) [
4043.180064] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (39)
- CAN plug out / plug in ?
 [ 4063.727159] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 4063.730771] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 4084.564526] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 4084.566509] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 4090.721503] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 4090.730468] usb_8dev 2-1.2:1.0 can2: Unknown status/error message (0)
[ 4135.224318] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
 - USB plug out
 [ 4135.224560] usb_8dev 2-1.2:1.0 can2: Rx URB 

Re: [PATCH v8 05/22] mfd: omap-usb-tll: Clean up clock handling

2013-01-18 Thread Russell King - ARM Linux
On Fri, Jan 18, 2013 at 02:17:08PM +0200, Roger Quadros wrote:
 + tll-ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll-nch]),
 + GFP_KERNEL);
 + if (!tll-ch_clk) {
 + ret = -ENOMEM;
 + dev_err(dev, Couldn't allocate memory for channel clocks\n);
 + goto err_clk_alloc;
 + }
 +
 + for (i = 0; i  tll-nch; i++) {
 + char clkname[] = usb_tll_hs_usb_chx_clk;
 + struct clk *fck;
 +
 + snprintf(clkname, sizeof(clkname),
 + usb_tll_hs_usb_ch%d_clk, i);
 + fck = clk_get(dev, clkname);
 +
 + if (IS_ERR(fck))
 + dev_dbg(dev, can't get clock : %s\n, clkname);
 + else
 + tll-ch_clk[i] = fck;

Hmm.  I'd actually suggest that this becomes:

tll-ch_clk[i] = fck;
if (IS_ERR(fck)
dev_dbg(dev, can't get clock: %s\n, clkname);

so that tll-ch_clk is always written to.

  static int usbtll_omap_remove(struct platform_device *pdev)
  {
   struct usbtll_omap *tll = platform_get_drvdata(pdev);
 + int i;
 +
 + for (i = 0; i  tll-nch; i++)
 + clk_put(tll-ch_clk[i]);

And change this to:

for (i = 0; i  tll-nch; i++)
if (!IS_ERR(tll-ch_clk[i]))
clk_put(tll-ch_clk[i]);

so that you're not passing a NULL pointer in.

 + for (i = 0; i  tll-nch; i++) {
 + if (is_ehci_tll_mode(pdata-port_mode[i])) {
 + int r;
  
 - if (is_ehci_tll_mode(pdata-port_mode[1]))
 - clk_enable(tll-usbtll_p2_fck);
 + if (!tll-ch_clk[i])

if (IS_ERR(tll-ch_clk[i]))

 + continue;
 +
 + r = clk_enable(tll-ch_clk[i]);
 + if (r) {
 + dev_err(dev,
 +  Error enabling ch %d clock: %d\n, i, r);
 + }
 + }
 + }

 @@ -387,11 +409,12 @@ static int usbtll_runtime_suspend(struct device *dev)
  
   spin_lock_irqsave(tll-lock, flags);
  
 - if (is_ehci_tll_mode(pdata-port_mode[0]))
 - clk_disable(tll-usbtll_p1_fck);
 -
 - if (is_ehci_tll_mode(pdata-port_mode[1]))
 - clk_disable(tll-usbtll_p2_fck);
 + for (i = 0; i  tll-nch; i++) {
 + if (is_ehci_tll_mode(pdata-port_mode[i])) {
 + if (tll-ch_clk[i])

if (!IS_ERR(tll-ch_clk[i]))

 + clk_disable(tll-ch_clk[i]);
 + }
 + }
  
   spin_unlock_irqrestore(tll-lock, flags);
  
 -- 
 1.7.4.1
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 06/22] mfd: omap-usb-tll: introduce and use mode_needs_tll()

2013-01-18 Thread Russell King - ARM Linux
On Fri, Jan 18, 2013 at 02:17:09PM +0200, Roger Quadros wrote:
 +/* only PHY and UNUSED modes don't need TLL */
 +#define omap_usb_mode_needs_tll(x)   ((x != OMAP_USBHS_PORT_MODE_UNUSED) \
 +  (x != OMAP_EHCI_PORT_MODE_PHY))

Growl.

These parens do not make anything safer at all - they just obfuscate.  The
safe version of the above macro would have been:

#define omap_usb_mode_needs_tll(x)  ((x) != OMAP_USBHS_PORT_MODE_UNUSED \
 (x) != OMAP_EHCI_PORT_MODE_PHY)

If you're going to use a macro argument in an expression, it needs parens.
Simple expressions like a != b  c != d do _not_ need parens.

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


Re: [PATCH v8 05/22] mfd: omap-usb-tll: Clean up clock handling

2013-01-18 Thread Roger Quadros
On 01/18/2013 04:59 PM, Russell King - ARM Linux wrote:
 On Fri, Jan 18, 2013 at 02:17:08PM +0200, Roger Quadros wrote:
 +tll-ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll-nch]),
 +GFP_KERNEL);
 +if (!tll-ch_clk) {
 +ret = -ENOMEM;
 +dev_err(dev, Couldn't allocate memory for channel clocks\n);
 +goto err_clk_alloc;
 +}
 +
 +for (i = 0; i  tll-nch; i++) {
 +char clkname[] = usb_tll_hs_usb_chx_clk;
 +struct clk *fck;
 +
 +snprintf(clkname, sizeof(clkname),
 +usb_tll_hs_usb_ch%d_clk, i);
 +fck = clk_get(dev, clkname);
 +
 +if (IS_ERR(fck))
 +dev_dbg(dev, can't get clock : %s\n, clkname);
 +else
 +tll-ch_clk[i] = fck;
 
 Hmm.  I'd actually suggest that this becomes:
 
   tll-ch_clk[i] = fck;
   if (IS_ERR(fck)
   dev_dbg(dev, can't get clock: %s\n, clkname);
 
 so that tll-ch_clk is always written to.

Yes, I'll fix this.

 
  static int usbtll_omap_remove(struct platform_device *pdev)
  {
  struct usbtll_omap *tll = platform_get_drvdata(pdev);
 +int i;
 +
 +for (i = 0; i  tll-nch; i++)
 +clk_put(tll-ch_clk[i]);
 
 And change this to:
 
   for (i = 0; i  tll-nch; i++)
   if (!IS_ERR(tll-ch_clk[i]))
   clk_put(tll-ch_clk[i]);
 
 so that you're not passing a NULL pointer in.

ok.

 +for (i = 0; i  tll-nch; i++) {
 +if (is_ehci_tll_mode(pdata-port_mode[i])) {
 +int r;
  
 -if (is_ehci_tll_mode(pdata-port_mode[1]))
 -clk_enable(tll-usbtll_p2_fck);
 +if (!tll-ch_clk[i])
 
   if (IS_ERR(tll-ch_clk[i]))
ok.
 
 +continue;
 +
 +r = clk_enable(tll-ch_clk[i]);
 +if (r) {
 +dev_err(dev,
 + Error enabling ch %d clock: %d\n, i, r);
 +}
 +}
 +}
 
 @@ -387,11 +409,12 @@ static int usbtll_runtime_suspend(struct device *dev)
  
  spin_lock_irqsave(tll-lock, flags);
  
 -if (is_ehci_tll_mode(pdata-port_mode[0]))
 -clk_disable(tll-usbtll_p1_fck);
 -
 -if (is_ehci_tll_mode(pdata-port_mode[1]))
 -clk_disable(tll-usbtll_p2_fck);
 +for (i = 0; i  tll-nch; i++) {
 +if (is_ehci_tll_mode(pdata-port_mode[i])) {
 +if (tll-ch_clk[i])
 
   if (!IS_ERR(tll-ch_clk[i]))
ok.

 
 +clk_disable(tll-ch_clk[i]);
 +}
 +}
  
  spin_unlock_irqrestore(tll-lock, flags);
  

--
cheers,
-roger

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


Re: [PATCH v7 2/4] usb: phy: samsung: Add host phy support to samsung-phy driver

2013-01-18 Thread Felipe Balbi
On Fri, Jan 18, 2013 at 07:59:52PM +0530, Vivek Gautam wrote:
 HI Balbi,
 
 
 On Fri, Jan 18, 2013 at 7:52 PM, Felipe Balbi ba...@ti.com wrote:
  On Fri, Jan 18, 2013 at 07:51:08PM +0530, Vivek Gautam wrote:
  Hi Felipe,
 
 
  On Fri, Jan 18, 2013 at 6:46 PM, Felipe Balbi ba...@ti.com wrote:
   Hi,
  
   On Mon, Jan 14, 2013 at 05:52:15PM +0530, Vivek Gautam wrote:
   This patch adds host phy support to samsung-usbphy driver and
   further adds support for samsung's exynos5250 usb-phy.
  
   Signed-off-by: Praveen Paneri p.pan...@samsung.com
   Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
  
   Missing Kukjim's Acked-by here
  
 
  Hope you are fine with the changes happened after discussion in thread:
  [PATCH v5 2/4] usb: phy: samsung: Add host phy support to samsung-phy 
  driver
 
  Is it something you want me to modify in this patch ?
 
  please send the final patch and we shall see. After quickly browsing
  that thread, I didn't see anything scary, but I'd like to see your final
  version before giving my final answer ;-)
 
 
 this series of patch is the final version from my side unless Doug or
 you have any further comments
 on the thread :
 https://lkml.org/lkml/2013/1/14/481
 
 Seems like Doug wanted to know your opinion in this regard. ;-)

only Kukjim's Acked-by missing ;-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v8 06/22] mfd: omap-usb-tll: introduce and use mode_needs_tll()

2013-01-18 Thread Roger Quadros
On 01/18/2013 05:02 PM, Russell King - ARM Linux wrote:
 On Fri, Jan 18, 2013 at 02:17:09PM +0200, Roger Quadros wrote:
 +/* only PHY and UNUSED modes don't need TLL */
 +#define omap_usb_mode_needs_tll(x)  ((x != OMAP_USBHS_PORT_MODE_UNUSED) \
 + (x != OMAP_EHCI_PORT_MODE_PHY))
 
 Growl.
 
 These parens do not make anything safer at all - they just obfuscate.  The
 safe version of the above macro would have been:
 
 #define omap_usb_mode_needs_tll(x)((x) != OMAP_USBHS_PORT_MODE_UNUSED \
(x) != OMAP_EHCI_PORT_MODE_PHY)
 
 If you're going to use a macro argument in an expression, it needs parens.
 Simple expressions like a != b  c != d do _not_ need parens.
 

Yikes, that was brain dead stuff from me ;). Will fix.

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


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

2013-01-18 Thread Alan Stern
On Fri, 18 Jan 2013, Venu Byravarasu wrote:

 As Tegra PHY driver needs to access one of the Host registers,
 added few APIs.
 
 Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
 ---
 delta from v2:
 Renamed USB_PORTSC1 to TEGRA_USB_PORTSC1.
 Removed tegra_ehci_set_wakeon_events() and its references.
 Used standard defines for accessing PORTSC fields defined in ehci_def.h
 Included OCC bit of PORTSC as part of TEGRA_PORTSC1_RWC_BITS.
 
 delta from v1:
 Taken care of RWC bits, while accessing PORTSC register.

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 v6 3/4] USB: ehci-s5p: Add phy driver support

2013-01-18 Thread Alan Stern
On Fri, 11 Jan 2013, Vivek Gautam wrote:

 Adding the phy driver to ehci-s5p. Keeping the platform data
 for continuing the smooth operation for boards which still uses it
 
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 Acked-by: Jingoo Han jg1@samsung.com

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 v6 3/4] USB: ehci-s5p: Add phy driver support

2013-01-18 Thread Alan Stern
On Fri, 18 Jan 2013, Vivek Gautam wrote:

 Hi Alan,
 
 
 On Fri, Jan 18, 2013 at 6:46 PM, Felipe Balbi ba...@ti.com wrote:
  On Fri, Jan 11, 2013 at 08:32:29PM +0530, Vivek Gautam wrote:
  Adding the phy driver to ehci-s5p. Keeping the platform data
  for continuing the smooth operation for boards which still uses it
 
  Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
  Acked-by: Jingoo Han jg1@samsung.com
 
  Missing Alan's Acked-by here.
 
 
 Any comments on this patch-series ?

Sorry, this patch and the ohci-exynos one slipped through my net.  
Acked-by's have been sent.

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


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

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

Signed-off-by: Lan Tianyu tianyu@intel.com
---
This patch is rebased on the usb-linus branch commit 1ee0a224bc9aa
USB: io_ti: Fix NULL dereference in chase_port()
---
 drivers/usb/core/hub.c   |   71 +++---
 include/uapi/linux/usb/ch9.h |6 
 2 files changed, 59 insertions(+), 18 deletions(-)

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

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

2013-01-18 Thread Alan Stern
On Fri, 18 Jan 2013, Lan Tianyu wrote:

  By the way, have you checked whether the auto-power-off mechanism works 
  correctly when you do a system suspend?
  
 Thanks for reminder. I test this today and find an issue. If usb device
 was powered off during runtime, pm_runtime_get_sync() in the
 usb_port_resume() will return -EACCES when do system resume. This is
 because port's runtime pm was disabled during system suspend.

Actually it's worse than that.  The PM layer assumes that devices are 
brought back to full power during system resume.  But that's not true 
for your usb_port devices, because they don't have a resume callback.

In addition, we need to enable async PM for the usb_ports, just like
everything else in the USB stack.  This means you have to call
device_enable_async_suspend before the port is registered.

  Following
 are some log. The device's runtime pm will be enabled after system
 suspend. The port device is advance to be inserted in the dpm_list than
 usb device(port device is created before creating usb device). So the
 resume sequence is that resume usb device firstly and then usb port. In
 the result, pm_runtime_get_sync() doesn't work.

When async is enabled, there won't be any defined ordering.  We will
have to enforce the proper ordering by hand.  This means
usb_resume_device will have to call device_pm_wait_for_dev for the port
device (it already does this for the companion root hub).  In fact, the
code to do this waiting probably should be moved to usb_resume, because
it applies only to system resume, not to runtime resume.

 [   70.448028] power LNXPOWER:03: driver resume
 [   70.448029] usb usb4: runtime enable
 [   70.448031] usb 3-1: can't resume usb port, status -13
 [   70.448032] usb usb4: type resume
 [   70.448039] dpm_run_callback(): usb_dev_resume+0x0/0x15 returns -13
 [   70.448040] usb usb4: usb resume
 [   70.448041] usb 3-2: can't resume usb port, status -13
 [   70.448043] PM: Device 3-1 failed to resume async: error -13
 [   70.448047] dpm_run_callback(): usb_dev_resume+0x0/0x15 returns -13
 [   70.448048] PM: Device 3-2 failed to resume async: error -13
 [   70.448056] hub 4-0:1.0: hub_resume
 [   70.448088] acpi device:49: runtime enable
 
 I found one solution of adding pm_runtime_enable/disable() in the
 usb_port_resume(). This is simple sovlution.
 
 if (port_dev-did_runtime_put) {
   if (!PMSG_IS_AUTO(msg)) {
   pm_runtime_enable(port_dev-dev);
   status = pm_runtime_get_sync(port_dev-dev);
   pm_runtime_disable(port_dev-dev);
   } else
   status = pm_runtime_get_sync(port_dev-dev);
 
   port_dev-did_runtime_put = false;
   if (status  0) {
   dev_dbg(udev-dev, can't resume usb port, status %d\n,
   status);
   return status;
   }
 }
 
 This can work but I am not sure that it is safe to do system resume() in
 the system resume().
 
 Another proposal is to export usb_port_runtime_resume() or do a wrapper.
 Call it in the usb_port_resume() with pm_runtime_get_noresume() and
 pm_runtime_set_active(). This also work.
 
 if (port_dev-did_runtime_put) {
   if (!PMSG_IS_AUTO(msg)) {
   status = usb_port_runtime_resume(port_dev-dev);
   pm_runtime_get_noresume(port_dev-dev);
   pm_runtime_set_active(udev-dev);
   } else
   status = pm_runtime_get_sync(port_dev-dev);
 
   port_dev-did_runtime_put = false;
   if (status  0) {
   dev_dbg(udev-dev, can't resume usb port, status %d\n,
   status);
   return status;
   }
 }

No, neither of these.  The right approach is to define a new
usb_port_system_resume routine.  It should call usb_port_runtime_resume
directly and set the runtime PM status back to ACTIVE, similar to what
usb_resume() does.  In the dev_pm_ops structure, both the resume and
the restore callbacks should point to this new routine.

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: config x has an invalid interface number: y but max is z

2013-01-18 Thread Alan Stern
On Thu, 17 Jan 2013, Bjørn Mork wrote:

 Peter Stuge pe...@stuge.se writes:
  Alan Stern wrote:
   Is this useful to anyone?
  
  In theory it would be useful to somebody developing firmware for a USB 
  device.  If only such people would test their firmwares under Linux...
 
  Some do. Maybe it's only hobbyists, but I think it may change, 
 
 The example I posted actually originates from a device with vendor
 Linux support.  I am pretty sure that some firmware engineer there has
 tested the device with Linux and ignored those warnings.
 
  and I
  think it's very good to warn about things which are wrong.
 
 I agree in principle, as long as the warning is good for something.  In
 this case it is not.  There is absolutely zilch you and I can do about
 the issue, and it does not cause any problems we need to be aware of
 either.
 
   Should we just drop those warnings?
  
  No opinion.
 
  I think they should stay.
 
 OK, but how about demoting them to debug messages instead of warnings?

If you want to make that change, I don't mind.

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: config x has an invalid interface number: y but max is z

2013-01-18 Thread Peter Stuge
Alan Stern wrote:
Should we just drop those warnings?
   
   No opinion.
  
   I think they should stay.
  
  OK, but how about demoting them to debug messages instead of warnings?
 
 If you want to make that change, I don't mind.

I prefer that they stay visible by default, because it increases the
likelyhood that someone will actually notice them.

Clearly the people who stand to benefit from these messages aren't
actively looking to find problems with their USB device.


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


[PATCH v2 1/3] usb: add find_raw_port_number callback to struct hc_driver()

2013-01-18 Thread Lan Tianyu
xhci driver divides the root hub into two logical hubs which work
respectively for usb 2.0 and usb 3.0 devices. They are independent
devices in the usb core. But in the ACPI table, it's one device node
and all usb2.0 and usb3.0 ports are under it. Binding usb port with
its acpi node needs the raw port number which is reflected in the xhci
extended capabilities table. This patch is to add find_raw_port_number
callback to struct hc_driver() and fill it with xhci_find_raw_port_number().

Signed-off-by: Lan Tianyu tianyu@intel.com
---
Change since v1:
Don't export usb_hcd_find_raw_port_number() symbol since there is no
its user outside of usb core.

This patchset is rebased on the usb-next tree commit 74ff31b81d9
usb: misc: usb3503_probe() can be static
---
 drivers/usb/core/hcd.c  |8 
 drivers/usb/host/xhci-pci.c |1 +
 drivers/usb/host/xhci.c |   22 ++
 drivers/usb/host/xhci.h |1 +
 include/linux/usb/hcd.h |2 ++
 5 files changed, 34 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 5f6da8b..0277bd2 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2364,6 +2364,14 @@ int usb_hcd_is_primary_hcd(struct usb_hcd *hcd)
 }
 EXPORT_SYMBOL_GPL(usb_hcd_is_primary_hcd);
 
+int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1)
+{
+   if (!hcd-driver-find_raw_port_number)
+   return port1;
+
+   return hcd-driver-find_raw_port_number(hcd, port1);
+}
+
 static int usb_hcd_request_irqs(struct usb_hcd *hcd,
unsigned int irqnum, unsigned long irqflags)
 {
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index af259e0..1a30c38 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -313,6 +313,7 @@ static const struct hc_driver xhci_pci_hc_driver = {
.set_usb2_hw_lpm =  xhci_set_usb2_hardware_lpm,
.enable_usb3_lpm_timeout =  xhci_enable_usb3_lpm_timeout,
.disable_usb3_lpm_timeout = xhci_disable_usb3_lpm_timeout,
+   .find_raw_port_number = xhci_find_raw_port_number,
 };
 
 /*-*/
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index f1f01a8..0780d8f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3778,6 +3778,28 @@ int xhci_address_device(struct usb_hcd *hcd, struct 
usb_device *udev)
return 0;
 }
 
+/*
+ * Transfer the port index into real index in the HW port status
+ * registers. Caculate offset between the port's PORTSC register
+ * and port status base. Divide the number of per port register
+ * to get the real index. The raw port number bases 1.
+ */
+int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1)
+{
+   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   __le32 __iomem *base_addr = xhci-op_regs-port_status_base;
+   __le32 __iomem *addr;
+   int raw_port;
+
+   if (hcd-speed != HCD_USB3)
+   addr = xhci-usb2_ports[port1 - 1];
+   else
+   addr = xhci-usb3_ports[port1 - 1];
+
+   raw_port = (addr - base_addr)/NUM_PORT_REGS + 1;
+   return raw_port;
+}
+
 #ifdef CONFIG_USB_SUSPEND
 
 /* BESL to HIRD Encoding array for USB2 LPM */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index f791bd0..55345d9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1829,6 +1829,7 @@ void xhci_test_and_clear_bit(struct xhci_hcd *xhci, 
__le32 __iomem **port_array,
 int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
char *buf, u16 wLength);
 int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);
+int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1);
 
 #ifdef CONFIG_PM
 int xhci_bus_suspend(struct usb_hcd *hcd);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 608050b..61b88b5 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -357,6 +357,7 @@ struct hc_driver {
 */
int (*disable_usb3_lpm_timeout)(struct usb_hcd *,
struct usb_device *, enum usb3_link_state state);
+   int (*find_raw_port_number)(struct usb_hcd *, int);
 };
 
 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
@@ -396,6 +397,7 @@ extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd);
 extern int usb_add_hcd(struct usb_hcd *hcd,
unsigned int irqnum, unsigned long irqflags);
 extern void usb_remove_hcd(struct usb_hcd *hcd);
+extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1);
 
 struct platform_device;
 extern void usb_hcd_platform_shutdown(struct platform_device *dev);
-- 
1.7.10.4

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


[PATCH v2 2/3] usb/acpi: binding xhci root hub usb port with ACPI

2013-01-18 Thread Lan Tianyu
This patch is to bind xhci root hub usb port with its acpi node.
The port num in the acpi table matches with the sequence in the xhci
extended capabilities table. So call usb_hcd_find_raw_port_number() to
transfer hub port num into raw port number which associates with
the sequence in the xhci extended capabilities table before binding.

Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/core/usb-acpi.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index cef4252..40f5a6a 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -15,6 +15,7 @@
 #include linux/kernel.h
 #include linux/acpi.h
 #include linux/pci.h
+#include linux/usb/hcd.h
 #include acpi/acpi_bus.h
 
 #include usb.h
@@ -188,6 +189,9 @@ static int usb_acpi_find_device(struct device *dev, 
acpi_handle *handle)
 * connected to.
 */
if (!udev-parent) {
+   struct usb_hcd *hcd = bus_to_hcd(udev-bus);
+
+   port_num = usb_hcd_find_raw_port_number(hcd, port_num);
*handle = acpi_get_child(DEVICE_ACPI_HANDLE(udev-dev),
port_num);
if (!*handle)
-- 
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 v2 3/3] usb/xhci: refactor xhci_find_real_port_number()

2013-01-18 Thread Lan Tianyu
This patch is to optimize xhci_find_realport_number(). Call
xhci_find_raw_port_number() to get real index in the HW port
status registers instead of scanning through the xHCI roothub
port array.

Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/host/xhci-mem.c |   36 
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 35616ff..6dc238c 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1022,44 +1022,24 @@ void xhci_copy_ep0_dequeue_into_input_ctx(struct 
xhci_hcd *xhci,
  * is attached to (or the roothub port its ancestor hub is attached to).  All 
we
  * know is the index of that port under either the USB 2.0 or the USB 3.0
  * roothub, but that doesn't give us the real index into the HW port status
- * registers.  Scan through the xHCI roothub port array, looking for the Nth
- * entry of the correct port speed.  Return the port number of that entry.
+ * registers. Call xhci_find_raw_port_number() to get real index.
  */
 static u32 xhci_find_real_port_number(struct xhci_hcd *xhci,
struct usb_device *udev)
 {
struct usb_device *top_dev;
-   unsigned int num_similar_speed_ports;
-   unsigned int faked_port_num;
-   int i;
+   struct usb_hcd *hcd;
+
+   if (udev-speed == USB_SPEED_SUPER)
+   hcd = xhci-shared_hcd;
+   else
+   hcd = xhci-main_hcd;
 
for (top_dev = udev; top_dev-parent  top_dev-parent-parent;
top_dev = top_dev-parent)
/* Found device below root hub */;
-   faked_port_num = top_dev-portnum;
-   for (i = 0, num_similar_speed_ports = 0;
-   i  HCS_MAX_PORTS(xhci-hcs_params1); i++) {
-   u8 port_speed = xhci-port_array[i];
-
-   /*
-* Skip ports that don't have known speeds, or have duplicate
-* Extended Capabilities port speed entries.
-*/
-   if (port_speed == 0 || port_speed == DUPLICATE_ENTRY)
-   continue;
 
-   /*
-* USB 3.0 ports are always under a USB 3.0 hub.  USB 2.0 and
-* 1.1 ports are under the USB 2.0 hub.  If the port speed
-* matches the device speed, it's a similar speed port.
-*/
-   if ((port_speed == 0x03) == (udev-speed == USB_SPEED_SUPER))
-   num_similar_speed_ports++;
-   if (num_similar_speed_ports == faked_port_num)
-   /* Roothub ports are numbered from 1 to N */
-   return i+1;
-   }
-   return 0;
+   return  xhci_find_raw_port_number(hcd, top_dev-portnum);
 }
 
 /* Setup an xHCI virtual device for a Set Address command */
-- 
1.7.10.4

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


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

2013-01-18 Thread Stephen Warren
On 01/16/2013 06:30 AM, Venu Byravarasu wrote:
 Tegra20 USB has 3 PHY instances:
 Instance 1 and 3 are UTMI. Instance 2 is ULPI.
 
 As instance number was used to differentiate ULPI from UTMI,
 used DT param to get this info and processed accordingly.

 diff --git a/include/linux/usb/tegra_usb_phy.h 
 b/include/linux/usb/tegra_usb_phy.h
 index f03e157..a6a89d4 100644
 --- a/include/linux/usb/tegra_usb_phy.h
 +++ b/include/linux/usb/tegra_usb_phy.h
 @@ -60,6 +60,7 @@ struct tegra_usb_phy {
   struct usb_phy u_phy;
   struct device *dev;
   bool is_legacy_phy;
 + bool is_ulpi_phy;
  };

I see the code that uses this new field, but it doesn't appear to be set
anywhere...
--
To unsubscribe from this list: send the line unsubscribe 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 4/4] usb: Add APIs to access host registers from Tegra PHY

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

 Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
 ---
 delta from v2:
 Renamed USB_PORTSC1 to TEGRA_USB_PORTSC1.
 Removed tegra_ehci_set_wakeon_events() and its references.
 Used standard defines for accessing PORTSC fields defined in ehci_def.h
 Included OCC bit of PORTSC as part of TEGRA_PORTSC1_RWC_BITS.

 delta from v1:
 Taken care of RWC bits, while accessing PORTSC register.
 
 Acked-by: Alan Stern st...@rowland.harvard.edu

Felipe, you said on a previous version that you weren't sure if you
could ack this since it means the PHY driver is touching EHCI
registers... I don't think we really have much choice w.r.t. what the
driver is doing, since it's driven purely by HW design. Is this updated
patched at least OK for you not to NAK it, and hence I can apply it? Thanks.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-01-18 Thread Pete Zaitcev
On Mon, 14 Jan 2013 12:23:05 -0800
Greg KH gre...@linuxfoundation.org wrote:

 Forgot to mention the side effect of the patch: one can't submit read and
  write URB simultaneously via USBDEVFS_BULK ioctl(). That has been dealt in 
  2.4
  by later patch by Pete, which I can try to port if needed.
 
 That's not good, it would need to be part of this patch, we don't want
 to break that existing functionality.

I knew that it was no good, but hoped to skate by :-). My fix for Sergey's
patch looked like this, with a bitmask:

diff -urp -X dontdiff linux-2.4.33-rc3/drivers/usb/devices.c 
linux-2.4.33-rc3-u/drivers/usb/devices.c
--- linux-2.4.33-rc3/drivers/usb/devices.c  2004-11-17 03:54:21.0 
-0800
+++ linux-2.4.33-rc3-u/drivers/usb/devices.c2006-08-04 14:56:11.0 
-0700
@@ -392,7 +392,7 @@ static char *usb_dump_desc(char *start, 
 * Grab device's exclusive_access mutex to prevent its driver or
 * devio from using this device while we are accessing it.
 */
-   down (dev-exclusive_access);
+   usb_excl_lock(dev, 3, 0);
 
start = usb_dump_device_descriptor(start, end, dev-descriptor);
 
@@ -411,7 +411,7 @@ static char *usb_dump_desc(char *start, 
}
 
 out:
-   up (dev-exclusive_access);
+   usb_excl_unlock(dev, 3);
return start;
 }
 
diff -urp -X dontdiff linux-2.4.33-rc3/drivers/usb/devio.c 
linux-2.4.33-rc3-u/drivers/usb/devio.c
--- linux-2.4.33-rc3/drivers/usb/devio.c2006-04-13 19:02:30.0 
-0700
+++ linux-2.4.33-rc3-u/drivers/usb/devio.c  2006-08-04 14:56:11.0 
-0700
@@ -623,7 +623,12 @@ static int proc_bulk(struct dev_state *p
free_page((unsigned long)tbuf);
return -EINVAL;
}
+   if (usb_excl_lock(dev, 1, 1) != 0) {
+   free_page((unsigned long)tbuf);
+   return -ERESTARTSYS;
+   }
i = usb_bulk_msg(dev, pipe, tbuf, len1, len2, tmo);
+   usb_excl_unlock(dev, 1);
if (!i  len2) {
if (copy_to_user(bulk.data, tbuf, len2)) {
free_page((unsigned long)tbuf);
@@ -637,7 +642,12 @@ static int proc_bulk(struct dev_state *p
return -EFAULT;
}
}
+   if (usb_excl_lock(dev, 2, 1) != 0) {
+   free_page((unsigned long)tbuf);
+   return -ERESTARTSYS;
+   }
i = usb_bulk_msg(dev, pipe, tbuf, len1, len2, tmo);
+   usb_excl_unlock(dev, 2);
}
free_page((unsigned long)tbuf);
if (i  0) {
@@ -1160,12 +1170,6 @@ static int usbdev_ioctl_exclusive(struct
inode-i_mtime = CURRENT_TIME;
break;
 
-   case USBDEVFS_BULK:
-   ret = proc_bulk(ps, (void *)arg);
-   if (ret = 0)
-   inode-i_mtime = CURRENT_TIME;
-   break;
-
case USBDEVFS_RESETEP:
ret = proc_resetep(ps, (void *)arg);
if (ret = 0)
@@ -1259,8 +1263,13 @@ static int usbdev_ioctl(struct inode *in
ret = proc_disconnectsignal(ps, (void *)arg);
break;
 
-   case USBDEVFS_CONTROL:
case USBDEVFS_BULK:
+   ret = proc_bulk(ps, (void *)arg);
+   if (ret = 0)
+   inode-i_mtime = CURRENT_TIME;
+   break;
+
+   case USBDEVFS_CONTROL:
case USBDEVFS_RESETEP:
case USBDEVFS_RESET:
case USBDEVFS_CLEAR_HALT:
@@ -1272,9 +1281,9 @@ static int usbdev_ioctl(struct inode *in
case USBDEVFS_RELEASEINTERFACE:
case USBDEVFS_IOCTL:
ret = -ERESTARTSYS;
-   if (down_interruptible(ps-dev-exclusive_access) == 0) {
+   if (usb_excl_lock(ps-dev, 3, 1) == 0) {
ret = usbdev_ioctl_exclusive(ps, inode, cmd, arg);
-   up(ps-dev-exclusive_access);
+   usb_excl_unlock(ps-dev, 3);
}
break;
 
diff -urp -X dontdiff linux-2.4.33-rc3/drivers/usb/storage/transport.c 
linux-2.4.33-rc3-u/drivers/usb/storage/transport.c
--- linux-2.4.33-rc3/drivers/usb/storage/transport.c2005-04-03 
18:42:19.0 -0700
+++ linux-2.4.33-rc3-u/drivers/usb/storage/transport.c  2006-08-04 
14:35:15.0 -0700
@@ -628,16 +628,16 @@ void usb_stor_invoke_transport(Scsi_Cmnd
int result;
 
/*
-* Grab device's exclusive_access mutex to prevent libusb/usbfs from
+* Grab device's exclusive access lock to prevent libusb/usbfs from
 * sending out a command in the middle of ours (if libusb sends a
 * get_descriptor or something on pipe 0 after our CBW and before
 * our CSW, and then we get a stall, we have trouble).
 */
-   

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

2013-01-18 Thread Stephen Warren
On 01/18/2013 10:58 AM, Felipe Balbi wrote:
 On Fri, Jan 18, 2013 at 10:28:38AM -0700, Stephen Warren wrote:
 On 01/18/2013 08:30 AM, Alan Stern wrote:
 On Fri, 18 Jan 2013, Venu Byravarasu wrote:
 
 As Tegra PHY driver needs to access one of the Host
 registers, added few APIs.
 
 Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com --- 
 delta from v2: Renamed USB_PORTSC1 to TEGRA_USB_PORTSC1. 
 Removed tegra_ehci_set_wakeon_events() and its references. 
 Used standard defines for accessing PORTSC fields defined in
 ehci_def.h Included OCC bit of PORTSC as part of
 TEGRA_PORTSC1_RWC_BITS.
 
 delta from v1: Taken care of RWC bits, while accessing PORTSC
 register.
 
 Acked-by: Alan Stern st...@rowland.harvard.edu
 
 Felipe, you said on a previous version that you weren't sure if
 you could ack this since it means the PHY driver is touching
 EHCI registers... I don't think we really have much choice w.r.t.
 what the driver is doing, since it's driven purely by HW design.
 Is this updated patched at least OK for you not to NAK it, and
 hence I can apply it? Thanks.
 
 Sure I will not block it, please go ahead and apply it through your
 tree ;-)

Great, thanks very much.

Are patch 2/4 and 3/4 OK; could you Ack them since they touch USB PHY
code?

I guess in the interests of moving this USB rework forward, I'll
actually fix up the issue with assigning phy-is_ulpi_phy while I
apply the patches, just by moving that one chunk of code from patch 4
to patch 3.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-01-18 Thread Lan, Tianyu
HI Alan:
I just find Rafael's patch has resolved this issue. In this 
patch, enable runtime PM
right after executing subsystem/driver .resume_early() callbacks. When do 
resume(),
the device's runtime pm has been enabled. This patch now is already in the 
v3.8-rc4.
So this patchset will not cause problem with Rafael patch and I have tested. 
About the
port system suspend/resume() callback, Could I do this in the next step?

commit a8d3848dadc2fd41a9117cb08dc04fe6d7c551f9
Author: Rafael J. Wysocki rafael.j.wyso...@intel.com
Date:   Sat Dec 22 23:59:01 2012 +0100

PM: Move disabling/enabling runtime PM to late suspend/early resume

Currently, the PM core disables runtime PM for all devices right
after executing subsystem/driver .suspend() callbacks for them
and re-enables it right before executing subsystem/driver .resume()
callbacks for them.  This may lead to problems when there are
two devices such that the .suspend() callback executed for one of
them depends on runtime PM working for the other.  In that case,
if runtime PM has already been disabled for the second device,
the first one's .suspend() won't work correctly (and analogously
for resume).

To make those issues go away, make the PM core disable runtime PM
for devices right before executing subsystem/driver .suspend_late()
callbacks for them and enable runtime PM for them right after
executing subsystem/driver .resume_early() callbacks for them.  This
way the potential conflitcs between .suspend_late()/.resume_early()
and their runtime PM counterparts are still prevented from happening,
but the subtle ordering issues related to disabling/enabling runtime
PM for devices during system suspend/resume are much easier to avoid.

Best Regards 
Tianyu Lan 


-Original Message-
From: Alan Stern [mailto:st...@rowland.harvard.edu] 
Sent: Saturday, January 19, 2013 12:21 AM
To: Lan, Tianyu
Cc: r...@sisk.pl; gre...@linuxfoundation.org; sarah.a.sh...@linux.intel.com; 
oneu...@suse.de; linux-usb@vger.kernel.org
Subject: Re: [Resend PATCH V4 0/10] usb: usb port power off mechanism anc 
expose usb port connect type

On Fri, 18 Jan 2013, Lan Tianyu wrote:

  By the way, have you checked whether the auto-power-off mechanism 
  works correctly when you do a system suspend?
  
 Thanks for reminder. I test this today and find an issue. If usb 
 device was powered off during runtime, pm_runtime_get_sync() in the
 usb_port_resume() will return -EACCES when do system resume. This is 
 because port's runtime pm was disabled during system suspend.

Actually it's worse than that.  The PM layer assumes that devices are brought 
back to full power during system resume.  But that's not true for your usb_port 
devices, because they don't have a resume callback.

In addition, we need to enable async PM for the usb_ports, just like everything 
else in the USB stack.  This means you have to call device_enable_async_suspend 
before the port is registered.

  Following
 are some log. The device's runtime pm will be enabled after system 
 suspend. The port device is advance to be inserted in the dpm_list 
 than usb device(port device is created before creating usb device). So 
 the resume sequence is that resume usb device firstly and then usb 
 port. In the result, pm_runtime_get_sync() doesn't work.

When async is enabled, there won't be any defined ordering.  We will have to 
enforce the proper ordering by hand.  This means usb_resume_device will have to 
call device_pm_wait_for_dev for the port device (it already does this for the 
companion root hub).  In fact, the code to do this waiting probably should be 
moved to usb_resume, because it applies only to system resume, not to runtime 
resume.

 [   70.448028] power LNXPOWER:03: driver resume
 [   70.448029] usb usb4: runtime enable
 [   70.448031] usb 3-1: can't resume usb port, status -13
 [   70.448032] usb usb4: type resume
 [   70.448039] dpm_run_callback(): usb_dev_resume+0x0/0x15 returns -13
 [   70.448040] usb usb4: usb resume
 [   70.448041] usb 3-2: can't resume usb port, status -13
 [   70.448043] PM: Device 3-1 failed to resume async: error -13
 [   70.448047] dpm_run_callback(): usb_dev_resume+0x0/0x15 returns -13
 [   70.448048] PM: Device 3-2 failed to resume async: error -13
 [   70.448056] hub 4-0:1.0: hub_resume
 [   70.448088] acpi device:49: runtime enable
 
 I found one solution of adding pm_runtime_enable/disable() in the 
 usb_port_resume(). This is simple sovlution.
 
 if (port_dev-did_runtime_put) {
   if (!PMSG_IS_AUTO(msg)) {
   pm_runtime_enable(port_dev-dev);
   status = pm_runtime_get_sync(port_dev-dev);
   pm_runtime_disable(port_dev-dev);
   } else
   status = pm_runtime_get_sync(port_dev-dev);
 
   port_dev-did_runtime_put = false;
   if (status  0) {
   dev_dbg(udev-dev, can't resume usb port, status %d\n,

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

2013-01-18 Thread Felipe Balbi
On Wed, Jan 16, 2013 at 07:00:20PM +0530, Venu Byravarasu wrote:
 Tegra20 USB has 3 PHY instances. Instance 0 is based on
 legacy PHY interface and other two are standard interfaces.
 
 As instance number was used to differentiate legacy from
 standard interfaces, used DT param to get this info and
 processed accordingly.
 
 Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com

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

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

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

2013-01-18 Thread Felipe Balbi
On Wed, Jan 16, 2013 at 07:00:21PM +0530, Venu Byravarasu wrote:
 Tegra20 USB has 3 PHY instances:
 Instance 1 and 3 are UTMI. Instance 2 is ULPI.
 
 As instance number was used to differentiate ULPI from UTMI,
 used DT param to get this info and processed accordingly.
 
 Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com

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

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

-- 
balbi


signature.asc
Description: Digital signature


Re: ehci-hcd compile error

2013-01-18 Thread Alan Stern
On Fri, 18 Jan 2013, Roger Quadros wrote:

 Thanks. I used the below code (also attached) and could reproduce
 corruption on the first byte at ehci-priv. This is from the the kernel log.
 
  [   30.381774] ehci-omap ehci-omap.0: ehci_hcd_omap_probe a 0x1234abcd, b 
  0x5679efba
 
  [  122.523468] ehci-omap ehci-omap.0: ehci_hcd_omap_remove a 0x1234abe0, b 
  0x5679efba
 
 NOTE: EHCI needs to be running and you need to enumerate some device for
 the corruption to happen.
 
 If I disable CONFIG_USB_DEBUG, then there is no corruption.

I tried doing something similar with (using ehci-pci rather than 
ehci-omap) and didn't get any corruption.  My test patch is below.  
Unforunately you won't be able to utilize the hw_breakpoint mechanism 
in your testing because it hasn't been set up for OMAP.  Here's the log 
for a test with two EHCI controllers and one device plugged in.  (Note: 
I did have CONFIG_USB_DEBUG enabled, but this log doesn't include any 
of the debug-level messages.)

[ 1217.550517] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 1220.650589] ehci-pci: EHCI PCI platform driver
[ 1220.658534] ehci-pci :00:1d.7: EHCI Host Controller
[ 1220.662595] ehci-pci :00:1d.7: new USB bus registered, assigned bus 
number 1
[ 1220.680773] Breakpoint at e993a868 was hit!
[ 1220.683678] Pid: 2853, comm: modprobe Tainted: G   O 
3.7.0AS-00240-g4e405e8-dirty #17
[ 1220.684016] Call Trace:
[ 1220.684016]  [c102387b] ? console_unlock+0x323/0x34c
[ 1220.684016]  [f0034137] ? ehci_hrtimer_func+0xa6/0xa6 [ehci_hcd]
[ 1220.684016]  [f003414f] ehci_hbp_handler+0x18/0x1c [ehci_hcd]
[ 1220.684016]  [c106f17f] __perf_event_overflow+0x183/0x1fb
[ 1220.684016]  [c106f33c] perf_swevent_overflow+0x40/0x5e
[ 1220.684016]  [c106f41d] perf_swevent_event+0xc3/0xcd
[ 1220.684016]  [c106faf9] perf_bp_event+0x86/0x8f
[ 1220.684016]  [c10566b5] ? __lock_acquire+0xc5b/0xc6a
[ 1220.684016]  [c10522db] ? tick_program_event+0x1f/0x24
[ 1220.684016]  [c123405b] hw_breakpoint_exceptions_notify+0xec/0x17a
[ 1220.684016]  [c12350d2] notifier_call_chain+0x51/0x7a
[ 1220.684016]  [c123512d] __atomic_notifier_call_chain+0x32/0x56
[ 1220.684016]  [c123515d] atomic_notifier_call_chain+0xc/0xe
[ 1220.684016]  [c123518c] notify_die+0x2d/0x2f
[ 1220.684016]  [c12336cd] do_debug+0x69/0x11b
[ 1220.684016]  [c12332e9] debug_stack_correct+0x2e/0x35
[ 1220.684016]  [f003007b] ? single_unlink_async+0xc/0x5d [ehci_hcd]
[ 1220.684016]  [f0037633] ? ehci_setup+0x64d/0x6aa [ehci_hcd]
[ 1220.684016]  [c100502a] ? dma_set_mask+0x41/0x41
[ 1220.684016]  [eff742a3] ehci_pci_setup+0x2a3/0x498 [ehci_pci]
[ 1220.684016]  [effe7643] usb_add_hcd+0x18c/0x5a5 [usbcore]
[ 1220.684016]  [efff26a7] usb_hcd_pci_probe+0x1d3/0x2d8 [usbcore]
[ 1220.684016]  [c1145ff3] pci_device_probe+0x7c/0xd9
[ 1220.684016]  [c119629d] driver_probe_device+0x8b/0x168
[ 1220.684016]  [c11963c4] __driver_attach+0x4a/0x66
[ 1220.684016]  [c119503e] bus_for_each_dev+0x3f/0x61
[ 1220.684016]  [c1195fd3] driver_attach+0x17/0x1c
[ 1220.684016]  [c119637a] ? driver_probe_device+0x168/0x168
[ 1220.684016]  [c1195ba3] bus_add_driver+0x8e/0x1b4
[ 1220.684016]  [c11967a8] driver_register+0x72/0xdd
[ 1220.684016]  [c1138107] ? __raw_spin_lock_init+0x26/0x48
[ 1220.684016]  [c11460e5] __pci_register_driver+0x45/0x48
[ 1220.684016]  [eff79059] ehci_pci_init+0x59/0x1000 [ehci_pci]
[ 1220.684016]  [c1001183] do_one_initcall+0x71/0x11a
[ 1220.684016]  [eff79000] ? 0xeff78fff
[ 1220.684016]  [c105e01f] sys_init_module+0x1354/0x1516
[ 1220.684016]  [c1054e98] ? trace_hardirqs_on_caller+0x13f/0x17e
[ 1220.684016]  [c12366fe] sysenter_do_call+0x12/0x36
[ 1220.796643] ehci-pci :00:1d.7: ehci_setup a 1238abcf b 5679efba
[ 1220.799409] ehci-pci :00:1d.7: debug port 1
[ 1220.807738] ehci-pci :00:1d.7: irq 23, io mem 0xfe77bc00
[ 1220.824062] ehci-pci :00:1d.7: USB 2.0 started, EHCI 1.00
[ 1220.835340] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 1220.838733] usb usb1: New USB device strings: Mfr=3, Product=2, 
SerialNumber=1
[ 1220.842190] usb usb1: Product: EHCI Host Controller
[ 1220.845492] usb usb1: Manufacturer: Linux 3.7.0AS-00240-g4e405e8-dirty 
ehci_hcd
[ 1220.848827] usb usb1: SerialNumber: :00:1d.7
[ 1220.885420] hub 1-0:1.0: USB hub found
[ 1220.889325] hub 1-0:1.0: 8 ports detected
[ 1220.940628] ehci-pci :01:01.2: EHCI Host Controller
[ 1220.943363] ehci-pci :01:01.2: new USB bus registered, assigned bus 
number 2
[ 1220.975320] ehci-pci :01:01.2: ehci_setup a 1238abcf b 5679efba
[ 1220.985385] ehci-pci :01:01.2: irq 9, io mem 0xfe5dfc00
[ 1221.70] ehci-pci :01:01.2: USB 2.0 started, EHCI 1.00
[ 1221.011691] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[ 1221.015403] usb usb2: New USB device strings: Mfr=3, Product=2, 
SerialNumber=1
[ 1221.018738] usb usb2: Product: EHCI Host Controller
[ 1221.026111] usb usb2: Manufacturer: Linux 3.7.0AS-00240-g4e405e8-dirty 
ehci_hcd
[ 1221.032874] usb usb2: 

USB storage suspend

2013-01-18 Thread Sarah Sharp
Hi Alan,

What's the current state of USB mass storage suspend?  I know there was
some purposed changes to the SCSI or block layer that would have
effected suspend, and I wondered if those made it in.

I'm specifically looking for when we can expect a USB storage device to
go into auto-suspend.  If userspace enables auto-suspend and sets the
autosuspend_delay_ms to zero, could we see auto-suspend between SCSI
commands?  Or will the device remain in U0 until the storage device is
unmounted?

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: [Resend PATCH V4 0/10] usb: usb port power off mechanism anc expose usb port connect type

2013-01-18 Thread Alan Stern
On Fri, 18 Jan 2013, Lan, Tianyu wrote:

 HI Alan:
   I just find Rafael's patch has resolved this issue. In this 
 patch, enable runtime PM
 right after executing subsystem/driver .resume_early() callbacks. When do 
 resume(),
 the device's runtime pm has been enabled. This patch now is already in the 
 v3.8-rc4.
 So this patchset will not cause problem with Rafael patch and I have tested. 
 About the
 port system suspend/resume() callback, Could I do this in the next step?

Well, I guess you don't really need a resume callback now.  Leaving the
port in its old runtime PM state should be okay, because hub_activate
will set the port power correctly.  The important thing is that the
hardware's actual power level should agree with the runtime PM status.

However, you still need to enable async suspend for the port devices.
The device_pm_wait_for_dev call isn't needed if the ports don't have a
resume callback.

Have you tested hibernation as well as system suspend?

Alan Stern

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


Re: [PATCH net] net: cdc_ncm: workaround for missing CDC Union

2013-01-18 Thread Oliver Neukum
On Friday 18 January 2013 15:25:47 Bjørn Mork wrote:
 Adding support for the MBIM mode in some Sierra Wireless devices.
 
 Some Sierra Wireless firmwares support CDC MBIM but have no CDC
 Union funtional descriptor. This violates the MBIM specification,
 but we can easily work around the bug by looking at the Interface
 Association Descriptor instead.  This is most likely what
 Windows uses too, which explains how the firmware bug has gone
 unnoticed until now.

Should we do this for everything CDC?

Regards
Oliver

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


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

2013-01-18 Thread David Miller
From: Lucas Stach d...@lynxeye.de
Date: Wed, 16 Jan 2013 15:24:06 +0100

 The device comes up with a MAC address of all zeros. We need to read the
 initial device MAC from EEPROM so it can be set properly later.
 
 Signed-off-by: Lucas Stach d...@lynxeye.de

Applied.
--
To unsubscribe from this list: send the line unsubscribe 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 2/2] net: asix: handle packets crossing URB boundaries

2013-01-18 Thread David Miller
From: Lucas Stach d...@lynxeye.de
Date: Wed, 16 Jan 2013 15:24:07 +0100

 ASIX AX88772B started to pack data even more tightly. Packets and the ASIX 
 packet
 header may now cross URB boundaries. To handle this we have to introduce
 some state between individual calls to asix_rx_fixup().
 
 Signed-off-by: Lucas Stach d...@lynxeye.de

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


Re: [PATCH] usb: dwc3: debugfs: convert our regdump to use regsets

2013-01-18 Thread Greg KH
On Fri, Jan 18, 2013 at 10:24:39AM +0200, Felipe Balbi wrote:
 regset is a generic implementation of regdump
 utility through debugfs.
 
 Signed-off-by: Felipe Balbi ba...@ti.com
 ---
 
 Hi Greg, would you take the patch below to debugfs ? I don't think debugfs
 should ever change whatever's passed through struct debugfs_reg32 anyway.
 
  struct debugfs_regset32 {
 - struct debugfs_reg32 *regs;
 + const struct debugfs_reg32 *regs;
   int nregs;
   void __iomem *base;
  };

Yes, I would be glad to take that type of change, feel free to send it
to me.

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, resubmit] ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

2013-01-18 Thread David Miller
From: Freddy Xin fre...@asix.com.tw
Date: Thu, 17 Jan 2013 17:32:54 +0800

 +struct ax88179_rx_pkt_header {
 +
 + u8  l4_csum_err:1,

Get rid of such extraneous empty lines.  They do not add clarity,
rather they just take up space.

 + ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR |
 + USB_RECIP_DEVICE, value, index, data, size);

This is not indented properly.  When a function call takes up
multiple lines, the text on the second and subsequent lines must
be left justified to the first column after the openning parenthesis
of the function call, like this:

function(arg1, arg2,
 arg3, arg4);

You must use the appropriate combination of TAB and space characters
to achieve this.  If you are trying to only use TAB characters, you
are doing it wrong.

This code has a lot of other similar coding style errors, please
put some effort into fixing them up before you consider resubmitting
this driver.

All of the coding style errors are probably why nobody reviewed your
driver the first time around, there's already enough properly styled
submissions to review.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-01-18 Thread Sergei Shtylyov
Serialize usb-storage operations with usbfs and 'cat /proc/bus/usb/devices',
so that they cannot disturb storage by seemingly harmless control reads.

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

Signed-off-by: Sergei Shtylyov sshtyl...@ru.mvista.com
Cc: sta...@vger.kernel.org

---
This patch is atop of 'usb-linus' branch of Greg's tree.
It has been boot tested with non-buggy USB stick only.

 drivers/usb/core/devices.c  |   13 +++-
 drivers/usb/core/devio.c|   26 +++--
 drivers/usb/core/usb.c  |   61 
 drivers/usb/storage/transport.c |   11 +++
 include/linux/usb.h |   19 
 5 files changed, 126 insertions(+), 4 deletions(-)

Index: usb/drivers/usb/core/devices.c
===
--- usb.orig/drivers/usb/core/devices.c
+++ usb/drivers/usb/core/devices.c
@@ -423,21 +423,30 @@ static char *usb_dump_desc(char *start, 
if (start  end)
return start;
 
+   /*
+* Grab device's exclusive_access mutex to prevent its driver or
+* usbfs from using this device while we are accessing it.
+*/
+   usb_excl_lock(dev, 3, 0);
+
start = usb_dump_device_descriptor(start, end, dev-descriptor);
 
if (start  end)
-   return start;
+   goto out;
 
start = usb_dump_device_strings(start, end, dev);
 
for (i = 0; i  dev-descriptor.bNumConfigurations; i++) {
if (start  end)
-   return start;
+   goto out;
start = usb_dump_config(dev-speed,
start, end, dev-config + i,
/* active ? */
(dev-config + i) == dev-actconfig);
}
+
+out:
+   usb_excl_unlock(dev, 3);
return start;
 }
 
Index: usb/drivers/usb/core/devio.c
===
--- usb.orig/drivers/usb/core/devio.c
+++ usb/drivers/usb/core/devio.c
@@ -992,6 +992,10 @@ static int proc_bulk(struct dev_state *p
ret = -EINVAL;
goto done;
}
+   if (usb_excl_lock(dev, 1, 1)) {
+   ret = -ERESTARTSYS;
+   goto done;
+   }
snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0);
 
usb_unlock_device(dev);
@@ -999,6 +1003,7 @@ static int proc_bulk(struct dev_state *p
usb_lock_device(dev);
snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, tbuf, len2);
 
+   usb_excl_unlock(dev, 1);
if (!i  len2) {
if (copy_to_user(bulk.data, tbuf, len2)) {
ret = -EFAULT;
@@ -1012,12 +1017,18 @@ static int proc_bulk(struct dev_state *p
goto done;
}
}
+   if (usb_excl_lock(dev, 2, 1)) {
+   ret = -ERESTARTSYS;
+   goto done;
+   }
snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1);
 
usb_unlock_device(dev);
i = usb_bulk_msg(dev, pipe, tbuf, len1, len2, tmo);
usb_lock_device(dev);
snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0);
+
+   usb_excl_unlock(dev, 2);
}
ret = (i  0 ? i : len2);
  done:
@@ -1979,8 +1990,17 @@ static long usbdev_do_ioctl(struct file 
 
usb_lock_device(dev);
if (!connected(ps)) {
-   usb_unlock_device(dev);
-   return -ENODEV;
+   ret = -ENODEV;
+   goto unlock;
+   }
+
+   /*
+* Grab device's exclusive_access lock to prevent its driver from
+* using this device while it is being accessed by us.
+*/
+   if (usb_excl_lock(ps-dev, 3, 1)) {
+   ret = -ERESTARTSYS;
+   goto unlock;
}
 
switch (cmd) {
@@ -2138,6 +2158,8 @@ static long usbdev_do_ioctl(struct file 
ret = proc_disconnect_claim(ps, p);
break;
}
+   usb_excl_unlock(dev, 3);
+unlock:
usb_unlock_device(dev);
if (ret = 0)
   

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

2013-01-18 Thread Stephen Warren
On 01/17/2013 11:15 PM, Venu Byravarasu wrote:
 As Tegra PHY driver needs to access one of the Host registers,
 added few APIs.

I have applied patches 1-3 (v1) and patch 4 (v3) to Tegra's for-3.9/usb
branch.
--
To unsubscribe from this list: send the line unsubscribe 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] USB: prevent overlapping access by usb-storage and usbfs

2013-01-18 Thread Sergei Shtylyov
Serialize usb-storage operations with usbfs and 'cat /proc/bus/usb/devices',
so that they cannot disturb storage by seemingly harmless control reads.

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

Signed-off-by: Sergei Shtylyov sshtyl...@ru.mvista.com
Cc: sta...@vger.kernel.org

---
This patch is atop of 'usb-linus' branch of Greg's tree.
It has been boot tested with non-buggy USB stick only.

Changes since v1:
- changed 'mutex' to custom lock in order to provide duplex USBDEVFS_BULK[32]
  ioctl's;

Changes since v2:
- s/0/false/ and s/1/true/ in usb_excl_lock() calls.

 drivers/usb/core/devices.c  |   13 +++-
 drivers/usb/core/devio.c|   26 +++--
 drivers/usb/core/usb.c  |   61 
 drivers/usb/storage/transport.c |   11 +++
 include/linux/usb.h |   19 
 5 files changed, 126 insertions(+), 4 deletions(-)

Index: usb/drivers/usb/core/devices.c
===
--- usb.orig/drivers/usb/core/devices.c
+++ usb/drivers/usb/core/devices.c
@@ -423,21 +423,30 @@ static char *usb_dump_desc(char *start, 
if (start  end)
return start;
 
+   /*
+* Grab device's exclusive_access mutex to prevent its driver or
+* usbfs from using this device while we are accessing it.
+*/
+   usb_excl_lock(dev, 3, false);
+
start = usb_dump_device_descriptor(start, end, dev-descriptor);
 
if (start  end)
-   return start;
+   goto out;
 
start = usb_dump_device_strings(start, end, dev);
 
for (i = 0; i  dev-descriptor.bNumConfigurations; i++) {
if (start  end)
-   return start;
+   goto out;
start = usb_dump_config(dev-speed,
start, end, dev-config + i,
/* active ? */
(dev-config + i) == dev-actconfig);
}
+
+out:
+   usb_excl_unlock(dev, 3);
return start;
 }
 
Index: usb/drivers/usb/core/devio.c
===
--- usb.orig/drivers/usb/core/devio.c
+++ usb/drivers/usb/core/devio.c
@@ -992,6 +992,10 @@ static int proc_bulk(struct dev_state *p
ret = -EINVAL;
goto done;
}
+   if (usb_excl_lock(dev, 1, true)) {
+   ret = -ERESTARTSYS;
+   goto done;
+   }
snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0);
 
usb_unlock_device(dev);
@@ -999,6 +1003,7 @@ static int proc_bulk(struct dev_state *p
usb_lock_device(dev);
snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, tbuf, len2);
 
+   usb_excl_unlock(dev, 1);
if (!i  len2) {
if (copy_to_user(bulk.data, tbuf, len2)) {
ret = -EFAULT;
@@ -1012,12 +1017,18 @@ static int proc_bulk(struct dev_state *p
goto done;
}
}
+   if (usb_excl_lock(dev, 2, true)) {
+   ret = -ERESTARTSYS;
+   goto done;
+   }
snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1);
 
usb_unlock_device(dev);
i = usb_bulk_msg(dev, pipe, tbuf, len1, len2, tmo);
usb_lock_device(dev);
snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0);
+
+   usb_excl_unlock(dev, 2);
}
ret = (i  0 ? i : len2);
  done:
@@ -1979,8 +1990,17 @@ static long usbdev_do_ioctl(struct file 
 
usb_lock_device(dev);
if (!connected(ps)) {
-   usb_unlock_device(dev);
-   return -ENODEV;
+   ret = -ENODEV;
+   goto unlock;
+   }
+
+   /*
+* Grab device's exclusive_access lock to prevent its driver from
+* using this device while it is being accessed by us.
+*/
+   if (usb_excl_lock(ps-dev, 3, true)) {
+   ret = -ERESTARTSYS;
+   goto unlock;
}
 
switch (cmd) {
@@ -2138,6 +2158,8 @@ static long usbdev_do_ioctl(struct 

Re: USB3 Not Being Detected on Intel DX79TO Desktop Board

2013-01-18 Thread Greg KH
On Fri, Jan 18, 2013 at 07:36:38PM +, Robert Dvoracek wrote:
 Hello.  Is there any chance a future version of the kernel will
 support the Renesis USB3 on the DX79TO?  Everything else is working
 great though, so I still love you.

Specifics as to exactly what is not working would be appreciated.

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 v9] usb_8dev: Add support for USB2CAN interface from 8 devices

2013-01-18 Thread Oliver Hartkopp
On 18.01.2013 15:31, Bernd Krumböck wrote:


 [ 5941.577933] peak_usb 2-1.4:1.0 can3: Rx urb aborted (-32)
 [ 5941.743693] usb 2-1.2: USB disconnect, device number 11
 [ 5941.744096] usb_8dev 2-1.2:1.0 can2: device disconnected
 [ 5941.744121] usb_8dev 2-1.2:1.0 can2: sending command message failed [
 5941.744124] usb_8dev 2-1.2:1.0 can2: couldn't stop device
 
 How did you do this test?
 


- plug in USB
- ip link set can2 type can bitrate 100 restart-ms 100
- ifconfig can2 up
- plug out USB

leads to

(..)

[  347.106542] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.106802] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.107057] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.107308] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.107541] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.107790] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.108049] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.108289] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.108539] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.108794] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.108939] usb 2-1.2: USB disconnect, device number 6
[  347.109022] usb_8dev 2-1.2:1.0 can2: Rx URB aborted (-32)
[  347.111677] usb_8dev 2-1.2:1.0 can2: device disconnected
[  347.111863] usb_8dev 2-1.2:1.0 can2: sending command message failed
[  347.111868] usb_8dev 2-1.2:1.0 can2: couldn't stop device

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


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

2013-01-18 Thread Greg KH
On Fri, Jan 18, 2013 at 11:35:49PM +0300, Sergei Shtylyov wrote:
 Serialize usb-storage operations with usbfs and 'cat /proc/bus/usb/devices',
 so that they cannot disturb storage by seemingly harmless control reads.
 
 This patch was adapted from 2.4 patches by Pete Zaitcev.  The initial patch of
 the series dates back to 2004 and it unfortunately wasn't applied to 2.6 in 
 the
 same form back then (it was applied in another form and immediately reverted).
 Despite 8+ years passing from that moment, the vendors didn't stop producing
 USB devices that require this kind of patch. Two recent examples are SanDisk
 Cruzer Slice 8GB and Kingston DataTraveller 100 G2 32GB.  In the latter case,
 even the enumeration fails as the INQUIRY command normally takes 2.8 seconds 
 to
 finish, so 'udev' also comes into action with its control requests, with 
 neither
 completing normally.
 
 Signed-off-by: Sergei Shtylyov sshtyl...@ru.mvista.com
 Cc: sta...@vger.kernel.org
 
 ---
 This patch is atop of 'usb-linus' branch of Greg's tree.
 It has been boot tested with non-buggy USB stick only.

I really want to see this tested on the hardware that it is supposed to
fix the problem for, otherwise it's kind of pointless, 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: [usb-storage] Re: USB storage suspend

2013-01-18 Thread Oliver Neukum
On Friday 18 January 2013 14:09:26 Alan Stern wrote:

 The autosuspend delay at the USB level probably should be set to 0; 
 then the autosuspend delay at the SCSI disk level will control the 
 actual power changes.

What about things like lsusb? Should we better not go down quite
to zero?

 Note that drives with removable media are polled automatically by the
 kernel at intervals of 2 seconds by default.  If the autosuspend delay
 is longer than that, it will never have a chance to take effect.

Unfortunately most storage devices in the usual dongle shape, even if
they do not have a removable medium claim to have a removable medium.

Actually I consider this a bug in the spec. It should specify a method
for the device to tell the driver whether medium removal or insertation
will trigger remote wakeup.

Regards
Oliver

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


[GIT PATCH] USB fixes for 3.8-rc4

2013-01-18 Thread Greg KH
The following changes since commit 8cf65dc386f3634a43312f436cc7a935476a40c4:

  usb: ftdi_sio: Crucible Technologies COMET Caller ID - pid added (2013-01-13 
13:44:23 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ tags/usb-3.8-rc4

for you to fetch changes up to 1ee0a224bc9aad1de496c795f96bc6ba2c394811:

  USB: io_ti: Fix NULL dereference in chase_port() (2013-01-17 17:34:39 -0800)


USB fixes for 3.8-rc4

Here are 3 USB patches for 3.8-rc4.  Two of them are new device id
patches, and the third fixes a reported oops in the io_ti USB serial
driver.

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


Bjørn Mork (2):
  USB: option: blacklist network interface on ONDA MT8205 4G LTE
  USB: option: add TP-LINK HSUPA Modem MA180

Wolfgang Frisch (1):
  USB: io_ti: Fix NULL dereference in chase_port()

 drivers/usb/serial/io_ti.c  | 3 +++
 drivers/usb/serial/option.c | 9 -
 2 files changed, 11 insertions(+), 1 deletion(-)
--
To unsubscribe from this list: send the line unsubscribe 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] USB: prevent overlapping access by usb-storage and usbfs

2013-01-18 Thread Sergei Shtylyov
Hello.

On 01/18/2013 10:48 PM, Greg KH wrote:

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

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

 Signed-off-by: Sergei Shtylyov sshtyl...@ru.mvista.com
 Cc: sta...@vger.kernel.org

 ---
 This patch is atop of 'usb-linus' branch of Greg's tree.
 It has been boot tested with non-buggy USB stick only.

 I really want to see this tested on the hardware that it is supposed to
 fix the problem for, otherwise it's kind of pointless, right?

   Don't forget that the same code is working in 2.4 for several years. It would
be hard for me, I'm afraid, to arrange testing this on the modern broken h/w in
the near future as I'm being switched from working with MontaVista to another
company starting next week. Also, we've already internally committed v1 of the
patch as the fix for the issue...

 thanks,

 greg k-h

WBR, Sergei

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


Re: USB storage suspend

2013-01-18 Thread Sarah Sharp
On Fri, Jan 18, 2013 at 02:09:26PM -0500, Alan Stern wrote:
 On Fri, 18 Jan 2013, Sarah Sharp wrote:
 
  Hi Alan,
  
  What's the current state of USB mass storage suspend?  I know there was
  some purposed changes to the SCSI or block layer that would have
  effected suspend, and I wondered if those made it in.
 
 The block-layer autosuspend patches are in pretty good shape.  I
 haven't heard any objections to them recently from James Bottomley or
 Jens Axboe, so maybe they'll be accepted soon.

Can you remind me how those patches will change the current auto-suspend
behavior?

 Don't forget that autosuspend for mass storage is available right now,
 in 3.7 and earlier kernels.  It affects only disks whose device file
 isn't open (hence no mounted filesystems on the disk), and it has to be
 enabled by userspace (write auto to power/control for the SCSI disk
 device and its ancestors).

Ok, just to verify, say I have this tree:

sarah@xanatos:~$ lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
|__ Port 2: Dev 2, If 0, Class=stor., Driver=usb-storage, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/4p, 12M
|__ Port 2: Dev 3, If 0, Class=HID, Driver=usbhid, 1.5M
|__ Port 2: Dev 3, If 1, Class=HID, Driver=usbhid, 1.5M
|__ Port 3: Dev 4, If 0, Class=HID, Driver=usbhid, 1.5M
|__ Port 3: Dev 4, If 1, Class=HID, Driver=usbhid, 1.5M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/8p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
|__ Port 6: Dev 3, If 0, Class='bInterfaceClass 0x0e not yet handled', 
Driver=uvcvideo, 480M
|__ Port 6: Dev 3, If 1, Class='bInterfaceClass 0x0e not yet handled', 
Driver=uvcvideo, 480M

If I want the usb-storage device to suspend, I would have to run:

root@xanatos:/sys/bus/usb/devices/4-2/power# echo auto  control
root@xanatos:/sys/bus/usb/devices/4-2/power# echo 100  autosuspend_delay_ms

Auto-suspend is already enabled for the roothub.  I unmounted the
filesystem on the SD card, and then waited for the port to go into U3.
That never happened, although I could see the port transition into other
link power states like U2.

I'm not sure why the device isn't going into U3.  I have
CONFIG_USB_SUSPEND turned on for this kernel.

  I'm specifically looking for when we can expect a USB storage device to
  go into auto-suspend.  If userspace enables auto-suspend and sets the
  autosuspend_delay_ms to zero, could we see auto-suspend between SCSI
  commands?  Or will the device remain in U0 until the storage device is
  unmounted?
 
 The autosuspend delay at the USB level probably should be set to 0; 
 then the autosuspend delay at the SCSI disk level will control the 
 actual power changes.

Is there a way to get at the auto-suspend delay at the SCSI disk level
through sysfs?  What's the default timeout?

 I'm not sure if everything will work correctly with the delay set to 0.  
 In theory you would indeed see autosuspend kicking in between SCSI
 commands.  But the implementation might not work correctly under those
 conditions -- I didn't care about that case because it shouldn't be
 used.
 
 On the other hand, it should work as expected once the autosuspend
 delay is set to a not-unreasonable value, say 100 ms or anything
 larger.  The drive should indeed go into suspend whenever the interval
 between SCSI commands is longer than the autosuspend delay (within a 
 factor of 2).
 
 Note that drives with removable media are polled automatically by the
 kernel at intervals of 2 seconds by default.  If the autosuspend delay
 is longer than that, it will never have a chance to take effect.

Isn't there a sysfs file to control the polling rate for removable
media?  I don't remember where is it though.  (I seem to ask about mass
storage suspend approximately once a year, and the state gets swapped
out in that time. :)

Sarah
--
To unsubscribe from this list: send the line unsubscribe 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] USB: prevent overlapping access by usb-storage and usbfs

2013-01-18 Thread Sergei Shtylyov
Hello.

On 01/18/2013 11:17 PM, Pete Zaitcev wrote:

Don't forget that the same code is working in 2.4 for several years.

 In mainline?  Or some random vendor-specific kernel branch where we have
 no visiblity into?  :)

 Yes, it's in mainline since 2006. However, I am in full agreement with

   Initial patch went in in 2004 even. Then it was reworked over 2 years.

 your demands for actual tests. 2.4 saw a significant shrinkage of installed
 base from the 2.4.35 onward, so it provided a narrow testing field.

   Well, back in 2006 it was 2.4.33 time yet... but anyway, I see it's hopeless
and 2.6 is probably going to lose that battle to 2.4 for the years to come as 
well.

 -- Pete

WBR, Sergei

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


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

2013-01-18 Thread Alan Stern
On Fri, 18 Jan 2013, David Miller wrote:

  +   ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR |
  +   USB_RECIP_DEVICE, value, index, data, size);
 
 This is not indented properly.  When a function call takes up
 multiple lines, the text on the second and subsequent lines must
 be left justified to the first column after the openning parenthesis
 of the function call, like this:
 
   function(arg1, arg2,
arg3, arg4);
 
 You must use the appropriate combination of TAB and space characters
 to achieve this.  If you are trying to only use TAB characters, you
 are doing it wrong.

Documentation/CodingStyle doesn't mention this.  Does the networking 
stack have its own special requirements, not listed in CodingStyle?

Alan Stern

P.S: The standard I have tried to follow for USB code is to indent
continuation lines by two tab stops more than the first line,
regardless of whether the break occurs inside a function call.  I have
seen other people consistently indent continuation lines by 1/2 tab
stop (i.e., four spaces) beyond the first line.

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


  1   2   >