Lines Matching refs:ts
50 struct max7301 *ts = container_of(chip, struct max7301, chip); in max7301_direction_input() local
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()
78 static int __max7301_set(struct max7301 *ts, unsigned offset, int value) in __max7301_set() argument
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()
92 struct max7301 *ts = container_of(chip, struct max7301, chip); in max7301_direction_output() local
101 config = &ts->port_config[offset >> 2]; in max7301_direction_output()
103 mutex_lock(&ts->lock); in max7301_direction_output()
108 ret = __max7301_set(ts, offset, value); 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()
120 struct max7301 *ts = gpiochip_get_data(chip); in max7301_get() local
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()
148 struct max7301 *ts = gpiochip_get_data(chip); in max7301_set() local
153 mutex_lock(&ts->lock); in max7301_set()
155 __max7301_set(ts, offset, value); in max7301_set()
157 mutex_unlock(&ts->lock); in max7301_set()
160 int __max730x_probe(struct max7301 *ts) in __max730x_probe() argument
162 struct device *dev = ts->dev; in __max730x_probe()
168 mutex_init(&ts->lock); in __max730x_probe()
169 dev_set_drvdata(dev, ts); 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()
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()
225 struct max7301 *ts = dev_get_drvdata(dev); in __max730x_remove() local
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()