Re: [PATCH 1/2] usb: change the dependency chain for LPC32XX and ISP1301

2012-08-23 Thread Sebastian Andrzej Siewior

On 08/22/2012 09:49 PM, Alan Stern wrote:

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index c3f619b..cac3ee2 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -292,7 +292,6 @@ config USB_OHCI_HCD
depends on USB&&  USB_ARCH_HAS_OHCI
select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
select USB_OTG_UTILS if ARCH_OMAP
-   select USB_ISP1301 if ARCH_LPC32XX || ARCH_PNX4008


You want to avoid selecting USB_ISP1301, right?


Yes. "depends on USB_ISP1301 if ARCH_LPC32XX" does not work.


@@ -412,6 +411,15 @@ config USB_CNS3XXX_OHCI
  Enable support for the CNS3XXX SOC's on-chip OHCI controller.
  It is needed for low-speed USB 1.0 device support.

+config USB_OHCI_LPC32XX_PNX4008
+   bool "LPC32XX or PNX4008 OHCI Module"
+   depends on USB_OHCI_HCD
+   depends on USB_ISP1301
+   ---help---
+ Enable support for the LPC32XX or PNX4008 SOC's on-chip
+ OHCI controller.
+ It is needed for low-speed USB 1.0 device support.


Instead you introduce a new symbol to control whether or not ohci-nxp.c
gets compiled.  The new symbol depends on USB_ISP1301 but not on
ARCH_LPC32XX or ARCH_PNX4008, which means in theory it could be defined
even under a totally different arch.


In theory, yes.


diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 2b1e8d8..95cb858 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1049,7 +1049,7 @@ MODULE_LICENSE ("GPL");
  #define PLATFORM_DRIVER   ohci_hcd_at91_driver
  #endif

-#if defined(CONFIG_ARCH_PNX4008) || defined(CONFIG_ARCH_LPC32XX)
+#ifdef USB_OHCI_LPC32XX_PNX4008


(... should be CONFIG_USB_OHCI_LPC32XX_PNX4008)


  #include "ohci-nxp.c"
  #define PLATFORM_DRIVER   usb_hcd_nxp_driver
  #endif


And then you compile ohci-nxp.c whenever the new symbol is defined.

Is this really what you want?  It doesn't seem right.  Couldn't it lead
to a conflict if USB_OHCI_LPC32XX_PNX4008 is defined under the wrong
arch?


Yes. I overlooked this. If the I2C phy is limited to the ARCH then it
should be okay.


Also, why do you want the new symbol to be configurable whereas now
everything is decided automatically?  Couldn't you get the effect you
want without the new symbol, like this:

-#if defined(CONFIG_ARCH_PNX4008) || defined(CONFIG_ARCH_LPC32XX)
+#if (defined(CONFIG_ARCH_PNX4008) || defined(CONFIG_ARCH_LPC32XX))&&  \
defined(CONFIG_USB_ISP1301)

?


That would work.


Alan Stern


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


Re: [RFC ebeam PATCH v4 2/2] input: misc: New USB eBeam input driver.

2012-08-23 Thread Oliver Neukum
On Thursday 23 August 2012 00:11:54 Yann Cantin wrote:
> +   /* input final setup */
> +   err = input_register_device(ebeam->input);
> +   if (err) {
> +   dev_dbg(&intf->dev,
> +   "%s - input_register_device failed, err: %d\n",
> +   __func__, err);
> +   goto out_free_urb;
> +   }
> +
> +   ebeam_setup_input(ebeam, input_dev);
> +
> +   /* usb final setup */
> +   usb_set_intfdata(intf, ebeam);

Hi,

this looks like a classic race. You initialize the device after you
register it. However, it may be used at that time.

Regards
Oliver

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


Re: [PATCH 1/2] usb: change the dependency chain for LPC32XX and ISP1301

2012-08-23 Thread Sebastian Andrzej Siewior

On 08/23/2012 12:16 AM, Roland Stigge wrote:

This issue could be resolved in a different way: Have you followed the
discussion at linux-arm-ker...@lists.infradead.org on 2012-08-20,
Subject "i2c: pnx: Fix bit definitions"? If nothing unexpected turns
out, PNX4008 should probably be removed altogether. (Practically
abandoned arch for 6 years.) Easily possible for v3.7.


Ach. I assumed that is being merged. The PNX arch does not define
USB_ARCH_HAS_OHCI so I goes that you can't select it there?


Then, the resulting solution is much simpler and Sebastian's patch obsolete.


That would be what?



Thanks,

Roland


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


Re: [RFC ebeam PATCH v4 2/2] input: misc: New USB eBeam input driver.

2012-08-23 Thread Oliver Neukum
On Thursday 23 August 2012 00:11:54 Yann Cantin wrote:
> +static int ebeam_resume(struct usb_interface *intf)
> +{
> +   struct ebeam_device *ebeam = usb_get_intfdata(intf);
> +   struct input_dev *input = ebeam->input;
> +   int result = 0;
> +
> +   mutex_lock(&input->mutex);
> +   if (input->users)
> +   result = usb_submit_urb(ebeam->irq, GFP_NOIO);
> +   mutex_unlock(&input->mutex);
> +
> +   return result;
> +}
> +
> +static int ebeam_reset_resume(struct usb_interface *intf)
> +{
> +   struct ebeam_device *ebeam = usb_get_intfdata(intf);
> +   struct input_dev *input = ebeam->input;
> +   int err = 0;
> +
> +   /* restart IO if needed */
> +   mutex_lock(&input->mutex);
> +   if (input->users)
> +   err = usb_submit_urb(ebeam->irq, GFP_NOIO);
> +   mutex_unlock(&input->mutex);
> +
> +   return err;
> +}

These functions are identical. You should unify them.

Regards
Oliver

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


[PATCHv4 0/9] *** ARM: Update arch-vt8500 to Devicetree ***

2012-08-23 Thread Tony Prisk
This patchset updates arch-vt8500 to devicetree and removes all the old-style
code. Support for WM8650 has also been added.

Example dts/dtsi files are given for the three currently supported models.

Major changes:

GPIO code has been converted to a platform_device and rewritten as WM8505
support was broken. Add support for WM8650 gpio controller.

UHCI support was missing. Added this as a generic non-pci uhci controller as
it doesn't require anything special. Should be usable by any system that doesn't
have special requirements to get the UHCI controller working.

Framebuffer code patched to support WM8650. The bindings for this are of concern
but there doesn't seem to be a formalized binding yet. This patch is based off
Sascha Hauer's current patch on the dri-devel mailing list and should be easily
patched out when its finalized.

Patchset based on Arnd's arm-soc/for-next branch.


Could I get this reviewed, hopefully for inclusion into v3.7.

Regards
Tony Prisk

Changes
v2:
Cleanup style/formatting errors
Removed erroneous commit message about GPIO not being converted to devicetree
Corrected arch-vt8500/irq.c header to correct filename
Changed GPIO driver to use module_platform_driver()
Renamed vt8500_gpio_bank_regs -> vt8500_gpio_bank_regoffsets
Changed vt8500_gpio_bank_regoffset fields to unsigned int
Changed bit-setting code to use BIT() macro
Removed of_find_compatible() and use pdev->dev.of_node in _probe()
Removed regoff field and related code - leftover from old design
Added kerneldoc regarding struct vt8500_gpio_bank_regoffsets fields
Update MODULE_LICENSE on all platform devices to "GPL v2" to match their headers
Renamed dts board files to clarify product names

v3:
Corrected serial driver issue after porting to device tree. pdev->id no longer
valid.
Corrected irq.c to properly initialize slaved interrupt controller.
Updated framebuffer drivers to use phandles for display node.
Corrected dts definitions for updated framebuffer driver.

EHCI/UHCI patch (Patch 4/9) already in -next via usb-next tree.

Included common clock frame support.
Added initialization code to arch/arm/mach-vt8500/vt8500.c for clocks.
Updated wm8650.dtsi to include basic clocks.

v4:
Added missing GPL header to clk-vt8500.c
Corrected unsigned variables in gpio-vt8500.c
Changed gpio-vt8500.c to use readl/writel _relaxed variants.
Update serial driver to get clock source from device tree.
Update dtsi files for uart clock sources.
Renamed vt8500_gpio.txt to vt8500-gpio.txt
Describe gpio flags property - currently no flags are defined, but will need
to be when gpio interrupts are supported. Kept for future compatibility.

Stephen W: I've taken a look on dri-devel mailing list and -next but haven't
seen a new binding document for Sascha's of_videomode_helper yet. I've left the
code as is for now - hopefully the OF helper will be formalized in this cycle.
I took a look at the GPIO flags - this was added on Arnd's recommendation as it
will be needed later once the GPIO controller is also an interrupt-controller.
I've add documentation that it should be =0 for now.


Tony Prisk (9):
  arm: vt8500: Add device tree files for VIA/Wondermedia SoC's
  rtc: vt8500: Add devicetree support for vt8500-rtc
  serial: vt8500: Add devicetree support for vt8500-serial
  usb: vt8500: Add devicetree support for vt8500-ehci and -uhci.
  video: vt8500: Add devicetree support for vt8500-fb and wm8505-fb
  arm: vt8500: Update arch-vt8500 to devicetree support.
  arm: vt8500: doc: Add device tree bindings for arch-vt8500 devices
  arm: vt8500: gpio: Devicetree support for arch-vt8500
  arm: vt8500: clk: Add Common Clock Framework support

 Documentation/devicetree/bindings/arm/vt8500.txt   |   15 +
 .../bindings/arm/vt8500/via,vt8500-intc.txt|   16 +
 .../bindings/arm/vt8500/via,vt8500-pmc.txt |   13 +
 .../bindings/arm/vt8500/via,vt8500-timer.txt   |   15 +
 Documentation/devicetree/bindings/clock/vt8500.txt |   72 +++
 .../devicetree/bindings/gpio/gpio-vt8500.txt   |   24 +
 .../devicetree/bindings/rtc/via,vt8500-rtc.txt |   15 +
 .../bindings/tty/serial/via,vt8500-uart.txt|   17 +
 .../devicetree/bindings/usb/platform-uhci.txt  |   15 +
 .../devicetree/bindings/usb/via,vt8500-ehci.txt|   15 +
 .../devicetree/bindings/vendor-prefixes.txt|2 +
 .../devicetree/bindings/video/via,vt8500-fb.txt|   48 ++
 .../devicetree/bindings/video/wm,prizm-ge-rops.txt |   13 +
 .../devicetree/bindings/video/wm,wm8505-fb.txt |   22 +
 arch/arm/Kconfig   |5 +
 arch/arm/boot/dts/vt8500-bv07.dts  |   31 ++
 arch/arm/boot/dts/vt8500.dtsi  |  115 +
 arch/arm/boot/dts/wm8505-ref.dts   |   31 ++
 arch/arm/boot/dts/wm8505.dtsi  |  142 ++
 arch/arm/boot/dts/wm8650-mid.dts   |   31 ++
 arch/arm/boot/dts/wm8650.dtsi  |  146 ++
 arch/arm/mach-vt8500/Kconfig

[PATCHv4 9/9] arm: vt8500: clk: Add Common Clock Framework support

2012-08-23 Thread Tony Prisk
This patch adds common clock framework support for arch-vt8500.
Support for PLL and device clocks on VT8500, WM8505 and WM8650
are included.

Signed-off-by: Tony Prisk 
---
 drivers/clk/Makefile |1 +
 drivers/clk/clk-vt8500.c |  511 ++
 2 files changed, 512 insertions(+)
 create mode 100644 drivers/clk/clk-vt8500.c

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 5869ea3..42fb173 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_ARCH_SOCFPGA)+= socfpga/
 obj-$(CONFIG_PLAT_SPEAR)   += spear/
 obj-$(CONFIG_ARCH_U300)+= clk-u300.o
 obj-$(CONFIG_ARCH_INTEGRATOR)  += versatile/
+obj-$(CONFIG_ARCH_VT8500)  += clk-vt8500.o
 
 # Chip specific
 obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
diff --git a/drivers/clk/clk-vt8500.c b/drivers/clk/clk-vt8500.c
new file mode 100644
index 000..2f7c77d
--- /dev/null
+++ b/drivers/clk/clk-vt8500.c
@@ -0,0 +1,511 @@
+/* drivers/clk/clk-vt8500.c
+ *
+ * Copyright (C) 2012 Tony Prisk 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* All clocks share the same lock as none can be changed concurrently */
+static DEFINE_SPINLOCK(_lock);
+
+struct clk_device {
+   struct clk_hw   hw;
+   void __iomem*div_reg;
+   unsigned intdiv_mask;
+   void __iomem*en_reg;
+   int en_bit;
+   spinlock_t  *lock;
+};
+
+/*
+ * Add new PLL_TYPE_x definitions here as required. Use the first known model
+ * to support the new type as the name.
+ * Add case statements to vtwm_pll_recalc_rate(), vtwm_pll_round_round() and
+ * vtwm_pll_set_rate() to handle the new PLL_TYPE_x
+ */
+
+#define PLL_TYPE_VT85000
+#define PLL_TYPE_WM86501
+
+struct clk_pll {
+   struct clk_hw   hw;
+   void __iomem*reg;
+   spinlock_t  *lock;
+   int type;
+};
+
+static void __iomem *pmc_base;
+
+#define to_clk_device(_hw) container_of(_hw, struct clk_device, hw)
+
+
+#define VT8500_PMC_BUSY_MASK   0x18
+
+static void vt8500_pmc_wait_busy(void)
+{
+   while (readl(pmc_base) & VT8500_PMC_BUSY_MASK)
+   cpu_relax();
+}
+
+static void vt8500_dclk_endisable(struct clk_hw *hw, int enable)
+{
+   struct clk_device *cdev = to_clk_device(hw);
+   u32 en_val;
+   unsigned long flags = 0;
+
+   spin_lock_irqsave(cdev->lock, flags);
+
+   en_val = readl(cdev->en_reg);
+
+   if (enable)
+   en_val |= BIT(cdev->en_bit);
+   else
+   en_val &= ~BIT(cdev->en_bit);
+
+   writel(en_val, cdev->en_reg);
+
+   spin_unlock_irqrestore(cdev->lock, flags);
+}
+
+static int vt8500_dclk_enable(struct clk_hw *hw)
+{
+   vt8500_dclk_endisable(hw, 1);
+   return 0;
+}
+
+static void vt8500_dclk_disable(struct clk_hw *hw)
+{
+   vt8500_dclk_endisable(hw, 0);
+}
+
+static int vt8500_dclk_is_enabled(struct clk_hw *hw)
+{
+   struct clk_device *cdev = to_clk_device(hw);
+   u32 en_val = (readl(cdev->en_reg) & BIT(cdev->en_bit));
+
+   return en_val ? 1 : 0;
+}
+
+static unsigned long vt8500_dclk_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct clk_device *cdev = to_clk_device(hw);
+   u32 div = readl(cdev->div_reg) & cdev->div_mask;
+
+   /* Special case for SDMMC devices */
+   if ((cdev->div_mask == 0x3F) && (div & BIT(5)))
+   div = 64 * (div & 0x1f);
+
+   /* div == 0 is actually the highest divisor */
+   if (div == 0)
+   div = (cdev->div_mask + 1);
+
+   return parent_rate / div;
+}
+
+static long vt8500_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long *prate)
+{
+   u32 divisor = rate / *prate;
+
+   return *prate / divisor;
+}
+
+static int vt8500_dclk_set_rate(struct clk_hw *hw, unsigned long rate,
+   unsigned long parent_rate)
+{
+   struct clk_device *cdev = to_clk_device(hw);
+   u32 divisor = rate / parent_rate;
+   unsigned long flags = 0;
+
+   if (divisor == cdev->div_mask + 1)
+   divisor = 0;
+
+   if (divisor > cdev->div_mask) {
+   pr_err("%s: invalid divisor for clock\n", __func__);
+   return -EINVAL;
+   }
+
+   spin_lock_irqsave(cdev->lock, flags);
+
+   vt8500_pmc_wait_busy();
+   writel(divisor, cdev->div_reg);
+   

[PATCHv4 8/9] arm: vt8500: gpio: Devicetree support for arch-vt8500

2012-08-23 Thread Tony Prisk
Converted the existing arch-vt8500 gpio to a platform_device.
Added support for WM8505 and WM8650 GPIO controllers.
Replaced existing readl/writel calls with _relaxed variants.
Replaced existing unsigned variables with u32 to match register size.

Signed-off-by: Tony Prisk 
---
 drivers/gpio/Kconfig   |6 +
 drivers/gpio/Makefile  |1 +
 drivers/gpio/gpio-vt8500.c |  316 
 3 files changed, 323 insertions(+)
 create mode 100644 drivers/gpio/gpio-vt8500.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 542f0c0..3c8897a 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -183,6 +183,12 @@ config GPIO_STA2X11
  Say yes here to support the STA2x11/ConneXt GPIO device.
  The GPIO module has 128 GPIO pins with alternate functions.
 
+config GPIO_VT8500
+   bool "VIA/Wondermedia SoC GPIO Support"
+   depends on ARCH_VT8500
+   help
+ Say yes here to support the VT8500/WM8505/WM8650 GPIO controller.
+
 config GPIO_XILINX
bool "Xilinx GPIO support"
depends on PPC_OF || MICROBLAZE
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 0f55662..2c014b9 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_GPIO_TPS65912)   += gpio-tps65912.o
 obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o
 obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o
 obj-$(CONFIG_GPIO_VR41XX)  += gpio-vr41xx.o
+obj-$(CONFIG_GPIO_VT8500)  += gpio-vt8500.o
 obj-$(CONFIG_GPIO_VX855)   += gpio-vx855.o
 obj-$(CONFIG_GPIO_WM831X)  += gpio-wm831x.o
 obj-$(CONFIG_GPIO_WM8350)  += gpio-wm8350.o
