BT: g12a_skt: initial host wake bt pin [1/1]
authorkuibao zhang <kuibao.zhang@amlogic.com>
Fri, 2 Feb 2018 13:28:39 +0000 (21:28 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Mon, 5 Mar 2018 07:34:27 +0000 (15:34 +0800)
PD#156734: bt: g12a_skt: initial host wake bt pin

1.host wake bt pin (gpiox_19) should keep high when bt
lpm function is enabled, otherwise bt moudle would go
to sleep.
2.set this pin in dts

Change-Id: I401fa158bf11b60ef1a7727ea25e55f94cf273a8
Signed-off-by: kuibao zhang <kuibao.zhang@amlogic.com>
arch/arm64/boot/dts/amlogic/g12a_skt.dts
drivers/amlogic/bluetooth/bt_device.c
include/linux/amlogic/bt_device.h

index 038fc60..e65f555 100644 (file)
                dev_name = "bt-dev";
                status = "okay";
                gpio_reset = <&gpio       GPIOX_17       GPIO_ACTIVE_HIGH>;
+               gpio_hostwake = <&gpio       GPIOX_19       GPIO_ACTIVE_HIGH>;
        };
 
        wifi{
index c18a676..af0ea21 100644 (file)
@@ -57,6 +57,17 @@ static void bt_device_init(struct bt_dev_data *pdata)
        if (pdata->gpio_en > 0)
                gpio_request(pdata->gpio_en, BT_RFKILL);
 
+       if (pdata->gpio_hostwake > 0) {
+               gpio_request(pdata->gpio_hostwake, BT_RFKILL);
+
+       if ((pdata->power_on_pin_OD) && (!pdata->power_low_level)) {
+               gpio_direction_input(pdata->gpio_hostwake);
+               } else {
+                       gpio_direction_output(pdata->gpio_hostwake,
+                               !pdata->power_low_level);
+               }
+       }
+
 }
 
 static void bt_device_deinit(struct bt_dev_data *pdata)
@@ -67,6 +78,9 @@ static void bt_device_deinit(struct bt_dev_data *pdata)
        if (pdata->gpio_en > 0)
                gpio_free(pdata->gpio_en);
 
+       if (pdata->gpio_hostwake > 0)
+               gpio_free(pdata->gpio_hostwake);
+
 }
 
 static void bt_device_on(struct bt_dev_data *pdata)
@@ -133,6 +147,7 @@ static void bt_device_off(struct bt_dev_data *pdata)
                        set_usb_bt_power(0);
                }
        }
+
        msleep(20);
 }
 
@@ -143,10 +158,10 @@ static int bt_set_block(void *data, bool blocked)
        pr_info("BT_RADIO going: %s\n", blocked ? "off" : "on");
 
        if (!blocked) {
-               pr_info("BCM_BT: going ON\n");
+               pr_info("AML_BT: going ON\n");
                bt_device_on(pdata);
        } else {
-               pr_info("BCM_BT: going OFF\n");
+               pr_info("AML_BT: going OFF\n");
        bt_device_off(pdata);
        }
        return 0;
@@ -205,7 +220,7 @@ static int bt_probe(struct platform_device *pdev)
                        pdata->gpio_reset = desc_to_gpio(desc);
                }
 
-       ret = of_property_read_string(pdev->dev.of_node,
+               ret = of_property_read_string(pdev->dev.of_node,
                "gpio_en", &str);
                if (ret) {
                        pr_warn("not get gpio_en\n");
@@ -215,6 +230,16 @@ static int bt_probe(struct platform_device *pdev)
                                "gpio_en", 0, NULL);
                        pdata->gpio_en = desc_to_gpio(desc);
                }
+               ret = of_property_read_string(pdev->dev.of_node,
+               "gpio_hostwake", &str);
+               if (ret) {
+                       pr_warn("not get gpio_hostwake\n");
+                       pdata->gpio_hostwake = 0;
+               } else {
+                       desc = of_get_named_gpiod_flags(pdev->dev.of_node,
+                               "gpio_hostwake", 0, NULL);
+                       pdata->gpio_hostwake = desc_to_gpio(desc);
+               }
 
                prop = of_get_property(pdev->dev.of_node,
                "power_low_level", NULL);
index e0c6de1..f233dbe 100644 (file)
@@ -21,6 +21,7 @@
 struct bt_dev_data {
        int gpio_reset;
        int gpio_en;
+       int gpio_hostwake;
        int power_low_level;
        int power_on_pin_OD;
 };