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

    原文网址:http://blog.csdn.net/dwyane_zhang/article/details/7180779

    网上关于BT的驱动很少,所以我在开发过程中把其中的步骤记录下来。供大家相互学习讨论。

    一、关于BT driver的移植:

    1. Enablebluetootch in BoadConfig.mk

           BOARD_HAVE_BLUETOOTH := true

     

    2.实现BT电源管理rfkill驱动。

    Kernel/driver/bluetooth/bluetooth-power.c    高通的这个文件基本上不用动。

    在kernelarcharmmach_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睡眠唤醒机制

    Kerneldriversluetoothluesleep.c一般来说这个文件改动比较少,但可能逻辑上会有些问题。需要小的改动。

    在kernelarcharmmach_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 ");
                    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。

  • 相关阅读:
    火狐插件火狐黑客插件将Firefox变成黑客工具的七个插件
    memcache安装环境:WINDOWS 7
    PHP正则表达式
    968. 监控二叉树 力扣(困难) dfs 官方说DP
    375. 猜数字大小 II 力扣(中等) 区间动态规划、记忆化搜索
    629. K个逆序对数组 力扣(困难) 区间动态规划
    剑指 Offer 51. 数组中的逆序对 力扣(困难) 巧用归并排序算法
    488. 祖玛游戏 力扣(困难) dfs
    16. 最接近的三数之和 力扣(中等) 双指针
    319. 灯泡开关 力扣(中等) 数论
  • 原文地址:https://www.cnblogs.com/wi100sh/p/4332751.html
Copyright © 2011-2022 走看看