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

2014-04-16 Thread Li Jun
On Tue, Apr 15, 2014 at 02:48:44PM +0800, Peter Chen wrote:
 On Tue, Apr 15, 2014 at 09:43:04AM +0800, Li Jun wrote:
  On Mon, Apr 14, 2014 at 08:45:13PM +0800, Peter Chen wrote:
   On Mon, Apr 14, 2014 at 10:22:32AM +0800, Li Jun wrote:
On Mon, Apr 14, 2014 at 09:37:50AM +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 v9:
 - Move xxx_fsm_start to be after request irq since xxx_fsm_work need 
 call to
   disable_irq_nosync(ci-irq).
   
   Then, the interrupt will be on during the host initialization, it may
   have unexpected interrupt.
   
   
  Maybe for some devices which need not vbus from host, the enum will start 
  when
  host init. one possible solution is split the current fsm_start into 2 
  parts,
  the first part is put into fsm_init(thus before request_irq), the 2nd part 
  is
  put into fsm_start, any idea? if no objection, I can go in this way.
  
 
 Try to defer ci_otg_fsm_work using queue_work, and disable irq before
 it.
 

Can work in this way, I will change.

  
 - Add fsm handling in xxx_fsm_work for regsiter gadget driver with 
 vbus on, instead
   of rely on B_SE0_SRP timer(which is not directly linked to this 
 case and need wait
   1s).
   
   The B_SE0_SRP timer still will queue otg fsm work or not? If it is, any
   side effects?
   
  
  yes, still queue otg fsm work, but no side effects, as B-device is already 
  queue
  one fsm work before B_SE0_SRP timer time out, then the later one will just 
  try to
  change state but do nothing.
 
 Get it.
 
  
 - Add comments on a_idle to a_wait_vrise due to ID change, which is 
 out of OTG spec
   but make sense for user experience.
 - Remove blank line introduced in v9.
  
Sorry, missed one update in v10 changes summary:
- Clear ID interrupt status before enable ID irq in ci_hdrc_probe().
   
   At ci_get_otg_capable, it will clear all otg interrupt status.
   
  
  I do still find there is one ID change irq pending there when power up with 
  ID is low.
  if I need rework the fsm start and put host init before request irq, this 
  problem
  will not exist.
 
 Try to find the root cause for it please, we can't accept the code which
 still not find the root cause.
 

After more check on this, 
- The default state of ID is 1
- It's too early to clear ID change irq stats in current sequence, my simple log
  information shows the ID is still in default state(1) when clear and disable
  OTG irq in ci_get_otg_capable().
- There is already safe check of ID status by 2ms delay in current code:
...
if (ci-is_otg) {
/*
 * ID pin needs 1ms debouce time,
 * we delay 2ms for safe.
 */
mdelay(2);
ci-role = ci_otg_role(ci);
...

  After this delay, ID state becomes correct(0) and real ID change should
  already happened, so I think this is the right place to clear this unexpected
  ID interrupt.
  
Li Jun
 -- 
 
 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 v10 00/11] Add USB OTG HNP and SRP support on Chipidea usb driver

2014-04-16 Thread Peter Chen

 
 On Tue, Apr 15, 2014 at 02:48:44PM +0800, Peter Chen wrote:
  On Tue, Apr 15, 2014 at 09:43:04AM +0800, Li Jun wrote:
   On Mon, Apr 14, 2014 at 08:45:13PM +0800, Peter Chen wrote:
On Mon, Apr 14, 2014 at 10:22:32AM +0800, Li Jun wrote:
 On Mon, Apr 14, 2014 at 09:37:50AM +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 v9:
  - Move xxx_fsm_start to be after request irq since xxx_fsm_work
 need call to
disable_irq_nosync(ci-irq).
   
Then, the interrupt will be on during the host initialization, it
may have unexpected interrupt.
   
  
   Maybe for some devices which need not vbus from host, the enum will
   start when host init. one possible solution is split the current
   fsm_start into 2 parts, the first part is put into fsm_init(thus
   before request_irq), the 2nd part is put into fsm_start, any idea? if
 no objection, I can go in this way.
  
 
  Try to defer ci_otg_fsm_work using queue_work, and disable irq before
  it.
 
 
 Can work in this way, I will change.
 
  
  - Add fsm handling in xxx_fsm_work for regsiter gadget driver
 with vbus on, instead
of rely on B_SE0_SRP timer(which is not directly linked to
 this case and need wait
1s).
   
The B_SE0_SRP timer still will queue otg fsm work or not? If it
is, any side effects?
   
  
   yes, still queue otg fsm work, but no side effects, as B-device is
   already queue one fsm work before B_SE0_SRP timer time out, then the
   later one will just try to change state but do nothing.
 
  Get it.
 
  
  - Add comments on a_idle to a_wait_vrise due to ID change,
 which is out of OTG spec
but make sense for user experience.
  - Remove blank line introduced in v9.
 
 Sorry, missed one update in v10 changes summary:
 - Clear ID interrupt status before enable ID irq in
 ci_hdrc_probe().
   
