From 1a5ab3c3cddbbcf4654ced2e35c66a78d40db944 Mon Sep 17 00:00:00 2001 From: Pradeep Panigrahi Date: Tue, 2 Jul 2013 03:03:41 +0530 Subject: [PATCH] init: qcom: Add hsic control service for bluetooth. The bt_hsic_control service is used for bluetooth to control the HSIC bus state for power management. CRs-fixed: 495435 Change-Id: Iebb32d63ae0eb297cb57c415b7a5fc50bf2d96f5 --- common.mk | 1 + rootdir/Android.mk | 7 +++ rootdir/etc/hsic.control.bt.sh | 79 ++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 rootdir/etc/hsic.control.bt.sh diff --git a/common.mk b/common.mk index 5423a1f4..93653ee0 100644 --- a/common.mk +++ b/common.mk @@ -170,6 +170,7 @@ INIT += init.qcom.thermal_conf.sh INIT += init.qcom.sensor.sh INIT += init.target.rc INIT += init.qcom.bt.sh +INIT += hsic.control.bt.sh INIT += init.qcom.coex.sh INIT += init.qcom.fm.sh INIT += init.qcom.early_boot.sh diff --git a/rootdir/Android.mk b/rootdir/Android.mk index 41d3ad0f..b37c2cfc 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -25,6 +25,13 @@ LOCAL_MODULE_CLASS := ETC LOCAL_SRC_FILES := etc/init.qcom.bt.sh include $(BUILD_PREBUILT) +include $(CLEAR_VARS) +LOCAL_MODULE := hsic.control.bt.sh +LOCAL_MODULE_TAGS := optional eng +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/hsic.control.bt.sh +include $(BUILD_PREBUILT) + include $(CLEAR_VARS) LOCAL_MODULE := init.ath3k.bt.sh LOCAL_MODULE_TAGS := optional eng diff --git a/rootdir/etc/hsic.control.bt.sh b/rootdir/etc/hsic.control.bt.sh new file mode 100644 index 00000000..5a26e3e7 --- /dev/null +++ b/rootdir/etc/hsic.control.bt.sh @@ -0,0 +1,79 @@ +#!/system/bin/sh +# Copyright (c) 2012, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +action=`getprop bluetooth.hsic_ctrl` +last_action=`getprop hsic_ctrl.last` +wifi_status=`getprop wlan.driver.status` +wifi_action=`getprop wlan.hsic_ctrl` +wifi_type=`getprop wlan.driver.ath` + +# check action from bt +if [ $wifi_type == "2" ]; then + if [ $action == "load_wlan" ]; then + if [ $wifi_status == "ok" ] || + [ $wifi_action == "wlan_loading" ] || + [ $last_action == "load_wlan" ]; then + echo "Not doing anything as wlan is on or turning on" + # do nothing + else + setprop wlan.hsic_ctrl "service_loading" + + # bind HSIC HCD + echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/bind + + # load WLAN driver + insmod /system/lib/modules/wlan.ko + + # inform WLAN driver bt is on + echo 1 > /sys/module/wlan/parameters/ath6kl_bt_on + + # unload WLAN driver + rmmod wlan + echo "Now hsic power control will be in auto mode" + fi + elif [ $action == "unbind_hsic" ]; then + if [ "$wifi_action" == "wlan_unloading" ] || + [ "$last_action" == "unbind_hsic" ]; then + echo "Not doing anything as wlan is also unloading" + # do nothing + else + # unbind HSIC HCD + echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind + echo "Unbinding HSIC before BT turns off" + fi + fi +fi # [ $wifi_type == "2" ] + +# set property to done +# setprop bluetooth.hsic_ctrl "done" + +# set property to NULL +setprop wlan.hsic_ctrl "" + +setprop hsic_ctrl.last $action +