18 #include <linux/slab.h>
19 #include <linux/module.h>
21 #define GEN_74X164_NUMBER_GPIOS 8
57 for (i = chip->
registers - 1; i >= 0; i--) {
59 msg_buf[
i].
len =
sizeof(
u8);
60 spi_message_add_tail(msg_buf + i, &
message);
70 static int gen_74x164_get_value(
struct gpio_chip *
gc,
unsigned offset)
84 static void gen_74x164_set_value(
struct gpio_chip *
gc,
97 __gen_74x164_write_config(chip);
101 static int gen_74x164_direction_output(
struct gpio_chip *gc,
102 unsigned offset,
int val)
104 gen_74x164_set_value(gc, offset, val);
114 if (!spi->
dev.of_node) {
115 dev_err(&spi->
dev,
"No device tree data available.\n");
132 pdata = spi->
dev.platform_data;
133 if (pdata && pdata->
base)
145 chip->
gpio_chip.direction_output = gen_74x164_direction_output;
146 chip->
gpio_chip.get = gen_74x164_get_value;
147 chip->
gpio_chip.set = gen_74x164_set_value;
149 if (of_property_read_u32(spi->
dev.of_node,
"registers-number", &chip->
registers)) {
150 dev_err(&spi->
dev,
"Missing registers-number property in the DT.\n");
166 ret = __gen_74x164_write_config(chip);
168 dev_err(&spi->
dev,
"Failed writing: %d\n", ret);
199 dev_err(&spi->
dev,
"Failed to remove the GPIO controller: %d\n",
205 static const struct of_device_id gen_74x164_dt_ids[] = {
206 { .compatible =
"fairchild,74hc595" },
211 static struct spi_driver gen_74x164_driver = {
217 .probe = gen_74x164_probe,