1 /*
2  * Copyright 2021-2022 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include "wifi_bt_config.h"
9 #include "pin_mux.h"
10 #include "fsl_gpio.h"
11 
12 /*******************************************************************************
13  * Definitions
14  ******************************************************************************/
15 
16 /*******************************************************************************
17  * Prototypes
18  ******************************************************************************/
19 
20 /*******************************************************************************
21  * Variables
22  ******************************************************************************/
23 
24 /*******************************************************************************
25  * Code
26  ******************************************************************************/
27 
BOARD_WIFI_BT_Enable(bool enable)28 void BOARD_WIFI_BT_Enable(bool enable)
29 {
30     if (enable)
31     {
32         /* Enable module */
33 #ifdef WIFI_BT_USE_M2_INTERFACE
34         /* Set SDIO_RST to 1 */
35         GPIO_PortSet(BOARD_INITPINSM2_SDIO_RST_GPIO, BOARD_INITPINSM2_SDIO_RST_GPIO_PIN_MASK);
36         vTaskDelay(pdMS_TO_TICKS(100));
37 
38         /* Set WL_RST to 1 */
39         GPIO_PortSet(BOARD_INITPINSM2_WL_RST_GPIO, BOARD_INITPINSM2_WL_RST_GPIO_PIN_MASK);
40         vTaskDelay(pdMS_TO_TICKS(100));
41 #elif defined(WIFI_BT_USE_USD_INTERFACE)
42         /* Enable power supply for SD */
43         GPIO_PinWrite(BOARD_SDMMC_SD_POWER_RESET_GPIO_BASE, BOARD_SDMMC_SD_POWER_RESET_GPIO_PIN, 0);
44         vTaskDelay(pdMS_TO_TICKS(100));
45 #endif /* WIFI_BT_USE_M2_INTERFACE */
46     }
47     else
48     {
49         /* Disable module */
50 #ifdef WIFI_BT_USE_M2_INTERFACE
51         /* Set WL_RST to 0 */
52         GPIO_PortClear(BOARD_INITPINSM2_WL_RST_GPIO, BOARD_INITPINSM2_WL_RST_GPIO_PIN_MASK);
53         /* Set SDIO_RST to 0 */
54         GPIO_PortClear(BOARD_INITPINSM2_SDIO_RST_GPIO, BOARD_INITPINSM2_SDIO_RST_GPIO_PIN_MASK);
55 #elif defined(WIFI_BT_USE_USD_INTERFACE)
56         /* Disable power supply for SD */
57         GPIO_PinWrite(BOARD_SDMMC_SD_POWER_RESET_GPIO_BASE, BOARD_SDMMC_SD_POWER_RESET_GPIO_PIN, 1);
58 #endif /* WIFI_BT_USE_M2_INTERFACE */
59         vTaskDelay(pdMS_TO_TICKS(100));
60     }
61 }
62 
BOARD_WIFI_BT_Config(void * card,sdio_int_t cardInt)63 void BOARD_WIFI_BT_Config(void *card, sdio_int_t cardInt)
64 {
65     BOARD_SDIO_Config(card, NULL, BOARD_SDMMC_SDIO_HOST_IRQ_PRIORITY, cardInt);
66 
67 #ifdef WIFI_BT_USE_M2_INTERFACE
68     ((sdio_card_t *)card)->usrParam.pwr = NULL;
69     BOARD_InitPinsM2();
70 #endif
71     BOARD_WIFI_BT_Enable(false);
72 }
73