Android BCM4330 藍芽BT驅動調試記錄

來源:互聯網
上載者:User

網上關於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。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.