Original URL: http://blog.csdn.net/dwyane_zhang/article/details/7180779
There are few drivers on the web about BT, so I recorded the steps in the development process. For everyone to study and discuss with each other.
First, the migration of BT driver:
1. Enablebluetootch in Boadconfig.mk
Board_have_bluetooth: = True
2. Implement BT Power management Rfkill driver.
This file for kernel/driver/bluetooth/bluetooth-power.c Qualcomm is basically not moving.
in kernel\arch\arm\mach_msm7x27.c:static int bluetooth_power (int on)
Implementation: Power up: Pull the bt_reset pin and bt_reg_on pin low
Mdelay (10);
Pull the Bt_resetpin and bt_reg_on pin high
Mdelay (150)
Power down: Pull the bt_reset pin and bt_reg_on pin low
3. Rebuildandroid Image and reboot
Command-line testing:
echo 0 >/sys/class/rfkill/rfkill0/state//BT Power down
Echo 1 >/sys/class/rfkill/rfkill0/state//bt power on
Brcm_patchram_plus-d--patchram/etc/firmware/bcm4329b1_002.002.023.0061.0062.hcd/dev/ttyhs0
Hciattach-s115200/dev/ttyhs0 any
There are no error hints that you can use the following tests
Hciconfig Hci0up
Hcitool Scan
4. Realization of BT sleep wake-up mechanism
Kernel\drivers\bluetooth\bluesleep.c Generally, this file is less modified, but there may be some logical problems. Small changes are required.
Define Gpio_host_wake (BT wake-up host pin), Gpio_ext_wake (host Wake BT foot) in Kernel\arch\arm\mach_xxx/board_xxx.c:bluesleep_resources , Host_wake (the interrupt number of the BT wake-up host).
Note: The board_xxx.c file name of each platform is different, please confirm the customer
5. System Integration
1) Confirm the following content in 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) Modify init.qcom.bt.sh
Confirmation is:
Bluetooth_sleep_path=/proc/bluetooth/sleep/proto
echo 1 > $BLUETOOTH _sleep_path
/system/bin/hciattach-n/dev/ttyhs0 any 3000000 flow & change to:
./BRCM_PATCHRAM_PLUS--ENABLE_LPM–ENABLE_HCI--PATCHRAM/SYSTEM/ETC/WIFI/BCM4329BT.HCD--baudrate3000000/dev/ TtyHS0 &
Note off: Qualcomm downloads the firmware command.
6. Recompile the system. At this point BT should be able to run.
Second, the BT sleep wake configuration
BT hibernation in Driver/bluetooth/bluesleep.c, first driven by the name "Bluesleep" and arch/arm/mach-msm/board-msm7x30.c match on the execution platform_driver _probe (&bluesleep_driver, Bluesleep_probe) then calls the static int __init bluesleep_probe (struct platform_device *pdev), This will be configured with two pins 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 the 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");
As shown in the code above, the HOST_WAKE_BT is mainly set to the output pin, the bt_wake_host is set to the input pin and also set as the interrupt pin, waiting for the BT chip to wake up.
Then bluesleep_init the function to establish the/proc/bluetooth/sleep/of the BT directory in the Read Btwake HOST_WAKE_BT state. The readout status value is 0 or 1.
or HOST_WAKE_BT status in the BT directory/proc/bluetooth/sleep/write Btwake. Writes out a status value of 0 or 1.
"Turn" Android BCM4330 bluetooth BT drive Debug Record