Lines Matching +full:chip +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0-only
3 * GPIO driver for EXAR XRA1403 16-bit GPIO expander
23 #define XRA_PUR 0x08 /* Input Internal Pull-up Resistor Enable/Disable */
25 #define XRA_TSCR 0x0C /* Output Three-State Control */
33 struct gpio_chip chip; member
50 static int xra1403_direction_input(struct gpio_chip *chip, unsigned int offset) in xra1403_direction_input() argument
52 struct xra1403 *xra = gpiochip_get_data(chip); in xra1403_direction_input()
54 return regmap_update_bits(xra->regmap, to_reg(XRA_GCR, offset), in xra1403_direction_input()
58 static int xra1403_direction_output(struct gpio_chip *chip, unsigned int offset, in xra1403_direction_output() argument
62 struct xra1403 *xra = gpiochip_get_data(chip); in xra1403_direction_output()
64 ret = regmap_update_bits(xra->regmap, to_reg(XRA_GCR, offset), in xra1403_direction_output()
69 ret = regmap_update_bits(xra->regmap, to_reg(XRA_OCR, offset), in xra1403_direction_output()
75 static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset) in xra1403_get_direction() argument
79 struct xra1403 *xra = gpiochip_get_data(chip); in xra1403_get_direction()
81 ret = regmap_read(xra->regmap, to_reg(XRA_GCR, offset), &val); in xra1403_get_direction()
91 static int xra1403_get(struct gpio_chip *chip, unsigned int offset) in xra1403_get() argument
95 struct xra1403 *xra = gpiochip_get_data(chip); in xra1403_get()
97 ret = regmap_read(xra->regmap, to_reg(XRA_GSR, offset), &val); in xra1403_get()
104 static void xra1403_set(struct gpio_chip *chip, unsigned int offset, int value) in xra1403_set() argument
107 struct xra1403 *xra = gpiochip_get_data(chip); in xra1403_set()
109 ret = regmap_update_bits(xra->regmap, to_reg(XRA_OCR, offset), in xra1403_set()
112 dev_err(chip->parent, "Failed to set pin: %d, ret: %d\n", in xra1403_set()
117 static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip) in xra1403_dbg_show() argument
120 struct xra1403 *xra = gpiochip_get_data(chip); in xra1403_dbg_show()
132 regmap_read(xra->regmap, reg, &value[reg]); in xra1403_dbg_show()
139 for_each_requested_gpio(chip, i, label) { in xra1403_dbg_show()
140 seq_printf(s, " gpio-%-3d (%-12s) %s %s\n", in xra1403_dbg_show()
141 chip->base + i, label, in xra1403_dbg_show()
156 xra = devm_kzalloc(&spi->dev, sizeof(*xra), GFP_KERNEL); in xra1403_probe()
158 return -ENOMEM; in xra1403_probe()
160 /* bring the chip out of reset if reset pin is provided*/ in xra1403_probe()
161 reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW); in xra1403_probe()
163 dev_warn(&spi->dev, "Could not get reset-gpios\n"); in xra1403_probe()
165 xra->chip.direction_input = xra1403_direction_input; in xra1403_probe()
166 xra->chip.direction_output = xra1403_direction_output; in xra1403_probe()
167 xra->chip.get_direction = xra1403_get_direction; in xra1403_probe()
168 xra->chip.get = xra1403_get; in xra1403_probe()
169 xra->chip.set = xra1403_set; in xra1403_probe()
171 xra->chip.dbg_show = xra1403_dbg_show; in xra1403_probe()
173 xra->chip.ngpio = 16; in xra1403_probe()
174 xra->chip.label = "xra1403"; in xra1403_probe()
176 xra->chip.base = -1; in xra1403_probe()
177 xra->chip.can_sleep = true; in xra1403_probe()
178 xra->chip.parent = &spi->dev; in xra1403_probe()
179 xra->chip.owner = THIS_MODULE; in xra1403_probe()
181 xra->regmap = devm_regmap_init_spi(spi, &xra1403_regmap_cfg); in xra1403_probe()
182 if (IS_ERR(xra->regmap)) { in xra1403_probe()
183 ret = PTR_ERR(xra->regmap); in xra1403_probe()
184 dev_err(&spi->dev, "Failed to allocate regmap: %d\n", ret); in xra1403_probe()
188 return devm_gpiochip_add_data(&spi->dev, &xra->chip, xra); in xra1403_probe()