RE: [PATCH v4 9/9] usb: chipidea: add support to the generic PHY framework in ChipIdea

2014-09-04 Thread b47...@freescale.com
Hi,

-Original Message-
From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-ow...@vger.kernel.org] 
On Behalf Of Antoine Tenart
Sent: Wednesday, September 03, 2014 3:41 PM
To: ba...@ti.com; gre...@linuxfoundation.org; Chen Peter-B29397; kis...@ti.com; 
st...@rowland.harvard.edu
Cc: Antoine Tenart; sergei.shtyl...@cogentembedded.com; 
yoshihiro.shimoda...@renesas.com; alexandre.bell...@free-electrons.com; 
thomas.petazz...@free-electrons.com; z...@marvell.com; jszh...@marvell.com; 
linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
Subject: [PATCH v4 9/9] usb: chipidea: add support to the generic PHY framework 
in ChipIdea

This patch adds support of the PHY framework for ChipIdea drivers.
Changes are done in both the ChipIdea common code and in the drivers accessing 
the PHY. This is done by adding a new PHY member in ChipIdea's structures and 
by taking care of it in the code.

Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
---
 drivers/usb/chipidea/ci.h  |  5 ++-
 drivers/usb/chipidea/core.c| 74 ++
 drivers/usb/chipidea/debug.c   |  3 +-
 drivers/usb/chipidea/host.c|  5 ++-
 drivers/usb/chipidea/otg_fsm.c |  6 +++-
 include/linux/usb/chipidea.h   |  2 ++
 6 files changed, 78 insertions(+), 17 deletions(-)
...

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 
5a7ea93011dd..999e9d683d7a 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -219,7 +219,8 @@ static int ci_otg_show(struct seq_file *s, void *unused)
fsm = ci-fsm;
 
/* -- State - */
-   usb_otg_state_string(ci-usb_phy-otg.state));
+   seq_printf(s, OTG state: %s\n\n,

Still not resolve this?

Li Jun 
+  usb_otg_state_string(ci-otg.state)); 

/* -- State Machine Variables - */
seq_printf(s, a_bus_drop: %d\n, fsm-a_bus_drop); diff --git 
a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 
--
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in the 
body of a message to majord...@vger.kernel.org More majordomo info at  
http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe 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 06/10] usb: chipidea: OTG fsm timers initialization.

2014-01-16 Thread b47...@freescale.com
-Original Message-
From: Michael Grzeschik [mailto:m...@pengutronix.de] 
Sent: Friday, January 10, 2014 9:48 PM
To: Li Jun-B47624
Cc: ba...@ti.com; Chen Peter-B29397; linux-usb@vger.kernel.org
Subject: Re: [PATCH 06/10] usb: chipidea: OTG fsm timers initialization.

Hi Li Jun,

On Wed, Jan 08, 2014 at 05:06:21PM +0800, Li Jun wrote:
 This patch adds OTG fsm timers initialization, which use controller's 
 1ms interrupt as time out 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/otg_fsm.c |  111 
 +++-
  drivers/usb/chipidea/otg_fsm.h |   65 +++
  2 files changed, 175 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/usb/chipidea/otg_fsm.c 
 b/drivers/usb/chipidea/otg_fsm.c index 31a046d..86bed68 100644
 --- a/drivers/usb/chipidea/otg_fsm.c
 +++ b/drivers/usb/chipidea/otg_fsm.c
 @@ -33,7 +33,23 @@ static struct list_head active_timers;
  /* FSM timers */
  struct ci_otg_fsm_timer *a_wait_vrise_tmr, *a_wait_vfall_tmr, 
 *a_wait_bcon_tmr,
   *a_aidl_bdis_tmr, *a_bidl_adis_tmr, *b_ase0_brst_tmr,
 - *b_se0_srp_tmr, *b_srp_fail_tmr, *b_data_pulse_tmr;
 + *b_se0_srp_tmr, *b_srp_fail_tmr, *b_data_pulse_tmr,
 + *b_ssend_srp_tmr, *b_sess_vld_tmr;
 +

One patch should not change code that another patch in that same series is 
introducing. These hunk seems to belong to the previous patch.
[Li Jun] You are right, I will re-split my patch set to resolve this, thanks!


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


--
To unsubscribe from this list: send the line unsubscribe 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 02/10] usb: chipidea: usb OTG fsm initlization.

2014-01-15 Thread b47...@freescale.com


Regards
Li Jun

Tel: 0512-6805 6912


-Original Message-
From: Peter Chen [mailto:peter.c...@freescale.com] 
Sent: Thursday, January 09, 2014 3:11 PM
To: Li Jun-B47624
Cc: ba...@ti.com; linux-usb@vger.kernel.org
Subject: Re: [PATCH 02/10] usb: chipidea: usb OTG fsm initlization.

