Lines Matching +full:int +full:- +full:gpios

1 /* SPDX-License-Identifier: GPL-2.0+ */
15 * Generic GPIO API for U-Boot
17 * --
20 * - gpio_request_by_name()
21 * - dm_gpio_get_value() etc.
24 * --
26 * GPIOs are numbered from 0 to GPIO_COUNT-1 which value is defined
38 * an error value of -1.
51 * @return 0 if ok, -1 on error
53 int gpio_request(unsigned gpio, const char *label);
60 * @return 0 if ok, -1 on error
62 int gpio_free(unsigned gpio);
69 * @return 0 if ok, -1 on error
71 int gpio_direction_input(unsigned gpio);
79 * @return 0 if ok, -1 on error
81 int gpio_direction_output(unsigned gpio, int value);
89 * @return 0 if low, 1 if high, -1 on error
91 int gpio_get_value(unsigned gpio);
100 * @return 0 if ok, -1 on error
102 int gpio_set_value(unsigned gpio, int value);
134 * dm_gpio_is_valid() - Check if a GPIO is valid
142 return desc->dev != NULL; in dm_gpio_is_valid()
146 * gpio_get_status() - get the current GPIO status as a string
163 int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize);
166 * gpio_get_function() - get the current function for a GPIO pin
174 * @namep: If non-NULL, this is set to the name given when the GPIO
175 * was requested, or -1 if it has not been requested
176 * @return -ENODATA if the driver returned an unknown function,
177 * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
181 int gpio_get_function(struct udevice *dev, int offset, const char **namep);
184 * gpio_get_raw_function() - get the current raw function for a GPIO pin
186 * Note this does not return GPIOF_UNUSED - it will always return the GPIO
193 * @namep: If non-NULL, this is set to the name given when the GPIO
194 * was requested, or -1 if it has not been requested
195 * @return -ENODATA if the driver returned an unknown function,
196 * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
199 int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep);
202 * gpio_requestf() - request a GPIO using a format string for the owner
205 * a printf()-format string for the GPIO owner. It calls gpio_request() with
208 int gpio_requestf(unsigned gpio, const char *fmt, ...)
214 * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate
219 int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
223 * struct struct dm_gpio_ops - Driver model GPIO operations
228 * This is trying to be close to Linux GPIO API. Once the U-Boot uses the
230 * GPIO API-alike interface.
235 * gpio_request() and gpio_free() are optional - if NULL then they will
239 * offset 0 is the device's first GPIO and offset o-1 is the last GPIO,
241 * is typically used to control a single bank of GPIOs. Within complex
246 * numbering from 0 to n-1, where n is the number of GPIOs in total across
250 int (*request)(struct udevice *dev, unsigned offset, const char *label);
251 int (*free)(struct udevice *dev, unsigned offset);
252 int (*direction_input)(struct udevice *dev, unsigned offset);
253 int (*direction_output)(struct udevice *dev, unsigned offset,
254 int value);
255 int (*get_value)(struct udevice *dev, unsigned offset);
256 int (*set_value)(struct udevice *dev, unsigned offset, int value);
257 int (*get_open_drain)(struct udevice *dev, unsigned offset);
258 int (*set_open_drain)(struct udevice *dev, unsigned offset, int value);
264 * @return current function - GPIOF_...
266 int (*get_function)(struct udevice *dev, unsigned offset);
269 * xlate() - Translate phandle arguments into a GPIO description
274 * @desc->dev to @dev
275 * @desc->flags to 0
276 * @desc->offset to 0
284 * desc->dev.
289 * @return 0 if OK, -ve on error
291 int (*xlate)(struct udevice *dev, struct gpio_desc *desc,
296 * struct gpio_dev_priv - information about a device used by the uclass
304 * This tells the uclass the name of the GPIO bank and the number of GPIOs
307 * @bank_name: Name of the GPIO device (e.g 'a' means GPIOs will be called
309 * @gpio_count: Number of GPIOs in this device
312 * @gpio_base for device 1 will equal the number of GPIOs in device 0.
324 #define gpio_get_ops(dev) ((struct dm_gpio_ops *)(dev)->driver->ops)
327 * gpio_get_bank_info - Return information about a GPIO bank/device
330 * of GPIOs it controls.
333 * @offset_count: Returns number of GPIOs within this bank
336 const char *gpio_get_bank_info(struct udevice *dev, int *offset_count);
339 * dm_gpio_lookup_name() - Look up a named GPIO and return its description
347 * @return 0 if OK, -ve on error
349 int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc);
352 * gpio_hog_lookup_name() - Look up a named GPIO and return the gpio descr.
356 * @return: Returns 0 if OK, else -ENODEV
358 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc);
361 * gpio_hog_probe_all() - probe all gpio devices with
362 * gpio-hog subnodes.
366 int gpio_hog_probe_all(void);
369 * gpio_lookup_name - Look up a GPIO name and return its details
379 int gpio_lookup_name(const char *name, struct udevice **devp,
380 unsigned int *offsetp, unsigned int *gpiop);
383 * gpio_get_values_as_int() - Turn the values of a list of GPIOs into an int
388 * @gpio_list: List of GPIOs to collect
389 * @return resulting integer value, or -ve on error
391 int gpio_get_values_as_int(const int *gpio_list);
394 * dm_gpio_get_values_as_int() - Turn the values of a list of GPIOs into an int
399 * @desc_list: List of GPIOs to collect
400 * @count: Number of GPIOs
401 * @return resulting integer value, or -ve on error
403 int dm_gpio_get_values_as_int(const struct gpio_desc *desc_list, int count);
406 * gpio_claim_vector() - claim a number of GPIOs for input
408 * @gpio_num_array: array of gpios to claim, terminated by -1
410 * @return 0 if OK, -ve on error
412 int gpio_claim_vector(const int *gpio_num_array, const char *fmt);
415 * gpio_request_by_name() - Locate and request a GPIO by name
431 * requests a GPIO which subsequently is unbound, the @desc->dev pointer
437 * The device tree binding is doc/device-tree-bindings/gpio/gpio.txt in
442 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
445 * GPIO, dev->dev will be NULL.
447 * @return 0 if OK, -ENOENT if the GPIO does not exist, -EINVAL if there is
448 * something wrong with the list, or other -ve for another error (e.g.
449 * -EBUSY if a GPIO was already requested)
451 int gpio_request_by_name(struct udevice *dev, const char *list_name,
452 int index, struct gpio_desc *desc, int flags);
455 * gpio_request_list_by_name() - Request a list of GPIOs
457 * Reads all the GPIOs from a list and requests them. See
459 * misused to hold unrelated or optional GPIOs. They should only be used
463 * This function will either succeed, and request all GPIOs in the list, or
464 * fail and request none (it will free already-requested GPIOs in case of
465 * an error part-way through).
468 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
470 * @max_count: Maximum number of GPIOs to return (@desc_list must be at least
473 * @return number of GPIOs requested, or -ve on error
475 int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
476 struct gpio_desc *desc_list, int max_count,
477 int flags);
480 * dm_gpio_request() - manually request a GPIO
483 * use gpio_request_by_name() to pull GPIOs from the device tree.
487 * @return 0 if OK, -ve on error
489 int dm_gpio_request(struct gpio_desc *desc, const char *label);
492 * gpio_get_list_count() - Returns the number of GPIOs in a list
494 * Counts the GPIOs in a list. See gpio_request_by_name() for additional
498 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
499 * @return number of GPIOs (0 for an empty property) or -ENOENT if the list
502 int gpio_get_list_count(struct udevice *dev, const char *list_name);
505 * gpio_request_by_name_nodev() - request GPIOs without a device
510 int gpio_request_by_name_nodev(ofnode node, const char *list_name, int index,
511 struct gpio_desc *desc, int flags);
514 * gpio_request_list_by_name_nodev() - request GPIOs without a device
519 int gpio_request_list_by_name_nodev(ofnode node, const char *list_name,
520 struct gpio_desc *desc_list, int max_count,
521 int flags);
524 * gpio_dev_request_index() - request single GPIO from gpio device
529 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
536 int gpio_dev_request_index(struct udevice *dev, const char *nodename,
537 char *list_name, int index, int flags,
538 int dtflags, struct gpio_desc *desc);
541 * dm_gpio_free() - Free a single GPIO
543 * This frees a single GPIOs previously returned from gpio_request_by_name().
547 * @return 0 if OK, -ve on error
549 int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc);
552 * gpio_free_list() - Free a list of GPIOs
554 * This frees a list of GPIOs previously returned from
557 * @dev: Device which requested the GPIOs
558 * @desc: List of GPIOs to free
559 * @count: Number of GPIOs in the list
560 * @return 0 if OK, -ve on error
562 int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count);
565 * gpio_free_list_nodev() - free GPIOs without a device
570 int gpio_free_list_nodev(struct gpio_desc *desc, int count);
573 * dm_gpio_get_value() - Get the value of a GPIO
583 * @return GPIO value (0 for inactive, 1 for active) or -ve on error
585 int dm_gpio_get_value(const struct gpio_desc *desc);
587 int dm_gpio_set_value(const struct gpio_desc *desc, int value);
590 * dm_gpio_get_open_drain() - Check if open-drain-mode of a GPIO is active
592 * This checks if open-drain-mode for a GPIO is enabled or not. This method is
598 * -ve on error
600 int dm_gpio_get_open_drain(struct gpio_desc *desc);
603 * dm_gpio_set_open_drain() - Switch open-drain-mode of a GPIO on or off
605 * This enables or disables open-drain mode for a GPIO. This method is
609 * In open-drain mode, instead of actively driving the output (Push-pull
617 * @return 0 if OK, -ve on error
619 int dm_gpio_set_open_drain(struct gpio_desc *desc, int value);
622 * dm_gpio_set_dir() - Set the direction for a GPIO
629 * @return 0 if OK, -ve on error
631 int dm_gpio_set_dir(struct gpio_desc *desc);
634 * dm_gpio_set_dir_flags() - Set direction using specific flags
637 * instead of being used from desc->flags. This is needed because in many
639 * Note that desc->flags is updated by this function.
644 * @return 0 if OK, -ve on error, in which case desc->flags is not updated
646 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags);
649 * gpio_get_number() - Get the global GPIO number of a GPIO
656 * @return GPIO number, or -ve if not found
658 int gpio_get_number(const struct gpio_desc *desc);