zoukankan      html  css  js  c++  java
  • Android BCM4330 蓝牙BT驱动调试记录

    http://blog.csdn.net/dwyane_zhang/article/details/7180779


    Android BCM4330 蓝牙BT驱动调试记录

    分类: Android驱动 1575人阅读 评论(0) 收藏 举报

    网上关于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。



  • 相关阅读:
    配置DHCP Snooping防止DHCP Server仿冒者攻击示例
    初识kbmmw 的多语言支持
    kbmmw 5.16.0 发布
    sql去除注释
    markdown写ppt
    Kafka流处理内幕详解
    【转载】matplotlib.pyplot的使用总结大全(入门加进阶)
    魔方第三层旋转公式
    自动化机器学习方面的开源框架和商业服务列表
    进阶版OFA算法:CompOFA: Compound Once-for-all Networks
  • 原文地址:https://www.cnblogs.com/yuzaipiaofei/p/4124187.html
Copyright © 2011-2022 走看看