From patchwork Wed Apr 3 00:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dustin L. Howett" X-Patchwork-Id: 13614857 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 F03B8522A for ; Wed, 3 Apr 2024 00:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712105253; cv=none; b=FViy0RqrzRC2xk/KW08YIS4XgSK3pxfOhhtyaBuNELR6a2J3mCG+i+8qKGHdFPXUn75VIesXtRN2eUSS1gqiQ9m7jWHygAsRMaB5wnRs8fhn0WR8dk3S7D3sBUTwqEVG3mvzP2z8/656QY5xPmAoWdhWbLt1kLe4pOU1ncbM/j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712105253; c=relaxed/simple; bh=ypOZTAcjlL+1cFLM3zOXHHIuCrcmEC4EJUNjNg4fUuU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hETliVQfEth7Os0i/QfZEZhcMcjDnxXDmr2tgkC18f3rwsU1sMIVQYpRiSSN8VUEABMvYttB4sv5s5KSFQACv1beBx8bldflHoj7KnOwN9ctNMZ8mNgulIjIHLRS1GyQfbzGJWWW/XCVYIXv5Qc131PZndxt3ddCfuCVw+cKY5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=howett.net; spf=none smtp.mailfrom=howett.net; dkim=pass (2048-bit key) header.d=howett-net.20230601.gappssmtp.com header.i=@howett-net.20230601.gappssmtp.com header.b=xgyj4hNm; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=howett.net Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=howett.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=howett-net.20230601.gappssmtp.com header.i=@howett-net.20230601.gappssmtp.com header.b="xgyj4hNm" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-789d0c90cadso373609285a.3 for ; Tue, 02 Apr 2024 17:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=howett-net.20230601.gappssmtp.com; s=20230601; t=1712105251; x=1712710051; darn=lists.linux.dev; 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=y7t4ZRkpXwioaVpNshtIgWzx1ezII8HKHitPdK2X1SE=; b=xgyj4hNmqa+0PjwFmlaeUwolLQUabrd2fxGqfPrhp2TpDLEuXNpqzNUqo3xtWfamKJ 30mpYHXnPyavgcm5LAedH+kb1yw8jG2z9sKxLjhKo9QZKfY+pq+rbNP7xmlIRmZTiSfn SSRevLJoYq4wXfNAZDtJ7tS4Duf1f72vILFtU1H6GUGk8jhDgv01zcOT3TefxTRs/Yqc taDMWVQ3rMRAArictNvbDgyDTi3w06qu/efkfrFPBIvUUswreKvWgrQi1/RaFO8lJC15 BHONF5bUU2pEarFj+99+7baj+qqJw02KkO3AAGVy7Xx8Z81vMI7fO05h1+uO00WKVxBZ bexg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712105251; x=1712710051; 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=y7t4ZRkpXwioaVpNshtIgWzx1ezII8HKHitPdK2X1SE=; b=mA5Ia+75ensGkiF2IzkjqJo6E2DS4+E9nix97R8d0YGZHUVllJNLTtI4CRlo1QAP8n m0h4YBzyHQrl9NXfTVOYI0KSZS/MlVCUbcWHmL2nCxyic5yGl5KWYNaaLFoj1AqtyZXL 0JD5l15M8m1IHC9pmPiZMkJqyhTh0oC6I7zqxRlmwOM2R6qwT6OXMrLfXVdo/G9xm5Yg SBI6a4yHrAj2tLydKt/sQgKcfz2gQjH1N5Ea5EYBeubI6xKaQPBuJ0PXt6N3L1AWdUy4 FeoxcYMlGodDJBPw38fepMHmGQpYIq7SFFhONUihFY6pmlmE08yVWsyEUCEDxNdEchiJ Y6ZQ== X-Forwarded-Encrypted: i=1; AJvYcCWTtde26X56o732BAANiVUKfwOrIwPu9oA2StpMKYPiLunnpivAeBlpD6JmtlVb4DyblAr8+QTELqk4axQMMbt7YwQNdXVQzpBtg9Wrr/6z X-Gm-Message-State: AOJu0YzlRL5fUowkX4Nebh0cvxMV4EJHccPhwA60yqXdkfqsFLZA55jO d+oyoXenPFVKGFRNbRM9CCA47+VZ9wAglwsND5Z5GQ5dfcetDrPRJdtWd/qqJA== X-Google-Smtp-Source: AGHT+IHrUuP+QVWBFq+CVkqAjuL3mAWNmHkZihWsfqU0ClwJW8476gQip5ymF1yGxM4686CCkqqS6g== X-Received: by 2002:a05:620a:8325:b0:78a:6bf6:9186 with SMTP id pa37-20020a05620a832500b0078a6bf69186mr14758801qkn.66.1712105250885; Tue, 02 Apr 2024 17:47:30 -0700 (PDT) Received: from tycho.delfino.n.howett.net (99-107-94-179.lightspeed.stlsmo.sbcglobal.net. [99.107.94.179]) by smtp.googlemail.com with ESMTPSA id h15-20020a05620a13ef00b00789effdd500sm4700834qkl.76.2024.04.02.17.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 17:47:30 -0700 (PDT) From: "Dustin L. Howett" To: Tzung-Bi Shih , Guenter Roeck , chrome-platform@lists.linux.dev Cc: "Dustin L. Howett" Subject: [PATCH v3 3/4] platform/chrome: cros_ec_lpc: add a "quirks" system Date: Tue, 2 Apr 2024 19:47:12 -0500 Message-ID: <20240403004713.130365-4-dustin@howett.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240403004713.130365-1-dustin@howett.net> References: <20231126192452.97824-1-dustin@howett.net> <20240403004713.130365-1-dustin@howett.net> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some devices ship a ChromeOS EC in a non-standard configuration. Quirks allow cros_ec_lpc to account for these non-standard configurations. It only supports one quirk right now: - CROS_EC_LPC_QUIRK_REMAP_MEMORY: use a different port I/O base for MMIO to the EC's memory region Signed-off-by: Dustin L. Howett --- drivers/platform/chrome/cros_ec_lpc.c | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c index b3aa60e0feb3..087131f159d4 100644 --- a/drivers/platform/chrome/cros_ec_lpc.c +++ b/drivers/platform/chrome/cros_ec_lpc.c @@ -34,6 +34,24 @@ /* True if ACPI device is present */ static bool cros_ec_lpc_acpi_device_found; +/* + * Indicates that lpc_driver_data.quirk_mmio_memory_base should + * be used as the base port for EC mapped memory. + */ +#define CROS_EC_LPC_QUIRK_REMAP_MEMORY BIT(0) + +/** + * struct lpc_driver_data - driver data attached to a DMI device ID to indicate + * hardware quirks. + * @quirks: a bitfield composed of quirks from CROS_EC_LPC_QUIRK_* + * @quirk_mmio_memory_base: The first I/O port addressing EC mapped memory (used + * when quirk ...REMAP_MEMORY is set.) + */ +struct lpc_driver_data { + u32 quirks; + u16 quirk_mmio_memory_base; +}; + /** * struct cros_ec_lpc - LPC device-specific data * @mmio_memory_base: The first I/O port addressing EC mapped memory. @@ -363,8 +381,10 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) acpi_status status; struct cros_ec_device *ec_dev; struct cros_ec_lpc *ec_lpc; + struct lpc_driver_data *driver_data; u8 buf[2] = {}; int irq, ret; + u32 quirks; ec_lpc = devm_kzalloc(dev, sizeof(*ec_lpc), GFP_KERNEL); if (!ec_lpc) @@ -372,6 +392,17 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) ec_lpc->mmio_memory_base = EC_LPC_ADDR_MEMMAP; + driver_data = platform_get_drvdata(pdev); + if (driver_data) { + quirks = driver_data->quirks; + + if (quirks) + dev_info(dev, "loaded with quirks %8.08x\n", quirks); + + if (quirks & CROS_EC_LPC_QUIRK_REMAP_MEMORY) + ec_lpc->mmio_memory_base = driver_data->quirk_mmio_memory_base; + } + /* * The Framework Laptop (and possibly other non-ChromeOS devices) * only exposes the eight I/O ports that are required for the Microchip EC.