quec_boot_pin_cfg.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /** @file
  2. quec_boot_pin_index.h
  3. @brief
  4. This file is used to define boot pin index api for different Quectel Project.
  5. */
  6. /*================================================================
  7. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  8. Quectel Wireless Solution Proprietary and Confidential.
  9. =================================================================*/
  10. /*=================================================================
  11. EDIT HISTORY FOR MODULE
  12. This section contains comments describing changes made to the module.
  13. Notice that changes are listed in reverse chronological order.
  14. WHEN WHO WHAT, WHERE, WHY
  15. ------------ ------- -------------------------------------------------------------------------------
  16. 24/01/2021 Neo Init version
  17. =================================================================*/
  18. #ifndef QUEC_BOOT_PIN_CFG_H
  19. #define QUEC_BOOT_PIN_CFG_H
  20. #include "quec_cust_feature.h"
  21. #include "ql_api_common.h"
  22. #include "hal_chip.h"
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /*===========================================================================
  27. * Macro Definition
  28. ===========================================================================*/
  29. #define QL_BOOT_ERRCODE_BASE (QL_COMPONENT_BSP_GPIO<<16)
  30. /*===========================================================================
  31. * Enum
  32. ===========================================================================*/
  33. /**
  34. * GPIO errcode
  35. */
  36. typedef enum
  37. {
  38. QL_BOOT_PIN_SUCCESS = 0,
  39. QL_BOOT_PIN_INVALID_PARAM_ERR = 1|QL_BOOT_ERRCODE_BASE,
  40. QL_BOOT_PIN_MAP_ERR,
  41. QL_BOOT_PIN_SET_PWR_DOMIAN_ERR,
  42. QL_BOOT_PIN_SET_PWR_INVALID_PARAM_ERRR,
  43. }ql_boot_errcode_pin_e;
  44. //==================================================================
  45. typedef enum
  46. {
  47. QUEC_BOOT_V_NONE = 0, //V_PAD_1V8和V_PAD_1V8_RTC 芯片初始值默认打开 V_MMC芯片上电默认打开3V2
  48. QUEC_BOOT_V_LCD, //V_LCD 电压域芯片初始值默认关闭 要自行打开
  49. QUEC_BOOT_V_SIM1 // hardware is SIM2, = HAL_POWER_SIM1
  50. }quec_boot_pd_type_e;
  51. typedef struct
  52. {
  53. //uint8_t pin_num;
  54. volatile uint32_t *reg;
  55. uint8_t function;
  56. quec_boot_pd_type_e power_domain;
  57. uint32_t power_mv;
  58. volatile uint32_t *pad_reg; //设置驱动能力等功能的寄存器
  59. uint8_t drv; //驱动能力等级
  60. } quec_boot_pin_cfg_t;
  61. //==================================================================
  62. typedef enum
  63. {
  64. QL_BOOT_UART_PORT_1 = 0,
  65. QL_BOOT_UART_PORT_2,
  66. QL_BOOT_UART_PORT_3,
  67. QL_BOOT_UART_PORT_4,
  68. QL_BOOT_UART_PORT_5,
  69. QL_BOOT_UART_PORT_6,
  70. QL_BOOT_UART_PORT_MAX
  71. }ql_boot_uart_port_e;
  72. typedef struct
  73. {
  74. ql_boot_uart_port_e port;
  75. quec_boot_pin_cfg_t pin_tx;
  76. quec_boot_pin_cfg_t pin_rx;
  77. } ql_boot_uart_pin_cfg_t;
  78. //==================================================================
  79. typedef enum
  80. {
  81. QL_BOOT_SPI_PORT_1 = 0, //SPI1总线
  82. QL_BOOT_SPI_PORT_2, //SPI2总线
  83. QL_BOOT_SPI_PORT_MAX
  84. }ql_boot_spi_port_e;
  85. typedef struct
  86. {
  87. ql_boot_spi_port_e port;
  88. quec_boot_pin_cfg_t pin_clk;
  89. quec_boot_pin_cfg_t pin_cs;
  90. quec_boot_pin_cfg_t pin_mosi;
  91. quec_boot_pin_cfg_t pin_miso;
  92. } ql_boot_spi_pin_cfg_t;
  93. typedef struct
  94. {
  95. ql_boot_spi_port_e port;
  96. quec_boot_pin_cfg_t pin_clk;
  97. quec_boot_pin_cfg_t pin_cs;
  98. quec_boot_pin_cfg_t pin_sio0;
  99. quec_boot_pin_cfg_t pin_sio1;
  100. quec_boot_pin_cfg_t pin_sio2;
  101. quec_boot_pin_cfg_t pin_sio3;
  102. } ql_boot_spi6_pin_cfg_t;
  103. typedef struct
  104. {
  105. uint8_t channel_adc0;
  106. uint8_t channel_adc1;
  107. uint8_t channel_adc2;
  108. uint8_t channel_adc3;
  109. uint8_t channel_vbat;
  110. } ql_boot_adc_channel_s;
  111. typedef struct
  112. {
  113. bool gnss_enabled;
  114. }ql_boot_model_diff_ctx_s;
  115. /*==================================================================
  116. ******************************uart*********************************
  117. ==================================================================*/
  118. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_URC
  119. #define QL_BOOT_UART_PORT_NUM_MAX (5) //UART1默认的 其他的UART需要set func
  120. extern ql_boot_uart_pin_cfg_t quec_boot_uart_pin_cfg_map[QL_BOOT_UART_PORT_NUM_MAX];
  121. #endif
  122. /*==================================================================
  123. *******************************spi*********************************
  124. ==================================================================*/
  125. #if (defined CONFIG_QUEC_PROJECT_FEATURE_BOOT_NAND_FLASH || defined CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI4_EXTNSFFS || defined CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI4_NORFLASH)
  126. #define QL_BOOT_SPI_PORT_NUM_MAX (2) //最多支持两组4线spi
  127. extern ql_boot_spi_pin_cfg_t quec_boot_spi_pin_cfg_map[QL_BOOT_SPI_PORT_NUM_MAX];
  128. #define QL_BOOT_CUR_SPI_PORT QL_BOOT_SPI_PORT_1 //当前boot中使用的4线spi口
  129. #endif
  130. #if (defined CONFIG_QUEC_PROJECT_FEATURE_SPI6_EXT_NOR || defined CONFIG_QUEC_PROJECT_FEATURE_BOOT_SPI6_NAND)
  131. /*======================================================================================
  132. **注:SPI6 PORT其实是一个6线SPI控制器复用到不同的pin脚上,所以不能同时复用。
  133. ** 例如EC200 默认QL_BOOT_SPI_PORT_1所对应pin脚复用成6线SPI功能,如果想切换
  134. ** 成QL_BOOT_SPI_PORT_2所对应pin脚复用成6线SPI功能,要先把QL_BOOT_SPI_PORT_1所对应
  135. ** pin脚复用成其他功能(比如gpio等),再把QL_BOOT_SPI_PORT_2所对应pin脚复用成6线SPI功能。
  136. ** PS:pin默认功能表:ql_pin_cfg.c
  137. =======================================================================================*/
  138. #define QL_BOOT_SPI6_PORT_NUM_MAX (2)
  139. extern ql_boot_spi6_pin_cfg_t quec_boot_spi6_pin_cfg_map[QL_BOOT_SPI6_PORT_NUM_MAX];
  140. #define QL_BOOT_CUR_SPI6_PORT QL_BOOT_SPI_PORT_1 //当前boot中使用的6线spi口
  141. #endif
  142. #ifdef CONFIG_QUEC_PROJECT_FEATURE_BOOT_ADC
  143. extern const ql_boot_adc_channel_s ql_boot_adc_channel_num;
  144. #endif
  145. /*========================================================================
  146. * function Definition
  147. *========================================================================*/
  148. /*****************************************************************
  149. * Function: ql_boot_set_power_domain
  150. *
  151. * Description:
  152. * 设置电压域
  153. *
  154. * Parameters:
  155. * type [in] 电压域类型选择
  156. *
  157. * Return:ql_boot_errcode
  158. *
  159. *****************************************************************/
  160. ql_boot_errcode_pin_e ql_boot_set_power_domain(quec_boot_pd_type_e type,powerLevel_t mv);
  161. ql_boot_errcode_pin_e quec_boot_pin_init(quec_boot_pin_cfg_t *pin , uint32_t *reg_bak, uint32_t *pad_reg_bak);
  162. #ifdef __cplusplus
  163. } /*"C" */
  164. #endif
  165. #endif /* QUEC_BOOT_PIN_CFG_H */