コード例 #1
0
int bcm_sdiowl_init(int onoff)
{
	int rc;
	struct sdio_wifi_dev *dev = &gDev;
#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT
	int wait_cnt;
	struct mmc_card *card;
#endif

	printk(KERN_ERR "%s:ENTRY\n",__FUNCTION__);


//Set the Pull of Sdio Lines first

	SdioPinCfgs.name = PN_MMC1CMD;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=0;
	SdioPinCfgs.reg.b.pull_up=1;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs);


	SdioPinCfgs.name = PN_MMC1DAT0;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=0;
	SdioPinCfgs.reg.b.pull_up=1;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs);

	SdioPinCfgs.name = PN_MMC1DAT1;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=0;
	SdioPinCfgs.reg.b.pull_up=1;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs);


	SdioPinCfgs.name = PN_MMC1DAT2;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=0;
	SdioPinCfgs.reg.b.pull_up=1;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs);


	SdioPinCfgs.name = PN_MMC1DAT3;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=0;
	SdioPinCfgs.reg.b.pull_up=1;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs);

#if defined(CONFIG_MACH_RHEA_SS_ZANIN) || defined(CONFIG_MACH_RHEA_SS_CORIPLUS)
	SdioPinCfgs.name = PN_GPIO07;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=1;
	SdioPinCfgs.reg.b.pull_up=0;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs);
#elif defined(CONFIG_MACH_RHEA_SS_LUCAS)
	SdioPinCfgs.name = PN_UBCTSN;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=1;
	SdioPinCfgs.reg.b.pull_up=0;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs);
#endif

	SdioPinCfgs.name = PN_MMC1RST;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn=0;
	SdioPinCfgs.reg.b.pull_up=0;
	SdioPinCfgs.reg.b.drv_sth=3;
	pinmux_set_pin_config(&SdioPinCfgs); 



//-----------------------------------



	/* check if the SDIO device is already up */
	rc = sdio_dev_is_initialized(SDIO_DEV_TYPE_WIFI);
	if (rc <= 0) {
		PRINT_ERR("sdio interface is not initialized or err=%d\n", rc);
		return rc;  
	}
	printk(KERN_ERR "%s:GET_GPIO INFO\n",__FUNCTION__);

	dev->wifi_gpio = sdio_get_wifi_gpio(SDIO_DEV_TYPE_WIFI);
#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT

	if (dev->wifi_gpio == NULL) {
		PRINT_ERR("wifi gpio hardware config is missing\n");
		return -EFAULT;
	}
#endif 

	/* reserve GPIOs */
	rc = wifi_gpio_request(dev->wifi_gpio);
	if (rc < 0) {
		PRINT_ERR("unable to reserve certain gpio pins\n");
		return rc;
	}

	/* reset the wifi chip */
	if(onoff)
		__wifi_reset(dev->wifi_gpio->reset, 1);
	else
		__wifi_reset(dev->wifi_gpio->reset, 0);

	printk(KERN_ERR "%s: WLAN_REG_ON(GPIO%d) : value(%d)\n",__FUNCTION__, dev->wifi_gpio->reset, gpio_get_value(dev->wifi_gpio->reset));


#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT

	/* now, emulate the card insertion */
	rc = sdio_card_emulate(SDIO_DEV_TYPE_WIFI, 1);
	if (rc < 0) {
		PRINT_ERR("sdio_card_emulate failed\n");
		goto err_free_gpio;
	}
#define WAIT_CNT 10
	/* need to wait for the mmc device population to finish */
	wait_cnt = 0;
	while (wait_cnt++ < WAIT_CNT) {
		card = sdio_get_mmc_card(SDIO_DEV_TYPE_WIFI);
		if (card) {
			atomic_set(&dev->dev_is_ready, 1);
			return 0;
		}
		msleep(100);
	}
	PRINT_ERR("timeout while populating sdio wifi device\n");
	rc = -EIO;
	sdio_card_emulate(SDIO_DEV_TYPE_WIFI, 0);

err_free_gpio:
	wifi_gpio_free(dev->wifi_gpio);
