Re: [PATCH v3 04/11] otg-fsm: move usb_bus_start_enum into otg-fsm-ops

2015-07-15 Thread Peter Chen
On Wed, Jul 15, 2015 at 04:30:27PM +0300, Roger Quadros wrote:
 On 14/07/15 03:34, Peter Chen wrote:
  On Mon, Jul 13, 2015 at 01:13:54PM +0300, Roger Quadros wrote:
  Peter,
 
  On 13/07/15 04:58, Peter Chen wrote:
  On Wed, Jul 08, 2015 at 01:19:30PM +0300, Roger Quadros wrote:
  This is to prevent missing symbol build error if OTG is
  enabled (built-in) and HCD core (CONFIG_USB) is module.
 
 
  We may let the OTG-DRD/OTG-FSM depends on CONFIG_USB to fix it.
 
  CONFIG_OTG already depends on CONFIG_USB as it is a sub-option of
  CONFIG_USB. It doesn't depend on CONFIG_USB_GADGET and that can
  be fixed.
 
  But dependency is not the problem here. Symbols not available to
  OTG driver when USB/GADGET is 'm' is the problem.
 
  e.g.
  CONFIG_USB_OTG is always built-in.
  we need to work if CONFIG_USB is 'm'/'y'
  _and_ if CONFIG_USB_GADGET is 'm'/'y'
 
  
  below should fix this issue, but we may need to make some
  changes for code which are defined by CONFIG_USB_OTG.
  
  diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
  index a99c89e..5e374ad 100644
  --- a/drivers/usb/core/Kconfig
  +++ b/drivers/usb/core/Kconfig
  @@ -42,8 +42,9 @@ config USB_DYNAMIC_MINORS
If you are unsure about this, say N here.
  
  config USB_OTG
  -   bool OTG support
  +   tristate OTG support
  depends on PM
  +   depends on USB  USB_GADGET
  default n
 help
   The most notable feature of
   USB OTG is support for a
 
 With this USB_OTG will become 'm' when either USB or USB_GADGET is m
 and will break if either USB or USB_GADGET is made y as all OTG core
 API symbols won't be available. :)
 

Ok, after thinking more, seems we can't handle properly if USB_OTG as
'm', your idea that using host/gadget/fsm-ops to call hcd/gadget API
and the controller driver will defines these ops (due to it will use
hcd/gadget function) is proper way currently.

-- 

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


Re: [PATCH 2/2] gpio: gpio-ftdi-cbus: add driver for FTDI CBUS GPIOs

2015-07-15 Thread Linus Walleij
On Sun, Jun 21, 2015 at 12:12 AM, Stefan Agner ste...@agner.ch wrote:

 This driver allows to use the CBUS pins, e.g. CBUS 0-3 on FT232R
 type of devices. Note that the pins need to be configured first
 by using I/O mode signal option in the EEPROM. This is _not_ the
 factory default configuration of any of the four pins.

 See also FTDI's Application Note AN_232R-01.

 Signed-off-by: Stefan Agner ste...@agner.ch

I see no big problems with this driver but I guess the serial portions
are the controversial parts.

 +++ b/drivers/gpio/gpio-ftdi-cbus.c
 @@ -0,0 +1,167 @@
 +/*
 + * gpiolib support for FTDI SIO chips supporting CBUS GPIO's (FT232R class)
 + *
 + * Copyright 2015 Stefan Agner
 + *
 + * Author: Stefan Agner ste...@agner.ch
 + *
 + *  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;  either version 2 of the  License, or (at your
 + *  option) any later version.
 + *
 + * Note: To use the GPIOs on CBUS the signal option need to be set to
 + * I/O mode in EEPROM!
 + */
 +
 +#include linux/kernel.h
 +#include linux/slab.h
 +#include linux/module.h
 +#include linux/gpio.h

#include linux/gpio/driver.h

should be enough.

 +static int ftdi_cbus_gpio_direction_input(struct gpio_chip *chip,
 + unsigned offset)
 +{
 +   struct ftdi_cbus_gpio *fcg = to_ftdi_cbus_gpio(chip);
 +
 +   fcg-cbus_mask = ~((1  offset)  4);

I usually replace:

(1  offset)

with

#include linux/bitops.h

BIT(offset)

so it's clear what is happening.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe 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] phy: ulpi_phy: Add const qualifier to ops

2015-07-15 Thread Kishon Vijay Abraham I
Hi Axel,

On Wednesday 15 July 2015 12:40 PM, Axel Lin wrote:
 2015-06-05 8:27 GMT+08:00 Axel Lin axel@ingics.com:
 The ops is never changed in ulpi_phy_create(), so make it const.
 
 Hi Kishon,
 
 Would you pick up this patch?

yes.. I'll take once I start queuing the patches.

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 RESEND] phy: tusb1210: Use devm_gpiod_get_optional for optional GPIOs

2015-07-15 Thread Axel Lin
2015-07-15 16:29 GMT+08:00 Uwe Kleine-König u.kleine-koe...@pengutronix.de:
 Hello,

 On Wed, Jul 15, 2015 at 01:45:44PM +0530, Kishon Vijay Abraham I wrote:
 Hi,

 On Wednesday 15 July 2015 12:34 PM, Axel Lin wrote:
  2015-06-20 15:39 GMT+08:00 Axel Lin axel@ingics.com:
  Also simplify the code a bit by specify direction and initial value for
  output in devm_gpiod_get_optional function.
 
  Signed-off-by: Axel Lin axel@ingics.com
  Acked-by: Heikki Krogerus heikki.kroge...@linux.intel.com
  Acked-by: Kishon Vijay Abraham I kis...@ti.com
  ---
  Hi
  This patch was sent on https://lkml.org/lkml/2015/5/31/221 with ACKs.
  It's still not in linux-next, so here is a resend.
 
  Hi Kishon,
  No response from Felipe.
  The phy-tusb1210 driver is already in Linus' tree, maybe you can pick
  up this patch.

 A similar patch was done by Uwe [1]. But since you've sent this patch before
 Uwe, IMO your patch must be merged.

 Uwe,
 How do you want this patch to be merged. Is it okay If I take this in PHY 
 tree?
 Can you give your Acked-by?
 I intend to change the gpiod functions to make the flags mandatory
 for 4.3. I already sent the respective change to Linus Walleij to pull
 for next and my commit to fix phy-tusb1210 is included to not break this
 driver.

I'm fine to just apply Uwe's patch if it make things easier.

Axel
--
To unsubscribe from this list: send the line unsubscribe 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: io_ti: Move request_firmware() calls out of download_fw()

2015-07-15 Thread Johan Hovold
On Sun, Jun 28, 2015 at 01:28:19PM -0500, Peter E. Berger wrote:
 From: Peter E. Berger pber...@brimson.com
 
 The io_ti driver fails to download firmware to Edgeport
 devices such as the EP/416, even when the on-disk firmware image
 (/lib/firmware/edgeport/down3.bin) is more current than the version
 on the EP/416.  The current download code is broken in a few ways.
 Notably it mis-uses global variables OperationalMajorVersion and
 OperationalMinorVersion (reading their values before they've been
 properly initialized and subsequently initializing them multiple times
 without synchronization).  This patch drops the global variables and
 replaces the redundant calls to request_firmware()/release_firmware()
 in download_fw() with a single call pair in edge_startup(); the firmware
 image pointer is then passed to download_fw() and build_i2c_fw_hdr().

This looks good now apart from one small issue I mention below.

Could you also please rename the patch summary (Subject) to something
more descriptive such as

USB: io_ti: fix firmware version handling

or similar?

 Signed-off-by: Peter E. Berger pber...@brimson.com
 ---
  drivers/usb/serial/io_ti.c | 91 
 +-
  1 file changed, 42 insertions(+), 49 deletions(-)
 
 diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
 index 69378a7..4492c17 100644
 --- a/drivers/usb/serial/io_ti.c
 +++ b/drivers/usb/serial/io_ti.c

 @@ -943,6 +925,13 @@ static int download_fw(struct edgeport_serial *serial)
   struct usb_interface_descriptor *interface;
   int download_cur_ver;
   int download_new_ver;
 + u8 fw_major_version;
 + u8 fw_minor_version;
 +

I think you should add minimal sanity checks on the firmware length here
as part of this patch. That is, make sure that fw-size = 4, or if you
prefer, fw-size = FW_HEADER_SIZE (i.e. 8).

 + fw_major_version = fw-data[0];
 + fw_minor_version = fw-data[1];

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


Re: [PATCH RESEND] phy: tusb1210: Use devm_gpiod_get_optional for optional GPIOs

2015-07-15 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 15 July 2015 12:34 PM, Axel Lin wrote:
 2015-06-20 15:39 GMT+08:00 Axel Lin axel@ingics.com:
 Also simplify the code a bit by specify direction and initial value for
 output in devm_gpiod_get_optional function.

 Signed-off-by: Axel Lin axel@ingics.com
 Acked-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 Acked-by: Kishon Vijay Abraham I kis...@ti.com
 ---
 Hi
 This patch was sent on https://lkml.org/lkml/2015/5/31/221 with ACKs.
 It's still not in linux-next, so here is a resend.
 
 Hi Kishon,
 No response from Felipe.
 The phy-tusb1210 driver is already in Linus' tree, maybe you can pick
 up this patch.

A similar patch was done by Uwe [1]. But since you've sent this patch before
Uwe, IMO your patch must be merged.

Uwe,
How do you want this patch to be merged. Is it okay If I take this in PHY tree?
Can you give your Acked-by?

Thanks
Kishon

[1] - https://www.mail-archive.com/linux-media@vger.kernel.org/msg90203.html
 
 Regards,
 Axel
 
--
To unsubscribe from this list: send the line unsubscribe 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: About zero-length packet design for EHCI

2015-07-15 Thread Bernd Porr

Thanks Alan,

that was very helpful.

/Bernd

Alan Stern wrote:

On Tue, 14 Jul 2015, Bernd Porr wrote:

I've got a question regarding ISO transfer. If the firmware is not 
providing data is the ISO urb returning zero packet length and if yes 
how can I check that in the driver? I'm working on a solution for my 
USBDUX driver where the ADC for example takes 800us to measure all data 
so that a couple of zero length packets were generated until new data 
has been created.


I assume you're talking about isoc-IN transfers where the device either
sends a 0-length packet or doesn't send any packet at all.  When that
happens, the corresponding urb_iso_packet_descriptor structure will
contain 0 for .actual_length and either 0 for .status (if a 0-length
packet was received) or -EXDEV for .status (if no packet was received). 
Your driver can check these values in the URB's completion routine.


Alan Stern



--
http://www.berndporr.me.uk
http://www.imdb.com/name/nm3293421/
http://www.facebook.com/bernd.porr
+44 (0)7840 340069
--
To unsubscribe from this list: send the line unsubscribe 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 RESEND] phy: tusb1210: Use devm_gpiod_get_optional for optional GPIOs

2015-07-15 Thread Uwe Kleine-König
Hello,

On Wed, Jul 15, 2015 at 01:45:44PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Wednesday 15 July 2015 12:34 PM, Axel Lin wrote:
  2015-06-20 15:39 GMT+08:00 Axel Lin axel@ingics.com:
  Also simplify the code a bit by specify direction and initial value for
  output in devm_gpiod_get_optional function.
 
  Signed-off-by: Axel Lin axel@ingics.com
  Acked-by: Heikki Krogerus heikki.kroge...@linux.intel.com
  Acked-by: Kishon Vijay Abraham I kis...@ti.com
  ---
  Hi
  This patch was sent on https://lkml.org/lkml/2015/5/31/221 with ACKs.
  It's still not in linux-next, so here is a resend.
  
  Hi Kishon,
  No response from Felipe.
  The phy-tusb1210 driver is already in Linus' tree, maybe you can pick
  up this patch.
 
 A similar patch was done by Uwe [1]. But since you've sent this patch before
 Uwe, IMO your patch must be merged.
 
 Uwe,
 How do you want this patch to be merged. Is it okay If I take this in PHY 
 tree?
 Can you give your Acked-by?
I intend to change the gpiod functions to make the flags mandatory
for 4.3. I already sent the respective change to Linus Walleij to pull
for next and my commit to fix phy-tusb1210 is included to not break this
driver.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4 1/1] usb:serial:f81534 add F81532/534 driver

2015-07-15 Thread Paul Bolle
Just a few nits, I'm afraid.

On di, 2015-07-14 at 11:13 +0800, Peter Hung wrote:
 --- /dev/null
 +++ b/drivers/usb/serial/f81534.c

 +int f81534_gpio_request(struct gpio_chip *chip, unsigned offset)
 +{
 + [...]
 +}

static?

 +void f81534_gpio_free(struct gpio_chip *chip, unsigned offset)
 +{
 + [...]
 +}

Ditto.

 +static struct gpio_chip f81534_gpio_chip_templete = {
 + [...]
 + .request = f81534_gpio_request,
 + .free = f81534_gpio_free,
 + [...]
 +};

 +int f81534_ioctl_set_rs485(struct usb_serial_port *port,
 +struct serial_rs485 __user *arg)
 +{
 + [...]
 +}

Ditto.

 +static int f81534_ioctl(struct tty_struct *tty, unsigned int cmd,
 + unsigned long arg)
 +{
 + [...]
 + case TIOCSRS485:
 + return f81534_ioctl_set_rs485(port,
 +   (struct serial_rs485 __user *)
 +   arg);
 + [...]
 +}

 +int f81534_prepare_write_buffer(struct usb_serial_port *port,
 + void *dest, size_t size)
 +{
 + [...]
 +}

Ditto.

 +static struct usb_serial_driver f81534_device = {
 + [...]
 + .prepare_write_buffer = f81534_prepare_write_buffer,
 + .[...]
 +};
 +
 +static struct usb_serial_driver *const serial_drivers[] = {
 + f81534_device, NULL
 +};
 +

If you drop this empty line ...

 +module_usb_serial_driver(serial_drivers, id_table);

and add an empty line here, things look neater.

 +MODULE_DESCRIPTION(DRIVER_DESC);
 +MODULE_AUTHOR(Peter Hong peter_h...@fintek.com.tw);
 +MODULE_AUTHOR(Tom Tsai tom_t...@fintek.com.tw);
 +MODULE_LICENSE(GPL);

Thanks,


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


Re: [PATCH V4 1/1] usb:serial:f81534 add F81532/534 driver

2015-07-15 Thread Peter Hung

Hi Paul  Johan

Paul Bolle 於 2015/7/15 下午 04:36 寫道:

Just a few nits, I'm afraid.

+int f81534_gpio_request(struct gpio_chip *chip, unsigned offset)
+{
+   [...]
+}


static?


Thanks Paul for point this out.

And sorry for Johan. It's seems to make a new patch V5. I'll merge
some minor fix with newer patch.
--
With Best Regards,
Peter Hung
--
To unsubscribe from this list: send the line unsubscribe 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 3/4] USB: io_ti: Add firmware image sanity checks

