About the DRD mode implementation of DWC3 driver

2014-04-09 Thread Wang, Yu
Hi Balbi,

Glad to see the OTG mode is prepare to support in your dwc3-role-switch
branch. But it is not fit for intel Merrfield/Moorfield platforms. :(

The reason is we implemented DRD mode instead of OTG mode. So the
GCTL.PortCapDir will be set as 01 for host mode, and 10 for device mode.

And the most important thing is we implemented two low power states for
dwc3 controller. D0i3hot and D0i3cold.

If no cable connected, we will trigger D0i3cold which will power gate
every clock/power used by dwc3 controller.

And entering D0i3hot with hibernation mode when acting as host mode
(micro A cable connected), also during device mode(micro B cable connected
to PC host).

For ID/VBus detection, we are using PMIC to do detect. So we will also
power gate the USB PHY for D0i3cold.

When we plug in micro A/B cable, the PMIC will report the ID/VBus change
event, then driver will force controller resume to D0 from D0i3cold. Due
to we haven't do any backup before entering D0i3cold, so we have to
re-initialize all host/device portion registers with setting
GCTL.PortCapDir to 01 or 10.

So with this PM design and DRD mode, we can't use your OTG mode. :(
I want to get your suggestions for DRD mode of dwc3 driver.

We add DRD support based on your otg.c or create new file drd.c?

Thanks
Yu
--
To unsubscribe from this list: send the line unsubscribe 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: Fwd: Isochronos audio

2014-04-09 Thread Clemens Ladisch
Alan Stern wrote:
 The IN transfer was 1 frame long and scheduled for frame 1123, so its
 completion indicates that the current frame number is = 1123.  The OUT
 transfer was 6 frames long and scheduled for frame , so it should
 have completed in frame 1117.  But the timestamps show that the two
 URBs completed at the same time (only 13 us between them).

Looks like interrupt moderation.

What minimum queue length should a driver use to work with all HCs?


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


Re: [PATCH v7 01/11] usb: chipidea: usb OTG fsm initialization.

2014-04-09 Thread Li Jun
On Wed, Apr 09, 2014 at 08:34:51AM +0800, Peter Chen wrote:
 On Sat, Apr 05, 2014 at 01:37:14PM +0800, Li Jun wrote:
  This patch adds OTG fsm related initialization when do otg init,
  add a seperate file for OTG fsm related utilities.
  
  Signed-off-by: Li Jun b47...@freescale.com
  ---
   drivers/usb/chipidea/Makefile  |1 +
   drivers/usb/chipidea/ci.h  |   17 ++
   drivers/usb/chipidea/otg.c |1 +
   drivers/usb/chipidea/otg_fsm.c |   68 
  
   drivers/usb/chipidea/otg_fsm.h |   29 +
   5 files changed, 116 insertions(+)
  
  diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
  index 480bd4d..2f099c7 100644
  --- a/drivers/usb/chipidea/Makefile
  +++ b/drivers/usb/chipidea/Makefile
  @@ -6,6 +6,7 @@ ci_hdrc-y   := core.o otg.o
   ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
   ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o
   ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG)   += debug.o
  +ci_hdrc-$(CONFIG_USB_OTG_FSM)  += otg_fsm.o
   
   # Glue/Bridge layers go here
   
  diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
  index 7ae8cb6..bd3529f 100644
  --- a/drivers/usb/chipidea/ci.h
  +++ b/drivers/usb/chipidea/ci.h
  @@ -17,6 +17,7 @@
   #include linux/irqreturn.h
   #include linux/usb.h
   #include linux/usb/gadget.h
  +#include linux/usb/otg-fsm.h
   
   
  /**
* DEFINE
  @@ -139,6 +140,7 @@ struct hw_bank {
* @roles: array of supported roles for this controller
* @role: current role
* @is_otg: if the device is otg-capable
  + * @fsm: otg finite state machine
* @work: work for role changing
* @wq: workqueue thread
* @qh_pool: allocation pool for queue heads
  @@ -174,6 +176,7 @@ struct ci_hdrc {
  struct ci_role_driver   *roles[CI_ROLE_END];
  enum ci_rolerole;
  boolis_otg;
  +   struct otg_fsm  fsm;
  struct work_struct  work;
  struct workqueue_struct *wq;
   
  @@ -319,6 +322,20 @@ static inline u32 hw_test_and_write(struct ci_hdrc 
  *ci, enum ci_hw_regs reg,
  return (val  mask)  __ffs(mask);
   }
   
  +/**
  + * ci_otg_is_fsm_mode: runtime check if otg controller
  + * is in otg fsm mode.
  + */
  +static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
  +{
  +#ifdef CONFIG_USB_OTG_FSM
  +   return ci-is_otg  ci-roles[CI_ROLE_HOST] 
  +   ci-roles[CI_ROLE_GADGET];
  +#else
  +   return false;
  +#endif
  +}
  +
   u32 hw_read_intr_enable(struct ci_hdrc *ci);
   
   u32 hw_read_intr_status(struct ci_hdrc *ci);
  diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
  index c694340..f978fa9 100644
  --- a/drivers/usb/chipidea/otg.c
  +++ b/drivers/usb/chipidea/otg.c
  @@ -22,6 +22,7 @@
   #include ci.h
   #include bits.h
   #include otg.h
  +#include otg_fsm.h
   
   /**
* hw_read_otgsc returns otgsc register bits value.
  diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
  new file mode 100644
  index 000..eddfe53
  --- /dev/null
  +++ b/drivers/usb/chipidea/otg_fsm.c
  @@ -0,0 +1,68 @@
  +/*
  + * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
  + *
  + * Copyright (C) 2014 Freescale Semiconductor, Inc.
  + *
  + * Author: Jun Li
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +
  +/*
  + * This file mainly handles OTG fsm, it includes OTG fsm operations
  + * for HNP and SRP.
  + */
  +
  +#include linux/usb/otg.h
  +#include linux/usb/gadget.h
  +#include linux/usb/hcd.h
  +#include linux/usb/chipidea.h
  +
  +#include ci.h
  +#include bits.h
  +#include otg.h
  +#include otg_fsm.h
  +
  +int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
  +{
  +   struct usb_otg *otg;
  +
  +   otg = devm_kzalloc(ci-dev,
  +   sizeof(struct usb_otg), GFP_KERNEL);
  +   if (!otg) {
  +   dev_err(ci-dev,
  +   Failed to allocate usb_otg structure for ci hdrc otg!\n);
  +   return -ENOMEM;
  +   }
  +
  +   otg-phy = ci-transceiver;
  +   otg-gadget = ci-gadget;
  +   if (ci-hcd)
  +   otg-host = ci-hcd-self;
 
 What's the purpose for this?
 
Since I move fsm init after ci_role_start in this patchset,
For case host start happens before this fsm init (power up with ID is 0), so
need init otg-host here.

Li Jun

  +   ci-fsm.otg = otg;
  +   ci-transceiver-otg = ci-fsm.otg;
  +   ci-fsm.power_up = 1;
  +   ci-fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
  +   ci-transceiver-state = OTG_STATE_UNDEFINED;
  +
  +   mutex_init(ci-fsm.lock);
  +
  +   /* Enable A vbus valid irq */
  +   hw_write_otgsc(ci, OTGSC_AVVIE, OTGSC_AVVIE);
  +
  +   if 

Re: [PATCH v7 03/11] usb: chipidea: host: init otg port number.

2014-04-09 Thread Li Jun
On Wed, Apr 09, 2014 at 08:44:32AM +0800, Peter Chen wrote:
 On Sat, Apr 05, 2014 at 01:37:16PM +0800, Li Jun wrote:
  Init otg_port number of otg capable host to be 1 at host start.
  
  Signed-off-by: Li Jun b47...@freescale.com
  ---
   drivers/usb/chipidea/host.c |   11 +--
   1 file changed, 9 insertions(+), 2 deletions(-)
  
  diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
  index ffb4168..c9c645b 100644
  --- a/drivers/usb/chipidea/host.c
  +++ b/drivers/usb/chipidea/host.c
  @@ -82,10 +82,17 @@ static int host_start(struct ci_hdrc *ci)
  }
   
  ret = usb_add_hcd(hcd, 0, 0);
  -   if (ret)
  +   if (ret) {
  goto disable_reg;
  -   else
  +   } else {
  +   struct usb_otg *otg = ci-transceiver-otg;
  +
  ci-hcd = hcd;
  +   if (ci_otg_is_fsm_mode(ci))
  +   hcd-self.otg_port = 1;
  +   if (otg)
  +   otg-host = hcd-self;
 
 Why update this patch? The ci-transceiver-otg is only allocated 
 at otg_fsm_mode, isn't it?
 

This is the same reason as your previous question in my 1st patch,
if the host start happens before fsm init, I need leave the otg-host
to be set in fsm init.

Li Jun

  +   }
   
  if (ci-platdata-flags  CI_HDRC_DISABLE_STREAMING)
  hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
  -- 
  1.7.9.5
  
  
 
 -- 
 
 Best Regards,
 Peter Chen
 

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


Re: [PATCH v7 00/11] Add USB OTG HNP and SRP support on Chipidea usb driver

2014-04-09 Thread Li Jun
On Wed, Apr 09, 2014 at 08:50:49AM +0800, Peter Chen wrote:
 On Sat, Apr 05, 2014 at 01:37:13PM +0800, Li Jun wrote:
  From: Li Jun b47...@freescale.com
  
  This patchset adds USB OTG HNP and SRP support on chipidea usb driver,
  existing OTG port role swtich function by ID pin status kept unchanged,
  based on that, if select CONFIG_USB_OTG_FSM, OTG HNP and SRP will be
  supported.
  
  Reference to:
  On-The-Go and Embedded Host Supplement to the USB Revision 2.0 
  Specification July 27, 2012
  Revision 2.0 version 1.1a
  
  Changes since v6:
  - Move ci_hdrc_otg_fsm_start() into ci_hdrc_otg_fsm_init()
 
 Where is the above change?
 
 Peter
 
Sorry I missed this change, I will fix and rework the otg fsm as below:
-ci_role_start with condition ci_otg_is_fsm_mode when ci_hdrc_probe.
-move fsm start into ci_hdrc_probe.
-move fsm init into otg init.
-Add special handling for start host/gadget when power up.
-Remove fsm protocol init.

Li Jun

  - Call ci_hdrc_otg_fsm_init() in ci_hdrc_probe()
  - Add fsm-protocol init in ci_hdrc_otg_fsm_init()
  - Remove role check in start/stop host/gadget.
  - Add ci_otg_is_fsm_mode() check when start fsm in ci_udc_start().
  - Add struct usb_otg *otg in ci_hdrc_otg_fsm_init() for easy read when
do init, set otg-host if host role start before otg fsm init(power up
with ID is 0).
  - set otg-host in host_start() if otg fsm init happens before host start
(power up with ID is 1) in host.c
  - Add comments of ci_hdrc structure for added fileds(fsm and fsm_timer)
in ci.h
  
  Changes since v5:
  - Move ci_otg_is_fsm_mode() check into caller functions.
  - Update comments alignment in otg_fsm.h
  - Revert the ci_hdrc_otg_fsm_start() change to be v4
  - Revert the role check removal of start host/gadget to be v4 since
ci_start_role may be called out of otg fsm.
  - Set controller to be device mode after stop host, to be able to
generate data pulse correctly.
  - Update some fsm variables to align with otg state.
  - Update test documents for A device start new seesion in step 6):
need set a_bus_drop to be 0 and set a_bus_req to be 1.
  - Typo fix.
  
  Changes since v4:
  - Fix compile warnings if USB_OTG_FSM is not enabled.
  - Add ci_otg_is_fsm_mode() to replace ci-is_otg for checking if ci is in
OTG FSM mode.
  - Move ci_hdrc_otg_fsm_start() at end of ci_hdrc_otg_fsm_init().
  - Fix patch splict problem(a later patch changes a previous one).
  - Remove unnecessary role check in start host/gadget.
  - Add {} in start_host.c to fix Coding style problem and declar a variable
equal to ci-transceiver-otg firstly when init otg port number.
  - Update some driver comments of chipidea drivers if this patchset applied.
  
  Changes since v3:
  - Move out 2 patches from this patchset, as which are not directly related 
  to
otg fsm.
  - Add a new file chipidea.txt under Documentation/usb/ to show how to test
OTG HNP and SRP.
  - Directly embed struct otg_fsm into ci_hdrc instead of pointer of otg_fsm.
  - Remove flag check in ci_otg_del_timer().
  - Remove ADP related code and comments since ADP is not supported by chip.
  - Start OTG fsm before request_irq.
  - For B-device, do not do OTG fsm transitions when gadget driver
is not registered, and start OTG fsm in register gadget driver.
  - Directly call ci_otg_fsm_work() in ci_hdrc_otg_fsm_start().
  - Enable data pulse when a_wait_vfall timer time out.
  - Update a_wait_vrise time out function.
  - UPdate comments of OTG time macro definitions in otg_fsm.h according to
OTG and EH 2.0.
  - Some typo and comments format changes.
  
  Changes since v2:
  - Add ABI document for sysfs input files description:
Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
  - Add a debug file for show some USB registers value.
  - Split host driver change to be 2 patches, one for otg_port number init;
the other one for vbus control change.
  - Export interrupt enable and status read functions from udc driver.
  - Only enable AVV irq in otg fsm init.
  - Remove duplicated USBSTS bits definitions.
  - Add HowTo demo role switch with 2 Freescale i.MX6Q sabre SD boards
in cover letter.
  - typo correction.
  
  Changes since v1:
  - Move out HNP polling patch from this series, which will be a seperated 
  patchset
followed this one
  - Change fsm timers global variables to be a structure embeded in ci_hdrc,
to make multiple OTG instances can exist in one system
  - Change some otg fsm functions to be static
  - Re-split timer init patch to avoid a later patch changing a previous one
in the same series
  - Change timer structure memory allocation to be devm_kzalloc
  - Update some format alignment and spelling errors
  
  Li Jun (11):
usb: chipidea: usb OTG fsm initialization.
usb: chipidea: host: vbus control change for OTG HNP.
usb: chipidea: host: init otg port number.
usb: chipidea: udc: driver update for OTG HNP.
usb: chipidea: add OTG fsm 

[PATCH 1/1] usb: usb-common: fix typo for usb_state_string

2014-04-09 Thread Peter Chen
%s/addresssed/addressed

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/usb-common.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
index d771870..6dfd30a 100644
--- a/drivers/usb/usb-common.c
+++ b/drivers/usb/usb-common.c
@@ -69,7 +69,7 @@ const char *usb_state_string(enum usb_device_state state)
[USB_STATE_RECONNECTING] = reconnecting,
[USB_STATE_UNAUTHENTICATED] = unauthenticated,
[USB_STATE_DEFAULT] = default,
-   [USB_STATE_ADDRESS] = addresssed,
+   [USB_STATE_ADDRESS] = addressed,
[USB_STATE_CONFIGURED] = configured,
[USB_STATE_SUSPENDED] = suspended,
};
-- 
1.7.8


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


Re: [PATCH 2/2] USB: serial: add dell wwan card(413c:81a9)

2014-04-09 Thread Bjørn Mork
AceLan Kao acelan@canonical.com writes:

 The udev rule works, it creates the ttyUSB* device nodes and I can
 operate mobile network from network manager.
 But, it can't get connected and I can't find mobile network device
 from iwconfig.

iwconfig is for 802.11 devices.  You'll normally use ModemManager or
some similar software to configure 3G/LTE modems

 And you think it's not a good way to add those ids into sierra driver,
 and you had added some of this kind of ids into qcserial driver.
 Even if it's not so scalable, but do you think should we collect those
 ids to qcserial and then refine the code when we are available.

 I'm willing to help, but I don't have enough devices to verify the work.

There are always too many devices when cleaning out the attic, but
always too few when wanting to test something :-)

A Sierra Wireless EM7345, Telit LN930 or any other Intel XMM7160 based
modem is high on my wish list right now...  The report I've seen so far
indicates that we have a job to do with the cdc-wdm driver to make these
devices work properly. But that's another topic.

Thanks for reporting the new Dell devices.


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


Re: [PATCH V4 1/5] phy: Add new Exynos5 USB 3.0 PHY driver

