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 ******************************************************************************/
22 * This file can be applied to following platforms:
23 * CONFIG_PLATFORM_ARM_SUN6I
24 * CONFIG_PLATFORM_ARM_SUN7I
25 * CONFIG_PLATFORM_ARM_SUN8I
27 #include <drv_types.h>
28 #include <mach/sys_config.h>
29 #ifdef CONFIG_GPIO_WAKEUP
30 #include <linux/gpio.h>
34 static int sdc_id = -1;
35 static signed int gpio_eint_wlan = -1;
36 static u32 eint_wlan_handle = 0;
38 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
39 extern void sw_mci_rescan_card(unsigned id, unsigned insert);
40 #elif defined(CONFIG_PLATFORM_ARM_SUN8I)
41 extern void sunxi_mci_rescan_card(unsigned id, unsigned insert);
44 #ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
45 extern int get_rf_mod_type(void);
47 extern int wifi_pm_get_mod_type(void);
50 extern void wifi_pm_power(int on);
51 #ifdef CONFIG_GPIO_WAKEUP
52 extern unsigned int oob_irq;
54 #endif /* CONFIG_MMC */
58 * 0: power on successfully
59 * others: power on failed
61 int platform_wifi_power_on(void)
68 script_item_value_type_e type;
70 #ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
71 unsigned int mod_sel = get_rf_mod_type();
73 unsigned int mod_sel = wifi_pm_get_mod_type();
76 type = script_get_item("wifi_para", "wifi_sdc_id", &val);
77 if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
78 RTW_INFO("get wifi_sdc_id failed\n");
82 RTW_INFO("----- %s sdc_id: %d, mod_sel: %d\n", __FUNCTION__, sdc_id, mod_sel);
84 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
85 sw_mci_rescan_card(sdc_id, 1);
86 #elif defined(CONFIG_PLATFORM_ARM_SUN8I)
87 sunxi_mci_rescan_card(sdc_id, 1);
92 RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
95 #ifdef CONFIG_GPIO_WAKEUP
96 #ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
97 type = script_get_item("wifi_para", "wl_host_wake", &val);
99 #ifdef CONFIG_RTL8723B
100 type = script_get_item("wifi_para", "rtl8723bs_wl_host_wake", &val);
102 #ifdef CONFIG_RTL8188E
103 type = script_get_item("wifi_para", "rtl8189es_host_wake", &val);
105 #endif /* CONFIG_PLATFORM_ARM_SUN8I_W5P1 */
106 if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
107 RTW_INFO("No definition of wake up host PIN\n");
110 gpio_eint_wlan = val.gpio.gpio;
111 #ifdef CONFIG_PLATFORM_ARM_SUN8I
112 oob_irq = gpio_to_irq(gpio_eint_wlan);
115 #endif /* CONFIG_GPIO_WAKEUP */
117 #endif /* CONFIG_MMC */
122 void platform_wifi_power_off(void)
125 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
126 sw_mci_rescan_card(sdc_id, 0);
127 #elif defined(CONFIG_PLATFORM_ARM_SUN8I)
128 sunxi_mci_rescan_card(sdc_id, 0);
133 RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
134 #endif /* CONFIG_MMC */