Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp451179lqp; Mon, 10 Jun 2024 08:55:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWf2aUNTLu56X6zuVocC/qmKOUGOD51lL34ZKjE8J3pRisTSAceoC8oEN1Lj5W+gdQL896/4PKmWunN2FXT9JUglKDTaieLaesnQYzL+A== X-Google-Smtp-Source: AGHT+IH3u+rei5t6GrFMsToe/DsDphiXQunoeLafMYlSfi5RzEJPsMw1Ij2eo6TvjfEmGf1eKks/ X-Received: by 2002:a25:b204:0:b0:df4:dfee:3572 with SMTP id 3f1490d57ef6-dfaf663ca80mr9369715276.38.1718034901192; Mon, 10 Jun 2024 08:55:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718034901; cv=pass; d=google.com; s=arc-20160816; b=rjs9seuLq9jnJ8/dsXk+20W4KNKAX5Lu7JgjopKF6F8GwV2xqaswOri/coAyJ5Mj4v jO+IJ8sPyvqxokADgqb+gAZ5jI9rDv1/ymdymrvG5yI/sWSge1MX5QpWUpdhoxJ4sFWX DWlWGbx35A7PIFQxv2gNEICJI0gtvz1eIzrHn+HwVaY1nxKU4I7AD5SUayxIzLmly5N4 55A69fiEuf9uTykszQcW86AM4i+Erk3/16x0b+sNNtcTuLMkFtszKNRxV3JZA12thgGq kpl+zwrBYqPSUV6qOHeYDhkCgv/r71uQjdlUoMt293kDxMF1bULDcKlsFhWHBQmpr/ez /Q8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=QaaIIRwFjPhCr7/2srmlWkXF+ArTnCZi1AHQT9Xz64c=; fh=mNAGY4UiCC2gtYBxmMCQKDpXYJDs8SkK6GbJ2jw39Lc=; b=ZUG7Cozifddyu763NHNyb27exzb1hn6LoOVr2Xex8n/XExkHiNVFO5Sk4J1cTfXCrx 7NtkFPklsA29JFcEdRAvvuzg2Wc20RISsp5VdQRmxKZycLaQjryzTHgr8k7uN8wNmQ45 XDGSIKC7I8IbE/UgEvb6FoxwRdtYqijeU2hX1or9XObtd7b05TyUCVzLlwHY0wPfjjDM 69nzyGQm6wBBlU3xYUVgSm4wQYW438ZdHJP1AJuLFF+05StrgLSfFO0tOGe/082rrX8e 60M5bNXTrgDD4V/z6rDJ5QaIKRwpFSESIulkhLBWvmOVBFQmDF2ZjjT2i3urqOxvn8rA xO+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=lEXm9ND2; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net dmarc=pass fromdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-208514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208514-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=weissschuh.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44038b178e6si109662491cf.325.2024.06.10.08.55.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 08:55:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208514-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=lEXm9ND2; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net dmarc=pass fromdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-208514-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208514-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=weissschuh.net 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 D71401C2267C for ; Mon, 10 Jun 2024 15:53:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11ED414C58C; Mon, 10 Jun 2024 15:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="lEXm9ND2" 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 B722C1448E1; Mon, 10 Jun 2024 15:52:12 +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=1718034734; cv=none; b=SHNKCeKZC1PoMrZqKOiXkui56BzoMdeqZI99OJAw5Q8hHg1DR0XtRgytFWGUZ3JaGkaOwxbJBKybuxHfnXZvk8nzFsABidRxJEJ64fV0TpFQUilwioVVf4xVe3VukSPeAv80KDorg4ZXdJ8rVR9PFDKJuYsdeyMjYhMEID6beOI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718034734; c=relaxed/simple; bh=yLPuywKxlke6NT+olphfKJbBjlPvjs/2umweIlCb7Oc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r4LdSs1DkHeYoc62U+z8YBl8OztuGIF6CYSaxhyphqrS0crWOx1cECYPR8xZZdudOywyz3SFMVgmHeDYF8Y5hmlZ3ItTLfCD4A4MO1h8+d4iB474ZHoITiBzW3KpK3BEfsFXAg5V9MaJAeczNsHZFeDQYiqMGmoLUtO//HDdXvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=lEXm9ND2; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=1718034727; bh=yLPuywKxlke6NT+olphfKJbBjlPvjs/2umweIlCb7Oc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lEXm9ND2/w0HRAMcQ5ZiCAtRBk3MWTlkT5d9EupLPFpf6hZImMDXTccLMKg4dTuut d0v7aTdKPpByQtbSKTIuhYLEGQU+f81/E8pOkE8QrjAlCbVUEZ3Y60u8wN5L85NfFO ILf/NIGC2Y4dpY8vnYC8ndntu12W1AIkLyZZqxo4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 10 Jun 2024 17:51:10 +0200 Subject: [PATCH v3 5/5] power: supply: cros_charge-control: don't probe if Framework control is present 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-Transfer-Encoding: 8bit Message-Id: <20240610-cros_ec-charge-control-v3-5-135e37252094@weissschuh.net> References: <20240610-cros_ec-charge-control-v3-0-135e37252094@weissschuh.net> In-Reply-To: <20240610-cros_ec-charge-control-v3-0-135e37252094@weissschuh.net> To: Benson Leung , Guenter Roeck , Sebastian Reichel , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Rafael J. Wysocki" , Len Brown , Robert Moore , Tzung-Bi Shih Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Mario Limonciello , Dustin Howett , Stephen Horvath , Rajas Paranjpe , linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, Matt Hartley , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718034726; l=2319; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=yLPuywKxlke6NT+olphfKJbBjlPvjs/2umweIlCb7Oc=; b=3wIbND3IYNvwmQXgsspa8RqWb8j8yyNshSXEsCKlvqFzB6+tqyIDudmsHo6iGQ9EoemomN9Mg 6E4FnVddsYAArcpQMSS0ptxqSUcOjTFzP84Yy+KHgX733nZNaEmDUsI X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Framework laptops implement a custom charge control EC command. The upstream CrOS EC command is also present and functional but can get overridden by the custom one. Until Framework make both commands compatible or remove their custom one, don't load the driver on those machines. If the user knows they are not going to use the custom command they can use a module parameter to load cros_charge-control anyways. Note that the UEFI setup configuration for battery control also uses their custom command. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/cros_charge-control.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c index 056346850c6d..3688e021b4da 100644 --- a/drivers/power/supply/cros_charge-control.c +++ b/drivers/power/supply/cros_charge-control.c @@ -6,6 +6,7 @@ */ #include #include +#include #include #include #include @@ -259,6 +260,19 @@ static int cros_chctl_remove_battery(struct power_supply *battery, struct acpi_b return 0; } +static bool probe_with_fwk_charge_control; +module_param(probe_with_fwk_charge_control, bool, 0644); +MODULE_PARM_DESC(probe_with_fwk_charge_control, + "Probe the driver in the presence of the custom Framework EC charge control"); + +static int cros_chctl_fwk_charge_control_versions(struct cros_ec_device *cros_ec) +{ + if (!dmi_match(DMI_SYS_VENDOR, "Framework")) + return 0; + + return cros_ec_cmd_versions(cros_ec, 0x3E03 /* FW_EC_CMD_CHARGE_LIMIT */); +} + static int cros_chctl_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -268,6 +282,14 @@ static int cros_chctl_probe(struct platform_device *pdev) size_t i; int ret; + ret = cros_chctl_fwk_charge_control_versions(cros_ec); + if (ret < 0) + return ret; + if (ret > 0 && !probe_with_fwk_charge_control) { + dev_info(dev, "Framework charge control detected, not probing\n"); + return -ENODEV; + } + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; -- 2.45.2