From: "J. Neuschäfer via B4 Relay" <devnull+j.ne.posteo.net@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Maxime Ripard <mripard@kernel.org>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, "J. Neuschäfer" <j.ne@posteo.net>
Subject: [PATCH 4/4] gpio: 74x164: Add latch GPIO support
Date: Fri, 13 Dec 2024 18:32:50 +0100 [thread overview]
Message-ID: <20241213-gpio74-v1-4-fa2c089caf41@posteo.net> (raw)
In-Reply-To: <20241213-gpio74-v1-0-fa2c089caf41@posteo.net>
From: "J. Neuschäfer" <j.ne@posteo.net>
The Fairchild MM74HC595 and other compatible parts have a latch clock
input (also known as storage register clock input), which must be
clocked once in order to apply any value that was serially shifted in.
This patch adds driver support for using a GPIO that connects to the
latch clock.
Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
---
drivers/gpio/gpio-74x164.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index 187032efa5b5cd1aa7aea7b2d55f6c06df4ccac4..8e87eeb7a1c7a8c71079c8d837dc5c426db8b65b 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -7,6 +7,7 @@
*/
#include <linux/bitops.h>
+#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/module.h>
@@ -21,6 +22,7 @@ struct gen_74x164_chip {
struct gpio_chip gpio_chip;
struct mutex lock;
struct gpio_desc *gpiod_oe;
+ struct gpio_desc *gpiod_latch;
u32 registers;
/*
* Since the registers are chained, every byte sent will make
@@ -34,8 +36,20 @@ struct gen_74x164_chip {
static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
{
- return spi_write(to_spi_device(chip->gpio_chip.parent), chip->buffer,
+ int ret;
+
+ ret = spi_write(to_spi_device(chip->gpio_chip.parent), chip->buffer,
chip->registers);
+ if (ret)
+ return ret;
+
+ if (chip->gpiod_latch) {
+ gpiod_set_value_cansleep(chip->gpiod_latch, 1);
+ udelay(1);
+ gpiod_set_value_cansleep(chip->gpiod_latch, 0);
+ }
+
+ return 0;
}
static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset)
@@ -127,6 +141,11 @@ static int gen_74x164_probe(struct spi_device *spi)
if (IS_ERR(chip->gpiod_oe))
return PTR_ERR(chip->gpiod_oe);
+ chip->gpiod_latch = devm_gpiod_get_optional(&spi->dev, "latch",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(chip->gpiod_latch))
+ return PTR_ERR(chip->gpiod_latch);
+
spi_set_drvdata(spi, chip);
chip->gpio_chip.label = spi->modalias;
--
2.45.2
next prev parent reply other threads:[~2024-12-13 17:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 17:32 [PATCH 0/4] gpio: 74HC595 / 74x164 shift register improvements J. Neuschäfer via B4 Relay
2024-12-13 17:32 ` [PATCH 1/4] dt-bindings: gpio: fairchild,74hc595: Add On Semi MC74HC595A compat J. Neuschäfer via B4 Relay
2024-12-20 12:53 ` Linus Walleij
2024-12-13 17:32 ` [PATCH 2/4] dt-bindings: gpio: fairchild,74hc595: Add latch-gpios property J. Neuschäfer via B4 Relay
2024-12-17 15:25 ` Rob Herring
2024-12-19 12:44 ` J. Neuschäfer
2024-12-13 17:32 ` [PATCH 3/4] gpio: 74x164: Add On Semi MC74HC595A compat J. Neuschäfer via B4 Relay
2024-12-20 12:54 ` Linus Walleij
2024-12-13 17:32 ` J. Neuschäfer via B4 Relay [this message]
2024-12-16 18:20 ` [PATCH 4/4] gpio: 74x164: Add latch GPIO support J. Neuschäfer
2024-12-22 8:58 ` Linus Walleij
2024-12-24 7:26 ` J. Neuschäfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241213-gpio74-v1-4-fa2c089caf41@posteo.net \
--to=devnull+j.ne.posteo.net@kernel.org \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=j.ne@posteo.net \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®