/*
 *  Qualcomm's Bluetooth Software In-Band Sleep UART protocol
 *
 *  HCI_IBS (HCI In-Band Sleep) is Qualcomm's power management
 *  protocol extension to H4.
 *
 *  Copyright (C) 2007 Texas Instruments, Inc.
 *  Copyright (c) 2010, 2012 Code Aurora Forum. All rights reserved.
 *
 *  Acknowledgements:
 *  This file is based on hci_ll.c, which was...
 *  Written by Ohad Ben-Cohen <ohad@bencohen.org>
 *  which was in turn based on hci_h4.c, which was written
 *  by Maxim Krasnyansky and Marcel Holtmann.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2
 *  as published by the Free Software Foundation
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include <linux/module.h>
#include <linux/kernel.h>

#include <linux/init.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/interrupt.h>
#include <linux/ptrace.h>
#include <linux/poll.h>

#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/signal.h>
#include <linux/ioctl.h>
#include <linux/timer.h>
#include <linux/skbuff.h>
#include <linux/serial_core.h>

#ifdef CONFIG_SERIAL_MSM_HS
#include <mach/msm_serial_hs.h>
#endif

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>

#include "hci_uart.h"

/* HCI_IBS protocol messages */
#define HCI_IBS_SLEEP_IND	0xFE
#define HCI_IBS_WAKE_IND	0xFD
#define HCI_IBS_WAKE_ACK	0xFC

/* HCI_IBS receiver States */
#define HCI_IBS_W4_PACKET_TYPE	0
#define HCI_IBS_W4_EVENT_HDR	1
#define HCI_IBS_W4_ACL_HDR	2
#define HCI_IBS_W4_SCO_HDR	3
#define HCI_IBS_W4_DATA		4

/* HCI_IBS transmit side sleep protocol states */
enum tx_ibs_states_e {
	HCI_IBS_TX_ASLEEP,
	HCI_IBS_TX_WAKING,
	HCI_IBS_TX_AWAKE,
};

/* HCI_IBS receive side sleep protocol states */
enum rx_states_e {
	HCI_IBS_RX_ASLEEP,
	HCI_IBS_RX_AWAKE,
};

/* HCI_IBS transmit and receive side clock state vote */
enum hci_ibs_clock_state_vote_e {
	HCI_IBS_VOTE_STATS_UPDATE,
	HCI_IBS_TX_VOTE_CLOCK_ON,
	HCI_IBS_TX_VOTE_CLOCK_OFF,
	HCI_IBS_RX_VOTE_CLOCK_ON,
	HCI_IBS_RX_VOTE_CLOCK_OFF,
};

static unsigned long wake_retrans = 1;
static unsigned long tx_idle_delay = (HZ * 2);

struct hci_ibs_cmd {
	u8 cmd;
} __attribute__((packed));

struct ibs_struct {
	unsigned long rx_state;
	unsigned long rx_count;
	struct sk_buff *rx_skb;
	struct sk_buff_head txq;
	struct sk_buff_head tx_wait_q;	/* HCI_IBS wait queue	*/
	spinlock_t hci_ibs_lock;	/* HCI_IBS state lock	*/
	unsigned long tx_ibs_state;	/* HCI_IBS transmit side power state */
	unsigned long rx_ibs_state;	/* HCI_IBS receive side power state */
	unsigned long tx_vote;		/* clock must be on for TX */
	unsigned long rx_vote;		/* clock must be on for RX */
	struct	timer_list tx_idle_timer;
	struct	timer_list wake_retrans_timer;
	/* debug */
	unsigned long ibs_sent_wacks;
	unsigned long ibs_sent_slps;
	unsigned long ibs_sent_wakes;
	unsigned long ibs_recv_wacks;
	unsigned long ibs_recv_slps;
	unsigned long ibs_recv_wakes;
	unsigned long vote_last_jif;
	unsigned long vote_on_ticks;
	unsigned long vote_off_ticks;
	unsigned long tx_votes_on;
	unsigned long rx_votes_on;
	unsigned long tx_votes_off;
	unsigned long rx_votes_off;
	unsigned long votes_on;
	unsigned long votes_off;
};

