diff --git a/drivers/amlogic/bluetooth/bt_device.c b/drivers/amlogic/bluetooth/bt_device.c index 394ad8d1ffe9..82745e757bdb 100644 --- a/drivers/amlogic/bluetooth/bt_device.c +++ b/drivers/amlogic/bluetooth/bt_device.c @@ -49,8 +49,38 @@ struct bt_dev_runtime_data { struct bt_dev_data *pdata; }; + +static void bt_device_off(struct bt_dev_data *pdata) +{ + if (pdata->power_down_disable == 0) { + if (pdata->power_off_flag > 0) { /*bt rc wakeup flag for bcm.*/ + if (pdata->gpio_reset > 0) { + if ((pdata->power_on_pin_OD) + && (pdata->power_low_level)) { + gpio_direction_input(pdata->gpio_reset); + } else { + gpio_direction_output(pdata->gpio_reset, + pdata->power_low_level); + } + } + if (pdata->gpio_en > 0) { + if ((pdata->power_on_pin_OD) + && (pdata->power_low_level)) { + gpio_direction_input(pdata->gpio_en); + } else { + set_usb_bt_power(0); + } + } + msleep(20); + } + } +} + + static void bt_device_init(struct bt_dev_data *pdata) { + int tmp = 0; + if (pdata->gpio_reset > 0) gpio_request(pdata->gpio_reset, BT_RFKILL); @@ -59,15 +89,14 @@ static void bt_device_init(struct bt_dev_data *pdata) 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); - } + gpio_direction_output(pdata->gpio_hostwake, 1); } + tmp = pdata->power_down_disable; + pdata->power_down_disable = 0; + bt_device_off(pdata); + pdata->power_down_disable = tmp; + } static void bt_device_deinit(struct bt_dev_data *pdata) @@ -127,32 +156,6 @@ static void bt_device_on(struct bt_dev_data *pdata) msleep(200); } -static void bt_device_off(struct bt_dev_data *pdata) -{ - if (pdata->power_down_disable == 0) { - if (pdata->power_off_flag > 0) { /*bt rc wakeup flag for bcm.*/ - if (pdata->gpio_reset > 0) { - if ((pdata->power_on_pin_OD) - && (pdata->power_low_level)) { - gpio_direction_input(pdata->gpio_reset); - } else { - gpio_direction_output(pdata->gpio_reset, - pdata->power_low_level); - } - } - if (pdata->gpio_en > 0) { - if ((pdata->power_on_pin_OD) - && (pdata->power_low_level)) { - gpio_direction_input(pdata->gpio_en); - } else { - set_usb_bt_power(0); - } - } - msleep(20); - } - } -} - static int bt_set_block(void *data, bool blocked) { struct bt_dev_data *pdata = data;