Lines Matching +full:dout +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0-only
8 * 28 GPIOs. 8 of them can trigger an interrupt. See datasheet for more
11 * - DIN must be stable at the rising edge of clock.
12 * - when writing:
13 * - always clock in 16 clocks at once
14 * - at DIN: D15 first, D0 last
15 * - D0..D7 = databyte, D8..D14 = commandbyte
16 * - D15 = low -> write command
17 * - when reading
18 * - always clock in 16 clocks at once
19 * - at DIN: D15 first, D0 last
20 * - D0..D7 = dummy, D8..D14 = register address
21 * - D15 = high -> read command
22 * - raise CS and assert it again
23 * - always clock in 16 clocks at once
24 * - at DOUT: D15 first, D0 last
25 * - D0..D7 contains the data from the first cycle
59 config = &ts->port_config[offset >> 2]; in max7301_direction_input()
61 if (ts->input_pullup_active & BIT(offset)) in max7301_direction_input()
66 mutex_lock(&ts->lock); in max7301_direction_input()
71 ret = ts->write(ts->dev, 0x08 + (offset >> 2), *config); in max7301_direction_input()
73 mutex_unlock(&ts->lock); in max7301_direction_input()
81 ts->out_level |= 1 << offset; in __max7301_set()
82 return ts->write(ts->dev, 0x20 + offset, 0x01); in __max7301_set()
84 ts->out_level &= ~(1 << offset); in __max7301_set()
85 return ts->write(ts->dev, 0x20 + offset, 0x00); in __max7301_set()
101 config = &ts->port_config[offset >> 2]; in max7301_direction_output()
103 mutex_lock(&ts->lock); in max7301_direction_output()
111 ret = ts->write(ts->dev, 0x08 + (offset >> 2), *config); in max7301_direction_output()
113 mutex_unlock(&ts->lock); in max7301_direction_output()
121 int config, level = -EINVAL; in max7301_get()
126 mutex_lock(&ts->lock); in max7301_get()
128 config = (ts->port_config[offset >> 2] >> ((offset & 3) << 1)) in max7301_get()
134 level = !!(ts->out_level & (1 << offset)); in max7301_get()
139 level = ts->read(ts->dev, 0x20 + offset) & 0x01; in max7301_get()
141 mutex_unlock(&ts->lock); in max7301_get()
153 mutex_lock(&ts->lock); in max7301_set()
157 mutex_unlock(&ts->lock); in max7301_set()
162 struct device *dev = ts->dev; in __max730x_probe()
168 mutex_init(&ts->lock); in __max730x_probe()
172 ts->write(dev, 0x04, 0x01); in __max730x_probe()
175 ts->input_pullup_active = pdata->input_pullup_active; in __max730x_probe()
176 ts->chip.base = pdata->base; in __max730x_probe()
178 ts->chip.base = -1; in __max730x_probe()
180 ts->chip.label = dev->driver->name; in __max730x_probe()
182 ts->chip.direction_input = max7301_direction_input; in __max730x_probe()
183 ts->chip.get = max7301_get; in __max730x_probe()
184 ts->chip.direction_output = max7301_direction_output; in __max730x_probe()
185 ts->chip.set = max7301_set; in __max730x_probe()
187 ts->chip.ngpio = PIN_NUMBER; in __max730x_probe()
188 ts->chip.can_sleep = true; in __max730x_probe()
189 ts->chip.parent = dev; in __max730x_probe()
190 ts->chip.owner = THIS_MODULE; in __max730x_probe()
204 ts->port_config[i] = 0xAA; in __max730x_probe()
206 int offset = (i - 1) * 4 + j; in __max730x_probe()
207 ret = max7301_direction_input(&ts->chip, offset); in __max730x_probe()
213 ret = gpiochip_add_data(&ts->chip, ts); in __max730x_probe()
218 mutex_destroy(&ts->lock); in __max730x_probe()
228 ts->write(dev, 0x04, 0x00); in __max730x_remove()
229 gpiochip_remove(&ts->chip); in __max730x_remove()
230 mutex_destroy(&ts->lock); in __max730x_remove()
236 MODULE_DESCRIPTION("MAX730x GPIO-Expanders, generic parts");