2014-04-09 Thread Tomasz Figa

Hi Vivek,

Please see my comments inline.

On 08.04.2014 16:36, Vivek Gautam wrote:

Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs.
The new driver uses the generic PHY framework and will interact
with DWC3 controller present on Exynos5 series of SoCs.
Thereby, removing old phy-samsung-usb3 driver and related code
used untill now which was based on usb/phy framework.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
  .../devicetree/bindings/phy/samsung-phy.txt|   42 ++
  drivers/phy/Kconfig|   11 +
  drivers/phy/Makefile   |1 +
  drivers/phy/phy-exynos5-usbdrd.c   |  668 
  4 files changed, 722 insertions(+)
  create mode 100644 drivers/phy/phy-exynos5-usbdrd.c


[snip]


+   Additional clock required for Exynos5420:
+   - usb30_sclk_100m: Additional special clock used for PHY operation
+  depicted as 'sclk_usbphy30' in CMU of Exynos5420.


Are you sure this isn't simply a gate for the ref clock, as it can be 
found on another SoC that is not upstream yet? I don't have 
documentation for Exynos 5420 so I can't tell, but I'd like to ask you 
to recheck this.



+- samsung,syscon-phandle: phandle for syscon interface, which is used to
+ control pmu registers for power isolation.
+- samsung,pmu-offset: phy power control register offset to 
pmu-system-controller
+ base.
+- #phy-cells : from the generic PHY bindings, must be 1;
+
+For samsung,exynos5250-usbdrd-phy and samsung,exynos5420-usbdrd-phy
+compatible PHYs, the second cell in the PHY specifier identifies the
+PHY id, which is interpreted as follows:
+  0 - UTMI+ type phy,
+  1 - PIPE3 type phy,
+
+Example:
+   usb3_phy: usbphy@1210 {
+   compatible = samsung,exynos5250-usbdrd-phy;
+   reg = 0x1210 0x100;
+   clocks = clock 286, clock 1;
+   clock-names = phy, usb3phy_refclk;


Binding description above doesn't mention usb3phy_refclk entry.


+   samsung,syscon-phandle = pmu_syscon;
+   samsung,pmu-offset = 0x704;
+   #phy-cells = 1;
+   };


[snip]


diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c
new file mode 100644
index 000..ff54a7c
--- /dev/null
+++ b/drivers/phy/phy-exynos5-usbdrd.c


[snip]


+static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct device_node *node = dev-of_node;
+   struct exynos5_usbdrd_phy *phy_drd;
+   struct phy_provider *phy_provider;
+   struct resource *res;
+   const struct of_device_id *match;
+   const struct exynos5_usbdrd_phy_drvdata *drv_data;
+   struct regmap *reg_pmu;
+   u32 pmu_offset;
+   int i;
+
+   /*
+* Exynos systems are completely DT enabled,
+* so lets not have any platform data support for this driver.
+*/
+   if (!node) {
+   dev_err(dev, no device node found\n);


This error message is not very meaningful. I'd rather use something like 
This driver can be only instantiated using Device Tree.



+   return -ENODEV;
+   }
+
+   match = of_match_node(exynos5_usbdrd_phy_of_match, pdev-dev.of_node);
+   if (!match) {
+   dev_err(dev, of_match_node() failed\n);
+   return -EINVAL;
+   }
+   drv_data = match-data;
+
+   phy_drd = devm_kzalloc(dev, sizeof(*phy_drd), GFP_KERNEL);
+   if (!phy_drd)
+   return -ENOMEM;
+
+   dev_set_drvdata(dev, phy_drd);
+   phy_drd-dev = dev;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   phy_drd-reg_phy = devm_ioremap_resource(dev, res);
+   if (IS_ERR(phy_drd-reg_phy)) {
+   dev_err(dev, Failed to map register memory (phy)\n);


devm_ioremap_resource() already prints an error message.

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


Re: [PATCH v4 2/5] dt: exynos5420: Enable support for USB 3.0 PHY controller

2014-04-09 Thread Tomasz Figa

On 08.04.2014 16:36, Vivek Gautam wrote:

Add device tree nodes for USB 3.0 PHY present alongwith
USB 3.0 controller Exynos 5420 SoC. This phy driver is
based on generic phy framework.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
  arch/arm/boot/dts/exynos5420.dtsi |   20 
  1 file changed, 20 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index 8db792b..a6efb52 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -652,4 +652,24 @@
clocks = clock 319, clock 318;
clock-names = tmu_apbif, tmu_triminfo_apbif;
};
+
+   usbdrd_phy0: phy@1210 {
+   compatible = samsung,exynos5420-usbdrd-phy;
+   reg = 0x1210 0x100;
+   clocks = clock 366, clock 1, clock 152;
+   clock-names = phy, ref, usb30_sclk_100m;


As I mentioned in another reply, please make sure that usb30_sclk_100m 
isn't simply a gate clock for ref clock.


Otherwise,

Reviewed-by: Tomasz Figa t.f...@samsung.com

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


Re: [PATCH V4 3/5] dt: exynos5420: Enable support for DWC3 controller

2014-04-09 Thread Tomasz Figa

On 08.04.2014 16:36, Vivek Gautam wrote:

Add device tree nodes for DWC3 controller present on
Exynos 5420 SoC, to enable support for USB 3.0.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
  arch/arm/boot/dts/exynos5420.dtsi |   34 ++
  1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5420.dtsi 
b/arch/arm/boot/dts/exynos5420.dtsi
index a6efb52..20c2d0b 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -653,6 +653,23 @@
clock-names = tmu_apbif, tmu_triminfo_apbif;
};

+   usb@1200 {
+   compatible = samsung,exynos5250-dwusb3;
+   clocks = clock 366;
+   clock-names = usbdrd30;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   dwc3 {
+   compatible = synopsys,dwc3;
+   reg = 0x1200 0x1;
+   interrupts = 0 72 0;
+   phys = usbdrd_phy0 0, usbdrd_phy0 1;
+   phy-names = usb2-phy, usb3-phy;
+   };
+   };
+
usbdrd_phy0: phy@1210 {
compatible = samsung,exynos5420-usbdrd-phy;
reg = 0x1210 0x100;
@@ -663,6 +680,23 @@
#phy-cells = 1;
};

+   usb@1240 {
+   compatible = samsung,exynos5250-dwusb3;
+   clocks = clock 367;
+   clock-names = usbdrd30;
+   #address-cells = 1;
+   #size-cells = 1;
+   ranges;
+
+   dwc3 {
+   compatible = synopsys,dwc3;
+   reg = 0x1240 0x1;
+   interrupts = 0 73 0;
+   phys = usbdrd_phy1 0, usbdrd_phy1 1;
+   phy-names = usb2-phy, usb3-phy;
+   };
+   };
+
usbdrd_phy1: phy@1250 {
compatible = samsung,exynos5420-usbdrd-phy;
reg = 0x1250 0x100;



Reviewed-by: Tomasz Figa t.f...@samsung.com

--
Best regards,
Tomasz

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


Re: [PATCH V4 4/5] dt: exynos5250: Enable support for generic USB DRD phy

2014-04-09 Thread Tomasz Figa

On 08.04.2014 16:36, Vivek Gautam wrote:

Add device tree node for new usbdrd-phy driver, which
is based on generic phy framework.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
  arch/arm/boot/dts/exynos5250.dtsi |   10 ++
  1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index b7dec41..92c6fcd 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -530,6 +530,16 @@
};
};

