gpio_interface.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright 2012-15 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef __DAL_GPIO_INTERFACE_H__
  26. #define __DAL_GPIO_INTERFACE_H__
  27. #include "gpio_types.h"
  28. #include "grph_object_defs.h"
  29. struct gpio;
  30. /* Open the handle for future use */
  31. enum gpio_result dal_gpio_open(
  32. struct gpio *gpio,
  33. enum gpio_mode mode);
  34. enum gpio_result dal_gpio_open_ex(
  35. struct gpio *gpio,
  36. enum gpio_mode mode);
  37. /* Get high or low from the pin */
  38. enum gpio_result dal_gpio_get_value(
  39. const struct gpio *gpio,
  40. uint32_t *value);
  41. /* Set pin high or low */
  42. enum gpio_result dal_gpio_set_value(
  43. const struct gpio *gpio,
  44. uint32_t value);
  45. /* Get current mode */
  46. enum gpio_mode dal_gpio_get_mode(
  47. const struct gpio *gpio);
  48. /* Change mode of the handle */
  49. enum gpio_result dal_gpio_change_mode(
  50. struct gpio *gpio,
  51. enum gpio_mode mode);
  52. /* Lock Pin */
  53. enum gpio_result dal_gpio_lock_pin(
  54. struct gpio *gpio);
  55. /* Unlock Pin */
  56. enum gpio_result dal_gpio_unlock_pin(
  57. struct gpio *gpio);
  58. /* Get the GPIO id */
  59. enum gpio_id dal_gpio_get_id(
  60. const struct gpio *gpio);
  61. /* Get the GPIO enum */
  62. uint32_t dal_gpio_get_enum(
  63. const struct gpio *gpio);
  64. /* Set the GPIO pin configuration */
  65. enum gpio_result dal_gpio_set_config(
  66. struct gpio *gpio,
  67. const struct gpio_config_data *config_data);
  68. /* Obtain GPIO pin info */
  69. enum gpio_result dal_gpio_get_pin_info(
  70. const struct gpio *gpio,
  71. struct gpio_pin_info *pin_info);
  72. /* Obtain GPIO sync source */
  73. enum sync_source dal_gpio_get_sync_source(
  74. const struct gpio *gpio);
  75. /* Obtain GPIO pin output state (active low or active high) */
  76. enum gpio_pin_output_state dal_gpio_get_output_state(
  77. const struct gpio *gpio);
  78. struct hw_ddc *dal_gpio_get_ddc(struct gpio *gpio);
  79. struct hw_hpd *dal_gpio_get_hpd(struct gpio *gpio);
  80. struct hw_generic *dal_gpio_get_generic(struct gpio *gpio);
  81. /* Close the handle */
  82. void dal_gpio_close(
  83. struct gpio *gpio);
  84. #endif