Lines Matching refs:gdev
110 struct gpio_device *gdev; in gpio_to_desc() local
115 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_to_desc()
116 if (gdev->base <= gpio && in gpio_to_desc()
117 gdev->base + gdev->ngpio > gpio) { in gpio_to_desc()
119 return &gdev->descs[gpio - gdev->base]; in gpio_to_desc()
145 struct gpio_device *gdev = gc->gpiodev; in gpiochip_get_desc() local
147 if (hwnum >= gdev->ngpio) in gpiochip_get_desc()
150 return &gdev->descs[hwnum]; in gpiochip_get_desc()
166 return desc->gdev->base + (desc - &desc->gdev->descs[0]); in desc_to_gpio()
177 if (!desc || !desc->gdev) in gpiod_to_chip()
179 return desc->gdev->chip; in gpiod_to_chip()
186 struct gpio_device *gdev; in gpiochip_find_base() local
189 list_for_each_entry_reverse(gdev, &gpio_devices, list) { in gpiochip_find_base()
191 if (gdev->base + gdev->ngpio <= base) in gpiochip_find_base()
194 base = gdev->base - ngpio; in gpiochip_find_base()
255 static int gpiodev_add_to_list(struct gpio_device *gdev) in gpiodev_add_to_list() argument
261 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
266 if (gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
268 list_add(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
273 if (prev->base + prev->ngpio <= gdev->base) { in gpiodev_add_to_list()
275 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
285 if (prev->base + prev->ngpio <= gdev->base in gpiodev_add_to_list()
286 && gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
287 list_add(&gdev->list, &prev->list); in gpiodev_add_to_list()
292 dev_err(&gdev->dev, "GPIO integer space overlap, cannot add chip\n"); in gpiodev_add_to_list()
304 struct gpio_device *gdev; in gpio_name_to_desc() local
312 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_name_to_desc()
315 for (i = 0; i != gdev->ngpio; ++i) { in gpio_name_to_desc()
316 struct gpio_desc *desc = &gdev->descs[i]; in gpio_name_to_desc()
343 struct gpio_device *gdev = gc->gpiodev; in gpiochip_set_desc_names() local
352 dev_warn(&gdev->dev, in gpiochip_set_desc_names()
359 gdev->descs[i].name = gc->names[i]; in gpiochip_set_desc_names()
375 struct gpio_device *gdev = chip->gpiodev; in devprop_gpiochip_set_names() local
376 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); in devprop_gpiochip_set_names()
385 if (count > gdev->ngpio) { in devprop_gpiochip_set_names()
386 dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", in devprop_gpiochip_set_names()
387 count, gdev->ngpio); in devprop_gpiochip_set_names()
388 count = gdev->ngpio; in devprop_gpiochip_set_names()
398 dev_warn(&gdev->dev, "failed to read GPIO line names\n"); in devprop_gpiochip_set_names()
404 gdev->descs[i].name = names[i]; in devprop_gpiochip_set_names()
473 struct gpio_device *gdev = container_of(dev, struct gpio_device, dev); in gpiodevice_release() local
477 list_del(&gdev->list); in gpiodevice_release()
480 ida_free(&gpio_ida, gdev->id); in gpiodevice_release()
481 kfree_const(gdev->label); in gpiodevice_release()
482 kfree(gdev->descs); in gpiodevice_release()
483 kfree(gdev); in gpiodevice_release()
487 #define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt)) argument
488 #define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev)) argument
494 #define gcdev_register(gdev, devt) device_add(&(gdev)->dev) argument
495 #define gcdev_unregister(gdev) device_del(&(gdev)->dev) argument
498 static int gpiochip_setup_dev(struct gpio_device *gdev) in gpiochip_setup_dev() argument
502 ret = gcdev_register(gdev, gpio_devt); in gpiochip_setup_dev()
506 ret = gpiochip_sysfs_register(gdev); in gpiochip_setup_dev()
511 gdev->dev.release = gpiodevice_release; in gpiochip_setup_dev()
512 dev_dbg(&gdev->dev, "registered GPIOs %d to %d on %s\n", gdev->base, in gpiochip_setup_dev()
513 gdev->base + gdev->ngpio - 1, gdev->chip->label ? : "generic"); in gpiochip_setup_dev()
518 gcdev_unregister(gdev); in gpiochip_setup_dev()
559 struct gpio_device *gdev; in gpiochip_setup_devs() local
562 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_setup_devs()
563 ret = gpiochip_setup_dev(gdev); in gpiochip_setup_devs()
565 dev_err(&gdev->dev, in gpiochip_setup_devs()
579 struct gpio_device *gdev; in gpiochip_add_data_with_key() local
586 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); in gpiochip_add_data_with_key()
587 if (!gdev) in gpiochip_add_data_with_key()
589 gdev->dev.bus = &gpio_bus_type; in gpiochip_add_data_with_key()
590 gdev->chip = gc; in gpiochip_add_data_with_key()
591 gc->gpiodev = gdev; in gpiochip_add_data_with_key()
593 gdev->dev.parent = gc->parent; in gpiochip_add_data_with_key()
594 gdev->dev.of_node = gc->parent->of_node; in gpiochip_add_data_with_key()
597 of_gpio_dev_init(gc, gdev); in gpiochip_add_data_with_key()
603 gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode; in gpiochip_add_data_with_key()
605 gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); in gpiochip_add_data_with_key()
606 if (gdev->id < 0) { in gpiochip_add_data_with_key()
607 ret = gdev->id; in gpiochip_add_data_with_key()
611 ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); in gpiochip_add_data_with_key()
615 device_initialize(&gdev->dev); in gpiochip_add_data_with_key()
617 gdev->owner = gc->parent->driver->owner; in gpiochip_add_data_with_key()
620 gdev->owner = gc->owner; in gpiochip_add_data_with_key()
622 gdev->owner = THIS_MODULE; in gpiochip_add_data_with_key()
624 gdev->descs = kcalloc(gc->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL); in gpiochip_add_data_with_key()
625 if (!gdev->descs) { in gpiochip_add_data_with_key()
640 gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); in gpiochip_add_data_with_key()
641 if (!gdev->label) { in gpiochip_add_data_with_key()
646 gdev->ngpio = gc->ngpio; in gpiochip_add_data_with_key()
647 gdev->data = data; in gpiochip_add_data_with_key()
673 gdev->base = base; in gpiochip_add_data_with_key()
675 ret = gpiodev_add_to_list(gdev); in gpiochip_add_data_with_key()
682 gdev->descs[i].gdev = gdev; in gpiochip_add_data_with_key()
686 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->notifier); in gpiochip_add_data_with_key()
689 INIT_LIST_HEAD(&gdev->pin_ranges); in gpiochip_add_data_with_key()
711 trace_android_vh_gpio_block_read(gdev, &block_gpio_read); in gpiochip_add_data_with_key()
714 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key()
755 ret = gpiochip_setup_dev(gdev); in gpiochip_add_data_with_key()
775 list_del(&gdev->list); in gpiochip_add_data_with_key()
778 kfree_const(gdev->label); in gpiochip_add_data_with_key()
780 kfree(gdev->descs); in gpiochip_add_data_with_key()
782 kfree(dev_name(&gdev->dev)); in gpiochip_add_data_with_key()
784 ida_free(&gpio_ida, gdev->id); in gpiochip_add_data_with_key()
788 gdev->base, gdev->base + gdev->ngpio - 1, in gpiochip_add_data_with_key()
790 kfree(gdev); in gpiochip_add_data_with_key()
816 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove() local
821 gpiochip_sysfs_unregister(gdev); in gpiochip_remove()
824 gdev->chip = NULL; in gpiochip_remove()
834 gdev->data = NULL; in gpiochip_remove()
837 for (i = 0; i < gdev->ngpio; i++) { in gpiochip_remove()
843 if (i != gdev->ngpio) in gpiochip_remove()
844 dev_crit(&gdev->dev, in gpiochip_remove()
853 gcdev_unregister(gdev); in gpiochip_remove()
854 put_device(&gdev->dev); in gpiochip_remove()
873 struct gpio_device *gdev; in gpiochip_find() local
878 list_for_each_entry(gdev, &gpio_devices, list) in gpiochip_find()
879 if (gdev->chip && match(gdev->chip, data)) { in gpiochip_find()
880 gc = gdev->chip; in gpiochip_find()
1883 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pingroup_range() local
1896 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pingroup_range()
1913 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pingroup_range()
1941 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pin_range() local
1954 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pin_range()
1970 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pin_range()
1983 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove_pin_ranges() local
1985 list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { in gpiochip_remove_pin_ranges()
2002 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
2070 if (!desc->gdev) { in validate_desc()
2074 if (!desc->gdev->chip) { in validate_desc()
2075 dev_warn(&desc->gdev->dev, in validate_desc()
2097 struct gpio_device *gdev; in gpiod_request() local
2100 gdev = desc->gdev; in gpiod_request()
2102 if (try_module_get(gdev->owner)) { in gpiod_request()
2105 module_put(gdev->owner); in gpiod_request()
2107 get_device(&gdev->dev); in gpiod_request()
2128 gc = desc->gdev->chip; in gpiod_free_commit()
2158 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_free_commit()
2166 if (desc && desc->gdev && gpiod_free_commit(desc)) { in gpiod_free()
2167 module_put(desc->gdev->owner); in gpiod_free()
2168 put_device(&desc->gdev->dev); in gpiod_free()
2289 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config()
2342 gc = desc->gdev->chip; in gpiod_direction_input()
2384 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2530 gc = desc->gdev->chip; in gpiod_set_config()
2577 gc = desc->gdev->chip; in gpiod_set_transitory()
2586 dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", in gpiod_set_transitory()
2647 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2711 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_get_array_value_complex()
2745 (desc_array[i]->gdev->chip == gc)); in gpiod_get_array_value_complex()
2790 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2811 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
2885 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
2910 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
2931 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
2994 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_set_array_value_complex()
3049 (desc_array[i]->gdev->chip == gc)); in gpiod_set_array_value_complex()
3075 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
3116 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3180 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3222 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3225 gc = desc->gdev->chip; in gpiod_to_irq()
4045 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_get_index()
4113 blocking_notifier_call_chain(&desc->gdev->notifier, in fwnode_get_named_gpiod()
4454 static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) in gpiolib_dbg_show() argument
4457 struct gpio_chip *gc = gdev->chip; in gpiolib_dbg_show()
4458 unsigned gpio = gdev->base; in gpiolib_dbg_show()
4459 struct gpio_desc *gdesc = &gdev->descs[0]; in gpiolib_dbg_show()
4464 for (i = 0; i < gdev->ngpio; i++, gpio++, gdesc++) { in gpiolib_dbg_show()
4490 struct gpio_device *gdev = NULL; in gpiolib_seq_start() local
4496 list_for_each_entry(gdev, &gpio_devices, list) in gpiolib_seq_start()
4499 return gdev; in gpiolib_seq_start()
4509 struct gpio_device *gdev = v; in gpiolib_seq_next() local
4513 if (list_is_last(&gdev->list, &gpio_devices)) in gpiolib_seq_next()
4516 ret = list_entry(gdev->list.next, struct gpio_device, list); in gpiolib_seq_next()
4531 struct gpio_device *gdev = v; in gpiolib_seq_show() local
4532 struct gpio_chip *gc = gdev->chip; in gpiolib_seq_show()
4537 dev_name(&gdev->dev)); in gpiolib_seq_show()
4542 dev_name(&gdev->dev), in gpiolib_seq_show()
4543 gdev->base, gdev->base + gdev->ngpio - 1); in gpiolib_seq_show()
4558 gpiolib_dbg_show(s, gdev); in gpiolib_seq_show()