+   usbdrd_phy: phy@1210 {
+   compatible = samsung,exynos5250-usbdrd-phy;
+   reg = 0x1210 0x100;
+   clocks = clock 286, clock 1;
+   clock-names = phy, ref;
+   samsung,syscon-phandle = pmu_system_controller;
+   samsung,pmu-offset = 0x704;
+   #phy-cells = 1;
+   };
+
usb@1211 {
compatible = samsung,exynos4210-ehci;
reg = 0x1211 0x100;



Reviewed-by: Tomasz Figa t.f...@samsung.com

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


Re: [PATCH V4 5/5] usb-phy: samsung-usb3: Remove older phy-samsung-usb3 driver

2014-04-09 Thread Tomasz Figa

Hi Vivek,

On 08.04.2014 16:36, Vivek Gautam wrote:

Removing this older USB 3.0 DRD controller PHY driver, since
a new driver based on generic phy framework is now available.

Also removing the dt node for older driver from Exynos5250
device tree and updating the dt node for DWC3 controller.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---

NOTE: This patch should be merged only when the new USB 3.0
DRD phy controller driver is available in the tree from the
patches:
phy: Add new Exynos5 USB 3.0 PHY driver; and
dt: exynos5250: Enable support for generic USB DRD phy

  arch/arm/boot/dts/exynos5250.dtsi  |   17 +-
  drivers/usb/phy/phy-samsung-usb.h  |   83 -
  drivers/usb/phy/phy-samsung-usb3.c |  350 
  3 files changed, 2 insertions(+), 448 deletions(-)
  delete mode 100644 drivers/usb/phy/phy-samsung-usb3.c

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index 92c6fcd..1cb1e91 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi


IMHO driver and dts changes should be separated into two patches, first 
updating device tree to use the new driver and second removing the driver.


After fixing this issue,

Reviewed-by: Tomasz Figa t.f...@samsung.com

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


Re: [PATCH V4 5/5] usb-phy: samsung-usb3: Remove older phy-samsung-usb3 driver

2014-04-09 Thread Vivek Gautam
Hi Tomasz,
'

On Wed, Apr 9, 2014 at 4:43 PM, Tomasz Figa t.f...@samsung.com wrote:
 Hi Vivek,

Thanks for reviewing the patch series.


 On 08.04.2014 16:36, Vivek Gautam wrote:

 Removing this older USB 3.0 DRD controller PHY driver, since
 a new driver based on generic phy framework is now available.

 Also removing the dt node for older driver from Exynos5250
 device tree and updating the dt node for DWC3 controller.

 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 ---

 NOTE: This patch should be merged only when the new USB 3.0
 DRD phy controller driver is available in the tree from the
 patches:
 phy: Add new Exynos5 USB 3.0 PHY driver; and
 dt: exynos5250: Enable support for generic USB DRD phy

   arch/arm/boot/dts/exynos5250.dtsi  |   17 +-
   drivers/usb/phy/phy-samsung-usb.h  |   83 -
   drivers/usb/phy/phy-samsung-usb3.c |  350
 
   3 files changed, 2 insertions(+), 448 deletions(-)
   delete mode 100644 drivers/usb/phy/phy-samsung-usb3.c

 diff --git a/arch/arm/boot/dts/exynos5250.dtsi
 b/arch/arm/boot/dts/exynos5250.dtsi
 index 92c6fcd..1cb1e91 100644
 --- a/arch/arm/boot/dts/exynos5250.dtsi
 +++ b/arch/arm/boot/dts/exynos5250.dtsi


 IMHO driver and dts changes should be separated into two patches, first
 updating device tree to use the new driver and second removing the driver.

Sure will separate the patch into driver and dts change.


 After fixing this issue,

 Reviewed-by: Tomasz Figa t.f...@samsung.com

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


Re: [PATCH V4 1/5] phy: Add new Exynos5 USB 3.0 PHY driver

2014-04-09 Thread Vivek Gautam
Hi,


On Wed, Apr 9, 2014 at 4:36 PM, Tomasz Figa t.f...@samsung.com wrote:
 Hi Vivek,

 Please see my comments inline.


 On 08.04.2014 16:36, Vivek Gautam wrote:

 Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs.
 The new driver uses the generic PHY framework and will interact
 with DWC3 controller present on Exynos5 series of SoCs.
 Thereby, removing old phy-samsung-usb3 driver and related code
 used untill now which was based on usb/phy framework.

 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 ---
   .../devicetree/bindings/phy/samsung-phy.txt|   42 ++
   drivers/phy/Kconfig|   11 +
   drivers/phy/Makefile   |1 +
   drivers/phy/phy-exynos5-usbdrd.c   |  668
 
   4 files changed, 722 insertions(+)
   create mode 100644 drivers/phy/phy-exynos5-usbdrd.c


 [snip]


 +   Additional clock required for Exynos5420:
 +   - usb30_sclk_100m: Additional special clock used for PHY operation
 +  depicted as 'sclk_usbphy30' in CMU of
 Exynos5420.


 Are you sure this isn't simply a gate for the ref clock, as it can be found
 on another SoC that is not upstream yet? I don't have documentation for
 Exynos 5420 so I can't tell, but I'd like to ask you to recheck this.

From what i can see in the manual :
sclk_usbphy30 is derived from OSCCLK.
It is coming from a MUX (default input line to this is OSCCLK)  and
then through a DIV
there's this gate.

  {OSCCLK  + other sources} ---[MUX] --- [DIV] -- [GATE for
sclk_usbphy30]

the {rate of sclk_usbphy30} == OSCCLK

However the 'ref' clock that we have been using is the actual oscillator clock.
And on SoC Exynos5250, we don't have any such gate (sclk_usbphy30).
So should this mean that ref clock and sclk_usbphy30 are still be controlled by
two different gates ?



 +- samsung,syscon-phandle: phandle for syscon interface, which is used to
 + control pmu registers for power isolation.
 +- samsung,pmu-offset: phy power control register offset to
 pmu-system-controller
 + base.
 +- #phy-cells : from the generic PHY bindings, must be 1;
 +
 +For samsung,exynos5250-usbdrd-phy and samsung,exynos5420-usbdrd-phy
 +compatible PHYs, the second cell in the PHY specifier identifies the
 +PHY id, which is interpreted as follows:
 +  0 - UTMI+ type phy,
 +  1 - PIPE3 type phy,
 +
 +Example:
 +   usb3_phy: usbphy@1210 {
 +   compatible = samsung,exynos5250-usbdrd-phy;
 +   reg = 0x1210 0x100;
 +   clocks = clock 286, clock 1;
 +   clock-names = phy, usb3phy_refclk;


 Binding description above doesn't mention usb3phy_refclk entry.

my bad !! will correct this.



 +   samsung,syscon-phandle = pmu_syscon;
 +   samsung,pmu-offset = 0x704;
 +   #phy-cells = 1;
 +   };


 [snip]


 diff --git a/drivers/phy/phy-exynos5-usbdrd.c
 b/drivers/phy/phy-exynos5-usbdrd.c
 new file mode 100644
 index 000..ff54a7c
 --- /dev/null
 +++ b/drivers/phy/phy-exynos5-usbdrd.c


 [snip]


 +static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 +{
 +   struct device *dev = pdev-dev;
 +   struct device_node *node = dev-of_node;
 +   struct exynos5_usbdrd_phy *phy_drd;
 +   struct phy_provider *phy_provider;
 +   struct resource *res;
 +   const struct of_device_id *match;
 +   const struct exynos5_usbdrd_phy_drvdata *drv_data;
 +   struct regmap *reg_pmu;
 +   u32 pmu_offset;
 +   int i;
 +
 +   /*
 +* Exynos systems are completely DT enabled,
 +* so lets not have any platform data support for this driver.
 +*/
 +   if (!node) {
 +   dev_err(dev, no device node found\n);


 This error message is not very meaningful. I'd rather use something like
 This driver can be only instantiated using Device Tree.

Sure, will amend this.



 +   return -ENODEV;
 +   }
 +
 +   match = of_match_node(exynos5_usbdrd_phy_of_match,
 pdev-dev.of_node);
 +   if (!match) {
 +   dev_err(dev, of_match_node() failed\n);
 +   return -EINVAL;
 +   }
 +   drv_data = match-data;
 +
 +   phy_drd = devm_kzalloc(dev, sizeof(*phy_drd), GFP_KERNEL);
 +   if (!phy_drd)
 +   return -ENOMEM;
 +
 +   dev_set_drvdata(dev, phy_drd);
 +   phy_drd-dev = dev;
 +
 +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 +   phy_drd-reg_phy = devm_ioremap_resource(dev, res);
 +   if (IS_ERR(phy_drd-reg_phy)) {
 +   dev_err(dev, Failed to map register memory (phy)\n);


 devm_ioremap_resource() already prints an error message.
Ok, will remove this message.


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

[PATCH] phy: exynos5-usbdrd: Add facility to toggle vbus gpio on/off

2014-04-09 Thread Vivek Gautam
Adding support to enable/disable VBUS hooked to a gpio
to enable vbus supply on the port.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---

Based on 'phy-exynos5-usbdrd' patches:
[PATCH V4 0/5] Add Exynos5 USB 3.0 phy driver based on generic PHY framework
http://www.spinics.net/lists/linux-usb/msg105507.html

 drivers/phy/phy-exynos5-usbdrd.c |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5-usbdrd.c
index ff54a7c..5ca7485 100644
--- a/drivers/phy/phy-exynos5-usbdrd.c
+++ b/drivers/phy/phy-exynos5-usbdrd.c
@@ -18,6 +18,7 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_address.h
+#include linux/of_gpio.h
 #include linux/phy/phy.h
 #include linux/platform_device.h
 #include linux/mutex.h
@@ -176,6 +177,7 @@ struct exynos5_usbdrd_phy {
struct clk *ref_clk;
unsigned long ref_rate;
unsigned int refclk_reg;
+   int gpio;
 };
 
 #define to_usbdrd_phy(inst) \
@@ -460,6 +462,9 @@ static int exynos5_usbdrd_phy_power_on(struct phy *phy)
if (!IS_ERR(phy_drd-usb30_sclk))
clk_prepare_enable(phy_drd-usb30_sclk);
 
+   /* Toggle VBUS gpio - on */
+   gpio_set_value(phy_drd-gpio, 1);
+
/* Power-on PHY*/
inst-phy_cfg-phy_isol(inst, 0);
 
@@ -476,6 +481,9 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy)
/* Power-off the PHY */
inst-phy_cfg-phy_isol(inst, 1);
 
+   /* Toggle VBUS gpio - off */
+   gpio_set_value(phy_drd-gpio, 0);
+
if (!IS_ERR(phy_drd-usb30_sclk))
clk_disable_unprepare(phy_drd-usb30_sclk);
 
@@ -585,6 +593,16 @@ static int exynos5_usbdrd_phy_probe(struct platform_device 
*pdev)
 
phy_drd-drv_data = drv_data;
 
+   /* Get required GPIO for vbus */
+   phy_drd-gpio = of_get_named_gpio(dev-of_node,
+ samsung,vbus-gpio, 0);
+   if (!gpio_is_valid(phy_drd-gpio))
+   dev_dbg(dev, no usbdrd-phy vbus gpio defined\n);
+
+   if (devm_gpio_request(dev, phy_drd-gpio, phydrd_vbus_gpio))
+   dev_dbg(dev, can't request usbdrd-phy vbus gpio %d\n,
+   phy_drd-gpio);
+
if (of_property_read_u32(node, samsung,pmu-offset, pmu_offset)) {
dev_err(dev, Missing pmu-offset for phy isolation\n);
return -EINVAL;
-- 
1.7.10.4

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


Re: [PATCH] phy: exynos5-usbdrd: Add facility to toggle vbus gpio on/off

2014-04-09 Thread Sylwester Nawrocki
Hi Vivek,

On 09/04/14 13:54, Vivek Gautam wrote:
 Adding support to enable/disable VBUS hooked to a gpio
 to enable vbus supply on the port.

Does the GPIO control a fixed voltage regulator ? If so, shouldn't
it be modelled by the regulator API instead ?

 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
[...]
 + /* Get required GPIO for vbus */
 + phy_drd-gpio = of_get_named_gpio(dev-of_node,
 +   samsung,vbus-gpio, 0);
 + if (!gpio_is_valid(phy_drd-gpio))
 + dev_dbg(dev, no usbdrd-phy vbus gpio defined\n);
 +
 + if (devm_gpio_request(dev, phy_drd-gpio, phydrd_vbus_gpio))
 + dev_dbg(dev, can't request usbdrd-phy vbus gpio %d\n,
 + phy_drd-gpio);

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


Re: [PATCH] phy: exynos5-usbdrd: Add facility to toggle vbus gpio on/off

2014-04-09 Thread Vivek Gautam
Hi Sylwester,


On Wed, Apr 9, 2014 at 5:41 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 Hi Vivek,

 On 09/04/14 13:54, Vivek Gautam wrote:
 Adding support to enable/disable VBUS hooked to a gpio
 to enable vbus supply on the port.

 Does the GPIO control a fixed voltage regulator ? If so, shouldn't
 it be modelled by the regulator API instead ?

No, this GPIO controls a 'current limiting power distribution switch',
which gives the output vbus to usb controller.
Should i model this as a fixed regulator ?


 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 [...]
 + /* Get required GPIO for vbus */
 + phy_drd-gpio = of_get_named_gpio(dev-of_node,
 +   samsung,vbus-gpio, 0);
 + if (!gpio_is_valid(phy_drd-gpio))
 + dev_dbg(dev, no usbdrd-phy vbus gpio defined\n);
 +
 + if (devm_gpio_request(dev, phy_drd-gpio, phydrd_vbus_gpio))
 + dev_dbg(dev, can't request usbdrd-phy vbus gpio %d\n,
 + phy_drd-gpio);

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


Re: [PATCH] phy: exynos5-usbdrd: Add facility to toggle vbus gpio on/off

2014-04-09 Thread Tomasz Figa

Hi,

On 09.04.2014 14:24, Vivek Gautam wrote:

Hi Sylwester,


On Wed, Apr 9, 2014 at 5:41 PM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:

Hi Vivek,

On 09/04/14 13:54, Vivek Gautam wrote:

Adding support to enable/disable VBUS hooked to a gpio
to enable vbus supply on the port.


Does the GPIO control a fixed voltage regulator ? If so, shouldn't
it be modelled by the regulator API instead ?


No, this GPIO controls a 'current limiting power distribution switch',
which gives the output vbus to usb controller.
Should i model this as a fixed regulator ?


If I understand this correctly, this is just a switch that lets you 
control whether vbus is provided to the USB connector or not. If so, 
this doesn't look like an Exynos-specific thing at all and should rather 
be modeled on higher level.


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


Re: [PATCH] phy: exynos5-usbdrd: Add facility to toggle vbus gpio on/off

2014-04-09 Thread Sylwester Nawrocki
On 09/04/14 14:24, Vivek Gautam wrote:
 On Wed, Apr 9, 2014 at 5:41 PM, Sylwester Nawrocki
 s.nawro...@samsung.com wrote:
  On 09/04/14 13:54, Vivek Gautam wrote:
  Adding support to enable/disable VBUS hooked to a gpio
  to enable vbus supply on the port.
 
  Does the GPIO control a fixed voltage regulator ? If so, shouldn't
  it be modelled by the regulator API instead ?

 No, this GPIO controls a 'current limiting power distribution switch',
 which gives the output vbus to usb controller.
 Should i model this as a fixed regulator ?

OK, it's just a power switch then. I suspect using the regulator API
would be more universal, as such a GPIO is somewhat a board design
detail. I'm not going to object to your patch, just might be better
to use the gpiod API instead.

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


Re: [PATCH V4 1/5] phy: Add new Exynos5 USB 3.0 PHY driver

2014-04-09 Thread Tomasz Figa

On 09.04.2014 13:49, Vivek Gautam wrote:

Hi,


On Wed, Apr 9, 2014 at 4:36 PM, Tomasz Figa t.f...@samsung.com wrote:

Hi Vivek,

Please see my comments inline.


On 08.04.2014 16:36, Vivek Gautam wrote:


Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs.
The new driver uses the generic PHY framework and will interact
with DWC3 controller present on Exynos5 series of SoCs.
Thereby, removing old phy-samsung-usb3 driver and related code
used untill now which was based on usb/phy framework.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
---
   .../devicetree/bindings/phy/samsung-phy.txt|   42 ++
   drivers/phy/Kconfig|   11 +
   drivers/phy/Makefile   |1 +
   drivers/phy/phy-exynos5-usbdrd.c   |  668

   4 files changed, 722 insertions(+)
   create mode 100644 drivers/phy/phy-exynos5-usbdrd.c



[snip]



+   Additional clock required for Exynos5420:
+   - usb30_sclk_100m: Additional special clock used for PHY operation
+  depicted as 'sclk_usbphy30' in CMU of
Exynos5420.



Are you sure this isn't simply a gate for the ref clock, as it can be found
on another SoC that is not upstream yet? I don't have documentation for
Exynos 5420 so I can't tell, but I'd like to ask you to recheck this.



From what i can see in the manual :

sclk_usbphy30 is derived from OSCCLK.
It is coming from a MUX (default input line to this is OSCCLK)  and
then through a DIV
there's this gate.

   {OSCCLK  + other sources} ---[MUX] --- [DIV] -- [GATE for
sclk_usbphy30]

the {rate of sclk_usbphy30} == OSCCLK

However the 'ref' clock that we have been using is the actual oscillator clock.
And on SoC Exynos5250, we don't have any such gate (sclk_usbphy30).
So should this mean that ref clock and sclk_usbphy30 are still be controlled by
two different gates ?



Is there maybe a diagram of PHY input clocks in the datasheet, like for 
USB 2.0 PHY in Exynos4210/4412/5250 datasheets in the chapter about 
USB2.0 Device? Something like:


 
||
| ___|
XusbXTI |   Phy_fsel[2:0]|  ___  |
   ___[X]___|| __|_|___|\__|_|
  | |   _v___ |  _   ^ |   |/  | |
_   |  | || | |  | |  ___  | |
 ___|  | || | |  | | |   |_|_|
|___|   |  | X 0 ||_| PLL |__|_|_|CLK|_|_|
_   |  | |  | || |DIV|_|_|
  |___[X]   |  |_| 12   |_|480 | |___| | |
|  MHz MHz |Digital| |
XusbXTO |   USB PHY|___| |
||


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


[PATCH v8 10/11] Documentation: ABI: usb: sysfs Description for chipidea USB OTG HNP and SRP

2014-04-09 Thread Li Jun
From: Li Jun b47...@freescale.com

This patch adds sysfs interface description for chipidea USB OTG HNP and SRP.

Signed-off-by: Li Jun b47...@freescale.com
---
 .../ABI/testing/sysfs-platform-chipidea-usb-otg|   56 
 1 file changed, 56 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg 
b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
new file mode 100644
index 000..151c595
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
@@ -0,0 +1,56 @@
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
+Date:  Feb 2014
+Contact:   Li Jun b47...@freescale.com
+Description:
+   Can be set and read.
+   Set a_bus_req(A-device bus request) input to be 1 if
+   the application running on the A-device wants to use the bus,
+   and to be 0 when the application no longer wants to use
+   the bus(or wants to work as peripheral). a_bus_req can also
+   be set to 1 by kernel in response to remote wakeup signaling
+   from the B-device, the A-device should decide to resume the bus.
+
+   Valid values are 1 and 0.
+
+   Reading: returns 1 if the application running on the A-device
+   is using the bus as host role, otherwise 0.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
+Date:  Feb 2014
+Contact:   Li Jun b47...@freescale.com
+Description:
+   Can be set and read
+   The a_bus_drop(A-device bus drop) input is 1 when the
+   application running on the A-device wants to power down
+   the bus, and is 0 otherwise, When a_bus_drop is 1, then
+   the a_bus_req shall be 0.
+
+   Valid values are 1 and 0.
+
+   Reading: returns 1 if the bus is off(vbus is turned off) by
+A-device, otherwise 0.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+Date:  Feb 2014
+Contact:   Li Jun b47...@freescale.com
+Description:
+   Can be set and read.
+   The b_bus_req(B-device bus request) input is 1 during the time
+   that the application running on the B-device wants to use the
+   bus as host, and is 0 when the application no longer wants to
+   work as host and decides to switch back to be peripheral.
+
+   Valid values are 1 and 0.
+
+   Reading: returns if the application running on the B device
+   is using the bus as host role, otherwise 0.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_clr_err
+Date:  Feb 2014
+Contact:   Li Jun b47...@freescale.com
+Description:
+   Only can be set.
+   The a_clr_err(A-device Vbus error clear) input is used to clear
+   vbus error, then A-device will power down the bus.
+
+   Valid value is 1
-- 
1.7.9.5


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


[PATCH v8 02/11] usb: chipidea: host: vbus control change for OTG HNP.

2014-04-09 Thread Li Jun
Leave vbus on/off hanlded by OTG fsm if in OTG mode.

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/host.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index a8ac6c1..ffb4168 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -67,7 +67,11 @@ static int host_start(struct ci_hdrc *ci)
ehci-has_tdi_phy_lpm = ci-hw_bank.lpm;
ehci-imx28_write_fix = ci-imx28_write_fix;
 
-   if (ci-platdata-reg_vbus) {
+   /*
+* vbus is always on if host is not in OTG FSM mode,
+* otherwise should be controlled by OTG FSM
+*/
+   if (ci-platdata-reg_vbus  !ci_otg_is_fsm_mode(ci)) {
ret = regulator_enable(ci-platdata-reg_vbus);
if (ret) {
dev_err(ci-dev,
@@ -89,7 +93,7 @@ static int host_start(struct ci_hdrc *ci)
return ret;
 
 disable_reg:
-   if (ci-platdata-reg_vbus)
+   if (ci-platdata-reg_vbus  !ci_otg_is_fsm_mode(ci))
regulator_disable(ci-platdata-reg_vbus);
 
 put_hcd:
@@ -105,7 +109,7 @@ static void host_stop(struct ci_hdrc *ci)
if (hcd) {
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
-   if (ci-platdata-reg_vbus)
+   if (ci-platdata-reg_vbus  !ci_otg_is_fsm_mode(ci))
regulator_disable(ci-platdata-reg_vbus);
}
 }
-- 
1.7.9.5


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


[PATCH v8 01/11] usb: chipidea: usb OTG fsm initialization.

2014-04-09 Thread Li Jun
This patch adds OTG fsm related initialization when do otg init,
add a seperate file for OTG fsm related utilities.

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/Makefile  |1 +
 drivers/usb/chipidea/ci.h  |   17 +++
 drivers/usb/chipidea/otg.c |4 +++
 drivers/usb/chipidea/otg_fsm.c |   61 
 drivers/usb/chipidea/otg_fsm.h |   29 +++
 5 files changed, 112 insertions(+)

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 480bd4d..2f099c7 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -6,6 +6,7 @@ ci_hdrc-y   := core.o otg.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG)   += debug.o
+ci_hdrc-$(CONFIG_USB_OTG_FSM)  += otg_fsm.o
 
 # Glue/Bridge layers go here
 
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 7ae8cb6..bd3529f 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -17,6 +17,7 @@
 #include linux/irqreturn.h
 #include linux/usb.h
 #include linux/usb/gadget.h
+#include linux/usb/otg-fsm.h
 
 /**
  * DEFINE
@@ -139,6 +140,7 @@ struct hw_bank {
  * @roles: array of supported roles for this controller
  * @role: current role
  * @is_otg: if the device is otg-capable
+ * @fsm: otg finite state machine
  * @work: work for role changing
  * @wq: workqueue thread
  * @qh_pool: allocation pool for queue heads
@@ -174,6 +176,7 @@ struct ci_hdrc {
struct ci_role_driver   *roles[CI_ROLE_END];
enum ci_rolerole;
boolis_otg;
+   struct otg_fsm  fsm;
struct work_struct  work;
struct workqueue_struct *wq;
 
@@ -319,6 +322,20 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, 
enum ci_hw_regs reg,
return (val  mask)  __ffs(mask);
 }
 
+/**
+ * ci_otg_is_fsm_mode: runtime check if otg controller
+ * is in otg fsm mode.
+ */
+static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
+{
+#ifdef CONFIG_USB_OTG_FSM
+   return ci-is_otg  ci-roles[CI_ROLE_HOST] 
+   ci-roles[CI_ROLE_GADGET];
+#else
+   return false;
+#endif
+}
+
 u32 hw_read_intr_enable(struct ci_hdrc *ci);
 
 u32 hw_read_intr_status(struct ci_hdrc *ci);
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index c694340..d76db51 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -22,6 +22,7 @@
 #include ci.h
 #include bits.h
 #include otg.h
+#include otg_fsm.h
 
 /**
  * hw_read_otgsc returns otgsc register bits value.
@@ -116,6 +117,9 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci)
return -ENODEV;
}
 
+   if (ci_otg_is_fsm_mode(ci))
+   return ci_hdrc_otg_fsm_init(ci);
+
return 0;
 }
 
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
new file mode 100644
index 000..20bed84
--- /dev/null
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -0,0 +1,61 @@
+/*
+ * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ *
+ * Author: Jun Li
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This file mainly handles OTG fsm, it includes OTG fsm operations
+ * for HNP and SRP.
+ */
+
+#include linux/usb/otg.h
+#include linux/usb/gadget.h
+#include linux/usb/hcd.h
+#include linux/usb/chipidea.h
+
+#include ci.h
+#include bits.h
+#include otg.h
+#include otg_fsm.h
+
+int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
+{
+   struct usb_otg *otg;
+
+   otg = devm_kzalloc(ci-dev,
+   sizeof(struct usb_otg), GFP_KERNEL);
+   if (!otg) {
+   dev_err(ci-dev,
+   Failed to allocate usb_otg structure for ci hdrc otg!\n);
+   return -ENOMEM;
+   }
+
+   otg-phy = ci-transceiver;
+   otg-gadget = ci-gadget;
+   ci-fsm.otg = otg;
+   ci-transceiver-otg = ci-fsm.otg;
+   ci-fsm.power_up = 1;
+   ci-fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
+   ci-transceiver-state = OTG_STATE_UNDEFINED;
+
+   mutex_init(ci-fsm.lock);
+
+   /* Enable A vbus valid irq */
+   hw_write_otgsc(ci, OTGSC_AVVIE, OTGSC_AVVIE);
+
+   if (ci-fsm.id) {
+   ci-fsm.b_ssend_srp =
+   hw_read_otgsc(ci, OTGSC_BSV) ? 0 : 1;
+   ci-fsm.b_sess_vld =
+   hw_read_otgsc(ci, OTGSC_BSV) ? 1 : 0;
+   }
+
+   return 0;
+}
diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h
new file mode 100644
index 

[PATCH v8 03/11] usb: chipidea: host: init otg port number.

2014-04-09 Thread Li Jun
Init otg_port number of otg capable host to be 1 at host start.

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/host.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index ffb4168..a93d950 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -82,10 +82,17 @@ static int host_start(struct ci_hdrc *ci)
}
 
ret = usb_add_hcd(hcd, 0, 0);
-   if (ret)
+   if (ret) {
goto disable_reg;
-   else
+   } else {
+   struct usb_otg *otg = ci-transceiver-otg;
+
ci-hcd = hcd;
+   if (otg) {
+   otg-host = hcd-self;
+   hcd-self.otg_port = 1;
+   }
+   }
 
if (ci-platdata-flags  CI_HDRC_DISABLE_STREAMING)
hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
-- 
1.7.9.5


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


[PATCH v8 05/11] usb: chipidea: add OTG fsm operation functions implemenation.

2014-04-09 Thread Li Jun
Add OTG HNP and SRP operation functions implementation:
- charge vbus
- drive vbus
- connection signaling
- drive sof
- start data pulse
- add fsm timer
- delete fsm timer
- start host
- start gadget

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/bits.h|9 ++
 drivers/usb/chipidea/ci.h  |2 +
 drivers/usb/chipidea/otg_fsm.c |  196 
 drivers/usb/chipidea/otg_fsm.h |   25 +
 4 files changed, 232 insertions(+)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 83d06c1..44882c8 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -44,9 +44,14 @@
 #define DEVICEADDR_USBADR (0x7FUL  25)
 
 /* PORTSC */
+#define PORTSC_CCSBIT(0)
+#define PORTSC_CSCBIT(1)
+#define PORTSC_PECBIT(3)
+#define PORTSC_OCCBIT(5)
 #define PORTSC_FPRBIT(6)
 #define PORTSC_SUSP   BIT(7)
 #define PORTSC_HSPBIT(9)
+#define PORTSC_PP BIT(12)
 #define PORTSC_PTC(0x0FUL  16)
 #define PORTSC_PHCD(d)   ((d) ? BIT(22) : BIT(23))
 /* PTS and PTW for non lpm version only */
@@ -56,6 +61,9 @@
 #define PORTSC_PTWBIT(28)
 #define PORTSC_STSBIT(29)
 
+#define PORTSC_W1C_BITS\
+   (PORTSC_CSC | PORTSC_PEC | PORTSC_OCC)
+
 /* DEVLC */
 #define DEVLC_PFSCBIT(23)
 #define DEVLC_PSPD(0x03UL  25)
@@ -72,6 +80,7 @@
 
 /* OTGSC */
 #define OTGSC_IDPU   BIT(5)
+#define OTGSC_HADP   BIT(6)
 #define OTGSC_ID BIT(8)
 #define OTGSC_AVVBIT(9)
 #define OTGSC_ASVBIT(10)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index bd3529f..9563cb5 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -141,6 +141,7 @@ struct hw_bank {
  * @role: current role
  * @is_otg: if the device is otg-capable
  * @fsm: otg finite state machine
+ * @fsm_timer: pointer to timer list of otg fsm
  * @work: work for role changing
  * @wq: workqueue thread
  * @qh_pool: allocation pool for queue heads
@@ -177,6 +178,7 @@ struct ci_hdrc {
enum ci_rolerole;
boolis_otg;
struct otg_fsm  fsm;
+   struct ci_otg_fsm_timer_list*fsm_timer;
struct work_struct  work;
struct workqueue_struct *wq;
 
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 20bed84..d09508a 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -19,12 +19,207 @@
 #include linux/usb/gadget.h
 #include linux/usb/hcd.h
 #include linux/usb/chipidea.h
+#include linux/regulator/consumer.h
 
 #include ci.h
 #include bits.h
 #include otg.h
 #include otg_fsm.h
 
+/*
+ * Add timer to active timer list
+ */
+static void ci_otg_add_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
+{
+   struct ci_otg_fsm_timer *tmp_timer;
+   struct ci_otg_fsm_timer *timer = ci-fsm_timer-timer_list[t];
+   struct list_head *active_timers = ci-fsm_timer-active_timers;
+
+   if (t = NUM_CI_OTG_FSM_TIMERS)
+   return;
+
+   /*
+* Check if the timer is already in the active list,
+* if so update timer count
+*/
+   list_for_each_entry(tmp_timer, active_timers, list)
+   if (tmp_timer == timer) {
+   timer-count = timer-expires;
+   return;
+   }
+
+   timer-count = timer-expires;
+   list_add_tail(timer-list, active_timers);
+
+   /* Enable 1ms irq */
+   if (!(hw_read_otgsc(ci, OTGSC_1MSIE)))
+   hw_write_otgsc(ci, OTGSC_1MSIE, OTGSC_1MSIE);
+}
+
+/*
+ * Remove timer from active timer list
+ */
+static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
+{
+   struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
+   struct ci_otg_fsm_timer *timer = ci-fsm_timer-timer_list[t];
+   struct list_head *active_timers = ci-fsm_timer-active_timers;
+
+   if (t = NUM_CI_OTG_FSM_TIMERS)
+   return;
+
+   list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list)
+   if (tmp_timer == timer)
+   list_del(timer-list);
+
+   /* Disable 1ms irq if there is no any active timer */
+   if (list_empty(active_timers))
+   hw_write_otgsc(ci, OTGSC_1MSIE, 0);
+}
+
+/* -*/
+/* Operations that will be called from OTG Finite State Machine */
+/* -*/
+static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
+{
+   struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
+
+   if (t  NUM_OTG_FSM_TIMERS)
+   ci_otg_add_timer(ci, t);
+   return;
+}

[PATCH v8 09/11] usb: chipidea: debug: add debug file for OTG variables

2014-04-09 Thread Li Jun
From: Li Jun b47...@freescale.com

This patch adds a debug file for OTG vairables show.

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/debug.c |   84 ++
 1 file changed, 84 insertions(+)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 5b890c1..7cccab6 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -7,6 +7,9 @@
 #include linux/uaccess.h
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
+#include linux/usb/phy.h
+#include linux/usb/otg.h
+#include linux/usb/otg-fsm.h
 
 #include ci.h
 #include udc.h
@@ -205,6 +208,80 @@ static const struct file_operations ci_requests_fops = {
.release= single_release,
 };
 
+int ci_otg_show(struct seq_file *s, void *unused)
+{
+   struct ci_hdrc *ci = s-private;
+   struct otg_fsm *fsm;
+
+   if (!ci || !ci_otg_is_fsm_mode(ci))
+   return 0;
+
+   fsm = ci-fsm;
+
+   /* -- State - */
+   seq_printf(s, OTG state: %s\n\n,
+   usb_otg_state_string(ci-transceiver-state));
+
+   /* -- State Machine Variables - */
+   seq_printf(s, a_bus_drop: %d\n, fsm-a_bus_drop);
+
+   seq_printf(s, a_bus_req: %d\n, fsm-a_bus_req);
+
+   seq_printf(s, a_srp_det: %d\n, fsm-a_srp_det);
+
+   seq_printf(s, a_vbus_vld: %d\n, fsm-a_vbus_vld);
+
+   seq_printf(s, b_conn: %d\n, fsm-b_conn);
+
+   seq_printf(s, adp_change: %d\n, fsm-adp_change);
+
+   seq_printf(s, power_up: %d\n, fsm-power_up);
+
+   seq_printf(s, a_bus_resume: %d\n, fsm-a_bus_resume);
+
+   seq_printf(s, a_bus_suspend: %d\n, fsm-a_bus_suspend);
+
+   seq_printf(s, a_conn: %d\n, fsm-a_conn);
+
+   seq_printf(s, b_bus_req: %d\n, fsm-b_bus_req);
+
+   seq_printf(s, b_bus_suspend: %d\n, fsm-b_bus_suspend);
+
+   seq_printf(s, b_se0_srp: %d\n, fsm-b_se0_srp);
+
+   seq_printf(s, b_ssend_srp: %d\n, fsm-b_ssend_srp);
+
+   seq_printf(s, b_sess_vld: %d\n, fsm-b_sess_vld);
+
+   seq_printf(s, b_srp_done: %d\n, fsm-b_srp_done);
+
+   seq_printf(s, drv_vbus: %d\n, fsm-drv_vbus);
+
+   seq_printf(s, loc_conn: %d\n, fsm-loc_conn);
+
+   seq_printf(s, loc_sof: %d\n, fsm-loc_sof);
+
+   seq_printf(s, adp_prb: %d\n, fsm-adp_prb);
+
+   seq_printf(s, id: %d\n, fsm-id);
+
+   seq_printf(s, protocol: %d\n, fsm-protocol);
+
+   return 0;
+}
+
+static int ci_otg_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, ci_otg_show, inode-i_private);
+}
+
+static const struct file_operations ci_otg_fops = {
+   .open   = ci_otg_open,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= single_release,
+};
+
 static int ci_role_show(struct seq_file *s, void *data)
 {
struct ci_hdrc *ci = s-private;
@@ -332,6 +409,13 @@ int dbg_create_files(struct ci_hdrc *ci)
if (!dent)
goto err;
 
+   if (ci_otg_is_fsm_mode(ci)) {
+   dent = debugfs_create_file(otg, S_IRUGO, ci-debugfs, ci,
+   ci_otg_fops);
+   if (!dent)
+   goto err;
+   }
+
dent = debugfs_create_file(role, S_IRUGO | S_IWUSR, ci-debugfs, ci,
   ci_role_fops);
if (!dent)
-- 
1.7.9.5


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


[PATCH v8 08/11] usb: chipidea: add sys inputs for OTG fsm input.

2014-04-09 Thread Li Jun
From: Li Jun b47...@freescale.com

This patch adds sys input to control and show OTG fsm inputs by application,
user can do host and preipheral role switch by change these inputs.

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/otg.c |2 +
 drivers/usb/chipidea/otg_fsm.c |  173 
 drivers/usb/chipidea/otg_fsm.h |6 ++
 3 files changed, 181 insertions(+)

diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 38e340c..a048b08 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -141,4 +141,6 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
/* Disable all OTG irq and clear status */
hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
OTGSC_INT_STATUS_BITS);
+   if (ci_otg_is_fsm_mode(ci))
+   ci_hdrc_otg_fsm_remove(ci);
 }
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 796e92e..9a86366 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -46,6 +46,167 @@ static struct ci_otg_fsm_timer *otg_timer_initializer
return timer;
 }
 
