From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20640C10F1B for ; Wed, 28 Dec 2022 00:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbiL1A4p (ORCPT ); Tue, 27 Dec 2022 19:56:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiL1A4m (ORCPT ); Tue, 27 Dec 2022 19:56:42 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 940FCDFFD for ; Tue, 27 Dec 2022 16:56:41 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id m7-20020a17090a730700b00225ebb9cd01so6749049pjk.3 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=JoKtnna/0seKf6sMZE/Im/FHXyS8u6aZGAg5o2kCxvIFJXIKeXqk0ad9f19l7fr8Ug IYfoOG7RW/TcuLgpLuM7F05GigTJ45hceEAGpgzVcl8JvFkBwgCq4Lpi+8eYD/giwjC0 caaXnYFXXAc/tmiBMwhAQQyrarUQ00U2wP44qTmqey4bNMaWnSrT+2Arzsv+fxPCXLca WWJ8KSa4Ip9jhfK/dteVlExTx1xwQyPFi96c+quk11yAlfz+N5ZZACP2LxbmqRoz1BYr LvlCioAkOqACuwYZZCMq56OZwkGEqod8vK2TGvDmnz2tqc6IUBjmPgFPE3dS/tVoe/fQ 5ASA== X-Gm-Message-State: AFqh2kptKugesJdDrPh90ncrHsd1LqmLt2gYhbUDhEx3nyWmya6YFlOk 4SBdlww05XKiOqM9zyQMmnREj/43uF83q8uf 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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:incl= ude/ec_commands.h Signed-off-by: Prashant Malani Acked-by: Heikki Krogerus 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_device= s[] =3D { .name =3D CROS_EC_DEV_SCP_NAME, .desc =3D "System Control Processor", }, - { - .id =3D EC_FEATURE_SCP_C1, - .name =3D CROS_EC_DEV_SCP_C1_NAME, - .desc =3D "System Control Processor 2nd Core", - }, { .id =3D EC_FEATURE_TOUCHPAD, .name =3D 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 =3D 43, - /* The MCU is a System Companion Processor (SCP) 2nd Core. */ - EC_FEATURE_SCP_C1 =3D 45, }; =20 #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/pl= atform_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" =20 #define CROS_EC_DEV_EC_INDEX 0 --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68F82C10F1B for ; Wed, 28 Dec 2022 00:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbiL1A6V (ORCPT ); Tue, 27 Dec 2022 19:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiL1A6S (ORCPT ); Tue, 27 Dec 2022 19:58:18 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 405FEE013 for ; Tue, 27 Dec 2022 16:58:17 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d15so14681449pls.6 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=5pvNumffqQvSdlIcYAr+ztstpfBsBuurF3FXXBxwyadt2zxQANbC5tgjPmCqh4hvw9 ZxZOEfTUXbXiG6+bHoF3pN90UQE4FRvY+shFi4erdNPlAKoeVq04q6hdbKp0liAeB1Kb YSK7NQfIrOJa0HmCr9BrISkQDx1nAsljztTZQxcDwqEYxKYv2WfB0trlEzM5C5/6FWHl 28gFG03w8Etp4IJ3AeLR/5rIImXZ/B9+BGpcFd0CnvxVSpMxaLT1cY8rRpswgJmhYxrR LhPZd6kmRgoP2XH5KNKuAYcDllf/d14XjOJ5RRtZ/GtEARXZG43PQ9jZ4dggFj3xCOuu DZAQ== X-Gm-Message-State: AFqh2kqerPBaYVbZPlX+l/6SZrNztwZKAKEgSCDxVXm5/jZNDwRRo16r SwV+5Y7Axr2GXzf8NEN7cl4xkxPAc6Iw6rGA 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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:incl= ude/ec_commands.h Signed-off-by: Prashant Malani Acked-by: Heikki Krogerus 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 =3D 43, + /* + * The EC supports entering and residing in S4. + */ + EC_FEATURE_S4_RESIDENCY =3D 44, + /* + * The EC supports the AP directing mux sets for the board. + */ + EC_FEATURE_TYPEC_AP_MUX_SET =3D 45, + /* + * The EC supports the AP composing VDMs for us to send. + */ + EC_FEATURE_TYPEC_AP_VDM_SEND =3D 46, }; =20 #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, }; =20 /* 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; =20 +#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) =20 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; =20 +/* + * 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. */ =20 --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61B6BC10F1B for ; Wed, 28 Dec 2022 01:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230357AbiL1BAE (ORCPT ); Tue, 27 Dec 2022 20:00:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiL1BAC (ORCPT ); Tue, 27 Dec 2022 20:00:02 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B737E013 for ; Tue, 27 Dec 2022 17:00:02 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id 6so7067091pfz.4 for ; Tue, 27 Dec 2022 17:00:02 -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=b5K/TZRU4Wn3CIOIeEkZJOsP3rh6XznvBj6oKvH5Y2d2+Rud+xlTBKxGSRk51svC5V 8r4Ale4v1NkiIB3/3otefsLkFCtmbbnZB+kQhGslbnBRWyrjXou03DL4bdd0dF9RTN6T 9mYtINrAx1sGfhMvJKafAAgqjcL6RfjJdy2rJbhQSD/YApH/zAKJuLB9tSFhtBP8ksww 239mtzRRT45JtqEDexCVYyYaSDp76vcu5egq7A6qY1XOSg5nSU3l8rD/rSQl1wUY4LI+ NBIYGRIdrDVyBdbQRR7Ef5GTDRiSlurDZojqSlm5td1ENTXgeuhI5MEVcmmCB4HVkpSC 8RqA== X-Gm-Message-State: AFqh2kpjfFJo2uIFuXYOgHRFZ0+3DGC7fIAhPvGh+nZgPG5Htt5QJEqJ L1+yvL2SMldr3GK3MPaOV2Iy3Zk20N+QM7Ft 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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/chr= ome/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; }; =20 /* 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; } =20 + cros_port->port_num =3D port_num; + cros_port->typec_data =3D typec; typec->ports[port_num] =3D cros_port; cap =3D &cros_port->caps; =20 --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D215FC10F1B for ; Wed, 28 Dec 2022 01:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbiL1BC7 (ORCPT ); Tue, 27 Dec 2022 20:02:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiL1BC6 (ORCPT ); Tue, 27 Dec 2022 20:02:58 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFB23DFD7 for ; Tue, 27 Dec 2022 17:02:54 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id q68so2216513pgq.9 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=Ys4ArStEMVWwgqQRqHxSCPrOkNQ60Mhbiil1sA0qeZh0iw3JFTDYSfP1XXvOa8TaeX Or6M1Jh+3ab1BVTDPhclosa622loGuFsO/SbrXvT1v25A+K7rztMj4ZnvpRiFbFbj4Kk hzFTDtUJ61JhmAIDHxRa86qmTLwfwZ1YG/tsGyEmNGPk9hOXgkuc+1inP8+vZr2MlPM/ UUpddx8DclwluzroWUGayb/2pu/CBsCxwt4G4SD88iypw/Mv/XVMtEy6eLGq3FOs2sLs YxeMEC1OYjmwnJzrCC2eNZ1kQl8Zu1lyYX3LuyNNSESLQf0bJYGm5vV/QipYPe7MsTMs CoUw== X-Gm-Message-State: AFqh2krYdM3c3iNeDhQN4NjFfEShLzw5GIy+rFL5Pwk/Nnnxlj1iDNuL 0PjzNrb6PuzP46tkuskrdLM+YD5p+GyBMB10 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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/chr= ome/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 cro= s_typec_data *typec, if (IS_ERR(amode)) return PTR_ERR(amode); port->port_altmode[CROS_EC_ALTMODE_DP] =3D amode; + typec_altmode_set_drvdata(amode, port); =20 /* * Register TBT compatibility alt mode. The EC will not enter the mode @@ -358,6 +359,7 @@ static int cros_typec_register_port_altmodes(struct cro= s_typec_data *typec, if (IS_ERR(amode)) return PTR_ERR(amode); port->port_altmode[CROS_EC_ALTMODE_TBT] =3D amode; + typec_altmode_set_drvdata(amode, port); =20 port->state.alt =3D NULL; port->state.mode =3D TYPEC_STATE_USB; --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CC82C10F1B for ; Wed, 28 Dec 2022 01:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230438AbiL1BEo (ORCPT ); Tue, 27 Dec 2022 20:04:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiL1BEm (ORCPT ); Tue, 27 Dec 2022 20:04:42 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1492FE013 for ; Tue, 27 Dec 2022 17:04:40 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id c9so4920333pfj.5 for ; Tue, 27 Dec 2022 17:04:40 -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=hY9YjvgLN/5qIzZpnodK7GegD1idEmcOtPBZ9aD3ZnWI+j0ZyzgxbiLVNXnhSrznLP FlBvJJo6VeUCDYCiOt9V0iOkjpthfNjf8rMlMuuOVpk398RP80aMjuv6N/oeN5rcor1c PRqv1lVJI34GfA0FRySdor9AiXjZVhK+9uCrJT/zu/1OU/KNih094IE++4z+95ni4hC5 sQO5gMy+wDbsYxEsE+UVVItT82K+SoGPKsmjmRGS4hLVXpYu98Ccx/b3b9z8iEo6xTga m+TazhbnKWYxh3WcZmrrv93BJFc+yj2RNNCVp00ECtUkgaw7hsK/RofWdigljGVmwuRR Ux0g== X-Gm-Message-State: AFqh2ko27IRXI1/7/VxmOSq5NxsbdfD12RMp43oLFZ5KuEpYH6qO5nfc nNyko04KNmjj+1Cz/h7it2R2A/RpOXdAMvBT 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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/chr= ome/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" =20 #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) =20 /* Supported alt modes. */ enum { --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 109F7C10F1B for ; Wed, 28 Dec 2022 01:06:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbiL1BGu (ORCPT ); Tue, 27 Dec 2022 20:06:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiL1BGp (ORCPT ); Tue, 27 Dec 2022 20:06:45 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B25E8B85E for ; Tue, 27 Dec 2022 17:06:44 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id e21so241920pfl.1 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=HApIwANi9+MzpLWyc2AyLa5bd1jxJHTZQkuequ67ClroJ2bUyZwjNLigipm+cZoQuG +6eG49kkh+ur65ZydFWQJDSAb+IQoYC/yb9592t4OQruF8AnRpPulzpRY7xyat4ql1Fl DyYX2J6eOh1Zq2TcURWhfhgXiKYNAtCXRUvJWWbhGFZItxl6BfD6ZBRB1TOrCfkmMetR N8YizYuev7QU/JPLPektCEhlSi1ZMjTRbLd98O9Zl4BdVwyKgrxGmJkLewz0/P4N7Tj5 PCDqQWP7L21Vozpf6XwA0Q1ALPtJOVZpInOfTNCB8HVnh+Ezo0yA61Og9fBMp77+X51K f5ww== X-Gm-Message-State: AFqh2kqeStEBzoJDWuEBuMelkyhFFQTr3AGYmeFFwxx7W/h65e/7+0er EqtUtI67aBiUAkZ9FNKLZWS+Pdyy7r9czV9w 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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 =20 CHROMEOS EC USB PD NOTIFY DRIVER diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chr= ome/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 @@ */ =20 #include -#include #include #include #include -#include #include #include -#include #include -#include -#include #include -#include -#include #include -#include + +#include "cros_ec_typec.h" =20 #define DRV_NAME "cros-ec-typec" =20 #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) =20 -/* Supported alt modes. */ -enum { - CROS_EC_ALTMODE_DP =3D 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/chr= ome/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 =3D 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__ */ --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13355C10F1B for ; Wed, 28 Dec 2022 01:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbiL1BIZ (ORCPT ); Tue, 27 Dec 2022 20:08:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbiL1BIU (ORCPT ); Tue, 27 Dec 2022 20:08:20 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DEC6E03C for ; Tue, 27 Dec 2022 17:08:20 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id w26so9813462pfj.6 for ; Tue, 27 Dec 2022 17:08:20 -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=bu0jkpgP0C1xlGYfUSC/xTvH9/qDwjYlumJsQPxZY7UaGmQqPcJ3gSxrAtSnM5oqUS TXSq5MkqWL/IlEDmY6FjAVP5rRk00ILeax7l6XXeoZGRQghwf0TbvaH4heil0gFgt/UN Hxe8zmlVhxZp/KjwYaTvSA66L+OEPyrn2xGtmJe8+Cm2TDh6dn8QC5GfiGEL2VlNT/2d uormtZiiq06RZXkJGQVbE9krhb4Ooas8nniIY4GYwYcHuhILK72GQ520rDH7IXkqZzto g1sVpyQa40g92YwZ6eYLxNFyXxwgFfUexgKZwPIHZjMC7rDAUO1WoNU64+ajKoeURzSC wQuw== X-Gm-Message-State: AFqh2krE6/aE/Jx1lZPuip7X/8NcSNsNG6YUStmdaoa/6FyvX8N8Jom5 bHvWDe6+JO9+MId3Xq7uXSw87z2qdp0dR8T1 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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/Kcon= fig 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. =20 To compile this driver as a module, choose M here: the module will be - called cros_ec_typec. + called cros-ec-typec. =20 config CROS_HPS_I2C tristate "ChromeOS HPS device" diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Mak= efile index f6068d077a40..fd29fa74ba33 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile @@ -16,7 +16,8 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) +=3D cros_typec_switch.o obj-$(CONFIG_CROS_EC_RPMSG) +=3D cros_ec_rpmsg.o obj-$(CONFIG_CROS_EC_SPI) +=3D cros_ec_spi.o cros_ec_lpcs-objs :=3D cros_ec_lpc.o cros_ec_lpc_mec.o -obj-$(CONFIG_CROS_EC_TYPEC) +=3D cros_ec_typec.o +cros-ec-typec-objs :=3D cros_ec_typec.o +obj-$(CONFIG_CROS_EC_TYPEC) +=3D cros-ec-typec.o obj-$(CONFIG_CROS_EC_LPC) +=3D cros_ec_lpcs.o obj-$(CONFIG_CROS_EC_PROTO) +=3D cros_ec_proto.o cros_ec_trace.o obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) +=3D cros_kbd_led_backlight.o --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A912C10F1B for ; Wed, 28 Dec 2022 01:09:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232197AbiL1BJ4 (ORCPT ); Tue, 27 Dec 2022 20:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiL1BJx (ORCPT ); Tue, 27 Dec 2022 20:09:53 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83483E01D for ; Tue, 27 Dec 2022 17:09:52 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id k137so5031114pfd.8 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=xomE3gbuDTY3AA8VcyHNZ8vY6XHW4NYEllp3TwE+6Z7/zzhWcjTH4WJSMHOlpBRhzy AqfIc7+lj6qbHgVo2BfU9+MfY0XvXzGrcgaErPgV0e6Om7qblHf3Zy+nxdEGmFMx85A9 BCS+Z298IHBsrgS/crtNzTGKPab242vvWsU/q4JOEVnmmuKLucXzLmlqW/MW+BkYa6hT pztVKy2oGkFN0gC/rqa9YpSDIF9Qv1GvTDl5pMD9KjfGBj8+i6XWjiJM5L91oUntNcaX tzlkWv5swpOFoTCG5G1V2aM1xgYguOVL7KfK8k48Yvj1DhNQjIhzixYZ2Oem+pwqfuJO nElA== X-Gm-Message-State: AFqh2kpEa+29/jUZRGI5r1TmKLMe2FBAKIgAZx9vuJfd2mI8y20Fo8cL Tx5/Fa4BKfMoVJu/OmB5r+7jEwPCqdsBtGX9 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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.* =20 CHROMEOS EC USB PD NOTIFY DRIVER M: Prashant Malani diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Mak= efile index fd29fa74ba33..dae0ed3c8656 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile @@ -16,7 +16,7 @@ obj-$(CONFIG_CROS_TYPEC_SWITCH) +=3D cros_typec_switch.o obj-$(CONFIG_CROS_EC_RPMSG) +=3D cros_ec_rpmsg.o obj-$(CONFIG_CROS_EC_SPI) +=3D cros_ec_spi.o cros_ec_lpcs-objs :=3D cros_ec_lpc.o cros_ec_lpc_mec.o -cros-ec-typec-objs :=3D cros_ec_typec.o +cros-ec-typec-objs :=3D cros_ec_typec.o cros_typec_vdm.o obj-$(CONFIG_CROS_EC_TYPEC) +=3D cros-ec-typec.o obj-$(CONFIG_CROS_EC_LPC) +=3D cros_ec_lpcs.o obj-$(CONFIG_CROS_EC_PROTO) +=3D cros_ec_proto.o cros_ec_trace.o diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chr= ome/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 =20 #include "cros_ec_typec.h" +#include "cros_typec_vdm.h" =20 #define DRV_NAME "cros-ec-typec" =20 @@ -272,6 +273,7 @@ static int cros_typec_register_port_altmodes(struct cro= s_typec_data *typec, return PTR_ERR(amode); port->port_altmode[CROS_EC_ALTMODE_DP] =3D amode; typec_altmode_set_drvdata(amode, port); + amode->ops =3D &port_amode_ops; =20 /* * Register TBT compatibility alt mode. The EC will not enter the mode @@ -286,6 +288,7 @@ static int cros_typec_register_port_altmodes(struct cro= s_typec_data *typec, return PTR_ERR(amode); port->port_altmode[CROS_EC_ALTMODE_TBT] =3D amode; typec_altmode_set_drvdata(amode, port); + amode->ops =3D &port_amode_ops; =20 port->state.alt =3D NULL; port->state.mode =3D TYPEC_STATE_USB; diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/ch= rome/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 *v= do) +{ + struct cros_typec_port *port =3D typec_altmode_get_drvdata(amode); + struct ec_params_typec_control req =3D { + .port =3D port->port_num, + .command =3D TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + }; + struct typec_vdm_req vdm_req =3D {}; + u32 hdr; + + hdr =3D VDO(amode->svid, 1, SVDM_VER_2_0, CMD_ENTER_MODE); + hdr |=3D VDO_OPOS(amode->mode); + + vdm_req.vdm_data[0] =3D hdr; + vdm_req.vdm_data_objects =3D 1; + vdm_req.partner_type =3D TYPEC_PARTNER_SOP; + req.vdm_req_params =3D 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 =3D { + .enter =3D cros_typec_port_amode_enter, +}; diff --git a/drivers/platform/chrome/cros_typec_vdm.h b/drivers/platform/ch= rome/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__ */ --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC12DC10F1B for ; Wed, 28 Dec 2022 01:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232290AbiL1BL3 (ORCPT ); Tue, 27 Dec 2022 20:11:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiL1BL1 (ORCPT ); Tue, 27 Dec 2022 20:11:27 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18708E2A for ; Tue, 27 Dec 2022 17:11:23 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id c7so9804642pfc.12 for ; Tue, 27 Dec 2022 17:11:23 -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=x0IzbXANOA4smyJWPf6k5K+LHE/i6odBcmTrvB/EUa6Z9R2hEAn2A+QQv/CcRLp1xo 0+6FOem7IhGFaKAYkqBB2Wp6VsmTuRNjfwbRliyxVtSzNk/b2ysi7SElGOVyKud7UBML pt2CjhMoHKi1icmwhtqBNTxLWCSdnI/FtRJiK5LWdGjUbMQfiXY8H33vUJmHvBijhH+m yqap8zrtJCYpXL0uw+7PSYDq648/PjgyQ/+HgWlXlLBDiKKOIm2xDgkbZt4uGjdlkil7 NfWDPMZhaBRuAhZpARMP4cGmwDlOSH2a5eZANlGh9AAf5giGAzk29JsqxTISf90vc8Xo 5owA== X-Gm-Message-State: AFqh2kqN7sHIfsccav6SxEi86mL0me2/t3Cme5Un1IG5+EB6LkraMYcI 6Q/6BJ/uDqR+ITnHHVf964gNMy3vnyWcyehA 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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/chr= ome/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_typ= ec_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 =3D 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_n= um); + } } =20 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/ch= rome/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" =20 +/* + * Retrieves a VDM response from the EC and forwards it to the altmode dri= ver based on SVID. + */ +void cros_typec_handle_vdm_response(struct cros_typec_data *typec, int por= t_num) +{ + struct ec_response_typec_vdm_response resp; + struct ec_params_typec_vdm_response req =3D { + .port =3D port_num, + }; + struct typec_altmode *amode; + u16 svid; + u32 hdr; + int ret; + + ret =3D 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 =3D resp.vdm_response[0]; + svid =3D PD_VDO_VID(hdr); + dev_dbg(typec->dev, "Received VDM header: %x, port: %d\n", hdr, port_num); + + amode =3D 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), po= rt: %d\n", + svid, port_num); + return; + } + + ret =3D typec_altmode_vdm(amode, hdr, &resp.vdm_response[1], resp.vdm_dat= a_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 *v= do) { struct cros_typec_port *port =3D typec_altmode_get_drvdata(amode); diff --git a/drivers/platform/chrome/cros_typec_vdm.h b/drivers/platform/ch= rome/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 @@ =20 extern struct typec_altmode_ops port_amode_ops; =20 +void cros_typec_handle_vdm_response(struct cros_typec_data *typec, int por= t_num); + #endif /* __CROS_TYPEC_VDM__ */ --=20 2.39.0.314.g84b9a713c41-goog From nobody Tue Sep 16 23:23:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F382C3DA7D for ; Wed, 28 Dec 2022 01:13:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232355AbiL1BNG (ORCPT ); Tue, 27 Dec 2022 20:13:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiL1BNB (ORCPT ); Tue, 27 Dec 2022 20:13:01 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2706B4B for ; Tue, 27 Dec 2022 17:12:57 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id d10so9698743pgm.13 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=znZTzoMVJf+N7o2aWM8cYcw0G/jHf5hXX4+PG7k4DRDP1eUhgkdmJoxfWof2G1E2se uVZILR4TW0bADhN8F/o4MGqeWzWJ2eGx/Oz9IkFjqgjzB5CpVrFeRP671A0P8sQW3mji R1AJf0JtFXe9nxSshDHppyL4QnDD1Tl1bTBatrZOwnTI4ByPKt9jIVOnw95lolEOmqzq 7a7KlY6WhrAawfH9xUBBdkxcSy3ef4eZvFtBC01wjat+PFVkwtyIvAhDeaFrhKGnX75K Ji7sMMymyTxb1kS39dI1kBumvCTobRV2sLQsNZ/0jvq4g7CqjNe5rCYuY+z2nsH08eqR mlrQ== X-Gm-Message-State: AFqh2kq/OJSiJbwAilMsPhV48axXssJkkfwpi7z/1l7DIhB7DFiXJ6Mp FyJ3okCGJU5+1PscusC94TbTlh3jhpRFUQg5 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Acked-by: Heikki Krogerus 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/ch= rome/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_altm= ode *amode, u32 *vdo) sizeof(req), NULL, 0); } =20 +static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u3= 2 hdr, + const u32 *vdo, int cnt) +{ + struct cros_typec_port *port =3D typec_altmode_get_drvdata(amode); + struct ec_params_typec_control req =3D { + .port =3D port->port_num, + .command =3D TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + }; + struct typec_vdm_req vdm_req =3D {}; + + vdm_req.vdm_data[0] =3D hdr; + vdm_req.vdm_data_objects =3D cnt; + memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1); + vdm_req.partner_type =3D TYPEC_PARTNER_SOP; + req.vdm_req_params =3D vdm_req; + + dev_dbg(port->typec_data->dev, "Sending VDM, hdr: %x, num_objects: %d, po= rt: %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 =3D { .enter =3D cros_typec_port_amode_enter, + .vdm =3D cros_typec_port_amode_vdm, }; --=20 2.39.0.314.g84b9a713c41-goog