#ifdef CONFIG_SERIAL_MSM_HS
static void __ibs_msm_serial_clock_on(struct tty_struct *tty)
{
	struct uart_state *state = tty->driver_data;
	struct uart_port *port = state->uart_port;

	msm_hs_request_clock_on(port);
}

static void __ibs_msm_serial_clock_request_off(struct tty_struct *tty)
{
	struct uart_state *state = tty->driver_data;
	struct uart_port *port = state->uart_port;

	msm_hs_request_clock_off(port);
}
#else
static inline void __ibs_msm_serial_clock_on(struct tty_struct *tty) {}
static inline void __ibs_msm_serial_clock_request_off(struct tty_struct *tty) {}
#endif

/* clock_vote needs to be called with the ibs lock held */
static void ibs_msm_serial_clock_vote(unsigned long vote, struct hci_uart *hu)
{
	struct ibs_struct *ibs = hu->priv;

	unsigned long old_vote = (ibs->tx_vote | ibs->rx_vote);
	unsigned long new_vote;

	switch (vote) {
	default: /* error */
		BT_ERR("voting irregularity");
		return;
	case HCI_IBS_VOTE_STATS_UPDATE:
		if (old_vote)
			ibs->vote_off_ticks += (jiffies - ibs->vote_last_jif);
		else
			ibs->vote_on_ticks += (jiffies - ibs->vote_last_jif);
		return;
	case HCI_IBS_TX_VOTE_CLOCK_ON:
		ibs->tx_vote = 1;
		ibs->tx_votes_on++;
		new_vote = 1;
		break;
	case HCI_IBS_RX_VOTE_CLOCK_ON:
		ibs->rx_vote = 1;
		ibs->rx_votes_on++;
		new_vote = 1;
		break;
	case HCI_IBS_TX_VOTE_CLOCK_OFF:
		ibs->tx_vote = 0;
		ibs->tx_votes_off++;
		new_vote = ibs->rx_vote | ibs->tx_vote;
		break;
	case HCI_IBS_RX_VOTE_CLOCK_OFF:
		ibs->rx_vote = 0;
		ibs->rx_votes_off++;
		new_vote = ibs->rx_vote | ibs->tx_vote;
		break;
	}
	if (new_vote != old_vote) {
		if (new_vote)
			__ibs_msm_serial_clock_on(hu->tty);
		else
			__ibs_msm_serial_clock_request_off(hu->tty);

		BT_DBG("HCIUART_IBS: vote msm_serial_hs clock %lu(%lu)",
			new_vote, vote);
		/* debug */
		if (new_vote) {
			ibs->votes_on++;
			ibs->vote_off_ticks += (jiffies - ibs->vote_last_jif);
		} else {
			ibs->votes_off++;
			ibs->vote_on_ticks += (jiffies - ibs->vote_last_jif);
		}
		ibs->vote_last_jif = jiffies;
	}
}

/*
 * Builds and sends an HCI_IBS command packet.
 * These are very simple packets with only 1 cmd byte
 */
static int send_hci_ibs_cmd(u8 cmd, struct hci_uart *hu)
{
	int err = 0;
	struct sk_buff *skb = NULL;
	struct ibs_struct *ibs = hu->priv;
	struct hci_ibs_cmd *hci_ibs_packet;

	BT_DBG("hu %p cmd 0x%x", hu, cmd);

	/* allocate packet */
	skb = bt_skb_alloc(1, GFP_ATOMIC);
	if (!skb) {
		BT_ERR("cannot allocate memory for HCI_IBS packet");
		err = -ENOMEM;
		goto out;
	}

	/* prepare packet */
	hci_ibs_packet = (struct hci_ibs_cmd *) skb_put(skb, 1);
	hci_ibs_packet->cmd = cmd;
	skb->dev = (void *) hu->hdev;

	/* send packet */
	skb_queue_tail(&ibs->txq, skb);
out:
	return err;
}

