From patchwork Tue Aug 4 09:59:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Codrin Ciubotariu X-Patchwork-Id: 11700165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B0EE413B1 for ; Tue, 4 Aug 2020 10:00:15 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B5A37206F6 for ; Tue, 4 Aug 2020 10:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ncVsONqu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="GiwMud1U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5A37206F6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=QaAEJhyKymbSYPiajJaLJMmYCkwVCKbFV/dYZ8tiluU=; b=ncVsONqu0oU/EE+SDUWCKXkiI5 kMa10xew4+rEjB/WoMY83TcCePz5PG1b2FtSFCuJO8m5I4GOI7UqONDwsI9vEC3i6gYIkdrAx+JSJ NqToAbAC6pEnwyguvaNzte1ExZG60bprMyON1IcqHId6nEKT3QEGrBMGRUHfAidjza0cqPtK2krY8 Vi6nIUVvWCVIrSlFk5hHttZ+IIaxEX857IuTUnZrNLYgO6OHunTgzhC/s84IVjGKJ6NPp2lBRAMD/ M+/FBuWEPzkHlupcgpykUoh50mrz5efMgU6g5uAcWb3qOXhLcPkY2FUsNlmKJOV6sarLPOiY/IkPG 3s+7Yuqg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2tjh-00043d-Ds; Tue, 04 Aug 2020 09:59:57 +0000 Received: from esa5.microchip.iphmx.com ([216.71.150.166]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2tjf-00042X-3r for linux-arm-kernel@lists.infradead.org; Tue, 04 Aug 2020 09:59:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1596535195; x=1628071195; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GTtso34T+c/2IIFCa0TTcMqhENR3/ROdcVBd3KrCKhw=; b=GiwMud1U2tPSt/2hEzSNQ3Ruz4NdFhYCG+/Y+jFh26dwWrziyuVHbRa6 nhNxTrpiQK8h90hVWKhypY/+CqSySEXm3g91fTMiSV22GOvAmunUu8Dlz 1cmP9uhYfzJ6HzZE0vOijCW6mt0SNtlLCoOiaDAyZrHPabS99Apouw6zR rCxHkzYS/HGjaw0/lOG/9bWsC5bU6F5Lu+HC0p8WNBOQnw807/HYvs2UT L7Gg7k9nm3moaqvVzaHgK1kgk48nQCrzPZLGLASPKkHL2HfYNKtaee/TD vpR4dLr+1ejlyfd84VJoM7PamrpQT6jzwz0ft5Lp9/GDO3AQ3ocpZJyww Q==; IronPort-SDR: u84SfLNWqiorX/pxS0wI7QF1VuB+j1TEr37drBBn1mKkKB1G4JeaEW4wdni1nT1WWUZ5EcQ85j 86tA8LXavAVAq58faDRYEEXGFLjaYT7Gjnlx5FsDmPJY1yoL9DtDEKjHYfrUjt17C4rNIpjA9C WaAcu167kSNUj7OVz7SOMrjm0gy1fXBviNHQUUVN/b9DN2veFI2jl8nLW5KB6lrORup7e/1IYW 7ji/li+qKJ7MsRRf35zKals6FAfY3EaimyT6VKsi42QtIMv6aDNiq4rNwLSggb2n7Dz9banJW9 fPc= X-IronPort-AV: E=Sophos;i="5.75,433,1589266800"; d="scan'208";a="85757564" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Aug 2020 02:59:48 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 4 Aug 2020 02:59:45 -0700 Received: from rob-ult-m19940.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Tue, 4 Aug 2020 02:59:35 -0700 From: Codrin Ciubotariu To: , , , Subject: [PATCH 0/4] i2c: core: add generic GPIO bus recovery Date: Tue, 4 Aug 2020 12:59:22 +0300 Message-ID: <20200804095926.205643-1-codrin.ciubotariu@microchip.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200804_055955_296211_24C81BE7 X-CRM114-Status: GOOD ( 12.42 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.150.166 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [216.71.150.166 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamel.bouhara@bootlin.com, alexandre.belloni@bootlin.com, linux@armlinux.org.uk, wsa@kernel.org, ludovic.desroches@microchip.com, robh+dt@kernel.org, Codrin Ciubotariu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org GPIO recovery has been added already for some I2C bus drivers, such as imx, pxa and at91. These drivers use similar bindings and have more or less the same code for recovery. For this reason, we aim to move the GPIO bus recovery implementation to the I2C core so that other drivers can benefit from it, with small modifications. This implementation initializes the pinctrl states and the SDA/SCL GPIOs based on common bindings. The I2C bus drivers can still use different bindings or other particular recovery steps if needed. The ugly part with this patch series is the handle of PROBE_DEFER which could be returned by devm_gpiod_get(). This changes things a little for i2c_register_adapter() and for this reason this step is implemented in a sperate patch. The at91 Microchip driver is the first to use this implementation, with an AI to move the rest of the drivers in the following steps. This patch series was previously sent as a RFC. Significant changes since RFC: - "recovery" pinctrl state marked as deprecared in bindings; - move to "gpio" pinctrl state done after the call to prepare_recovery() callback; - glitch protection when SDA gpio is taken at initialization; Codrin Ciubotariu (4): dt-binding: i2c: add generic properties for GPIO bus recovery i2c: core: add generic I2C GPIO recovery i2c: core: treat EPROBE_DEFER when acquiring SCL/SDA GPIOs i2c: at91: Move to generic GPIO bus recovery Documentation/devicetree/bindings/i2c/i2c.txt | 10 ++ drivers/i2c/busses/i2c-at91-master.c | 69 +------- drivers/i2c/busses/i2c-at91.h | 3 - drivers/i2c/i2c-core-base.c | 150 ++++++++++++++++-- include/linux/i2c.h | 11 ++ 5 files changed, 163 insertions(+), 80 deletions(-)