From nobody Tue Feb 10 05:44:10 2026 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 B9FA92FF65B for ; Sun, 25 Jan 2026 19:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769370707; cv=none; b=PtfO7GdOkj6/w/iW97sNGABzSuDrKYuf7mTlZjEBv7Ac/W9b2f1Nldz7jcGHaELvmvIJJ3wmVNgtAUvopK2/B9WODi9Tlya2Lfm5le437LFSBWReiy3+TpLlKd7KOQ4YcrNI5sXW3IX8zBNIUZG0LHv2sxaBIhJ02B+4MFYjR94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769370707; c=relaxed/simple; bh=yOJ54pYpL2f9TTcF6tyIQse6Pob6FYPNHJ3RzR+Wm5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bHFg8hbB8mY6RkVNwUQtyMWxxQJSc5bIslOzjI1qhO7s6oNFDGoZarXy372UFTpDLYGIs7pvUz7EEtEWZNOIb9r2WTu9xEp4JOCKq3xnTWyuYHlwZSWMYKeydiEcnsb/KPB3vL6zF4VQXUbyoQ4pwakcbX7cLhUCjjCQrCNr28k= 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=Av0Hlmsx; arc=none smtp.client-ip=209.85.208.46 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="Av0Hlmsx" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-652fdd043f9so6863062a12.1 for ; Sun, 25 Jan 2026 11:51:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769370704; x=1769975504; 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=p1NkWW5tAbnDHrUHLuon+4jkp7FZIlzNu5NjUea5Lk8=; b=Av0HlmsxmAQXgP6vapbuxYcC4Wm4OtQoveFCE3TEGHbei/JKjzp3nq7fNiEA21DTxf HaSajvsn/ZgT8Zw3eM1G0NLvrdafqxKSadRI489sWFNGHSpPfh/KIO78RYEGjgG+zhK4 s/mZ5G/gDIKfKe3CeSwPFeQY9koON+y6C1Xf6VcCTvhpOJjFRcuhF+2IHPutRaCUbLqx g4t2dJTqwQ2w7+0YzGIx+KG/EFURZJfgeN9XxL+UZ6OZFLmVRiKOWhDIS/U6z3/k5Y8p 1YyUvVRbJYbZdMpl5+ruKSC4kuIiKNpX8hEbXfSdrYD56Q8IwstNN/GWLrjzID0d6zCb yMPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769370704; x=1769975504; 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=p1NkWW5tAbnDHrUHLuon+4jkp7FZIlzNu5NjUea5Lk8=; b=qGol7wjpTJj5cwTAsrYViS45S8WBQlT09XWkQOB5kciI+/6iebAPnAW6/IhOfd/G2v utRA0jWANiaEOZhpDIgNCHC1qztk0XHbHyhBFslOhdsrQWdyy0wFcMScCzHXRE+8JGyg Rwk+bGdZJRYZQE3qtWfCbk929RriCneCHC2BBRaXLN4w26HHihxeBNX3s4m71NEVYl28 7J31LPcxwR9c+yc+4QmDFACwxQ64bsgy5+BwX7ZFofdqSXz+Vs0JGvtpCvJkbHRDxzsG Gh7jBnGygAdVzkSyPutLwJDp9mvWP4vUOdag3B38S/GscOhxb/U/CawD0eYkLE3iq+gT 4jWw== X-Forwarded-Encrypted: i=1; AJvYcCUNUD4V3Kq1VfUzNs3Om1i1Z5ZhWnGkUs6kx6+r7os8bDS2HZgAczcp3tE5gtTkTfzNMSy343ZTf0TCkCA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7+y6jVBknGB7oKQcM5UUy+KbMotHnY9ugq6Tu+2grbZhcFuDe hLCt9D4YeE4LNIbApfDCAzys1uKtva+60n8T/Jn5GkW2jVgasOOPjzCf X-Gm-Gg: AZuq6aJA9dH9vVWvhER9t+7R6vzcqIFOCNDxcUshp8qU1CVNw++qP14vZMpgXzzovzt IUisZ70GUT7Hrquvi51W5o2C1Qc03NdHwxhRqvWTh+ZaMMWFEJK7RXe4oKf6hYIEHWIhDZRgARk 0JUuxqVT7n+YLJFO/M4Cj21sY+l6FBiV9QXlVM4uXBDcu0GUj8I41j1cxK4Dhj897PhLxFc9XOP iLFQ6DaKhXfwvPD3yoWeqHcPn1p/Cp6dGt62WTO3yLcmaL/wtJtQ/BqmsV3SGjhAC/+RhiAgumV 1brkrjSieAYx1aQ8X9bLulv/uKPSk1b+UGo0BVI5fBaZ5+nGRjaWVz80pIpqEvDjqi5g6RKB2zG n5EDzc8/KLL1r+VOegDtl4wz/wTvCxws8/SzBF4CNOEAalRcJ3+55EjFYHgIVXQ71twlUaNu3jh bcYXsDOH+lZbYfdzVF+BfLdko= X-Received: by 2002:a05:6402:26c7:b0:658:1b1b:15a2 with SMTP id 4fb4d7f45d1cf-658706aa73emr1572957a12.7.1769370703967; Sun, 25 Jan 2026 11:51:43 -0800 (PST) Received: from C-PF5D4647.localdomain ([147.161.248.108]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6584b965df4sm4010232a12.31.2026.01.25.11.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 11:51:43 -0800 (PST) From: Jie Li X-Google-Original-From: Jie Li To: wsa@kernel.org, linus.walleij@linaro.org Cc: linux-i2c@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Jie Li Subject: [PATCH v2 2/2] i2c: core: support recovery for single-ended GPIOs Date: Sun, 25 Jan 2026 20:51:23 +0100 Message-ID: <20260125195123.248798-3-jie.i.li@nokia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260125195123.248798-1-jie.i.li@nokia.com> References: <20260125195123.248798-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" Currently, i2c_init_recovery() only assigns the set_sda/set_scl hooks if gpiod_get_direction() returns 0 (output). This logic fails on certain SoC controllers where open-drain lines in a high-impedance state are physically reported as inputs. This leads to a "deadlock" where the I2C core refuses to assign the recovery hooks because it incorrectly assumes the pins are input-only, even though they are fully capable of driving the bus low for recovery. Update the recovery initialization to use the new gpiod_is_single_ended() helper. If a GPIO is configured as open-drain or open-source in the firmware, it is safe to assume it can be used for bus recovery, even if the current hardware direction is reported as input. Signed-off-by: Jie Li Reviewed-by: Linus Walleij --- drivers/i2c/i2c-core-base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index ae7e9c8b65a6..11bd801418e8 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -446,7 +446,8 @@ 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 || + gpiod_is_single_ended(bri->sda_gpiod)) bri->set_sda =3D set_sda_gpio_value; } } else if (bri->recover_bus =3D=3D i2c_generic_scl_recovery) { --=20 2.43.0