From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 7D80839A04E for ; Sat, 9 May 2026 09:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778317946; cv=none; b=YiUAYrpmGPGc5XkKbWmrEgf8KjtPdK6KSoe/7nXp+4ttZGpLZKQMfundWLL9bGlUNno6x7Xfd48d6w+c7HHH/wdRoxjRMKlVHFspFwgzc+t8A7N1Huju5ZFKhM3c2YhzeyNlKu+6Z9wueqXrf0ULL4N/G+QKI2zeR0RzqiMWvGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778317946; c=relaxed/simple; bh=ULSxsA99WtOVeyQnnnWwi4Szn0714xC40QbXKSsl18o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rbiPM2zUoru1lCyxhget6Chxf19EGTJdj0MDtWqP1fPj2olgj4OT8d2zGus4eacyJBJMFJEE/c8SUKsA+WrIwcx2zai2rziWfsX0CqoGX/xkwG3UdoUq7KoKlKhMi58pRiPDUZKMiZqF/ev8QU/E3dJJaH8uaBjwTCy+3H9lh3M= 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=iPitiYVR; arc=none smtp.client-ip=209.85.208.41 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="iPitiYVR" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-67e9b3037dcso3257278a12.0 for ; Sat, 09 May 2026 02:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778317942; x=1778922742; 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=pk/ryGv+w8weiU5QHQuVNcKF565C/DJ9GpiFb4c/EJM=; b=iPitiYVRebqxAaucnGOFAC/4+/M5h1gtxJo9Zx+fH0B2iq/v2+cLZfs1evCq1i8qS5 yhn7JmpwZoWDPyAta8hueKBtiPDhq36zJrmPZEQ+cPtP5io6WcRZWGJWkubAGUZLK57a Nkn+CgGZQ1xakpHBWsSLCsqAkDOaklXKqbgyT+Mv6nVjWJKQRA45bxPifBGZA1y16u+6 miCOEaAlUtDpF+K+uJ9+ruuMh7xXMe28Q/dK1iQi58vGE9aGZmoM6jeRL4N3O7dvIuj2 4F/NypL3EQ36kIwR8I/30j98lqKUUxlkU+zvz8rLq8NUMDkM6aNc33M139eTR4ila214 lq8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778317942; x=1778922742; 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=pk/ryGv+w8weiU5QHQuVNcKF565C/DJ9GpiFb4c/EJM=; b=Eu6bGWMuNuSAOiEFUoRtL055+P5SjChWrnk6GTFxuW2ej09ZpemOq2LPxyVzozsDLY Mv6yuxnr/XrUndtMrKg4mPuNTcPh6CwvJqRSK0yGGsxD7cvfdWJi1tMZdcIhQfmlTzZH PxxqsJzCSTxpFHAx4j2IadxEimvLAsJMltp1o8dWhYcO8DR2/UPhewlI0qiYTWa4F/sE NMkd56ruPIK2PKYneKJ0gZe/LHTsJvWsY7A1wAlYPHAeEIL1wzpBvED+yYBrZ0SyPK3R utuPKOc7e5JvnVnZ+uwIvd1ffJ5dRjrBE3+ewRvSplL7OyvK43EXTzI6sq17Q/Du8sP2 Ms9w== X-Forwarded-Encrypted: i=1; AFNElJ+hirnc0ysW9HT6cy1vHgx38DzI25zJKRtSz7BAotSFeSPutb7a6nFGcIVYYP9QuYpe8f9IRIG0I6GkCgU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2QK8HGrKA0KvXtdy0fHwpGHuWBcWdwqrCGmx0YNmjSssQjdw9 glYmDugnCs9r/qs+eqAwQeQe7EYGWkoBguOhrJ8YnvnS/T40UKa2O7Us X-Gm-Gg: Acq92OHg/CnBUZhrDfggvqoPsRAA57OtEX8szyqyuAW3f5/cIgw4MDVivzWu9p75W/T P/Hx+qB7XIrbyHsL1xQWqU0/kvA2UdBj+4BmkCLvCppKCwvYJywD1BOOP7Zjqv7dFbbwS0LqD96 bBcF7JNv//7Edb0KRkqEokEzHJYVFtqt6rJOwrBi8D9Pek/BKpU9hLv6EW+t210Vj7kmP+aMPKV 9YRnOW8EoVuUhPokLBAAjiB9P80yqR3iYsmdgr2oxfhaT1iy3VO1OCrN6cUKomBSZ7JDrbHsEZl OEQvv7H2adfzP8W0yW1aeZWiJc+NZ/9wimqgmzz+HREYI7JXb3zuIevYjMvr3xx3ISMxLQmCucn Dk6bbUpN4dyFdMqgLoratViJJsDf+YzciX+30imvFvFo9IALhgEDqUjeNEFf4bH2PzwhbrRvHLt QpEHSEHCeyTqyp//hOQOwFdS9QjlloTN86gpn7rRhRLC7q7A== X-Received: by 2002:a17:907:9346:b0:bc3:b598:7f47 with SMTP id a640c23a62f3a-bcaad226929mr377767166b.42.1778317942195; Sat, 09 May 2026 02:12:22 -0700 (PDT) Received: from C-PF5D4647.localdomain ([147.161.248.89]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bcac3f66cadsm203819866b.42.2026.05.09.02.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2026 02:12:21 -0700 (PDT) From: Jie Li X-Google-Original-From: Jie Li To: wsa@kernel.org, linusw@kernel.org Cc: linux-i2c@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Jie Li , Wolfram Sang Subject: [PATCH v4 2/2] i2c: core: support recovery for single-ended GPIOs Date: Sat, 9 May 2026 11:12:08 +0200 Message-ID: <20260509091208.18346-3-jie.i.li@nokia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260509091208.18346-1-jie.i.li@nokia.com> References: <20260509091208.18346-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: 8bit Currently, i2c_init_recovery() only assigns the set_sda/set_scl hooks if gpiod_get_direction() returns GPIO_LINE_DIRECTION_OUT. 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 Acked-by: Wolfram Sang --- drivers/i2c/i2c-core-base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 9c46147e3506..a3c33e804d47 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -445,8 +445,8 @@ static int i2c_init_recovery(struct i2c_adapter *adap) bri->set_scl = set_scl_gpio_value; if (bri->sda_gpiod) { bri->get_sda = get_sda_gpio_value; - /* FIXME: add proper flag instead of '0' once available */ - if (gpiod_get_direction(bri->sda_gpiod) == 0) + if (gpiod_get_direction(bri->sda_gpiod) == GPIO_LINE_DIRECTION_OUT || + gpiod_is_single_ended(bri->sda_gpiod)) bri->set_sda = set_sda_gpio_value; } } else if (bri->recover_bus == i2c_generic_scl_recovery) { -- 2.43.0