示例#1
0
static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf,
				 size_t len, bool fixed)
{
	int ret;
	struct sdio_func *func = wl_to_func(wl);

	if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
		((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret);
		wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x",
			     addr, ((u8 *)buf)[0]);
	} else {
		if (fixed)
			ret = sdio_readsb(func, buf, addr, len);
		else
			ret = sdio_memcpy_fromio(func, buf, addr, len);

		wl1271_debug(DEBUG_SDIO, "sdio read 53 addr 0x%x, %zu bytes",
			     addr, len);
		wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len);
	}

	if (ret)
		wl1271_error("sdio read failed (%d)", ret);

}
示例#2
0
文件: sdio.c 项目: ANFS/ANFS-kernel
static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf,
				  size_t len, bool fixed)
{
	int ret;
	struct sdio_func *func = wl_to_func(wl);

	sdio_claim_host(func);

	if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
		sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret);
		wl1271_debug(DEBUG_SDIO, "sdio write 52 addr 0x%x, byte 0x%02x",
			     addr, ((u8 *)buf)[0]);
	} else {
		wl1271_debug(DEBUG_SDIO, "sdio write 53 addr 0x%x, %zu bytes",
			     addr, len);
		wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len);

		if (fixed)
			ret = sdio_writesb(func, addr, buf, len);
		else
			ret = sdio_memcpy_toio(func, addr, buf, len);
	}

	sdio_release_host(func);

	if (ret)
		wl1271_error("sdio write failed (%d)", ret);
}
示例#3
0
static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;

	/* Let the SDIO stack handle wlan_enable control, so we
	 * keep host claimed while wlan is in use to keep wl1271
	 * alive.
	 */
	if (enable) {
		/* Power up the card */
		ret = pm_runtime_get_sync(&func->dev);
		if (ret < 0)
			goto out;
		sdio_claim_host(func);
		sdio_enable_func(func);
		sdio_release_host(func);
	} else {
		sdio_claim_host(func);
		sdio_disable_func(func);
		sdio_release_host(func);

		/* Power down the card */
		ret = pm_runtime_put_sync(&func->dev);
	}