static void hci_ibs_tx_idle_timeout(unsigned long arg)
{
	struct hci_uart *hu = (struct hci_uart *) arg;
	struct ibs_struct *ibs = hu->priv;
	unsigned long flags;
	unsigned long vote_tx_sleep = 0;

	BT_DBG("hu %p idle timeout in %lu state", hu, ibs->tx_ibs_state);

	spin_lock_irqsave_nested(&ibs->hci_ibs_lock,
					flags, SINGLE_DEPTH_NESTING);

	switch (ibs->tx_ibs_state) {
	default:
	case HCI_IBS_TX_ASLEEP:
	case HCI_IBS_TX_WAKING:
		BT_ERR("spurrious timeout in tx state %ld", ibs->tx_ibs_state);
		goto out;
	case HCI_IBS_TX_AWAKE: /* TX_IDLE, go to SLEEP */
		if (send_hci_ibs_cmd(HCI_IBS_SLEEP_IND, hu) < 0) {
			BT_ERR("cannot send SLEEP to device");
			goto out;
		}
		ibs->tx_ibs_state = HCI_IBS_TX_ASLEEP;
		ibs->ibs_sent_slps++; /* debug */
		vote_tx_sleep = 1;
		break;
	}

	spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);

	hci_uart_tx_wakeup(hu);  /* run HCI tx handling unlocked */

	if (!vote_tx_sleep)
		return;
	/* now that message queued to tty driver, vote for tty clocks off */
	/* It is up to the tty driver to pend the clocks off until tx done. */

	spin_lock_irqsave_nested(&ibs->hci_ibs_lock,
					flags, SINGLE_DEPTH_NESTING);
	ibs_msm_serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_OFF, hu);
out:
	spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);
}

static void hci_ibs_wake_retrans_timeout(unsigned long arg)
{
	struct hci_uart *hu = (struct hci_uart *) arg;
	struct ibs_struct *ibs = hu->priv;
	unsigned long flags;
	unsigned long retransmit = 0;

	BT_DBG("hu %p wake retransmit timeout in %lu state",
		hu, ibs->tx_ibs_state);

	spin_lock_irqsave_nested(&ibs->hci_ibs_lock,
					flags, SINGLE_DEPTH_NESTING);

	switch (ibs->tx_ibs_state) {
	default:
	case HCI_IBS_TX_ASLEEP:
	case HCI_IBS_TX_AWAKE:
		BT_ERR("spurrious timeout tx state %ld", ibs->tx_ibs_state);
		goto out;
	case HCI_IBS_TX_WAKING: /* No WAKE_ACK, retransmit WAKE */
		retransmit = 1;
		if (send_hci_ibs_cmd(HCI_IBS_WAKE_IND, hu) < 0) {
			BT_ERR("cannot acknowledge device wake up");
			goto out;
		}
		ibs->ibs_sent_wakes++; /* debug */
		mod_timer(&ibs->wake_retrans_timer, jiffies + wake_retrans);
		break;
	}
out:
	spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);
	if (retransmit)
		hci_uart_tx_wakeup(hu);
}

/* Initialize protocol */
static int ibs_open(struct hci_uart *hu)
{
	struct ibs_struct *ibs;

	BT_DBG("hu %p", hu);

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

	skb_queue_head_init(&ibs->txq);
	skb_queue_head_init(&ibs->tx_wait_q);
	spin_lock_init(&ibs->hci_ibs_lock);

	/* Assume we start with both sides asleep -- extra wakes OK */
	ibs->tx_ibs_state = HCI_IBS_TX_ASLEEP;
	ibs->rx_ibs_state = HCI_IBS_RX_ASLEEP;
	/* clocks actually on, but we start votes off */
	ibs->tx_vote = 0;
	ibs->rx_vote = 0;

	/* debug */
	ibs->ibs_sent_wacks = 0;
	ibs->ibs_sent_slps = 0;
	ibs->ibs_sent_wakes = 0;
	ibs->ibs_recv_wacks = 0;
	ibs->ibs_recv_slps = 0;
	ibs->ibs_recv_wakes = 0;
	ibs->vote_last_jif = jiffies;
	ibs->vote_on_ticks = 0;
	ibs->vote_off_ticks = 0;
	ibs->votes_on = 0;
	ibs->votes_off = 0;
	ibs->tx_votes_on = 0;
	ibs->tx_votes_off = 0;
	ibs->rx_votes_on = 0;
	ibs->rx_votes_off = 0;

	hu->priv = ibs;

	init_timer(&ibs->wake_retrans_timer);
	ibs->wake_retrans_timer.function = hci_ibs_wake_retrans_timeout;
	ibs->wake_retrans_timer.data     = (u_long) hu;

	init_timer(&ibs->tx_idle_timer);
	ibs->tx_idle_timer.function = hci_ibs_tx_idle_timeout;
	ibs->tx_idle_timer.data     = (u_long) hu;

	BT_INFO("HCI_IBS open, tx_idle_delay=%lu, wake_retrans=%lu",
		tx_idle_delay, wake_retrans);

	return 0;
}