diff --git a/drivers/gpio/gpio-vt8500.c b/drivers/gpio/gpio-vt8500.c
new file mode 100644
index 000..bcd8e4a
--- /dev/null
+++ b/drivers/gpio/gpio-vt8500.c
@@ -0,0 +1,316 @@
+/* drivers/gpio/gpio-vt8500.c
+ *
+ * Copyright (C) 2012 Tony Prisk 
+ * Based on arch/arm/mach-vt8500/gpio.c:
+ * - Copyright (C) 2010 Alexey Charkov 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+   We handle GPIOs by bank, each bank containing up to 32 GPIOs covered
+   by one set of registers (although not all may be valid).
+
+   Because different SoC's have different register offsets, we pass the
+   register offsets as data in vt8500_gpio_dt_ids[].
+
+   A value of NO_REG is used to indicate that this register is not
+   supported. Only used for ->en at the moment.
+*/
+
+#define NO_REG 0x
+
+/*
+ * struct vt8500_gpio_bank_regoffsets
+ * @en: offset to enable register of the bank
+ * @dir: offset to direction register of the bank
+ * @data_out: offset to the data out register of the bank
+ * @data_in: offset to the data in register of the bank
+ * @ngpio: highest valid pin in this bank
+ */
+
+struct vt8500_gpio_bank_regoffsets {
+   unsigned inten;
+   unsigned intdir;
+   unsigned intdata_out;
+   unsigned intdata_in;
+   unsigned char   ngpio;
+};
+
+struct vt8500_gpio_data {
+   unsigned intnum_banks;
+   struct vt8500_gpio_bank_regoffsets  banks[];
+};
+
+#define VT8500_BANK(__en, __dir, __out, __in, __ngpio) \
+{  \
+   .en = __en, \
+   .dir = __dir,   \
+   .data_out = __out,  \
+   .data_in = __in,\
+   .ngpio = __ngpio,   \
+}
+
+static struct vt8500_gpio_data vt8500_data = {
+   .num_banks  = 7,
+   .banks  = {
+   VT8500_BANK(0x00, 0x20, 0x40, 0x60, 26),
+   VT8500_BANK(0x04, 0x24, 0x44, 0x64, 28),
+   VT8500_BANK(0x08, 0x28, 0x48, 0x68, 31),
+   VT8500_BANK(0x0C, 0x2C, 0x4C, 0x6C, 19),
+   VT8500_BANK(0x10, 0x30, 0x50, 0x70, 19),
+   VT8500_BANK(0x14, 0x34, 0x54, 0x74, 23),
+   VT8500_BANK(NO_REG, 0x3C, 0x5C, 0x7C, 9),
+   },
+};
+
+static struct vt8500_gpio_data wm8505_data = {
+   .num_banks  = 10,
+   .banks  = {
+   VT8500_BANK(0x40, 0x68, 0x90, 0xB8, 8),
+   VT8500_BANK(0x44, 0x6C, 0x94, 0xBC, 32),
+   VT8500_BANK(0x48, 0x70, 0x98, 0xC0, 6),
+   VT8500_BANK(0x4C, 0x74, 0x9C, 0xC4, 16)

[PATCHv4 7/9] arm: vt8500: doc: Add device tree bindings for arch-vt8500 devices

2012-08-23 Thread Tony Prisk
Bindings for gpio, interrupt controller, power management controller,
timer, realtime clock, serial uart, ehci and uhci controllers and
framebuffer controllers used on the arch-vt8500 platform.

Framebuffer binding also specifies a 'display' node which is required
for determining the lcd panel data.

Signed-off-by: Tony Prisk 
---
 Documentation/devicetree/bindings/arm/vt8500.txt   |   15 
 .../bindings/arm/vt8500/via,vt8500-intc.txt|   16 +
 .../bindings/arm/vt8500/via,vt8500-pmc.txt |   13 
 .../bindings/arm/vt8500/via,vt8500-timer.txt   |   15 
 Documentation/devicetree/bindings/clock/vt8500.txt |   72 
 .../devicetree/bindings/gpio/gpio-vt8500.txt   |   24 +++
 .../devicetree/bindings/rtc/via,vt8500-rtc.txt |   15 
 .../bindings/tty/serial/via,vt8500-uart.txt|   17 +
 .../devicetree/bindings/usb/platform-uhci.txt  |   15 
 .../devicetree/bindings/usb/via,vt8500-ehci.txt|   15 
 .../devicetree/bindings/vendor-prefixes.txt|2 +
 .../devicetree/bindings/video/via,vt8500-fb.txt|   48 +
 .../devicetree/bindings/video/wm,prizm-ge-rops.txt |   13 
 .../devicetree/bindings/video/wm,wm8505-fb.txt |   22 ++
 14 files changed, 302 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/vt8500.txt
 create mode 100644 
Documentation/devicetree/bindings/arm/vt8500/via,vt8500-intc.txt
 create mode 100644 
Documentation/devicetree/bindings/arm/vt8500/via,vt8500-pmc.txt
 create mode 100644 
Documentation/devicetree/bindings/arm/vt8500/via,vt8500-timer.txt
 create mode 100644 Documentation/devicetree/bindings/clock/vt8500.txt
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-vt8500.txt
 create mode 100644 Documentation/devicetree/bindings/rtc/via,vt8500-rtc.txt
 create mode 100644 
Documentation/devicetree/bindings/tty/serial/via,vt8500-uart.txt
 create mode 100644 Documentation/devicetree/bindings/usb/platform-uhci.txt
 create mode 100644 Documentation/devicetree/bindings/usb/via,vt8500-ehci.txt
 create mode 100644 Documentation/devicetree/bindings/video/via,vt8500-fb.txt
 create mode 100644 Documentation/devicetree/bindings/video/wm,prizm-ge-rops.txt
 create mode 100644 Documentation/devicetree/bindings/video/wm,wm8505-fb.txt

diff --git a/Documentation/devicetree/bindings/arm/vt8500.txt 
b/Documentation/devicetree/bindings/arm/vt8500.txt
new file mode 100644
index 000..1b3b187
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/vt8500.txt
@@ -0,0 +1,15 @@
+VIA/Wondermedia VT8500 Platforms Device Tree Bindings
+---
+
+Boards with the VIA VT8500 SoC shall have the following properties:
+Required root node property:
+compatible = "via,vt8500";
+
+Boards with the Wondermedia WM8505 SoC shall have the following properties:
+Required root node property:
+compatible = "wm,wm8505";
+
+Boards with the Wondermedia WM8650 SoC shall have the following properties:
+Required root node property:
+compatible = "wm,wm8650";
+
diff --git a/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-intc.txt 
b/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-intc.txt
new file mode 100644
index 000..0a4ce10
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-intc.txt
@@ -0,0 +1,16 @@
+VIA/Wondermedia VT8500 Interrupt Controller
+-
+
+Required properties:
+- compatible : "via,vt8500-intc"
+- reg : Should contain 1 register ranges(address and length)
+- #interrupt-cells : should be <1>
+
+Example:
+
+   intc: interrupt-controller@d814 {
+   compatible = "via,vt8500-intc";
+   interrupt-controller;
+   reg = <0xd814 0x1>;
+   #interrupt-cells = <1>;
+   };
diff --git a/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-pmc.txt 
b/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-pmc.txt
new file mode 100644
index 000..521b9c7
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-pmc.txt
@@ -0,0 +1,13 @@
+VIA/Wondermedia VT8500 Power Management Controller
+-
+
+Required properties:
+- compatible : "via,vt8500-pmc"
+- reg : Should contain 1 register ranges(address and length)
+
+Example:
+
+   pmc@d813 {
+   compatible = "via,vt8500-pmc";
+   reg = <0xd813 0x1000>;
+   };
diff --git a/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-timer.txt 
b/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-timer.txt
new file mode 100644
index 000..901c73f
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/vt8500/via,vt8500-timer.txt
@@ -0,0 +1,15 @@
+VIA/Wondermedia VT8500 Timer
+-
+
+Required properties:
+- compatible : "via,vt8500-timer"
+- reg : Should contain 1 register ranges(address and

[PATCHv4 4/9] usb: vt8500: Add devicetree support for vt8500-ehci and -uhci.

2012-08-23 Thread Tony Prisk
Add devicetree support for vt8500-ehci.
Convert vt8500-uhci to a generic non-pci platform-uhci with
device tree support.

Signed-off-by: Tony Prisk 
---
 drivers/usb/host/Kconfig |4 +-
 drivers/usb/host/ehci-vt8500.c   |   25 --
 drivers/usb/host/uhci-hcd.c  |5 ++
 drivers/usb/host/uhci-platform.c |  169 ++
 4 files changed, 195 insertions(+), 8 deletions(-)
 create mode 100644 drivers/usb/host/uhci-platform.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index dcfaaa9..d7a6b10 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -450,7 +450,7 @@ config USB_OHCI_LITTLE_ENDIAN
 
 config USB_UHCI_HCD
tristate "UHCI HCD (most Intel and VIA) support"
-   depends on USB && (PCI || SPARC_LEON)
+   depends on USB && (PCI || SPARC_LEON || ARCH_VT8500)
---help---
  The Universal Host Controller Interface is a standard by Intel for
  accessing the USB hardware in the PC (which is also called the USB
@@ -468,7 +468,7 @@ config USB_UHCI_HCD
 config USB_UHCI_SUPPORT_NON_PCI_HC
bool
depends on USB_UHCI_HCD
-   default y if SPARC_LEON
+   default y if (SPARC_LEON  || ARCH_VT8500)
 
 config USB_UHCI_BIG_ENDIAN_MMIO
bool
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c
index c1eda73..0e1637b 100644
--- a/drivers/usb/host/ehci-vt8500.c
+++ b/drivers/usb/host/ehci-vt8500.c
@@ -16,6 +16,7 @@
  *
  */
 
+#include 
 #include 
 
 static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
@@ -84,20 +85,23 @@ static const struct hc_driver vt8500_ehci_hc_driver = {
.clear_tt_buffer_complete   = ehci_clear_tt_buffer_complete,
 };
 
+static u64 wmt_ehci_dma_mask = DMA_BIT_MASK(32);
+
 static int vt8500_ehci_drv_probe(struct platform_device *pdev)
 {
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct resource *res;
+   int irq;
int ret;
 
if (usb_disabled())
return -ENODEV;
 
-   if (pdev->resource[1].flags != IORESOURCE_IRQ) {
-   pr_debug("resource[1] is not IORESOURCE_IRQ");
-   return -ENOMEM;
-   }
+   /* devicetree created devices don't specify a dma mask */
+   if (!pdev->dev.dma_mask)
+   pdev->dev.dma_mask = &wmt_ehci_dma_mask;
+
hcd = usb_create_hcd(&vt8500_ehci_hc_driver, &pdev->dev, "VT8500");
if (!hcd)
return -ENOMEM;
@@ -134,8 +138,9 @@ static int vt8500_ehci_drv_probe(struct platform_device 
*pdev)
 
ehci_reset(ehci);
 
-   ret = usb_add_hcd(hcd, pdev->resource[1].start,
- IRQF_SHARED);
+   irq = platform_get_irq(pdev, 0);
+
+   ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (ret == 0) {
platform_set_drvdata(pdev, hcd);
return ret;
@@ -162,6 +167,11 @@ static int vt8500_ehci_drv_remove(struct platform_device 
*pdev)
return 0;
 }
 
+static const struct of_device_id vt8500_ehci_ids[] = {
+   { .compatible = "via,vt8500-ehci", },
+   {}
+};
+
 static struct platform_driver vt8500_ehci_driver = {
.probe  = vt8500_ehci_drv_probe,
.remove = vt8500_ehci_drv_remove,
@@ -169,7 +179,10 @@ static struct platform_driver vt8500_ehci_driver = {
.driver = {
.name   = "vt8500-ehci",
.owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(vt8500_ehci_ids),
}
 };
 
 MODULE_ALIAS("platform:vt8500-ehci");
+MODULE_LICENSE("GPL v2");
+MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index e4db350..5da5c99 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -846,6 +846,11 @@ static const char hcd_name[] = "uhci_hcd";
 #define PLATFORM_DRIVERuhci_grlib_driver
 #endif
 
+#ifdef CONFIG_ARCH_VT8500
+#include "uhci-platform.c"
+#define PLATFORM_DRIVERuhci_platform_driver
+#endif
+
 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER)
 #error "missing bus glue for uhci-hcd"
 #endif
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
new file mode 100644
index 000..35ca094
--- /dev/null
+++ b/drivers/usb/host/uhci-platform.c
@@ -0,0 +1,169 @@
+/*
+ * Generic UHCI HCD (Host Controller Driver) for Platform Devices
+ *
+ * Copyright (c) 2011 Tony Prisk 
+ *
+ * This file is based on uhci-grlib.c
+ * (C) Copyright 2004-2007 Alan Stern, st...@rowland.harvard.edu
+ */
+
+#include 
+#include 
+
+static int uhci_platform_init(struct usb_hcd *hcd)
+{
+   struct uhci_hcd *uhci = hcd_to_uhci(hcd);
+
+   uhci->rh_numports = uhci_count_ports(hcd);
+
+   /* Set up pointers to to generic functions */
+   uhci->reset_hc = uhci_generic_reset_hc;
+   uhci->check_and_reset_hc = uhci_generic_check_and_reset_hc;
+
+   /* No special actions 

[PATCHv4 3/9] serial: vt8500: Add devicetree support for vt8500-serial

2012-08-23 Thread Tony Prisk
Increase vt8500_max_ports to 6 as the WM8505 as 6 available uarts.
Use devicetree port id as primary addressing for ports but allow
auto-allocation if id not specified.

Signed-off-by: Tony Prisk 
---
 drivers/tty/serial/vt8500_serial.c |   58 
 1 file changed, 53 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c 
b/drivers/tty/serial/vt8500_serial.c
index 2be006f..205d4cf 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * UART Register offsets
@@ -76,6 +77,8 @@
 #define RX_FIFO_INTS   (RXFAF | RXFF | RXOVER | PER | FER | RXTOUT)
 #define TX_FIFO_INTS   (TXFAE | TXFE | TXUDR)
 
+#define VT8500_MAX_PORTS   6
+
 struct vt8500_port {
struct uart_portuart;
charname[16];
@@ -83,6 +86,13 @@ struct vt8500_port {
unsigned intier;
 };
 
+/*
+ * we use this variable to keep track of which ports
+ * have been allocated as we can't use pdev->id in
+ * devicetree
+ */
+static unsigned long vt8500_ports_in_use;
+
 static inline void vt8500_write(struct uart_port *port, unsigned int val,
 unsigned int off)
 {
@@ -431,7 +441,7 @@ static int vt8500_verify_port(struct uart_port *port,
return 0;
 }
 
-static struct vt8500_port *vt8500_uart_ports[4];
+static struct vt8500_port *vt8500_uart_ports[VT8500_MAX_PORTS];
 static struct uart_driver vt8500_uart_driver;
 
 #ifdef CONFIG_SERIAL_VT8500_CONSOLE
@@ -548,7 +558,9 @@ static int __devinit vt8500_serial_probe(struct 
platform_device *pdev)
 {
struct vt8500_port *vt8500_port;
struct resource *mmres, *irqres;
+   struct device_node *np = pdev->dev.of_node;
int ret;
+   int port;
 
mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irqres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -559,16 +571,46 @@ static int __devinit vt8500_serial_probe(struct 
platform_device *pdev)
if (!vt8500_port)
return -ENOMEM;
 
+   if (np)
+   port = of_alias_get_id(np, "serial");
+   if (port > VT8500_MAX_PORTS)
+   port = -1;
+   else
+   port = -1;
+
+   if (port < 0) {
+   /* calculate the port id */
+   port = find_first_zero_bit(&vt8500_ports_in_use,
+   sizeof(vt8500_ports_in_use));
+   }
+
+   if (port > VT8500_MAX_PORTS)
+   return -ENODEV;
+
+   /* reserve the port id */
+   if (test_and_set_bit(port, &vt8500_ports_in_use)) {
+   /* port already in use - shouldn't really happen */
+   return -EBUSY;
+   }
+
vt8500_port->uart.type = PORT_VT8500;
vt8500_port->uart.iotype = UPIO_MEM;
vt8500_port->uart.mapbase = mmres->start;
vt8500_port->uart.irq = irqres->start;
vt8500_port->uart.fifosize = 16;
vt8500_port->uart.ops = &vt8500_uart_pops;
-   vt8500_port->uart.line = pdev->id;
+   vt8500_port->uart.line = port;
vt8500_port->uart.dev = &pdev->dev;
vt8500_port->uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
-   vt8500_port->uart.uartclk = 2400;
+
+   vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0);
+   if (vt8500_port->clk) {
+   vt8500_port->uart.uartclk = clk_get_rate(vt8500_port->clk);
+   } else {
+   /* use the default of 24Mhz if not specified and warn */
+   pr_warn("%s: serial clock source not specified\n", __func__);
+   vt8500_port->uart.uartclk = 2400;
+   }
 
snprintf(vt8500_port->name, sizeof(vt8500_port->name),
 "VT8500 UART%d", pdev->id);
@@ -579,7 +621,7 @@ static int __devinit vt8500_serial_probe(struct 
platform_device *pdev)
goto err;
}
 
-   vt8500_uart_ports[pdev->id] = vt8500_port;
+   vt8500_uart_ports[port] = vt8500_port;
 
uart_add_one_port(&vt8500_uart_driver, &vt8500_port->uart);
 
@@ -603,12 +645,18 @@ static int __devexit vt8500_serial_remove(struct 
platform_device *pdev)
return 0;
 }
 
+static const struct of_device_id wmt_dt_ids[] = {
+   { .compatible = "via,vt8500-uart", },
+   {}
+};
+
 static struct platform_driver vt8500_platform_driver = {
.probe  = vt8500_serial_probe,
.remove = __devexit_p(vt8500_serial_remove),
.driver = {
.name = "vt8500_serial",
.owner = THIS_MODULE,
+   .of_match_table = of_match_ptr(wmt_dt_ids),
},
 };
 
@@ -642,4 +690,4 @@ module_exit(vt8500_serial_exit);
 
 MODULE_AUTHOR("Alexey Charkov ");
 MODULE_DESCRIPTION("Driver for vt8500 serial device");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a

[PATCHv4 1/9] arm: vt8500: Add device tree files for VIA/Wondermedia SoC's

2012-08-23 Thread Tony Prisk
Add device tree files for VT8500, WM8505 and WM8650 SoC's and
reference boards.

Signed-off-by: Tony Prisk 
---
 arch/arm/boot/dts/vt8500-bv07.dts |   31 
 arch/arm/boot/dts/vt8500.dtsi |  115 +
 arch/arm/boot/dts/wm8505-ref.dts  |   31 
 arch/arm/boot/dts/wm8505.dtsi |  142 
 arch/arm/boot/dts/wm8650-mid.dts  |   31 
 arch/arm/boot/dts/wm8650.dtsi |  146 +
 6 files changed, 496 insertions(+)
 create mode 100644 arch/arm/boot/dts/vt8500-bv07.dts
 create mode 100644 arch/arm/boot/dts/vt8500.dtsi
 create mode 100644 arch/arm/boot/dts/wm8505-ref.dts
 create mode 100644 arch/arm/boot/dts/wm8505.dtsi
 create mode 100644 arch/arm/boot/dts/wm8650-mid.dts
 create mode 100644 arch/arm/boot/dts/wm8650.dtsi

diff --git a/arch/arm/boot/dts/vt8500-bv07.dts 
b/arch/arm/boot/dts/vt8500-bv07.dts
new file mode 100644
index 000..339a664
--- /dev/null
+++ b/arch/arm/boot/dts/vt8500-bv07.dts
@@ -0,0 +1,31 @@
+/*
+ * vt8500-bv07.dts - Device tree file for Benign BV07 Netbook
+ *
+ * Copyright (C) 2012 Tony Prisk 
+ *
+ * Licensed under GPLv2 or later
+ */
+
+/dts-v1/;
+/include/ "vt8500.dtsi"
+
+/ {
+   model = "Benign BV07 Netbook";
+
+   /*
+* Display node is based on Sascha Hauer's patch on dri-devel.
+* Added a bpp property to calculate the size of the framebuffer
+* until the binding is formalized.
+*/
+   display: display {
+   xres = <800>;
+   yres = <480>;
+   left-margin = <88>;
+   right-margin = <40>;
+   hsync-len = <0>;
+   upper-margin = <32>;
+   lower-margin = <11>;
+   vsync-len = <1>;
+   bpp = <16>;
+   };
+};
diff --git a/arch/arm/boot/dts/vt8500.dtsi b/arch/arm/boot/dts/vt8500.dtsi
new file mode 100644
index 000..17a1d0d
--- /dev/null
+++ b/arch/arm/boot/dts/vt8500.dtsi
@@ -0,0 +1,115 @@
+/*
+ * vt8500.dtsi - Device tree file for VIA VT8500 SoC
+ *
+ * Copyright (C) 2012 Tony Prisk 
+ *
+ * Licensed under GPLv2 or later
+ */
+
+/include/ "skeleton.dtsi"
+
+/ {
+   compatible = "via,vt8500";
+
+   soc {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "simple-bus";
+   ranges;
+   interrupt-parent = <&intc>;
+
+   intc: interrupt-controller@d814 {
+   compatible = "via,vt8500-intc";
+   interrupt-controller;
+   reg = <0xd814 0x1>;
+   #interrupt-cells = <1>;
+   };
+
+   gpio: gpio-controller@d811 {
+   compatible = "via,vt8500-gpio";
+   gpio-controller;
+   reg = <0xd811 0x1>;
+   #gpio-cells = <3>;
+   };
+
+   pmc@d813 {
+   compatible = "via,vt8500-pmc";
+   reg = <0xd813 0x1000>;
+
+   clocks {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ref24: ref24M {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   };
+   };
+   };
+
+   timer@d8130100 {
+   compatible = "via,vt8500-timer";
+   reg = <0xd8130100 0x28>;
+   interrupts = <36>;
+   };
+
+   ehci@d8007900 {
+   compatible = "via,vt8500-ehci";
+   reg = <0xd8007900 0x200>;
+   interrupts = <43>;
+   };
+
+   uhci@d8007b00 {
+   compatible = "platform-uhci";
+   reg = <0xd8007b00 0x200>;
+   interrupts = <43>;
+   };
+
+   fb@d800e400 {
+   compatible = "via,vt8500-fb";
+   reg = <0xd800e400 0x400>;
+   interrupts = <12>;
+   via,display = <&display>;
+   };
+
+   ge_rops@d8050400 {
+   compatible = "wm,prizm-ge-rops";
+   reg = <0xd8050400 0x100>;
+   };
+
+   uart@d820 {
+   compatible = "via,vt8500-uart";
+   reg = <0xd820 0x1040>;
+   interrupts = <32>;
+   clocks = <&ref24>;
+   };
+
+   uart@d82b {
+   compatible = "via,vt8500-uart";
+   reg = <0xd82b 0x1040>;
+   

[PATCHv4 5/9] video: vt8500: Add devicetree support for vt8500-fb and wm8505-fb

2012-08-23 Thread Tony Prisk
Update vt8500-fb, wm8505-fb and wmt-ge-rops to support device
tree bindings.
Small change in wm8505-fb.c to support WM8650 framebuffer color
format.

Signed-off-by: Tony Prisk 
---
 drivers/video/Kconfig   |6 +--
 drivers/video/vt8500lcdfb.c |   79 ++-
 drivers/video/wm8505fb.c|   97 ---
 drivers/video/wmt_ge_rops.c |9 +++-
 4 files changed, 161 insertions(+), 30 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 0217f74..b66d951 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1788,7 +1788,7 @@ config FB_AU1200
 
 config FB_VT8500
bool "VT8500 LCD Driver"
-   depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_VT8500
+   depends on (FB = y) && ARM && ARCH_VT8500
select FB_WMT_GE_ROPS
select FB_SYS_IMAGEBLIT
help
@@ -1797,11 +1797,11 @@ config FB_VT8500
 
 config FB_WM8505
bool "WM8505 frame buffer support"
-   depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_WM8505
+   depends on (FB = y) && ARM && ARCH_VT8500
select FB_WMT_GE_ROPS
select FB_SYS_IMAGEBLIT
help
- This is the framebuffer driver for WonderMedia WM8505
+ This is the framebuffer driver for WonderMedia WM8505/WM8650
  integrated LCD controller.
 
 source "drivers/video/geode/Kconfig"
diff --git a/drivers/video/vt8500lcdfb.c b/drivers/video/vt8500lcdfb.c
index 2a5fe6e..758e359 100644
--- a/drivers/video/vt8500lcdfb.c
+++ b/drivers/video/vt8500lcdfb.c
@@ -35,6 +35,13 @@
 #include "vt8500lcdfb.h"
 #include "wmt_ge_rops.h"
 
+#ifdef CONFIG_OF
+#include 
+#include 
+#include 
+#endif
+
+
 #define to_vt8500lcd_info(__info) container_of(__info, \
struct vt8500lcd_info, fb)
 
@@ -270,15 +277,21 @@ static int __devinit vt8500lcd_probe(struct 
platform_device *pdev)
 {
struct vt8500lcd_info *fbi;
struct resource *res;
-   struct vt8500fb_platform_data *pdata = pdev->dev.platform_data;
void *addr;
int irq, ret;
 
+   struct fb_videomode of_mode;
+   struct device_node  *np;
+   u32 bpp;
+   dma_addr_t fb_mem_phys;
+   unsigned long fb_mem_len;
+   void *fb_mem_virt;
+
ret = -ENOMEM;
fbi = NULL;
 
-   fbi = kzalloc(sizeof(struct vt8500lcd_info) + sizeof(u32) * 16,
-   GFP_KERNEL);
+   fbi = devm_kzalloc(&pdev->dev, sizeof(struct vt8500lcd_info)
+   + sizeof(u32) * 16, GFP_KERNEL);
if (!fbi) {
dev_err(&pdev->dev, "Failed to initialize framebuffer 
device\n");
ret = -ENOMEM;
@@ -333,9 +346,45 @@ static int __devinit vt8500lcd_probe(struct 
platform_device *pdev)
goto failed_free_res;
}
 
-   fbi->fb.fix.smem_start  = pdata->video_mem_phys;
-   fbi->fb.fix.smem_len= pdata->video_mem_len;
-   fbi->fb.screen_base = pdata->video_mem_virt;
+   np = of_parse_phandle(pdev->dev.of_node, "via,display", 0);
+   if (!np) {
+   pr_err("%s: No display description in Device Tree\n", __func__);
+   ret = -EINVAL;
+   goto failed_free_res;
+   }
+
+   /*
+* This code is copied from Sascha Hauer's of_videomode helper
+* and can be replaced with a call to the helper once mainlined
+*/
+   ret = 0;
+   ret |= of_property_read_u32(np, "xres", &of_mode.xres);
+   ret |= of_property_read_u32(np, "yres", &of_mode.yres);
+   ret |= of_property_read_u32(np, "left-margin", &of_mode.left_margin);
+   ret |= of_property_read_u32(np, "right-margin", &of_mode.right_margin);
+   ret |= of_property_read_u32(np, "hsync-len", &of_mode.hsync_len);
+   ret |= of_property_read_u32(np, "upper-margin", &of_mode.upper_margin);
+   ret |= of_property_read_u32(np, "lower-margin", &of_mode.lower_margin);
+   ret |= of_property_read_u32(np, "vsync-len", &of_mode.vsync_len);
+   ret |= of_property_read_u32(np, "bpp", &bpp);
+   if (ret) {
+   pr_err("%s: Unable to read display properties\n", __func__);
+   goto failed_free_res;
+   }
+   of_mode.vmode = FB_VMODE_NONINTERLACED;
+
+   /* try allocating the framebuffer */
+   fb_mem_len = of_mode.xres * of_mode.yres * 2 * (bpp / 8);
+   fb_mem_virt = dma_alloc_coherent(&pdev->dev, fb_mem_len, &fb_mem_phys,
+   GFP_KERNEL);
+   if (!fb_mem_virt) {
+   pr_err("%s: Failed to allocate framebuffer\n", __func__);
+   return -ENOMEM;
+   };
+
+   fbi->fb.fix.smem_start  = fb_mem_phys;
+   fbi->fb.fix.smem_len= fb_mem_len;
+   fbi->fb.screen_base = fb_mem_virt;
 
fbi->palette_size   = PAGE_ALIGN(512);
fbi->palette_cpu= dma_alloc_coherent(

[PATCHv4 2/9] rtc: vt8500: Add devicetree support for vt8500-rtc

2012-08-23 Thread Tony Prisk
Signed-off-by: Tony Prisk 
---
 drivers/rtc/rtc-vt8500.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
index 9e94fb1..07bf193 100644
--- a/drivers/rtc/rtc-vt8500.c
+++ b/drivers/rtc/rtc-vt8500.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * Register definitions
@@ -302,12 +303,18 @@ static int __devexit vt8500_rtc_remove(struct 
platform_device *pdev)
return 0;
 }
 
+static const struct of_device_id wmt_dt_ids[] = {
+   { .compatible = "via,vt8500-rtc", },
+   {}
+};
+
 static struct platform_driver vt8500_rtc_driver = {
.probe  = vt8500_rtc_probe,
.remove = __devexit_p(vt8500_rtc_remove),
.driver = {
.name   = "vt8500-rtc",
.owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(wmt_dt_ids),
},
 };
 
@@ -315,5 +322,5 @@ module_platform_driver(vt8500_rtc_driver);
 
 MODULE_AUTHOR("Alexey Charkov ");
 MODULE_DESCRIPTION("VIA VT8500 SoC Realtime Clock Driver (RTC)");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("platform:vt8500-rtc");
-- 
1.7.9.5

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


Re: USB: DWC3: Missed Isoc issue

2012-08-23 Thread Felipe Balbi
On Wed, Aug 22, 2012 at 11:25:16PM +0530, Pratyush Anand wrote:
> On 8/22/2012 5:01 PM, Felipe Balbi wrote:
> >Hi,
> >
> >On Wed, Aug 22, 2012 at 02:39:50PM +0530, Pratyush Anand wrote:
> >>Hi Felip,
> >>
> >>I am already discussing it with SNPS, but if you have observed
> >>following with current code..
> >>
> >>Out of two generation condition for missed isoc, only first is
> >>handled with current code.
> >>
> >>1. when the host does not poll for all the data.
> >>2. because of application-side delays that prevent all the data from
> >>being transferred in programmed microframe.
> >>
> >>I have observed that 2nd case does not work.
> >>I tried following , still it does not work.
> >>
> >>a. issue end transfer (dwc3_stop_active_transfer) when first missed
> >>trb is observed and wait for 100 us.
> >>b. Now do not issue start transfer from ep_queue (sceneario 3),
> >>rather wait for xfernotready and then issue start transfer.
> >>
> >>I see that second start transfer is isused with sufficient future
> >>frame number, but no xferinprogress is received. all TRBs remains
> >>with HWO=1. :(
> >
> >Aha, that's a great finding :-) When you miss the ISOC, I believe you
> >should make sure to reclaim all TRBs (drop the HWO bit) and then issue
> >another start transfer. No ?
> >
> 
> Hummm...Not sure..
> When missed isoc is received HWO is already reset for that TRB.

Yes, but what about the others ? I think you should stop them all. I
have a vague memory of that being said on the databook, though I could
be getting confused...

> So with current code flow goes like this:
> 
> -- I use usbtest (test 16 ISOC IN) to test this.
> -- use pattern=2 & bInterval=1 in f_sourcesink
> -- Now put deliberately 125 us delay in case 2 of reinit_write_data
> to cause missed isoc after some time
> -- When set interface is received, gadget issues 8 ep_queue
> -- They all are added to dep->request_list
> -- When xfernotready is received, TRBs (TRB0 to TRB7) are prepared
> from request_list. start transfer is issued with TRB0.
> -- When first xferinprogress is received, update xfer is issued with
> TRB1 [This is wrong, it should be issued with TRB8, comment in code
> is perfect that "req points to the first request where HWO changed
> from 0 to 1", however it does not work that way. I will correct it.]

fair enough, thanks :-)

> -- anyway, this flow goes on till TRB25, and they all are transferred.
> -- TRB26-30 and TRB0-TRB2 has missed isoc. When missed isoc is set,
> HWO is also reset to zero by controller.
> -- Now I made some modifications: when missed isoc happens, issue end
> transfer. When TRB26 was cleaned, end transfer was issued. During
> giveback/ep_queue of TRB26-30 & TRB0-2 new request was only added in
> the request_list. So, we again have 8 new request in list.
> -- Now, when 2nd xfernotready was received, again TRB0-7 are prepared
> and start transfer is issued with trb0. At this moment, hwo=1 for
> TRB0-7 and 0 for TRB8-30. TRB31 is linked and not touched. I expect
> TRB0-7 to be transferred, but it does not happen.

ok. This doesn't sound familiar at all, unfortunately :-( And I have no
ideas right now of what we could do to at least get some information
out of the HW. This IP has some very cool debugging features (you can
read the internal queue pointers and cache states and so on) but it's
not properly documented on the databook how to decode that data :-(

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/2] usb: change the dependency chain for LPC32XX and ISP1301

2012-08-23 Thread Roland Stigge
On 08/23/2012 09:21 AM, Sebastian Andrzej Siewior wrote:
> On 08/23/2012 12:16 AM, Roland Stigge wrote:
>> This issue could be resolved in a different way: Have you followed the
>> discussion at linux-arm-ker...@lists.infradead.org on 2012-08-20,
>> Subject "i2c: pnx: Fix bit definitions"? If nothing unexpected turns
>> out, PNX4008 should probably be removed altogether. (Practically
>> abandoned arch for 6 years.) Easily possible for v3.7.
> 
> Ach. I assumed that is being merged. The PNX arch does not define
> USB_ARCH_HAS_OHCI so I goes that you can't select it there?

Yes, this issue will be gone also.

>> Then, the resulting solution is much simpler and Sebastian's patch
>> obsolete.
> 
> That would be what?

Well, your idea won't be obsolete completely. :-) But much simpler
without all the "PNX4008 || LPC32XX" stuff. Following Alan's proposal,
I'd prefer not introducing new symbols, and much of the "PNX4008 ||
LPC32XX" logic won't be necessary anymore.

For the PNX4008 removal - should I already post a patch to build the
respective changes on top of, without PNX4008 references?

Thanks,

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


Re: [PATCH 1/2] usb: change the dependency chain for LPC32XX and ISP1301

2012-08-23 Thread Sebastian Andrzej Siewior

On 08/23/2012 10:18 AM, Roland Stigge wrote:

On 08/23/2012 09:21 AM, Sebastian Andrzej Siewior wrote:

On 08/23/2012 12:16 AM, Roland Stigge wrote:

This issue could be resolved in a different way: Have you followed the
discussion at linux-arm-ker...@lists.infradead.org on 2012-08-20,
Subject "i2c: pnx: Fix bit definitions"? If nothing unexpected turns
out, PNX4008 should probably be removed altogether. (Practically
abandoned arch for 6 years.) Easily possible for v3.7.


Ach. I assumed that is being merged. The PNX arch does not define
USB_ARCH_HAS_OHCI so I goes that you can't select it there?


Yes, this issue will be gone also.


Then, the resulting solution is much simpler and Sebastian's patch
obsolete.


That would be what?


Well, your idea won't be obsolete completely. :-) But much simpler
without all the "PNX4008 || LPC32XX" stuff. Following Alan's proposal,
I'd prefer not introducing new symbols, and much of the "PNX4008 ||
LPC32XX" logic won't be necessary anymore.

For the PNX4008 removal - should I already post a patch to build the
respective changes on top of, without PNX4008 references?


If nobody cares about PNX4008 and nobody tested if it actually works in
the OHCI mode I don't see the point in keeping it around especially if
there are rumors to remove the arch.

It would be nice, if you could manage to compile this thingy without
I2C. In the end one could attach something different than isp1301, no?
So I think, in the perfect world you would probe for your phy and
notice that it is not there and print a message: "Dude! Select isp1301
for OHCI, aight?!"



Thanks,

Roland


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


Re: [PATCH 1/2] usb: change the dependency chain for LPC32XX and ISP1301

2012-08-23 Thread Roland Stigge
On 08/23/2012 10:29 AM, Sebastian Andrzej Siewior wrote:
>> For the PNX4008 removal - should I already post a patch to build the
>> respective changes on top of, without PNX4008 references?
> 
> If nobody cares about PNX4008 and nobody tested if it actually works in
> the OHCI mode I don't see the point in keeping it around especially if
> there are rumors to remove the arch.
> 
> It would be nice, if you could manage to compile this thingy without
> I2C. In the end one could attach something different than isp1301, no?
> So I think, in the perfect world you would probe for your phy and
> notice that it is not there and print a message: "Dude! Select isp1301
> for OHCI, aight?!"

Currently, we really need I2C for OHCI on LPC32XX, so actually need to
depend on it. Removing the I2C calls in ohci-nxp.c is waiting for the
phy framework so that I don't need to introduce new API in isp1301.c at
this point.

And right, in the ideal world, we have no I2C dependency and can control
a phy in an abstract way, even without depending on ISP1301, which could
be replaced by sth. else (not sure if this will be done/soldered
practically, though).

For now, will post patches for the current I2C dependency and the
PNX4008 removal.

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


[GIT PULL] USB fixes for v3.6-rc4

2012-08-23 Thread Felipe Balbi
Hi Greg,

Here's my (hopefully) last set of fixes for v3.6-rc cycle. Let me know if you
want me to change anything and I'll do so ASAP.

cheers

The following changes since commit 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee:

  Linux 3.6-rc1 (2012-08-02 16:38:10 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
tags/fixes-for-v3.6-rc4

for you to fetch changes up to 07dc6cb73678e5a2bdaed74774b9064d27b8da0d:

  usb: renesas_usbhs: fixup DMA transport data alignment (2012-08-23 11:05:40 
+0300)


(from the branch description for fixes local branch)


usb: fixes for v3.6-rc4

Here's a rather big set of fixes for v3.6-rc4.

There are some fixes for bugs which have been pending for a long
time and only now were uncovered, like the musb and dwc3 patches.

We have some remaining fixes for the ep->desc patch series from
Ido, and a very important fix to u_ether which would cause 100%
cpu utilization in eth_stop.

All patches have been pending on linux-usb for a long time and
shouldn't cause any further regressions.


Ajay Kumar Gupta (3):
  usb: musb: Fix wrong config for am33xx and ti81xx
  usb: musb: am335x: fix pdev resource bug
  usb: musb: reorder runtime pm call

Andrzej Pietrasiewicz (1):
  usb: gadget: add multiple definition guards

Julia Lawall (1):
  usb: gadget: s3c-hsotg.c: fix error return code

Kishon Vijay Abraham I (1):
  usb: dwc3: core: fix incorrect usage of resource pointer

Kuninori Morimoto (3):
  usb: renesas_usbhs: mod_host: add missing .bus_suspend/resume
  usb: renesas_usbhs: fixup resume method for autonomy mode
  usb: renesas_usbhs: fixup DMA transport data alignment

Michael Grzeschik (1):
  usb: gadget: u_ether: fix kworker 100% CPU issue with still used 
interfaces in eth_stop

Pratyush Anand (1):
  usb: dwc3: ep0: correct cache sync issue in case of ep0_bounced

Sebastian Andrzej Siewior (4):
  usb: gadget: dummy_hcd: fixup error probe path
  usb: gadget: dummy_hcd: add support for USB_DT_BOS on rh
  usb: gadget: at91udc: don't overwrite driver data
  usb: gadget: at91udc: Don't check for ep->ep.desc

Sergei Shtylyov (2):
  usb: musb: tusb6010: fix error path in tusb_probe()
  usb: musb: musbhsdma: fix IRQ check

yuzheng ma (1):
  usb: musb: host: fix for musb_start_urb Oops

 drivers/usb/dwc3/core.c  |  9 ++--
 drivers/usb/dwc3/ep0.c   |  1 -
 drivers/usb/dwc3/gadget.c|  7 --
 drivers/usb/gadget/at91_udc.c|  6 +-
 drivers/usb/gadget/dummy_hcd.c   | 41 
 drivers/usb/gadget/f_fs.c|  4 
 drivers/usb/gadget/s3c-hsotg.c   |  3 +++
 drivers/usb/gadget/u_ether.c |  6 ++
 drivers/usb/gadget/u_serial.c|  4 
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/musb_dsps.c | 19 +
 drivers/usb/musb/musb_host.c |  2 +-
 drivers/usb/musb/musbhsdma.c |  2 +-
 drivers/usb/musb/tusb6010.c  |  2 +-
 drivers/usb/renesas_usbhs/common.c   |  6 +++---
 drivers/usb/renesas_usbhs/fifo.c |  4 ++--
 drivers/usb/renesas_usbhs/mod_host.c |  8 +++
 17 files changed, 95 insertions(+), 33 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe 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: [GIT PULL] USB fixes for v3.6-rc4

2012-08-23 Thread Marc Kleine-Budde
On 08/23/2012 11:03 AM, Felipe Balbi wrote:
> Hi Greg,
> 
> Here's my (hopefully) last set of fixes for v3.6-rc cycle. Let me know if you
> want me to change anything and I'll do so ASAP.
> 
> cheers
> 
> The following changes since commit 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee:
> 
>   Linux 3.6-rc1 (2012-08-02 16:38:10 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/fixes-for-v3.6-rc4
> 
> for you to fetch changes up to 07dc6cb73678e5a2bdaed74774b9064d27b8da0d:
> 
>   usb: renesas_usbhs: fixup DMA transport data alignment (2012-08-23 11:05:40 
> +0300)
> 
> 
> (from the branch description for fixes local branch)
> 
> 
> usb: fixes for v3.6-rc4
> 
> Here's a rather big set of fixes for v3.6-rc4.
> 
> There are some fixes for bugs which have been pending for a long
> time and only now were uncovered, like the musb and dwc3 patches.
> 
> We have some remaining fixes for the ep->desc patch series from
> Ido, and a very important fix to u_ether which would cause 100%
> cpu utilization in eth_stop.
> 
> All patches have been pending on linux-usb for a long time and
> shouldn't cause any further regressions.
> 
> 
> Ajay Kumar Gupta (3):
>   usb: musb: Fix wrong config for am33xx and ti81xx
>   usb: musb: am335x: fix pdev resource bug
>   usb: musb: reorder runtime pm call
> 
> Andrzej Pietrasiewicz (1):
>   usb: gadget: add multiple definition guards
> 
> Julia Lawall (1):
>   usb: gadget: s3c-hsotg.c: fix error return code
> 
> Kishon Vijay Abraham I (1):
>   usb: dwc3: core: fix incorrect usage of resource pointer
> 
> Kuninori Morimoto (3):
>   usb: renesas_usbhs: mod_host: add missing .bus_suspend/resume
>   usb: renesas_usbhs: fixup resume method for autonomy mode
>   usb: renesas_usbhs: fixup DMA transport data alignment
> 
> Michael Grzeschik (1):
>   usb: gadget: u_ether: fix kworker 100% CPU issue with still used 
> interfaces in eth_stop

This patch is already mainline:

$ git lg b1b552a69b8805e7e338074a9e8b670b4a795218 -1
b1b552a usb: gadget: u_ether: fix kworker 100% CPU issue with still used
interfaces in eth_stop

$ git describe --contains b1b552a69b8805e7e338074a9e8b670b4a795218
--match=v*
v3.6-rc3~19^2~13

cheers, Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH 2/9] usb/libcomposite: move config.c into libcomposite

2012-08-23 Thread Sebastian Andrzej Siewior
This moves config.c into libcomposite and updates all gadgets.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/staging/ccg/ccg.c   |1 -
 drivers/usb/gadget/Makefile |2 +-
 drivers/usb/gadget/acm_ms.c |1 -
 drivers/usb/gadget/audio.c  |1 -
 drivers/usb/gadget/cdc2.c   |1 -
 drivers/usb/gadget/config.c |6 --
 drivers/usb/gadget/ether.c  |1 -
 drivers/usb/gadget/file_storage.c   |1 -
 drivers/usb/gadget/g_ffs.c  |1 -
 drivers/usb/gadget/gmidi.c  |1 -
 drivers/usb/gadget/hid.c|1 -
 drivers/usb/gadget/mass_storage.c   |1 -
 drivers/usb/gadget/multi.c  |1 -
 drivers/usb/gadget/ncm.c|1 -
 drivers/usb/gadget/nokia.c  |1 -
 drivers/usb/gadget/printer.c|1 -
 drivers/usb/gadget/serial.c |1 -
 drivers/usb/gadget/tcm_usb_gadget.c |1 -
 drivers/usb/gadget/webcam.c |1 -
 drivers/usb/gadget/zero.c   |1 -
 20 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
index c379b9f..0b31369 100644
--- a/drivers/staging/ccg/ccg.c
+++ b/drivers/staging/ccg/ccg.c
@@ -44,7 +44,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
-#include "../../usb/gadget/config.c"
 #include "../../usb/gadget/epautoconf.c"
 #include "composite.c"
 
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 4ff3f0c..f6387b4 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -5,7 +5,7 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_GADGET)   += udc-core.o
 obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
-libcomposite-y := usbstring.o
+libcomposite-y := usbstring.o config.o
 obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o
 obj-$(CONFIG_USB_NET2272)  += net2272.o
 obj-$(CONFIG_USB_NET2280)  += net2280.o
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 9820960..3078d79 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -42,7 +42,6 @@
  */
 
 #include "composite.c"
-#include "config.c"
 #include "epautoconf.c"
 #include "u_serial.c"
 #include "f_acm.c"
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 76e54b4..9e85df2 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -27,7 +27,6 @@
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "composite.c"
-#include "config.c"
 #include "epautoconf.c"
 
 /* string IDs are assigned dynamically */
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 74a9c7f..d06d079 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -44,7 +44,6 @@
  */
 
 #include "composite.c"
-#include "config.c"
 #include "epautoconf.c"
 #include "u_serial.c"
 #include "f_acm.c"
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 7542a72..e3a9892 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -53,7 +54,7 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen,
}
return dest - (u8 *)buf;
 }
-
+EXPORT_SYMBOL_GPL(usb_descriptor_fillbuf);
 
 /**
  * usb_gadget_config_buf - builts a complete configuration descriptor
@@ -106,6 +107,7 @@ int usb_gadget_config_buf(
cp->bmAttributes |= USB_CONFIG_ATT_ONE;
return len;
 }
+EXPORT_SYMBOL_GPL(usb_gadget_config_buf);
 
 /**
  * usb_copy_descriptors - copy a vector of USB descriptors
@@ -155,4 +157,4 @@ usb_copy_descriptors(struct usb_descriptor_header **src)
 
return ret;
 }
-
+EXPORT_SYMBOL_GPL(usb_copy_descriptors);
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index e16094e..557021e 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -103,7 +103,6 @@ static inline bool has_rndis(void)
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "composite.c"
-#include "config.c"
 #include "epautoconf.c"
 
 #include "f_ecm.c"
diff --git a/drivers/usb/gadget/file_storage.c 
b/drivers/usb/gadget/file_storage.c
index 8d0166b..77cf108 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -265,7 +265,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
-#include "config.c"
 #include "epautoconf.c"
 
 /*-*/
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 407b5cc..2409570 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -24,7 +24,6 @@
  */
 
 #

[PATCH 1/9] usb/gadget: start with libcomposite

2012-08-23 Thread Sebastian Andrzej Siewior
This patch aims to be simple. It removes #include usbstribgs.c line from each
gadget and creats libcomposite.ko which has only one member, that is
usbstribgs.c.
To avoid mass select statements in Kconfig I simply group the composite
based gadgets together. The three gadgets which are not part of the group
are:
- EHCI Debug Device Gadget. Could be converted to composite if anyone
  cares
- File-backed Storage Gadget. Replaced by "mass storage", will be
  removed soon.
- Gadget Filesystem. Functionality is provided by "Function Filesystem".
  Unfortunatelly can't be replaced because the user space visible API is
  different.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/staging/ccg/Kconfig |1 +
 drivers/staging/ccg/ccg.c   |1 -
 drivers/usb/gadget/Kconfig  |  116 ---
 drivers/usb/gadget/Makefile |2 +
 drivers/usb/gadget/acm_ms.c |1 -
 drivers/usb/gadget/audio.c  |1 -
 drivers/usb/gadget/cdc2.c   |1 -
 drivers/usb/gadget/ether.c  |1 -
 drivers/usb/gadget/file_storage.c   |1 -
 drivers/usb/gadget/g_ffs.c  |1 -
 drivers/usb/gadget/gmidi.c  |1 -
 drivers/usb/gadget/hid.c|1 -
 drivers/usb/gadget/mass_storage.c   |1 -
 drivers/usb/gadget/multi.c  |1 -
 drivers/usb/gadget/ncm.c|1 -
 drivers/usb/gadget/nokia.c  |1 -
 drivers/usb/gadget/printer.c|1 -
 drivers/usb/gadget/serial.c |1 -
 drivers/usb/gadget/tcm_usb_gadget.c |1 -
 drivers/usb/gadget/usbstring.c  |4 +-
 drivers/usb/gadget/webcam.c |1 -
 drivers/usb/gadget/zero.c   |1 -
 22 files changed, 72 insertions(+), 69 deletions(-)

diff --git a/drivers/staging/ccg/Kconfig b/drivers/staging/ccg/Kconfig
index 187bcdb..ef4f25b 100644
--- a/drivers/staging/ccg/Kconfig
+++ b/drivers/staging/ccg/Kconfig
@@ -3,6 +3,7 @@ if USB_GADGET
 config USB_G_CCG
tristate "Configurable Composite Gadget (STAGING)"
depends on STAGING && BLOCK
+   depends on USB_LIBCOMPOSITE
help
  The Configurable Composite Gadget supports multiple USB
  functions: acm, mass storage, rndis and FunctionFS.
diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
index d726a8d..c379b9f 100644
--- a/drivers/staging/ccg/ccg.c
+++ b/drivers/staging/ccg/ccg.c
@@ -44,7 +44,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
-#include "../../usb/gadget/usbstring.c"
 #include "../../usb/gadget/config.c"
 #include "../../usb/gadget/epautoconf.c"
 #include "composite.c"
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 1494112..c26c26c 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -507,6 +507,16 @@ config USB_GADGET_SUPERSPEED
 #
 # USB Gadget Drivers
 #
+
+# composite based drivers
+config USB_LIBCOMPOSITE
+   tristate "Lib composite based gadgets"
+   depends on USB_GADGET
+   help
+ Most gadgets are using the composite framework. There are only three
+ gadgets left which do not use the composite framework and two of them
+ have been replaced by alternatives.
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
@@ -526,6 +536,8 @@ choice
  not be able work with that controller, or might need to implement
  a less common variant of a device class protocol.
 
+if USB_LIBCOMPOSITE
+#
 # this first set of drivers all depend on bulk-capable hardware.
 
 config USB_ZERO
@@ -672,22 +684,6 @@ config USB_G_NCM
  Say "y" to link the driver statically, or "m" to build a
  dynamically linked module called "g_ncm".
 
-config USB_GADGETFS
-   tristate "Gadget Filesystem (EXPERIMENTAL)"
-   depends on EXPERIMENTAL
-   help
- This driver provides a filesystem based API that lets user mode
- programs implement a single-configuration USB device, including
- endpoint I/O and control requests that don't relate to enumeration.
- All endpoints, transfer speeds, and transfer types supported by
- the hardware are available, through read() and write() calls.
-
- Currently, this option is still labelled as EXPERIMENTAL because
- of existing race conditions in the underlying in-kernel AIO core.
-
- Say "y" to link the driver statically, or "m" to build a
- dynamically linked module called "gadgetfs".
-
 config USB_FUNCTIONFS
tristate "Function Filesystem (EXPERIMENTAL)"
depends on EXPERIMENTAL
@@ -726,31 +722,6 @@ config USB_FUNCTIONFS_GENERIC
  Include a configuration with the Function Filesystem alone with
  no Ethernet interface.
 
-config USB_FILE_STORAGE
-   tristate "File-backed Storage Gadget (DEPRECATED)"
-   depends on BLOCK
-   help
-   

[PATCH 3/9] usb/gadget: move global vars from epautoconf into struct usb_gadget

2012-08-23 Thread Sebastian Andrzej Siewior
epautoconf has two global variables which count the endpoint number
current endpoint assignet endpoint.
This patch removes the global variable and keeps it as per (UDC) gadget.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/usb/gadget/epautoconf.c |   23 ++-
 include/linux/usb/gadget.h  |6 ++
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 51f3d42..2c6c61f 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,17 +22,6 @@
 
 #include "gadget_chips.h"
 
-
-/* we must assign addresses for configurable endpoints (like net2280) */
-static unsigned epnum;
-
-// #define MANY_ENDPOINTS
-#ifdef MANY_ENDPOINTS
-/* more than 15 configurable endpoints */
-static unsigned in_epnum;
-#endif
-
-
 /*
  * This should work with endpoints from controller drivers sharing the
  * same endpoint naming convention.  By example:
@@ -178,14 +167,14 @@ ep_matches (
desc->bEndpointAddress |= num;
 #ifdef MANY_ENDPOINTS
} else if (desc->bEndpointAddress & USB_DIR_IN) {
-   if (++in_epnum > 15)
+   if (++gadget->in_epnum > 15)
return 0;
-   desc->bEndpointAddress = USB_DIR_IN | in_epnum;
+   desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum;
 #endif
} else {
-   if (++epnum > 15)
+   if (++gadget->epnum > 15)
return 0;
-   desc->bEndpointAddress |= epnum;
+   desc->bEndpointAddress |= gadget->epnum;
}
 
/* report (variable) full speed bulk maxpacket */
@@ -386,8 +375,8 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
ep->driver_data = NULL;
}
 #ifdef MANY_ENDPOINTS
-   in_epnum = 0;
+   gadget->in_epnum = 0;
 #endif
-   epnum = 0;
+   gadget->epnum = 0;
 }
 
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index fdf85a7..01fe02a 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -537,6 +537,12 @@ struct usb_gadget {
unsigneda_alt_hnp_support:1;
const char  *name;
struct device   dev;
+   unsignedepnum;
+/* #define MANY_ENDPOINTS */
+#ifdef MANY_ENDPOINTS
+   /* more than 15 configurable endpoints */
+   unsignedin_epnum;
+#endif
 };
 
 static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
-- 
1.7.10.4

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


[PATCH 4/9] usb/gadget: add epautoconf.c to libcomposite

2012-08-23 Thread Sebastian Andrzej Siewior
This adds epautoconf.c into libcomposite and updates all gadgets.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/staging/ccg/ccg.c   |1 -
 drivers/usb/gadget/Makefile |2 +-
 drivers/usb/gadget/acm_ms.c |1 -
 drivers/usb/gadget/audio.c  |2 +-
 drivers/usb/gadget/cdc2.c   |1 -
 drivers/usb/gadget/dbgp.c   |3 ---
 drivers/usb/gadget/epautoconf.c |6 --
 drivers/usb/gadget/ether.c  |1 -
 drivers/usb/gadget/file_storage.c   |   13 -
 drivers/usb/gadget/g_ffs.c  |1 -
 drivers/usb/gadget/gadget_chips.h   |2 ++
 drivers/usb/gadget/gmidi.c  |1 -
 drivers/usb/gadget/hid.c|2 +-
 drivers/usb/gadget/mass_storage.c   |1 -
 drivers/usb/gadget/multi.c  |1 -
 drivers/usb/gadget/ncm.c|1 -
 drivers/usb/gadget/nokia.c  |1 -
 drivers/usb/gadget/printer.c|1 -
 drivers/usb/gadget/serial.c |1 -
 drivers/usb/gadget/tcm_usb_gadget.c |1 -
 drivers/usb/gadget/webcam.c |1 -
 drivers/usb/gadget/zero.c   |1 -
 22 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
index 0b31369..1f6c249 100644
--- a/drivers/staging/ccg/ccg.c
+++ b/drivers/staging/ccg/ccg.c
@@ -44,7 +44,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
-#include "../../usb/gadget/epautoconf.c"
 #include "composite.c"
 
 #include "../../usb/gadget/f_mass_storage.c"
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f6387b4..d394162 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -5,7 +5,7 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_GADGET)   += udc-core.o
 obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
-libcomposite-y := usbstring.o config.o
+libcomposite-y := usbstring.o config.o epautoconf.o
 obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o
 obj-$(CONFIG_USB_NET2272)  += net2272.o
 obj-$(CONFIG_USB_NET2280)  += net2280.o
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 3078d79..5db661d 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -42,7 +42,6 @@
  */
 
 #include "composite.c"
-#include "epautoconf.c"
 #include "u_serial.c"
 #include "f_acm.c"
 #include "f_mass_storage.c"
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 9e85df2..689d142 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 
+#include "gadget_chips.h"
 #define DRIVER_DESC"Linux USB Audio Gadget"
 #define DRIVER_VERSION "Feb 2, 2012"
 
@@ -27,7 +28,6 @@
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "composite.c"
-#include "epautoconf.c"
 
 /* string IDs are assigned dynamically */
 
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index d06d079..8e386cf 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -44,7 +44,6 @@
  */
 
 #include "composite.c"
-#include "epautoconf.c"
 #include "u_serial.c"
 #include "f_acm.c"
 #include "f_ecm.c"
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c
index cc17465..87d1650 100644
--- a/drivers/usb/gadget/dbgp.c
+++ b/drivers/usb/gadget/dbgp.c
@@ -13,9 +13,6 @@
 #include 
 #include 
 
-/* See comments in "zero.c" */
-#include "epautoconf.c"
-
 #ifdef CONFIG_USB_G_DBGP_SERIAL
 #include "u_serial.c"
 #endif
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 2c6c61f..28113f9 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -317,6 +318,7 @@ found_ep:
ep->comp_desc = NULL;
return ep;
 }
+EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss);
 
 /**
  * usb_ep_autoconfig() - choose an endpoint matching the
@@ -356,7 +358,7 @@ struct usb_ep *usb_ep_autoconfig(
 {
return usb_ep_autoconfig_ss(gadget, desc, NULL);
 }
-
+EXPORT_SYMBOL(usb_ep_autoconfig);
 
 /**
  * usb_ep_autoconfig_reset - reset endpoint autoconfig state
@@ -379,4 +381,4 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
 #endif
gadget->epnum = 0;
 }
-
+EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset);
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 557021e..39eb718 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -103,7 +103,6 @@ static inline bool has_rndis(void)
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #include "composite.c"
-#include "epautoconf.c"
 
 #include "f_ecm.c"
 #include "f_subset.c"
diff --git a/drivers/usb/gadget/file_storage.c 
b/drivers/usb/gadget/file_storage

[PATCH 5/9] staging/ccg: make composite.c function static and remove unsused

2012-08-23 Thread Sebastian Andrzej Siewior
The next step is to move composite.c into the library. Since the Android
gadget has its composite.c copy this make makes sure both symbols do not
clash by making the symbols static. The unused functions are removed.
This patch also provides a local copy of composite.h because the
prototype is now different due to the static attribute.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/staging/ccg/ccg.c   |2 +-
 drivers/staging/ccg/composite.c |  117 ++---
 drivers/staging/ccg/composite.h |  368 +++
 3 files changed, 379 insertions(+), 108 deletions(-)
 create mode 100644 drivers/staging/ccg/composite.h

diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
index 1f6c249..453c0ea 100644
--- a/drivers/staging/ccg/ccg.c
+++ b/drivers/staging/ccg/ccg.c
@@ -32,9 +32,9 @@
 #include 
 
 #include 
-#include 
 #include 
 
+#include "composite.h"
 #include "gadget_chips.h"
 
 /*
diff --git a/drivers/staging/ccg/composite.c b/drivers/staging/ccg/composite.c
index 9391f3b..f00b0388 100644
--- a/drivers/staging/ccg/composite.c
+++ b/drivers/staging/ccg/composite.c
@@ -112,7 +112,7 @@ next_ep_desc(struct usb_descriptor_header **t)
  * Note: the supplied function should hold all the descriptors
  * for supported speeds
  */
-int config_ep_by_speed(struct usb_gadget *g,
+static int config_ep_by_speed(struct usb_gadget *g,
struct usb_function *f,
struct usb_ep *_ep)
 {
@@ -206,7 +206,7 @@ ep_found:
  * This function returns the value of the function's bind(), which is
  * zero for success else a negative errno value.
  */
-int usb_add_function(struct usb_configuration *config,
+static int usb_add_function(struct usb_configuration *config,
struct usb_function *function)
 {
int value = -EINVAL;
@@ -251,72 +251,6 @@ done:
 }
 
 /**
- * usb_function_deactivate - prevent function and gadget enumeration
- * @function: the function that isn't yet ready to respond
- *
- * Blocks response of the gadget driver to host enumeration by
- * preventing the data line pullup from being activated.  This is
- * normally called during @bind() processing to change from the
- * initial "ready to respond" state, or when a required resource
- * becomes available.
- *
- * For example, drivers that serve as a passthrough to a userspace
- * daemon can block enumeration unless that daemon (such as an OBEX,
- * MTP, or print server) is ready to handle host requests.
- *
- * Not all systems support software control of their USB peripheral
- * data pullups.
- *
- * Returns zero on success, else negative errno.
- */
-int usb_function_deactivate(struct usb_function *function)
-{
-   struct usb_composite_dev*cdev = function->config->cdev;
-   unsigned long   flags;
-   int status = 0;
-
-   spin_lock_irqsave(&cdev->lock, flags);
-
-   if (cdev->deactivations == 0)
-   status = usb_gadget_disconnect(cdev->gadget);
-   if (status == 0)
-   cdev->deactivations++;
-
-   spin_unlock_irqrestore(&cdev->lock, flags);
-   return status;
-}
-
-/**
- * usb_function_activate - allow function and gadget enumeration
- * @function: function on which usb_function_activate() was called
- *
- * Reverses effect of usb_function_deactivate().  If no more functions
- * are delaying their activation, the gadget driver will respond to
- * host enumeration procedures.
- *
- * Returns zero on success, else negative errno.
- */
-int usb_function_activate(struct usb_function *function)
-{
-   struct usb_composite_dev*cdev = function->config->cdev;
-   unsigned long   flags;
-   int status = 0;
-
-   spin_lock_irqsave(&cdev->lock, flags);
-
-   if (WARN_ON(cdev->deactivations == 0))
-   status = -EINVAL;
-   else {
-   cdev->deactivations--;
-   if (cdev->deactivations == 0)
-   status = usb_gadget_connect(cdev->gadget);
-   }
-
-   spin_unlock_irqrestore(&cdev->lock, flags);
-   return status;
-}
-
-/**
  * usb_interface_id() - allocate an unused interface ID
  * @config: configuration associated with the interface
  * @function: function handling the interface
@@ -339,7 +273,7 @@ int usb_function_activate(struct usb_function *function)
  * Returns the interface ID which was allocated; or -ENODEV if no
  * more interface IDs can be allocated.
  */
-int usb_interface_id(struct usb_configuration *config,
+static int usb_interface_id(struct usb_configuration *config,
struct usb_function *function)
 {
unsigned id = config->next_interface_id;
@@ -710,7 +644,7 @@ done:
  * assigns global resources including string IDs, and per-configuration
  * resources such as interface IDs and endpoints.
  */
-int usb_add_config(struct usb_composite_dev *cdev,
+static int usb_add_config(st

[PATCH 6/9] usb/gadget: move USB_BUFSIZ into global composite.h

2012-08-23 Thread Sebastian Andrzej Siewior
This patch moves USB_BUFSIZ into global header file as
USB_COMP_EP0_BUFSIZ. There is currently only one user (f_sourcesink)
besides composite which needs it. Ideally f_sourcesink would have its
own ep0 buffer. Lets keep it that way it was for now.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/usb/gadget/composite.c|   10 --
 drivers/usb/gadget/f_sourcesink.c |2 +-
 include/linux/usb/composite.h |3 +++
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 598df69..e380a05 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -28,9 +28,6 @@
  * with the relevant device-wide data.
  */
 
-/* big enough to hold our biggest descriptor */
-#define USB_BUFSIZ 1024
-
 /* Some systems will need runtime overrides for the  product identifiers
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
@@ -355,10 +352,11 @@ static int config_buf(struct usb_configuration *config,
 {
struct usb_config_descriptor*c = buf;
void*next = buf + USB_DT_CONFIG_SIZE;
-   int len = USB_BUFSIZ - USB_DT_CONFIG_SIZE;
+   int len;
struct usb_function *f;
int status;
 
+   len = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE;
/* write the config descriptor */
c = buf;
c->bLength = USB_DT_CONFIG_SIZE;
@@ -1445,13 +1443,13 @@ static int composite_bind(struct usb_gadget *gadget,
cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
if (!cdev->req)
goto fail;
-   cdev->req->buf = kmalloc(USB_BUFSIZ, GFP_KERNEL);
+   cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
if (!cdev->req->buf)
goto fail;
cdev->req->complete = composite_setup_complete;
gadget->ep0->driver_data = cdev;
 
-   cdev->bufsiz = USB_BUFSIZ;
+   cdev->bufsiz = USB_COMP_EP0_BUFSIZ;
cdev->driver = cdriver;
 
/*
diff --git a/drivers/usb/gadget/f_sourcesink.c 
b/drivers/usb/gadget/f_sourcesink.c
index 5c1b68b..3c126fd 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -795,7 +795,7 @@ static int sourcesink_setup(struct usb_configuration *c,
u16 w_value = le16_to_cpu(ctrl->wValue);
u16 w_length = le16_to_cpu(ctrl->wLength);
 
-   req->length = USB_BUFSIZ;
+   req->length = USB_COMP_EP0_BUFSIZ;
 
/* composite driver infrastructure handles everything except
 * the two control test requests.
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 43d6b9c..89d91b6 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -46,6 +46,9 @@
  */
 #define USB_GADGET_DELAYED_STATUS   0x7fff /* Impossibly large value */
 
+/* big enough to hold our biggest descriptor */
+#define USB_COMP_EP0_BUFSIZ1024
+
 struct usb_configuration;
 
 /**
-- 
1.7.10.4

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


[PATCH 7/9] usb/gadget: remove bufsiz from struct usb_composite_dev

2012-08-23 Thread Sebastian Andrzej Siewior
there is no read user of bufsiz, its content is available via
USB_COMP_EP0_BUFSIZ. Remove it.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/usb/gadget/composite.c |1 -
 include/linux/usb/composite.h  |2 --
 2 files changed, 3 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index e380a05..0f548fe 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1449,7 +1449,6 @@ static int composite_bind(struct usb_gadget *gadget,
cdev->req->complete = composite_setup_complete;
gadget->ep0->driver_data = cdev;
 
-   cdev->bufsiz = USB_COMP_EP0_BUFSIZ;
cdev->driver = cdriver;
 
/*
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 89d91b6..e970fba 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -318,7 +318,6 @@ extern void usb_composite_setup_continue(struct 
usb_composite_dev *cdev);
  * struct usb_composite_device - represents one composite usb gadget
  * @gadget: read-only, abstracts the gadget's usb peripheral controller
  * @req: used for control responses; buffer is pre-allocated
- * @bufsiz: size of buffer pre-allocated in @req
  * @config: the currently active configuration
  *
  * One of these devices is allocated and initialized before the
@@ -349,7 +348,6 @@ extern void usb_composite_setup_continue(struct 
usb_composite_dev *cdev);
 struct usb_composite_dev {
struct usb_gadget   *gadget;
struct usb_request  *req;
-   unsignedbufsiz;
 
struct usb_configuration*config;
 
-- 
1.7.10.4

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


[PATCH 8/9] usb/gadget: make composite module options readonly only

2012-08-23 Thread Sebastian Andrzej Siewior
This is a partly revert of 4fffd6e5 ("usb: gadget: composite: make
module parameters accessible at runtime").
It is not possible to change the VID or other properly for a gadget
right now. This change has been made for Anrdoid gadget which has this
change in its copy of the file. This function is executed currently only
once and post caller in tree __init.

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/usb/gadget/composite.c |   20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 0f548fe..153efc4 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -34,27 +34,27 @@
  */
 
 static ushort idVendor;
-module_param(idVendor, ushort, 0644);
+module_param(idVendor, ushort, S_IRUGO);
 MODULE_PARM_DESC(idVendor, "USB Vendor ID");
 
 static ushort idProduct;
-module_param(idProduct, ushort, 0644);
+module_param(idProduct, ushort, S_IRUGO);
 MODULE_PARM_DESC(idProduct, "USB Product ID");
 
 static ushort bcdDevice;
-module_param(bcdDevice, ushort, 0644);
+module_param(bcdDevice, ushort, S_IRUGO);
 MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
 
 static char *iManufacturer;
-module_param(iManufacturer, charp, 0644);
+module_param(iManufacturer, charp, S_IRUGO);
 MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
 
 static char *iProduct;
-module_param(iProduct, charp, 0644);
+module_param(iProduct, charp, S_IRUGO);
 MODULE_PARM_DESC(iProduct, "USB Product string");
 
 static char *iSerialNumber;
-module_param(iSerialNumber, charp, 0644);
+module_param(iSerialNumber, charp, S_IRUGO);
 MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");
 
 static char composite_manufacturer[50];
@@ -1478,16 +1478,12 @@ static int composite_bind(struct usb_gadget *gadget,
/* standardized runtime overrides for device ID data */
if (idVendor)
cdev->desc.idVendor = cpu_to_le16(idVendor);
-   else
-   idVendor = le16_to_cpu(cdev->desc.idVendor);
+
if (idProduct)
cdev->desc.idProduct = cpu_to_le16(idProduct);
-   else
-   idProduct = le16_to_cpu(cdev->desc.idProduct);
+
if (bcdDevice)
cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
-   else
-   bcdDevice = le16_to_cpu(cdev->desc.bcdDevice);
 
/* string overrides */
if (iManufacturer || !cdev->desc.iManufacturer) {
-- 
1.7.10.4

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


[PATCH 9/9] usb/gadget: push VID/PID/USB BCD module option into gadgets

2012-08-23 Thread Sebastian Andrzej Siewior
This patch moves the module options idVendor, idProduct and bcdDevice
from composite.c into each gadgets. This ensures compatibility with
current gadgets and removes the global variable which brings me step
closer towards composite.c in libcomposite

Signed-off-by: Sebastian Andrzej Siewior 
---
 drivers/usb/gadget/acm_ms.c |3 ++-
 drivers/usb/gadget/audio.c  |3 ++-
 drivers/usb/gadget/cdc2.c   |3 ++-
 drivers/usb/gadget/composite.c  |   23 ---
 drivers/usb/gadget/ether.c  |3 ++-
 drivers/usb/gadget/g_ffs.c  |4 +++-
 drivers/usb/gadget/gmidi.c  |3 ++-
 drivers/usb/gadget/hid.c|2 ++
 drivers/usb/gadget/mass_storage.c   |3 ++-
 drivers/usb/gadget/multi.c  |3 ++-
 drivers/usb/gadget/ncm.c|2 ++
 drivers/usb/gadget/nokia.c  |2 ++
 drivers/usb/gadget/printer.c|9 -
 drivers/usb/gadget/serial.c |2 ++
 drivers/usb/gadget/tcm_usb_gadget.c |4 
 drivers/usb/gadget/webcam.c |2 ++
 drivers/usb/gadget/zero.c   |2 ++
 include/linux/usb/composite.h   |   28 
 18 files changed, 69 insertions(+), 32 deletions(-)

diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 5db661d..bef987a 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -151,7 +151,7 @@ static struct usb_configuration acm_ms_config_driver = {
 };
 
 /*-*/
-
+USB_GADGET_COMPOSITE_OPTIONS();
 static int __init acm_ms_bind(struct usb_composite_dev *cdev)
 {
int gcnum;
@@ -209,6 +209,7 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
if (status < 0)
goto fail1;
 
+   USB_GADGET_COMPOSITE_OVERWRITE_VID_PID_BCD(device_desc);
dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
DRIVER_DESC);
fsg_common_put(&fsg_common);
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 689d142..2d05734 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -144,7 +144,7 @@ static struct usb_configuration audio_config_driver = {
 };
 
 /*-*/
-
+USB_GADGET_COMPOSITE_OPTIONS();
 static int __init audio_bind(struct usb_composite_dev *cdev)
 {
int gcnum;
@@ -180,6 +180,7 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
status = usb_add_config(cdev, &audio_config_driver, audio_do_config);
if (status < 0)
goto fail;
+   USB_GADGET_COMPOSITE_OVERWRITE_VID_PID_BCD(device_desc);
 
INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION);
return 0;
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 8e386cf..8878414 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -146,7 +146,7 @@ static struct usb_configuration cdc_config_driver = {
 };
 
 /*-*/
-
+USB_GADGET_COMPOSITE_OPTIONS();
 static int __init cdc_bind(struct usb_composite_dev *cdev)
 {
int gcnum;
@@ -210,6 +210,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
if (status < 0)
goto fail1;
 
+   USB_GADGET_COMPOSITE_OVERWRITE_VID_PID_BCD(device_desc);
dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
DRIVER_DESC);
 
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 153efc4..aac450e 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -32,19 +32,6 @@
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
  */
-
-static ushort idVendor;
-module_param(idVendor, ushort, S_IRUGO);
-MODULE_PARM_DESC(idVendor, "USB Vendor ID");
-
-static ushort idProduct;
-module_param(idProduct, ushort, S_IRUGO);
-MODULE_PARM_DESC(idProduct, "USB Product ID");
-
-static ushort bcdDevice;
-module_param(bcdDevice, ushort, S_IRUGO);
-MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
-
 static char *iManufacturer;
 module_param(iManufacturer, charp, S_IRUGO);
 MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
@@ -1475,16 +1462,6 @@ static int composite_bind(struct usb_gadget *gadget,
 
cdev->desc = *cdriver->dev;
 
-   /* standardized runtime overrides for device ID data */
-   if (idVendor)
-   cdev->desc.idVendor = cpu_to_le16(idVendor);
-
-   if (idProduct)
-   cdev->desc.idProduct = cpu_to_le16(idProduct);
-
-   if (bcdDevice)
-   cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
-
/* string overrides */

Re: PROBLEM: Certain USB devices wake up the system after power off

2012-08-23 Thread Àlex Magaz Graça

El 22/08/12 18:43, Alan Stern escribió:

On Wed, 22 Aug 2012, Àlex Magaz Graça wrote:


Hi,

[1.] One line summary of the problem:
Certain USB devices wake up the system after power off

[2.] Full description of the problem/report:

The computer no longer shuts down properly after upgrading from Ubuntu
11.04 to 11.10 (this is from kernel 2.6.38 to 3.0.20 (*)), it powers on
immediately after being shut down.

WORKAROUND: It doesn't happen if any of the problematic USB devices are
not plugged.

I perform the following the following steps:

1. Switch to a virtual terminal (no XWindow) and log in.
2. Run: sudo poweroff
3. The computer shuts down (I see how all LEDs switch off and hear the
hard drive stopping).
4. Immediately the computer powers on again.

It only fails when the device is plugged in on the back USB ports, NOT
in the ones in the front panel.
- Fails with: WiFi card or pendrive.
- Doesn't fail with: printer, keyboard/mouse wireless receiver,
bluetooth dongle.

If I boot passing acpi=off to the kernel command line, the computer
doesn't shut down.

After bisecting I've found the problem was introduced in commit
c61875977458637226ab093a35d200f2d5789787. OHCI: final fix for NVIDIA
problems (I hope).

That patch affects shutdown for all OHCI controllers, not just NVIDIA
controllers.  On the other hand, it's strange that the problem is
triggered only by devices that don't use OHCI.

Have you checked for any BIOS updates from the manufacturer?

The lsusb output attached to your bug report indicates that only two
devices were plugged in: the WiFi card and the wireless receiver.
What happens if the only USB device attached is the WiFi card?  (For
best testing, unplug the receiver and other things before you boot.)

Please post the output from:

ls -d /sys/bus/pci/drivers/?hci_hcd/*/usb?

Also, post the output from "lsusb" with the WiFi card plugged
into a rear port and the pendrive plugged into a front port.

Alan Stern



Sorry, I forgot to check for BIOS updates. After updating the BIOS the 
problem is fixed.


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


Re: [PATCH 1/2] usb: change the dependency chain for LPC32XX and ISP1301

2012-08-23 Thread Roland Stigge
On 08/23/2012 09:18 AM, Sebastian Andrzej Siewior wrote:
> On 08/22/2012 09:49 PM, Alan Stern wrote:
>>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>>> index c3f619b..cac3ee2 100644
>>> --- a/drivers/usb/host/Kconfig
>>> +++ b/drivers/usb/host/Kconfig
>>> @@ -292,7 +292,6 @@ config USB_OHCI_HCD
>>>   depends on USB&&  USB_ARCH_HAS_OHCI
>>>   select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
>>>   select USB_OTG_UTILS if ARCH_OMAP
>>> -select USB_ISP1301 if ARCH_LPC32XX || ARCH_PNX4008
>>
>> You want to avoid selecting USB_ISP1301, right?
> 
> Yes. "depends on USB_ISP1301 if ARCH_LPC32XX" does not work.

How about:

depends on USB_ISP1301 || !(ARCH_LPC32XX || ARCH_PNX4008)

or

depends on USB_ISP1301 || !ARCH_LPC32XX

resp.? (Emulates "depends on USB_ISP1301 if ARCH_LPC32XX".)

Roland
--
To unsubscribe from this list: send the line "unsubscribe 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: [PATCHv4 3/9] serial: vt8500: Add devicetree support for vt8500-serial

2012-08-23 Thread Alan Cox
On Thu, 23 Aug 2012 19:35:39 +1200
Tony Prisk  wrote:

> Increase vt8500_max_ports to 6 as the WM8505 as 6 available uarts.
> Use devicetree port id as primary addressing for ports but allow
> auto-allocation if id not specified.

Acked-by: Alan Cox 

for the serial bits
--
To unsubscribe from this list: send the line "unsubscribe 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: [PATCHv4 0/9] *** ARM: Update arch-vt8500 to Devicetree ***

2012-08-23 Thread Arnd Bergmann
On Thursday 23 August 2012, Tony Prisk wrote:
> Patchset based on Arnd's arm-soc/for-next branch.
> 
> 
> Could I get this reviewed, hopefully for inclusion into v3.7.

I can take them into the arm-soc tree if there are no new comments.
For the last two patches, you need to get an Acked-by comment from the
gpio and clk maintainers, respectively, or you should send them
the patches for inclusion in those subsystem trees.

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


[PATCH] usb: ohci: Fix Kconfig dependency on USB_ISP1301

2012-08-23 Thread Roland Stigge
With "select USB_ISP1301 ...", it could happen that I2C isn't selected although
USB_ISP1301 depends on it. Fixing with "depends on ..." and emulating the
condition via "|| !()".

Signed-off-by: Roland Stigge 
---
 drivers/usb/host/Kconfig |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -292,7 +292,7 @@ config USB_OHCI_HCD
depends on USB && USB_ARCH_HAS_OHCI
select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
select USB_OTG_UTILS if ARCH_OMAP
-   select USB_ISP1301 if ARCH_LPC32XX || ARCH_PNX4008
+   depends on USB_ISP1301 || !(ARCH_LPC32XX || ARCH_PNX4008)
---help---
  The Open Host Controller Interface (OHCI) is a standard for accessing
  USB 1.1 host controller hardware.  It does more in hardware than 
Intel's
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] usb/gadget: start with libcomposite

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> This patch aims to be simple. It removes #include usbstribgs.c line from each
> gadget and creats libcomposite.ko which has only one member, that is
> usbstribgs.c.
> To avoid mass select statements in Kconfig I simply group the composite
> based gadgets together. The three gadgets which are not part of the group
> are:
> - EHCI Debug Device Gadget. Could be converted to composite if anyone
>   cares
> - File-backed Storage Gadget. Replaced by "mass storage", will be
>   removed soon.
> - Gadget Filesystem. Functionality is provided by "Function Filesystem".
>   Unfortunatelly can't be replaced because the user space visible API is
>   different.
>
> Signed-off-by: Sebastian Andrzej Siewior 

Perhaps also wrap declaration of usb_gadget_get_string() with an #ifdef
in include/linux/usb/gadget.h?  This way, anything trying to use the
function w/o USB_LIBCOMPOSITE selected will fail to compile rather than
failing to load.

Also, I would personally prefer having selects in Kconfig since I don't
see the need for user who compiles the kernel to know about or
understand the distinction between composite and “raw” gadgets.

Other than that:

Acked-by: Michal Nazarewicz 

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpWRmx6lfiYO.pgp
Description: PGP signature


Re: [PATCH 2/9] usb/libcomposite: move config.c into libcomposite

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> This moves config.c into libcomposite and updates all gadgets.
>
> Signed-off-by: Sebastian Andrzej Siewior 

Acked-by: Michal Nazarewicz 

> diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
> index 7542a72..e3a9892 100644
> --- a/drivers/usb/gadget/config.c
> +++ b/drivers/usb/gadget/config.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -53,7 +54,7 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen,
>   }
>   return dest - (u8 *)buf;
>  }
> -
> +EXPORT_SYMBOL_GPL(usb_descriptor_fillbuf);

Interestingly, this is only used in composite.c and config.c, so maybe
in the end we would be able to drop this EXPORT_SYMBOL?

>  /**
>   * usb_gadget_config_buf - builts a complete configuration descriptor
> @@ -106,6 +107,7 @@ int usb_gadget_config_buf(
>   cp->bmAttributes |= USB_CONFIG_ATT_ONE;
>   return len;
>  }
> +EXPORT_SYMBOL_GPL(usb_gadget_config_buf);
>  
>  /**
>   * usb_copy_descriptors - copy a vector of USB descriptors
> @@ -155,4 +157,4 @@ usb_copy_descriptors(struct usb_descriptor_header **src)
>  
>   return ret;
>  }
> -
> +EXPORT_SYMBOL_GPL(usb_copy_descriptors);

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpz3LApAiYBm.pgp
Description: PGP signature


Re: [PATCH 3/9] usb/gadget: move global vars from epautoconf into struct usb_gadget

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> epautoconf has two global variables which count the endpoint number
> current endpoint assignet endpoint.
> This patch removes the global variable and keeps it as per (UDC) gadget.
>
> Signed-off-by: Sebastian Andrzej Siewior 
> ---
>  drivers/usb/gadget/epautoconf.c |   23 ++-
>  include/linux/usb/gadget.h  |6 ++
>  2 files changed, 12 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
> index 51f3d42..2c6c61f 100644
> --- a/drivers/usb/gadget/epautoconf.c
> +++ b/drivers/usb/gadget/epautoconf.c
> @@ -22,17 +22,6 @@
>  
>  #include "gadget_chips.h"
>  
> -
> -/* we must assign addresses for configurable endpoints (like net2280) */
> -static unsigned epnum;
> -
> -// #define MANY_ENDPOINTS
> -#ifdef MANY_ENDPOINTS
> -/* more than 15 configurable endpoints */
> -static unsigned in_epnum;
> -#endif
> -
> -
>  /*
>   * This should work with endpoints from controller drivers sharing the
>   * same endpoint naming convention.  By example:
> @@ -178,14 +167,14 @@ ep_matches (
>   desc->bEndpointAddress |= num;
>  #ifdef   MANY_ENDPOINTS
>   } else if (desc->bEndpointAddress & USB_DIR_IN) {
> - if (++in_epnum > 15)
> + if (++gadget->in_epnum > 15)
>   return 0;
> - desc->bEndpointAddress = USB_DIR_IN | in_epnum;
> + desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum;
>  #endif
>   } else {
> - if (++epnum > 15)
> + if (++gadget->epnum > 15)
>   return 0;
> - desc->bEndpointAddress |= epnum;
> + desc->bEndpointAddress |= gadget->epnum;
>   }
>  
>   /* report (variable) full speed bulk maxpacket */
> @@ -386,8 +375,8 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
>   ep->driver_data = NULL;
>   }
>  #ifdef   MANY_ENDPOINTS
> - in_epnum = 0;
> + gadget->in_epnum = 0;
>  #endif
> - epnum = 0;
> + gadget->epnum = 0;
>  }
>  
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index fdf85a7..01fe02a 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -537,6 +537,12 @@ struct usb_gadget {
>   unsigneda_alt_hnp_support:1;
>   const char  *name;
>   struct device   dev;
> + unsignedepnum;
> +/* #define MANY_ENDPOINTS */
> +#ifdef MANY_ENDPOINTS
> + /* more than 15 configurable endpoints */
> + unsignedin_epnum;
> +#endif
>  };

This looks tricky.  At the moment, MANY_ENDPOINTS is not defined
anywhere, but if for some reason someone tries to define it in some
composite gadgets, we may end up with different definitions of
usb_gadget structure.  It appears to me that we should drop this all
together or switch it to Kconfig option.

>  static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
> -- 
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpUYucrTGj6B.pgp
Description: PGP signature


Re: [PATCH 1/9] usb/gadget: start with libcomposite

2012-08-23 Thread Sebastian Andrzej Siewior

On 08/23/2012 03:07 PM, Michal Nazarewicz wrote:

Perhaps also wrap declaration of usb_gadget_get_string() with an #ifdef
in include/linux/usb/gadget.h?  This way, anything trying to use the
function w/o USB_LIBCOMPOSITE selected will fail to compile rather than
failing to load.


Good hint. The file_storage gadget which is leaving is the other user
besides composite.


Also, I would personally prefer having selects in Kconfig since I don't
see the need for user who compiles the kernel to know about or
understand the distinction between composite and “raw” gadgets.


I tried to avoid this but can change. In the end I would like to have
this "traditional" gadget and those which are created on runtime by
configfs.


Other than that:

Acked-by: Michal Nazarewicz



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


Re: [PATCH 4/9] usb/gadget: add epautoconf.c to libcomposite

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> This adds epautoconf.c into libcomposite and updates all gadgets.
>
> Signed-off-by: Sebastian Andrzej Siewior 

Acked-by: Michal Nazarewicz 

> diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
> index 3078d79..5db661d 100644
> --- a/drivers/usb/gadget/acm_ms.c
> +++ b/drivers/usb/gadget/acm_ms.c
> @@ -42,7 +42,6 @@
>   */
>  
>  #include "composite.c"
> -#include "epautoconf.c"
>  #include "u_serial.c"
>  #include "f_acm.c"
>  #include "f_mass_storage.c"
> diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
> index 9e85df2..689d142 100644
> --- a/drivers/usb/gadget/audio.c
> +++ b/drivers/usb/gadget/audio.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  
> +#include "gadget_chips.h"

Perhaps we should EXPORT_SYMBOL usb_gadget_controller_number() and
gadget_supports_altsettings() functions from epautoconf.c instead?  The
former does not look like it's something compiler would inline anyway.

>  #define DRIVER_DESC  "Linux USB Audio Gadget"
>  #define DRIVER_VERSION   "Feb 2, 2012"
>  
> @@ -27,7 +28,6 @@
>   * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
>   */
>  #include "composite.c"
> -#include "epautoconf.c"
>  
>  /* string IDs are assigned dynamically */
>  

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpQprn6K13H3.pgp
Description: PGP signature


Re: [PATCH 6/9] usb/gadget: move USB_BUFSIZ into global composite.h

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> This patch moves USB_BUFSIZ into global header file as
> USB_COMP_EP0_BUFSIZ. There is currently only one user (f_sourcesink)
> besides composite which needs it. Ideally f_sourcesink would have its
> own ep0 buffer. Lets keep it that way it was for now.
>
> Signed-off-by: Sebastian Andrzej Siewior 

Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/composite.c|   10 --
>  drivers/usb/gadget/f_sourcesink.c |2 +-
>  include/linux/usb/composite.h |3 +++
>  3 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 598df69..e380a05 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -28,9 +28,6 @@
>   * with the relevant device-wide data.
>   */
>  
> -/* big enough to hold our biggest descriptor */
> -#define USB_BUFSIZ   1024
> -
>  /* Some systems will need runtime overrides for the  product identifiers
>   * published in the device descriptor, either numbers or strings or both.
>   * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
> @@ -355,10 +352,11 @@ static int config_buf(struct usb_configuration *config,
>  {
>   struct usb_config_descriptor*c = buf;
>   void*next = buf + USB_DT_CONFIG_SIZE;
> - int len = USB_BUFSIZ - USB_DT_CONFIG_SIZE;
> + int len;
>   struct usb_function *f;
>   int status;
>  
> + len = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE;
>   /* write the config descriptor */
>   c = buf;
>   c->bLength = USB_DT_CONFIG_SIZE;
> @@ -1445,13 +1443,13 @@ static int composite_bind(struct usb_gadget *gadget,
>   cdev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
>   if (!cdev->req)
>   goto fail;
> - cdev->req->buf = kmalloc(USB_BUFSIZ, GFP_KERNEL);
> + cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
>   if (!cdev->req->buf)
>   goto fail;
>   cdev->req->complete = composite_setup_complete;
>   gadget->ep0->driver_data = cdev;
>  
> - cdev->bufsiz = USB_BUFSIZ;
> + cdev->bufsiz = USB_COMP_EP0_BUFSIZ;
>   cdev->driver = cdriver;
>  
>   /*
> diff --git a/drivers/usb/gadget/f_sourcesink.c 
> b/drivers/usb/gadget/f_sourcesink.c
> index 5c1b68b..3c126fd 100644
> --- a/drivers/usb/gadget/f_sourcesink.c
> +++ b/drivers/usb/gadget/f_sourcesink.c
> @@ -795,7 +795,7 @@ static int sourcesink_setup(struct usb_configuration *c,
>   u16 w_value = le16_to_cpu(ctrl->wValue);
>   u16 w_length = le16_to_cpu(ctrl->wLength);
>  
> - req->length = USB_BUFSIZ;
> + req->length = USB_COMP_EP0_BUFSIZ;
>  
>   /* composite driver infrastructure handles everything except
>* the two control test requests.
> diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
> index 43d6b9c..89d91b6 100644
> --- a/include/linux/usb/composite.h
> +++ b/include/linux/usb/composite.h
> @@ -46,6 +46,9 @@
>   */
>  #define USB_GADGET_DELAYED_STATUS   0x7fff   /* Impossibly large 
> value */
>  
> +/* big enough to hold our biggest descriptor */
> +#define USB_COMP_EP0_BUFSIZ  1024
> +
>  struct usb_configuration;
>  
>  /**

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpyXGLjaDcdR.pgp
Description: PGP signature


Re: [PATCH 7/9] usb/gadget: remove bufsiz from struct usb_composite_dev

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> there is no read user of bufsiz, its content is available via
> USB_COMP_EP0_BUFSIZ. Remove it.
>
> Signed-off-by: Sebastian Andrzej Siewior 

Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/composite.c |1 -
>  include/linux/usb/composite.h  |2 --
>  2 files changed, 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index e380a05..0f548fe 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -1449,7 +1449,6 @@ static int composite_bind(struct usb_gadget *gadget,
>   cdev->req->complete = composite_setup_complete;
>   gadget->ep0->driver_data = cdev;
>  
> - cdev->bufsiz = USB_COMP_EP0_BUFSIZ;
>   cdev->driver = cdriver;
>  
>   /*
> diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
> index 89d91b6..e970fba 100644
> --- a/include/linux/usb/composite.h
> +++ b/include/linux/usb/composite.h
> @@ -318,7 +318,6 @@ extern void usb_composite_setup_continue(struct 
> usb_composite_dev *cdev);
>   * struct usb_composite_device - represents one composite usb gadget
>   * @gadget: read-only, abstracts the gadget's usb peripheral controller
>   * @req: used for control responses; buffer is pre-allocated
> - * @bufsiz: size of buffer pre-allocated in @req
>   * @config: the currently active configuration
>   *
>   * One of these devices is allocated and initialized before the
> @@ -349,7 +348,6 @@ extern void usb_composite_setup_continue(struct 
> usb_composite_dev *cdev);
>  struct usb_composite_dev {
>   struct usb_gadget   *gadget;
>   struct usb_request  *req;
> - unsignedbufsiz;
>  
>   struct usb_configuration*config;
>  
> -- 
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpw93cJRigLl.pgp
Description: PGP signature


Re: [PATCH 3/9] usb/gadget: move global vars from epautoconf into struct usb_gadget

2012-08-23 Thread Sebastian Andrzej Siewior

On 08/23/2012 03:15 PM, Michal Nazarewicz wrote:

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index fdf85a7..01fe02a 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -537,6 +537,12 @@ struct usb_gadget {
unsigneda_alt_hnp_support:1;
const char  *name;
struct device   dev;
+   unsignedepnum;
+/* #define MANY_ENDPOINTS */
+#ifdef MANY_ENDPOINTS
+   /* more than 15 configurable endpoints */
+   unsignedin_epnum;
+#endif
  };


This looks tricky.  At the moment, MANY_ENDPOINTS is not defined
anywhere, but if for some reason someone tries to define it in some
composite gadgets, we may end up with different definitions of
usb_gadget structure.  It appears to me that we should drop this all
together or switch it to Kconfig option.


Sounds like a plan. I think I drop the ifdef. DWC3 supports 32
endpoints. So with configfs and a giant gadget we might hit that 15ep
limit.

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


Re: [rtc-linux] [PATCHv4 8/9] arm: vt8500: gpio: Devicetree support for arch-vt8500

2012-08-23 Thread Linus Walleij
On Thu, Aug 23, 2012 at 9:35 AM, Tony Prisk  wrote:

> Converted the existing arch-vt8500 gpio to a platform_device.
> Added support for WM8505 and WM8650 GPIO controllers.
> Replaced existing readl/writel calls with _relaxed variants.
> Replaced existing unsigned variables with u32 to match register size.
>
> Signed-off-by: Tony Prisk 

Sweet!
Reviewed-by: Linus Walleij 

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 4/9] usb/gadget: add epautoconf.c to libcomposite

2012-08-23 Thread Sebastian Andrzej Siewior

On 08/23/2012 03:25 PM, Michal Nazarewicz wrote:

diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 9e85df2..689d142 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -14,6 +14,7 @@
  #include
  #include

+#include "gadget_chips.h"


Perhaps we should EXPORT_SYMBOL usb_gadget_controller_number() and
gadget_supports_altsettings() functions from epautoconf.c instead?  The
former does not look like it's something compiler would inline anyway.


Both are static inline. The compile hat to include this function in
code, it has no other choice.

But you are right, the format is getting huge. I will move this
function into composite in a later patch.

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


Re: [rtc-linux] RE: [PATCHv4 0/9] *** ARM: Update arch-vt8500 to Devicetree ***

2012-08-23 Thread Linus Walleij
On Thu, Aug 23, 2012 at 2:58 PM, Tony Prisk  wrote:

> Linus W has provided some feedback on the gpio driver - I missed the
> issues he raised the first time around so just waiting for him to take a look
> at v4 when he's got time.

Reviewed and OK:ed, looking good now.

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 9/9] usb/gadget: push VID/PID/USB BCD module option into gadgets

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> This patch moves the module options idVendor, idProduct and bcdDevice
> from composite.c into each gadgets. This ensures compatibility with
> current gadgets and removes the global variable which brings me step
> closer towards composite.c in libcomposite
>
> Signed-off-by: Sebastian Andrzej Siewior 

> diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
> index e970fba..bc84afc 100644
> --- a/include/linux/usb/composite.h
> +++ b/include/linux/usb/composite.h
> @@ -381,6 +381,34 @@ extern int usb_string_ids_tab(struct usb_composite_dev 
> *c,
> struct usb_string *str);
>  extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
>  
> +/*
> + * Some systems will need runtime overrides for the  product identifiers
> + * published in the device descriptor, either numbers or strings or both.
> + * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
> + */
> +#define USB_GADGET_COMPOSITE_OPTIONS()   
> \
> + static ushort idVendor; \
> + module_param(idVendor, ushort, S_IRUGO);\
> + MODULE_PARM_DESC(idVendor, "USB Vendor ID");\
> + \
> + static ushort idProduct;\
> + module_param(idProduct, ushort, S_IRUGO);   \
> + MODULE_PARM_DESC(idProduct, "USB Product ID");  \
> + \
> + static ushort bcdDevice;\
> + module_param(bcdDevice, ushort, S_IRUGO);   \
> + MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)")
> +
> +#define USB_GADGET_COMPOSITE_OVERWRITE_VID_PID_BCD(__usb_desc)   
> \
> + if (idVendor)   \
> + __usb_desc.idVendor = cpu_to_le16(idVendor);\
> + \
> + if (idProduct)  \
> + __usb_desc.idProduct = cpu_to_le16(idProduct);  \
> + \
> + if (bcdDevice)  \
> + __usb_desc.bcdDevice = cpu_to_le16(bcdDevice)
> +

Wrap with a “do { ... } while (0)”.

>  /* messaging utils */
>  #define DBG(d, fmt, args...) \

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpCQ7lQeCV4E.pgp
Description: PGP signature


Re: [PATCH 9/9] usb/gadget: push VID/PID/USB BCD module option into gadgets

2012-08-23 Thread Sebastian Andrzej Siewior

On 08/23/2012 03:38 PM, Michal Nazarewicz wrote:

Wrap with a “do { ... } while (0)”.

Will do.

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


Re: [PATCH 4/9] usb/gadget: add epautoconf.c to libcomposite

2012-08-23 Thread Michal Nazarewicz
>>> diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
>>> index 9e85df2..689d142 100644
>>> --- a/drivers/usb/gadget/audio.c
>>> +++ b/drivers/usb/gadget/audio.c
>>> @@ -14,6 +14,7 @@
>>>   #include
>>>   #include
>>>
>>> +#include "gadget_chips.h"

> On 08/23/2012 03:25 PM, Michal Nazarewicz wrote:
>> Perhaps we should EXPORT_SYMBOL usb_gadget_controller_number() and
>> gadget_supports_altsettings() functions from epautoconf.c instead?  The
>> former does not look like it's something compiler would inline anyway.

Sebastian Andrzej Siewior  writes:
> Both are static inline. The compile hat to include this function in
> code, it has no other choice.

Right, I've misspoken.  What I meant was that the whole function is
included so there is no compile-time optimisations going on which reduce
the whole function to a single statement.

Back in the day when only UDC driver could have been compiled, the whole
gadget_chips.h file used to have tons of #ifdefs turning all but one of
gadget_is_foo() macros into zeros.  Back than it made sense to keep
usb_gadget_controller_number() as static inline in the header file since
it was reduced to a single strcmp() at compile-time, but now all the
strcmp()s are there in the code anyway.

> But you are right, the format is getting huge. I will move this
> function into composite in a later patch.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpSK4lRGf2Bk.pgp
Description: PGP signature


Re: [PATCH 8/9] usb/gadget: make composite module options readonly only

2012-08-23 Thread Michal Nazarewicz
Sebastian Andrzej Siewior  writes:
> This is a partly revert of 4fffd6e5 ("usb: gadget: composite: make
> module parameters accessible at runtime").
> It is not possible to change the VID or other properly for a gadget
> right now. This change has been made for Anrdoid gadget which has this
> change in its copy of the file. This function is executed currently only
> once and post caller in tree __init.
>
> Signed-off-by: Sebastian Andrzej Siewior 

Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/composite.c |   20 
>  1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 0f548fe..153efc4 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -34,27 +34,27 @@
>   */
>  
>  static ushort idVendor;
> -module_param(idVendor, ushort, 0644);
> +module_param(idVendor, ushort, S_IRUGO);
>  MODULE_PARM_DESC(idVendor, "USB Vendor ID");
>  
>  static ushort idProduct;
> -module_param(idProduct, ushort, 0644);
> +module_param(idProduct, ushort, S_IRUGO);
>  MODULE_PARM_DESC(idProduct, "USB Product ID");
>  
>  static ushort bcdDevice;
> -module_param(bcdDevice, ushort, 0644);
> +module_param(bcdDevice, ushort, S_IRUGO);
>  MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
>  
>  static char *iManufacturer;
> -module_param(iManufacturer, charp, 0644);
> +module_param(iManufacturer, charp, S_IRUGO);
>  MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
>  
>  static char *iProduct;
> -module_param(iProduct, charp, 0644);
> +module_param(iProduct, charp, S_IRUGO);
>  MODULE_PARM_DESC(iProduct, "USB Product string");
>  
>  static char *iSerialNumber;
> -module_param(iSerialNumber, charp, 0644);
> +module_param(iSerialNumber, charp, S_IRUGO);
>  MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");
>  
>  static char composite_manufacturer[50];
> @@ -1478,16 +1478,12 @@ static int composite_bind(struct usb_gadget *gadget,
>   /* standardized runtime overrides for device ID data */
>   if (idVendor)
>   cdev->desc.idVendor = cpu_to_le16(idVendor);
> - else
> - idVendor = le16_to_cpu(cdev->desc.idVendor);
> +
>   if (idProduct)
>   cdev->desc.idProduct = cpu_to_le16(idProduct);
> - else
> - idProduct = le16_to_cpu(cdev->desc.idProduct);
> +
>   if (bcdDevice)
>   cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
> - else
> - bcdDevice = le16_to_cpu(cdev->desc.bcdDevice);
>  
>   /* string overrides */
>   if (iManufacturer || !cdev->desc.iManufacturer) {
> -- 
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpHMDOXbsVDY.pgp
Description: PGP signature


Re: [RFC PATCH 2/2] USB: Set usb port's DevicerRemovable according acpi information in EHCI

2012-08-23 Thread Alan Stern
On Thu, 23 Aug 2012, Lan Tianyu wrote:

> >>> Why not just update the ACPI information using the current hub
> >>> descriptor?  You don't need to fetch the hub descriptor again.
> >>>
> >> You mean to set DeviceRemovable directly rather than via hub descriptor 
> >> request
> >> here, right?
> > 
> > Right.  DeviceRemovable should be set in only one place, and this
> > should be that place.
> > 
> But if other places got hub descriptor, they can't get DeviceRemovable
> value since we only set DeviceRemovable in the hub_configure().(e.g lsusb).

I don't understand.  lsusb will be able to see the DeviceRemovable 
values in sysfs, won't it?

Besides, there aren't any other places in the kernel that get the hub 
descriptor.

> Another problem is that some hcds will set DeviceRemovable themselves.
> There will be a conflict between hcd and acpi information. Different
> hcds may have different processes.

There is always the possibility of a conflict.  This remains true 
whether you get the hub descriptor once or twice.

>  So at first, I put setting
> DeviceRemovable in the hcd's hub descriptor request routine.

But that is the wrong place to put it.  As you pointed out, when the 
hub descriptor is requested we don't know how many ports there are and 
so we can't set up the DeviceRemovable information.

Alan Stern

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


Re: [PATCH 1/9] usb/gadget: start with libcomposite

2012-08-23 Thread Alan Stern
On Thu, 23 Aug 2012, Sebastian Andrzej Siewior wrote:

> This patch aims to be simple. It removes #include usbstribgs.c line from each
> gadget and creats libcomposite.ko which has only one member, that is
> usbstribgs.c.
> To avoid mass select statements in Kconfig I simply group the composite
> based gadgets together. The three gadgets which are not part of the group
> are:
> - EHCI Debug Device Gadget. Could be converted to composite if anyone
>   cares
> - File-backed Storage Gadget. Replaced by "mass storage", will be
>   removed soon.
> - Gadget Filesystem. Functionality is provided by "Function Filesystem".
>   Unfortunatelly can't be replaced because the user space visible API is
>   different.

> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -507,6 +507,16 @@ config USB_GADGET_SUPERSPEED
>  #
>  # USB Gadget Drivers
>  #
> +
> +# composite based drivers
> +config USB_LIBCOMPOSITE
> + tristate "Lib composite based gadgets"
> + depends on USB_GADGET

Shouldn't this have "default USB_GADGET"?  There will be very few cases
where anyone wants to configure a system with gadget support but
without libcomposite.

> + help
> +   Most gadgets are using the composite framework. There are only three

s/framework/library/

> +   gadgets left which do not use the composite framework and two of them

Ditto.

> +   have been replaced by alternatives.

Alan Stern

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


Re: [PATCH] usb: ohci: Fix Kconfig dependency on USB_ISP1301

2012-08-23 Thread Alan Stern
On Thu, 23 Aug 2012, Roland Stigge wrote:

> With "select USB_ISP1301 ...", it could happen that I2C isn't selected 
> although
> USB_ISP1301 depends on it. Fixing with "depends on ..." and emulating the
> condition via "|| !()".
> 
> Signed-off-by: Roland Stigge 
> ---
>  drivers/usb/host/Kconfig |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- linux-2.6.orig/drivers/usb/host/Kconfig
> +++ linux-2.6/drivers/usb/host/Kconfig
> @@ -292,7 +292,7 @@ config USB_OHCI_HCD
>   depends on USB && USB_ARCH_HAS_OHCI
>   select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
>   select USB_OTG_UTILS if ARCH_OMAP
> - select USB_ISP1301 if ARCH_LPC32XX || ARCH_PNX4008
> + depends on USB_ISP1301 || !(ARCH_LPC32XX || ARCH_PNX4008)
>   ---help---
> The Open Host Controller Interface (OHCI) is a standard for accessing
> USB 1.1 host controller hardware.  It does more in hardware than 
> Intel's

I was going to suggest the exact same solution, but you beat me to it.  
:-)

Acked-by: Alan Stern 

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


[PATCH] usbhid: add NOGET quirk for Eaton Ellipse MAX UPS

2012-08-23 Thread Alan Stern
This patch (as1603) adds a NOGET quirk for the Eaton Ellipse MAX UPS
device.  (The USB IDs were already present in hid-ids.h, apparently
under a different name.)

Signed-off-by: Alan Stern 
Reported-by: Laurent Bigonville 
CC: 

---

 drivers/hid/usbhid/hid-quirks.c |1 +
 1 file changed, 1 insertion(+)

Index: usb-3.5/drivers/hid/usbhid/hid-quirks.c
===
--- usb-3.5.orig/drivers/hid/usbhid/hid-quirks.c
+++ usb-3.5/drivers/hid/usbhid/hid-quirks.c
@@ -70,6 +70,7 @@ static const struct hid_blacklist {
{ USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
+   { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET },
{ USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, 
HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, 
HID_QUIRK_NO_INIT_REPORTS },
{ USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, 
HID_QUIRK_NO_INIT_REPORTS },

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


chipidea driver

2012-08-23 Thread Marc Kleine-Budde
Hello,

Michael and I have a bunch of updates and improvement for the chipidea
driver. They apply to Richard's tree:

https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

What's the status of these patches? It would be fine if someone queues
them for upstream.

regards, Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH 1/3] usb: phy: get phy driver's module if phy is acquired

2012-08-23 Thread Marc Kleine-Budde
Otherwise the module's refcount is 0 and it's possible to unload the module,
even if the phy is in use.

Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/otg/otg.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 1bf60a2..98c430e 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -95,7 +96,7 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type)
spin_lock_irqsave(&phy_lock, flags);
 
phy = __usb_find_phy(&phy_list, type);
-   if (IS_ERR(phy)) {
+   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
pr_err("unable to find transceiver of type %s\n",
usb_phy_type_string(type));
goto err0;
@@ -139,8 +140,10 @@ EXPORT_SYMBOL(devm_usb_put_phy);
  */
 void usb_put_phy(struct usb_phy *x)
 {
-   if (x)
+   if (x) {
put_device(x->dev);
+   module_put(x->dev->driver->owner);
+   }
 }
 EXPORT_SYMBOL(usb_put_phy);
 
-- 
1.7.10.4

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


[PATCH 3/3] usb: mxs-phy: register phy as USB_PHY_TYPE_USB2

2012-08-23 Thread Marc Kleine-Budde
This patch registers the msx-phy as an USB_PHY_TYPE_USB2. This is needed to get
reference to the phy with devm_usb_get_phy_by_phandle(), which will be added in
a later patch.

Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/otg/mxs-phy.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index c1a67cb..240b945 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -141,11 +141,14 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, &mxs_phy->phy);
 
-   return 0;
+   return usb_add_phy(&mxs_phy->phy, USB_PHY_TYPE_USB2);
 }
 
 static int __devexit mxs_phy_remove(struct platform_device *pdev)
 {
+   struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
+
+   usb_remove_phy(&mxs_phy->phy);
platform_set_drvdata(pdev, NULL);
 
return 0;
-- 
1.7.10.4

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


[PATCH 2/3] usb: otg: add device tree support to otg library

2012-08-23 Thread Marc Kleine-Budde
From: Kishon Vijay Abraham I 

This patch adds an API to get usb phy by passing a device node phandle value.
The new added devm_usb_get_phy_by_phandle() function will return a pointer to
the phy on success, -EPROBE_DEFER if there is a device_node for the phandle,
but the phy has not been added, or a ERR_PTR() otherwise.

Since it's possible to obtain a phy by phandle, the checks in usb_add_phy() for
a valid phy type is removed (now it's just a debug message if a user tries to
add a phy with undefined type). This also allows to add multiple phys of same
type.

Cc: Richard Zhao 
Cc: Marek Vasut 
Signed-off-by: Kishon Vijay Abraham I 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/otg/otg.c   |   96 ---
 include/linux/usb/otg.h |8 
 2 files changed, 90 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 98c430e..23618de 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -36,6 +37,21 @@ static struct usb_phy *__usb_find_phy(struct list_head *list,
return ERR_PTR(-ENODEV);
 }
 
+static struct usb_phy *__of_usb_find_phy(struct list_head *list,
+   struct device_node *node)
+{
+   struct usb_phy  *phy;
+
+   list_for_each_entry(phy, list, head) {
+   if (node != phy->dev->of_node)
+   continue;
+
+   return phy;
+   }
+
+   return ERR_PTR(-ENODEV);
+}
+
 static void devm_usb_phy_release(struct device *dev, void *res)
 {
struct usb_phy *phy = *(struct usb_phy **)res;
@@ -112,6 +128,66 @@ err0:
 EXPORT_SYMBOL(usb_get_phy);
 
 /**
+ * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
+ * @dev - device that requests this phy
+ * @phandle - name of the property holding the phy phandle value
+ *
+ * Returns the phy driver associated with the given phandle value,
+ * after getting a refcount to it, -ENODEV if there is no such phy or
+ * -EPROBE_DEFER if there is a phandle to the phy, but the device is
+ * not yet loaded. While at that, it also associates the device with
+ * the phy using devres. On driver detach, release function is invoked
+ * on the devres data, then, devres data is freed.
+ *
+ * For use by USB host and peripheral drivers.
+ */
+struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
+   const char *phandle)
+{
+   struct usb_phy  *phy = NULL, **ptr;
+   unsigned long   flags;
+   struct device_node *node;
+
+   if (!dev->of_node) {
+   dev_dbg(dev, "device does not have a device node entry\n");
+   return ERR_PTR(-EINVAL);
+   }
+
+   node = of_parse_phandle(dev->of_node, phandle, 0);
+   if (!node) {
+   dev_dbg(dev, "failed to get %s phandle in %s node\n", phandle,
+   dev->of_node->full_name);
+   return ERR_PTR(-ENODEV);
+   }
+
+   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr) {
+   dev_dbg(dev, "failed to allocate memory for devres\n");
+   return ERR_PTR(-ENOMEM);
+   }
+
+   spin_lock_irqsave(&phy_lock, flags);
+
+   phy = __of_usb_find_phy(&phy_list, node);
+   if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
+   phy = ERR_PTR(-EPROBE_DEFER);
+   devres_free(ptr);
+   goto err0;
+   }
+
+   *ptr = phy;
+   devres_add(dev, ptr);
+
+   get_device(phy->dev);
+
+err0:
+   spin_unlock_irqrestore(&phy_lock, flags);
+
+   return phy;
+}
+EXPORT_SYMBOL(devm_usb_get_phy_by_phandle);
+
+/**
  * devm_usb_put_phy - release the USB PHY
  * @dev - device that wants to release this phy
  * @phy - the phy returned by devm_usb_get_phy()
@@ -158,32 +234,24 @@ EXPORT_SYMBOL(usb_put_phy);
  */
 int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
 {
-   int ret = 0;
unsigned long   flags;
struct usb_phy  *phy;
 
-   if (x && x->type != USB_PHY_TYPE_UNDEFINED) {
-   dev_err(x->dev, "not accepting initialized PHY %s\n", x->label);
-   return -EINVAL;
-   }
+   if (x && x->type != USB_PHY_TYPE_UNDEFINED)
+   dev_dbg(x->dev, "add a phy with undefined type %s\n", x->label);
 
spin_lock_irqsave(&phy_lock, flags);
 
-   list_for_each_entry(phy, &phy_list, head) {
-   if (phy->type == type) {
-   ret = -EBUSY;
-   dev_err(x->dev, "transceiver type %s already exists\n",
+   list_for_each_entry(phy, &phy_list, head)
+   if (phy->type == type)
+   dev_dbg(x->dev, "transceiver type %s already exists\n",
usb_phy_type_string(type));
-   goto out;
-   }
-   }
 
x->type = type;
list_add_tail(&x->head, &ph

[PATCH 1/3] usb: otg: Improve phy handling

2012-08-23 Thread Marc Kleine-Budde
This patch series improves the phy handling.

The first patch fixes the problem that the phy driver, when build as module,
can be unloaded when the phy is in use. The second patch takes up Kishon's work
and adds device tree support to the otg library. New in this patch is that
devm_usb_get_phy_by_phandle() will return with -EPROBE_DEFER, if the requested
phy has not registered itself yet. The third patch registers the mxs-phy as a
USB_PHY_TYPE_USB2 phy, so that the ci13xxx_imx driver can reqeust it via the
devm_usb_get_phy_by_phandle() function.

These patches apply to v3.6-rc3 and have ben successfully tested on mx28 and
mx53 (with an improved version of the chipidea driver though).

regards, Marc

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


[PATCH 3/4] usb: chipidea: udc: don't stall endpoint if request list is empty in isr_tr_complete_low

2012-08-23 Thread Marc Kleine-Budde
From: Michael Grzeschik 

When attaching an imx28 or imx53 in USB gadget mode to a Windows host and
starting a rndis connection we see this message every 4-10 seconds:

g_ether gadget: high speed config #2: RNDIS

Analysis shows that each time this message is printed, the rndis connection is
re-establish due to a reset because of a stalled endpoint (ep 0, dir 1). The
endpoint is stalled because the reqeust complete bit on that endpoint is set,
but in isr_tr_complete_low() the endpoint request list (mEp->qh.queue) is
empty.

This patch removed this check, because the code doesn't take the following
situation into account:

The loop over all endpoints in isr_tr_complete_handler() will call ep_nuke() on
both ep0/dir0 and ep/dir1 in the first loop. Pending reqeusts will be flushed
and completed here. There seems to be a race condition, the request is nuked,
but the request complete bit will be set, too. The subsequent check (in
ep0/dir1's loop cycle) for endpoint request list (mEp->qh.queue) empty will
fail.

Both other mainline chipidea drivers (mv_udc_core.c and fsl_udc_core.c) don't
have this check.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/udc.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 75a96ec..3bfc030 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -774,10 +774,7 @@ __acquires(mEp->lock)
 {
struct ci13xxx_req *mReq, *mReqTemp;
struct ci13xxx_ep *mEpTemp = mEp;
-   int uninitialized_var(retval);
-
-   if (list_empty(&mEp->qh.queue))
-   return -EINVAL;
+   int retval = 0;
 
list_for_each_entry_safe(mReq, mReqTemp, &mEp->qh.queue,
queue) {
-- 
1.7.10.4

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


[PATCH 0/4] usb: chipidea: Fixes

2012-08-23 Thread Marc Kleine-Budde
Hello,

this is a series fixes several problems in the chipidea udc driver. Although
this applies to v3.6-rc3, I don't want to push this into v3.6. Please review
and test.

These patches have been tested on mx28 and mx53.

regards, Marc

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


[PATCH 4/4] usb: chipidea: udc: add pullup fuction, needed by the uvc gadget

2012-08-23 Thread Marc Kleine-Budde
From: Michael Grzeschik 

Add function to physicaly enable or disable of pullup connection on the USB-D+
line. The uvc gaget will fail, if this function is not implemented.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/udc.c |   21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 3bfc030..5f99b17 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -78,8 +78,7 @@ static inline int ep_to_bit(struct ci13xxx *ci, int n)
 }
 
 /**
- * hw_device_state: enables/disables interrupts & starts/stops device (execute
- *  without interruption)
+ * hw_device_state: enables/disables interrupts (execute without interruption)
  * @dma: 0 => disable, !0 => enable and set dma engine
  *
  * This function returns an error code
@@ -91,9 +90,7 @@ static int hw_device_state(struct ci13xxx *ci, u32 dma)
/* interrupt, error, port change, reset, sleep/suspend */
hw_write(ci, OP_USBINTR, ~0,
 USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
-   hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
} else {
-   hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
hw_write(ci, OP_USBINTR, ~0, 0);
}
return 0;
@@ -1417,6 +1414,21 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, 
unsigned mA)
return -ENOTSUPP;
 }
 
+/* Change Data+ pullup status
+ * this func is used by usb_gadget_connect/disconnet
+ */
+static int ci13xxx_pullup(struct usb_gadget *_gadget, int is_on)
+{
+   struct ci13xxx *ci = container_of(_gadget, struct ci13xxx, gadget);
+
+   if (is_on)
+   hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
+   else
+   hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
+
+   return 0;
+}
+
 static int ci13xxx_start(struct usb_gadget *gadget,
 struct usb_gadget_driver *driver);
 static int ci13xxx_stop(struct usb_gadget *gadget,
@@ -1429,6 +1441,7 @@ static int ci13xxx_stop(struct usb_gadget *gadget,
 static const struct usb_gadget_ops usb_gadget_ops = {
.vbus_session   = ci13xxx_vbus_session,
.wakeup = ci13xxx_wakeup,
+   .pullup = ci13xxx_pullup,
.vbus_draw  = ci13xxx_vbus_draw,
.udc_start  = ci13xxx_start,
.udc_stop   = ci13xxx_stop,
-- 
1.7.10.4

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


[PATCH 1/4] usb: chipidea: udc: fix error path in udc_start()

2012-08-23 Thread Marc Kleine-Budde
This patch fixes the error path of udc_start(). Now NULL is used to
unset the peripheral with otg_set_peripheral().

Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/udc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c7a032a..e4db7af 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1729,7 +1729,7 @@ static int udc_start(struct ci13xxx *ci)
 
 remove_trans:
if (!IS_ERR_OR_NULL(ci->transceiver)) {
-   otg_set_peripheral(ci->transceiver->otg, &ci->gadget);
+   otg_set_peripheral(ci->transceiver->otg, NULL);
if (ci->global_phy)
usb_put_phy(ci->transceiver);
}
-- 
1.7.10.4

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


[PATCH 2/4] usb: chipidea: udc: set endpoint to undefined maxpacket size on start

2012-08-23 Thread Marc Kleine-Budde
From: Michael Grzeschik 

Non control endpoints have an undefined maxpacket size on udc start. Some
gadget drivers check for the maxpacket size before they enable the endpoint,
which leads to a wrong state.

Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
---
 drivers/usb/chipidea/udc.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index e4db7af..75a96ec 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1455,7 +1455,12 @@ static int init_eps(struct ci13xxx *ci)
 
mEp->ep.name  = mEp->name;
mEp->ep.ops   = &usb_ep_ops;
-   mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;
+   /*
+* for ep0: maxP defined in desc, for other
+* eps, maxP is set by epautoconfig() called
+* by gadget layer
+*/
+   mEp->ep.maxpacket = (unsigned short)~0;
 
INIT_LIST_HEAD(&mEp->qh.queue);
mEp->qh.ptr = dma_pool_alloc(ci->qh_pool, GFP_KERNEL,
@@ -1475,6 +1480,7 @@ static int init_eps(struct ci13xxx *ci)
else
ci->ep0in = mEp;
 
+   mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;
continue;
}
 
-- 
1.7.10.4

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


[PATCH] usb: chipidea: ci13xxx_imx: add 2nd and 3rd clock to support imx5x and newer

2012-08-23 Thread Marc Kleine-Budde
From: Michael Grzeschik 

This patch adds support for a second and third clock to the chipidea driver. On
modern freescale ARM cores like the imx51, imx53 and imx6q three clocks ("ahb",
"ipg" and "per") must be enabled in order to access the USB core.

In the original driver, the clock was requested without specifying the
connection id, further all mainline ARM archs with support for the chipidea
core (imx23, imx28) register their USB clock without a connection id.

This patch first renames the existing clk variable to clk_ahb. The connection
id "ahb" is added to the devm_clk_get() call. Then the clocks "ipg" and "per"
are requested. As all archs don't specify a connection id, all clk_get return
the same clock. This ensures compatibility to existing USB support and adds
support for imx5x at the same time.

The same change has been applied to the fsl_mxc_udc.c in commit:
ba78917 usb: gadget: fsl_mxc_udc: do not depend on grouped clocks

This patch has been tested on imx28 and on imx53 with seperate "ahb", "ipg"
and "per" clocks.

Cc: Shawn Guo 
Signed-off-by: Michael Grzeschik 
Signed-off-by: Marc Kleine-Budde 
---
Hello,

this patch applies to Richard's tree at:
https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

regards, Marc

 drivers/usb/chipidea/ci13xxx_imx.c |   54 ++--
 1 file changed, 45 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index dd7f3a3..a42599d 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -35,7 +35,9 @@ struct ci13xxx_imx_data {
struct device_node *phy_np;
struct usb_phy *phy;
struct platform_device *ci_pdev;
-   struct clk *clk;
+   struct clk *clk_ahb;
+   struct clk *clk_ipg;
+   struct clk *clk_per;
struct regulator *reg_vbus;
 };
 
@@ -94,20 +96,48 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
dev_warn(&pdev->dev, "pinctrl get/select failed, err=%ld\n",
PTR_ERR(pinctrl));
 
-   data->clk = devm_clk_get(&pdev->dev, NULL);
-   if (IS_ERR(data->clk)) {
+   data->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+   if (IS_ERR(data->clk_ahb)) {
dev_err(&pdev->dev,
-   "Failed to get clock, err=%ld\n", PTR_ERR(data->clk));
-   return PTR_ERR(data->clk);
+   "Failed to get ahb clock, err=%ld\n", 
PTR_ERR(data->clk_ahb));
+   return PTR_ERR(data->clk_ahb);
}
 
-   ret = clk_prepare_enable(data->clk);
+   data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+   if (IS_ERR(data->clk_ipg)) {
+   dev_err(&pdev->dev,
+   "Failed to get ipg clock, err=%ld\n", 
PTR_ERR(data->clk_ipg));
+   return PTR_ERR(data->clk_ipg);
+   }
+
+   data->clk_per = devm_clk_get(&pdev->dev, "per");
+   if (IS_ERR(data->clk_per)) {
+   dev_err(&pdev->dev,
+   "Failed to get per clock, err=%ld\n", 
PTR_ERR(data->clk_per));
+   return PTR_ERR(data->clk_per);
+   }
+
+   ret = clk_prepare_enable(data->clk_ahb);
if (ret) {
dev_err(&pdev->dev,
-   "Failed to prepare or enable clock, err=%d\n", ret);
+   "Failed to prepare or enable ahb clock, err=%d\n", ret);
return ret;
}
 
+   ret = clk_prepare_enable(data->clk_ipg);
+   if (ret) {
+   dev_err(&pdev->dev,
+   "Failed to prepare or enable ipg clock, err=%d\n", ret);
+   goto err_ipg_failed;
+   }
+
+   ret = clk_prepare_enable(data->clk_per);
+   if (ret) {
+   dev_err(&pdev->dev,
+   "Failed to prepare or enable per clock, err=%d\n", ret);
+   goto err_per_failed;
+   }
+
phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0);
if (phy_np) {
data->phy_np = phy_np;
@@ -171,7 +201,11 @@ err:
regulator_disable(reg_vbus);
if (phy_np)
of_node_put(phy_np);
-   clk_disable_unprepare(data->clk);
+   clk_disable_unprepare(data->clk_per);
+err_per_failed:
+   clk_disable_unprepare(data->clk_ipg);
+err_ipg_failed:
+   clk_disable_unprepare(data->clk_ahb);
return ret;
 }
 
@@ -192,7 +226,9 @@ static int __devexit ci13xxx_imx_remove(struct 
platform_device *pdev)
 
of_node_put(data->phy_np);
 
-   clk_disable_unprepare(data->clk);
+   clk_disable_unprepare(data->clk_per);
+   clk_disable_unprepare(data->clk_ipg);
+   clk_disable_unprepare(data->clk_ahb);
 
platform_set_drvdata(pdev, NULL);
 
-- 
1.7.10.4

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

Re: [PATCH 1/3] usb: phy: get phy driver's module if phy is acquired

2012-08-23 Thread Alan Stern
On Thu, 23 Aug 2012, Marc Kleine-Budde wrote:

> Otherwise the module's refcount is 0 and it's possible to unload the module,
> even if the phy is in use.

> @@ -139,8 +140,10 @@ EXPORT_SYMBOL(devm_usb_put_phy);
>   */
>  void usb_put_phy(struct usb_phy *x)
>  {
> - if (x)
> + if (x) {
>   put_device(x->dev);
> + module_put(x->dev->driver->owner);
> + }

You musn't dereference x->dev after calling put_device().  Instead, 
save x->dev->driver->owner beforehand.

Alan Stern

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


Re: [PATCH 1/3] usb: phy: get phy driver's module if phy is acquired

2012-08-23 Thread Marc Kleine-Budde
On 08/23/2012 08:33 PM, Alan Stern wrote:
> On Thu, 23 Aug 2012, Marc Kleine-Budde wrote:
> 
>> Otherwise the module's refcount is 0 and it's possible to unload the module,
>> even if the phy is in use.
> 
>> @@ -139,8 +140,10 @@ EXPORT_SYMBOL(devm_usb_put_phy);
>>   */
>>  void usb_put_phy(struct usb_phy *x)
>>  {
>> -if (x)
>> +if (x) {
>>  put_device(x->dev);
>> +module_put(x->dev->driver->owner);
>> +}
> 
> You musn't dereference x->dev after calling put_device().  Instead, 
> save x->dev->driver->owner beforehand.

Will fix.

Tnx, Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: linux 3.6-rc2, undefined reference to omap_musb_mailbox

2012-08-23 Thread Peter Meerwald
On Mon, 20 Aug 2012, Felipe Balbi wrote:

> On Mon, Aug 20, 2012 at 04:37:28PM +0530, ABRAHAM, KISHON VIJAY wrote:
> > Hi,
> > 
> > On Mon, Aug 20, 2012 at 3:56 PM, Felipe Balbi  wrote:
> > > On Mon, Aug 20, 2012 at 03:46:07PM +0530, ABRAHAM, KISHON VIJAY wrote:
> > >> Hi,
> > >>
> > >> On Mon, Aug 20, 2012 at 3:24 PM, Felipe Balbi  wrote:
> > >> > On Mon, Aug 20, 2012 at 11:06:34AM +0530, ABRAHAM, KISHON VIJAY wrote:
> > >> >> Hi,
> > >> >>
> > >> >> On Sat, Aug 18, 2012 at 9:34 PM, Peter Meerwald  
> > >> >> wrote:
> > >> >> >
> > >> >> > 3.6-rc2 fails to compile with
> > >> >> > CONFIG_USB_MUSB_HDRC=m
> > >> >> > CONFIG_USB_MUSB_OMAP2PLUS=m
> > >> >> >
> > >> >> >   LD  init/built-in.o
> > >> >> > drivers/built-in.o: In function `twl4030_usb_irq':
> > >> >> > /home/pmeerw/linux-3.6-rc2/drivers/usb/otg/twl4030-usb.c:518: 
> > >> >> > undefined reference to `omap_musb_mailbox'
> > >> >> > drivers/built-in.o: In function `twl4030_usb_phy_init':
> > >> >> > /home/pmeerw/linux-3.6-rc2/drivers/usb/otg/twl4030-usb.c:540: 
> > >> >> > undefined reference to `omap_musb_mailbox'
> > >> >>
> > >> >> Having TWL4030_USB as a module will get rid of this.
> > >> >> I'll see how this can be resolved when some modules are *built-in* and
> > >> >> some are made as *modules*.
> > >> >
> > >> > EXPORT_SYMBOL_GPL() should sort that out, right ?
> > >>
> > >> No :-( I already have EXPORT_SYMBOL_GPL() in omap2430.c.
> > >
> > > I see you're missing an "extern" on the function prototype (on the
> > > header). Not sure how modules.dep is generated, but maybe it needs the
> > > "extern" there. Can you check it out ?
> > 
> > That isn't helping either.
> 
> oh, ok... twl4030-usb is built-in... now that makes sense. Since
> twl4030-usb uses a symbol from omap2430, then it should depend on it,
> otherwise this will always happen.

so add USB_MUSB_OMAP2PLUS to the depends of TWL4030_USB in 
drivers/usb/otg/Kconfig?

thanks, p.

-- 

Peter Meerwald
+43-664-218 (mobile)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb otg: TWL4030_USB depends on USB_MUSB_OMAP2PLUS in Kconfig

2012-08-23 Thread Peter Meerwald
Signed-off-by: Peter Meerwald 
---
 drivers/usb/otg/Kconfig |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 13fd1ddf..fefca18 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -58,7 +58,7 @@ config USB_ULPI_VIEWPORT
 
 config TWL4030_USB
tristate "TWL4030 USB Transceiver Driver"
-   depends on TWL4030_CORE && REGULATOR_TWL4030
+   depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS
select USB_OTG_UTILS
help
  Enable this to support the USB OTG transceiver on TWL4030
-- 
1.7.9.5

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


Re: Huawei E372 does not work via TI usb3 chip

2012-08-23 Thread Martin Mokrejs
Hi Sarah and Alan,
  thank you for your answer. I finally got to look for some current patches and 
to
test them. Confirming that patch 50d0206fcaea3e736f912fd5b00ec6233fb4ce44
applied over linux-3.5.1 fixes my problem and the modem now works fine
when attached to USB3 host.

Quoting the patch from http://www.spinics.net/lists/stable-commits/msg19131.html
below:



Subject: Patch "xhci: Fix bug after deq ptr set to link TRB." has been 
added to the 3.5-stable tree
From: 
Date: Fri, 17 Aug 2012 10:51:27 -0700
Cc: , 
Reply-to: linux-kernel@xxx

This is a note to let you know that I've just added the patch titled

xhci: Fix bug after deq ptr set to link TRB.

to the 3.5-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 xhci-fix-bug-after-deq-ptr-set-to-link-trb.patch
and it can be found in the queue-3.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From 50d0206fcaea3e736f912fd5b00ec6233fb4ce44 Mon Sep 17 00:00:00 2001
From: Sarah Sharp 
Date: Thu, 26 Jul 2012 12:03:59 -0700
Subject: xhci: Fix bug after deq ptr set to link TRB.

From: Sarah Sharp 

commit 50d0206fcaea3e736f912fd5b00ec6233fb4ce44 upstream.



Thanks,
Martin

Alan Stern wrote:
> On Tue, 14 Aug 2012, Martin Mokrejs wrote:
> 
>> Dear Sarah and Alan,
>>   would you please help me with fixing the issue of a USB2 modem stick not 
>> working via USB3
>> chip from Texas Instruments? This is Dell Vostro 3550. It never worked 
>> before and the kernel
>> is now plain 3.5.0. Attached are two usbmon traces and corresponding 
>> messages snippets.
>> In the "broken" mode pppd fires up the interface and sends and receives 7 
>> packets but is stuck
>> then.
> 
> This is entirely Sarah's ballpark; I can't be of any help except to 
> point out that the error occurs at this point in the USB3 log:
> 
> Aug 14 09:10:31 vostro pppd[30105]: Script /etc/ppp/ip-up finished (pid 
> 30779), status = 0x0
> Aug 14 09:10:35 vostro kernel: [ 1168.524795] xhci_hcd :0b:00.0: ERROR 
> Transfer event TRB DMA ptr not part of current TD
> 
> You can try looking through the mailing list archives; there may 
> already be some patches to fix this problem.
> 
> Alan Stern
> 
> 


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


Re: [PATCHv3 3/9] serial: vt8500: Add devicetree support for

2012-08-23 Thread Rob Landley
On 08/22/2012 01:44 AM, Arnd Bergmann wrote:
> On Wednesday 22 August 2012, Tony Prisk wrote:
>> The original patch was very simple, but I revisited it to fix other
>> issues and forgot to add the relevant comments.
>>
>> Port size is changed to fix a problem - WM8505 actually had 6 uart's
>> defined in platform data but the vt8500_ports variable was only 4.
>>
>> I have added devicetree port id support as well.
> 
> If you do multiple things in one driver, you should normally send multiple
> patches as well, each with a description why that change is done.
> It may seem silly at first to send out a one-line patch next to a 100-line
> patch for the same file, but those cases are actually the ones where it's
> most important.

Think of us poor git-bisect monkeys who have no idea why something broke
but can (purely mechanically) figure out which commit did it. If it's a
patch that does three unrelated things, we're kinda stuck.

Rob
-- 
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation.  Pick one.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] usb: otg: Improve phy handling

2012-08-23 Thread Richard Zhao
On Thu, Aug 23, 2012 at 07:22:51PM +0200, Marc Kleine-Budde wrote:
> This patch series improves the phy handling.
> 
> The first patch fixes the problem that the phy driver, when build as module,
> can be unloaded when the phy is in use.
ci13xxx_imx also have a try_module_get.

Thanks
Richard
> The second patch takes up Kishon's work
> and adds device tree support to the otg library. New in this patch is that
> devm_usb_get_phy_by_phandle() will return with -EPROBE_DEFER, if the requested
> phy has not registered itself yet. The third patch registers the mxs-phy as a
> USB_PHY_TYPE_USB2 phy, so that the ci13xxx_imx driver can reqeust it via the
> devm_usb_get_phy_by_phandle() function.
> 
> These patches apply to v3.6-rc3 and have ben successfully tested on mx28 and
> mx53 (with an improved version of the chipidea driver though).
> 
> regards, Marc
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe 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: chipidea driver

2012-08-23 Thread Richard Zhao
On Thu, Aug 23, 2012 at 06:57:03PM +0200, Marc Kleine-Budde wrote:
> Hello,
> 
> Michael and I have a bunch of updates and improvement for the chipidea
> driver. They apply to Richard's tree:
> 
> https://github.com/riczhao/kernel-imx/commits/topics/usb-driver
> 
> What's the status of these patches? It would be fine if someone queues
> them for upstream.
My patches is pending on Alex to review. The otg patch series was sent
on Jul 12. I don't know whether Alex has been back from vacation, or
what else I can do.

otg patch: 
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/109020.html
usbmisc: 
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/111945.html

Thanks
Richard
> 
> regards, Marc
> 
> -- 
> Pengutronix e.K.  | Marc Kleine-Budde   |
> Industrial Linux Solutions| Phone: +49-231-2826-924 |
> Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
> Amtsgericht Hildesheim, HRA 2686  | 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: [RFC PATCH 2/2] USB: Set usb port's DevicerRemovable according acpi information in EHCI

2012-08-23 Thread Lan Tianyu
On 2012年08月23日 22:10, Alan Stern wrote:
> On Thu, 23 Aug 2012, Lan Tianyu wrote:
> 
> Why not just update the ACPI information using the current hub
> descriptor?  You don't need to fetch the hub descriptor again.
>
 You mean to set DeviceRemovable directly rather than via hub descriptor 
 request
 here, right?
>>>
>>> Right.  DeviceRemovable should be set in only one place, and this
>>> should be that place.
>>>
>> But if other places got hub descriptor, they can't get DeviceRemovable
>> value since we only set DeviceRemovable in the hub_configure().(e.g lsusb).
> 
> I don't understand.  lsusb will be able to see the DeviceRemovable 
> values in sysfs, won't it?
lsusb will issue get hub descriptor request in the usr space and print
DeviceRemovable.
e.g lsusb show on my machine.

Hub Descriptor:
  bLength   9
  bDescriptorType  41
  nNbrPorts 6
  wHubCharacteristic 0x0089
Per-port power switching
Per-port overcurrent protection
TT think time 8 FS bits
Port indicators
  bPwrOn2PwrGood   50 * 2 milli seconds
  bHubContrCurrent  0 milli Ampere
  DeviceRemovable0x00   <
  PortPwrCtrlMask0xff
 Hub Port Status:
   Port 1: .0303 lowspeed power enable connect
   Port 2: .0100 power
   Port 3: .0303 lowspeed power enable connect
   Port 4: .0100 power
   Port 5: .0100 power
   Port 6: .0100 power

code in the usbutils/lsusb.c
do_hub()
{
...
ret = usb_control_msg(fd,
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS
| LIBUSB_RECIPIENT_DEVICE,
LIBUSB_REQUEST_GET_DESCRIPTOR,
value << 8, 0,
buf, sizeof buf, CTRL_TIMEOUT);
...
dump_hub("", buf, tt_type);
...
}

dump_hub()
{
...
printf("%s  DeviceRemovable   ", prefix);
...
}

So if we put setting DeviceRemovable in the hcd's hub descriptor request
routine, usr space could also get acpi information via getting hub
descriptor and we don't need to expose DeviceRemovable sysfs file.
> 
> Besides, there aren't any other places in the kernel that get the hub 
> descriptor.
Usr space may do this.

> 
>> Another problem is that some hcds will set DeviceRemovable themselves.
>> There will be a conflict between hcd and acpi information. Different
>> hcds may have different processes.
> 
> There is always the possibility of a conflict.  This remains true 
> whether you get the hub descriptor once or twice.
Yeah. how to deal with conflict
First time of getting the hub descriptor is to initialize hub and create
port devices. The second time is to update DeviceRemovable after
port devices create.

Another proposal is to set DeviceRemovable both in the hcd driver and
hub_configue() since hub probe maybe a special case. We have to get port
number first and then create port devices. Does this make sense?

> 
>>  So at first, I put setting
>> DeviceRemovable in the hcd's hub descriptor request routine.
> 
> But that is the wrong place to put it.  As you pointed out, when the 
> hub descriptor is requested we don't know how many ports there are and 
> so we can't set up the DeviceRemovable information.
This only works after the first hub descriptor request.

> 
> Alan Stern
> 


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


Re: [PATCH 2/3] usb: otg: add device tree support to otg library

2012-08-23 Thread Richard Zhao
Hi Marc,

Did you try both enableing and disabing DT pass build?

On Thu, Aug 23, 2012 at 07:22:53PM +0200, Marc Kleine-Budde wrote:
> From: Kishon Vijay Abraham I 
> 
> This patch adds an API to get usb phy by passing a device node phandle value.
> The new added devm_usb_get_phy_by_phandle() function will return a pointer to
> the phy on success, -EPROBE_DEFER if there is a device_node for the phandle,
> but the phy has not been added, or a ERR_PTR() otherwise.
> 
> Since it's possible to obtain a phy by phandle, the checks in usb_add_phy() 
> for
> a valid phy type is removed (now it's just a debug message if a user tries to
> add a phy with undefined type). This also allows to add multiple phys of same
> type.
> 
> Cc: Richard Zhao 
> Cc: Marek Vasut 
> Signed-off-by: Kishon Vijay Abraham I 
> Signed-off-by: Marc Kleine-Budde 
> ---
>  drivers/usb/otg/otg.c   |   96 
> ---
>  include/linux/usb/otg.h |8 
>  2 files changed, 90 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
> index 98c430e..23618de 100644
> --- a/drivers/usb/otg/otg.c
> +++ b/drivers/usb/otg/otg.c
> @@ -15,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -36,6 +37,21 @@ static struct usb_phy *__usb_find_phy(struct list_head 
> *list,
>   return ERR_PTR(-ENODEV);
>  }
>  
> +static struct usb_phy *__of_usb_find_phy(struct list_head *list,
> + struct device_node *node)
> +{
> + struct usb_phy  *phy;
> +
> + list_for_each_entry(phy, list, head) {
> + if (node != phy->dev->of_node)
> + continue;
> +
> + return phy;
> + }
> +
> + return ERR_PTR(-ENODEV);
> +}
> +
>  static void devm_usb_phy_release(struct device *dev, void *res)
>  {
>   struct usb_phy *phy = *(struct usb_phy **)res;
> @@ -112,6 +128,66 @@ err0:
>  EXPORT_SYMBOL(usb_get_phy);
>  
>  /**
> + * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
> + * @dev - device that requests this phy
> + * @phandle - name of the property holding the phy phandle value
> + *
> + * Returns the phy driver associated with the given phandle value,
> + * after getting a refcount to it, -ENODEV if there is no such phy or
> + * -EPROBE_DEFER if there is a phandle to the phy, but the device is
> + * not yet loaded. While at that, it also associates the device with
> + * the phy using devres. On driver detach, release function is invoked
> + * on the devres data, then, devres data is freed.
> + *
> + * For use by USB host and peripheral drivers.
> + */
> +struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
> + const char *phandle)
Since it's already a common function, we may give phandler property
a common name too. So we will not need phandle argument.
Please also don't forget to document the devm_xxx and dt binding.
> +{
> + struct usb_phy  *phy = NULL, **ptr;
> + unsigned long   flags;
> + struct device_node *node;
> +
> + if (!dev->of_node) {
> + dev_dbg(dev, "device does not have a device node entry\n");
> + return ERR_PTR(-EINVAL);
> + }
> +
> + node = of_parse_phandle(dev->of_node, phandle, 0);
> + if (!node) {
> + dev_dbg(dev, "failed to get %s phandle in %s node\n", phandle,
> + dev->of_node->full_name);
> + return ERR_PTR(-ENODEV);
> + }
> +
> + ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
> + if (!ptr) {
> + dev_dbg(dev, "failed to allocate memory for devres\n");
> + return ERR_PTR(-ENOMEM);
> + }
> +
> + spin_lock_irqsave(&phy_lock, flags);
> +
> + phy = __of_usb_find_phy(&phy_list, node);
> + if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
> + phy = ERR_PTR(-EPROBE_DEFER);
> + devres_free(ptr);
> + goto err0;
> + }
> +
> + *ptr = phy;
> + devres_add(dev, ptr);
> +
> + get_device(phy->dev);
> +
> +err0:
> + spin_unlock_irqrestore(&phy_lock, flags);
> +
> + return phy;
> +}
> +EXPORT_SYMBOL(devm_usb_get_phy_by_phandle);
> +
> +/**
>   * devm_usb_put_phy - release the USB PHY
>   * @dev - device that wants to release this phy
>   * @phy - the phy returned by devm_usb_get_phy()
> @@ -158,32 +234,24 @@ EXPORT_SYMBOL(usb_put_phy);
>   */
>  int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
>  {
> - int ret = 0;
>   unsigned long   flags;
>   struct usb_phy  *phy;
>  
> - if (x && x->type != USB_PHY_TYPE_UNDEFINED) {
> - dev_err(x->dev, "not accepting initialized PHY %s\n", x->label);
> - return -EINVAL;
why do you remove re-intialize check? Maybe you can add a
USB_PHY_TYPE_DT and below logic will be more clear.
> - }
> + if (x && x->type != USB_PHY_TYPE_UNDEFINED)
> + dev_dbg(x->dev, "add a phy with undefined type %s\n", x->label);
>  
>   s

Re: [PATCH 3/3] usb: mxs-phy: register phy as USB_PHY_TYPE_USB2

2012-08-23 Thread Richard Zhao
On Thu, Aug 23, 2012 at 07:22:54PM +0200, Marc Kleine-Budde wrote:
> This patch registers the msx-phy as an USB_PHY_TYPE_USB2. This is needed to 
> get
> reference to the phy with devm_usb_get_phy_by_phandle(), which will be added 
> in
> a later patch.
> 
> Signed-off-by: Marc Kleine-Budde 
> ---
>  drivers/usb/otg/mxs-phy.c |5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
> index c1a67cb..240b945 100644
> --- a/drivers/usb/otg/mxs-phy.c
> +++ b/drivers/usb/otg/mxs-phy.c
> @@ -141,11 +141,14 @@ static int mxs_phy_probe(struct platform_device *pdev)
>  
>   platform_set_drvdata(pdev, &mxs_phy->phy);
>  
> - return 0;
> + return usb_add_phy(&mxs_phy->phy, USB_PHY_TYPE_USB2);
Why is it usb2? It's kind of USB_PHY_TYPE_DT.
>  }
>  
>  static int __devexit mxs_phy_remove(struct platform_device *pdev)
>  {
> + struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
drvdata is usb_phy.

Thanks
Richard
> +
> + usb_remove_phy(&mxs_phy->phy);
>   platform_set_drvdata(pdev, NULL);
>  
>   return 0;
> -- 
> 1.7.10.4
> 
> 

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