+/* Add for otg: interact with user space app */
+static ssize_t
+get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+   t = scnprintf(next, size, %d\n, ci-fsm.a_bus_req);
+   size -= t;
+   next += t;
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_req(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc *ci = dev_get_drvdata(dev);
+
+   if (count  2)
+   return -1;
+
+   mutex_lock(ci-fsm.lock);
+   if (buf[0] == '0') {
+   ci-fsm.a_bus_req = 0;
+   } else if (buf[0] == '1') {
+   /* If a_bus_drop is TRUE, a_bus_req can't be set */
+   if (ci-fsm.a_bus_drop) {
+   mutex_unlock(ci-fsm.lock);
+   return count;
+   }
+   ci-fsm.a_bus_req = 1;
+   }
+
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+   mutex_unlock(ci-fsm.lock);
+
+   return count;
+}
+static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
+
+static ssize_t
+get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+   t = scnprintf(next, size, %d\n, ci-fsm.a_bus_drop);
+   size -= t;
+   next += t;
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_drop(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count  2)
+   return -1;
+
+   mutex_lock(ci-fsm.lock);
+   if (buf[0] == '0') {
+   ci-fsm.a_bus_drop = 0;
+   } else if (buf[0] == '1') {
+   ci-fsm.a_bus_drop = 1;
+   ci-fsm.a_bus_req = 0;
+   }
+
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+   mutex_unlock(ci-fsm.lock);
+
+   return count;
+}
+static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop,
+   set_a_bus_drop);
+
+static ssize_t
+get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+   t = scnprintf(next, size, %d\n, ci-fsm.b_bus_req);
+   size -= t;
+   next += t;
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_b_bus_req(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count  2)
+   return -1;
+
+   mutex_lock(ci-fsm.lock);
+   if (buf[0] == '0')
+   ci-fsm.b_bus_req = 0;
+   else if (buf[0] == '1')
+   ci-fsm.b_bus_req = 1;
+
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+   mutex_unlock(ci-fsm.lock);
+
+   return count;
+}
+static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req);
+
+static ssize_t
+set_a_clr_err(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count  2)
+   return 

[PATCH v8 00/11] Add USB OTG HNP and SRP support on Chipidea usb driver

2014-04-09 Thread Li Jun
From: Li Jun b47...@freescale.com

This patchset adds USB OTG HNP and SRP support on chipidea usb driver,
existing OTG port role swtich function by ID pin status kept unchanged,
based on that, if select CONFIG_USB_OTG_FSM, OTG HNP and SRP will be
supported.

Reference to:
On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification 
July 27, 2012
Revision 2.0 version 1.1a

Changes since v7:
- move role start special handling in ci_hdrc_otg_fsm_start()
  this can make start host/gadget clean.
- move ci_hdrc_otg_fsm_init() into ci_hdrc_otg_init()
- Remain ci_role_start() in ci_hdrc_probe because host role start
  need be done before request_irq.
- Revert the otg-host set change since fsm init will be fixed before
  role start.
- Remove fsm-protocol init in ci_hdrc_otg_fsm_init().

Changes since v6:
- Move ci_hdrc_otg_fsm_start() into ci_hdrc_otg_fsm_init()
- Call ci_hdrc_otg_fsm_init() in ci_hdrc_probe()
- Add fsm-protocol init in ci_hdrc_otg_fsm_init()
- Remove role check in start/stop host/gadget.
- Add ci_otg_is_fsm_mode() check when start fsm in ci_udc_start().
- Add struct usb_otg *otg in ci_hdrc_otg_fsm_init() for easy read when
  do init, set otg-host if host role start before otg fsm init(power up
  with ID is 0).
- set otg-host in host_start() if otg fsm init happens before host start
  (power up with ID is 1) in host.c
- Add comments of ci_hdrc structure for added fileds(fsm and fsm_timer)
  in ci.h

Changes since v5:
- Move ci_otg_is_fsm_mode() check into caller functions.
- Update comments alignment in otg_fsm.h
- Revert the ci_hdrc_otg_fsm_start() change to be v4
- Revert the role check removal of start host/gadget to be v4 since
  ci_start_role may be called out of otg fsm.
