Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp322648lqh; Mon, 6 May 2024 23:11:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaChX+HtQy1IkKXwhgLB0XtqfnFekXSc7AZzK1GOU0Sd53lU4ONUZFhJ9Hm8nFB8oCZnDRvqOiZ0FTdsrxTxlaz7FfZCLG6JqfKuEVnA== X-Google-Smtp-Source: AGHT+IHXNpMpVMYNlX4zNye40W6cSFNZJXATucHfDTvQSs0aNrsGyWQWTqgZ8b2o6S2IxFCp/KAl X-Received: by 2002:a05:622a:1a95:b0:43a:bcee:1124 with SMTP id s21-20020a05622a1a9500b0043abcee1124mr13486034qtc.45.1715062282847; Mon, 06 May 2024 23:11:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715062282; cv=pass; d=google.com; s=arc-20160816; b=S2KeL+nl6ZD793PQGkufQGkULRdnY21fjUM4tdJdRCr3JdhbtqzCtAcdbU9w8WBNAN XtHV5UU77LH8OTs0u7dwUJg8P9Bg3LWLUgeVKc7gwcA+1+YiyHk5reJxS8CT8nNVczQ2 fXcDzyySb67udKxh30f/iETEK1LRHEBP9CPujygfuN8DM9rnfnv05/HK4Mz3gCfqzF2a CPNInXRn0XfcjwEZY5yse/QtkJlAHtLlDIwAZ14HqoYoqFNtnZiOnDGwwm18EuVkAU7i C9+ZcuuUJNFPaGjLzYjZUOLtuiBP7lNa7anqsJpZgU/VL2V9zuYh3qO1ZpC7s1odrkV6 /dog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZVF1ykk69lNW1h22ppMfYnYfsX1CiSrL52G6jBWwSyU=; fh=nrP7T0LmhK8MWvgKmx3yMSNmqRLfoxdpIApiXEFFDdY=; b=DjJuWwreEgBkm4Uo08FoFGrv0I366TnCTPG4u7j7OwQeUrehF6L4VupCof4xwTcbjq vnBXyjfn+MoEP7hJtbaSS8FCUjwXIHs1FkFa0Yx2uTtFURx0UQyeXohjMIHnJIqvNtnz JqPUnpqGnB2HtKOJyPChrIxE8y4RrZvJu5Ad96MFEP4D/KTFPbhTqDO7EAVO0aTcYnLF 0DoUPVqLckGsDT7zQf0K1jqtnJODzDNPRIzk9oDzuggsGP6BUai59xq1IurZ++w4fo/C d4vehCwNhlKkWxJv52Gb5JFlPBnKLBwR4hy/0GxA9A6OaNMkHPWSc7pbKc5GFnD6vJ0L 3rDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=d0S05ZBx; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-170730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170730-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 13-20020ac8570d000000b0043b024830f5si11531903qtw.341.2024.05.06.23.11.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 23:11:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=d0S05ZBx; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-170730-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170730-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 847311C21F9A for ; Tue, 7 May 2024 06:11:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62E8670CC8; Tue, 7 May 2024 06:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="d0S05ZBx" Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8810F6D1C8; Tue, 7 May 2024 06:11:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715062271; cv=none; b=XrzVa3ZBCqznoBvKo+z45fIKrD5maqUDYC8wlyHJp86yT0fQ/pMrc8x2wOAsF4S4oJXtkEUDT10GPjhvzOwgsLYKF9wFWO/XEk/65h6o+/V6Peke5W12y1e8/fFZYbI5v05ECv1p0AYsrDMp2HpCGw8lw2kTM9Ql/4I5tySoWZw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715062271; c=relaxed/simple; bh=aOz9fe41WAKNxF6hfkGSEIu6azwOFn4nkwJSjri5io4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tTkZsOcgi44QUl4nEDk+kQleKpszcYwzgWYRB0q22OZ6q6s7slu7G5KLMBa3N9j3X2mM9dAUCcMLuV3mWuBXEW/eqZ1cq71TvqxkBddvhunaXkftgNT0U1DlP7bw7HVncXXVOOiDaRiVIFLY4COrykTxSyr3Xumw+AawCmbIs0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=d0S05ZBx; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1715062265; bh=aOz9fe41WAKNxF6hfkGSEIu6azwOFn4nkwJSjri5io4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d0S05ZBxRizCGgFtKbQ7BtcO+yYMGuBiYUmrS2xORY55741JGhtObzfNA8rTfLGk+ 9J0XF+qHkeklti47dfmnUxFvdzO6At3vTtBjx3I59GGcYvwdOwbqm/OOAEN+ZIb/67 OnCT5Vi9jUFNHV1c4oT6/bYZrhuEFfXy3ClXgoc8= Date: Tue, 7 May 2024 08:11:04 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Dustin Howett Cc: "Limonciello, Mario" , Lee Jones , Benson Leung , Guenter Roeck , Tzung-Bi Shih , linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev, Sebastian Reichel , linux-pm@vger.kernel.org Subject: Re: [PATCH 0/2] platform/chrome: cros_ec_framework_laptop: new driver Message-ID: <99ae4866-a8cd-408c-8227-006f96f14dc7@t-8ch.de> References: <20240505-cros_ec-framework-v1-0-402662d6276b@weissschuh.net> <613369f9-42c5-4a59-b83f-45bd1773ffe4@t-8ch.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi Dustin, On 2024-05-06 13:29:32+0000, Dustin Howett wrote: > On Mon, May 6, 2024 at 12:43 PM Thomas Weißschuh wrote: > > On 2024-05-06 08:09:07+0000, Limonciello, Mario wrote: > > > On 5/6/2024 1:09 AM, Thomas Weißschuh wrote: > > > > On 2024-05-05 22:56:33+0000, Thomas Weißschuh wrote: > > > > > Framework Laptops are using embedded controller firmware based on the > > > > > ChromeOS EC project. > > > > > In addition to the standard upstream commands some vendor-specific > > > > > commands are implemented. > > > > > > > > > > Add a driver that implements battery charge thresholds using these > > > > > custom commands. > > > > > > > > It turns out that standard ChromesOS EC defines EC_CMD_CHARGE_CONTROL. > > > > The kernel headers however only define v1 of the protocol, which is very > > > > limited. > > > > > > > > But in the upstream firmware repo there is a v3 which is much better. > > > > > > > > The Framework laptop only implements v2 which is also fine. > > > > Given that v3 was only introduced late last year, it seems better to > > > > stick to v2 anyways for now. > > > > > > > > So please disregard Patch 2, I'll see on how to use this via a normal > > > > cros_ec driver. > > > > > > > > There are some other Framework-only features that will use Patch 1, > > > > so feedback for that would still be good. > > > > > > What other kinds of features do you have in mind? > > > > Definitely privacy switch reporting belongs in a driver like this. If it can't be done via one of the upstream CrOS EC commands, surely. > Overall, I'm not sure about making it a subjugate driver under the > cros_ec_mfd virtual "bus"... even though a lot of the features take a > dependency on cros_ec. > Doing so centralizes the work in the platform-chrome tree and may > serve as a guidepost for any future laptop OEMs that derive their > embedded controller firmware from ChromeOS's. > If the owners of this tree sign off on that, that's awesome! I'd be > concerned about making it all their responsibility. Yes, some guidance from the maintainers will be great. > I may be a bit biased, as I have been working on a driver of my own[1] > for this purpose. It currently supports battery charge limiting[3], > reporting fan speed via hwmon, the keyboard backlight[2], and has an > open pull request that exposes the status of the privacy switches. I have taken a look at that driver but wasn't fond of the fact that it is not using cros_ec mfd. Taking a reference on a completely different device looks iffy to me and in violation of the device hierarchy. FYI I have completely non-Framework-specific implementations for keyboard backlight [0], charge limiting [1] and hwmon [2]. (I didn't look at the privacy switches yet, maybe there is a generic solution) (I'm currently polishing [1] and [2], any feedback already would also be much appreciated) All of them work correctly on my Framework 13 AMD, Firmware 3.05. These standard APIs are more powerful than the Framework-only ones. Charge control can do start_threshold, stop_threshold and charge_behaviour. Hwmon can do fans and temperature sensors. Keyboard backlight just reuses the existing mainline driver. > It is destined--once I find the time to clean it up--for > drivers\platforms\x86 instead of ...\chrome. > > This may be a good place for us to combine our efforts! Surely! Personally I only have the AMD 13 device (Azalea), so I can't test anything else. And I'd like to focus on the mainline-compatible APIs (first). Feel free to contact me (privately?) if you have any suggestions. > [1] https://github.com/DHowett/framework-laptop-kmod > [2] I found that the Azalea did not report its keyboard backlight > values through the standard cros ec KBLIGHT interface like hx20/30 > did, so the driver as it stands implements a fallback that uses the > raw PWM state. I'm sure that you'd've noticed this if it was still > true... so I am always happy to drop an unnecessary workaround. :) For me the posted driver under [0] works as expected. > [3] Which I believe still requires a special host command and is not > integrated into the charge manager, at least as of Azalea/Lotus and > _definitely_ not as of hx20/30! This also works for me correctly with [1]. Do you know if there are plans by Framework to move the older devices to a newer firmware? This would also make their own maintenance work easier in the future, especially considering their commitment to software longevity[3]. > [..] Thomas [0] https://lore.kernel.org/lkml/20240505-cros_ec-kbd-led-framework-v1-1-bfcca69013d2@weissschuh.net/ [1] https://git.sr.ht/~t-8ch/linux/tree/b4/cros_ec-charge-control [2] https://git.sr.ht/~t-8ch/linux/tree/b4/cros_ec-hwmon [3] https://frame.work/de/en/blog/enabling-software-longevity