aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-07-16 09:12:14 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-07-17 13:48:33 -0400
commit10122d07ced378ec9187f4b3110e110282beb192 (patch)
treeb7a67094bdd06d7db487528b64373f953b1d095b
parent255a68e0124082396d5e6a073ae80f2c41d9c886 (diff)
Bluetooth: Add initial sleep support to Three-wire UART
This patch adds very basic support for the sleep related messages. The only thing the code does right now is send a wakeup message as soon as receiving a sleep one, essentially preventing the controller from going to sleep. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r--drivers/bluetooth/hci_h5.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index eb40b9a38289..d9d42f65ee6e 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -74,6 +74,8 @@ struct h5 {
74 bool tx_ack_req; /* Pending ack to send */ 74 bool tx_ack_req; /* Pending ack to send */
75 u8 tx_seq; /* Next seq number to send */ 75 u8 tx_seq; /* Next seq number to send */
76 u8 tx_ack; /* Next ack number to send */ 76 u8 tx_ack; /* Next ack number to send */
77
78 bool sleeping;
77}; 79};
78 80
79static void h5_reset_rx(struct h5 *h5); 81static void h5_reset_rx(struct h5 *h5);
@@ -211,6 +213,9 @@ static void h5_handle_internal_rx(struct hci_uart *hu)
211 const unsigned char sync_rsp[] = { 0x02, 0x7d }; 213 const unsigned char sync_rsp[] = { 0x02, 0x7d };
212 const unsigned char conf_req[] = { 0x03, 0xfc, 0x01 }; 214 const unsigned char conf_req[] = { 0x03, 0xfc, 0x01 };
213 const unsigned char conf_rsp[] = { 0x04, 0x7b, 0x01 }; 215 const unsigned char conf_rsp[] = { 0x04, 0x7b, 0x01 };
216 const unsigned char wakeup_req[] = { 0x05, 0xfa };
217 const unsigned char woken_req[] = { 0x06, 0xf9 };
218 const unsigned char sleep_req[] = { 0x07, 0x78 };
214 const unsigned char *hdr = h5->rx_skb->data; 219 const unsigned char *hdr = h5->rx_skb->data;
215 const unsigned char *data = &h5->rx_skb->data[4]; 220 const unsigned char *data = &h5->rx_skb->data[4];
216 221
@@ -233,6 +238,14 @@ static void h5_handle_internal_rx(struct hci_uart *hu)
233 BT_DBG("Three-wire init sequence complete"); 238 BT_DBG("Three-wire init sequence complete");
234 hci_uart_init_ready(hu); 239 hci_uart_init_ready(hu);
235 return; 240 return;
241 } else if (memcmp(data, sleep_req, 2) == 0) {
242 BT_DBG("Peer went to sleep");
243 h5->sleeping = true;
244 h5_link_control(hu, wakeup_req, 2);
245 } else if (memcmp(data, woken_req, 2) == 0) {
246 BT_DBG("Peer woke up");
247 h5->sleeping = false;
248 return;
236 } else { 249 } else {
237 BT_DBG("Link Control: 0x%02hhx 0x%02hhx", data[0], data[1]); 250 BT_DBG("Link Control: 0x%02hhx 0x%02hhx", data[0], data[1]);
238 return; 251 return;