1 /******************************************************************************
\r
3 * Copyright(c) 2013 Realtek Corporation. All rights reserved.
\r
5 * This program is free software; you can redistribute it and/or modify it
\r
6 * under the terms of version 2 of the GNU General Public License as
\r
7 * published by the Free Software Foundation.
\r
9 * This program is distributed in the hope that it will be useful, but WITHOUT
\r
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
14 * You should have received a copy of the GNU General Public License along with
\r
15 * this program; if not, write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
\r
19 ******************************************************************************/
\r
22 * This file can be applied to following platforms:
\r
23 * CONFIG_PLATFORM_ARM_SUN6I
\r
24 * CONFIG_PLATFORM_ARM_SUN7I
\r
25 * CONFIG_PLATFORM_ARM_SUN8I
\r
27 #include <drv_types.h>
\r
28 #include <mach/sys_config.h>
\r
29 #ifdef CONFIG_GPIO_WAKEUP
\r
30 #include <linux/gpio.h>
\r
34 static int sdc_id = -1;
\r
35 static signed int gpio_eint_wlan = -1;
\r
36 static u32 eint_wlan_handle = 0;
\r
37 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
\r
38 extern void sw_mci_rescan_card(unsigned id, unsigned insert);
\r
39 #elif defined(CONFIG_PLATFORM_ARM_SUN8I)
\r
40 extern void sunxi_mci_rescan_card(unsigned id, unsigned insert);
\r
42 extern int wifi_pm_get_mod_type(void);
\r
43 extern void wifi_pm_power(int on);
\r
44 #ifdef CONFIG_GPIO_WAKEUP
\r
45 extern unsigned int oob_irq;
\r
47 #endif // CONFIG_MMC
\r
51 * 0: power on successfully
\r
52 * others: power on failed
\r
54 int platform_wifi_power_on(void)
\r
61 script_item_value_type_e type;
\r
63 unsigned int mod_sel = wifi_pm_get_mod_type();
\r
65 type = script_get_item("wifi_para", "wifi_sdc_id", &val);
\r
66 if (SCIRPT_ITEM_VALUE_TYPE_INT!=type) {
\r
67 DBG_871X("get wifi_sdc_id failed\n");
\r
71 DBG_871X("----- %s sdc_id: %d, mod_sel: %d\n", __FUNCTION__, sdc_id, mod_sel);
\r
73 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
\r
74 sw_mci_rescan_card(sdc_id, 1);
\r
75 #elif defined(CONFIG_PLATFORM_ARM_SUN8I)
\r
76 sunxi_mci_rescan_card(sdc_id, 1);
\r
81 DBG_871X("%s: power up, rescan card.\n", __FUNCTION__);
\r
84 #ifdef CONFIG_GPIO_WAKEUP
\r
85 #ifdef CONFIG_RTL8723B
\r
86 type = script_get_item("wifi_para", "rtl8723bs_wl_host_wake", &val);
\r
88 #ifdef CONFIG_RTL8188E
\r
89 type = script_get_item("wifi_para", "rtl8189es_host_wake", &val);
\r
91 if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
\r
92 DBG_871X("No definition of wake up host PIN\n");
\r
95 gpio_eint_wlan = val.gpio.gpio;
\r
96 #ifdef CONFIG_PLATFORM_ARM_SUN8I
\r
97 oob_irq = gpio_to_irq(gpio_eint_wlan);
\r
100 #endif // CONFIG_GPIO_WAKEUP
\r
102 #endif // CONFIG_MMC
\r
107 void platform_wifi_power_off(void)
\r
110 #if defined(CONFIG_PLATFORM_ARM_SUN6I) ||defined(CONFIG_PLATFORM_ARM_SUN7I)
\r
111 sw_mci_rescan_card(sdc_id, 0);
\r
112 #elif defined(CONFIG_PLATFORM_ARM_SUN8I)
\r
113 sunxi_mci_rescan_card(sdc_id, 0);
\r
118 DBG_871X("%s: remove card, power off.\n", __FUNCTION__);
\r
119 #endif // CONFIG_MMC
\r