2015-07-15 Thread Johan Hovold
On Sun, Jun 28, 2015 at 01:28:20PM -0500, Peter E. Berger wrote:
 From: Peter E. Berger pber...@brimson.com
 
 Do what we can to verify that the driver's firmware image is valid
 (before attempting to download it to the Edgeport) by adding a new
 function, check_fw_sanity(), and a call to it in in download_fw().
 Also add an fw == NULL check in edge_startup().
 
 Note: It looks like some Edgeports (models like the EP/416 with on-board
 E2PROM) may be able to function even if the on-disk firmware image is
 bad or missing, iff their local E2PROM versions are valid.  But most
 Edgeport models (I've tried EP/1 and EP/8) do not appear to have this
 capability and they always rely on the on-disk firmware image.
 
 I tested an implementation that calls the new check_fw_sanity()
 function at the top of download_fw() and, rather than simply returning
 an error if the firmware image is bad or missing, it saves the result
 and defers the decision until later when it may find that it is running
 on a E2PROM-equipped device with a valid image.  But I think this is
 messier than it is worth (adding still more messiness to the already
 very messy download_fw()) for such a marginal possible benefit.  So, at
 least for now, I have chosen the much simpler approach of returning an
 error whenever edge_startup() fails to load an on-disk firmware image, or
 check_fw_sanity() indicates that it is unusable.
 
 Signed-off-by: Peter E. Berger pber...@brimson.com
 ---
  drivers/usb/serial/io_ti.c | 63 
 +-
  1 file changed, 62 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
 index 4492c17..7c5f6fd 100644
 --- a/drivers/usb/serial/io_ti.c
 +++ b/drivers/usb/serial/io_ti.c
 @@ -35,6 +35,7 @@
  #include linux/uaccess.h
  #include linux/usb.h
  #include linux/usb/serial.h
 +#include asm/unaligned.h
  
  #include io_16654.h
  #include io_usbvend.h
 @@ -909,6 +910,64 @@ static int ti_cpu_rev(struct edge_ti_manuf_descriptor 
 *desc)
   return TI_GET_CPU_REVISION(desc-CpuRev_BoardRev);
  }
  
 +/*
 + * Edgeport firmware images start with a 7-byte header:
 + *
 + *  u8 major_version;
 + *  u8 minor_version;
 + *  le16 build_number;
 + *  le16 length;
 + *  u8 checksum;
 + *
 + * build_number has been set to 0 in all three of the images I have
 + * seen, and Digi Tech Support suggests that it is safe to ignore it.
 + *
 + * length is the number of bytes of actual data following the header.
 + *
 + * checksum is the low order byte resulting from adding the values of
 + * all the data bytes.
 + *
 + */
 +static int check_fw_sanity(struct edgeport_serial *serial,
 + const struct firmware *fw)
 +{
 +#define FW_HEADER_SIZE 7
 +#define FW_LENGTH_OFFSET 4
 +#define FW_CHECKSUM_OFFSET 6

Could you move this to the top of the file with the other defines?

Why not use a struct edgeport_fw_hdr instead? That could be reused when
parsing the header in download_fw as well.

 + u16 length_data;
 + u16 length_total;
 + u8 checksum;
 + int checksum_new = 0;
 + int pos;
 + struct device *dev = serial-serial-interface-dev;
 +
 + if (fw-size  FW_HEADER_SIZE) {
 + dev_err(dev, %s - Incomplete fw header\n, __func__);

You can drop the function name from these error messages that are
already descriptive enough.

 + return 1;

return -EINVAL on errors

 + }
 +
 + length_data = get_unaligned_le16(fw-data[FW_LENGTH_OFFSET]);
 + checksum = fw-data[FW_CHECKSUM_OFFSET];
 + length_total = length_data + FW_HEADER_SIZE;
 +
 + if (fw-size != length_total) {
 + dev_err(dev, %s - Bad fw size (Expected:%d, Got:%d)\n,
 + __func__, length_total, (int)fw-size);

Use %u and %zu and drop the cast.

Space after ':'?

 + return 1;
 + }
 +
 + for (pos = FW_HEADER_SIZE; pos  length_total; ++pos)

 Use pos  fw-size

 + checksum_new = (checksum_new + fw-data[pos])  0xFF;
 +
 + if (checksum_new != checksum) {
 + dev_err(dev, %s - Bad fw checksum (Expected:0x%x, Got:0x%x)\n,
 +  __func__, checksum, checksum_new);
 + return 1;
 + }
 +
 + return 0;
 +}
 +
  /**
   * DownloadTIFirmware - Download run-time operating firmware to the TI5052
   *
 @@ -928,6 +987,8 @@ static int download_fw(struct edgeport_serial *serial,
   u8 fw_major_version;
   u8 fw_minor_version;
  
 + if (check_fw_sanity(serial, fw))
 + return -EINVAL;

I'd add a newline here.

   fw_major_version = fw-data[0];
   fw_minor_version = fw-data[1];
   /* If on-board version is newer, fw_version will be updated below. */
 @@ -2377,7 +2438,7 @@ static int edge_startup(struct usb_serial *serial)
   usb_set_serial_data(serial, edge_serial);
  
   status = request_firmware(fw, fw_name, dev);
 - if (status) {
 + if (status || fw == NULL) {

This 

Re: [PATCH v7 1/4] USB: io_ti: Increase insufficient timeout for firmware downloads

2015-07-15 Thread Johan Hovold
On Sun, Jun 28, 2015 at 01:28:18PM -0500, Peter E. Berger wrote:
 From: Peter E. Berger pber...@brimson.com
 
 The io_ti driver fails to download firmware to Edgeport devices such as
 the EP/416.  One of the problems is that the default 1 second timeout
 in ti_vsend_sync() is insufficient for download operations.  This patch
 increases the download timeout to 10 seconds.

So only EP/416 appears to affected and this is only needed after fixing
the firmware version handling as these devices have an e2prom and will
function anyway?

I'm trying to determine whether we need this one in stable or not. The
three last patches are too big and intrusive to meet the stable-kernel
rules (the sanity one isn't even a fix). We could just say that using
the latest firmware requires a recent kernel for these devices.

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


Re: [PATCH V4 1/1] usb:serial:f81534 add F81532/534 driver

2015-07-15 Thread Johan Hovold
On Wed, Jul 15, 2015 at 04:55:19PM +0800, Peter Hung wrote:
 Hi Paul  Johan
 
 Paul Bolle 於 2015/7/15 下午 04:36 寫道:
  Just a few nits, I'm afraid.
  +int f81534_gpio_request(struct gpio_chip *chip, unsigned offset)
  +{
  +  [...]
  +}
 
  static?
 
 Thanks Paul for point this out.
 
 And sorry for Johan. It's seems to make a new patch V5. I'll merge
 some minor fix with newer patch.

No problem, I'll wait for v5.

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


RE: [PATCH v2 3/3] usb: dwc3: gadget: return error if command sent to DEPCMD register fails

2015-07-15 Thread Subbaraya Sundeep Bhatta
Hi John,

 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Tuesday, July 14, 2015 12:29 AM
 To: John Youn
 Cc: ba...@ti.com; Subbaraya Sundeep Bhatta; gre...@linuxfoundation.org;
 linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 sta...@vger.kernel.org
 Subject: Re: [PATCH v2 3/3] usb: dwc3: gadget: return error if command
 sent to DEPCMD register fails
 
 Hi,
 
 On Mon, Jul 13, 2015 at 05:50:49PM +, John Youn wrote:
  On 7/11/2015 12:29 PM, Felipe Balbi wrote:
   Hi,
  
   On Sat, Jul 11, 2015 at 05:17:32PM +, Subbaraya Sundeep Bhatta
 wrote:
   Hi Felipe,
  
   Just an update on this.
  
   I'm trying to get this working with our latest IP with dwc3
   from your testing/next branch. It fails the usbtest with a
   problem unrelated to this patch.
   .
   It passes on 4.1.1.
  
   I'll have to look into the failure but I won't get to it until
   next week as I'm off the rest of this week.
  
   interesting... If you could post failure signature, I can help
   looking at it, but I guess it's too late to ask :-)
  
   thanks for helping though
  
  
  
   Hi Felipe,
  
   Nevermind about my issue, it ended up being a setup-related
 problem.
  
   I actually do see the same error as you due to this series of patches.
   Except I see it happening before even the first iteration. I get
   a completion status of 1 for the Set Endpoint Transfer Resources
   command. I'm not sure why this is.
  
   I don't see any conflict with any previous Transfer Complete.
  
   Same behavior at my end too. Fails before first iteration and I get
   completion status of 1 for Set Endpoint Resource command. Attached
   the logs of testing done with this patch and without this patch.
   Without this patch I often see completion status of 1 for Set
   Endpoint Transfer Resources command for Bulk and Isoc endpoints but
   test proceeds because driver just logs command completion status
   and moves on. We can revert this patch for time being. IP version is
 2.90a.
  
   yeah, that's what I mean, it really seems like it's the IP misbehaving.
  
   John, let's try to figure out what's the root cause of this, we
   really want to use command completion status at some point, but for
   now we need to revert the patch :-(
  
   Let me know if you want me to log STARS ticket on your solvnet system.
  
   cheers
  
 
  Hi Felipe,
 
  We found the issue last week.
 
  The start config command isn't getting called during SET_INTERFACE.
  Thus the transfer resource index isn't getting reset, and with
  multiple SET_INTERFACE commands it will eventually exhaust the
  resources.
 
  I tried out a fix and it works for me. I'll send it out separately for
  review.

Thanks John for debugging :). Yes we are not handling SET_INTERFACE similar to
SET_CONFIGURATION in driver. I guess we follow 
Alternate Initialization on SetInterface Request sequence as per data book.
Felipe can confirm this.

 
 Thanks a lot John. Not sure how come we missed that for such a long time
 :-) Let's Cc stable and get it plugged ASAP :-)
 
  Also, I noticed that the trace message that shows control transfers
  doesn't show the SET_INTERFACE properly. Any idea why this is?
 
  For example, here is the line in the trace that corresponds to the
  SET_INTERFACE:
  irq/33-dwc3-10808 [003] d...  2443.494368: dwc3_ctrl_req:
 bRequestType
  01 bRequest 0b wValue 0001 wIndex  wLength 0

Can you please elaborate? What is expected here? Did you mean it shows wrong 
info
(other than the request actually sent by Host) ?

Thanks,
Sundeep.B.S.

 
 I'll have a look at this when I'm back in the office (Jul 18th).
 
 --
 balbi
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 4/4] USB: io_ti: Add heartbeat to keep idle Edgeport ports from disconnecting

2015-07-15 Thread Johan Hovold
On Sun, Jun 28, 2015 at 01:28:21PM -0500, Peter E. Berger wrote:
 From: Peter E. Berger pber...@brimson.com
 
 When using newer Edgeport devices such as the EP/416, idle ports are
 automatically bounced (disconnected and then reconnected) approximately
 every 60 seconds.  This breaks programs (e.g: minicom) where idle periods
 are common, normal and expected.
 
 I confirmed with the manufacturer (Digi International) that some Edgeports
 now ship from the factory with firmware that expects periodic heartbeat
 queries from the driver to keep idle ports alive.  This patch implements
 heartbeat support using the mechanism Digi suggested (periodically
 requesting an I2C descriptor address) that appears effective on Edgeports
 running the newer firmware (that require it) and benign on Edgeport
 devices running older firmware.  Since we know that Edgeport firmware
 version 4.80 (the version distributed in /lib/firmware/down3.bin and used
 for Edgeports that are either running still older versions or have no
 onboard non-volatile firmware image) does not require heartbeat support,
 this patch schedules heartbeats only on devices running firmware versions
 newer than 4.80.

Looks good now.

I did a quick test here with an Edgeport/1 and firmware version 4.80 and
5.32 (from digi's ftp) and do not see any disconnects with either
version even without this patch.

Is that expected? Is only EP/416 affected or are you seeing these
disconnects with even newer firmware than 5.32?

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


[PATCH v3 09/46] usb: gadget: at91_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/at91_udc.c | 33 -
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index fc42264..a04b073 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -59,15 +59,29 @@
 #defineDRIVER_VERSION  3 May 2006
 
 static const char driver_name [] = at91_udc;
-static const char * const ep_names[] = {
-   ep0,
-   ep1,
-   ep2,
-   ep3-int,
-   ep4,
-   ep5,
+
+static const struct {
+   const char *name;
+   const struct usb_ep_caps caps;
+} ep_info[] = {
+#define EP_INFO(_name, _type, _dir) \
+   { \
+   .name = _name, \
+   .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \
+   USB_EP_CAPS_DIR_ ## _dir), \
+   }
+
+   EP_INFO(ep0,  CONTROL, ALL),
+   EP_INFO(ep1,  ALL,ALL),
+   EP_INFO(ep2,  ALL,ALL),
+   EP_INFO(ep3-int,  INT,ALL),
+   EP_INFO(ep4,  ALL,ALL),
+   EP_INFO(ep5,  ALL,ALL),
+
+#undef EP_INFO
 };
-#define ep0nameep_names[0]
+
+#define ep0nameep_info[0].name
 
 #define VBUS_POLL_TIMEOUT  msecs_to_jiffies(1000)
 
@@ -1830,7 +1844,8 @@ static int at91udc_probe(struct platform_device *pdev)
 
for (i = 0; i  NUM_ENDPOINTS; i++) {
ep = udc-ep[i];
-   ep-ep.name = ep_names[i];
+   ep-ep.name = ep_info[i].name;
+   ep-ep.caps = ep_info[i].caps;
ep-ep.ops = at91_ep_ops;
ep-udc = udc;
ep-int_mask = BIT(i);
-- 
1.9.1

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


[PATCH v3 25/46] usb: gadget: omap_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/omap_udc.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/usb/gadget/udc/omap_udc.c 
b/drivers/usb/gadget/udc/omap_udc.c
index e2fcdb8..9b7d394 100644
--- a/drivers/usb/gadget/udc/omap_udc.c
+++ b/drivers/usb/gadget/udc/omap_udc.c
@@ -2579,6 +2579,28 @@ omap_ep_setup(char *name, u8 addr, u8 type,
ep-double_buf = dbuf;
ep-udc = udc;
 
+   switch (type) {
+   case USB_ENDPOINT_XFER_CONTROL:
+   ep-ep.caps.type_control = true;
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
+   break;
+   case USB_ENDPOINT_XFER_ISOC:
+   ep-ep.caps.type_iso = true;
+   break;
+   case USB_ENDPOINT_XFER_BULK:
+   ep-ep.caps.type_bulk = true;
+   break;
+   case USB_ENDPOINT_XFER_INT:
+   ep-ep.caps.type_int = true;
+   break;
+   };
+
+   if (addr  USB_DIR_IN)
+   ep-ep.caps.dir_in = true;
+   else
+   ep-ep.caps.dir_out = true;
+
ep-ep.name = ep-name;
ep-ep.ops = omap_ep_ops;
ep-maxpacket = maxp;
-- 
1.9.1

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


[PATCH v3 27/46] usb: gadget: pxa25x_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/pxa25x_udc.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c 
b/drivers/usb/gadget/udc/pxa25x_udc.c
index f6cbe66..1301e29 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -1821,6 +1821,8 @@ static struct pxa25x_udc memory = {
.name   = ep0name,
.ops= pxa25x_ep_ops,
.maxpacket  = EP0_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL,
+   USB_EP_CAPS_DIR_ALL),
},
.dev= memory,
.reg_udccs  = UDCCS0,
@@ -1833,6 +1835,8 @@ static struct pxa25x_udc memory = {
.name   = ep1in-bulk,
.ops= pxa25x_ep_ops,
.maxpacket  = BULK_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_IN),
},
.dev= memory,
.fifo_size  = BULK_FIFO_SIZE,
@@ -1846,6 +1850,8 @@ static struct pxa25x_udc memory = {
.name   = ep2out-bulk,
.ops= pxa25x_ep_ops,
.maxpacket  = BULK_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_OUT),
},
.dev= memory,
.fifo_size  = BULK_FIFO_SIZE,
@@ -1861,6 +1867,8 @@ static struct pxa25x_udc memory = {
.name   = ep3in-iso,
.ops= pxa25x_ep_ops,
.maxpacket  = ISO_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO,
+   USB_EP_CAPS_DIR_IN),
},
.dev= memory,
.fifo_size  = ISO_FIFO_SIZE,
@@ -1874,6 +1882,8 @@ static struct pxa25x_udc memory = {
.name   = ep4out-iso,
.ops= pxa25x_ep_ops,
.maxpacket  = ISO_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO,
+   USB_EP_CAPS_DIR_OUT),
},
.dev= memory,
.fifo_size  = ISO_FIFO_SIZE,
@@ -1888,6 +1898,8 @@ static struct pxa25x_udc memory = {
.name   = ep5in-int,
.ops= pxa25x_ep_ops,
.maxpacket  = INT_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
+   USB_EP_CAPS_DIR_IN),
},
.dev= memory,
.fifo_size  = INT_FIFO_SIZE,
@@ -1903,6 +1915,8 @@ static struct pxa25x_udc memory = {
.name   = ep6in-bulk,
.ops= pxa25x_ep_ops,
.maxpacket  = BULK_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_IN),
},
.dev= memory,
.fifo_size  = BULK_FIFO_SIZE,
@@ -1916,6 +1930,8 @@ static struct pxa25x_udc memory = {
.name   = ep7out-bulk,
.ops= pxa25x_ep_ops,
.maxpacket  = BULK_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_OUT),
},
.dev= memory,
.fifo_size  = BULK_FIFO_SIZE,
@@ -1930,6 +1946,8 @@ static struct pxa25x_udc memory = {
.name   = ep8in-iso,
.ops= pxa25x_ep_ops,
.maxpacket  = ISO_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO,
+   USB_EP_CAPS_DIR_IN),
},
.dev= memory,
.fifo_size  = ISO_FIFO_SIZE,
@@ -1943,6 +1961,8 @@ static struct pxa25x_udc memory = {
.name   = ep9out-iso,
.ops= pxa25x_ep_ops,
.maxpacket  = ISO_FIFO_SIZE,
+   

[PATCH v3 23/46] usb: gadget: net2272: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/net2272.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c
index 195baf3..34ec1ec 100644
--- a/drivers/usb/gadget/udc/net2272.c
+++ b/drivers/usb/gadget/udc/net2272.c
@@ -1404,6 +1404,17 @@ net2272_usb_reinit(struct net2272 *dev)
else
ep-fifo_size = 64;
net2272_ep_reset(ep);
+
+   if (i == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
}
usb_ep_set_maxpacket_limit(dev-ep[0].ep, 64);
 
-- 
1.9.1

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


[PATCH v3 22/46] usb: gadget: mv_udc_core: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/mv_udc_core.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/gadget/udc/mv_udc_core.c 
b/drivers/usb/gadget/udc/mv_udc_core.c
index d32160d..306a7ff 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -1257,6 +1257,9 @@ static int eps_init(struct mv_udc *udc)
ep-wedge = 0;
ep-stopped = 0;
usb_ep_set_maxpacket_limit(ep-ep, EP0_MAX_PKT_SIZE);
+   ep-ep.caps.type_control = true;
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
ep-ep_num = 0;
ep-ep.desc = mv_ep0_desc;
INIT_LIST_HEAD(ep-queue);
@@ -1269,14 +1272,20 @@ static int eps_init(struct mv_udc *udc)
if (i % 2) {
snprintf(name, sizeof(name), ep%din, i / 2);
ep-direction = EP_DIR_IN;
+   ep-ep.caps.dir_in = true;
} else {
snprintf(name, sizeof(name), ep%dout, i / 2);
ep-direction = EP_DIR_OUT;
+   ep-ep.caps.dir_out = true;
}
ep-udc = udc;
strncpy(ep-name, name, sizeof(ep-name));
ep-ep.name = ep-name;
 
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+
ep-ep.ops = mv_ep_ops;
ep-stopped = 0;
usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0);
-- 
1.9.1

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


[PATCH v3 24/46] usb: gadget: net2280: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/net2280.c | 50 ++--
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 2bee912..0295cf7 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -74,19 +74,41 @@ static const char driver_desc[] = DRIVER_DESC;
 
 static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 };
 static const char ep0name[] = ep0;
-static const char *const ep_name[] = {
-   ep0name,
-   ep-a, ep-b, ep-c, ep-d,
-   ep-e, ep-f, ep-g, ep-h,
-};
 
-/* Endpoint names for usb3380 advance mode */
-static const char *const ep_name_adv[] = {
-   ep0name,
-   ep1in, ep2out, ep3in, ep4out,
-   ep1out, ep2in, ep3out, ep4in,
+#define EP_INFO(_name, _type, _dir) \
+   { \
+   .name = _name, \
+   .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \
+   USB_EP_CAPS_DIR_ ## _dir), \
+   }
+
+static const struct {
+   const char *name;
+   const struct usb_ep_caps caps;
+} ep_info_dft[] = { /* Default endpoint configuration */
+   EP_INFO(ep0name, CONTROL, ALL),
+   EP_INFO(ep-a, ALL,ALL),
+   EP_INFO(ep-b, ALL,ALL),
+   EP_INFO(ep-c, ALL,ALL),
+   EP_INFO(ep-d, ALL,ALL),
+   EP_INFO(ep-e, ALL,ALL),
+   EP_INFO(ep-f, ALL,ALL),
+   EP_INFO(ep-g, ALL,ALL),
+   EP_INFO(ep-h, ALL,ALL),
+}, ep_info_adv[] = { /* Endpoints for usb3380 advance mode */
+   EP_INFO(ep0name, CONTROL, ALL),
+   EP_INFO(ep1in,ALL,IN),
+   EP_INFO(ep2out,   ALL,OUT),
+   EP_INFO(ep3in,ALL,IN),
+   EP_INFO(ep4out,   ALL,OUT),
+   EP_INFO(ep1out,   ALL,OUT),
+   EP_INFO(ep2in,ALL,IN),
+   EP_INFO(ep3out,   ALL,OUT),
+   EP_INFO(ep4in,ALL,IN),
 };
 
+#undef EP_INFO
+
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
  * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
  * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable
@@ -2055,7 +2077,8 @@ static void usb_reinit_228x(struct net2280 *dev)
for (tmp = 0; tmp  7; tmp++) {
struct net2280_ep   *ep = dev-ep[tmp];
 
-   ep-ep.name = ep_name[tmp];
+   ep-ep.name = ep_info_dft[tmp].name;
+   ep-ep.caps = ep_info_dft[tmp].caps;
ep-dev = dev;
ep-num = tmp;
 
@@ -2095,7 +2118,10 @@ static void usb_reinit_338x(struct net2280 *dev)
for (i = 0; i  dev-n_ep; i++) {
struct net2280_ep *ep = dev-ep[i];
 
-   ep-ep.name = dev-enhanced_mode ? ep_name_adv[i] : ep_name[i];
+   ep-ep.name = dev-enhanced_mode ? ep_info_adv[i].name :
+  ep_info_dft[i].name;
+   ep-ep.caps = dev-enhanced_mode ? ep_info_adv[i].caps :
+  ep_info_dft[i].caps;
ep-dev = dev;
ep-num = i;
 
-- 
1.9.1

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


[PATCH v3 04/46] staging: emxx_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Fixed typo in epc-nulk to epc-bulk.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/staging/emxx_udc/emxx_udc.c | 60 ++---
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c 
b/drivers/staging/emxx_udc/emxx_udc.c
index 3b7aa36..0d64bee 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -3153,36 +3153,33 @@ static const struct usb_gadget_ops nbu2ss_gadget_ops = {
.ioctl  = nbu2ss_gad_ioctl,
 };
 
-static const char g_ep0_name[] = ep0;
-static const char g_ep1_name[] = ep1-bulk;
-static const char g_ep2_name[] = ep2-bulk;
-static const char g_ep3_name[] = ep3in-int;
-static const char g_ep4_name[] = ep4-iso;
-static const char g_ep5_name[] = ep5-iso;
-static const char g_ep6_name[] = ep6-bulk;
-static const char g_ep7_name[] = ep7-bulk;
-static const char g_ep8_name[] = ep8in-int;
-static const char g_ep9_name[] = ep9-iso;
-static const char g_epa_name[] = epa-iso;
-static const char g_epb_name[] = epb-bulk;
-static const char g_epc_name[] = epc-nulk;
-static const char g_epd_name[] = epdin-int;
-
-static const char *gp_ep_name[NUM_ENDPOINTS] = {
-   g_ep0_name,
-   g_ep1_name,
-   g_ep2_name,
-   g_ep3_name,
-   g_ep4_name,
-   g_ep5_name,
-   g_ep6_name,
-   g_ep7_name,
-   g_ep8_name,
-   g_ep9_name,
-   g_epa_name,
-   g_epb_name,
-   g_epc_name,
-   g_epd_name,
+static const struct {
+   const char *name;
+   const struct usb_ep_caps caps;
+} ep_info[NUM_ENDPOINTS] = {
+#define EP_INFO(_name, _type, _dir) \
+   { \
+   .name = _name, \
+   .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \
+   USB_EP_CAPS_DIR_ ## _dir), \
+   }
+
+   EP_INFO(ep0,  CONTROL, ALL),
+   EP_INFO(ep1-bulk, BULK,   ALL),
+   EP_INFO(ep2-bulk, BULK,   ALL),
+   EP_INFO(ep3in-int,INT,IN),
+   EP_INFO(ep4-iso,  INT,ALL),
+   EP_INFO(ep5-iso,  ISO,ALL),
+   EP_INFO(ep6-bulk, ISO,ALL),
+   EP_INFO(ep7-bulk, BULK,   ALL),
+   EP_INFO(ep8in-int,INT,IN),
+   EP_INFO(ep9-iso,  ISO,ALL),
+   EP_INFO(epa-iso,  ISO,ALL),
+   EP_INFO(epb-bulk, BULK,   ALL),
+   EP_INFO(epc-bulk, BULK,   ALL),
+   EP_INFO(epdin-int,INT,IN),
+
+#undef EP_INFO
 };
 
 /*-*/
@@ -3200,7 +3197,8 @@ static void __init nbu2ss_drv_ep_init(struct nbu2ss_udc 
*udc)
ep-desc = NULL;
 
ep-ep.driver_data = NULL;
-   ep-ep.name = gp_ep_name[i];
+   ep-ep.name = ep_info[i].name;
+   ep-ep.caps = ep_info[i].caps;
ep-ep.ops = nbu2ss_ep_ops;
 
usb_ep_set_maxpacket_limit(ep-ep,
-- 
1.9.1

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


[PATCH v3 02/46] usb: gadget: add endpoint capabilities flags

2015-07-15 Thread Robert Baldyga
Introduce struct usb_ep_caps which contains information about capabilities
of usb endpoints - supported transfer types and directions. This structure
should be filled by UDC driver for each of its endpoints, and will be
used in epautoconf in new ep matching mechanism which will replace ugly
guessing of endpoint capabilities basing on its name.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 include/linux/usb/gadget.h | 21 +
 1 file changed, 21 insertions(+)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index fcb0a4e..6f3e0fb 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -141,10 +141,29 @@ struct usb_ep_ops {
 };
 
 /**
+ * struct usb_ep_caps - endpoint capabilities description
+ * @type_control:Endpoint supports control type (reserved for ep0).
+ * @type_iso:Endpoint supports isochronous transfers.
+ * @type_bulk:Endpoint supports bulk transfers.
+ * @type_int:Endpoint supports interrupt transfers.
+ * @dir_in:Endpoint supports IN direction.
+ * @dir_out:Endpoint supports OUT direction.
+ */
+struct usb_ep_caps {
+   unsigned type_control:1;
+   unsigned type_iso:1;
+   unsigned type_bulk:1;
+   unsigned type_int:1;
+   unsigned dir_in:1;
+   unsigned dir_out:1;
+};
+
+/**
  * struct usb_ep - device side representation of USB endpoint
  * @name:identifier for the endpoint, such as ep-a or ep9in-bulk
  * @ops: Function pointers used to access hardware-specific operations.
  * @ep_list:the gadget's ep_list holds all of its endpoints
+ * @caps:The structure describing types and directions supported by endoint.
  * @maxpacket:The maximum packet size used on this endpoint.  The initial
  * value can sometimes be reduced (hardware allowing), according to
  *  the endpoint descriptor used to configure the endpoint.
@@ -167,12 +186,14 @@ struct usb_ep_ops {
  * gadget-ep_list.  the control endpoint (gadget-ep0) is not in that list,
  * and is accessed only in response to a driver setup() callback.
  */
+
 struct usb_ep {
void*driver_data;
 
const char  *name;
const struct usb_ep_ops *ops;
struct list_headep_list;
+   struct usb_ep_caps  caps;
boolclaimed;
unsignedmaxpacket:16;
unsignedmaxpacket_limit:16;
-- 
1.9.1

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


[PATCH v3 07/46] usb: dwc3: gadget: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/dwc3/gadget.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 333a7c0..8d1f768 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1713,6 +1713,19 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 
*dwc,
return ret;
}
 
+   if (epnum == 0) {
+   dep-endpoint.caps.type_control = true;
+   } else {
+   dep-endpoint.caps.type_iso = true;
+   dep-endpoint.caps.type_bulk = true;
+   dep-endpoint.caps.type_int = true;
+   }
+
+   if (epnum  1)
+   dep-endpoint.caps.dir_in = true;
+   else
+   dep-endpoint.caps.dir_out = true;
+
INIT_LIST_HEAD(dep-request_list);
INIT_LIST_HEAD(dep-req_queued);
}
-- 
1.9.1

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


[PATCH v3 05/46] usb: chipidea: udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/chipidea/udc.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 764f668..eff7cfb 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1624,6 +1624,20 @@ static int init_eps(struct ci_hdrc *ci)
 
hwep-ep.name  = hwep-name;
hwep-ep.ops   = usb_ep_ops;
+
+   if (i == 0) {
+   hwep-ep.caps.type_control = true;
+   } else {
+   hwep-ep.caps.type_iso = true;
+   hwep-ep.caps.type_bulk = true;
+   hwep-ep.caps.type_int = true;
+   }
+
+   if (j == TX)
+   hwep-ep.caps.dir_in = true;
+   else
+   hwep-ep.caps.dir_out = true;
+
/*
 * for ep0: maxP defined in desc, for other
 * eps, maxP is set by epautoconfig() called
-- 
1.9.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] phy: ulpi_phy: Add const qualifier to ops

2015-07-15 Thread Axel Lin
2015-06-05 8:27 GMT+08:00 Axel Lin axel@ingics.com:
 The ops is never changed in ulpi_phy_create(), so make it const.

Hi Kishon,

Would you pick up this patch?
Without this patch, passing a const struct phy_ops* to ulip_phy_create will
have compiler warning.
It should be fine to pass a const struct phy_ops* to ulip_phy_create and
since the drivers usually never change phy_ops after initialized,
it can be const.
--
To unsubscribe from this list: send the line unsubscribe 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 45/46] usb: gadget: goku_udc: add goku_match_ep() function

2015-07-15 Thread Robert Baldyga
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c   | 20 ++--
 drivers/usb/gadget/udc/goku_udc.c | 25 +
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index d41fd82..da45371 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -86,24 +86,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
/* First, apply chip-specific best usage knowledge.
 * This might make a good usb_gadget_ops hook ...
 */
-   if (gadget_is_goku (gadget)) {
-   if (USB_ENDPOINT_XFER_INT == type) {
-   /* single buffering is enough */
-   ep = gadget_find_ep_by_name(gadget, ep3-bulk);
-   if (ep  usb_gadget_ep_match_desc(gadget,
-   ep, desc, ep_comp))
-   goto found_ep;
-   } else if (USB_ENDPOINT_XFER_BULK == type
-(USB_DIR_IN  desc-bEndpointAddress)) {
-   /* DMA may be available */
-   ep = gadget_find_ep_by_name(gadget, ep2-bulk);
-   if (ep  usb_gadget_ep_match_desc(gadget,
-   ep, desc, ep_comp))
-   goto found_ep;
-   }
-
 #ifdef CONFIG_BLACKFIN
-   } else if (gadget_is_musbhdrc(gadget)) {
+   if (gadget_is_musbhdrc(gadget)) {
if ((USB_ENDPOINT_XFER_BULK == type) ||
(USB_ENDPOINT_XFER_ISOC == type)) {
if (USB_DIR_IN  desc-bEndpointAddress)
@@ -119,8 +103,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
ep = NULL;
if (ep  usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
-#endif
}
+#endif
 
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry (ep, gadget-ep_list, ep_list) {
diff --git a/drivers/usb/gadget/udc/goku_udc.c 
b/drivers/usb/gadget/udc/goku_udc.c
index 46b8d14..d5a93ea 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -990,6 +990,30 @@ static int goku_get_frame(struct usb_gadget *_gadget)
return -EOPNOTSUPP;
 }
 
+static struct usb_ep *goku_match_ep(struct usb_gadget *g,
+   struct usb_endpoint_descriptor *desc,
+   struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+   struct goku_udc *dev = to_goku_udc(g);
+   struct usb_ep *ep;
+   u8 type = usb_endpoint_type(desc);
+
+   if (type == USB_ENDPOINT_XFER_INT) {
+   /* single buffering is enough */
+   ep = dev-ep[3].ep;
+   if (ep  usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
+   return ep;
+   } else if (type == USB_ENDPOINT_XFER_BULK
+usb_endpoint_dir_in(desc)) {
+   /* DMA may be available */
+   ep = dev-ep[2].ep;
+   if (ep  usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
+   return ep;
+   }
+
+   return NULL;
+}
+
 static int goku_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
 static int goku_udc_stop(struct usb_gadget *g);
@@ -998,6 +1022,7 @@ static const struct usb_gadget_ops goku_ops = {
.get_frame  = goku_get_frame,
.udc_start  = goku_udc_start,
.udc_stop   = goku_udc_stop,
+   .match_ep   = goku_match_ep,
// no remote wakeup
// not selfpowered
 };
-- 
1.9.1

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


[PATCH v3 46/46] usb: musb: gadget: add musb_match_ep() function

2015-07-15 Thread Robert Baldyga
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 23 ---
 drivers/usb/musb/musb_gadget.c  | 34 ++
 2 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index da45371..254ece7 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -83,29 +83,6 @@ struct usb_ep *usb_ep_autoconfig_ss(
goto found_ep;
}
 
-   /* First, apply chip-specific best usage knowledge.
-* This might make a good usb_gadget_ops hook ...
-*/
-#ifdef CONFIG_BLACKFIN
-   if (gadget_is_musbhdrc(gadget)) {
-   if ((USB_ENDPOINT_XFER_BULK == type) ||
-   (USB_ENDPOINT_XFER_ISOC == type)) {
-   if (USB_DIR_IN  desc-bEndpointAddress)
-   ep = gadget_find_ep_by_name(gadget, ep5in);
-   else
-   ep = gadget_find_ep_by_name(gadget, ep6out);
-   } else if (USB_ENDPOINT_XFER_INT == type) {
-   if (USB_DIR_IN  desc-bEndpointAddress)
-   ep = gadget_find_ep_by_name(gadget, ep1in);
-   else
-   ep = gadget_find_ep_by_name(gadget, ep2out);
-   } else
-   ep = NULL;
-   if (ep  usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
-   goto found_ep;
-   }
-#endif
-
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry (ep, gadget-ep_list, ep_list) {
if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 043248a..3a64cf2 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1684,6 +1684,39 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, 
int is_on)
return 0;
 }
 
+#ifdef CONFIG_BLACKFIN
+static struct usb_ep *musb_match_ep(struct usb_gadget *g,
+   struct usb_endpoint_descriptor *desc,
+   struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+   struct usb_ep *ep = NULL;
+   u8 type = usb_endpoint_type(desc);
+
+   switch(type) {
+   case USB_ENDPOINT_XFER_ISOC:
+   case USB_ENDPOINT_XFER_BULK:
+   if (usb_endpoint_dir_in(desc))
+   ep = gadget_find_ep_by_name(g, ep5in);
+   else
+   ep = gadget_find_ep_by_name(g, ep6out);
+   break;
+   case USB_ENDPOINT_XFER_INT:
+   if (usb_endpoint_dir_in(desc))
+   ep = gadget_find_ep_by_name(g, ep1in);
+   else
+   ep = gadget_find_ep_by_name(g, ep2out);
+   default:
+   }
+
+   if (ep  usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
+   return ep;
+
+   return NULL;
+}
+#else
+#define musb_match_ep NULL
+#endif
+
 static int musb_gadget_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
 static int musb_gadget_stop(struct usb_gadget *g);
@@ -1697,6 +1730,7 @@ static const struct usb_gadget_ops musb_gadget_operations 
= {
.pullup = musb_gadget_pullup,
.udc_start  = musb_gadget_start,
.udc_stop   = musb_gadget_stop,
+   .match_ep   = musb_match_ep,
 };
 
 /* --- */
-- 
1.9.1

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


[PATCH v3 42/46] usb: gadget: move ep_matches() from epautoconf to udc-core

2015-07-15 Thread Robert Baldyga
Move ep_matches() function to udc-core and rename it to
usb_gadget_ep_match_desc(). This function can be used by UDC drivers
in 'match_ep' callback to avoid writing lots of repetitive code.

Replace all calls of ep_matches() with usb_gadget_ep_match_desc().

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c   | 95 +--
 drivers/usb/gadget/udc/udc-core.c | 69 
 include/linux/usb/gadget.h|  8 
 3 files changed, 88 insertions(+), 84 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 1b1fee0..3f0a380 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,82 +22,6 @@
 
 #include gadget_chips.h
 
-static int
-ep_matches (
-   struct usb_gadget   *gadget,
-   struct usb_ep   *ep,
-   struct usb_endpoint_descriptor  *desc,
-   struct usb_ss_ep_comp_descriptor *ep_comp
-)
-{
-   u8  type;
-   u16 max;
-   int num_req_streams = 0;
-
-   /* endpoint already claimed? */
-   if (ep-claimed)
-   return 0;
-
-   type = usb_endpoint_type(desc);
-   max = 0x7ff  usb_endpoint_maxp(desc);
-
-   if (usb_endpoint_dir_in(desc)  !ep-caps.dir_in)
-   return 0;
-   else if (!ep-caps.dir_out)
-   return 0;
-
-   if (max  ep-maxpacket_limit)
-   return 0;
-
-   /* high bandwidth works only at high speed */
-   if (!gadget_is_dualspeed(gadget)  usb_endpoint_maxp(desc)  (311))
-   return 0;
-
-   switch (type) {
-   case USB_ENDPOINT_XFER_CONTROL:
-   /* only support ep0 for portable CONTROL traffic */
-   return 0;
-   case USB_ENDPOINT_XFER_ISOC:
-   if (!ep-caps.type_iso)
-   return 0;
-   /* ISO:  limit 1023 bytes full speed,
-* 1024 high/super speed
-*/
-   if (!gadget_is_dualspeed(gadget)  max  1023)
-   return 0;
-   break;
-   case USB_ENDPOINT_XFER_BULK:
-   if (!ep-caps.type_bulk)
-   return 0;
-   if (ep_comp  gadget_is_superspeed(gadget)) {
-   /* Get the number of required streams from the
-* EP companion descriptor and see if the EP
-* matches it
-*/
-   num_req_streams = ep_comp-bmAttributes  0x1f;
-   if (num_req_streams  ep-max_streams)
-   return 0;
-   }
-   break;
-   case USB_ENDPOINT_XFER_INT:
-   /* Bulk endpoints handle interrupt transfers,
-* except the toggle-quirky iso-synch kind
-*/
-   if (!ep-caps.type_int  !ep-caps.type_bulk)
-   return 0;
-   /* INT:  limit 64 bytes full speed,
-* 1024 high/super speed
-*/
-   if (!gadget_is_dualspeed(gadget)  max  64)
-   return 0;
-   break;
-   }
-
-   /* MATCH!! */
-
-   return 1;
-}
-
 static struct usb_ep *
 find_ep (struct usb_gadget *gadget, const char *name)
 {
@@ -180,10 +104,12 @@ struct usb_ep *usb_ep_autoconfig_ss(
if (type == USB_ENDPOINT_XFER_INT) {
/* ep-e, ep-f are PIO with only 64 byte fifos */
ep = find_ep(gadget, ep-e);
-   if (ep  ep_matches(gadget, ep, desc, ep_comp))
+   if (ep  usb_gadget_ep_match_desc(gadget,
+   ep, desc, ep_comp))
goto found_ep;
ep = find_ep(gadget, ep-f);
-   if (ep  ep_matches(gadget, ep, desc, ep_comp))
+   if (ep  usb_gadget_ep_match_desc(gadget,
+   ep, desc, ep_comp))
goto found_ep;
}
 
@@ -191,20 +117,21 @@ struct usb_ep *usb_ep_autoconfig_ss(
snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc),
usb_endpoint_dir_in(desc) ? in : out);
ep = find_ep(gadget, name);
-   if (ep  ep_matches(gadget, ep, desc, ep_comp))
+   if (ep  usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
} else if (gadget_is_goku (gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
ep = find_ep(gadget, ep3-bulk);
-   if (ep  ep_matches(gadget, ep, desc, ep_comp))
+   if (ep  usb_gadget_ep_match_desc(gadget,
+  

[PATCH v3 44/46] usb: gadget: net2280: add net2280_match_ep() function

2015-07-15 Thread Robert Baldyga
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c  | 23 +--
 drivers/usb/gadget/udc/net2280.c | 31 +++
 2 files changed, 32 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index cc0b084..d41fd82 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -86,28 +86,7 @@ struct usb_ep *usb_ep_autoconfig_ss(
/* First, apply chip-specific best usage knowledge.
 * This might make a good usb_gadget_ops hook ...
 */
-   if (gadget_is_net2280(gadget)) {
-   char name[8];
-
-   if (type == USB_ENDPOINT_XFER_INT) {
-   /* ep-e, ep-f are PIO with only 64 byte fifos */
-   ep = gadget_find_ep_by_name(gadget, ep-e);
-   if (ep  usb_gadget_ep_match_desc(gadget,
-   ep, desc, ep_comp))
-   goto found_ep;
-   ep = gadget_find_ep_by_name(gadget, ep-f);
-   if (ep  usb_gadget_ep_match_desc(gadget,
-   ep, desc, ep_comp))
-   goto found_ep;
-   }
-
-   /* USB3380: use same address for usb and hardware endpoints */
-   snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc),
-   usb_endpoint_dir_in(desc) ? in : out);
-   ep = gadget_find_ep_by_name(gadget, name);
-   if (ep  usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
-   goto found_ep;
-   } else if (gadget_is_goku (gadget)) {
+   if (gadget_is_goku (gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
ep = gadget_find_ep_by_name(gadget, ep3-bulk);
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 0295cf7..41e6568 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1533,6 +1533,36 @@ static int net2280_pullup(struct usb_gadget *_gadget, 
int is_on)
return 0;
 }
 
+static struct usb_ep *net2280_match_ep(struct usb_gadget *_gadget,
+   struct usb_endpoint_descriptor *desc,
+   struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+   char name[8];
+   struct usb_ep *ep;
+   u8 type;
+
+   type = usb_endpoint_type(desc);
+
+   if (type == USB_ENDPOINT_XFER_INT) {
+   /* ep-e, ep-f are PIO with only 64 byte fifos */
+   ep = gadget_find_ep_by_name(_gadget, ep-e);
+   if (ep  usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+   return ep;
+   ep = gadget_find_ep_by_name(_gadget, ep-f);
+   if (ep  usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+   return ep;
+   }
+
+   /* USB3380: use same address for usb and hardware endpoints */
+   snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc),
+   usb_endpoint_dir_in(desc) ? in : out);
+   ep = gadget_find_ep_by_name(_gadget, name);
+   if (ep  usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+   return ep;
+
+   return NULL;
+}
+
 static int net2280_start(struct usb_gadget *_gadget,
struct usb_gadget_driver *driver);
 static int net2280_stop(struct usb_gadget *_gadget);
@@ -1544,6 +1574,7 @@ static const struct usb_gadget_ops net2280_ops = {
.pullup = net2280_pullup,
.udc_start  = net2280_start,
.udc_stop   = net2280_stop,
+   .match_ep   = net2280_match_ep,
 };
 
 /*-*/
-- 
1.9.1

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


[PATCH v3 39/46] usb: gadget: epautoconf: remove ep and desc configuration from ep_matches()

2015-07-15 Thread Robert Baldyga
As function ep_matches() is used to match endpoint with usb descriptor it's
highly unintuitive that it modifies endpoint and descriptor structures fields.
This patch moves code configuring ep and desc from ep_matches() to
usb_ep_autoconfig_ss(), so now function ep_matches() does nothing more than
its name suggests.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 66 +
 1 file changed, 34 insertions(+), 32 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 4f66e9d73..7bb28f1 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -82,13 +82,6 @@ ep_matches (
 
}
 
-   /*
-* If the protocol driver hasn't yet decided on wMaxPacketSize
-* and wants to know the maximum possible, provide the info.
-*/
-   if (desc-wMaxPacketSize == 0)
-   desc-wMaxPacketSize = cpu_to_le16(ep-maxpacket_limit);
-
/* endpoint maxpacket size is an input parameter, except for bulk
 * where it's an output parameter representing the full speed limit.
 * the usb spec fixes high speed bulk maxpacket at 512 bytes.
@@ -119,31 +112,6 @@ ep_matches (
 
/* MATCH!! */
 
-   /* report address */
-   desc-bEndpointAddress = USB_DIR_IN;
-   if (isdigit (ep-name [2])) {
-   u8  num = simple_strtoul (ep-name [2], NULL, 10);
-   desc-bEndpointAddress |= num;
-   } else if (desc-bEndpointAddress  USB_DIR_IN) {
-   if (++gadget-in_epnum  15)
-   return 0;
-   desc-bEndpointAddress = USB_DIR_IN | gadget-in_epnum;
-   } else {
-   if (++gadget-out_epnum  15)
-   return 0;
-   desc-bEndpointAddress |= gadget-out_epnum;
-   }
-
-   /* report (variable) full speed bulk maxpacket */
-   if ((USB_ENDPOINT_XFER_BULK == type)  !ep_comp) {
-   int size = ep-maxpacket_limit;
-
-   /* min() doesn't work on bitfields with gcc-3.5 */
-   if (size  64)
-   size = 64;
-   desc-wMaxPacketSize = cpu_to_le16(size);
-   }
-   ep-address = desc-bEndpointAddress;
return 1;
 }
 
@@ -280,6 +248,40 @@ struct usb_ep *usb_ep_autoconfig_ss(
/* Fail */
return NULL;
 found_ep:
+
+   /*
+* If the protocol driver hasn't yet decided on wMaxPacketSize
+* and wants to know the maximum possible, provide the info.
+*/
+   if (desc-wMaxPacketSize == 0)
+   desc-wMaxPacketSize = cpu_to_le16(ep-maxpacket_limit);
+
+   /* report address */
+   desc-bEndpointAddress = USB_DIR_IN;
+   if (isdigit(ep-name[2])) {
+   u8 num = simple_strtoul(ep-name[2], NULL, 10);
+   desc-bEndpointAddress |= num;
+   } else if (desc-bEndpointAddress  USB_DIR_IN) {
+   if (++gadget-in_epnum  15)
+   return 0;
+   desc-bEndpointAddress = USB_DIR_IN | gadget-in_epnum;
+   } else {
+   if (++gadget-out_epnum  15)
+   return 0;
+   desc-bEndpointAddress |= gadget-out_epnum;
+   }
+
+   /* report (variable) full speed bulk maxpacket */
+   if ((type == USB_ENDPOINT_XFER_BULK)  !ep_comp) {
+   int size = ep-maxpacket_limit;
+
+   /* min() doesn't work on bitfields with gcc-3.5 */
+   if (size  64)
+   size = 64;
+   desc-wMaxPacketSize = cpu_to_le16(size);
+   }
+
+   ep-address = desc-bEndpointAddress;
ep-desc = NULL;
ep-comp_desc = NULL;
ep-claimed = true;
-- 
1.9.1

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


[PATCH v3 43/46] usb: gadget: move find_ep() from epautoconf to gadget.h

2015-07-15 Thread Robert Baldyga
Move find_ep() function to gadget.h, rename it to gadget_find_ep_by_name()
and make it static inline. It can be used in UDC drivers, especially in
'match_ep' callback after moving chip-specific endpoint matching logic from
epautoconf to UDC drivers.

Replace all calls of find_ep() function with gadget_find_ep_by_name().

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 30 +-
 include/linux/usb/gadget.h  | 18 ++
 2 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 3f0a380..cc0b084 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,18 +22,6 @@
 
 #include gadget_chips.h
 
-static struct usb_ep *
-find_ep (struct usb_gadget *gadget, const char *name)
-{
-   struct usb_ep   *ep;
-
-   list_for_each_entry (ep, gadget-ep_list, ep_list) {
-   if (0 == strcmp (ep-name, name))
-   return ep;
-   }
-   return NULL;
-}
-
 /**
  * usb_ep_autoconfig_ss() - choose an endpoint matching the ep
  * descriptor and ep companion descriptor
@@ -103,11 +91,11 @@ struct usb_ep *usb_ep_autoconfig_ss(
 
if (type == USB_ENDPOINT_XFER_INT) {
/* ep-e, ep-f are PIO with only 64 byte fifos */
-   ep = find_ep(gadget, ep-e);
+   ep = gadget_find_ep_by_name(gadget, ep-e);
if (ep  usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
-   ep = find_ep(gadget, ep-f);
+   ep = gadget_find_ep_by_name(gadget, ep-f);
if (ep  usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
@@ -116,20 +104,20 @@ struct usb_ep *usb_ep_autoconfig_ss(
/* USB3380: use same address for usb and hardware endpoints */
snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc),
usb_endpoint_dir_in(desc) ? in : out);
-   ep = find_ep(gadget, name);
+   ep = gadget_find_ep_by_name(gadget, name);
if (ep  usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
} else if (gadget_is_goku (gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
-   ep = find_ep(gadget, ep3-bulk);
+   ep = gadget_find_ep_by_name(gadget, ep3-bulk);
if (ep  usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
} else if (USB_ENDPOINT_XFER_BULK == type
 (USB_DIR_IN  desc-bEndpointAddress)) {
/* DMA may be available */
-   ep = find_ep(gadget, ep2-bulk);
+   ep = gadget_find_ep_by_name(gadget, ep2-bulk);
if (ep  usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
@@ -140,14 +128,14 @@ struct usb_ep *usb_ep_autoconfig_ss(
if ((USB_ENDPOINT_XFER_BULK == type) ||
(USB_ENDPOINT_XFER_ISOC == type)) {
if (USB_DIR_IN  desc-bEndpointAddress)
-   ep = find_ep (gadget, ep5in);
+   ep = gadget_find_ep_by_name(gadget, ep5in);
else
-   ep = find_ep (gadget, ep6out);
+   ep = gadget_find_ep_by_name(gadget, ep6out);
} else if (USB_ENDPOINT_XFER_INT == type) {
if (USB_DIR_IN  desc-bEndpointAddress)
-   ep = find_ep(gadget, ep1in);
+   ep = gadget_find_ep_by_name(gadget, ep1in);
else
-   ep = find_ep(gadget, ep2out);
+   ep = gadget_find_ep_by_name(gadget, ep2out);
} else
ep = NULL;
if (ep  usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 77e2c1e..42e951b 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -629,6 +629,24 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct 
device *dev)
 #define gadget_for_each_ep(tmp, gadget) \
list_for_each_entry(tmp, (gadget)-ep_list, ep_list)
 
+/**
+ * gadget_find_ep_by_name - returns ep whose name is the same as sting passed
+ * in second parameter or NULL if 

[PATCH v3 20/46] usb: gadget: m66592-udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/m66592-udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/m66592-udc.c 
b/drivers/usb/gadget/udc/m66592-udc.c
index 309706f..e404553 100644
--- a/drivers/usb/gadget/udc/m66592-udc.c
+++ b/drivers/usb/gadget/udc/m66592-udc.c
@@ -1644,6 +1644,17 @@ static int m66592_probe(struct platform_device *pdev)
ep-ep.name = m66592_ep_name[i];
ep-ep.ops = m66592_ep_ops;
usb_ep_set_maxpacket_limit(ep-ep, 512);
+
+   if (i == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
}
usb_ep_set_maxpacket_limit(m66592-ep[0].ep, 64);
m66592-ep[0].pipenum = 0;
-- 
1.9.1

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


[PATCH v3 19/46] usb: gadget: lpc32xx_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c 
b/drivers/usb/gadget/udc/lpc32xx_udc.c
index 3b6a785..00b5006 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -2575,6 +2575,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep0,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 64,
.hwep_num_base  = 0,
@@ -2586,6 +2588,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep1-int,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 64,
.hwep_num_base  = 2,
@@ -2597,6 +2601,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep2-bulk,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 64,
.hwep_num_base  = 4,
@@ -2608,6 +2614,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep3-iso,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 1023,
.hwep_num_base  = 6,
@@ -2619,6 +2627,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep4-int,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 64,
.hwep_num_base  = 8,
@@ -2630,6 +2640,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep5-bulk,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 64,
.hwep_num_base  = 10,
@@ -2641,6 +2653,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep6-iso,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 1023,
.hwep_num_base  = 12,
@@ -2652,6 +2666,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep7-int,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 64,
.hwep_num_base  = 14,
@@ -2663,6 +2679,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep8-bulk,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 64,
.hwep_num_base  = 16,
@@ -2674,6 +2692,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep9-iso,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO,
+   USB_EP_CAPS_DIR_ALL),
},
.maxpacket  = 1023,
.hwep_num_base  = 18,
@@ -2685,6 +2705,8 @@ static const struct lpc32xx_udc controller_template = {
.ep = {
.name   = ep10-int,
.ops= lpc32xx_ep_ops,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
+   USB_EP_CAPS_DIR_ALL),
},
   

[PATCH v3 16/46] usb: gadget: fusb300_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/fusb300_udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/fusb300_udc.c 
b/drivers/usb/gadget/udc/fusb300_udc.c
index 3970f45..948845c 100644
--- a/drivers/usb/gadget/udc/fusb300_udc.c
+++ b/drivers/usb/gadget/udc/fusb300_udc.c
@@ -1450,6 +1450,17 @@ static int fusb300_probe(struct platform_device *pdev)
ep-ep.name = fusb300_ep_name[i];
ep-ep.ops = fusb300_ep_ops;
usb_ep_set_maxpacket_limit(ep-ep, HS_BULK_MAX_PACKET_SIZE);
+
+   if (i == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
}
usb_ep_set_maxpacket_limit(fusb300-ep[0]-ep, HS_CTL_MAX_PACKET_SIZE);
fusb300-ep[0]-epnum = 0;
-- 
1.9.1

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


[PATCH v3 21/46] usb: gadget: mv_u3d_core: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/mv_u3d_core.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c 
b/drivers/usb/gadget/udc/mv_u3d_core.c
index ea35a24..4c48969 100644
--- a/drivers/usb/gadget/udc/mv_u3d_core.c
+++ b/drivers/usb/gadget/udc/mv_u3d_core.c
@@ -1324,6 +1324,9 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d)
ep-ep.ops = mv_u3d_ep_ops;
ep-wedge = 0;
usb_ep_set_maxpacket_limit(ep-ep, MV_U3D_EP0_MAX_PKT_SIZE);
+   ep-ep.caps.type_control = true;
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
ep-ep_num = 0;
ep-ep.desc = mv_u3d_ep0_desc;
INIT_LIST_HEAD(ep-queue);
@@ -1339,14 +1342,20 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d)
if (i  1) {
snprintf(name, sizeof(name), ep%din, i  1);
ep-direction = MV_U3D_EP_DIR_IN;
+   ep-ep.caps.dir_in = true;
} else {
snprintf(name, sizeof(name), ep%dout, i  1);
ep-direction = MV_U3D_EP_DIR_OUT;
+   ep-ep.caps.dir_out = true;
}
ep-u3d = u3d;
strncpy(ep-name, name, sizeof(ep-name));
ep-ep.name = ep-name;
 
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+
ep-ep.ops = mv_u3d_ep_ops;
usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0);
ep-ep_num = i / 2;
-- 
1.9.1

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


[PATCH v3 18/46] usb: gadget: gr_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/gr_udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
index c886887..8aa2593 100644
--- a/drivers/usb/gadget/udc/gr_udc.c
+++ b/drivers/usb/gadget/udc/gr_udc.c
@@ -2018,12 +2018,23 @@ static int gr_ep_init(struct gr_udc *dev, int num, int 
is_in, u32 maxplimit)
 
usb_ep_set_maxpacket_limit(ep-ep, MAX_CTRL_PL_SIZE);
ep-bytes_per_buffer = MAX_CTRL_PL_SIZE;
+
+   ep-ep.caps.type_control = true;
} else {
usb_ep_set_maxpacket_limit(ep-ep, (u16)maxplimit);
list_add_tail(ep-ep.ep_list, dev-gadget.ep_list);
+
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
}
list_add_tail(ep-ep_list, dev-ep_list);
 
+   if (is_in)
+   ep-ep.caps.dir_in = true;
+   else
+   ep-ep.caps.dir_out = true;
+
ep-tailbuf = dma_alloc_coherent(dev-dev, ep-ep.maxpacket_limit,
 ep-tailbuf_paddr, GFP_ATOMIC);
if (!ep-tailbuf)
-- 
1.9.1

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


[PATCH v3 14/46] usb: gadget: fsl_qe_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/fsl_qe_udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c 
b/drivers/usb/gadget/udc/fsl_qe_udc.c
index e0822f1..5fb6f8b 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
@@ -2417,6 +2417,17 @@ static int qe_ep_config(struct qe_udc *udc, unsigned 
char pipe_num)
strcpy(ep-name, ep_name[pipe_num]);
ep-ep.name = ep_name[pipe_num];
 
+   if (pipe_num == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
+
ep-ep.ops = qe_ep_ops;
ep-stopped = 1;
usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0);
-- 
1.9.1

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


[PATCH v3 13/46] usb: gadget: fotg210-udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/fotg210-udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/fotg210-udc.c 
b/drivers/usb/gadget/udc/fotg210-udc.c
index e547ea7..960c70c 100644
--- a/drivers/usb/gadget/udc/fotg210-udc.c
+++ b/drivers/usb/gadget/udc/fotg210-udc.c
@@ -1153,6 +1153,17 @@ static int fotg210_udc_probe(struct platform_device 
*pdev)
ep-ep.name = fotg210_ep_name[i];
ep-ep.ops = fotg210_ep_ops;
usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0);
+
+   if (i == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
}
usb_ep_set_maxpacket_limit(fotg210-ep[0]-ep, 0x40);
fotg210-gadget.ep0 = fotg210-ep[0]-ep;
-- 
1.9.1

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


[PATCH v3 17/46] usb: gadget: goku_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/goku_udc.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/gadget/udc/goku_udc.c 
b/drivers/usb/gadget/udc/goku_udc.c
index 9e8d842..46b8d14 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -1257,6 +1257,14 @@ static void udc_reinit (struct goku_udc *dev)
INIT_LIST_HEAD (ep-queue);
 
ep_reset(NULL, ep);
+
+   if (i == 0)
+   ep-ep.caps.type_control = true;
+   else
+   ep-ep.caps.type_bulk = true;
+
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
}
 
dev-ep[0].reg_mode = NULL;
-- 
1.9.1

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


[PATCH v3 15/46] usb: gadget: fsl_udc_core: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index c60022b..aab5221 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -2313,6 +2313,19 @@ static int struct_ep_setup(struct fsl_udc *udc, unsigned 
char index,
ep-ep.ops = fsl_ep_ops;
ep-stopped = 0;
 
+   if (index == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+
+   if (index  1)
+   ep-ep.caps.dir_in = true;
+   else
+   ep-ep.caps.dir_out = true;
+
/* for ep0: maxP defined in desc
 * for other eps, maxP is set by epautoconfig() called by gadget layer
 */
-- 
1.9.1

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


[PATCH v3 12/46] usb: gadget: dummy-hcd: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/dummy_hcd.c | 65 +-
 1 file changed, 50 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c 
b/drivers/usb/gadget/udc/dummy_hcd.c
index 181112c..69fd29a 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -127,23 +127,57 @@ static inline struct dummy_request 
*usb_request_to_dummy_request
 
 static const char ep0name[] = ep0;
 
-static const char *const ep_name[] = {
-   ep0name,/* everyone has ep0 */
+static const struct {
+   const char *name;
+   const struct usb_ep_caps caps;
+} ep_info[] = {
+#define EP_INFO(_name, _type, _dir) \
+   { \
+   .name = _name, \
+   .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \
+   USB_EP_CAPS_DIR_ ## _dir), \
+   }
 
+   /* everyone has ep0 */
+   EP_INFO(ep0name,CONTROL, ALL),
/* act like a pxa250: fifteen fixed function endpoints */
-   ep1in-bulk, ep2out-bulk, ep3in-iso, ep4out-iso, ep5in-int,
-   ep6in-bulk, ep7out-bulk, ep8in-iso, ep9out-iso, ep10in-int,
-   ep11in-bulk, ep12out-bulk, ep13in-iso, ep14out-iso,
-   ep15in-int,
-
+   EP_INFO(ep1in-bulk,   BULK,   IN),
+   EP_INFO(ep2out-bulk,  BULK,   OUT),
+   EP_INFO(ep3in-iso,ISO,IN),
+   EP_INFO(ep4out-iso,   ISO,OUT),
+   EP_INFO(ep5in-int,INT,IN),
+   EP_INFO(ep6in-bulk,   BULK,   IN),
+   EP_INFO(ep7out-bulk,  BULK,   OUT),
+   EP_INFO(ep8in-iso,ISO,IN),
+   EP_INFO(ep9out-iso,   ISO,OUT),
+   EP_INFO(ep10in-int,   INT,IN),
+   EP_INFO(ep11in-bulk,  BULK,   IN),
+   EP_INFO(ep12out-bulk, BULK,   OUT),
+   EP_INFO(ep13in-iso,   ISO,IN),
+   EP_INFO(ep14out-iso,  ISO,OUT),
+   EP_INFO(ep15in-int,   INT,IN),
/* or like sa1100: two fixed function endpoints */
-   ep1out-bulk, ep2in-bulk,
-
+   EP_INFO(ep1out-bulk,  BULK,   OUT),
+   EP_INFO(ep2in-bulk,   BULK,   IN),
/* and now some generic EPs so we have enough in multi config */
-   ep3out, ep4in, ep5out, ep6out, ep7in, ep8out, ep9in,
-   ep10out, ep11out, ep12in, ep13out, ep14in, ep15out,
+   EP_INFO(ep3out,   ALL,OUT),
+   EP_INFO(ep4in,ALL,IN),
+   EP_INFO(ep5out,   ALL,OUT),
+   EP_INFO(ep6out,   ALL,OUT),
+   EP_INFO(ep7in,ALL,IN),
+   EP_INFO(ep8out,   ALL,OUT),
+   EP_INFO(ep9in,ALL,IN),
+   EP_INFO(ep10out,  ALL,OUT),
+   EP_INFO(ep11out,  ALL,OUT),
+   EP_INFO(ep12in,   ALL,IN),
+   EP_INFO(ep13out,  ALL,OUT),
+   EP_INFO(ep14in,   ALL,IN),
+   EP_INFO(ep15out,  ALL,OUT),
+
+#undef EP_INFO
 };
-#define DUMMY_ENDPOINTSARRAY_SIZE(ep_name)
+
+#define DUMMY_ENDPOINTSARRAY_SIZE(ep_info)
 
 /*-*/
 
@@ -938,9 +972,10 @@ static void init_dummy_udc_hw(struct dummy *dum)
for (i = 0; i  DUMMY_ENDPOINTS; i++) {
struct dummy_ep *ep = dum-ep[i];
 
-   if (!ep_name[i])
+   if (!ep_info[i].name)
break;
-   ep-ep.name = ep_name[i];
+   ep-ep.name = ep_info[i].name;
+   ep-ep.caps = ep_info[i].caps;
ep-ep.ops = dummy_ep_ops;
list_add_tail(ep-ep.ep_list, dum-gadget.ep_list);
ep-halted = ep-wedged = ep-already_seen =
@@ -1684,7 +1719,7 @@ static void dummy_timer(unsigned long _dum_hcd)
}
 
for (i = 0; i  DUMMY_ENDPOINTS; i++) {
-   if (!ep_name[i])
+   if (!ep_info[i].name)
break;
dum-ep[i].already_seen = 0;
}
-- 
1.9.1

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


[PATCH v3 38/46] usb: gadget: epautoconf: remove pxa quirk from ep_matches()

2015-07-15 Thread Robert Baldyga
The same effect can be achieved by using capabilities flags, so now we can
get rid of handling of hardware specific limitations in generic code.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 5 -
 drivers/usb/gadget/udc/pxa25x_udc.c | 9 +++--
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index af4b10a..4f66e9d73 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -58,11 +58,6 @@ ep_matches (
 */
if (!ep-caps.type_int  !ep-caps.type_bulk)
return 0;
-   /* for now, avoid PXA interrupt-in;
-* it's documented as never using DATA1.
-*/
-   if (gadget_is_pxa(gadget)  ep-caps.type_int)
-   return 0;
break;
}
 
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c 
b/drivers/usb/gadget/udc/pxa25x_udc.c
index 1301e29..f53e526 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -1898,8 +1898,7 @@ static struct pxa25x_udc memory = {
.name   = ep5in-int,
.ops= pxa25x_ep_ops,
.maxpacket  = INT_FIFO_SIZE,
-   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
-   USB_EP_CAPS_DIR_IN),
+   .caps   = USB_EP_CAPS(0, 0),
},
.dev= memory,
.fifo_size  = INT_FIFO_SIZE,
@@ -1977,8 +1976,7 @@ static struct pxa25x_udc memory = {
.name   = ep10in-int,
.ops= pxa25x_ep_ops,
.maxpacket  = INT_FIFO_SIZE,
-   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
-   USB_EP_CAPS_DIR_IN),
+   .caps   = USB_EP_CAPS(0, 0),
},
.dev= memory,
.fifo_size  = INT_FIFO_SIZE,
@@ -2056,8 +2054,7 @@ static struct pxa25x_udc memory = {
.name   = ep15in-int,
.ops= pxa25x_ep_ops,
.maxpacket  = INT_FIFO_SIZE,
-   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT,
-   USB_EP_CAPS_DIR_IN),
+   .caps   = USB_EP_CAPS(0, 0),
},
.dev= memory,
.fifo_size  = INT_FIFO_SIZE,
-- 
1.9.1

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


[PATCH v3 37/46] usb: gadget: epautoconf: add endpoint capabilities flags verification

2015-07-15 Thread Robert Baldyga
Introduce endpoint matching mechanism basing on endpoint capabilities
flags. We check if endpoint supports transfer type and direction requested
in ep descriptor. Since we have this new endpoint matching mechanism
there is no need to have old code guessing endpoint capabilities basing
on its name, so we are getting rid of it. Remove also the obsolete comment.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 96 +
 1 file changed, 30 insertions(+), 66 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 8e00ca7..af4b10a 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,22 +22,6 @@
 
 #include gadget_chips.h
 
-/*
- * This should work with endpoints from controller drivers sharing the
- * same endpoint naming convention.  By example:
- *
- * - ep1, ep2, ... address is fixed, not direction or type
- * - ep1in, ep2out, ... address and direction are fixed, not type
- * - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction
- * - ep1in-bulk, ep2out-iso, ... all three are fixed
- * - ep-* ... no functionality restrictions
- *
- * Type suffixes are -bulk, -iso, or -int.  Numbers are decimal.
- * Less common restrictions are implied by gadget_is_*().
- *
- * NOTE:  each endpoint is unidirectional, as specified by its USB
- * descriptor; and isn't specific to a configuration or altsetting.
- */
 static int
 ep_matches (
struct usb_gadget   *gadget,
@@ -47,7 +31,6 @@ ep_matches (
 )
 {
u8  type;
-   const char  *tmp;
u16 max;
 
int num_req_streams = 0;
@@ -56,58 +39,39 @@ ep_matches (
if (ep-claimed)
return 0;
 
-   /* only support ep0 for portable CONTROL traffic */
type = usb_endpoint_type(desc);
-   if (USB_ENDPOINT_XFER_CONTROL == type)
-   return 0;
-
-   /* some other naming convention */
-   if ('e' != ep-name[0])
+   switch (type) {
+   case USB_ENDPOINT_XFER_CONTROL:
+   /* only support ep0 for portable CONTROL traffic */
return 0;
+   case USB_ENDPOINT_XFER_ISOC:
+   if (!ep-caps.type_iso)
+   return 0;
+   break;
+   case USB_ENDPOINT_XFER_BULK:
+   if (!ep-caps.type_bulk)
+   return 0;
+   break;
+   case USB_ENDPOINT_XFER_INT:
+   /* bulk endpoints handle interrupt transfers,
+* except the toggle-quirky iso-synch kind
+*/
+   if (!ep-caps.type_int  !ep-caps.type_bulk)
+   return 0;
+   /* for now, avoid PXA interrupt-in;
+* it's documented as never using DATA1.
+*/
+   if (gadget_is_pxa(gadget)  ep-caps.type_int)
+   return 0;
+   break;
+   }
 
-   /* type-restriction:  -iso, -bulk, or -int.
-* direction-restriction:  in, out.
-*/
-   if ('-' != ep-name[2]) {
-   tmp = strrchr (ep-name, '-');
-   if (tmp) {
-   switch (type) {
-   case USB_ENDPOINT_XFER_INT:
-   /* bulk endpoints handle interrupt transfers,
-* except the toggle-quirky iso-synch kind
-*/
-   if ('s' == tmp[2])  // == -iso
-   return 0;
-   /* for now, avoid PXA interrupt-in;
-* it's documented as never using DATA1.
-*/
-   if (gadget_is_pxa (gadget)
-'i' == tmp [1])
-   return 0;
-   break;
-   case USB_ENDPOINT_XFER_BULK:
-   if ('b' != tmp[1])  // != -bulk
-   return 0;
-   break;
-   case USB_ENDPOINT_XFER_ISOC:
-   if ('s' != tmp[2])  // != -iso
-   return 0;
-   }
-   } else {
-   tmp = ep-name + strlen (ep-name);
-   }
-
-   /* direction-restriction:  ..in-.., out-.. */
-   tmp--;
-   if (!isdigit (*tmp)) {
-   if (desc-bEndpointAddress  USB_DIR_IN) {
-   if ('n' != *tmp)
-   return 0;
-   } else {
-   if ('t' != *tmp)
-   return 0;
-   

[PATCH v3 40/46] usb: gadget: epautoconf: rework ep_matches() function

2015-07-15 Thread Robert Baldyga
Rework ep_matches() function to make it shorter and more readable.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 87 +
 1 file changed, 35 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 7bb28f1..4fa6f5d 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -30,16 +30,29 @@ ep_matches (
struct usb_ss_ep_comp_descriptor *ep_comp
 )
 {
-   u8  type;
-   u16 max;
-
-   int num_req_streams = 0;
+   u8  type;
+   u16 max;
+   int num_req_streams = 0;
 
/* endpoint already claimed? */
if (ep-claimed)
return 0;
 
type = usb_endpoint_type(desc);
+   max = 0x7ff  usb_endpoint_maxp(desc);
+
+   if (usb_endpoint_dir_in(desc)  !ep-caps.dir_in)
+   return 0;
+   else if (!ep-caps.dir_out)
+   return 0;
+
+   if (max  ep-maxpacket_limit)
+   return 0;
+
+   /* high bandwidth works only at high speed */
+   if (!gadget_is_dualspeed(gadget)  usb_endpoint_maxp(desc)  (311))
+   return 0;
+
switch (type) {
case USB_ENDPOINT_XFER_CONTROL:
/* only support ep0 for portable CONTROL traffic */
@@ -47,66 +60,36 @@ ep_matches (
case USB_ENDPOINT_XFER_ISOC:
if (!ep-caps.type_iso)
return 0;
+   /* ISO:  limit 1023 bytes full speed,
+* 1024 high/super speed
+*/
+   if (!gadget_is_dualspeed(gadget)  max  1023)
+   return 0;
break;
case USB_ENDPOINT_XFER_BULK:
if (!ep-caps.type_bulk)
return 0;
+   if (ep_comp  gadget_is_superspeed(gadget)) {
+   /* Get the number of required streams from the
+* EP companion descriptor and see if the EP
+* matches it
+*/
+   num_req_streams = ep_comp-bmAttributes  0x1f;
+   if (num_req_streams  ep-max_streams)
+   return 0;
+   }
break;
case USB_ENDPOINT_XFER_INT:
-   /* bulk endpoints handle interrupt transfers,
+   /* Bulk endpoints handle interrupt transfers,
 * except the toggle-quirky iso-synch kind
 */
if (!ep-caps.type_int  !ep-caps.type_bulk)
return 0;
-   break;
-   }
-
-   if (usb_endpoint_dir_in(desc)) {
-   if (!ep-caps.dir_in)
-   return 0;
-   } else {
-   if (!ep-caps.dir_out)
-   return 0;
-   }
-
-   /*
-* Get the number of required streams from the EP companion
-* descriptor and see if the EP matches it
-*/
-   if (usb_endpoint_xfer_bulk(desc)) {
-   if (ep_comp  gadget-max_speed = USB_SPEED_SUPER) {
-   num_req_streams = ep_comp-bmAttributes  0x1f;
-   if (num_req_streams  ep-max_streams)
-   return 0;
-   }
-
-   }
-
-   /* endpoint maxpacket size is an input parameter, except for bulk
-* where it's an output parameter representing the full speed limit.
-* the usb spec fixes high speed bulk maxpacket at 512 bytes.
-*/
-   max = 0x7ff  usb_endpoint_maxp(desc);
-   switch (type) {
-   case USB_ENDPOINT_XFER_INT:
-   /* INT:  limit 64 bytes full speed, 1024 high/super speed */
+   /* INT:  limit 64 bytes full speed,
+* 1024 high/super speed
+*/
if (!gadget_is_dualspeed(gadget)  max  64)
return 0;
-   /* FALLTHROUGH */
-
-   case USB_ENDPOINT_XFER_ISOC:
-   /* ISO:  limit 1023 bytes full speed, 1024 high/super speed */
-   if (ep-maxpacket_limit  max)
-   return 0;
-   if (!gadget_is_dualspeed(gadget)  max  1023)
-   return 0;
-
-   /* BOTH:  high bandwidth works only at high speed */
-   if ((desc-wMaxPacketSize  cpu_to_le16(311))) {
-   if (!gadget_is_dualspeed(gadget))
-   return 0;
-   /* configure your hardware with enough buffering!! */
-   }
break;
}
 
-- 
1.9.1

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


[PATCH v3 32/46] usb: gadget: udc-xilinx: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/udc-xilinx.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/gadget/udc/udc-xilinx.c 
b/drivers/usb/gadget/udc/udc-xilinx.c
index 1f24274..1cbb0ac 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -1317,12 +1317,21 @@ static void xudc_eps_init(struct xusb_udc *udc)
snprintf(ep-name, EPNAME_SIZE, ep%d, ep_number);
ep-ep_usb.name = ep-name;
ep-ep_usb.ops = xusb_ep_ops;
+
+   ep-ep_usb.caps.type_iso = true;
+   ep-ep_usb.caps.type_bulk = true;
+   ep-ep_usb.caps.type_int = true;
} else {
ep-ep_usb.name = ep0name;
usb_ep_set_maxpacket_limit(ep-ep_usb, EP0_MAX_PACKET);
ep-ep_usb.ops = xusb_ep0_ops;
+
+   ep-ep_usb.caps.type_control = true;
}
 
+   ep-ep_usb.caps.dir_in = true;
+   ep-ep_usb.caps.dir_out = true;
+
ep-udc = udc;
ep-epnumber = ep_number;
ep-desc = NULL;
-- 
1.9.1

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


[PATCH v3 35/46] usb: renesas: gadget: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/renesas_usbhs/mod_gadget.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index dc2aa32..ed8d890 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -1041,12 +1041,18 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
if (usbhsg_is_dcp(uep)) {
gpriv-gadget.ep0 = uep-ep;
usb_ep_set_maxpacket_limit(uep-ep, 64);
+   uep-ep.caps.type_control = true;
}
/* init normal pipe */
else {
usb_ep_set_maxpacket_limit(uep-ep, 512);
+   uep-ep.caps.type_iso = true;
+   uep-ep.caps.type_bulk = true;
+   uep-ep.caps.type_int = true;
list_add_tail(uep-ep.ep_list, gpriv-gadget.ep_list);
}
+   uep-ep.caps.dir_in = true;
+   uep-ep.caps.dir_out = true;
}
 
ret = usb_add_gadget_udc(dev, gpriv-gadget);
-- 
1.9.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 RESEND] phy: tusb1210: Use devm_gpiod_get_optional for optional GPIOs

2015-07-15 Thread Axel Lin
2015-06-20 15:39 GMT+08:00 Axel Lin axel@ingics.com:
 Also simplify the code a bit by specify direction and initial value for
 output in devm_gpiod_get_optional function.

 Signed-off-by: Axel Lin axel@ingics.com
 Acked-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 Acked-by: Kishon Vijay Abraham I kis...@ti.com
 ---
 Hi
 This patch was sent on https://lkml.org/lkml/2015/5/31/221 with ACKs.
 It's still not in linux-next, so here is a resend.

Hi Kishon,
No response from Felipe.
The phy-tusb1210 driver is already in Linus' tree, maybe you can pick
up this patch.

Regards,
Axel
--
To unsubscribe from this list: send the line unsubscribe 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 01/46] usb: gadget: encapsulate endpoint claiming mechanism

2015-07-15 Thread Robert Baldyga
So far it was necessary for usb functions to set ep-driver_data in
endpoint obtained from autoconfig to non-null value, to indicate that
endpoint is claimed by function (in autoconfig it was checked if endpoint
has set this field to non-null value, and if it has, it was assumed that
it is claimed). It could cause bugs becouse if some function doesn't
set this field autoconfig could return the same endpoint more than one
time.

To help to avoid such bugs this patch adds claimed flag to struct usb_ep,
and  encapsulates endpoint claiming mechanism inside usb_ep_autoconfig_ss()
and usb_ep_autoconfig_reset(), so now usb functions don't need to perform
any additional actions to mark endpoint obtained from autoconfig as claimed.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 11 ++-
 include/linux/usb/gadget.h  |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 919cdfd..8e00ca7 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -53,7 +53,7 @@ ep_matches (
int num_req_streams = 0;
 
/* endpoint already claimed? */
-   if (NULL != ep-driver_data)
+   if (ep-claimed)
return 0;
 
/* only support ep0 for portable CONTROL traffic */
@@ -240,7 +240,7 @@ find_ep (struct usb_gadget *gadget, const char *name)
  * updated with the assigned number of streams if it is
  * different from the original value. To prevent the endpoint
  * from being returned by a later autoconfig call, claim it by
- * assigning ep-driver_data to some non-null value.
+ * assigning ep-claimed to true.
  *
  * On failure, this returns a null endpoint descriptor.
  */
@@ -323,6 +323,7 @@ struct usb_ep *usb_ep_autoconfig_ss(
 found_ep:
ep-desc = NULL;
ep-comp_desc = NULL;
+   ep-claimed = true;
return ep;
 }
 EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss);
@@ -354,7 +355,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss);
  * descriptor bEndpointAddress.  For bulk endpoints, the wMaxPacket value
  * is initialized as if the endpoint were used at full speed.  To prevent
  * the endpoint from being returned by a later autoconfig call, claim it
- * by assigning ep-driver_data to some non-null value.
+ * by assigning ep-claimed to true.
  *
  * On failure, this returns a null endpoint descriptor.
  */
@@ -373,7 +374,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig);
  *
  * Use this for devices where one configuration may need to assign
  * endpoint resources very differently from the next one.  It clears
- * state such as ep-driver_data and the record of assigned endpoints
+ * state such as ep-claimed and the record of assigned endpoints
  * used by usb_ep_autoconfig().
  */
 void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
@@ -381,7 +382,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
struct usb_ep   *ep;
 
list_for_each_entry (ep, gadget-ep_list, ep_list) {
-   ep-driver_data = NULL;
+   ep-claimed = false;
}
gadget-in_epnum = 0;
gadget-out_epnum = 0;
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 4f3dfb7..fcb0a4e 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -173,6 +173,7 @@ struct usb_ep {
const char  *name;
const struct usb_ep_ops *ops;
struct list_headep_list;
+   boolclaimed;
unsignedmaxpacket:16;
unsignedmaxpacket_limit:16;
unsignedmax_streams:16;
-- 
1.9.1

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


[PATCH v3 00/46] usb: gadget: rework ep matching and claiming mechanism

2015-07-15 Thread Robert Baldyga
Hello,

This patch series reworks endpoint matching and claiming mechanism in
epautoconf. From v2 there are couple of new patches adding 'ep_match'
to usb_gadget_ops and removing chip-specific quirk handling from generic
code of autoconfig.

I'm not sure if this patch set isn't too long, as it has 46 patches,
but I decided to send it as single series to avoid problems with patch
applying order.

The aim of whole patchset is to rework epautoconf code to get rid of
things like name-based endpoint matching and UDC name-based quirks in
generic code. These needed to do some modifications in framework like
adding 'endpoint capabilities flags' feature or adding 'match_ep'.

Following paragraphs contain brief description of what modifications are
done by particular parts of this patch set:

Patch (1) introduces new safer endpoint claiming method, basing on new
'claimed' flag. It was discussed here [1]. I proposed this solution over
year ago and it was accepted, but I apparently forgot to send the final
version of my patch.

Patches (2-3) add the 'capabilities flags' structure and helper macros.
This solution is inspired by the 'feature flags' originally proposed
by Felipe Balbi in 2013 [2], but unfortunately implementation of this
feature has never been completed.

Patches (4-36) add' capabilites flags' support to all UDC drivers present
in the kernel tree. It's needed to be done before replacing old endpoint
matching mechanism, otherwise UDC drivers which doesn't set 'capabilities
flags' won't work with new matching function.

Patch (37) finally replaces old endpoint matching method with the new
one basing on capabilities flags.

These changes aims to get rid of code, which guesses endpoint capabilities
basing on it's name, and introduce new better replacement. In result
we have better way to describe types and directions supported by each
endpoint.

For example the old name-based method didn't allow to have endpoint
supporing two types of transfers - there were only ability to support
one or all of endpoint types. The 'capabilities flags' feature supply
precise, flexible and extensible mechanism of description of endpoint
hardware limitations, which is desired for proper endpoint matching.

Patch (38) removes chip-specific quirk from ep_matches() function.

Patches (39-40) remove code modifying endpoint and descriptor structures
from ep_matches() function and cleans it up to make it simpler and more
readable.

Patch (41) add 'match_ep' callback to usb_gadget_ops and make use of
it in epautoconf. This callback allows UDC drivers to supply non-standard
endpoint matching algorithms.

Patches (42-43) move ep_matches() and find_ep() functions outside
epautoconf and rename them to usb_gadget_ep_match_desc() and
gadget_find_ep_by_name(). It's because they may be useful in 'match_ep'
callbacks in UDC drivers to avoid writing repetitive code.

Patches (44-46) move chip-specific enpoint matching algorithms from
generic code of usb_ep_autoconfig_ss() function to UDC controller drivers
using 'match_ep' callback.

In the result we have epautoconf source free of chip-specific code, plus
two new mechanisms allowing to handle non-standard hardware limitations.

[1] https://lkml.org/lkml/2014/6/16/94
[2] http://www.spinics.net/lists/linux-usb/msg99662.html

Best regards,
Robert Baldyga

Changelog:

v3:
- addressed comments from Sergei Shtylyov

v2: https://lkml.org/lkml/2015/7/14/172
- remove PXA quirk from ep_matches() function without behaviour change
  using ep capabilities flags
- separate ep and desc configuration code from ep_match() function
- add 'ep_match' to usb_gadget_ops and move chip-specific endpoint
  matching algorithms from generic code to UDC controller drivers

v1: https://lkml.org/lkml/2015/7/8/436

Robert Baldyga (46):
  usb: gadget: encapsulate endpoint claiming mechanism
  usb: gadget: add endpoint capabilities flags
  usb: gadget: add endpoint capabilities helper macros
  staging: emxx_udc: add ep capabilities support
  usb: chipidea: udc: add ep capabilities support
  usb: dwc2: gadget: add ep capabilities support
  usb: dwc3: gadget: add ep capabilities support
  usb: gadget: amd5536udc: add ep capabilities support
  usb: gadget: at91_udc: add ep capabilities support
  usb: gadget: bcm63xx_udc: add ep capabilities support
  usb: gadget: bdc: add ep capabilities support
  usb: gadget: dummy-hcd: add ep capabilities support
  usb: gadget: fotg210-udc: add ep capabilities support
  usb: gadget: fsl_qe_udc: add ep capabilities support
  usb: gadget: fsl_udc_core: add ep capabilities support
  usb: gadget: fusb300_udc: add ep capabilities support
  usb: gadget: goku_udc: add ep capabilities support
  usb: gadget: gr_udc: add ep capabilities support
  usb: gadget: lpc32xx_udc: add ep capabilities support
  usb: gadget: m66592-udc: add ep capabilities support
  usb: gadget: mv_u3d_core: add ep capabilities support
  usb: gadget: mv_udc_core: add ep capabilities support
  usb: gadget: net2272: add ep 

[PATCH v3 41/46] usb: gadget: add 'ep_match' callback to usb_gadget_ops

2015-07-15 Thread Robert Baldyga
Add callback that is called by epautoconf to allow UDC driver match the
best endpoint for specific descriptor. It's intended to supply mechanism
which allows to get rid of chip-specific endpoint matching code from
epautoconf.

If gadget has set 'ep_match' callback we prefer to call it first, and
if it fails to find matching endpoint, then we try to use default matching
algorithm.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/epautoconf.c | 6 ++
 include/linux/usb/gadget.h  | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 4fa6f5d..1b1fee0 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -165,6 +165,12 @@ struct usb_ep *usb_ep_autoconfig_ss(
 
type = desc-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK;
 
+   if (gadget-ops-match_ep) {
+   ep = gadget-ops-match_ep(gadget, desc, ep_comp);
+   if (ep)
+   goto found_ep;
+   }
+
/* First, apply chip-specific best usage knowledge.
 * This might make a good usb_gadget_ops hook ...
 */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index e6cbc25..0041bb9 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -534,6 +534,9 @@ struct usb_gadget_ops {
int (*udc_start)(struct usb_gadget *,
struct usb_gadget_driver *);
int (*udc_stop)(struct usb_gadget *);
+   struct usb_ep *(*match_ep)(struct usb_gadget *,
+   struct usb_endpoint_descriptor *,
+   struct usb_ss_ep_comp_descriptor *);
 };
 
 /**
-- 
1.9.1

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


[PATCH v3 36/46] usb: gadget: atmel_usba_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 37d414e..267d84f 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2067,6 +2067,17 @@ static struct usba_ep * usba_udc_pdata(struct 
platform_device *pdev,
ep-can_dma = pdata-ep[i].can_dma;
ep-can_isoc = pdata-ep[i].can_isoc;
 
+   if (i == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = ep-can_isoc;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
+
if (i)
list_add_tail(ep-ep.ep_list, udc-gadget.ep_list);
}
-- 
1.9.1

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


[PATCH v3 08/46] usb: gadget: amd5536udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/amd5536udc.c | 57 ++---
 1 file changed, 47 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/udc/amd5536udc.c 
b/drivers/usb/gadget/udc/amd5536udc.c
index de7e5e2..1a1d91c 100644
--- a/drivers/usb/gadget/udc/amd5536udc.c
+++ b/drivers/usb/gadget/udc/amd5536udc.c
@@ -138,15 +138,51 @@ static DECLARE_TASKLET(disconnect_tasklet, 
udc_tasklet_disconnect,
 
 /* endpoint names used for print */
 static const char ep0_string[] = ep0in;
-static const char *const ep_string[] = {
-   ep0_string,
-   ep1in-int, ep2in-bulk, ep3in-bulk, ep4in-bulk, ep5in-bulk,
-   ep6in-bulk, ep7in-bulk, ep8in-bulk, ep9in-bulk, ep10in-bulk,
-   ep11in-bulk, ep12in-bulk, ep13in-bulk, ep14in-bulk,
-   ep15in-bulk, ep0out, ep1out-bulk, ep2out-bulk, ep3out-bulk,
-   ep4out-bulk, ep5out-bulk, ep6out-bulk, ep7out-bulk,
-   ep8out-bulk, ep9out-bulk, ep10out-bulk, ep11out-bulk,
-   ep12out-bulk, ep13out-bulk, ep14out-bulk, ep15out-bulk
+static const struct {
+   const char *name;
+   const struct usb_ep_caps caps;
+} ep_info[] = {
+#define EP_INFO(_name, _type, _dir) \
+   { \
+   .name = _name, \
+   .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \
+   USB_EP_CAPS_DIR_ ## _dir), \
+   }
+
+   EP_INFO(ep0_string, CONTROL, IN),
+   EP_INFO(ep1in-int,BULK,   IN),
+   EP_INFO(ep2in-bulk,   BULK,   IN),
+   EP_INFO(ep3in-bulk,   BULK,   IN),
+   EP_INFO(ep4in-bulk,   BULK,   IN),
+   EP_INFO(ep5in-bulk,   BULK,   IN),
+   EP_INFO(ep6in-bulk,   BULK,   IN),
+   EP_INFO(ep7in-bulk,   BULK,   IN),
+   EP_INFO(ep8in-bulk,   BULK,   IN),
+   EP_INFO(ep9in-bulk,   BULK,   IN),
+   EP_INFO(ep10in-bulk,  BULK,   IN),
+   EP_INFO(ep11in-bulk,  BULK,   IN),
+   EP_INFO(ep12in-bulk,  BULK,   IN),
+   EP_INFO(ep13in-bulk,  BULK,   IN),
+   EP_INFO(ep14in-bulk,  BULK,   IN),
+   EP_INFO(ep15in-bulk,  BULK,   IN),
+   EP_INFO(ep0out,   CONTROL, OUT),
+   EP_INFO(ep1out-bulk,  BULK,   OUT),
+   EP_INFO(ep2out-bulk,  BULK,   OUT),
+   EP_INFO(ep3out-bulk,  BULK,   OUT),
+   EP_INFO(ep4out-bulk,  BULK,   OUT),
+   EP_INFO(ep5out-bulk,  BULK,   OUT),
+   EP_INFO(ep6out-bulk,  BULK,   OUT),
+   EP_INFO(ep7out-bulk,  BULK,   OUT),
+   EP_INFO(ep8out-bulk,  BULK,   OUT),
+   EP_INFO(ep9out-bulk,  BULK,   OUT),
+   EP_INFO(ep10out-bulk, BULK,   OUT),
+   EP_INFO(ep11out-bulk, BULK,   OUT),
+   EP_INFO(ep12out-bulk, BULK,   OUT),
+   EP_INFO(ep13out-bulk, BULK,   OUT),
+   EP_INFO(ep14out-bulk, BULK,   OUT),
+   EP_INFO(ep15out-bulk, BULK,   OUT),
+
+#undef EP_INFO
 };
 
 /* DMA usage flag */
@@ -1517,7 +1553,8 @@ static void udc_setup_endpoints(struct udc *dev)
for (tmp = 0; tmp  UDC_EP_NUM; tmp++) {
ep = dev-ep[tmp];
ep-dev = dev;
-   ep-ep.name = ep_string[tmp];
+   ep-ep.name = ep_info[tmp].name;
+   ep-ep.caps = ep_info[tmp].caps;
ep-num = tmp;
/* txfifo size is calculated at enable time */
ep-txfifo = dev-txfifo;
-- 
1.9.1

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


[PATCH v3 11/46] usb: gadget: bdc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/bdc/bdc_ep.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index b04980c..f9a8f57 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -1952,12 +1952,18 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir)
ep-bdc = bdc;
ep-dir = dir;
 
+   if (dir)
+   ep-usb_ep.caps.dir_in = true;
+   else
+   ep-usb_ep.caps.dir_out = true;
+
/* ep-ep_num is the index inside bdc_ep */
if (epnum == 1) {
ep-ep_num = 1;
bdc-bdc_ep_array[ep-ep_num] = ep;
snprintf(ep-name, sizeof(ep-name), ep%d, epnum - 1);
usb_ep_set_maxpacket_limit(ep-usb_ep, EP0_MAX_PKT_SIZE);
+   ep-usb_ep.caps.type_control = true;
ep-comp_desc = NULL;
bdc-gadget.ep0 = ep-usb_ep;
} else {
@@ -1971,6 +1977,9 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir)
 dir  1 ? in : out);
 
usb_ep_set_maxpacket_limit(ep-usb_ep, 1024);
+   ep-usb_ep.caps.type_iso = true;
+   ep-usb_ep.caps.type_bulk = true;
+   ep-usb_ep.caps.type_int = true;
ep-usb_ep.max_streams = 0;
list_add_tail(ep-usb_ep.ep_list, bdc-gadget.ep_list);
}
-- 
1.9.1

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


[PATCH v3 10/46] usb: gadget: bcm63xx_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/bcm63xx_udc.c | 25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c 
b/drivers/usb/gadget/udc/bcm63xx_udc.c
index 9db968b..c5e0894 100644
--- a/drivers/usb/gadget/udc/bcm63xx_udc.c
+++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
@@ -44,9 +44,25 @@
 #define DRV_MODULE_NAMEbcm63xx_udc
 
 static const char bcm63xx_ep0name[] = ep0;
-static const char *const bcm63xx_ep_name[] = {
-   bcm63xx_ep0name,
-   ep1in-bulk, ep2out-bulk, ep3in-int, ep4out-int,
+
+static const struct {
+   const char *name;
+   const struct usb_ep_caps caps;
+} bcm63xx_ep_info[] = {
+#define EP_INFO(_name, _type, _dir) \
+   { \
+   .name = _name, \
+   .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \
+   USB_EP_CAPS_DIR_ ## _dir), \
+   }
+
+   EP_INFO(bcm63xx_ep0name, CONTROL, ALL),
+   EP_INFO(ep1in-bulk,   BULK,   IN),
+   EP_INFO(ep2out-bulk,  BULK,   OUT),
+   EP_INFO(ep3in-int,INT,IN),
+   EP_INFO(ep4out-int,   INT,OUT),
+
+#undef EP_INFO
 };
 
 static bool use_fullspeed;
@@ -943,7 +959,8 @@ static int bcm63xx_init_udc_hw(struct bcm63xx_udc *udc)
for (i = 0; i  BCM63XX_NUM_EP; i++) {
struct bcm63xx_ep *bep = udc-bep[i];
 
-   bep-ep.name = bcm63xx_ep_name[i];
+   bep-ep.name = bcm63xx_ep_info[i].name;
+   bep-ep.caps = bcm63xx_ep_info[i].caps;
bep-ep_num = i;
bep-ep.ops = bcm63xx_udc_ep_ops;
list_add_tail(bep-ep.ep_list, udc-gadget.ep_list);
-- 
1.9.1

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


[PATCH v3 03/46] usb: gadget: add endpoint capabilities helper macros

2015-07-15 Thread Robert Baldyga
Add macros useful while initializing array of endpoint capabilities
structures. These macros makes structure initialization more compact
to decrease number of code lines and increase readability of code.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 include/linux/usb/gadget.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 6f3e0fb..e6cbc25 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -158,6 +158,26 @@ struct usb_ep_caps {
unsigned dir_out:1;
 };
 
+#define USB_EP_CAPS_TYPE_CONTROL 0x01
+#define USB_EP_CAPS_TYPE_ISO 0x02
+#define USB_EP_CAPS_TYPE_BULK0x04
+#define USB_EP_CAPS_TYPE_INT 0x08
+#define USB_EP_CAPS_TYPE_ALL \
+   (USB_EP_CAPS_TYPE_ISO | USB_EP_CAPS_TYPE_BULK | USB_EP_CAPS_TYPE_INT)
+#define USB_EP_CAPS_DIR_IN   0x01
+#define USB_EP_CAPS_DIR_OUT  0x02
+#define USB_EP_CAPS_DIR_ALL  (USB_EP_CAPS_DIR_IN | USB_EP_CAPS_DIR_OUT)
+
+#define USB_EP_CAPS(_type, _dir) \
+   { \
+   .type_control = !!(_type  USB_EP_CAPS_TYPE_CONTROL), \
+   .type_iso = !!(_type  USB_EP_CAPS_TYPE_ISO), \
+   .type_bulk = !!(_type  USB_EP_CAPS_TYPE_BULK), \
+   .type_int = !!(_type  USB_EP_CAPS_TYPE_INT), \
+   .dir_in = !!(_dir  USB_EP_CAPS_DIR_IN), \
+   .dir_out = !!(_dir  USB_EP_CAPS_DIR_OUT), \
+   }
+
 /**
  * struct usb_ep - device side representation of USB endpoint
  * @name:identifier for the endpoint, such as ep-a or ep9in-bulk
-- 
1.9.1

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


[PATCH v3 06/46] usb: dwc2: gadget: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/dwc2/gadget.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 4d47b7c..8771b66 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3289,6 +3289,19 @@ static void s3c_hsotg_initep(struct dwc2_hsotg *hsotg,
usb_ep_set_maxpacket_limit(hs_ep-ep, epnum ? 1024 : EP0_MPS_LIMIT);
hs_ep-ep.ops = s3c_hsotg_ep_ops;
 
+   if (epnum == 0) {
+   hs_ep-ep.caps.type_control = true;
+   } else {
+   hs_ep-ep.caps.type_iso = true;
+   hs_ep-ep.caps.type_bulk = true;
+   hs_ep-ep.caps.type_int = true;
+   }
+
+   if (dir_in)
+   hs_ep-ep.caps.dir_in = true;
+   else
+   hs_ep-ep.caps.dir_out = true;
+
/*
 * if we're using dma, we need to set the next-endpoint pointer
 * to be something valid.
-- 
1.9.1

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


Re: [PATCH] USB: pl2303: Rewrite pl2303_encode_baud_rate_divisor

2015-07-15 Thread Johan Hovold
On Wed, Jul 08, 2015 at 12:51:03PM +0200, Michał Pecio wrote:
 
 This commit fixes the following issues:
 
 1. The 9th bit of buf was believed to be the LSB of divisor's
 exponent, but the hardware interprets it as MSB (9th bit) of the
 mantissa. The exponent is actually one bit shorter and applies
 to base 4, not 2 as previously believed.
 
 2. Loop iterations doubled the exponent instead of incrementing.
 
 3. The exponent wasn't checked for overflow.
 
 4. The function returned requested rate instead of actual rate.
 
 Due to issue #2, the old code deviated from the wrong formula
 described in #1 and actually yielded correct rates when divisor
 was lower than 4096 by giving exponents of 0, 2 or 4 base-2,
 interpreted as 0, 1, 2 base-4 with the 9th mantissa bit clear.
 However, at 93.75 kbaud or less the rate turned out too slow
 due to #1 and #2 or too fast due to #2 with #3.
 
 I tested this patch by sending and validating 0x00,0x01,..,0xff
 to an FTDI dongle at 234, 987, 2401, 9601, 31415, 115199, 250k,
 500k, 750k, 1M, 1.5M, 3M+1 baud. All rates passed.
 
 I also used pv to check speed at some rates unsupported by FTDI:
 45 (the lowest possible), 2M, 4M, 5M and 6M-1. Looked sane.
 
 Signed-off-by: Michal Pecio michal.pe...@gmail.com
 ---
  drivers/usb/serial/pl2303.c | 32 ++--
  1 file changed, 22 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
 index f5257af..8141ccc 100644
 --- a/drivers/usb/serial/pl2303.c
 +++ b/drivers/usb/serial/pl2303.c
 @@ -362,22 +362,34 @@ static speed_t pl2303_encode_baud_rate_direct(unsigned 
 char buf[4],
  static speed_t pl2303_encode_baud_rate_divisor(unsigned char buf[4],
   speed_t baud)
  {
 - unsigned int tmp;
 -
   /*
* Apparently the formula is:
 -  * baudrate = 12M * 32 / (2^buf[1]) / buf[0]
 +  *   baudrate = 12M * 32 / (mantissa * 4^exponent)
 +  * where
 +  *   mantissa = buf[8:0]
 +  *   exponent = buf[11:9]
*/
 - tmp = 1200 * 32 / baud;
 + u32 baseline = 1200 * 32;
 + u32 mantissa = baseline / baud;
 + u32 exponent = 0;

You'd get a checkpatch warning here about a missing new line after the
declarations (always run checkpatch.pl before submitting).

Please declare the variables at the top of the function and initialise
after the comment.

 + while (mantissa = 512) {
 + if (likely(exponent  7)) {

Don't use likely().

 + mantissa = 2; /* divide by 4 */
 + exponent++;
 + } else {
 + /* Exponent is maxed. Trim mantissa and leave. */
 + mantissa = 511;
 + break;
 + }
 + }
 +
   buf[3] = 0x80;
   buf[2] = 0;
 - buf[1] = (tmp = 256);
 - while (tmp = 256) {
 - tmp = 2;
 - buf[1] = 1;
 - }
 - buf[0] = tmp;
 + buf[1] = (exponent  1) | (mantissa  8);
 + buf[0] = (mantissa  0xff);

No parentheses.

  
 + /* Calculate and return the exact baud rate. */
 + baud = (baseline / mantissa)  (exponent  1);
   return baud;
  }

Looks nice and clean otherwise.

Were you already going to send a v2 or was this version complete?

Care to fix up the above style issues and resend so I can apply this for
4.2?

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


Re: [PATCH] USB: pl2303: Rewrite pl2303_encode_baud_rate_divisor

2015-07-15 Thread Johan Hovold
On Tue, Jul 14, 2015 at 09:29:29PM +0200, Frank Schäfer wrote:
 Am 13.07.2015 um 18:47 schrieb Johan Hovold:
  On Mon, Jul 13, 2015 at 06:08:50PM +0200, Michał Pecio wrote:
  Commit 57ce61aad748 might be helpful... ;)
 
  Good luck,
  Frank
 
 
  Pretty much the same thing I have done, except that I didn't notice that
  0 = 512 :)
 
  Apparently, 57ce61aad748 fell victim of a mass-revert caused by some
  underdebugged issues. Is it known what they were? Is there any chance
  of getting this driver fixed again?
  Yes, that series caused some regressions late in the release cycle and
  was reverted so that it could get some more review and testing.
 
 It was the baud rate divisor fix patch (only) which unveiled a single
 long standing bug in another part of the driver
 I offered you a simple and 100% safe solution for this (not reporting
 the actually set baud rate as before).

Your changes caused a regression that was discovered mere days before
3.12 was released. At the time the reason had not been fully determined
so the patches were consequently reverted.

  If you want to pick this up and improve the divisor calculations that'd
  be great.
 
 Maybe you should just start doing your job as the maintainer and accept
 one of the patches people are sending to you to get this issue fixed ?

I see you're still upset over this almost two years later.

Patches are always welcome if you change your mind.

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


Renesas upd7202 (xhci): can't setup

2015-07-15 Thread Jean-Francois SIMON
Hi,

We have designed a h/w system with the Renesas USB 3.0 upd7202 controller.
We are seeing that sometimes xhci initialization fails with a can't
setup error message.
As a result lsusb doesn't report the USB3.0 ports.

Adding traces to the kernel we could see that this is happening in
xhci_reset() -- xhci_handshake() sequence, where xhci_handshake exits
in time out. (I tried to increase the time out value by 10 times..it
didn't help)

This is happening on Centos 6.5 using Centos kernel
2.6.32-431.el6.x86_64. Now I know it is very old and I apologize. But
I have limited access to the system, and that is what it is configured
with currently. But we had the opportunity to quickly load latest
fedora 22 (kernel is 4.0) and the same problem happens.

Here is what dmesg says:

uhci_hcd: USB Universal Host Controller Interface driver
xhci_hcd :94:00.0: PCI INT A - GSI 64 (level, low) - IRQ 64
xhci_hcd :94:00.0: setting latency timer to 64
xhci_hcd :94:00.0: xHCI Host Controller
xhci_hcd :94:00.0: new USB bus registered, assigned bus number 15
usb usb13: bus auto-suspend
xhci_hcd :94:00.0: // Halt the HC
xhci_hcd :94:00.0: Resetting HCD
xhci_hcd :94:00.0: // Reset the HC
usb usb14: bus auto-suspend

(xhci_handshake: exits in time out)

xhci_hcd :94:00.0: can't setup
xhci_hcd :94:00.0: USB bus 15 deregistered
xhci_hcd :94:00.0: PCI INT A disabled
xhci_hcd :94:00.0: init :94:00.0 fail, -110
xhci_hcd: probe of :94:00.0 failed with error -110


As you can see for below, the PCI-e hierarchy includes a
PEX8624--PEX8606- (OPTICAL LINK)-PEX8509--UPD7202.

The upd7202 is remote. There is a optical link between the 8606 and the 8509.
The upd7202 is located in a remote enclosure that has its own power
supply. That means  it doesn't get powered at the same time the main
PCI-e fabric is powered. This is probably a key factor in the error.

   84:08.0 PCI bridge: PLX Technology, Inc. PEX 8624 24-lane, 6-Port
PCI Express Gen 2 (5.0 GT/s) Switch [ExpressLane] (rev bb)
  8e:00.0 PCI bridge: PLX Technology, Inc. PEX 8606 6 Lane, 6 Port
PCI Express Gen 2 (5.0 GT/s) Switch (rev ba)
8f:07.0 PCI bridge: PLX Technology, Inc. PEX 8606 6 Lane, 6
Port PCI Express Gen 2 (5.0 GT/s) Switch (rev ba)
  92:00.0 PCI bridge: PLX Technology, Inc. PEX 8509 8-lane,
8-port PCI Express Switch (rev aa)
93:01.0 PCI bridge: PLX Technology, Inc. PEX 8509 8-lane,
8-port PCI Express Switch (rev aa)
  94:00.0 USB controller: Renesas Technology Corp.
uPD720202 USB 3.0 Host Controller (rev 02)



Here some info based on lspci:



# lspci -s 8f:07.0 -vvv
8f:07.0 PCI bridge: PLX Technology, Inc. PEX 8606 6 Lane, 6 Port PCI
Express Gen 2 (5.0 GT/s) Switch (rev ba) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast TAbort-
TAbort- MAbort- SERR- PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=8f, secondary=92, subordinate=9a, sec-latency=0
I/O behind bridge: f000-0fff
Memory behind bridge: faf0-fb5f
Prefetchable memory behind bridge: fff0-000f
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast TAbort-
TAbort- MAbort- SERR- PERR-
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA
PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] MSI: Enable+ Count=1/4 Maskable+ 64bit+
Address: fee00338  Data: 
Masking: 0001  Pending: 
Capabilities: [68] Express (v2) Downstream Port (Slot+), MSI 00
DevCap:MaxPayload 512 bytes, PhantFunc 0, Latency L0s 64ns, L1 1us
ExtTag- RBE+ FLReset-
DevCtl:Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta:CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
LnkCap:Port #7, Speed 5GT/s, Width x1, ASPM L0s L1,
Latency L0 2us, L1 4us
ClockPM- Surprise+ LLActRep+ BwNot+
LnkCtl:ASPM Disabled; Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta:Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk-
DLActive+ BWMgmt+ ABWMgmt-
SltCap:AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
Slot #119, PowerLimit 25.000W; Interlock- NoCompl-
SltCtl:Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt-
HPIrq- LinkChg-
Control: AttnInd Off, PwrInd Off, Power- Interlock-
SltSta:Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet+ Interlock-
   

[PATCH 8/8][v2]usb:fsl:otg: Add host-gadget drv sync delay

2015-07-15 Thread Ramneek Mehresh
Resolve synchronization issue between host
and gadget drivers upon role-reversal.

Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
Reviewed-by: Li Yang-R58472 le...@freescale.com
Reviewed-by: Fleming Andrew-AFLEMING aflem...@freescale.com
Tested-by: Fleming Andrew-AFLEMING aflem...@freescale.com
---
 drivers/usb/phy/phy-fsl-usb.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 689516d..5d678ea 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -544,8 +544,18 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
dev = otg-gadget-dev.parent;
 
if (on) {
-   if (dev-driver-resume)
+   /*
+* Delay gadget resume to synchronize between host and gadget
+* drivers. Upon role-reversal host drv is shutdown by kernel
+* worker thread. By the time host drv shuts down, controller
+* gets programmed for gadget role. Shutting host drv after
+* this results in controller getting reset, and it stops
+* responding to otg events
+*/
+   if (dev-driver-resume) {
+   msleep(1000);
dev-driver-resume(dev);
+   }
} else {
if (dev-driver-suspend)
dev-driver-suspend(dev, otg_suspend_state);
-- 
1.8.3.1

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


Re: [PATCH v2 1/5] dt-bindings: Add usb3.0 phy binding for MT65xx SoCs

2015-07-15 Thread chunfeng yun
On Tue, 2015-07-14 at 09:45 +0200, Sascha Hauer wrote:
 On Tue, Jul 14, 2015 at 02:19:51PM +0800, chunfeng yun wrote:
  hi,
  On Fri, 2015-07-10 at 07:10 +0200, Sascha Hauer wrote:
   On Wed, Jul 08, 2015 at 05:41:03PM +0800, Chunfeng Yun wrote:
add a DT binding documentation of usb3.0 phy for MT65xx
SoCs from Mediatek.

Signed-off-by: Chunfeng Yun chunfeng@mediatek.com
---
 .../devicetree/bindings/usb/mt65xx-u3phy.txt   | 34 
++
 1 file changed, 34 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/usb/mt65xx-u3phy.txt

diff --git a/Documentation/devicetree/bindings/usb/mt65xx-u3phy.txt 
b/Documentation/devicetree/bindings/usb/mt65xx-u3phy.txt
new file mode 100644
index 000..056b2aa
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/mt65xx-u3phy.txt
@@ -0,0 +1,34 @@
+MT65xx U3PHY
+
+The device node for Mediatek SOC usb3.0 phy
+
+Required properties:
+ - compatible : Should be mediatek,mt8173-u3phy
+ - reg: Offset and length of registers, the first is for mac 
domain,
+   another for phy domain
+ - power-domains: to enable usb's mtcmos
+ - usb-wakeup-ctrl : to access usb wakeup control register
+ - wakeup-src : 1: ip sleep wakeup mode; 2: line state wakeup mode; 
others
+   means don't enable wakeup source of usb
+ - u2port-num : number of usb2.0 ports to support which should be 1 or 
2
+ - clocks : must support all clocks that phy need
+ - clock-names: should be wakeup_deb_p0, wakeup_deb_p1 for wakeup
+   debounce control clocks, and u3phya_ref for u3phya reference 
clock.
+
+Example:
+
+u3phy: usb-phy@11271000 {
+   compatible = mediatek,mt8173-u3phy;
+   reg = 0 0x11271000 0 0x3000,
+ 0 0x1128 0 0x2;
   
   0x11271000 is the register space the xhci controller takes. You should
   not expose the same register space to two different drivers.
   
  
  usb: usb30@1127 {
 compatible = mediatek,mt8173-xhci;
 reg = 0 0x1127 0 0x1000;
  
  the size of xhci register space is 0x1000, and the range is
  [0x1127, 0x11271000 - 1], so the address of 0x11271000 is not
  included.
 
 Indeed, you are right. Nevertheless my datasheet lists these resources:
 
 0x1127 - 0x1127: SSUSB CSR
 0x1128 - 0x1128: SSUSB SIF
 0x1129 - 0x1129: SSUSB
 
 It seems that with the current binding you are not modelling the
 hardware but something that reflects your current implementation. This
 is not a good sign. Normally I would expect device nodes that match the
 above resources, but your USB phy spans most of the SSUSB CSR register
 space and both the SSUSB SIF and SSUSB regster space. I think it would
 be good if you could give an overview over the USB hardware and explain
 why you have to violate the above resources.
 
 Also something to consider: Is your binding suitable for adding OTG
 support later? You don't have to add OTG support to the Kernel now,
 but your binding should be suitable to add it later.
 
 Sascha
 

I agree with you, but timing parameter settings of super speed port are
put in [0x11272400 - 0x11272800], which is not included by xhci register
space. SSUSB SIF includes some control and status registers of each
ports and also OTG etc. It is better to put them into the node of gadget
device node which is not supported now, so put them into phy device
node.

Do you have any good idea to deal with the special case?


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


Re: [PATCH v4 1/2] phy-sun4i-usb: Add full support for usb0 phy / OTG

2015-07-15 Thread Kishon Vijay Abraham I
Hi,

On Sunday 31 May 2015 09:40 PM, Hans de Goede wrote:
 The usb0 phy is connected to an OTG controller, and as such needs some special
 handling:
 
 1) It allows explicit control over the pullups, enable these on phy_init and
 disable them on phy_exit.
 
 2) It has bits to signal id and vbus detect to the musb-core, add support for
 for monitoring id and vbus detect gpio-s for use in dual role mode, and set
 these bits to the correct values for operating in host only mode when no
 gpios are specified in the devicetree.
 
 3) When in dual role mode the musb sunxi glue needs to know if the a host or
 device cable is plugged in, so when in dual role mode register an extcon.
 
 While updating the devicetree binding documentation also add documentation
 for the sofar undocumented usage of regulators for vbus for all 3 phys.

merged this to linux-phy tree.

Cheers
Kishon
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
 Changes in v2:
 -Removed the sunxi specific phy functions, instead the id / vbus gpio polling
  has been moved to the phy-sun4i-usb driver and their status is exported
  through extcon for the sunxi-musb glue
 Changes in v3:
 -No changes
 Changes in v4:
 -Do not call regulator_disable in an unbalanced manner when an external vbus
  is present
 ---
  .../devicetree/bindings/phy/sun4i-usb-phy.txt  |  18 +-
  drivers/phy/Kconfig|   1 +
  drivers/phy/phy-sun4i-usb.c| 273 
 -
  3 files changed, 281 insertions(+), 11 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt 
 b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
 index 16528b9..557fa99 100644
 --- a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
 +++ b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
 @@ -23,6 +23,13 @@ Required properties:
* usb1_reset
* usb2_reset for sun4i, sun6i or sun7i
  
 +Optional properties:
 +- usb0_id_det-gpios : gpio phandle for reading the otg id pin value
 +- usb0_vbus_det-gpios : gpio phandle for detecting the presence of usb0 vbus
 +- usb0_vbus-supply : regulator phandle for controller usb0 vbus
 +- usb1_vbus-supply : regulator phandle for controller usb1 vbus
 +- usb2_vbus-supply : regulator phandle for controller usb2 vbus
 +
  Example:
   usbphy: phy@0x01c13400 {
   #phy-cells = 1;
 @@ -32,6 +39,13 @@ Example:
   reg-names = phy_ctrl, pmu1, pmu2;
   clocks = usb_clk 8;
   clock-names = usb_phy;
 - resets = usb_clk 1, usb_clk 2;
 - reset-names = usb1_reset, usb2_reset;
 + resets = usb_clk 0, usb_clk 1, usb_clk 2;
 + reset-names = usb0_reset, usb1_reset, usb2_reset;
 + pinctrl-names = default;
 + pinctrl-0 = usb0_id_detect_pin, usb0_vbus_detect_pin;
 + usb0_id_det-gpios = pio 7 19 GPIO_ACTIVE_HIGH; /* PH19 */
 + usb0_vbus_det-gpios = pio 7 22 GPIO_ACTIVE_HIGH; /* PH22 */
 + usb0_vbus-supply = reg_usb0_vbus;
 + usb1_vbus-supply = reg_usb1_vbus;
 + usb2_vbus-supply = reg_usb2_vbus;
   };
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index a53bd5b..4614fba 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -173,6 +173,7 @@ config PHY_SUN4I_USB
   tristate Allwinner sunxi SoC USB PHY driver
   depends on ARCH_SUNXI  HAS_IOMEM  OF
   depends on RESET_CONTROLLER
 + select EXTCON
   select GENERIC_PHY
   help
 Enable this to support the transceiver that is part of Allwinner
 diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
 index 91c5be4..b45d707 100644
 --- a/drivers/phy/phy-sun4i-usb.c
 +++ b/drivers/phy/phy-sun4i-usb.c
 @@ -1,7 +1,7 @@
  /*
   * Allwinner sun4i USB phy driver
   *
 - * Copyright (C) 2014 Hans de Goede hdego...@redhat.com
 + * Copyright (C) 2014-2015 Hans de Goede hdego...@redhat.com
   *
   * Based on code from
   * Allwinner Technology Co., Ltd. www.allwinnertech.com
 @@ -23,17 +23,23 @@
  
  #include linux/clk.h
  #include linux/err.h
 +#include linux/extcon.h
  #include linux/io.h
 +#include linux/interrupt.h
  #include linux/kernel.h
  #include linux/module.h
  #include linux/mutex.h
  #include linux/of.h
  #include linux/of_address.h
 +#include linux/of_gpio.h
  #include linux/phy/phy.h
  #include linux/phy/phy-sun4i-usb.h
  #include linux/platform_device.h
  #include linux/regulator/consumer.h
  #include linux/reset.h
 +#include linux/workqueue.h
 +
 +#define DRIVER_NAME sun4i-usb-phy
  
  #define REG_ISCR 0x00
  #define REG_PHYCTL   0x04
 @@ -47,6 +53,17 @@
  #define SUNXI_AHB_INCRX_ALIGN_EN BIT(8)
  #define SUNXI_ULPI_BYPASS_EN BIT(0)
  
 +/* ISCR, Interface Status and Control bits */
 +#define ISCR_ID_PULLUP_EN(1  17)
 +#define ISCR_DPDM_PULLUP_EN  (1  16)
 +/* sunxi has the phy id/vbus pins not connected, so we use 

Re: [PATCH v5 0/7] phy-sun4i-usb: Add OTG and newer SoC support

2015-07-15 Thread Kishon Vijay Abraham I
Hi,

On Saturday 13 June 2015 06:07 PM, Hans de Goede wrote:
 Hi Kishon,
 
 Here is a patch series with all my oustanding phy-sun4i-usb changes pending
 for merging into 4.3.
 
 This includes the 5th iteration of the OTG support addition, now with the
 extcon provider support addition split-out into a new patch and ported to
 the extcon API changes which are queued up for 4.2 from :
 
 http://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/log/?h=extcon-next-v4.2
 
 which already merged in GKH's char-misc branch for 4.2, this means that
 this series now depends on those changes.
 
 Other than that this is a resend of some of the other feature addition
 patches I recently send rebased on top of v5 of the OTG support.
 
 Please merge this series for 4.3.

Fixed a couple of checkpatch warnings and merged this to linux-phy tree

WARNING: 'explictly' may be misspelled - perhaps 'explicitly'?
#113: FILE: drivers/phy/phy-sun4i-usb.c:164:
+   /* A33 needs us to set phyctl to 0 explictly */

ERROR: trailing whitespace
#556: FILE: drivers/phy/phy-sun4i-usb.c:461:
+^Istruct sun4i_usb_phy_data *data = $

Cheers
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] USB: pl2303: Rewrite pl2303_encode_baud_rate_divisor

2015-07-15 Thread Michał Pecio
 Looks nice and clean otherwise.
 
 Were you already going to send a v2 or was this version complete?
I didn't intend to change anything. This works fine for me.

Maybe proper rounding would be a nice addition, but I'm not sure if
it's worth the effort. Now we can at least guarantee that the rate is
no lower than requested :)

I'll just fix the style and resend in a moment.
--
To unsubscribe from this list: send the line unsubscribe 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: pl2303: Rewrite pl2303_encode_baud_rate_divisor

2015-07-15 Thread Michał Pecio

This commit fixes the following issues:

1. The 9th bit of buf was believed to be the LSB of divisor's
exponent, but the hardware interprets it as MSB (9th bit) of the
mantissa. The exponent is actually one bit shorter and applies
to base 4, not 2 as previously believed.

2. Loop iterations doubled the exponent instead of incrementing.

3. The exponent wasn't checked for overflow.

4. The function returned requested rate instead of actual rate.

Due to issue #2, the old code deviated from the wrong formula
described in #1 and actually yielded correct rates when divisor
was lower than 4096 by using exponents of 0, 2 or 4 base-2,
interpreted as 0, 1, 2 base-4 with the 9th mantissa bit clear.
However, at 93.75 kbaud or less the rate turned out too slow
due to #2 or too fast due to #2 and #3.

I tested this patch by sending and validating 0x00,0x01,..,0xff
to an FTDI dongle at 234, 987, 2401, 9601, 31415, 115199, 250k,
500k, 750k, 1M, 1.5M, 3M+1 baud. All rates passed.

I also used pv to check speed at some rates unsupported by FTDI:
45 (the lowest possible), 2M, 4M, 5M and 6M-1. Looked sane.

Signed-off-by: Michal Pecio michal.pe...@gmail.com
---
 drivers/usb/serial/pl2303.c | 32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index f5257af..3f9a808 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -362,22 +362,36 @@ static speed_t pl2303_encode_baud_rate_direct(unsigned 
char buf[4],
 static speed_t pl2303_encode_baud_rate_divisor(unsigned char buf[4],
speed_t baud)
 {
-   unsigned int tmp;
+   u32 baseline, mantissa, exponent;
 
/*
 * Apparently the formula is:
-* baudrate = 12M * 32 / (2^buf[1]) / buf[0]
+*   baudrate = 12M * 32 / (mantissa * 4^exponent)
+* where
+*   mantissa = buf[8:0]
+*   exponent = buf[11:9]
 */
-   tmp = 1200 * 32 / baud;
+   baseline = 1200 * 32;
+   mantissa = baseline / baud;
+   exponent = 0;
+   while (mantissa = 512) {
+   if (exponent  7) {
+   mantissa = 2; /* divide by 4 */
+   exponent++;
+   } else {
+   /* Exponent is maxed. Trim mantissa and leave. */
+   mantissa = 511;
+   break;
+   }
+   }
+
buf[3] = 0x80;
buf[2] = 0;
-   buf[1] = (tmp = 256);
-   while (tmp = 256) {
-   tmp = 2;
-   buf[1] = 1;
-   }
-   buf[0] = tmp;
+   buf[1] = exponent  1 | mantissa  8;
+   buf[0] = mantissa  0xff;
 
+   /* Calculate and return the exact baud rate. */
+   baud = (baseline / mantissa)  (exponent  1);
return baud;
 }
 
-- 
2.4.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 v6 1/4] phy-sun4i-usb: Add missing EXPORT_SYMBOL for sun4i_usb_phy_set_squelch_detect

2015-07-15 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 08 July 2015 08:11 PM, Hans de Goede wrote:
 sun4i_usb_phy_set_squelch_detect is used by other code, which may be built
 as a module, so it should be exported.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com

merged this patch to linux-phy tree.

Cheers
Kishon
 ---
 Changes in v6:
 -New patch in v6 of the sunxi musb support series
 ---
  drivers/phy/phy-sun4i-usb.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
 index e17c539..b82aa26 100644
 --- a/drivers/phy/phy-sun4i-usb.c
 +++ b/drivers/phy/phy-sun4i-usb.c
 @@ -212,6 +212,7 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, 
 bool enabled)
  
   sun4i_usb_phy_write(phy, PHY_SQUELCH_DETECT, enabled ? 0 : 2, 2);
  }
 +EXPORT_SYMBOL(sun4i_usb_phy_set_squelch_detect);
  
  static struct phy_ops sun4i_usb_phy_ops = {
   .init   = sun4i_usb_phy_init,
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/8][v2]usb:fsl:otg: Add support to add/remove usb host driver

2015-07-15 Thread Ramneek Mehresh
Add workqueue to add/remove host driver (outside
interrupt context) upon each id change.

Signed-off-by: Li Yang le...@freescale.com
Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
---
 drivers/usb/host/ehci-fsl.c | 83 ++---
 drivers/usb/host/ehci-fsl.h | 20 +++
 2 files changed, 84 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 5352e74..81e4bf5 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -44,6 +44,34 @@
 
 static struct hc_driver __read_mostly fsl_ehci_hc_driver;
 
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+static struct ehci_fsl *hcd_to_ehci_fsl(struct usb_hcd *hcd)
+{
+   return (struct ehci_fsl *)hcd_to_ehci(hcd)-priv;
+}
+
+static void do_change_hcd(struct work_struct *work)
+{
+   struct ehci_fsl *ehci_fsl = container_of(work, struct ehci_fsl,
+   change_hcd_work);
+   struct usb_hcd *hcd = ehci_fsl-hcd;
+   void __iomem *non_ehci = hcd-regs;
+   int retval;
+
+   if (ehci_fsl-hcd_add  !ehci_fsl-have_hcd) {
+   writel(USBMODE_CM_HOST, non_ehci + FSL_SOC_USB_USBMODE);
+   /* host, gadget and otg share same int line */
+   retval = usb_add_hcd(hcd, hcd-irq, IRQF_SHARED);
+   if (retval == 0)
+   ehci_fsl-have_hcd = 1;
+   } else if (!ehci_fsl-hcd_add  ehci_fsl-have_hcd) {
+   usb_remove_hcd(hcd);
+   ehci_fsl-have_hcd = 0;
+   }
+}
+#endif
+
+
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
@@ -136,11 +164,16 @@ static int fsl_ehci_drv_probe(struct platform_device 
*pdev)
goto err2;
device_wakeup_enable(hcd-self.controller);
 
-#ifdef CONFIG_USB_OTG
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
if (pdata-operating_mode == FSL_USB2_DR_OTG) {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
 
+   ehci_fsl-hcd = hcd;
hcd-usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
+
+   INIT_WORK(ehci_fsl-change_hcd_work, do_change_hcd);
+
dev_dbg(pdev-dev, hcd=0x%p  ehci=0x%p, phy=0x%p\n,
hcd, ehci, hcd-usb_phy);
 
@@ -354,15 +387,6 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
return retval;
 }
 
-struct ehci_fsl {
-   struct ehci_hcd ehci;
-
-#ifdef CONFIG_PM
-   /* Saved USB PHY settings, need to restore after deep sleep. */
-   u32 usb_ctrl;
-#endif
-};
-
 #ifdef CONFIG_PM
 
 #ifdef CONFIG_PPC_MPC512x
@@ -510,24 +534,31 @@ static inline int ehci_fsl_mpc512x_drv_resume(struct 
device *dev)
 }
 #endif /* CONFIG_PPC_MPC512x */
 
-static struct ehci_fsl *hcd_to_ehci_fsl(struct usb_hcd *hcd)
-{
-   struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-
-   return container_of(ehci, struct ehci_fsl, ehci);
-}
-
 static int ehci_fsl_drv_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
-   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
void __iomem *non_ehci = hcd-regs;
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
+   struct usb_bus host = hcd-self;
+#endif
+
 
if (of_device_is_compatible(dev-parent-of_node,
fsl,mpc5121-usb2-dr)) {
return ehci_fsl_mpc512x_drv_suspend(dev);
}
 
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+   if (host.is_otg) {
+   /* remove hcd */
+   ehci_fsl-hcd_add = 0;
+   schedule_work(ehci_fsl-change_hcd_work);
+   host.is_otg = 0;
+   return 0;
+   }
+#endif
+
ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd),
device_may_wakeup(dev));
if (!fsl_deep_sleep())
@@ -540,15 +571,29 @@ static int ehci_fsl_drv_suspend(struct device *dev)
 static int ehci_fsl_drv_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
-   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
void __iomem *non_ehci = hcd-regs;
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
+   struct usb_bus host = hcd-self;
+#endif
 
if (of_device_is_compatible(dev-parent-of_node,
fsl,mpc5121-usb2-dr)) {
return ehci_fsl_mpc512x_drv_resume(dev);
}
 
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+   if (host.is_otg) {
+   /* add hcd */
+   ehci_fsl-hcd_add = 1;
+

Re: [PATCH] USB: pl2303: Rewrite pl2303_encode_baud_rate_divisor

2015-07-15 Thread Johan Hovold
[ Please try to avoid top-posting. ]

On Tue, Jul 14, 2015 at 07:22:01PM +0200, Michał Pecio wrote:
 I managed to reproduce this old issue, both on vanilla v4.1.1 and with
 my patch, IF and ONLY if I reverted commit 623c82633 by changing:
 
 -   if (!old_termios || memcmp(buf, priv-line_settings, 7)) {
 ret = pl2303_set_line_request(port, buf);
 if (!ret)
 memcpy(priv-line_settings, buf, 7);
 -   }

That was expected. Thanks for verifying.

 Bottom line: my patch seems safe and fixes custom baud rates below 94k,
 which are completely screwed without it.
 
 The only thing I could imagine going wrong is chips which actually
 interpret baud rate settings the way described in the old comment.
 
 This definitely isn't my HX (rev A) nor my other HX knockoff.
 
 This also isn't whatever chips Frank Schäfer used during 57ce61aad748
 development.
 
 Finally, this probably isn't this comment author's chip either. I bet
 he wrote the comment and then randomly tweaked the code until it started
 working with actual hardware without realizing that the comment is wrong
 and doesn't describe the code anymore.

Sounds plausible. I'll take at look at your patch.

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


Re: [PATCH v4 1/2] phy-sun4i-usb: Add full support for usb0 phy / OTG

2015-07-15 Thread Kishon Vijay Abraham I


On Wednesday 15 July 2015 04:25 PM, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Sunday 31 May 2015 09:40 PM, Hans de Goede wrote:
 The usb0 phy is connected to an OTG controller, and as such needs some 
 special
 handling:

 1) It allows explicit control over the pullups, enable these on phy_init and
 disable them on phy_exit.

 2) It has bits to signal id and vbus detect to the musb-core, add support for
 for monitoring id and vbus detect gpio-s for use in dual role mode, and set
 these bits to the correct values for operating in host only mode when no
 gpios are specified in the devicetree.

 3) When in dual role mode the musb sunxi glue needs to know if the a host or
 device cable is plugged in, so when in dual role mode register an extcon.

 While updating the devicetree binding documentation also add documentation
 for the sofar undocumented usage of regulators for vbus for all 3 phys.
 
 merged this to linux-phy tree.

Please ignore. I merged the v5 of the patch series.

Cheers
Kishon
 
 Cheers
 Kishon

 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
 Changes in v2:
 -Removed the sunxi specific phy functions, instead the id / vbus gpio polling
  has been moved to the phy-sun4i-usb driver and their status is exported
  through extcon for the sunxi-musb glue
 Changes in v3:
 -No changes
 Changes in v4:
 -Do not call regulator_disable in an unbalanced manner when an external vbus
  is present
 ---
  .../devicetree/bindings/phy/sun4i-usb-phy.txt  |  18 +-
  drivers/phy/Kconfig|   1 +
  drivers/phy/phy-sun4i-usb.c| 273 
 -
  3 files changed, 281 insertions(+), 11 deletions(-)

 diff --git a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt 
 b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
 index 16528b9..557fa99 100644
 --- a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
 +++ b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
 @@ -23,6 +23,13 @@ Required properties:
* usb1_reset
* usb2_reset for sun4i, sun6i or sun7i
  
 +Optional properties:
 +- usb0_id_det-gpios : gpio phandle for reading the otg id pin value
 +- usb0_vbus_det-gpios : gpio phandle for detecting the presence of usb0 vbus
 +- usb0_vbus-supply : regulator phandle for controller usb0 vbus
 +- usb1_vbus-supply : regulator phandle for controller usb1 vbus
 +- usb2_vbus-supply : regulator phandle for controller usb2 vbus
 +
  Example:
  usbphy: phy@0x01c13400 {
  #phy-cells = 1;
 @@ -32,6 +39,13 @@ Example:
  reg-names = phy_ctrl, pmu1, pmu2;
  clocks = usb_clk 8;
  clock-names = usb_phy;
 -resets = usb_clk 1, usb_clk 2;
 -reset-names = usb1_reset, usb2_reset;
 +resets = usb_clk 0, usb_clk 1, usb_clk 2;
 +reset-names = usb0_reset, usb1_reset, usb2_reset;
 +pinctrl-names = default;
 +pinctrl-0 = usb0_id_detect_pin, usb0_vbus_detect_pin;
 +usb0_id_det-gpios = pio 7 19 GPIO_ACTIVE_HIGH; /* PH19 */
 +usb0_vbus_det-gpios = pio 7 22 GPIO_ACTIVE_HIGH; /* PH22 */
 +usb0_vbus-supply = reg_usb0_vbus;
 +usb1_vbus-supply = reg_usb1_vbus;
 +usb2_vbus-supply = reg_usb2_vbus;
  };
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index a53bd5b..4614fba 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -173,6 +173,7 @@ config PHY_SUN4I_USB
  tristate Allwinner sunxi SoC USB PHY driver
  depends on ARCH_SUNXI  HAS_IOMEM  OF
  depends on RESET_CONTROLLER
 +select EXTCON
  select GENERIC_PHY
  help
Enable this to support the transceiver that is part of Allwinner
 diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
 index 91c5be4..b45d707 100644
 --- a/drivers/phy/phy-sun4i-usb.c
 +++ b/drivers/phy/phy-sun4i-usb.c
 @@ -1,7 +1,7 @@
  /*
   * Allwinner sun4i USB phy driver
   *
 - * Copyright (C) 2014 Hans de Goede hdego...@redhat.com
 + * Copyright (C) 2014-2015 Hans de Goede hdego...@redhat.com
   *
   * Based on code from
   * Allwinner Technology Co., Ltd. www.allwinnertech.com
 @@ -23,17 +23,23 @@
  
  #include linux/clk.h
  #include linux/err.h
 +#include linux/extcon.h
  #include linux/io.h
 +#include linux/interrupt.h
  #include linux/kernel.h
  #include linux/module.h
  #include linux/mutex.h
  #include linux/of.h
  #include linux/of_address.h
 +#include linux/of_gpio.h
  #include linux/phy/phy.h
  #include linux/phy/phy-sun4i-usb.h
  #include linux/platform_device.h
  #include linux/regulator/consumer.h
  #include linux/reset.h
 +#include linux/workqueue.h
 +
 +#define DRIVER_NAME sun4i-usb-phy
  
  #define REG_ISCR0x00
  #define REG_PHYCTL  0x04
 @@ -47,6 +53,17 @@
  #define SUNXI_AHB_INCRX_ALIGN_ENBIT(8)
  #define SUNXI_ULPI_BYPASS_ENBIT(0)
  
 +/* ISCR, Interface Status and Control bits */
 +#define 

Re: [PATCH v4 0/2] USB OTG PHY driver for NXP LPC18xx family

2015-07-15 Thread Joachim Eastwood
On 15 July 2015 at 12:50, Kishon Vijay Abraham I kis...@ti.com wrote:


 On Friday 10 July 2015 02:18 AM, Joachim Eastwood wrote:
 This patch set adds support for the internal USB OTG PHY found
 on NXP LPC18xx and LPC43xx devices. Driver takes care of
 enabling the PHY and setting the clock rate which is need for
 USB0 support on this platform.

 This version address moves the dt node under the creg syscon
 and rebases the patch set on 4.2-rc1.

 merged this to linux-phy tree.

Thanks, Kishon.

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


Re: [PATCH v4 0/2] USB OTG PHY driver for NXP LPC18xx family

2015-07-15 Thread Kishon Vijay Abraham I


On Friday 10 July 2015 02:18 AM, Joachim Eastwood wrote:
 This patch set adds support for the internal USB OTG PHY found
 on NXP LPC18xx and LPC43xx devices. Driver takes care of
 enabling the PHY and setting the clock rate which is need for
 USB0 support on this platform.
 
 This version address moves the dt node under the creg syscon
 and rebases the patch set on 4.2-rc1.

merged this to linux-phy tree.

Cheers
Kishon

 
 Changes in v4:
  - rebase on 4.2-rc1
  - move dt node under creg where the control reg is
 
 Changes in v3:
  - depend on MFD_SYSCON
 
 Changes in v2:
  - use PTR_ERR_OR_ZERO in phy driver
  - rename binding doc
  - update doc commit message
 
 Joachim Eastwood (2):
   phy: add lpc18xx usb otg phy driver
   phy: dt bindings: add NXP LPC18xx/43xx USB OTG PHY bindings
 
  .../bindings/phy/phy-lpc18xx-usb-otg.txt   |  26 
  drivers/phy/Kconfig|  11 ++
  drivers/phy/Makefile   |   1 +
  drivers/phy/phy-lpc18xx-usb-otg.c  | 143 
 +
  4 files changed, 181 insertions(+)
  create mode 100644 
 Documentation/devicetree/bindings/phy/phy-lpc18xx-usb-otg.txt
  create mode 100644 drivers/phy/phy-lpc18xx-usb-otg.c
 
--
To unsubscribe from this list: send the line unsubscribe 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/8][v2]usb:fsl:otg: Add controller version based ULPI and UTMI phy

2015-07-15 Thread Ramneek Mehresh
Add controller version based ULPI and UTMI phy
initialization for otg driver.

Signed-off-by: Shengzhou Liu shengzhou@freescale.com
Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
Reviewed-by: Fleming Andrew-AFLEMING aflem...@freescale.com
Tested-by: Fleming Andrew-AFLEMING aflem...@freescale.com
---
 drivers/usb/phy/phy-fsl-usb.c | 20 
 drivers/usb/phy/phy-fsl-usb.h |  7 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 94eb292..4e58aee 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -923,12 +923,32 @@ int usb_otg_start(struct platform_device *pdev)
temp = ~(PORTSC_PHY_TYPE_SEL | PORTSC_PTW);
switch (pdata-phy_mode) {
case FSL_USB2_PHY_ULPI:
+   if (pdata-controller_ver) {
+   /* controller version 1.6 or above */
+   setbits32(p_otg-dr_mem_map-control,
+   USB_CTRL_ULPI_PHY_CLK_SEL);
+   /*
+* Due to controller issue of PHY_CLK_VALID in ULPI
+* mode, set USB_CTRL_USB_EN before checking
+* PHY_CLK_VALID, otherwise PHY_CLK_VALID doesn't work
+*/
+   clrsetbits_be32(p_otg-dr_mem_map-control,
+   USB_CTRL_UTMI_PHY_EN, USB_CTRL_IOENB);
+   }
temp |= PORTSC_PTS_ULPI;
break;
case FSL_USB2_PHY_UTMI_WIDE:
temp |= PORTSC_PTW_16BIT;
/* fall through */
case FSL_USB2_PHY_UTMI:
+   if (pdata-controller_ver) {
+   /* controller version 1.6 or above */
+   setbits32(p_otg-dr_mem_map-control,
+   USB_CTRL_UTMI_PHY_EN);
+   /* Delay for UTMI PHY CLK to become stable - 10ms */
+   mdelay(FSL_UTMI_PHY_DLY);
+   }
+   setbits32(p_otg-dr_mem_map-control, USB_CTRL_UTMI_PHY_EN);
temp |= PORTSC_PTS_UTMI;
/* fall through */
default:
diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h
index 2314995..4a78fb3 100644
--- a/drivers/usb/phy/phy-fsl-usb.h
+++ b/drivers/usb/phy/phy-fsl-usb.h
@@ -199,6 +199,13 @@
 /* control Register Bit Masks */
 #define  USB_CTRL_IOENB(0x12)
 #define  USB_CTRL_ULPI_INT0EN  (0x10)
+#define  USB_CTRL_WU_INT_EN(0x11)
+#define  USB_CTRL_LINE_STATE_FILTER__EN(0x13)
+#define  USB_CTRL_KEEP_OTG_ON  (0x14)
+#define  USB_CTRL_OTG_PORT (0x15)
+#define  USB_CTRL_PLL_RESET(0x18)
+#define  USB_CTRL_UTMI_PHY_EN  (0x19)
+#define  USB_CTRL_ULPI_PHY_CLK_SEL (0x110)
 
 /* BCSR5 */
 #define BCSR5_INT_USB  (0x02)
-- 
1.8.3.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 6/8][v2]usb:fsl:otg: Combine host/gadget start/resume for ID change

2015-07-15 Thread Ramneek Mehresh
Make call to fsl_otg_event for each id change even.

Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
Reviewed-by: Fleming Andrew-AFLEMING aflem...@freescale.com
Tested-by: Fleming Andrew-AFLEMING aflem...@freescale.com
---
 drivers/usb/phy/phy-fsl-usb.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 3b8a9e5..689516d 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -733,6 +733,7 @@ irqreturn_t fsl_otg_isr(int irq, void *dev_id)
 {
struct otg_fsm *fsm = ((struct fsl_otg *)dev_id)-fsm;
struct usb_otg *otg = ((struct fsl_otg *)dev_id)-phy.otg;
+   struct fsl_otg *otg_dev = dev_id;
u32 otg_int_src, otg_sc;
 
otg_sc = fsl_readl(usb_dr_regs-otgsc);
@@ -762,18 +763,8 @@ irqreturn_t fsl_otg_isr(int irq, void *dev_id)
otg-gadget-is_a_peripheral = !fsm-id;
VDBG(ID int (ID is %d)\n, fsm-id);
 
-   if (fsm-id) {  /* switch to gadget */
-   schedule_delayed_work(
-   ((struct fsl_otg *)dev_id)-otg_event,
-   100);
-   } else {/* switch to host */
-   cancel_delayed_work(
-   ((struct fsl_otg *)dev_id)-
-   otg_event);
-   fsl_otg_start_gadget(fsm, 0);
-   otg_drv_vbus(fsm, 1);
-   fsl_otg_start_host(fsm, 1);
-   }
+   schedule_delayed_work(otg_dev-otg_event, 100);
+
return IRQ_HANDLED;
}
}
-- 
1.8.3.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 v6 1/4] phy-sun4i-usb: Add missing EXPORT_SYMBOL for sun4i_usb_phy_set_squelch_detect

2015-07-15 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 08 July 2015 08:11 PM, Hans de Goede wrote:
 sun4i_usb_phy_set_squelch_detect is used by other code, which may be built
 as a module, so it should be exported.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
 Changes in v6:
 -New patch in v6 of the sunxi musb support series
 ---
  drivers/phy/phy-sun4i-usb.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
 index e17c539..b82aa26 100644
 --- a/drivers/phy/phy-sun4i-usb.c
 +++ b/drivers/phy/phy-sun4i-usb.c
 @@ -212,6 +212,7 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, 
 bool enabled)
  
   sun4i_usb_phy_write(phy, PHY_SQUELCH_DETECT, enabled ? 0 : 2, 2);
  }
 +EXPORT_SYMBOL(sun4i_usb_phy_set_squelch_detect);

EXPORT_SYMBOL_GPL?

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


[PATCH v4 3/3] USB / PM: Allow USB devices to remain runtime-suspended when sleeping

2015-07-15 Thread Tomeu Vizoso
Have dev_pm_ops.prepare return 1 for USB devices and ports so that USB
devices can remain runtime-suspended when the system goes to a sleep
state, if their wakeup state is correct and they have runtime PM enabled.

Signed-off-by: Tomeu Vizoso tomeu.viz...@collabora.com
---

 drivers/usb/core/port.c |  6 ++
 drivers/usb/core/usb.c  | 11 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 210618319f10..f49707d73b5a 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -168,12 +168,18 @@ static int usb_port_runtime_suspend(struct device *dev)
 
return retval;
 }
+
+static int usb_port_prepare(struct device *dev)
+{
+   return 1;
+}
 #endif
 
 static const struct dev_pm_ops usb_port_pm_ops = {
 #ifdef CONFIG_PM
.runtime_suspend =  usb_port_runtime_suspend,
.runtime_resume =   usb_port_runtime_resume,
+   .prepare =  usb_port_prepare,
 #endif
 };
 
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 8d5b2f4113cd..cf4dde11db1c 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -316,7 +316,16 @@ static int usb_dev_uevent(struct device *dev, struct 
kobj_uevent_env *env)
 
 static int usb_dev_prepare(struct device *dev)
 {
-   return 0;   /* Implement eventually? */
+   struct usb_device *udev = to_usb_device(dev);
+
+   if (!pm_runtime_enabled(dev))
+   return 0;
+
+   /* Return 0 if the current wakeup setting is wrong, otherwise 1 */
+   if (udev-do_remote_wakeup != device_may_wakeup(dev))
+   return 0;
+
+   return 1;
 }
 
 static void usb_dev_complete(struct device *dev)
-- 
2.4.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


[PATCH v4 0/3]

2015-07-15 Thread Tomeu Vizoso
Hi,

this is v4 of an attempt to make easier for devices to remain in runtime
PM when the system ges to sleep, mainly to reduce the time spent
resuming devices.

In this version there's a patch from Alan that relaxes the conditions
that allow a device to go directly to the complete phase, thus allowing
its ancestors to do the same.

Also, we interpret the absence of all PM callback implementations as
being safe to do direct_complete as well.

With these changes, a uvcvideo device (for example) stays in runtime
suspend when the system goes to sleep and is left in that state when the
system resumes, not delaying it unnecessarily.

Thanks,

Tomeu


Alan Stern (1):
  PM / sleep: Allow devices without runtime PM to do direct-complete

Tomeu Vizoso (2):
  PM / sleep: Go direct_complete if driver has no callbacks
  USB / PM: Allow USB devices to remain runtime-suspended when sleeping

 Documentation/power/devices.txt|  7 +++
 Documentation/power/runtime_pm.txt |  4 
 drivers/base/power/main.c  | 19 ++-
 drivers/usb/core/port.c|  6 ++
 drivers/usb/core/usb.c | 11 ++-
 include/linux/pm_runtime.h |  6 --
 6 files changed, 41 insertions(+), 12 deletions(-)

-- 
2.4.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: [PATCH] usb: dwc3: core: avoid NULL pointer dereference

2015-07-15 Thread santosh shilimkar

Felipe,

On 7/15/2015 2:56 PM, Murali Karicheri wrote:

On 07/02/2015 06:34 PM, Felipe Balbi wrote:

commit 3e10a2ce98d1 (usb: dwc3: add hsphy_interface
property) introduced a possible NULL pointer
dereference because dwc-hsphy_interface can be
NULL.

In order to fix it, all we have to do is guard
strncmp() against a NULL argument.

Fixes: 3e10a2ce98d1 (usb: dwc3: add hsphy_interface property)
Tested-by: Murali Karicheri m-kariche...@ti.com
Signed-off-by: Felipe Balbi ba...@ti.com
---
  drivers/usb/dwc3/core.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 5c110d8e293b..ff5773c66b84 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -446,10 +446,12 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
  /* Select the HS PHY interface */
  switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc-hwparams.hwparams3)) {
  case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
-if (!strncmp(dwc-hsphy_interface, utmi, 4)) {
+if (dwc-hsphy_interface 
+!strncmp(dwc-hsphy_interface, utmi, 4)) {
  reg = ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
  break;
-} else if (!strncmp(dwc-hsphy_interface, ulpi, 4)) {
+} else if (dwc-hsphy_interface 
+!strncmp(dwc-hsphy_interface, ulpi, 4)) {
  reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
  dwc3_writel(dwc-regs, DWC3_GUSB2PHYCFG(0), reg);
  } else {


Dear Maintainer,

This is patch is urgently required to be applied to master for v4.2 for
fixing a crash seen on keystone based boards (K2HK, K2L and K2E EVMs).
Please merge it asap.


I assume you are you sending this one for rc's ?
Feel free to use my ack if you need one.
Acked-by: Santosh Shilimkar ssant...@kernel.org
--
To unsubscribe from this list: send the line unsubscribe 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: detect what type of USB it is connected to

2015-07-15 Thread James
Alan Stern stern@... writes:

 
 On Sat, 11 Jul 2015, James wrote:
 
  I have an external drive that has an activity LED.
  It would be nice if it told me if it was connected to a USB2 or USB3 port.
  Is it possible for devices to know what they are connected to?
 
 How would you expect the drive to tell you what sort of port it is 
 connected to?  By shining an LED of a different color?  Green for USB-2 
 and blue for USB-3, for example?
Yes.
The device could have different coloured LEDs depending on the speed it is
transferring data.

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


Re: [PATCH v4 3/3] USB / PM: Allow USB devices to remain runtime-suspended when sleeping

2015-07-15 Thread Rafael J. Wysocki
On Wednesday, July 15, 2015 02:40:08 PM Tomeu Vizoso wrote:
 Have dev_pm_ops.prepare return 1 for USB devices and ports so that USB
 devices can remain runtime-suspended when the system goes to a sleep
 state, if their wakeup state is correct and they have runtime PM enabled.
 
 Signed-off-by: Tomeu Vizoso tomeu.viz...@collabora.com
 ---
 
  drivers/usb/core/port.c |  6 ++
  drivers/usb/core/usb.c  | 11 ++-
  2 files changed, 16 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
 index 210618319f10..f49707d73b5a 100644
 --- a/drivers/usb/core/port.c
 +++ b/drivers/usb/core/port.c
 @@ -168,12 +168,18 @@ static int usb_port_runtime_suspend(struct device *dev)
  
   return retval;
  }
 +
 +static int usb_port_prepare(struct device *dev)
 +{
 + return 1;
 +}
  #endif
  
  static const struct dev_pm_ops usb_port_pm_ops = {
  #ifdef CONFIG_PM
   .runtime_suspend =  usb_port_runtime_suspend,
   .runtime_resume =   usb_port_runtime_resume,
 + .prepare =  usb_port_prepare,
  #endif
  };
  
 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
 index 8d5b2f4113cd..cf4dde11db1c 100644
 --- a/drivers/usb/core/usb.c
 +++ b/drivers/usb/core/usb.c
 @@ -316,7 +316,16 @@ static int usb_dev_uevent(struct device *dev, struct 
 kobj_uevent_env *env)
  
  static int usb_dev_prepare(struct device *dev)
  {
 - return 0;   /* Implement eventually? */
 + struct usb_device *udev = to_usb_device(dev);
 +
 + if (!pm_runtime_enabled(dev))

Why just enabled and not suspended?

 + return 0;
 +
 + /* Return 0 if the current wakeup setting is wrong, otherwise 1 */
 + if (udev-do_remote_wakeup != device_may_wakeup(dev))
 + return 0;
 +
 + return 1;
  }
  
  static void usb_dev_complete(struct device *dev)
 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: dwc3: core: avoid NULL pointer dereference

2015-07-15 Thread Murali Karicheri

On 07/02/2015 06:34 PM, Felipe Balbi wrote:

commit 3e10a2ce98d1 (usb: dwc3: add hsphy_interface
property) introduced a possible NULL pointer
dereference because dwc-hsphy_interface can be
NULL.

In order to fix it, all we have to do is guard
strncmp() against a NULL argument.

Fixes: 3e10a2ce98d1 (usb: dwc3: add hsphy_interface property)
Tested-by: Murali Karicheri m-kariche...@ti.com
Signed-off-by: Felipe Balbi ba...@ti.com
---
  drivers/usb/dwc3/core.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 5c110d8e293b..ff5773c66b84 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -446,10 +446,12 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
/* Select the HS PHY interface */
switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc-hwparams.hwparams3)) {
case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
-   if (!strncmp(dwc-hsphy_interface, utmi, 4)) {
+   if (dwc-hsphy_interface 
+   !strncmp(dwc-hsphy_interface, utmi, 4)) {
reg = ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
break;
-   } else if (!strncmp(dwc-hsphy_interface, ulpi, 4)) {
+   } else if (dwc-hsphy_interface 
+   !strncmp(dwc-hsphy_interface, ulpi, 4)) {
reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
dwc3_writel(dwc-regs, DWC3_GUSB2PHYCFG(0), reg);
} else {


Dear Maintainer,

This is patch is urgently required to be applied to master for v4.2 for 
fixing a crash seen on keystone based boards (K2HK, K2L and K2E EVMs). 
Please merge it asap.


--
Murali Karicheri
Linux Kernel, Keystone
--
To unsubscribe from this list: send the line unsubscribe 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/8][v2]usb:fsl:otg: Signal host drv when host is otg

2015-07-15 Thread Ramneek Mehresh
Set is_otg boolean flag to signal host driver when host
is running in context of otg host suspend/resume.

Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
---
 drivers/usb/phy/phy-fsl-usb.c | 7 ++-
 include/linux/usb.h   | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 4e58aee..815c22c 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -463,6 +463,7 @@ void otg_reset_controller(void)
 int fsl_otg_start_host(struct otg_fsm *fsm, int on)
 {
struct usb_otg *otg = fsm-otg;
+   struct usb_bus *host = otg-host;
struct device *dev;
struct fsl_otg *otg_dev =
container_of(otg-usb_phy, struct fsl_otg, phy);
@@ -485,6 +486,7 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
else {
otg_reset_controller();
VDBG(host on..\n);
+   host-is_otg = 1;
if (dev-driver-pm  dev-driver-pm-resume) {
retval = dev-driver-pm-resume(dev);
if (fsm-id) {
@@ -510,8 +512,11 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
else {
VDBG(host off..\n);
if (dev  dev-driver) {
-   if (dev-driver-pm  dev-driver-pm-suspend)
+   if (dev-driver-pm 
+   dev-driver-pm-suspend) {
+   host-is_otg = 1;
retval = dev-driver-pm-suspend(dev);
+   }
if (fsm-id)
/* default-b */
fsl_otg_drv_vbus(fsm, 0);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 447fe29..2208822 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -355,6 +355,7 @@ struct usb_bus {
 * for control transfers?
 */
u8 otg_port;/* 0, or number of OTG/HNP port */
+   unsigned is_otg:1;  /* true when host is also otg */
unsigned is_b_host:1;   /* true during some HNP roleswitches */
unsigned b_hnp_enable:1;/* OTG: did A-Host enable HNP? */
unsigned no_stop_on_short:1;/*
-- 
1.8.3.1

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


[PATCH 7/8][v2]usb:fsl:otg: Remove host drv upon otg bring-up

2015-07-15 Thread Ramneek Mehresh
Change have_hcd variable to remove/suspend host driver on
completion of otg initialization for otg auto detect.

Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
Reviewed-by: Li Yang-R58472 le...@freescale.com
Reviewed-by: Fleming Andrew-AFLEMING aflem...@freescale.com
Tested-by: Fleming Andrew-AFLEMING aflem...@freescale.com
---
 drivers/usb/host/ehci-fsl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 81e4bf5..daca957 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -189,6 +189,8 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
retval = -ENODEV;
goto err2;
}
+
+   ehci_fsl-have_hcd = 1;
}
 #endif
return retval;
-- 
1.8.3.1

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


[PATCH 1/8][v2]usb:fsl:otg: Make fsl otg driver as tristate

2015-07-15 Thread Ramneek Mehresh
Provide option to load fsl otg driver as loadable module.

Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
---
 drivers/usb/phy/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 869c0cfcad..8a09267 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -19,7 +19,7 @@ config AB8500_USB
  in host mode, low speed.
 
 config FSL_USB2_OTG
-   bool Freescale USB OTG Transceiver Driver
+   tristate Freescale USB OTG Transceiver Driver
depends on USB_EHCI_FSL  USB_FSL_USB2  USB_OTG_FSM  PM
select USB_OTG
select USB_PHY
-- 
1.8.3.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 5/8][v2]usb:fsl:otg: Modify otg_event to start host drv

2015-07-15 Thread Ramneek Mehresh
Add mechanism to start host driver from inside fsl_otg_even upon
each id change interrupt.

Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
Reviewed-by: Fleming Andrew-AFLEMING aflem...@freescale.com
Tested-by: Fleming Andrew-AFLEMING aflem...@freescale.com
---
 drivers/usb/phy/phy-fsl-usb.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 815c22c..3b8a9e5 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -677,6 +677,10 @@ static void fsl_otg_event(struct work_struct *work)
fsl_otg_start_host(fsm, 0);
otg_drv_vbus(fsm, 0);
fsl_otg_start_gadget(fsm, 1);
+   } else {
+   fsl_otg_start_gadget(fsm, 0);
+   otg_drv_vbus(fsm, 1);
+   fsl_otg_start_host(fsm, 1);
}
 }
 
-- 
1.8.3.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 0/8][v2]Add OTG support for FSL socs

2015-07-15 Thread Ramneek Mehresh
Add support for otg for all freescale socs having internal
usb phy. 


Ramneek Mehresh (8):
  usb:fsl:otg: Make fsl otg driver as tristate
  usb:fsl:otg: Add controller version based ULPI and UTMI phy
  usb:fsl:otg: Add support to add/remove usb host driver
  usb:fsl:otg: Signal host drv when host is otg
  usb:fsl:otg: Modify otg_event to start host drv
  usb:fsl:otg: Combine host/gadget start/resume for ID change
  usb:fsl:otg: Remove host drv upon otg bring-up
  usb:fsl:otg: Add host-gadget drv sync delay

 drivers/usb/host/ehci-fsl.c   | 85 +--
 drivers/usb/host/ehci-fsl.h   | 20 ++
 drivers/usb/phy/Kconfig   |  2 +-
 drivers/usb/phy/phy-fsl-usb.c | 58 ++---
 drivers/usb/phy/phy-fsl-usb.h |  7 
 include/linux/usb.h   |  1 +
 6 files changed, 139 insertions(+), 34 deletions(-)

--
Changes for v2:
- moved struct ehci_fsl out of ehci-fsl.c
  to ehci-fsl.h
- made struct ehci_fsl private of struct ehci_hcd
1.8.3.1

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


[PATCH v3 28/46] usb: gadget: pxa27x_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/pxa27x_udc.h | 33 ++---
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h 
b/drivers/usb/gadget/udc/pxa27x_udc.h
index 11e1423..ded058c 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.h
+++ b/drivers/usb/gadget/udc/pxa27x_udc.h
@@ -234,25 +234,28 @@
 /*
  * Endpoint definition helpers
  */
-#define USB_EP_DEF(addr, bname, dir, type, maxpkt) \
-{ .usb_ep = { .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, }, \
+#define USB_EP_DEF(addr, bname, dir, type, maxpkt, ctype, cdir) \
+{ .usb_ep = {  .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, \
+   .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## ctype, \
+   USB_EP_CAPS_DIR_ ## cdir), }, \
   .desc = {.bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \
-   .bmAttributes = type, \
+   .bmAttributes = USB_ENDPOINT_XFER_ ## type, \
.wMaxPacketSize = maxpkt, }, \
   .dev = memory \
 }
-#define USB_EP_BULK(addr, bname, dir) \
-  USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE)
-#define USB_EP_ISO(addr, bname, dir) \
-  USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE)
-#define USB_EP_INT(addr, bname, dir) \
-  USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE)
-#define USB_EP_IN_BULK(n)  USB_EP_BULK(n, ep #n in-bulk, 1)
-#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0)
-#define USB_EP_IN_ISO(n)   USB_EP_ISO(n,  ep #n in-iso, 1)
-#define USB_EP_OUT_ISO(n)  USB_EP_ISO(n,  ep #n out-iso, 0)
-#define USB_EP_IN_INT(n)   USB_EP_INT(n,  ep #n in-int, 1)
-#define USB_EP_CTRLUSB_EP_DEF(0,  ep0, 0, 0, EP0_FIFO_SIZE)
+#define USB_EP_BULK(addr, bname, dir, cdir) \
+   USB_EP_DEF(addr, bname, dir, BULK, BULK_FIFO_SIZE, BULK, cdir)
+#define USB_EP_ISO(addr, bname, dir, cdir) \
+   USB_EP_DEF(addr, bname, dir, ISOC, ISO_FIFO_SIZE, ISO, cdir)
+#define USB_EP_INT(addr, bname, dir, cdir) \
+   USB_EP_DEF(addr, bname, dir, INT, INT_FIFO_SIZE, INT, cdir)
+#define USB_EP_IN_BULK(n)  USB_EP_BULK(n, ep #n in-bulk, 1, IN)
+#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0, OUT)
+#define USB_EP_IN_ISO(n)   USB_EP_ISO(n,  ep #n in-iso, 1, IN)
+#define USB_EP_OUT_ISO(n)  USB_EP_ISO(n,  ep #n out-iso, 0, OUT)
+#define USB_EP_IN_INT(n)   USB_EP_INT(n,  ep #n in-int, 1, IN)
+#define USB_EP_CTRLUSB_EP_DEF(0,  ep0, 0, CONTROL, \
+  EP0_FIFO_SIZE, CONTROL, ALL)
 
 #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \
 { \
-- 
1.9.1

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


[PATCH v3 34/46] usb: musb: gadget: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/musb/musb_gadget.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 625d482f..043248a 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1729,6 +1729,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, 
u8 epnum, int is_in)
INIT_LIST_HEAD(ep-end_point.ep_list);
if (!epnum) {
usb_ep_set_maxpacket_limit(ep-end_point, 64);
+   ep-end_point.caps.type_control = true;
ep-end_point.ops = musb_g_ep0_ops;
musb-g.ep0 = ep-end_point;
} else {
@@ -1736,9 +1737,20 @@ init_peripheral_ep(struct musb *musb, struct musb_ep 
*ep, u8 epnum, int is_in)
usb_ep_set_maxpacket_limit(ep-end_point, 
hw_ep-max_packet_sz_tx);
else
usb_ep_set_maxpacket_limit(ep-end_point, 
hw_ep-max_packet_sz_rx);
+   ep-end_point.caps.type_iso = true;
+   ep-end_point.caps.type_bulk = true;
+   ep-end_point.caps.type_int = true;
ep-end_point.ops = musb_ep_ops;
list_add_tail(ep-end_point.ep_list, musb-g.ep_list);
}
+
+   if (!epnum || hw_ep-is_shared_fifo) {
+   ep-end_point.caps.dir_in = true;
+   ep-end_point.caps.dir_out = true;
+   } else if (is_in)
+   ep-end_point.caps.dir_in = true;
+   else
+   ep-end_point.caps.dir_out = true;
 }
 
 /*
-- 
1.9.1

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


[PATCH v3 33/46] usb: isp1760: udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/isp1760/isp1760-udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/isp1760/isp1760-udc.c 
b/drivers/usb/isp1760/isp1760-udc.c
index 3699962..1c3d0fd 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -1383,13 +1383,24 @@ static void isp1760_udc_init_eps(struct isp1760_udc 
*udc)
 */
if (ep_num == 0) {
usb_ep_set_maxpacket_limit(ep-ep, 64);
+   ep-ep.caps.type_control = true;
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
ep-maxpacket = 64;
udc-gadget.ep0 = ep-ep;
} else {
usb_ep_set_maxpacket_limit(ep-ep, 512);
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
ep-maxpacket = 0;
list_add_tail(ep-ep.ep_list, udc-gadget.ep_list);
}
+
+   if (is_in)
+   ep-ep.caps.dir_in = true;
+   else
+   ep-ep.caps.dir_out = true;
}
 }
 
-- 
1.9.1

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


[PATCH v3 26/46] usb: gadget: pch_ud: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/pch_udc.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index 613547f..cc8fb3c 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -2895,11 +2895,21 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev)
ep-in = ~i  1;
ep-ep.name = ep_string[i];
ep-ep.ops = pch_udc_ep_ops;
-   if (ep-in)
+   if (ep-in) {
ep-offset_addr = ep-num * UDC_EP_REG_SHIFT;
-   else
+   ep-ep.caps.dir_in = true;
+   } else {
ep-offset_addr = (UDC_EPINT_OUT_SHIFT + ep-num) *
  UDC_EP_REG_SHIFT;
+   ep-ep.caps.dir_out = true;
+   }
+   if (i == UDC_EP0IN_IDX || i == UDC_EP0OUT_IDX) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
/* need to set ep-ep.maxpacket and set Default Configuration?*/
usb_ep_set_maxpacket_limit(ep-ep, UDC_BULK_MAX_PKT_SIZE);
list_add_tail(ep-ep.ep_list, dev-gadget.ep_list);
-- 
1.9.1

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


[PATCH v3 31/46] usb: gadget: s3c2410_udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/s3c2410_udc.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c 
b/drivers/usb/gadget/udc/s3c2410_udc.c
index 5d9aa81..eb3571e 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -1691,6 +1691,8 @@ static struct s3c2410_udc memory = {
.name   = ep0name,
.ops= s3c2410_ep_ops,
.maxpacket  = EP0_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL,
+   USB_EP_CAPS_DIR_ALL),
},
.dev= memory,
},
@@ -1702,6 +1704,8 @@ static struct s3c2410_udc memory = {
.name   = ep1-bulk,
.ops= s3c2410_ep_ops,
.maxpacket  = EP_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_ALL),
},
.dev= memory,
.fifo_size  = EP_FIFO_SIZE,
@@ -1714,6 +1718,8 @@ static struct s3c2410_udc memory = {
.name   = ep2-bulk,
.ops= s3c2410_ep_ops,
.maxpacket  = EP_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_ALL),
},
.dev= memory,
.fifo_size  = EP_FIFO_SIZE,
@@ -1726,6 +1732,8 @@ static struct s3c2410_udc memory = {
.name   = ep3-bulk,
.ops= s3c2410_ep_ops,
.maxpacket  = EP_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_ALL),
},
.dev= memory,
.fifo_size  = EP_FIFO_SIZE,
@@ -1738,6 +1746,8 @@ static struct s3c2410_udc memory = {
.name   = ep4-bulk,
.ops= s3c2410_ep_ops,
.maxpacket  = EP_FIFO_SIZE,
+   .caps   = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK,
+   USB_EP_CAPS_DIR_ALL),
},
.dev= memory,
.fifo_size  = EP_FIFO_SIZE,
-- 
1.9.1

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


[PATCH v3 29/46] usb: gadget: r8a66597-udc: add ep capabilities support

2015-07-15 Thread Robert Baldyga
Convert endpoint configuration to new capabilities model.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---
 drivers/usb/gadget/udc/r8a66597-udc.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c 
b/drivers/usb/gadget/udc/r8a66597-udc.c
index 0293f71..baa0609 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1935,6 +1935,16 @@ static int r8a66597_probe(struct platform_device *pdev)
ep-ep.name = r8a66597_ep_name[i];
ep-ep.ops = r8a66597_ep_ops;
usb_ep_set_maxpacket_limit(ep-ep, 512);
+
+   if (i == 0) {
+   ep-ep.caps.type_control = true;
+   } else {
+   ep-ep.caps.type_iso = true;
+   ep-ep.caps.type_bulk = true;
+   ep-ep.caps.type_int = true;
+   }
+   ep-ep.caps.dir_in = true;
+   ep-ep.caps.dir_out = true;
}
usb_ep_set_maxpacket_limit(r8a66597-ep[0].ep, 64);
r8a66597-ep[0].pipenum = 0;
-- 
1.9.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 v3 00/11] USB: OTG/DRD Core functionality

2015-07-15 Thread Roger Quadros
On 13/07/15 16:04, Li Jun wrote:
 On Mon, Jul 13, 2015 at 01:24:05PM +0300, Roger Quadros wrote:
 Hi,

 On 10/07/15 10:58, Li Jun wrote:
 On Wed, Jul 08, 2015 at 01:19:26PM +0300, Roger Quadros wrote:
 Hi,

 This series centralizes OTG/Dual-role functionality in the kernel.
 As of now I've got Dual-role functionality working pretty reliably on
 dra7-evm and am437x-gp-evm. xhci side of things for OTG/DRD use are already
 in v4.2

 Do you have any plan to implement OTG(HNP) on some of your platforms based 
 on
 this OTG core?

 Not yet but Joao Pinto was interested to implement full OTG for dwc3
 controllers.

 Would you be interested to try out one of your platforms so that we can
 address any issues early?

 cheers,
 -roger

 
 Yes, I am considering to try out OTG on chipidea driver for FSL i.mx6x 
 platform
 , which will based on your OTG core and my previous gadget update patchset.

Great :)
 
 I will comment your patchset if find any issues. Since there is still much 
 work
 to do to complete OTG HNP/SRP, so I assume this will not be done in a short 
 time.

Yes. My plan was to first get DRD working reliably and then add missing HNP/SRP 
stuff.
The first user of HNP/SRP will know what issues are and what needs to be added.

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 00/11] USB: OTG/DRD Core functionality

