Skip to contentSkip to conversation

Bluetooth: add support for TI's HCILL UART protocol

PATCH In review Ohad Ben-Cohen 2 participants 4 messages Apr 30, 2007 – May 4, 2007 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: add support for TI's HCILL UART protocol

From: Ohad Ben-Cohen <[email protected]>

Add support for Texas Instruments' HCI Low Level (HCILL) UART Bluetooth protocol. HCILL is a runtime power management extension to H4, which is widely used by TI's BRF63xx Bluetooth chips.

---
 drivers/bluetooth/Kconfig     |   10 +
 drivers/bluetooth/Makefile    |    1 +
 drivers/bluetooth/hci_ldisc.c |   11 +
 drivers/bluetooth/hci_ll.c    |  502 +++++++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/hci_ll.h    |   81 +++++++
 drivers/bluetooth/hci_uart.h  |   14 +-
 6 files changed, 616 insertions(+), 3 deletions(-)
 create mode 100644 drivers/bluetooth/hci_ll.c
 create mode 100644 drivers/bluetooth/hci_ll.h
drivers/bluetooth/Kconfig +10 -0
index b9fbe6e..02be474 100644
@@ -55,6 +55,16 @@ config BT_HCIUART_BCSP
 
 	  Say Y here to compile support for HCI BCSP protocol.
 
+config BT_HCIUART_LL
+	bool "HCILL protocol support"
+	depends on BT_HCIUART
+	help
+	  HCILL (HCI Low Level) is a serial protocol for communication
+	  between Bluetooth device and host. This protocol is required for
+	  serial Bluetooth devices that are based on Texas Instruments' BRF chips.
+
+	  Say Y here to compile support for HCILL protocol.
+
 config BT_HCIBCM203X
 	tristate "HCI BCM203x USB driver"
 	depends on USB
drivers/bluetooth/Makefile +1 -0
index 08c10e1..a543dfc 100644
@@ -16,4 +16,5 @@ obj-$(CONFIG_BT_HCIBTUART)	+= btuart_cs.o
 hci_uart-y				:= hci_ldisc.o
 hci_uart-$(CONFIG_BT_HCIUART_H4)	+= hci_h4.o
 hci_uart-$(CONFIG_BT_HCIUART_BCSP)	+= hci_bcsp.o
+hci_uart-$(CONFIG_BT_HCIUART_LL)	+= hci_ll.o
 hci_uart-objs				:= $(hci_uart-y)
drivers/bluetooth/hci_ldisc.c +11 -0
index 0f4203b..b1e7201 100644
@@ -479,6 +479,9 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
 			return hu->proto->id;
 		return -EUNATCH;
 
+	case HCIUARTGETDEVICE:
+		return hu->hdev->id;
+
 	default:
 		err = n_tty_ioctl(tty, file, cmd, arg);
 		break;
@@ -541,6 +544,10 @@ static int __init hci_uart_init(void)
 #ifdef CONFIG_BT_HCIUART_BCSP
 	bcsp_init();
 #endif
+#ifdef CONFIG_BT_HCIUART_LL
+	ll_init();
+#endif
+
 	
 	return 0;
 }
@@ -555,6 +562,10 @@ static void __exit hci_uart_exit(void)
 #ifdef CONFIG_BT_HCIUART_BCSP
 	bcsp_deinit();
 #endif
+#ifdef CONFIG_BT_HCIUART_LL
+	ll_deinit();
+#endif
+
 
 	/* Release tty registration of line discipline */
 	if ((err = tty_unregister_ldisc(N_HCI)))
drivers/bluetooth/hci_ll.c new file +502 -0

502 lines not on this page · raw message

drivers/bluetooth/hci_ll.h new file +81 -0

81 lines not on this page · raw message

drivers/bluetooth/hci_uart.h +11 -3
index b250e67..30f9f29 100644
@@ -28,16 +28,18 @@
 #endif
 
 /* Ioctls */
