Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp758001rdh; Tue, 22 Aug 2023 09:46:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHbEs5eJXolrkeKjPsEtir/BNb1xDUXOUaJXx3A+4dXhymy7zPQeMIkwOCbXwmjb0i2UfQ X-Received: by 2002:a05:6a20:729b:b0:140:a6ec:b55e with SMTP id o27-20020a056a20729b00b00140a6ecb55emr9250155pzk.3.1692722786643; Tue, 22 Aug 2023 09:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692722786; cv=none; d=google.com; s=arc-20160816; b=BKx4OZSFWLjH1vIMMvYf0MedKtyb5/xQptrLces6iL3ZiXGzhH8S9HHbg4MsbOev95 YNcwu9TFDQbXr4VHeAezqh3ZcXS1vWWBXJRDxj+ZXRdi3XtyEDRFcHhZmxkdXUGTqkv6 /S06/7+dWw0hCteLe3g8ddE5OlLPVLcUJDwFdm37XyLOIAVxGFeIYB6n4MVn/1i34xMU 6rKFCQfbpH5dU/TUhMRzfatj9zTAxEA02yXOnT/nNbNbaA/DbZHf6CepI5Tp0N4lXeqY TWz2J7B9UiibOc3x8tguhdP5tO61trPTF47+vPkMkZjIRS3TKq3OWHaBZji87RHZ0nTw BxnQ== 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=9QHaEZG3GKRZQHVmYpOnLkhB8Fgqpm8Clw8s8MGMZKo=; fh=mG8JK5O8r0Xb4UuxJ3TgUl3687HAjOPkNqwdLPrxGQE=; b=stnEDSo/NxqwiB7YvjxErNxg/F9ddv7cvcYkLaSRcaSvoojKntLnsaPWAPmqZK86JX QACHreb3bpjK9zdhEq2LvbAyZEHZxCNGoUY311DebZAS0E5W8W/eURkHnneEhoDNrsa4 agp2ymlEHbjnY0QhO1ghjJJrAo3dM8T8RJF2eNR0evsy1kcwoGlaLBEoQNEUMAIcCWOi CLAD5LGVJm9lct0S6rJ7r1KDU1HNNKgDiZbRiqmjPYBvBoE6cZRIQpppFXvwsSB3EbFL 2WcJ2+cxWnG0DxI3Sc+BZTX6f98o91BYsFhrf66UaAAr/yXKDhj0AXQAdLzM0YyzMqK1 UDPQ== 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 u185-20020a6385c2000000b00569561773a6si7961746pgd.549.2023.08.22.09.46.10; Tue, 22 Aug 2023 09:46:26 -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 S236815AbjHVOex (ORCPT + 99 others); Tue, 22 Aug 2023 10:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234144AbjHVOew (ORCPT ); Tue, 22 Aug 2023 10:34:52 -0400 Received: from mx4.sionneau.net (mx4.sionneau.net [51.15.250.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E371BCEA; Tue, 22 Aug 2023 07:34:47 -0700 (PDT) Received: from junon.lin.mbt.kalray.eu ( [217.181.231.53]) by mx4.sionneau.net (OpenSMTPD) with ESMTPSA id ba139134 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 22 Aug 2023 14:34:46 +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 v6] i2c: designware: Add support for recovery when GPIO need pinctrl. Date: Tue, 22 Aug 2023 16:34:37 +0200 Message-Id: <20230822143437.9395-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,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 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. Signed-off-by: Yann Sionneau Reviewed-by: Andy Shevchenko --- V5 -> V6: * Put a proper commit msg subject V4 -> V5: * put back `else if` * reword the commit msg Subject to add the `i2c: designware: ` tag * Add the missing `Reviewed-by: Andy Shevchenko` tag V3 -> V4: * Replace `else if` by simply `if`. 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