• Home
  • Raw
  • Download

Lines Matching +full:de +full:- +full:serializer

2  * gpio-max3191x.c - GPIO driver for Maxim MAX3191x industrial serializer
7 * Multiple chips can be daisy-chained, the spec does not impose
10 * Either of two modes is selectable: In 8-bit mode, only the state
12 * In 16-bit mode, an additional status byte is clocked out with
16 * readout of non-faulting chips in the same daisy-chain.
20 * daisy-chain.
22 * If the chips are hardwired to 8-bit mode ("modesel" pulled high),
23 * gpio-pisosr.c can be used alternatively to this driver.
29 * https://datasheets.maximintegrated.com/en/ds/MAX31953-MAX31963.pdf
49 * struct max3191x_chip - max3191x daisy-chain
52 * @nchips: number of chips in the daisy-chain
53 * @mode: current mode, 0 for 16-bit, 1 for 8-bit;
54 * for simplicity, all chips in the daisy-chain are assumed
71 * for simplicity, all chips in the daisy-chain are assumed
111 return -EINVAL; in max3191x_direction_output()
123 return max3191x->mode == STATUS_BYTE_ENABLED ? 2 : 1; in max3191x_wordlen()
128 struct device *dev = max3191x->gpio.parent; in max3191x_readout_locked()
132 val = spi_sync(spi, &max3191x->mesg); in max3191x_readout_locked()
138 for (i = 0; i < max3191x->nchips; i++) { in max3191x_readout_locked()
139 if (max3191x->mode == STATUS_BYTE_ENABLED) { in max3191x_readout_locked()
140 u8 in = ((u8 *)max3191x->xfer.rx_buf)[i * 2]; in max3191x_readout_locked()
141 u8 status = ((u8 *)max3191x->xfer.rx_buf)[i * 2 + 1]; in max3191x_readout_locked()
144 __assign_bit(i, max3191x->crc_error, val); in max3191x_readout_locked()
150 __assign_bit(i, max3191x->overtemp, ot); in max3191x_readout_locked()
155 if (!max3191x->ignore_uv) { in max3191x_readout_locked()
157 __assign_bit(i, max3191x->undervolt1, uv1); in max3191x_readout_locked()
163 __assign_bit(i, max3191x->undervolt2, val); in max3191x_readout_locked()
170 if (max3191x->fault_pins && !max3191x->ignore_uv) { in max3191x_readout_locked()
173 (max3191x->fault_pins->ndescs == 1) in max3191x_readout_locked()
174 ? max3191x->fault_pins->desc[0] in max3191x_readout_locked()
175 : max3191x->fault_pins->desc[i]; in max3191x_readout_locked()
183 __assign_bit(i, max3191x->fault, val); in max3191x_readout_locked()
197 if (!max3191x->ignore_uv && test_bit(chipnum, max3191x->fault)) in max3191x_chip_is_faulting()
200 if (max3191x->mode == STATUS_BYTE_DISABLED) in max3191x_chip_is_faulting()
203 return test_bit(chipnum, max3191x->crc_error) || in max3191x_chip_is_faulting()
204 test_bit(chipnum, max3191x->overtemp) || in max3191x_chip_is_faulting()
205 (!max3191x->ignore_uv && in max3191x_chip_is_faulting()
206 test_bit(chipnum, max3191x->undervolt1)); in max3191x_chip_is_faulting()
215 mutex_lock(&max3191x->lock); in max3191x_get()
222 ret = -EIO; in max3191x_get()
226 in = ((u8 *)max3191x->xfer.rx_buf)[chipnum * wordlen]; in max3191x_get()
230 mutex_unlock(&max3191x->lock); in max3191x_get()
240 mutex_lock(&max3191x->lock); in max3191x_get_multiple()
245 while ((bit = find_next_bit(mask, gpio->ngpio, bit)) != gpio->ngpio) { in max3191x_get_multiple()
250 ret = -EIO; in max3191x_get_multiple()
254 in = ((u8 *)max3191x->xfer.rx_buf)[chipnum * wordlen]; in max3191x_get_multiple()
264 mutex_unlock(&max3191x->lock); in max3191x_get_multiple()
275 return -ENOTSUPP; in max3191x_set_config()
277 if (!max3191x->db0_pins || !max3191x->db1_pins) in max3191x_set_config()
278 return -EINVAL; in max3191x_set_config()
299 return -EINVAL; in max3191x_set_config()
302 if (max3191x->db0_pins->ndescs == 1) in max3191x_set_config()
307 mutex_lock(&max3191x->lock); in max3191x_set_config()
308 gpiod_set_value_cansleep(max3191x->db0_pins->desc[chipnum], db0_val); in max3191x_set_config()
309 gpiod_set_value_cansleep(max3191x->db1_pins->desc[chipnum], db1_val); in max3191x_set_config()
310 mutex_unlock(&max3191x->lock); in max3191x_set_config()
338 if (found == -ENOENT) in devm_gpiod_get_array_optional_count()
342 dev_err(dev, "ignoring %s-gpios: found %d, expected %u or 1\n", in devm_gpiod_get_array_optional_count()
350 dev_err(dev, "failed to get %s-gpios: %ld\n", in devm_gpiod_get_array_optional_count()
360 struct device *dev = &spi->dev; in max3191x_probe()
366 return -ENOMEM; in max3191x_probe()
369 max3191x->nchips = 1; in max3191x_probe()
370 device_property_read_u32(dev, "#daisy-chained-devices", in max3191x_probe()
371 &max3191x->nchips); in max3191x_probe()
373 n = BITS_TO_LONGS(max3191x->nchips); in max3191x_probe()
374 max3191x->crc_error = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL); in max3191x_probe()
375 max3191x->undervolt1 = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL); in max3191x_probe()
376 max3191x->undervolt2 = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL); in max3191x_probe()
377 max3191x->overtemp = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL); in max3191x_probe()
378 max3191x->fault = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL); in max3191x_probe()
379 max3191x->xfer.rx_buf = devm_kcalloc(dev, max3191x->nchips, in max3191x_probe()
381 if (!max3191x->crc_error || !max3191x->undervolt1 || in max3191x_probe()
382 !max3191x->overtemp || !max3191x->undervolt2 || in max3191x_probe()
383 !max3191x->fault || !max3191x->xfer.rx_buf) in max3191x_probe()
384 return -ENOMEM; in max3191x_probe()
386 max3191x->modesel_pins = devm_gpiod_get_array_optional_count(dev, in max3191x_probe()
387 "maxim,modesel", GPIOD_ASIS, max3191x->nchips); in max3191x_probe()
388 max3191x->fault_pins = devm_gpiod_get_array_optional_count(dev, in max3191x_probe()
389 "maxim,fault", GPIOD_IN, max3191x->nchips); in max3191x_probe()
390 max3191x->db0_pins = devm_gpiod_get_array_optional_count(dev, in max3191x_probe()
391 "maxim,db0", GPIOD_OUT_LOW, max3191x->nchips); in max3191x_probe()
392 max3191x->db1_pins = devm_gpiod_get_array_optional_count(dev, in max3191x_probe()
393 "maxim,db1", GPIOD_OUT_LOW, max3191x->nchips); in max3191x_probe()
395 max3191x->mode = device_property_read_bool(dev, "maxim,modesel-8bit") in max3191x_probe()
397 if (max3191x->modesel_pins) in max3191x_probe()
399 max3191x->modesel_pins->ndescs, in max3191x_probe()
400 max3191x->modesel_pins->desc, max3191x->mode); in max3191x_probe()
402 max3191x->ignore_uv = device_property_read_bool(dev, in max3191x_probe()
403 "maxim,ignore-undervoltage"); in max3191x_probe()
405 if (max3191x->db0_pins && max3191x->db1_pins && in max3191x_probe()
406 max3191x->db0_pins->ndescs != max3191x->db1_pins->ndescs) { in max3191x_probe()
407 dev_err(dev, "ignoring maxim,db*-gpios: array len mismatch\n"); in max3191x_probe()
408 devm_gpiod_put_array(dev, max3191x->db0_pins); in max3191x_probe()
409 devm_gpiod_put_array(dev, max3191x->db1_pins); in max3191x_probe()
410 max3191x->db0_pins = NULL; in max3191x_probe()
411 max3191x->db1_pins = NULL; in max3191x_probe()
414 max3191x->xfer.len = max3191x->nchips * max3191x_wordlen(max3191x); in max3191x_probe()
415 spi_message_init_with_transfers(&max3191x->mesg, &max3191x->xfer, 1); in max3191x_probe()
417 max3191x->gpio.label = spi->modalias; in max3191x_probe()
418 max3191x->gpio.owner = THIS_MODULE; in max3191x_probe()
419 max3191x->gpio.parent = dev; in max3191x_probe()
420 max3191x->gpio.base = -1; in max3191x_probe()
421 max3191x->gpio.ngpio = max3191x->nchips * MAX3191X_NGPIO; in max3191x_probe()
422 max3191x->gpio.can_sleep = true; in max3191x_probe()
424 max3191x->gpio.get_direction = max3191x_get_direction; in max3191x_probe()
425 max3191x->gpio.direction_input = max3191x_direction_input; in max3191x_probe()
426 max3191x->gpio.direction_output = max3191x_direction_output; in max3191x_probe()
427 max3191x->gpio.set = max3191x_set; in max3191x_probe()
428 max3191x->gpio.set_multiple = max3191x_set_multiple; in max3191x_probe()
429 max3191x->gpio.get = max3191x_get; in max3191x_probe()
430 max3191x->gpio.get_multiple = max3191x_get_multiple; in max3191x_probe()
431 max3191x->gpio.set_config = max3191x_set_config; in max3191x_probe()
433 mutex_init(&max3191x->lock); in max3191x_probe()
435 ret = gpiochip_add_data(&max3191x->gpio, max3191x); in max3191x_probe()
437 mutex_destroy(&max3191x->lock); in max3191x_probe()
448 gpiochip_remove(&max3191x->gpio); in max3191x_remove()
449 mutex_destroy(&max3191x->lock); in max3191x_remove()
495 MODULE_AUTHOR("Lukas Wunner <lukas@wunner.de>");
496 MODULE_DESCRIPTION("GPIO driver for Maxim MAX3191x industrial serializer");