Path: blob/master/ALFA-W1F1/RTL8814AU/platform/platform_ARM_SUNxI_sdio.c
1307 views
/******************************************************************************1*2* Copyright(c) 2013 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/14#include <drv_types.h>1516#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL17#ifdef CONFIG_WITS_EVB_V1318#define SDIOID 019#else /* !CONFIG_WITS_EVB_V13 */20#define SDIOID (CONFIG_CHIP_ID == 1123 ? 3 : 1)21#endif /* !CONFIG_WITS_EVB_V13 */2223#define SUNXI_SDIO_WIFI_NUM_RTL8189ES 1024extern void sunximmc_rescan_card(unsigned id, unsigned insert);25extern int mmc_pm_get_mod_type(void);26extern int mmc_pm_gpio_ctrl(char *name, int level);27/*28* rtl8189es_shdn = port:PH09<1><default><default><0>29* rtl8189es_wakeup = port:PH10<1><default><default><1>30* rtl8189es_vdd_en = port:PH11<1><default><default><0>31* rtl8189es_vcc_en = port:PH12<1><default><default><0>32*/3334int rtl8189es_sdio_powerup(void)35{36mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 1);37udelay(100);38mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 1);39udelay(50);40mmc_pm_gpio_ctrl("rtl8189es_shdn", 1);41return 0;42}4344int rtl8189es_sdio_poweroff(void)45{46mmc_pm_gpio_ctrl("rtl8189es_shdn", 0);47mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 0);48mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 0);49return 0;50}51#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */5253/*54* Return:55* 0: power on successfully56* others: power on failed57*/58int platform_wifi_power_on(void)59{60int ret = 0;61#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL62unsigned int mod_sel = mmc_pm_get_mod_type();63#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */646566#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL67if (mod_sel == SUNXI_SDIO_WIFI_NUM_RTL8189ES) {68rtl8189es_sdio_powerup();69sunximmc_rescan_card(SDIOID, 1);70printk("[rtl8189es] %s: power up, rescan card.\n", __FUNCTION__);71} else {72ret = -1;73printk("[rtl8189es] %s: mod_sel = %d is incorrect.\n", __FUNCTION__, mod_sel);74}75#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */7677return ret;78}7980void platform_wifi_power_off(void)81{82#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL83sunximmc_rescan_card(SDIOID, 0);84#ifdef CONFIG_RTL8188E85rtl8189es_sdio_poweroff();86printk("[rtl8189es] %s: remove card, power off.\n", __FUNCTION__);87#endif /* CONFIG_RTL8188E */88#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */89}909192