From patchwork Tue Sep 10 10:15:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 827313 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 0021318FC9C for ; Tue, 10 Sep 2024 10:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963339; cv=none; b=CPJUb+baVSppW3DTgl5K4rNvJgg+5T4L/GbSBz1oV+zKwtluju1uSlBX9au68USTGvAksSEqHUE2DSzRQZpj8/7+uEhH9Ubl6XskpyLDrQPikvtO3z0umcP+PQpvwYTiGgo44ehhhoFd2jeY6GKnbwHMif7TyIzQyGPjxdhhYSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963339; c=relaxed/simple; bh=P845PChozNDR5SGQbooLDKSy6BNU+jWzs4r3D6gy+s0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FnjvF7G+Art7x71e0Z4KkJVedxQF0F8zqpEP/LXpgLM+U+TK04VXRQPsMOKxlK2l9oONqp4HsvtdnCbeaNiu4iHSvrXn3mW5VPxcGZOdKBEcZTJE2L53N0Xg2HXsO0sN6TBr5IKsrSuvGo5djIEixGbvMVL+PjTzIDYJnZbZgcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=HCRtq62D; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HCRtq62D" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5c3c34e3c39so7618969a12.2 for ; Tue, 10 Sep 2024 03:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725963336; x=1726568136; darn=vger.kernel.org; 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=14fOqglI4gqlZHINscrTLoCf9Zlvu7dl6ljaBQHSUuQ=; b=HCRtq62D3+x4ANREAolesytWo87UyA+a3Z5He5Ou9Ge0nfOPYhpf7ppepmgACyDQXp 2JpimxegEX8kWqBo+5x1joIyckfU4SBVxPnAbpAIk9ElL0uMZtnm9pwZZLnWz1MAFfF3 xzb2DMfuacitOsi+O/uo9geoXRujVaGQfK58w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725963336; x=1726568136; 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=14fOqglI4gqlZHINscrTLoCf9Zlvu7dl6ljaBQHSUuQ=; b=dbIm0Dh0sS1JfdzwkbRl4/LwynIFk9WG+mqFbX1j3oFgjpxPGrr2qQ5JpxWsj5PEl8 Zl9SmJQFkzBggMPO7lYpI7qSPC/K6lFfK0Bx/Egm8A+drrKOkkDTjRL9REWEasFGv4xM D4yK99afJ1ZhTFg/slSWfAySB7M4YIFPlEGlLbD/D/5+VpqxuofR7lBXShXDQAutCtjy HTHc7UWMAwfLYtlPTsUERV3xGBUofI0m4CSi0Nq0UofMW8eWRjlawH2r6hzjdi8Ono2c KDUEGVtzH9gkzN17Q2/ju/5eYWpm/O5bW4kp7V3dY4VYuxygV2unQMUauJwnMZbQV4lO 43bA== X-Forwarded-Encrypted: i=1; AJvYcCXzkLzs0u6ynCtyogd4elWGPH6cJsEtb5nAZoBrADmswVLpcrrm04ksuoBOh0rxAkKperPxMjK/TVM=@vger.kernel.org X-Gm-Message-State: AOJu0YyQzJeUBTeqzS85vEpx41zjwDj6f4Wn2zhEyvxlOL48jZxb/Ys8 vJj0sp29eBq0931w3p9tDOb3cPd+vmD+XQ4s5tw4EQY2lV+Y3CFyD4Uzn7pi X-Google-Smtp-Source: AGHT+IHf3x52xmPmWW27g7tPZAnY8Wi/THOklHIPEmyuKAyafMoyrrGYgmExnYJC5b9NF8LHKNzaSg== X-Received: by 2002:a05:6402:34c8:b0:5be:fadc:e13c with SMTP id 4fb4d7f45d1cf-5c3dc77ff52mr9531818a12.4.1725963336069; Tue, 10 Sep 2024 03:15:36 -0700 (PDT) Received: from ukaszb-ng.c.googlers.com.com (140.20.91.34.bc.googleusercontent.com. [34.91.20.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd424f0sm4075401a12.7.2024.09.10.03.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 03:15:35 -0700 (PDT) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Heikki Krogerus , Greg Kroah-Hartman , Lee Jones , Benson Leung , Guenter Roeck Cc: Abhishek Pandit-Subedi , Pavan Holla , Tzung-Bi Shih , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Subject: [PATCH v6 1/8] platform/chrome: Update ChromeOS EC header for UCSI Date: Tue, 10 Sep 2024 10:15:20 +0000 Message-ID: <20240910101527.603452-2-ukaszb@chromium.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240910101527.603452-1-ukaszb@chromium.org> References: <20240910101527.603452-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Pavan Holla Add EC host commands for reading and writing UCSI structures in the EC. The corresponding kernel driver is cros-ec-ucsi. Also update PD events supported by the EC. Signed-off-by: Pavan Holla Signed-off-by: Łukasz Bartosik --- .../linux/platform_data/cros_ec_commands.h | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index e574b790be6f..8dbb6a769e4f 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -5012,8 +5012,11 @@ struct ec_response_pd_status { #define PD_EVENT_POWER_CHANGE BIT(1) #define PD_EVENT_IDENTITY_RECEIVED BIT(2) #define PD_EVENT_DATA_SWAP BIT(3) +#define PD_EVENT_TYPEC BIT(4) +#define PD_EVENT_PPM BIT(5) + struct ec_response_host_event_status { - uint32_t status; /* PD MCU host event status */ + uint32_t status; /* PD MCU host event status */ } __ec_align4; /* Set USB type-C port role and muxes */ @@ -6073,6 +6076,29 @@ struct ec_response_typec_vdm_response { #undef VDO_MAX_SIZE +/* + * UCSI OPM-PPM commands + * + * These commands are used for communication between OPM and PPM. + * Only UCSI3.0 is tested. + */ + +#define EC_CMD_UCSI_PPM_SET 0x0140 + +/* The data size is stored in the host command protocol header. */ +struct ec_params_ucsi_ppm_set { + uint16_t offset; + uint8_t data[]; +} __ec_align2; + +#define EC_CMD_UCSI_PPM_GET 0x0141 + +/* For 'GET' sub-commands, data will be returned as a raw payload. */ +struct ec_params_ucsi_ppm_get { + uint16_t offset; + uint8_t size; +} __ec_align2; + /*****************************************************************************/ /* The command range 0x200-0x2FF is reserved for Rotor. */ From patchwork Tue Sep 10 10:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 827312 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 6E8C31917C6 for ; Tue, 10 Sep 2024 10:15:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963341; cv=none; b=HZF6mKDRuj1Pp6JhP4Hb0NkdPuCEKhdV6Fiq+e+z9YGll+OSi6AgZrTicHpZBmPiMMUwyHkA6znd6inU5GXD7ye+VX905QhDuTJnmutI0+FPwaF1JVuz+Hjkjp6SajzcpPR0yejJN4LaiseWZy0ECQ3fyB/BpNYGMuwkMKhEzP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963341; c=relaxed/simple; bh=+8hk+kJmR2SsDvw10WpS8DsYjndB+0n7l87NsIhLzJY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=URjv+6Mddqp8VBSjZHAln0SSwDZ5cFViBmgMQ8DLVDxlbpvFfhRVyR8fxMVbEWp8Cv+AxaBicNV0qXPb+ZZH5+0Y/XGva45XAR2bLeC2niOC8BVRH/F24ePRjTSAxVdyZO79aZyX/uFu9wMZ2sRSKNL0xG57pMRKsy53bzM3MTM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Ix/COoD0; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Ix/COoD0" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a8a837cec81so244027466b.2 for ; Tue, 10 Sep 2024 03:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725963338; x=1726568138; darn=vger.kernel.org; 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=83DCmEuq7JrWTmbULmBpjHQMPEO/K0lZCYAd0BrN8Kc=; b=Ix/COoD0Rqg4/KMfMJ3VpNZyCT2MR9Ltu1xFXYXBPp98oe5MzJFAIRPPzNNtpKrHs5 iz6rkfx0F6/QKCV7Id4x40w41wPaFrx8nhVUq1dpFNpaBSTs64DibouEO47WsmsA58jZ r9R2D9jdmTflW95rwvzLr3gE2U9LcyWYzLPvE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725963338; x=1726568138; 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=83DCmEuq7JrWTmbULmBpjHQMPEO/K0lZCYAd0BrN8Kc=; b=pZPMT+Ax6F7gL2xnBhTkiFEKOFwwPhgu+UJU6Ip1WZgAPDlgA2SAcLAVk6eJihIRtD bo08Mjp/I0NnyboC+NYyiXhizt8bmB9SnvKfTcoXTet7CCLYPz5wM5lO0mJTN1lgh5gE SZfQf3Lb/qPCWcFzVtCrbBZWp4Lh8Nn/6ClZfABOPN+RRgxvaAF0+LogRPsKxhb13MKj uK4+Z+rYp9IxbCpgMEruULuXwjO3Cf2wZOAwQaHYzeao/6WWHKrvfQi6BDOiV1Q1Wpu4 VTPSuMlEcA7cqO9cOy9qFHMo/moEh1rb6fcc1wZuseOjRjr+pH/Atcevp7/0a6g3BNEo kv0w== X-Forwarded-Encrypted: i=1; AJvYcCUiVPg3EtCP7T6OnYl0xQFBYahGVbEQaugMabS8N18biR2Xn9zdNT3gr3dMGgoID18fih0AyTfaFLU=@vger.kernel.org X-Gm-Message-State: AOJu0YzH++V8rWcfVLyLONUpj0lqhMh2olX45owWH3RadBTK5tNMNg0X /+8NFCYnWVA/bh3K5dXJgRfCWIlaIE9tafpD1MW3xbdw8g+RouCxeMLLBHQR X-Google-Smtp-Source: AGHT+IHE4rrZXnsK6QRB1ACp9FxoMImuTXf20860U02c9qcu6cfe7aWIFZs39uplA7VdzTCrQ45ZPg== X-Received: by 2002:a05:6402:360a:b0:5c2:6a73:d13b with SMTP id 4fb4d7f45d1cf-5c3dc7c02d8mr12419030a12.34.1725963336780; Tue, 10 Sep 2024 03:15:36 -0700 (PDT) Received: from ukaszb-ng.c.googlers.com.com (140.20.91.34.bc.googleusercontent.com. [34.91.20.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd424f0sm4075401a12.7.2024.09.10.03.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 03:15:36 -0700 (PDT) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Heikki Krogerus , Greg Kroah-Hartman , Lee Jones , Benson Leung , Guenter Roeck Cc: Abhishek Pandit-Subedi , Pavan Holla , Tzung-Bi Shih , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Subject: [PATCH v6 2/8] platform/chrome: Update EC feature flags Date: Tue, 10 Sep 2024 10:15:21 +0000 Message-ID: <20240910101527.603452-3-ukaszb@chromium.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240910101527.603452-1-ukaszb@chromium.org> References: <20240910101527.603452-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Pavan Holla Define EC_FEATURE_UCSI_PPM to enable usage of the cros_ec_ucsi driver. Also, add any feature flags that are implemented by the EC but are missing in the kernel header. Signed-off-by: Pavan Holla Signed-off-by: Łukasz Bartosik Acked-by: Tzung-Bi Shih --- .../linux/platform_data/cros_ec_commands.h | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index 8dbb6a769e4f..ecf290a0c98f 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -1312,6 +1312,38 @@ enum ec_feature_code { * The EC supports the AP composing VDMs for us to send. */ EC_FEATURE_TYPEC_AP_VDM_SEND = 46, + /* + * The EC supports system safe mode panic recovery. + */ + EC_FEATURE_SYSTEM_SAFE_MODE = 47, + /* + * The EC will reboot on runtime assertion failures. + */ + EC_FEATURE_ASSERT_REBOOTS = 48, + /* + * The EC image is built with tokenized logging enabled. + */ + EC_FEATURE_TOKENIZED_LOGGING = 49, + /* + * The EC supports triggering an STB dump. + */ + EC_FEATURE_AMD_STB_DUMP = 50, + /* + * The EC supports memory dump commands. + */ + EC_FEATURE_MEMORY_DUMP = 51, + /* + * The EC supports DP2.1 capability + */ + EC_FEATURE_TYPEC_DP2_1 = 52, + /* + * The MCU is System Companion Processor Core 1 + */ + EC_FEATURE_SCP_C1 = 53, + /* + * The EC supports UCSI PPM. + */ + EC_FEATURE_UCSI_PPM = 54, }; #define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32) From patchwork Tue Sep 10 10:15:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 827311 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 2C881191F6D for ; Tue, 10 Sep 2024 10:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963343; cv=none; b=Y+06XQkC5inmoPZaUYGH4Dq2t1t0Tr2LhzmGXlWtcaxovXPbDS6SNkuXg0kgtXHbltjB7AVJlvgqv020JtdnypGwA9pJrXEC7DyFPu46j/v+r5xZzENSC6T5IzAOmJVe4IApgR7pw80LKkJ2vEJBYGOcXDQdPhzHLo7Rci9aBEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963343; c=relaxed/simple; bh=lKcBF8gwOmt/ffGeVilM/VC//BkP07Qg7KfFhbt/ATM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cBiRzvwAHH4eXhsepOVD2oUME2XLnR7/skFgM25fUbyaaxJSqw9UUcQONmZLW8mxyTJBAcG1bjUr6usLGamBoeFQRz7Cne0x6YE83PVD3KCTVWHyJZTGHWFTdWcD38rILdXK43vNLySEUocH79ZHB5xXlEVRC9i9MnkkB/C/G2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ValYS4BZ; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ValYS4BZ" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5365392cfafso5087438e87.0 for ; Tue, 10 Sep 2024 03:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725963340; x=1726568140; darn=vger.kernel.org; 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=d8X/ITKpB8AA7PfOztOSGy2OE3K0m/AlkMzm5sCSbuU=; b=ValYS4BZQ2MGdLi9rsHxGIeSlkKt+H9B6MbtdjZrgVBbShoU0edz0hQ89hBZGrFGmN +rKbT2G9drPGNfi54/vyJT4HHrg0kTV2+TGGuJBdouR/kDWUmvKW8CtC/OBzyle3zpIZ A86eh2hPJ7pZsLHLw4IAbvmTDIN6dTQ8jdAxU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725963340; x=1726568140; 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=d8X/ITKpB8AA7PfOztOSGy2OE3K0m/AlkMzm5sCSbuU=; b=dEYQWnjPnM9jd1gyOdbyUJK0D06zGTXlRtbzZMOmnaP32VC8Tu/qwv0bxXBmnzqS+r KCyKHTQOu/TwE8L8S3dkQGPQO2MwpH9Z4R25y5QW2hov+RMbyt39vxTvoN6AyXkYkllI Z3eMa6IrGx2b9kLOu/tvYvP8yKHP1GnNtnfA0PaMwb4/1miIzY25dItLu3XL8f8wbg5F 1Yduv/07E3mVb6yDq/bdAQdlHNyYrn1TWq4i7mcYc/vHHxr5PTeUXiaJsw+JeLbMCZDV 6AjfaWP+nutVEeA90VOnsAJVTFHJ0RQ3088RcKiNuHT8JO6QkCOkPQc1a4Un82nrCJuv JYIA== X-Forwarded-Encrypted: i=1; AJvYcCWsBrEQUGWYECODgPGNpXvABOk2k41t4jXTisGmIPz+g9K82ECmceOZ+VvaVtODjqfFyvUV4VgmWvU=@vger.kernel.org X-Gm-Message-State: AOJu0YzJ/ZlsVilE5UEOud4vbCH2xunPOr5do1rywLTN2M4fs9mrYoLN t9jHbU6WX3+lDcMcj6xxAxHglyUoTZgAMyaedVQyjen+vxxXOHc0ikLSWAPo X-Google-Smtp-Source: AGHT+IEmWkkPyz1oxTksKWySx9B5Qd1qQQdKYCW6OpqyNaZ/PupJucqIzyjiUeUuE62f//tDSeOB4w== X-Received: by 2002:a05:6512:695:b0:52e:97b3:42a1 with SMTP id 2adb3069b0e04-536587b2c9emr7792710e87.24.1725963340124; Tue, 10 Sep 2024 03:15:40 -0700 (PDT) Received: from ukaszb-ng.c.googlers.com.com (140.20.91.34.bc.googleusercontent.com. [34.91.20.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd424f0sm4075401a12.7.2024.09.10.03.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 03:15:39 -0700 (PDT) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Heikki Krogerus , Greg Kroah-Hartman , Lee Jones , Benson Leung , Guenter Roeck Cc: Abhishek Pandit-Subedi , Pavan Holla , Tzung-Bi Shih , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Subject: [PATCH v6 4/8] usb: typec: cros_ec_ucsi: Use complete instead of resume Date: Tue, 10 Sep 2024 10:15:23 +0000 Message-ID: <20240910101527.603452-5-ukaszb@chromium.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240910101527.603452-1-ukaszb@chromium.org> References: <20240910101527.603452-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Abhishek Pandit-Subedi On platforms using cros_ec_lpc, resume is split into .resume_early and .complete. To avoid missing EC events, use .complete to schedule work when resuming. Signed-off-by: Abhishek Pandit-Subedi Signed-off-by: Łukasz Bartosik --- drivers/usb/typec/ucsi/cros_ec_ucsi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c index 20e608097fc6..422b3b14028c 100644 --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c @@ -241,15 +241,18 @@ static int __maybe_unused cros_ucsi_suspend(struct device *dev) return 0; } -static int __maybe_unused cros_ucsi_resume(struct device *dev) +static void __maybe_unused cros_ucsi_complete(struct device *dev) { struct cros_ucsi_data *udata = dev_get_drvdata(dev); - - return ucsi_resume(udata->ucsi); + ucsi_resume(udata->ucsi); } -static SIMPLE_DEV_PM_OPS(cros_ucsi_pm_ops, cros_ucsi_suspend, - cros_ucsi_resume); +static const struct dev_pm_ops cros_ucsi_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = cros_ucsi_suspend, + .complete = cros_ucsi_complete, +#endif +}; static const struct platform_device_id cros_ucsi_id[] = { { KBUILD_MODNAME, 0 }, From patchwork Tue Sep 10 10:15:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 827310 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 87B2B192B7F for ; Tue, 10 Sep 2024 10:15:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963346; cv=none; b=Jj/ltU7VgoQQ9iF4YDb0b1bt8E/inK5PFJT6Sgqz4kVDBTB9JBj2Iijem/N5S8vAXCbmox/hYTkL+LnKztZkmqiWKPEAYBG/FmBSrYNcBV+ktGH/lAz2FV/3L2GAOiJOLHORXJWoacZSg5AlwI7AdWTOY+Jr15rrcvZDY30Nk80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963346; c=relaxed/simple; bh=iXPIP6+YQyOdRHDOYj91I1S82qPxTNJ9cmgwoqMYGps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CxwtRIETr5NBRB6m7fXQWt8pn6SVkNhvXrq0ZesTa4+MLBPzRER5vBsurW/EgvZHltnW4iFUFf2BkRXOfn9/7MGGc2yIMzPUKMsQmLca5j4Ap+PHhr1mh8Pt5Sp3+PIplnjZHJJ/HEfXFWaCsfjfffVe/LOr7S+uSYCtlQQ6Y/I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=G7H4LLcE; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="G7H4LLcE" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2f75c6ed397so32237851fa.2 for ; Tue, 10 Sep 2024 03:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725963343; x=1726568143; darn=vger.kernel.org; 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=VYHsXwSttfzZMC12xnE6xhPab+ybIDxMmR3RdSOS+3Y=; b=G7H4LLcEDQHsFqzdCGk2RA5v3EStfzXwub+TjcLHM9finIk2ObNA8AxpK6bVvtyV6W V+0dpBtIocY5aVDmQBtK3Rwq/QmuSBPC+KmQka0vW4RvnPUQIyf/oQklccZzEFaPka10 xGschCjiPhqgBvteLnu+VNLRn/d97Tx/t/ugs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725963343; x=1726568143; 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=VYHsXwSttfzZMC12xnE6xhPab+ybIDxMmR3RdSOS+3Y=; b=kkOFOtqefXB4Q6QH+fERVHhLXRuOt09JH0GTVotyBgyC1Ot+NhRdHTNRnJtVDfzdB4 FS7mEIaDqCr8zKd+VL5QE+JRz8u4JmpQjNOpi7tgCN186+kmRm/oFegy4IVejGJHl5Pc UCDasDWcjefOWj8miaJwL4G0+fH67ETnQAaJ2j2GMH1LOjBqHLlG7qWNANvtTOWgHFWV aQ4jKsS7zmWw2o3jKLhWr8OpI89ONFk++HRb8LUkIEiGjTdt7ma8yq9yDIgL52VQloZX SlDdU0tWgzAY9/4ZBiveSSbLMtFXe3XvQk5aMYvz3GjIA3w7kuaiby9Ij9ThnFdWK2px Df6Q== X-Forwarded-Encrypted: i=1; AJvYcCWgjz1AIDHh68HgE3x0vupSwyJGsxBTG95+n/QiS9a1JKvTPHRlkvQTirJF6VNb3QmTo5u+og23/2Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzOeDDU+SvWUzlG3isBI93ENsf9ujRVWCyZBV8cKf+giBk02U+d 2a/Be/uzCKQil7bJI+a+AkFPO2Go5w+5PMR2RjhWq+eIJ85yIZ15NozynINJ X-Google-Smtp-Source: AGHT+IE5gd9tsanQl8hD6vroVjUks4Szy7+74eAS8FDkQ7MxuIpXNVdiLiYd8bOh8AI3dl/HCa2e8w== X-Received: by 2002:a2e:b8c7:0:b0:2ef:2555:e52f with SMTP id 38308e7fff4ca-2f751f5d04dmr106355401fa.35.1725963342576; Tue, 10 Sep 2024 03:15:42 -0700 (PDT) Received: from ukaszb-ng.c.googlers.com.com (140.20.91.34.bc.googleusercontent.com. [34.91.20.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd424f0sm4075401a12.7.2024.09.10.03.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 03:15:42 -0700 (PDT) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Heikki Krogerus , Greg Kroah-Hartman , Lee Jones , Benson Leung , Guenter Roeck Cc: Abhishek Pandit-Subedi , Pavan Holla , Tzung-Bi Shih , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Subject: [PATCH v6 6/8] usb: typec: cros_ec_ucsi: Add netlink Date: Tue, 10 Sep 2024 10:15:25 +0000 Message-ID: <20240910101527.603452-7-ukaszb@chromium.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240910101527.603452-1-ukaszb@chromium.org> References: <20240910101527.603452-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add netlink to ChromeOS UCSI driver to allow forwarding of UCSI messages to userspace for debugging and testing purposes. Signed-off-by: Łukasz Bartosik --- MAINTAINERS | 4 +- drivers/usb/typec/ucsi/Makefile | 4 +- .../{cros_ec_ucsi.c => cros_ec_ucsi_main.c} | 66 +++++++++++++- drivers/usb/typec/ucsi/cros_ec_ucsi_nl.c | 87 +++++++++++++++++++ drivers/usb/typec/ucsi/cros_ec_ucsi_nl.h | 52 +++++++++++ 5 files changed, 209 insertions(+), 4 deletions(-) rename drivers/usb/typec/ucsi/{cros_ec_ucsi.c => cros_ec_ucsi_main.c} (79%) create mode 100644 drivers/usb/typec/ucsi/cros_ec_ucsi_nl.c create mode 100644 drivers/usb/typec/ucsi/cros_ec_ucsi_nl.h diff --git a/MAINTAINERS b/MAINTAINERS index d084f32208f0..2afb406a24ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5305,7 +5305,9 @@ M: Abhishek Pandit-Subedi M: Łukasz Bartosik L: chrome-platform@lists.linux.dev S: Maintained -F: drivers/usb/typec/ucsi/cros_ec_ucsi.c +F: drivers/usb/typec/ucsi/cros_ec_ucsi_main.c +F: drivers/usb/typec/ucsi/cros_ec_ucsi_nl.c +F: drivers/usb/typec/ucsi/cros_ec_ucsi_nl.h F: drivers/usb/typec/ucsi/cros_ec_ucsi_trace.h CHRONTEL CH7322 CEC DRIVER diff --git a/drivers/usb/typec/ucsi/Makefile b/drivers/usb/typec/ucsi/Makefile index be98a879104d..82d960394c39 100644 --- a/drivers/usb/typec/ucsi/Makefile +++ b/drivers/usb/typec/ucsi/Makefile @@ -21,5 +21,7 @@ obj-$(CONFIG_UCSI_ACPI) += ucsi_acpi.o obj-$(CONFIG_UCSI_CCG) += ucsi_ccg.o obj-$(CONFIG_UCSI_STM32G0) += ucsi_stm32g0.o obj-$(CONFIG_UCSI_PMIC_GLINK) += ucsi_glink.o -obj-$(CONFIG_CROS_EC_UCSI) += cros_ec_ucsi.o obj-$(CONFIG_UCSI_LENOVO_YOGA_C630) += ucsi_yoga_c630.o + +obj-$(CONFIG_CROS_EC_UCSI) += cros_ec_ucsi.o +cros_ec_ucsi-y := cros_ec_ucsi_main.o cros_ec_ucsi_nl.o diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi_main.c similarity index 79% rename from drivers/usb/typec/ucsi/cros_ec_ucsi.c rename to drivers/usb/typec/ucsi/cros_ec_ucsi_main.c index 70185616ec86..008b61921278 100644 --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi_main.c @@ -19,6 +19,7 @@ #define CREATE_TRACE_POINTS #include "ucsi.h" #include "cros_ec_ucsi_trace.h" +#include "cros_ec_ucsi_nl.h" /* * Maximum size in bytes of a UCSI message between AP and EC @@ -43,6 +44,43 @@ struct cros_ucsi_data { unsigned long flags; }; +/* + * When set to true the cros_ec_ucsi driver will forward all UCSI messages + * exchanged between OPM <-> PPM to userspace through netlink + */ +static bool is_ap_sniffer_en; + +static ssize_t enable_ap_sniffer_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", is_ap_sniffer_en); +} + +static ssize_t enable_ap_sniffer_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + u8 value; + + if (kstrtou8(buf, 0, &value)) + return -EINVAL; + + is_ap_sniffer_en = value ? 1 : 0; + return count; +} + +static DEVICE_ATTR_RW(enable_ap_sniffer); + +static struct attribute *cros_ec_ucsi_attrs[] = { + &dev_attr_enable_ap_sniffer.attr, + NULL +}; + +static const struct attribute_group cros_ec_ucsi_attrs_grp = { + .attrs = cros_ec_ucsi_attrs, +}; + static int cros_ucsi_read(struct ucsi *ucsi, unsigned int offset, void *val, size_t val_len) { @@ -65,6 +103,9 @@ static int cros_ucsi_read(struct ucsi *ucsi, unsigned int offset, void *val, return ret; } + if (is_ap_sniffer_en) + nl_cros_ec_bcast_msg(NL_CROS_EC_TO_PPM, NL_CROS_EC_RD, offset, + val, val_len); trace_cros_ec_opm_to_ppm_rd(offset, val, val_len); return 0; } @@ -101,6 +142,9 @@ static int cros_ucsi_async_control(struct ucsi *ucsi, u64 cmd) return ret; } + if (is_ap_sniffer_en) + nl_cros_ec_bcast_msg(NL_CROS_EC_TO_PPM, NL_CROS_EC_WR, + req->offset, (u8 *) &cmd, sizeof(cmd)); trace_cros_ec_opm_to_ppm_wr(req->offset, &cmd, sizeof(cmd)); return 0; } @@ -144,6 +188,8 @@ static void cros_ucsi_work(struct work_struct *work) struct cros_ucsi_data *udata = container_of(work, struct cros_ucsi_data, work); u32 cci; + if (is_ap_sniffer_en) + nl_cros_ec_bcast_msg(NL_CROS_EC_TO_OPM, 0, 0, NULL, 0); trace_cros_ec_ppm_to_opm(0); if (cros_ucsi_read_cci(udata->ucsi, &cci)) @@ -229,13 +275,29 @@ static int cros_ucsi_probe(struct platform_device *pdev) return ret; } + ret = nl_cros_ec_register(); + if (ret) { + dev_err(dev, "failed to register netlink: error=%d", ret); + cros_ucsi_destroy(udata); + return ret; + } + + ret = sysfs_create_group(&dev->kobj, &cros_ec_ucsi_attrs_grp); + if (ret) { + dev_err(dev, "failed to register sysfs group: error=%d", ret); + cros_ucsi_destroy(udata); + return ret; + } + return 0; } -static void cros_ucsi_remove(struct platform_device *dev) +static void cros_ucsi_remove(struct platform_device *pdev) { - struct cros_ucsi_data *udata = platform_get_drvdata(dev); + struct cros_ucsi_data *udata = platform_get_drvdata(pdev); + sysfs_remove_group(&pdev->dev.kobj, &cros_ec_ucsi_attrs_grp); + nl_cros_ec_unregister(); ucsi_unregister(udata->ucsi); cros_ucsi_destroy(udata); } diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi_nl.c b/drivers/usb/typec/ucsi/cros_ec_ucsi_nl.c new file mode 100644 index 000000000000..360568044891 --- /dev/null +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi_nl.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include "cros_ec_ucsi_nl.h" + +static const struct genl_multicast_group nl_mc_grps[] = { + { .name = NL_CROS_EC_MC_GRP_NAME }, +}; + +static struct genl_family genl_fam = { + .name = NL_CROS_EC_NAME, + .version = NL_CROS_EC_VER, + .maxattr = NL_CROS_EC_A_MAX, + .mcgrps = nl_mc_grps, + .n_mcgrps = ARRAY_SIZE(nl_mc_grps), +}; + +int nl_cros_ec_register(void) +{ + return genl_register_family(&genl_fam); +} + +void nl_cros_ec_unregister(void) +{ + genl_unregister_family(&genl_fam); +} + +int nl_cros_ec_bcast_msg(enum nl_cros_ec_msg_dir dir, + enum nl_cros_ec_cmd_type cmd_type, + u16 offset, const u8 *payload, size_t msg_size) +{ + struct timespec64 ts; + struct sk_buff *skb; + int ret = -ENOMEM; + void *hdr; + + skb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + hdr = genlmsg_put(skb, 0, 0, &genl_fam, 0, NL_CROS_EC_C_UCSI); + if (!hdr) + goto free_mem; + + ret = nla_put_u8(skb, NL_CROS_EC_A_SRC, NL_CROS_EC_AP); + if (ret) + goto cancel; + + ret = nla_put_u8(skb, NL_CROS_EC_A_DIR, dir); + if (ret) + goto cancel; + + ret = nla_put_u16(skb, NL_CROS_EC_A_OFFSET, offset); + if (ret) + goto cancel; + + ret = nla_put_u8(skb, NL_CROS_EC_A_CMD_TYPE, cmd_type); + if (ret) + goto cancel; + + ktime_get_ts64(&ts); + ret = nla_put_u32(skb, NL_CROS_EC_A_TSTAMP_SEC, (u32)ts.tv_sec); + if (ret) + goto cancel; + + ret = nla_put_u32(skb, NL_CROS_EC_A_TSTAMP_USEC, + (u32)(ts.tv_nsec/1000)); + if (ret) + goto cancel; + + ret = nla_put(skb, NL_CROS_EC_A_PAYLOAD, msg_size, payload); + if (ret) + goto cancel; + + genlmsg_end(skb, hdr); + + ret = genlmsg_multicast(&genl_fam, skb, 0, 0, GFP_KERNEL); + if (ret && ret != -ESRCH) + goto free_mem; + + return 0; +cancel: + genlmsg_cancel(skb, hdr); +free_mem: + nlmsg_free(skb); + return ret; +} diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi_nl.h b/drivers/usb/typec/ucsi/cros_ec_ucsi_nl.h new file mode 100644 index 000000000000..c6192d8ace56 --- /dev/null +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi_nl.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __DRIVER_USB_TYPEC_CROS_EC_UCSI_NL_H +#define __DRIVER_USB_TYPEC_CROS_EC_UCSI_NL_H + +#define NL_CROS_EC_NAME "cros_ec_ucsi" +#define NL_CROS_EC_VER 1 +#define NL_CROS_EC_MC_GRP_NAME "cros_ec_ucsi_mc" + +/* attributes */ +enum nl_cros_ec_attrs { + NL_CROS_EC_A_SRC, + NL_CROS_EC_A_DIR, + NL_CROS_EC_A_OFFSET, + NL_CROS_EC_A_CMD_TYPE, + NL_CROS_EC_A_TSTAMP_SEC, + NL_CROS_EC_A_TSTAMP_USEC, + NL_CROS_EC_A_PAYLOAD, + NL_CROS_EC_A_MAX +}; + +enum nl_cros_ec_cmds { + NL_CROS_EC_C_UCSI, + NL_CROS_EC_C_MAX +}; + +/* where message was captured - EC or AP */ +enum nl_cros_ec_src { + NL_CROS_EC_AP, + NL_CROS_EC_EC +}; + +/* message destination */ +enum nl_cros_ec_msg_dir { + NL_CROS_EC_TO_PPM, + NL_CROS_EC_TO_OPM, + NL_CROS_EC_TO_LPM +}; + +/* command type - read or write */ +enum nl_cros_ec_cmd_type { + NL_CROS_EC_RD, + NL_CROS_EC_WR +}; + +int nl_cros_ec_register(void); +void nl_cros_ec_unregister(void); +int nl_cros_ec_bcast_msg(enum nl_cros_ec_msg_dir dir, + enum nl_cros_ec_cmd_type cmd_type, + u16 offset, const u8 *payload, size_t msg_size); + +#endif /* __DRIVER_USB_TYPEC_CROS_EC_UCSI_NL_H */ From patchwork Tue Sep 10 10:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 827309 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.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 8046C18C00C for ; Tue, 10 Sep 2024 10:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963349; cv=none; b=uPtG4yqEYOokziLcwnm0Icba98E1MM+w3N6hTkombErGLNY1hCOqx/6CBxhG448fOgBA1FJQkDdTmHlOpIE46O025uM9eq3ccmEDTqqQw3V9i4Poux0NzJjDCfqTK+xoF6lRWYJEeeIP7DwphziyzC2VzFWF2zgvt3WQzfq9aj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963349; c=relaxed/simple; bh=tSQJHbj2LLXTeUHGgMMfJ5BWAL/nLVLLEk1C+o3nHws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BmDVnHvjO43bC8g+W02UlK43lf2gHiQHm9t+ZvGqp1E/1mWrEH0J+Cw4Rov7Khv8+uISxeE96NV/OEJxg04UND5H4Ih+wB41LBykRMglxdqBFD/I/z1enkqzzr9x1AQNrYjTXyq0jf5wmsRFZ3XFTrLqoXVK7RtRmluKAfX5DPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ecnFquS4; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ecnFquS4" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2f753375394so35363531fa.0 for ; Tue, 10 Sep 2024 03:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725963346; x=1726568146; darn=vger.kernel.org; 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=e6E5yTq083nuSzrDbz7WTLj5zuoz2JOMDpjBBNEDmzQ=; b=ecnFquS40VhD8kc0IVHwo6o53BggtyuLUul619VLfNYwtZ4uD+8L2HCzibrCePknyP GNR6IaglX7tnfUy/OHXyKnd9OnSS0Mn6qaRnNvujUTyfanHunHvy5GcUlgp/L2yp/yAI I3/9lR3OmzJW9nfXvwgtr/Z32qWfkrQjLqlfw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725963346; x=1726568146; 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=e6E5yTq083nuSzrDbz7WTLj5zuoz2JOMDpjBBNEDmzQ=; b=SagM2UghsRraaU1UqLGSVwUsEqRUYbR1cSdPF/ykqEZXoiq0LhiRyf05IBFIfAn1zb EisA74OniJjvyVIwl1540UuWglIPoe+4VeaDyTloAyicvbIgnZfgPsObHEagxdGRwbhU a1vZfrRkHNmDagM0Dlmkc/RjHQnIx4DSdzSkkEWAIAIY3k2xiyJsSGdkWqGffxzBIeTp dJNVP/bocmnTtvUKH0QNhJZ8Lvzv/bkONq1sKQSCYtHnjrvIzdsu/p37ErJu+3bxgVl1 Fi0vS60iqzHWdNpNVKIkoR8ZSO6qjkipgtE7Qnrr9YwzXazksAn2zOUPWHnf3As7j3mX jRyw== X-Forwarded-Encrypted: i=1; AJvYcCUtrkLhEFg3QKrt4TKdP05iA7HtSaAceg5As3Ty8KQjaObiCjbdKLPQRxG/aIXArnmYnSu9uK4mzZo=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/Cx2Cf3CUIi8VuSXI3oBVO67Dso7Or4c+XKcfgmJJUdqrcy3b Tk8PuQUHdsLhxJEpnleMPvW8/o3ppEOd6ToFqZ9iOlhi7tJ9UCLWlVdLbdBH X-Google-Smtp-Source: AGHT+IHaKe6rWjU3xH9ycsM7F8BdbXD7rsT077HrnyCJDew/oIYr2SQOxzYhjp9tGDoTKY9rIz0ULg== X-Received: by 2002:a2e:5109:0:b0:2f5:806:5cee with SMTP id 38308e7fff4ca-2f751ec7daamr64177571fa.11.1725963345513; Tue, 10 Sep 2024 03:15:45 -0700 (PDT) Received: from ukaszb-ng.c.googlers.com.com (140.20.91.34.bc.googleusercontent.com. [34.91.20.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd424f0sm4075401a12.7.2024.09.10.03.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 03:15:43 -0700 (PDT) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Heikki Krogerus , Greg Kroah-Hartman , Lee Jones , Benson Leung , Guenter Roeck Cc: Abhishek Pandit-Subedi , Pavan Holla , Tzung-Bi Shih , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Subject: [PATCH v6 8/8] mfd: cros_ec: Don't load charger with UCSI Date: Tue, 10 Sep 2024 10:15:27 +0000 Message-ID: <20240910101527.603452-9-ukaszb@chromium.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240910101527.603452-1-ukaszb@chromium.org> References: <20240910101527.603452-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Abhishek Pandit-Subedi When UCSI is enabled, don't load cros_usbpd_charger and cros_usbpd_logger drivers. Charger functionality is provided by the UCSI driver already and logging will need to be added. Signed-off-by: Abhishek Pandit-Subedi Signed-off-by: Łukasz Bartosik --- drivers/mfd/cros_ec_dev.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index d5d63df7fcbd..bc083c7b21de 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -133,11 +133,6 @@ static const struct cros_feature_to_cells cros_subdevices[] = { .mfd_cells = cros_ec_ucsi_cells, .num_cells = ARRAY_SIZE(cros_ec_ucsi_cells), }, - { - .id = EC_FEATURE_USB_PD, - .mfd_cells = cros_usbpd_charger_cells, - .num_cells = ARRAY_SIZE(cros_usbpd_charger_cells), - }, { .id = EC_FEATURE_HANG_DETECT, .mfd_cells = cros_ec_wdt_cells, @@ -261,6 +256,21 @@ static int ec_device_probe(struct platform_device *pdev) } } + /* + * UCSI provides power supply information so we don't need to separately + * load the cros_usbpd_charger driver. + */ + if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) && + !cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM)) { + retval = mfd_add_hotplug_devices(ec->dev, + cros_usbpd_charger_cells, + ARRAY_SIZE(cros_usbpd_charger_cells)); + + if (retval) + dev_warn(ec->dev, "failed to add usbpd-charger: %d\n", + retval); + } + /* * Lightbar is a special case. Newer devices support autodetection, * but older ones do not.