#endif // CONFIG_BRCM_UNIFIED_DHD_SUPPORT
	return rc;
}
コード例 #2
0
ファイル: sdio-wifi.c プロジェクト: CVlaspoel/VSMC-i9105p
int bcm_sdiowl_init(int onoff)
{
	int rc;
	struct sdio_wifi_dev *dev = &gDev;
#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT
	int wait_cnt;
	struct mmc_card *card;
#endif

	printk(KERN_ERR "%s:ENTRY\n", __func__);

	/* check if the SDIO device is already up */
	rc = wifi_sdio_is_initialized();
	if (rc <= 0) {
		PRINT_ERR("sdio interface is not initialized or err=%d\n", rc);
		return rc;
	}
	printk(KERN_ERR "%s:GET_GPIO INFO\n", __func__);

	dev->wifi_gpio = wifi_sdio_get_gpio();

#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT
        if (dev->wifi_gpio == NULL) {
                PRINT_ERR("wifi gpio hardware config is missing\n");
                return -EFAULT;
       }
#endif


#ifdef CONFIG_BRCM_UNIFIED_DHD_SUPPORT

#ifdef HW_WLAN_GPIO_RESET_PIN
	dev->wifi_gpio->reset = HW_WLAN_GPIO_RESET_PIN;
#else
	dev->wifi_gpio->reset = -1;
#endif
#ifdef HW_WLAN_GPIO_SHUTDOWN_PIN
	dev->wifi_gpio->shutdown = HW_WLAN_GPIO_SHUTDOWN_PIN;
#else
	dev->wifi_gpio->shutdown = -1;
#endif
#ifdef HW_WLAN_GPIO_REG_PIN
	dev->wifi_gpio->reg = HW_WLAN_GPIO_REG_PIN;
#else
	dev->wifi_gpio->reg = -1;
#endif
#ifdef HW_WLAN_GPIO_HOST_WAKE_PIN
	dev->wifi_gpio->host_wake = HW_WLAN_GPIO_HOST_WAKE_PIN;
#else
	dev->wifi_gpio->host_wake = -1;
#endif

#endif

	/* reserve GPIOs */
	rc = wifi_gpio_request(dev->wifi_gpio);
	if (rc < 0) {
		PRINT_ERR("unable to reserve certain gpio pins\n");
		return rc;
	}

#ifdef CONFIG_ARCH_CAPRI
	capri_pm_sdio_pinmux_ctrl(SDIO_DEV_NUM, 0);
#endif
	wifi_sdio_pinmux_pullup_enable(1);

	/* reset the wifi chip */
	if(onoff)
		__wifi_reset(dev->wifi_gpio->reset, 1);
	else
	__wifi_reset(dev->wifi_gpio->reset, 0);

 	printk(KERN_ERR "%s: WLAN_REG_ON(GPIO%d) : value(%d)\n",__func__, dev->wifi_gpio->reset, gpio_get_value(dev->wifi_gpio->reset));
	printk(KERN_ERR "%s:GPIO TOGGLED AND EXIT\n", __func__);

        /* now, emulate the card insertion */
        rc = wifi_sdio_card_emulate(1);
        if (rc < 0) {
                PRINT_ERR("sdio_card_emulate failed\n");
                goto err_free_gpio;
        }

#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT
 #define WAIT_CNT 10

        /* need to wait for the mmc device population to finish */
        wait_cnt = 0;
        while (wait_cnt++ < WAIT_CNT) {
                card = wifi_sdio_get_card();
                if (card) {
                        atomic_set(&dev->dev_is_ready, 1);
                        return 0;
                }
                msleep(100);
        }
        PRINT_ERR("timeout while populating sdio wifi device\n");
        rc = -EIO;

        wifi_sdio_card_emulate(0);
#endif

err_free_gpio:
	wifi_gpio_free(dev->wifi_gpio);

	return rc;
}
コード例 #3
0
int bcm_sdiowl_init(int onoff)
{
	int rc;
	struct sdio_wifi_dev *dev = &gDev;
#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT
	int wait_cnt;
	struct mmc_card *card;
#endif

	printk(KERN_ERR "%s:ENTRY\n", __func__);


/* Set the Pull of Sdio Lines first */
	SdioPinCfgs.name = PN_MMC1CK;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.input_dis = 0;
	SdioPinCfgs.reg.b.pull_dn = 0;
	SdioPinCfgs.reg.b.pull_up = 0;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);

	SdioPinCfgs.name = PN_MMC1CMD;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn = 0;
	SdioPinCfgs.reg.b.pull_up = 1;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);


	SdioPinCfgs.name = PN_MMC1DAT0;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn = 0;
	SdioPinCfgs.reg.b.pull_up = 1;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);

	SdioPinCfgs.name = PN_MMC1DAT1;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn = 0;
	SdioPinCfgs.reg.b.pull_up = 1;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);


	SdioPinCfgs.name = PN_MMC1DAT2;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn = 0;
	SdioPinCfgs.reg.b.pull_up = 1;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);


	SdioPinCfgs.name = PN_MMC1DAT3;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn = 0;
	SdioPinCfgs.reg.b.pull_up = 1;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);


	SdioPinCfgs.name = PN_MMC1DAT4;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn = 1;
	SdioPinCfgs.reg.b.pull_up = 0;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);
