Lines Matching +full:in +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
35 * In some cases the operation may fail, for example if the GPIO number
37 * being used by another function. In that case, functions may return
38 * an error value of -1.
51 * @return 0 if ok, -1 on error
60 * @return 0 if ok, -1 on error
69 * @return 0 if ok, -1 on error
79 * @return 0 if ok, -1 on error
89 * @return 0 if low, 1 if high, -1 on error
100 * @return 0 if ok, -1 on error
128 * We could consider adding the GPIO label in here. Possibly we could
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
151 * "b4: in: 1 [x] sdmmc_cd"
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.
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.
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
214 * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate
217 * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1].
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
247 * all devices. Be careful not to confuse offset with gpio in the parameters.
264 * @return current function - GPIOF_...
269 * xlate() - Translate phandle arguments into a GPIO description
271 * This function should set up the fields in desc according to the
272 * information in the arguments. The uclass will have set up:
274 * @desc->dev to @dev
275 * @desc->flags to 0
276 * @desc->offset to 0
279 * which will parse offset and the GPIO_ACTIVE_LOW flag in the first
282 * Note that @dev is passed in as a parameter to follow driver model
284 * desc->dev.
288 * @args: Arguments provided in description
289 * @return 0 if OK, -ve on error
296 * struct gpio_dev_priv - information about a device used by the uclass
302 * To implement driver model support in your GPIO driver, add a probe
303 * handler, and set @gpio_count and @bank_name correctly in that handler.
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.
313 * @name: Array of pointers to the name for each GPIO in this bank. The
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
339 * dm_gpio_lookup_name() - Look up a named GPIO and return its description
342 * For example A0 is the first GPIO in bank A. Each bank is a separate driver
347 * @return 0 if OK, -ve on error
352 * gpio_hog_lookup_name() - Look up a named GPIO and return the gpio descr.
356 * @return: Returns 0 if OK, else -ENODEV
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
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
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
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
415 * gpio_request_by_name() - Locate and request a GPIO by name
417 * This operates by looking up the given list name in the device (device
419 * in @dev's node.
421 * Use @flags to specify whether the GPIO should be an input or output. In
431 * requests a GPIO which subsequently is unbound, the @desc->dev pointer
434 * for now. There is no real use case for unbinding drivers in normal
437 * The device tree binding is doc/device-tree-bindings/gpio/gpio.txt in
438 * generate terms and each specific device may add additional details in
439 * a binding file in the same directory.
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)
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)
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
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
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
505 * gpio_request_by_name_nodev() - request GPIOs without a device
514 * gpio_request_list_by_name_nodev() - request GPIOs without a device
524 * gpio_dev_request_index() - request single GPIO from gpio device
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)
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
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
565 * gpio_free_list_nodev() - free GPIOs without a device
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
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
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
622 * dm_gpio_set_dir() - Set the direction for a GPIO
629 * @return 0 if OK, -ve on error
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
649 * gpio_get_number() - Get the global GPIO number of a GPIO
656 * @return GPIO number, or -ve if not found