1 /******************************************************************************
3 * Copyright(c) 2013 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #include <drv_types.h>
22 #ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
23 #ifdef CONFIG_WITS_EVB_V13
25 #else /* !CONFIG_WITS_EVB_V13 */
26 #define SDIOID (CONFIG_CHIP_ID == 1123 ? 3 : 1)
27 #endif /* !CONFIG_WITS_EVB_V13 */
29 #define SUNXI_SDIO_WIFI_NUM_RTL8189ES 10
30 extern void sunximmc_rescan_card(unsigned id, unsigned insert);
31 extern int mmc_pm_get_mod_type(void);
32 extern int mmc_pm_gpio_ctrl(char *name, int level);
34 * rtl8189es_shdn = port:PH09<1><default><default><0>
35 * rtl8189es_wakeup = port:PH10<1><default><default><1>
36 * rtl8189es_vdd_en = port:PH11<1><default><default><0>
37 * rtl8189es_vcc_en = port:PH12<1><default><default><0>
40 int rtl8189es_sdio_powerup(void)
42 mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 1);
44 mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 1);
46 mmc_pm_gpio_ctrl("rtl8189es_shdn", 1);
50 int rtl8189es_sdio_poweroff(void)
52 mmc_pm_gpio_ctrl("rtl8189es_shdn", 0);
53 mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 0);
54 mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 0);
57 #endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
61 * 0: power on successfully
62 * others: power on failed
64 int platform_wifi_power_on(void)
67 #ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
68 unsigned int mod_sel = mmc_pm_get_mod_type();
69 #endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
72 #ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
73 if (mod_sel == SUNXI_SDIO_WIFI_NUM_RTL8189ES) {
74 rtl8189es_sdio_powerup();
75 sunximmc_rescan_card(SDIOID, 1);
76 printk("[rtl8189es] %s: power up, rescan card.\n", __FUNCTION__);
79 printk("[rtl8189es] %s: mod_sel = %d is incorrect.\n", __FUNCTION__, mod_sel);
81 #endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
86 void platform_wifi_power_off(void)
88 #ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
89 sunximmc_rescan_card(SDIOID, 0);
90 #ifdef CONFIG_RTL8188E
91 rtl8189es_sdio_poweroff();
92 printk("[rtl8189es] %s: remove card, power off.\n", __FUNCTION__);
93 #endif /* CONFIG_RTL8188E */
94 #endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */