staging: typec: tcpm: Drop commented out code
Subsystems (4)
PATCH 1/5 staging: typec: tcpm: Drop commented out code
Commented out code can be added as needed. Drop it. Also drop TODO and an obsolete XXX comment.
--- drivers/staging/typec/tcpm.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
drivers/staging/typec/tcpm.c +1 -36
@@ -908,27 +908,6 @@ static void svdm_consume_identity(struct tcpm_port *port, const __le32 *payload,memset (&port->mode_data,0 ,sizeof (port->mode_data)); -#if 0 /* Not really a match */ -switch (PD_IDH_PTYPE (vdo)) { -case IDH_PTYPE_UNDEF : - port->partner.type =TYPEC_PARTNER_NONE ;/* no longer exists */ -break ; -case IDH_PTYPE_HUB : -break ; -case IDH_PTYPE_PERIPH : -break ; -case IDH_PTYPE_PCABLE : -break ; -case IDH_PTYPE_ACABLE : -break ; -case IDH_PTYPE_AMA : - port->partner.type =TYPEC_PARTNER_ALTMODE ; -break ; -default : -break ; - } -#endif - port->partner_ident.id_header = vdo; port->partner_ident.cert_stat =le32_to_cpu (payload[VDO_INDEX_CSTAT ]); port->partner_ident.product = product;
@@ -1103,11 +1082,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, response[0 ] =VDO (svid,1 ,CMD_DISCOVER_MODES ); rlen =1 ; }else { -#if 0 - response[0 ] =pd_dfp_enter_mode (port,0 ,0 ); -if (response[0 ]) - rlen =1 ; -#endif +/* enter alternate mode if/when implemented */ }break ;case CMD_ENTER_MODE :
@@ -1145,10 +1120,6 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,if (PD_VDO_SVDM (p0)) rlen =tcpm_pd_svdm (port, payload, cnt, response); -#if 0 - else - rlen =tcpm_pd_custom_vdm (port, cnt, payload, response); -#endif if (rlen >0 ) {tcpm_queue_vdm (port, response[0 ], &response[1 ], rlen -1 );
@@ -2442,7 +2413,6 @@ static void run_state_machine(struct tcpm_port *port)tcpm_set_state (port,SNK_STARTUP ,0 );break ;case SNK_STARTUP : -/* XXX: callback into infrastructure */ opmode =tcpm_get_pwr_opmode (port->polarity ? port->cc2 : port->cc1);typec_set_pwr_opmode (port->typec_port, opmode);
@@ -3589,11 +3559,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) port->partner_desc.identity = &port->partner_ident; port->port_type = tcpc->config->type; -/* -* TODO: -* - alt_modes, set_alt_mode -* - {debug,audio}_accessory -*/ port->typec_port =typec_register_port (port->dev, &port->typec_caps);if (!port->typec_port) {
Signature · 1 line
2.7.4
PATCH 2/5 staging: typec: tcpm: Document data structures
Document struct tcpc_config and struct tcpc_dev.
Drop unused TCPC_USB_SWITCH_RESTORE.
--- drivers/staging/typec/tcpm.h | 57 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)
drivers/staging/typec/tcpm.h +50 -7
@@ -54,6 +54,27 @@ enum tcpm_transmit_type {TCPC_TX_BIST_MODE_2 =7 }; +/** +* struct tcpc_config - Port configuration +* @src_pdo: PDO parameters sent to port partner as response to +* PD_CTRL_GET_SOURCE_CAP message +* @nr_src_pdo: Number of entries in @src_pdo +* @snk_pdo: PDO parameters sent to partner as response to +* PD_CTRL_GET_SINK_CAP message +* @nr_snk_pdo: Number of entries in @snk_pdo +* @max_snk_mv: Maximum acceptable sink voltage in mV +* @max_snk_ma: Maximum sink current in mA +* @max_snk_mw: Maximum required sink power in mW +* @operating_snk_mw: +* Required operating sink power in mW +* @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or +* TYPEC_PORT_DRP) +* @default_role: +* Default port role (TYPEC_SINK or TYPEC_SOURCE). +* Set to TYPEC_NO_PREFERRED_ROLE if no default role. +* @try_role_hw:True if try.{Src,Snk} is implemented in hardware +* @alt_modes: List of supported alternate modes +*/ struct tcpc_config {const u32 *src_pdo;unsigned int nr_src_pdo;
@@ -79,7 +100,6 @@ struct tcpc_config {enum tcpc_usb_switch {TCPC_USB_SWITCH_CONNECT ,TCPC_USB_SWITCH_DISCONNECT , -TCPC_USB_SWITCH_RESTORE ,/* TODO FIXME */ };/* Mux state attributes */
@@ -104,17 +124,40 @@ struct tcpc_mux_dev {void *priv_data; }; +/** +* struct tcpc_dev - Port configuration and callback functions +* @config: Pointer to port configuration +* @get_vbus: Called to read current VBUS state +* @get_current_limit: +* Optional; called by the tcpm core when configured as a snk +* and cc=Rp-def. This allows the tcpm to provide a fallback +* current-limit detection method for the cc=Rp-def case. +* For example, some tcpcs may include BC1.2 charger detection +* and use that in this case. +* @set_cc: Called to set value of CC pins +* @get_cc: Called to read current CC pin values +* @set_polarity: +* Called to set polarity +* @set_vconn: Called to enable or disable VCONN +* @set_vbus: Called to enable or disable VBUS +* @set_current_limit: +* Optional; called to set current limit as negotiated +* with partner. +* @set_pd_rx: Called to enable or disable reception of PD messages +* @set_roles: Called to set power and data roles +* @start_drp_toggling: +* Optional; if supported by hardware, called to start DRP +* toggling. DRP toggling is stopped automatically if +* a connection is established. +* @try_role: Optional; called to set a preferred role +* @pd_transmit:Called to transmit PD message +* @mux: Pointer to multiplexer data +*/ struct tcpc_dev {const struct tcpc_config *config;int (*init)(struct tcpc_dev *dev);int (*get_vbus)(struct tcpc_dev *dev); -/* -* This optional callback gets called by the tcpm core when configured -* as a snk and cc=Rp-def. This allows the tcpm to provide a fallback -* current-limit detection method for the cc=Rp-def case. E.g. some -* tcpcs may include BC1.2 charger detection and use that in this case. -*/ int (*get_current_limit)(struct tcpc_dev *dev);int (*set_cc)(struct tcpc_dev *dev,enum typec_cc_status cc); int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1,
Signature · 1 line
2.7.4
PATCH 3/5 staging: typec: pd: Document struct pd_message
In reply to Guenter Roeckstruct pd_message is the format of a PD message as seen on the wire.
--- drivers/staging/typec/pd.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/staging/typec/pd.h +5 -0
@@ -104,6 +104,11 @@ static inline unsigned int pd_header_msgid_le(__le16 header)#define PD_MAX_PAYLOAD 7 +/* +* struct pd_message - PD message as seen on wire +* @header: PD message header +* @payload: PD message payload +*/ struct pd_message {__le16 header;__le32 payload[PD_MAX_PAYLOAD ];
Signature · 1 line
2.7.4
Re: [PATCH 3/5] staging: typec: pd: Document struct pd_message
Hello.
Quoted 12 lines · Guenter Roeck
struct
pd_messageis the format of a PD message as seen on the wire.Signed-off-by Guenter Roeck <[email protected]>--- drivers/staging/typec/pd.h | 5 +++++ 1 file changed, 5 insertions(+)drivers/staging/typec/pd.h +0
-0
drivers/staging/typec/pd.h static inline unsigned int pd_header_msgid_le(__le16 header) · line 107
Quoted 4 lines
drivers/staging/typec/pd.h +1
-0@@ -104,6 +104,11 @@ static inline unsigned int pd_header_msgid_le(__le16 header)#define PD_MAX_PAYLOAD 7 +/*
The kernel-doc comments (to which this comment looks alike) should start
with /**.
drivers/staging/typec/pd.h static inline unsigned int pd_header_msgid_le(__le16 header) · line 114
Quoted 7 lines
drivers/staging/typec/pd.h +4
-0+* struct pd_message - PD message as seen on wire +* @header: PD message header +* @payload: PD message payload +*/ struct pd_message {__le16 header;__le32 payload[PD_MAX_PAYLOAD ];
MBR, Sergei
PATCH 4/5 typec: tcpm: Move out of staging
In reply to Guenter RoeckMove tcpm (USB Type-C Port Manager) out of staging.
--- drivers/staging/typec/Kconfig | 8 - drivers/staging/typec/Makefile | 1 - drivers/staging/typec/TODO | 10 - drivers/staging/typec/fusb302/fusb302.c | 4 +- drivers/staging/typec/pd.h | 298 --- drivers/staging/typec/pd_bdo.h | 31 - drivers/staging/typec/pd_vdo.h | 251 --- drivers/staging/typec/tcpci.c | 4 +- drivers/staging/typec/tcpm.c | 3616 ------------------------------- drivers/staging/typec/tcpm.h | 204 -- drivers/usb/typec/Kconfig | 8 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/tcpm.c | 3615 ++++++++++++++++++++++++++++++ include/linux/usb/pd.h | 298 +++ include/linux/usb/pd_bdo.h | 31 + include/linux/usb/pd_vdo.h | 251 +++ include/linux/usb/tcpm.h | 204 ++ 17 files changed, 4412 insertions(+), 4423 deletions(-) delete mode 100644 drivers/staging/typec/pd.h delete mode 100644 drivers/staging/typec/pd_bdo.h delete mode 100644 drivers/staging/typec/pd_vdo.h delete mode 100644 drivers/staging/typec/tcpm.c delete mode 100644 drivers/staging/typec/tcpm.h create mode 100644 drivers/usb/typec/tcpm.c 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 create mode 100644 include/linux/usb/tcpm.h
drivers/staging/typec/Kconfig +0 -8
@@ -1,13 +1,5 @@ menu "USB Power Delivery and Type-C drivers" -config TYPEC_TCPM - tristate "USB Type-C Port Controller Manager" - depends on USB - 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. - if TYPEC_TCPM config TYPEC_TCPCI
drivers/staging/typec/Makefile +0 -1
@@ -1,3 +1,2 @@ -obj-$(CONFIG_TYPEC_TCPM) += tcpm.o obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o obj-y += fusb302/
drivers/staging/typec/TODO +0 -10
@@ -1,13 +1,3 @@ -tcpm: -- Add documentation (at the very least for the API to low level drivers) -- Split PD code into separate file -- Check if it makes sense to use tracepoints instead of debugfs for debug logs -- Implement Alternate Mode handling -- Address "#if 0" code if not addressed with the above -- Validate all comments marked with "XXX"; either address or remove comments -- Add support for USB PD 3.0. While not mandatory, at least fast role swap - as well as authentication support would be very desirable. - tcpci: - Test with real hardware
drivers/staging/typec/fusb302/fusb302.c +2 -2
@@ -37,11 +37,11 @@#include <linux/string.h> #include <linux/types.h> #include <linux/usb/typec.h> +#include <linux/usb/tcpm.h> +#include <linux/usb/pd.h> #include <linux/workqueue.h> #include "fusb302_reg.h" -#include "../tcpm.h" -#include "../pd.h" /* * When the device is SNK, BC_LVL interrupt is used to monitor cc pins
drivers/staging/typec/pd.h deleted +0 -298
298 lines not on this page · raw message
drivers/staging/typec/pd_bdo.h deleted +0 -31
@@ -1,31 +0,0 @@ -/* -* Copyright 2015-2017 Google, Inc -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ - -#ifndef __LINUX_USB_PD_BDO_H -#define __LINUX_USB_PD_BDO_H - -/* BDO : BIST Data Object */ -#define BDO_MODE_RECV (0 << 28) -#define BDO_MODE_TRANSMIT (1 << 28) -#define BDO_MODE_COUNTERS (2 << 28) -#define BDO_MODE_CARRIER0 (3 << 28) -#define BDO_MODE_CARRIER1 (4 << 28) -#define BDO_MODE_CARRIER2 (5 << 28) -#define BDO_MODE_CARRIER3 (6 << 28) -#define BDO_MODE_EYE (7 << 28) -#define BDO_MODE_TESTDATA (8 << 28) - -#define BDO_MODE_MASK (mode) ((mode) & 0xf0000000) - -#endif
drivers/staging/typec/pd_vdo.h deleted +0 -251
251 lines not on this page · raw message
drivers/staging/typec/tcpci.c +2 -2
@@ -20,11 +20,11 @@#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/regmap.h> +#include <linux/usb/pd.h> +#include <linux/usb/tcpm.h> #include <linux/usb/typec.h> -#include "pd.h" #include "tcpci.h" -#include "tcpm.h" #define PD_RETRY_COUNT 3
drivers/staging/typec/tcpm.c deleted +0 -3616
2,365 lines not on this page · raw message
drivers/staging/typec/tcpm.h deleted +0 -204
204 lines not on this page · raw message
drivers/usb/typec/tcpm.c new file +3615 -0
3,615 lines not on this page · raw message
include/linux/usb/pd.h new file +298 -0
298 lines not on this page · raw message
include/linux/usb/pd_vdo.h new file +251 -0
251 lines not on this page · raw message
include/linux/usb/tcpm.h new file +204 -0
204 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.4
Part of the diff is not shown here. View the raw message.
Re: [PATCH 4/5] typec: tcpm: Move out of staging
Quoted 1 line · Guenter Roeck
Move tcpm (USB Type-C Port Manager) out of staging.
git format-patch -M
Re: [PATCH 4/5] typec: tcpm: Move out of staging
Quoted 6 lines · Joe Perches
Quoted 1 line · Guenter Roeck
Move tcpm (USB Type-C Port Manager) out of staging.
git format-patch -M
Thanks - I'll resend but wait a bit for additional comments before I do.
Guenter
PATCH 5/5 usb: typec: fusb302: Move out of staging
In reply to Guenter RoeckThe driver is in good enough shape to be moved out of staging. Do it.
--- drivers/staging/typec/Kconfig | 2 - drivers/staging/typec/Makefile | 1 - drivers/staging/typec/fusb302/Kconfig | 7 - drivers/staging/typec/fusb302/Makefile | 1 - drivers/staging/typec/fusb302/TODO | 10 - drivers/staging/typec/fusb302/fusb302.c | 1947 --------------------------- drivers/staging/typec/fusb302/fusb302_reg.h | 186 --- drivers/usb/typec/Kconfig | 6 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/fusb302/Kconfig | 7 + drivers/usb/typec/fusb302/Makefile | 1 + drivers/usb/typec/fusb302/fusb302.c | 1947 +++++++++++++++++++++++++++ drivers/usb/typec/fusb302/fusb302_reg.h | 186 +++ 13 files changed, 2148 insertions(+), 2154 deletions(-) delete mode 100644 drivers/staging/typec/fusb302/Kconfig delete mode 100644 drivers/staging/typec/fusb302/Makefile delete mode 100644 drivers/staging/typec/fusb302/TODO delete mode 100644 drivers/staging/typec/fusb302/fusb302.c delete mode 100644 drivers/staging/typec/fusb302/fusb302_reg.h create mode 100644 drivers/usb/typec/fusb302/Kconfig create mode 100644 drivers/usb/typec/fusb302/Makefile create mode 100644 drivers/usb/typec/fusb302/fusb302.c create mode 100644 drivers/usb/typec/fusb302/fusb302_reg.h
drivers/staging/typec/Kconfig +0 -2
@@ -9,8 +9,6 @@ config TYPEC_TCPCI help Type-C Port Controller driver for TCPCI-compliant controller. -source "drivers/staging/typec/fusb302/Kconfig" - endif endmenu
drivers/staging/typec/Makefile +0 -1
@@ -1,2 +1 @@ obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o -obj-y += fusb302/
drivers/staging/typec/fusb302/Kconfig deleted +0 -7
@@ -1,7 +0,0 @@ -config TYPEC_FUSB302 - tristate "Fairchild FUSB302 Type-C chip driver" - depends on I2C && POWER_SUPPLY - help - The Fairchild FUSB302 Type-C chip driver that works with - Type-C Port Controller Manager to provide USB PD and USB - Type-C functionalities.
drivers/staging/typec/fusb302/Makefile deleted +0 -1
@@ -1 +0,0 @@ -obj-$(CONFIG_TYPEC_FUSB302) += fusb302.o
drivers/staging/typec/fusb302/TODO deleted +0 -10
@@ -1,10 +0,0 @@ -fusb302: -- Find a better logging scheme, at least not having the same debugging/logging - code replicated here and in tcpm -- Find a non-hacky way to coordinate between PM and I2C access -- Documentation? The FUSB302 datasheet provides information on the chip to help - understand the code. But it may still be helpful to have a documentation. -- We may want to replace the "fcs,max-snk-microvolt", "fcs,max-snk-microamp", - "fcs,max-snk-microwatt" and "fcs,operating-snk-microwatt" device(tree) - properties with properties which are part of a generic type-c controller - devicetree binding.
drivers/staging/typec/fusb302/fusb302.c deleted +0 -1947
1,947 lines not on this page · raw message
drivers/staging/typec/fusb302/fusb302_reg.h deleted +0 -186
186 lines not on this page · raw message
drivers/usb/typec/Kconfig +6 -0
@@ -12,6 +12,12 @@ config TYPEC_TCPM The Type-C Port Controller Manager provides a USB PD and USB Type-C state machine for use with Type-C Port Controllers. +if TYPEC_TCPM + +source "drivers/usb/typec/fusb302/Kconfig" + +endif + config TYPEC_WCOVE tristate "Intel WhiskeyCove PMIC USB Type-C PHY driver" depends on ACPI
drivers/usb/typec/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_TYPEC) += typec.o obj-$(CONFIG_TYPEC_TCPM) += tcpm.o +obj-y += fusb302/ obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o obj-$(CONFIG_TYPEC_UCSI) += ucsi/
drivers/usb/typec/fusb302/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +config TYPEC_FUSB302 + tristate "Fairchild FUSB302 Type-C chip driver" + depends on I2C && POWER_SUPPLY + help + The Fairchild FUSB302 Type-C chip driver that works with + Type-C Port Controller Manager to provide USB PD and USB + Type-C functionalities.
drivers/usb/typec/fusb302/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_TYPEC_FUSB302) += fusb302.o
drivers/usb/typec/fusb302/fusb302.c new file +1947 -0
814 lines not on this page · raw message
drivers/usb/typec/fusb302/fusb302_reg.h new file +186 -0
186 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.4
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerQuoted 7 lines · Guenter Roeck
Commented out code can be added as needed. Drop it. Also drop TODO and an obsolete XXX comment.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/staging/typec/tcpm.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
Thans for the series, I'll queue it up once 4.14-rc1 is out and make a branch that can get pulled into both the staging and usb trees, so that future work on this can all happen through the usb tree.
thanks,
greg k-h
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines · Guenter Roeck
Commented out code can be added as needed. Drop it. Also drop TODO and an obsolete XXX comment.
Quoted 9 lines
Quoted 4 lines
Signed-off-by Guenter Roeck <[email protected]>--- drivers/staging/typec/tcpm.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)Thans for the series, I'll queue it up once 4.14-rc1 is out and make a branch that can get pulled into both the staging and usb trees, so that future work on this can all happen through the usb tree.
Should I resend to add the '/**' in patch 3, or can you take care of it ?
Thanks,
Guenter
Greg Kroah-Hartman
maintainerQuoted 10 lines · Guenter Roeck
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Guenter Roeck
Commented out code can be added as needed. Drop it. Also drop TODO and an obsolete XXX comment.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/staging/typec/tcpm.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
Quoted 5 lines
Quoted 4 lines
Thans for the series, I'll queue it up once 4.14-rc1 is out and make a branch that can get pulled into both the staging and usb trees, so that future work on this can all happen through the usb tree.
Should I resend to add the '/**' in patch 3, or can you take care of it ?
A resend, with -M format, would always be appreciated :)
thanks,
greg k-h
Quoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Guenter Roeck
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Guenter Roeck
Commented out code can be added as needed. Drop it. Also drop TODO and an obsolete XXX comment.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/staging/typec/tcpm.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Thans for the series, I'll queue it up once 4.14-rc1 is out and make a branch that can get pulled into both the staging and usb trees, so that future work on this can all happen through the usb tree.
Should I resend to add the '/**' in patch 3, or can you take care of it ?
A resend, with -M format, would always be appreciated :)
I did that, as v2, but it does not include the comment change in patch 3.
I'll send v3 tonight.
Guenter