static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
{
    int retval;

    /* Wait for DMA, ignore error until we initialize queues. */
    rt2800_wait_wpdma_ready(rt2x00dev);

    if (unlikely(rt2800pci_init_queues(rt2x00dev)))
        return -EIO;

    retval = rt2800_enable_radio(rt2x00dev);
    if (retval)
        return retval;

    /* After resume MCU_BOOT_SIGNAL will trash these. */
    rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
    rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);

    rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_RADIO_OFF, 0xff, 0x02);
    rt2800pci_mcu_status(rt2x00dev, TOKEN_RADIO_OFF);

    rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP, 0, 0);
    rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP);

    return retval;
}
/*
 * Device state switch handlers.
 */
static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
{
	int retval;

	retval = rt2800mmio_enable_radio(rt2x00dev);
	if (retval)
		return retval;

	/* After resume MCU_BOOT_SIGNAL will trash these. */
	rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
	rt2x00mmio_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);

	rt2800_mcu_request(rt2x00dev, MCU_SLEEP, TOKEN_RADIO_OFF, 0xff, 0x02);
	rt2800pci_mcu_status(rt2x00dev, TOKEN_RADIO_OFF);

	rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKEUP, 0, 0);
	rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKEUP);

	return retval;
}
static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev,
			       enum dev_state state)
{
	if (state == STATE_AWAKE) {
		rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKUP, 0, 0x02);
		rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKUP);
	} else if (state == STATE_SLEEP) {
		rt2800_register_write(rt2x00dev, H2M_MAILBOX_STATUS, 0xffffffff);
		rt2800_register_write(rt2x00dev, H2M_MAILBOX_CID, 0xffffffff);
		rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0x01, 0xff, 0x01);
	}

	return 0;
}
Example #4
0
static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev,
			       enum dev_state state)
{
	/*
	 * Always put the device to sleep (even when we intend to wakeup!)
	 * if the device is booting and wasn't asleep it will return
	 * failure when attempting to wakeup.
	 */
	rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2);

	if (state == STATE_AWAKE) {
		rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, TOKEN_WAKUP, 0, 0);
		rt2800pci_mcu_status(rt2x00dev, TOKEN_WAKUP);
	}

	return 0;
}