Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4417818rdh; Wed, 29 Nov 2023 00:24:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHP5bdzFJAUrWmtyxvLgHYR3dUwwENI3F7vndjjLpegQ9NGZKw7iLHh6RfdlF/6gI+nfBch X-Received: by 2002:a17:90b:3504:b0:280:5b33:d30 with SMTP id ls4-20020a17090b350400b002805b330d30mr19198111pjb.44.1701246261475; Wed, 29 Nov 2023 00:24:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701246261; cv=none; d=google.com; s=arc-20160816; b=Bz4NoarC8bEVaOt90UJe17+wsaMNLfOiBP041P3rxvkA2amkB5gP5kvRcN5xoi5X1Q FJXPBfrUEIkHh6ZNav20AxrOGL2HHZrL4l99bnBvxbAnIXQPEnZ08dP+ok2iCRYQFZ1v 6Slg+hV0RIPaKjohgACkp33MvMh19VsC+C1g2FJd6h6TeoqUa2tbmyxCIsHUey7RN+SO EBqk2tzLuhMTW8x7dRagrX11AIzQTdB4hGCXTsPzhHrAPGFam1c1k8wN46zsPLKR9Cnz OxlpsfYVwucmbP65pf7hFbnNE5cr2oTEIg03E0mUEp9SAHAjoloLmNkqKdaj49MSU8x/ o8GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=k7+haveSoq7m2f2Pj8HBweyY+n64mswSOvsdXSe1aV8=; fh=gR4/X/s1l+FakwDPWFQ3rskOCjXO+B88ygTwZVaq+70=; b=GbcHExxDKZwZvHp6deQo/ADYwNJB3yPDZImoCPcVam4ia6/SMrEIWyphU6aZxOBTRV bNSsHb2EXO/m8vH9H8F9Ux7XKsU4mXWpcO0ZgX5XToJTyIPO8AYYa/Z1ZYV7vAekAC+S eFRmLc45636TEsQ5OWJoRLECbUT00V6FRDY2jL0WTOvqtmuiwdStbQvp8dbhuEf6bwdc KPP29lzii8KZPI/aulJHEeTh0t8mFF/VjJjlJTYqMvWVDZiqtvyU6yp1YEsDI3s6bb3f tgufUR0XRu/AP9PIl8oIDX5+FKmMg06q96JOafYHRiowG2RlgGXCBCRSS09E4t0DVtGD n5PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hjdvXDGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id s5-20020a17090aad8500b0028586287439si816881pjq.93.2023.11.29.00.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:24:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hjdvXDGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 99C278061154; Wed, 29 Nov 2023 00:24:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbjK2IXt (ORCPT + 99 others); Wed, 29 Nov 2023 03:23:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjK2IXs (ORCPT ); Wed, 29 Nov 2023 03:23:48 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B37C19B1 for ; Wed, 29 Nov 2023 00:23:54 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50bc39dcbcbso896197e87.1 for ; Wed, 29 Nov 2023 00:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701246232; x=1701851032; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=k7+haveSoq7m2f2Pj8HBweyY+n64mswSOvsdXSe1aV8=; b=hjdvXDGDD08RCKyP1WgixBq2jpGt75z1x6E/hpnjKvO7mKkV9cul30JkBYKnQ8FVV3 rL9BZ0tLuidlItrJOCVz+4pzpl7A9pD0LR0NcsdWdJlcMg9fYT+1y52vF+S345lXc8Da Gxql1X2l8GdOWSv/ZL9gGe2uMW7kc2aPHmfko= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701246232; x=1701851032; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k7+haveSoq7m2f2Pj8HBweyY+n64mswSOvsdXSe1aV8=; b=iYB7kNMfyk6eiVaMnqB3KLkHeDV/E6Z+Z/oeD2S8+EmWS31SFgxQgmYtMTQFwyeBoN gpiks4vVf5s5Dm3aeNzK7ACepdodhD68JXVFHLXya3nY1MsfT+FFERl7G1eTZshy0pDC aTJcbMvTPTW1n9xQ6kKO2Na+PJpBMnHTMB6eC6hR0YPp8/jGdiCnxj/dv0ve1vZxdlaK GDnNpHk7TDy+hDpxhUZdbFGKSi9sgkNQkCSQNoMW/uBeAF4NrnTc/HRLIflrWJ+CjiJZ 6crs/L+irPWUTH6JNro6laeXS1zdr/lTHEBLKYxsuHpsVg6rv98vuAbz6/CyuOw3OxLM G/1w== X-Gm-Message-State: AOJu0Yxbaj4thVAiE+oeWv0NaOb86I0RNR3RARshbVVG6yZBJDTwkj4D SQT/l4RK9RrQRwqDg+obpzH6ZAtP9fGuH2ykYsRdKw== X-Received: by 2002:a05:6512:3081:b0:507:a1dd:5a86 with SMTP id z1-20020a056512308100b00507a1dd5a86mr12720343lfd.13.1701246232561; Wed, 29 Nov 2023 00:23:52 -0800 (PST) MIME-Version: 1.0 References: <20231128084236.157152-1-wenst@chromium.org> <20231128084236.157152-4-wenst@chromium.org> In-Reply-To: From: Chen-Yu Tsai Date: Wed, 29 Nov 2023 16:23:41 +0800 Message-ID: Subject: Re: [RFC PATCH v3 3/5] platform/chrome: Introduce device tree hardware prober To: Andy Shevchenko Cc: Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Wolfram Sang , Benson Leung , Tzung-Bi Shih , 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 , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 00:24:18 -0800 (PST) On Wed, Nov 29, 2023 at 12:26=E2=80=AFAM Andy Shevchenko wrote: > > On Tue, Nov 28, 2023 at 04:42:32PM +0800, Chen-Yu Tsai wrote: > > 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 devic= e > > 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 prob= e > > function. This works, but has been broken before due to the introductio= n > > 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 see= n > > 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. > > ... > > > +#include > > +#include > > +#include > > +#include > > init.h for init calls. Added to next version. > > +static int chromeos_of_hw_prober_probe(struct platform_device *pdev) > > +{ > > + for (size_t i =3D 0; i < ARRAY_SIZE(hw_prober_platforms); i++) > > + if (of_machine_is_compatible(hw_prober_platforms[i].compa= tible)) { > > + int ret; > > Perhaps > > if (!of_machine_is_compatible(hw_prober_platforms[i].comp= atible)) > continue; > > ? Works for me. One less level of indentation. Thanks ChenYu > > + ret =3D hw_prober_platforms[i].prober(&pdev->dev, > > + hw_prober_pla= tforms[i].data); > > + if (ret) > > + return ret; > > + } > > + > > + return 0; > > +} > > -- > With Best Regards, > Andy Shevchenko > >