void ibs_log_local_stats(struct ibs_struct *ibs)
{
	BT_INFO("HCI_IBS stats: tx_idle_delay=%lu, wake_retrans=%lu",
		tx_idle_delay, wake_retrans);

	BT_INFO("HCI_IBS stats: tx_ibs_state=%lu, rx_ibs_state=%lu",
		ibs->tx_ibs_state, ibs->rx_ibs_state);
	BT_INFO("HCI_IBS stats: sent: sleep=%lu, wake=%lu, wake_ack=%lu",
		ibs->ibs_sent_slps, ibs->ibs_sent_wakes, ibs->ibs_sent_wacks);
	BT_INFO("HCI_IBS stats: recv: sleep=%lu, wake=%lu, wake_ack=%lu",
		ibs->ibs_recv_slps, ibs->ibs_recv_wakes, ibs->ibs_recv_wacks);

	BT_INFO("HCI_IBS stats: queues: txq=%s, txwaitq=%s",
		skb_queue_empty(&(ibs->txq)) ? "empty" : "full",
		skb_queue_empty(&(ibs->tx_wait_q)) ? "empty" : "full");

	BT_INFO("HCI_IBS stats: vote state: tx=%lu, rx=%lu",
		ibs->tx_vote, ibs->rx_vote);
	BT_INFO("HCI_IBS stats: tx votes cast: on=%lu, off=%lu",
		ibs->tx_votes_on, ibs->tx_votes_off);
	BT_INFO("HCI_IBS stats: rx votes cast: on=%lu, off=%lu",
		ibs->rx_votes_on, ibs->rx_votes_off);
	BT_INFO("HCI_IBS stats: msm_clock votes cast: on=%lu, off=%lu",
		ibs->votes_on, ibs->votes_off);
	BT_INFO("HCI_IBS stats: vote ticks: on=%lu, off=%lu",
		ibs->vote_on_ticks, ibs->vote_off_ticks);
}

/* Flush protocol data */
static int ibs_flush(struct hci_uart *hu)
{
	struct ibs_struct *ibs = hu->priv;

	BT_DBG("hu %p", hu);

	skb_queue_purge(&ibs->tx_wait_q);
	skb_queue_purge(&ibs->txq);

	return 0;
}

/* Close protocol */
static int ibs_close(struct hci_uart *hu)
{
	struct ibs_struct *ibs = hu->priv;

	BT_DBG("hu %p", hu);

	ibs_msm_serial_clock_vote(HCI_IBS_VOTE_STATS_UPDATE, hu);
	ibs_log_local_stats(ibs);

	skb_queue_purge(&ibs->tx_wait_q);
	skb_queue_purge(&ibs->txq);
	del_timer(&ibs->tx_idle_timer);
	del_timer(&ibs->wake_retrans_timer);

	kfree_skb(ibs->rx_skb);

	hu->priv = NULL;

	kfree(ibs);

	return 0;
}

/*
 * Called upon a wake-up-indication from the device
 */
