Message ID | 20231109100606.1245545-1-wenst@chromium.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp332896vqs; Thu, 9 Nov 2023 02:08:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHELyBMEMfaSjSqbDv8qAct6znxfC2xADLnYa6qfJPMOH6CrfhyUfIcMLFwJiq3uF1Zy19B X-Received: by 2002:a05:6e02:20c2:b0:359:c30f:63c9 with SMTP id 2-20020a056e0220c200b00359c30f63c9mr4894861ilq.32.1699524510535; Thu, 09 Nov 2023 02:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699524510; cv=none; d=google.com; s=arc-20160816; b=ZIRxoCnLAaPzoMYyZt9jOzLhBL6zF8YCUwV8864eU9aEqO1BKYoJSMuehyhn+9Wc2x NopoT2aPvW+VUx6TiEGiAUUj0zUrp185nsofw+bG9NgNfjzX3VmAKNpRgiSKuBxo+ScN JUM8c77hq6mfHv8XCViSlE4vIctwil5Cl0P/zz0Mk8TK+krGX0/NipSFxoC+AXJ5rnGO 0JUCdtWU/t+JdLNXxWKhqopVLn2waXlavuZxTHKnvm2hT0h96Vw3FO/hFZN5YsRFu5I3 MbhbE9XiJOR0X0SAoxQZKb87u9Fx3T5Yal+Ohza8Ojeg4V59laDLMfKi6Peev9TZt/YS gI8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fJvWVs2pvEah4vcu8xn+6aEsMzIEVFQ3nL2+j2vnxy4=; fh=9RjyB+hDNs618LdaNPm846thAWpv+UOF4Pqs3eQuhzI=; b=h0hA+m+BzJ27FOc7bU6DB0rLMvodmmEqhhL1L50A4xMRg6X+DbviKD8LEP4auS5zx4 ljzZJkoTeQ4x++Sd5oTz57omxLkofAfeUfvVm78ygMtbfMQ++aEpRdysAk5YfWXBxQ+w 3s0n4Q4/NhuxcB7fd9EbHzU1BB3CJQ/xs5o2sIxG3yoyve6CJSTRHh2W1PaXT3bGOT8s JnivvieZWUkcXwQuHES6wEBUEj0rVEciSpFgnliblUHPM9hUtD8ynMaFBzdq5+Lg3+Xx O4y3nA5oUii8e7C/BOpJ70HAWKICTzQueae/miR9MYTrJfy76OTdpY4omC3QGim2Zp56 edXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=L901mAJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id q22-20020a63cc56000000b005ab776a4d4csi6245756pgi.610.2023.11.09.02.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:08:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=L901mAJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 33B1D820001E; Thu, 9 Nov 2023 02:08:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232700AbjKIKGo (ORCPT <rfc822;jaysivo@gmail.com> + 32 others); Thu, 9 Nov 2023 05:06:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232627AbjKIKGm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Nov 2023 05:06:42 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CFA2D6A for <linux-kernel@vger.kernel.org>; Thu, 9 Nov 2023 02:06:40 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5a9bf4fbd3fso587544a12.1 for <linux-kernel@vger.kernel.org>; Thu, 09 Nov 2023 02:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699524400; x=1700129200; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fJvWVs2pvEah4vcu8xn+6aEsMzIEVFQ3nL2+j2vnxy4=; b=L901mAJg+s8HDZtKm2ry/XnVBkEYxhR8+I15n3LJGxXFg8lduSjOtOtRFnM+0s5NBg cJH7d0fz1m9aa+b/qMmuV8nEdAP17pBm/5/KZSPk187szGndLrIR+1opkwnaA4WDJfxT 3v84gF/qKLEOriJYzIpfc11YuqDT65poM1P6g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524400; x=1700129200; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fJvWVs2pvEah4vcu8xn+6aEsMzIEVFQ3nL2+j2vnxy4=; b=sO8mYd//5tUgDW6QY8bU/4B8bHD+sY8xXAm+/V5qqleueFZ4XnZS1CrvLIz/mZ1//g zDFXHKSdDTcvxaUpBCA5vG47mJvD2VDjmvfjaxT4DU2hdWNmjwrRHYZjv0zaVPPChk/l /1y2OHqGpyFodglpGCQdanUSuYk3GcDGSk8ampBJe7oml9K8px2rLDXYWpL8OXGIJfmE Q2NmO702g+gceeLdmqL1C0P6gVXCZUXFR2NTfsqxZlqBNQ57IL25Fww2Of8FDmeswLpS 0W/YR4kDdJcwg3pHq1PfUbawZHS3Bt5n1r9tNtHFNw6//5cgO98E8Kbucy5/t7NqnRWw ygGQ== X-Gm-Message-State: AOJu0YyL1XrAWm+b4xnD3Cqa3+ntqJt4g7ey8Xs2UcCxNnK31959F42y ep6wiA/LsLPoXV2dplSuWkF1AA== X-Received: by 2002:a17:902:d48b:b0:1c0:cbaf:6930 with SMTP id c11-20020a170902d48b00b001c0cbaf6930mr5153488plg.54.1699524400148; Thu, 09 Nov 2023 02:06:40 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 02:06:39 -0800 (PST) From: Chen-Yu Tsai <wenst@chromium.org> To: Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Cc: Hsin-Yi Wang <hsinyi@chromium.org>, Dmitry Torokhov <dmitry.torokhov@gmail.com>, andriy.shevchenko@linux.intel.com, Jiri Kosina <jikos@kernel.org>, 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 <jeff@labundy.com>, linux-input@vger.kernel.org, Chen-Yu Tsai <wenst@chromium.org>, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson <dianders@chromium.org>, Johan Hovold <johan@kernel.org> Subject: [RFC PATCH v2 0/7] of: Introduce hardware prober driver Date: Thu, 9 Nov 2023 18:05:57 +0800 Message-ID: <20231109100606.1245545-1-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 09 Nov 2023 02:08:23 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782080605869416337 X-GMAIL-MSGID: 1782080612943898237 |
Series |
of: Introduce hardware prober driver
|
|
Message
Chen-Yu Tsai
Nov. 9, 2023, 10:05 a.m. UTC
Hi everyone, This v2 series continues Doug's "of: device: Support 2nd sources of probeable but undiscoverable devices" [1] series, but follows the scheme suggested by Rob, marking all second source component device nodes as "fail-needs-probe-XXX", and having a hardware prober driver enable the one of them. I tried to include everyone from the original Cc: list. Please let me know if you would like to be dropped from future submissions. For the I2C component (touchscreens and trackpads) case from the original series, the hardware prober driver finds the particular class of device in the device tree, gets its parent I2C adapter, and tries to initiate a simple I2C read for each device under that I2C bus. When it finds one that responds, it considers that one present, marks it as "okay", and returns, letting the driver core actually probe the device. This works fine in most cases since these components are connected via ribbon cable and always have the same resources. The driver as implemented currently doesn't deal with regulators or GPIO pins, since in the existing device trees they are either always on for regulators, or have GPIO hogs or pinmux and pinconfig directly tied to the pin controller. Another case this driver could handle is selecting components based on some identifier passed in by the firmware. On Chromebooks we have a SKU ID which is inserted by the bootloader at /firmware/coreboot/sku-id. When a new combination of components is introduced, a new SKU ID is allocated to it. To have SKU ID based device trees, we would need to have one per SKU ID. This ends up increasing the number of device trees we have a lot. The recent MT8186 devices already have 10+10 SKUs [2], with possibly more to come. Instead, we could have just one device tree for each device, with component options listed and marked as "fail-needs-probe-XXX", and let the hardware prober enable one of them based on the given SKU ID. The driver will also fix up OF graph remote endpoints to point to the enabled component. The MT8186 Corsola series [2] can also benefit from this, though I haven't implemented anything yet. Patch 1 adds of_device_is_fail() for the new driver to use. Patch 2 implements the first case, probing the I2C bus for presence of components. This initial version targets the Hana Chromebooks. Patch 3 modifies the Hana device tree and marks the touchscreens and trackpads as "fail-needs-probe-XXX", ready for the driver to probe. Patch 4 adds a missing touchscreen variant to Hana. Patch 5 implements the second case, selectively enabling components based on the SKU ID. This initial version targets the Krane ChromeOS tablet, which has two possible MIPI DSI display panel options. Patch 6 drops Krane's SKU-specific compatible strings from the bindings. Patch 7 merges Krane's SKU-specific device trees into one, with the device tree now containing two possible panels. This unfortunately introduces a dtc warning: arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts:81.13-83.6: Warning (graph_endpoint): /soc/dsi@14014000/panel2@0/port/endpoint: graph connection to node '/soc/dsi@14014000/ports/port/endpoint' is not bidirectional Please take a look. Johan, I'm not sure if this works as is for the Lenovo Thinkpad 13S case, since it looks like the trackpad shares the I2C bus with the keyboard. Thanks ChenYu Background as given in Doug's cover letter: Support for multiple "equivalent" sources for components (also known as second sourcing components) is a standard practice that helps keep cost down and also makes sure that if one component is unavailable due to a shortage that we don't need to stop production for the whole product. Some components are very easy to second source. eMMC, for instance, is fully discoverable and probable so you can stuff a wide variety of similar eMMC chips on your board and things will work without a hitch. Some components are more difficult to second source, specifically because it's difficult for software to probe what component is present on any given board. In cases like this software is provided supplementary information to help it, like a GPIO strap or a SKU ID programmed into an EEPROM. This helpful information can allow the bootloader to select a different device tree. The various different "SKUs" of different Chromebooks are examples of this. Some components are somewhere in between. These in-between components are the subject of this patch. Specifically, these components are easily "probeable" but not easily "discoverable". A good example of a probeable but undiscoverable device is an i2c-connected touchscreen or trackpad. Two separate components may be electrically compatible with each other and may have compatible power sequencing requirements but may require different software. If software is told about the different possible components (because it can't discover them), it can safely probe them to figure out which ones are present. On systems using device tree, if we want to tell the OS about all of the different components we need to list them all in the device tree. This leads to a problem. The multiple sources for components likely use the same resources (GPIOs, interrupts, regulators). If the OS tries to probe all of these components at the same time then it will detect a resource conflict and that's a fatal error. The fact that Linux can't handle these probeable but undiscoverable devices well has had a few consequences: 1. In some cases, we've abandoned the idea of second sourcing components for a given board, which increases cost / generates manufacturing headaches. 2. In some cases, we've been forced to add some sort of strapping / EEPROM to indicate which component is present. This adds difficulty to manufacturing / refurb processes. 3. In some cases, we've managed to make things work by the skin of our teeth through slightly hacky solutions. Specifically, if we remove the "pinctrl" entry from the various options then it won't conflict. Regulators inherently can have more than one consumer, so as long as there are no GPIOs involved in power sequencing and probing devices then things can work. This is how "sc8280xp-lenovo-thinkpad-x13s" works and also how "mt8173-elm-hana" works. End of background from Doug's cover letter. [1] https://lore.kernel.org/all/20230921102420.RFC.1.I9dddd99ccdca175e3ceb1b9fa1827df0928c5101@changeid/ [2] https://lore.kernel.org/linux-mediatek/20231012230237.2676469-1-wenst@chromium.org/ Chen-Yu Tsai (7): of: base: Add of_device_is_fail of: Introduce hardware prober driver arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads as fail arm64: dts: mediatek: mt8173-elm-hana: Add G2touch G7500 touchscreen of: hw_prober: Support Chromebook SKU ID based component selection dt-bindings: arm: mediatek: Remove SKU specific compatibles for Google Krane arm64: dts: mediatek: mt8183-kukui: Merge Krane device trees .../devicetree/bindings/arm/mediatek.yaml | 3 - arch/arm64/boot/dts/mediatek/Makefile | 3 +- .../boot/dts/mediatek/mt8173-elm-hana.dtsi | 20 ++ .../dts/mediatek/mt8183-kukui-krane-sku0.dts | 24 -- .../mediatek/mt8183-kukui-krane-sku176.dts | 24 -- ...ukui-krane.dtsi => mt8183-kukui-krane.dts} | 47 ++- drivers/of/Kconfig | 13 + drivers/of/Makefile | 1 + drivers/of/base.c | 20 ++ drivers/of/hw_prober.c | 314 ++++++++++++++++++ include/linux/of.h | 6 + 11 files changed, 418 insertions(+), 57 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%) create mode 100644 drivers/of/hw_prober.c
Comments
Il 09/11/23 11:05, Chen-Yu Tsai ha scritto: > Hi everyone, > > This v2 series continues Doug's "of: device: Support 2nd sources of > probeable but undiscoverable devices" [1] series, but follows the scheme > suggested by Rob, marking all second source component device nodes > as "fail-needs-probe-XXX", and having a hardware prober driver enable > the one of them. I tried to include everyone from the original Cc: list. > Please let me know if you would like to be dropped from future > submissions. > > > For the I2C component (touchscreens and trackpads) case from the > original series, the hardware prober driver finds the particular > class of device in the device tree, gets its parent I2C adapter, > and tries to initiate a simple I2C read for each device under that > I2C bus. When it finds one that responds, it considers that one > present, marks it as "okay", and returns, letting the driver core > actually probe the device. > > This works fine in most cases since these components are connected > via ribbon cable and always have the same resources. The driver as > implemented currently doesn't deal with regulators or GPIO pins, > since in the existing device trees they are either always on for > regulators, or have GPIO hogs or pinmux and pinconfig directly > tied to the pin controller. > > > Another case this driver could handle is selecting components based > on some identifier passed in by the firmware. On Chromebooks we have > a SKU ID which is inserted by the bootloader at > /firmware/coreboot/sku-id. When a new combination of components is > introduced, a new SKU ID is allocated to it. To have SKU ID based > device trees, we would need to have one per SKU ID. This ends up > increasing the number of device trees we have a lot. The recent > MT8186 devices already have 10+10 SKUs [2], with possibly more to come. > > Instead, we could have just one device tree for each device, with > component options listed and marked as "fail-needs-probe-XXX", and > let the hardware prober enable one of them based on the given SKU ID. > The driver will also fix up OF graph remote endpoints to point to the > enabled component. > > The MT8186 Corsola series [2] can also benefit from this, though I > haven't implemented anything yet. > > > Patch 1 adds of_device_is_fail() for the new driver to use. > > Patch 2 implements the first case, probing the I2C bus for presence > of components. This initial version targets the Hana Chromebooks. > > Patch 3 modifies the Hana device tree and marks the touchscreens > and trackpads as "fail-needs-probe-XXX", ready for the driver to > probe. > > Patch 4 adds a missing touchscreen variant to Hana. > > Patch 5 implements the second case, selectively enabling components > based on the SKU ID. This initial version targets the Krane ChromeOS > tablet, which has two possible MIPI DSI display panel options. > > Patch 6 drops Krane's SKU-specific compatible strings from the bindings. > > Patch 7 merges Krane's SKU-specific device trees into one, with the > device tree now containing two possible panels. This unfortunately > introduces a dtc warning: > > arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts:81.13-83.6: > Warning (graph_endpoint): /soc/dsi@14014000/panel2@0/port/endpoint: > graph connection to node '/soc/dsi@14014000/ports/port/endpoint' > is not bidirectional > > > Please take a look. > > Johan, I'm not sure if this works as is for the Lenovo Thinkpad 13S > case, since it looks like the trackpad shares the I2C bus with the > keyboard. > > > Thanks > ChenYu > > > Background as given in Doug's cover letter: > > Support for multiple "equivalent" sources for components (also known > as second sourcing components) is a standard practice that helps keep > cost down and also makes sure that if one component is unavailable due > to a shortage that we don't need to stop production for the whole > product. > > Some components are very easy to second source. eMMC, for instance, is > fully discoverable and probable so you can stuff a wide variety of > similar eMMC chips on your board and things will work without a hitch. > > Some components are more difficult to second source, specifically > because it's difficult for software to probe what component is present > on any given board. In cases like this software is provided > supplementary information to help it, like a GPIO strap or a SKU ID > programmed into an EEPROM. This helpful information can allow the > bootloader to select a different device tree. The various different > "SKUs" of different Chromebooks are examples of this. > > Some components are somewhere in between. These in-between components > are the subject of this patch. Specifically, these components are > easily "probeable" but not easily "discoverable". > > A good example of a probeable but undiscoverable device is an > i2c-connected touchscreen or trackpad. Two separate components may be > electrically compatible with each other and may have compatible power > sequencing requirements but may require different software. If > software is told about the different possible components (because it > can't discover them), it can safely probe them to figure out which > ones are present. > > On systems using device tree, if we want to tell the OS about all of > the different components we need to list them all in the device > tree. This leads to a problem. The multiple sources for components > likely use the same resources (GPIOs, interrupts, regulators). If the > OS tries to probe all of these components at the same time then it > will detect a resource conflict and that's a fatal error. > > The fact that Linux can't handle these probeable but undiscoverable > devices well has had a few consequences: > 1. In some cases, we've abandoned the idea of second sourcing > components for a given board, which increases cost / generates > manufacturing headaches. > 2. In some cases, we've been forced to add some sort of strapping / > EEPROM to indicate which component is present. This adds difficulty > to manufacturing / refurb processes. > 3. In some cases, we've managed to make things work by the skin of our > teeth through slightly hacky solutions. Specifically, if we remove > the "pinctrl" entry from the various options then it won't > conflict. Regulators inherently can have more than one consumer, so > as long as there are no GPIOs involved in power sequencing and > probing devices then things can work. This is how > "sc8280xp-lenovo-thinkpad-x13s" works and also how > "mt8173-elm-hana" works. > > End of background from Doug's cover letter. I think that using "status" is not a good idea, I find that confusing. Perhaps we could have a node like something { device-class-one = <&device1>, <&device2>, <&device3>; device-class-two = <&device4>, <&device5>, <&device6>; } so that'd be more or less hw-prober { trackpads = <&tp1>, <&tp2>; keyboards = <&kb1>, <&kb2>; touchscreens = <&ts1>, <&ts2>; } Besides, something else I can suggest here is to make this more generic: actually, this issue is spread across way more devices than you maybe think... for example, I know of some smartphones that may have the same situation with DSI displays and they're sometimes distinguished by an ADC value, sometimes by reading back the manufacturer ID (or panel id) through DSI. Also, if Chromebooks really need something "special", such as that coreboot sku-id parameter, I think that this should be registered externally into the hw prober and not embedded inside of the *generic* hw prober driver. We can even reuse of_device_id instead of inventing a new hw_prober_entry struct... Idea: drivers/platform/chrome/cros_of_hw_prober.c static int cros_sku_hw_prober(struct platform_device *pdev, const void *data) { ...this is your cros_sku_component_selector() function, anyway... } static const struct of_device_id cros_hw_prober_ids[] = { { .compatible = "google,hana", .data = something }, { /* sentinel */ } }; static int some_kind_of_early_init_function(something) { int a,b,c,ret,something; .. some logic if necessary .. return of_hw_prober_register(cros_sku_hw_prober, cros_hw_prober_ids); } Btw, thanks for starting that. If this will be done the right way, it's going to be useful to many, many people. Regards, Angelo > > [1] https://lore.kernel.org/all/20230921102420.RFC.1.I9dddd99ccdca175e3ceb1b9fa1827df0928c5101@changeid/ > [2] https://lore.kernel.org/linux-mediatek/20231012230237.2676469-1-wenst@chromium.org/ > > Chen-Yu Tsai (7): > of: base: Add of_device_is_fail > of: Introduce hardware prober driver > arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads > as fail > arm64: dts: mediatek: mt8173-elm-hana: Add G2touch G7500 touchscreen > of: hw_prober: Support Chromebook SKU ID based component selection > dt-bindings: arm: mediatek: Remove SKU specific compatibles for Google > Krane > arm64: dts: mediatek: mt8183-kukui: Merge Krane device trees > > .../devicetree/bindings/arm/mediatek.yaml | 3 - > arch/arm64/boot/dts/mediatek/Makefile | 3 +- > .../boot/dts/mediatek/mt8173-elm-hana.dtsi | 20 ++ > .../dts/mediatek/mt8183-kukui-krane-sku0.dts | 24 -- > .../mediatek/mt8183-kukui-krane-sku176.dts | 24 -- > ...ukui-krane.dtsi => mt8183-kukui-krane.dts} | 47 ++- > drivers/of/Kconfig | 13 + > drivers/of/Makefile | 1 + > drivers/of/base.c | 20 ++ > drivers/of/hw_prober.c | 314 ++++++++++++++++++ > include/linux/of.h | 6 + > 11 files changed, 418 insertions(+), 57 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%) > create mode 100644 drivers/of/hw_prober.c >
On Thu, Nov 9, 2023 at 4:54 AM AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote: > > Il 09/11/23 11:05, Chen-Yu Tsai ha scritto: > > Hi everyone, > > > > This v2 series continues Doug's "of: device: Support 2nd sources of > > probeable but undiscoverable devices" [1] series, but follows the scheme > > suggested by Rob, marking all second source component device nodes > > as "fail-needs-probe-XXX", and having a hardware prober driver enable > > the one of them. I tried to include everyone from the original Cc: list. > > Please let me know if you would like to be dropped from future > > submissions. > > > > > > For the I2C component (touchscreens and trackpads) case from the > > original series, the hardware prober driver finds the particular > > class of device in the device tree, gets its parent I2C adapter, > > and tries to initiate a simple I2C read for each device under that > > I2C bus. When it finds one that responds, it considers that one > > present, marks it as "okay", and returns, letting the driver core > > actually probe the device. > > > > This works fine in most cases since these components are connected > > via ribbon cable and always have the same resources. The driver as > > implemented currently doesn't deal with regulators or GPIO pins, > > since in the existing device trees they are either always on for > > regulators, or have GPIO hogs or pinmux and pinconfig directly > > tied to the pin controller. > > > > > > Another case this driver could handle is selecting components based > > on some identifier passed in by the firmware. On Chromebooks we have > > a SKU ID which is inserted by the bootloader at > > /firmware/coreboot/sku-id. When a new combination of components is > > introduced, a new SKU ID is allocated to it. To have SKU ID based > > device trees, we would need to have one per SKU ID. This ends up > > increasing the number of device trees we have a lot. The recent > > MT8186 devices already have 10+10 SKUs [2], with possibly more to come. > > > > Instead, we could have just one device tree for each device, with > > component options listed and marked as "fail-needs-probe-XXX", and > > let the hardware prober enable one of them based on the given SKU ID. > > The driver will also fix up OF graph remote endpoints to point to the > > enabled component. > > > > The MT8186 Corsola series [2] can also benefit from this, though I > > haven't implemented anything yet. > > > > > > Patch 1 adds of_device_is_fail() for the new driver to use. > > > > Patch 2 implements the first case, probing the I2C bus for presence > > of components. This initial version targets the Hana Chromebooks. > > > > Patch 3 modifies the Hana device tree and marks the touchscreens > > and trackpads as "fail-needs-probe-XXX", ready for the driver to > > probe. > > > > Patch 4 adds a missing touchscreen variant to Hana. > > > > Patch 5 implements the second case, selectively enabling components > > based on the SKU ID. This initial version targets the Krane ChromeOS > > tablet, which has two possible MIPI DSI display panel options. > > > > Patch 6 drops Krane's SKU-specific compatible strings from the bindings. > > > > Patch 7 merges Krane's SKU-specific device trees into one, with the > > device tree now containing two possible panels. This unfortunately > > introduces a dtc warning: > > > > arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts:81.13-83.6: > > Warning (graph_endpoint): /soc/dsi@14014000/panel2@0/port/endpoint: > > graph connection to node '/soc/dsi@14014000/ports/port/endpoint' > > is not bidirectional > > > > > > Please take a look. > > > > Johan, I'm not sure if this works as is for the Lenovo Thinkpad 13S > > case, since it looks like the trackpad shares the I2C bus with the > > keyboard. > > > > > > Thanks > > ChenYu > > > > > > Background as given in Doug's cover letter: > > > > Support for multiple "equivalent" sources for components (also known > > as second sourcing components) is a standard practice that helps keep > > cost down and also makes sure that if one component is unavailable due > > to a shortage that we don't need to stop production for the whole > > product. > > > > Some components are very easy to second source. eMMC, for instance, is > > fully discoverable and probable so you can stuff a wide variety of > > similar eMMC chips on your board and things will work without a hitch. > > > > Some components are more difficult to second source, specifically > > because it's difficult for software to probe what component is present > > on any given board. In cases like this software is provided > > supplementary information to help it, like a GPIO strap or a SKU ID > > programmed into an EEPROM. This helpful information can allow the > > bootloader to select a different device tree. The various different > > "SKUs" of different Chromebooks are examples of this. > > > > Some components are somewhere in between. These in-between components > > are the subject of this patch. Specifically, these components are > > easily "probeable" but not easily "discoverable". > > > > A good example of a probeable but undiscoverable device is an > > i2c-connected touchscreen or trackpad. Two separate components may be > > electrically compatible with each other and may have compatible power > > sequencing requirements but may require different software. If > > software is told about the different possible components (because it > > can't discover them), it can safely probe them to figure out which > > ones are present. > > > > On systems using device tree, if we want to tell the OS about all of > > the different components we need to list them all in the device > > tree. This leads to a problem. The multiple sources for components > > likely use the same resources (GPIOs, interrupts, regulators). If the > > OS tries to probe all of these components at the same time then it > > will detect a resource conflict and that's a fatal error. > > > > The fact that Linux can't handle these probeable but undiscoverable > > devices well has had a few consequences: > > 1. In some cases, we've abandoned the idea of second sourcing > > components for a given board, which increases cost / generates > > manufacturing headaches. > > 2. In some cases, we've been forced to add some sort of strapping / > > EEPROM to indicate which component is present. This adds difficulty > > to manufacturing / refurb processes. > > 3. In some cases, we've managed to make things work by the skin of our > > teeth through slightly hacky solutions. Specifically, if we remove > > the "pinctrl" entry from the various options then it won't > > conflict. Regulators inherently can have more than one consumer, so > > as long as there are no GPIOs involved in power sequencing and > > probing devices then things can work. This is how > > "sc8280xp-lenovo-thinkpad-x13s" works and also how > > "mt8173-elm-hana" works. > > > > End of background from Doug's cover letter. > > I think that using "status" is not a good idea, I find that confusing. "status" is what defines a device's state in terms of enabled, present, available. That's exactly what we're expressing here. Now, I do not think we should be mixing the device class (e.g. touchscreen) into status. I said this on v1, but apparently that was not listened to. > > Perhaps we could have a node like > > something { > device-class-one = <&device1>, <&device2>, <&device3>; > device-class-two = <&device4>, <&device5>, <&device6>; > } > > so that'd be more or less > > hw-prober { > trackpads = <&tp1>, <&tp2>; > keyboards = <&kb1>, <&kb2>; > touchscreens = <&ts1>, <&ts2>; > } No. That's more or less what v1 had. Rob
Hi, On Thu, Nov 9, 2023 at 5:52 AM Rob Herring <robh+dt@kernel.org> wrote: > > > > End of background from Doug's cover letter. > > > > I think that using "status" is not a good idea, I find that confusing. > > "status" is what defines a device's state in terms of enabled, > present, available. That's exactly what we're expressing here. > > Now, I do not think we should be mixing the device class (e.g. > touchscreen) into status. I said this on v1, but apparently that was > not listened to. Interesting. I must have missed the "don't mix device class into status" part. Do you have a link to your post about that? Maybe there's other stuff I missed... Having the device class stuck at the end there was at least part of my last post [1] which gathered no response. I think one of the reasons that I felt we needed to mux the device class into status was that it was going to make the code a lot less fragile. Everything I've seen indicates that you don't want us to create a "HW prober" node that could be used to provide relevant phandles for different classes of devices, so the "HW prober" code needs to either search through the whole device tree for a status of "failed-needs-probe" or needs to contain per-board, hardcoded, fully-qualified paths. I don't think we want to include hardcoded, fully-qualified paths in the code. That would mean that if someone changed a node name somewhere in the path to one of the devices that we're dealing with then it would break. So if we're searching the whole device tree for "failed-needs-probe" then we need to figure out which devices are related to each other. If a given board has second sources for MIPI panels, touchscreens, and trackpads then we need to know which of the "failed-needs-probe" devices are trackpads, which are touchscreens, and which are MIPI panels. Do you have any suggestions for how we should do that? Maybe it was in some other thread that I missed? I guess we could have a board-specific table mapping (compatible + node name + reg) to a class, but that feels awkward. [1] https://lore.kernel.org/r/CAD=FV=UjVAgT-febtj4=UZ2GQp01D-ern2Ff9+ODcHeQBOsdTQ@mail.gmail.com
Hi, On Thu, Nov 9, 2023 at 2:06 AM Chen-Yu Tsai <wenst@chromium.org> wrote: > > The driver as > implemented currently doesn't deal with regulators or GPIO pins, > since in the existing device trees they are either always on for > regulators, or have GPIO hogs or pinmux and pinconfig directly > tied to the pin controller. I guess I won't object too much about this limitation for v1, but IMO it would be good to get this sorted out since I think part of the power of having the HW Prober is specifically that it can handle this type of use case. You have a little bit of board-specific code that knows how to turn on the regulators / GPIOs and can then probe the devices. Note: even if this is "board specific", it doesn't mean you couldn't share code between boards. For instance, you could have a helper function that would turn on regulators/GPIOs based on some type of table and that helper function could be used across a whole pile of Chromebooks. If a Chromebook is sufficiently different that it couldn't use the helper function then it could call its own function, but presumably it wouldn't be hard to support a bunch of boards without much code. As part of this, I think that your main "HW Prober" for Chromebooks should be in "drivers/platform/chrome/". I think that the only things that should be in the "drivers/of" directory should be helper functions used by the Chromebook HW Probers. -Doug
On Thu, Nov 9, 2023 at 9:52 PM Rob Herring <robh+dt@kernel.org> wrote: > > On Thu, Nov 9, 2023 at 4:54 AM AngeloGioacchino Del Regno > <angelogioacchino.delregno@collabora.com> wrote: > > > > Il 09/11/23 11:05, Chen-Yu Tsai ha scritto: > > > Hi everyone, > > > > > > This v2 series continues Doug's "of: device: Support 2nd sources of > > > probeable but undiscoverable devices" [1] series, but follows the scheme > > > suggested by Rob, marking all second source component device nodes > > > as "fail-needs-probe-XXX", and having a hardware prober driver enable > > > the one of them. I tried to include everyone from the original Cc: list. > > > Please let me know if you would like to be dropped from future > > > submissions. > > > > > > > > > For the I2C component (touchscreens and trackpads) case from the > > > original series, the hardware prober driver finds the particular > > > class of device in the device tree, gets its parent I2C adapter, > > > and tries to initiate a simple I2C read for each device under that > > > I2C bus. When it finds one that responds, it considers that one > > > present, marks it as "okay", and returns, letting the driver core > > > actually probe the device. > > > > > > This works fine in most cases since these components are connected > > > via ribbon cable and always have the same resources. The driver as > > > implemented currently doesn't deal with regulators or GPIO pins, > > > since in the existing device trees they are either always on for > > > regulators, or have GPIO hogs or pinmux and pinconfig directly > > > tied to the pin controller. > > > > > > > > > Another case this driver could handle is selecting components based > > > on some identifier passed in by the firmware. On Chromebooks we have > > > a SKU ID which is inserted by the bootloader at > > > /firmware/coreboot/sku-id. When a new combination of components is > > > introduced, a new SKU ID is allocated to it. To have SKU ID based > > > device trees, we would need to have one per SKU ID. This ends up > > > increasing the number of device trees we have a lot. The recent > > > MT8186 devices already have 10+10 SKUs [2], with possibly more to come. > > > > > > Instead, we could have just one device tree for each device, with > > > component options listed and marked as "fail-needs-probe-XXX", and > > > let the hardware prober enable one of them based on the given SKU ID. > > > The driver will also fix up OF graph remote endpoints to point to the > > > enabled component. > > > > > > The MT8186 Corsola series [2] can also benefit from this, though I > > > haven't implemented anything yet. > > > > > > > > > Patch 1 adds of_device_is_fail() for the new driver to use. > > > > > > Patch 2 implements the first case, probing the I2C bus for presence > > > of components. This initial version targets the Hana Chromebooks. > > > > > > Patch 3 modifies the Hana device tree and marks the touchscreens > > > and trackpads as "fail-needs-probe-XXX", ready for the driver to > > > probe. > > > > > > Patch 4 adds a missing touchscreen variant to Hana. > > > > > > Patch 5 implements the second case, selectively enabling components > > > based on the SKU ID. This initial version targets the Krane ChromeOS > > > tablet, which has two possible MIPI DSI display panel options. > > > > > > Patch 6 drops Krane's SKU-specific compatible strings from the bindings. > > > > > > Patch 7 merges Krane's SKU-specific device trees into one, with the > > > device tree now containing two possible panels. This unfortunately > > > introduces a dtc warning: > > > > > > arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts:81.13-83.6: > > > Warning (graph_endpoint): /soc/dsi@14014000/panel2@0/port/endpoint: > > > graph connection to node '/soc/dsi@14014000/ports/port/endpoint' > > > is not bidirectional > > > > > > > > > Please take a look. > > > > > > Johan, I'm not sure if this works as is for the Lenovo Thinkpad 13S > > > case, since it looks like the trackpad shares the I2C bus with the > > > keyboard. > > > > > > > > > Thanks > > > ChenYu > > > > > > > > > Background as given in Doug's cover letter: > > > > > > Support for multiple "equivalent" sources for components (also known > > > as second sourcing components) is a standard practice that helps keep > > > cost down and also makes sure that if one component is unavailable due > > > to a shortage that we don't need to stop production for the whole > > > product. > > > > > > Some components are very easy to second source. eMMC, for instance, is > > > fully discoverable and probable so you can stuff a wide variety of > > > similar eMMC chips on your board and things will work without a hitch. > > > > > > Some components are more difficult to second source, specifically > > > because it's difficult for software to probe what component is present > > > on any given board. In cases like this software is provided > > > supplementary information to help it, like a GPIO strap or a SKU ID > > > programmed into an EEPROM. This helpful information can allow the > > > bootloader to select a different device tree. The various different > > > "SKUs" of different Chromebooks are examples of this. > > > > > > Some components are somewhere in between. These in-between components > > > are the subject of this patch. Specifically, these components are > > > easily "probeable" but not easily "discoverable". > > > > > > A good example of a probeable but undiscoverable device is an > > > i2c-connected touchscreen or trackpad. Two separate components may be > > > electrically compatible with each other and may have compatible power > > > sequencing requirements but may require different software. If > > > software is told about the different possible components (because it > > > can't discover them), it can safely probe them to figure out which > > > ones are present. > > > > > > On systems using device tree, if we want to tell the OS about all of > > > the different components we need to list them all in the device > > > tree. This leads to a problem. The multiple sources for components > > > likely use the same resources (GPIOs, interrupts, regulators). If the > > > OS tries to probe all of these components at the same time then it > > > will detect a resource conflict and that's a fatal error. > > > > > > The fact that Linux can't handle these probeable but undiscoverable > > > devices well has had a few consequences: > > > 1. In some cases, we've abandoned the idea of second sourcing > > > components for a given board, which increases cost / generates > > > manufacturing headaches. > > > 2. In some cases, we've been forced to add some sort of strapping / > > > EEPROM to indicate which component is present. This adds difficulty > > > to manufacturing / refurb processes. > > > 3. In some cases, we've managed to make things work by the skin of our > > > teeth through slightly hacky solutions. Specifically, if we remove > > > the "pinctrl" entry from the various options then it won't > > > conflict. Regulators inherently can have more than one consumer, so > > > as long as there are no GPIOs involved in power sequencing and > > > probing devices then things can work. This is how > > > "sc8280xp-lenovo-thinkpad-x13s" works and also how > > > "mt8173-elm-hana" works. > > > > > > End of background from Doug's cover letter. > > > > I think that using "status" is not a good idea, I find that confusing. > > "status" is what defines a device's state in terms of enabled, > present, available. That's exactly what we're expressing here. > > Now, I do not think we should be mixing the device class (e.g. > touchscreen) into status. I said this on v1, but apparently that was > not listened to. I must have missed it and only took in Doug's final response. My code doesn't actually use the class in the status property though. I will remove it and just keep "fail-needs-probe". ChenYu > > > > Perhaps we could have a node like > > > > something { > > device-class-one = <&device1>, <&device2>, <&device3>; > > device-class-two = <&device4>, <&device5>, <&device6>; > > } > > > > so that'd be more or less > > > > hw-prober { > > trackpads = <&tp1>, <&tp2>; > > keyboards = <&kb1>, <&kb2>; > > touchscreens = <&ts1>, <&ts2>; > > } > > No. That's more or less what v1 had. > > Rob
On Sat, Nov 11, 2023 at 8:22 AM Doug Anderson <dianders@chromium.org> wrote: > > Hi, > > On Thu, Nov 9, 2023 at 2:06 AM Chen-Yu Tsai <wenst@chromium.org> wrote: > > > > The driver as > > implemented currently doesn't deal with regulators or GPIO pins, > > since in the existing device trees they are either always on for > > regulators, or have GPIO hogs or pinmux and pinconfig directly > > tied to the pin controller. > > I guess I won't object too much about this limitation for v1, but IMO > it would be good to get this sorted out since I think part of the > power of having the HW Prober is specifically that it can handle this > type of use case. You have a little bit of board-specific code that > knows how to turn on the regulators / GPIOs and can then probe the > devices. > > Note: even if this is "board specific", it doesn't mean you couldn't > share code between boards. For instance, you could have a helper > function that would turn on regulators/GPIOs based on some type of > table and that helper function could be used across a whole pile of > Chromebooks. If a Chromebook is sufficiently different that it > couldn't use the helper function then it could call its own function, > but presumably it wouldn't be hard to support a bunch of boards > without much code. I agree this part is fairly generic and should be implemented. We probably don't even need such a table. If these components share a common connection to the mainboard, they certainly will have the same GPIO lines and regulator supplies. The prober could just scan the nodes looking for -gpio and -supply properties, de-duplicate them, and turn them on. The reason this isn't implemented in this version is because the devices I'm currently using do not have these resources togglable. The supply is always on, and the GPIO line is disconnected from the SoC. So I have no way of testing it yet. > As part of this, I think that your main "HW Prober" for Chromebooks > should be in "drivers/platform/chrome/". I think that the only things > that should be in the "drivers/of" directory should be helper > functions used by the Chromebook HW Probers. Sound like what Rob wants. ChenYu
On Thu, Nov 9, 2023 at 6:54 PM AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote: > > Il 09/11/23 11:05, Chen-Yu Tsai ha scritto: > > Hi everyone, > > > > This v2 series continues Doug's "of: device: Support 2nd sources of > > probeable but undiscoverable devices" [1] series, but follows the scheme > > suggested by Rob, marking all second source component device nodes > > as "fail-needs-probe-XXX", and having a hardware prober driver enable > > the one of them. I tried to include everyone from the original Cc: list. > > Please let me know if you would like to be dropped from future > > submissions. > > > > > > For the I2C component (touchscreens and trackpads) case from the > > original series, the hardware prober driver finds the particular > > class of device in the device tree, gets its parent I2C adapter, > > and tries to initiate a simple I2C read for each device under that > > I2C bus. When it finds one that responds, it considers that one > > present, marks it as "okay", and returns, letting the driver core > > actually probe the device. > > > > This works fine in most cases since these components are connected > > via ribbon cable and always have the same resources. The driver as > > implemented currently doesn't deal with regulators or GPIO pins, > > since in the existing device trees they are either always on for > > regulators, or have GPIO hogs or pinmux and pinconfig directly > > tied to the pin controller. > > > > > > Another case this driver could handle is selecting components based > > on some identifier passed in by the firmware. On Chromebooks we have > > a SKU ID which is inserted by the bootloader at > > /firmware/coreboot/sku-id. When a new combination of components is > > introduced, a new SKU ID is allocated to it. To have SKU ID based > > device trees, we would need to have one per SKU ID. This ends up > > increasing the number of device trees we have a lot. The recent > > MT8186 devices already have 10+10 SKUs [2], with possibly more to come. > > > > Instead, we could have just one device tree for each device, with > > component options listed and marked as "fail-needs-probe-XXX", and > > let the hardware prober enable one of them based on the given SKU ID. > > The driver will also fix up OF graph remote endpoints to point to the > > enabled component. > > > > The MT8186 Corsola series [2] can also benefit from this, though I > > haven't implemented anything yet. > > > > > > Patch 1 adds of_device_is_fail() for the new driver to use. > > > > Patch 2 implements the first case, probing the I2C bus for presence > > of components. This initial version targets the Hana Chromebooks. > > > > Patch 3 modifies the Hana device tree and marks the touchscreens > > and trackpads as "fail-needs-probe-XXX", ready for the driver to > > probe. > > > > Patch 4 adds a missing touchscreen variant to Hana. > > > > Patch 5 implements the second case, selectively enabling components > > based on the SKU ID. This initial version targets the Krane ChromeOS > > tablet, which has two possible MIPI DSI display panel options. > > > > Patch 6 drops Krane's SKU-specific compatible strings from the bindings. > > > > Patch 7 merges Krane's SKU-specific device trees into one, with the > > device tree now containing two possible panels. This unfortunately > > introduces a dtc warning: > > > > arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts:81.13-83.6: > > Warning (graph_endpoint): /soc/dsi@14014000/panel2@0/port/endpoint: > > graph connection to node '/soc/dsi@14014000/ports/port/endpoint' > > is not bidirectional > > > > > > Please take a look. > > > > Johan, I'm not sure if this works as is for the Lenovo Thinkpad 13S > > case, since it looks like the trackpad shares the I2C bus with the > > keyboard. > > > > > > Thanks > > ChenYu > > > > > > Background as given in Doug's cover letter: > > > > Support for multiple "equivalent" sources for components (also known > > as second sourcing components) is a standard practice that helps keep > > cost down and also makes sure that if one component is unavailable due > > to a shortage that we don't need to stop production for the whole > > product. > > > > Some components are very easy to second source. eMMC, for instance, is > > fully discoverable and probable so you can stuff a wide variety of > > similar eMMC chips on your board and things will work without a hitch. > > > > Some components are more difficult to second source, specifically > > because it's difficult for software to probe what component is present > > on any given board. In cases like this software is provided > > supplementary information to help it, like a GPIO strap or a SKU ID > > programmed into an EEPROM. This helpful information can allow the > > bootloader to select a different device tree. The various different > > "SKUs" of different Chromebooks are examples of this. > > > > Some components are somewhere in between. These in-between components > > are the subject of this patch. Specifically, these components are > > easily "probeable" but not easily "discoverable". > > > > A good example of a probeable but undiscoverable device is an > > i2c-connected touchscreen or trackpad. Two separate components may be > > electrically compatible with each other and may have compatible power > > sequencing requirements but may require different software. If > > software is told about the different possible components (because it > > can't discover them), it can safely probe them to figure out which > > ones are present. > > > > On systems using device tree, if we want to tell the OS about all of > > the different components we need to list them all in the device > > tree. This leads to a problem. The multiple sources for components > > likely use the same resources (GPIOs, interrupts, regulators). If the > > OS tries to probe all of these components at the same time then it > > will detect a resource conflict and that's a fatal error. > > > > The fact that Linux can't handle these probeable but undiscoverable > > devices well has had a few consequences: > > 1. In some cases, we've abandoned the idea of second sourcing > > components for a given board, which increases cost / generates > > manufacturing headaches. > > 2. In some cases, we've been forced to add some sort of strapping / > > EEPROM to indicate which component is present. This adds difficulty > > to manufacturing / refurb processes. > > 3. In some cases, we've managed to make things work by the skin of our > > teeth through slightly hacky solutions. Specifically, if we remove > > the "pinctrl" entry from the various options then it won't > > conflict. Regulators inherently can have more than one consumer, so > > as long as there are no GPIOs involved in power sequencing and > > probing devices then things can work. This is how > > "sc8280xp-lenovo-thinkpad-x13s" works and also how > > "mt8173-elm-hana" works. > > > > End of background from Doug's cover letter. > > I think that using "status" is not a good idea, I find that confusing. It isn't a hard requirement. The current I2C prober actually just looks at the node name, which already should be a generic class type. It then assumes that all the components of the same class that it is supposed to probe for are on the same bus. I think this is a fair assumption for replaceable parts connected via ribbon cable or co-layout parts? > Perhaps we could have a node like > > something { > device-class-one = <&device1>, <&device2>, <&device3>; > device-class-two = <&device4>, <&device5>, <&device6>; > } > > so that'd be more or less > > hw-prober { > trackpads = <&tp1>, <&tp2>; > keyboards = <&kb1>, <&kb2>; > touchscreens = <&ts1>, <&ts2>; > } This was already nacked by Rob. > Besides, something else I can suggest here is to make this more generic: actually, > this issue is spread across way more devices than you maybe think... for example, > I know of some smartphones that may have the same situation with DSI displays and > they're sometimes distinguished by an ADC value, sometimes by reading back the > manufacturer ID (or panel id) through DSI. ADC strapping is common. Though we might need some kind of binding about how to describe the ADC strapping scheme, as this is bound to be different across boards. Reading back from DSI feels problematic to implement. But I don't know much about DSI ATM. Doug implied in our offline discussion that DSI panels might have power sequencing requirements that are all over the place. > Also, if Chromebooks really need something "special", such as that coreboot sku-id > parameter, I think that this should be registered externally into the hw prober > and not embedded inside of the *generic* hw prober driver. > > We can even reuse of_device_id instead of inventing a new hw_prober_entry struct... > > Idea: > > drivers/platform/chrome/cros_of_hw_prober.c > > static int cros_sku_hw_prober(struct platform_device *pdev, const void *data) > { > ...this is your cros_sku_component_selector() function, anyway... > } > > static const struct of_device_id cros_hw_prober_ids[] = { > { .compatible = "google,hana", .data = something }, > { /* sentinel */ } > }; > > static int some_kind_of_early_init_function(something) > { > int a,b,c,ret,something; > > .. some logic if necessary .. > > return of_hw_prober_register(cros_sku_hw_prober, cros_hw_prober_ids); > } This feels a bit too layered, and requires all the board specific code to have an early init function. I think exposing common helper functions for boards to implement prober drivers would be better. Then the prober could also be a module if that made sense. Given that SoC vendors are making clock controller drivers modules, this doesn't seem very far fetched. > Btw, thanks for starting that. If this will be done the right way, it's going to > be useful to many, many people. Right. I only have a limited view of applications, so input is always welcome. Thanks ChenYu > Regards, > Angelo > > > > > [1] https://lore.kernel.org/all/20230921102420.RFC.1.I9dddd99ccdca175e3ceb1b9fa1827df0928c5101@changeid/ > > [2] https://lore.kernel.org/linux-mediatek/20231012230237.2676469-1-wenst@chromium.org/ > > > > Chen-Yu Tsai (7): > > of: base: Add of_device_is_fail > > of: Introduce hardware prober driver > > arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads > > as fail > > arm64: dts: mediatek: mt8173-elm-hana: Add G2touch G7500 touchscreen > > of: hw_prober: Support Chromebook SKU ID based component selection > > dt-bindings: arm: mediatek: Remove SKU specific compatibles for Google > > Krane > > arm64: dts: mediatek: mt8183-kukui: Merge Krane device trees > > > > .../devicetree/bindings/arm/mediatek.yaml | 3 - > > arch/arm64/boot/dts/mediatek/Makefile | 3 +- > > .../boot/dts/mediatek/mt8173-elm-hana.dtsi | 20 ++ > > .../dts/mediatek/mt8183-kukui-krane-sku0.dts | 24 -- > > .../mediatek/mt8183-kukui-krane-sku176.dts | 24 -- > > ...ukui-krane.dtsi => mt8183-kukui-krane.dts} | 47 ++- > > drivers/of/Kconfig | 13 + > > drivers/of/Makefile | 1 + > > drivers/of/base.c | 20 ++ > > drivers/of/hw_prober.c | 314 ++++++++++++++++++ > > include/linux/of.h | 6 + > > 11 files changed, 418 insertions(+), 57 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%) > > create mode 100644 drivers/of/hw_prober.c > > >
Il 14/11/23 09:57, Chen-Yu Tsai ha scritto: > On Thu, Nov 9, 2023 at 6:54 PM AngeloGioacchino Del Regno > <angelogioacchino.delregno@collabora.com> wrote: >> >> Il 09/11/23 11:05, Chen-Yu Tsai ha scritto: >>> Hi everyone, >>> >>> This v2 series continues Doug's "of: device: Support 2nd sources of >>> probeable but undiscoverable devices" [1] series, but follows the scheme >>> suggested by Rob, marking all second source component device nodes >>> as "fail-needs-probe-XXX", and having a hardware prober driver enable >>> the one of them. I tried to include everyone from the original Cc: list. >>> Please let me know if you would like to be dropped from future >>> submissions. >>> >>> >>> For the I2C component (touchscreens and trackpads) case from the >>> original series, the hardware prober driver finds the particular >>> class of device in the device tree, gets its parent I2C adapter, >>> and tries to initiate a simple I2C read for each device under that >>> I2C bus. When it finds one that responds, it considers that one >>> present, marks it as "okay", and returns, letting the driver core >>> actually probe the device. >>> >>> This works fine in most cases since these components are connected >>> via ribbon cable and always have the same resources. The driver as >>> implemented currently doesn't deal with regulators or GPIO pins, >>> since in the existing device trees they are either always on for >>> regulators, or have GPIO hogs or pinmux and pinconfig directly >>> tied to the pin controller. >>> >>> >>> Another case this driver could handle is selecting components based >>> on some identifier passed in by the firmware. On Chromebooks we have >>> a SKU ID which is inserted by the bootloader at >>> /firmware/coreboot/sku-id. When a new combination of components is >>> introduced, a new SKU ID is allocated to it. To have SKU ID based >>> device trees, we would need to have one per SKU ID. This ends up >>> increasing the number of device trees we have a lot. The recent >>> MT8186 devices already have 10+10 SKUs [2], with possibly more to come. >>> >>> Instead, we could have just one device tree for each device, with >>> component options listed and marked as "fail-needs-probe-XXX", and >>> let the hardware prober enable one of them based on the given SKU ID. >>> The driver will also fix up OF graph remote endpoints to point to the >>> enabled component. >>> >>> The MT8186 Corsola series [2] can also benefit from this, though I >>> haven't implemented anything yet. >>> >>> >>> Patch 1 adds of_device_is_fail() for the new driver to use. >>> >>> Patch 2 implements the first case, probing the I2C bus for presence >>> of components. This initial version targets the Hana Chromebooks. >>> >>> Patch 3 modifies the Hana device tree and marks the touchscreens >>> and trackpads as "fail-needs-probe-XXX", ready for the driver to >>> probe. >>> >>> Patch 4 adds a missing touchscreen variant to Hana. >>> >>> Patch 5 implements the second case, selectively enabling components >>> based on the SKU ID. This initial version targets the Krane ChromeOS >>> tablet, which has two possible MIPI DSI display panel options. >>> >>> Patch 6 drops Krane's SKU-specific compatible strings from the bindings. >>> >>> Patch 7 merges Krane's SKU-specific device trees into one, with the >>> device tree now containing two possible panels. This unfortunately >>> introduces a dtc warning: >>> >>> arch/arm64/boot/dts/mediatek/mt8183-kukui-krane.dts:81.13-83.6: >>> Warning (graph_endpoint): /soc/dsi@14014000/panel2@0/port/endpoint: >>> graph connection to node '/soc/dsi@14014000/ports/port/endpoint' >>> is not bidirectional >>> >>> >>> Please take a look. >>> >>> Johan, I'm not sure if this works as is for the Lenovo Thinkpad 13S >>> case, since it looks like the trackpad shares the I2C bus with the >>> keyboard. >>> >>> >>> Thanks >>> ChenYu >>> >>> >>> Background as given in Doug's cover letter: >>> >>> Support for multiple "equivalent" sources for components (also known >>> as second sourcing components) is a standard practice that helps keep >>> cost down and also makes sure that if one component is unavailable due >>> to a shortage that we don't need to stop production for the whole >>> product. >>> >>> Some components are very easy to second source. eMMC, for instance, is >>> fully discoverable and probable so you can stuff a wide variety of >>> similar eMMC chips on your board and things will work without a hitch. >>> >>> Some components are more difficult to second source, specifically >>> because it's difficult for software to probe what component is present >>> on any given board. In cases like this software is provided >>> supplementary information to help it, like a GPIO strap or a SKU ID >>> programmed into an EEPROM. This helpful information can allow the >>> bootloader to select a different device tree. The various different >>> "SKUs" of different Chromebooks are examples of this. >>> >>> Some components are somewhere in between. These in-between components >>> are the subject of this patch. Specifically, these components are >>> easily "probeable" but not easily "discoverable". >>> >>> A good example of a probeable but undiscoverable device is an >>> i2c-connected touchscreen or trackpad. Two separate components may be >>> electrically compatible with each other and may have compatible power >>> sequencing requirements but may require different software. If >>> software is told about the different possible components (because it >>> can't discover them), it can safely probe them to figure out which >>> ones are present. >>> >>> On systems using device tree, if we want to tell the OS about all of >>> the different components we need to list them all in the device >>> tree. This leads to a problem. The multiple sources for components >>> likely use the same resources (GPIOs, interrupts, regulators). If the >>> OS tries to probe all of these components at the same time then it >>> will detect a resource conflict and that's a fatal error. >>> >>> The fact that Linux can't handle these probeable but undiscoverable >>> devices well has had a few consequences: >>> 1. In some cases, we've abandoned the idea of second sourcing >>> components for a given board, which increases cost / generates >>> manufacturing headaches. >>> 2. In some cases, we've been forced to add some sort of strapping / >>> EEPROM to indicate which component is present. This adds difficulty >>> to manufacturing / refurb processes. >>> 3. In some cases, we've managed to make things work by the skin of our >>> teeth through slightly hacky solutions. Specifically, if we remove >>> the "pinctrl" entry from the various options then it won't >>> conflict. Regulators inherently can have more than one consumer, so >>> as long as there are no GPIOs involved in power sequencing and >>> probing devices then things can work. This is how >>> "sc8280xp-lenovo-thinkpad-x13s" works and also how >>> "mt8173-elm-hana" works. >>> >>> End of background from Doug's cover letter. >> >> I think that using "status" is not a good idea, I find that confusing. > > It isn't a hard requirement. The current I2C prober actually just looks > at the node name, which already should be a generic class type. It then > assumes that all the components of the same class that it is supposed > to probe for are on the same bus. I think this is a fair assumption for > replaceable parts connected via ribbon cable or co-layout parts? > Assuming that the parts are on the exact same bus is ok, there has to be a flexibility limit, or this framework will definitely get abused in the wrong ways. >> Perhaps we could have a node like >> >> something { >> device-class-one = <&device1>, <&device2>, <&device3>; >> device-class-two = <&device4>, <&device5>, <&device6>; >> } >> >> so that'd be more or less >> >> hw-prober { >> trackpads = <&tp1>, <&tp2>; >> keyboards = <&kb1>, <&kb2>; >> touchscreens = <&ts1>, <&ts2>; >> } > > This was already nacked by Rob. Oh. Oops. :-) > >> Besides, something else I can suggest here is to make this more generic: actually, >> this issue is spread across way more devices than you maybe think... for example, >> I know of some smartphones that may have the same situation with DSI displays and >> they're sometimes distinguished by an ADC value, sometimes by reading back the >> manufacturer ID (or panel id) through DSI. > > ADC strapping is common. Though we might need some kind of binding about how > to describe the ADC strapping scheme, as this is bound to be different across > boards. > > Reading back from DSI feels problematic to implement. But I don't know much > about DSI ATM. Doug implied in our offline discussion that DSI panels might > have power sequencing requirements that are all over the place. > This is exactly why I think that this should allow a certain kind of "modularity", meaning that subsystems should be able to register their own hook into this: in both cases of ADC and/or DSI readback we're getting into some fairly (less, or more) complicated territory - and it's something that people around each subsystem knows best - and they must have that kind of flexibility and freedom to change the hooked implementation in their own subsystem instead of somewhere else. There would be much more to say about this, but I'm avoiding to write a wall of text because I'm sure that you can read through the lines and can get my point anyway. >> Also, if Chromebooks really need something "special", such as that coreboot sku-id >> parameter, I think that this should be registered externally into the hw prober >> and not embedded inside of the *generic* hw prober driver. >> >> We can even reuse of_device_id instead of inventing a new hw_prober_entry struct... >> >> Idea: >> >> drivers/platform/chrome/cros_of_hw_prober.c >> >> static int cros_sku_hw_prober(struct platform_device *pdev, const void *data) >> { >> ...this is your cros_sku_component_selector() function, anyway... >> } >> >> static const struct of_device_id cros_hw_prober_ids[] = { >> { .compatible = "google,hana", .data = something }, >> { /* sentinel */ } >> }; >> >> static int some_kind_of_early_init_function(something) >> { >> int a,b,c,ret,something; >> >> .. some logic if necessary .. >> >> return of_hw_prober_register(cros_sku_hw_prober, cros_hw_prober_ids); >> } > > This feels a bit too layered, and requires all the board specific code to > have an early init function. I think exposing common helper functions for > boards to implement prober drivers would be better. Then the prober could > also be a module if that made sense. Given that SoC vendors are making > clock controller drivers modules, this doesn't seem very far fetched. > That would as well work - and would be way better than early init. Reading it back now, putting that in a early init function would be counter-productive in general. >> Btw, thanks for starting that. If this will be done the right way, it's going to >> be useful to many, many people. > > Right. I only have a limited view of applications, so input is always welcome. > > Thanks > ChenYu > >> Regards, >> Angelo >> >>> >>> [1] https://lore.kernel.org/all/20230921102420.RFC.1.I9dddd99ccdca175e3ceb1b9fa1827df0928c5101@changeid/ >>> [2] https://lore.kernel.org/linux-mediatek/20231012230237.2676469-1-wenst@chromium.org/ >>> >>> Chen-Yu Tsai (7): >>> of: base: Add of_device_is_fail >>> of: Introduce hardware prober driver >>> arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads >>> as fail >>> arm64: dts: mediatek: mt8173-elm-hana: Add G2touch G7500 touchscreen >>> of: hw_prober: Support Chromebook SKU ID based component selection >>> dt-bindings: arm: mediatek: Remove SKU specific compatibles for Google >>> Krane >>> arm64: dts: mediatek: mt8183-kukui: Merge Krane device trees >>> >>> .../devicetree/bindings/arm/mediatek.yaml | 3 - >>> arch/arm64/boot/dts/mediatek/Makefile | 3 +- >>> .../boot/dts/mediatek/mt8173-elm-hana.dtsi | 20 ++ >>> .../dts/mediatek/mt8183-kukui-krane-sku0.dts | 24 -- >>> .../mediatek/mt8183-kukui-krane-sku176.dts | 24 -- >>> ...ukui-krane.dtsi => mt8183-kukui-krane.dts} | 47 ++- >>> drivers/of/Kconfig | 13 + >>> drivers/of/Makefile | 1 + >>> drivers/of/base.c | 20 ++ >>> drivers/of/hw_prober.c | 314 ++++++++++++++++++ >>> include/linux/of.h | 6 + >>> 11 files changed, 418 insertions(+), 57 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%) >>> create mode 100644 drivers/of/hw_prober.c >>> >>
On Fri, Nov 10, 2023 at 6:12 PM Doug Anderson <dianders@chromium.org> wrote: > > Hi, > > On Thu, Nov 9, 2023 at 5:52 AM Rob Herring <robh+dt@kernel.org> wrote: > > > > > > End of background from Doug's cover letter. > > > > > > I think that using "status" is not a good idea, I find that confusing. > > > > "status" is what defines a device's state in terms of enabled, > > present, available. That's exactly what we're expressing here. > > > > Now, I do not think we should be mixing the device class (e.g. > > touchscreen) into status. I said this on v1, but apparently that was > > not listened to. > > Interesting. I must have missed the "don't mix device class into > status" part. Do you have a link to your post about that? Maybe > there's other stuff I missed... Having the device class stuck at the > end there was at least part of my last post [1] which gathered no > response. https://lore.kernel.org/all/CAL_JsqKK0tjeXNv=a8L3k0AjhCa15XOq1tPWqVod9mycsKXJHg@mail.gmail.com/ "I would not combine the 2 things. Knowing the class/type of the device may be useful independent of your problem." > I think one of the reasons that I felt we needed to mux the device > class into status was that it was going to make the code a lot less > fragile. Everything I've seen indicates that you don't want us to > create a "HW prober" node that could be used to provide relevant > phandles for different classes of devices, so the "HW prober" code > needs to either search through the whole device tree for a status of > "failed-needs-probe" or needs to contain per-board, hardcoded, > fully-qualified paths. > > I don't think we want to include hardcoded, fully-qualified paths in > the code. That would mean that if someone changed a node name > somewhere in the path to one of the devices that we're dealing with > then it would break. Right, nothing should depend on the full path. That's not an ABI just like the device path in sysfs is not (despite what Android HALs do). > So if we're searching the whole device tree for "failed-needs-probe" > then we need to figure out which devices are related to each other. If > a given board has second sources for MIPI panels, touchscreens, and > trackpads then we need to know which of the "failed-needs-probe" > devices are trackpads, which are touchscreens, and which are MIPI > panels. Do you have any suggestions for how we should do that? Maybe > it was in some other thread that I missed? I guess we could have a > board-specific table mapping (compatible + node name + reg) to a > class, but that feels awkward. Node name is supposed to correspond to device class, so why not use that (no path or unit-address.) and nothing else (well, besides "status")? Rob
Hi, On Wed, Nov 15, 2023 at 2:28 PM Rob Herring <robh+dt@kernel.org> wrote: > > > So if we're searching the whole device tree for "failed-needs-probe" > > then we need to figure out which devices are related to each other. If > > a given board has second sources for MIPI panels, touchscreens, and > > trackpads then we need to know which of the "failed-needs-probe" > > devices are trackpads, which are touchscreens, and which are MIPI > > panels. Do you have any suggestions for how we should do that? Maybe > > it was in some other thread that I missed? I guess we could have a > > board-specific table mapping (compatible + node name + reg) to a > > class, but that feels awkward. > > Node name is supposed to correspond to device class, so why not use > that (no path or unit-address.) and nothing else (well, besides > "status")? One problem is that I could imagine having two second source trackpads that both have the same i2c address. That would give them the same name, right? I guess you could maybe come up with some sort of suffix rule? Like trackpad-1@10 { compatible = "elan,blah"; ret = <0x10>; status = "failed-needs-probe"; ... } trackpad-2@10 { compatible = "goodix,gt7375p"; ret = <0x10>; status = "failed-needs-probe"; ... } Then I guess the class would be "trackpad"? -Doug
On Wed, Nov 15, 2023 at 2:45 PM Doug Anderson <dianders@chromium.org> wrote: > > Hi, > > On Wed, Nov 15, 2023 at 2:28 PM Rob Herring <robh+dt@kernel.org> wrote: > > > > > So if we're searching the whole device tree for "failed-needs-probe" > > > then we need to figure out which devices are related to each other. If > > > a given board has second sources for MIPI panels, touchscreens, and > > > trackpads then we need to know which of the "failed-needs-probe" > > > devices are trackpads, which are touchscreens, and which are MIPI > > > panels. Do you have any suggestions for how we should do that? Maybe > > > it was in some other thread that I missed? I guess we could have a > > > board-specific table mapping (compatible + node name + reg) to a > > > class, but that feels awkward. > > > > Node name is supposed to correspond to device class, so why not use > > that (no path or unit-address.) and nothing else (well, besides > > "status")? > > One problem is that I could imagine having two second source trackpads > that both have the same i2c address. That would give them the same > name, right? I guess you could maybe come up with some sort of suffix > rule? Like > > trackpad-1@10 { > compatible = "elan,blah"; > ret = <0x10>; > status = "failed-needs-probe"; > ... > } > trackpad-2@10 { > compatible = "goodix,gt7375p"; > ret = <0x10>; > status = "failed-needs-probe"; > ... > } > > Then I guess the class would be "trackpad"? That issue is somewhat orthogonal because it is not following the spec. I'm not sure mixing the 2 styles of node names is a good idea. While not used too much, matching by node name does ignore the unit-address, but I'm not sure we could ignore a '-N'. I think our options are either add something to the unit-address or use i2c-mux binding. Adding to the unit-address is not unprecedented. I did that for some of the register bit level bindings where you have a node for different bits at the same address. The downside is unit-address is bus specific, so we'd have to add that for multiple buses. For the i2c-mux, it's perhaps a bit complex and I'm not sure what if anything you'd have to do to manage the mux that's not really there. Rob
Hi, On Wed, Nov 15, 2023 at 4:35 PM Rob Herring <robh+dt@kernel.org> wrote: > > On Wed, Nov 15, 2023 at 2:45 PM Doug Anderson <dianders@chromium.org> wrote: > > > > Hi, > > > > On Wed, Nov 15, 2023 at 2:28 PM Rob Herring <robh+dt@kernel.org> wrote: > > > > > > > So if we're searching the whole device tree for "failed-needs-probe" > > > > then we need to figure out which devices are related to each other. If > > > > a given board has second sources for MIPI panels, touchscreens, and > > > > trackpads then we need to know which of the "failed-needs-probe" > > > > devices are trackpads, which are touchscreens, and which are MIPI > > > > panels. Do you have any suggestions for how we should do that? Maybe > > > > it was in some other thread that I missed? I guess we could have a > > > > board-specific table mapping (compatible + node name + reg) to a > > > > class, but that feels awkward. > > > > > > Node name is supposed to correspond to device class, so why not use > > > that (no path or unit-address.) and nothing else (well, besides > > > "status")? > > > > One problem is that I could imagine having two second source trackpads > > that both have the same i2c address. That would give them the same > > name, right? I guess you could maybe come up with some sort of suffix > > rule? Like > > > > trackpad-1@10 { > > compatible = "elan,blah"; > > ret = <0x10>; > > status = "failed-needs-probe"; > > ... > > } > > trackpad-2@10 { > > compatible = "goodix,gt7375p"; > > ret = <0x10>; > > status = "failed-needs-probe"; > > ... > > } > > > > Then I guess the class would be "trackpad"? > > That issue is somewhat orthogonal because it is not following the spec. I'm not sure why you say it's orthogonal. The whole reason why we get into the situation above is that we could have two devices, only one of which is present (hence the status of "failed-needs-probe"), that are the same type and have the same "reg" address. Essentially the whole "failed-needs-probe" is extending the spec, right? While extending the spec, we also need to talk about what to do if some of the devices that we need to probe have the same class and the same "reg". > I'm not sure mixing the 2 styles of node names is a good idea. While > not used too much, matching by node name does ignore the unit-address, > but I'm not sure we could ignore a '-N'. > > I think our options are either add something to the unit-address or > use i2c-mux binding. Adding to the unit-address is not unprecedented. > I did that for some of the register bit level bindings where you have > a node for different bits at the same address. The downside is > unit-address is bus specific, so we'd have to add that for multiple > buses. For the i2c-mux, it's perhaps a bit complex and I'm not sure > what if anything you'd have to do to manage the mux that's not really > there. Somehow it feels weird to use an i2c-mux because there's no real mux present, right? ...so this would be a virtual (bogus) device that doesn't really exist in hardware. ...though I guess if the "mux" type binding is OK then maybe we just use that as the HW prober, at least for i2c devices... -Doug
On Thu, Nov 16, 2023 at 5:35 AM Rob Herring <robh+dt@kernel.org> wrote: > > On Wed, Nov 15, 2023 at 2:45 PM Doug Anderson <dianders@chromium.org> wrote: > > > > Hi, > > > > On Wed, Nov 15, 2023 at 2:28 PM Rob Herring <robh+dt@kernel.org> wrote: > > > > > > > So if we're searching the whole device tree for "failed-needs-probe" > > > > then we need to figure out which devices are related to each other. If > > > > a given board has second sources for MIPI panels, touchscreens, and > > > > trackpads then we need to know which of the "failed-needs-probe" > > > > devices are trackpads, which are touchscreens, and which are MIPI > > > > panels. Do you have any suggestions for how we should do that? Maybe > > > > it was in some other thread that I missed? I guess we could have a > > > > board-specific table mapping (compatible + node name + reg) to a > > > > class, but that feels awkward. > > > > > > Node name is supposed to correspond to device class, so why not use > > > that (no path or unit-address.) and nothing else (well, besides > > > "status")? > > > > One problem is that I could imagine having two second source trackpads > > that both have the same i2c address. That would give them the same > > name, right? I guess you could maybe come up with some sort of suffix > > rule? Like > > > > trackpad-1@10 { > > compatible = "elan,blah"; > > ret = <0x10>; > > status = "failed-needs-probe"; > > ... > > } > > trackpad-2@10 { > > compatible = "goodix,gt7375p"; > > ret = <0x10>; > > status = "failed-needs-probe"; > > ... > > } > > > > Then I guess the class would be "trackpad"? > > That issue is somewhat orthogonal because it is not following the spec. > > I'm not sure mixing the 2 styles of node names is a good idea. While > not used too much, matching by node name does ignore the unit-address, > but I'm not sure we could ignore a '-N'. of_node_name_prefix() solves that. I assume that's the intended use case? > I think our options are either add something to the unit-address or > use i2c-mux binding. Adding to the unit-address is not unprecedented. > I did that for some of the register bit level bindings where you have > a node for different bits at the same address. The downside is > unit-address is bus specific, so we'd have to add that for multiple > buses. For the i2c-mux, it's perhaps a bit complex and I'm not sure > what if anything you'd have to do to manage the mux that's not really > there. > > Rob
On Thu, Nov 16, 2023 at 6:14 AM Doug Anderson <dianders@chromium.org> wrote: > > Hi, > > On Wed, Nov 15, 2023 at 4:35 PM Rob Herring <robh+dt@kernel.org> wrote: > > > > On Wed, Nov 15, 2023 at 2:45 PM Doug Anderson <dianders@chromium.org> wrote: > > > > > > Hi, > > > > > > On Wed, Nov 15, 2023 at 2:28 PM Rob Herring <robh+dt@kernel.org> wrote: > > > > > > > > > So if we're searching the whole device tree for "failed-needs-probe" > > > > > then we need to figure out which devices are related to each other. If > > > > > a given board has second sources for MIPI panels, touchscreens, and > > > > > trackpads then we need to know which of the "failed-needs-probe" > > > > > devices are trackpads, which are touchscreens, and which are MIPI > > > > > panels. Do you have any suggestions for how we should do that? Maybe > > > > > it was in some other thread that I missed? I guess we could have a > > > > > board-specific table mapping (compatible + node name + reg) to a > > > > > class, but that feels awkward. > > > > > > > > Node name is supposed to correspond to device class, so why not use > > > > that (no path or unit-address.) and nothing else (well, besides > > > > "status")? > > > > > > One problem is that I could imagine having two second source trackpads > > > that both have the same i2c address. That would give them the same > > > name, right? I guess you could maybe come up with some sort of suffix > > > rule? Like > > > > > > trackpad-1@10 { > > > compatible = "elan,blah"; > > > ret = <0x10>; > > > status = "failed-needs-probe"; > > > ... > > > } > > > trackpad-2@10 { > > > compatible = "goodix,gt7375p"; > > > ret = <0x10>; > > > status = "failed-needs-probe"; > > > ... > > > } > > > > > > Then I guess the class would be "trackpad"? > > > > That issue is somewhat orthogonal because it is not following the spec. > > I'm not sure why you say it's orthogonal. The whole reason why we get > into the situation above is that we could have two devices, only one > of which is present (hence the status of "failed-needs-probe"), that > are the same type and have the same "reg" address. > > Essentially the whole "failed-needs-probe" is extending the spec, > right? While extending the spec, we also need to talk about what to do > if some of the devices that we need to probe have the same class and > the same "reg". If it's at the same address, then you would need some device specific probing code, like reading a register back and checking if matches some known value. This could be done by passing in some kind of table, but it is by no means as generic as checking if an address responds. This is what we have on MT8186 Tentacruel. We do have the ability to differentiate using the SKU ID for the same address case, but I'm happy to try other methods if it helps everyone else. ChenYu > > I'm not sure mixing the 2 styles of node names is a good idea. While > > not used too much, matching by node name does ignore the unit-address, > > but I'm not sure we could ignore a '-N'. > > > > I think our options are either add something to the unit-address or > > use i2c-mux binding. Adding to the unit-address is not unprecedented. > > I did that for some of the register bit level bindings where you have > > a node for different bits at the same address. The downside is > > unit-address is bus specific, so we'd have to add that for multiple > > buses. For the i2c-mux, it's perhaps a bit complex and I'm not sure > > what if anything you'd have to do to manage the mux that's not really > > there. > > Somehow it feels weird to use an i2c-mux because there's no real mux > present, right? ...so this would be a virtual (bogus) device that > doesn't really exist in hardware. > > ...though I guess if the "mux" type binding is OK then maybe we just > use that as the HW prober, at least for i2c devices... > > -Doug
On Wed, Nov 15, 2023 at 05:13:50PM -0500, Doug Anderson wrote: > Hi, > > On Wed, Nov 15, 2023 at 4:35 PM Rob Herring <robh+dt@kernel.org> wrote: > > > > On Wed, Nov 15, 2023 at 2:45 PM Doug Anderson <dianders@chromium.org> wrote: > > > > > > Hi, > > > > > > On Wed, Nov 15, 2023 at 2:28 PM Rob Herring <robh+dt@kernel.org> wrote: > > > > > > > > > So if we're searching the whole device tree for "failed-needs-probe" > > > > > then we need to figure out which devices are related to each other. If > > > > > a given board has second sources for MIPI panels, touchscreens, and > > > > > trackpads then we need to know which of the "failed-needs-probe" > > > > > devices are trackpads, which are touchscreens, and which are MIPI > > > > > panels. Do you have any suggestions for how we should do that? Maybe > > > > > it was in some other thread that I missed? I guess we could have a > > > > > board-specific table mapping (compatible + node name + reg) to a > > > > > class, but that feels awkward. > > > > > > > > Node name is supposed to correspond to device class, so why not use > > > > that (no path or unit-address.) and nothing else (well, besides > > > > "status")? > > > > > > One problem is that I could imagine having two second source trackpads > > > that both have the same i2c address. That would give them the same > > > name, right? I guess you could maybe come up with some sort of suffix > > > rule? Like > > > > > > trackpad-1@10 { > > > compatible = "elan,blah"; > > > ret = <0x10>; > > > status = "failed-needs-probe"; > > > ... > > > } > > > trackpad-2@10 { > > > compatible = "goodix,gt7375p"; > > > ret = <0x10>; > > > status = "failed-needs-probe"; > > > ... > > > } > > > > > > Then I guess the class would be "trackpad"? > > > > That issue is somewhat orthogonal because it is not following the spec. > > I'm not sure why you say it's orthogonal. The whole reason why we get > into the situation above is that we could have two devices, only one > of which is present (hence the status of "failed-needs-probe"), that > are the same type and have the same "reg" address. I just mean that defining a node name for 2 devices of the same class and at same address is separate problem from selecting which one to enable. > > Essentially the whole "failed-needs-probe" is extending the spec, > right? While extending the spec, we also need to talk about what to do > if some of the devices that we need to probe have the same class and > the same "reg". > > > > I'm not sure mixing the 2 styles of node names is a good idea. While > > not used too much, matching by node name does ignore the unit-address, > > but I'm not sure we could ignore a '-N'. > > > > I think our options are either add something to the unit-address or > > use i2c-mux binding. Adding to the unit-address is not unprecedented. > > I did that for some of the register bit level bindings where you have > > a node for different bits at the same address. The downside is > > unit-address is bus specific, so we'd have to add that for multiple > > buses. For the i2c-mux, it's perhaps a bit complex and I'm not sure > > what if anything you'd have to do to manage the mux that's not really > > there. > > Somehow it feels weird to use an i2c-mux because there's no real mux > present, right? ...so this would be a virtual (bogus) device that > doesn't really exist in hardware. Yes, shrug... > ...though I guess if the "mux" type binding is OK then maybe we just > use that as the HW prober, at least for i2c devices... Except for any other case where it's different addresses or different buses. Maybe different addresses could still use the same thing. I suppose the same class of device is unlikely to be on a different bus. An extension to the unit-address would be the simpler solution, so we should explore that first I think. Rob