-#define HCIUARTSETPROTO	_IOW('U', 200, int)
-#define HCIUARTGETPROTO	_IOR('U', 201, int)
+#define HCIUARTSETPROTO		_IOW('U', 200, int)
+#define HCIUARTGETPROTO		_IOR('U', 201, int)
+#define HCIUARTGETDEVICE	_IOR('U', 202, int)
 
 /* UART protocols */
-#define HCI_UART_MAX_PROTO	4
+#define HCI_UART_MAX_PROTO	5
 
 #define HCI_UART_H4	0
 #define HCI_UART_BCSP	1
 #define HCI_UART_3WIRE	2
 #define HCI_UART_H4DS	3
+#define HCI_UART_LL	4
 
 struct hci_uart;
 
@@ -84,3 +86,9 @@ int h4_deinit(void);
 int bcsp_init(void);
 int bcsp_deinit(void);
 #endif
+
+#ifdef CONFIG_BT_HCIUART_LL
+int ll_init(void);
+int ll_deinit(void);
+#endif
+
Signature · 1 line
1.5.0.6
maintainer
#1 lore raw

Hi Ohad,

Quoted 3 lines

Add support for Texas Instruments' HCI Low Level (HCILL) UART Bluetooth protocol. HCILL is a runtime power management extension to H4, which is widely used by TI's BRF63xx Bluetooth chips.

please explain the usefulness of HCIUARTGETDEVICE to me.

And the ll_dbg_data() has to go away. On LKML they discussing a generic hexdump function. I could accept the usage of that, but no crazy own debug routine in the kernel code.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw

Hi Marcel,

Quoted 1 line · Marcel Holtmann

please explain the usefulness of HCIUARTGETDEVICE to me.

Most of the initializing commands should be (and thus are) sent normally, before the new device is added (and notification is sent to hcid).

But, there is one initialization command (deep sleep configuration), which must be sent _after_ the HCILL protocol is set.

This command is signalling the device that it can start initiating deep sleep. The device may immediate request to do so, so the HCILL protocol must already be there to receive this request.

That's why I let hciattach do its HCIUARTSETPROTO, and only then I send the remaining init commands.

But, at this stage, in order to send commands to the device, I must use Bluez' sockets interface, and for that I must know the device number (for hci_open_dev).

In order to be able to easily know the hci device number, I have added HCIUARTGETDEVICE.

If there's a better way of knowing the hci device number please tell me.

Quoted 3 lines

And the ll_dbg_data() has to go away. On LKML they discussing a generic hexdump function. I could accept the usage of that, but no crazy own debug routine in the kernel code.

Of course :)
I am aware of Randy's hexdumper, and once it will be merged I will make use of it.

Thanks,
Ohad.

maintainer
#3 lore raw

Hi Ohad,

Quoted 15 lines
Quoted 1 line

please explain the usefulness of HCIUARTGETDEVICE to me.

Most of the initializing commands should be (and thus are) sent normally, before the new device is added (and notification is sent to hcid).

But, there is one initialization command (deep sleep configuration), which must be sent _after_ the HCILL protocol is set.

This command is signalling the device that it can start initiating deep sleep. The device may immediate request to do so, so the HCILL protocol must already be there to receive this request.

That's why I let hciattach do its HCIUARTSETPROTO, and only then I send the remaining init commands.

Quoted 8 lines

But, at this stage, in order to send commands to the device, I must use Bluez' sockets interface, and for that I must know the device number (for hci_open_dev).

In order to be able to easily know the hci device number, I have added HCIUARTGETDEVICE.

If there's a better way of knowing the hci device number please tell me.

this sounds reasonable and could be useful for other transport protocols as well. Please create a separate patch for it, because it has nothing to do with the HCILL support.

However I have some concerns when hcid autoinits devices and you send extra commands at the same time. They get queued inside the kernel, but it make produce dead locks for some chips. I have to play a little bit with it, but the general idea is not bad.

Quoted 7 lines
Quoted 3 lines

And the ll_dbg_data() has to go away. On LKML they discussing a generic hexdump function. I could accept the usage of that, but no crazy own debug routine in the kernel code.

Of course :)
I am aware of Randy's hexdumper, and once it will be merged I will make use of it.

Until it is merged, this has to go away.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel