1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Simple GPIO access from SPL. This only supports a single GPIO space,
4 * typically the SoC GPIO banks.
6 * Copyright 2018 Google LLC
15 * The functions listed here should be implemented in the SoC GPIO driver.
16 * They correspond to the normal GPIO API (asm-generic/gpio.h). The GPIO
17 * number is encoded in an unsigned int by an SoC-specific means. Pull
18 * values are also SoC-specific.
20 * This API should only be used in TPL/SPL where GPIO access is needed but
21 * driver model is not available (yet) or adds too much overhead.
23 * The caller must supply the GPIO register base since this information is
24 * often specific to a particular SoC generation. This allows the GPIO
25 * code to be fairly generic.
27 * Only a single implementation of each of these functions can be provided.
29 * The 'gpio' value can include both a bank and a GPIO number, if desired. The
30 * encoding is SoC-specific.
34 * spl_gpio_set_pull() - Set the pull up/down state of a GPIO
36 * @regs: Pointer to GPIO registers
37 * @gpio: GPIO to adjust (SoC-specific)
38 * @pull: Pull value (SoC-specific)
39 * @return return 0 if OK, -ve on error
41 int spl_gpio_set_pull(void *regs, uint gpio, int pull);
44 * spl_gpio_output() - Set a GPIO as an output
46 * @regs: Pointer to GPIO registers
47 * @gpio: GPIO to adjust (SoC-specific)
48 * @value: 0 to set the output low, 1 to set it high
49 * @return return 0 if OK, -ve on error
51 int spl_gpio_output(void *regs, uint gpio, int value);
54 * spl_gpio_input() - Set a GPIO as an input
56 * @regs: Pointer to GPIO registers
57 * @gpio: GPIO to adjust (SoC-specific)
58 * @return return 0 if OK, -ve on error
60 int spl_gpio_input(void *regs, uint gpio);
62 #endif /* __SPL_GPIO_H */