From nobody Sun Feb 8 22:22:30 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 From nobody Sun Feb 8 22:22:30 2026 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 35D992D5940 for ; Wed, 14 Jan 2026 14:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768400049; cv=none; b=b0QMNp/tKP/KMQ/ZEHvwiEj4qbVGPbcOAKh3+tEAnHRQSUDpGQpOTAFidFELlvHUxpbBUvnVmPwPT5OT1mKT8uWr+xgu7dSgE2mSqC6UOqVtzPJIH7JhuYtS8spTpbjL6+ZpNC/ipVFXycryi5KM+cwmRDcZudTuVE0nODfaCMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768400049; c=relaxed/simple; bh=uI5UZ4Fop9VKEyQ8e7Vhlvs+3JV7DOHuBqbOoz+T8Js=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VWZyvHoV0VPMHMr07HCM8pkd5Vj5ZKZroduhnqk37hHwG88WQYEA74fWbyoUXsrscmVGUEGZh93w0Sapjni8d3LrzwWQwu7cs7fGztH1bNITsrFjr9KLrAEUXU9n/nESemI6ierzzyJRBv9hSdvYns/Ps+CiNrwGk1Rzdg9+aVY= 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=D1+Kkgc4; arc=none smtp.client-ip=209.85.208.44 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="D1+Kkgc4" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-65378ba2ff7so2527498a12.2 for ; Wed, 14 Jan 2026 06:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768400047; x=1769004847; 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=THHBPsnJ5h41RArKKPut42z3fPvZexdj9Mfmq6vuelM=; b=D1+Kkgc4N5Hf2VYP4ZAtPG+BZA4mOc23ozH+iTMdAh2SVyQ+Id2RsNv0wK5dtREfOm pt2W2Ql0cCkjGYz3ZRjtGiMYKFTmcxHFyTu5zV6YcvwM7pgOnFMVW01oYyT16oXYGgBC CsDa21NSE+Bto/LtGPFxgoxK+Tj84RXzDSJ/rqrWfDPuEywjRBCQJamxjNJD8LhzStxI XhuBLsRd5MvEAJQvSskWcDP5ny96FmWTYUj2p0t2hKUAOO6RtLZZWRhpMAie09Ud349Y ANyfUr/w9R9uPkppexe47De3gwfIMpzpYshbeUsPIdjqUmEDQOJY+aEipm3MQI01fOx1 sQSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768400047; x=1769004847; 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=THHBPsnJ5h41RArKKPut42z3fPvZexdj9Mfmq6vuelM=; b=nlXkU/jfXzNCWqFkWpMngjrEAUYoxwhd3n6sZYexRrCDtPRbLblI1DVs7J0V5AManq Zge1XhudLwVwdC1N5ZCIFjZyDfvcHDpR+tAVWi/vXiKDM5zbjVOZT/0pXu32FraCrWH4 EiKunY7Kuld+zCblnSoVbOPtzJoUMmwdX5oxkbBhNSWlCjUaaewM1QXpOM70+60csVlX GmsgDFBwMid/Osc5M9csUv+0a/mCMt61MtkBObeO0NLdFNcv94MK25YFy0z+1pP06m2U zjri08RxNpZWZQ61ZDZybma2akcfQd2c/tvLizAEGnjcYFRzYhjNoF+n1iNYug5chTo3 rU4g== X-Forwarded-Encrypted: i=1; AJvYcCVh3dz/4f3d/+aOSZwdjqYrjidiy5pJcRwkWC/iEM5Ujq9nHeUqq9+cALlSEIYTkn2y9u0p4pQXAHIUehY=@vger.kernel.org X-Gm-Message-State: AOJu0YxG0JJkTSObkA0M7RedcZs5lRplenFR5iOo0+fSq4JOuKbXW5V+ evlyPGw6NsTvWyc246u6SRfWmrtO/9YUe/m1z5V0+Mix/AXM+MQrFOof X-Gm-Gg: AY/fxX7ZRvmlSrFJQGMAmtMqqEBwbOU8FiAYsB+ih8I7ElvBRG0QjIz6TU7FRj4Lnpm Orq1deGqT9iWEc1r8Ie3ZXu1VO41uuFXKjUN1LA5Zt0fJJOgx6MYRyOhjr56vG2KOVGt0QNFLC3 c/yqr1RQORz3bV5iH9F7SDn7/tUbLEI/PQZRN7J8OnsDHW4Q+NneXlBTnTm/GiIiWGt3UZBasZR EcgiSJd+esKBEOmI7exFnsg5cuBNVO0PutKGYwlOMF3QA6EyNg6TBgbqKbqrUVWEsZ5MOBS5h1K UCH/wcr9V+Kl+UREXBDmDqDxaUX4G5KrMq+FSM+NlcfoI/iGakhmYcpjy37Gm1uvB1Ga5ybY6eG heKAxlAutnLqzMMWYilbkGkd/DcKqYwtLgM7kLAPSjfjidFb0II6XWdhQMbXvyl9uReQd0xCcZU Hu71LI2pWAfK5gXuIqvQllbQ== X-Received: by 2002:a05:6402:1ecd:b0:64b:7b73:7d50 with SMTP id 4fb4d7f45d1cf-653ec1021femr2004998a12.1.1768400046483; Wed, 14 Jan 2026 06:14:06 -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.14.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 06:14:06 -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 2/2] dt-bindings: i2c: add force-set-sda property Date: Wed, 14 Jan 2026 15:13:52 +0100 Message-ID: <20260114141352.103425-3-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" Document the new "force-set-sda" optional property. This property is used for hardware where the SDA line is open-drain but the standard driver-level check (like gpiod_get_direction) might not correctly reflect the ability to drive the line for bus recovery. Signed-off-by: Jie Li --- Documentation/devicetree/bindings/i2c/i2c-gpio.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml b/Document= ation/devicetree/bindings/i2c/i2c-gpio.yaml index afd4925c2a7d..82713fcf87e4 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml @@ -37,6 +37,13 @@ properties: description: sda as output only type: boolean =20 + force-set-sda: + type: boolean + description: + Force the use of the SDA output toggle during I2C bus recovery. + This is needed for some hardware where the SDA pin is open-drain + but the GPIO subsystem cannot automatically detect its output capabi= lity. + i2c-gpio,scl-output-only: description: scl as output only type: boolean --=20 2.43.0