Android BCM4330 蓝牙BT驱动调试记录
網上關于BT的驅動很少,所以我在開發過程中把其中的步驟記錄下來。供大家相互學習討論。
一、關于BT driver的移植:
1. Enablebluetootch in BoadConfig.mk
?????? BOARD_HAVE_BLUETOOTH := true
2.實現BT電源管理rfkill驅動。
Kernel/driver/bluetooth/bluetooth-power.c??? 高通的這個文件基本上不用動。
在kernel\arch\arm\mach_msm7x27.c: static int bluetooth_power(int on)中
實現:上電:把bt_reset pin 和bt_reg_on pin 拉低
?????? ???????? mdelay(10);
????????????? 把bt_resetpin 和bt_reg_on pin 拉高
????????????? mdelay(150)
????? 下電:把bt_reset pin 和bt_reg_on pin 拉低?? ????
?
3. RebuildAndroid image and reboot
命令行測試:
echo 0 >/sys/class/rfkill/rfkill0/state?? //BT下電
echo 1 >/sys/class/rfkill/rfkill0/state?? //BT上電
brcm_patchram_plus-d --patchram /etc/firmware/BCM4329B1_002.002.023.0061.0062.hcd/dev/ttyHS0
hciattach -s115200 /dev/ttyHS0 any
沒任何錯誤提示是可以用以下測試
hciconfig hci0up
hcitool scan
?
4.實現BT睡眠喚醒機制
Kernel\drivers\bluetooth\bluesleep.c一般來說這個文件改動比較少,但可能邏輯上會有些問題。需要小的改動。
在kernel\arch\arm\mach_xxx/board_xxx.c:bluesleep_resources中定義gpio_host_wake(BT喚醒host腳)、gpio_ext_wake(host喚醒BT腳)、host_wake(BT喚醒host的中斷號)。
注:各個平臺的board_xxx.c文件名字不同,請客戶確認?
5.系統集成
1)在init.qcom.rc中確認有下面的內容:
service hciattach/system/bin/sh /system/etc/init.qcom.bt.sh
??? user bluetooth
??? group qcom_oncrpc bluetooth net_bt_admin
??? disabled
??? oneshot
?
2)修改init.qcom.bt.sh
確認有:
BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto
echo 1 >$BLUETOOTH_SLEEP_PATH
/system/bin/hciattach-n /dev/ttyHS0 any 3000000 flow & 改為:
./brcm_patchram_plus--enable_lpm –enable_hci --patchram /system/etc/wifi/BCM4329BT.hcd --baudrate3000000 /dev/ttyHS0 &
注掉:高通下載firmware的命令。
?
6.重新編譯system。此時BT應該能運行了。
二、BT的休眠喚醒配置
BT的休眠在driver/bluetooth/bluesleep.c中,首先驅動的名字叫“bluesleep”與arch/arm/mach-msm/board-msm7x30.c相匹配就執行platform_driver_probe(&bluesleep_driver, bluesleep_probe)然后調用static int __init bluesleep_probe(struct platform_device *pdev),這里會配置兩個引腳HOST_WAKE_BT & BT_WAKE_HOST?
bsi = kzalloc(sizeof(struct bluesleep_info), GFP_KERNEL);
?? ? ? ?if (!bsi)
?? ? ? ? ? ? ? ?return -ENOMEM;
?? ? ? ?res = platform_get_resource_byname(pdev, IORESOURCE_IO,
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"gpio_host_wake");
?? ? ? ?if (!res) {
?? ? ? ? ? ? ? ?BT_ERR("couldn't find host_wake gpio\n");
?? ? ? ? ? ? ? ?ret = -ENODEV;
?? ? ? ? ? ? ? ?goto free_bsi;
?? ? ? ?}
?? ? ? ?bsi->host_wake = res->start;
?? ? ? ?//[SIMT-zhangmin-111230] change the configuration of BT sleep gpio from bt_power to here {
?? ? ? ?gpio_tlmm_config(GPIO_CFG(bsi->host_wake, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
?? ? ? ?//[SIMT-zhangmin-111230] }
?? ? ? ?ret = gpio_request(bsi->host_wake, "bt_host_wake");
?? ? ? ?if (ret)
?? ? ? ? ? ? ? ?goto free_bsi;
?? ? ? ?ret = gpio_direction_input(bsi->host_wake);
?bsi->host_wake_irq = platform_get_irq_byname(pdev, "host_wake");
如上代碼所示,主要將HOST_WAKE_BT設置為輸出腳,BT_WAKE_HOST 設置為輸入腳并也設置為中斷腳,等待BT芯片的喚醒。
然后再bluesleep_init函數中建立BT目錄/proc/bluetooth/sleep/讀btwake中HOST_WAKE_BT的狀態。讀出的狀態值為0或1。
或在BT目錄/proc/bluetooth/sleep/寫btwake中HOST_WAKE_BT的狀態。寫出狀態值為0或1。
總結
以上是生活随笔為你收集整理的Android BCM4330 蓝牙BT驱动调试记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MT6573驱动开发日志之touchpa
- 下一篇: gettimeofday