static void ibs_device_want_to_wakeup(struct hci_uart *hu)
{
	unsigned long flags;
	struct ibs_struct *ibs = hu->priv;

	BT_DBG("hu %p", hu);

	/* lock hci_ibs state */
	spin_lock_irqsave(&ibs->hci_ibs_lock, flags);

	/* debug */
	ibs->ibs_recv_wakes++;

	switch (ibs->rx_ibs_state) {
	case HCI_IBS_RX_ASLEEP:
		/* Make sure clock is on - we may have turned clock off since
		 * receiving the wake up indicator
		 */
		ibs_msm_serial_clock_vote(HCI_IBS_RX_VOTE_CLOCK_ON, hu);
		ibs->rx_ibs_state = HCI_IBS_RX_AWAKE;
		/* deliberate fall-through */
	case HCI_IBS_RX_AWAKE:
		/* Always acknowledge device wake up,
		 * sending IBS message doesn't count as TX ON.
		 */
		if (send_hci_ibs_cmd(HCI_IBS_WAKE_ACK, hu) < 0) {
			BT_ERR("cannot acknowledge device wake up");
			goto out;
		}
		ibs->ibs_sent_wacks++; /* debug */
		break;
	default:
		/* any other state is illegal */
		BT_ERR("received HCI_IBS_WAKE_IND in rx state %ld",
			ibs->rx_ibs_state);
		break;
	}

out:
	spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);

	/* actually send the packets */
	hci_uart_tx_wakeup(hu);
}

/*
 * Called upon a sleep-indication from the device
 */
static void ibs_device_want_to_sleep(struct hci_uart *hu)
{
	unsigned long flags;
	struct ibs_struct *ibs = hu->priv;

	BT_DBG("hu %p", hu);

	/* lock hci_ibs state */
	spin_lock_irqsave(&ibs->hci_ibs_lock, flags);

	/* debug */
	ibs->ibs_recv_slps++;

	switch (ibs->rx_ibs_state) {
	case HCI_IBS_RX_AWAKE:
		/* update state */
		ibs->rx_ibs_state = HCI_IBS_RX_ASLEEP;
		ibs_msm_serial_clock_vote(HCI_IBS_RX_VOTE_CLOCK_OFF, hu);
		break;
	case HCI_IBS_RX_ASLEEP:
		/* deliberate fall-through */
	default:
		/* any other state is illegal */
		BT_ERR("received HCI_IBS_SLEEP_IND in rx state %ld",
			ibs->rx_ibs_state);
		break;
	}

	spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);
}

/*
 * Called upon wake-up-acknowledgement from the device
 */
static void ibs_device_woke_up(struct hci_uart *hu)
{
	unsigned long flags;
	struct ibs_struct *ibs = hu->priv;
	struct sk_buff *skb = NULL;

	BT_DBG("hu %p", hu);

	/* lock hci_ibs state */
	spin_lock_irqsave(&ibs->hci_ibs_lock, flags);

	/* debug */
	ibs->ibs_recv_wacks++;

	switch (ibs->tx_ibs_state) {
	case HCI_IBS_TX_ASLEEP:
		/* This could be spurrious rx wake on the BT chip.
		 * Send it another SLEEP othwise it will stay awake. */
	default:
		BT_ERR("received HCI_IBS_WAKE_ACK in tx state %ld",
			ibs->tx_ibs_state);
		break;
	case HCI_IBS_TX_AWAKE:
		/* expect one if we send 2 WAKEs */
		BT_DBG("received HCI_IBS_WAKE_ACK in tx state %ld",
			ibs->tx_ibs_state);
		break;
	case HCI_IBS_TX_WAKING:
		/* send pending packets */
		while ((skb = skb_dequeue(&ibs->tx_wait_q)))
			skb_queue_tail(&ibs->txq, skb);
		/* switch timers and change state to HCI_IBS_TX_AWAKE */
		del_timer(&ibs->wake_retrans_timer);
		mod_timer(&ibs->tx_idle_timer, jiffies + tx_idle_delay);
		ibs->tx_ibs_state = HCI_IBS_TX_AWAKE;
	}

	spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);

	/* actually send the packets */
	hci_uart_tx_wakeup(hu);
}

