Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3969317rdh; Tue, 28 Nov 2023 08:23:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzCF3NIfdKhIhD+lQDCzv1C5qSXQ3aG+9puXs9V/E9bMaPqLRELqvRTY5pDxIq3qxXQU2/ X-Received: by 2002:a17:90b:3b90:b0:285:cc9c:74e7 with SMTP id pc16-20020a17090b3b9000b00285cc9c74e7mr7114390pjb.8.1701188586971; Tue, 28 Nov 2023 08:23:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701188586; cv=none; d=google.com; s=arc-20160816; b=Cphn3yzbIHeFelDn37ugTcgyyXWTvBsPuyFT0eIocgyxqnYjPq3GFo87xcqbC0gEtx b6YnDnX2OltIh0A9rc16mf+drSd9XQhJcTHaNSpUOYCxbp5Co2vFUGu/pa/gjZ64xPU9 eEqR5fWBX2niOLA13MhUKmofrN45MBcxt+BAwYbszlnxLtduHar22ceYQe4Drl+YH0rG xRVi+n7+qrn36sP9IYY6KvMuLsmGso4BO19+UJJzn6crCu7Xn9k8D17/Ln1JlYnrVcyt bJBfUvszRVFPPQFR8K+5DuaWtA+RjaL1gopFt02jlAj1onWU1qNzw5fxGr40c1j5/NXb pxaA== 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=oM1WikqvsGuyS04S7WH2pwhVf8EnhlYOnFbjP1TtNYM=; fh=vJXqLCk7KqNiEu6k8x6/1vHH1YINZbvFunKohfp2mnA=; b=DoE6N+bEFkSqyd4ESYaxHiWR+Sd6Afa4KhilhT4f4knOabPkkg34BvHlOfMJxsmFZW lAdSWUC6sdIT2BfA3ilRL6/1z4FHAmDtrb9JpN/iMLj9stgLexLE011RBCKKA0LQAcOH yFlqKflaZRehs8BEajkcP8Mwy5lM4tSyx3++3VTYlDxIWHEBLXn2YhNH7ejJJMhXckVK 6ZcGiFesSVPVHOhg36ItJClmaXztiOCFPgNN4UqEc2zZiAcXk95icQiYqQL1lsROV05T fAwv2pOGK4kpgqHBDzqIG8k/GsUi/2O4lkCGCHp+RQzj4veyWRIbWvibqJogdNT/K1cs 8G2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ibPnxvJO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s18-20020a17090aad9200b0028604307fedsi1075778pjq.97.2023.11.28.08.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:23:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ibPnxvJO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id CA5EE8225CAC; Tue, 28 Nov 2023 08:23:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344274AbjK1QWp (ORCPT + 99 others); Tue, 28 Nov 2023 11:22:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjK1QWn (ORCPT ); Tue, 28 Nov 2023 11:22:43 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03A7F131; Tue, 28 Nov 2023 08:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701188570; x=1732724570; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=gE5J7qstsZ3WcDaR4Cb/bPac5/L+CEn93CqYK6zcnMA=; b=ibPnxvJOQTBzo3VzRYJ8p3jD1jA/V1xB0jKzJHAB4YNZ00YfpepQBW5I /jas0JfMkhVdgOkIuDn9UYPGx/yTrihE5K+WcXI6VtLbTQ+yZKFCpnR4Z kpZNOneLW8NvfAh+Afq24xiJwDbpKYb8XISNA5gIpbo0dGDh/f99gb4qZ 1p92Cq8lSoOwL/kdbC3azA75sTQHj/3TPFlORzY57N8NffhgVkaWCYHeZ 9HXuP0jnb0xB0l/NghmGYpIYsgtdF9S5xgfWE9Nqcf3uoKaDqNXEnZAuA ip7A/cYA/cNzIWq9F482NvIIuceJZhp4caC0heQ/fHpTRTiZIbyqmykNd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="459461899" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="459461899" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 08:22:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="1015938153" X-IronPort-AV: E=Sophos;i="6.04,234,1695711600"; d="scan'208";a="1015938153" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 08:22:40 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1r80r6-00000000CwM-3RK7; Tue, 28 Nov 2023 18:22:36 +0200 Date: Tue, 28 Nov 2023 18:22:36 +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 2/5] i2c: of: Introduce component probe function Message-ID: References: <20231128084236.157152-1-wenst@chromium.org> <20231128084236.157152-3-wenst@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231128084236.157152-3-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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 08:23:03 -0800 (PST) On Tue, Nov 28, 2023 at 04:42:31PM +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 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. ... > +/** > + * 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". Definitely you haven't run kernel-doc validation. > + */ ... > + return dev_err_probe(dev, -ENODEV, "Could not find %s device node\n", type); I haven't noticed clear statement in the description that this API is only for the ->probe() stages. ... > + if (i2c_smbus_xfer(i2c, addr, 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data) < 0) > + continue; This will require the device to be powered on. Are you sure it will be always the case? -- With Best Regards, Andy Shevchenko