platform/chrome: cros_ec_typec: VDM support
Subsystems (4)
cover platform/chrome: cros_ec_typec: VDM support
This series adds support for sending and receiving USB PD Vendor Defined Messages (VDMs) between the Application Processor's Type-C ports and connected peripherals.
Thir enables the Application processor to enter alternate modes and process VDMs directly, instead of relying on state machines that exist inside of co-processors like the ChromeOS Embedded Controller (EC).
Patch 1/10 reverts an incorrect EC header modification. Patch 2/10 to 5/10 update headers and existing Type-C structs to accommodate the VDM code.
Patch 6/10 and 7/10 prepare the Type-C driver to have more than 1 file. Patch 8/10 to 10/10 introduce the VDM functionality.
Patch submissions suggestion (if approved):
- Even though Patch 1 touches drivers/mfd, it would be better to take the entire series through the cbrome-platform branch, to avoid cross-dependencies across maintainer trees.
Prashant Malani (10):
Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
platform_chrome: cros_ec: Add Type-C VDM defines platform/chrome: cros_ec_typec: Stash port driver info platform/chrome: cros_ec_typec: Set port alt mode drvdata platform/chrome: cros_ec_typec: Update port DP VDO platform/chrome: cros_ec_typec: Move structs to header platform/chrome: cros_ec_typec: Alter module name with hyphens platform/chrome: cros_ec_typec: Add initial VDM support platform/chrome: cros_typec_vdm: Add VDM reply support platform/chrome: cros_typec_vdm: Add VDM send support
MAINTAINERS | 3 +- drivers/mfd/cros_ec_dev.c | 5 - drivers/platform/chrome/Kconfig | 2 +- drivers/platform/chrome/Makefile | 3 +- drivers/platform/chrome/cros_ec_typec.c | 91 +++------------ drivers/platform/chrome/cros_ec_typec.h | 85 ++++++++++++++ drivers/platform/chrome/cros_typec_vdm.c | 106 ++++++++++++++++++ drivers/platform/chrome/cros_typec_vdm.h | 12 ++ .../linux/platform_data/cros_ec_commands.h | 53 ++++++++- include/linux/platform_data/cros_ec_proto.h | 1 - 10 files changed, 276 insertions(+), 85 deletions(-) create mode 100644 drivers/platform/chrome/cros_ec_typec.h create mode 100644 drivers/platform/chrome/cros_typec_vdm.c create mode 100644 drivers/platform/chrome/cros_typec_vdm.h
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
PATCH 1/10 Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
This reverts commit 66ee379d743c69c726b61d078119a34d5be96a35.
The feature flag introduced by Commit 66ee379d743c ("mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU") was not first added in the source EC code base[1]. This can lead to the possible misinterpration of an EC's supported feature set, as well as causes issues with all future feature flag updates.
[1] https://source.chromium.org/chromium/chromiumos/platform/ec/+/main:include/ec_commands.h
---
While this patch modifies drivers/mfd, it would be preferable to submit it through the chrome-platform tree, since that eliminates cross-tree dependencies for the series of which this patch is a part.
drivers/mfd/cros_ec_dev.c | 5 ----- include/linux/platform_data/cros_ec_commands.h | 2 -- include/linux/platform_data/cros_ec_proto.h | 1 - 3 files changed, 8 deletions(-)
drivers/mfd/cros_ec_dev.c +0 -5
@@ -64,11 +64,6 @@ static const struct cros_feature_to_name cros_mcu_devices[] = { .name = CROS_EC_DEV_SCP_NAME, .desc = "System Control Processor", }, - { - .id = EC_FEATURE_SCP_C1, - .name = CROS_EC_DEV_SCP_C1_NAME, - .desc = "System Control Processor 2nd Core", - }, { .id = EC_FEATURE_TOUCHPAD, .name = CROS_EC_DEV_TP_NAME,
include/linux/platform_data/cros_ec_commands.h +0 -2
@@ -1300,8 +1300,6 @@ enum ec_feature_code {* mux. */ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK = 43, -/* The MCU is a System Companion Processor (SCP) 2nd Core. */ - EC_FEATURE_SCP_C1 = 45, };#define EC_FEATURE_MASK_0 (event_code) BIT(event_code % 32)
include/linux/platform_data/cros_ec_proto.h +0 -1
@@ -19,7 +19,6 @@#define CROS_EC_DEV_ISH_NAME "cros_ish"#define CROS_EC_DEV_PD_NAME "cros_pd"#define CROS_EC_DEV_SCP_NAME "cros_scp" -#define CROS_EC_DEV_SCP_C1_NAME "cros_scp_c1"#define CROS_EC_DEV_TP_NAME "cros_tp"#define CROS_EC_DEV_EC_INDEX 0
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 01/10] Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
Quoted 8 lines · Prashant Malani
This reverts commit
66ee379d743c69c726b61d078119a34d5be96a35.The feature flag introduced by Commit
66ee379d743c("mfd:cros_ec: Add SCP Core-1 as a new CrOS EC MCU") was not first added in the source EC code base[1]. This can lead to the possible misinterpration of an EC's supported feature set, as well as causes issues with all future feature flag updates.
Quoted 8 lines
[1] https://source.chromium.org/chromium/chromiumos/platform/ec/+/main:include/ec_commands.h
Signed-off-by Prashant Malani <[email protected]>---
While this patch modifies
drivers/mfd, it would be preferable to submit it through the chrome-platform tree, since that eliminates cross-tree dependencies for the series of which this patch is a part.
Shouldn't be an issue:
Quoted 49 lines
drivers/mfd/cros_ec_dev.c | 5 ----- include/linux/platform_data/cros_ec_commands.h | 2 -- include/linux/platform_data/cros_ec_proto.h | 1 - 3 files changed, 8 deletions(-)drivers/mfd/cros_ec_dev.c +0
-5@@ -64,11 +64,6 @@ static const struct cros_feature_to_name cros_mcu_devices[] = { .name = CROS_EC_DEV_SCP_NAME, .desc = "System Control Processor", }, - { - .id = EC_FEATURE_SCP_C1, - .name = CROS_EC_DEV_SCP_C1_NAME, - .desc = "System Control Processor 2nd Core", - }, { .id = EC_FEATURE_TOUCHPAD, .name = CROS_EC_DEV_TP_NAME,include/linux/platform_data/cros_ec_commands.h +0
-2@@ -1300,8 +1300,6 @@ enum ec_feature_code {* mux. */ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK = 43, -/* The MCU is a System Companion Processor (SCP) 2nd Core. */ - EC_FEATURE_SCP_C1 = 45, };#define EC_FEATURE_MASK_0 (event_code) BIT(event_code % 32)include/linux/platform_data/cros_ec_proto.h +0
-1@@ -19,7 +19,6 @@#define CROS_EC_DEV_ISH_NAME "cros_ish"#define CROS_EC_DEV_PD_NAME "cros_pd"#define CROS_EC_DEV_SCP_NAME "cros_scp" -#define CROS_EC_DEV_SCP_C1_NAME "cros_scp_c1"#define CROS_EC_DEV_TP_NAME "cros_tp"#define CROS_EC_DEV_EC_INDEX 0Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 1 line
Lee Jones [李琼斯]
Re: [PATCH 01/10] Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
In reply to Prashant MalaniQuoted 11 lines · Prashant Malani
This reverts commit
66ee379d743c69c726b61d078119a34d5be96a35.The feature flag introduced by Commit
66ee379d743c("mfd:cros_ec: Add SCP Core-1 as a new CrOS EC MCU") was not first added in the source EC code base[1]. This can lead to the possible misinterpration of an EC's supported feature set, as well as causes issues with all future feature flag updates.[1] https://source.chromium.org/chromium/chromiumos/platform/ec/+/main:include/ec_commands.h
Signed-off-by Prashant Malani <[email protected]>
Quoted 57 lines
---
While this patch modifies
drivers/mfd, it would be preferable to submit it through the chrome-platform tree, since that eliminates cross-tree dependencies for the series of which this patch is a part.drivers/mfd/cros_ec_dev.c | 5 ----- include/linux/platform_data/cros_ec_commands.h | 2 -- include/linux/platform_data/cros_ec_proto.h | 1 - 3 files changed, 8 deletions(-)drivers/mfd/cros_ec_dev.c +0
-5@@ -64,11 +64,6 @@ static const struct cros_feature_to_name cros_mcu_devices[] = { .name = CROS_EC_DEV_SCP_NAME, .desc = "System Control Processor", }, - { - .id = EC_FEATURE_SCP_C1, - .name = CROS_EC_DEV_SCP_C1_NAME, - .desc = "System Control Processor 2nd Core", - }, { .id = EC_FEATURE_TOUCHPAD, .name = CROS_EC_DEV_TP_NAME,include/linux/platform_data/cros_ec_commands.h +0
-2@@ -1300,8 +1300,6 @@ enum ec_feature_code {* mux. */ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK = 43, -/* The MCU is a System Companion Processor (SCP) 2nd Core. */ - EC_FEATURE_SCP_C1 = 45, };#define EC_FEATURE_MASK_0 (event_code) BIT(event_code % 32)include/linux/platform_data/cros_ec_proto.h +0
-1@@ -19,7 +19,6 @@#define CROS_EC_DEV_ISH_NAME "cros_ish"#define CROS_EC_DEV_PD_NAME "cros_pd"#define CROS_EC_DEV_SCP_NAME "cros_scp" -#define CROS_EC_DEV_SCP_C1_NAME "cros_scp_c1"#define CROS_EC_DEV_TP_NAME "cros_tp"#define CROS_EC_DEV_EC_INDEX 0Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 2/10 platform_chrome: cros_ec: Add Type-C VDM defines
In reply to Prashant MalaniAdd the EC header changes need to support USB Type-C VDM (Vendor Defined Messages) communication between the system and USB PD-enabled peripherals.
The headers are already present in the EC code base, from which they've been ported [1].
[1] https://source.chromium.org/chromium/chromiumos/platform/ec/+/main:include/ec_commands.h
--- .../linux/platform_data/cros_ec_commands.h | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+)
include/linux/platform_data/cros_ec_commands.h +51 -0
@@ -1300,6 +1300,18 @@ enum ec_feature_code {* mux. */ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK =43 , +/* +* The EC supports entering and residing in S4. +*/ +EC_FEATURE_S4_RESIDENCY =44 , +/* +* The EC supports the AP directing mux sets for the board. +*/ +EC_FEATURE_TYPEC_AP_MUX_SET =45 , +/* +* The EC supports the AP composing VDMs for us to send. +*/ + EC_FEATURE_TYPEC_AP_VDM_SEND = 46, };#define EC_FEATURE_MASK_0 (event_code) BIT(event_code % 32)
@@ -5724,6 +5736,8 @@ enum typec_control_command {TYPEC_CONTROL_COMMAND_ENTER_MODE ,TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY ,TYPEC_CONTROL_COMMAND_USB_MUX_SET , +TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE , + TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, };/* Replies the AP may specify to the TBT EnterMode command as a UFP */
@@ -5737,6 +5751,17 @@ struct typec_usb_mux_set {uint8_t mux_flags;/* USB_PD_MUX_*-encoded USB mux state to set */ } __ec_align1; +#define VDO_MAX_SIZE 7 + +struct typec_vdm_req { +/* VDM data, including VDM header */ +uint32_t vdm_data[VDO_MAX_SIZE ]; +/* Number of 32-bit fields filled in */ +uint8_t vdm_data_objects; +/* Partner to address - see enum typec_partner_type */ +uint8_t partner_type; +} __ec_align1; +struct ec_params_typec_control {uint8_t port;uint8_t command;/* enum typec_control_command */
@@ -5752,6 +5777,8 @@ struct ec_params_typec_control {uint8_t mode_to_enter;/* enum typec_mode */ uint8_t tbt_ufp_reply;/* enum typec_tbt_ufp_reply */ struct typec_usb_mux_set mux_params; +/* Used for VMD_REQ */ +struct typec_vdm_req vdm_req_params;uint8_t placeholder[128 ]; }; } __ec_align1;
@@ -5833,6 +5860,8 @@ enum tcpc_cc_polarity {#define PD_STATUS_EVENT_DISCONNECTED BIT(3)#define PD_STATUS_EVENT_MUX_0_SET_DONE BIT(4)#define PD_STATUS_EVENT_MUX_1_SET_DONE BIT(5) +#define PD_STATUS_EVENT_VDM_REQ_REPLY BIT(6) +#define PD_STATUS_EVENT_VDM_REQ_FAILED BIT(7)struct ec_params_typec_status {uint8_t port;
@@ -5876,6 +5905,28 @@ struct ec_response_typec_status {uint32_t sink_cap_pdos[7 ];/* Max 7 PDOs can be present */ } __ec_align1; +/* +* Gather the response to the most recent VDM REQ from the AP +*/ +#define EC_CMD_TYPEC_VDM_RESPONSE 0x013C + +struct ec_params_typec_vdm_response { +uint8_t port; +} __ec_align1; + +struct ec_response_typec_vdm_response { +/* Number of 32-bit fields filled in */ +uint8_t vdm_data_objects; +/* Partner to address - see enum typec_partner_type */ +uint8_t partner_type; +/* Reserved */ +uint16_t reserved; +/* VDM data, including VDM header */ +uint32_t vdm_response[VDO_MAX_SIZE ]; +} __ec_align1; + +#undef VDO_MAX_SIZE +/*****************************************************************************/ /* The command range 0x200-0x2FF is reserved for Rotor. */
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 02/10] platform_chrome: cros_ec: Add Type-C VDM defines
Quoted 10 lines · Prashant Malani
Add the EC header changes need to support USB Type-C VDM (Vendor Defined Messages) communication between the system and USB PD-enabled peripherals.
The headers are already present in the EC code base, from which they've been ported [1].
[1] https://source.chromium.org/chromium/chromiumos/platform/ec/+/main:include/ec_commands.h
Signed-off-by Prashant Malani <[email protected]>
Quoted 105 lines
--- .../linux/platform_data/cros_ec_commands.h | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+)include/linux/platform_data/cros_ec_commands.h +51
-0@@ -1300,6 +1300,18 @@ enum ec_feature_code {* mux. */ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK =43 , +/* +* The EC supports entering and residing in S4. +*/ +EC_FEATURE_S4_RESIDENCY =44 , +/* +* The EC supports the AP directing mux sets for the board. +*/ +EC_FEATURE_TYPEC_AP_MUX_SET =45 , +/* +* The EC supports the AP composing VDMs for us to send. +*/ + EC_FEATURE_TYPEC_AP_VDM_SEND = 46, };#define EC_FEATURE_MASK_0 (event_code) BIT(event_code % 32)@@ -5724,6 +5736,8 @@ enum typec_control_command {TYPEC_CONTROL_COMMAND_ENTER_MODE ,TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY ,TYPEC_CONTROL_COMMAND_USB_MUX_SET , +TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE , + TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, };/* Replies the AP may specify to the TBT EnterMode command as a UFP */ @@ -5737,6 +5751,17 @@ struct typec_usb_mux_set {uint8_t mux_flags;/* USB_PD_MUX_*-encoded USB mux state to set */ } __ec_align1; +#define VDO_MAX_SIZE 7 + +struct typec_vdm_req { +/* VDM data, including VDM header */ +uint32_t vdm_data[VDO_MAX_SIZE ]; +/* Number of 32-bit fields filled in */ +uint8_t vdm_data_objects; +/* Partner to address - see enum typec_partner_type */ +uint8_t partner_type; +} __ec_align1; +struct ec_params_typec_control {uint8_t port;uint8_t command;/* enum typec_control_command */ @@ -5752,6 +5777,8 @@ struct ec_params_typec_control {uint8_t mode_to_enter;/* enum typec_mode */ uint8_t tbt_ufp_reply;/* enum typec_tbt_ufp_reply */ struct typec_usb_mux_set mux_params; +/* Used for VMD_REQ */ +struct typec_vdm_req vdm_req_params;uint8_t placeholder[128 ]; }; } __ec_align1;@@ -5833,6 +5860,8 @@ enum tcpc_cc_polarity {#define PD_STATUS_EVENT_DISCONNECTED BIT(3)#define PD_STATUS_EVENT_MUX_0_SET_DONE BIT(4)#define PD_STATUS_EVENT_MUX_1_SET_DONE BIT(5) +#define PD_STATUS_EVENT_VDM_REQ_REPLY BIT(6) +#define PD_STATUS_EVENT_VDM_REQ_FAILED BIT(7)struct ec_params_typec_status {uint8_t port;@@ -5876,6 +5905,28 @@ struct ec_response_typec_status {uint32_t sink_cap_pdos[7 ];/* Max 7 PDOs can be present */ } __ec_align1; +/* +* Gather the response to the most recent VDM REQ from the AP +*/ +#define EC_CMD_TYPEC_VDM_RESPONSE 0x013C + +struct ec_params_typec_vdm_response { +uint8_t port; +} __ec_align1; + +struct ec_response_typec_vdm_response { +/* Number of 32-bit fields filled in */ +uint8_t vdm_data_objects; +/* Partner to address - see enum typec_partner_type */ +uint8_t partner_type; +/* Reserved */ +uint16_t reserved; +/* VDM data, including VDM header */ +uint32_t vdm_response[VDO_MAX_SIZE ]; +} __ec_align1; + +#undef VDO_MAX_SIZE +/*****************************************************************************/ /* The command range 0x200-0x2FF is reserved for Rotor. */ Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 3/10 platform/chrome: cros_ec_typec: Stash port driver info
In reply to Prashant MalaniStash port number and a pointer to the driver-specific struct in the local typec port struct.
These can be useful to the port driver to figure out how to communicate with the Chrome EC when an altmode-driver related callback is invoked from the Type-C class code.
--- drivers/platform/chrome/cros_ec_typec.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +5 -0
@@ -45,6 +45,7 @@ struct cros_typec_altmode_node {/* Per port data. */ struct cros_typec_port {struct typec_port *port; +int port_num;/* Initial capabilities for the port. */ struct typec_capability caps;struct typec_partner *partner;
@@ -78,6 +79,8 @@ struct cros_typec_port {struct usb_power_delivery *partner_pd;struct usb_power_delivery_capabilities *partner_src_caps;struct usb_power_delivery_capabilities *partner_sink_caps; + +struct cros_typec_data *typec_data; };/* Platform-specific data for the Chrome OS EC Type C controller. */
@@ -408,6 +411,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) goto unregister_ports; } + cros_port->port_num = port_num; + cros_port->typec_data = typec; typec->ports[port_num] = cros_port; cap = &cros_port->caps;
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 03/10] platform/chrome: cros_ec_typec: Stash port driver info
Quoted 8 lines · Prashant Malani
Stash port number and a pointer to the driver-specific struct in the local typec port struct.
These can be useful to the port driver to figure out how to communicate with the Chrome EC when an altmode-driver related callback is invoked from the Type-C class code.
Signed-off-by Prashant Malani <[email protected]>
Quoted 37 lines
--- drivers/platform/chrome/cros_ec_typec.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/platform/chrome/cros_ec_typec.c +5
-0@@ -45,6 +45,7 @@ struct cros_typec_altmode_node {/* Per port data. */ struct cros_typec_port {struct typec_port *port; +int port_num;/* Initial capabilities for the port. */ struct typec_capability caps;struct typec_partner *partner;@@ -78,6 +79,8 @@ struct cros_typec_port {struct usb_power_delivery *partner_pd;struct usb_power_delivery_capabilities *partner_src_caps;struct usb_power_delivery_capabilities *partner_sink_caps; + +struct cros_typec_data *typec_data; };/* Platform-specific data for the Chrome OS EC Type C controller. */ @@ -408,6 +411,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) goto unregister_ports; } + cros_port->port_num = port_num; + cros_port->typec_data = typec; typec->ports[port_num] = cros_port; cap = &cros_port->caps;Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 4/10 platform/chrome: cros_ec_typec: Set port alt mode drvdata
In reply to Prashant MalaniSave the ChromeOS-specific Type-C port info in the port altmodes' driver data. This makes communication with the ChromeOS EC (Embedded Controller) easier when alt mode drivers need to send messages to peripherals.
--- drivers/platform/chrome/cros_ec_typec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +2 -0
@@ -345,6 +345,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,if (IS_ERR (amode))return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_DP ] = amode; +typec_altmode_set_drvdata (amode, port);/* * Register TBT compatibility alt mode. The EC will not enter the mode
@@ -358,6 +359,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,if (IS_ERR (amode))return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_TBT ] = amode; +typec_altmode_set_drvdata (amode, port); port->state.alt =NULL ; port->state.mode =TYPEC_STATE_USB ;
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 04/10] platform/chrome: cros_ec_typec: Set port alt mode drvdata
Quoted 7 lines · Prashant Malani
Save the ChromeOS-specific Type-C port info in the port altmodes' driver data. This makes communication with the ChromeOS EC (Embedded Controller) easier when alt mode drivers need to send messages to peripherals.
Cc Heikki Krogerus <[email protected]>Signed-off-by Prashant Malani <[email protected]>
Quoted 28 lines
--- drivers/platform/chrome/cros_ec_typec.c | 2 ++ 1 file changed, 2 insertions(+)drivers/platform/chrome/cros_ec_typec.c +2
-0@@ -345,6 +345,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,if (IS_ERR (amode))return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_DP ] = amode; +typec_altmode_set_drvdata (amode, port);/* * Register TBT compatibility alt mode. The EC will not enter the mode @@ -358,6 +359,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,if (IS_ERR (amode))return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_TBT ] = amode; +typec_altmode_set_drvdata (amode, port); port->state.alt =NULL ; port->state.mode =TYPEC_STATE_USB ;Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 5/10 platform/chrome: cros_ec_typec: Update port DP VDO
In reply to Prashant MalaniThe port advertising DP support is a Type-C receptacle. Fix the port's DisplayPort VDO to reflect this.
--- drivers/platform/chrome/cros_ec_typec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_typec.c +1 -1
@@ -27,7 +27,7 @@#define DRV_NAME "cros-ec-typec"#define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \ - DP_CAP_DFP_D) + DP_CAP_DFP_D | DP_CAP_RECEPTACLE)/* Supported alt modes. */ enum {
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 05/10] platform/chrome: cros_ec_typec: Update port DP VDO
Quoted 5 lines · Prashant Malani
The port advertising DP support is a Type-C receptacle. Fix the port's DisplayPort VDO to reflect this.
Fixes 1903adae0464 ("platform/chrome: cros_ec_typec: Add bit offset for DP VDO")Signed-off-by Prashant Malani <[email protected]>
Quoted 21 lines
--- drivers/platform/chrome/cros_ec_typec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/chrome/cros_ec_typec.c +1
-1@@ -27,7 +27,7 @@#define DRV_NAME "cros-ec-typec"#define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \ - DP_CAP_DFP_D) + DP_CAP_DFP_D | DP_CAP_RECEPTACLE)/* Supported alt modes. */ enum {Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 6/10 platform/chrome: cros_ec_typec: Move structs to header
In reply to Prashant MalaniMove ChromeOS Type-C structs into their own header, so they can be referenced by other files which can be added to the same module.
No functional changes introduced by this patch.
--- MAINTAINERS | 2 +- drivers/platform/chrome/cros_ec_typec.c | 78 +---------------------- drivers/platform/chrome/cros_ec_typec.h | 85 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 77 deletions(-) create mode 100644 drivers/platform/chrome/cros_ec_typec.h
MAINTAINERS +1 -1
@@ -4998,7 +4998,7 @@ CHROMEOS EC USB TYPE-C DRIVER M: Prashant Malani <[email protected]> L: [email protected] S: Maintained -F: drivers/platform/chrome/cros_ec_typec.c +F: drivers/platform/chrome/cros_ec_typec.* F: drivers/platform/chrome/cros_typec_switch.c CHROMEOS EC USB PD NOTIFY DRIVER
drivers/platform/chrome/cros_ec_typec.c +2 -76
98 lines not on this page · raw message
drivers/platform/chrome/cros_ec_typec.h new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 06/10] platform/chrome: cros_ec_typec: Move structs to header
Quoted 6 lines · Prashant Malani
Move ChromeOS Type-C structs into their own header, so they can be referenced by other files which can be added to the same module.
No functional changes introduced by this patch.
Signed-off-by Prashant Malani <[email protected]>
Quoted 218 lines
--- MAINTAINERS | 2 +- drivers/platform/chrome/cros_ec_typec.c | 78 +---------------------- drivers/platform/chrome/cros_ec_typec.h | 85 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 77 deletions(-) create mode 100644 drivers/platform/chrome/cros_ec_typec.hMAINTAINERS +1
-1@@ -4998,7 +4998,7 @@ CHROMEOS EC USB TYPE-C DRIVER M: Prashant Malani <[email protected]> L: [email protected] S: Maintained -F: drivers/platform/chrome/cros_ec_typec.c +F: drivers/platform/chrome/cros_ec_typec.* F: drivers/platform/chrome/cros_typec_switch.c CHROMEOS EC USB PD NOTIFY DRIVERdrivers/platform/chrome/cros_ec_typec.c +2
-76@@ -7,96 +7,22 @@*/ #include <linux/acpi.h> -#include <linux/list.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_data/cros_ec_commands.h> -#include <linux/platform_data/cros_ec_proto.h> #include <linux/platform_data/cros_usbpd_notify.h> #include <linux/platform_device.h> -#include <linux/usb/pd.h> #include <linux/usb/pd_vdo.h> -#include <linux/usb/typec.h> -#include <linux/usb/typec_altmode.h> #include <linux/usb/typec_dp.h> -#include <linux/usb/typec_mux.h> -#include <linux/usb/typec_retimer.h> #include <linux/usb/typec_tbt.h> -#include <linux/usb/role.h> + +#include "cros_ec_typec.h" #define DRV_NAME "cros-ec-typec"#define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \ DP_CAP_DFP_D | DP_CAP_RECEPTACLE) -/* Supported alt modes. */ -enum { -CROS_EC_ALTMODE_DP =0 , -CROS_EC_ALTMODE_TBT , -CROS_EC_ALTMODE_MAX , -}; - -/* Container for altmode pointer nodes. */ -struct cros_typec_altmode_node { -struct typec_altmode *amode; -struct list_head list; -}; - -/* Per port data. */ -struct cros_typec_port { -struct typec_port *port; -int port_num; -/* Initial capabilities for the port. */ -struct typec_capability caps; -struct typec_partner *partner; -struct typec_cable *cable; -/* SOP' plug. */ -struct typec_plug *plug; -/* Port partner PD identity info. */ -struct usb_pd_identity p_identity; -/* Port cable PD identity info. */ -struct usb_pd_identity c_identity; -struct typec_switch *ori_sw; -struct typec_mux *mux; -struct typec_retimer *retimer; -struct usb_role_switch *role_sw; - -/* Variables keeping track of switch state. */ -struct typec_mux_state state; -uint8_t mux_flags; -uint8_t role; - -struct typec_altmode *port_altmode[CROS_EC_ALTMODE_MAX ]; - -/* Flag indicating that PD partner discovery data parsing is completed. */ -bool sop_disc_done; -bool sop_prime_disc_done; -struct ec_response_typec_discovery *disc_data; -struct list_head partner_mode_list; -struct list_head plug_mode_list; - -/* PDO-related structs */ -struct usb_power_delivery *partner_pd; -struct usb_power_delivery_capabilities *partner_src_caps; -struct usb_power_delivery_capabilities *partner_sink_caps; - -struct cros_typec_data *typec_data; -}; - -/* Platform-specific data for the Chrome OS EC Type C controller. */ -struct cros_typec_data { -struct device *dev; -struct cros_ec_device *ec; -int num_ports; -unsigned int pd_ctrl_ver; -/* Array of ports, indexed by port number. */ -struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS ]; -struct notifier_block nb; -struct work_struct port_work; -bool typec_cmd_supported; -bool needs_mux_ack; -}; -static int cros_typec_parse_port_props (struct typec_capability *cap,struct fwnode_handle *fwnode,struct device *dev)drivers/platform/chrome/cros_ec_typec.h new file +85
-0@@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __CROS_EC_TYPEC__ +#define __CROS_EC_TYPEC__ + +#include <linux/list.h> +#include <linux/notifier.h> +#include <linux/platform_data/cros_ec_proto.h> +#include <linux/usb/pd.h> +#include <linux/usb/role.h> +#include <linux/usb/typec.h> +#include <linux/usb/typec_altmode.h> +#include <linux/usb/typec_mux.h> +#include <linux/usb/typec_retimer.h> +#include <linux/workqueue.h> + +/* Supported alt modes. */ +enum { +CROS_EC_ALTMODE_DP =0 , +CROS_EC_ALTMODE_TBT , +CROS_EC_ALTMODE_MAX , +}; + +/* Container for altmode pointer nodes. */ +struct cros_typec_altmode_node { +struct typec_altmode *amode; +struct list_head list; +}; + +/* Platform-specific data for the Chrome OS EC Type C controller. */ +struct cros_typec_data { +struct device *dev; +struct cros_ec_device *ec; +int num_ports; +unsigned int pd_ctrl_ver; +/* Array of ports, indexed by port number. */ +struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS ]; +struct notifier_block nb; +struct work_struct port_work; +bool typec_cmd_supported; +bool needs_mux_ack; +}; + +/* Per port data. */ +struct cros_typec_port { +struct typec_port *port; +int port_num; +/* Initial capabilities for the port. */ +struct typec_capability caps; +struct typec_partner *partner; +struct typec_cable *cable; +/* SOP' plug. */ +struct typec_plug *plug; +/* Port partner PD identity info. */ +struct usb_pd_identity p_identity; +/* Port cable PD identity info. */ +struct usb_pd_identity c_identity; +struct typec_switch *ori_sw; +struct typec_mux *mux; +struct typec_retimer *retimer; +struct usb_role_switch *role_sw; + +/* Variables keeping track of switch state. */ +struct typec_mux_state state; +uint8_t mux_flags; +uint8_t role; + +struct typec_altmode *port_altmode[CROS_EC_ALTMODE_MAX ]; + +/* Flag indicating that PD partner discovery data parsing is completed. */ +bool sop_disc_done; +bool sop_prime_disc_done; +struct ec_response_typec_discovery *disc_data; +struct list_head partner_mode_list; +struct list_head plug_mode_list; + +/* PDO-related structs */ +struct usb_power_delivery *partner_pd; +struct usb_power_delivery_capabilities *partner_src_caps; +struct usb_power_delivery_capabilities *partner_sink_caps; + +struct cros_typec_data *typec_data; +}; + +#endif /* __CROS_EC_TYPEC__ */ Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 7/10 platform/chrome: cros_ec_typec: Alter module name with hyphens
In reply to Prashant MalaniChange the Type-C module name from cros_ec_typec to cros-ec-typec. This allows us to include more files in the same module (rather than relying on the file name cros_ec_typec to also be the module name).
--- drivers/platform/chrome/Kconfig | 2 +- drivers/platform/chrome/Makefile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/platform/chrome/Kconfig +1 -1
@@ -226,7 +226,7 @@ config CROS_EC_TYPEC information from the Chrome OS EC. To compile this driver as a module, choose M here: the module will be - called cros_ec_typec. + called cros-ec-typec. config CROS_HPS_I2C tristate "ChromeOS HPS device"
drivers/platform/chrome/Makefile +2 -1
@@ -16,7 +16,8 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o -obj-$(CONFIG_CROS_EC_TYPEC) += cros_ec_typec.o +cros-ec-typec-objs := cros_ec_typec.o +obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens
Quoted 5 lines · Prashant Malani
Change the Type-C module name from
cros_ec_typecto cros-ec-typec. This allows us to include more files in the same module (rather than relying on the file namecros_ec_typecto also be the module name).Signed-off-by Prashant Malani <[email protected]>
Quoted 36 lines
--- drivers/platform/chrome/Kconfig | 2 +- drivers/platform/chrome/Makefile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)drivers/platform/chrome/Kconfig +1
-1@@ -226,7 +226,7 @@ config CROS_EC_TYPEC information from the Chrome OS EC. To compile this driver as a module, choose M here: the module will be - called cros_ec_typec. + called cros-ec-typec. config CROS_HPS_I2C tristate "ChromeOS HPS device"drivers/platform/chrome/Makefile +2
-1@@ -16,7 +16,8 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o -obj-$(CONFIG_CROS_EC_TYPEC) += cros_ec_typec.o +cros-ec-typec-objs := cros_ec_typec.o +obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.oSignature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 8/10 platform/chrome: cros_ec_typec: Add initial VDM support
In reply to Prashant MalaniAdd ops to support USB PD VDM (Vendor Defined Message) from the port driver. This enables the port driver to interface with alternate mode drivers and communicate with connected peripherals.
The initial support just contains an implementation of the Enter Mode command.
--- MAINTAINERS | 1 + drivers/platform/chrome/Makefile | 2 +- drivers/platform/chrome/cros_ec_typec.c | 3 ++ drivers/platform/chrome/cros_typec_vdm.c | 43 ++++++++++++++++++++++++ drivers/platform/chrome/cros_typec_vdm.h | 10 ++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/chrome/cros_typec_vdm.c create mode 100644 drivers/platform/chrome/cros_typec_vdm.h
MAINTAINERS +1 -0
@@ -5000,6 +5000,7 @@ L: [email protected] S: Maintained F: drivers/platform/chrome/cros_ec_typec.* F: drivers/platform/chrome/cros_typec_switch.c +F: drivers/platform/chrome/cros_typec_vdm.* CHROMEOS EC USB PD NOTIFY DRIVER M: Prashant Malani <[email protected]>
drivers/platform/chrome/Makefile +1 -1
@@ -16,7 +16,7 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o -cros-ec-typec-objs := cros_ec_typec.o +cros-ec-typec-objs := cros_ec_typec.o cros_typec_vdm.o obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
drivers/platform/chrome/cros_ec_typec.c +3 -0
@@ -17,6 +17,7 @@#include <linux/usb/typec_tbt.h> #include "cros_ec_typec.h" +#include "cros_typec_vdm.h" #define DRV_NAME "cros-ec-typec"
@@ -272,6 +273,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_DP ] = amode;typec_altmode_set_drvdata (amode, port); + amode->ops = &port_amode_ops;/* * Register TBT compatibility alt mode. The EC will not enter the mode
@@ -286,6 +288,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_TBT ] = amode;typec_altmode_set_drvdata (amode, port); + amode->ops = &port_amode_ops; port->state.alt =NULL ; port->state.mode =TYPEC_STATE_USB ;
drivers/platform/chrome/cros_typec_vdm.c new file +43 -0
43 lines not on this page · raw message
drivers/platform/chrome/cros_typec_vdm.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __CROS_TYPEC_VDM__ +#define __CROS_TYPEC_VDM__ + +#include <linux/usb/typec_altmode.h> + +extern struct typec_altmode_ops port_amode_ops; + +#endif /* __CROS_TYPEC_VDM__ */
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 08/10] platform/chrome: cros_ec_typec: Add initial VDM support
Quoted 9 lines · Prashant Malani
Add ops to support USB PD VDM (Vendor Defined Message) from the port driver. This enables the port driver to interface with alternate mode drivers and communicate with connected peripherals.
The initial support just contains an implementation of the Enter Mode command.
Cc Heikki Krogerus <[email protected]>Signed-off-by Prashant Malani <[email protected]>
Quoted 132 lines
--- MAINTAINERS | 1 + drivers/platform/chrome/Makefile | 2 +- drivers/platform/chrome/cros_ec_typec.c | 3 ++ drivers/platform/chrome/cros_typec_vdm.c | 43 ++++++++++++++++++++++++ drivers/platform/chrome/cros_typec_vdm.h | 10 ++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/chrome/cros_typec_vdm.c create mode 100644 drivers/platform/chrome/cros_typec_vdm.hMAINTAINERS +1
-0@@ -5000,6 +5000,7 @@ L: [email protected] S: Maintained F: drivers/platform/chrome/cros_ec_typec.* F: drivers/platform/chrome/cros_typec_switch.c +F: drivers/platform/chrome/cros_typec_vdm.* CHROMEOS EC USB PD NOTIFY DRIVER M: Prashant Malani <[email protected]>drivers/platform/chrome/Makefile +1
-1@@ -16,7 +16,7 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) += cros_typec_switch.o obj-$(CONFIG_CROS_EC_RPMSG) += cros_ec_rpmsg.o obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_mec.o -cros-ec-typec-objs := cros_ec_typec.o +cros-ec-typec-objs := cros_ec_typec.o cros_typec_vdm.o obj-$(CONFIG_CROS_EC_TYPEC) += cros-ec-typec.o obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.odrivers/platform/chrome/cros_ec_typec.c +3
-0@@ -17,6 +17,7 @@#include <linux/usb/typec_tbt.h> #include "cros_ec_typec.h" +#include "cros_typec_vdm.h" #define DRV_NAME "cros-ec-typec"@@ -272,6 +273,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_DP ] = amode;typec_altmode_set_drvdata (amode, port); + amode->ops = &port_amode_ops;/* * Register TBT compatibility alt mode. The EC will not enter the mode @@ -286,6 +288,7 @@ static int cros_typec_register_port_altmodes(struct cros_typec_data *typec,return PTR_ERR (amode); port->port_altmode[CROS_EC_ALTMODE_TBT ] = amode;typec_altmode_set_drvdata (amode, port); + amode->ops = &port_amode_ops; port->state.alt =NULL ; port->state.mode =TYPEC_STATE_USB ;drivers/platform/chrome/cros_typec_vdm.c new file +43
-0@@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* USB Power Delivery Vendor Defined Message (VDM) support code. +* +* Copyright 2023 Google LLC +* Author: Prashant Malani <[email protected]> +*/ + +#include <linux/module.h> +#include <linux/platform_data/cros_ec_commands.h> +#include <linux/usb/pd_vdo.h> + +#include "cros_ec_typec.h" +#include "cros_typec_vdm.h" + +static int cros_typec_port_amode_enter (struct typec_altmode *amode,u32 *vdo) +{ +struct cros_typec_port *port =typec_altmode_get_drvdata (amode); +struct ec_params_typec_control req = { + .port = port->port_num, + .command =TYPEC_CONTROL_COMMAND_SEND_VDM_REQ , + }; +struct typec_vdm_req vdm_req = {}; +u32 hdr; + + hdr =VDO (amode->svid,1 ,SVDM_VER_2_0 ,CMD_ENTER_MODE ); + hdr |=VDO_OPOS (amode->mode); + + vdm_req.vdm_data[0 ] = hdr; + vdm_req.vdm_data_objects =1 ; + vdm_req.partner_type =TYPEC_PARTNER_SOP ; + req.vdm_req_params = vdm_req; + +dev_dbg (port->typec_data->dev,"Sending EnterMode VDM, hdr: %x, port: %d\n" , + hdr, port->port_num); + +return cros_ec_cmd (port->typec_data->ec,0 ,EC_CMD_TYPEC_CONTROL , &req, +sizeof (req),NULL ,0 ); +} + +struct typec_altmode_ops port_amode_ops = { + .enter = cros_typec_port_amode_enter, +};drivers/platform/chrome/cros_typec_vdm.h new file +10
-0@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __CROS_TYPEC_VDM__ +#define __CROS_TYPEC_VDM__ + +#include <linux/usb/typec_altmode.h> + +extern struct typec_altmode_ops port_amode_ops; + +#endif /* __CROS_TYPEC_VDM__ */ Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 9/10 platform/chrome: cros_typec_vdm: Add VDM reply support
In reply to Prashant MalaniHandle response VDMs which are sent by the partner (replying to VDMs sent by the host system itself). These get forwarded to the altmode driver.
--- drivers/platform/chrome/cros_ec_typec.c | 7 +++++ drivers/platform/chrome/cros_typec_vdm.c | 39 ++++++++++++++++++++++++ drivers/platform/chrome/cros_typec_vdm.h | 2 ++ 3 files changed, 48 insertions(+)
drivers/platform/chrome/cros_ec_typec.c +7 -0
@@ -1000,6 +1000,13 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num "Failed SOP Disc event clear, port: %d\n", port_num); } } + +if (resp.events &PD_STATUS_EVENT_VDM_REQ_REPLY ) { +cros_typec_handle_vdm_response (typec, port_num); + ret =cros_typec_send_clear_event (typec, port_num,PD_STATUS_EVENT_VDM_REQ_REPLY ); +if (ret <0 ) +dev_warn (typec->dev,"Failed VDM Reply event clear, port: %d\n" , port_num); + } }static int cros_typec_port_update (struct cros_typec_data *typec,int port_num)
drivers/platform/chrome/cros_typec_vdm.c +39 -0
@@ -13,6 +13,45 @@#include "cros_ec_typec.h" #include "cros_typec_vdm.h" +/* +* Retrieves a VDM response from the EC and forwards it to the altmode driver based on SVID. +*/ +void cros_typec_handle_vdm_response (struct cros_typec_data *typec,int port_num) +{ +struct ec_response_typec_vdm_response resp; +struct ec_params_typec_vdm_response req = { + .port = port_num, + }; +struct typec_altmode *amode; +u16 svid; +u32 hdr; +int ret; + + ret =cros_ec_cmd (typec->ec,0 ,EC_CMD_TYPEC_VDM_RESPONSE , &req, +sizeof (req), &resp,sizeof (resp)); +if (ret <0 ) { +dev_warn (typec->dev,"Failed VDM response fetch, port: %d\n" , port_num); +return ; + } + + hdr = resp.vdm_response[0 ]; + svid =PD_VDO_VID (hdr); +dev_dbg (typec->dev,"Received VDM header: %x, port: %d\n" , hdr, port_num); + + amode =typec_match_altmode (typec->ports[port_num]->port_altmode,CROS_EC_ALTMODE_MAX , + svid,PD_VDO_OPOS (hdr)); +if (!amode) { +dev_err (typec->dev,"Received VDM for unregistered altmode (SVID:%x), port: %d\n" , + svid, port_num); +return ; + } + + ret =typec_altmode_vdm (amode, hdr, &resp.vdm_response[1 ], resp.vdm_data_objects); +if (ret) +dev_err (typec->dev,"Failed to forward VDM to altmode (SVID:%x), port: %d\n" , + svid, port_num); +} +static int cros_typec_port_amode_enter (struct typec_altmode *amode,u32 *vdo) {struct cros_typec_port *port =typec_altmode_get_drvdata (amode);
drivers/platform/chrome/cros_typec_vdm.h +2 -0
@@ -7,4 +7,6 @@extern struct typec_altmode_ops port_amode_ops; +void cros_typec_handle_vdm_response (struct cros_typec_data *typec,int port_num); +#endif /* __CROS_TYPEC_VDM__ */
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 09/10] platform/chrome: cros_typec_vdm: Add VDM reply support
Quoted 6 lines · Prashant Malani
Handle response VDMs which are sent by the partner (replying to VDMs sent by the host system itself). These get forwarded to the altmode driver.
Cc Heikki Krogerus <[email protected]>Signed-off-by Prashant Malani <[email protected]>
Quoted 89 lines
--- drivers/platform/chrome/cros_ec_typec.c | 7 +++++ drivers/platform/chrome/cros_typec_vdm.c | 39 ++++++++++++++++++++++++ drivers/platform/chrome/cros_typec_vdm.h | 2 ++ 3 files changed, 48 insertions(+)drivers/platform/chrome/cros_ec_typec.c +7
-0@@ -1000,6 +1000,13 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num "Failed SOP Disc event clear, port: %d\n", port_num); } } + +if (resp.events &PD_STATUS_EVENT_VDM_REQ_REPLY ) { +cros_typec_handle_vdm_response (typec, port_num); + ret =cros_typec_send_clear_event (typec, port_num,PD_STATUS_EVENT_VDM_REQ_REPLY ); +if (ret <0 ) +dev_warn (typec->dev,"Failed VDM Reply event clear, port: %d\n" , port_num); + } }static int cros_typec_port_update (struct cros_typec_data *typec,int port_num)drivers/platform/chrome/cros_typec_vdm.c +39
-0@@ -13,6 +13,45 @@#include "cros_ec_typec.h" #include "cros_typec_vdm.h" +/* +* Retrieves a VDM response from the EC and forwards it to the altmode driver based on SVID. +*/ +void cros_typec_handle_vdm_response (struct cros_typec_data *typec,int port_num) +{ +struct ec_response_typec_vdm_response resp; +struct ec_params_typec_vdm_response req = { + .port = port_num, + }; +struct typec_altmode *amode; +u16 svid; +u32 hdr; +int ret; + + ret =cros_ec_cmd (typec->ec,0 ,EC_CMD_TYPEC_VDM_RESPONSE , &req, +sizeof (req), &resp,sizeof (resp)); +if (ret <0 ) { +dev_warn (typec->dev,"Failed VDM response fetch, port: %d\n" , port_num); +return ; + } + + hdr = resp.vdm_response[0 ]; + svid =PD_VDO_VID (hdr); +dev_dbg (typec->dev,"Received VDM header: %x, port: %d\n" , hdr, port_num); + + amode =typec_match_altmode (typec->ports[port_num]->port_altmode,CROS_EC_ALTMODE_MAX , + svid,PD_VDO_OPOS (hdr)); +if (!amode) { +dev_err (typec->dev,"Received VDM for unregistered altmode (SVID:%x), port: %d\n" , + svid, port_num); +return ; + } + + ret =typec_altmode_vdm (amode, hdr, &resp.vdm_response[1 ], resp.vdm_data_objects); +if (ret) +dev_err (typec->dev,"Failed to forward VDM to altmode (SVID:%x), port: %d\n" , + svid, port_num); +} +static int cros_typec_port_amode_enter (struct typec_altmode *amode,u32 *vdo) {struct cros_typec_port *port =typec_altmode_get_drvdata (amode);drivers/platform/chrome/cros_typec_vdm.h +2
-0@@ -7,4 +7,6 @@extern struct typec_altmode_ops port_amode_ops; +void cros_typec_handle_vdm_response (struct cros_typec_data *typec,int port_num); +#endif /* __CROS_TYPEC_VDM__ */ Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
PATCH 10/10 platform/chrome: cros_typec_vdm: Add VDM send support
In reply to Prashant MalaniAdd support to send generic VDM messages from the alt mode driver to the partner (via the ChromeOS EC). The function introduced here is intended to be called by the alt mode driver (via the Type-C bus logic).
--- drivers/platform/chrome/cros_typec_vdm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/platform/chrome/cros_typec_vdm.c +24 -0
@@ -77,6 +77,30 @@ static int cros_typec_port_amode_enter(struct typec_altmode *amode, u32 *vdo) sizeof(req), NULL, 0); } +static int cros_typec_port_amode_vdm (struct typec_altmode *amode,const u32 hdr, +const u32 *vdo,int cnt) +{ +struct cros_typec_port *port =typec_altmode_get_drvdata (amode); +struct ec_params_typec_control req = { + .port = port->port_num, + .command =TYPEC_CONTROL_COMMAND_SEND_VDM_REQ , + }; +struct typec_vdm_req vdm_req = {}; + + vdm_req.vdm_data[0 ] = hdr; + vdm_req.vdm_data_objects = cnt; +memcpy (&vdm_req.vdm_data[1 ], vdo, cnt -1 ); + vdm_req.partner_type =TYPEC_PARTNER_SOP ; + req.vdm_req_params = vdm_req; + +dev_dbg (port->typec_data->dev,"Sending VDM, hdr: %x, num_objects: %d, port: %d\n" , + hdr, cnt, port->port_num); + +return cros_ec_cmd (port->typec_data->ec,0 ,EC_CMD_TYPEC_CONTROL , &req, +sizeof (req),NULL ,0 ); +} +struct typec_altmode_ops port_amode_ops = { .enter = cros_typec_port_amode_enter, + .vdm = cros_typec_port_amode_vdm, };
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 10/10] platform/chrome: cros_typec_vdm: Add VDM send support
Quoted 6 lines · Prashant Malani
Add support to send generic VDM messages from the alt mode driver to the partner (via the ChromeOS EC). The function introduced here is intended to be called by the alt mode driver (via the Type-C bus logic).
Cc Heikki Krogerus <[email protected]>Signed-off-by Prashant Malani <[email protected]>
Quoted 43 lines
--- drivers/platform/chrome/cros_typec_vdm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)drivers/platform/chrome/cros_typec_vdm.c +24
-0@@ -77,6 +77,30 @@ static int cros_typec_port_amode_enter(struct typec_altmode *amode, u32 *vdo) sizeof(req), NULL, 0); } +static int cros_typec_port_amode_vdm (struct typec_altmode *amode,const u32 hdr, +const u32 *vdo,int cnt) +{ +struct cros_typec_port *port =typec_altmode_get_drvdata (amode); +struct ec_params_typec_control req = { + .port = port->port_num, + .command =TYPEC_CONTROL_COMMAND_SEND_VDM_REQ , + }; +struct typec_vdm_req vdm_req = {}; + + vdm_req.vdm_data[0 ] = hdr; + vdm_req.vdm_data_objects = cnt; +memcpy (&vdm_req.vdm_data[1 ], vdo, cnt -1 ); + vdm_req.partner_type =TYPEC_PARTNER_SOP ; + req.vdm_req_params = vdm_req; + +dev_dbg (port->typec_data->dev,"Sending VDM, hdr: %x, num_objects: %d, port: %d\n" , + hdr, cnt, port->port_num); + +return cros_ec_cmd (port->typec_data->ec,0 ,EC_CMD_TYPEC_CONTROL , &req, +sizeof (req),NULL ,0 ); +} +struct typec_altmode_ops port_amode_ops = { .enter = cros_typec_port_amode_enter, + .vdm = cros_typec_port_amode_vdm, };Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 7 lines
Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. [email protected] Chromium OS Project [email protected]
Quoted 14 lines · Prashant Malani
This series adds support for sending and receiving USB PD Vendor Defined Messages (VDMs) between the Application Processor's Type-C ports and connected peripherals.
Thir enables the Application processor to enter alternate modes and process VDMs directly, instead of relying on state machines that exist inside of co-processors like the ChromeOS Embedded Controller (EC).
Patch 1/10 reverts an incorrect EC header modification. Patch 2/10 to 5/10 update headers and existing Type-C structs to accommodate the VDM code.
Patch 6/10 and 7/10 prepare the Type-C driver to have more than 1 file. Patch 8/10 to 10/10 introduce the VDM functionality.
Quoted 4 lines
Patch submissions suggestion (if approved):
- Even though Patch 1 touchesdrivers/mfd, it would be better to take the entire series through the cbrome-platform branch, to avoid cross-dependencies across maintainer trees.
For the whole series, FWIW:
Quoted 26 lines
Prashant Malani (10):
Revert "mfd:cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
platform_chrome:cros_ec: Add Type-C VDM defines platform/chrome:cros_ec_typec: Stash port driver info platform/chrome:cros_ec_typec: Set port alt mode drvdata platform/chrome:cros_ec_typec: Update port DP VDO platform/chrome:cros_ec_typec: Move structs to header platform/chrome:cros_ec_typec: Alter module name with hyphens platform/chrome:cros_ec_typec: Add initial VDM support platform/chrome:cros_typec_vdm: Add VDM reply support platform/chrome:cros_typec_vdm: Add VDM send supportMAINTAINERS | 3 +- drivers/mfd/cros_ec_dev.c | 5 - drivers/platform/chrome/Kconfig | 2 +- drivers/platform/chrome/Makefile | 3 +- drivers/platform/chrome/cros_ec_typec.c | 91 +++------------ drivers/platform/chrome/cros_ec_typec.h | 85 ++++++++++++++ drivers/platform/chrome/cros_typec_vdm.c | 106 ++++++++++++++++++ drivers/platform/chrome/cros_typec_vdm.h | 12 ++ .../linux/platform_data/cros_ec_commands.h | 53 ++++++++- include/linux/platform_data/cros_ec_proto.h | 1 - 10 files changed, 276 insertions(+), 85 deletions(-) create mode 100644 drivers/platform/chrome/cros_ec_typec.h create mode 100644 drivers/platform/chrome/cros_typec_vdm.c create mode 100644 drivers/platform/chrome/cros_typec_vdm.h
Signature · 1 line
heikki
This series was applied to chrome-platform/linux.git (for-kernelci) by Prashant Malani <[email protected]>:
Hello:
This series was applied to chrome-platform/linux.git (for-kernelci) by Prashant Malani <[email protected]>:
Quoted 9 lines · On Wed, 28 Dec 2022 00:45:03 +0000 you wrote:
This series adds support for sending and receiving USB PD Vendor Defined Messages (VDMs) between the Application Processor's Type-C ports and connected peripherals.
Thir enables the Application processor to enter alternate modes and process VDMs directly, instead of relying on state machines that exist inside of co-processors like the ChromeOS Embedded Controller (EC).
[...]
Here is the summary with links:
- [01/10] Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
https://git.kernel.org/chrome-platform/c/0ac7200e3317 - [02/10] platform_chrome: cros_ec: Add Type-C VDM defines https://git.kernel.org/chrome-platform/c/0e0dba884c43 - [03/10] platform/chrome: cros_ec_typec: Stash port driver info https://git.kernel.org/chrome-platform/c/4dc9355cef4f - [04/10] platform/chrome: cros_ec_typec: Set port alt mode drvdata https://git.kernel.org/chrome-platform/c/c856e3ff98bb - [05/10] platform/chrome: cros_ec_typec: Update port DP VDO https://git.kernel.org/chrome-platform/c/8d2b28df6c3d - [06/10] platform/chrome: cros_ec_typec: Move structs to header https://git.kernel.org/chrome-platform/c/690580965153 - [07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens https://git.kernel.org/chrome-platform/c/e5eea6a3319f - [08/10] platform/chrome: cros_ec_typec: Add initial VDM support https://git.kernel.org/chrome-platform/c/493e699b9934 - [09/10] platform/chrome: cros_typec_vdm: Add VDM reply support https://git.kernel.org/chrome-platform/c/50ed638bbc47 - [10/10] platform/chrome: cros_typec_vdm: Add VDM send support https://git.kernel.org/chrome-platform/c/40a9b13a09ef
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
This series was applied to chrome-platform/linux.git (for-next) by Prashant Malani <[email protected]>:
Hello:
This series was applied to chrome-platform/linux.git (for-next) by Prashant Malani <[email protected]>:
Quoted 9 lines · On Wed, 28 Dec 2022 00:45:03 +0000 you wrote:
This series adds support for sending and receiving USB PD Vendor Defined Messages (VDMs) between the Application Processor's Type-C ports and connected peripherals.
Thir enables the Application processor to enter alternate modes and process VDMs directly, instead of relying on state machines that exist inside of co-processors like the ChromeOS Embedded Controller (EC).
[...]
Here is the summary with links:
- [01/10] Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU"
https://git.kernel.org/chrome-platform/c/0ac7200e3317 - [02/10] platform_chrome: cros_ec: Add Type-C VDM defines https://git.kernel.org/chrome-platform/c/0e0dba884c43 - [03/10] platform/chrome: cros_ec_typec: Stash port driver info https://git.kernel.org/chrome-platform/c/4dc9355cef4f - [04/10] platform/chrome: cros_ec_typec: Set port alt mode drvdata https://git.kernel.org/chrome-platform/c/c856e3ff98bb - [05/10] platform/chrome: cros_ec_typec: Update port DP VDO https://git.kernel.org/chrome-platform/c/8d2b28df6c3d - [06/10] platform/chrome: cros_ec_typec: Move structs to header https://git.kernel.org/chrome-platform/c/690580965153 - [07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens https://git.kernel.org/chrome-platform/c/e5eea6a3319f - [08/10] platform/chrome: cros_ec_typec: Add initial VDM support https://git.kernel.org/chrome-platform/c/493e699b9934 - [09/10] platform/chrome: cros_typec_vdm: Add VDM reply support https://git.kernel.org/chrome-platform/c/50ed638bbc47 - [10/10] platform/chrome: cros_typec_vdm: Add VDM send support https://git.kernel.org/chrome-platform/c/40a9b13a09ef
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html