quec_pin_init.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. 
  2. /*================================================================
  3. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  4. Quectel Wireless Solutions Proprietary and Confidential.
  5. =================================================================*/
  6. /*=================================================================
  7. EDIT HISTORY FOR MODULE
  8. This section contains comments describing changes made to the module.
  9. Notice that changes are listed in reverse chronological order.
  10. WHEN WHO WHAT, WHERE, WHY
  11. ------------ ------- -------------------------------------------------------------------------------
  12. =================================================================*/
  13. /*===========================================================================
  14. * include files
  15. ===========================================================================*/
  16. #include "quec_cust_feature.h"
  17. #include "quec_common.h"
  18. #include "hal_chip.h"
  19. #include "quec_pin_cfg.h"
  20. #include "ql_gpio_internal.h"
  21. #include "quec_internal_cfg.h"
  22. #ifdef CONFIG_QUEC_PROJECT_FEATURE_GPIO
  23. extern bool ql_audio_codec_ldo_ctrl;
  24. /*===========================================================================
  25. * Macro Definition
  26. ===========================================================================*/
  27. #define QUEC_GPIOINIT_LOG(msg, ...) custom_log_tag("QGPIO_Init",QUEC_LOG_TAG_GPIO, msg, ##__VA_ARGS__)
  28. /*===========================================================================
  29. * Functions
  30. ===========================================================================*/
  31. __attribute__((weak)) void quec_pin_cfg_init(void)
  32. {
  33. uint8_t index = 0;
  34. uint8_t pin_num = 0;
  35. uint8_t default_func = 0;
  36. uint8_t gpio_func = 0;
  37. ql_GpioNum gpio_num = 0;
  38. ql_GpioDir gpio_dir = 0;
  39. ql_PullMode gpio_pull = 0;
  40. ql_LvlMode gpio_lvl = 0;
  41. //将i2s_mclk脚的功能置空,避免使用其他引脚作为GPIO46使用出现问题
  42. hwp_iomux->i2s1_mclk = (2 << 2);
  43. for( index = 0; index < ql_model_diff_ctx.pin_num; index++ )
  44. {
  45. //QUEC_GPIOINIT_LOG("pin%d=%d", index, quec_pin_cfg_map[index].pin_num);
  46. if (QUEC_PIN_NONE == quec_pin_cfg_map[index].pin_num)
  47. {
  48. QUEC_GPIOINIT_LOG("init exit %d!", index);
  49. break;
  50. }
  51. pin_num = quec_pin_cfg_map[index].pin_num;
  52. default_func = quec_pin_cfg_map[index].default_func;
  53. gpio_func = quec_pin_cfg_map[index].gpio_func;
  54. gpio_num = quec_pin_cfg_map[index].gpio_num;
  55. gpio_dir = quec_pin_cfg_map[index].gpio_dir;
  56. gpio_pull = quec_pin_cfg_map[index].gpio_pull;
  57. gpio_lvl = quec_pin_cfg_map[index].gpio_lvl;
  58. ql_pin_set_func_internal(pin_num, default_func);
  59. if( default_func == gpio_func )
  60. {
  61. ql_gpio_init(gpio_num, gpio_dir, gpio_pull, gpio_lvl);
  62. }
  63. }
  64. /*解决部分客户遇到的串口TX脚低电平下拉不下去的问题,默认驱动能力为2,标准版本修改为7*/
  65. #ifndef CONFIG_QL_OPEN_EXPORT_PKG
  66. /*主串口*/
  67. ql_pin_set_drving(QUEC_PIN_DNAME_UART_1_TXD,7);//主串TX驱动能力设置
  68. /*其他串口*/
  69. #ifdef CONFIG_QL_PROJECT_DEF_EC200G
  70. ql_pin_set_drving(QUEC_PIN_DNAME_KEYIN_5,7);
  71. #elif (defined CONFIG_QL_PROJECT_DEF_EC800G) || (defined CONFIG_QL_PROJECT_DEF_EG800G) || (defined CONFIG_QL_PROJECT_DEF_EG700G)
  72. ql_pin_set_drving(QUEC_PIN_DNAME_GPIO_7,7);
  73. #endif
  74. #endif
  75. /* Power Domain ON */
  76. //for( index = 0; index < HAL_PMU_POWER_MAX_COUNT; index++ )
  77. for( index = 0; index < ql_power_domain_table_len; index++ )
  78. {
  79. if(ql_power_domain_table[index].id == HAL_POWER_NONE)
  80. {
  81. break;
  82. }
  83. #ifndef CONFIG_QL_OPEN_EXPORT_PKG
  84. // for DSDS, no need to deal with the power domain
  85. // for DSSS and no multiplexed PIN, no need to deal with the power domain
  86. if ((HAL_POWER_SIM1 == ql_power_domain_table[index].id) &&
  87. (((DSIM_DSDS == ql_model_feature_ctx.dsim_feature) ||
  88. ((DSIM_DSSS == ql_model_feature_ctx.dsim_feature) && (!QUEC_SIM1_REUSED())))))
  89. {
  90. QUEC_GPIOINIT_LOG("not set sim1 domain");
  91. continue;
  92. }
  93. #endif
  94. if(ql_power_domain_table[index].init_phase == POWER_INIT_PHASE2)
  95. {
  96. halPmuSwitchPower(ql_power_domain_table[index].id, ql_power_domain_table[index].enabled, ql_power_domain_table[index].lp_enabled);
  97. halPmuSetPowerLevel(ql_power_domain_table[index].id, ql_power_domain_table[index].mv);
  98. }
  99. }
  100. if(ql_audio_codec_ldo_ctrl)//EG700G codec需要单独ldo供电,此ldo是通过gpio34 去输出高,来控制ldo输出3.3v给codec供电
  101. {
  102. hwp_iomux->keyout_2 = (1 << 2);
  103. hwp_gpio2->gpio_oen_set_out = (1 << (GPIO_34 - 16));
  104. hwp_gpio2->gpio_set_reg = (1 << (GPIO_34 - 16));
  105. }
  106. }
  107. #endif /* CONFIG_QUEC_PROJECT_FEATURE_GPIO */
  108. #ifdef CONFIG_BOARD_WITH_EXT_FLASH
  109. #include "hal_iomux.h"
  110. void quec_ext_flash_init(void)
  111. {
  112. halIomuxSetFunction(HAL_IOMUX_FUN_SPI_FLASH1_CLK);
  113. halIomuxSetFunction(HAL_IOMUX_FUN_SPI_FLASH1_CS);
  114. halIomuxSetFunction(HAL_IOMUX_FUN_SPI_FLASH1_SIO_0);
  115. halIomuxSetFunction(HAL_IOMUX_FUN_SPI_FLASH1_SIO_1);
  116. halIomuxSetFunction(HAL_IOMUX_FUN_SPI_FLASH1_SIO_2);
  117. halIomuxSetFunction(HAL_IOMUX_FUN_SPI_FLASH1_SIO_3);
  118. }
  119. #endif