Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3971380rdh; Tue, 28 Nov 2023 08:26:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdRkN4cMsgtcCIUzS4k1Zjcwy+s30gES08YPfINHHWlp2Y7RSVk7cCkDrQfvzDR/a7jXt2 X-Received: by 2002:a17:90a:68c3:b0:283:21d3:11ea with SMTP id q3-20020a17090a68c300b0028321d311eamr18504332pjj.0.1701188777132; Tue, 28 Nov 2023 08:26:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701188777; cv=none; d=google.com; s=arc-20160816; b=lgY7ub9moY1cXe7Tm/XEigxzP2c1GbGbPoEOTOQGDzOsQLBseBkuJ6GzHhyXXptMp7 NEF65l4CdUiBoYNF6qmgEuTWv+Kz+QYDacRTx4WlktMF4+9iDtZN8dyjxHoI6BTjlkOC KjRbyo8mdCMOoI4S2Xm6Fi5HFKUYgkZRFxnhNrB4K2LBRPK3s6qGhc3WlVDon/x5TzQ3 tKXeYg0tPcc8jKqNC8/kzusjKwCfIqW0NJOp/D5iXqoWBtY90N536dtavkHx8+gL3r1F 2Krv+IajjeMQMdO4ebaWcEdiN/MUrmrkuFOx+FqJv59tRJZzZZ1g5nC2XVOSfNzWnqRb 4c4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=W1ywWWTIjPTvPOiE3I/U/Ertmn0SdcywoKEnpfUiiAw=; fh=vJXqLCk7KqNiEu6k8x6/1vHH1YINZbvFunKohfp2mnA=; b=KmlD/q07Piq2koi2xwUB4cl+qdKa+bWdsdrbtba4DQTl8/Lf+6F04QRaaQiNtBiuoW vlT14u57VmdMH6O37YB2iGemKR9t8EP91rQmFccHWm6dzyOKYaloUzrjG+B0bCh44ePE vNVQUdtecu3bZEMqCwYFf6YOebK8fIpCSk+cjtep8CseMVQaF7tk8kEnfiAljxeiIT0r nL9qz1IAMJE8WQ6IV1EdL5J8PmIraw2+LWS6MwJmP2lcIIbmTn/90fuK7/2RPJWPDOkN Win/K4gLDOhvrDHc9p0ZEwZr+nMg7HDk5HaFRdss1huumBw8TzbnyZRYmnTnVfIlghtY cWYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bSPbZ9c5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h13-20020a17090adb8d00b002764fc15dd3si12807812pjv.37.2023.11.28.08.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:26:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bSPbZ9c5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id EC7B38131C1D; Tue, 28 Nov 2023 08:26:13 -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 S229691AbjK1QZ4 (ORCPT + 99 others); Tue, 28 Nov 2023 11:25:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjK1QZz (ORCPT ); Tue, 28 Nov 2023 11:25:55 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD3898; Tue, 28 Nov 2023 08:26:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701188761; x=1732724761; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=WQHZ+PbGGa3aDyciuChblMvLCm0dgXzHSZ5ktHj28m0=; b=bSPbZ9c5azkxLWG50D9N/FTbgfbLDO07LBiAGTDa9/q5ZQX9xKXE7g08 CGrq06Ltpnq4h+T3siVS8D361QlVFX9QZIvUDJ0N6EY+ZcdRCKxVkTV5r GJMfCEZPHGxfbiIsRSwOwtz9OAAAVeMem9eDeI6bfTEEqBC2Yn2onzcmB Tcy7S/bUTqrf++B5w0hoT+yxndYZf4G8SnYmSB4tlP2jHO3Og3NvNIzTf Fj8tLMqr7Td0LrNao3A8p84X5egw1ioTiAKUAnKdHbcBYkQJA6R+LxpRW QzXLJiiRt39+skzrwcxFdnT25Lk7eULZtGJCL+xT6oElKVFnX7+b1Auk6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="424106462" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="424106462" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 08:26:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="768577278" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="768577278" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 08:25:51 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1r80uB-00000000CyG-1z99; Tue, 28 Nov 2023 18:25:47 +0200 Date: Tue, 28 Nov 2023 18:25:47 +0200 From: Andy Shevchenko To: Chen-Yu Tsai 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 Subject: Re: [RFC PATCH v3 3/5] platform/chrome: Introduce device tree hardware prober Message-ID: References: <20231128084236.157152-1-wenst@chromium.org> <20231128084236.157152-4-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231128084236.157152-4-wenst@chromium.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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]); Tue, 28 Nov 2023 08:26:14 -0800 (PST) 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 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. ... > +#include > +#include > +#include > +#include init.h for init calls. > +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; Perhaps if (!of_machine_is_compatible(hw_prober_platforms[i].compatible)) continue; ? > + ret = hw_prober_platforms[i].prober(&pdev->dev, > + hw_prober_platforms[i].data); > + if (ret) > + return ret; > + } > + > + return 0; > +} -- With Best Regards, Andy Shevchenko