From patchwork Thu Nov 9 10:05:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13450858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71702C4167B for ; Thu, 9 Nov 2023 10:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xXb0VSUQ4TqXpK/DxMrm7AkCLiIxmDdQwJxaK85Jf50=; b=KgawS46Y4ym1FU qf+ori3wza6iLd5JJ8RJZioapicx4k/z/8j7AePS2/6BgbaQEsAQFCgycuLoDMIWncJVXsn0q4Kj5 ztSy5Gi3BNbnUD9pinQzW9GAtVqIiO4TV7XOycTpiSqocPZOqs3DmIYQQ3103BSiVejH9dQWauhXy NgtiFueaKJINhk1ogvZX06QYKbZjW3ESwdtxkD5Swlw06NO6p9N6lwLCy19zFGUFTDMzAXW80CIVo FieOLokNFddDvJP5SJRS3ZfIkvjx7h4+4+Ll1snhHaYK0wru/uEUYtr/lyWfi8fKZcq4yrlP2nFZU d3c4K8K9MSq832IxCQHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r11w0-005rh0-17; Thu, 09 Nov 2023 10:06:48 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r11vx-005rem-2M for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 10:06:47 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1cc131e52f1so14436055ad.0 for ; Thu, 09 Nov 2023 02:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524405; x=1700129205; darn=lists.infradead.org; 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=DGm2vHynu/hBFToljMIoyOJ5nVIf243JSwQjqrxxy/0=; b=dBe6G9szctzL1OtjSNKJMKbE+ud/M5ClXmwaf5OPygTxbRkhbA0tJ4HOcXKhPURXsv jPUfFG0L43V5Fzs54zAtvaLWoKGG2tr2JA5rTRt25i9wTvY2Zz5J0zHhEs8btbA7qrQc +79xvGyNJWQJIS3iFTgOR3kRK7xDsz3rebBik= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524405; x=1700129205; 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=DGm2vHynu/hBFToljMIoyOJ5nVIf243JSwQjqrxxy/0=; b=Zdsmzmze3/ZuqFWUIiZR2O5UfTuDW9OTX3QnAVeg9YhycwYuo2mzP8G0vD+MVMVkaj 4igoU8y0KNYxp0/X17OpxO+aQ0CSXl4RBWSqMWPOIkejt/cbLFnFaRHwZoXCQ3Xni3DS R5PzkxRwbwSl8BEdd2Si0cCgL0Spip9SbkpcJsvUn1Pq8X/HL7SxqRoAbHWcYTCPi/v+ mecumaeSwN9pXoWMsl1UP73sUbakMGSw6UK0RrlOtnmXzH0IwpTlFlc4g381zS2URF/L jzygcOdHzehK1S9i1fyWBS5cPiqxsxyQIGRqKi/zx01VWLcoMq2HfJ048UnXyrgH4uzJ xeeQ== X-Gm-Message-State: AOJu0YyPZYv1tn+389kvpTTMHsFu43EI2o2lhs8ikrRq0BFJ13PI3xD+ WvWD8/qOFnORwSEfv1piboRKew== X-Google-Smtp-Source: AGHT+IFiKBNutMsj7ANOubArOU/tBBm0unUxGA8equMZgzL/JO0wpYcbiQ5Wq/R+556TKcVcpFKnlQ== X-Received: by 2002:a17:902:ec89:b0:1cc:436f:70c2 with SMTP id x9-20020a170902ec8900b001cc436f70c2mr7534166plg.9.1699524404876; Thu, 09 Nov 2023 02:06:44 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6f57:d4c:468c:5daf]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001c60ba709b7sm3127511plg.125.2023.11.09.02.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:06:44 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Hsin-Yi Wang , Dmitry Torokhov , andriy.shevchenko@linux.intel.com, Jiri Kosina , linus.walleij@linaro.org, broonie@kernel.org, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, petr.tesarik.ext@huawei.com, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold Subject: [RFC PATCH v2 1/7] of: base: Add of_device_is_fail Date: Thu, 9 Nov 2023 18:05:58 +0800 Message-ID: <20231109100606.1245545-2-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231109100606.1245545-1-wenst@chromium.org> References: <20231109100606.1245545-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_020645_770181_09D9A18A X-CRM114-Status: GOOD ( 16.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In some cases we want to check that a device is not only unavailable, but specifically marked as "fail". This will be used in a following change in the hardware prober driver. Signed-off-by: Chen-Yu Tsai --- drivers/of/base.c | 20 ++++++++++++++++++++ include/linux/of.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 8d93cb6ea9cd..2726e5dce1bf 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -486,6 +486,26 @@ static bool __of_device_is_fail(const struct device_node *device) return !strcmp(status, "fail") || !strncmp(status, "fail-", 5); } +/** + * of_device_is_fail - check if a device has status "fail" or "fail-..." + * + * @device: Node to check status for + * + * Return: True if the status property is set to "fail" or "fail-..." (for any + * error code suffix), false otherwise + */ +bool of_device_is_fail(const struct device_node *device) +{ + unsigned long flags; + bool res; + + raw_spin_lock_irqsave(&devtree_lock, flags); + res = __of_device_is_fail(device); + raw_spin_unlock_irqrestore(&devtree_lock, flags); + return res; +} +EXPORT_SYMBOL(of_device_is_fail); + /** * of_device_is_big_endian - check if a device has BE registers * diff --git a/include/linux/of.h b/include/linux/of.h index 6a9ddf20e79a..463fbf0072bd 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -350,6 +350,7 @@ extern int of_device_is_compatible(const struct device_node *device, extern int of_device_compatible_match(const struct device_node *device, const char *const *compat); extern bool of_device_is_available(const struct device_node *device); +extern bool of_device_is_fail(const struct device_node *device); extern bool of_device_is_big_endian(const struct device_node *device); extern const void *of_get_property(const struct device_node *node, const char *name, @@ -584,6 +585,11 @@ static inline bool of_device_is_available(const struct device_node *device) return false; } +static inline bool of_device_is_fail(const struct device_node *device) +{ + return false; +} + static inline bool of_device_is_big_endian(const struct device_node *device) { return false; From patchwork Thu Nov 9 10:05:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13450859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6471C4332F for ; Thu, 9 Nov 2023 10:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rtV2h17LEMoEyIYSK7Ha3P4hZmb+TNx9ZPaOs4Jr4W4=; b=kLoB9xkE2QSHm5 h4RZtWDlE4huqHGQzr4yfXcZXc6NvpuzZUQ7yudDSqaLP3BiXywXj1iiq5dj/5m2k++f4EG+/xZ/c NxNhMrGPJCi1NTD/IQ9MMO0ecpNmrgeSZRl95wIYAtl1/UNxXNZ4rux9UPWR57m7+rtryddTbwSCk HO0mOg2DDI7zBuXEY97LaYCj27uSF7hs4c/0mssaDb3q7Vy5bN+F6BiJj4qZ+5hH3CRGhKqAqHtF9 yafa8ZsSsEvDwnbu/YYj/k70+WFDI/6fJgm3cUIY+GmloqL+0XydoeNzOdC16dbcFN/qMEXZ/vgJk 6RYd9KZcKW/lzLs5+hKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r11w6-005rlK-0T; Thu, 09 Nov 2023 10:06:54 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r11w2-005riK-2t for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 10:06:52 +0000 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5b8f68ba4e5so538956a12.1 for ; Thu, 09 Nov 2023 02:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524410; x=1700129210; darn=lists.infradead.org; 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=t5ye6xQE9knRoa1If0NJpRXCWT7E3YY80pCdkZR9RUU=; b=Pl58ZkPb68emJ4FT055r1Xanj5QdqAonHiPkJhFixqCjKPHC6Er06Hbiuk2Wfmlrcj B2e4pUKygwGfphS9PFNszbSec6AUTtK7ZEj0QLtMjQTwvgOmAwdeKsB7NCPXSUWXWQKq Q1h0NzwKtrswb4kW7sb9lDKW+FXtSn2E0fOXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524410; x=1700129210; 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=t5ye6xQE9knRoa1If0NJpRXCWT7E3YY80pCdkZR9RUU=; b=YVxLVxlwcaAT+N2NYbnjJkMcS+K6oSagiALeM+9qr0v1oFb3uW/JWqDZkkETLCYlzZ YXiEbqrJdTcDhJsn6etl78x2nuIGthFjruSwtQG+4r3VqnZLz1dcTvtbqvin0zDcrvlm VlIur2DCQuXohUaVckL1WrKA3cZ/+pn1yI/8akcpsvaBBVF7Jbnvh+qeLM9OQTpobCZh t/rsuDDl0JWFHBDkV/lV6fbZF0IE6ji7XVah1SBYXF7HYI4yQIxzQfX99MfqdI+s2ZFa GhgfcfrA4IssjNdTJiTunVPO3JOB3wG5Y2XGAXOqVs1yaqlwswGWkWhbeeIPIn9Xxubt LV8Q== X-Gm-Message-State: AOJu0YzlZW1Q0LAiWHbccA0d+KpahuIUiBP/sX/BOxlPPDONtmstoVv3 E0iF05cmnfdB3YD/NdWNNBRMrg== X-Google-Smtp-Source: AGHT+IHfRhp6aSHaPlAD6Z0UbsTUInpZ/6xri+wdrZK5r1MjtzbG8S3+Ea6iHjo67SKMt6d5dpyRgA== X-Received: by 2002:a17:902:8c83:b0:1cc:2c45:757a with SMTP id t3-20020a1709028c8300b001cc2c45757amr4475248plo.10.1699524409702; Thu, 09 Nov 2023 02:06:49 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6f57:d4c:468c:5daf]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001c60ba709b7sm3127511plg.125.2023.11.09.02.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:06:49 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Hsin-Yi Wang , Dmitry Torokhov , andriy.shevchenko@linux.intel.com, Jiri Kosina , linus.walleij@linaro.org, broonie@kernel.org, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, petr.tesarik.ext@huawei.com, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold Subject: [RFC PATCH v2 2/7] of: Introduce hardware prober driver Date: Thu, 9 Nov 2023 18:05:59 +0800 Message-ID: <20231109100606.1245545-3-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231109100606.1245545-1-wenst@chromium.org> References: <20231109100606.1245545-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_020650_936745_BF14640C X-CRM114-Status: GOOD ( 36.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some devices are designed and manufactured with some components having multiple drop-in replacement options. These components are often connected to the mainboard via ribbon cables, having the same signals and pin assignments across all options. These may include the display panel and touchscreen on laptops and tablets, and the trackpad on laptops. Sometimes which component option is used in a particular device can be detected by some firmware provided identifier, other times that information is not available, and the kernel has to try to probe each device. This change attempts to make the "probe each device" case cleaner. The current approach is to have all options added and enabled in the device tree. The kernel would then bind each device and run each driver's probe function. This works, but has been broken before due to the introduction of asynchronous probing, causing multiple instances requesting "shared" resources, such as pinmuxes, GPIO pins, interrupt lines, at the same time, with only one instance succeeding. Work arounds for these include moving the pinmux to the parent I2C controller, using GPIO hogs or pinmux settings to keep the GPIO pins in some fixed configuration, and requesting the interrupt line very late. Such configurations can be seen on the MT8183 Krane Chromebook tablets, and the Qualcomm sc8280xp-based Lenovo Thinkpad 13S. Instead of this delicate dance between drivers and device tree quirks, this change introduces a simple I2C component prober. For any given class of devices on the same I2C bus, it will go through all of them, doing a simple I2C read transfer and see which one of them responds. It will then enable the device that responds. This requires some minor modifications in the existing device tree. The status for all the device nodes for the component options must be set to "failed-needs-probe-xxx". This makes it clear that some mechanism is needed to enable one of them, and also prevents the prober and device drivers running at the same time. Signed-off-by: Chen-Yu Tsai --- drivers/of/Kconfig | 13 ++++ drivers/of/Makefile | 1 + drivers/of/hw_prober.c | 154 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 drivers/of/hw_prober.c diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index da9826accb1b..269d20d51936 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -102,4 +102,17 @@ config OF_OVERLAY config OF_NUMA bool +config HW_PROBER + bool "Hardware Prober driver" + select I2C + select OF_DYNAMIC + help + Some devices will have multiple drop-in options for one component. + In many cases the different options are indistinguishable by the + kernel without actually probing each possible option. + + This driver is meant to handle the probing of such components, and + update the running device tree such that the correct variant is + made available. + endif # OF diff --git a/drivers/of/Makefile b/drivers/of/Makefile index eff624854575..ed3875cdc554 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o obj-$(CONFIG_OF_RESOLVE) += resolver.o obj-$(CONFIG_OF_OVERLAY) += overlay.o obj-$(CONFIG_OF_NUMA) += of_numa.o +obj-$(CONFIG_HW_PROBER) += hw_prober.o ifdef CONFIG_KEXEC_FILE ifdef CONFIG_OF_FLATTREE diff --git a/drivers/of/hw_prober.c b/drivers/of/hw_prober.c new file mode 100644 index 000000000000..442da6eff896 --- /dev/null +++ b/drivers/of/hw_prober.c @@ -0,0 +1,154 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * hw_prober.c - Hardware prober driver + * + * Copyright (c) 2023 Google LLC + */ + +#include +#include +#include +#include + +#define DRV_NAME "hw_prober" + +/** + * struct hw_prober_entry - Holds an entry for the hardware prober + * + * @compatible: compatible string to match against the machine + * @prober: prober function to call when machine matches + * @data: extra data for the prober function + */ +struct hw_prober_entry { + const char *compatible; + int (*prober)(struct platform_device *pdev, const void *data); + const void *data; +}; + +/* + * Some devices, such as Google Hana Chromebooks, are produced by multiple + * vendors each using their preferred components. This prober assumes such + * drop-in parts are on dedicated I2C busses, have non-conflicting addresses, + * and can be directly probed by seeing which address responds without needing + * regulators or GPIOs being enabled or toggled. + */ +static int i2c_component_prober(struct platform_device *pdev, const void *data) +{ + const char *node_name = data; + struct device_node *node, *i2c_node; + struct i2c_adapter *i2c; + int ret = 0; + + node = of_find_node_by_name(NULL, node_name); + if (!node) + return dev_err_probe(&pdev->dev, -ENODEV, "Could not find %s device node\n", + node_name); + + i2c_node = of_get_next_parent(node); + if (strcmp(i2c_node->name, "i2c")) { + of_node_put(i2c_node); + return dev_err_probe(&pdev->dev, -EINVAL, "%s device isn't on I2C bus\n", + node_name); + } + + for_each_child_of_node(i2c_node, node) { + if (!of_node_name_prefix(node, node_name)) + continue; + if (!of_device_is_fail(node)) { + /* device tree has component already enabled */ + of_node_put(node); + of_node_put(i2c_node); + return 0; + } + } + + i2c = of_get_i2c_adapter_by_node(i2c_node); + if (!i2c) { + of_node_put(i2c_node); + return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "Couldn't get I2C adapter\n"); + } + + for_each_child_of_node(i2c_node, node) { + struct property *prop; + union i2c_smbus_data data; + u32 addr; + + if (!of_node_name_prefix(node, node_name)) + continue; + if (of_property_read_u32(node, "reg", &addr)) + continue; + if (i2c_smbus_xfer(i2c, addr, 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data) < 0) + continue; + + dev_info(&pdev->dev, "Enabling %pOF\n", node); + + prop = kzalloc(sizeof(*prop), GFP_KERNEL); + if (!prop) { + ret = -ENOMEM; + of_node_put(node); + break; + } + + prop->name = "status"; + prop->length = 5; + prop->value = "okay"; + + /* Found a device that is responding */ + ret = of_update_property(node, prop); + if (ret) + kfree(prop); + + of_node_put(node); + break; + } + + i2c_put_adapter(i2c); + of_node_put(i2c_node); + + return ret; +} + +static const struct hw_prober_entry hw_prober_platforms[] = { + { .compatible = "google,hana", .prober = i2c_component_prober, .data = "touchscreen" }, + { .compatible = "google,hana", .prober = i2c_component_prober, .data = "trackpad" }, +}; + +static int hw_prober_probe(struct platform_device *pdev) +{ + for (int i = 0; i < ARRAY_SIZE(hw_prober_platforms); i++) + if (of_machine_is_compatible(hw_prober_platforms[i].compatible)) { + int ret; + + ret = hw_prober_platforms[i].prober(pdev, hw_prober_platforms[i].data); + if (ret) + return ret; + } + + return 0; +} + +static struct platform_driver hw_prober_driver = { + .probe = hw_prober_probe, + .driver = { + .name = DRV_NAME, + }, +}; + +static int __init hw_prober_driver_init(void) +{ + struct platform_device *pdev; + int ret; + + ret = platform_driver_register(&hw_prober_driver); + if (ret) + return ret; + + pdev = platform_device_register_simple(DRV_NAME, -1, NULL, 0); + if (!IS_ERR(pdev)) + return 0; + + platform_driver_unregister(&hw_prober_driver); + + return PTR_ERR(pdev); +} +device_initcall(hw_prober_driver_init); From patchwork Thu Nov 9 10:06:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13450860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC5E6C0018C for ; Thu, 9 Nov 2023 10:07:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LuiubIAoZDSirb/81X7ZemQENs5+xQLTj/K6UUJOY5M=; b=Wx3l923xGgZL5I 7xXz3yRF5Fq/ZW/Gd0cW9NeuxXXgoRd19ooP0FCmLAhcqEF+mx7I4QkaWXNRq1311bfZumzy1QX4T ZLzCMd2qwid43XUg8Inx1/2OIIeHSbIzRCudNlKVrAK3kdFG9r2l4lKlAUaA/1SUAHKRVz1WrG0FB KoSrJD2GR1HawUxh1FdTZPkab7LbVg5D7+UFyZQ1G/n85du5dSYMno1GzSI5e0v36613sFSFnvYkr yqjyyDxhyBVXzRgJfXgXNP3NTYznhiRdD5LkJG+iCDitvhHTDfnyuGQ8uNy1WI6OwRuqIkMmtBE2P oywA5g23wmTs0AQWpwcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r11w9-005rnj-0u; Thu, 09 Nov 2023 10:06:57 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r11w7-005rmC-00 for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 10:06:56 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1ccce410660so5857545ad.3 for ; Thu, 09 Nov 2023 02:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524414; x=1700129214; darn=lists.infradead.org; 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=WEwbem2dUlV4PdFvgxehEwFjO+wcgltSG0KbchvjnmI=; b=Vgp2Z2+6fe+Ia8RVoSq7rXicSYNzuAS7ThcBOC2PQtCfAiI3TuEMFLN1MhGndLNX42 PmAkk9xgnBAzMKoa+aVZcaVQKvCbJZaxCBvfAj90BkMr4dpx8UuF41JEOTSnbN2HSyWs NqJKOX0L6+/CLPNJ6O/xtvFTyQbPtKzd1w5dY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524414; x=1700129214; 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=WEwbem2dUlV4PdFvgxehEwFjO+wcgltSG0KbchvjnmI=; b=ZIfqrLs9oRfKu8KakYuO/Cc+zATsR1fz9+m9ewftO1L0cfvZ08oXK1I3TASzcR0R22 Ds2AkGGcN6f4bh004T9tRYibDZzgjYWrSXhpELvdQvVkZpLQ3QgMtkPP6IFUHFIuolvc s4f045L/tYQdiUKaSP/sdpzlGdHv4jjysua5dXGzYq3u4E80rQG+YiDnqirtE2yYfjHP oSF+7Eef+3k6I/GUwi/eMq/948KbOOKxaz5ak4bpoNvCjyYzqxiB0A74SJPR+YP49koX FWTLbBRgSdzLc1AK1I9OSoaKtGzft5cIgy1WhWiAE2NZA0k1Ds8R0+l3kfM5hgxQC+Ue TTTQ== X-Gm-Message-State: AOJu0YwluovhXOe1wohlvHrSfbgIMdb1oKt4YB8p8R71xEE+kuANMvN4 UZfyevDUo05ZLLAscBiDwzQ9Aw== X-Google-Smtp-Source: AGHT+IEqvxAt34/tbw9mX55Y4YBlm7iDQwp+MvYnRdV6qPSukdlOlKZvyMezlSiJe3j/GHyYqBRycw== X-Received: by 2002:a17:902:8603:b0:1c9:e229:f5e2 with SMTP id f3-20020a170902860300b001c9e229f5e2mr4402418plo.34.1699524414545; Thu, 09 Nov 2023 02:06:54 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6f57:d4c:468c:5daf]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001c60ba709b7sm3127511plg.125.2023.11.09.02.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:06:54 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Hsin-Yi Wang , Dmitry Torokhov , andriy.shevchenko@linux.intel.com, Jiri Kosina , linus.walleij@linaro.org, broonie@kernel.org, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, petr.tesarik.ext@huawei.com, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold Subject: [RFC PATCH v2 3/7] arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads as fail Date: Thu, 9 Nov 2023 18:06:00 +0800 Message-ID: <20231109100606.1245545-4-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231109100606.1245545-1-wenst@chromium.org> References: <20231109100606.1245545-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_020655_037573_BFA91220 X-CRM114-Status: GOOD ( 12.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of having them all available, mark them all as "fail-needs-probe-*" and have the implementation try to probe which one is present. Signed-off-by: Chen-Yu Tsai --- arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi index bdcd35cecad9..052109b0fa3b 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi @@ -15,6 +15,7 @@ touchscreen2: touchscreen@34 { reg = <0x34>; interrupt-parent = <&pio>; interrupts = <88 IRQ_TYPE_LEVEL_LOW>; + status = "fail-needs-probe-touchscreen"; }; /* @@ -28,6 +29,7 @@ touchscreen3: touchscreen@20 { hid-descr-addr = <0x0020>; interrupt-parent = <&pio>; interrupts = <88 IRQ_TYPE_LEVEL_LOW>; + status = "fail-needs-probe-touchscreen"; }; }; @@ -44,6 +46,7 @@ trackpad2: trackpad@2c { reg = <0x2c>; hid-descr-addr = <0x0020>; wakeup-source; + status = "fail-needs-probe-trackpad"; }; }; @@ -68,3 +71,11 @@ pins_wp { }; }; }; + +&touchscreen { + status = "fail-needs-probe-touchscreen"; +}; + +&trackpad { + status = "fail-needs-probe-trackpad"; +}; From patchwork Thu Nov 9 10:06:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13450861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D60B4C4332F for ; Thu, 9 Nov 2023 10:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Sp+d7tCGZqzseX7Nl8+Sx9gcwlzCRhoNKIpEkLT4uh0=; b=CFG9fBK93Ebysc TNLa2Z+zYWUanL/PW53J5KTTLpprstiKrht/l58IGSfmmpdZCLmpGrjXlSA8qeaHLlu9X/lPTC/yq dkmn7W15ADK04eEhQSLFe9lVNzFTzlKAwnksGaG85xINgBilXyO7jWlMEMyZc+NFxdxB9yzNS4AYK k9Ui2Zv9J6/gSPas4Xv4xffYFvh9OD1AUdLBRrF3dopzZ7kp/52PobJMgVPwW56rboumqNEJw4vHm hXPbNURzOKMANP0bqwRKldc3CADbfxtmGdKiQGG3fjUV5gib84xq/jTuiuGVEJBApUglEtrjVghvj nheJxKqFgr/oei/IVp2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r11wI-005rws-2X; Thu, 09 Nov 2023 10:07:06 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r11wF-005rq0-1L for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 10:07:04 +0000 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5bdc185c449so545194a12.0 for ; Thu, 09 Nov 2023 02:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524419; x=1700129219; darn=lists.infradead.org; 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=SXvBziOOzPoe9p06qPekw9ojRyDCzXj55skHWBeOemE=; b=d/b7PkYAX4gUyIgzqMc70WPGN5ry62AD+8kAuHWZGTvaZ7qSE0O0wb4Kc2MnfHvZkS 4omcy/cG2bHZZLZ4ivHm2QYA1tMGEQ0CDw0d25V0PnuukJukKzrDr+IAzcRyS/1+n70+ 8fqcNaC7PK6OUjEGuzfUI48jbp1P1MydhX1p8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524419; x=1700129219; 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=SXvBziOOzPoe9p06qPekw9ojRyDCzXj55skHWBeOemE=; b=BiNKTagzLGA1+vhDzhzPvPYcAcLWDNuJBaqsV+4XiKVJpRBVkZALR1qYOUABcdV7M1 3oo987KpC7l9Hd8ElYTb84dem/Rw9bJMHV5F7vlwyqcV9PJkogoLDsWHSJSvX7yvPiqP IMe/jZKK22I7824TqHsQ7qUNJove79gP9iSRaqWv8tccxKNxylImqr6x4/ygF+8RTz4J s5xt4ESo3p9fg9dQoRxRvwre2mfHbxoXLfNBOyqQXtjcBbye3dLltDUrJMCKhFkNKDrd 8B/VB+QInhL1j1aXpiwxPKS9vV+TJFVzCC3WCFPQhBYyzvEDMtaBWUxGIH4kxKsQ28gV w2mQ== X-Gm-Message-State: AOJu0YxTRFlEgeCPa4Ty5Mk9ZDCpmj/T9TjDPGCDkeZe8JmMKbPjg4Ya 5c9FrYokeL+/dY8ciKrJummx3A== X-Google-Smtp-Source: AGHT+IGjXFbBjSHLl5U/ebTbDrumNW0v2EVWcvyySgzvtZFdToUF1oRe0pnconHbHlzrFnCRFotkOA== X-Received: by 2002:a17:903:234e:b0:1cc:50f6:7fcc with SMTP id c14-20020a170903234e00b001cc50f67fccmr5370038plh.55.1699524419209; Thu, 09 Nov 2023 02:06:59 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6f57:d4c:468c:5daf]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001c60ba709b7sm3127511plg.125.2023.11.09.02.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:06:58 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Hsin-Yi Wang , Dmitry Torokhov , andriy.shevchenko@linux.intel.com, Jiri Kosina , linus.walleij@linaro.org, broonie@kernel.org, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, petr.tesarik.ext@huawei.com, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold Subject: [RFC PATCH v2 4/7] arm64: dts: mediatek: mt8173-elm-hana: Add G2touch G7500 touchscreen Date: Thu, 9 Nov 2023 18:06:01 +0800 Message-ID: <20231109100606.1245545-5-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231109100606.1245545-1-wenst@chromium.org> References: <20231109100606.1245545-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_020703_483589_58EDC0BC X-CRM114-Status: GOOD ( 11.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This introduces yet another second-source touchscreen found on Hana. This is a G2touch G7500 touchscreen, which is compatible with HID over I2C. Add a device node for it. In keeping with the new scheme for second source components, mark it as "failed-needs-probe-touchscreen". Signed-off-by: Chen-Yu Tsai --- arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi index 052109b0fa3b..d3f1277ac9b2 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi @@ -31,6 +31,15 @@ touchscreen3: touchscreen@20 { interrupts = <88 IRQ_TYPE_LEVEL_LOW>; status = "fail-needs-probe-touchscreen"; }; + + touchscreen4: touchscreen@40 { + compatible = "hid-over-i2c"; + reg = <0x40>; + hid-descr-addr = <0x0001>; + interrupt-parent = <&pio>; + interrupts = <88 IRQ_TYPE_LEVEL_LOW>; + status = "fail-needs-probe-touchscreen"; + }; }; &i2c4 { From patchwork Thu Nov 9 10:06:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13450874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94E51C4167B for ; Thu, 9 Nov 2023 10:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kLIo3QfIB+GKfsxc+Huh+aMT2IiJET/SGGBkovjms5w=; b=xzBtNAERdkvMBR Yq4lYXmuIlBYzGAIwXWmZB76miGLldmJ9tuUZVY6dmv6lPzhte85KtN7txzVKj7k9Dn7+cejblhyJ r8ZhSfyU/xu+CUPOTi1B4bCepvy03afpiiI//tKTCEJxKYj9MknDIGeelEJqkmxawpMohahjAY7Xr Nx94VvF7GfyLEnEGob51SSfxNOgfvBoPGnbLPFkLHI7ebrOspwYOTn/9RdhMZLo7Wx4hUz5w7npLN 0lf5tjkTHYybRitnfMWsdteIBbtrJPoeIQvZkMRmN/SuWprht4K/Bd0kMqdYb75arv5ZdNLOcBw+k eNSZBiEr4btHzXRm6dTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r11wM-005rzN-0H; Thu, 09 Nov 2023 10:07:10 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r11wI-005ruf-09 for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 10:07:07 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1cc68c1fac2so6123745ad.0 for ; Thu, 09 Nov 2023 02:07:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524424; x=1700129224; darn=lists.infradead.org; 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=Rs4qbwNofKphTE2zreJeFqCc6xRNAsKGF5LoBHdl0a8=; b=c2QpAPKtE7vc8SsV6a3d1Ki+Fe94lr5ycdP7B7xpVVIpy6Xs0aKd4nOy/12hYLvERS E8ijzsyLYtkTgEluZbQeRv9w7dTiCu+d8tYFzvm57Wbg/FGzMP0G9PIG0aDTH+J8zHO4 1aGeGSs8myTKLMcyGoUEWsKQO98n4IBQE0dEk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524424; x=1700129224; 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=Rs4qbwNofKphTE2zreJeFqCc6xRNAsKGF5LoBHdl0a8=; b=qVpWfJAmKGwE8qXkmQ9OiveYaunvW/PQL6Ghd+/sn+Dq2GhLUpcOl8GxqyL4P2xW7k ta/BFTFK79PmFfzTMhREvseN9s8/L9FZlTlRisZw3eJvZXRpy0ns0sJJFgktg5yO4vp4 BPW36Ynv/g8e5Dpsel/lM1UwjClE/ajM0BF60niIuo10h0X0X7IXjV0tLSxrxllZdap5 nq9wbHBXpI2m8qmzwrmLUaZ50bmXcFcBz7Qmf7oQhO59JPisUg1faDfLol8l05EgsxEv Cb3w2O5FX+pGHPTeWL9MPztGH4UwUWauXLZwvjDw90tn2yVlssaD3ljzQV1MTbqd88AQ Gmgg== X-Gm-Message-State: AOJu0YwTfErpqMmhohWDrVTcYqVWv8Q0RzpzN5LV3xbt4Q0iOT464DRD lMWccEkFi7SfzcRr6qKTekausA== X-Google-Smtp-Source: AGHT+IHWUtsr4bhvzCEP1VHdQwxeHKMo7QV044imQ44mdSODoeojv4KtXVlrqKklo16HOdu2p0mAvw== X-Received: by 2002:a17:902:f807:b0:1c9:b2c1:139c with SMTP id ix7-20020a170902f80700b001c9b2c1139cmr4180478plb.62.1699524423943; Thu, 09 Nov 2023 02:07:03 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6f57:d4c:468c:5daf]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001c60ba709b7sm3127511plg.125.2023.11.09.02.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:07:03 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Hsin-Yi Wang , Dmitry Torokhov , andriy.shevchenko@linux.intel.com, Jiri Kosina , linus.walleij@linaro.org, broonie@kernel.org, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, petr.tesarik.ext@huawei.com, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold Subject: [RFC PATCH v2 5/7] of: hw_prober: Support Chromebook SKU ID based component selection Date: Thu, 9 Nov 2023 18:06:02 +0800 Message-ID: <20231109100606.1245545-6-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231109100606.1245545-1-wenst@chromium.org> References: <20231109100606.1245545-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_020706_086683_E393C5A5 X-CRM114-Status: GOOD ( 26.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In cases where the same Chromebook model is manufactured with different components (MIPI DSI panels, MIPI CSI camera sensors, or trackpad / touchscreens with conflicting addresses), a different SKU ID is allocated to each specific combination. This SKU ID is exported by the bootloader into the device tree, and can be used to "discover" which combination is present on the current machine. This change adds a hardware prober that will match the SKU ID against a provided table, and enable the component for the matched entry based on the given compatible string. In the MIPI DSI panel and MIPI CSI camera sensor cases which have OF graphs, it will also update the remote endpoint to point to the enabled component. This assumes a single endpoint only. This will provide a path to reducing the number of Chromebook device trees. Signed-off-by: Chen-Yu Tsai --- drivers/of/hw_prober.c | 160 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/drivers/of/hw_prober.c b/drivers/of/hw_prober.c index 442da6eff896..4345e5aed6d8 100644 --- a/drivers/of/hw_prober.c +++ b/drivers/of/hw_prober.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #define DRV_NAME "hw_prober" @@ -108,9 +109,168 @@ static int i2c_component_prober(struct platform_device *pdev, const void *data) return ret; } +static int cros_get_coreboot_sku_id(struct device *dev, u32 *sku_id) +{ + struct device_node *node = NULL; + int ret; + + node = of_find_node_by_path("/firmware/coreboot"); + if (!node) + return dev_err_probe(dev, -EINVAL, "Cannot find coreboot firmware node\n"); + + ret = of_property_read_u32(node, "sku-id", sku_id); + if (ret) + dev_err_probe(dev, ret, "Cannot get SKU ID\n"); + + of_node_put(node); + return ret; +} + +struct cros_sku_option { + u32 sku_id_val; + u32 sku_id_mask; + const char *compatible; +}; + +struct cros_sku_component_data { + const struct cros_sku_option *options; + int num_options; +}; + +/* + * cros_sku_component_selector - Selectively enable a component based on SKU ID + * + * Based on the list of component options and SKU ID read back from the device + * tree, enable the matching component. Also update the OF graph if it exists, + * so that the enabled component's remote endpoint correctly points to it. This + * assumes a single local endpoint, which should be the case for panels and + * camera sensors. + */ +static int cros_sku_component_selector(struct platform_device *pdev, const void *data) +{ + const struct cros_sku_component_data *pdata = data; + const char *compatible; + struct device_node *node = NULL, *endpoint = NULL, *remote = NULL; + struct property *status_prop = NULL, *endpoint_prop = NULL; + struct of_changeset *ocs = NULL; + __be32 *val = NULL; + int ret, i; + u32 sku_id; + + if (!data) + return dev_err_probe(&pdev->dev, -EINVAL, "No data given\n"); + + ret = cros_get_coreboot_sku_id(&pdev->dev, &sku_id); + if (ret) + return ret; + + for (i = 0; i < pdata->num_options; i++) + if ((sku_id & pdata->options[i].sku_id_mask) == pdata->options[i].sku_id_val) { + compatible = pdata->options->compatible; + break; + } + + if (i == pdata->num_options) + return dev_err_probe(&pdev->dev, -EINVAL, "Unknown SKU ID: 0x%x\n", sku_id); + + node = of_find_compatible_node(NULL, NULL, compatible); + if (!node) + return dev_err_probe(&pdev->dev, -ENODEV, "Cannot find matching device node\n"); + + /* device node not marked as fail; don't mess with the device tree */ + if (!of_device_is_fail(node)) + goto err_free; + + dev_info(&pdev->dev, "Enabling %pOF for SKU 0x%x\n", node, sku_id); + + ret = -ENOMEM; + ocs = kzalloc(sizeof(*ocs), GFP_KERNEL); + if (!ocs) + goto err_free; + + status_prop = kzalloc(sizeof(*status_prop), GFP_KERNEL); + if (!status_prop) + goto err_free; + + status_prop->name = "status"; + status_prop->length = 5; + status_prop->value = "okay"; + + /* Create changeset to apply DT changes atomically */ + of_changeset_init(ocs); + + if (of_graph_is_present(node)) { + ret = -EINVAL; + + /* This currently assumes a single port on the component. */ + endpoint = of_graph_get_next_endpoint(node, NULL); + if (!endpoint) { + dev_err(&pdev->dev, "No endpoint found for %pOF\n", node); + goto err_destroy_ocs; + } + + remote = of_graph_get_remote_endpoint(endpoint); + if (!remote) { + dev_err(&pdev->dev, "No remote endpoint node found for %pOF\n", endpoint); + goto err_destroy_ocs; + } + + endpoint_prop = kzalloc(sizeof(*endpoint_prop), GFP_KERNEL); + if (!endpoint_prop) + goto err_destroy_ocs; + + val = kzalloc(sizeof(*val), GFP_KERNEL); + if (!val) + goto err_destroy_ocs; + + *val = cpu_to_be32(endpoint->phandle); + endpoint_prop->name = "remote-endpoint"; + endpoint_prop->length = sizeof(*val); + endpoint_prop->value = val; + + ret = of_changeset_update_property(ocs, node, endpoint_prop); + if (ret) + goto err_destroy_ocs; + } + + ret = of_changeset_update_property(ocs, node, status_prop); + if (ret) + goto err_destroy_ocs; + ret = of_changeset_apply(ocs); + if (ret) + goto err_destroy_ocs; + + of_node_put(node); + + return 0; + +err_destroy_ocs: + of_node_put(remote); + of_node_put(endpoint); + kfree(val); + kfree(endpoint_prop); + of_changeset_destroy(ocs); +err_free: + kfree(ocs); + kfree(status_prop); + of_node_put(node); + return ret; +} + +static const struct cros_sku_option cros_krane_panel_options[] = { + { .sku_id_val = 0x00, .sku_id_mask = 0xf0, .compatible = "auo,kd101n80-45na" }, + { .sku_id_val = 0xb0, .sku_id_mask = 0xf0, .compatible = "boe,tv101wum-nl6" }, +}; + +static const struct cros_sku_component_data cros_krane_panel_data = { + .options = cros_krane_panel_options, + .num_options = ARRAY_SIZE(cros_krane_panel_options), +}; + static const struct hw_prober_entry hw_prober_platforms[] = { { .compatible = "google,hana", .prober = i2c_component_prober, .data = "touchscreen" }, { .compatible = "google,hana", .prober = i2c_component_prober, .data = "trackpad" }, + { .compatible = "google,krane", .prober = cros_sku_component_selector, .data = &cros_krane_panel_data }, }; static int hw_prober_probe(struct platform_device *pdev) From patchwork Thu Nov 9 10:06:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13450873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FF02C4332F for ; Thu, 9 Nov 2023 10:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0NyYHNVZhyUEA3r2+JZF9X7GI0YBVZLQy0hzteCr5sk=; b=t7ILOsjZAjN9PB m3fdcfDgeqWPrLqkvRS6WEBPkVU2PBly84y9OoqUVm4SFxsYdxg2OpY1yhDUoIEaT5DzGgcbbTZEO 1tqxsNgduv63pr0+gPJsoT1wicJpcWz6xorP16Hul4diqhfhQlreKatvfw2WZzNK6i2zVlZoShaRF 0GeIGOsWiQ5DOVQez4gkiWM/yFMr+1EMz1cpP9SykeehRSOdMD4jLUHy/vzkbtVgWi206ysBtw4WV oj9X7S9B2Ng5XAntKbUyENlwF3nTlGC9U5db54oFceFK/m3y6p0JAY8MKjNJb1je7LzVnUvr+iLFQ Uue+ptVOzs+whxXIrVlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r11wQ-005s3N-0L; Thu, 09 Nov 2023 10:07:14 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r11wN-005ryT-27 for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 10:07:13 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1cc1ee2d8dfso6248355ad.3 for ; Thu, 09 Nov 2023 02:07:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524428; x=1700129228; darn=lists.infradead.org; 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=0ireTpCfN0lAkDpS22SoHjbEWTJUzLlFEUnZESQj8kY=; b=DC5UOEl0AQO/oUE/Yr6XKlwAqcr1mZlW118YWGq4vVCI31ammryw2QVmBG1yLw8Nz/ pZ9byHrunUtHj5pMKaJOyn62WFC84NNN164ISAwiLxRELA0+s3KCi2EINL0PCYtaeTSd LVOGIYA5s7EXe+veW4dcS+RxZaQH0vse1Z7LQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524428; x=1700129228; 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=0ireTpCfN0lAkDpS22SoHjbEWTJUzLlFEUnZESQj8kY=; b=qIQyCJYDM/QdPKprdgmOuQ8WajK82vsiZ5O0hFIaqRDe5Nyw3bWXfEOZouuOwdyjFv jBUyhtrvRXNas4nWmi529JfJBLm/Bz6in0fU3nEc6fYkQdhNweS4G2b0OrpLLePBrJBr NAldMMCNG5mzx5alSw4AgwJoCsL3lQYNs7Em423YNt3rgMNV7/UqT1wwfgr6cMAyFKxm VaAQOX3dX1gAfNmuNqWQUzUNacIDbOs+Nl2IXrDsBG/S7hCyM2zghiWb92BsSGkJFfEk 8JPHjJr7fzej7CqwTdqcwBQU0psB39SXtCrcz2+Zcf0jT+RkPqGxikpQHwboP6t7WAAs tEQg== X-Gm-Message-State: AOJu0YwISoMoXDViVPMSx8CQJRce+EiGuwRgiVfG+IhsYNscG2KvEOOn cDnuFi8b7F6k1h2/Q3KOv5nDDg== X-Google-Smtp-Source: AGHT+IFYLvEMMUZ9GrbH908WNtQJvicj83HyjofOmfRWFZrCflNz7TaOuy+rHHNosFSsiJ8aNjo+JQ== X-Received: by 2002:a17:902:ecc1:b0:1cc:2ed0:5ab1 with SMTP id a1-20020a170902ecc100b001cc2ed05ab1mr5039394plh.17.1699524428617; Thu, 09 Nov 2023 02:07:08 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6f57:d4c:468c:5daf]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001c60ba709b7sm3127511plg.125.2023.11.09.02.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:07:08 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Hsin-Yi Wang , Dmitry Torokhov , andriy.shevchenko@linux.intel.com, Jiri Kosina , linus.walleij@linaro.org, broonie@kernel.org, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, petr.tesarik.ext@huawei.com, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold Subject: [RFC PATCH v2 6/7] dt-bindings: arm: mediatek: Remove SKU specific compatibles for Google Krane Date: Thu, 9 Nov 2023 18:06:03 +0800 Message-ID: <20231109100606.1245545-7-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231109100606.1245545-1-wenst@chromium.org> References: <20231109100606.1245545-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_020711_720712_F6589CE5 X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In cases where the same Chromebook model is manufactured with different components (MIPI DSI panels, MIPI CSI camera sensors, or trackpad / touchscreens with conflicting addresses), a different SKU ID is allocated to each specific combination. This SKU ID is exported by the bootloader into the device tree, and can be used to "discover" which combination is present on the current machine. Thus we no longer have to specify separate compatible strings for each of them. Remove the SKU specific compatible strings for Google Krane. Signed-off-by: Chen-Yu Tsai --- Documentation/devicetree/bindings/arm/mediatek.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/mediatek.yaml b/Documentation/devicetree/bindings/arm/mediatek.yaml index a4541855a838..ef3dfb286814 100644 --- a/Documentation/devicetree/bindings/arm/mediatek.yaml +++ b/Documentation/devicetree/bindings/arm/mediatek.yaml @@ -186,9 +186,6 @@ properties: - const: mediatek,mt8183 - description: Google Krane (Lenovo IdeaPad Duet, 10e,...) items: - - enum: - - google,krane-sku0 - - google,krane-sku176 - const: google,krane - const: mediatek,mt8183 - description: Google Willow (Acer Chromebook 311 C722/C722T) From patchwork Thu Nov 9 10:06:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13450875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE78DC4332F for ; Thu, 9 Nov 2023 10:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MQrHUJwZT8+JZ3ir3qGV8aXGIgs0DcC7m2/9ANzDIi0=; b=ghjW4YGtXQB5Vi YQykqngdyWqP1QGk4T7JsooVt7WfMwd74wY11ZG9ux4Q+ogEPYWxvl+jhcdQ3oGFJVIzTtK5qyvO0 7J7uzxNiD45285RphOUW0oTlur4FAtYntJeYOOzrAz2Y5unv33PZf1ekK/tPsULMYiVPGKAPQwRDM pk5Kn/a+Rk2uRK/UdCcCFdLYmfbKO5utJSGgFwoaIsF4tnXohiK6bRF5ctOveLQCDSkLVNp7ROC40 PUqna8b0O06YbNkKAENA5g1+vBZIsBDY56oNeFMiZ3m359kOTJIrOrgTRBIjo5CyaXEKswKztFBnM VZyj4Z85Q5ihTyq2s87w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r11wV-005s87-39; Thu, 09 Nov 2023 10:07:19 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r11wS-005s3B-1U for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 10:07:18 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b5e6301a19so735409b3a.0 for ; Thu, 09 Nov 2023 02:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524433; x=1700129233; darn=lists.infradead.org; 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=onLNc+Oko6/d4dZDi8m4Ahc5zglhx4oC8hmNsm3uUAA=; b=e+QAy50WsgXkD4oFGUbdaoynFK/FUsAUPgRUGAyudJ31+KmjXY92AjOIGRWWyWKmEq zI0eCHFua8ttpYMO/GRVVabCTUiVduGUrn2jxDs1LZehcTpLB0j7R/zjKy2OtlwTQunO c/oVxPkMJVKuxRohm7dX/QwA3VZAEg5+JbtXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524433; x=1700129233; 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=onLNc+Oko6/d4dZDi8m4Ahc5zglhx4oC8hmNsm3uUAA=; b=lDsNlr6hNkIlWyTSnQVzn6jJk+0kRma8ax6lVqIJrwWt02tLsWYdP0lxXGj2DA8Fdv gWoOa/8vNLqjcVjZ37BcZsY4dh/Jpnkz1PYs+SG0UR9R3IEGGohxMWpsws+eaGFa6i61 4bHXZm5GRfDw1UA2QWvXtDjnQN3s9ZBo0bljs8kfvCcXID/o6677PkSWxsGcOGYyF7LP ZDVhGyfChBk64ac3alA9o1EjHGRggB+DeKY1b63Ysa43rVeaJ2kGfZZE9p/sPeja17ox fiA5wQcnYtgtVvR/BakOzPg2p3LzSWeyO8TaBL44C3cTYXIHwhRdCAHOxXu1HLAfc+Md +/VA== X-Gm-Message-State: AOJu0YynzW7qzTF+vYbfNR4umaf715X0htnK+L4cOSZonZ/th/5Olnsc ewFe5sBukn8EF1cjtwrvA6zDPQ== X-Google-Smtp-Source: AGHT+IE47jHpK3aDbKhKoDgiHCyXY2l2uWAuEaUiNlv/nfVr6trsVMV2KYbXDfC5qwkSNTHKG8ky5g== X-Received: by 2002:a05:6a21:19a:b0:181:10ee:20d5 with SMTP id le26-20020a056a21019a00b0018110ee20d5mr6079204pzb.12.1699524433438; Thu, 09 Nov 2023 02:07:13 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:6f57:d4c:468c:5daf]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001c60ba709b7sm3127511plg.125.2023.11.09.02.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:07:12 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno Cc: Hsin-Yi Wang , Dmitry Torokhov , andriy.shevchenko@linux.intel.com, Jiri Kosina , linus.walleij@linaro.org, broonie@kernel.org, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, petr.tesarik.ext@huawei.com, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold Subject: [RFC PATCH v2 7/7] arm64: dts: mediatek: mt8183-kukui: Merge Krane device trees Date: Thu, 9 Nov 2023 18:06:04 +0800 Message-ID: <20231109100606.1245545-8-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231109100606.1245545-1-wenst@chromium.org> References: <20231109100606.1245545-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_020716_498989_3CB4312D X-CRM114-Status: GOOD ( 18.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In cases where the same Chromebook model is manufactured with different components (MIPI DSI panels, MIPI CSI camera sensors, or trackpad / touchscreens with conflicting addresses), a different SKU ID is allocated to each specific combination. This SKU ID is exported by the bootloader into the device tree, and can be used to "discover" which combination is present on the current machine. Merge the separate Krane dtsi/dts files into one shared for all SKUs. A new device node is added for the alternative panel. Both it and the original panel are marked as "fail-needs-probe-panel" to let the hardware prober handle it. Also move the cros_ec node so that all node references are ordered alphabetically. Signed-off-by: Chen-Yu Tsai --- arch/arm64/boot/dts/mediatek/Makefile | 3 +- .../dts/mediatek/mt8183-kukui-krane-sku0.dts | 24 ---------- .../mediatek/mt8183-kukui-krane-sku176.dts | 24 ---------- ...ukui-krane.dtsi => mt8183-kukui-krane.dts} | 47 +++++++++++++++++-- 4 files changed, 44 insertions(+), 54 deletions(-) delete mode 100644 arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dts delete mode 100644 arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts rename arch/arm64/boot/dts/mediatek/{mt8183-kukui-krane.dtsi => mt8183-kukui-krane.dts} (86%) diff --git a/arch/arm64/boot/dts/mediatek/Makefile b/arch/arm64/boot/dts/mediatek/Makefile index 7e365e9516ab..d4d97b315b2f 100644 --- a/arch/arm64/boot/dts/mediatek/Makefile +++ b/arch/arm64/boot/dts/mediatek/Makefile @@ -40,8 +40,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-kodama-sku16.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-kodama-sku272.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-kodama-sku288.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-kodama-sku32.dtb -dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-krane-sku0.dtb -dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-krane-sku176.dtb +dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-krane.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-pumpkin.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8186-corsola-magneton-sku393216.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8186-corsola-magneton-sku393217.dtb diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dts b/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dts deleted file mode 100644 index 4ac75806fa94..000000000000 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dts +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: (GPL-2.0 OR MIT) -/* - * Copyright 2019 Google LLC - * - * Device-tree for Krane sku0. - * - * SKU is a 8-bit value (0x00 == 0): - * - Bits 7..4: Panel ID: 0x0 (AUO) - * - Bits 3..0: SKU ID: 0x0 (default) - */ - -/dts-v1/; -#include "mt8183-kukui-krane.dtsi" - -/ { - model = "MediaTek krane sku0 board"; - chassis-type = "tablet"; - compatible = "google,krane-sku0", "google,krane", "mediatek,mt8183"; -}; - -&panel { - status = "okay"; - compatible = "auo,kd101n80-45na"; -}; diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts b/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts deleted file mode 100644 index 095279e55d50..000000000000 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: (GPL-2.0 OR MIT) -/* - * Copyright 2019 Google LLC - * - * Device-tree for Krane sku176. - * - * SKU is a 8-bit value (0xb0 == 176): - * - Bits 7..4: Panel ID: 0xb (BOE) - * - Bits 3..0: SKU ID: 0x0 (default) - */ - -/dts-v1/; -#include "mt8183-kukui-krane.dtsi" - -/ { - model = "MediaTek krane sku176 board"; - chassis-type = "tablet"; - compatible = "google,krane-sku176", "google,krane", "mediatek,mt8183"; -}; - -&panel { - status = "okay"; - compatible = "boe,tv101wum-nl6"; -}; diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dtsi b/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts similarity index 86% rename from arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dtsi rename to arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts index d5f41c6c9881..75a734c0fbcc 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts @@ -1,12 +1,24 @@ // SPDX-License-Identifier: (GPL-2.0 OR MIT) /* * Copyright 2019 Google LLC + * + * Device tree for Krane Chromebook family. + * + * SKU ID is a 8-bit value (0x00 == 0): + * - Bits 7..4: Panel ID: 0x0 (AUO) + * 0xb (BOE) + * - Bits 3..0: SKU ID: 0x0 (default) */ +/dts-v1/; #include "mt8183-kukui.dtsi" #include "mt8183-kukui-audio-max98357a.dtsi" / { + model = "Google Krane Chromebook"; + chassis-type = "tablet"; + compatible = "google,krane", "mediatek,mt8183"; + ppvarn_lcd: ppvarn-lcd { compatible = "regulator-fixed"; regulator-name = "ppvarn_lcd"; @@ -45,6 +57,34 @@ &bluetooth { firmware-name = "nvm_00440302_i2s_eu.bin"; }; +&cros_ec { + keyboard-controller { + compatible = "google,cros-ec-keyb-switches"; + }; +}; + +&dsi0 { + panel2@0 { + compatible = "boe,tv101wum-nl6"; + reg = <0>; + enable-gpios = <&pio 45 0>; + pinctrl-names = "default"; + pinctrl-0 = <&panel_pins_default>; + avdd-supply = <&ppvarn_lcd>; + avee-supply = <&ppvarp_lcd>; + pp1800-supply = <&pp1800_lcd>; + backlight = <&backlight_lcd0>; + rotation = <270>; + status = "fail-needs-probe-panel"; + + port { + endpoint { + remote-endpoint = <&dsi_out>; + }; + }; + }; +}; + &i2c0 { status = "okay"; @@ -343,10 +383,9 @@ rst_pin { }; }; -&cros_ec { - keyboard-controller { - compatible = "google,cros-ec-keyb-switches"; - }; +&panel { + compatible = "auo,kd101n80-45na"; + status = "fail-needs-probe-panel"; }; &qca_wifi {