linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre Michon <pierre.michon@gmail.com>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] hciattach for bcm2035
Date: Fri, 20 Jan 2006 21:07:33 +0100	[thread overview]
Message-ID: <908666c60601201207x7a2adfa5g@mail.gmail.com> (raw)

[-- 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 }
 };
 


             reply	other threads:[~2006-01-20 20:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-20 20:07 Pierre Michon [this message]
2006-01-21  1:45 ` [Bluez-devel] hciattach for bcm2035 Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=908666c60601201207x7a2adfa5g@mail.gmail.com \
    --to=pierre.michon@gmail.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).