linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] hciattach for bcm2035
@ 2006-01-20 20:07 Pierre Michon
  2006-01-21  1:45 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Pierre Michon @ 2006-01-20 20:07 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

Hi,

I have extracted from jungo modification of bluez [1], the vendor code
for changing the baudrate.
It could useful for embedded device that use broadcom chip.

Pierre


[1] http://openboxes.free.fr/download/ad6843/rg-bluetooth_4.0.29_200512141341-src.tar.bz2

[-- Attachment #2: hciattach_bcm2035.patch --]
[-- Type: application/octet-stream, Size: 3211 bytes --]

--- hciattach.c.org	2006-01-20 21:04:48.000000000 +0100
+++ hciattach.c	2006-01-20 21:03:29.000000000 +0100
@@ -802,6 +802,117 @@
 	return 0;
 }
 
+
+/*
+ * Broadcom specific initialization
+ * Extracted from Jungo openrg
+ */
+static int bcm2035(int fd, struct uart_t *u, struct termios *ti)
+{
+	int n;
+	unsigned char cmd[30], resp[30];
+
+	/* Reset the BT Chip */
+	memset(cmd, 0, sizeof(cmd));
+	memset(resp, 0, sizeof(resp));
+	cmd[0] = HCI_COMMAND_PKT;
+	cmd[1] = 0x03;
+	cmd[2] = 0x0c;
+	cmd[3] = 0x00;
+	/* Send command */
+	if (write(fd, cmd, 4) != 4) {
+		fprintf(stderr, "Failed to write reset command\n");
+		return -1;
+	}
+	/* Read reply */
+	if ((n = read_hci_event(fd, resp, 4)) < 0) {
+	        fprintf(stderr, "Failed to reset chip\n");
+                return -1;
+	}
+
+	/* Read the local version info */
+	memset(cmd, 0, sizeof(cmd));
+	memset(resp, 0, sizeof(resp));
+	cmd[0] = HCI_COMMAND_PKT;
+	cmd[1] = 0x01;
+	cmd[2] = 0x10;
+	cmd[3] = 0x00;
+	/* Send command */
+	if (write(fd, cmd, 4) != 4) {
+		fprintf(stderr, "Failed to write \"read local version\" "
+			"command\n");
+		return -1;
+	}
+	/* Read reply */
+	if ((n = read_hci_event(fd, resp, 4)) < 0) {
+		fprintf(stderr, "Failed to read local version\n");
+                return -1;
+	}
+
+	/* Read the local supported commands info */
+	memset(cmd, 0, sizeof(cmd));
+	memset(resp, 0, sizeof(resp));
+	cmd[0] = HCI_COMMAND_PKT;
+	cmd[1] = 0x02;
+	cmd[2] = 0x10;
+	cmd[3] = 0x00;
+	/* Send command */
+	if (write(fd, cmd, 4) != 4) {
+		fprintf(stderr, "Failed to write \"read local supported "
+			"commands\" command\n");
+		return -1;
+	}
+	/* Read reply */
+	if ((n = read_hci_event(fd, resp, 4)) < 0) {
+		fprintf(stderr, "Failed to read local supported commands\n");
+                return -1;
+	}
+
+	/* Set the baud rate */
+	memset(cmd, 0, sizeof(cmd));
+	memset(resp, 0, sizeof(resp));
+	cmd[0] = HCI_COMMAND_PKT;
+	cmd[1] = 0x18;
+	cmd[2] = 0xfc;
+	cmd[3] = 0x02;
+	switch (u->speed) {
+	case 57600:
+	    cmd[4] = 0x00;
+	    cmd[5] = 0xe6;
+	    break;
+	case 230400:
+	    cmd[4] = 0x22;
+	    cmd[5] = 0xfa;
+	    break;
+	case 460800:
+	    cmd[4] = 0x11;
+	    cmd[5] = 0xfd;
+	    break;
+	case 921600:
+	    cmd[4] = 0x65;
+	    cmd[5] = 0xff;
+	    break;
+	default:
+	    /* Default is 115200 */
+	    cmd[4] = 0x00;
+	    cmd[5] = 0xf3;
+	    break;
+	}
+	fprintf(stderr, "Baud rate parameters: DHBR=0x%2x,DLBR=0x%2x\n",
+		cmd[4], cmd[5]);
+
+	/* Send command */
+	if (write(fd, cmd, 6) != 6) {
+		fprintf(stderr, "Failed to write \"set baud rate\" command\n");
+		return -1;
+	}
+	if ((n = read_hci_event(fd, resp, 6)) < 0) {
+	        fprintf(stderr, "Failed to set baud rate\n");
+                return -1;
+	}
+	return 0;
+}
+
 struct uart_t uart[] = {
 	{ "any",        0x0000, 0x0000, HCI_UART_H4,   115200, 115200, FLOW_CTL, NULL     },
 	{ "ericsson",   0x0000, 0x0000, HCI_UART_H4,   57600,  115200, FLOW_CTL, ericsson },
@@ -855,6 +966,9 @@
 	/* Billionton PCBTC1 PCMCIA Card */
 	{ "billionton", 0x0279, 0x950b, HCI_UART_BCSP, 115200, 115200, 0,        bcsp     },
 
+	/* Broadcom BCM2035 */
+	{ "bcm2035",  0x0A5C, 0x2035, HCI_UART_H4,   115200, 115200 , 0, bcm2035 },
+
 	{ NULL, 0 }
 };
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-21  1:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-20 20:07 [Bluez-devel] hciattach for bcm2035 Pierre Michon
2006-01-21  1:45 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).