From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,PDS_BTC_ID, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD0C5C43603 for ; Fri, 6 Dec 2019 17:36:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 966312245C for ; Fri, 6 Dec 2019 17:36:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gfoPp+6h"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="1VwSy8yk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 966312245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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:Subject:To:From :Date: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=VSpGvdEUKjxNyjxRqPfVp6/JBEzlzxgZn7q7BTM4nYg=; b=gfoPp+6hHnQJKK lsbqUSm7oMf5m3ToPyRiKtbQ83aNbHZ/461V53U/P1dfmCBCK5JZeBThOk/fddltetTN83XT2nsXU Gv4Ytjky3uIPbU6iaoWIhcGbjcu5BmirOLE9jMjNUGj1bNoeFpHA1SRObznYvoqlUZW75KTuZUt5B hX2jgH1VV7N+GTZLlWapiKol/rCRwRWKFhqmOUvUh57WHte4czZ+//VUQetsoutGn7t9O3ky8p288 O3HRUUklWykXdg70hcRP/AngEU/uWVs7eIOpWMfC13FHPyB4gl5rg7GjF4ozIC7+Itr7EbkYbbofu Pnb6XuX4QxnNFtLP4whA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1idHWO-00037X-8l; Fri, 06 Dec 2019 17:36:04 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1idHWJ-0001ei-KW for linux-arm-kernel@lists.infradead.org; Fri, 06 Dec 2019 17:36:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:Content-Type:MIME-Version: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=I5DvSSUq8kBmzZvYKJavtYFkUBKlP3+nbcIZ+mewhp8=; b=1VwSy8ykjbEMabTB7ELm4Qgpg GpcDhQiyMp/9vzKyNtwmiFAntC1d4Heie8TuaYq9avhyZeeNU0qqGaf+p/rw1P0OHKRSqqr5+UkIA SMtxLhU9/sYY4+ygfoOz5KAf833aZ26Jt9GZATurl4FR2IXkSrW/DsOsA57a2EQ/K2ynFxbNsN4qm EgsAyuYIhe/bgqmREgvhrLrdMys0w+rHERM2Dm5G197Dt6gpBKDC6pynqqlpDh0oHFn0vJFlKtT7V LYVpY9ppSnXHkDBM0ozxzL2xusCCw6thn4HE6m3eJ2331DA5qGJrCIU2i5wRy2/9dNC29Bsbx1Z/I hMH7R++5Q==; Received: from shell.armlinux.org.uk ([2002:4e20:1eda:1:5054:ff:fe00:4ec]:45226) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1idHU8-00020S-MW; Fri, 06 Dec 2019 17:33:44 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1idHU7-0000qM-If; Fri, 06 Dec 2019 17:33:43 +0000 Date: Fri, 6 Dec 2019 17:33:43 +0000 From: Russell King - ARM Linux admin To: Linus Walleij Subject: pinctrl states vs pinmux vs gpio (i2c bus recovery) Message-ID: <20191206173343.GX25745@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191206_093559_832176_3D1D5BB0 X-CRM114-Status: GOOD ( 11.51 ) 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: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Linus, There seems to be a problem in pinctrl land when pinctrls interact with GPIOs. If, for example, an I2C driver wants to attempt bus recovery, and needs to use GPIO mode to control the I2C bus pins to do this, then one may expect code such as found in i2c_imx_init_recovery_info() to work. However, consider that devm_gpiod_get() may invoke pinctrl_gpio_request(), which changes the pinmux settings independently of the pinctrl layer. The result is that after devm_gpiod_get() has completed, the I2C bus pins are in GPIO mode. One may expect: pinctrl_select_state(i2c_imx->pinctrl, i2c_imx->pinctrl_pins_default); to change them back to the default state, but that would be incorrect. The first thing that pinctrl_select_state() does is check whether p->state == state which it will do, as the pinctrl layer hasn't been informed of the change that has happened behind its back at the pinmux level. The result is, one needs to switch the state to gpio mode, and then back to default to ensure that the pins are muxed back to the I2C controller while the I2C controller is supposed to be operational. GPIO mode is only used to recover the bus when a bus hang has happened due to a slave device holding SDA low - and the only way that can be recovered is by toggling the SCL signal. If the controller provides no means to do this other than switching to GPIO mode, the above is necessary. I spotted this while trying out this method of i2c bus recovery on a different I2C controller. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel