Esempio n. 1
0
int bcm_wlan_set_power(bool on)
{
	int err = 0;

	if (on) {
		printk("======== PULL WL_REG_ON HIGH! ========\n");
#ifdef CONFIG_MACH_ODROID_4210
		err = gpio_set_value(EXYNOS4_GPK1(0), 1);
#endif
#ifdef CUSTOMER_HW_ALLWINNER
		wifi_pm_power(1);
#endif
		/* Lets customer power to get stable */
		mdelay(100);
	} else {
		printk("======== PULL WL_REG_ON LOW! ========\n");
#ifdef CONFIG_MACH_ODROID_4210
		err = gpio_set_value(EXYNOS4_GPK1(0), 0);
#endif
#ifdef CUSTOMER_HW_ALLWINNER
		wifi_pm_power(0);
#endif
	}

	return err;
}
/*
 * Return:
 *	0:	power on successfully
 *	others: power on failed
 */
int platform_wifi_power_on(void)
{
	int ret = 0;

#ifdef CONFIG_MMC
{
	script_item_u val;
	script_item_value_type_e type;

	unsigned int mod_sel = wifi_pm_get_mod_type();

	type = script_get_item("wifi_para", "wifi_sdc_id", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT!=type) {
		DBG_871X("get wifi_sdc_id failed\n");
		ret = -1;
	} else {
		sdc_id = val.val;
		DBG_871X("----- %s sdc_id: %d, mod_sel: %d\n", __FUNCTION__, sdc_id, mod_sel);

		wifi_pm_power(0);
		mdelay(50);
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
		sw_mci_rescan_card(sdc_id, 1);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
		sunxi_mci_rescan_card(sdc_id, 1);
#endif
		mdelay(100);
		wifi_pm_power(1);

		DBG_871X("%s: power up, rescan card.\n", __FUNCTION__);
	}

#ifdef CONFIG_GPIO_WAKEUP
#ifdef CONFIG_RTL8723B
	type = script_get_item("wifi_para", "rtl8723bs_wl_host_wake", &val);
#endif
#ifdef CONFIG_RTL8188E
	type = script_get_item("wifi_para", "rtl8189es_host_wake", &val);
#endif
	if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
		DBG_871X("No definition of wake up host PIN\n");
		ret = -1;
	} else {
		gpio_eint_wlan = val.gpio.gpio;
#ifdef CONFIG_PLATFORM_ARM_SUN8I
		oob_irq = gpio_to_irq(gpio_eint_wlan);
#endif
	}
#endif // CONFIG_GPIO_WAKEUP
}
#endif // CONFIG_MMC

	return ret;
}
int platform_wifi_power_on(void)
{
	int ret = 0;

#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
	{
		script_item_value_type_e type;

		type = script_get_item("wifi_para", "wifi_usbc_id", &item);
		if(SCIRPT_ITEM_VALUE_TYPE_INT != type){
			printk("ERR: script_get_item wifi_usbc_id failed\n");
			ret = -ENOMEM;
			goto exit;
		}

		printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
		wifi_pm_power(1);
		mdelay(10);
	
		#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
		sw_usb_enable_hcd(item.val);
		#endif
	}
#endif //defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)

#if defined(CONFIG_PLATFORM_ARM_SUNxI)
	{
		script_item_value_type_e type;

		type = script_get_item("wifi_para", "wifi_usbc_id", &item);
		if(SCIRPT_ITEM_VALUE_TYPE_INT != type){
			printk("ERR: script_get_item wifi_usbc_id failed\n");
			ret = -ENOMEM;
			goto exit;
		}

		printk("sunxi_usb_enable_hcd: usbc_num = %d\n", item.val);
		wifi_pm_power(1);
		mdelay(10);
	
		#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
		sunxi_usb_enable_hcd(item.val);
		#endif
	}
#endif //CONFIG_PLATFORM_ARM_SUNxI

exit:
	return ret;
}
void platform_wifi_power_off(void)
{
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
	#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
	sw_usb_disable_hcd(item.val);
	#endif
	wifi_pm_power(0);
#endif //defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)

#if defined(CONFIG_PLATFORM_ARM_SUNxI)
	#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
	sunxi_usb_disable_hcd(item.val);
	#endif
	wifi_pm_power(0);
#endif //defined(CONFIG_PLATFORM_ARM_SUNxI) 

}
void platform_wifi_power_off(void)
{
#ifdef CONFIG_MMC
	wifi_pm_power(0);
#if defined(CONFIG_PLATFORM_ARM_SUN6I) ||defined(CONFIG_PLATFORM_ARM_SUN7I)
	sw_mci_rescan_card(sdc_id, 0);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
	sunxi_mci_rescan_card(sdc_id, 0);
#endif
	DBG_871X("%s: remove card, power off.\n", __FUNCTION__);
#endif // CONFIG_MMC
}
void platform_wifi_power_off(void)
{
#ifdef CONFIG_MMC
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
	sw_mci_rescan_card(sdc_id, 0);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
	sunxi_mci_rescan_card(sdc_id, 0);
#endif
	mdelay(100);
	wifi_pm_power(0);

	RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
#endif /* CONFIG_MMC */
}
/* Customer function to control hw specific wlan gpios */
void
dhd_customer_gpio_wlan_ctrl(int onoff)
{
    static int first = 1;
    static int sdc_id = 1;

    script_item_value_type_e type;
    script_item_u val;

    if (first == 1) {
        type = script_get_item("wifi_para", "wifi_sdc_id", &val);
        if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
            WL_ERROR(("failed to fetch sdio card's sdcid\n"));
            return -1;
        }
        sdc_id = val.val;
        first = 0;
    }

    switch (onoff) {
    case WLAN_RESET_OFF:
        WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n",
                  __FUNCTION__));
#ifdef CUSTOMER_HW
        wifi_pm_power(0);
#endif /* CUSTOMER_HW */
#if defined(CUSTOMER_HW2)
        wifi_set_power(0, 0);
#endif
        mdelay(100);
        WL_ERROR(("=========== WLAN placed in RESET ========\n"));
        break;

    case WLAN_RESET_ON:
        WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n",
                  __FUNCTION__));
#ifdef CUSTOMER_HW
        wifi_pm_power(1);
#endif /* CUSTOMER_HW */
#if defined(CUSTOMER_HW2)
        wifi_set_power(1, 0);
#endif
        mdelay(100);
        WL_ERROR(("=========== WLAN going back to live  ========\n"));
        break;

    case WLAN_POWER_OFF:
        WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n",
                  __FUNCTION__));
#ifdef CUSTOMER_HW
        wifi_pm_power(0);
        sw_mci_rescan_card(sdc_id, 0);
#endif /* CUSTOMER_HW */
        WL_ERROR(("=========== WLAN placed in POWER OFF ========\n"));
        break;

    case WLAN_POWER_ON:
        WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n",
                  __FUNCTION__));
#ifdef CUSTOMER_HW
        wifi_pm_power(1);
        sw_mci_rescan_card(sdc_id, 1);
        /* Lets customer power to get stable */
#endif /* CUSTOMER_HW */
        mdelay(100);
        WL_ERROR(("=========== WLAN placed in POWER ON ========\n"));
        break;
    }
}