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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BFCA5EB64D7 for ; Tue, 13 Jun 2023 23:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=igzxIxpOF85svQWwJ0MY6agEHm0CWksH77rf7vmsRFk=; b=RkT1Xue4TMCujO oph8e/ODzStcEse3Iu91TgydTXB7d0mxQR+EV3hJuPS0TYzc2yWgYktr7KQtFwXl2vzB91JPOopY5 zZ5SoHgMTbujg33Ds712DMsZX6OytwsWsJR8S44dJ6a9LkIkST4SE1XSFQps71t2shXnlJHE99dv3 hzzEL2sfEjy9VKQn7nLmkXm2KM3120/DpUh/oRu1+TLTHWbGR5MCf9s3+GqKPDdpGH3uI4SHGN+hu pUiJA1VGpTLJus1M4o5PQlyGJrTfvzsvk8Dim7AMPe7vgbOuc3F7y6Zc0gX0skkdwxq9UXAiBgl3X y2xjy7T6Flbb7tEB62Og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9DIw-009POR-1u; Tue, 13 Jun 2023 23:20:02 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9DIr-009PMK-1r for linux-arm-kernel@lists.infradead.org; Tue, 13 Jun 2023 23:20:01 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1BE162F35; Tue, 13 Jun 2023 23:19:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92ADAC433C8; Tue, 13 Jun 2023 23:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686698392; bh=00coPlPXq6Ktp19aty/LWQkO7wWlaavBkvbNCMX5SbQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=egp3dL+4CxEETZh0irhPP7WF+JjV8Pa97+xdQA7mFDesH95x5MA9mr+mxuJ3fXh0y 1Y0aSHmjopW0HBd/CHN/WrJJ4F1jiFBvwa3OmhenyHy8SVvTOv8YLodquyAZCBYU9l uVZevqEC4x1ZokS/BUg/V9e+b92LWRdITkox7MnYbRZwXGChUZa2Eyb7jOf4vj+2Go mene99vWxPTpUgT7MGmc0fTLg8Lle+lFKC16AbllacoTr2T1L4q48yZSW7gr3oaQeM lnFdOxbY2sqMtnIcBBwYYhaFO+dom0BkPNum3SomYa3e19bGY9dZmNUwn/cg1M3Cr/ CNtKb2A5KqZnw== Date: Wed, 14 Jun 2023 01:19:48 +0200 From: Andi Shyti To: carlos.song@nxp.com Cc: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, Anson.Huang@nxp.com, xiaoning.wang@nxp.com, haibo.chen@nxp.com, linux-imx@nxp.com, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] i2c: imx-lpi2c: add bus recovery feature Message-ID: <20230613231948.bsxuou4nnwbg2ui5@intel.intel> References: <20230529074302.3612294-1-carlos.song@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230529074302.3612294-1-carlos.song@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230613_161958_284623_32BB9F4C X-CRM114-Status: GOOD ( 22.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Mon, May 29, 2023 at 03:43:01PM +0800, carlos.song@nxp.com wrote: > From: Clark Wang > > Add bus recovery feature for LPI2C. > Need add gpio pinctrl, scl-gpios and sda-gpios configuration in dts. please update the commit message according to the dts changes, as well. [...] > +static void lpi2c_imx_prepare_recovery(struct i2c_adapter *adap) > +{ > + struct lpi2c_imx_struct *lpi2c_imx; > + > + lpi2c_imx = container_of(adap, struct lpi2c_imx_struct, adapter); > + > + pinctrl_select_state(lpi2c_imx->pinctrl, lpi2c_imx->pinctrl_pins_gpio); > +} > + > +static void lpi2c_imx_unprepare_recovery(struct i2c_adapter *adap) > +{ > + struct lpi2c_imx_struct *lpi2c_imx; > + > + lpi2c_imx = container_of(adap, struct lpi2c_imx_struct, adapter); > + > + pinctrl_select_state(lpi2c_imx->pinctrl, lpi2c_imx->pinctrl_pins_default); > +} > + > +/* > + * We switch SCL and SDA to their GPIO function and do some bitbanging > + * for bus recovery. These alternative pinmux settings can be > + * described in the device tree by a separate pinctrl state "gpio". If is this still true? > + * this is missing this is not a big problem, the only implication is > + * that we can't do bus recovery. > + */ > +static int lpi2c_imx_init_recovery_info(struct lpi2c_imx_struct *lpi2c_imx, > + struct platform_device *pdev) > +{ > + struct i2c_bus_recovery_info *rinfo = &lpi2c_imx->rinfo; > + > + lpi2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev); > + if (!lpi2c_imx->pinctrl || IS_ERR(lpi2c_imx->pinctrl)) { > + dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); > + return PTR_ERR(lpi2c_imx->pinctrl); > + } > + > + lpi2c_imx->pinctrl_pins_default = pinctrl_lookup_state(lpi2c_imx->pinctrl, > + PINCTRL_STATE_DEFAULT); > + lpi2c_imx->pinctrl_pins_gpio = pinctrl_lookup_state(lpi2c_imx->pinctrl, > + "gpio"); > + rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN); > + rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl", GPIOD_OUT_HIGH_OPEN_DRAIN); > + > + if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER || > + PTR_ERR(rinfo->scl_gpiod) == -EPROBE_DEFER) { > + return -EPROBE_DEFER; > + } else if (IS_ERR(rinfo->sda_gpiod) || > + IS_ERR(rinfo->scl_gpiod) || > + IS_ERR(lpi2c_imx->pinctrl_pins_default) || > + IS_ERR(lpi2c_imx->pinctrl_pins_gpio)) { > + dev_dbg(&pdev->dev, "recovery information incomplete\n"); > + return 0; > + } Why not use these assignement from the default i2c_init_recovery()? Is there anything you are doing I am not seeing? > + > + dev_info(&pdev->dev, "using scl%s for recovery\n", > + rinfo->sda_gpiod ? ",sda" : ""); is there any case when sda_gpiod is NULL? > + > + rinfo->prepare_recovery = lpi2c_imx_prepare_recovery; > + rinfo->unprepare_recovery = lpi2c_imx_unprepare_recovery; > + rinfo->recover_bus = i2c_generic_scl_recovery; > + lpi2c_imx->adapter.bus_recovery_info = rinfo; do you need also the set_scl() function? It should be mandatory. > + > + return 0; > +} Besides, this is a copy/paste from i2c-imx.c, any chance to put the two things together? Andi _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel