From patchwork Tue Nov 28 08:42:30 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: 1869190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=PVg+vAbG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-i2c+bounces-498-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sfbcp6tVCz1yS6 for ; Tue, 28 Nov 2023 19:45:14 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 82F99B2140B for ; Tue, 28 Nov 2023 08:45:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1086199C7; Tue, 28 Nov 2023 08:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PVg+vAbG" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A216A1A3 for ; Tue, 28 Nov 2023 00:45:06 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d00689f5c8so324655ad.3 for ; Tue, 28 Nov 2023 00:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701161106; x=1701765906; darn=vger.kernel.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=kHxxwveZDRAPnfOWumxXktb5k7NbUjKgtDpJO55ZaA8=; b=PVg+vAbG5Eli/fKzjnqSzq3QEwBSoaN9bOYtemv4oCkYgNDbXV7U2P5Sz7GwuxRSwY cAWt8nh6n4Jqufzl4cYLtzzmNGOkzTHSGqJkWIWElJlOwJPUV59MYPgi9Qy0+oqrYyZb EBV/JQsIk7XOGsrA7Mavoiqn8zqa1sW9x2hnk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701161106; x=1701765906; 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=kHxxwveZDRAPnfOWumxXktb5k7NbUjKgtDpJO55ZaA8=; b=kofo3v1jT9XyKp9V84SnqwesxC7qzvgo1IoGrs1Q2N9dO/JMmLu7LCW2CcCzTF4mFT T6Z0gK2cU1PjO8FqwHM8tXECShecu56LbDFdKuC7EmY6EQiRF5pX1jT84ZMlP/qAR1cL rskgf1HcsdcLl/Y9vOHeOQVFbLD4bNIjWzh5AOtO7JiGt6jVM8Bvh/lk3rsjSQAgVp4m +ChcBdUdBX6OGrekjsj7hjA+B7Dzl9FfR9A98+OiiYm0LcAbGPtEi3aryZlivHsxtbhO pykYT24EvoEbY3gcYUyjGwuUu5QPaBg5anEjdCaLsBCZPJP5SLffhZ8OJw2owpAHa1/x YUnw== X-Gm-Message-State: AOJu0YxUzVJHuVyEoZjAVB57SHiJbzjv59/LnGzfPjFO4OiUjBpbbScZ vzPXU+g3Cf1V/Ph5c1GnaLA/cw== X-Google-Smtp-Source: AGHT+IFwNRanqg6iNjPiAn8C7xAInJUbYOtL1AJjn6XOh76hm70XQlF/qqZTYAqMlV2R/DvAZERpiQ== X-Received: by 2002:a17:902:d2c1:b0:1cf:ccc3:c9d7 with SMTP id n1-20020a170902d2c100b001cfccc3c9d7mr7924520plc.3.1701161106024; Tue, 28 Nov 2023 00:45:06 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:a990:1e95:a915:9c70]) by smtp.gmail.com with ESMTPSA id j1-20020a170902c08100b001ab39cd875csm8358074pld.133.2023.11.28.00.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:45:05 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih Cc: Chen-Yu Tsai , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold , 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, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [RFC PATCH v3 1/5] of: dynamic: Add of_changeset_update_prop_string Date: Tue, 28 Nov 2023 16:42:30 +0800 Message-ID: <20231128084236.157152-2-wenst@chromium.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128084236.157152-1-wenst@chromium.org> References: <20231128084236.157152-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a helper function to add string property updates to an OF changeset. This is similar to of_changeset_add_prop_string(), but instead of adding the property (and failing if it exists), it will update the property. This shall be used later in the DT hardware prober. Signed-off-by: Chen-Yu Tsai --- New patch added in v3. --- drivers/of/dynamic.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 3 +++ 2 files changed, 50 insertions(+) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index f63250c650ca..d22aad938667 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -1039,3 +1039,50 @@ int of_changeset_add_prop_u32_array(struct of_changeset *ocs, return ret; } EXPORT_SYMBOL_GPL(of_changeset_add_prop_u32_array); + +static int of_changeset_update_prop_helper(struct of_changeset *ocs, + struct device_node *np, + const struct property *pp) +{ + struct property *new_pp; + int ret; + + new_pp = __of_prop_dup(pp, GFP_KERNEL); + if (!new_pp) + return -ENOMEM; + + ret = of_changeset_update_property(ocs, np, new_pp); + if (ret) { + kfree(new_pp->name); + kfree(new_pp->value); + kfree(new_pp); + } + + return ret; +} + +/** + * of_changeset_update_prop_string - Add a string property update to a changeset + * + * @ocs: changeset pointer + * @np: device node pointer + * @prop_name: name of the property to be updated + * @str: pointer to null terminated string + * + * Create a string property to be updated and add it to a changeset. + * + * Return: 0 on success, a negative error value in case of an error. + */ +int of_changeset_update_prop_string(struct of_changeset *ocs, + struct device_node *np, + const char *prop_name, const char *str) +{ + struct property prop; + + prop.name = (char *)prop_name; + prop.length = strlen(str) + 1; + prop.value = (void *)str; + + return of_changeset_update_prop_helper(ocs, np, &prop); +} +EXPORT_SYMBOL_GPL(of_changeset_update_prop_string); diff --git a/include/linux/of.h b/include/linux/of.h index 6a9ddf20e79a..c69bc7da380e 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1601,6 +1601,9 @@ static inline int of_changeset_add_prop_u32(struct of_changeset *ocs, { return of_changeset_add_prop_u32_array(ocs, np, prop_name, &val, 1); } +int of_changeset_update_prop_string(struct of_changeset *ocs, + struct device_node *np, + const char *prop_name, const char *str); #else /* CONFIG_OF_DYNAMIC */ static inline int of_reconfig_notifier_register(struct notifier_block *nb) From patchwork Tue Nov 28 08:42:31 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: 1869191 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gmHJQWie; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-i2c+bounces-499-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sfbcv5Qhdz1yS6 for ; Tue, 28 Nov 2023 19:45:19 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 81170B21651 for ; Tue, 28 Nov 2023 08:45:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15D85199C7; Tue, 28 Nov 2023 08:45:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gmHJQWie" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D604A10C1 for ; Tue, 28 Nov 2023 00:45:11 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1cfbda041f3so21645215ad.2 for ; Tue, 28 Nov 2023 00:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701161111; x=1701765911; darn=vger.kernel.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=rrIzkF3BPgnSgOC4+jRg+GY/s6tE7F98s9pAwcg2bLw=; b=gmHJQWieuKvv+lZayWffijw/IQ+TkyU2V+mDe5qluwQihRNeS0D4D/H9HEOvqYZWNi tzgSxYTj75/rmyctOyeQEf3EHZnqmB0BX7RiYVAdZohgqHUn+9yMdxMFkl2skvL9GUdT euFhX+aMC+2R66t6wban6eLSmjopA0XgKWiCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701161111; x=1701765911; 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=rrIzkF3BPgnSgOC4+jRg+GY/s6tE7F98s9pAwcg2bLw=; b=WqaiN1dEanPEaefXr/iYICUzcb9/TIMtMjjFq/UaWPPFvcqYSaarqY4bzzMqoNC1yk Ai/7qLtRWM5sJbKC+LtVdz07GgVAJFpd4tuJdv2ja6UTjYQue+ygnEM4nS7F3Mj+cGUZ zCjro2m1MTM67neoNd3qnYKEbH/QGkE18Tubu4XDR+EnwcVcyrgQAjK0wgqPkjpubZaF Wyd30z+KT9aLf69XHaMSv9ZSpQa6VAlNWyhjXnShuQtf4nT8WBOmDl/PX5tH2ckPyPoZ yCmn78AavYQIDfdvgwpEyChF6+PQppizth/MJ581emuxQDRTX0TMjlWkF8d7GSqTlFzs ChSQ== X-Gm-Message-State: AOJu0YxysP1oR8OBVjQAuxHIUDmkJ1tByi5XBPn1frMc9hnmrJwYHqFF +cIunNfH6q3HaZswC6ndOA+SwQ== X-Google-Smtp-Source: AGHT+IEJ8bYtjQkgtD3EytEtczIspfAvOpqGUCTKBUGdEVYLqzk3kuxJ5+ccBoS4ivRCvYA3p8TkZg== X-Received: by 2002:a17:903:1ce:b0:1cf:c518:fa39 with SMTP id e14-20020a17090301ce00b001cfc518fa39mr7406158plh.19.1701161111196; Tue, 28 Nov 2023 00:45:11 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:a990:1e95:a915:9c70]) by smtp.gmail.com with ESMTPSA id j1-20020a170902c08100b001ab39cd875csm8358074pld.133.2023.11.28.00.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:45:10 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih Cc: Chen-Yu Tsai , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold , 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, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [RFC PATCH v3 2/5] i2c: of: Introduce component probe function Date: Tue, 28 Nov 2023 16:42:31 +0800 Message-ID: <20231128084236.157152-3-wenst@chromium.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128084236.157152-1-wenst@chromium.org> References: <20231128084236.157152-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 probe. function For a 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". 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 --- Changes since v2: - New patch split out from "of: Introduce hardware prober driver" - Addressed Rob's comments - Move i2c prober to i2c subsystem - Use of_node_is_available() to check if node is enabled. - Use OF changeset API to update status property - Addressed Andy's comments - Probe function now accepts "struct device *dev" instead to reduce line length and dereferences - Move "ret = 0" to just before for_each_child_of_node(i2c_node, node) --- drivers/i2c/i2c-core-of.c | 110 ++++++++++++++++++++++++++++++++++++++ include/linux/i2c.h | 4 ++ 2 files changed, 114 insertions(+) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index a6c407d36800..3a0b4986c585 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -217,4 +217,114 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, struct notifier_block i2c_of_notifier = { .notifier_call = of_i2c_notify, }; + +/* + * Some devices, such as Google Hana Chromebooks, are produced by multiple + * vendors each using their preferred components. Such components are all + * in the device tree. Instead of having all of them enabled and having each + * driver separately try and probe its device while fighting over shared + * resources, they can be marked as "fail-needs-probe" and have a prober + * figure out which one is actually used beforehand. + * + * This prober assumes such drop-in parts are on the same I2C bus, have + * non-conflicting addresses, and can be directly probed by seeing which + * address responds. + * + * TODO: + * - Support handling common regulators and GPIOs. + * - Support I2C muxes + */ + +/** + * i2c_of_probe_component() - probe for devices of "type" on the same i2c bus + * @dev: &struct device of the caller, only used for dev_* printk messages + * @type: a string to match the device node name prefix to probe for + * + * Probe for possible I2C components of the same "type" on the same I2C bus + * that have their status marked as "fail". + */ +int i2c_of_probe_component(struct device *dev, const char *type) +{ + struct device_node *node, *i2c_node; + struct i2c_adapter *i2c; + struct of_changeset *ocs = NULL; + int ret; + + node = of_find_node_by_name(NULL, type); + if (!node) + return dev_err_probe(dev, -ENODEV, "Could not find %s device node\n", type); + + i2c_node = of_get_next_parent(node); + if (!of_node_name_eq(i2c_node, "i2c")) { + of_node_put(i2c_node); + return dev_err_probe(dev, -EINVAL, "%s device isn't on I2C bus\n", type); + } + + for_each_child_of_node(i2c_node, node) { + if (!of_node_name_prefix(node, type)) + continue; + if (of_device_is_available(node)) { + /* + * Device tree has component already enabled. Either the + * device tree isn't supported or we already probed once. + */ + 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(dev, -EPROBE_DEFER, "Couldn't get I2C adapter\n"); + } + + ret = 0; + for_each_child_of_node(i2c_node, node) { + union i2c_smbus_data data; + u32 addr; + + if (!of_node_name_prefix(node, type)) + 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(dev, "Enabling %pOF\n", node); + + ocs = kzalloc(sizeof(*ocs), GFP_KERNEL); + if (!ocs) { + ret = -ENOMEM; + goto err_put_node; + } + + /* Found a device that is responding */ + of_changeset_init(ocs); + ret = of_changeset_update_prop_string(ocs, node, "status", "okay"); + if (ret) + goto err_free_ocs; + ret = of_changeset_apply(ocs); + if (ret) + goto err_destroy_ocs; + + of_node_put(node); + break; + } + + i2c_put_adapter(i2c); + of_node_put(i2c_node); + + return 0; + +err_destroy_ocs: + of_changeset_destroy(ocs); +err_free_ocs: + kfree(ocs); +err_put_node: + of_node_put(node); + return ret; +} +EXPORT_SYMBOL_GPL(i2c_of_probe_component); #endif /* CONFIG_OF_DYNAMIC */ diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 0dae9db27538..75fbbd5a4b15 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -997,6 +997,10 @@ const struct of_device_id int of_i2c_get_board_info(struct device *dev, struct device_node *node, struct i2c_board_info *info); +#if IS_ENABLED(CONFIG_OF_DYNAMIC) +int i2c_of_probe_component(struct device *dev, const char *type); +#endif + #else static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) From patchwork Tue Nov 28 08:42:32 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: 1869192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=m27szb8L; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-i2c+bounces-500-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sfbd04ktRz1yS6 for ; Tue, 28 Nov 2023 19:45:24 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3F6A7B21731 for ; Tue, 28 Nov 2023 08:45:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61C77199B2; Tue, 28 Nov 2023 08:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="m27szb8L" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A9FD10E7 for ; Tue, 28 Nov 2023 00:45:17 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6cbe6d514cdso4224796b3a.1 for ; Tue, 28 Nov 2023 00:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701161116; x=1701765916; darn=vger.kernel.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=W8/TdtPK7mZHmPEMzqlWjR5HwzhRhEqW5dnoF8OBNcQ=; b=m27szb8LxKARre4eazapdHG3ArkqLpOcvNNIFBH8kxUG6vmSzX2a9revgy+8tQVUbx itpJ1RHDege9HG9CCdktKupNQccZnI9PJ4JLCbilNUzimUJKK2KVJ/HJBWEhOA3UzFkI S8I1Qv9hoGC1ODJzoT/JxGk6jSRwwLH+VwQNE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701161116; x=1701765916; 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=W8/TdtPK7mZHmPEMzqlWjR5HwzhRhEqW5dnoF8OBNcQ=; b=vHyMEZnEBiYi/EJBAG2pdbgxdZCSgjGfgoGcUbe2spuRItX+Sl+YOqh3sgdslC7i/I WRw0fiNYjegD3nT/PohaxoMdoc0NdVgz+oygeGoFkRbQ1vBi1SVbUQwhGRpEmWa15J1w /2Y66PHIv5SKPufdovz/anbuYrK+ick8ysyB5u2yHynSV+aSAjZDUKP4GcBIL/vj504i u+rD2hAQRlFW569z9WR/eNPV8I9UGCxw3APl59jk2Ilcq7DljOhqGxJZr4EaSkV4PGbT y4s77L016gBYRDS/WfBZt0405fRJhuLJxRcMnPVUIPsD69uDwpZ9HBiOuamvF8KzXATb SmOQ== X-Gm-Message-State: AOJu0YyiM2iFQ7nVS6C+jpU0sEimNf0gIj2Kkm75N2aZgQndli6gGvvS jjD40fHLmCCCTK2mmgIyb7KOgQ== X-Google-Smtp-Source: AGHT+IG6UzF6jCgkNYomISFp5LxHRmJmbSt0cMuJU32MtFDCyOlf9c7ui7iv5r+wF6dwufogT4B1GQ== X-Received: by 2002:a05:6a20:d48d:b0:189:dc00:cf85 with SMTP id im13-20020a056a20d48d00b00189dc00cf85mr14610135pzb.36.1701161116308; Tue, 28 Nov 2023 00:45:16 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:a990:1e95:a915:9c70]) by smtp.gmail.com with ESMTPSA id j1-20020a170902c08100b001ab39cd875csm8358074pld.133.2023.11.28.00.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:45:15 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih Cc: Chen-Yu Tsai , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold , 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, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [RFC PATCH v3 3/5] platform/chrome: Introduce device tree hardware prober Date: Tue, 28 Nov 2023 16:42:32 +0800 Message-ID: <20231128084236.157152-4-wenst@chromium.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128084236.157152-1-wenst@chromium.org> References: <20231128084236.157152-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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". 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 --- Changes since v2: - Addressed Rob's comments - Move remaining driver code to drivers/platform/chrome/ - Depend on rather than select CONFIG_I2C - Copy machine check to driver init function - Addressed Andy's comments - Explicitly mention "device tree" or OF in driver name, description and Kconfig symbol - Drop filename from inside the file - Switch to passing "struct device *" to shorten lines - Move "ret = 0" to just before for_each_child_of_node(i2c_node, node) - Make loop variable size_t (instead of unsigned int as Andy asked) - Use PLATFORM_DEVID_NONE instead of raw -1 - Use standard goto error path pattern in hw_prober_driver_init() - Changes since v1: - New patch --- drivers/platform/chrome/Kconfig | 11 +++ drivers/platform/chrome/Makefile | 1 + .../platform/chrome/chromeos_of_hw_prober.c | 89 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 drivers/platform/chrome/chromeos_of_hw_prober.c diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index 7a83346bfa53..aa161f2f09e3 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig @@ -61,6 +61,17 @@ config CHROMEOS_TBMC To compile this driver as a module, choose M here: the module will be called chromeos_tbmc. +config CHROMEOS_OF_HW_PROBER + bool "ChromeOS Device Tree Hardware Prober" + depends on OF + depends on I2C + select OF_DYNAMIC + default OF + help + This option enables the device tree hardware prober for ChromeOS + devices. The driver will probe the correct component variant in + devices that have multiple drop-in options for one component. + config CROS_EC tristate "ChromeOS Embedded Controller" select CROS_EC_PROTO diff --git a/drivers/platform/chrome/Makefile b/drivers/platform/chrome/Makefile index 2dcc6ccc2302..21a9d5047053 100644 --- a/drivers/platform/chrome/Makefile +++ b/drivers/platform/chrome/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_CHROMEOS_ACPI) += chromeos_acpi.o obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o obj-$(CONFIG_CHROMEOS_PRIVACY_SCREEN) += chromeos_privacy_screen.o obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o +obj-$(CONFIG_CHROMEOS_OF_HW_PROBER) += chromeos_of_hw_prober.o obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o obj-$(CONFIG_CROS_EC) += cros_ec.o obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o diff --git a/drivers/platform/chrome/chromeos_of_hw_prober.c b/drivers/platform/chrome/chromeos_of_hw_prober.c new file mode 100644 index 000000000000..13aaad6382aa --- /dev/null +++ b/drivers/platform/chrome/chromeos_of_hw_prober.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ChromeOS Device Tree Hardware Prober + * + * Copyright (c) 2023 Google LLC + */ + +#include +#include +#include +#include + +#define DRV_NAME "chromeos_of_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 device *dev, const void *data); + const void *data; +}; + +static int chromeos_i2c_component_prober(struct device *dev, const void *data) +{ + const char *type = data; + + return i2c_of_probe_component(dev, type); +} + +static const struct hw_prober_entry hw_prober_platforms[] = { + { .compatible = "google,hana", .prober = chromeos_i2c_component_prober, .data = "touchscreen" }, + { .compatible = "google,hana", .prober = chromeos_i2c_component_prober, .data = "trackpad" }, +}; + +static int chromeos_of_hw_prober_probe(struct platform_device *pdev) +{ + for (size_t 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->dev, + hw_prober_platforms[i].data); + if (ret) + return ret; + } + + return 0; +} + +static struct platform_driver chromeos_of_hw_prober_driver = { + .probe = chromeos_of_hw_prober_probe, + .driver = { + .name = DRV_NAME, + }, +}; + +static int __init chromeos_of_hw_prober_driver_init(void) +{ + struct platform_device *pdev; + size_t i; + int ret; + + for (i = 0; i < ARRAY_SIZE(hw_prober_platforms); i++) + if (of_machine_is_compatible(hw_prober_platforms[i].compatible)) + break; + if (i == ARRAY_SIZE(hw_prober_platforms)) + return 0; + + ret = platform_driver_register(&chromeos_of_hw_prober_driver); + if (ret) + return ret; + + pdev = platform_device_register_simple(DRV_NAME, PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(pdev)) + goto err; + + return 0; + +err: + platform_driver_unregister(&chromeos_of_hw_prober_driver); + + return PTR_ERR(pdev); +} +device_initcall(chromeos_of_hw_prober_driver_init); From patchwork Tue Nov 28 08:42:33 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: 1869193 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=SwGzLlVx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-i2c+bounces-501-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sfbd85Pgkz1yS6 for ; Tue, 28 Nov 2023 19:45:32 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 79DBF2816CE for ; Tue, 28 Nov 2023 08:45:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 895C5199C4; Tue, 28 Nov 2023 08:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SwGzLlVx" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1430719A8 for ; Tue, 28 Nov 2023 00:45:22 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1cfafe3d46bso28840295ad.0 for ; Tue, 28 Nov 2023 00:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701161121; x=1701765921; darn=vger.kernel.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=/Y9ycKtKFTX/BTOyRnkXgZtClc28FDD42zjunKgTjuA=; b=SwGzLlVxYnuU6rAgNgj3DZrhO26TdPHjJsVmCM/NrZV6DUC8GIS7AFsMT86M2+orCe sOha5G6nntDkOommdQkSqmgGX9tdr8zhz/5p/xn+mFv+Cr1pHv7mBI/1ddtNYsH9T/fA U3piRgAPk5ZbvU3l9vvmiLjvgpH1fM/NSV884= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701161121; x=1701765921; 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=/Y9ycKtKFTX/BTOyRnkXgZtClc28FDD42zjunKgTjuA=; b=jSSyk5zXDfRAXCIZsS2GTULhMEZUH50X6cNhIKQ8cYKo0Rq506yKEL4Uqm0WPsTXdu DlekhMVgZikjPHPDf1J8tXPkhHxgxR3prV6U+nMaM/2/NHkGbEsmXaC9vQuVGXHRDqAi G6uI4FT0qgT3rHuPPe76sqMGQaMCuNdwh2hR0SDCNkBFd9yXbYKWvYoLjnQjQ0efrW5a 57ZOmFLtt2qxBAbjRUJj2Fdwq8JVt3BYp6Y8naA0PzvKt61hlWBiZfkwlDLgAAeJCym/ SanJNwB6+B9SEUjcn+3TrilzVA4Jdm6NmBHgIAO800R2/gWHVicR0LK2A4hy7OWh77pY 0heA== X-Gm-Message-State: AOJu0YxsXEzlLtjD1VNvwhTNOHFjlzUQlwEKfqMu8OmtlEOSgkiGi/+A GkILXjSQ98o46gMqI29Ns6Omrw== X-Google-Smtp-Source: AGHT+IH69IcUw69JVhOmNdkKKnr/r6NBV02lgRCYBJhyyb9MW19+XXMSc7tXlITs3/tx986s7x1SPg== X-Received: by 2002:a17:902:f54d:b0:1cf:b3d2:5f18 with SMTP id h13-20020a170902f54d00b001cfb3d25f18mr13659883plf.56.1701161121540; Tue, 28 Nov 2023 00:45:21 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:a990:1e95:a915:9c70]) by smtp.gmail.com with ESMTPSA id j1-20020a170902c08100b001ab39cd875csm8358074pld.133.2023.11.28.00.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:45:21 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih Cc: Chen-Yu Tsai , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold , 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, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [RFC PATCH v3 4/5] arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads as fail Date: Tue, 28 Nov 2023 16:42:33 +0800 Message-ID: <20231128084236.157152-5-wenst@chromium.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128084236.157152-1-wenst@chromium.org> References: <20231128084236.157152-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- Changes since v2: - Drop class from status --- 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..1d68bc6834e4 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"; }; /* @@ -28,6 +29,7 @@ touchscreen3: touchscreen@20 { hid-descr-addr = <0x0020>; interrupt-parent = <&pio>; interrupts = <88 IRQ_TYPE_LEVEL_LOW>; + status = "fail-needs-probe"; }; }; @@ -44,6 +46,7 @@ trackpad2: trackpad@2c { reg = <0x2c>; hid-descr-addr = <0x0020>; wakeup-source; + status = "fail-needs-probe"; }; }; @@ -68,3 +71,11 @@ pins_wp { }; }; }; + +&touchscreen { + status = "fail-needs-probe"; +}; + +&trackpad { + status = "fail-needs-probe"; +}; From patchwork Tue Nov 28 08:42:34 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: 1869194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=M7OCSlHr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-i2c+bounces-502-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SfbdP22MVz1yS6 for ; Tue, 28 Nov 2023 19:45:45 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 09BFEB21AC9 for ; Tue, 28 Nov 2023 08:45:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6124C199CC; Tue, 28 Nov 2023 08:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="M7OCSlHr" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A96B919A7 for ; Tue, 28 Nov 2023 00:45:27 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cf856663a4so36006265ad.3 for ; Tue, 28 Nov 2023 00:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701161126; x=1701765926; darn=vger.kernel.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=dxKs9xH99OQyNQM5ja7w5sBqIVdDZ2l2tkwooD9gc1c=; b=M7OCSlHrgPke0dbRqhyKdV1U2j9DpXjb4BCazCV3m+84qXU2FL1ddycrfXCIqHph/f ho6kJGxPgWAnRHqRtJAJRY2tqfLbYFoAVS5FClxouPLTXDerBCtgJN1NI8jPG81stcAm tovPvDMh9jBVtmUBDucEX24Dj789D8LC366RQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701161126; x=1701765926; 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=dxKs9xH99OQyNQM5ja7w5sBqIVdDZ2l2tkwooD9gc1c=; b=tnOMjdl6BOsIU2TUDphW9C1BBZ/LxQVW0gzk6Zc0AT2Dg1va1mB9eeO7OAsF/G8ksY qXEQylaU6Flsieiu5FGXpLPXlWmH67eGyMbzEOY6t60N+EeTF2F5Ux/wGLDqfXmxgd0a hF+eW/lvEbnDsuO0F44FkVb5yBEfCqa++wVGIEnPiyRrXXA7ognl/v8JN0T2Rwd24fim U9zLfcJ29o5GURsG4nMCA35cTwZn+Zf0VDTqFB1gjiLPfs5ir0w68m0X2voxWmcOTwNY QWOAaTBROtnAH7vxZEPaLCQ8zzTx2OBS9GDTB5ZNlg9Uqw9p56dzNfZajUb0bOu7MArw et/w== X-Gm-Message-State: AOJu0YyjRuJxhu3vLW7rRVFL/XMgAv5MIW809pRpdiWDyTG4+BdzPh17 iyf/MCtBA1Ggs7UeRCsENHQP3w== X-Google-Smtp-Source: AGHT+IEHq/8o8TRy8LBy9PDIxcsp3BaVE1rQDjyRLP/di+1I1g3a9pBwAwe3ppG7Mgw8ZIdwK6eHKA== X-Received: by 2002:a17:902:988b:b0:1cf:b130:e9af with SMTP id s11-20020a170902988b00b001cfb130e9afmr10074896plp.20.1701161126645; Tue, 28 Nov 2023 00:45:26 -0800 (PST) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:a990:1e95:a915:9c70]) by smtp.gmail.com with ESMTPSA id j1-20020a170902c08100b001ab39cd875csm8358074pld.133.2023.11.28.00.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 00:45:26 -0800 (PST) From: Chen-Yu Tsai To: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih Cc: Chen-Yu Tsai , chrome-platform@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Douglas Anderson , Johan Hovold , 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, rafael@kernel.org, tglx@linutronix.de, Jeff LaBundy , linux-input@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [RFC PATCH v3 5/5] arm64: dts: mediatek: mt8173-elm-hana: Add G2touch G7500 touchscreen Date: Tue, 28 Nov 2023 16:42:34 +0800 Message-ID: <20231128084236.157152-6-wenst@chromium.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128084236.157152-1-wenst@chromium.org> References: <20231128084236.157152-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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". Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Drop class from status --- 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 1d68bc6834e4..216d8b43be05 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"; }; + + 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"; + }; }; &i2c4 {