- Set controller to be device mode after stop host, to be able to
  generate data pulse correctly.
- Update some fsm variables to align with otg state.
- Update test documents for A device start new seesion in step 6):
  need set a_bus_drop to be 0 and set a_bus_req to be 1.
- Typo fix.

Changes since v4:
- Fix compile warnings if USB_OTG_FSM is not enabled.
- Add ci_otg_is_fsm_mode() to replace ci-is_otg for checking if ci is in
  OTG FSM mode.
- Move ci_hdrc_otg_fsm_start() at end of ci_hdrc_otg_fsm_init().
- Fix patch splict problem(a later patch changes a previous one).
- Remove unnecessary role check in start host/gadget.
- Add {} in start_host.c to fix Coding style problem and declar a variable
  equal to ci-transceiver-otg firstly when init otg port number.
- Update some driver comments of chipidea drivers if this patchset applied.

Changes since v3:
- Move out 2 patches from this patchset, as which are not directly related to
  otg fsm.
- Add a new file chipidea.txt under Documentation/usb/ to show how to test
  OTG HNP and SRP.
- Directly embed struct otg_fsm into ci_hdrc instead of pointer of otg_fsm.
- Remove flag check in ci_otg_del_timer().
- Remove ADP related code and comments since ADP is not supported by chip.
- Start OTG fsm before request_irq.
- For B-device, do not do OTG fsm transitions when gadget driver
  is not registered, and start OTG fsm in register gadget driver.
- Directly call ci_otg_fsm_work() in ci_hdrc_otg_fsm_start().
- Enable data pulse when a_wait_vfall timer time out.
- Update a_wait_vrise time out function.
- UPdate comments of OTG time macro definitions in otg_fsm.h according to
  OTG and EH 2.0.
- Some typo and comments format changes.

Changes since v2:
- Add ABI document for sysfs input files description:
  Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
- Add a debug file for show some USB registers value.
- Split host driver change to be 2 patches, one for otg_port number init;
  the other one for vbus control change.
- Export interrupt enable and status read functions from udc driver.
- Only enable AVV irq in otg fsm init.
- Remove duplicated USBSTS bits definitions.
- Add HowTo demo role switch with 2 Freescale i.MX6Q sabre SD boards
  in cover letter.
- typo correction.

Changes since v1:
- Move out HNP polling patch from this series, which will be a seperated 
patchset
  followed this one
- Change fsm timers global variables to be a structure embeded in ci_hdrc,
  to make multiple OTG instances can exist in one system
- Change some otg fsm functions to be static
- Re-split timer init patch to avoid a later patch changing a previous one
  in the same series
- Change timer structure memory allocation to be devm_kzalloc
- Update some format alignment and spelling errors

Li Jun (11):
  usb: chipidea: usb OTG fsm initialization.
  usb: chipidea: host: vbus control change for OTG HNP.
  usb: chipidea: host: init otg port number.
  usb: chipidea: udc: driver update for OTG HNP.
  usb: chipidea: add OTG fsm operation functions implemenation.
  usb: chipidea: OTG fsm timers initialization.
  usb: chipidea: OTG HNP and SRP fsm implementation.
  usb: chipidea: add sys inputs for OTG fsm input.
  usb: chipidea: debug: add debug file for OTG variables
  

[PATCH v8 06/11] usb: chipidea: OTG fsm timers initialization.

2014-04-09 Thread Li Jun
From: Li Jun b47...@freescale.com

This patch adds OTG fsm timers initialization, which use controller's 1ms
interrupt as timeout counter, also adds some local timers which are not
in otg_fsm_timer list.

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/bits.h|1 +
 drivers/usb/chipidea/otg_fsm.c |  189 
 drivers/usb/chipidea/otg_fsm.h |   51 +++
 3 files changed, 241 insertions(+)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 44882c8..ca57e3d 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -81,6 +81,7 @@
 /* OTGSC */
 #define OTGSC_IDPU   BIT(5)
 #define OTGSC_HADP   BIT(6)
+#define OTGSC_HABA   BIT(7)
 #define OTGSC_ID BIT(8)
 #define OTGSC_AVVBIT(9)
 #define OTGSC_ASVBIT(10)
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index d09508a..3a98b46 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -26,6 +26,22 @@
 #include otg.h
 #include otg_fsm.h
 
+static struct ci_otg_fsm_timer *otg_timer_initializer
+(struct ci_hdrc *ci, void (*function)(void *, unsigned long),
+   unsigned long expires, unsigned long data)
+{
+   struct ci_otg_fsm_timer *timer;
+
+   timer = devm_kzalloc(ci-dev, sizeof(struct ci_otg_fsm_timer),
+   GFP_KERNEL);
+   if (!timer)
+   return NULL;
+   timer-function = function;
+   timer-expires = expires;
+   timer-data = data;
+   return timer;
+}
+
 /*
  * Add timer to active timer list
  */
@@ -77,6 +93,163 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum 
ci_otg_fsm_timer_index t)
hw_write_otgsc(ci, OTGSC_1MSIE, 0);
 }
 
+/* The timeout callback function to set time out bit */
+static void set_tmout(void *ptr, unsigned long indicator)
+{
+   *(int *)indicator = 1;
+}
+
+static void set_tmout_and_fsm(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+}
+
+static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+   /* Disable port power */
+   hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP, 0);
+   /* Clear exsiting DP irq */
+   hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
+   /* Enable data pulse irq */
+   hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE);
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+}
+
+static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+   if (!hw_read_otgsc(ci, OTGSC_BSV))
+   ci-fsm.b_sess_vld = 0;
+
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+}
+
+static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+
+   /* only vbus fall below B_sess_vld in b_idle state */
+   if (ci-transceiver-state == OTG_STATE_B_IDLE) {
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+   }
+}
+
+static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   /* Check if A detached */
+   if (!(hw_read_otgsc(ci, OTGSC_BSV))) {
+   ci-fsm.b_sess_vld = 0;
+   ci_otg_add_timer(ci, B_SSEND_SRP);
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+   }
+}
+
+static void b_data_pulse_end(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   ci-fsm.b_srp_done = 1;
+   ci-fsm.b_bus_req = 0;
+   if (ci-fsm.power_up)
+   ci-fsm.power_up = 0;
+
+   hw_write_otgsc(ci, OTGSC_HABA, 0);
+
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+}
+
+/* Initialize timers */
+static int ci_otg_init_timers(struct ci_hdrc *ci)
+{
+   struct otg_fsm *fsm = ci-fsm;
+
+   /* FSM used timers */
+   ci-fsm_timer-timer_list[A_WAIT_VRISE] =
+   otg_timer_initializer(ci, set_tmout_and_fsm, TA_WAIT_VRISE,
+   (unsigned long)fsm-a_wait_vrise_tmout);
+   if (ci-fsm_timer-timer_list[A_WAIT_VRISE] == NULL)
+   return -ENOMEM;
+
+   ci-fsm_timer-timer_list[A_WAIT_VFALL] =
+   otg_timer_initializer(ci, a_wait_vfall_tmout_func,
+   TA_WAIT_VFALL, (unsigned long)fsm-a_wait_vfall_tmout);
+   if (ci-fsm_timer-timer_list[A_WAIT_VFALL] == NULL)
+   return -ENOMEM;
+
+   

[PATCH v8 11/11] Documentation: usb: add chipidea.txt for how to demo usb OTG HNP and SRP

2014-04-09 Thread Li Jun
From: Li Jun b47...@freescale.com

This patch adds a file chipidea.txt for how to demo chipidea usb OTG HNP and SRP
functions via sysfs input files, any other possible information should be
documented for chipidea usb driver in future can be added into this file.

Signed-off-by: Li Jun b47...@freescale.com
---
 Documentation/usb/chipidea.txt |   71 
 1 file changed, 71 insertions(+)

diff --git a/Documentation/usb/chipidea.txt b/Documentation/usb/chipidea.txt
new file mode 100644
index 000..4c0e2ea
--- /dev/null
+++ b/Documentation/usb/chipidea.txt
@@ -0,0 +1,71 @@
+1. How to test OTG FSM(HNP and SRP)
+---
+To show how to demo OTG HNP and SRP functions via sys input files
+with 2 Freescale i.MX6Q sabre SD boards.
+
+1.1 How to enable OTG FSM in menuconfig
+---
+Select CONFIG_USB_OTG_FSM.
+If you want to check some internal variables for otg fsm,
+select CONFIG_USB_CHIPIDEA_DEBUG, there are 2 files which
+can show otg fsm variables and some controller registers value:
+cat /sys/kernel/debug/ci_hdrc.0/otg
+cat /sys/kernel/debug/ci_hdrc.0/registers
+
+1.2 Test operations
+---
+1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
+   (e.g. g_mass_storage).
+
+2) Connect 2 boards with usb cable with one end is micro A plug, the other end
+   is micro B plug.
+
+   The A-device(with micro A plug inserted) should enumrate B-device.
+
+3) Role switch
+   On B-device:
+   echo 1  /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+   if HNP polling is not supported, also need:
+   On A-device:
+   echo 0  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
+
+   B-device should take host role and enumrate A-device.
+
+4) A-device switch back to host.
+   On B-device:
+   echo 0  /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+   A-device should switch back to host and enumrate B-device.
+
+5) Remove B-device(unplug micro B plug) and insert again in 10 seconds,
+   A-device should enumrate B-device again.
+
+6) Remove B-device(unplug micro B plug) and insert again after 10 seconds,
+   A-device should NOT enumrate B-device.
+
+   if A-device wants to use bus:
+   On A-device:
+   echo 0  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
+   echo 1  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
+
+   if B-device wants to use bus:
+   On B-device:
+   echo 1  /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+7) A-device power down the bus.
+   On A-device:
+   echo 1  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
+
+   A-device should disconnect with B-device and power down the bus.
+
+8) B-device does data pulse for SRP.
+   On B-device:
+   echo 1  /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+   A-device should resume usb bus and enumrate B-device.
+
+1.3 Reference document
+--
+On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
+July 27, 2012 Revision 2.0 version 1.1a
-- 
1.7.9.5


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


