summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/bccmd.83
-rw-r--r--tools/bccmd.c61
2 files changed, 64 insertions, 0 deletions
diff --git a/tools/bccmd.8 b/tools/bccmd.8
index 95d67461..c3c93f76 100644
--- a/tools/bccmd.8
+++ b/tools/bccmd.8
@@ -54,6 +54,9 @@ Get local Bluetooth clock
.BI rand
Get random number
.TP
+.BI chiprev
+Get chip revision
+.TP
.BI buildname
Get the full build name
.TP
diff --git a/tools/bccmd.c b/tools/bccmd.c
index 7f5deb5b..8d65a454 100644
--- a/tools/bccmd.c
+++ b/tools/bccmd.c
@@ -345,6 +345,66 @@ static int cmd_rand(int transport, int argc, char *argv[])
return 0;
}
+static int cmd_chiprev(int transport, int argc, char *argv[])
+{
+ uint8_t array[8];
+ uint16_t rev;
+ char *str;
+ int err;
+
+ OPT_HELP(0, NULL);
+
+ memset(array, 0, sizeof(array));
+
+ err = transport_read(transport, CSR_VARID_CHIPREV, array, 8);
+ if (err < 0) {
+ errno = -err;
+ return -1;
+ }
+
+ rev = array[0] | (array[1] << 8);
+
+ switch (rev) {
+ case 0x64:
+ str = "BC1 ES";
+ break;
+ case 0x65:
+ str = "BC1";
+ break;
+ case 0x89:
+ str = "BC2-External A";
+ break;
+ case 0x8a:
+ str = "BC2-External B";
+ break;
+ case 0x28:
+ str = "BC2-ROM";
+ break;
+ case 0x43:
+ str = "BC3-Multimedia";
+ break;
+ case 0x15:
+ str = "BC3-ROM";
+ break;
+ case 0xe2:
+ str = "BC3-Flash";
+ break;
+ case 0x26:
+ str = "BC4-External";
+ break;
+ case 0x30:
+ str = "BC4-ROM";
+ break;
+ default:
+ str = "NA";
+ break;
+ }
+
+ printf("Chip revision: 0x%04x (%s)\n", rev, str);
+
+ return 0;
+}
+
static int cmd_buildname(int transport, int argc, char *argv[])
{
uint8_t array[130];
@@ -987,6 +1047,7 @@ static struct {
{ "keylen", cmd_keylen, "<handle>", "Get current crypt key length" },
{ "clock", cmd_clock, "", "Get local Bluetooth clock" },
{ "rand", cmd_rand, "", "Get random number" },
+ { "chiprev", cmd_chiprev, "", "Get chip revision" },
{ "buildname", cmd_buildname, "", "Get the full build name" },
{ "panicarg", cmd_panicarg, "", "Get panic code argument" },
{ "faultarg", cmd_faultarg, "", "Get fault code argument" },