/* Enqueue frame for transmittion (padding, crc, etc) */
/* may be called from two simultaneous tasklets */
static int ibs_enqueue(struct hci_uart *hu, struct sk_buff *skb)
{
	unsigned long flags = 0;
	struct ibs_struct *ibs = hu->priv;

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

	/* Prepend skb with frame type */
	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);

	/* lock hci_ibs state */
	spin_lock_irqsave(&ibs->hci_ibs_lock, flags);

	/* act according to current state */
	switch (ibs->tx_ibs_state) {
	case HCI_IBS_TX_AWAKE:
		BT_DBG("device awake, sending normally");
		skb_queue_tail(&ibs->txq, skb);
		mod_timer(&ibs->tx_idle_timer, jiffies + tx_idle_delay);
		break;

	case HCI_IBS_TX_ASLEEP:
		BT_DBG("device asleep, waking up and queueing packet");
		ibs_msm_serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_ON, hu);
		/* save packet for later */
		skb_queue_tail(&ibs->tx_wait_q, skb);
		/* awake device */
		if (send_hci_ibs_cmd(HCI_IBS_WAKE_IND, hu) < 0) {
			BT_ERR("cannot send WAKE to device");
			break;
		}
		ibs->ibs_sent_wakes++; /* debug */

		/* start retransmit timer */
		mod_timer(&ibs->wake_retrans_timer, jiffies + wake_retrans);

		ibs->tx_ibs_state = HCI_IBS_TX_WAKING;
		break;

	case HCI_IBS_TX_WAKING:
		BT_DBG("device waking up, queueing packet");
		/* transient state; just keep packet for later */
		skb_queue_tail(&ibs->tx_wait_q, skb);
		break;

	default:
		BT_ERR("illegal tx state: %ld (losing packet)",
			ibs->tx_ibs_state);
		kfree_skb(skb);
		break;
	}

	spin_unlock_irqrestore(&ibs->hci_ibs_lock, flags);

	return 0;
}

static inline int ibs_check_data_len(struct ibs_struct *ibs, int len)
{
	register int room = skb_tailroom(ibs->rx_skb);

	BT_DBG("len %d room %d", len, room);

	if (!len) {
		hci_recv_frame(ibs->rx_skb);
	} else if (len > room) {
		BT_ERR("Data length is too large");
		kfree_skb(ibs->rx_skb);
	} else {
		ibs->rx_state = HCI_IBS_W4_DATA;
		ibs->rx_count = len;
		return len;
	}

	ibs->rx_state = HCI_IBS_W4_PACKET_TYPE;
	ibs->rx_skb   = NULL;
	ibs->rx_count = 0;

	return 0;
}

