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_SUN50IW1P1
25 #include <drv_types.h>
26 #ifdef CONFIG_GPIO_WAKEUP
27 #include <linux/gpio.h>
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);
38 #ifdef CONFIG_GPIO_WAKEUP
39 extern unsigned int oob_irq;
41 #endif /* CONFIG_MMC */
45 * 0: power on successfully
46 * others: power on failed
48 int platform_wifi_power_on(void)
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;
60 sunxi_wlan_set_power(1);
62 sunxi_mmc_rescan_card(wlan_bus_index);
64 RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
66 #ifdef CONFIG_GPIO_WAKEUP
67 #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
68 oob_irq = sunxi_wlan_get_oob_irq();
70 #endif /* CONFIG_GPIO_WAKEUP */
72 #endif /* CONFIG_MMC */
77 void platform_wifi_power_off(void)
80 #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
81 int wlan_bus_index = sunxi_wlan_get_bus_index();
82 if (wlan_bus_index < 0)
85 sunxi_mmc_rescan_card(wlan_bus_index);
87 sunxi_wlan_set_power(0);
89 RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
90 #endif /* CONFIG_MMC */