/*
	SdioPinCfgs.name = PN_LCDTE;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.pull_dn = 0;
	SdioPinCfgs.reg.b.pull_up = 0;
	SdioPinCfgs.reg.b.drv_sth = 3;
	pinmux_set_pin_config(&SdioPinCfgs);
*/


/* ----------------------------------- */



	/* check if the SDIO device is already up */
	rc = sdio_dev_is_initialized(SDIO_DEV_TYPE_WIFI);
	if (rc <= 0) {
		PRINT_ERR("sdio interface is not initialized or err=%d\n", rc);
		return rc;
	}
	printk(KERN_ERR "%s:GET_GPIO INFO\n", __func__);

	dev->wifi_gpio = sdio_get_wifi_gpio(SDIO_DEV_TYPE_WIFI);
#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT

	if (dev->wifi_gpio == NULL) {
		PRINT_ERR("wifi gpio hardware config is missing\n");
		return -EFAULT;
	}
#endif

#ifdef CONFIG_BRCM_UNIFIED_DHD_SUPPORT
#if defined(CONFIG_MACH_HAWAII_RAY) || defined(CONFIG_MACH_HAWAII_STONE) \
	|| defined(CONFIG_MACH_HAWAII_GARNET) \
	|| defined(CONFIG_MACH_HAWAII_SS_EVAL_REV00) \
	|| defined(CONFIG_MACH_HAWAII_SS_LOGAN_REV00) \
	|| defined(CONFIG_MACH_HAWAII_SS_LOGAN_REV01)
	dev->wifi_gpio->reset = 3;
	dev->wifi_gpio->reg = -1;
	dev->wifi_gpio->host_wake = 74;
	dev->wifi_gpio->shutdown = -1;
#endif
#endif

	/* reserve GPIOs */
	rc = wifi_gpio_request(dev->wifi_gpio);
	if (rc < 0) {
		PRINT_ERR("unable to reserve certain gpio pins\n");
		return rc;
	}

	/* reset the wifi chip */
	if (onoff)
		__wifi_reset(dev->wifi_gpio->reset, 1);
	else
		__wifi_reset(dev->wifi_gpio->reset, 0);

	printk(KERN_ERR "%s: WLAN_REG_ON(GPIO%d) : value(%d)\n",
		__func__, dev->wifi_gpio->reset,
		gpio_get_value(dev->wifi_gpio->reset));

	printk(KERN_ERR "%s:GPIO TOGGLED AND EXIT\n", __func__);

#ifndef CONFIG_BRCM_UNIFIED_DHD_SUPPORT

	/* now, emulate the card insertion */
	rc = sdio_card_emulate(SDIO_DEV_TYPE_WIFI, 1);
	if (rc < 0) {
		PRINT_ERR("sdio_card_emulate failed\n");
		goto err_free_gpio;
	}
#define WAIT_CNT 10
	/* need to wait for the mmc device population to finish */
	wait_cnt = 0;
	while (wait_cnt++ < WAIT_CNT) {
		card = sdio_get_mmc_card(SDIO_DEV_TYPE_WIFI);
		if (card) {
			atomic_set(&dev->dev_is_ready, 1);
			return 0;
		}
		msleep(100);
	}
	PRINT_ERR("timeout while populating sdio wifi device\n");
	rc = -EIO;
	sdio_card_emulate(SDIO_DEV_TYPE_WIFI, 0);

err_free_gpio:
	wifi_gpio_free(dev->wifi_gpio);
#endif /* CONFIG_BRCM_UNIFIED_DHD_SUPPORT */
	return rc;
}