usb: typec: tcpm: Add Callback to Usb Communication capable partner
Subsystems (3)
Badhri Jagan Sridharan
maintainerPATCH v2 1/3 usb: typec: tcpm: Add Callback to Usb Communication capable partner
The USB Communications Capable bit indicates if port partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). Notify the status of the bit to low level drivers to perform chip specific operation. For instance, low level driver enables USB switches on D+/D- lines to set up data path when the bit is set.
Refactored from patch initially authored by
Kyle Tso <[email protected]>
---
Changes since V1:
- Removed partner_usb_comm_capable flag.
- Fixed capable flag for SNK_NEGOTIATE_CAPABILITIES.
--- drivers/usb/typec/tcpm/tcpm.c | 13 +++++++++++++ include/linux/usb/tcpm.h | 5 +++++ 2 files changed, 18 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +13 -0
@@ -3429,6 +3429,14 @@ static void tcpm_unregister_altmodes(struct tcpm_port *port)memset (modep,0 ,sizeof (*modep)); } +static void tcpm_set_partner_usb_comm_capable (struct tcpm_port *port,bool capable) +{ +tcpm_log (port,"Setting usb_comm capable %s" , capable ?"true" :"false" ); + +if (port->tcpc->set_partner_usb_comm_capable) + port->tcpc->set_partner_usb_comm_capable (port->tcpc, capable); +} +static void tcpm_reset_port (struct tcpm_port *port) {int ret;
@@ -3445,6 +3453,7 @@ static void tcpm_reset_port(struct tcpm_port *port) port->attached = false; port->pd_capable = false; port->pps_data.supported = false; +tcpm_set_partner_usb_comm_capable (port, false);/* * First Rx ID should be 0; set this to a sentinel of -1 so that
@@ -3785,6 +3794,8 @@ static void run_state_machine(struct tcpm_port *port) } }else {tcpm_pd_send_control (port,PD_CTRL_ACCEPT ); +tcpm_set_partner_usb_comm_capable (port, + !!(port->sink_request &RDO_USB_COMM ));tcpm_set_state (port,SRC_TRANSITION_SUPPLY ,PD_T_SRC_TRANSITION ); }
@@ -4004,6 +4015,8 @@ static void run_state_machine(struct tcpm_port *port)break ;case SNK_NEGOTIATE_CAPABILITIES : port->pd_capable = true; +tcpm_set_partner_usb_comm_capable (port, + !!(port->source_caps[0 ] &PDO_FIXED_USB_COMM )); port->hard_reset_count =0 ; ret =tcpm_pd_send_request (port);if (ret <0 ) {
include/linux/usb/tcpm.h +5 -0
@@ -108,6 +108,10 @@ enum tcpm_transmit_type {* is supported by TCPC, set this callback for TCPM to query * whether vbus is at VSAFE0V when needed. * Returns true when vbus is at VSAFE0V, false otherwise. +* @set_partner_usb_comm_capable: +* Optional; The USB Communications Capable bit indicates if port +* partner is capable of communication over the USB data lines +* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. */ struct tcpc_dev {struct fwnode_handle *fwnode;
@@ -139,6 +143,7 @@ struct tcpc_dev {int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev,enum typec_pwr_opmode mode,bool pps_active,u32 requested_vbus_voltage);bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev); +void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev,bool enable); };struct tcpm_port ;
Signature · 1 line
2.30.0.365.g02bc693789-goog
Badhri Jagan Sridharan
maintainerPATCH v2 2/3 usb: typec: tcpci: Add Callback to Usb Communication capable partner
The USB Communications Capable bit indicates if port
partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). TCPM passes this information for chip specific operations.
--- drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++ drivers/usb/typec/tcpm/tcpci.h | 6 ++++++ 2 files changed, 15 insertions(+)
drivers/usb/typec/tcpm/tcpci.c +9 -0
@@ -255,6 +255,14 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, TCPC_TCPC_CTRL_ORIENTATION : 0); } +static void tcpci_set_partner_usb_comm_capable (struct tcpc_dev *tcpc,bool capable) +{ +struct tcpci *tcpci =tcpc_to_tcpci (tcpc); + +if (tcpci->data->set_partner_usb_comm_capable) + tcpci->data->set_partner_usb_comm_capable (tcpci, tcpci->data, capable); +} +static int tcpci_set_vconn (struct tcpc_dev *tcpc,bool enable) {struct tcpci *tcpci =tcpc_to_tcpci (tcpc);
@@ -720,6 +728,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) tcpci->tcpc.set_bist_data = tcpci_set_bist_data; tcpci->tcpc.enable_frs = tcpci_enable_frs; tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus; + tcpci->tcpc.set_partner_usb_comm_capable = tcpci_set_partner_usb_comm_capable;if (tcpci->data->auto_discharge_disconnect) { tcpci->tcpc.enable_auto_vbus_discharge = tcpci_enable_auto_vbus_discharge;
drivers/usb/typec/tcpm/tcpci.h +6 -0
@@ -161,6 +161,10 @@ struct tcpci;* Optional; Enables TCPC to autonously discharge vbus on disconnect. * @vbus_vsafe0v: * optional; Set when TCPC can detect whether vbus is at VSAFE0V. +* @set_partner_usb_comm_capable: +* Optional; The USB Communications Capable bit indicates if port +* partner is capable of communication over the USB data lines +* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. */ struct tcpci_data {struct regmap *regmap;
@@ -175,6 +179,8 @@ struct tcpci_data { enum typec_cc_status cc);int (*set_vbus)(struct tcpci *tcpci,struct tcpci_data *data,bool source,bool sink);void (*frs_sourcing_vbus)(struct tcpci *tcpci,struct tcpci_data *data); +void (*set_partner_usb_comm_capable)(struct tcpci *tcpci,struct tcpci_data *data, +bool capable); };struct tcpci *tcpci_register_port (struct device *dev,struct tcpci_data *data);
Signature · 1 line
2.30.0.365.g02bc693789-goog
Re: [PATCH v2 2/3] usb: typec: tcpci: Add Callback to Usb Communication capable partner
Quoted 6 lines · Badhri Jagan Sridharan
The USB Communications Capable bit indicates if port
partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). TCPM passes this information for chip specific operations.Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 58 lines
--- drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++ drivers/usb/typec/tcpm/tcpci.h | 6 ++++++ 2 files changed, 15 insertions(+)drivers/usb/typec/tcpm/tcpci.c +9
-0@@ -255,6 +255,14 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, TCPC_TCPC_CTRL_ORIENTATION : 0); } +static void tcpci_set_partner_usb_comm_capable (struct tcpc_dev *tcpc,bool capable) +{ +struct tcpci *tcpci =tcpc_to_tcpci (tcpc); + +if (tcpci->data->set_partner_usb_comm_capable) + tcpci->data->set_partner_usb_comm_capable (tcpci, tcpci->data, capable); +} +static int tcpci_set_vconn (struct tcpc_dev *tcpc,bool enable) {struct tcpci *tcpci =tcpc_to_tcpci (tcpc);@@ -720,6 +728,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) tcpci->tcpc.set_bist_data = tcpci_set_bist_data; tcpci->tcpc.enable_frs = tcpci_enable_frs; tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus; + tcpci->tcpc.set_partner_usb_comm_capable = tcpci_set_partner_usb_comm_capable;if (tcpci->data->auto_discharge_disconnect) { tcpci->tcpc.enable_auto_vbus_discharge = tcpci_enable_auto_vbus_discharge;drivers/usb/typec/tcpm/tcpci.h +6
-0@@ -161,6 +161,10 @@ struct tcpci;* Optional; Enables TCPC to autonously discharge vbus on disconnect. * @vbus_vsafe0v: * optional; Set when TCPC can detect whether vbus is at VSAFE0V. +* @set_partner_usb_comm_capable: +* Optional; The USB Communications Capable bit indicates if port +* partner is capable of communication over the USB data lines +* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. */ struct tcpci_data {struct regmap *regmap;@@ -175,6 +179,8 @@ struct tcpci_data { enum typec_cc_status cc);int (*set_vbus)(struct tcpci *tcpci,struct tcpci_data *data,bool source,bool sink);void (*frs_sourcing_vbus)(struct tcpci *tcpci,struct tcpci_data *data); +void (*set_partner_usb_comm_capable)(struct tcpci *tcpci,struct tcpci_data *data, +bool capable); };struct tcpci *tcpci_register_port (struct device *dev,struct tcpci_data *data);Signature · 1 line
2.30.0.365.g02bc693789-goog
thanks,
Signature · 1 line
heikki
Re: [PATCH v2 2/3] usb: typec: tcpci: Add Callback to Usb Communication capable partner
In reply to Badhri Jagan SridharanQuoted 6 lines · Badhri Jagan Sridharan
The USB Communications Capable bit indicates if port
partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). TCPM passes this information for chip specific operations.Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 59 lines
--- drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++ drivers/usb/typec/tcpm/tcpci.h | 6 ++++++ 2 files changed, 15 insertions(+)drivers/usb/typec/tcpm/tcpci.c +9
-0@@ -255,6 +255,14 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, TCPC_TCPC_CTRL_ORIENTATION : 0); } +static void tcpci_set_partner_usb_comm_capable (struct tcpc_dev *tcpc,bool capable) +{ +struct tcpci *tcpci =tcpc_to_tcpci (tcpc); + +if (tcpci->data->set_partner_usb_comm_capable) + tcpci->data->set_partner_usb_comm_capable (tcpci, tcpci->data, capable); +} +static int tcpci_set_vconn (struct tcpc_dev *tcpc,bool enable) {struct tcpci *tcpci =tcpc_to_tcpci (tcpc);@@ -720,6 +728,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) tcpci->tcpc.set_bist_data = tcpci_set_bist_data; tcpci->tcpc.enable_frs = tcpci_enable_frs; tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus; + tcpci->tcpc.set_partner_usb_comm_capable = tcpci_set_partner_usb_comm_capable;if (tcpci->data->auto_discharge_disconnect) { tcpci->tcpc.enable_auto_vbus_discharge = tcpci_enable_auto_vbus_discharge;drivers/usb/typec/tcpm/tcpci.h +6
-0@@ -161,6 +161,10 @@ struct tcpci;* Optional; Enables TCPC to autonously discharge vbus on disconnect. * @vbus_vsafe0v: * optional; Set when TCPC can detect whether vbus is at VSAFE0V. +* @set_partner_usb_comm_capable: +* Optional; The USB Communications Capable bit indicates if port +* partner is capable of communication over the USB data lines +* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. */ struct tcpci_data {struct regmap *regmap;@@ -175,6 +179,8 @@ struct tcpci_data { enum typec_cc_status cc);int (*set_vbus)(struct tcpci *tcpci,struct tcpci_data *data,bool source,bool sink);void (*frs_sourcing_vbus)(struct tcpci *tcpci,struct tcpci_data *data); +void (*set_partner_usb_comm_capable)(struct tcpci *tcpci,struct tcpci_data *data, +bool capable); };struct tcpci *tcpci_register_port (struct device *dev,struct tcpci_data *data);Signature · 1 line
2.30.0.365.g02bc693789-goog
Badhri Jagan Sridharan
maintainerPATCH v2 3/3 usb: typec: tcpci_maxim: Enable data path when partner is USB Comm capable
In reply to Badhri Jagan SridharanConfigure USB switches when partner is USB Communication capable. The is enabled USB data communication over D+/D- pins.
--- drivers/usb/typec/tcpm/tcpci_maxim.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/usb/typec/tcpm/tcpci_maxim.c +19 -0
@@ -19,6 +19,9 @@#define PD_ACTIVITY_TIMEOUT_MS 10000#define TCPC_VENDOR_ALERT 0x80 +#define TCPC_VENDOR_USBSW_CTRL 0x93 +#define TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA 0x9 +#define TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA 0#define TCPC_RECEIVE_BUFFER_COUNT_OFFSET 0#define TCPC_RECEIVE_BUFFER_FRAME_TYPE_OFFSET 1
@@ -274,6 +277,21 @@ static void process_tx(struct max_tcpci_chip *chip, u16 status)max_tcpci_init_regs (chip); } +/* Enable USB switches when partner is USB communications capable */ +static void max_tcpci_set_partner_usb_comm_capable (struct tcpci *tcpci,struct tcpci_data *data, +bool capable) +{ +struct max_tcpci_chip *chip =tdata_to_max_tcpci (data); +int ret; + + ret =max_tcpci_write8 (chip,TCPC_VENDOR_USBSW_CTRL , capable ? +TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA : +TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA ); + +if (ret <0 ) +dev_err (chip->dev,"Failed to enable USB switches" ); +} +static irqreturn_t _max_tcpci_irq (struct max_tcpci_chip *chip,u16 status) {u16 mask;
@@ -453,6 +471,7 @@ static int max_tcpci_probe(struct i2c_client *client, const struct i2c_device_id chip->data.frs_sourcing_vbus = max_tcpci_frs_sourcing_vbus; chip->data.auto_discharge_disconnect = true; chip->data.vbus_vsafe0v = true; + chip->data.set_partner_usb_comm_capable = max_tcpci_set_partner_usb_comm_capable;max_tcpci_init_regs (chip); chip->tcpci =tcpci_register_port (chip->dev, &chip->data);
Signature · 1 line
2.30.0.365.g02bc693789-goog
Re: [PATCH v2 3/3] usb: typec: tcpci_maxim: Enable data path when partner is USB Comm capable
Quoted 4 lines · Badhri Jagan Sridharan
Configure USB switches when partner is USB Communication capable. The is enabled USB data communication over D+/D- pins.
Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 50 lines
--- drivers/usb/typec/tcpm/tcpci_maxim.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/usb/typec/tcpm/tcpci_maxim.c +19
-0@@ -19,6 +19,9 @@#define PD_ACTIVITY_TIMEOUT_MS 10000#define TCPC_VENDOR_ALERT 0x80 +#define TCPC_VENDOR_USBSW_CTRL 0x93 +#define TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA 0x9 +#define TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA 0#define TCPC_RECEIVE_BUFFER_COUNT_OFFSET 0#define TCPC_RECEIVE_BUFFER_FRAME_TYPE_OFFSET 1@@ -274,6 +277,21 @@ static void process_tx(struct max_tcpci_chip *chip, u16 status)max_tcpci_init_regs (chip); } +/* Enable USB switches when partner is USB communications capable */ +static void max_tcpci_set_partner_usb_comm_capable (struct tcpci *tcpci,struct tcpci_data *data, +bool capable) +{ +struct max_tcpci_chip *chip =tdata_to_max_tcpci (data); +int ret; + + ret =max_tcpci_write8 (chip,TCPC_VENDOR_USBSW_CTRL , capable ? +TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA : +TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA ); + +if (ret <0 ) +dev_err (chip->dev,"Failed to enable USB switches" ); +} +static irqreturn_t _max_tcpci_irq (struct max_tcpci_chip *chip,u16 status) {u16 mask;@@ -453,6 +471,7 @@ static int max_tcpci_probe(struct i2c_client *client, const struct i2c_device_id chip->data.frs_sourcing_vbus = max_tcpci_frs_sourcing_vbus; chip->data.auto_discharge_disconnect = true; chip->data.vbus_vsafe0v = true; + chip->data.set_partner_usb_comm_capable = max_tcpci_set_partner_usb_comm_capable;max_tcpci_init_regs (chip); chip->tcpci =tcpci_register_port (chip->dev, &chip->data);Signature · 1 line
2.30.0.365.g02bc693789-goog
thanks,
Signature · 1 line
heikki
Re: [PATCH v2 3/3] usb: typec: tcpci_maxim: Enable data path when partner is USB Comm capable
In reply to Badhri Jagan SridharanQuoted 4 lines · Badhri Jagan Sridharan
Configure USB switches when partner is USB Communication capable. The is enabled USB data communication over D+/D- pins.
Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 51 lines
--- drivers/usb/typec/tcpm/tcpci_maxim.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/usb/typec/tcpm/tcpci_maxim.c +19
-0@@ -19,6 +19,9 @@#define PD_ACTIVITY_TIMEOUT_MS 10000#define TCPC_VENDOR_ALERT 0x80 +#define TCPC_VENDOR_USBSW_CTRL 0x93 +#define TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA 0x9 +#define TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA 0#define TCPC_RECEIVE_BUFFER_COUNT_OFFSET 0#define TCPC_RECEIVE_BUFFER_FRAME_TYPE_OFFSET 1@@ -274,6 +277,21 @@ static void process_tx(struct max_tcpci_chip *chip, u16 status)max_tcpci_init_regs (chip); } +/* Enable USB switches when partner is USB communications capable */ +static void max_tcpci_set_partner_usb_comm_capable (struct tcpci *tcpci,struct tcpci_data *data, +bool capable) +{ +struct max_tcpci_chip *chip =tdata_to_max_tcpci (data); +int ret; + + ret =max_tcpci_write8 (chip,TCPC_VENDOR_USBSW_CTRL , capable ? +TCPC_VENDOR_USBSW_CTRL_ENABLE_USB_DATA : +TCPC_VENDOR_USBSW_CTRL_DISABLE_USB_DATA ); + +if (ret <0 ) +dev_err (chip->dev,"Failed to enable USB switches" ); +} +static irqreturn_t _max_tcpci_irq (struct max_tcpci_chip *chip,u16 status) {u16 mask;@@ -453,6 +471,7 @@ static int max_tcpci_probe(struct i2c_client *client, const struct i2c_device_id chip->data.frs_sourcing_vbus = max_tcpci_frs_sourcing_vbus; chip->data.auto_discharge_disconnect = true; chip->data.vbus_vsafe0v = true; + chip->data.set_partner_usb_comm_capable = max_tcpci_set_partner_usb_comm_capable;max_tcpci_init_regs (chip); chip->tcpci =tcpci_register_port (chip->dev, &chip->data);Signature · 1 line
2.30.0.365.g02bc693789-goog
Badhri Jagan Sridharan
maintainerHi Guenter,
Sent V2 version of the patch stack:
https://patchwork.kernel.org/project/linux-usb/list/?series=425705.
For me, Gmail is grouping this under v1 version for some reason and since you had reviewed one other patch
which was sent later, I was wondering if you are having similar grouping issue as well.
I am pinging here to make sure that the patch isn't missed.
Thanks,
Badhri
Quoted 92 lines · Badhri Jagan Sridharan
The USB Communications Capable bit indicates if port partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). Notify the status of the bit to low level drivers to perform chip specific operation. For instance, low level driver enables USB switches on D+/D- lines to set up data path when the bit is set.
Refactored from patch initially authored by
Kyle Tso <[email protected]>Signed-off-by Badhri Jagan Sridharan <[email protected]>---
Changes since V1:
- Removedpartner_usb_comm_capableflag.
- Fixed capable flag forSNK_NEGOTIATE_CAPABILITIES.--- drivers/usb/typec/tcpm/tcpm.c | 13 +++++++++++++ include/linux/usb/tcpm.h | 5 +++++ 2 files changed, 18 insertions(+)drivers/usb/typec/tcpm/tcpm.c +13
-0@@ -3429,6 +3429,14 @@ static void tcpm_unregister_altmodes(struct tcpm_port *port)memset (modep,0 ,sizeof (*modep)); } +static void tcpm_set_partner_usb_comm_capable (struct tcpm_port *port,bool capable) +{ +tcpm_log (port,"Setting usb_comm capable %s" , capable ?"true" :"false" ); + +if (port->tcpc->set_partner_usb_comm_capable) + port->tcpc->set_partner_usb_comm_capable (port->tcpc, capable); +} +static void tcpm_reset_port (struct tcpm_port *port) {int ret;@@ -3445,6 +3453,7 @@ static void tcpm_reset_port(struct tcpm_port *port) port->attached = false; port->pd_capable = false; port->pps_data.supported = false; +tcpm_set_partner_usb_comm_capable (port, false);/* * First Rx ID should be 0; set this to a sentinel of -1 so that @@ -3785,6 +3794,8 @@ static void run_state_machine(struct tcpm_port *port) } }else {tcpm_pd_send_control (port,PD_CTRL_ACCEPT ); +tcpm_set_partner_usb_comm_capable (port, + !!(port->sink_request &RDO_USB_COMM ));tcpm_set_state (port,SRC_TRANSITION_SUPPLY ,PD_T_SRC_TRANSITION ); }@@ -4004,6 +4015,8 @@ static void run_state_machine(struct tcpm_port *port)break ;case SNK_NEGOTIATE_CAPABILITIES : port->pd_capable = true; +tcpm_set_partner_usb_comm_capable (port, + !!(port->source_caps[0 ] &PDO_FIXED_USB_COMM )); port->hard_reset_count =0 ; ret =tcpm_pd_send_request (port);if (ret <0 ) {include/linux/usb/tcpm.h +5
-1@@ -108,6 +108,10 @@ enum tcpm_transmit_type {* is supported by TCPC, set this callback for TCPM to query * whether vbus is at VSAFE0V when needed. * Returns true when vbus is at VSAFE0V, false otherwise. +* @set_partner_usb_comm_capable: +* Optional; The USB Communications Capable bit indicates if port +* partner is capable of communication over the USB data lines +* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. */ struct tcpc_dev {struct fwnode_handle *fwnode;@@ -139,6 +143,7 @@ struct tcpc_dev {int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev,enum typec_pwr_opmode mode,bool pps_active,u32 requested_vbus_voltage);bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev); +void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev,bool enable); };struct tcpm_port ; --2.30.0.365.g02bc693789-goog
Quoted 11 lines · Badhri Jagan Sridharan
The USB Communications Capable bit indicates if port partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). Notify the status of the bit to low level drivers to perform chip specific operation. For instance, low level driver enables USB switches on D+/D- lines to set up data path when the bit is set.
Refactored from patch initially authored by
Kyle Tso <[email protected]>Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 79 lines
---
Changes since V1:
- Removedpartner_usb_comm_capableflag.
- Fixed capable flag forSNK_NEGOTIATE_CAPABILITIES.--- drivers/usb/typec/tcpm/tcpm.c | 13 +++++++++++++ include/linux/usb/tcpm.h | 5 +++++ 2 files changed, 18 insertions(+)drivers/usb/typec/tcpm/tcpm.c +13
-0@@ -3429,6 +3429,14 @@ static void tcpm_unregister_altmodes(struct tcpm_port *port)memset (modep,0 ,sizeof (*modep)); } +static void tcpm_set_partner_usb_comm_capable (struct tcpm_port *port,bool capable) +{ +tcpm_log (port,"Setting usb_comm capable %s" , capable ?"true" :"false" ); + +if (port->tcpc->set_partner_usb_comm_capable) + port->tcpc->set_partner_usb_comm_capable (port->tcpc, capable); +} +static void tcpm_reset_port (struct tcpm_port *port) {int ret;@@ -3445,6 +3453,7 @@ static void tcpm_reset_port(struct tcpm_port *port) port->attached = false; port->pd_capable = false; port->pps_data.supported = false; +tcpm_set_partner_usb_comm_capable (port, false);/* * First Rx ID should be 0; set this to a sentinel of -1 so that @@ -3785,6 +3794,8 @@ static void run_state_machine(struct tcpm_port *port) } }else {tcpm_pd_send_control (port,PD_CTRL_ACCEPT ); +tcpm_set_partner_usb_comm_capable (port, + !!(port->sink_request &RDO_USB_COMM ));tcpm_set_state (port,SRC_TRANSITION_SUPPLY ,PD_T_SRC_TRANSITION ); }@@ -4004,6 +4015,8 @@ static void run_state_machine(struct tcpm_port *port)break ;case SNK_NEGOTIATE_CAPABILITIES : port->pd_capable = true; +tcpm_set_partner_usb_comm_capable (port, + !!(port->source_caps[0 ] &PDO_FIXED_USB_COMM )); port->hard_reset_count =0 ; ret =tcpm_pd_send_request (port);if (ret <0 ) {include/linux/usb/tcpm.h +5
-0@@ -108,6 +108,10 @@ enum tcpm_transmit_type {* is supported by TCPC, set this callback for TCPM to query * whether vbus is at VSAFE0V when needed. * Returns true when vbus is at VSAFE0V, false otherwise. +* @set_partner_usb_comm_capable: +* Optional; The USB Communications Capable bit indicates if port +* partner is capable of communication over the USB data lines +* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. */ struct tcpc_dev {struct fwnode_handle *fwnode;@@ -139,6 +143,7 @@ struct tcpc_dev {int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev,enum typec_pwr_opmode mode,bool pps_active,u32 requested_vbus_voltage);bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev); +void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev,bool enable); };struct tcpm_port ;Signature · 1 line
2.30.0.365.g02bc693789-goog
thanks,
Signature · 1 line
heikki
Quoted 11 lines · Badhri Jagan Sridharan
The USB Communications Capable bit indicates if port partner is capable of communication over the USB data lines (e.g. D+/- or SS Tx/Rx). Notify the status of the bit to low level drivers to perform chip specific operation. For instance, low level driver enables USB switches on D+/D- lines to set up data path when the bit is set.
Refactored from patch initially authored by
Kyle Tso <[email protected]>Signed-off-by Badhri Jagan Sridharan <[email protected]>
Quoted 80 lines
---
Changes since V1:
- Removedpartner_usb_comm_capableflag.
- Fixed capable flag forSNK_NEGOTIATE_CAPABILITIES.--- drivers/usb/typec/tcpm/tcpm.c | 13 +++++++++++++ include/linux/usb/tcpm.h | 5 +++++ 2 files changed, 18 insertions(+)drivers/usb/typec/tcpm/tcpm.c +13
-0@@ -3429,6 +3429,14 @@ static void tcpm_unregister_altmodes(struct tcpm_port *port)memset (modep,0 ,sizeof (*modep)); } +static void tcpm_set_partner_usb_comm_capable (struct tcpm_port *port,bool capable) +{ +tcpm_log (port,"Setting usb_comm capable %s" , capable ?"true" :"false" ); + +if (port->tcpc->set_partner_usb_comm_capable) + port->tcpc->set_partner_usb_comm_capable (port->tcpc, capable); +} +static void tcpm_reset_port (struct tcpm_port *port) {int ret;@@ -3445,6 +3453,7 @@ static void tcpm_reset_port(struct tcpm_port *port) port->attached = false; port->pd_capable = false; port->pps_data.supported = false; +tcpm_set_partner_usb_comm_capable (port, false);/* * First Rx ID should be 0; set this to a sentinel of -1 so that @@ -3785,6 +3794,8 @@ static void run_state_machine(struct tcpm_port *port) } }else {tcpm_pd_send_control (port,PD_CTRL_ACCEPT ); +tcpm_set_partner_usb_comm_capable (port, + !!(port->sink_request &RDO_USB_COMM ));tcpm_set_state (port,SRC_TRANSITION_SUPPLY ,PD_T_SRC_TRANSITION ); }@@ -4004,6 +4015,8 @@ static void run_state_machine(struct tcpm_port *port)break ;case SNK_NEGOTIATE_CAPABILITIES : port->pd_capable = true; +tcpm_set_partner_usb_comm_capable (port, + !!(port->source_caps[0 ] &PDO_FIXED_USB_COMM )); port->hard_reset_count =0 ; ret =tcpm_pd_send_request (port);if (ret <0 ) {include/linux/usb/tcpm.h +5
-0@@ -108,6 +108,10 @@ enum tcpm_transmit_type {* is supported by TCPC, set this callback for TCPM to query * whether vbus is at VSAFE0V when needed. * Returns true when vbus is at VSAFE0V, false otherwise. +* @set_partner_usb_comm_capable: +* Optional; The USB Communications Capable bit indicates if port +* partner is capable of communication over the USB data lines +* (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. */ struct tcpc_dev {struct fwnode_handle *fwnode;@@ -139,6 +143,7 @@ struct tcpc_dev {int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev,enum typec_pwr_opmode mode,bool pps_active,u32 requested_vbus_voltage);bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev); +void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev,bool enable); };struct tcpm_port ;Signature · 1 line
2.30.0.365.g02bc693789-goog