Path: blob/master/ALFA-W1F1/RTL8814AU/platform/platform_ARM_SUNxI_usb.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_SUNXI Series platform18*19*/2021#include <drv_types.h>22#include <mach/sys_config.h>2324#ifdef CONFIG_PLATFORM_ARM_SUNxI25extern int sw_usb_disable_hcd(__u32 usbc_no);26extern int sw_usb_enable_hcd(__u32 usbc_no);27static int usb_wifi_host = 2;28#endif2930#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)31extern int sw_usb_disable_hcd(__u32 usbc_no);32extern int sw_usb_enable_hcd(__u32 usbc_no);33extern void wifi_pm_power(int on);34static script_item_u item;35#endif3637#ifdef CONFIG_PLATFORM_ARM_SUN8I38extern int sunxi_usb_disable_hcd(__u32 usbc_no);39extern int sunxi_usb_enable_hcd(__u32 usbc_no);40extern void wifi_pm_power(int on);41static script_item_u item;42#endif434445int platform_wifi_power_on(void)46{47int ret = 0;4849#ifdef CONFIG_PLATFORM_ARM_SUNxI50#ifndef CONFIG_RTL8723A51{52/* ----------get usb_wifi_usbc_num------------- */53ret = script_parser_fetch("usb_wifi_para", "usb_wifi_usbc_num", (int *)&usb_wifi_host, 64);54if (ret != 0) {55RTW_INFO("ERR: script_parser_fetch usb_wifi_usbc_num failed\n");56ret = -ENOMEM;57goto exit;58}59RTW_INFO("sw_usb_enable_hcd: usbc_num = %d\n", usb_wifi_host);60sw_usb_enable_hcd(usb_wifi_host);61}62#endif /* CONFIG_RTL8723A */63#endif /* CONFIG_PLATFORM_ARM_SUNxI */6465#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)66{67script_item_value_type_e type;6869type = script_get_item("wifi_para", "wifi_usbc_id", &item);70if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {71printk("ERR: script_get_item wifi_usbc_id failed\n");72ret = -ENOMEM;73goto exit;74}7576printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);77wifi_pm_power(1);78mdelay(10);7980#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))81sw_usb_enable_hcd(item.val);82#endif83}84#endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */8586#if defined(CONFIG_PLATFORM_ARM_SUN8I)87{88script_item_value_type_e type;8990type = script_get_item("wifi_para", "wifi_usbc_id", &item);91if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {92printk("ERR: script_get_item wifi_usbc_id failed\n");93ret = -ENOMEM;94goto exit;95}9697printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);98wifi_pm_power(1);99mdelay(10);100101#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))102sunxi_usb_enable_hcd(item.val);103#endif104}105#endif /* CONFIG_PLATFORM_ARM_SUN8I */106107exit:108return ret;109}110111void platform_wifi_power_off(void)112{113114#ifdef CONFIG_PLATFORM_ARM_SUNxI115#ifndef CONFIG_RTL8723A116RTW_INFO("sw_usb_disable_hcd: usbc_num = %d\n", usb_wifi_host);117sw_usb_disable_hcd(usb_wifi_host);118#endif /* ifndef CONFIG_RTL8723A */119#endif /* CONFIG_PLATFORM_ARM_SUNxI */120121#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)122#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))123sw_usb_disable_hcd(item.val);124#endif125wifi_pm_power(0);126#endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */127128#if defined(CONFIG_PLATFORM_ARM_SUN8I)129#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))130sunxi_usb_disable_hcd(item.val);131#endif132wifi_pm_power(0);133#endif /* defined(CONFIG_PLATFORM_ARM_SUN8I) */134135}136137138