Lines Matching refs:desc
182 int desc_to_gpio(const struct gpio_desc *desc) in desc_to_gpio() argument
184 return desc->gdev->base + (desc - &desc->gdev->descs[0]); in desc_to_gpio()
193 struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) in gpiod_to_chip() argument
195 if (!desc || !desc->gdev) in gpiod_to_chip()
197 return desc->gdev->chip; in gpiod_to_chip()
234 int gpiod_get_direction(struct gpio_desc *desc) in gpiod_get_direction() argument
240 gc = gpiod_to_chip(desc); in gpiod_get_direction()
241 offset = gpio_chip_hwgpio(desc); in gpiod_get_direction()
247 if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) && in gpiod_get_direction()
248 test_bit(FLAG_IS_OUT, &desc->flags)) in gpiod_get_direction()
262 assign_bit(FLAG_IS_OUT, &desc->flags, !ret); in gpiod_get_direction()
332 struct gpio_desc *desc; in gpio_name_to_desc() local
334 for_each_gpio_desc(gdev->chip, desc) { in gpio_name_to_desc()
335 if (desc->name && !strcmp(desc->name, name)) { in gpio_name_to_desc()
337 return desc; in gpio_name_to_desc()
640 struct gpio_desc *desc; in gpiochip_machine_hog() local
643 desc = gpiochip_get_desc(gc, hog->chip_hwnum); in gpiochip_machine_hog()
644 if (IS_ERR(desc)) { in gpiochip_machine_hog()
646 PTR_ERR(desc)); in gpiochip_machine_hog()
650 if (test_bit(FLAG_IS_HOGGED, &desc->flags)) in gpiochip_machine_hog()
653 rv = gpiod_hog(desc, hog->line_name, hog->lflags, hog->dflags); in gpiochip_machine_hog()
655 gpiod_err(desc, "%s: unable to hog GPIO line (%s:%u): %d\n", in gpiochip_machine_hog()
877 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key() local
881 &desc->flags, !gc->get_direction(gc, i)); in gpiochip_add_data_with_key()
884 &desc->flags, !gc->direction_input); in gpiochip_add_data_with_key()
2086 static int gpiod_request_commit(struct gpio_desc *desc, const char *label) in gpiod_request_commit() argument
2088 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
2105 if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) { in gpiod_request_commit()
2106 desc_set_label(desc, label ? : "?"); in gpiod_request_commit()
2115 offset = gpio_chip_hwgpio(desc); in gpiod_request_commit()
2123 desc_set_label(desc, NULL); in gpiod_request_commit()
2124 clear_bit(FLAG_REQUESTED, &desc->flags); in gpiod_request_commit()
2131 gpiod_get_direction(desc); in gpiod_request_commit()
2149 static int validate_desc(const struct gpio_desc *desc, const char *func) in validate_desc() argument
2151 if (!desc) in validate_desc()
2153 if (IS_ERR(desc)) { in validate_desc()
2155 return PTR_ERR(desc); in validate_desc()
2157 if (!desc->gdev) { in validate_desc()
2161 if (!desc->gdev->chip) { in validate_desc()
2162 dev_warn(&desc->gdev->dev, in validate_desc()
2169 #define VALIDATE_DESC(desc) do { \ argument
2170 int __valid = validate_desc(desc, __func__); \
2175 #define VALIDATE_DESC_VOID(desc) do { \ argument
2176 int __valid = validate_desc(desc, __func__); \
2181 int gpiod_request(struct gpio_desc *desc, const char *label) in gpiod_request() argument
2185 VALIDATE_DESC(desc); in gpiod_request()
2187 if (try_module_get(desc->gdev->owner)) { in gpiod_request()
2188 ret = gpiod_request_commit(desc, label); in gpiod_request()
2190 module_put(desc->gdev->owner); in gpiod_request()
2192 gpio_device_get(desc->gdev); in gpiod_request()
2196 gpiod_dbg(desc, "%s: status %d\n", __func__, ret); in gpiod_request()
2201 static bool gpiod_free_commit(struct gpio_desc *desc) in gpiod_free_commit() argument
2211 gc = desc->gdev->chip; in gpiod_free_commit()
2212 if (gc && test_bit(FLAG_REQUESTED, &desc->flags)) { in gpiod_free_commit()
2216 gc->free(gc, gpio_chip_hwgpio(desc)); in gpiod_free_commit()
2219 kfree_const(desc->label); in gpiod_free_commit()
2220 desc_set_label(desc, NULL); in gpiod_free_commit()
2221 clear_bit(FLAG_ACTIVE_LOW, &desc->flags); in gpiod_free_commit()
2222 clear_bit(FLAG_REQUESTED, &desc->flags); in gpiod_free_commit()
2223 clear_bit(FLAG_OPEN_DRAIN, &desc->flags); in gpiod_free_commit()
2224 clear_bit(FLAG_OPEN_SOURCE, &desc->flags); in gpiod_free_commit()
2225 clear_bit(FLAG_PULL_UP, &desc->flags); in gpiod_free_commit()
2226 clear_bit(FLAG_PULL_DOWN, &desc->flags); in gpiod_free_commit()
2227 clear_bit(FLAG_BIAS_DISABLE, &desc->flags); in gpiod_free_commit()
2228 clear_bit(FLAG_EDGE_RISING, &desc->flags); in gpiod_free_commit()
2229 clear_bit(FLAG_EDGE_FALLING, &desc->flags); in gpiod_free_commit()
2230 clear_bit(FLAG_IS_HOGGED, &desc->flags); in gpiod_free_commit()
2232 desc->hog = NULL; in gpiod_free_commit()
2235 WRITE_ONCE(desc->debounce_period_us, 0); in gpiod_free_commit()
2241 gpiod_line_state_notify(desc, GPIOLINE_CHANGED_RELEASED); in gpiod_free_commit()
2246 void gpiod_free(struct gpio_desc *desc) in gpiod_free() argument
2252 if (!desc) in gpiod_free()
2255 if (!gpiod_free_commit(desc)) in gpiod_free()
2258 module_put(desc->gdev->owner); in gpiod_free()
2259 gpio_device_put(desc->gdev); in gpiod_free()
2277 struct gpio_desc *desc; in gpiochip_is_requested() local
2279 desc = gpiochip_get_desc(gc, offset); in gpiochip_is_requested()
2280 if (IS_ERR(desc)) in gpiochip_is_requested()
2283 if (test_bit(FLAG_REQUESTED, &desc->flags) == 0) in gpiochip_is_requested()
2285 return desc->label; in gpiochip_is_requested()
2316 struct gpio_desc *desc = gpiochip_get_desc(gc, hwnum); in gpiochip_request_own_desc() local
2319 if (IS_ERR(desc)) { in gpiochip_request_own_desc()
2321 return desc; in gpiochip_request_own_desc()
2324 ret = gpiod_request_commit(desc, label); in gpiochip_request_own_desc()
2328 ret = gpiod_configure_flags(desc, label, lflags, dflags); in gpiochip_request_own_desc()
2331 gpiod_free_commit(desc); in gpiochip_request_own_desc()
2335 return desc; in gpiochip_request_own_desc()
2346 void gpiochip_free_own_desc(struct gpio_desc *desc) in gpiochip_free_own_desc() argument
2348 if (desc) in gpiochip_free_own_desc()
2349 gpiod_free_commit(desc); in gpiochip_free_own_desc()
2372 static int gpio_set_config_with_argument(struct gpio_desc *desc, in gpio_set_config_with_argument() argument
2376 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config_with_argument()
2380 return gpio_do_set_config(gc, gpio_chip_hwgpio(desc), config); in gpio_set_config_with_argument()
2383 static int gpio_set_config_with_argument_optional(struct gpio_desc *desc, in gpio_set_config_with_argument_optional() argument
2387 struct device *dev = &desc->gdev->dev; in gpio_set_config_with_argument_optional()
2388 int gpio = gpio_chip_hwgpio(desc); in gpio_set_config_with_argument_optional()
2391 ret = gpio_set_config_with_argument(desc, mode, argument); in gpio_set_config_with_argument_optional()
2406 static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode) in gpio_set_config() argument
2408 return gpio_set_config_with_argument(desc, mode, 0); in gpio_set_config()
2411 static int gpio_set_bias(struct gpio_desc *desc) in gpio_set_bias() argument
2416 if (test_bit(FLAG_BIAS_DISABLE, &desc->flags)) in gpio_set_bias()
2418 else if (test_bit(FLAG_PULL_UP, &desc->flags)) in gpio_set_bias()
2420 else if (test_bit(FLAG_PULL_DOWN, &desc->flags)) in gpio_set_bias()
2436 return gpio_set_config_with_argument_optional(desc, bias, arg); in gpio_set_bias()
2449 int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce) in gpio_set_debounce_timeout() argument
2451 return gpio_set_config_with_argument_optional(desc, in gpio_set_debounce_timeout()
2465 int gpiod_direction_input(struct gpio_desc *desc) in gpiod_direction_input() argument
2470 VALIDATE_DESC(desc); in gpiod_direction_input()
2471 gc = desc->gdev->chip; in gpiod_direction_input()
2479 gpiod_warn(desc, in gpiod_direction_input()
2492 ret = gc->direction_input(gc, gpio_chip_hwgpio(desc)); in gpiod_direction_input()
2494 (gc->get_direction(gc, gpio_chip_hwgpio(desc)) != 1)) { in gpiod_direction_input()
2495 gpiod_warn(desc, in gpiod_direction_input()
2501 clear_bit(FLAG_IS_OUT, &desc->flags); in gpiod_direction_input()
2502 ret = gpio_set_bias(desc); in gpiod_direction_input()
2505 trace_gpio_direction(desc_to_gpio(desc), 1, ret); in gpiod_direction_input()
2511 static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value) in gpiod_direction_output_raw_commit() argument
2513 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2523 gpiod_warn(desc, in gpiod_direction_output_raw_commit()
2530 ret = gc->direction_output(gc, gpio_chip_hwgpio(desc), val); in gpiod_direction_output_raw_commit()
2534 gc->get_direction(gc, gpio_chip_hwgpio(desc))) { in gpiod_direction_output_raw_commit()
2535 gpiod_warn(desc, in gpiod_direction_output_raw_commit()
2544 gc->set(gc, gpio_chip_hwgpio(desc), val); in gpiod_direction_output_raw_commit()
2548 set_bit(FLAG_IS_OUT, &desc->flags); in gpiod_direction_output_raw_commit()
2549 trace_gpio_value(desc_to_gpio(desc), 0, val); in gpiod_direction_output_raw_commit()
2550 trace_gpio_direction(desc_to_gpio(desc), 0, ret); in gpiod_direction_output_raw_commit()
2565 int gpiod_direction_output_raw(struct gpio_desc *desc, int value) in gpiod_direction_output_raw() argument
2567 VALIDATE_DESC(desc); in gpiod_direction_output_raw()
2568 return gpiod_direction_output_raw_commit(desc, value); in gpiod_direction_output_raw()
2584 int gpiod_direction_output(struct gpio_desc *desc, int value) in gpiod_direction_output() argument
2588 VALIDATE_DESC(desc); in gpiod_direction_output()
2589 if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) in gpiod_direction_output()
2595 if (test_bit(FLAG_USED_AS_IRQ, &desc->flags) && in gpiod_direction_output()
2596 test_bit(FLAG_IRQ_IS_ENABLED, &desc->flags)) { in gpiod_direction_output()
2597 gpiod_err(desc, in gpiod_direction_output()
2603 if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { in gpiod_direction_output()
2605 ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_DRAIN); in gpiod_direction_output()
2610 ret = gpiod_direction_input(desc); in gpiod_direction_output()
2613 } else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { in gpiod_direction_output()
2614 ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_SOURCE); in gpiod_direction_output()
2619 ret = gpiod_direction_input(desc); in gpiod_direction_output()
2623 gpio_set_config(desc, PIN_CONFIG_DRIVE_PUSH_PULL); in gpiod_direction_output()
2627 ret = gpio_set_bias(desc); in gpiod_direction_output()
2630 return gpiod_direction_output_raw_commit(desc, value); in gpiod_direction_output()
2640 set_bit(FLAG_IS_OUT, &desc->flags); in gpiod_direction_output()
2653 int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags) in gpiod_enable_hw_timestamp_ns() argument
2658 VALIDATE_DESC(desc); in gpiod_enable_hw_timestamp_ns()
2660 gc = desc->gdev->chip; in gpiod_enable_hw_timestamp_ns()
2662 gpiod_warn(desc, "%s: hw ts not supported\n", __func__); in gpiod_enable_hw_timestamp_ns()
2666 ret = gc->en_hw_timestamp(gc, gpio_chip_hwgpio(desc), flags); in gpiod_enable_hw_timestamp_ns()
2668 gpiod_warn(desc, "%s: hw ts request failed\n", __func__); in gpiod_enable_hw_timestamp_ns()
2682 int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags) in gpiod_disable_hw_timestamp_ns() argument
2687 VALIDATE_DESC(desc); in gpiod_disable_hw_timestamp_ns()
2689 gc = desc->gdev->chip; in gpiod_disable_hw_timestamp_ns()
2691 gpiod_warn(desc, "%s: hw ts not supported\n", __func__); in gpiod_disable_hw_timestamp_ns()
2695 ret = gc->dis_hw_timestamp(gc, gpio_chip_hwgpio(desc), flags); in gpiod_disable_hw_timestamp_ns()
2697 gpiod_warn(desc, "%s: hw ts release failed\n", __func__); in gpiod_disable_hw_timestamp_ns()
2712 int gpiod_set_config(struct gpio_desc *desc, unsigned long config) in gpiod_set_config() argument
2716 VALIDATE_DESC(desc); in gpiod_set_config()
2717 gc = desc->gdev->chip; in gpiod_set_config()
2719 return gpio_do_set_config(gc, gpio_chip_hwgpio(desc), config); in gpiod_set_config()
2732 int gpiod_set_debounce(struct gpio_desc *desc, unsigned int debounce) in gpiod_set_debounce() argument
2737 return gpiod_set_config(desc, config); in gpiod_set_debounce()
2749 int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) in gpiod_set_transitory() argument
2751 VALIDATE_DESC(desc); in gpiod_set_transitory()
2756 assign_bit(FLAG_TRANSITORY, &desc->flags, transitory); in gpiod_set_transitory()
2759 return gpio_set_config_with_argument_optional(desc, in gpiod_set_transitory()
2771 int gpiod_is_active_low(const struct gpio_desc *desc) in gpiod_is_active_low() argument
2773 VALIDATE_DESC(desc); in gpiod_is_active_low()
2774 return test_bit(FLAG_ACTIVE_LOW, &desc->flags); in gpiod_is_active_low()
2782 void gpiod_toggle_active_low(struct gpio_desc *desc) in gpiod_toggle_active_low() argument
2784 VALIDATE_DESC_VOID(desc); in gpiod_toggle_active_low()
2785 change_bit(FLAG_ACTIVE_LOW, &desc->flags); in gpiod_toggle_active_low()
2789 static int gpio_chip_get_value(struct gpio_chip *gc, const struct gpio_desc *desc) in gpio_chip_get_value() argument
2791 return gc->get ? gc->get(gc, gpio_chip_hwgpio(desc)) : -EIO; in gpio_chip_get_value()
2816 static int gpiod_get_raw_value_commit(const struct gpio_desc *desc) in gpiod_get_raw_value_commit() argument
2821 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2822 value = gpio_chip_get_value(gc, desc); in gpiod_get_raw_value_commit()
2824 trace_gpio_value(desc_to_gpio(desc), 1, value); in gpiod_get_raw_value_commit()
2860 if (array_info && array_info->desc == desc_array && in gpiod_get_array_value_complex()
2915 const struct gpio_desc *desc = desc_array[i]; in gpiod_get_array_value_complex() local
2916 int hwgpio = gpio_chip_hwgpio(desc); in gpiod_get_array_value_complex()
2937 const struct gpio_desc *desc = desc_array[j]; in gpiod_get_array_value_complex() local
2938 int hwgpio = gpio_chip_hwgpio(desc); in gpiod_get_array_value_complex()
2941 if (!raw && test_bit(FLAG_ACTIVE_LOW, &desc->flags)) in gpiod_get_array_value_complex()
2944 trace_gpio_value(desc_to_gpio(desc), 1, value); in gpiod_get_array_value_complex()
2970 int gpiod_get_raw_value(const struct gpio_desc *desc) in gpiod_get_raw_value() argument
2972 VALIDATE_DESC(desc); in gpiod_get_raw_value()
2974 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2975 return gpiod_get_raw_value_commit(desc); in gpiod_get_raw_value()
2989 int gpiod_get_value(const struct gpio_desc *desc) in gpiod_get_value() argument
2993 VALIDATE_DESC(desc); in gpiod_get_value()
2995 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
2997 value = gpiod_get_raw_value_commit(desc); in gpiod_get_value()
3001 if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) in gpiod_get_value()
3066 static void gpio_set_open_drain_value_commit(struct gpio_desc *desc, bool value) in gpio_set_open_drain_value_commit() argument
3069 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
3070 int offset = gpio_chip_hwgpio(desc); in gpio_set_open_drain_value_commit()
3077 set_bit(FLAG_IS_OUT, &desc->flags); in gpio_set_open_drain_value_commit()
3079 trace_gpio_direction(desc_to_gpio(desc), value, ret); in gpio_set_open_drain_value_commit()
3081 gpiod_err(desc, in gpio_set_open_drain_value_commit()
3091 static void gpio_set_open_source_value_commit(struct gpio_desc *desc, bool value) in gpio_set_open_source_value_commit() argument
3094 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
3095 int offset = gpio_chip_hwgpio(desc); in gpio_set_open_source_value_commit()
3100 set_bit(FLAG_IS_OUT, &desc->flags); in gpio_set_open_source_value_commit()
3104 trace_gpio_direction(desc_to_gpio(desc), !value, ret); in gpio_set_open_source_value_commit()
3106 gpiod_err(desc, in gpio_set_open_source_value_commit()
3111 static void gpiod_set_raw_value_commit(struct gpio_desc *desc, bool value) in gpiod_set_raw_value_commit() argument
3115 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
3116 trace_gpio_value(desc_to_gpio(desc), 0, value); in gpiod_set_raw_value_commit()
3117 gc->set(gc, gpio_chip_hwgpio(desc), value); in gpiod_set_raw_value_commit()
3157 if (array_info && array_info->desc == desc_array && in gpiod_set_array_value_complex()
3207 struct gpio_desc *desc = desc_array[i]; in gpiod_set_array_value_complex() local
3208 int hwgpio = gpio_chip_hwgpio(desc); in gpiod_set_array_value_complex()
3218 test_bit(FLAG_ACTIVE_LOW, &desc->flags)) in gpiod_set_array_value_complex()
3220 trace_gpio_value(desc_to_gpio(desc), 0, value); in gpiod_set_array_value_complex()
3225 if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) && !raw) { in gpiod_set_array_value_complex()
3226 gpio_set_open_drain_value_commit(desc, value); in gpiod_set_array_value_complex()
3227 } else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags) && !raw) { in gpiod_set_array_value_complex()
3228 gpio_set_open_source_value_commit(desc, value); in gpiod_set_array_value_complex()
3264 void gpiod_set_raw_value(struct gpio_desc *desc, int value) in gpiod_set_raw_value() argument
3266 VALIDATE_DESC_VOID(desc); in gpiod_set_raw_value()
3268 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
3269 gpiod_set_raw_value_commit(desc, value); in gpiod_set_raw_value()
3282 static void gpiod_set_value_nocheck(struct gpio_desc *desc, int value) in gpiod_set_value_nocheck() argument
3284 if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) in gpiod_set_value_nocheck()
3286 if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) in gpiod_set_value_nocheck()
3287 gpio_set_open_drain_value_commit(desc, value); in gpiod_set_value_nocheck()
3288 else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) in gpiod_set_value_nocheck()
3289 gpio_set_open_source_value_commit(desc, value); in gpiod_set_value_nocheck()
3291 gpiod_set_raw_value_commit(desc, value); in gpiod_set_value_nocheck()
3305 void gpiod_set_value(struct gpio_desc *desc, int value) in gpiod_set_value() argument
3307 VALIDATE_DESC_VOID(desc); in gpiod_set_value()
3309 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3310 gpiod_set_value_nocheck(desc, value); in gpiod_set_value()
3370 int gpiod_cansleep(const struct gpio_desc *desc) in gpiod_cansleep() argument
3372 VALIDATE_DESC(desc); in gpiod_cansleep()
3373 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3382 int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) in gpiod_set_consumer_name() argument
3384 VALIDATE_DESC(desc); in gpiod_set_consumer_name()
3391 kfree_const(desc->label); in gpiod_set_consumer_name()
3392 desc_set_label(desc, name); in gpiod_set_consumer_name()
3405 int gpiod_to_irq(const struct gpio_desc *desc) in gpiod_to_irq() argument
3415 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3418 gc = desc->gdev->chip; in gpiod_to_irq()
3419 offset = gpio_chip_hwgpio(desc); in gpiod_to_irq()
3453 struct gpio_desc *desc; in gpiochip_lock_as_irq() local
3455 desc = gpiochip_get_desc(gc, offset); in gpiochip_lock_as_irq()
3456 if (IS_ERR(desc)) in gpiochip_lock_as_irq()
3457 return PTR_ERR(desc); in gpiochip_lock_as_irq()
3464 int dir = gpiod_get_direction(desc); in gpiochip_lock_as_irq()
3474 if (test_bit(FLAG_IS_OUT, &desc->flags) && in gpiochip_lock_as_irq()
3475 !test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { in gpiochip_lock_as_irq()
3482 set_bit(FLAG_USED_AS_IRQ, &desc->flags); in gpiochip_lock_as_irq()
3483 set_bit(FLAG_IRQ_IS_ENABLED, &desc->flags); in gpiochip_lock_as_irq()
3490 if (!desc->label) in gpiochip_lock_as_irq()
3491 desc_set_label(desc, "interrupt"); in gpiochip_lock_as_irq()
3507 struct gpio_desc *desc; in gpiochip_unlock_as_irq() local
3509 desc = gpiochip_get_desc(gc, offset); in gpiochip_unlock_as_irq()
3510 if (IS_ERR(desc)) in gpiochip_unlock_as_irq()
3513 clear_bit(FLAG_USED_AS_IRQ, &desc->flags); in gpiochip_unlock_as_irq()
3514 clear_bit(FLAG_IRQ_IS_ENABLED, &desc->flags); in gpiochip_unlock_as_irq()
3517 if (desc->label && !strcmp(desc->label, "interrupt")) in gpiochip_unlock_as_irq()
3518 desc_set_label(desc, NULL); in gpiochip_unlock_as_irq()
3524 struct gpio_desc *desc = gpiochip_get_desc(gc, offset); in gpiochip_disable_irq() local
3526 if (!IS_ERR(desc) && in gpiochip_disable_irq()
3527 !WARN_ON(!test_bit(FLAG_USED_AS_IRQ, &desc->flags))) in gpiochip_disable_irq()
3528 clear_bit(FLAG_IRQ_IS_ENABLED, &desc->flags); in gpiochip_disable_irq()
3534 struct gpio_desc *desc = gpiochip_get_desc(gc, offset); in gpiochip_enable_irq() local
3536 if (!IS_ERR(desc) && in gpiochip_enable_irq()
3537 !WARN_ON(!test_bit(FLAG_USED_AS_IRQ, &desc->flags))) { in gpiochip_enable_irq()
3542 WARN_ON(test_bit(FLAG_IS_OUT, &desc->flags) && in gpiochip_enable_irq()
3543 !test_bit(FLAG_OPEN_DRAIN, &desc->flags)); in gpiochip_enable_irq()
3544 set_bit(FLAG_IRQ_IS_ENABLED, &desc->flags); in gpiochip_enable_irq()
3618 int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) in gpiod_get_raw_value_cansleep() argument
3621 VALIDATE_DESC(desc); in gpiod_get_raw_value_cansleep()
3622 return gpiod_get_raw_value_commit(desc); in gpiod_get_raw_value_cansleep()
3635 int gpiod_get_value_cansleep(const struct gpio_desc *desc) in gpiod_get_value_cansleep() argument
3640 VALIDATE_DESC(desc); in gpiod_get_value_cansleep()
3641 value = gpiod_get_raw_value_commit(desc); in gpiod_get_value_cansleep()
3645 if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) in gpiod_get_value_cansleep()
3715 void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value) in gpiod_set_raw_value_cansleep() argument
3718 VALIDATE_DESC_VOID(desc); in gpiod_set_raw_value_cansleep()
3719 gpiod_set_raw_value_commit(desc, value); in gpiod_set_raw_value_cansleep()
3733 void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) in gpiod_set_value_cansleep() argument
3736 VALIDATE_DESC_VOID(desc); in gpiod_set_value_cansleep()
3737 gpiod_set_value_nocheck(desc, value); in gpiod_set_value_cansleep()
3809 void gpiod_line_state_notify(struct gpio_desc *desc, unsigned long action) in gpiod_line_state_notify() argument
3811 blocking_notifier_call_chain(&desc->gdev->line_state_notifier, in gpiod_line_state_notify()
3812 action, desc); in gpiod_line_state_notify()
3915 struct gpio_desc *desc = ERR_PTR(-ENOENT); in gpiod_find() local
3921 return desc; in gpiod_find()
3935 desc = gpio_name_to_desc(p->key); in gpiod_find()
3936 if (desc) { in gpiod_find()
3938 return desc; in gpiod_find()
3969 desc = gpiochip_get_desc(gc, p->chip_hwnum); in gpiod_find()
3972 return desc; in gpiod_find()
3975 return desc; in gpiod_find()
4006 struct gpio_desc *desc = ERR_PTR(-ENOENT); in gpiod_find_by_fwnode() local
4011 desc = of_find_gpio(to_of_node(fwnode), con_id, idx, lookupflags); in gpiod_find_by_fwnode()
4015 desc = acpi_find_gpio(fwnode, con_id, idx, flags, lookupflags); in gpiod_find_by_fwnode()
4019 desc = swnode_find_gpio(fwnode, con_id, idx, lookupflags); in gpiod_find_by_fwnode()
4022 return desc; in gpiod_find_by_fwnode()
4034 struct gpio_desc *desc; in gpiod_find_and_request() local
4037 desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx, &flags, &lookupflags); in gpiod_find_and_request()
4038 if (gpiod_not_found(desc) && platform_lookup_allowed) { in gpiod_find_and_request()
4045 desc = gpiod_find(consumer, con_id, idx, &lookupflags); in gpiod_find_and_request()
4048 if (IS_ERR(desc)) { in gpiod_find_and_request()
4050 return desc; in gpiod_find_and_request()
4057 ret = gpiod_request(desc, label); in gpiod_find_and_request()
4072 return desc; in gpiod_find_and_request()
4075 ret = gpiod_configure_flags(desc, con_id, lookupflags, flags); in gpiod_find_and_request()
4078 gpiod_put(desc); in gpiod_find_and_request()
4082 gpiod_line_state_notify(desc, GPIOLINE_CHANGED_REQUESTED); in gpiod_find_and_request()
4084 return desc; in gpiod_find_and_request()
4191 int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, in gpiod_configure_flags() argument
4197 set_bit(FLAG_ACTIVE_LOW, &desc->flags); in gpiod_configure_flags()
4200 set_bit(FLAG_OPEN_DRAIN, &desc->flags); in gpiod_configure_flags()
4208 set_bit(FLAG_OPEN_DRAIN, &desc->flags); in gpiod_configure_flags()
4209 gpiod_warn(desc, in gpiod_configure_flags()
4214 set_bit(FLAG_OPEN_SOURCE, &desc->flags); in gpiod_configure_flags()
4219 gpiod_err(desc, in gpiod_configure_flags()
4225 set_bit(FLAG_PULL_UP, &desc->flags); in gpiod_configure_flags()
4227 set_bit(FLAG_PULL_DOWN, &desc->flags); in gpiod_configure_flags()
4229 set_bit(FLAG_BIAS_DISABLE, &desc->flags); in gpiod_configure_flags()
4231 ret = gpiod_set_transitory(desc, (lflags & GPIO_TRANSITORY)); in gpiod_configure_flags()
4237 gpiod_dbg(desc, "no flags found for %s\n", con_id); in gpiod_configure_flags()
4243 ret = gpiod_direction_output(desc, in gpiod_configure_flags()
4246 ret = gpiod_direction_input(desc); in gpiod_configure_flags()
4295 struct gpio_desc *desc; in gpiod_get_index_optional() local
4297 desc = gpiod_get_index(dev, con_id, index, flags); in gpiod_get_index_optional()
4298 if (gpiod_not_found(desc)) in gpiod_get_index_optional()
4301 return desc; in gpiod_get_index_optional()
4313 int gpiod_hog(struct gpio_desc *desc, const char *name, in gpiod_hog() argument
4321 gc = gpiod_to_chip(desc); in gpiod_hog()
4322 hwnum = gpio_chip_hwgpio(desc); in gpiod_hog()
4334 set_bit(FLAG_IS_HOGGED, &desc->flags); in gpiod_hog()
4336 gpiod_dbg(desc, "hogged as %s%s\n", in gpiod_hog()
4350 struct gpio_desc *desc; in gpiochip_free_hogs() local
4352 for_each_gpio_desc_with_flag(gc, desc, FLAG_IS_HOGGED) in gpiochip_free_hogs()
4353 gpiochip_free_own_desc(desc); in gpiochip_free_hogs()
4372 struct gpio_desc *desc; in gpiod_get_array() local
4383 descs_size = struct_size(descs, desc, count); in gpiod_get_array()
4389 desc = gpiod_get_index(dev, con_id, descs->ndescs, flags); in gpiod_get_array()
4390 if (IS_ERR(desc)) { in gpiod_get_array()
4392 return ERR_CAST(desc); in gpiod_get_array()
4395 descs->desc[descs->ndescs] = desc; in gpiod_get_array()
4397 gc = gpiod_to_chip(desc); in gpiod_get_array()
4402 if (descs->ndescs == 0 && gpio_chip_hwgpio(desc) == 0) { in gpiod_get_array()
4424 array_info->desc = descs->desc; in gpiod_get_array()
4447 else if (gpio_chip_hwgpio(desc) != descs->ndescs) { in gpiod_get_array()
4468 if (gpiod_is_active_low(desc)) in gpiod_get_array()
4513 void gpiod_put(struct gpio_desc *desc) in gpiod_put() argument
4515 if (desc) in gpiod_put()
4516 gpiod_free(desc); in gpiod_put()
4529 gpiod_put(descs->desc[i]); in gpiod_put_array()
4600 struct gpio_desc *desc; in gpiolib_dbg_show() local
4607 for_each_gpio_desc(gc, desc) { in gpiolib_dbg_show()
4608 if (test_bit(FLAG_REQUESTED, &desc->flags)) { in gpiolib_dbg_show()
4609 gpiod_get_direction(desc); in gpiolib_dbg_show()
4610 is_out = test_bit(FLAG_IS_OUT, &desc->flags); in gpiolib_dbg_show()
4611 value = gpio_chip_get_value(gc, desc); in gpiolib_dbg_show()
4612 is_irq = test_bit(FLAG_USED_AS_IRQ, &desc->flags); in gpiolib_dbg_show()
4613 active_low = test_bit(FLAG_ACTIVE_LOW, &desc->flags); in gpiolib_dbg_show()
4615 gpio, desc->name ?: "", desc->label, in gpiolib_dbg_show()
4620 } else if (desc->name) { in gpiolib_dbg_show()
4621 seq_printf(s, " gpio-%-3d (%-20.20s)\n", gpio, desc->name); in gpiolib_dbg_show()