out:
	return ret;
}
示例#4
0
static void wl1271_sdio_enable_irq_wake(struct wl1271 *wl)
{
	int ret;
	mmc_pm_flag_t mmcflags;
	struct ieee80211_hw *hw = wl->hw;
	struct sdio_func *func = wl_to_func(wl);

	ret = enable_irq_wake(wl->irq);
	if (!ret) {
		wl->irq_wake_enabled = true;
		device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1);

		/* if sdio can keep power while host is suspended, enable wow */
		mmcflags = sdio_get_host_pm_caps(func);
		wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags);

		if (mmcflags & MMC_PM_KEEP_POWER) {
			hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY;
			hw->wiphy->wowlan.n_patterns =
					WL1271_MAX_RX_DATA_FILTERS;
			hw->wiphy->wowlan.pattern_min_len = 1;
			hw->wiphy->wowlan.pattern_max_len =
					WL1271_RX_DATA_FILTER_MAX_PATTERN_SIZE;
		}
	}
}
示例#5
0
static int wl1271_sdio_power_off(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;

        printk("%s: function entered \n", __FUNCTION__);
       //sdio_claim_host(func); 
	sdio_disable_func(func);
	sdio_release_host(func);
#if 1
	/* Runtime PM might be disabled, so power off the card manually */
	ret = mmc_power_save_host(func->card->host);
	if (ret < 0)
        {
            printk("%s: mmc_power_save_host() returned %d\n", __FUNCTION__, ret);
		return ret;
        }

	/* Let runtime PM know the card is powered off */
	return pm_runtime_put_sync(&func->dev);
#else
         //wl1271_setpower(0);

#endif
}
static int wl1271_sdio_power_on(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;
	/* If enabled, tell runtime PM not to power off the card */
	if (pm_runtime_enabled(&func->dev)) {
		ret = pm_runtime_get_sync(&func->dev);
		if (ret) {
printk (KERN_ERR "%s:pm_runtime_get_sync: %d\n", __func__, ret );
			goto out;
		}
	} else {
		/* Runtime PM is disabled: power up the card manually */
		ret = mmc_power_restore_host(func->card->host);
		if (ret < 0) {
printk (KERN_ERR "%s:mmc_power_restore_host: %d\n", __func__, ret );
			goto out;
		}
	}

	sdio_claim_host(func);
	sdio_enable_func(func);

out:
	return ret;
}
示例#7
0
static void wl1251_sdio_enable_irq(struct wl1251 *wl)
{
	struct sdio_func *func = wl_to_func(wl);

	sdio_claim_host(func);
	sdio_claim_irq(func, wl1251_sdio_interrupt);
	sdio_release_host(func);
}
示例#8
0
static void wl1251_sdio_disable_irq(struct wl1251 *wl)
{
	struct sdio_func *func = wl_to_func(wl);

	sdio_claim_host(func);
	sdio_release_irq(func);
	sdio_release_host(func);
}
示例#9
0
文件: sdio.c 项目: ANFS/ANFS-kernel
static int wl1271_sdio_power_off(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);

	sdio_claim_host(func);
	sdio_disable_func(func);
	sdio_release_host(func);

	/* Power down the card */
	return pm_runtime_put_sync(&func->dev);
}
static void wl1251_sdio_write_elp(struct wl1251 *wl, int addr, u32 val)
{
	int ret = 0;
	struct sdio_func *func = wl_to_func(wl);

	sdio_claim_host(func);
	sdio_writeb(func, val, addr, &ret);
	sdio_release_host(func);

	if (ret)
		wl1251_error("sdio_writeb failed (%d)", ret);
}
示例#11
0
static void wl1251_sdio_write(struct wl1251 *wl, int addr,
			      void *buf, size_t len)
{
	int ret;
	struct sdio_func *func = wl_to_func(wl);

	sdio_claim_host(func);
	ret = sdio_memcpy_toio(func, addr, buf, len);
	if (ret)
		wl1251_error("sdio write failed (%d)", ret);
	sdio_release_host(func);
}
示例#12
0
static void wl1271_sdio_set_power(struct wl1271 *wl, bool enable)
{
	struct sdio_func *func = wl_to_func(wl);

	/* Let the SDIO stack handle wlan_enable control, so we
	 * keep host claimed while wlan is in use to keep wl1271
	 * alive.
	 */
	if (enable) {
		sdio_claim_host(func);
		sdio_enable_func(func);
	} else {
		sdio_disable_func(func);
		sdio_release_host(func);
	}
}
示例#13
0
static int wl1271_sdio_power_off(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;

	sdio_disable_func(func);
	sdio_release_host(func);

	/* Runtime PM might be disabled, so power off the card manually */
	ret = mmc_power_save_host(func->card->host);
	if (ret < 0)
		return ret;

	/* Let runtime PM know the card is powered off */
	return pm_runtime_put_sync(&func->dev);
}
示例#14
0
文件: sdio.c 项目: ANFS/ANFS-kernel
static int wl1271_sdio_power_on(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;

	/* Power up the card */
	ret = pm_runtime_get_sync(&func->dev);
	if (ret < 0)
		goto out;

	sdio_claim_host(func);
	sdio_enable_func(func);
	sdio_release_host(func);

out:
	return ret;
}
static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
{
	int ret = 0;
	struct sdio_func *func = wl_to_func(wl);

	wl1251_enter();
	if (enable) {
		if (wl->set_power)
			wl->set_power(true);

		ret = mmc_power_restore_host(func->card->host);
		if (ret) {
			wl1251_error("failed to restore host power");
			goto out;
		}

		wl1251_debug(DEBUG_PSM, "sdio_claim_host");
		sdio_claim_host(func);
		wl1251_debug(DEBUG_PSM, "sdio_enable_func");
		sdio_enable_func(func);
		wl1251_debug(DEBUG_PSM, "sdio_release_host");
		sdio_release_host(func);
		wl1251_debug(DEBUG_PSM, "sdio_done");
	} else {
		wl1251_debug(DEBUG_PSM, "sdio_claim_host");
		sdio_claim_host(func);
		wl1251_debug(DEBUG_PSM, "sdio_disable_func");
		sdio_disable_func(func);
		wl1251_debug(DEBUG_PSM, "sdio_release_host");
		sdio_release_host(func);
		wl1251_debug(DEBUG_PSM, "power_save_host");
		ret = mmc_power_save_host(func->card->host);
		if (ret) {
			wl1251_error("failed to disable host power");
			goto out;
		}
		wl1251_debug(DEBUG_PSM, "power_save done");

		if (wl->set_power)
			wl->set_power(false);
	}

out:
	wl1251_leave();
	return ret;
}
示例#16
0
static int wl1271_sdio_power_off(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;

	sdio_disable_func(func);
	sdio_release_host(func);

	/* Power off the card manually, even if runtime PM is enabled. */
	ret = mmc_power_save_host(func->card->host);
	if (ret < 0)
		return ret;

	/* If enabled, let runtime PM know the card is powered off */
	if (pm_runtime_enabled(&func->dev))
		ret = pm_runtime_put_sync(&func->dev);

	return ret;
}
示例#17
0
static int wl1271_sdio_power_on(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;

	/* Make sure the card will not be powered off by runtime PM */
	ret = pm_runtime_get_sync(&func->dev);
	if (ret < 0)
		goto out;

	/* Runtime PM might be disabled, so power up the card manually */
	ret = mmc_power_restore_host(func->card->host);
	if (ret < 0)
		goto out;

	sdio_claim_host(func);
	sdio_enable_func(func);

out:
	return ret;
}
示例#18
0
static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;

	if (enable) {
		/*
		 * Power is controlled by runtime PM, but we still call board
		 * callback in case it wants to do any additional setup,
		 * for example enabling clock buffer for the module.
		 */
		if (gpio_is_valid(wl->power_gpio))
			gpio_set_value(wl->power_gpio, true);


		ret = pm_runtime_get_sync(&func->dev);
		if (ret < 0) {
			pm_runtime_put_sync(&func->dev);
			goto out;
		}

		sdio_claim_host(func);
		sdio_enable_func(func);
		sdio_release_host(func);
	} else {
		sdio_claim_host(func);
		sdio_disable_func(func);
		sdio_release_host(func);

		ret = pm_runtime_put_sync(&func->dev);
		if (ret < 0)
			goto out;

		if (gpio_is_valid(wl->power_gpio))
			gpio_set_value(wl->power_gpio, false);
	}