At ci_get_otg_capable, it will clear all otg interrupt status.
   
  
   I do still find there is one ID change irq pending there when power
 up with ID is low.
   if I need rework the fsm start and put host init before request irq,
   this problem will not exist.
 
  Try to find the root cause for it please, we can't accept the code
  which still not find the root cause.
 
 
 After more check on this,
 - The default state of ID is 1
 - It's too early to clear ID change irq stats in current sequence, my
 simple log
   information shows the ID is still in default state(1) when clear and
 disable
   OTG irq in ci_get_otg_capable().
 - There is already safe check of ID status by 2ms delay in current code:
   ...
   if (ci-is_otg) {
   /*
* ID pin needs 1ms debouce time,
* we delay 2ms for safe.
*/
   mdelay(2);
   ci-role = ci_otg_role(ci);
   ...
 
 
I think I know the reason why you see this problem, your PHY is in low power 
mode
during the initialization, so after PHY's initialization has finished, we need 
to
delay 2ms for controller to reflect phy's status, and delay at 
ci_hdrc_enter_lpm are too much,
Please omit this ID status clear change in your patch, I will submit a patch to 
fix it soon.

Peter

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


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

2014-04-14 Thread Peter Chen
On Mon, Apr 14, 2014 at 10:22:32AM +0800, Li Jun wrote:
 On Mon, Apr 14, 2014 at 09:37:50AM +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 v9:
  - Move xxx_fsm_start to be after request irq since xxx_fsm_work need call to
disable_irq_nosync(ci-irq).

Then, the interrupt will be on during the host initialization, it may
have unexpected interrupt.

  - Add fsm handling in xxx_fsm_work for regsiter gadget driver with vbus on, 
  instead
of rely on B_SE0_SRP timer(which is not directly linked to this case and 
  need wait
1s).

The B_SE0_SRP timer still will queue otg fsm work or not? If it is, any
side effects?

  - Add comments on a_idle to a_wait_vrise due to ID change, which is out of 
  OTG spec
but make sense for user experience.
  - Remove blank line introduced in v9.
   
 Sorry, missed one update in v10 changes summary:
 - Clear ID interrupt status before enable ID irq in ci_hdrc_probe().

At ci_get_otg_capable, it will clear all otg interrupt status.

Peter
 
 Li Jun
  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
Documentation: ABI: usb: sysfs Description for chipidea USB OTG HNP
  and SRP
Documentation: usb: add chipidea.txt for how to demo usb OTG HNP and
  SRP
  
   .../ABI/testing/sysfs-platform-chipidea-usb-otg|   56 ++
   Documentation/usb/chipidea.txt |   71 ++
   drivers/usb/chipidea/Makefile  |1 +
   drivers/usb/chipidea/bits.h|   10 +
   drivers/usb/chipidea/ci.h  |   19 +
   drivers/usb/chipidea/core.c|   25 +-
   drivers/usb/chipidea/debug.c   |   84 ++
   drivers/usb/chipidea/host.c|   21 +-
   drivers/usb/chipidea/otg.c |   15 +-
   drivers/usb/chipidea/otg_fsm.c |  864 
  
   drivers/usb/chipidea/otg_fsm.h |  129 +++
   drivers/usb/chipidea/udc.c |   19 +-
   12 files changed, 1300 insertions(+), 14 deletions(-)
   create mode 100644 
  Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
   create mode 100644 Documentation/usb/chipidea.txt
   create mode 100644 drivers/usb/chipidea/otg_fsm.c
   create mode 100644 drivers/usb/chipidea/otg_fsm.h
  
  -- 
  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 v10 00/11] Add USB OTG HNP and SRP support on Chipidea usb driver

2014-04-14 Thread Li Jun
On Mon, Apr 14, 2014 at 08:45:13PM +0800, Peter Chen wrote:
 On Mon, Apr 14, 2014 at 10:22:32AM +0800, Li Jun wrote:
  On Mon, Apr 14, 2014 at 09:37:50AM +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 v9:
   - Move xxx_fsm_start to be after request irq since xxx_fsm_work need call 
   to
 disable_irq_nosync(ci-irq).
 
 Then, the interrupt will be on during the host initialization, it may
 have unexpected interrupt.
 
 
Maybe for some devices which need not vbus from host, the enum will start when
host init. one possible solution is split the current fsm_start into 2 parts,
the first part is put into fsm_init(thus before request_irq), the 2nd part is
put into fsm_start, any idea? if no objection, I can go in this way.

Li Jun

   - Add fsm handling in xxx_fsm_work for regsiter gadget driver with vbus 
   on, instead
 of rely on B_SE0_SRP timer(which is not directly linked to this case 
   and need wait
 1s).
 
 The B_SE0_SRP timer still will queue otg fsm work or not? If it is, any
 side effects?
 

