[PATCH 1/2] gpio: gpio-74x164: add support for CDx4HC4094

From: Marcus Folkesson
Date: Thu Jul 21 2022 - 05:31:02 EST


74hc4094 and 75hc4094 works similar to 74x164 but has an additional
storage latch associated with each stage for strobing data from the
serial input to parallell buffer tri-state output.

Add support for an optional strobe pin.

Signed-off-by: Marcus Folkesson <marcus.folkesson@xxxxxxxxx>
---
drivers/gpio/gpio-74x164.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index e00c33310517..4a1c4de358e4 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -21,6 +21,7 @@ struct gen_74x164_chip {
struct gpio_chip gpio_chip;
struct mutex lock;
struct gpio_desc *gpiod_oe;
+ struct gpio_desc *gpiod_strobe;
u32 registers;
/*
* Since the registers are chained, every byte sent will make
@@ -66,6 +67,10 @@ static void gen_74x164_set_value(struct gpio_chip *gc,
chip->buffer[bank] &= ~(1 << pin);

__gen_74x164_write_config(chip);
+
+ /* Latch data to output pins*/
+ gpiod_set_value_cansleep(chip->gpiod_strobe, 1);
+ gpiod_set_value_cansleep(chip->gpiod_strobe, 0);
mutex_unlock(&chip->lock);
}

@@ -87,6 +92,10 @@ static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask,
chip->buffer[bank] |= bitmask;
}
__gen_74x164_write_config(chip);
+
+ /* Latch data to output pins*/
+ gpiod_set_value_cansleep(chip->gpiod_strobe, 1);
+ gpiod_set_value_cansleep(chip->gpiod_strobe, 0);
mutex_unlock(&chip->lock);
}

@@ -129,6 +138,12 @@ static int gen_74x164_probe(struct spi_device *spi)

gpiod_set_value_cansleep(chip->gpiod_oe, 1);

+ chip->gpiod_strobe = devm_gpiod_get_optional(&spi->dev, "strobe",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(chip->gpiod_strobe))
+ return PTR_ERR(chip->gpiod_strobe);
+
+
spi_set_drvdata(spi, chip);

chip->gpio_chip.label = spi->modalias;
@@ -153,6 +168,10 @@ static int gen_74x164_probe(struct spi_device *spi)
goto exit_destroy;
}

+ /* Latch data to output pins*/
+ gpiod_set_value_cansleep(chip->gpiod_strobe, 1);
+ gpiod_set_value_cansleep(chip->gpiod_strobe, 0);
+
ret = gpiochip_add_data(&chip->gpio_chip, chip);
if (!ret)
return 0;
@@ -182,6 +201,8 @@ MODULE_DEVICE_TABLE(spi, gen_74x164_spi_ids);
static const struct of_device_id gen_74x164_dt_ids[] = {
{ .compatible = "fairchild,74hc595" },
{ .compatible = "nxp,74lvc594" },
+ { .compatible = "ti,cd54hc4094" },
+ { .compatible = "ti,cd74hc4094" },
{},
};
MODULE_DEVICE_TABLE(of, gen_74x164_dt_ids);
--
2.36.1