Esempio n. 1
0
/* Initialize protocol */
static int ath_open(struct hci_uart *hu)
{
	struct ath_struct *ath;

	BT_DBG("hu %p, bsi %p", hu, bsi);

	if (!bsi)
		return -EIO;

	ath = kzalloc(sizeof(*ath), GFP_ATOMIC);
	if (!ath)
		return -ENOMEM;

	skb_queue_head_init(&ath->txq);

	hu->priv = ath;
	ath->hu = hu;

	if (ath_bluesleep_gpio_config(ath, 1) < 0) {
		BT_ERR("HCIATH3K GPIO Config failed");
		hu->priv = NULL;
		kfree(ath);
		return -EIO;
	}

	ath->cur_sleep = enableuartsleep;
	if (ath->cur_sleep == 1) {
		set_bit(BT_SLEEPENABLE, &flags);
		modify_timer_task();
	}
	INIT_WORK(&ath->ctxtsw, ath_hci_uart_work);
	INIT_WORK(&ath->ws_sleep, wakeup_host_work);
	return 0;
}
static int ath_lpm_stop(void)
{
    BT_DBG("Stop LPM mode");
    cancel_work_sync(&ws_sleep);

    if (bsi) {
        bsi->uport = NULL;
        ath_bluesleep_gpio_config(0);
    }

    return 0;
}
/* Initialize protocol */
static int ath_open(struct hci_uart *hu)
{
    struct ath_struct *ath;
    struct uart_state *state;

    BT_DBG("hu %p, bsi %p", hu, bsi);

    if (!bsi) {
        BT_ERR("HCIATH3K bluesleep info does not exist");
        return -EIO;
    }

    ath = kzalloc(sizeof(*ath), GFP_ATOMIC);
    if (!ath) {
        BT_ERR("HCIATH3K Memory not enough to init driver");
        return -ENOMEM;
    }

    skb_queue_head_init(&ath->txq);

    hu->priv = ath;
    ath->hu = hu;
    state = hu->tty->driver_data;

    if (!state) {
        BT_ERR("HCIATH3K tty driver data does not exist");
        return -ENXIO;
    }
    bsi->uport = state->uart_port;

    if (ath_bluesleep_gpio_config(1) < 0) {
        BT_ERR("HCIATH3K GPIO Config failed");
        hu->priv = NULL;
        kfree(ath);
        return -EIO;
    }

    ath->cur_sleep = enableuartsleep;
    if (ath->cur_sleep == 1) {
        set_bit(BT_SLEEPENABLE, &flags);
        modify_timer_task();
    }
    INIT_WORK(&ath->ctxtsw, ath_hci_uart_work);
    INIT_WORK(&ws_sleep, wakeup_host_work);
    return 0;
}
/* Close protocol */
static int ath_close(struct hci_uart *hu)
{
	struct ath_struct *ath = hu->priv;

	BT_DBG("hu %p", hu);

	skb_queue_purge(&ath->txq);

	cancel_work_sync(&ath->ctxtsw);

	hu->priv = NULL;
	kfree(ath);

	if (bsi)
		ath_bluesleep_gpio_config(0);

	return 0;
}
static int ath_lpm_start(void)
{
    BT_DBG("Start LPM mode");

    if (!bsi) {
        BT_ERR("HCIATH3K bluesleep info does not exist");
        return -EIO;
    }

    bsi->uport = msm_hs_get_uart_port(0);
    if (!bsi->uport) {
        BT_ERR("UART Port is not available");
        return -ENODEV;
    }

    INIT_WORK(&ws_sleep, wakeup_host_work);

    if (ath_bluesleep_gpio_config(1) < 0) {
        BT_ERR("HCIATH3K GPIO Config failed");
        return -EIO;
    }

    return 0;
}