qal_devnode.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (c) 2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: qal_devnode
  20. * QCA driver framework for device node related APIs prototype
  21. */
  22. #ifndef __QAL_DEVNODE_H
  23. #define __QAL_DEVNODE_H
  24. /* Include Files */
  25. #include "qdf_types.h"
  26. #include "qdf_trace.h"
  27. #include "i_qal_devnode.h"
  28. #define PCI_DOMAIN_ID_MIN 0x0000
  29. #define PCI_DOMAIN_ID_MAX 0xFFFF
  30. typedef __qdf_devnode_t qdf_devnode_t;
  31. #ifdef ENHANCED_OS_ABSTRACTION
  32. /**
  33. * qal_devnode_fetch_pci_domain_id() - This function will try to obtain the
  34. * host bridge domain number
  35. * @node: device tree node
  36. * @domain_id: pointer to domain number
  37. *
  38. * Return: QDF_STATUS_SUCCESS if domain_id is in the range, error code otherwise
  39. */
  40. QDF_STATUS
  41. qal_devnode_fetch_pci_domain_id(qdf_devnode_t devnode, int *domain_id);
  42. /**
  43. * qal_devnode_read_u32_array() - Find and read an array of 32 bit integers
  44. * from a property.
  45. * @devnode: device node from which the property value is to be read.
  46. * @pname: name of the property to be searched.
  47. * @u32_val: pointer to return value, modified only if return value is 0.
  48. * @elem: number of array elements to read
  49. *
  50. * Return: QDF_STATUS_SUCCESS on success, error code
  51. */
  52. QDF_STATUS
  53. qal_devnode_read_u32_array(const qdf_devnode_t devnode,
  54. const char *pname, uint32_t *u32_val, size_t elem);
  55. /**
  56. * qal_devnode_read_u32() - Find and read 32 bit integer from a property.
  57. * @devnode: device node from which the property value is to be read.
  58. * @pname: name of the property to be searched.
  59. * @u32_val: pointer to return value, modified only if return value is 0.
  60. *
  61. * Return: QDF_STATUS_SUCCESS on success, error code
  62. */
  63. QDF_STATUS
  64. qal_devnode_read_u32(const qdf_devnode_t devnode,
  65. const char *pname, uint32_t *u32_val);
  66. #else
  67. static inline QDF_STATUS
  68. qal_devnode_fetch_pci_domain_id(qdf_devnode_t devnode, int *domain_id)
  69. {
  70. return __qal_devnode_fetch_pci_domain_id(devnode, domain_id);
  71. }
  72. static inline QDF_STATUS
  73. qal_devnode_read_u32_array(const qdf_devnode_t devnode,
  74. const char *pname, uint32_t *u32_val, size_t elem)
  75. {
  76. return __qal_devnode_read_u32_array(devnode, pname, u32_val, elem);
  77. }
  78. static inline QDF_STATUS
  79. qal_devnode_read_u32(const qdf_devnode_t devnode,
  80. const char *pname, uint32_t *u32_val)
  81. {
  82. return __qal_devnode_read_u32(devnode, pname, u32_val);
  83. }
  84. #endif
  85. #endif /* __QAL_DEVNODE_H */