Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1493581 > unrolled thread
| Started by | Guenter Roeck <groeck@google.com> |
|---|---|
| First post | 2016-09-29 18:40 +0200 |
| Last post | 2016-09-30 17:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) Guenter Roeck <groeck@google.com> - 2016-09-29 18:40 +0200
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) Jun Li <jun.li@nxp.com> - 2016-09-30 14:20 +0200
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) Guenter Roeck <groeck@google.com> - 2016-09-30 17:50 +0200
| From | Guenter Roeck <groeck@google.com> |
|---|---|
| Date | 2016-09-29 18:40 +0200 |
| Subject | Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) |
| Message-ID | <smMxm-6vr-71@gated-at.bofh.it> |
On Thu, Sep 29, 2016 at 7:35 AM, Jun Li <jun.li@nxp.com> wrote:
> Hi Guenter,
>
>> -----Original Message-----
>> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-
>> owner@vger.kernel.org] On Behalf Of Guenter Roeck
>> Sent: Wednesday, August 24, 2016 5:11 AM
>> To: Felipe Balbi <felipe.balbi@linux.intel.com>
>> Cc: Chandra Sekhar Anagani <chandra.sekhar.anagani@intel.com>; Bruce
>> Ashfield <bruce.ashfield@windriver.com>; Bin Gao <bin.gao@intel.com>;
>> Pranav Tipnis <pranav.tipnis@intel.com>; Heikki Krogerus
>> <heikki.krogerus@linux.intel.com>; linux-kernel@vger.kernel.org; linux-
>> usb@vger.kernel.org; Guenter Roeck <groeck@chromium.org>
>> Subject: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
>>
>> This driver implements the USB Type-C Power Delivery state machine
>> for both source and sink ports. Alternate mode support is not
>> fully implemented.
>>
>> The driver attaches to the USB Type-C class code implemented in
>> the following patches.
>>
>> usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY
>> usb: USB Type-C connector class
>>
>> This driver only implements the state machine. Lower level drivers are
>> responsible for
>> - Reporting VBUS status and activating VBUS
>> - Setting CC lines and providing CC line status
>> - Setting line polarity
>> - Activating and deactivating VCONN
>> - Setting the current limit
>> - Activating and deactivating PD message transfers
>> - Sending and receiving PD messages
>>
>> The driver provides both a functional API as well as callbacks for
>> lower level drivers.
>>
>> Signed-off-by: Guenter Roeck <groeck@chromium.org>
>> ---
>> v3:
>> - Improve TCPM state machine resiliency if there are spurious CC line
>> changes
>> while the state machine is in a transient change (waiting for a timeout)
>> - Update current limit after CC voltage level changes on a port which is
>> not
>> PD capable.
>>
>> v2:
>> - Only update polarity if setting it was successful
>> If setting the CC line polarity in the driver was not successful,
>> don't update the internal polarity state.
>> - All PD messages are little endian; convert to and from CPU endianness.
>> - Avoid comparisons against NULL.
>> - Use u8/u16/u32 instead of uint8_t/uint16_t/uint32_t consistently.
>> - Callbacks into tcpm need to be lockless to avoid timing problems
>> in low level drivers.
>> - Simplify callbacks; tcpm can request the current state of cc/vbus
>> when it is ready to use it.
>>
>> drivers/usb/typec/Kconfig | 7 +
>> drivers/usb/typec/Makefile | 1 +
>> drivers/usb/typec/tcpm.c | 3163
>> ++++++++++++++++++++++++++++++++++++++++++++
>> drivers/usb/typec/tcpm.h | 137 ++
>> include/linux/usb/pd.h | 282 ++++
>> include/linux/usb/pd_bdo.h | 31 +
>> include/linux/usb/pd_vdo.h | 412 ++++++
>> 7 files changed, 4033 insertions(+)
>> create mode 100644 drivers/usb/typec/tcpm.c
>> create mode 100644 drivers/usb/typec/tcpm.h
>> create mode 100644 include/linux/usb/pd.h
>> create mode 100644 include/linux/usb/pd_bdo.h
>> create mode 100644 include/linux/usb/pd_vdo.h
>>
>
> ...
>
>> +
>> +static void run_state_machine(struct tcpm_port *port)
>> +{
>> + int ret;
>> +
>> + port->enter_state = port->state;
>> + switch (port->state) {
>> + /* SRC states */
>> + case SRC_UNATTACHED:
>> + tcpm_swap_complete(port, -ENOTCONN);
>> + tcpm_src_detach(port);
>> + tcpm_set_cc(port, TYPEC_CC_RP_DEF);
>> + if (port->typec_caps.type == TYPEC_PORT_DRP)
>> + tcpm_set_state(port, SNK_UNATTACHED, PD_T_DRP_SNK);
>
> With this and below, after disconnect, the DRP port state machine will be
> in infinite loop of state transition between SRC_UNATTACHED <--> SNK_UNATTACHED,
> correct?
>
Only while disconnected. It tries to alternatively connect as source
and as sink (being configured as DRP). Once a CC line state change is
reported it will transition out. I have a newer version of the patch
(not yet published) which supports DRP toggling by the TCPC. With that
enabled, TCPM does not change states until a CC state change is
reported.
Guenter
> Li Jun
> ...
>
>> + /* SNK states */
>> + case SNK_UNATTACHED:
>> + tcpm_swap_complete(port, -ENOTCONN);
>> + tcpm_snk_detach(port);
>> + tcpm_set_cc(port, TYPEC_CC_RD);
>> + if (port->typec_caps.type == TYPEC_PORT_DRP)
>> + tcpm_set_state(port, SRC_UNATTACHED, PD_T_DRP_SRC);
>> + break;
>>
[toc] | [next] | [standalone]
| From | Jun Li <jun.li@nxp.com> |
|---|---|
| Date | 2016-09-30 14:20 +0200 |
| Message-ID | <sn4Xf-1Ge-15@gated-at.bofh.it> |
| In reply to | #1493581 |
Hi,
> -----Original Message-----
> From: Guenter Roeck [mailto:groeck@google.com]
> Sent: Friday, September 30, 2016 12:37 AM
> To: Jun Li <jun.li@nxp.com>
> Cc: Guenter Roeck <groeck@chromium.org>; Felipe Balbi
> <felipe.balbi@linux.intel.com>; Chandra Sekhar Anagani
> <chandra.sekhar.anagani@intel.com>; Bruce Ashfield
> <bruce.ashfield@windriver.com>; Bin Gao <bin.gao@intel.com>; Pranav Tipnis
> <pranav.tipnis@intel.com>; Heikki Krogerus
> <heikki.krogerus@linux.intel.com>; linux-kernel@vger.kernel.org; linux-
> usb@vger.kernel.org
> Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
>
> On Thu, Sep 29, 2016 at 7:35 AM, Jun Li <jun.li@nxp.com> wrote:
> > Hi Guenter,
> >
> >> -----Original Message-----
> >> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-
> >> owner@vger.kernel.org] On Behalf Of Guenter Roeck
> >> Sent: Wednesday, August 24, 2016 5:11 AM
> >> To: Felipe Balbi <felipe.balbi@linux.intel.com>
> >> Cc: Chandra Sekhar Anagani <chandra.sekhar.anagani@intel.com>; Bruce
> >> Ashfield <bruce.ashfield@windriver.com>; Bin Gao <bin.gao@intel.com>;
> >> Pranav Tipnis <pranav.tipnis@intel.com>; Heikki Krogerus
> >> <heikki.krogerus@linux.intel.com>; linux-kernel@vger.kernel.org;
> >> linux- usb@vger.kernel.org; Guenter Roeck <groeck@chromium.org>
> >> Subject: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager
> >> (tcpm)
> >>
> >> This driver implements the USB Type-C Power Delivery state machine
> >> for both source and sink ports. Alternate mode support is not fully
> >> implemented.
> >>
> >> The driver attaches to the USB Type-C class code implemented in the
> >> following patches.
> >>
> >> usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY
> >> usb: USB Type-C connector class
> >>
> >> This driver only implements the state machine. Lower level drivers
> >> are responsible for
> >> - Reporting VBUS status and activating VBUS
> >> - Setting CC lines and providing CC line status
> >> - Setting line polarity
> >> - Activating and deactivating VCONN
> >> - Setting the current limit
> >> - Activating and deactivating PD message transfers
> >> - Sending and receiving PD messages
> >>
> >> The driver provides both a functional API as well as callbacks for
> >> lower level drivers.
> >>
> >> Signed-off-by: Guenter Roeck <groeck@chromium.org>
> >> ---
> >> v3:
> >> - Improve TCPM state machine resiliency if there are spurious CC line
> >> changes
> >> while the state machine is in a transient change (waiting for a
> >> timeout)
> >> - Update current limit after CC voltage level changes on a port which
> >> is not
> >> PD capable.
> >>
> >> v2:
> >> - Only update polarity if setting it was successful
> >> If setting the CC line polarity in the driver was not successful,
> >> don't update the internal polarity state.
> >> - All PD messages are little endian; convert to and from CPU endianness.
> >> - Avoid comparisons against NULL.
> >> - Use u8/u16/u32 instead of uint8_t/uint16_t/uint32_t consistently.
> >> - Callbacks into tcpm need to be lockless to avoid timing problems
> >> in low level drivers.
> >> - Simplify callbacks; tcpm can request the current state of cc/vbus
> >> when it is ready to use it.
> >>
> >> drivers/usb/typec/Kconfig | 7 +
> >> drivers/usb/typec/Makefile | 1 +
> >> drivers/usb/typec/tcpm.c | 3163
> >> ++++++++++++++++++++++++++++++++++++++++++++
> >> drivers/usb/typec/tcpm.h | 137 ++
> >> include/linux/usb/pd.h | 282 ++++
> >> include/linux/usb/pd_bdo.h | 31 +
> >> include/linux/usb/pd_vdo.h | 412 ++++++
> >> 7 files changed, 4033 insertions(+)
> >> create mode 100644 drivers/usb/typec/tcpm.c create mode 100644
> >> drivers/usb/typec/tcpm.h create mode 100644 include/linux/usb/pd.h
> >> create mode 100644 include/linux/usb/pd_bdo.h create mode 100644
> >> include/linux/usb/pd_vdo.h
> >>
> >
> > ...
> >
> >> +
> >> +static void run_state_machine(struct tcpm_port *port) {
> >> + int ret;
> >> +
> >> + port->enter_state = port->state;
> >> + switch (port->state) {
> >> + /* SRC states */
> >> + case SRC_UNATTACHED:
> >> + tcpm_swap_complete(port, -ENOTCONN);
> >> + tcpm_src_detach(port);
> >> + tcpm_set_cc(port, TYPEC_CC_RP_DEF);
> >> + if (port->typec_caps.type == TYPEC_PORT_DRP)
> >> + tcpm_set_state(port, SNK_UNATTACHED,
> >> + PD_T_DRP_SNK);
> >
> > With this and below, after disconnect, the DRP port state machine will
> > be in infinite loop of state transition between SRC_UNATTACHED <-->
> > SNK_UNATTACHED, correct?
> >
>
> Only while disconnected. It tries to alternatively connect as source and
> as sink (being configured as DRP). Once a CC line state change is reported
> it will transition out. I have a newer version of the patch (not yet
> published) which supports DRP toggling by the TCPC. With that enabled,
> TCPM does not change states until a CC state change is reported.
>
Great, that way will be better, do you plan post your newer patch recently?
Thanks
Li Jun
> Guenter
>
> > Li Jun
> > ...
> >
> >> + /* SNK states */
> >> + case SNK_UNATTACHED:
> >> + tcpm_swap_complete(port, -ENOTCONN);
> >> + tcpm_snk_detach(port);
> >> + tcpm_set_cc(port, TYPEC_CC_RD);
> >> + if (port->typec_caps.type == TYPEC_PORT_DRP)
> >> + tcpm_set_state(port, SRC_UNATTACHED,
> PD_T_DRP_SRC);
> >> + break;
> >>
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <groeck@google.com> |
|---|---|
| Date | 2016-09-30 17:50 +0200 |
| Message-ID | <sn8eu-3B1-13@gated-at.bofh.it> |
| In reply to | #1494067 |
On Thu, Sep 29, 2016 at 11:41 PM, Jun Li <jun.li@nxp.com> wrote:
> Hi,
>
>> -----Original Message-----
>> From: Guenter Roeck [mailto:groeck@google.com]
>> Sent: Friday, September 30, 2016 12:37 AM
>> To: Jun Li <jun.li@nxp.com>
>> Cc: Guenter Roeck <groeck@chromium.org>; Felipe Balbi
>> <felipe.balbi@linux.intel.com>; Chandra Sekhar Anagani
>> <chandra.sekhar.anagani@intel.com>; Bruce Ashfield
>> <bruce.ashfield@windriver.com>; Bin Gao <bin.gao@intel.com>; Pranav Tipnis
>> <pranav.tipnis@intel.com>; Heikki Krogerus
>> <heikki.krogerus@linux.intel.com>; linux-kernel@vger.kernel.org; linux-
>> usb@vger.kernel.org
>> Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
>>
>> On Thu, Sep 29, 2016 at 7:35 AM, Jun Li <jun.li@nxp.com> wrote:
>> > Hi Guenter,
>> >
>> >> -----Original Message-----
>> >> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-
>> >> owner@vger.kernel.org] On Behalf Of Guenter Roeck
>> >> Sent: Wednesday, August 24, 2016 5:11 AM
>> >> To: Felipe Balbi <felipe.balbi@linux.intel.com>
>> >> Cc: Chandra Sekhar Anagani <chandra.sekhar.anagani@intel.com>; Bruce
>> >> Ashfield <bruce.ashfield@windriver.com>; Bin Gao <bin.gao@intel.com>;
>> >> Pranav Tipnis <pranav.tipnis@intel.com>; Heikki Krogerus
>> >> <heikki.krogerus@linux.intel.com>; linux-kernel@vger.kernel.org;
>> >> linux- usb@vger.kernel.org; Guenter Roeck <groeck@chromium.org>
>> >> Subject: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager
>> >> (tcpm)
>> >>
>> >> This driver implements the USB Type-C Power Delivery state machine
>> >> for both source and sink ports. Alternate mode support is not fully
>> >> implemented.
>> >>
>> >> The driver attaches to the USB Type-C class code implemented in the
>> >> following patches.
>> >>
>> >> usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY
>> >> usb: USB Type-C connector class
>> >>
>> >> This driver only implements the state machine. Lower level drivers
>> >> are responsible for
>> >> - Reporting VBUS status and activating VBUS
>> >> - Setting CC lines and providing CC line status
>> >> - Setting line polarity
>> >> - Activating and deactivating VCONN
>> >> - Setting the current limit
>> >> - Activating and deactivating PD message transfers
>> >> - Sending and receiving PD messages
>> >>
>> >> The driver provides both a functional API as well as callbacks for
>> >> lower level drivers.
>> >>
>> >> Signed-off-by: Guenter Roeck <groeck@chromium.org>
>> >> ---
>> >> v3:
>> >> - Improve TCPM state machine resiliency if there are spurious CC line
>> >> changes
>> >> while the state machine is in a transient change (waiting for a
>> >> timeout)
>> >> - Update current limit after CC voltage level changes on a port which
>> >> is not
>> >> PD capable.
>> >>
>> >> v2:
>> >> - Only update polarity if setting it was successful
>> >> If setting the CC line polarity in the driver was not successful,
>> >> don't update the internal polarity state.
>> >> - All PD messages are little endian; convert to and from CPU endianness.
>> >> - Avoid comparisons against NULL.
>> >> - Use u8/u16/u32 instead of uint8_t/uint16_t/uint32_t consistently.
>> >> - Callbacks into tcpm need to be lockless to avoid timing problems
>> >> in low level drivers.
>> >> - Simplify callbacks; tcpm can request the current state of cc/vbus
>> >> when it is ready to use it.
>> >>
>> >> drivers/usb/typec/Kconfig | 7 +
>> >> drivers/usb/typec/Makefile | 1 +
>> >> drivers/usb/typec/tcpm.c | 3163
>> >> ++++++++++++++++++++++++++++++++++++++++++++
>> >> drivers/usb/typec/tcpm.h | 137 ++
>> >> include/linux/usb/pd.h | 282 ++++
>> >> include/linux/usb/pd_bdo.h | 31 +
>> >> include/linux/usb/pd_vdo.h | 412 ++++++
>> >> 7 files changed, 4033 insertions(+)
>> >> create mode 100644 drivers/usb/typec/tcpm.c create mode 100644
>> >> drivers/usb/typec/tcpm.h create mode 100644 include/linux/usb/pd.h
>> >> create mode 100644 include/linux/usb/pd_bdo.h create mode 100644
>> >> include/linux/usb/pd_vdo.h
>> >>
>> >
>> > ...
>> >
>> >> +
>> >> +static void run_state_machine(struct tcpm_port *port) {
>> >> + int ret;
>> >> +
>> >> + port->enter_state = port->state;
>> >> + switch (port->state) {
>> >> + /* SRC states */
>> >> + case SRC_UNATTACHED:
>> >> + tcpm_swap_complete(port, -ENOTCONN);
>> >> + tcpm_src_detach(port);
>> >> + tcpm_set_cc(port, TYPEC_CC_RP_DEF);
>> >> + if (port->typec_caps.type == TYPEC_PORT_DRP)
>> >> + tcpm_set_state(port, SNK_UNATTACHED,
>> >> + PD_T_DRP_SNK);
>> >
>> > With this and below, after disconnect, the DRP port state machine will
>> > be in infinite loop of state transition between SRC_UNATTACHED <-->
>> > SNK_UNATTACHED, correct?
>> >
>>
>> Only while disconnected. It tries to alternatively connect as source and
>> as sink (being configured as DRP). Once a CC line state change is reported
>> it will transition out. I have a newer version of the patch (not yet
>> published) which supports DRP toggling by the TCPC. With that enabled,
>> TCPM does not change states until a CC state change is reported.
>>
> Great, that way will be better, do you plan post your newer patch recently?
>
I should be able to send out a new version early next week, after
applying and testing your suggested changes. I'll also try to make a
test branch available in my repository at kernel.org.
Guenter
> Thanks
> Li Jun
>
>> Guenter
>>
>> > Li Jun
>> > ...
>> >
>> >> + /* SNK states */
>> >> + case SNK_UNATTACHED:
>> >> + tcpm_swap_complete(port, -ENOTCONN);
>> >> + tcpm_snk_detach(port);
>> >> + tcpm_set_cc(port, TYPEC_CC_RD);
>> >> + if (port->typec_caps.type == TYPEC_PORT_DRP)
>> >> + tcpm_set_state(port, SRC_UNATTACHED,
>> PD_T_DRP_SRC);
>> >> + break;
>> >>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web