From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 21974388E75 for ; Wed, 29 Apr 2026 03:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777434704; cv=none; b=V6dyOEkjyE95d/6kxdR9YTTANpq/t6N5cof3UaiRzIZr2ETUrpDKMjzPcYsM7AID32zOKk/uhzjUO02xTru0oC4fbNKvokNkxw42w8qB9uhKd5Hq8SWGKj1ijqP0XKhOirtThQMT2Ufk2qAjjQAN/wn4TX9gJeFKsV43oEoob48= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777434704; c=relaxed/simple; bh=8ZTEWpljO0UJ4t5lvQukdUtvqSV7WB3UYomQlWmFqCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GCQUxKZF7Xz0yYyb6h/SeoULCj2dpgU6dCw3KgXU0nx+bkSxan8EhrS5hLZOdjNYj4b8iMGAixOqhxmjMLEGByeBZXw8FW8Xntb9ekWSNRwIJRshDKnuy7/duMjR1PD8v4lA1/+0mzNBAWSW3IL7tnAfsUQsmDVUAE8fDmPVxBk= 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=Mkcd4255; arc=none smtp.client-ip=209.85.210.175 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="Mkcd4255" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82f1f6103afso5651532b3a.1 for ; Tue, 28 Apr 2026 20:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777434702; x=1778039502; 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=DJRe07kUVUgqjg/ti8//IJVD4xo2eVRTabM2wx2IjhE=; b=Mkcd4255Nezp7I6VHDgWlkeZndr7xVbo42+7xJyvUcjyQ9FTXuCQUEmRsq5ZBBhR3+ Tx1+QesUqmYnhfKigrzINV3559Igkt7vsZiTAaQeOlzDTnbFtM0FK8qw0yI8+A8dt6BK YhWyRBFRGoLXLFfGJh4wGYWb3pRou+rCjKpVDtZuny6LyjXP57qocYNoSAaAvdBfcdeD AjfRGMtgR9Cpqnh9CXx4EMCkY7j4q3kRcyuvrXjzrSsFFnFUHyS0mRKSyM+cmZfDaBsa usHYHENHKptKNSDKAFstWdTkkUOck/yF+avm8oSFE43u9QxA0VjcE21dNweYJXpDWsTs XmIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777434702; x=1778039502; 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=DJRe07kUVUgqjg/ti8//IJVD4xo2eVRTabM2wx2IjhE=; b=EWT0mh46hfQerUDmdO80q/LoQFtV0wwjItb1V4D2i01EapeKrLeww4Wer7gFbTB7LY z7TOUPkMTcj2P8H8CBLq1Go+LNcXMydgNV3HWlD39NEAU7GFHVJE/tb3Mfwj3y9zqObL DdBTPp1CiMq8hVI0X3PoDKwVT+HYign1tpdo8ugQdI0XN8cIzH/hBpIhnyMVDBfS2GU5 Vll+ATi5qMujzzgNTtuL6j0XGNV2um4NbjYOMZEO3SiEhM0OWNIWVWo/09AIbiPd9Pnp knyPZ+qx+0gfEz0gzxWaiOFgfy+vKomcr4pZ/DYE8sPjgHbrp3uWW6OyqWO5b+7jROCI yc7Q== X-Forwarded-Encrypted: i=1; AFNElJ8L895Yhg9hSLtF5mg9zBCz388blk5YhRjd4pJOnQNAavVoXmSQdMNMrTvZI6AOTQ8wT94gljNNwMtn4CE=@vger.kernel.org X-Gm-Message-State: AOJu0YxBCrD/G4ROcfH75uRv7TrlrwrJVwU/ThtcFwvgM21is7B9/Q3c /v7CLjhuro/0ak+82bZdBJI+cF6ZYasQoz/oIzKszFupQ9ZUt4ceEYfW X-Gm-Gg: AeBDiet6LEamaXUmIKZCDrVGP26uyoOSnYyP8gBFz/7HcbkDI1v86DX0Xxc103eELsF xG0RUfIb2w751UlBE2Jbpurpt7LgCLkjPtkU1yoTYh5HEQhs5uuKm0iOoMUBkPTGFGqLGjM/ZuZ gxDimpYzW7JN/CzEAyKo6jZGod/itECMceOD616QSajnieuCqGo7jMO0w8ck+tUUFBj9fu/gNtO y3Zq0qZ7w/YMH6jpxCzVZ0mO8iF0ErpVn1keBi3m13rgglWatsz63VTLYT42T1w/SmAqRrxfMJg MscrsHcEqEpnoiLMIA0IOSjLfZKGaeE+HSDP8J2tJR/uwM3aZbi24Z/Sza0g4GWtGhdbVHh5MBj Hiw4ANYppAjgH5Wt5PBcsgYltza1ic1aPMrqPTiNb2i0UjHf3daghudT2KUouQ7zvqxy14mk6yB QFAMyMVRKEE3ExdQBjFOc7bmh6J32vMRIXTBwxWmPH7clbk8czLS+PMI5F360S1Y9a X-Received: by 2002:a05:6a00:3486:b0:82f:72e6:ed4 with SMTP id d2e1a72fcca58-834dd91736fmr6337129b3a.0.1777434702416; Tue, 28 Apr 2026 20:51:42 -0700 (PDT) Received: from happycpu-p1.. ([121.160.151.7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-834ed5f30ddsm502899b3a.26.2026.04.28.20.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 20:51:42 -0700 (PDT) From: Chanhong Jung To: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Ripard Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] gpio: 74x164: support lines-initial-states for boot-time output state Date: Wed, 29 Apr 2026 12:51:34 +0900 Message-Id: <20260429035134.1023330-3-happycpu@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 74HC595 and 74LVC594 chains retain their output state from the first serial write onwards. Today the driver always kicks that first write from a zero-initialised buffer, so every output comes up low until user space issues a write. Boards that rely on the chain to drive signals whose power-on state matters (active-low indicators, reset lines, etc.) have no way to express the desired initial pattern via DT. Read the optional lines-initial-states bitmask, recently documented for this binding, into chip->buffer before the first __gen_74x164_write_config() so the chain comes up in a known state on the very first SPI transaction. Bit N maps to GPIO line N (matching the nxp,pcf8575 convention); on this output-only device, bit=0 drives the line low and bit=1 drives it high. Property absence keeps the existing zeroing behaviour intact. Suggested-by: Linus Walleij Signed-off-by: Chanhong Jung --- drivers/gpio/gpio-74x164.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index c226524ef..5ca61cf52 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -112,7 +112,7 @@ static int gen_74x164_probe(struct spi_device *spi) { struct device *dev = &spi->dev; struct gen_74x164_chip *chip; - u32 nregs; + u32 nregs, init_state; int ret; /* @@ -134,6 +134,21 @@ static int gen_74x164_probe(struct spi_device *spi) chip->registers = nregs; + /* + * Optionally seed the chain with a board-specified pattern so the + * outputs come up in a known state on the first SPI write. The + * property follows the nxp,pcf8575 convention where bit N maps to + * GPIO line N. On this output-only device, bit=0 drives the line + * low and bit=1 drives it high. The bitmask covers up to 32 lines; + * any further outputs come up zeroed by devm_kzalloc(). + */ + if (!device_property_read_u32(dev, "lines-initial-states", &init_state)) { + unsigned int i; + + for (i = 0; i < min(nregs, 4U); i++) + chip->buffer[nregs - 1 - i] = (init_state >> (i * 8)) & 0xff; + } + chip->gpiod_oe = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(chip->gpiod_oe)) return PTR_ERR(chip->gpiod_oe); -- 2.34.1