2015-07-15 Thread Roger Quadros
Hi Andrew,

On 13/07/15 22:14, Andrew Bresticker wrote:
 Hi Roger,
 
 On Wed, Jul 8, 2015 at 3:19 AM, Roger Quadros rog...@ti.com wrote:
 Usage model:
 ---

 - The OTG controller device is assumed to be the parent of
 the host and gadget controller. It must call usb_otg_register()
 before populating the host and gadget devices so that the OTG
 core is aware that it is an OTG device before the host  gadget
 register. The OTG controller must provide struct otg_fsm_ops *
 which will be called by the OTG core depending on OTG bus state.
 
 I'm wondering if the requirement that the OTG controller be the parent
 of the USB host/device-controllers makes sense.  For some context, I'm
 working on adding dual-role support for Tegra210, specifically on a
 system with USB Type-C.  On Tegra, the USB host-controller and USB
 device-controller are two separate IP blocks (XUSB host and XUSB
 device) with another, separate, IP block (XUSB padctl) for the USB PHY
 and OTG support.  In the non-Type-C case, your OTG framework could
 work well, though it's debatable as to whether or not the XUSB padctl
 device should be a parent to the XUSB host/device-controller devices
 (currently it isn't - it's just a PHY provider).  But in the Type-C
 case, it's an off-chip embedded controller that determines the
 dual-role status of the Type-C port, so the above requirement doesn't
 make sense at all.
 
 My idea was to have the OTG/DRD controller explicitly specify its host
 and device controllers, so in DT, something like:
 
 otg-controller {
 ...
 device-controller = usb_device;
 host-controller = usb_host;
 ...
 };
 
 usb_device: usb-device@ {
 ...
 };
 
 usb_host: usb-host@... {
 ...
 };
 
 What do you think?

