meta-digi/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.41/ccimx6ul/0008-bluetooth-Enable-3Mbps...

151 lines
6.2 KiB
Diff

From: Anantha Krishnan <ananthk@codeaurora.org>
Date: Mon, 8 Sep 2014 14:31:18 +0530
Subject: [PATCH] bluetooth: Enable 3Mbps baud rate support
Allow APPS PROC and BT Controller to operate at 3Mbps baud rate
for faster exchange of commands, events and data between the two
Change-Id: I55651633027ea60a762b11abea84fe1abd6574a9
Signed-off-by: Rupesh Tatiya <rtatiya@codeaurora.org>
---
tools/hciattach_rome.c | 63 ++++++++++++++++++++++++++++++++++++++------------
1 file changed, 48 insertions(+), 15 deletions(-)
diff --git a/tools/hciattach_rome.c b/tools/hciattach_rome.c
index 4fcbdf2ab82a..d0e2935b9997 100644
--- a/tools/hciattach_rome.c
+++ b/tools/hciattach_rome.c
@@ -166,6 +166,7 @@ int userial_vendor_ioctl(int fd, userial_vendor_ioctl_op_t op, int *p_data)
}
cfmakeraw(&ti);
ti.c_cflag |= CLOCAL;
+ ti.c_cflag |= CREAD;
switch(op)
{
@@ -332,6 +333,8 @@ int read_vs_hci_event(int fd, unsigned char* buf, int size)
{
int remain, r;
int count = 0;
+ fd_set infids;
+ struct timeval timeout;
if (size <= 0) {
fprintf(stderr, "Invalid size arguement!\n");
@@ -340,6 +343,16 @@ int read_vs_hci_event(int fd, unsigned char* buf, int size)
fprintf(stderr, "%s: Wait for HCI-Vendor Specfic Event from SOC\n", __FUNCTION__);
+ FD_ZERO (&infids);
+ FD_SET (fd, &infids);
+ timeout.tv_sec = 3;
+ timeout.tv_usec = 0; /* half second is a long time at 115.2 Kbps */
+
+ if (select (fd + 1, &infids, NULL, NULL, &timeout) < 1)
+ fprintf(stderr, "%s: Timing out on select for 3 secs.\n", __FUNCTION__);
+ else
+ fprintf(stderr, "%s: Data available in TTY Serial buffer\n", __FUNCTION__);
+
/* The first byte identifies the packet type. For HCI event packets, it
* should be 0x04, so we read until we get to the 0x04. */
/* It will keep reading until find 0x04 byte */
@@ -1332,10 +1345,16 @@ int rome_set_baudrate_req(int fd)
cmd[0] = HCI_COMMAND_PKT;
cmd_hdr->opcode = cmd_opcode_pack(HCI_VENDOR_CMD_OGF, EDL_SET_BAUDRATE_CMD_OCF);
cmd_hdr->plen = VSC_SET_BAUDRATE_REQ_LEN;
- cmd[4] = BAUDRATE_115200;
+ cmd[4] = BAUDRATE_3000000;
/* Total length of the packet to be sent to the Controller */
size = (HCI_CMD_IND + HCI_COMMAND_HDR_SIZE + VSC_SET_BAUDRATE_REQ_LEN);
+ /* Flow off during baudrate change */
+ if ((err = userial_vendor_ioctl(fd, USERIAL_OP_FLOW_OFF , &flags)) < 0)
+ {
+ fprintf(stderr, "%s: HW Flow-off error: 0x%x\n", __FUNCTION__, err);
+ goto error;
+ }
/* Send the HCI command packet to UART for transmission */
fprintf(stderr, "%s: HCI CMD: 0x%x 0x%x 0x%x 0x%x 0x%x\n", __FUNCTION__, cmd[0], cmd[1], cmd[2], cmd[3],cmd[4]) ;
err = write(fd, cmd, size);
@@ -1343,7 +1362,15 @@ int rome_set_baudrate_req(int fd)
fprintf(stderr, "%s: Send failed with ret value: %d\n", __FUNCTION__, err);
goto error;
}
+ /* Change Local UART baudrate to high speed UART */
+ userial_vendor_set_baud(USERIAL_BAUD_3M);
+ /* Flow on after changing local uart baudrate */
+ if ((err = userial_vendor_ioctl(fd, USERIAL_OP_FLOW_ON , &flags)) < 0)
+ {
+ fprintf(stderr, "%s: HW Flow-on error: 0x%x \n", __FUNCTION__, err);
+ return err;
+ }
/* Check for response from the Controller */
if ((err =read_vs_hci_event(fd, rsp, HCI_MAX_EVENT_SIZE)) < 0) {
fprintf(stderr, "%s: Failed to get HCI-VS Event from SOC\n", __FUNCTION__);
@@ -1385,6 +1412,12 @@ int rome_hci_reset_req(int fd)
/* Total length of the packet to be sent to the Controller */
size = (HCI_CMD_IND + HCI_COMMAND_HDR_SIZE);
+ /* Flow off during baudrate change */
+ if ((err = userial_vendor_ioctl(fd, USERIAL_OP_FLOW_OFF , &flags)) < 0)
+ {
+ fprintf(stderr, "%s: HW Flow-off error: 0x%x\n", __FUNCTION__, err);
+ goto error;
+ }
/* Send the HCI command packet to UART for transmission */
fprintf(stderr, "%s: HCI CMD: 0x%x 0x%x 0x%x 0x%x\n", __FUNCTION__, cmd[0], cmd[1], cmd[2], cmd[3]);
err = write(fd, cmd, size);
@@ -1393,6 +1426,15 @@ int rome_hci_reset_req(int fd)
goto error;
}
+ /* Change Local UART baudrate to high speed UART */
+ userial_vendor_set_baud(USERIAL_BAUD_3M);
+
+ /* Flow on after changing local uart baudrate */
+ if ((err = userial_vendor_ioctl(fd, USERIAL_OP_FLOW_ON , &flags)) < 0)
+ {
+ fprintf(stderr, "%s: HW Flow-on error: 0x%x \n", __FUNCTION__, err);
+ return err;
+ }
/* Wait for command complete event */
err = read_hci_event(fd, rsp, HCI_MAX_EVENT_SIZE);
if ( err < 0) {
@@ -1534,16 +1576,7 @@ int qca_soc_init(int fd, char *bdaddr)
nvm_file_path = ROME_NVM_TLV_3_0_0_PATH;
download:
- /* Donwload TLV files (rampatch, NVM) */
- err = rome_download_tlv_file(fd);
- if (err < 0) {
- fprintf(stderr, "%s: Download TLV file failed!\n", __FUNCTION__);
- goto error;
- }
- fprintf(stderr, "%s: Download TLV file successfully \n", __FUNCTION__);
-
- /* Change baud rate back to user requested */
- fprintf(stderr, "Changing baud rate back from 3M --> 115K\n");
+ /* Change baud rate 115.2 kbps to 3Mbps*/
err = rome_set_baudrate_req(fd);
if (err < 0) {
fprintf(stderr, "%s: Baud rate change failed!\n", __FUNCTION__);
@@ -1551,13 +1584,13 @@ download:
}
fprintf(stderr, "%s: Baud rate changed successfully \n", __FUNCTION__);
- fprintf(stderr, "%s: Disabling In Band Sleep functionality\n", __FUNCTION__);
- err = rome_disable_sleep(fd);
+ /* Donwload TLV files (rampatch, NVM) */
+ err = rome_download_tlv_file(fd);
if (err < 0) {
- fprintf(stderr, "%s: Failed to disable IBS!\n", __FUNCTION__);
+ fprintf(stderr, "%s: Download TLV file failed!\n", __FUNCTION__);
goto error;
}
- fprintf(stderr, "%s: IBS disabled successfully \n", __FUNCTION__);
+ fprintf(stderr, "%s: Download TLV file successfully \n", __FUNCTION__);
/* Perform HCI reset here*/
err = rome_hci_reset_req(fd);