target_if_gpio.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /**
  17. * DOC: target_if_gpio.c
  18. *
  19. * This file provide definition for APIs registered through lmac Tx Ops
  20. */
  21. #include <qdf_status.h>
  22. #include <target_if.h>
  23. #include <wlan_gpio_priv_api.h>
  24. #include <target_if_gpio.h>
  25. #include <wmi_unified_gpio_api.h>
  26. /**
  27. * target_if_set_gpio_config() - API to send gpio config request to wmi
  28. * @psoc: pointer to psoc object
  29. * @param: pointer to gpio info
  30. *
  31. * Return: status of operation.
  32. */
  33. static QDF_STATUS
  34. target_if_set_gpio_config(struct wlan_objmgr_psoc *psoc,
  35. struct gpio_config_params *param)
  36. {
  37. struct wmi_unified *wmi_handle;
  38. wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
  39. if (!wmi_handle) {
  40. target_if_err("wmi_handle is null.");
  41. return QDF_STATUS_E_NULL_VALUE;
  42. }
  43. return wmi_unified_gpio_config_cmd_send(wmi_handle, param);
  44. }
  45. /**
  46. * target_if_set_gpio_output() - API to send gpio output request to wmi
  47. * @psoc: pointer to psoc object
  48. * @param: pointer to gpio info
  49. *
  50. * Return: status of operation.
  51. */
  52. static QDF_STATUS
  53. target_if_set_gpio_output(struct wlan_objmgr_psoc *psoc,
  54. struct gpio_output_params *param)
  55. {
  56. struct wmi_unified *wmi_handle;
  57. wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
  58. if (!wmi_handle) {
  59. target_if_err("wmi_handle is null.");
  60. return QDF_STATUS_E_NULL_VALUE;
  61. }
  62. return wmi_unified_gpio_output_cmd_send(wmi_handle, param);
  63. }
  64. QDF_STATUS
  65. target_if_gpio_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
  66. {
  67. struct wlan_lmac_if_gpio_tx_ops *gpio_ops;
  68. if (!tx_ops) {
  69. target_if_err("tx ops is NULL!");
  70. return QDF_STATUS_E_INVAL;
  71. }
  72. gpio_ops = &tx_ops->gpio_ops;
  73. gpio_ops->set_gpio_config = target_if_set_gpio_config;
  74. gpio_ops->set_gpio_output = target_if_set_gpio_output;
  75. return QDF_STATUS_SUCCESS;
  76. }