}
EXPORT_SYMBOL_GPL(gpiod_get_direction);
+/**
+ * gpiod_is_single_ended - check if the GPIO is configured as single-ended
+ * @desc: the GPIO descriptor to check
+ *
+ * Returns true if the GPIO is configured as either Open Drain or Open Source.
+ * In these modes, the direction of the line cannot always be reliably
+ * determined by reading hardware registers, as the "off" state (High-Z)
+ * is physically indistinguishable from an input state.
+ */
+bool gpiod_is_single_ended(struct gpio_desc *desc)
+{
+ if (!desc)
+ return false;
+
+ if (test_bit(GPIOD_FLAG_OPEN_DRAIN, &desc->flags) ||
+ test_bit(GPIOD_FLAG_OPEN_SOURCE, &desc->flags))
+ return true;
+
+ return false;
+}
+EXPORT_SYMBOL_GPL(gpiod_is_single_ended);
+
/*
* Add a new chip to the global chips list, keeping the list of chips sorted
* by range(means [base, base + ngpio - 1]) order.
void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs);
int gpiod_get_direction(struct gpio_desc *desc);
+bool gpiod_is_single_ended(struct gpio_desc *desc);
int gpiod_direction_input(struct gpio_desc *desc);
int gpiod_direction_output(struct gpio_desc *desc, int value);
int gpiod_direction_output_raw(struct gpio_desc *desc, int value);
WARN_ON(desc);
return -ENOSYS;
}
+static inline bool gpiod_is_single_ended(struct gpio_desc *desc)
+{
+ return false;
+}
static inline int gpiod_direction_input(struct gpio_desc *desc)
{
/* GPIO can never have been requested */