Пример #1
0
/*
 * Cabrcmed upon a sleep-indication from the device
 */
static void brcm_device_want_to_sleep(struct hci_uart *hu)
{
	unsigned long flags;
	struct brcm_struct *brcm = hu->priv;

	BT_DBG("hu %p", hu);

	/* lock hcibrcm state */
	spin_lock_irqsave(&brcm->hcibrcm_lock, flags);

	/* sanity check */
	if (brcm->hcibrcm_state != HCIBRCM_AWAKE)
		BT_ERR("ERR: HCIBRCM_GO_TO_SLEEP_IND in state %ld", brcm->hcibrcm_state);

	/* acknowledge device sleep */
	if (send_hcibrcm_cmd(HCIBRCM_GO_TO_SLEEP_ACK, hu) < 0) {
		BT_ERR("cannot acknowledge device sleep");
		goto out;
	}

	/* update state */
	brcm->hcibrcm_state = HCIBRCM_ASLEEP;

out:
	spin_unlock_irqrestore(&brcm->hcibrcm_lock, flags);

	/* actuabrcmy send the sleep ack packet */
	hci_uart_tx_wakeup(hu);

	spin_lock_irqsave(&brcm->hcibrcm_lock, flags);
	if (brcm->hcibrcm_state == HCIBRCM_ASLEEP)
		__brcm_msm_serial_clock_request_off(hu->tty);
	spin_unlock_irqrestore(&brcm->hcibrcm_lock, flags);
}
Пример #2
0
static void serial_asleep(struct hci_uart *hu)
{
    struct brcm_struct *lbrcm = (struct brcm_struct *)hu->priv;
    unsigned long flags;

    if (lbrcm->hcibrcm_state_serial == HCIBRCM_ASLEEP)
        return;

    lbrcm->inactive_period_serial += TIMER_PERIOD;
    if (lbrcm->inactive_period_serial < HOST_CONTROLLER_IDLE_TSH_SERIAL)
        return;

    if (!can_sleep(hu))
        return;

    spin_lock_irqsave(&lbrcm->hcibrcm_lock, flags);

    __brcm_msm_serial_clock_request_off(hu->tty);

    lbrcm->hcibrcm_state_serial = HCIBRCM_ASLEEP;

    spin_unlock_irqrestore(&lbrcm->hcibrcm_lock, flags);

    BT_DBG("bluetooth serial clock off");
}