osi_sysnv.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _OSI_SYSNV_H_
  13. #define _OSI_SYSNV_H_
  14. #include "kernel_config.h"
  15. #include "osi_compiler.h"
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #include <stddef.h>
  19. #include "quec_common.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #ifdef CONFIG_KERNEL_SYSNV_ENABLED
  24. #ifdef __SYSNV_DEFINE_VAR
  25. #define OSI_SYSNV_VAR(decl, ...) OSI_DEF_GLOBAL_VAR(decl, ##__VA_ARGS__)
  26. #else
  27. #define OSI_SYSNV_VAR(decl, ...) OSI_DECL_GLOBAL_VAR(decl, ##__VA_ARGS__)
  28. #endif
  29. #else
  30. #define OSI_SYSNV_VAR(decl, ...) OSI_DEF_CONST_VAR(decl, ##__VA_ARGS__)
  31. #endif
  32. #define OSI_SYSNV_OPT(decl, ...) OSI_DEF_CONST_VAR(decl, ##__VA_ARGS__)
  33. OSI_SYSNV_VAR(bool gSysnvTraceEnabled, true);
  34. OSI_SYSNV_VAR(bool gSysnvCalibTraceEnabled, false);
  35. OSI_SYSNV_VAR(bool gSysnvDeepSleepEnabled, true);
  36. #ifdef CONFIG_KERNEL_PSM_DEFAULT_ENABLE
  37. OSI_SYSNV_VAR(bool gSysnvPsmSleepEnabled, true);
  38. #else
  39. OSI_SYSNV_VAR(bool gSysnvPsmSleepEnabled, false);
  40. #endif
  41. OSI_SYSNV_VAR(bool gSysnvUsbMode, 0);
  42. #ifdef CONFIG_QUEC_PROJECT_FEATURE
  43. //jensen.fang 20200810: update the usb default mode as ECM+Serial
  44. OSI_SYSNV_VAR(int gSysnvUsbWorkMode, 5);
  45. OSI_SYSNV_VAR(int gSysnvTraceDevice, 2); // osi_trace.h
  46. //jensen.fang 20200812: update the diag device for FT default as usb
  47. OSI_SYSNV_VAR(int gSysnvDiagDevice, 2); // diag.h
  48. OSI_SYSNV_VAR(bool gSysnvSimHotPlug, false);//sim detect is disable as default
  49. OSI_SYSNV_VAR(bool gSysnvSimVoltTrigMode, false);// low level voltage as default for sim detect
  50. #else
  51. OSI_SYSNV_VAR(int gSysnvUsbWorkMode, 2);
  52. OSI_SYSNV_VAR(int gSysnvTraceDevice, 1); // osi_trace.h
  53. OSI_SYSNV_VAR(int gSysnvDiagDevice, 1); // diag.h
  54. OSI_SYSNV_VAR(bool gSysnvSimHotPlug, true);
  55. #if defined(CONFIG_SOC_8850)
  56. OSI_SYSNV_VAR(bool gSysnvSimVoltTrigMode, false);
  57. #elif defined(CONFIG_SOC_8910)
  58. OSI_SYSNV_VAR(bool gSysnvSimVoltTrigMode, true);
  59. #else
  60. OSI_SYSNV_VAR(bool gSysnvSimVoltTrigMode, true);
  61. #endif
  62. #endif
  63. OSI_SYSNV_VAR(int gSysnvUsbDetMode, 0); // drv_usb.h
  64. #ifdef __QUEC_OEM_VER_HW__
  65. OSI_SYSNV_VAR(int gSysnvNATCfg, 1);
  66. #else
  67. OSI_SYSNV_VAR(int gSysnvNATCfg, 0);
  68. #endif
  69. OSI_SYSNV_VAR(unsigned gSysnvFstraceMask, 0);
  70. OSI_SYSNV_VAR(bool gSysnvPoffChargeEnable, false);
  71. OSI_SYSNV_VAR(bool gSysnvPm2GpioInd, false);
  72. OSI_SYSNV_VAR(bool gSysnvPm3GpioInd, false);
  73. OSI_SYSNV_VAR(bool gSysnvUart1RxPsmPullUp, false);
  74. OSI_SYSNV_VAR(bool gSysnvPm2BootEnabled, false);
  75. OSI_SYSNV_VAR(int gSysnvSelfRegisterEnabled, 0);
  76. #ifndef CONFIG_SOC_8811
  77. OSI_SYSNV_VAR(bool gSysnvLogOutput, false);
  78. #endif
  79. /**
  80. * load system NV from persitent storage
  81. *
  82. * After load, the system NV in memory will be changed.
  83. *
  84. * \return
  85. * - true on success
  86. * - false on error
  87. */
  88. bool osiSysnvLoad(void);
  89. /**
  90. * save system NV to persitent storage
  91. *
  92. * \return
  93. * - true on success
  94. * - false on error
  95. */
  96. bool osiSysnvSave(void);
  97. /**
  98. * clear system NV from persitent storage
  99. */
  100. void osiSysnvClear(void);
  101. /**
  102. * get system NV encoded buffer size
  103. *
  104. * System NV encoded size may change when value changed.
  105. *
  106. * \return encoded system NV buffer size
  107. */
  108. int osiSysnvSize(void);
  109. /**
  110. * load encoded system NV to buffer
  111. *
  112. * \p size must be larger than or equal to encoded system NV size, which
  113. * can be get by \p osiSysnvSize.
  114. *
  115. * \param buf buffer for encoded system NV
  116. * \param size buffer size
  117. * \return
  118. * - encoded system NV size
  119. * - -1 on error
  120. */
  121. int osiSysnvLoadToMem(void *buf, size_t size);
  122. /**
  123. * save buffer to system NV persistent storage
  124. *
  125. * After save, the system NV value in effect keep unchanged. It is
  126. * recommended to reboot system to make new value take effect.
  127. *
  128. * It is only used for PC tools. The content in persistent storage is encoded,
  129. * and the provided buffer must match the codec in platform.
  130. *
  131. * \param buf buffer to be written
  132. * \param size buffer size
  133. * \return
  134. * - byte count written, should be the same as \p size
  135. * - -1 if write failed
  136. */
  137. int osiSysnvSaveFromMem(const void *buf, size_t size);
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #endif