Lines Matching full:gpio

15  * Generic GPIO API for U-Boot
29 * Each GPIO can be an input or output. If an input then its value can
35 * In some cases the operation may fail, for example if the GPIO number
36 * is out of range, or the GPIO is not available because its pin is
43 * Request a GPIO. This should be called before any of the other functions
44 * are used on this GPIO.
49 * @param gpio GPIO number
50 * @param label User label for this GPIO
53 int gpio_request(unsigned gpio, const char *label);
57 * Stop using the GPIO. This function should not alter pin configuration.
59 * @param gpio GPIO number
62 int gpio_free(unsigned gpio);
66 * Make a GPIO an input.
68 * @param gpio GPIO number
71 int gpio_direction_input(unsigned gpio);
75 * Make a GPIO an output, and set its value.
77 * @param gpio GPIO number
78 * @param value GPIO value (0 for low or 1 for high)
81 int gpio_direction_output(unsigned gpio, int value);
85 * Get a GPIO's value. This will work whether the GPIO is an input
88 * @param gpio GPIO number
91 int gpio_get_value(unsigned gpio);
95 * Set an output GPIO's value. The GPIO must already be an output or
98 * @param gpio GPIO number
99 * @param value GPIO value (0 for low or 1 for high)
102 int gpio_set_value(unsigned gpio, int value);
104 /* State of a GPIO, as reported by get_function() */
110 GPIOF_FUNC, /* Not used as a GPIO */
118 struct udevice *dev; /* Device, NULL for invalid GPIO */
121 #define GPIOD_IS_OUT (1 << 1) /* GPIO is an output */
122 #define GPIOD_IS_IN (1 << 2) /* GPIO is an input */
126 uint offset; /* GPIO offset within the device */
128 * We could consider adding the GPIO label in here. Possibly we could
129 * use this structure for internal GPIO information.
134 * dm_gpio_is_valid() - Check if a GPIO is valid
136 * @desc: GPIO description containing device, offset and flags,
146 * gpio_get_status() - get the current GPIO status as a string
148 * Obtain the current GPIO status as a string which can be presented to the
153 * which means this is GPIO bank b, offset 4, currently set to input, current
159 * @offset: Offset of device GPIO to check
166 * gpio_get_function() - get the current function for a GPIO pin
168 * Note this returns GPIOF_UNUSED if the GPIO is not requested.
173 * @offset: Offset of device GPIO to check
174 * @namep: If non-NULL, this is set to the name given when the GPIO
178 * GPIOF_UNUSED if the GPIO has not been requested. Otherwise returns the
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
192 * @offset: Offset of device GPIO to check
193 * @namep: If non-NULL, this is set to the name given when the GPIO
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, ...)
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
229 * new DM GPIO API, this should be really easy to flip over to the Linux
230 * GPIO API-alike interface.
238 * Note that @offset is the offset from the base GPIO of the device. So
239 * offset 0 is the device's first GPIO and offset o-1 is the last GPIO,
240 * where o is the number of GPIO lines controlled by the device. A device
245 * The uclass combines all GPIO devices together to provide a consistent
247 * all devices. Be careful not to confuse offset with gpio in the parameters.
260 * get_function() Get the GPIO function
263 * @offset: GPIO offset within that device
269 * xlate() - Translate phandle arguments into a GPIO description
286 * @dev: GPIO device
287 * @desc: Place to put GPIO description
298 * The uclass combines all active GPIO devices into a unified numbering
302 * To implement driver model support in your GPIO driver, add a probe
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
310 * @gpio_base: Base GPIO number for this device. For the first active device
313 * @name: Array of pointers to the name for each GPIO in this bank. The
314 * value of the pointer will be NULL if the GPIO has not been claimed.
323 /* Access the GPIO operations for a device */
327 * gpio_get_bank_info - Return information about a GPIO bank/device
329 * This looks up a device and returns both its GPIO base name and the number
339 * dm_gpio_lookup_name() - Look up a named GPIO and return its description
341 * The name of a GPIO is typically its bank name followed by a number from 0.
342 * For example A0 is the first GPIO in bank A. Each bank is a separate driver
352 * gpio_hog_lookup_name() - Look up a named GPIO and return the gpio descr.
355 * @desc: Returns GPIO description, on success, else NULL
361 * gpio_hog_probe_all() - probe all gpio devices with
362 * gpio-hog subnodes.
369 * gpio_lookup_name - Look up a GPIO name and return its details
371 * This is used to convert a named GPIO into a device, offset and GPIO
374 * @name: GPIO name to look up
375 * @devp: Returns pointer to device which contains this GPIO
377 * @gpiop: Returns the absolute GPIO number, numbered from 0
385 * This puts the value of the first GPIO into bit 0, the second into bit 1,
396 * This puts the value of the first GPIO into bit 0, the second into bit 1,
409 * @fmt: format string for GPIO names, e.g. "board_id%d"
415 * gpio_request_by_name() - Locate and request a GPIO by name
418 * tree property) and requesting the GPIO for use. The property must exist
421 * Use @flags to specify whether the GPIO should be an input or output. In
423 * bindings don't provide this information. Specifically, when the GPIO uclass
427 * If we find that requesting the GPIO is not always needed we could add a
431 * requests a GPIO which subsequently is unbound, the @desc->dev pointer
432 * will be invalid. However this will only happen if the GPIO device is
437 * The device tree binding is doc/device-tree-bindings/gpio/gpio.txt in
441 * @dev: Device requesting the GPIO
442 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
443 * @index: Index number of the GPIO in that list use request (0=first)
444 * @desc: Returns GPIO description information. If there is no such
445 * GPIO, dev->dev will be NULL.
446 * @flags: Indicates the GPIO input/output settings (GPIOD_...)
447 * @return 0 if OK, -ENOENT if the GPIO does not exist, -EINVAL if there is
449 * -EBUSY if a GPIO was already requested)
467 * @dev: Device requesting the GPIO
468 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
469 * @desc_list: Returns a list of GPIO description information
472 * @flags: Indicates the GPIO input/output settings (GPIOD_...)
480 * dm_gpio_request() - manually request a GPIO
485 * @desc: GPIO description of GPIO to request (see dm_gpio_lookup_name())
486 * @label: Label to attach to the GPIO while claimed
497 * @dev: Device requesting the GPIO
498 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
524 * gpio_dev_request_index() - request single GPIO from gpio device
526 * @dev: GPIO device
527 * @nodename: Name of node for which gpio gets requested, used
528 * for the gpio label name
529 * @list_name: Name of GPIO list (e.g. "board-id-gpios")
530 * @index: Index number of the GPIO in that list use request (0=first)
532 * @dtflags: GPIO flags read from DT defined see GPIOD_*
533 * @desc: returns GPIO descriptor filled from this function
541 * dm_gpio_free() - Free a single GPIO
545 * @dev: Device which requested the GPIO
546 * @desc: GPIO to free
573 * dm_gpio_get_value() - Get the value of a GPIO
581 * @desc: GPIO description containing device, offset and flags,
583 * @return GPIO value (0 for inactive, 1 for active) or -ve on error
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
595 * @desc: GPIO description containing device, offset and flags,
597 * @return Value of open drain mode for GPIO (0 for inactive, 1 for active) or
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
610 * output), the GPIO's pin is connected to the collector (for a NPN transistor)
615 * @desc: GPIO description containing device, offset and flags,
622 * dm_gpio_set_dir() - Set the direction for a GPIO
627 * @desc: GPIO description containing device, offset and flags,
638 * cases the GPIO description does not include direction information.
641 * @desc: GPIO description containing device, offset and flags,
649 * gpio_get_number() - Get the global GPIO number of a GPIO
652 * that should be used for gpio_get_value() etc. to access this GPIO.
654 * @desc: GPIO description containing device, offset and flags,
656 * @return GPIO number, or -ve if not found