On Wed, Jan 08, 2014 at 05:06:17PM +0800, Li Jun wrote:
 This patch adds OTG fsm related initizations 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  |1 +
  drivers/usb/chipidea/otg.c |6 +++
  drivers/usb/chipidea/otg_fsm.c |   70 
 
  drivers/usb/chipidea/otg_fsm.h |   27 +++
  5 files changed, 105 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/usb/chipidea/Makefile 
 b/drivers/usb/chipidea/Makefile index 7345d21..5e1ecc5 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 1c94fc5..0f1abc1 100644
 --- a/drivers/usb/chipidea/ci.h
 +++ b/drivers/usb/chipidea/ci.h
 @@ -144,6 +144,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;
  
 diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c 
 index 39bd7ec..2e13f2f 100644
 --- a/drivers/usb/chipidea/otg.c
 +++ b/drivers/usb/chipidea/otg.c
 @@ -95,6 +95,12 @@ static void ci_otg_work(struct work_struct *work)
   */
  int ci_hdrc_otg_init(struct ci_hdrc *ci)  {
 + int retval = 0;
 +
 + retval = ci_hdrc_otg_fsm_init(ci);
 + if (retval)
 + return retval;
 +
   INIT_WORK(ci-work, ci_otg_work);
   ci-wq = create_singlethread_workqueue(ci_otg);
   if (!ci-wq) {
 diff --git a/drivers/usb/chipidea/otg_fsm.c 
 b/drivers/usb/chipidea/otg_fsm.c new file mode 100644 index 
 000..1f8907d
 --- /dev/null
 +++ b/drivers/usb/chipidea/otg_fsm.c
 @@ -0,0 +1,70 @@
 +/*
 + * 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 otgsc register, it may include OTG 
 +operation
 + * in the future.
 + */

Please update description for both this file and otg.c.
[Li Jun] ok, I will update. 

 +
 +#include linux/usb/otg.h
 +#include linux/usb/otg-fsm.h
 +#include linux/usb/gadget.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) {
 + if (ci-transceiver == NULL)
 + return -EPROBE_DEFER;
 +

Since ci_usb_phy_init is run before that, this check should be there.
I will have a patch for that.
[Li Jun]I will remove this since you plan another patch for it. 

 + ci-transceiver-otg = devm_kzalloc(ci-dev,
 + sizeof(struct usb_otg), GFP_KERNEL);
 + if (!ci-transceiver-otg) {
 + dev_err(ci-dev,
 + Failed to allocate usb_otg structure for ci hdrc otg!\n);
 + return -ENOMEM;
 + }
 +
 + ci-fsm = devm_kzalloc(ci-dev,
 + sizeof(struct otg_fsm), GFP_KERNEL);
 + if (!ci-fsm) {
 + dev_err(ci-dev,
 + Failed to allocate otg_fsm structure for ci hdrc otg!\n);
 + return -ENOMEM;
 + }
 +
 + ci-fsm-power_up = 1;
 + ci-fsm-id = hw_read(ci, OP_OTGSC, OTGSC_ID);
 + ci-fsm-otg = ci-transceiver-otg;
 + ci-fsm-otg-phy = ci-transceiver;
 + ci-fsm-otg-gadget = ci-gadget;
 + ci-transceiver-state = OTG_STATE_UNDEFINED;
 +
 + mutex_init(ci-fsm-lock);
 +
 + /* enable ID and A vbus valid irq */
 + hw_write(ci, OP_OTGSC, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
 + OTGSC_IDIE | OTGSC_AVVIE);

One or two TAB between two lines for one statement is better.

Peter

[Li Jun]  The line  OTGSC_IDIE | OTGSC_AVVIE); is placed substantially to the 
right already.
 +
 + if (ci-fsm-id) {
 + ci-fsm-b_ssend_srp =
 + hw_read(ci, OP_OTGSC, OTGSC_BSV) ? 0 : 1;
 + ci-fsm-b_sess_vld =
 + hw_read(ci, OP_OTGSC

RE: [PATCH 08/10] usb: chipidea: add OTG HNP polling support.

2014-01-15 Thread b47...@freescale.com


-Original Message-
From: Felipe Balbi [mailto:ba...@ti.com] 
Sent: Thursday, January 09, 2014 5:07 AM
To: Li Jun-B47624
Cc: ba...@ti.com; Chen Peter-B29397; linux-usb@vger.kernel.org
Subject: Re: [PATCH 08/10] usb: chipidea: add OTG HNP polling support.

Hi,

On Wed, Jan 08, 2014 at 05:06:23PM +0800, Li Jun wrote:
 This patch add OTG HNP polling support for both A and B device.
 After A/B in host state, host request polling message will be sent 
 from host to peripheral every 1.5s, if host found the host request 
 flag is set to be 1 by peripheral, a role switch will be started.
 
 Signed-off-by: Li Jun b47...@freescale.com
 ---
  drivers/usb/chipidea/ci.h  |2 +
  drivers/usb/chipidea/otg_fsm.c |   80 
 
  drivers/usb/chipidea/otg_fsm.h |3 +
  drivers/usb/chipidea/udc.c |   11 -
  drivers/usb/phy/phy-fsm-usb.c  |6 +++

you need to figure out a way to split this patch, the dependency you created 
here is really pointless.
[Li Jun] I will split this patch and create a separate patch set for it.

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


RE: [PATCH 03/10] usb: chipidea: host:vbus control change for OTG HNP.

2014-01-15 Thread b47...@freescale.com
Hi

-Original Message-
From: Peter Chen [mailto:peter.c...@freescale.com] 
Sent: Thursday, January 09, 2014 4:00 PM
To: Li Jun-B47624
Cc: ba...@ti.com; linux-usb@vger.kernel.org
Subject: Re: [PATCH 03/10] usb: chipidea: host:vbus control change for OTG HNP.

A blank space between host: and vbus
[Li Jun]  OK, I will update.

Reply-To: 
In-Reply-To: 1389171985-9282-4-git-send-email-b47...@freescale.com

On Wed, Jan 08, 2014 at 05:06:18PM +0800, Li Jun wrote:
 Leave vbus on/off hanlded by OTG fsm if in OTG mode, init OTG port number.
 ^and
What does the OTG port number mean? It is always 1?
If there are two OTG port, how about the value of the otg_port?
[Li Jun] Here the OTG port number means the USB host port number to which a 
device attaches, which is 1 based, since HNP does not support hub(i.e. no 
intervening hub between the Host and the B-device), and only one OTG port per 
one OTG controller, so I set it to be 1. If there are 2 OTG controllers in one 
device, each OTG port will work the same way.  

 
 Signed-off-by: Li Jun b47...@freescale.com
 ---
  drivers/usb/chipidea/host.c |   13 +
  drivers/usb/chipidea/host.h |9 +
  2 files changed, 18 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c 
 index 526cd77..bba54c3 100644
 --- a/drivers/usb/chipidea/host.c
 +++ b/drivers/usb/chipidea/host.c
 @@ -66,7 +66,7 @@ static int host_start(struct ci_hdrc *ci)
   ehci-has_hostpc = ci-hw_bank.lpm;
   ehci-has_tdi_phy_lpm = ci-hw_bank.lpm;
  
 - if (ci-platdata-reg_vbus) {
 + if ((ci-platdata-reg_vbus)  !ci_host_is_otg(ci)) {

The first () is not needed.
[Li Jun] I will remove it.
Any ways to unify the vbus controller for both OTG and non-OTG cases?
[Li Jun] Both cases have diff V-bus handling, in OTG HNP case, V-bus is 
controlled by HNP fsm, it's not always on when in host mode.

   ret = regulator_enable(ci-platdata-reg_vbus);
   if (ret) {
   dev_err(ci-dev,
 @@ -79,8 +79,13 @@ static int host_start(struct ci_hdrc *ci)
   ret = usb_add_hcd(hcd, 0, 0);
   if (ret)
   goto disable_reg;
 - else
 + else {
   ci-hcd = hcd;
 + if (ci_host_is_otg(ci)) {
 + ci-transceiver-otg-host = hcd-self;
 + ci-transceiver-otg-host-otg_port = 1;
 + }
 + }
  
   if (ci-platdata-flags  CI_HDRC_DISABLE_STREAMING)
   hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); @@ 
 -88,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_host_is_otg(ci))
   regulator_disable(ci-platdata-reg_vbus);
  
  put_hcd:
 @@ -104,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_host_is_otg(ci))
   regulator_disable(ci-platdata-reg_vbus);
   }
  }
 diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h 
 index 5707bf3..f98d084 100644
 --- a/drivers/usb/chipidea/host.h
 +++ b/drivers/usb/chipidea/host.h
 @@ -6,6 +6,15 @@
  int ci_hdrc_host_init(struct ci_hdrc *ci);  void 
 ci_hdrc_host_destroy(struct ci_hdrc *ci);
  
 +static inline bool ci_host_is_otg(struct ci_hdrc *ci) { #ifdef 
 +CONFIG_USB_OTG_FSM

CONFIG_USB_OTG?
[Li Jun] Both can work for me, CONFIG_USB_OTG_FSM is more dedicated for OTG fsm.

 + return (ci-is_otg)  (ci-platdata-dr_mode == USB_DR_MODE_OTG);

Why ci-platdata-dr_mode == USB_DR_MODE_OTG is needed to judge if a host port 
is OTG port?
[Li Jun] This is used to judge if a OTG port is working in OTG mode with HNP 
enabled.

Besides, if the user chooses dr_mode as non USB_DR_MODE_OTG, and kernel 
configuration chooses CONFIG_USB_OTG, the port should responds as host only 
port. DT entries can always override kernel configuration.
[Li Jun] yes, if dr_mode is not USB_DR_MODE_OTG, OTG port will work in 
host-only or device-only mode, even CONFIG_USB_OTG_FSM is selected.

 +#else
 + return false;
 +#endif
 +}
 +
  #else
  
  static inline int ci_hdrc_host_init(struct ci_hdrc *ci)
 --
 1.7.8
 
 

-- 

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