Bluetooth: host level Support for Atheros AR300x device
Subsystems (2)
PATCH v3 1/1 Bluetooth: host level Support for Atheros AR300x device
Implements support for Atheros AR300x Bluetooth chip in hciattach application. Supports configuration download and power management configure feature.
--- Makefile.tools | 7 +- tools/hciattach.8 | 3 + tools/hciattach.c | 105 ++++++ tools/hciattach.h | 3 + tools/hciattach_ar3k.c | 859 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 974 insertions(+), 3 deletions(-) create mode 100644 tools/hciattach_ar3k.c
Makefile.tools +4 -3
@@ -21,9 +21,10 @@ tools_rfcomm_LDADD = lib/libbluetooth.la tools_l2ping_LDADD = lib/libbluetooth.la tools_hciattach_SOURCES = tools/hciattach.c tools/hciattach.h \ - tools/hciattach_st.c \ - tools/hciattach_ti.c \ - tools/hciattach_tialt.c + tools/hciattach_st.c \ + tools/hciattach_ti.c \ + tools/hciattach_tialt.c \ + tools/hciattach_ar3k.c tools_hciattach_LDADD = lib/libbluetooth.la tools_hciconfig_SOURCES = tools/hciconfig.c tools/csr.h tools/csr.c \
tools/hciattach.8 +3 -0
@@ -86,6 +86,9 @@ Silicon Wave kits .TP .B bcsp Serial adapters using CSR chips with BCSP serial protocol +.TP +.B ath3k +Atheros AR300x based serial Bluetooth device .RE Supported IDs are (manufacturer id, product id)
tools/hciattach.c +105 -0
117 lines not on this page · raw message
tools/hciattach.h +3 -0
@@ -38,6 +38,7 @@#define HCI_UART_3WIRE 2#define HCI_UART_H4DS 3#define HCI_UART_LL 4 +#define HCI_UART_ATH3K 5#define HCI_UART_RAW_DEVICE 0
@@ -49,3 +50,5 @@ int texas_post(int fd, struct termios *ti);int texasalt_init (int fd,int speed,struct termios *ti);int stlc2500_init (int fd,bdaddr_t *bdaddr);int bgb2xx_init (int dd,bdaddr_t *bdaddr); +int ath_configure_sleep (int fd,int sleep_stat); +int ath_ps_download (int fd);
tools/hciattach_ar3k.c new file +859 -0
859 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Marcel Holtmann
maintainerHi Suraj,
Quoted 18 lines
Implements support for Atheros AR300x Bluetooth chip in hciattach application. Supports configuration download and power management configure feature.
--- Makefile.tools | 7 +- tools/hciattach.8 | 3 + tools/hciattach.c | 105 ++++++ tools/hciattach.h | 3 + tools/hciattach_ar3k.c | 859 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 974 insertions(+), 3 deletions(-) create mode 100644 tools/hciattach_ar3k.cMakefile.tools +0
-0@@ -21,9 +21,10 @@ tools_rfcomm_LDADD = lib/libbluetooth.la tools_l2ping_LDADD = lib/libbluetooth.la
Makefile.tools tools_rfcomm_LDADD = lib/libbluetooth.la · line 28
Quoted 10 lines
Makefile.tools +4
-3tools_hciattach_SOURCES = tools/hciattach.c tools/hciattach.h \ - tools/hciattach_st.c \ - tools/hciattach_ti.c \ - tools/hciattach_tialt.c + tools/hciattach_st.c \ + tools/hciattach_ti.c \ + tools/hciattach_tialt.c \ + tools/hciattach_ar3k.c tools_hciattach_LDADD = lib/libbluetooth.la
please stop introducing new whitespaces in between. None of the Makefile.am to do this.
Quoted 102 lines
Makefile.tools +0
-0Supported IDs are (manufacturer id, product id)tools/hciattach.c +93
-0@@ -657,6 +657,109 @@ static int csr(int fd, struct uart_t *u, struct termios *ti)return 0 ; } +#define SLEEP_ENABLE 1 +#define SLEEP_DISABLE 0 + +/* +* Atheros AR300x specific initialization post callback +*/ +static int ath3kpost (int fd,struct uart_t *u,struct termios *ti) +{ +return ath_configure_sleep (fd, u->pm); +} + +#define HCI_VENDOR_CMD_OGF 0x3F +#define HCI_PS_CMD_OCF 0x0B +#define HCI_CHG_BAUD_CMD_OCF 0x0C + +#define WRITE_BDADDR_CMD_LEN 14 +#define WRITE_BAUD_CMD_LEN 6 +#define MAX_CMD_LEN WRITE_BDADDR_CMD_LEN + +/* +* Atheros AR300x specific initialization and configureation file +* download +*/ +static int ath3kinit (int fd,struct uart_t *u,struct termios *ti) +{ +int r; +int baud; +struct timespec tm = {0 ,500000 }; +unsigned char cmd[MAX_CMD_LEN ], rsp[HCI_MAX_EVENT_SIZE ]; +unsigned char *ptr = cmd +1 ; +hci_command_hdr *ch = (void *)ptr; + + cmd[0 ] =HCI_COMMAND_PKT ; + +/* Download PS and patch */ + r =ath_ps_download (fd); +if (r <0 ) { +perror ("Failed to Download configuration" ); +return -ETIMEDOUT ; + } + +/* Write BDADDR */ +if (u->bdaddr) { + ch->opcode =htobs (cmd_opcode_pack (HCI_VENDOR_CMD_OGF , +HCI_PS_CMD_OCF )); + ch->plen =10 ; + ptr +=HCI_COMMAND_HDR_SIZE ; + + ptr[0 ] =0x01 ; + ptr[1 ] =0x01 ; + ptr[2 ] =0x00 ; + ptr[3 ] =0x06 ; +str2ba (u->bdaddr, (bdaddr_t *)(ptr +4 )); + +if (write (fd, cmd,WRITE_BDADDR_CMD_LEN ) != +WRITE_BDADDR_CMD_LEN ) { +perror ("Failed to write BD_ADDR command\n" ); +return -ETIMEDOUT ; + } + +if (read_hci_event (fd, rsp,sizeof (rsp)) <0 ) { +perror ("Failed to set BD_ADDR\n" ); +return -ETIMEDOUT ; + } + } + +/* Send HCI Reset */ + cmd[1 ] =0x03 ; + cmd[2 ] =0x0C ; + cmd[3 ] =0x00 ; + + r =write (fd, cmd,4 ); +if (r !=4 ) +return -ETIMEDOUT ; + +nanosleep (&tm,NULL ); +if (read_hci_event (fd, rsp,sizeof (rsp)) <0 ) +return -ETIMEDOUT ; + +/* set controller baud rate to user specified value */ + ptr = cmd +1 ; + ch->opcode =htobs (cmd_opcode_pack (HCI_VENDOR_CMD_OGF , +HCI_CHG_BAUD_CMD_OCF )); + ch->plen =2 ; + ptr +=HCI_COMMAND_HDR_SIZE ; + + baud = u->speed/100 ; + ptr[0 ] = (char )baud; + ptr[1 ] = (char )(baud >>8 ); + +if (write (fd, cmd,WRITE_BAUD_CMD_LEN ) !=WRITE_BAUD_CMD_LEN ) { +perror ("Failed to write change baud rate command" ); +return -ETIMEDOUT ;
tools/hciattach.c static int csr(int fd, struct uart_t *u, struct termios *ti) · line 762
Quoted 10 lines
tools/hciattach.c +10
-0+ } + +nanosleep (&tm,NULL ); + +if (read_hci_event (fd, rsp,sizeof (rsp)) <0 ) +return -ETIMEDOUT ; + +return 0 ; +} +
Why is this in hciattach.c if you create your own file for the ar3k anyway. Please move it all into that file.
Regards
Marcel