From nobody Mon Feb 9 21:22:05 2026 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6738F2D6E55 for ; Wed, 14 Jan 2026 14:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768400041; cv=none; b=nsVRYQnUss+YYP6MrbTvjyXQP/iI9PmYKYU+8VJqC6v83I7US3LjEXdNvYXq0adO+WkelFDpa+6oGiDXhJ54aD8kVl5lcBkcIYEM9YVig+Hcnt4xPaWTqep8wFNKpNOLdqND6/W7lLvFME1Zuod4QMKKnZ/0MXvjRiCgquHnN1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768400041; c=relaxed/simple; bh=6HChBFN3+eN58bAfM528LWbrmEuRIcjyzHO9UkHjyc8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W1kdO7JhXdeu1i1ATy/ONTn+BK74JRrfvqxobmzJlKtnPI78AarpyFs+3Bh2U/qBh9c2jk72I1NEyPxUNzzcPUtOdnKpQzR/EpzZysJe6gkgBzr2nJ5fQ8laKQ+hMFgVfACSQkU1XCBr6b8ZSk1o5M1FwnwsxUv4BYrJfmOj2z4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dm462atB; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dm462atB" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-64b9cb94ff5so12779043a12.2 for ; Wed, 14 Jan 2026 06:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768400039; x=1769004839; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lw0lSbQFfSBadWYIdCR1R+5LqktQW19yPPn8YWeadt0=; b=dm462atBvWYnP4TW2NKp5IfBlfYYyQ/+rCCzx1tXMlfrh17gWwXDkRgbAN9G/sZhw5 OscQpVegGXG3h3/ZxfqSrawqdwknzqfNeQIaih1ZBM8qLABEVvMetxuU+BeKFzT2r7zP JN+336wWiFtmH/fWLQbej13tDskZIf2WLN3civGprHAhfl11U/kPQZbcNCgZn2sRKBWu UfNYefgwUH9aF2bN6bitJCcRmP9ugaMeJKxuVW0jsyTsO9U2KIF3Om9U9St+/YJWE3Bm fYRqnerqsWpQ5WjemM8dvdDowb1rPOES9+aVsSuHT2FH36iP7BtyTyNSYWndl/+cH9Y3 g/mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768400039; x=1769004839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lw0lSbQFfSBadWYIdCR1R+5LqktQW19yPPn8YWeadt0=; b=FfXw4dfr/kCPsMfXdnL6vW+ZLUJ5kUO2UbWlAFqDxPcEBZ81AQ3bpK1mJYXYwW9r0Q T4vIwuEoVdsdr8kaXF6rP8TmCsxTcIyr7a5SG2FPPueSjYSWJt5Dp9SRjs6MIC8pdMg/ faUw4BXO36r00mSgHYyCXQBRQeQHIcW2OWJ1KH5M/jvoaknOacHlvGAei7COqi9mTr4N OpN9T4BSMpxvyXP79v52zDLqsC3D40am/eDnp3e94u7oCksXhxo826iqqavQoYjUpRHd i744GDi9+Kf1xTtkjVrPpMnlaD9tn50M6gtK7hviOlo2y5nfIpB6nAL3ImkuiWXlHgxK eK4Q== X-Forwarded-Encrypted: i=1; AJvYcCUoFxKt1cY5nXTHxefZjajD57QkNuzflLjv7VW82KPzdtCDh7+uoKOT3pP1L+W+RXdHA6z1i4htdJhEyvw=@vger.kernel.org X-Gm-Message-State: AOJu0YwN6fTmJzeXDVom9CrmiM/7Xk52YNSrYA4vmV6nJjrt2wM+DhP1 OYtUPw2WyXc69ZT8dbOhFrW4Y2T95hSk1q2ueAFyTvB4SVGFh0NT4r3H X-Gm-Gg: AY/fxX79WQcmE4rFLXxsXO9qxnNdEjz6s8WFgK8aitrD4pI1moTGAR9ddIp9u0XG6IB pILhBkzjnrNejpalR/I1D97nzgT+TMbinvScyKt7GTxvpO+7RFBxobtFJecx0UaHZUjL/pLAwi8 Spa/UyaqH5+ymxwwcazmV9MgqrkJyp8LjicETG1iNPyTzlpVFllkc+erVLXiQlKRPmGnzzEZx+c 6bTLqL+r8x0bxSO7xPc/UCByjqK6nudGLsrmA6FRQwzapOAtf6u5AIqYKjbxwf6r68aP8YqhoZS i8Vo7fVnazzdCiqCMHlBV+EqbgYGwQ0VHRan5d0PsR08opdNV3UYJbmZCYgHozUAANKMmiRlVJN sOSVdZYKyuFLlsixKWMcENzGFtU9LpT9Vwg+z5BA6bQKsJ15UDZVgy8B2JverSBuPRcBeqAkVLp NK6pI7cxtmLxB9X6SHE4lH8A== X-Received: by 2002:a05:6402:1e94:b0:649:69da:6218 with SMTP id 4fb4d7f45d1cf-653ebf7a2e1mr2353585a12.0.1768400038618; Wed, 14 Jan 2026 06:13:58 -0800 (PST) Received: from C-PF5D4647.localdomain ([147.161.248.88]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6507bf667fcsm22651950a12.29.2026.01.14.06.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 06:13:58 -0800 (PST) From: Jie Li X-Google-Original-From: Jie Li To: wsa@kernel.org Cc: linux-i2c@vger.kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, Jie Li Subject: [PATCH v1 1/2] i2c: core: add "force-set-sda" flag for open-drain SDA without "FLAG_IS_OUT" bit Date: Wed, 14 Jan 2026 15:13:51 +0100 Message-ID: <20260114141352.103425-2-jie.i.li@nokia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260114141352.103425-1-jie.i.li@nokia.com> References: <20260114141352.103425-1-jie.i.li@nokia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On certain specialized SoC platforms, the I2C SDA pin is physically open-drain but lacks the "FLAG_IS_OUT" bit in the GPIO subsystem. In such cases, the set_sda function isn't assigned, causing bus recovery to fail. This patch introduces a new optional pinctrl flag "force-set-sda". When this flag is present in the device tree, the I2C recovery mechanism will explicitly attempt to toggle the SDA line through the pinctrl state, ensuring the bus can be freed even when the default recovery logic is insufficient for this specific hardware implementation. This change is necessary to improve the robustness of I2C communication on hardware where the SDA line can remain stuck low and standard recovery fails. Signed-off-by: Jie Li --- drivers/i2c/i2c-core-base.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index ae7e9c8b65a6..ffbab3e4528d 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -42,6 +42,9 @@ #include #include #include +#include +#include +#include =20 #include "i2c-core.h" =20 @@ -422,9 +425,25 @@ static int i2c_gpio_init_recovery(struct i2c_adapter *= adap) return i2c_gpio_init_generic_recovery(adap); } =20 +/* Check if SDA can be driven for recovery when + * GPIO direction reporting is unavailable. + * Usage: add new flag "force-set-sda" in dts pinctrl. + */ +static bool force_set_sda(struct device *dev) +{ + if (!dev || !dev->of_node) + return false; + + if (of_property_read_bool(dev->of_node, "force-set-sda")) + return true; + else + return false; +} + static int i2c_init_recovery(struct i2c_adapter *adap) { struct i2c_bus_recovery_info *bri =3D adap->bus_recovery_info; + struct device *dev =3D &adap->dev; bool is_error_level =3D true; char *err_str; =20 @@ -446,7 +465,7 @@ static int i2c_init_recovery(struct i2c_adapter *adap) if (bri->sda_gpiod) { bri->get_sda =3D get_sda_gpio_value; /* FIXME: add proper flag instead of '0' once available */ - if (gpiod_get_direction(bri->sda_gpiod) =3D=3D 0) + if (gpiod_get_direction(bri->sda_gpiod) =3D=3D 0 || force_set_sda(dev)) bri->set_sda =3D set_sda_gpio_value; } } else if (bri->recover_bus =3D=3D i2c_generic_scl_recovery) { --=20 2.43.0