net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / platform / platform_ARM_SUN50IW1P1_sdio.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2013 Realtek Corporation. All rights reserved.
4  *
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.
8  *
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
12  * more details.
13  *
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
17  *
18  *
19  ******************************************************************************/
20 /*
21  * Description:
22  *      This file can be applied to following platforms:
23  *      CONFIG_PLATFORM_ARM_SUN50IW1P1
24  */
25 #include <drv_types.h>
26 #ifdef CONFIG_GPIO_WAKEUP
27 #include <linux/gpio.h>
28 #endif
29
30 #ifdef CONFIG_MMC
31 #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
32 extern void sunxi_mmc_rescan_card(unsigned ids);
33 extern void sunxi_wlan_set_power(int on);
34 extern int sunxi_wlan_get_bus_index(void);
35 extern int sunxi_wlan_get_oob_irq(void);
36 extern int sunxi_wlan_get_oob_irq_flags(void);
37 #endif
38 #ifdef CONFIG_GPIO_WAKEUP
39 extern unsigned int oob_irq;
40 #endif
41 #endif /* CONFIG_MMC */
42
43 /*
44  * Return:
45  *      0:      power on successfully
46  *      others: power on failed
47  */
48 int platform_wifi_power_on(void)
49 {
50         int ret = 0;
51
52 #ifdef CONFIG_MMC
53         {
54
55 #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
56                 int wlan_bus_index = sunxi_wlan_get_bus_index();
57                 if (wlan_bus_index < 0)
58                         return wlan_bus_index;
59
60                 sunxi_wlan_set_power(1);
61                 mdelay(100);
62                 sunxi_mmc_rescan_card(wlan_bus_index);
63 #endif
64                 RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
65
66 #ifdef CONFIG_GPIO_WAKEUP
67 #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
68                 oob_irq = sunxi_wlan_get_oob_irq();
69 #endif
70 #endif /* CONFIG_GPIO_WAKEUP */
71         }
72 #endif /* CONFIG_MMC */
73
74         return ret;
75 }
76
77 void platform_wifi_power_off(void)
78 {
79 #ifdef CONFIG_MMC
80 #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
81         int wlan_bus_index = sunxi_wlan_get_bus_index();
82         if (wlan_bus_index < 0)
83                 return;
84
85         sunxi_mmc_rescan_card(wlan_bus_index);
86         mdelay(100);
87         sunxi_wlan_set_power(0);
88 #endif
89         RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
90 #endif /* CONFIG_MMC */
91 }