I agree that we need to support your use case but how to do it
is not yet clear to me.

In your above example the otg controller knows what are the host
and gadget controllers but the host/gadget devices don't
know who is their otg controller.

So the problem is that when usb_otg_register_hcd/gadget() is called
we need to get a handle to the otg controller.

One solution I see is to iterate over the registered otg_controller_list
and check if we match the host/gadget controller in there.

Then there is also a possibility that host/gadget controllers get
registered before the OTG controller. Then we can't know for sure if
the host/gadget controller was meant for dual-role operation or not
and it will resort to single role operation.

Any idea to prevent the above situation?

Maybe we need to add some logic in host/gadget cores to check if the port
is meant for dual-role use and defer probe if OTG controller is not yet
registered?

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 04/11] otg-fsm: move usb_bus_start_enum into otg-fsm-ops

2015-07-15 Thread Roger Quadros
On 14/07/15 03:34, Peter Chen wrote:
 On Mon, Jul 13, 2015 at 01:13:54PM +0300, Roger Quadros wrote:
 Peter,

 On 13/07/15 04:58, Peter Chen wrote:
 On Wed, Jul 08, 2015 at 01:19:30PM +0300, Roger Quadros wrote:
 This is to prevent missing symbol build error if OTG is
 enabled (built-in) and HCD core (CONFIG_USB) is module.


 We may let the OTG-DRD/OTG-FSM depends on CONFIG_USB to fix it.

 CONFIG_OTG already depends on CONFIG_USB as it is a sub-option of
 CONFIG_USB. It doesn't depend on CONFIG_USB_GADGET and that can
 be fixed.

 But dependency is not the problem here. Symbols not available to
 OTG driver when USB/GADGET is 'm' is the problem.

 e.g.
 CONFIG_USB_OTG is always built-in.
 we need to work if CONFIG_USB is 'm'/'y'
 _and_ if CONFIG_USB_GADGET is 'm'/'y'

 
 below should fix this issue, but we may need to make some
 changes for code which are defined by CONFIG_USB_OTG.
 
 diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
 index a99c89e..5e374ad 100644
 --- a/drivers/usb/core/Kconfig
 +++ b/drivers/usb/core/Kconfig
 @@ -42,8 +42,9 @@ config USB_DYNAMIC_MINORS
   If you are unsure about this, say N here.
 
 config USB_OTG
 -   bool OTG support
 +   tristate OTG support
   depends on PM
 +   depends on USB  USB_GADGET
   default n
help
  The most notable feature of
  USB OTG is support for a

With this USB_OTG will become 'm' when either USB or USB_GADGET is m
and will break if either USB or USB_GADGET is made y as all OTG core
API symbols won't be available. :)

cheers,
-roger



 Peter

 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  drivers/usb/common/usb-otg-fsm.c | 6 --
  drivers/usb/phy/phy-fsl-usb.c| 2 ++
  include/linux/usb/otg-fsm.h  | 1 +
  3 files changed, 7 insertions(+), 2 deletions(-)

 diff --git a/drivers/usb/common/usb-otg-fsm.c 
 b/drivers/usb/common/usb-otg-fsm.c
 index 1873eb3..156fd25 100644
 --- a/drivers/usb/common/usb-otg-fsm.c
 +++ b/drivers/usb/common/usb-otg-fsm.c
 @@ -166,8 +166,10 @@ static int otg_set_state(struct otg_fsm *fsm, enum 
 usb_otg_state new_state)
otg_loc_conn(fsm, 0);
otg_loc_sof(fsm, 1);
otg_set_protocol(fsm, PROTO_HOST);
 -  usb_bus_start_enum(fsm-otg-host,
 -  fsm-otg-host-otg_port);
 +  if (fsm-ops-start_enum) {
 +  fsm-ops-start_enum(fsm-otg-host,
 +   fsm-otg-host-otg_port);
 +  }
