From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) (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 23D8045A2A1 for ; Mon, 24 Aug 2026 15:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787586997; cv=none; b=c+x/t9AgkFuDwoWAAnl+SHzVDV7r2Ge5+sVftN2vV9uRMu0T8qupjgyAHZcONJOGLqHa5r/bBIJdD7FW9oIa0ATz3fgsqChnuu8+mkTybNsOWpCm4CmPBwUQJMOpKsMEFPkaJsE5UEhIICYVD1gaRth0SYhglUf8IPlb8uAeY40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787586997; c=relaxed/simple; bh=8SXzDdT7GWUWhSoa0ayu0NCwuv9AWuYg7CMOfT3V5/o=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=sct0Gghr3mq+GwuJT+Kj/DMXhtDhxm3DpntJkUXwbOkHmGWRHwPBB4swRixtSLA5rjveZxtQGKVTXwBA7WAwfi6k2BBA+T+/lK0eIo9DWgiZKRq4RYV3koRpZPxOMjM0oecAG7Yl4WuV7arX3TESCivlKDlx6f1DCOdVEEhc6+c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dbalint.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MaFJP5XF; arc=none smtp.client-ip=209.85.208.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dbalint.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MaFJP5XF" Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-3a0eac71204so12638881fa.1 for ; Mon, 24 Aug 2026 08:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787586991; x=1788191791; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=QIiBqNSDDVOkhse3dzgdWszMb+AaDTWW+ZJrLhjzFtY=; b=MaFJP5XF2gQ0L7xqbIoswCXFkqMmKZatNvRIrZXeMUQOlN8joySROyfvOm/tVST/Wh EWOYH2oNtlLLCMvAznCC3r74x517fm1P2yTNnL++78zw74n3gT0cgT4dkeKIJkm7TF+p 22gA6OIeOycKQROe+p5gvXZK5AFpu+7hRHTfoMxwqHCBRAzFBt1qZpXMRTytbqupHOE2 fjhg6JIuj8cVCLJAYyx9yoiMyAFp0PJ5DJPgeCeXleviJ6jJdHik0fRpQoVzNiY9o9O9 gi3oSY2JMzTPrcSfzwJm73om0xk++mBsnrvaqRQxIzEAKSz6m8REWliW48w/1RVUkAji 0oIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787586991; x=1788191791; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QIiBqNSDDVOkhse3dzgdWszMb+AaDTWW+ZJrLhjzFtY=; b=RyLeL9GG+u7pI2XsOP3XhM/gfZgS8DKZJWcfyFZLk6FRqdQlWANyh6mYPzFHBjdg/+ YQJewDXVXplM3Hp0BogOFHlmY8uN6pyNS2tTfBi+zz9THF681Uc/C6N0yarnhj9neBsr fMqCmS8zmd1UyMRmx2bondFYhTuzpL6D7yCrFgKmPSQacBUe3AD2JMqrlcnz7nk8yBAD cMkR9FDkhURRXMI6hd8U39rsZWn/lyx2T6TbbSNL0Wd5rjHtxPaHotJLhxZA/aNbJ0XL QCc3SIEfxx2FWA8gFFZgm9ksut+onIw2AdlnJeOlsQpLCAdma1z/un2nYAZ88WWyK6UE xIAg== X-Gm-Message-State: AFuF++nDOpCl+4inAJNBVpdw8B5arSK+C8C7UmZb5WtdQ/8cl+5Z97pO SlDfakg/wkPO0nvwhvOJyltnxDD7Sa5p3rHWDXBPaEtlEnnZP984wZ5pdrOEG8C2+RwtOZqrF/L q6t+P/CChTQ== X-Received: from ljqx34.prod.google.com ([2002:a2e:a9a2:0:b0:3a1:7f0f:2a05]) (user=dbalint job=prod-delivery.src-stubby-dispatcher) by 2002:a05:651c:a20f:10b0:3a1:5172:c287 with SMTP id 38308e7fff4ca-3a1aebdb861mr45321331fa.5.1787586991037; Mon, 24 Aug 2026 08:56:31 -0700 (PDT) Date: Mon, 24 Aug 2026 15:55:54 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.766.g2966f0265a-goog Message-ID: <20260824155554.1046334-1-dbalint@google.com> Subject: [PATCH] platform/chrome: cros_ec: add API for power monitoring From: Daniel Balint To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev, jakiela@google.com, hmazur@google.com, Benson Leung , Daniel Balint Content-Type: text/plain; charset="UTF-8" Add new EC host command and MKBP event to allow cros_ec_pwrmon iio devices to query the EC for power monitoring data. The actual cros_ec_pwrmon driver using this API is currently downstream and will be upstreamed at a later date. This is a sync between the EC header and the kernel. Signed-off-by: Daniel Balint --- .../linux/platform_data/cros_ec_commands.h | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/include/linux/platform_data/cros_ec_commands.h b/include/linux/platform_data/cros_ec_commands.h index 749d985e9da2..a7bd69d83522 100644 --- a/include/linux/platform_data/cros_ec_commands.h +++ b/include/linux/platform_data/cros_ec_commands.h @@ -1344,6 +1344,26 @@ enum ec_feature_code { * The EC supports UCSI PPM. */ EC_FEATURE_UCSI_PPM = 54, + /* + * The EC supports Strauss keyboard. + */ + EC_FEATURE_STRAUSS = 55, + /* + * The EC supports PoE. + */ + EC_FEATURE_POE = 56, + /* + * The EC supports a hybrid boost charger + */ + EC_FEATURE_CHARGER_HYBRID_POWER_BOOST = 57, + /* + * Support signaling new console logs via host event + */ + EC_FEATURE_CONSOLE_LOG_EVENT = 58, + /* + * The EC supports power monitoring + */ + EC_FEATURE_PWRMON = 59, }; #define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32) @@ -3516,6 +3536,9 @@ enum ec_mkbp_event { /* Peripheral device charger event */ EC_MKBP_EVENT_PCHG = 12, + /* Power monitor telemetry event */ + EC_MKBP_EVENT_PWRMON = 13, + /* Number of MKBP events */ EC_MKBP_EVENT_COUNT, }; @@ -3599,6 +3622,12 @@ union __ec_align_offset1 ec_response_get_next_data_v3 { uint32_t cec_events; uint8_t cec_message[16]; + + struct __ec_todo_packed { + int64_t value; + uint32_t samples; + uint8_t channel_id; + } pwrmon_data; }; BUILD_ASSERT(sizeof(union ec_response_get_next_data_v3) == 18); @@ -6589,6 +6618,49 @@ struct ec_params_usb_pd_mux_ack { uint8_t port; /* USB-C port number */ } __ec_align1; +/** + * Power monitoring. Used to read power consumptions on rails + */ +#define EC_CMD_PWRMON 0x0608 + +enum ec_pwrmon_cmd { + EC_PWRMON_GET_CHANNEL_COUNT = 0, + EC_PWRMON_DUMP_INFO = 1, + EC_PWRMON_SET_RATE = 2, + EC_PWRMON_GET_RATE = 3, + EC_PWRMON_START = 4, + EC_PWRMON_STOP = 5, + EC_PWRMON_LATCH = 6, +}; + +struct ec_params_pwrmon { + uint8_t cmd; + union { + uint16_t set_rate; + uint8_t channel_id; + } __ec_align2; + + /* + * The following commands have no args: + * + * start, stop, latch + * + */ +} __ec_align4; + +struct pwrmon_dump_info { + uint8_t channel_id; + char channel_name[32]; +} __ec_align4; + +struct ec_response_pwrmon { + union { + uint16_t sample_rate; + uint8_t channel_count; + struct pwrmon_dump_info dump_info; + } __ec_align4; +} __ec_align4; + /*****************************************************************************/ /* * Reserve a range of host commands for board-specific, experimental, or -- 2.55.0.766.g2966f0265a-goog