From patchwork Wed Aug 16 09:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 714209 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 585BAC001DF for ; Wed, 16 Aug 2023 09:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243604AbjHPJxD (ORCPT ); Wed, 16 Aug 2023 05:53:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243644AbjHPJwk (ORCPT ); Wed, 16 Aug 2023 05:52:40 -0400 Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B5CADF; Wed, 16 Aug 2023 02:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sionneau.net; s=selectormx4; t=1692179535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/bQOVUk1e3G6QvspZ4ulPcqWFNFGRI07zJ9KxOxlZ5w=; b=1rNAHQ1SUAhWqxSCvC9R+pMxQgyEQTeinvPk4eJZalNXYtHeWKPWoKRPVnhDMtpR5ypKRK HBJkg8itrJ4DrX0/+Z19Z/QIlzaEwNKLdXrgnu9Nic6OL0UFN+7lmYQWOfTqgJ+85uQerW aYoxVTdW3pdFlxRBYnBOK8C1TeN8LuE= Received: from fallen-ThinkPad-X260.home ( [109.190.253.11]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id 7e150d35 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 16 Aug 2023 09:52:15 +0000 (UTC) From: Yann Sionneau To: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jan Dabros , Andi Shyti Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Yann Sionneau Subject: [PATCH v2] i2c: designware: add support for pinctrl for recovery Date: Wed, 16 Aug 2023 11:50:15 +0200 Message-Id: <20230816095015.23705-1-yann@sionneau.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Yann Sionneau Currently if the SoC needs pinctrl to switch the SCL and SDA from the I2C function to GPIO function, the recovery won't work. scl-gpio = <>; sda-gpio = <>; Are not enough for some SoCs to have a working recovery. Some need: scl-gpio = <>; sda-gpio = <>; pinctrl-names = "default", "recovery"; pinctrl-0 = <&i2c_pins_hw>; pinctrl-1 = <&i2c_pins_gpio>; The driver was not filling rinfo->pinctrl with the device node pinctrl data which is needed by generic recovery code. Tested-by: Yann Sionneau Signed-off-by: Yann Sionneau --- V1 -> V2: * remove the unnecessary 'if (!rinfo->pinctrl)' test * test if return is -EPROBE_DEFER, in that case, return it. * Reword the commit message according to review drivers/i2c/busses/i2c-designware-master.c | 10 ++++++++++ 1 file changed, 10 insertions(+) base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421 diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c index 3bfd7a2232db..b45accbff915 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -905,6 +906,15 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev) return PTR_ERR(gpio); rinfo->sda_gpiod = gpio; + rinfo->pinctrl = devm_pinctrl_get(dev->dev); + if (IS_ERR(rinfo->pinctrl)) { + if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER) + return PTR_ERR(rinfo->pinctrl); + + rinfo->pinctrl = NULL; + dev_info(dev->dev, "can't get pinctrl, bus recovery might not work\n"); + } + rinfo->recover_bus = i2c_generic_scl_recovery; rinfo->prepare_recovery = i2c_dw_prepare_recovery; rinfo->unprepare_recovery = i2c_dw_unprepare_recovery;