Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, On Tue, Aug 23, 2016 at 02:10:50PM -0700, Guenter Roeck wrote: > +config TYPEC_TCPM > + tristate "USB Type-C Port Controller Manager" > + select TYPEC > + help > + The Type-C Port Controller Manager provides a USB PD and USB Type-C > + state machine for use with Type-C Port Controllers. Since this is "tristate", don't forget to add MODULE_*() stuff in the next version. Thanks, -- heikki
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, On Tue, Aug 23, 2016 at 02:10:50PM -0700, Guenter Roeck wrote: > +config TYPEC_TCPM > + tristate "USB Type-C Port Controller Manager" > + select TYPEC > + help > + The Type-C Port Controller Manager provides a USB PD and USB Type-C > + state machine for use with Type-C Port Controllers. Since this is "tristate", don't forget to add MODULE_*() stuff in the next version. Thanks, -- heikki
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, 2016-09-30 at 13:57 -0700, Guenter Roeck wrote: > Code now looks as follows. > > #define PDO_VAR_MIN_VOLT(mv) mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ > PDO_VAR_MIN_VOLT_SHIFT) > #define PDO_VAR_MAX_VOLT(mv) mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ > PDO_VAR_MAX_VOLT_SHIFT) > #define PDO_VAR_MAX_CURR(ma) ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ > PDO_VAR_MAX_CURR_SHIFT) When #defines are continued, I generally find it nicer to have the entire definition on a separate line #define PDO_VAR_MIN_VOLT(mv)\ mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) > Though maybe I should just ignore line length limits or use shorter defines. When it makes sense, yes please.
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, 2016-09-30 at 13:57 -0700, Guenter Roeck wrote: > Code now looks as follows. > > #define PDO_VAR_MIN_VOLT(mv) mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ > PDO_VAR_MIN_VOLT_SHIFT) > #define PDO_VAR_MAX_VOLT(mv) mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ > PDO_VAR_MAX_VOLT_SHIFT) > #define PDO_VAR_MAX_CURR(ma) ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ > PDO_VAR_MAX_CURR_SHIFT) When #defines are continued, I generally find it nicer to have the entire definition on a separate line #define PDO_VAR_MIN_VOLT(mv)\ mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) > Though maybe I should just ignore line length limits or use shorter defines. When it makes sense, yes please.
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, Sep 30, 2016 at 12:41 PM, Joe Percheswrote: > On Fri, 2016-09-30 at 12:06 -0700, Guenter Roeck wrote: >> On Thu, Sep 29, 2016 at 11:37 PM, Jun Li wrote: > [] >> > diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h > [] >> > +#define PDO_VAR(min_mv, max_mv, max_ma) >> >\ >> > + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ >> > + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ >> > + PDO_VAR_MIN_VOLT_SHIFT) | \ >> > + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ >> > + PDO_VAR_MAX_VOLT_SHIFT) | \ >> > + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ >> >> >> max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ > > This would be easier to read if laid out differently. > > #define PDO_VAR(min_mv, max_mv, max_ma) > \ > ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | > \ > min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << > PDO_VAR_MIN_VOLT_SHIFT) |\ > max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << > PDO_VAR_MAX_VOLT_SHIFT) |\ > max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << > PDO_VAR_MAX_CURR_SHIFT)) > Code now looks as follows. #define PDO_VAR_MIN_VOLT(mv) mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ PDO_VAR_MIN_VOLT_SHIFT) #define PDO_VAR_MAX_VOLT(mv) mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ PDO_VAR_MAX_VOLT_SHIFT) #define PDO_VAR_MAX_CURR(ma) ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ PDO_VAR_MAX_CURR_SHIFT) #define PDO_VAR(min_mv, max_mv, max_ma) \ (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) |\ PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma)) Though maybe I should just ignore line length limits or use shorter defines. Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, Sep 30, 2016 at 12:41 PM, Joe Perches wrote: > On Fri, 2016-09-30 at 12:06 -0700, Guenter Roeck wrote: >> On Thu, Sep 29, 2016 at 11:37 PM, Jun Li wrote: > [] >> > diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h > [] >> > +#define PDO_VAR(min_mv, max_mv, max_ma) >> >\ >> > + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ >> > + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ >> > + PDO_VAR_MIN_VOLT_SHIFT) | \ >> > + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ >> > + PDO_VAR_MAX_VOLT_SHIFT) | \ >> > + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ >> >> >> max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ > > This would be easier to read if laid out differently. > > #define PDO_VAR(min_mv, max_mv, max_ma) > \ > ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | > \ > min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << > PDO_VAR_MIN_VOLT_SHIFT) |\ > max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << > PDO_VAR_MAX_VOLT_SHIFT) |\ > max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << > PDO_VAR_MAX_CURR_SHIFT)) > Code now looks as follows. #define PDO_VAR_MIN_VOLT(mv) mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ PDO_VAR_MIN_VOLT_SHIFT) #define PDO_VAR_MAX_VOLT(mv) mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ PDO_VAR_MAX_VOLT_SHIFT) #define PDO_VAR_MAX_CURR(ma) ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ PDO_VAR_MAX_CURR_SHIFT) #define PDO_VAR(min_mv, max_mv, max_ma) \ (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) |\ PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma)) Though maybe I should just ignore line length limits or use shorter defines. Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, 2016-09-30 at 12:06 -0700, Guenter Roeck wrote: > On Thu, Sep 29, 2016 at 11:37 PM, Jun Liwrote: [] > > diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h [] > > +#define PDO_VAR(min_mv, max_mv, max_ma) > > \ > > + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ > > + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ > > + PDO_VAR_MIN_VOLT_SHIFT) | \ > > + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ > > + PDO_VAR_MAX_VOLT_SHIFT) | \ > > + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ > > > max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ This would be easier to read if laid out differently. #define PDO_VAR(min_mv, max_mv, max_ma) \ ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) |\ max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) |\ max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT))
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, 2016-09-30 at 12:06 -0700, Guenter Roeck wrote: > On Thu, Sep 29, 2016 at 11:37 PM, Jun Li wrote: [] > > diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h [] > > +#define PDO_VAR(min_mv, max_mv, max_ma) > > \ > > + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ > > + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ > > + PDO_VAR_MIN_VOLT_SHIFT) | \ > > + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ > > + PDO_VAR_MAX_VOLT_SHIFT) | \ > > + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ > > > max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ This would be easier to read if laid out differently. #define PDO_VAR(min_mv, max_mv, max_ma) \ ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) |\ max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) |\ max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT))
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Thu, Sep 29, 2016 at 11:37 PM, Jun Liwrote: > Hi Guenter, >> -Original Message- >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> Sent: Wednesday, August 24, 2016 5:11 AM >> To: Felipe Balbi >> Cc: Chandra Sekhar Anagani ; Bruce >> Ashfield ; Bin Gao ; >> Pranav Tipnis ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org; Guenter Roeck >> Subject: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) >> > ... >> diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h >> new file mode 100644 >> index ..6b1679af7a25 >> --- /dev/null >> +++ b/include/linux/usb/pd.h > > ... > >> +#define PDO_VAR(min_mv, max_mv, max_ma) >> \ >> + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ >> + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ >> + PDO_VAR_MIN_VOLT_SHIFT) | \ >> + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ >> + PDO_VAR_MAX_VOLT_SHIFT) | \ >> + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ > > max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ > Thanks, fixed. PDO_BATT has a similar problem, which I noticed while fixing the above. Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Thu, Sep 29, 2016 at 11:37 PM, Jun Li wrote: > Hi Guenter, >> -Original Message- >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> Sent: Wednesday, August 24, 2016 5:11 AM >> To: Felipe Balbi >> Cc: Chandra Sekhar Anagani ; Bruce >> Ashfield ; Bin Gao ; >> Pranav Tipnis ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org; Guenter Roeck >> Subject: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) >> > ... >> diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h >> new file mode 100644 >> index ..6b1679af7a25 >> --- /dev/null >> +++ b/include/linux/usb/pd.h > > ... > >> +#define PDO_VAR(min_mv, max_mv, max_ma) >> \ >> + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ >> + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ >> + PDO_VAR_MIN_VOLT_SHIFT) | \ >> + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ >> + PDO_VAR_MAX_VOLT_SHIFT) | \ >> + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ > > max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ > Thanks, fixed. PDO_BATT has a similar problem, which I noticed while fixing the above. Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Thu, Sep 29, 2016 at 11:41 PM, Jun Li <jun...@nxp.com> wrote: > Hi, > >> -Original Message- >> From: Guenter Roeck [mailto:gro...@google.com] >> Sent: Friday, September 30, 2016 12:37 AM >> To: Jun Li <jun...@nxp.com> >> Cc: Guenter Roeck <gro...@chromium.org>; Felipe Balbi >> <felipe.ba...@linux.intel.com>; Chandra Sekhar Anagani >> <chandra.sekhar.anag...@intel.com>; Bruce Ashfield >> <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; Pranav Tipnis >> <pranav.tip...@intel.com>; Heikki Krogerus >> <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; linux- >> u...@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...@nxp.com> wrote: >> > Hi Guenter, >> > >> >> -Original Message- >> >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> >> Sent: Wednesday, August 24, 2016 5:11 AM >> >> To: Felipe Balbi <felipe.ba...@linux.intel.com> >> >> Cc: Chandra Sekhar Anagani <chandra.sekhar.anag...@intel.com>; Bruce >> >> Ashfield <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; >> >> Pranav Tipnis <pranav.tip...@intel.com>; Heikki Krogerus >> >> <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; >> >> linux- u...@vger.kernel.org; Guenter Roeck <gro...@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 <gro...@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 >
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Thu, Sep 29, 2016 at 11:41 PM, Jun Li wrote: > Hi, > >> -Original Message- >> From: Guenter Roeck [mailto:gro...@google.com] >> Sent: Friday, September 30, 2016 12:37 AM >> To: Jun Li >> Cc: Guenter Roeck ; Felipe Balbi >> ; Chandra Sekhar Anagani >> ; Bruce Ashfield >> ; Bin Gao ; Pranav Tipnis >> ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@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 wrote: >> > Hi Guenter, >> > >> >> -Original Message- >> >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> >> Sent: Wednesday, August 24, 2016 5:11 AM >> >> To: Felipe Balbi >> >> Cc: Chandra Sekhar Anagani ; Bruce >> >> Ashfield ; Bin Gao ; >> >> Pranav Tipnis ; Heikki Krogerus >> >> ; linux-kernel@vger.kernel.org; >> >> linux- u...@vger.kernel.org; Guenter Roeck >> >> 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 >> >> --- >> >> 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: >> >> +
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi, > -Original Message- > From: Guenter Roeck [mailto:gro...@google.com] > Sent: Friday, September 30, 2016 12:37 AM > To: Jun Li <jun...@nxp.com> > Cc: Guenter Roeck <gro...@chromium.org>; Felipe Balbi > <felipe.ba...@linux.intel.com>; Chandra Sekhar Anagani > <chandra.sekhar.anag...@intel.com>; Bruce Ashfield > <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; Pranav Tipnis > <pranav.tip...@intel.com>; Heikki Krogerus > <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; linux- > u...@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...@nxp.com> wrote: > > Hi Guenter, > > > >> -Original Message- > >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck > >> Sent: Wednesday, August 24, 2016 5:11 AM > >> To: Felipe Balbi <felipe.ba...@linux.intel.com> > >> Cc: Chandra Sekhar Anagani <chandra.sekhar.anag...@intel.com>; Bruce > >> Ashfield <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; > >> Pranav Tipnis <pranav.tip...@intel.com>; Heikki Krogerus > >> <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; > >> linux- u...@vger.kernel.org; Guenter Roeck <gro...@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 <gro...@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) { > >> +
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi, > -Original Message- > From: Guenter Roeck [mailto:gro...@google.com] > Sent: Friday, September 30, 2016 12:37 AM > To: Jun Li > Cc: Guenter Roeck ; Felipe Balbi > ; Chandra Sekhar Anagani > ; Bruce Ashfield > ; Bin Gao ; Pranav Tipnis > ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@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 wrote: > > Hi Guenter, > > > >> -Original Message- > >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck > >> Sent: Wednesday, August 24, 2016 5:11 AM > >> To: Felipe Balbi > >> Cc: Chandra Sekhar Anagani ; Bruce > >> Ashfield ; Bin Gao ; > >> Pranav Tipnis ; Heikki Krogerus > >> ; linux-kernel@vger.kernel.org; > >> linux- u...@vger.kernel.org; Guenter Roeck > >> 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 > >> --- > >> 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
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Guenter Roeck > Sent: Wednesday, August 24, 2016 5:11 AM > To: Felipe Balbi> Cc: Chandra Sekhar Anagani ; Bruce > Ashfield ; Bin Gao ; > Pranav Tipnis ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org; Guenter Roeck > Subject: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) > ... > diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h > new file mode 100644 > index ..6b1679af7a25 > --- /dev/null > +++ b/include/linux/usb/pd.h ... > +#define PDO_VAR(min_mv, max_mv, max_ma) > \ > + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ > + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ > + PDO_VAR_MIN_VOLT_SHIFT) | \ > + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ > + PDO_VAR_MAX_VOLT_SHIFT) | \ > + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ Li Jun
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Guenter Roeck > Sent: Wednesday, August 24, 2016 5:11 AM > To: Felipe Balbi > Cc: Chandra Sekhar Anagani ; Bruce > Ashfield ; Bin Gao ; > Pranav Tipnis ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org; Guenter Roeck > Subject: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) > ... > diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h > new file mode 100644 > index ..6b1679af7a25 > --- /dev/null > +++ b/include/linux/usb/pd.h ... > +#define PDO_VAR(min_mv, max_mv, max_ma) > \ > + ((PDO_TYPE_VAR << PDO_TYPE_SHIFT) | \ > + min_mv) / 50) & PDO_VAR_MIN_VOLT_MASK) << \ > + PDO_VAR_MIN_VOLT_SHIFT) | \ > + max_mv) / 50) & PDO_VAR_MAX_VOLT_MASK) << \ > + PDO_VAR_MAX_VOLT_SHIFT) | \ > + max_ma) / 50) & PDO_VAR_MAX_CURR_MASK) << \ max_ma) / 10) & PDO_VAR_MAX_CURR_MASK) << \ Li Jun
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Guenter Roeck > Sent: Wednesday, August 24, 2016 5:11 AM > To: Felipe Balbi> Cc: Chandra Sekhar Anagani ; Bruce > Ashfield ; Bin Gao ; > Pranav Tipnis ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org; Guenter Roeck > 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 > --- > 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? 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; >
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Guenter Roeck > Sent: Wednesday, August 24, 2016 5:11 AM > To: Felipe Balbi > Cc: Chandra Sekhar Anagani ; Bruce > Ashfield ; Bin Gao ; > Pranav Tipnis ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org; Guenter Roeck > 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 > --- > 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? 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; >
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Thu, Sep 29, 2016 at 7:35 AM, Jun Liwrote: > Hi Guenter, > >> -Original Message- >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> Sent: Wednesday, August 24, 2016 5:11 AM >> To: Felipe Balbi >> Cc: Chandra Sekhar Anagani ; Bruce >> Ashfield ; Bin Gao ; >> Pranav Tipnis ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org; Guenter Roeck >> 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 >> --- >> 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; >>
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 wrote: > Hi Guenter, > >> -Original Message- >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> Sent: Wednesday, August 24, 2016 5:11 AM >> To: Felipe Balbi >> Cc: Chandra Sekhar Anagani ; Bruce >> Ashfield ; Bin Gao ; >> Pranav Tipnis ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org; Guenter Roeck >> 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 >> --- >> 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; >>
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter > -Original Message- > From: Guenter Roeck [mailto:gro...@google.com] > Sent: Saturday, September 10, 2016 10:23 AM > To: Jun Li <jun...@nxp.com> > Cc: Guenter Roeck <gro...@chromium.org>; Felipe Balbi > <felipe.ba...@linux.intel.com>; Chandra Sekhar Anagani > <chandra.sekhar.anag...@intel.com>; Bruce Ashfield > <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; Pranav Tipnis > <pranav.tip...@intel.com>; Heikki Krogerus > <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org > Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) > > On Fri, Sep 9, 2016 at 5:26 PM, Jun Li <jun...@nxp.com> wrote: > > Hi Guenter, > > > >> -Original Message- > >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck > >> Sent: Wednesday, August 24, 2016 5:11 AM > >> To: Felipe Balbi <felipe.ba...@linux.intel.com> > >> Cc: Chandra Sekhar Anagani <chandra.sekhar.anag...@intel.com>; Bruce > >> Ashfield <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; > >> Pranav Tipnis <pranav.tip...@intel.com>; Heikki Krogerus > >> <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; > >> linux- u...@vger.kernel.org; Guenter Roeck <gro...@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 <gro...@chromium.org> > >> --- > > > > A specific question, if power sink wants to request a new power level > > after SNK_READY, how to handle it with this tcpm? > > > > So far I have considered the required power level to be static, based on > our curent implementations. That should be easy to change, though, with an > additional API function, to be called from a low level driver. > Do you have that requirement, and would such a function meet your needs ? > So you are going to make port->tcpc->config to be dynamic to meet my need? Li Jun > Thanks, > Guenter
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter > -Original Message- > From: Guenter Roeck [mailto:gro...@google.com] > Sent: Saturday, September 10, 2016 10:23 AM > To: Jun Li > Cc: Guenter Roeck ; Felipe Balbi > ; Chandra Sekhar Anagani > ; Bruce Ashfield > ; Bin Gao ; Pranav Tipnis > ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org > Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) > > On Fri, Sep 9, 2016 at 5:26 PM, Jun Li wrote: > > Hi Guenter, > > > >> -Original Message- > >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck > >> Sent: Wednesday, August 24, 2016 5:11 AM > >> To: Felipe Balbi > >> Cc: Chandra Sekhar Anagani ; Bruce > >> Ashfield ; Bin Gao ; > >> Pranav Tipnis ; Heikki Krogerus > >> ; linux-kernel@vger.kernel.org; > >> linux- u...@vger.kernel.org; Guenter Roeck > >> 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 > >> --- > > > > A specific question, if power sink wants to request a new power level > > after SNK_READY, how to handle it with this tcpm? > > > > So far I have considered the required power level to be static, based on > our curent implementations. That should be easy to change, though, with an > additional API function, to be called from a low level driver. > Do you have that requirement, and would such a function meet your needs ? > So you are going to make port->tcpc->config to be dynamic to meet my need? Li Jun > Thanks, > Guenter
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
> -Original Message- > From: Guenter Roeck [mailto:gro...@google.com] > Sent: Monday, September 12, 2016 10:24 AM > To: Jun Li <jun...@nxp.com> > Cc: Guenter Roeck <gro...@chromium.org>; Felipe Balbi > <felipe.ba...@linux.intel.com>; Chandra Sekhar Anagani > <chandra.sekhar.anag...@intel.com>; Bruce Ashfield > <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; Pranav Tipnis > <pranav.tip...@intel.com>; Heikki Krogerus > <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org > Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) > > On Sun, Sep 11, 2016 at 7:16 PM, Jun Li <jun...@nxp.com> wrote: > > Hi Guenter > > > >> -Original Message- > >> From: Guenter Roeck [mailto:gro...@google.com] > >> Sent: Saturday, September 10, 2016 10:23 AM > >> To: Jun Li <jun...@nxp.com> > >> Cc: Guenter Roeck <gro...@chromium.org>; Felipe Balbi > >> <felipe.ba...@linux.intel.com>; Chandra Sekhar Anagani > >> <chandra.sekhar.anag...@intel.com>; Bruce Ashfield > >> <bruce.ashfi...@windriver.com>; Bin Gao <bin....@intel.com>; Pranav > >> Tipnis <pranav.tip...@intel.com>; Heikki Krogerus > >> <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; > >> linux- u...@vger.kernel.org > >> Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager > >> (tcpm) > >> > >> On Fri, Sep 9, 2016 at 5:26 PM, Jun Li <jun...@nxp.com> wrote: > >> > Hi Guenter, > >> > > >> >> -Original Message- > >> >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > >> >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck > >> >> Sent: Wednesday, August 24, 2016 5:11 AM > >> >> To: Felipe Balbi <felipe.ba...@linux.intel.com> > >> >> Cc: Chandra Sekhar Anagani <chandra.sekhar.anag...@intel.com>; > >> >> Bruce Ashfield <bruce.ashfi...@windriver.com>; Bin Gao > >> >> <bin@intel.com>; Pranav Tipnis <pranav.tip...@intel.com>; > >> >> Heikki Krogerus <heikki.kroge...@linux.intel.com>; > >> >> linux-kernel@vger.kernel.org; > >> >> linux- u...@vger.kernel.org; Guenter Roeck <gro...@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 <gro...@chromium.org> > >> >> --- > >> > > >> > A specific question, if power sink wants to request a new power > >> > level after SNK_READY, how to handle it with this tcpm? > >> > > >> > >> So far I have considered the required power level to be static, based > >> on our curent implementations. That should be easy to change, though, > >> with an additional API function, to be called from a low level driver. > >> Do you have that requirement, and would such a function meet your > needs ? > >> > > > > So you are going to make port->tcpc->config to be dynamic to meet my > need? > > > What would that help ? How would tcpm get informed that the power > requirements changed without an API function telling it that power > requirements changed ? Of cos I agree an additional API is required, I am just wondering how that API will be look like, as current request build is according to port->tcpc->config. Li Jun > > Guenter
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
> -Original Message- > From: Guenter Roeck [mailto:gro...@google.com] > Sent: Monday, September 12, 2016 10:24 AM > To: Jun Li > Cc: Guenter Roeck ; Felipe Balbi > ; Chandra Sekhar Anagani > ; Bruce Ashfield > ; Bin Gao ; Pranav Tipnis > ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org > Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) > > On Sun, Sep 11, 2016 at 7:16 PM, Jun Li wrote: > > Hi Guenter > > > >> -Original Message- > >> From: Guenter Roeck [mailto:gro...@google.com] > >> Sent: Saturday, September 10, 2016 10:23 AM > >> To: Jun Li > >> Cc: Guenter Roeck ; Felipe Balbi > >> ; Chandra Sekhar Anagani > >> ; Bruce Ashfield > >> ; Bin Gao ; Pranav > >> Tipnis ; Heikki Krogerus > >> ; linux-kernel@vger.kernel.org; > >> linux- u...@vger.kernel.org > >> Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager > >> (tcpm) > >> > >> On Fri, Sep 9, 2016 at 5:26 PM, Jun Li wrote: > >> > Hi Guenter, > >> > > >> >> -Original Message- > >> >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > >> >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck > >> >> Sent: Wednesday, August 24, 2016 5:11 AM > >> >> To: Felipe Balbi > >> >> Cc: Chandra Sekhar Anagani ; > >> >> Bruce Ashfield ; Bin Gao > >> >> ; Pranav Tipnis ; > >> >> Heikki Krogerus ; > >> >> linux-kernel@vger.kernel.org; > >> >> linux- u...@vger.kernel.org; Guenter Roeck > >> >> 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 > >> >> --- > >> > > >> > A specific question, if power sink wants to request a new power > >> > level after SNK_READY, how to handle it with this tcpm? > >> > > >> > >> So far I have considered the required power level to be static, based > >> on our curent implementations. That should be easy to change, though, > >> with an additional API function, to be called from a low level driver. > >> Do you have that requirement, and would such a function meet your > needs ? > >> > > > > So you are going to make port->tcpc->config to be dynamic to meet my > need? > > > What would that help ? How would tcpm get informed that the power > requirements changed without an API function telling it that power > requirements changed ? Of cos I agree an additional API is required, I am just wondering how that API will be look like, as current request build is according to port->tcpc->config. Li Jun > > Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Sun, Sep 11, 2016 at 7:16 PM, Jun Li <jun...@nxp.com> wrote: > Hi Guenter > >> -Original Message- >> From: Guenter Roeck [mailto:gro...@google.com] >> Sent: Saturday, September 10, 2016 10:23 AM >> To: Jun Li <jun...@nxp.com> >> Cc: Guenter Roeck <gro...@chromium.org>; Felipe Balbi >> <felipe.ba...@linux.intel.com>; Chandra Sekhar Anagani >> <chandra.sekhar.anag...@intel.com>; Bruce Ashfield >> <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; Pranav Tipnis >> <pranav.tip...@intel.com>; Heikki Krogerus >> <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org >> Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) >> >> On Fri, Sep 9, 2016 at 5:26 PM, Jun Li <jun...@nxp.com> wrote: >> > Hi Guenter, >> > >> >> -Original Message- >> >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> >> Sent: Wednesday, August 24, 2016 5:11 AM >> >> To: Felipe Balbi <felipe.ba...@linux.intel.com> >> >> Cc: Chandra Sekhar Anagani <chandra.sekhar.anag...@intel.com>; Bruce >> >> Ashfield <bruce.ashfi...@windriver.com>; Bin Gao <bin@intel.com>; >> >> Pranav Tipnis <pranav.tip...@intel.com>; Heikki Krogerus >> >> <heikki.kroge...@linux.intel.com>; linux-kernel@vger.kernel.org; >> >> linux- u...@vger.kernel.org; Guenter Roeck <gro...@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 <gro...@chromium.org> >> >> --- >> > >> > A specific question, if power sink wants to request a new power level >> > after SNK_READY, how to handle it with this tcpm? >> > >> >> So far I have considered the required power level to be static, based on >> our curent implementations. That should be easy to change, though, with an >> additional API function, to be called from a low level driver. >> Do you have that requirement, and would such a function meet your needs ? >> > > So you are going to make port->tcpc->config to be dynamic to meet my need? > What would that help ? How would tcpm get informed that the power requirements changed without an API function telling it that power requirements changed ? Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Sun, Sep 11, 2016 at 7:16 PM, Jun Li wrote: > Hi Guenter > >> -Original Message- >> From: Guenter Roeck [mailto:gro...@google.com] >> Sent: Saturday, September 10, 2016 10:23 AM >> To: Jun Li >> Cc: Guenter Roeck ; Felipe Balbi >> ; Chandra Sekhar Anagani >> ; Bruce Ashfield >> ; Bin Gao ; Pranav Tipnis >> ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org >> Subject: Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm) >> >> On Fri, Sep 9, 2016 at 5:26 PM, Jun Li wrote: >> > Hi Guenter, >> > >> >> -Original Message- >> >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> >> Sent: Wednesday, August 24, 2016 5:11 AM >> >> To: Felipe Balbi >> >> Cc: Chandra Sekhar Anagani ; Bruce >> >> Ashfield ; Bin Gao ; >> >> Pranav Tipnis ; Heikki Krogerus >> >> ; linux-kernel@vger.kernel.org; >> >> linux- u...@vger.kernel.org; Guenter Roeck >> >> 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 >> >> --- >> > >> > A specific question, if power sink wants to request a new power level >> > after SNK_READY, how to handle it with this tcpm? >> > >> >> So far I have considered the required power level to be static, based on >> our curent implementations. That should be easy to change, though, with an >> additional API function, to be called from a low level driver. >> Do you have that requirement, and would such a function meet your needs ? >> > > So you are going to make port->tcpc->config to be dynamic to meet my need? > What would that help ? How would tcpm get informed that the power requirements changed without an API function telling it that power requirements changed ? Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, Sep 9, 2016 at 5:26 PM, Jun Liwrote: > Hi Guenter, > >> -Original Message- >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> Sent: Wednesday, August 24, 2016 5:11 AM >> To: Felipe Balbi >> Cc: Chandra Sekhar Anagani ; Bruce >> Ashfield ; Bin Gao ; >> Pranav Tipnis ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org; Guenter Roeck >> 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 >> --- > > A specific question, if power sink wants to request a new power level > after SNK_READY, how to handle it with this tcpm? > So far I have considered the required power level to be static, based on our curent implementations. That should be easy to change, though, with an additional API function, to be called from a low level driver. Do you have that requirement, and would such a function meet your needs ? Thanks, Guenter
Re: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
On Fri, Sep 9, 2016 at 5:26 PM, Jun Li wrote: > Hi Guenter, > >> -Original Message- >> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- >> ow...@vger.kernel.org] On Behalf Of Guenter Roeck >> Sent: Wednesday, August 24, 2016 5:11 AM >> To: Felipe Balbi >> Cc: Chandra Sekhar Anagani ; Bruce >> Ashfield ; Bin Gao ; >> Pranav Tipnis ; Heikki Krogerus >> ; linux-kernel@vger.kernel.org; linux- >> u...@vger.kernel.org; Guenter Roeck >> 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 >> --- > > A specific question, if power sink wants to request a new power level > after SNK_READY, how to handle it with this tcpm? > So far I have considered the required power level to be static, based on our curent implementations. That should be easy to change, though, with an additional API function, to be called from a low level driver. Do you have that requirement, and would such a function meet your needs ? Thanks, Guenter
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Guenter Roeck > Sent: Wednesday, August 24, 2016 5:11 AM > To: Felipe Balbi> Cc: Chandra Sekhar Anagani ; Bruce > Ashfield ; Bin Gao ; > Pranav Tipnis ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org; Guenter Roeck > 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 > --- A specific question, if power sink wants to request a new power level after SNK_READY, how to handle it with this tcpm? Thanks Li Jun
RE: [RFC PATCH v3 1/2] usb: typec: USB Type-C Port Manager (tcpm)
Hi Guenter, > -Original Message- > From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb- > ow...@vger.kernel.org] On Behalf Of Guenter Roeck > Sent: Wednesday, August 24, 2016 5:11 AM > To: Felipe Balbi > Cc: Chandra Sekhar Anagani ; Bruce > Ashfield ; Bin Gao ; > Pranav Tipnis ; Heikki Krogerus > ; linux-kernel@vger.kernel.org; linux- > u...@vger.kernel.org; Guenter Roeck > 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 > --- A specific question, if power sink wants to request a new power level after SNK_READY, how to handle it with this tcpm? Thanks Li Jun