yes, still queue otg fsm work, but no side effects, as B-device is already queue
one fsm work before B_SE0_SRP timer time out, then the later one will just try 
to
change state but do nothing.

   - Add comments on a_idle to a_wait_vrise due to ID change, which is out 
   of OTG spec
 but make sense for user experience.
   - Remove blank line introduced in v9.

  Sorry, missed one update in v10 changes summary:
  - Clear ID interrupt status before enable ID irq in ci_hdrc_probe().
 
 At ci_get_otg_capable, it will clear all otg interrupt status.
 

I do still find there is one ID change irq pending there when power up with ID 
is low.
if I need rework the fsm start and put host init before request irq, this 
problem
will not exist.

 Peter
  
  Li Jun
   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
 Documentation: ABI: usb: sysfs Description for chipidea USB OTG HNP
   and SRP
 Documentation: usb: add chipidea.txt for how to demo usb OTG HNP and
   SRP
   
.../ABI/testing/sysfs-platform-chipidea-usb-otg|   56 ++
Documentation/usb/chipidea.txt |   71 ++
drivers/usb/chipidea/Makefile  |1 +
drivers/usb/chipidea/bits.h|   10 +
drivers/usb/chipidea/ci.h  |   19 +
drivers/usb/chipidea/core.c|   25 +-
drivers/usb/chipidea/debug.c   |   84 ++
drivers/usb/chipidea/host.c|   21 +-
drivers/usb/chipidea/otg.c |   15 +-
drivers/usb/chipidea/otg_fsm.c |  864 
   
drivers/usb/chipidea/otg_fsm.h |  129 +++
drivers/usb/chipidea/udc.c |   19 +-
12 files changed, 1300 insertions(+), 14 deletions(-)
create mode 100644 
   Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
create mode 100644 Documentation/usb/chipidea.txt
create mode 100644 drivers/usb/chipidea/otg_fsm.c
create mode 100644 drivers/usb/chipidea/otg_fsm.h
   
   -- 
   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


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

2014-04-13 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 v9:
- Move xxx_fsm_start to be after request irq since xxx_fsm_work need call to
  disable_irq_nosync(ci-irq).
- Add fsm handling in xxx_fsm_work for regsiter gadget driver with vbus on, 
instead
  of rely on B_SE0_SRP timer(which is not directly linked to this case and need 
wait
  1s).
- Add comments on a_idle to a_wait_vrise due to ID change, which is out of OTG 
spec
  but make sense for user experience.
- Remove blank line introduced in v9.
 
Changes since v8:
- fsm start is the only entry point to start fsm and cover all role start/stop,
  which only call to ci_otg_fsm_work(). Move otg fsm start before request_irq
  for fsm mode, ci_role_start only for non fsm mode.
- use queue work to handle further state changes in ci_otg_fsm_work().
- Let otg fsm handle all after ci-driver is set in ci_udc_start.
- Enable BSV irq when power up with ID is 1.

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
- 

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

2014-04-13 Thread Li Jun
On Mon, Apr 14, 2014 at 09:37:50AM +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 v9:
 - Move xxx_fsm_start to be after request irq since xxx_fsm_work need call to
   disable_irq_nosync(ci-irq).
 - Add fsm handling in xxx_fsm_work for regsiter gadget driver with vbus on, 
 instead
   of rely on B_SE0_SRP timer(which is not directly linked to this case and 
 need wait
   1s).
 - Add comments on a_idle to a_wait_vrise due to ID change, which is out of 
 OTG spec
   but make sense for user experience.
 - Remove blank line introduced in v9.
  
Sorry, missed one update in v10 changes summary:
- Clear ID interrupt status before enable ID irq in ci_hdrc_probe().

Li Jun
 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
   Documentation: ABI: usb: sysfs Description for chipidea USB OTG HNP
 and SRP
   Documentation: usb: add chipidea.txt for how to demo usb OTG HNP and
 SRP
 
  .../ABI/testing/sysfs-platform-chipidea-usb-otg|   56 ++
  Documentation/usb/chipidea.txt |   71 ++
  drivers/usb/chipidea/Makefile  |1 +
  drivers/usb/chipidea/bits.h|   10 +
  drivers/usb/chipidea/ci.h  |   19 +
  drivers/usb/chipidea/core.c|   25 +-
  drivers/usb/chipidea/debug.c   |   84 ++
  drivers/usb/chipidea/host.c|   21 +-
  drivers/usb/chipidea/otg.c |   15 +-
  drivers/usb/chipidea/otg_fsm.c |  864 
 
  drivers/usb/chipidea/otg_fsm.h |  129 +++
  drivers/usb/chipidea/udc.c |   19 +-
  12 files changed, 1300 insertions(+), 14 deletions(-)
  create mode 100644 Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
  create mode 100644 Documentation/usb/chipidea.txt
  create mode 100644 drivers/usb/chipidea/otg_fsm.c
  create mode 100644 drivers/usb/chipidea/otg_fsm.h
 
 -- 
 1.7.9.5
 
 

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