From patchwork Wed Dec 28 00:45:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082659 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CA7FA2A for ; Wed, 28 Dec 2022 00:56:41 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id n4so14699818plp.1 for ; Tue, 27 Dec 2022 16:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6pBNYJdKXzam2nXK0e/4rLZrKFDWqDasg6cE5ctCeLs=; b=RKvg/T3PMBvEQZilUPnU4QNnnFWl3WaUHN9Rf/hXYh6bzT9+tVGKtuqYOuFUFKL/xt tCiKyp2lUBydu+rR22CjAkhiw0oiIpA4oD8BVbALOVLcusx2KyR1ob1G8hQ/CiiitCzn bomGAoN0aZ4RLZl3gzDrce6rFlcaf3O69q7/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6pBNYJdKXzam2nXK0e/4rLZrKFDWqDasg6cE5ctCeLs=; b=Y5aVT4dQ9jV05wf8YXu2tGgwzpqAK7ww//lkdfO89kMgXpFdhilOqj4RnN3+9oLiXn qXH09W5mACSPR5fQIQyyEGzFHzy+MZA49vRm5veaZbISWV7nZ00ygKRHGw6rqkDPu2ag 43uNoFX2YfzFhSX+/X7178GvWXj0o04+des4M4zcL9XqBiM+jUxO7322Efm2peQEc4SY vU9auGotE8jO1dTl5xPbVwYUApNXwEsLqmLqqy54CHKp7LSELt7rwe6XmJtYofq0PFwe kg5a+uqvWkjDEGQktJRxIer09omwgWtBt3FVL6nK4p+ZJXoQU+DC3TpP/rC2FqHaYyzL 1zfg== X-Gm-Message-State: AFqh2kr4BOFsZguUYVDhuVSBbHVVnleKuokEA/h2hL5CgfDu5Z3ukT7l cg1zDWkazL7+bonZPcicIwO2Fg== X-Google-Smtp-Source: AMrXdXtlGD1iF9qDlfibxWqFvtJyFneuKzXuyKtopGLMCo88wsQSvk2xYDuqTAiHjx1yO48ULlMsFw== X-Received: by 2002:a05:6a20:1bd9:b0:ad:efda:5e5d with SMTP id cv25-20020a056a201bd900b000adefda5e5dmr24969506pzb.61.1672189000941; Tue, 27 Dec 2022 16:56:40 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.16.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 16:56:40 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Lee Jones , Lee Jones , Sebastian Reichel , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 01/10] Revert "mfd: cros_ec: Add SCP Core-1 as a new CrOS EC MCU" Date: Wed, 28 Dec 2022 00:45:04 +0000 Message-Id: <20221228004648.793339-2-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Acked-by: Lee Jones Reviewed-by: Benson Leung --- 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(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 344ad03bdc42..02d4271dfe06 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -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, diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index 5744a2d746aa..7c94bf5c8f05 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -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) diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h index e43107e0bee1..a1f5b6d6db3a 100644 --- a/include/linux/platform_data/cros_ec_proto.h +++ b/include/linux/platform_data/cros_ec_proto.h @@ -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 From patchwork Wed Dec 28 00:45:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082660 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A0FEA2A for ; Wed, 28 Dec 2022 00:58:17 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id v23so14760946pju.3 for ; Tue, 27 Dec 2022 16:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UlkVfUBe/NCfBa71O2rd9oCNbNRfdZ1yxlTWgpEWcJM=; b=DtPex/an83yfigVpvCXORqv940vc0AIQEz08QWsNwTfI1b4uzmqNDUsRKW9L7TdIe/ HjadvImKK/AW8yt34ZtnpaeGrp4qI8AOK+lcfHnyKHZYidt7wiIfZU8ttDEiPqqWANi9 VlE0AYjiRo5r4nS8KS+BsLPxLh+osXkwsoVCc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UlkVfUBe/NCfBa71O2rd9oCNbNRfdZ1yxlTWgpEWcJM=; b=3pGrSLbNs/7f75Kre56y4fniaGOfdFAoWz3H3vgZWIWyJzQ+YVSBXrjvoTAx23F85U SbSZnU13wXf/EFP8cLjOwI4d8hBf31+hwQHtYrQAmQ2QqFm0XxEdMbFplG42uzp1Cp2z fkS15cSrVgmJLw/KTRQ77DRZwRR/isw8FbYSdVZ6cx8G2sYI7ASZjgIAui4nslDTvzds g1hPzo7JIegln90pNCSHHnbuZnkkqBkLomRo5D0toluTsgGd8t0dCRaayLDQuJne5hWR QGAkf7164T89a7RltOz6crGfXxvIAW8WOmWO7zNTLH4Om7nV+M0RJnBAL2xdiIey51Vk 3RFQ== X-Gm-Message-State: AFqh2kpjfyGKNCwfa39yv659sYLI+8Ev1Lj4CMiPo4yiSV4NFIXWRtkQ Dlo+nrq5oLw4q1P6pNbp85tEoA== X-Google-Smtp-Source: AMrXdXufenNnXoC4kkU0SDNn5FlEczA8R3d5sE9/rZBWavVP5SpMEqK/pwUXdtNUGoE3mN/yZFMdaQ== X-Received: by 2002:a05:6a20:7da8:b0:a2:c45f:f0fc with SMTP id v40-20020a056a207da800b000a2c45ff0fcmr36080228pzj.27.1672189096619; Tue, 27 Dec 2022 16:58:16 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.16.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 16:58:16 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Lee Jones , Lee Jones , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 02/10] platform_chrome: cros_ec: Add Type-C VDM defines Date: Wed, 28 Dec 2022 00:45:05 +0000 Message-Id: <20221228004648.793339-3-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Benson Leung --- .../linux/platform_data/cros_ec_commands.h | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index 7c94bf5c8f05..6665e7da6ee2 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -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. */ From patchwork Wed Dec 28 00:45:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082661 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5EA2A2A for ; Wed, 28 Dec 2022 01:00:01 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id 78so9699122pgb.8 for ; Tue, 27 Dec 2022 17:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bl9lz1LdkOsI7rrZ+m78RYNdWxgzzlfo1gzTHpgM0to=; b=LEO2YJhja0QYiJBr0E4k0KdFonbevTkEqWkdTH1/UlaDcZ4FMjgHlEs4sYaltUvvup AflcM7I7fNmcBvbsXaJeuog+gvdLuVQPH/RgNR7FcmXGWF0sugC4nqSAY72+ztwvisM1 9CN5EhlD8jf6mZfTgEiKHhHINhVwFJJJTAIfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bl9lz1LdkOsI7rrZ+m78RYNdWxgzzlfo1gzTHpgM0to=; b=TXg9BQBLu9Z0r+4MT/HcbXRM0dlRfuQzPaP2YISdWZZ8RgK39iFEsq/ZQQV0CjKoGR 3jJjXjEyjLiDMT04u3I3LjqRS8Q1HaF8Ie/F09ILw67E15+IsZ/JeuN258qycExVv8nP 5YiqVUKE24vD8JSyvBkdkrbqhY+sIzhpuASYto5uyC03iyjsa0eJZlqcZUvYA7rZ13Tv 6l3r9jR6NSaxnzaVKHPwuk7OjExTdym04wPqMsn3CYf1WL2BfDCGDk4z1VJQSITNehqn oMvR+z5wVBkVyeabMfvYuY3OohI4o6cgFqflKz8JnP0kM7Nu5oO5IEaQcliyiIiRomCW 3dgg== X-Gm-Message-State: AFqh2kr043z98sS4Rt36gEnsbPGQUKkcZ1NfWjmFIO0aHKsT0u2P10Zv /koIi5prqsTmrcor1VqNRUiwcA== X-Google-Smtp-Source: AMrXdXtAppN52JChY/7t8akMZ+vaDIVh1t73ZtrT//8uxQ3LN5WN4hTEtGMrmbsqO/sRMnFMX5IfsA== X-Received: by 2002:a62:6143:0:b0:577:3546:d7be with SMTP id v64-20020a626143000000b005773546d7bemr24695903pfb.30.1672189201437; Tue, 27 Dec 2022 17:00:01 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:00:01 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Lee Jones , Lee Jones , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 03/10] platform/chrome: cros_ec_typec: Stash port driver info Date: Wed, 28 Dec 2022 00:45:06 +0000 Message-Id: <20221228004648.793339-4-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Benson Leung --- drivers/platform/chrome/cros_ec_typec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 001b0de95a46..bc8dc8bd90b3 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -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; From patchwork Wed Dec 28 00:45:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082662 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6CA8A2A for ; Wed, 28 Dec 2022 01:02:54 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id c9so4918388pfj.5 for ; Tue, 27 Dec 2022 17:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CbjTsx7UG59fZ2gLebJbhfQe4ODmuLy0COLAvv8hKdk=; b=ah1j6uRlh40gT4KP48ZO4mCU9YtccnyURceyhbTIH6fORS0aZqEok97bfxUQai4LLP fYfTjCPLYz2bUl5qvzmk3xYNuq7JsoBJDZ0IRGvTHnNfo/qczH/Tk6I+fBJ6wApoZ6aF Z5Onv+nMh5Qji4XfGX+1tzunUoq33squgPVWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CbjTsx7UG59fZ2gLebJbhfQe4ODmuLy0COLAvv8hKdk=; b=zyxjG7MBoSkOKqrGZXFsKrtMxoVsitKT41+Rci1GW+XmJUAGUBKEv5pVOeKbNGLkKd DLgnW+zkPTm8YYPtRXpb+K06FNzo5GbXMuKukraW78NxWtjaU3le1FLAppLwR8yfL9rU UDypKjW49PYjAQgrgHQpIR1VMH2Tdc1FkapU4mO05N0OIeXH/bEOEg+CRCPf6Zt9nAZJ ue9FutuKQjTsgDQkDqgZXz28soTAhZMmKp/MEBlc4Ev2uSsG3LvwUlpWBLTRLCZF/bGc OUnn1oJWibq0QTmP8jSwTCfGL/PoUrO1KjTqiWdfYSfgZi9nrHUH3A0vH6cEx3CuzeBm rQHw== X-Gm-Message-State: AFqh2kopFYVy0+RL/PDnaaJfOS8LrJpCP+d6+oWrSIiVP9tPYDijKnaq 6HE8g4Uw2dlv0UVDSTwiVAUaxw== X-Google-Smtp-Source: AMrXdXtag5e98w+qZ8o8usxXV7igTWLFzCDC0XYCGCVJixhOsxrxWP+M/gdV7E5FHEBniz371pMBMw== X-Received: by 2002:a05:6a00:1d91:b0:575:a4f5:7812 with SMTP id z17-20020a056a001d9100b00575a4f57812mr28189419pfw.4.1672189374332; Tue, 27 Dec 2022 17:02:54 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:02:54 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Lee Jones , Lee Jones , Sebastian Reichel , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 04/10] platform/chrome: cros_ec_typec: Set port alt mode drvdata Date: Wed, 28 Dec 2022 00:45:07 +0000 Message-Id: <20221228004648.793339-5-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- drivers/platform/chrome/cros_ec_typec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index bc8dc8bd90b3..05dc5a63af53 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -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; From patchwork Wed Dec 28 00:45:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082663 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3D49A2A for ; Wed, 28 Dec 2022 01:04:39 +0000 (UTC) Received: by mail-pf1-f182.google.com with SMTP id e21so239647pfl.1 for ; Tue, 27 Dec 2022 17:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r5mZF+HqNi7oJNQi66SgCofHZHC1n4UI9rtyVYM/8No=; b=KiXQtSzK6SfREKzd9svD1tT0Hd3tIGm6pdGm+RbC+q7dG/Y5Uk/MXDB4H+UwxH8CSF MF2snD+BFILP1wBx1EcIXbKnt+5YWVABswwFJ4OTWq1fYcIG1rqA1yK/0vCLyrc5do1I lFveHNrmGfJ1u01ZL+qgFDsqDoeqGy22tbUpY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r5mZF+HqNi7oJNQi66SgCofHZHC1n4UI9rtyVYM/8No=; b=mj1WXdx6AeieHpv+WbO4MrXhjsYmXyrkhlGb+a8XfPkUSbmSaEq7CqkoBVaxhvjQOR zr/4L89hba7FkjC8G3yo5NZjzDU/ZtB6xgHyvelE/wNqhFxzDZ/wMSV0bQUE0tMnsR1N ebAJAKhBS5FBOH+hdbryAT5qOW4TeTnus4Rk7sM8Zobc1Vd+z9qitke1wQxzDP/NEANc AGrc8M8RzrHeww9uuFG5ArybJWZAiEEIezc95Qwoe6vSRkLjtJ3Lk7WbyIP64HGxPHLY GNV0Db0WtSylV56UyOH94RmyPVLM1SeAeBzP7eZwtSQyUF8e4yXjAZEOaYAe9eC4+Rp5 /w0g== X-Gm-Message-State: AFqh2kq+cjV+FLimkzTp7bdL2EaBPGoqtMEYiP7naIcd9YPFHbllWM2X M92Hejp1b2znTZ04sAXAt6qsqQ== X-Google-Smtp-Source: AMrXdXveagOKrg0TX75B+ykXkGP1Pv+3qW3ri++W2sqEuWcUZoMLj6WCEAJPZTVuQO0zRoCzG7eoBw== X-Received: by 2002:a62:ae13:0:b0:577:9182:19a7 with SMTP id q19-20020a62ae13000000b00577918219a7mr27292800pff.29.1672189479431; Tue, 27 Dec 2022 17:04:39 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:04:39 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Lee Jones , Lee Jones , Sebastian Reichel , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 05/10] platform/chrome: cros_ec_typec: Update port DP VDO Date: Wed, 28 Dec 2022 00:45:08 +0000 Message-Id: <20221228004648.793339-6-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Benson Leung --- drivers/platform/chrome/cros_ec_typec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 05dc5a63af53..665fa76e2416 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -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 { From patchwork Wed Dec 28 00:45:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082664 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85042A2A for ; Wed, 28 Dec 2022 01:06:44 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id c9so4922563pfj.5 for ; Tue, 27 Dec 2022 17:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AhiBkh5UrcsoNdDiXRM07AJgxIo5p7Z6aIMZaYVIvlo=; b=PrdSKTukE+zAUoNbG7/Inyn4sNGFrt6NO9buKwzdkI3nP3vYEoq/SO44sr1/4E8qK1 Qc2xHsUrCt6IrZy9dSOBoU1F3c/61MRLaMwbeN9RTCPuDkHswFbmzL2hHwEvqMcDtYHd pZT3+Wzwhcys+WXAZZp/7QG44mIShSSmYdlw0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AhiBkh5UrcsoNdDiXRM07AJgxIo5p7Z6aIMZaYVIvlo=; b=vx0PTZ32pFE0r9Qdlo/uzAChh0NAojYbjLYnGVX0H1wFbFATVhU1UehQQdZK9ayryG hijbVJbphNCepKVKROlGsHebNjxU0Yu1C4cEQzKVAwaP6xFBy/vfUCuZtxDos2gLWk8Y bvzDgTl20woYdEHj5RC2CzWDZSW9G3ZaUB/aIo+rf7WoBuf7YKuMt36hyf5DstbNdNGy jqdrzz8Z0/mBi2A9r+ytSnpSLqh/2B2MUxkE4bTt50AUR7r8nRqLBbl92tOwtjbwQS3s YEDtt0+n9p6oAfNzlcvGsTbYTH8z6W3KaGAdvPqLtsM0n4hlYlN4qtiTLI6T5MiUk0w1 Rqvw== X-Gm-Message-State: AFqh2kqpylLWocVq5bZ8VmMGWU1njxZAZiJLZdcI/bRj1NuqMg641qsV Fw1cxpse4S5N1txVtgxW8hF6cw== X-Google-Smtp-Source: AMrXdXusSVTTr+/gOVAWeuwTjHDvy/AIwdLmwOkQNWcl+UYKgKn76RnQXJBLCdtBgP180NYFoubdaQ== X-Received: by 2002:a05:6a00:b48:b0:581:dda:cec3 with SMTP id p8-20020a056a000b4800b005810ddacec3mr14718665pfo.16.1672189603892; Tue, 27 Dec 2022 17:06:43 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:06:43 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Lee Jones , Lee Jones , Sebastian Reichel , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 06/10] platform/chrome: cros_ec_typec: Move structs to header Date: Wed, 28 Dec 2022 00:45:09 +0000 Message-Id: <20221228004648.793339-7-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Benson Leung --- 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 diff --git a/MAINTAINERS b/MAINTAINERS index f61eb221415b..8219b646ab50 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4998,7 +4998,7 @@ CHROMEOS EC USB TYPE-C DRIVER M: Prashant Malani L: chrome-platform@lists.linux.dev 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 diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 665fa76e2416..a4eff590ca56 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -7,96 +7,22 @@ */ #include -#include #include #include #include -#include #include #include -#include #include -#include -#include #include -#include -#include #include -#include + +#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) diff --git a/drivers/platform/chrome/cros_ec_typec.h b/drivers/platform/chrome/cros_ec_typec.h new file mode 100644 index 000000000000..deda180a646f --- /dev/null +++ b/drivers/platform/chrome/cros_ec_typec.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __CROS_EC_TYPEC__ +#define __CROS_EC_TYPEC__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* 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__ */ From patchwork Wed Dec 28 00:45:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082665 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8845A2A for ; Wed, 28 Dec 2022 01:08:19 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id b12so9713312pgj.6 for ; Tue, 27 Dec 2022 17:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q3Dq4wWbILHgSzdg9F0HvepnEYOyHWo5P75M1QcLm/s=; b=Fgalns0fr/AFzMRxFeH4/LwL0qZbL0snm2KwCCl2QnPyl5Kbj/+4zrKEcmy8PPTNsB 7FbZ2XYBB4W4MucUlLZY9jZSYs202FFXLnztqFnlw75So6egAqI4XNC2nmCgHZVLhOrE 1ffKuQRivqF0uBoREPBSAzm5QRibeBZ3I9Yt0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q3Dq4wWbILHgSzdg9F0HvepnEYOyHWo5P75M1QcLm/s=; b=ScoyJRf+3SQQgcsYrAwyBho9sXIVywOT7XkBA/FrTDxNb0e+jQvG+Dj75XuLNzHZnE prhg1u8IgpJWSRB58NUzOdU+SQi1qMtB5UmU024mZPEjM1B6ZDiikpRs5lokAud1ctIb wAaVqKOF3huoTCKsaCuEFpzYvxpoLtD//aX9oDgRvYYVkKDkfOqcKQePhLOXEmq1Sy7t iW+dSGDU7KlSSTZaN7hkOL3o/yuAXtJ6Ie5RTFZv6XepWL8wD7pL5r8a733LVm5oOF5T uXWNM3YqAsODeIOV8RNIHwlMaNfBoxu95JqIry4sIjsetiM+bildj49KSHfGbUXcVZ6A yabQ== X-Gm-Message-State: AFqh2kpzxBOiaTDBhPrxSX5or44gg/2CG3EiYcsT+fjwmIlVecdka6qJ HU8KOarD5jundMFPSFSHWpUnesbn0+74XlJJ X-Google-Smtp-Source: AMrXdXvprwqeO1sYyJAc2mcFG4t7ASTFUsJUdV61CCrza2i/K9kGZxDLNM1iO74sdjDDHZIEdiF7qg== X-Received: by 2002:a62:5f43:0:b0:576:dc40:6db9 with SMTP id t64-20020a625f43000000b00576dc406db9mr24269467pfb.13.1672189699426; Tue, 27 Dec 2022 17:08:19 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:08:19 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Lee Jones , Lee Jones , Sebastian Reichel , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 07/10] platform/chrome: cros_ec_typec: Alter module name with hyphens Date: Wed, 28 Dec 2022 00:45:10 +0000 Message-Id: <20221228004648.793339-8-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Change 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). Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- drivers/platform/chrome/Kconfig | 2 +- drivers/platform/chrome/Makefile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index c1ca247987d2..5e420c27662a 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig @@ -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" diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile index f6068d077a40..fd29fa74ba33 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile @@ -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 From patchwork Wed Dec 28 00:45:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082666 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57691A2A for ; Wed, 28 Dec 2022 01:09:52 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id d10so9695562pgm.13 for ; Tue, 27 Dec 2022 17:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Oi/kOlETPyv2MAO1V2HCLkw/mua4WIbZ/Rd76axTkmw=; b=XPNNK/pdpQNeuytYJsaqiYwaemm2ickjJ1kbCPbCpJWFnmHwC6uAaZ28x8m+64qwaz FFUtco2Gwgngd8D+vIcoWIxYtQtyVLOwfdSWTCyUVqp55cjssGMrbyBnog5eY7EXtDe0 RfbbXbxdQiJxzrOBANsD10JSlZIHMgGVzM1e0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oi/kOlETPyv2MAO1V2HCLkw/mua4WIbZ/Rd76axTkmw=; b=ENGITcYTQXYG/zOET6IjR5TBPuzzIK/aK6RxxHw2SIseS0aF3+ObTRoOIC8XsgKUYY J21Yz3DdKTmoLvi1dcBHIS87MtBEREZ5p3sQGmU5TB7uVgBo1Qtb2R1n3C2qzDo5y6dD ot7k+qgiIj01I7LROcNrx5kq3vw7vItyIgzFlm24r/dLj+23Lqf9HzlRBiLDONMhhkUO rJGW22iglojD4hbxXBsL7VYV2rI5vA0ybJIlIBRx1McQFPKCeRoRDm4JSTr8oHpSJdY9 oeYdxw+978/iRXNKnh4v4fWj3MRRS+mkvOOpHa7m3yvvNsRqUmW05bfN8dhDiQLjZeGz 5pxQ== X-Gm-Message-State: AFqh2krMA6T6tdsfySZCBCNTXZ5OVI+zCgNpvc5gRjUtbbuK6L+rvjvh bMmelrOYH+ornUhDlBDcdVdM1w== X-Google-Smtp-Source: AMrXdXuVBAPSSMLpM3oEwlDj1tsNz96oGf/u4MnYLpXIEQnfiMmpoI3CmcNWLbtoYAJyX+u2hvGGZg== X-Received: by 2002:a62:a21e:0:b0:581:95a7:d2f4 with SMTP id m30-20020a62a21e000000b0058195a7d2f4mr757839pff.9.1672189791828; Tue, 27 Dec 2022 17:09:51 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:09:51 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Lee Jones , Lee Jones , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 08/10] platform/chrome: cros_ec_typec: Add initial VDM support Date: Wed, 28 Dec 2022 00:45:11 +0000 Message-Id: <20221228004648.793339-9-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- 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 diff --git a/MAINTAINERS b/MAINTAINERS index 8219b646ab50..cfccbbbb083f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5000,6 +5000,7 @@ L: chrome-platform@lists.linux.dev 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 diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile index fd29fa74ba33..dae0ed3c8656 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile @@ -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 diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index a4eff590ca56..1e28d56b094d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -17,6 +17,7 @@ #include #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; diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c new file mode 100644 index 000000000000..df0102ca3a18 --- /dev/null +++ b/drivers/platform/chrome/cros_typec_vdm.c @@ -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 + */ + +#include +#include +#include + +#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, +}; diff --git a/drivers/platform/chrome/cros_typec_vdm.h b/drivers/platform/chrome/cros_typec_vdm.h new file mode 100644 index 000000000000..7e282d168a98 --- /dev/null +++ b/drivers/platform/chrome/cros_typec_vdm.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __CROS_TYPEC_VDM__ +#define __CROS_TYPEC_VDM__ + +#include + +extern struct typec_altmode_ops port_amode_ops; + +#endif /* __CROS_TYPEC_VDM__ */ From patchwork Wed Dec 28 00:45:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082667 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0658CA2A for ; Wed, 28 Dec 2022 01:11:22 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id y21so7631136pfo.7 for ; Tue, 27 Dec 2022 17:11:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BNxB8uMl8S+cIx13svZb0f8mLMHIEoe8sZA5V2z0kk4=; b=WE2qgyx2SI+0tgX6FHwbAgRVNSwZkLvp+BZysQ1edZOmVv9pJnG8YXnN/8Lclrb0Vl XqC3/gtQRm5xycVhdAzhZ2ri8e4ZOz/ULgJ34r+L9pGkwzarzraFHYwWE0QOPWSFzM2e teYVgdNUSBYpY+M3rIq1RMbt8q9twyzRCBpVc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BNxB8uMl8S+cIx13svZb0f8mLMHIEoe8sZA5V2z0kk4=; b=0PZ3SbACpOFvzc00Dc0/VL534g+gkQsk6qokBTIZEpBgJ9YtPKZCDYUTkPozvvN70n ELiEdVVVbXY1lSvbisASMI5uixbTjK6QmFU+Y9fUKLV/6xTElvJtwgGNtG8j2I4kR6Js tjjtTcW/2YewAuEiFSCBloCtHvzGpmyjl/ncm4zH9Pml8VCw+3l1gTm9p4sCkhfepRc3 1QnMU0lYAKxSX3Ag/jFZrh72XmtMd1IBrtrbctIGNpKigIsTn5NfwMDOTZfgQJtd5HHt zbfE0AiWckK+nBSssV3iN09YMJuWqnCHCGtCC3A2hJqQrr6mIgqJcxDy+31kqHaLVywH Tlrg== X-Gm-Message-State: AFqh2krEA6Jq5rOENASkux3IxQijfRg+H20MBEV8xP42f8cpS+0lYhoW Jt/5Zgf3UUm1hkDwkMob8yBdvwU+Z2j/sFF+ X-Google-Smtp-Source: AMrXdXuRniPa+kdLE35R+lvAK/KHSDtSV/UXu7eXSGc2mSHOFloadStPHn4NrOnaiT9YsDCTJDnekw== X-Received: by 2002:aa7:9e11:0:b0:576:c2f0:d6a1 with SMTP id y17-20020aa79e11000000b00576c2f0d6a1mr27063164pfq.8.1672189882439; Tue, 27 Dec 2022 17:11:22 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:11:22 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Lee Jones , Lee Jones , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 09/10] platform/chrome: cros_typec_vdm: Add VDM reply support Date: Wed, 28 Dec 2022 00:45:12 +0000 Message-Id: <20221228004648.793339-10-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- 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(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 1e28d56b094d..e02107a6870a 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -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) diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c index df0102ca3a18..fc7b602ceb37 100644 --- a/drivers/platform/chrome/cros_typec_vdm.c +++ b/drivers/platform/chrome/cros_typec_vdm.c @@ -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); diff --git a/drivers/platform/chrome/cros_typec_vdm.h b/drivers/platform/chrome/cros_typec_vdm.h index 7e282d168a98..003587525554 100644 --- a/drivers/platform/chrome/cros_typec_vdm.h +++ b/drivers/platform/chrome/cros_typec_vdm.h @@ -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__ */ From patchwork Wed Dec 28 00:45:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 13082668 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85DC8A2A for ; Wed, 28 Dec 2022 01:12:57 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id g20so1581317pfb.3 for ; Tue, 27 Dec 2022 17:12:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=19FACrxzZLvGXvd0qASwod3BuDfjZjR6MyHlKQ4qp7g=; b=iEVqWLpKFWneA1CaDK1kR7cs5OO3qwDqFvdU2t4jNQZOYZuUah0u5S9U6d6kBS9K5P 4GynIc5CjpScZRoFcv7w4txy1LtJyF1SiMm8Mapgj32y6w1cX9VXL6lcpELZYg4G3ohN YRRTb4EG9LMCE47SXDsUxXt8KElbfN1f9MgKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=19FACrxzZLvGXvd0qASwod3BuDfjZjR6MyHlKQ4qp7g=; b=sXE1uiZY9d0zEcRgl3bM7D8scwLYk/N6EJbL3CukWJMwm4jhd1AoGs3ULhNvqE+aqI qswmp3N7expIpcvX7oJi4AONfMPGlCfr34aw77jcw53T9U2/KkK89/3RfY1cMyCVrcLP vrjXq2MXYA6NzEBaLH4sIGUwknek+qXRZ2VbY2JgWo4UYpkM3ze14iPtmDymP0cZbfmq +BKA0jbx/xT9M9nj/2TEo6N8SzZkQNYrHvMETrAxr5L13rt6GFRqsI0vr9diEO19dpV1 6fBCe0LLTu6ccHoSM5okehVr8BlYy0PmtVdryblYsF6eqRng1zS75vNl2PyLHLDQXYE7 XS0A== X-Gm-Message-State: AFqh2kr3vGNGfVrNUhaIJaoziT3gJQ5nkZfjOqRGHbS8BWdlpYyk0aTe GKGGCxKtK4JcetL0U4oMmF5sbA== X-Google-Smtp-Source: AMrXdXtE+Iu61LxC8/oG9wiX3A5IaH1P+cVPyJUa2fQ6FKLIm8WQohl8bsbs8zl8o9Nxf1TwkKt2rA== X-Received: by 2002:a05:6a00:1f06:b0:581:366b:ca63 with SMTP id be6-20020a056a001f0600b00581366bca63mr7058629pfb.34.1672189977038; Tue, 27 Dec 2022 17:12:57 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm6045566pfz.157.2022.12.27.17.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 17:12:56 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Daisuke Nojiri , "Dustin L. Howett" , Evan Green , Greg Kroah-Hartman , Guenter Roeck , "Gustavo A. R. Silva" , Kees Cook , Lee Jones , Lee Jones , Sebastian Reichel , Stephen Boyd , Tinghan Shen , Tzung-Bi Shih , Xiang wangx Subject: [PATCH 10/10] platform/chrome: cros_typec_vdm: Add VDM send support Date: Wed, 28 Dec 2022 00:45:13 +0000 Message-Id: <20221228004648.793339-11-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221228004648.793339-1-pmalani@chromium.org> References: <20221228004648.793339-1-pmalani@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Signed-off-by: Prashant Malani Reviewed-by: Benson Leung --- drivers/platform/chrome/cros_typec_vdm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c index fc7b602ceb37..aca9d337118e 100644 --- a/drivers/platform/chrome/cros_typec_vdm.c +++ b/drivers/platform/chrome/cros_typec_vdm.c @@ -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, };