gpio_interface.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /* Get the GPIO id */
  53. enum gpio_id dal_gpio_get_id(
  54. const struct gpio *gpio);
  55. /* Get the GPIO enum */
  56. uint32_t dal_gpio_get_enum(
  57. const struct gpio *gpio);
  58. /* Set the GPIO pin configuration */
  59. enum gpio_result dal_gpio_set_config(
  60. struct gpio *gpio,
  61. const struct gpio_config_data *config_data);
  62. /* Obtain GPIO pin info */
  63. enum gpio_result dal_gpio_get_pin_info(
  64. const struct gpio *gpio,
  65. struct gpio_pin_info *pin_info);
  66. /* Obtain GPIO sync source */
  67. enum sync_source dal_gpio_get_sync_source(
  68. const struct gpio *gpio);
  69. /* Obtain GPIO pin output state (active low or active high) */
  70. enum gpio_pin_output_state dal_gpio_get_output_state(
  71. const struct gpio *gpio);
  72. /* Close the handle */
  73. void dal_gpio_close(
  74. struct gpio *gpio);
  75. #endif