Skip to content

Commit

Permalink
duos: add wifi power control GPIO
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonfix committed Jan 20, 2024
1 parent 543e96f commit f91cf43
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
max-frequency = <187500000>;
};

&wifi_pin {
compatible = "cvitek,wifi-pin";
poweron-gpio = <&porta 15 GPIO_ACTIVE_HIGH>;
wakeup-gpio = <&porte 7 GPIO_ACTIVE_HIGH>;
};

&uart4 {
status = "okay";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ CONFIG_ION_CARVEOUT_HEAP=y
CONFIG_ION_CMA_HEAP=y
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_CV1835_SYSDMA_REMAP=y
CONFIG_CVI_WIFI_PIN=y
CONFIG_PWM=y
CONFIG_SIFIVE_PLIC=y
CONFIG_ANDROID=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
max-frequency = <187500000>;
};

&wifi_pin {
compatible = "cvitek,wifi-pin";
poweron-gpio = <&porta 15 GPIO_ACTIVE_HIGH>;
wakeup-gpio = <&porte 7 GPIO_ACTIVE_HIGH>;
};

&uart4 {
status = "okay";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ CONFIG_ION_CARVEOUT_HEAP=y
CONFIG_ION_CMA_HEAP=y
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_CV1835_SYSDMA_REMAP=y
CONFIG_CVI_WIFI_PIN=y
CONFIG_PWM=y
CONFIG_SIFIVE_PLIC=y
CONFIG_ANDROID=y
Expand Down
2 changes: 1 addition & 1 deletion build/boards/default/dts/cv181x/cv181x_base.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@
cvi,card_name = "cv182x_internal_PDM";
};

wifi_pin {
wifi_pin: wifi_pin {
compatible = "cvitek,wifi-pin";
poweron-gpio = <&porta 18 GPIO_ACTIVE_HIGH>;
wakeup-gpio = <&porte 7 GPIO_ACTIVE_HIGH>;
Expand Down
4 changes: 0 additions & 4 deletions device/milkv-duos-sd/overlay/mnt/system/duo-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ function set_gpio()
echo ${gpio_val} > ${gpio_path}/value
}

# WIFI Power ON
wifi_power=495
set_gpio ${wifi_power} 1

# Host Wake BT
host_wake_bt=362
set_gpio ${host_wake_bt} 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/semaphore.h>
#include <linux/debugfs.h>
#include <linux/kthread.h>
#include <linux/gpio.h>
#include "aicsdio_txrxif.h"
#include "aicsdio.h"
#include "aic_bsp_driver.h"
Expand Down Expand Up @@ -42,6 +43,11 @@ extern void extern_wifi_set_enable(int is_on);
extern void set_power_control_lock(int lock);
#endif//for AML

#ifdef CONFIG_PLATFORM_CVITEK
extern int cvi_get_wifi_pwr_on_gpio(void);
extern int cvi_sdio_rescan(void);
static int cvi_wifi_power_gpio = -1;
#endif //CONFIG_PLATFORM_CVITEK

static int aicbsp_platform_power_on(void);
static void aicbsp_platform_power_off(void);
Expand All @@ -67,10 +73,6 @@ module_param_string(saved_sdk_ver, saved_sdk_ver,64, 0660);

extern int testmode;

#ifdef CONFIG_PLATFORM_CVITEK
extern int cvi_sdio_rescan(void);
#endif

#define SDIO_DEVICE_ID_AIC8801_FUNC2 0x0146
#define SDIO_DEVICE_ID_AIC8800D80_FUNC2 0x0182

Expand Down Expand Up @@ -508,6 +510,28 @@ static int aicbsp_platform_power_on(void)
rockchip_wifi_set_carddetect(1);
#endif /*CONFIG_PLATFORM_ROCKCHIP2*/

#ifdef CONFIG_PLATFORM_CVITEK
printk("======== CVITEK WLAN_POWER_ON ========\n");
cvi_wifi_power_gpio = cvi_get_wifi_pwr_on_gpio();
if (cvi_wifi_power_gpio >= 0) {
ret = gpio_request(cvi_wifi_power_gpio, "WLAN_POWER");
if (ret < 0) {
printk("%s: gpio_request(%d) for WLAN_POWER failed\n",
__func__, cvi_wifi_power_gpio);
cvi_wifi_power_gpio = -1;
}
}

if (cvi_wifi_power_gpio >= 0) {
ret = gpio_direction_output(cvi_wifi_power_gpio, 1);
if (ret) {
printk("%s: WLAN_POWER output high failed!\n", __func__);
return -EIO;
}
mdelay(50);
}
#endif //CONFIG_PLATFORM_CVITEK

sema_init(&aic_chipup_sem, 0);
ret = aicbsp_reg_sdio_notify(&aic_chipup_sem);
if (ret) {
Expand All @@ -521,10 +545,11 @@ static int aicbsp_platform_power_on(void)
sunxi_wlan_set_power(1);
mdelay(50);
sunxi_mmc_rescan_card(aicbsp_bus_index);

#endif //CONFIG_PLATFORM_ALLWINNER

#ifdef CONFIG_PLATFORM_CVITEK
printk("---aic,%s,%d: cvi_sdio_rescan\n", __func__, __LINE__);
printk("%s,%d: cvi_sdio_rescan\n", __func__, __LINE__);
cvi_sdio_rescan();
//udelay(1000);
#endif
Expand All @@ -547,11 +572,19 @@ static int aicbsp_platform_power_on(void)
extern_wifi_set_enable(0);
#endif


#ifdef CONFIG_PLATFORM_ROCKCHIP2
rockchip_wifi_power(0);
#endif /*CONFIG_PLATFORM_ROCKCHIP2*/

#ifdef CONFIG_PLATFORM_CVITEK
if (cvi_wifi_power_gpio >= 0) {
ret = gpio_direction_output(cvi_wifi_power_gpio, 0);
if (ret) {
printk("%s: WLAN_POWER output low failed!\n", __func__);
}
}
#endif //CONFIG_PLATFORM_CVITEK

return -1;
}

Expand Down Expand Up @@ -580,6 +613,14 @@ static void aicbsp_platform_power_off(void)
extern_wifi_set_enable(0);
#endif

#ifdef CONFIG_PLATFORM_CVITEK
printk("======== CVITEK WLAN_POWER_OFF ========\n");
if (cvi_wifi_power_gpio >= 0) {
if(gpio_direction_output(cvi_wifi_power_gpio, 0)) {
printk("%s: WLAN_POWER output low failed!\n", __func__);
}
}
#endif //CONFIG_PLATFORM_CVITEK

sdio_dbg("%s\n", __func__);
}
Expand Down

0 comments on commit f91cf43

Please sign in to comment.