From 8f470e6b2d2fe8de49395d447d08be69275a73ce Mon Sep 17 00:00:00 2001 From: tytung Date: Sat, 9 Apr 2011 01:56:44 +0800 Subject: [PATCH] htcleo: fixed Bluetooth MAC address to board device dependend one. (i.e. unique Bluetooth address) Use IEEE Standards 00:23:76:YY:YY:YY for HTC. -- http://standards.ieee.org/cgi-bin/ouisearch?00-23-76 --- arch/arm/mach-msm/board-htcleo-rfkill.c | 9 ---- arch/arm/mach-msm/board-htcleo.c | 61 +++++++++++++++---------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/arch/arm/mach-msm/board-htcleo-rfkill.c b/arch/arm/mach-msm/board-htcleo-rfkill.c index 2fb4f40a..c29e3ca8 100644 --- a/arch/arm/mach-msm/board-htcleo-rfkill.c +++ b/arch/arm/mach-msm/board-htcleo-rfkill.c @@ -23,18 +23,9 @@ #include "board-htcleo.h" -#define MAX_BT_SIZE 0x6U - static struct rfkill *bt_rfk; static const char bt_name[] = "bcm4329"; -/* Fix BT address for Leo */ -static unsigned char bt_bd_ram[MAX_BT_SIZE] = {0x50,0xC3,0x00,0x00,0x00,0x00}; -unsigned char *get_bt_bd_ram(void) -{ - return (bt_bd_ram); -} - static int bluetooth_set_power(void *data, bool blocked) { if (!blocked) { diff --git a/arch/arm/mach-msm/board-htcleo.c b/arch/arm/mach-msm/board-htcleo.c index 13a295c6..7e7add8e 100644 --- a/arch/arm/mach-msm/board-htcleo.c +++ b/arch/arm/mach-msm/board-htcleo.c @@ -15,6 +15,7 @@ * */ +#include #include #include #include @@ -531,10 +532,35 @@ int is_valid_mac_address(char *mac) /////////////////////////////////////////////////////////////////////// // bluetooth /////////////////////////////////////////////////////////////////////// + +/* AOSP style interface */ +#define BDADDR_STR_SIZE 18 +static char bdaddr[BDADDR_STR_SIZE]; + +module_param_string(bdaddr, bdaddr, sizeof(bdaddr), 0400); +MODULE_PARM_DESC(bdaddr, "bluetooth address"); + +static int parse_tag_bdaddr(void) +{ + uint32_t id1, id2, id3, sid1, sid2, sid3; + uint32_t id_base = 0xef260; + id1 = readl(MSM_SHARED_RAM_BASE + id_base + 0x0); + id2 = readl(MSM_SHARED_RAM_BASE + id_base + 0x4); + id3 = readl(MSM_SHARED_RAM_BASE + id_base + 0x8); + sid1 = crc32(~0, &id1, 4); + sid2 = crc32(~0, &id2, 4); + sid3 = crc32(~0, &id3, 4); + sprintf(bdaddr, "00:23:76:%2X:%2X:%2X", sid3 % 0xff, sid2 % 0xff, sid1 % 0xff); + pr_info("Device Bluetooth Mac Address: %s\n", bdaddr); + return 0; +} +/* end AOSP style interface */ + +/* for (sense roms) */ #define MAC_ADDRESS_SIZE_C 17 static char bdaddress[MAC_ADDRESS_SIZE_C+1] = ""; static void bt_export_bd_address(void) - { +{ unsigned char cTemp[6]; if (!is_valid_mac_address(bdaddress)){ memcpy(cTemp, get_bt_bd_ram(), 6); @@ -545,7 +571,14 @@ static void bt_export_bd_address(void) module_param_string(bdaddress, bdaddress, sizeof(bdaddress), S_IWUSR | S_IRUGO); MODULE_PARM_DESC(bdaddress, "BT MAC ADDRESS"); -# + +#define MAX_BT_SIZE 0x6U +static unsigned char bt_bd_ram[MAX_BT_SIZE] = {0x50,0xC3,0x00,0x00,0x00,0x00}; +unsigned char *get_bt_bd_ram(void) +{ + return (bt_bd_ram); +} + //-----added alias for bt mac address parameter-------- static int __init htcleo_bt_macaddress_setup(char *bootconfig) { @@ -555,8 +588,7 @@ static int __init htcleo_bt_macaddress_setup(char *bootconfig) } __setup("bt.mac=", htcleo_bt_macaddress_setup); //----------------------------------------------------- - -//----------------------------------------------------- +/* end (sense) */ #ifdef CONFIG_SERIAL_MSM_HS static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = { @@ -604,25 +636,6 @@ static uint32_t bt_gpio_table[] = { GPIO_PULL_DOWN, GPIO_4MA), }; -static uint32_t bt_gpio_table_rev_CX[] = { - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_UART1_RTS, 2, GPIO_OUTPUT, - GPIO_PULL_UP, GPIO_8MA), - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_UART1_CTS, 2, GPIO_INPUT, - GPIO_PULL_UP, GPIO_8MA), - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_UART1_RX, 2, GPIO_INPUT, - GPIO_PULL_UP, GPIO_8MA), - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_UART1_TX, 2, GPIO_OUTPUT, - GPIO_PULL_UP, GPIO_8MA), - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_RESET_N, 0, GPIO_OUTPUT, - GPIO_PULL_DOWN, GPIO_4MA), - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_SHUTDOWN_N, 0, GPIO_OUTPUT, - GPIO_PULL_DOWN, GPIO_4MA), - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_CHIP_WAKE, 0, GPIO_OUTPUT, - GPIO_PULL_DOWN, GPIO_4MA), - PCOM_GPIO_CFG(HTCLEO_GPIO_BT_HOST_WAKE, 0, GPIO_INPUT, - GPIO_PULL_DOWN, GPIO_4MA), -}; - static struct platform_device htcleo_rfkill = { .name = "htcleo_rfkill", @@ -1049,6 +1062,8 @@ static void __init htcleo_init(void) config_gpio_table(bt_gpio_table, ARRAY_SIZE(bt_gpio_table)); + parse_tag_bdaddr(); + bt_export_bd_address(); htcleo_audio_init();