From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 9F7973603E8 for ; Wed, 22 Apr 2026 16:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776873918; cv=none; b=TMsI+Rzcwnpa0jfEo944lVW7zCJG3idPdybXLFpq+TcvGQhUz0rXdwTDEY43/TK/8zj0pVfWsQPQjqCV6IOFfaOl3ZyrYVQg/QW0jsuRE7L57Lcfo7q9osDjMc0TfflHrewdBu6gQSEALFi+KB+dWLDLn8JzJvO8c3oT71rP3Lo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776873918; c=relaxed/simple; bh=VgOr825JFd85qpx9ZSe3P5UBh8fNbkiALkxKCmKvveY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oAzs361/cz5pIb29jBC02ppQ1FwTN0Mp3rymAK0grXXgLuERgVf6nUCqoy6wLbnK+/goF5hSnL5LIUG3BiyxhCvTWRA7cmTcmWlLXXfJV4Rcl2g5zjFMJrTiZHdgu3kO71urK5H2KktWAkYR1+G1/quNtDNe6t/qGCxAFfzu9k8= 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=U4rbNoMF; arc=none smtp.client-ip=209.85.210.179 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="U4rbNoMF" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-82fcd0aa2dbso1052784b3a.0 for ; Wed, 22 Apr 2026 09:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776873916; x=1777478716; 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=r78Ht7d3rD0nKWuIXu8vxDpeZ4/LkBaXzBNsFb0PtOo=; b=U4rbNoMFQuAci9G8rVh8tGL7tiwcAwZh5UnmQHdJLpbKQr2/OSu6KSulDw1MA9q+OV 1TRgxivxt9TELwvEbRkSD88MiH0891ykjZtgaJM17+Ttzxgw+nPHvE+cpYB1JX2SbOtv 0zOFpXu6E6StIla6WPK/dmSiKuI3Cql5N4lK5NjsLWS1II0EhRT8Qasy5EFic9IDjj7Y ijv4H6C121lEUaDJ53EOw1Je86sDpOZEfqD6kNmAi2ZIB+e4eypTC2gV/AOj13liTgLq WeLqQeKE0TTit0+x5v/aJAGG0CZxh4HpqxIgCmiN5X3tG0L49BcEssOmH3FQyDsvDObZ w0Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776873916; x=1777478716; 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=r78Ht7d3rD0nKWuIXu8vxDpeZ4/LkBaXzBNsFb0PtOo=; b=E9o0MLMspjrHX29Jp8pTWnF8feTF/hBMiNo8bwRXMUVi9CLGyHnl1Ro/F2NdvY/3GE +/cJdV9zrfMuA7Rf3c3BE4ccHsClpxglIQBgV+eAiIisLlNCeGgqe6RI4X9bjXquEb1o 3bnggnVbSriBRwyEonPyVwt5LsEQ2jcaXOCSbKin2D6W3iv3ehPZV2XnY8Vj/YvPm/7U /UAu1h+gZZNrWwE20g9flWAB8AW6gAOwOQILPWdYAVuSoFPkkTbfeoWbPs1uqeDhwK0x sXc76JjxEKaG6PXL2L8fbWgwOH/Y5A/74CnJ3ImBJbyAztEyuEdJotnkamUYA0MMw7UD W4pw== X-Forwarded-Encrypted: i=1; AFNElJ/kzIYHq7VDCHNEFDnpjwExfytdCeeLlCZ0UF+zvSvaFOTCCoEZU5ibxwlgYprGXbl2W9scttEnfLQy4mY=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3bNwNexu+GlWLR+3O84huH6RI3ZLAhN3Li/tzDYKs11+Z2n6C iLfzx8vW1gE1ppmatOYtS4QXoLeLf6PgI0cY3svDJiIH3PliV2dl0enNwmi3sq38 X-Gm-Gg: AeBDiet/7vnffMjjPSfa+jHfd+PxcYWEXGePd/CtWqCfWdrLS+y5cczKkNvgdCs9wla NL72FaydsNmJXsXn9XZtxIstEUyqDMzDEu3yh11HhQkKJobE9CpNHwoW5nmxvIbEtD26Zs0gFK5 f6CUJSThDNwty7G3RAbnh15yPRTxO+xHBzElm8YBUNmqWoG/RvE35PYBaZsNCTyG3zPYnATMUlV +N/sGtsSZvvC2+4yy99SnLrIUyk9lZU5HL3ssfy7u0J51K8btawFNiB1tw25Vo57qVF5EiXQDCC +KTo0vrx1lLdl0MpB/rbyoKNQu6nrykgmOX4c9ohSNcUmtEkA/ZKKgpJ3yvL6wHfV/RkJVAFagc S/wkcjb9nSzKs0kBmvMglPUH+kNWXaXpqeLH6n3w9fWMHmIWrdCzLteqjZD6RR84DLnY7PXnsyA 7uVuBdHr0HDFCvJKO9hT+OidxWbrpjqNwO+FtI6r28ofE/bo0PQFhnM814Ip3Tm1fA X-Received: by 2002:a05:6a00:3a20:b0:82f:50ef:3eab with SMTP id d2e1a72fcca58-82f8b54738emr19822095b3a.28.1776873915614; Wed, 22 Apr 2026 09:05:15 -0700 (PDT) Received: from happycpu-p1.. ([121.160.151.7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ec003dcsm18151031b3a.52.2026.04.22.09.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 09:05:15 -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 v1 2/2] gpio: 74x164: support 'registers-default' DT property for initial state Date: Thu, 23 Apr 2026 01:05:04 +0900 Message-Id: <77cc91a966bfcbeaad825b8be607dbd7a85dbbdb.1776872453.git.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, and must reinvent it from user space each time after probe. Read the new optional 'registers-default' u8 array into chip->buffer after the buffer's size becomes known (so __counted_by() is satisfied) and before the first __gen_74x164_write_config(). Absence of the property keeps the current zeroing behaviour; an invalid size is rejected with dev_err_probe() so that dtbs_check violations surface loudly at probe time. The matching binding change documents the property's layout. The corresponding U-Boot driver (drivers/gpio/74x164_gpio.c) has honoured the same property for years, so the two bootstages can now agree on the initial state without user-space involvement. Signed-off-by: Chanhong Jung --- drivers/gpio/gpio-74x164.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index c226524ef..b433a4a61 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -134,6 +134,20 @@ static int gen_74x164_probe(struct spi_device *spi) chip->registers = nregs; + /* + * Optionally seed the chain with a board-specified pattern so that + * the outputs come up in a known state on the first SPI write. When + * the property is absent, the buffer stays zeroed by devm_kzalloc() + * and the existing behaviour is preserved. + */ + if (device_property_present(dev, "registers-default")) { + ret = device_property_read_u8_array(dev, "registers-default", + chip->buffer, nregs); + if (ret) + return dev_err_probe(dev, ret, + "Invalid 'registers-default'\n"); + } + 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