out:
	return ret;
}
示例#19
0
static int wl1271_sdio_power_on(struct wl1271 *wl)
{
	struct sdio_func *func = wl_to_func(wl);
	int ret;


        printk("%s: function entered \n", __FUNCTION__);
#if 1
	/* Make sure the card will not be powered off by runtime PM */
#if 0  // Added Michael Carrier
        printk("%s: Calling pm_runtime_get_sync\n", __FUNCTION__);
	ret = pm_runtime_get_sync(&func->dev);
        printk("%s: pm_runtime_get_sync returned %d\n", __FUNCTION__, ret);
	if (ret < 0)
		goto out;
	/* Runtime PM might be disabled, so power up the card manually */
#endif 

        printk("%s: Calling mmc_power_restore_host\n", __FUNCTION__);
	ret = mmc_power_restore_host(func->card->host);
        printk("%s: mmc_power_restore_host() returned %d\n", __FUNCTION__, ret);
	if (ret < 0)
		goto out;
#else
       //wl1271_setpower(1);

#endif
	/* if the power is already on (WHY?) ret == 1 */
	ret = 0;

	sdio_claim_host(func);
	sdio_enable_func(func);

	/* Set the default block size in case it was modified */
	sdio_set_block_size(func, 0);

out:
	return ret;
}
示例#20
0
static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl)
{
	return &(wl_to_func(wl)->dev);
}
示例#21
0
static int tester(void *data)
{
	struct wl1271 *wl = data;
	struct sdio_func *func = wl_to_func(wl);
	struct device *pdev = &func->dev;
	int ret = 0;
	bool rx_started = 0;
	bool tx_started = 0;
	uint8_t *tx_buf, *rx_buf;
	int test_size = PAGE_SIZE;
	u32 addr = 0;
	struct wl1271_partition_set partition;

	/* We assume chip is powered up and firmware fetched */

	memcpy(&partition, &part_down, sizeof(partition));
	partition.mem.start = addr;
	wl1271_set_partition(wl, &partition);

	tx_buf = kmalloc(test_size, GFP_KERNEL);
	rx_buf = kmalloc(test_size, GFP_KERNEL);
	if (!tx_buf || !rx_buf) {
		dev_err(pdev,
			"Could not allocate memory. Test will not run.\n");
		ret = -ENOMEM;
		goto free;
	}

	memset(tx_buf, 0x5a, test_size);

	/* write something in data area so we can read it back */
	wl1271_write(wl, addr, tx_buf, test_size, false);

	while (!kthread_should_stop()) {
		if (rx && !rx_started) {
			dev_info(pdev, "starting rx test\n");
			rx_started = 1;
		} else if (!rx && rx_started) {
			dev_info(pdev, "stopping rx test\n");
			rx_started = 0;
		}

		if (tx && !tx_started) {
			dev_info(pdev, "starting tx test\n");
			tx_started = 1;
		} else if (!tx && tx_started) {
			dev_info(pdev, "stopping tx test\n");
			tx_started = 0;
		}

		if (rx_started)
			wl1271_read(wl, addr, rx_buf, test_size, false);

		if (tx_started)
			wl1271_write(wl, addr, tx_buf, test_size, false);

		if (!rx_started && !tx_started)
			msleep(100);
	}

free:
	kfree(tx_buf);
	kfree(rx_buf);
	return ret;
}