Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp562038rdh; Tue, 22 Aug 2023 04:31:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIjvztw8SX9lWmChu+uRlrwgwfPUkmarx1GdbsrTT/JqSOs1cPEDsi+fJska9430m/AXNv X-Received: by 2002:a17:902:fe83:b0:1b8:76ce:9d91 with SMTP id x3-20020a170902fe8300b001b876ce9d91mr5414467plm.1.1692703892072; Tue, 22 Aug 2023 04:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692703892; cv=none; d=google.com; s=arc-20160816; b=DpUwNqEHYz/gy03u/R5PhPmyKlzIFgh1Gvy5exXgss2Xm5+ByV31L5Zw1Q5ErSXe1M 5TZZ+oNv6maVorXfIKXdeJ6sQm5hpXnS1b0HaOYOvCdiQD9/dD/d9JHlp59575BVgfuh rziKXfXifpItmPSSLCxdbMJSz7Im6ab9kn/6j3/trXD6XhrCYT1Cu4h7k66JsZq4Kj4e oHE+MuFyMAl8Rs00TscU1HjFMbKQeAmiGwfpYwrlgs/eqD2ZgLQZPYh9G4RMJ3fGKiVb i3SMCTlqcMsJegT2hr2raZrR/w7sv2f3shP9nRmZGkx6xoBgst8xlUTeyA+Rl/p/pcvb 93wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=I4ekdu82EN3ncP5XdH1McsW/F5ZpXAiWmznQLRZhwpk=; fh=mG8JK5O8r0Xb4UuxJ3TgUl3687HAjOPkNqwdLPrxGQE=; b=C6orB7L+92pvpuyIVXZjYioru99Dwyp087d7EmKwmGWK5/kYbhwkzOrTCfVDamTzb4 wu3/7jITwFWz24JcZw4RjFnel+lxJSC3PPu0DceJ6ceQDyGlW/zvoVt4L36uXOh2wcAr MXcYnjQ7AW5yt8LzBbbmcZZ6yolpMnwk4SJvmWYxzHG5BkDiCQuyHSGkQjtMPyL8kC9d QgQcz/8gG+noXwZbQ3wMhDFO3wWcQYJ7R+wilV6ujd83/O0xb1Jmfo+I5cwjjWik+zyN dSzv9/9r5okmeOsObwWuT8H86z0UF0N0jDzEIbzsdUtqPDqeVqLWMxYQ3KtTPJkbSlOe p0Sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=kalray.eu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a170903108d00b001bbdd44bba8si8150521pld.645.2023.08.22.04.31.19; Tue, 22 Aug 2023 04:31:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=kalray.eu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234228AbjHVJQH (ORCPT + 99 others); Tue, 22 Aug 2023 05:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234202AbjHVJQG (ORCPT ); Tue, 22 Aug 2023 05:16:06 -0400 X-Greylist: delayed 394 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 22 Aug 2023 02:16:01 PDT Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79B2C189; Tue, 22 Aug 2023 02:16:01 -0700 (PDT) Received: from junon.lin.mbt.kalray.eu ( [217.181.231.53]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id 837e536d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 22 Aug 2023 09:15:59 +0000 (UTC) From: Yann Sionneau To: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Julian Vetter Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Yann Sionneau Subject: [PATCH v3] Currently if the SoC needs pinctrl to switch the SCL and SDA from the I2C function to GPIO function, the recovery won't work. Date: Tue, 22 Aug 2023 11:15:55 +0200 Message-Id: <20230822091555.18015-1-ysionneau@kalray.eu> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_FAIL,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Yann Sionneau --- V2 -> V3: * put back 'if (!rinfo->pinctrl)' test since devm_pinctrl_get() can return NULL if CONFIG_PINCTRL is not set. * print an error msg when devm_pinctrl_get() returns an error that is not -EPROBE_DEFER. * print a dbg msg if devm_pinctrl_get() return NULL. 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c index b720fcc5c10a..30b2de829a32 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 @@ -855,6 +856,17 @@ 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_err(dev->dev, "getting pinctrl info failed: bus recovery might not work\n"); + } else if (!rinfo->pinctrl) { + dev_dbg(dev->dev, "pinctrl is disabled, 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; -- 2.17.1