[PATCH v8 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.

2014-04-09 Thread Li Jun
From: Li Jun b47...@freescale.com

USB OTG interrupt handling and fsm transitions according to USB OTG
and EH 2.0.

Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/core.c|   13 ++-
 drivers/usb/chipidea/otg.c |9 +-
 drivers/usb/chipidea/otg_fsm.c |  237 
 drivers/usb/chipidea/otg_fsm.h |   18 +++
 drivers/usb/chipidea/udc.c |6 +
 5 files changed, 279 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ff38cf3..7e8f223 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -42,7 +42,6 @@
  * - Not Supported: 15  16 (ISO)
  *
  * TODO List
- * - OTG
  * - Interrupt Traffic
  * - GET_STATUS(device) - always reports 0
  * - Gadget API (majority of optional features)
@@ -74,6 +73,7 @@
 #include host.h
 #include debug.h
 #include otg.h
+#include otg_fsm.h
 
 /* Controller register map */
 static const u8 ci_regs_nolpm[] = {
@@ -412,8 +412,14 @@ static irqreturn_t ci_irq(int irq, void *data)
irqreturn_t ret = IRQ_NONE;
u32 otgsc = 0;
 
-   if (ci-is_otg)
+   if (ci-is_otg) {
otgsc = hw_read_otgsc(ci, ~0);
+   if (ci_otg_is_fsm_mode(ci)) {
+   ret = ci_otg_fsm_irq(ci);
+   if (ret == IRQ_HANDLED)
+   return ret;
+   }
+   }
 
/*
 * Handle id change interrupt, it indicates device/host function
@@ -703,6 +709,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (ret)
goto stop;
 
+   if (ci_otg_is_fsm_mode(ci))
+   ci_hdrc_otg_fsm_start(ci);
+
ret = dbg_create_files(ci);
if (!ret)
return 0;
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index d76db51..38e340c 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -11,8 +11,8 @@
  */
 
 /*
- * This file mainly handles otgsc register, it may include OTG operation
- * in the future.
+ * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP
+ * are also included.
  */
 
 #include linux/usb/otg.h
@@ -91,6 +91,11 @@ static void ci_otg_work(struct work_struct *work)
 {
struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
 
+   if (ci_otg_is_fsm_mode(ci)  !ci_otg_fsm_work(ci)) {
+   enable_irq(ci-irq);
+   return;
+   }
+
if (ci-id_event) {
ci-id_event = false;
ci_handle_id_switch(ci);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 3a98b46..796e92e 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -13,6 +13,10 @@
 /*
  * This file mainly handles OTG fsm, it includes OTG fsm operations
  * for HNP and SRP.
+ *
+ * TODO List
+ * - ADP
+ * - OTG test device
  */
 
 #include linux/usb/otg.h
@@ -93,6 +97,33 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum 
ci_otg_fsm_timer_index t)
hw_write_otgsc(ci, OTGSC_1MSIE, 0);
 }
 
+/*
+ * Reduce timer count by 1, and find timeout conditions.
+ * Called by otg 1ms timer interrupt
+ */
+static inline int ci_otg_tick_timer(struct ci_hdrc *ci)
+{
+   struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
+   struct list_head *active_timers = ci-fsm_timer-active_timers;
+   int expired = 0;
+
+   list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) {
+   tmp_timer-count--;
+   /* check if timer expires */
+   if (!tmp_timer-count) {
+   list_del(tmp_timer-list);
+   tmp_timer-function(ci, tmp_timer-data);
+   expired = 1;
+   }
+   }
+
+   /* disable 1ms irq if there is no any timer active */
+   if ((expired == 1)  list_empty(active_timers))
+   hw_write_otgsc(ci, OTGSC_1MSIE, 0);
+
+   return expired;
+}
+
 /* The timeout callback function to set time out bit */
 static void set_tmout(void *ptr, unsigned long indicator)
 {
@@ -393,6 +424,212 @@ static struct otg_fsm_ops ci_otg_ops = {
.start_gadget = ci_otg_start_gadget,
 };
 
+int ci_otg_fsm_work(struct ci_hdrc *ci)
+{
+   /*
+* Don't do fsm transition for B device
+* when there is no gadget class driver
+*/
+   if (ci-fsm.id  !(ci-driver) 
+   ci-transceiver-state  OTG_STATE_A_IDLE)
+   return 0;
+
+   if (otg_statemachine(ci-fsm)) {
+   if (ci-transceiver-state == OTG_STATE_A_IDLE) {
+   if (ci-fsm.id)
+   /* A idle to B idle */
+   otg_statemachine(ci-fsm);
+   else if ((ci-id_event) || (ci-fsm.power_up)) {
+   ci-id_event = false;
+   /* A idle to A wait vrise */
+  

[PATCH v8 04/11] usb: chipidea: udc: driver update for OTG HNP.

2014-04-09 Thread Li Jun
Add b_hnp_enable request handling and enable gadget-is_otg

Acked-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Li Jun b47...@freescale.com
---
 drivers/usb/chipidea/udc.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index f58857d..cba7fd6 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -20,6 +20,7 @@
 #include linux/pm_runtime.h
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
+#include linux/usb/otg-fsm.h
 #include linux/usb/chipidea.h
 
 #include ci.h
@@ -1052,6 +1053,14 @@ __acquires(ci-lock)
default:
break;
}
+   break;
+   case USB_DEVICE_B_HNP_ENABLE:
+   if (ci_otg_is_fsm_mode(ci)) {
+   ci-gadget.b_hnp_enable = 1;
+   err = isr_setup_status_phase(
+   ci);
+   }
+   break;
default:
goto delegate;
}
@@ -1759,7 +1768,7 @@ static int udc_start(struct ci_hdrc *ci)
ci-gadget.ops  = usb_gadget_ops;
ci-gadget.speed= USB_SPEED_UNKNOWN;
ci-gadget.max_speed= USB_SPEED_HIGH;
-   ci-gadget.is_otg   = 0;
+   ci-gadget.is_otg   = ci-is_otg ? 1 : 0;
ci-gadget.name = ci-platdata-name;
 
INIT_LIST_HEAD(ci-gadget.ep_list);
-- 
1.7.9.5


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


[PATCH 2/2] usb: hcd: add generic PHY support

2014-04-09 Thread Sergei Shtylyov
Add the generic PHY support, analogous to the USB PHY support. Intended it to be
used with the PCI EHCI/OHCI drivers and the xHCI platform driver.

Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

 drivers/usb/core/hcd.c  |   42 --
 include/linux/usb/hcd.h |1 +
 2 files changed, 41 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/core/hcd.c
===
--- usb.orig/drivers/usb/core/hcd.c
+++ usb/drivers/usb/core/hcd.c
@@ -42,6 +42,7 @@
 #include linux/pm_runtime.h
 #include linux/types.h
 
+#include linux/phy/phy.h
 #include linux/usb.h
 #include linux/usb/hcd.h
 #include linux/usb/phy.h
@@ -2623,6 +2624,29 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}
 
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
+   struct phy *phy = phy_get(hcd-self.controller, usb);
+
+   if (IS_ERR(phy)) {
+   retval = PTR_ERR(phy);
+   if (retval == -EPROBE_DEFER)
+   goto err_phy;
+   } else {
+   retval = phy_init(phy);
+   if (retval) {
+   phy_put(phy);
+   goto err_phy;
+   }
+   retval = phy_power_on(phy);
+   if (retval) {
+   phy_exit(phy);
+   phy_put(phy);
+   goto err_phy;
+   }
+   hcd-phy = phy;
+   }
+   }
+
dev_info(hcd-self.controller, %s\n, hcd-product_desc);
 
/* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2638,7 +2662,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
 */
if ((retval = hcd_buffer_create(hcd)) != 0) {
dev_dbg(hcd-self.controller, pool alloc failed\n);
-   goto err_remove_phy;
+   goto err_create_buf;
}
 
if ((retval = usb_register_bus(hcd-self))  0)
@@ -2763,7 +2787,14 @@ err_allocate_root_hub:
usb_deregister_bus(hcd-self);
 err_register_bus:
hcd_buffer_destroy(hcd);
-err_remove_phy:
+err_create_buf:
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-phy) {
+   phy_power_off(hcd-phy);
+   phy_exit(hcd-phy);
+   phy_put(hcd-phy);
+   hcd-phy = NULL;
+   }
+err_phy:
if (hcd-remove_phy  hcd-transceiver) {
usb_phy_shutdown(hcd-transceiver);
usb_put_phy(hcd-transceiver);
@@ -2841,6 +2872,13 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_put_dev(hcd-self.root_hub);
usb_deregister_bus(hcd-self);
hcd_buffer_destroy(hcd);
+
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-phy) {
+   phy_power_off(hcd-phy);
+   phy_exit(hcd-phy);
+   phy_put(hcd-phy);
+   hcd-phy = NULL;
+   }
if (hcd-remove_phy  hcd-transceiver) {
usb_phy_shutdown(hcd-transceiver);
usb_put_phy(hcd-transceiver);
Index: usb/include/linux/usb/hcd.h
===
--- usb.orig/include/linux/usb/hcd.h
+++ usb/include/linux/usb/hcd.h
@@ -107,6 +107,7 @@ struct usb_hcd {
 * other external PHYs should be software-transparent
 */
struct usb_phy  *transceiver;
+   struct phy  *phy;
 
/* Flags that need to be manipulated atomically because they can
 * change while the host controller is running.  Always use
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Sergei Shtylyov
Return to the 'phy' field of 'struct usb_hcd' its historic name 'transceiver'. 
This is in preparation to adding the generic PHY support.

Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

 drivers/usb/chipidea/host.c   |2 +-
 drivers/usb/core/hcd.c|   20 ++--
 drivers/usb/core/hub.c|9 +
 drivers/usb/host/ehci-fsl.c   |   16 
 drivers/usb/host/ehci-hub.c   |2 +-
 drivers/usb/host/ehci-msm.c   |4 ++--
 drivers/usb/host/ehci-tegra.c |   16 
 drivers/usb/host/ohci-omap.c  |   20 ++--
 include/linux/usb/hcd.h   |6 +++---
 9 files changed, 48 insertions(+), 47 deletions(-)

Index: usb/drivers/usb/chipidea/host.c
===
--- usb.orig/drivers/usb/chipidea/host.c
+++ usb/drivers/usb/chipidea/host.c
@@ -59,7 +59,7 @@ static int host_start(struct ci_hdrc *ci
hcd-has_tt = 1;
 
hcd-power_budget = ci-platdata-power_budget;
-   hcd-phy = ci-transceiver;
+   hcd-transceiver = ci-transceiver;
 
ehci = hcd_to_ehci(hcd);
ehci-caps = ci-hw_bank.cap;
Index: usb/drivers/usb/core/hcd.c
===
--- usb.orig/drivers/usb/core/hcd.c
+++ usb/drivers/usb/core/hcd.c
@@ -2605,7 +2605,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
int retval;
struct usb_device *rhdev;
 
-   if (IS_ENABLED(CONFIG_USB_PHY)  !hcd-phy) {
+   if (IS_ENABLED(CONFIG_USB_PHY)  !hcd-transceiver) {
struct usb_phy *phy = usb_get_phy_dev(hcd-self.controller, 0);
 
if (IS_ERR(phy)) {
@@ -2618,7 +2618,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
usb_put_phy(phy);
return retval;
}
-   hcd-phy = phy;
+   hcd-transceiver = phy;
hcd-remove_phy = 1;
}
}
@@ -2764,10 +2764,10 @@ err_allocate_root_hub:
 err_register_bus:
hcd_buffer_destroy(hcd);
 err_remove_phy:
-   if (hcd-remove_phy  hcd-phy) {
-   usb_phy_shutdown(hcd-phy);
-   usb_put_phy(hcd-phy);
-   hcd-phy = NULL;
+   if (hcd-remove_phy  hcd-transceiver) {
+   usb_phy_shutdown(hcd-transceiver);
+   usb_put_phy(hcd-transceiver);
+   hcd-transceiver = NULL;
}
return retval;
 }
@@ -2841,10 +2841,10 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_put_dev(hcd-self.root_hub);
usb_deregister_bus(hcd-self);
hcd_buffer_destroy(hcd);
-   if (hcd-remove_phy  hcd-phy) {
-   usb_phy_shutdown(hcd-phy);
-   usb_put_phy(hcd-phy);
-   hcd-phy = NULL;
+   if (hcd-remove_phy  hcd-transceiver) {
+   usb_phy_shutdown(hcd-transceiver);
+   usb_put_phy(hcd-transceiver);
+   hcd-transceiver = NULL;
}
 }
 EXPORT_SYMBOL_GPL(usb_remove_hcd);
Index: usb/drivers/usb/core/hub.c
===
--- usb.orig/drivers/usb/core/hub.c
+++ usb/drivers/usb/core/hub.c
@@ -4250,8 +4250,8 @@ hub_port_init (struct usb_hub *hub, stru
if (retval)
goto fail;
 
-   if (hcd-phy  !hdev-parent)
-   usb_phy_notify_connect(hcd-phy, udev-speed);
+   if (hcd-transceiver  !hdev-parent)
+   usb_phy_notify_connect(hcd-transceiver, udev-speed);
 
/*
 * Some superspeed devices have finished the link training process
@@ -4459,9 +4459,10 @@ static void hub_port_connect_change(stru
 
/* Disconnect any existing devices under this port */
if (udev) {
-   if (hcd-phy  !hdev-parent 
+   if (hcd-transceiver  !hdev-parent 
!(portstatus  USB_PORT_STAT_CONNECTION))
-   usb_phy_notify_disconnect(hcd-phy, udev-speed);
+   usb_phy_notify_disconnect(hcd-transceiver,
+ udev-speed);
usb_disconnect(hub-ports[port1 - 1]-child);
}
clear_bit(port1, hub-change_bits);
Index: usb/drivers/usb/host/ehci-fsl.c
===
--- usb.orig/drivers/usb/host/ehci-fsl.c
+++ usb/drivers/usb/host/ehci-fsl.c
@@ -136,15 +136,15 @@ static int usb_hcd_fsl_probe(const struc
if (pdata-operating_mode == FSL_USB2_DR_OTG) {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
 
-   hcd-phy = usb_get_phy(USB_PHY_TYPE_USB2);
+   hcd-transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
dev_dbg(pdev-dev, hcd=0x%p  ehci=0x%p, phy=0x%p\n,
-   hcd, ehci, hcd-phy);
+   hcd, ehci, 

Re: [PATCH] cdc-acm: some enhancement on acm delayed write

2014-04-09 Thread Xiao Jin
Thanks all for the review. We meet with the problems when developing 
product. I would like to explain my understanding.


On 04/08/2014 11:05 AM, Xiao Jin wrote:


We find two problems on acm tty write delayed mechanism.
(1) When acm resume, the delayed wb will be started. But now
only one write can be saved during acm suspend. More acm write
may be abandoned.


The scenario usually happened when user space write series AT after acm 
suspend. If acm accept the first AT, what's the reason for acm to refuse 
the second AT? If write return 0, user space will try repeatedly until 
resume. It looks simpler that acm accept all the data and sent out urb 
when resume.



(2) acm tty port ASYNCB_INITIALIZED flag will be cleared when
close. If acm resume callback run after ASYNCB_INITIALIZED flag
cleared, there will have no chance for delayed write to start.
That lead to acm_wb.use can't be cleared. If user space open
acm tty again and try to setd, tty will be blocked in
tty_wait_until_sent for ever.



We see tty write and close concurrently after acm suspend in this case. 
It looks no method to avoid it from tty layer. acm_tty_write and 
acm_resume call after acm_port_shutdown. It looks any action in 
acm_port_shutdown can't solve the problem. As acm has accepted the user 
space data, we can only find a way to send out urb. I feel anyway to 
discard the data looks like a lie to user space.


In my understanding acm should accept data as much as possible, and send 
out urb as soon as possible. What do you think of?


Br, Jin
--
To unsubscribe from this list: send the line unsubscribe 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: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Stephen Warren
On 04/09/2014 07:57 AM, Sergei Shtylyov wrote:
 Return to the 'phy' field of 'struct usb_hcd' its historic name 
 'transceiver'. 
 This is in preparation to adding the generic PHY support.

Surely if the correct term is transceiver, we should be adding generic
transceiver support not generic PHY support? To be honest, this rename
feels like churn, especially since the APIs and DT bindings all still
include the work phy so now everything will be inconsistent.
--
To unsubscribe from this list: send the line unsubscribe 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: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Sergei Shtylyov

Hello.

On 04/09/2014 07:31 PM, Stephen Warren wrote:


Return to the 'phy' field of 'struct usb_hcd' its historic name 'transceiver'.
This is in preparation to adding the generic PHY support.



Surely if the correct term is transceiver, we should be adding generic
transceiver support not generic PHY support? To be honest, this rename
feels like churn, especially since the APIs and DT bindings all still
include the work phy so now everything will be inconsistent.


   How about 'usb_phy'?

WBR, Sergei

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


Re: [PATCH 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Stephen Warren
On 04/09/2014 10:27 AM, Sergei Shtylyov wrote:
 Hello.
 
 On 04/09/2014 07:31 PM, Stephen Warren wrote:
 
 Return to the 'phy' field of 'struct usb_hcd' its historic name
 'transceiver'.
 This is in preparation to adding the generic PHY support.
 
 Surely if the correct term is transceiver, we should be adding generic
 transceiver support not generic PHY support? To be honest, this rename
 feels like churn, especially since the APIs and DT bindings all still
 include the work phy so now everything will be inconsistent.
 
How about 'usb_phy'?

That certainly would make things more consistent, but I wonder why
usb_phy is better than phy when the code/struct in question is
something USB-specific; the usb_ prefix seems implicit to me due to
context.
--
To unsubscribe from this list: send the line unsubscribe 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: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Sergei Shtylyov

On 04/09/2014 08:48 PM, Stephen Warren wrote:


Return to the 'phy' field of 'struct usb_hcd' its historic name
'transceiver'.
This is in preparation to adding the generic PHY support.



Surely if the correct term is transceiver, we should be adding generic
transceiver support not generic PHY support? To be honest, this rename
feels like churn, especially since the APIs and DT bindings all still
include the work phy so now everything will be inconsistent.



How about 'usb_phy'?



That certainly would make things more consistent, but I wonder why
usb_phy is better than phy when the code/struct in question is
something USB-specific; the usb_ prefix seems implicit to me due to
context.


   I tend to agree. However, I need to name the new field of stype 'struct 
phy *' somehow... perhaps something like 'gen_phy' for it would do?


WBR, Sergei

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


Re: [PATCH 1/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Stephen Warren
On 04/09/2014 10:53 AM, Sergei Shtylyov wrote:
 On 04/09/2014 08:48 PM, Stephen Warren wrote:
 
 Return to the 'phy' field of 'struct usb_hcd' its historic name
 'transceiver'.
 This is in preparation to adding the generic PHY support.
 
 Surely if the correct term is transceiver, we should be adding generic
 transceiver support not generic PHY support? To be honest, this rename
 feels like churn, especially since the APIs and DT bindings all still
 include the work phy so now everything will be inconsistent.
 
 How about 'usb_phy'?
 
 That certainly would make things more consistent, but I wonder why
 usb_phy is better than phy when the code/struct in question is
 something USB-specific; the usb_ prefix seems implicit to me due to
 context.
 
I tend to agree. However, I need to name the new field of stype
 'struct phy *' somehow... perhaps something like 'gen_phy' for it would do?

Ok, the existing field is being replaced by something? I didn't get that
from the patch description; I thought the new name in this patch was
going to be it. In that case, a temporary name of usb_phy for the
existing field, or adding the new field as gen_phy sound reasonable.

--
To unsubscribe from this list: send the line unsubscribe 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 0/3] Fix USB deadlock caused by SCSI error handling

2014-04-09 Thread Hannes Reinecke

On 04/07/2014 05:26 PM, Alan Stern wrote:

On Wed, 2 Apr 2014, Hannes Reinecke wrote:


On 04/01/2014 11:28 PM, Alan Stern wrote:

On Tue, 1 Apr 2014, Hannes Reinecke wrote:


So if the above reasoning is okay then this patch should be doing
the trick:

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 771c16b..0e72374 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -189,6 +189,7 @@ scsi_abort_command(struct scsi_cmnd *scmd)
 /*
  * Retry after abort failed, escalate to next level.
  */
+   scmd-eh_eflags = ~SCSI_EH_ABORT_SCHEDULED;
 SCSI_LOG_ERROR_RECOVERY(3,
 scmd_printk(KERN_INFO, scmd,
 scmd %p previous abort
failed\n, scmd));

(Beware of line
breaks)

Can you test with it?


I don't understand.  This doesn't solve the fundamental problem (namely
that you escalate before aborting a running command).  All it does is
clear the SCSI_EH_ABORT_SCHEDULED flag before escalating.


Which was precisely the point :-)

Hmm. The comment might've been clearer.

What this patch is _supposed_ to be doing is that it'll clear the
SCSI_EH_ABORT_SCHEDULED flag it it has been set.
Which means this will be the second time scsi_abort_command() has
been called for the same command.
IE the first abort went out, did its thing, but now the same command
has timed out again.

So this flag gets cleared, and scsi_abort_command() returns FAILED,
and _no_ asynchronous abort is being scheduled.
scsi_times_out() will then proceed to call scsi_eh_scmd_add().
But as we've cleared the SCSI_EH_ABORT_SCHEDULED flag
the SCSI_EH_CANCEL_CMD flag will continue to be set,
and the command will be aborted with the main SCSI EH routine.

It looks to me as if it should do what you desire, namely abort the
command asynchronously the first time, and invoking the SCSI EH the
second time.

Am I wrong?


I don't know -- I'll have to try it out.  Currently I'm busy with a
bunch of other stuff, so it will take some time.


I finally got a chance to try it out.  It does seem to do what we want.
I didn't track the flow of control in complete detail, but the command
definitely got aborted both times it was issued.

Good, so it is as I thought. James, can we include this patch instead of 
your prior solution?


Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: About the DRD mode implementation of DWC3 driver

2014-04-09 Thread David Cohen
On Wed, Apr 09, 2014 at 02:08:32PM +0800, Wang, Yu wrote:
 Hi Balbi,
 
 Glad to see the OTG mode is prepare to support in your dwc3-role-switch
 branch. But it is not fit for intel Merrfield/Moorfield platforms. :(
 
 The reason is we implemented DRD mode instead of OTG mode. So the
 GCTL.PortCapDir will be set as 01 for host mode, and 10 for device mode.
 
 And the most important thing is we implemented two low power states for
 dwc3 controller. D0i3hot and D0i3cold.
 
 If no cable connected, we will trigger D0i3cold which will power gate
 every clock/power used by dwc3 controller.
 
 And entering D0i3hot with hibernation mode when acting as host mode
 (micro A cable connected), also during device mode(micro B cable connected
 to PC host).
 
 For ID/VBus detection, we are using PMIC to do detect. So we will also
 power gate the USB PHY for D0i3cold.
 
 When we plug in micro A/B cable, the PMIC will report the ID/VBus change
 event, then driver will force controller resume to D0 from D0i3cold. Due
 to we haven't do any backup before entering D0i3cold, so we have to
 re-initialize all host/device portion registers with setting
 GCTL.PortCapDir to 01 or 10.
 
 So with this PM design and DRD mode, we can't use your OTG mode. :(
 I want to get your suggestions for DRD mode of dwc3 driver.

Why do you insist in tell role switching and PM are part of same thing?
It's my understanding we need to implement proper pm runtime callbacks
for D0i3* and leave role switching alone.
We can make proper calls of pm runtime from phy driver to control PM
state of dwc3 (for D0i3cold).

Br, David

 
 We add DRD support based on your otg.c or create new file drd.c?
 
 Thanks
 Yu
--
To unsubscribe from this list: send the line unsubscribe 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: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Sergei Shtylyov

On 04/09/2014 09:37 PM, Stephen Warren wrote:


Return to the 'phy' field of 'struct usb_hcd' its historic name
'transceiver'.
This is in preparation to adding the generic PHY support.



Surely if the correct term is transceiver, we should be adding generic
transceiver support not generic PHY support? To be honest, this rename
feels like churn, especially since the APIs and DT bindings all still
include the work phy so now everything will be inconsistent.



 How about 'usb_phy'?



That certainly would make things more consistent, but I wonder why
usb_phy is better than phy when the code/struct in question is
something USB-specific; the usb_ prefix seems implicit to me due to
context.



I tend to agree. However, I need to name the new field of stype
'struct phy *' somehow... perhaps something like 'gen_phy' for it would do?



Ok, the existing field is being replaced by something? I didn't get that


   No, not replaced. I'm adding the support for generic PHY to the existing 
USB PHY support. I thought that was clear from the changelog.



from the patch description; I thought the new name in this patch was
going to be it. In that case, a temporary name of usb_phy for the
existing field, or adding the new field as gen_phy sound reasonable.


   OK, I'll respin the patch #2 with 'gen_phy' and remove the patch #1.

WBR, Sergei

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


Re: Fwd: Isochronos audio

2014-04-09 Thread Alan Stern
On Wed, 9 Apr 2014, Clemens Ladisch wrote:

 Alan Stern wrote:
  The IN transfer was 1 frame long and scheduled for frame 1123, so its
  completion indicates that the current frame number is = 1123.  The OUT
  transfer was 6 frames long and scheduled for frame , so it should
  have completed in frame 1117.  But the timestamps show that the two
  URBs completed at the same time (only 13 us between them).
 
 Looks like interrupt moderation.

I don't think so; to me it looks more like a bug.  We're already
getting one interrupt per ms for the IN endpoint anyway; there's no
reason to moderate the one-every-6-ms interrupts for the OUT endpoint.  
Also, with moderation you'd see several URBs apparently completing at
once, but that's not what happened here.

In fact, I get the impression that with isochronous URBs A, B, C,...
in the queue, xhci-hcd doesn't report the completion of A to the driver
until B has terminated, and it reports the completion of B when C has
terminated, etc.  That's got to be a programming error somewhere.

 What minimum queue length should a driver use to work with all HCs?

What snd-usb-audio is doing right now should be fine.  While I'm not 
acquainted with the detailed operation of xhci-hcd, its requirements 
should not be any more strict than those of ehci-hcd.  And this was a 
full-speed USB device -- not even high speed, let alone SuperSpeed!

Furthermore, I clearly recall Sarah Sharp (the original maintainer for 
xhci-hcd) saying that the support for isochronous transfers needed 
attention.  This may well be an example.

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] cdc-acm: some enhancement on acm delayed write

2014-04-09 Thread David Cohen
On Wed, Apr 09, 2014 at 10:57:10PM +0800, Xiao Jin wrote:
 Thanks all for the review. We meet with the problems when developing
 product. I would like to explain my understanding.
 
 On 04/08/2014 11:05 AM, Xiao Jin wrote:
 
 We find two problems on acm tty write delayed mechanism.
 (1) When acm resume, the delayed wb will be started. But now
 only one write can be saved during acm suspend. More acm write
 may be abandoned.
 
 The scenario usually happened when user space write series AT after acm
 suspend. If acm accept the first AT, what's the reason for acm to refuse the
 second AT? If write return 0, user space will try repeatedly until resume.
 It looks simpler that acm accept all the data and sent out urb when resume.

That was my understanding too. The delayed mechanism is not being
implemented by this patch, just improved.

Br, David

 
 (2) acm tty port ASYNCB_INITIALIZED flag will be cleared when
 close. If acm resume callback run after ASYNCB_INITIALIZED flag
 cleared, there will have no chance for delayed write to start.
 That lead to acm_wb.use can't be cleared. If user space open
 acm tty again and try to setd, tty will be blocked in
 tty_wait_until_sent for ever.
 
 
 We see tty write and close concurrently after acm suspend in this case. It
 looks no method to avoid it from tty layer. acm_tty_write and acm_resume
 call after acm_port_shutdown. It looks any action in acm_port_shutdown can't
 solve the problem. As acm has accepted the user space data, we can only find
 a way to send out urb. I feel anyway to discard the data looks like a lie to
 user space.
 
 In my understanding acm should accept data as much as possible, and send out
 urb as soon as possible. What do you think of?
 
 Br, Jin
--
To unsubscribe from this list: send the line unsubscribe 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: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Alan Stern
On Wed, 9 Apr 2014, Sergei Shtylyov wrote:

  Ok, the existing field is being replaced by something? I didn't get that
 
 No, not replaced. I'm adding the support for generic PHY to the existing 
 USB PHY support. I thought that was clear from the changelog.
 
  from the patch description; I thought the new name in this patch was
  going to be it. In that case, a temporary name of usb_phy for the
  existing field, or adding the new field as gen_phy sound reasonable.
 
 OK, I'll respin the patch #2 with 'gen_phy' and remove the patch #1.

What is the reason for all of this?  That is, can you explain the
difference between USB PHY support and general PHY support, and why we
need both?

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 0/3] Fix USB deadlock caused by SCSI error handling

2014-04-09 Thread Alan Stern
On Wed, 9 Apr 2014, Hannes Reinecke wrote:

  I finally got a chance to try it out.  It does seem to do what we want.
  I didn't track the flow of control in complete detail, but the command
  definitely got aborted both times it was issued.
 
 Good, so it is as I thought. James, can we include this patch instead of 
 your prior solution?

First, we should have the original bug reporter try it out.

Andreas, the patch in question can be found here:

http://marc.info/?l=linux-usbm=13962706597w=2

Can you try this in place of the 1/3 patch posted by James?  It should 
have the same effect, of preventing your system from crashing when the 
READ command fails.

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/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Sergei Shtylyov

Hello.

On 04/09/2014 09:56 PM, Alan Stern wrote:


Ok, the existing field is being replaced by something? I didn't get that



 No, not replaced. I'm adding the support for generic PHY to the existing
USB PHY support. I thought that was clear from the changelog.



from the patch description; I thought the new name in this patch was
going to be it. In that case, a temporary name of usb_phy for the
existing field, or adding the new field as gen_phy sound reasonable.



 OK, I'll respin the patch #2 with 'gen_phy' and remove the patch #1.



What is the reason for all of this?  That is, can you explain the
difference between USB PHY support and general PHY support, and why we
need both?


   The generic PHY framework (drivers/phy/phy-core.c) supports multifunction 
complex PHYs (some functions of which may be related to USB). My case is a 
Renesas R-Car generation 2 PHY that can switch two USB ports between different 
USB controllers (one PCI and one non-PCI on each port); I just haven't CCed 
linux-usb on my driver submission. Though there's already drivers/phy/usb/ 
driver for that hardware, it failed to meet the expectations (dynamic setting 
of the port multiplexing depending on what USB host/gadget drivers are 
loaded), so I had to write a new driver. I guess I don't need to describe 
drivers/phy/usb/ framework in detail, do I? It only provides for 
single-function simple USB PHYs...



Alan Stern


WBR, Sergei

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


Re: [PATCH 1/2] usb: ehci-exynos: Return immediately from suspend if ehci_suspend fails

2014-04-09 Thread Alan Stern
On Wed, 9 Apr 2014, Vivek Gautam wrote:

 Patch 'b8efdaf USB: EHCI: add check for wakeup/suspend race'
 adds a check for possible race between suspend and wakeup interrupt,
 and thereby it returns -EBUSY as error code if there's a wakeup
 interrupt.
 So the platform host controller should not proceed further with
 its suspend callback, rather should return immediately to avoid
 powering down the essential things, like phy.
 
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 Cc: Alan Stern st...@rowland.harvard.edu
 Cc: Jingoo Han jg1@samsung.com
 ---
 
 Based on 'usb-next' branch of Greg's usb tree.
 
  drivers/usb/host/ehci-exynos.c |4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
 index d1d8c47..a4550eb 100644
 --- a/drivers/usb/host/ehci-exynos.c
 +++ b/drivers/usb/host/ehci-exynos.c
 @@ -212,6 +212,8 @@ static int exynos_ehci_suspend(struct device *dev)
   int rc;
  
   rc = ehci_suspend(hcd, do_wakeup);
 + if (rc)
 + return rc;
  
   if (exynos_ehci-otg)
   exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
 @@ -221,7 +223,7 @@ static int exynos_ehci_suspend(struct device *dev)
  
   clk_disable_unprepare(exynos_ehci-clk);
  
 - return rc;
 + return 0;
  }
  
  static int exynos_ehci_resume(struct device *dev)

The first hunk of this patch is correct, but the second hunk isn't 
needed.  A similar remark is true for the ehci-platform patch.

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/2] usb: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Stephen Warren
On 04/09/2014 12:16 PM, Sergei Shtylyov wrote:
 Hello.
 
 On 04/09/2014 09:56 PM, Alan Stern wrote:
 
 Ok, the existing field is being replaced by something? I didn't get
 that
 
  No, not replaced. I'm adding the support for generic PHY to the
 existing
 USB PHY support. I thought that was clear from the changelog.
 
 from the patch description; I thought the new name in this patch was
 going to be it. In that case, a temporary name of usb_phy for the
 existing field, or adding the new field as gen_phy sound reasonable.
 
  OK, I'll respin the patch #2 with 'gen_phy' and remove the patch
 #1.
 
 What is the reason for all of this?  That is, can you explain the
 difference between USB PHY support and general PHY support, and why we
 need both?
 
The generic PHY framework (drivers/phy/phy-core.c) supports
 multifunction complex PHYs (some functions of which may be related to
 USB). My case is a Renesas R-Car generation 2 PHY that can switch two
 USB ports between different USB controllers (one PCI and one non-PCI on
 each port); I just haven't CCed linux-usb on my driver submission.
 Though there's already drivers/phy/usb/ driver for that hardware, it
 failed to meet the expectations (dynamic setting of the port
 multiplexing depending on what USB host/gadget drivers are loaded), so I
 had to write a new driver. I guess I don't need to describe
 drivers/phy/usb/ framework in detail, do I? It only provides for
 single-function simple USB PHYs...

Naively, it sounds like the complex PHY driver should also be a pinctrl
driver, since it sounds like the main feature it has beyond a simple PHY
is the ability to do pin muxing.

--
To unsubscribe from this list: send the line unsubscribe 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: rename 'phy' field of 'struct usb_hcd' to 'transceiver'

2014-04-09 Thread Sergei Shtylyov

On 04/09/2014 11:01 PM, Stephen Warren wrote:


Ok, the existing field is being replaced by something? I didn't get
that



  No, not replaced. I'm adding the support for generic PHY to the
existing
USB PHY support. I thought that was clear from the changelog.



from the patch description; I thought the new name in this patch was
going to be it. In that case, a temporary name of usb_phy for the
existing field, or adding the new field as gen_phy sound reasonable.



  OK, I'll respin the patch #2 with 'gen_phy' and remove the patch
#1.



What is the reason for all of this?  That is, can you explain the
difference between USB PHY support and general PHY support, and why we
need both?



The generic PHY framework (drivers/phy/phy-core.c) supports
multifunction complex PHYs (some functions of which may be related to
USB). My case is a Renesas R-Car generation 2 PHY that can switch two
USB ports between different USB controllers (one PCI and one non-PCI on
each port); I just haven't CCed linux-usb on my driver submission.
Though there's already drivers/phy/usb/ driver for that hardware, it
failed to meet the expectations (dynamic setting of the port
multiplexing depending on what USB host/gadget drivers are loaded), so I
had to write a new driver. I guess I don't need to describe
drivers/phy/usb/ framework in detail, do I? It only provides for
single-function simple USB PHYs...



Naively, it sounds like the complex PHY driver should also be a pinctrl
driver, since it sounds like the main feature it has beyond a simple PHY
is the ability to do pin muxing.


   It doesn't do any pin muxing. It switches SoC internal USB signals between 
USB controllers. The pins remain the same.


WBR, Sergei

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


check USB33x.ko module

2014-04-09 Thread Arturo Veras
Hi all,

I loaded the usb338x.ko module for the usb3380.
How can i check that the module is working?

-- 
Atte.
Arturo
--
To unsubscribe from this list: send the line unsubscribe 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: check USB33x.ko module

2014-04-09 Thread Greg KH
On Wed, Apr 09, 2014 at 05:30:17PM -0300, Arturo Veras wrote:
 Hi all,
 
 I loaded the usb338x.ko module for the usb3380.
 How can i check that the module is working?

How do you know it's not working?  :)

Seriously, test the hardware...

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


Re: Fwd: Isochronos audio

2014-04-09 Thread Alan Stern
On Wed, 9 Apr 2014, Clemens Ladisch wrote:

 Alan Stern wrote:
  The IN transfer was 1 frame long and scheduled for frame 1123, so its
  completion indicates that the current frame number is = 1123.  The OUT
  transfer was 6 frames long and scheduled for frame , so it should
  have completed in frame 1117.  But the timestamps show that the two
  URBs completed at the same time (only 13 us between them).

By the way, the completion times aren't the only thing that look messed 
up.  The starting frame numbers are also wrong.

Here's an extract showing some of the URB completions for the OUT
endpoint:

 880036e14600 2003747539 C Zo:2:003:1 0:1:1106:0 5 0:0:264
 880036e15c00 2003753507 C Zo:2:003:1 0:1::0 6 0:0:264
 880036e14000 2003758499 C Zo:2:003:1 0:1:1116:0 5 0:0:264
 880036e14600 2003763509 C Zo:2:003:1 0:1:1121:0 5 0:0:264
 880036e15c00 2003768475 C Zo:2:003:1 0:1:1127:0 5 0:0:264
 880036e14000 2003774499 C Zo:2:003:1 0:1:1132:0 6 0:0:264
 880036e14600 2003779478 C Zo:2:003:1 0:1:1137:0 5 0:0:264
 Starting frame number-^  ^
 Number of frames-^

If you do the arithmetic, you'll see that the starting frame numbers 
aren't all what they should be.  For example, the 2nd URB starts in 
frame  and lasts 6 frames, so the 3rd URB should start in frame 
1117.  But instead it starts in 1116.

These numbers are clear indications of a bug somewhere in the driver.

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 v2] usb: hcd: add generic PHY support

2014-04-09 Thread Sergei Shtylyov
Add the generic PHY support, analogous to the USB PHY support. Intended it to be
used with the PCI EHCI/OHCI drivers and the xHCI platform driver.

Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

Changes in version 2:
- renamed the new 'phy' field of 'struct usb_phy' to 'gen_phy';
- resolved rejects due to removal of the first patch in the series.

 drivers/usb/core/hcd.c  |   42 --
 include/linux/usb/hcd.h |3 ++-
 2 files changed, 42 insertions(+), 3 deletions(-)

Index: usb/drivers/usb/core/hcd.c
===
--- usb.orig/drivers/usb/core/hcd.c
+++ usb/drivers/usb/core/hcd.c
@@ -42,6 +42,7 @@
 #include linux/pm_runtime.h
 #include linux/types.h
 
+#include linux/phy/phy.h
 #include linux/usb.h
 #include linux/usb/hcd.h
 #include linux/usb/phy.h
@@ -2623,6 +2624,29 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}
 
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
+   struct phy *phy = phy_get(hcd-self.controller, usb);
+
+   if (IS_ERR(phy)) {
+   retval = PTR_ERR(phy);
+   if (retval == -EPROBE_DEFER)
+   goto err_phy;
+   } else {
+   retval = phy_init(phy);
+   if (retval) {
+   phy_put(phy);
+   goto err_phy;
+   }
+   retval = phy_power_on(phy);
+   if (retval) {
+   phy_exit(phy);
+   phy_put(phy);
+   goto err_phy;
+   }
+   hcd-gen_phy = phy;
+   }
+   }
+
dev_info(hcd-self.controller, %s\n, hcd-product_desc);
 
/* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2638,7 +2662,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
 */
if ((retval = hcd_buffer_create(hcd)) != 0) {
dev_dbg(hcd-self.controller, pool alloc failed\n);
-   goto err_remove_phy;
+   goto err_create_buf;
}
 
if ((retval = usb_register_bus(hcd-self))  0)
@@ -2763,7 +2787,14 @@ err_allocate_root_hub:
usb_deregister_bus(hcd-self);
 err_register_bus:
hcd_buffer_destroy(hcd);
-err_remove_phy:
+err_create_buf:
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-gen_phy) {
+   phy_power_off(hcd-gen_phy);
+   phy_exit(hcd-gen_phy);
+   phy_put(hcd-gen_phy);
+   hcd-gen_phy = NULL;
+   }
+err_phy:
if (hcd-remove_phy  hcd-phy) {
usb_phy_shutdown(hcd-phy);
usb_put_phy(hcd-phy);
@@ -2841,6 +2872,13 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_put_dev(hcd-self.root_hub);
usb_deregister_bus(hcd-self);
hcd_buffer_destroy(hcd);
+
+   if (IS_ENABLED(CONFIG_GENERIC_PHY)  hcd-gen_phy) {
+   phy_power_off(hcd-gen_phy);
+   phy_exit(hcd-gen_phy);
+   phy_put(hcd-gen_phy);
+   hcd-gen_phy = NULL;
+   }
if (hcd-remove_phy  hcd-phy) {
usb_phy_shutdown(hcd-phy);
usb_put_phy(hcd-phy);
Index: usb/include/linux/usb/hcd.h
===
--- usb.orig/include/linux/usb/hcd.h
+++ usb/include/linux/usb/hcd.h
@@ -106,7 +106,8 @@ struct usb_hcd {
 * OTG and some Host controllers need software interaction with phys;
 * other external phys should be software-transparent
 */
-   struct usb_phy  *phy;
+   struct usb_phy  *phy;
+   struct phy  *gen_phy;
 
/* Flags that need to be manipulated atomically because they can
 * change while the host controller is running.  Always use
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


How to put the io_ti driver in RS485 mode?

2014-04-09 Thread Jim Bockerstette
I have been using the Edgeport 8s MEI to talk RS232 to my devices with good 
success. However, I cannot get it to talk RS485.
1. Does the io_ti driver support RS485?
2. If yes, is there a procedure I can follow to put it in that mode?
3. Thanks.

Here is my distro info:
CentOS release 6.5 (Final)
Linux version 2.6.32-431.5.1.el6.centos.plus.i686 (gcc version 4.4.6 20120305 
(Red Hat 4.4.6-4) (GCC) )


Jim Bockerstette
Senior Software Engineer
Systems Integrated


--
To unsubscribe from this list: send the line unsubscribe 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: ehci-exynos: Return immediately from suspend if ehci_suspend fails

2014-04-09 Thread Jingoo Han
On Thursday, April 10, 2014 3:32 AM, Alan Stern wrote:
 On Wed, 9 Apr 2014, Vivek Gautam wrote:
 
  Patch 'b8efdaf USB: EHCI: add check for wakeup/suspend race'
  adds a check for possible race between suspend and wakeup interrupt,
  and thereby it returns -EBUSY as error code if there's a wakeup
  interrupt.
  So the platform host controller should not proceed further with
  its suspend callback, rather should return immediately to avoid
  powering down the essential things, like phy.
 
  Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
  Cc: Alan Stern st...@rowland.harvard.edu
  Cc: Jingoo Han jg1@samsung.com
  ---
 
  Based on 'usb-next' branch of Greg's usb tree.
 
   drivers/usb/host/ehci-exynos.c |4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
 
  diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
  index d1d8c47..a4550eb 100644
  --- a/drivers/usb/host/ehci-exynos.c
  +++ b/drivers/usb/host/ehci-exynos.c
  @@ -212,6 +212,8 @@ static int exynos_ehci_suspend(struct device *dev)
  int rc;
 
  rc = ehci_suspend(hcd, do_wakeup);
  +   if (rc)
  +   return rc;
 
  if (exynos_ehci-otg)
  exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
  @@ -221,7 +223,7 @@ static int exynos_ehci_suspend(struct device *dev)
 
  clk_disable_unprepare(exynos_ehci-clk);
 
  -   return rc;
  +   return 0;
   }
 
   static int exynos_ehci_resume(struct device *dev)
 
 The first hunk of this patch is correct, but the second hunk isn't
 needed.  A similar remark is true for the ehci-platform patch.

Hi Alan,

Do you mean the following?

1st hunk
 +  if (rc)
 +  return rc;

2nd hunk
 -  return rc;
 +  return 0;

Currently, the 'rc' will be always 'zero'; however, I don't
Have any objection, because the code might be  modified later.

Best regards,
Jingoo Han
 
 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/2] usb: ehci-exynos: Return immediately from suspend if ehci_suspend fails

2014-04-09 Thread Alan Stern
On Thu, 10 Apr 2014, Jingoo Han wrote:

   --- a/drivers/usb/host/ehci-exynos.c
   +++ b/drivers/usb/host/ehci-exynos.c
   @@ -212,6 +212,8 @@ static int exynos_ehci_suspend(struct device *dev)
 int rc;
  
 rc = ehci_suspend(hcd, do_wakeup);
   + if (rc)
   + return rc;
  
 if (exynos_ehci-otg)
 exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
   @@ -221,7 +223,7 @@ static int exynos_ehci_suspend(struct device *dev)
  
 clk_disable_unprepare(exynos_ehci-clk);
  
   - return rc;
   + return 0;
}
  
static int exynos_ehci_resume(struct device *dev)
  
  The first hunk of this patch is correct, but the second hunk isn't
  needed.  A similar remark is true for the ehci-platform patch.
 
 Hi Alan,
 
 Do you mean the following?
 
 1st hunk
  +if (rc)
  +return rc;
 
 2nd hunk
  -return rc;
  +return 0;

Yes, that's what I mean.

 Currently, the 'rc' will be always 'zero'; however, I don't
 Have any objection, because the code might be  modified later.

Exactly.  We should add the new if statement but leave the return 
rc the way it is.

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: How to put the io_ti driver in RS485 mode?

2014-04-09 Thread Greg KH
On Wed, Apr 09, 2014 at 10:02:53PM +, Jim Bockerstette wrote:
 I have been using the Edgeport 8s MEI to talk RS232 to my devices with
 good success. However, I cannot get it to talk RS485.

Does that hardware even support 485?

 1. Does the io_ti driver support RS485?

I do not think so.

 2. If yes, is there a procedure I can follow to put it in that mode?
 3. Thanks.
 
 Here is my distro info:
 CentOS release 6.5 (Final)
 Linux version 2.6.32-431.5.1.el6.centos.plus.i686 (gcc version 4.4.6 20120305 
 (Red Hat 4.4.6-4) (GCC) )

That's a _very_ old kernel release, based on a 2009 kernel release.
That was some 260 thousand kernel changes ago :(

There's not much of anything that the kernel developer community can do
about that release, sorry.

thanks,

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


[PATCH 3.4 025/134] HID: clean up quirk for Sony RF receivers

2014-04-09 Thread Greg Kroah-Hartman
3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Fernando Luis Vazquez Cao ferna...@oss.ntt.co.jp

commit 99d249021abd4341771523ed8dd7946276103432 upstream.

Document what the fix-up is does and make it more robust by ensuring
that it is only applied to the USB interface that corresponds to the
mouse (sony_report_fixup() is called once per interface during probing).

Cc: linux-in...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Fernando Luis Vazquez Cao ferna...@oss.ntt.co.jp
Signed-off-by: Jiri Kosina jkos...@suse.cz
Signed-off-by: Ben Hutchings b...@decadent.org.uk
Cc: Yijing Wang wangyij...@huawei.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

---
 drivers/hid/hid-sony.c |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -44,9 +44,19 @@ static __u8 *sony_report_fixup(struct hi
 {
struct sony_sc *sc = hid_get_drvdata(hdev);
 
-   if ((sc-quirks  VAIO_RDESC_CONSTANT) 
-   *rsize = 56  rdesc[54] == 0x81  rdesc[55] == 0x07) 
{
+   /*
+* Some Sony RF receivers wrongly declare the mouse pointer as a
+* a constant non-data variable.
+*/
+   if ((sc-quirks  VAIO_RDESC_CONSTANT)  *rsize = 56 
+   /* usage page: generic desktop controls */
+   /* rdesc[0] == 0x05  rdesc[1] == 0x01  */
+   /* usage: mouse */
+   rdesc[2] == 0x09  rdesc[3] == 0x02 
+   /* input (usage page for x,y axes): constant, variable, relative */
+   rdesc[54] == 0x81  rdesc[55] == 0x07) {
hid_info(hdev, Fixing up Sony RF Receiver report 
descriptor\n);
+   /* input: data, variable, relative */
rdesc[55] = 0x06;
}
 


--
To unsubscribe from this list: send the line unsubscribe 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 024/134] HID: add support for Sony RF receiver with USB product id 0x0374

2014-04-09 Thread Greg Kroah-Hartman
3.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Fernando Luis Vazquez Cao ferna...@oss.ntt.co.jp

commit a464918419f94a0043d2f549d6defb4c3f69f68a upstream.

Some Vaio desktop computers, among them the VGC-LN51JGB multimedia PC, have
a RF receiver, multi-interface USB device 054c:0374, that is used to connect
a wireless keyboard and a wireless mouse.

The keyboard works flawlessly, but the mouse (VGP-WMS3 in my case) does not
seem to be generating any pointer events. The problem is that the mouse pointer
is wrongly declared as a constant non-data variable in the report descriptor
(see lsusb and usbhid-dump output below), with the consequence that it is
ignored by the HID code.

Add this device to the have-special-driver list and fix up the report
descriptor in the Sony-specific driver which happens to already have a fixup
for a similar firmware bug.

# lsusb -vd 054C:0374
Bus 003 Device 002: ID 054c:0374 Sony Corp.
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 8
  idVendor   0x054c Sony Corp.
  idProduct  0x0374
  iSerial 0
[...]
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber1
  bAlternateSetting   0
  bNumEndpoints   1
  bInterfaceClass 3 Human Interface Device
  bInterfaceSubClass  1 Boot Interface Subclass
  bInterfaceProtocol  2 Mouse
  iInterface  2 RF Receiver
[...]
  Report Descriptor: (length is 100)
[...]
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x30 ] 48
Direction-X
Item(Local ): Usage, data= [ 0x31 ] 49
Direction-Y
Item(Global): Report Count, data= [ 0x02 ] 2
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Logical Minimum, data= [ 0x81 ] 129
Item(Global): Logical Maximum, data= [ 0x7f ] 127
Item(Main  ): Input, data= [ 0x07 ] 7
Constant Variable Relative No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile 
Bitfield

# usbhid-dump
003:002:001:DESCRIPTOR 1357910009.758544
 05 01 09 02 A1 01 05 01 09 02 A1 02 85 01 09 01
 A1 00 05 09 19 01 29 05 95 05 75 01 15 00 25 01
 81 02 75 03 95 01 81 01 05 01 09 30 09 31 95 02
 75 08 15 81 25 7F 81 07 A1 02 85 01 09 38 35 00
 45 00 15 81 25 7F 95 01 75 08 81 06 C0 A1 02 85
 01 05 0C 15 81 25 7F 95 01 75 08 0A 38 02 81 06
 C0 C0 C0 C0

Cc: linux-in...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Fernando Luis Vazquez Cao ferna...@oss.ntt.co.jp
Signed-off-by: Jiri Kosina jkos...@suse.cz
Signed-off-by: Ben Hutchings b...@decadent.org.uk
Cc: Yijing Wang wangyij...@huawei.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

---
 drivers/hid/hid-core.c |1 +
 drivers/hid/hid-ids.h  |1 +
 drivers/hid/hid-sony.c |4 +++-
 3 files changed, 5 insertions(+), 1 deletion(-)

--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1619,6 +1619,7 @@ static const struct hid_device_id hid_ha
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, 
USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, 
USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) 
},
+   { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) 
},
{ HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
{ HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) },
{ HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, 
USB_DEVICE_ID_MTP_SITRONIX) },
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -685,6 +685,7 @@
 
 #define USB_VENDOR_ID_SONY 0x054c
 #define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE  0x024b
+#define USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE  0x0374
 #define USB_DEVICE_ID_SONY_PS3_CONTROLLER  0x0268
 #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER   0x042f
 
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -46,7 +46,7 @@ static __u8 *sony_report_fixup(struct hi
 
if ((sc-quirks  VAIO_RDESC_CONSTANT) 
*rsize = 56  rdesc[54] == 0x81  rdesc[55] == 0x07) 
{
-   hid_info(hdev, Fixing up Sony Vaio VGX report descriptor\n);
+   hid_info(hdev, Fixing up Sony RF Receiver report 
descriptor\n);
rdesc[55] = 0x06;
}
 
@@ -218,6 +218,8 @@ static const struct hid_device_id sony_d
.driver_data = 

Re: [PATCH 1/2] usb: ehci-exynos: Return immediately from suspend if ehci_suspend fails

2014-04-09 Thread Vivek Gautam
Hi Alan,


On Thu, Apr 10, 2014 at 7:06 AM, Alan Stern st...@rowland.harvard.edu wrote:
 On Thu, 10 Apr 2014, Jingoo Han wrote:

   --- a/drivers/usb/host/ehci-exynos.c
   +++ b/drivers/usb/host/ehci-exynos.c
   @@ -212,6 +212,8 @@ static int exynos_ehci_suspend(struct device *dev)
 int rc;
  
 rc = ehci_suspend(hcd, do_wakeup);
   + if (rc)
   + return rc;
  
 if (exynos_ehci-otg)
 exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
   @@ -221,7 +223,7 @@ static int exynos_ehci_suspend(struct device *dev)
  
 clk_disable_unprepare(exynos_ehci-clk);
  
   - return rc;
   + return 0;
}
  
static int exynos_ehci_resume(struct device *dev)
 
  The first hunk of this patch is correct, but the second hunk isn't
  needed.  A similar remark is true for the ehci-platform patch.

 Hi Alan,

 Do you mean the following?

 1st hunk
  +if (rc)
  +return rc;

 2nd hunk
  -return rc;
  +return 0;

 Yes, that's what I mean.

 Currently, the 'rc' will be always 'zero'; however, I don't
 Have any objection, because the code might be  modified later.

 Exactly.  We should add the new if statement but leave the return
 rc the way it is.

Sure, i will update both the patches.


 Alan Stern

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


[no subject]

2014-04-09 Thread Christian organization

Good day,

if you are a dedicated christian,contact us for your christian loan
organization, via email;info.finance...@yahoo.com



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