Path: blob/master/ALFA-W1F1/RTL8814AU/platform/platform_ARM_SUNnI_sdio.c
1307 views
/******************************************************************************1*2* Copyright(c) 2013 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/14/*15* Description:16* This file can be applied to following platforms:17* CONFIG_PLATFORM_ARM_SUN6I18* CONFIG_PLATFORM_ARM_SUN7I19* CONFIG_PLATFORM_ARM_SUN8I20*/21#include <drv_types.h>22#include <mach/sys_config.h>23#ifdef CONFIG_GPIO_WAKEUP24#include <linux/gpio.h>25#endif2627#ifdef CONFIG_MMC28static int sdc_id = -1;29static signed int gpio_eint_wlan = -1;30static u32 eint_wlan_handle = 0;3132#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)33extern void sw_mci_rescan_card(unsigned id, unsigned insert);34#elif defined(CONFIG_PLATFORM_ARM_SUN8I)35extern void sunxi_mci_rescan_card(unsigned id, unsigned insert);36#endif3738#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P139extern int get_rf_mod_type(void);40#else41extern int wifi_pm_get_mod_type(void);42#endif4344extern void wifi_pm_power(int on);45#ifdef CONFIG_GPIO_WAKEUP46extern unsigned int oob_irq;47#endif48#endif /* CONFIG_MMC */4950/*51* Return:52* 0: power on successfully53* others: power on failed54*/55int platform_wifi_power_on(void)56{57int ret = 0;5859#ifdef CONFIG_MMC60{61script_item_u val;62script_item_value_type_e type;6364#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P165unsigned int mod_sel = get_rf_mod_type();66#else67unsigned int mod_sel = wifi_pm_get_mod_type();68#endif6970type = script_get_item("wifi_para", "wifi_sdc_id", &val);71if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {72RTW_INFO("get wifi_sdc_id failed\n");73ret = -1;74} else {75sdc_id = val.val;76RTW_INFO("----- %s sdc_id: %d, mod_sel: %d\n", __FUNCTION__, sdc_id, mod_sel);7778#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)79sw_mci_rescan_card(sdc_id, 1);80#elif defined(CONFIG_PLATFORM_ARM_SUN8I)81sunxi_mci_rescan_card(sdc_id, 1);82#endif83mdelay(100);84wifi_pm_power(1);8586RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);87}8889#ifdef CONFIG_GPIO_WAKEUP90#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P191type = script_get_item("wifi_para", "wl_host_wake", &val);92#else93#ifdef CONFIG_RTL8723B94type = script_get_item("wifi_para", "rtl8723bs_wl_host_wake", &val);95#endif96#ifdef CONFIG_RTL8188E97type = script_get_item("wifi_para", "rtl8189es_host_wake", &val);98#endif99#endif /* CONFIG_PLATFORM_ARM_SUN8I_W5P1 */100if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {101RTW_INFO("No definition of wake up host PIN\n");102ret = -1;103} else {104gpio_eint_wlan = val.gpio.gpio;105#ifdef CONFIG_PLATFORM_ARM_SUN8I106oob_irq = gpio_to_irq(gpio_eint_wlan);107#endif108}109#endif /* CONFIG_GPIO_WAKEUP */110}111#endif /* CONFIG_MMC */112113return ret;114}115116void platform_wifi_power_off(void)117{118#ifdef CONFIG_MMC119#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)120sw_mci_rescan_card(sdc_id, 0);121#elif defined(CONFIG_PLATFORM_ARM_SUN8I)122sunxi_mci_rescan_card(sdc_id, 0);123#endif124mdelay(100);125wifi_pm_power(0);126127RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);128#endif /* CONFIG_MMC */129}130131132