From patchwork Tue Apr 12 08:50:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Whitchurch X-Patchwork-Id: 560117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A9D5C433F5 for ; Tue, 12 Apr 2022 10:13:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232141AbiDLKPY (ORCPT ); Tue, 12 Apr 2022 06:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351898AbiDLJmd (ORCPT ); Tue, 12 Apr 2022 05:42:33 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 760465548E; Tue, 12 Apr 2022 01:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1649753457; x=1681289457; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qPE0cAEK4Wc/D+HUkql/yGqGenPvs1X2rgbcrD3CHyo=; b=Sc8gyDZtRU4/xVNmwqKCzXG4HyM4qvQO6BdHfl4xJbPMlYgGpx865gB1 O5jLQfpE9mTCtMfFGeua4vWx866foXTULMIAW//5S6QYOpD0k6woTP9Ez htF8SzsIu2vwQ57lAYcDgMvIDkP1wixqhZjl4uDNjaUNhmLU0O75ljpCX iK14B7ElyAO3mNzsbpjWAqZk9BVjriw0UlZFip8Nqwa70xVAfTNl7dNJe /uclWPIzEGVLUHSnq1DJw0uxbXRDAb9GIqhiZGof2daliJHOfgi9yj9x9 8rSCewopVHGd4Nw84SJFBCRmZ4QiZ0zHQpMGE56UcAtaRKzsuy0xyrgbq g==; From: Vincent Whitchurch To: CC: , Vincent Whitchurch , , , , , Subject: [PATCH v2 1/2] dt-bindings: i2c: add property to avoid device detection Date: Tue, 12 Apr 2022 10:50:45 +0200 Message-ID: <20220412085046.1110127-2-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220412085046.1110127-1-vincent.whitchurch@axis.com> References: <20220412085046.1110127-1-vincent.whitchurch@axis.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org When drivers with ->detect callbacks are loaded, the I2C core does a bunch of transactions to try to probe for these devices, regardless of whether they are specified in the devicetree or not. (This only happens on I2C controllers whose drivers enable the I2C_CLASS* flags, but this is the case for generic drivers like i2c-gpio.) These kinds of transactions are unnecessary on systems where the devicetree specifies all the devices on the I2C bus, so add a property to indicate that the devicetree description of the hardware is complete and thus allow this discovery to be disabled. Signed-off-by: Vincent Whitchurch --- Notes: v2: - Change subject prefix - Reword description of property Documentation/devicetree/bindings/i2c/i2c.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt b/Documentation/devicetree/bindings/i2c/i2c.txt index fc3dd7ec0445..960d1d5c9362 100644 --- a/Documentation/devicetree/bindings/i2c/i2c.txt +++ b/Documentation/devicetree/bindings/i2c/i2c.txt @@ -72,6 +72,10 @@ wants to support one of the below features, it should adapt these bindings. this information to adapt power management to keep the arbitration awake all the time, for example. Can not be combined with 'single-master'. +- no-detect + states that no other devices are present on this bus other than the + ones listed in the devicetree. + - pinctrl add extra pinctrl to configure SCL/SDA pins to GPIO function for bus recovery, call it "gpio" or "recovery" (deprecated) state From patchwork Tue Apr 12 08:50:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Whitchurch X-Patchwork-Id: 560116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 232ABC433EF for ; Tue, 12 Apr 2022 10:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237762AbiDLKP3 (ORCPT ); Tue, 12 Apr 2022 06:15:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351629AbiDLJmd (ORCPT ); Tue, 12 Apr 2022 05:42:33 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AFB952E51; Tue, 12 Apr 2022 01:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1649753455; x=1681289455; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uLQdlfAQXlCN4pf6t7na9yusjUfO4K5tqg+Dz7YUDFM=; b=Rr4kEVfRpFsMjSaJj/0JFOFNCi8+JOAdv6lqvppuw5AS2jvUp1il8T7f j7mNOyFEO0TM+JiQYcD5RfuTUO1tWMGKpMtAA8Hi0OkYChMgIhpVD3fg4 Qrv3bP+NZhEROqKfIjP/sO4UHmJDGhrvs9xu2Exal3vRZH7IWa21X6a5+ 6OsI00oMHRqcFOH09wnr6WXqJR4Oly4KUnzSR/J3gP5uMdhCyYK/C6u0X UgUrvdT+1uOTMej86LF2+0dszNno9Ve7yFVsDZb/baXLYbasuQ754Fq9R 44IpE9R6jtqbJ+NCl0JFYOtv9E6FFU0jcVDLIVNtGWbelhD6T6ROPnr0R Q==; From: Vincent Whitchurch To: CC: , Vincent Whitchurch , , , , , Subject: [PATCH v2 2/2] i2c: core: support no-detect property Date: Tue, 12 Apr 2022 10:50:46 +0200 Message-ID: <20220412085046.1110127-3-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220412085046.1110127-1-vincent.whitchurch@axis.com> References: <20220412085046.1110127-1-vincent.whitchurch@axis.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org If the devicetree specifies the no-detect property, we know that there are no other devices on the bus other than the ones listed in the devicetree, so avoid calling drivers' detect callback and wasting time probing for devices which do not exist. Signed-off-by: Vincent Whitchurch --- drivers/i2c/i2c-core-base.c | 8 +++++++- include/linux/i2c.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index d43db2c3876e..d43025b84546 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1341,7 +1341,8 @@ static int i2c_do_add_adapter(struct i2c_driver *driver, struct i2c_adapter *adap) { /* Detect supported devices on that bus, and instantiate them */ - i2c_detect(adap, driver); + if (adap->detect) + i2c_detect(adap, driver); return 0; } @@ -1432,6 +1433,7 @@ EXPORT_SYMBOL_GPL(i2c_handle_smbus_host_notify); static int i2c_register_adapter(struct i2c_adapter *adap) { + struct device_node *np = adap->dev.of_node; int res = -EINVAL; /* Can't register until after driver model init */ @@ -1502,6 +1504,10 @@ static int i2c_register_adapter(struct i2c_adapter *adap) "Failed to create compatibility class link\n"); #endif + adap->detect = true; + if (np && of_property_read_bool(np, "no-detect")) + adap->detect = false; + /* create pre-declared device nodes */ of_i2c_register_devices(adap); i2c_acpi_install_space_handler(adap); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index fbda5ada2afc..8fad5fe85685 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -728,6 +728,7 @@ struct i2c_adapter { struct rt_mutex bus_lock; struct rt_mutex mux_lock; + bool detect; int timeout; /* in jiffies */ int retries; struct device dev; /* the adapter device */