Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3110549lqo; Tue, 14 May 2024 22:58:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/sljUiucDJL83NwKgT9p5gXM8VfvdkMlQNSMnz5XTMs9irhmh3NxkBvsCXObd3/NKqRVp8APD6gJvK572ug5iNmNFob2K9r8E9BS28Q== X-Google-Smtp-Source: AGHT+IHkyt2Sg3jdi/7rqYro9adhaLcZ8lsKe+AarNrYBhRwpSNhU5YaxABtn3ZsYxC+KtMJLhLF X-Received: by 2002:a05:6214:5903:b0:6a3:5297:cf16 with SMTP id 6a1803df08f44-6a35297d04dmr34915106d6.57.1715752689709; Tue, 14 May 2024 22:58:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715752689; cv=pass; d=google.com; s=arc-20160816; b=KGnmDa4pB5H1egiiKQq5aIoec7UQx7K4J+MqoP4HXAWWu3Ruji7rdJQfJvfsnk4Lri 9EWBXAxXWURzxjILQq20JvlViZD1czkDZuGY5d/pF/4XmRawdO+mR+t53As8dEUzguCQ hfnmAJeBW1XsCVDkVjkwDMo7ob66AiVJUPjdFeOfDSsRs8FQthD+cawhXdjEYiK6krFU dPIf2wScFJigSx5GP5WifJFExs5embl4+UoA63zQ17Trt+YcrfQXg+4vJ017MkiWep/L qAK8AwFXDKOekjmi2b3rtb37/tfNpTATfn/ad59QdoQz9pEnNjDvuqizk6YuMnPBU3yC FdOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=P92v+w98Jljb+c9QhFtRBSt+CRxl2epw8ENibcEK1wM=; fh=TB40nJxdONdf4WtVAnDt8DWbDrzJeBBXgHK/mPL12mo=; b=qTB8v6/57m6ZTcOeM+VEZL/+3rgU7jRiTmH/K85lOYqXUmPG2ApplH5hSVh3sodS29 zDXWU+CY7sezv7Pf6DWMJJjC915OZAUtIalQsZuAZMMuxUlcyotY/JMea4rYS2tDrq+o 1HW+0vJC2SssqBcaUNtbmaGewnVZwztuJa0Cb00S4RmM8cB8/TIkLaMHYNZmwYExp7f9 +epChgSQN3CZetao4C02QcTKa48l2RawiXXqNoqVeKN1S6xUwBYjHxnFdELWNUMSja+B /bGaU7iM6sxi58wL7ItvLxBbsu/Z0LzYWYc3eAp0XtjzSrydAKZTM0o9BCQ1W5Tkl+pV zfgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@jubnut.com header.s=MBO0001 header.b=nV5ZNoCY; arc=pass (i=1 spf=pass spfdomain=jubnut.com dkim=pass dkdomain=jubnut.com dmarc=pass fromdomain=jubnut.com); spf=pass (google.com: domain of linux-kernel+bounces-179484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=jubnut.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f3047ecsi136882556d6.548.2024.05.14.22.58.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 22:58:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@jubnut.com header.s=MBO0001 header.b=nV5ZNoCY; arc=pass (i=1 spf=pass spfdomain=jubnut.com dkim=pass dkdomain=jubnut.com dmarc=pass fromdomain=jubnut.com); spf=pass (google.com: domain of linux-kernel+bounces-179484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=jubnut.com 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 E75601C20B16 for ; Wed, 15 May 2024 05:58:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE51D44C67; Wed, 15 May 2024 05:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jubnut.com header.i=@jubnut.com header.b="nV5ZNoCY" Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (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 392154175A for ; Wed, 15 May 2024 05:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752613; cv=none; b=MXkftjV+P+9vuJAoL2k4gh8OL+xyVYic6bT+fjB/5qyf8nbYj58GH4loQJPO3DSfNiNNjUB9h7tVDaRf1bgMsIdNHZHm9tYG4kMsc3GQxXwHNEeSaTWAPkkUUEvao4EFCtoF+gR/ww9bbkie2sQpUZVi5fxqBFQKcBVVHMxX5/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752613; c=relaxed/simple; bh=K+VP68HCvfFFdGmWMTrvq+V5aUwfknlhvQc7PiWu+Ls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SYoEFhkAf7rUhnCO2iQ6karFORw24Lh/BDf2FDOvGBjluMO65zF76POdEYINVFhDRtWZNYYd9Jgnzbjr6LVe4q8TxVFdT/PO+ESRq2yDyY4rQEMFF7sxvNYWTBpqbDtKx0k9hRNn3Cesu417w8q9sIO8uxSF24ttZb7uKbh+IdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=jubnut.com; spf=pass smtp.mailfrom=jubnut.com; dkim=pass (2048-bit key) header.d=jubnut.com header.i=@jubnut.com header.b=nV5ZNoCY; arc=none smtp.client-ip=80.241.56.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=jubnut.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jubnut.com Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4VfMtP0kd1z9sdZ; Wed, 15 May 2024 07:56:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jubnut.com; s=MBO0001; t=1715752605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P92v+w98Jljb+c9QhFtRBSt+CRxl2epw8ENibcEK1wM=; b=nV5ZNoCYd4EMV2Gmgs75jYWwJ7Ddai/pv4xPc97gPRopDvdunCy2o7w1/bCHza4xnoAhnc xSklzX8hl0PVLylhZy7zlVuD2tdPdao8chiAee8z5r8+4yg2r1j7kp9FW4mb4xsHwXg6mr mZHllbuUBalb0x5wqBhGKjMyYa8lHx7Ii5GucjKR9j9ilFqCwskwBOWHdev8bb4FVRHCMI obe+/NIFgLrCECg0eDymVKq8gp25VvXsoB+MKBdG6uu/DMeDUM5trTDMg/FG2hVgDLnUWJ Dy8w6cWc8qaVIM9Zuca201R9nW+Tuc3hgI8ZiZKDBM1JqovhUJ8Ig+NuKdSluA== From: Ben Walsh To: Benson Leung , Tzung-Bi Shih , Guenter Roeck , "Dustin L. Howett" , Kieran Levin , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Mario Limonciello , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Ben Walsh Subject: [PATCH 5/6] platform/chrome: cros_ec_lpc: Correct ACPI name for Framework Laptop Date: Wed, 15 May 2024 06:56:30 +0100 Message-ID: <20240515055631.5775-6-ben@jubnut.com> In-Reply-To: <20240515055631.5775-1-ben@jubnut.com> References: <20240515055631.5775-1-ben@jubnut.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Framework Laptops' ACPI exposes the EC as name "PNP0C09". Use this to find the device. This makes it easy to find the AML mutex via the ACPI_COMPANION device. The name "PNP0C09" is part of the ACPI standard, not Chrome-specific, so only recognise the device if the DMI data is recognised too. Signed-off-by: Ben Walsh --- drivers/platform/chrome/cros_ec_lpc.c | 38 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c index ab7779b57a13..a9200f0a1a37 100644 --- a/drivers/platform/chrome/cros_ec_lpc.c +++ b/drivers/platform/chrome/cros_ec_lpc.c @@ -29,10 +29,12 @@ #include "cros_ec_lpc_mec.h" #define DRV_NAME "cros_ec_lpcs" -#define ACPI_DRV_NAME "GOOG0004" -/* True if ACPI device is present */ -static bool cros_ec_lpc_acpi_device_found; +/* + * Index into cros_ec_lpc_acpi_device_ids of ACPI device, + * negative for ACPI device not found. + */ +static int cros_ec_lpc_acpi_device_found; /* * Indicates that lpc_driver_data.quirk_mmio_memory_base should @@ -598,7 +600,8 @@ static void cros_ec_lpc_remove(struct platform_device *pdev) } static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = { - { ACPI_DRV_NAME, 0 }, + { "PNP0C09", 0 }, /* Standard ACPI EC name. Must be first in list */ + { "GOOG0004", 0 }, { } }; MODULE_DEVICE_TABLE(acpi, cros_ec_lpc_acpi_device_ids); @@ -737,30 +740,33 @@ static struct platform_device cros_ec_lpc_device = { .name = DRV_NAME }; -static acpi_status cros_ec_lpc_parse_device(acpi_handle handle, u32 level, - void *context, void **retval) +static int cros_ec_lpc_find_acpi_dev(const struct acpi_device_id *acpi_ids) { - *(bool *)context = true; - return AE_CTRL_TERMINATE; + int i; + + for (i = 0; acpi_ids[i].id[0]; ++i) { + if (acpi_dev_present(acpi_ids[i].id, NULL, -1)) + return i; + } + + return -1; } static int __init cros_ec_lpc_init(void) { int ret; - acpi_status status; const struct dmi_system_id *dmi_match; - status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device, - &cros_ec_lpc_acpi_device_found, NULL); - if (ACPI_FAILURE(status)) - pr_warn(DRV_NAME ": Looking for %s failed\n", ACPI_DRV_NAME); + cros_ec_lpc_acpi_device_found = cros_ec_lpc_find_acpi_dev( + cros_ec_lpc_driver.driver.acpi_match_table); dmi_match = dmi_first_match(cros_ec_lpc_dmi_table); if (dmi_match) { /* Pass the DMI match's driver data down to the platform device */ cros_ec_lpc_driver_data = dmi_match->driver_data; - } else if (!cros_ec_lpc_acpi_device_found) { + } else if (cros_ec_lpc_acpi_device_found <= 0) { + /* Standard EC "PNP0C09" not supported without DMI data */ pr_err(DRV_NAME ": unsupported system.\n"); return -ENODEV; } @@ -772,7 +778,7 @@ static int __init cros_ec_lpc_init(void) return ret; } - if (!cros_ec_lpc_acpi_device_found) { + if (cros_ec_lpc_acpi_device_found < 0) { /* Register the device, and it'll get hooked up automatically */ ret = platform_device_register(&cros_ec_lpc_device); if (ret) { @@ -786,7 +792,7 @@ static int __init cros_ec_lpc_init(void) static void __exit cros_ec_lpc_exit(void) { - if (!cros_ec_lpc_acpi_device_found) + if (cros_ec_lpc_acpi_device_found < 0) platform_device_unregister(&cros_ec_lpc_device); platform_driver_unregister(&cros_ec_lpc_driver); } -- 2.45.0