90 lines
2.2 KiB
Diff
Executable File
90 lines
2.2 KiB
Diff
Executable File
diff --git a/tools/hciattach_xradio.c b/tools/hciattach_xradio.c
|
|
index a0ae7e3..d87185c 100644
|
|
--- a/tools/hciattach_xradio.c
|
|
+++ b/tools/hciattach_xradio.c
|
|
@@ -288,6 +288,20 @@ enum {
|
|
|
|
#define BT_WAKE_VIA_PROC 1
|
|
|
|
+/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
|
|
+#ifndef LPM_BT_WAKE_POLARITY
|
|
+#define LPM_BT_WAKE_POLARITY 1 /* maguro */
|
|
+#endif
|
|
+
|
|
+/* BT_WAKE Lock - 2=LOCK, 3= UNLOCK */
|
|
+#ifndef LPM_BT_WAKE_LOCK
|
|
+#define LPM_BT_WAKE_LOCK 2
|
|
+#endif
|
|
+
|
|
+#ifndef LPM_BT_WAKE_UNLOCK
|
|
+#define LPM_BT_WAKE_UNLOCK 3
|
|
+#endif
|
|
+
|
|
/* proc fs node for enable/disable lpm mode */
|
|
#ifndef VENDOR_LPM_PROC_NODE
|
|
#define VENDOR_LPM_PROC_NODE "/proc/bluetooth/sleep/lpm"
|
|
@@ -298,6 +312,10 @@ enum {
|
|
#define VENDOR_BTWAKE_PROC_NODE "/proc/bluetooth/sleep/btwrite"
|
|
#endif
|
|
|
|
+#ifndef VENDOR_BTWAKE_PROC_NODE
|
|
+#define VENDOR_BTWAKE_PROC_NODE "/proc/bluetooth/sleep/btwake"
|
|
+#endif
|
|
+
|
|
/*
|
|
* Maximum btwrite assertion holding time without consecutive btwrite kicking.
|
|
* This value is correlative(shorter) to the in-activity timeout period set in
|
|
@@ -818,6 +836,44 @@ static int upio_set_bluetooth_power(int on)
|
|
return ret;
|
|
}
|
|
|
|
+static int upio_set_btwake(int action)
|
|
+{
|
|
+ int fd = -1;
|
|
+ int ret = -1;
|
|
+ char buffer = '0';
|
|
+
|
|
+ if (action == 0) {
|
|
+ buffer = '0';
|
|
+ } else if (action == LPM_BT_WAKE_POLARITY) {
|
|
+ buffer = '1';
|
|
+ } else if (action == LPM_BT_WAKE_LOCK) {
|
|
+ buffer = '2';
|
|
+ } else if (action == LPM_BT_WAKE_UNLOCK) {
|
|
+ buffer = '3';
|
|
+ } else {
|
|
+ printf("Invalid btwake action\n");
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ fd = open(VENDOR_BTWAKE_PROC_NODE, O_WRONLY);
|
|
+ if (fd < 0) {
|
|
+ printf("upio_set : open(%s) for write failed: %s (%d)",
|
|
+ VENDOR_BTWAKE_PROC_NODE, strerror(errno), errno);
|
|
+ return fd;
|
|
+ }
|
|
+
|
|
+ if (write(fd, &buffer, 1) < 0) {
|
|
+ printf("upio_set : write(%s) failed: %s (%d)",
|
|
+ VENDOR_BTWAKE_PROC_NODE, strerror(errno),errno);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (fd >= 0)
|
|
+ close(fd);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static void upio_init(void)
|
|
{
|
|
memset(upio_state, UPIO_UNKNOWN, UPIO_MAX_COUNT);
|
|
@@ -1340,6 +1396,7 @@ int xradio_init(int fd, int def_speed, int speed, struct termios *ti,
|
|
usleep(20000);
|
|
|
|
upio_init();
|
|
+ upio_set_btwake(LPM_BT_WAKE_POLARITY);
|
|
upio_set(UPIO_LPM_MODE, UPIO_DEASSERT, 0);
|
|
usleep(50000);
|
|
|