char *bdaddr;
int (*init) (int fd, struct uart_t *u, struct termios *ti);
int (*post) (int fd, struct uart_t *u, struct termios *ti);
+
+/* __TIZEN_PATCH__ */
+#ifdef __TI_PATCH__
+ uint16_t device_param;
+#endif
};
+#ifdef __TI_PATCH__
+ int firmware_path = 0;
+#endif
+
+#if defined(__TI_PATCH__) || defined(__BROADCOM_PATCH__)
+#define TIOSETBRFPOWER 0x6000
+#define BRF_DEEP_SLEEP_OPCODE_BYTE_1 0x0c
+#define BRF_DEEP_SLEEP_OPCODE_BYTE_2 0xfd
+#define BRF_DEEP_SLEEP_OPCODE \
+ (BRF_DEEP_SLEEP_OPCODE_BYTE_1 | (BRF_DEEP_SLEEP_OPCODE_BYTE_2 << 8))
+#endif
#define FLOW_CTL 0x0001
#define AMP_DEV 0x0002
#define ENABLE_PM 1
/* Set the baud rate */
memset(cmd, 0, sizeof(cmd));
memset(resp, 0, sizeof(resp));
+
+/* __TIZEN_PATCH__ */
+#ifndef __BROADCOM_PATCH__
cmd[0] = HCI_COMMAND_PKT;
cmd[1] = 0x18;
cmd[2] = 0xfc;
fprintf(stderr, "Failed to write \"set baud rate\" command\n");
return -1;
}
+#else
+ cmd[0] = HCI_COMMAND_PKT;
+ cmd[1] = 0x18;
+ cmd[2] = 0xfc;
+
+ switch (u->speed) {
+ case 57600:
+ case 230400:
+ case 460800:
+ case 921600:
+ case 3000000:
+ break;
+ default:
+ break;
+ }
+
+ cmd[3] = 0x06;
+ cmd[4] = 0x00;
+ cmd[5] = 0x00;
+ cmd[6] = u->speed & 0xFF;
+ cmd[7] = (u->speed >> 8) & 0xFF;
+ cmd[8] = (u->speed >> 16) & 0xFF;
+ cmd[9] = (u->speed >> 24) & 0xFF;
+
+ fprintf(stderr, "Set the baud rate %d : 0x%02x,0x%02x,0x%02x,0x%02x\n",u->speed,cmd[6],cmd[7],cmd[8],cmd[9] );
+
+ /* Send command */
+ if (write(fd, cmd, 10) != 10) {
+ fprintf(stderr, "Failed to write \"set baud rate\" command\n");
+ return -1;
+ }
+
+#endif
if ((n = read_hci_event(fd, resp, 6)) < 0) {
fprintf(stderr, "Failed to set baud rate\n");
{ "swave", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200,
FLOW_CTL, DISABLE_PM, NULL, swave },
+/* __TIZEN_PATCH__ */
+#ifdef __TI_PATCH__
+ /* Texas Instruments BRF63xx modules */
+ { "texas", 0x0000, 0x0000, HCI_UART_LL, 115200,3000000, FLOW_CTL, NULL, texas, NULL/*texas_continue_script*/, BRF_DEEP_SLEEP_OPCODE},
+#else
/* Texas Instruments Bluelink (BRF) modules */
{ "texas", 0x0000, 0x0000, HCI_UART_LL, 115200, 115200,
FLOW_CTL, DISABLE_PM, NULL, texas, texas2 },
{ "texasalt", 0x0000, 0x0000, HCI_UART_LL, 115200, 115200,
FLOW_CTL, DISABLE_PM, NULL, texasalt, NULL },
+#endif
/* ST Microelectronics minikits based on STLC2410/STLC2415 */
{ "st", 0x0000, 0x0000, HCI_UART_H4, 57600, 115200,
int fd, i;
unsigned long flags = 0;
+/* __TIZEN_PATCH__ */
+#if defined(__TI_PATCH__) || defined(__BROADCOM_PATCH__)
+ int power;
+#endif
+
if (raw)
flags |= 1 << HCI_UART_RAW_DEVICE;
cfmakeraw(&ti);
+/* __TIZEN_PATCH__ */
+#ifndef __BROADCOM_PATCH__
ti.c_cflag |= CLOCAL;
if (u->flags & FLOW_CTL)
ti.c_cflag |= CRTSCTS;
else
ti.c_cflag &= ~CRTSCTS;
+#endif
if (tcsetattr(fd, TCSANOW, &ti) < 0) {
perror("Can't set port settings");
usleep(500000);
}
+/* __TIZEN_PATCH__ */
+#if defined(__TI_PATCH__) || defined(__BROADCOM_PATCH__)
+ /* Power up the BRF chip */
+ power = 1;
+ ioctl(fd, TIOSETBRFPOWER, &power);
+#endif
+#ifdef __TI_PATCH__
+ usleep(500000);
+#endif
+
if (u->init && u->init(fd, u, &ti) < 0)
return -1;
{
printf("hciattach - HCI UART driver initialization utility\n");
printf("Usage:\n");
+
+/* __TIZEN_PATCH__ */
+#ifdef __TI_PATCH__
+ printf("\thciattach [-n] [-p] [-b] [-g device_param] [-r] [-f] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]\n");
+#else
printf("\thciattach [-n] [-p] [-b] [-r] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]\n");
+#endif
printf("\thciattach -l\n");
}
sigset_t sigs;
char dev[PATH_MAX];
+/* __TIZEN_PATCH__ */
+#if defined(__TI_PATCH__) || defined(__BROADCOM_PATCH__)
+ int power;
+#endif
+#ifdef __TI_PATCH__
+ uint16_t device_param = 0;
+ int reset_device = 0;
+ int bt_fd;
+#endif
detach = 1;
printpid = 0;
raw = 0;
-
+#ifdef __TI_PATCH__
+ while ((opt=getopt(argc, argv, "bnprft:g:s:l")) != EOF) {
+#else
while ((opt=getopt(argc, argv, "bnpt:s:lr")) != EOF) {
+#endif
switch(opt) {
case 'b':
send_break = 1;
to = atoi(optarg);
break;
+/* __TIZEN_PATCH__ */
+#ifdef __TI_PATCH__
+ case 'g':
+ device_param = (uint16_t)strtol(optarg, NULL, 16);
+ break;
+
+ case 'r':
+ reset_device = 1;
+ break;
+
+ case 'f':
+ firmware_path = 1;
+ break;
+#endif
case 's':
init_speed = atoi(optarg);
break;
}
n = argc - optind;
+/* __TIZEN_PATCH__ */
+#ifdef __TI_PATCH__
+ if (!reset_device || (reset_device && n < 1))
+#endif
if (n < 2) {
usage();
exit(1);
break;
}
}
+/* __TIZEN_PATCH__ */
+#ifdef __TI_PATCH__
+ if (reset_device)
+ {
+ // Reset row device
+ bt_fd = open(dev, O_RDWR | O_NOCTTY);
+ if (bt_fd< 0) {
+ perror("Can't open serial port");
+ return -1;
+ }
+ /* Power up the BRF chip */
+ power = 0;
+ ioctl(bt_fd, TIOSETBRFPOWER, &power);
+ return 0;
+ }
+#endif
if (!u) {
fprintf(stderr, "Unknown device type or id\n");
the hardware's default */
if (init_speed)
u->init_speed = init_speed;
+#ifdef __TI_PATCH__
+ /* If user specified a device parameter, use that instead of
+ the hardware's default */
+ if (device_param)
+ u->device_param = device_param;
+#endif
memset(&sa, 0, sizeof(sa));
sa.sa_flags = SA_NOCLDSTOP;
exit(1);
}
+/* __TIZEN_PATCH__ */
+#if defined(__TI_PATCH__) || defined(__BROADCOM_PATCH__)
+ /* Power down the BRF or BCMchip */
+ power = 0;
+ ioctl(n, TIOSETBRFPOWER, &power);
+#endif
return 0;
}