蓝牙4个电源相关GPIO
// bluetooth GPIOs
#define BT_POWER TEGRA_GPIO_PU0
#define BT_RESET TEGRA_GPIO_PU4
#define EXT_WAKE TEGRA_GPIO_PU1
#define HOST_WAKE TEGRA_GPIO_PU6
1)BT模块的的enable & disable一般是通过rfkill控制,但是在我们一个AP20项目上没有使用rfkill这个机制,
而是控制/proc/bt_power文件。
代码如下:
#ifdef NVIDIA_AP20
#define BLUETOOTH_POWER_PATH "/proc/bt_power"
#endif
static int set_bluetooth_power(int on) {
int ret = -1;
int sz;
const char buffer = (on ? '1' : '0');
int fd = open(BLUETOOTH_POWER_PATH, O_WRONLY | O_APPEND);
if (fd == -1) {
LOGE("Can't open %s for write: %s (%d)", BLUETOOTH_POWER_PATH,
strerror(errno), errno);
goto out;
}
sz = write(fd, &buffer, 1);
if (sz != 1) {
LOGE("Can't write to %s: %s (%d)", BLUETOOTH_POWER_PATH,
strerror(errno), errno);
goto out;
}
ret = 0;
out:
if (fd >= 0) close(fd);
return ret;
}
对应的kernel space
int bt_power_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
{
....
if('1' == *proc_buf)
{
if(!power_is_on)
{
set_power(1); // turn power on to BT module
set_reset(1); // take BT out of reset
power_is_on = 1;
printk(KERN_INFO "BLUETOOTH: bt_power: ON
");
}
}
....
}
void set_power(int state) {gpio_set_value(BT_POWER, state); mdelay(100);}
void set_reset(int state) {gpio_set_value(BT_RESET, state); mdelay(100);}
void set_bt_wake(int state) {gpio_set_value(EXT_WAKE, state); mdelay(100);}
2)在AP20上,
BT的休眠唤醒配置和Android
BCM4330 蓝牙BT驱动调试记录一样,
是使用bluesleep driver.