/* Recv data */
static int ibs_recv(struct hci_uart *hu, void *data, int count)
{
	struct ibs_struct *ibs = hu->priv;
	register char *ptr;
	struct hci_event_hdr *eh;
	struct hci_acl_hdr   *ah;
	struct hci_sco_hdr   *sh;
	register int len, type, dlen;

	BT_DBG("hu %p count %d rx_state %ld rx_count %ld",
			hu, count, ibs->rx_state, ibs->rx_count);

	ptr = data;
	while (count) {
		if (ibs->rx_count) {
			len = min_t(unsigned int, ibs->rx_count, count);
			memcpy(skb_put(ibs->rx_skb, len), ptr, len);
			ibs->rx_count -= len; count -= len; ptr += len;

			if (ibs->rx_count)
				continue;

			switch (ibs->rx_state) {
			case HCI_IBS_W4_DATA:
				BT_DBG("Complete data");
				hci_recv_frame(ibs->rx_skb);

				ibs->rx_state = HCI_IBS_W4_PACKET_TYPE;
				ibs->rx_skb = NULL;
				continue;

			case HCI_IBS_W4_EVENT_HDR:
				eh = (struct hci_event_hdr *) ibs->rx_skb->data;

				BT_DBG("Event header: evt 0x%2.2x plen %d",
					eh->evt, eh->plen);

				ibs_check_data_len(ibs, eh->plen);
				continue;

			case HCI_IBS_W4_ACL_HDR:
				ah = (struct hci_acl_hdr *) ibs->rx_skb->data;
				dlen = __le16_to_cpu(ah->dlen);

				BT_DBG("ACL header: dlen %d", dlen);

				ibs_check_data_len(ibs, dlen);
				continue;

			case HCI_IBS_W4_SCO_HDR:
				sh = (struct hci_sco_hdr *) ibs->rx_skb->data;

				BT_DBG("SCO header: dlen %d", sh->dlen);

				ibs_check_data_len(ibs, sh->dlen);
				continue;
			}
		}

		/* HCI_IBS_W4_PACKET_TYPE */
		switch (*ptr) {
		case HCI_EVENT_PKT:
			BT_DBG("Event packet");
			ibs->rx_state = HCI_IBS_W4_EVENT_HDR;
			ibs->rx_count = HCI_EVENT_HDR_SIZE;
			type = HCI_EVENT_PKT;
			break;

		case HCI_ACLDATA_PKT:
			BT_DBG("ACL packet");
			ibs->rx_state = HCI_IBS_W4_ACL_HDR;
			ibs->rx_count = HCI_ACL_HDR_SIZE;
			type = HCI_ACLDATA_PKT;
			break;

		case HCI_SCODATA_PKT:
			BT_DBG("SCO packet");
			ibs->rx_state = HCI_IBS_W4_SCO_HDR;
			ibs->rx_count = HCI_SCO_HDR_SIZE;
			type = HCI_SCODATA_PKT;
			break;

		/* HCI_IBS signals */
		case HCI_IBS_SLEEP_IND:
			BT_DBG("HCI_IBS_SLEEP_IND packet");
			ibs_device_want_to_sleep(hu);
			ptr++; count--;
			continue;

		case HCI_IBS_WAKE_IND:
			BT_DBG("HCI_IBS_WAKE_IND packet");
			ibs_device_want_to_wakeup(hu);
			ptr++; count--;
			continue;

		case HCI_IBS_WAKE_ACK:
			BT_DBG("HCI_IBS_WAKE_ACK packet");
			ibs_device_woke_up(hu);
			ptr++; count--;
			continue;

		default:
			BT_ERR("Unknown HCI packet type %2.2x", (__u8)*ptr);
			hu->hdev->stat.err_rx++;
			ptr++; count--;
			continue;
		};

		ptr++; count--;

		/* Allocate packet */
		ibs->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
		if (!ibs->rx_skb) {
			BT_ERR("Can't allocate mem for new packet");
			ibs->rx_state = HCI_IBS_W4_PACKET_TYPE;
			ibs->rx_count = 0;
			return 0;
		}

		ibs->rx_skb->dev = (void *) hu->hdev;
		bt_cb(ibs->rx_skb)->pkt_type = type;
	}

	return count;
}

static struct sk_buff *ibs_dequeue(struct hci_uart *hu)
{
	struct ibs_struct *ibs = hu->priv;
	return skb_dequeue(&ibs->txq);
}

static struct hci_uart_proto ibs_p = {
	.id		= HCI_UART_IBS,
	.open		= ibs_open,
	.close		= ibs_close,
	.recv		= ibs_recv,
	.enqueue	= ibs_enqueue,
	.dequeue	= ibs_dequeue,
	.flush		= ibs_flush,
};

int ibs_init(void)
{
	int err = hci_uart_register_proto(&ibs_p);

	if (!err)
		BT_INFO("HCI_IBS protocol initialized");
	else
		BT_ERR("HCI_IBS protocol registration failed");

	return err;
}

int ibs_deinit(void)
{
	return hci_uart_unregister_proto(&ibs_p);
}

module_param(wake_retrans, ulong, 0644);
MODULE_PARM_DESC(wake_retrans, "Delay (1/HZ) to retransmit WAKE_IND");

module_param(tx_idle_delay, ulong, 0644);
MODULE_PARM_DESC(tx_idle_delay, "Delay (1/HZ) since last tx for SLEEP_IND");
