spl_gpio.h 1.8 KB

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