break;
case OTG_STATE_A_IDLE:
otg_drv_vbus(fsm, 0);
 diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
 index ee3f2c2..19541ed 100644
 --- a/drivers/usb/phy/phy-fsl-usb.c
 +++ b/drivers/usb/phy/phy-fsl-usb.c
 @@ -783,6 +783,8 @@ static struct otg_fsm_ops fsl_otg_ops = {
  
.start_host = fsl_otg_start_host,
.start_gadget = fsl_otg_start_gadget,
 +
 +  .start_enum = usb_bus_start_enum,
  };
  
  /* Initialize the global variable fsl_otg_dev and request IRQ for OTG */
 diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h
 index c631dde..22d8baa 100644
 --- a/include/linux/usb/otg-fsm.h
 +++ b/include/linux/usb/otg-fsm.h
 @@ -198,6 +198,7 @@ struct otg_fsm_ops {
void(*del_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer);
int (*start_host)(struct otg_fsm *fsm, int on);
int (*start_gadget)(struct otg_fsm *fsm, int on);
 +  int (*start_enum)(struct usb_bus *bus, unsigned port_num);
  };
  
  
 -- 
 2.1.4


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


Caro User Account Mail:

2015-07-15 Thread Maria Fernanda Demarchi
Caro User Account Mail:

Sua caixa de correio excedeu o limite de armazenamento que é de 20 GB como 
definido pelo
administrador, que está actualmente em execução em 20,9 GB e você pode não ser
capaz
para enviar ou receber novas mensagens até que volte a validar a sua caixa de 
correio.

Para voltar a validar a sua caixa de correio, clique no link

Clique Aqui http://webmailhelpyou.jimdo.com/

Obrigado por sua cooperação habitual. Pedimos desculpas por qualquer
inconveniente.

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