blob: f1441625dc779c570f1e405d519c6107580b10db [file] [log] [blame]
Zvikomborero VIncent Zvikarambaa25011a2016-07-21 16:32:35 -04001#!/system/bin/sh
2# Copyright (c) 2013, The Linux Foundation. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6# * Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# * Redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution.
11# * Neither the name of The Linux Foundation nor
12# the names of its contributors may be used to endorse or promote
13# products derived from this software without specific prior written
14# permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29ssr_str="$1"
30IFS=,
31ssr_array=($ssr_str)
32declare -i subsys_mask=0
33
34# check user input subsystem with system device
35ssr_check_subsystem_name()
36{
37 declare -i i=0
38 subsys=`cat /sys/bus/msm_subsys/devices/subsys$i/name`
39 while [ "$subsys" != "" ]
40 do
41 if [ "$subsys" == "$ssr_name" ]; then
42 return 1
43 fi
44 i=$i+1
45 subsys=`cat /sys/bus/msm_subsys/devices/subsys$i/name`
46 done
47 return 0
48}
49
50# set subsystem mask to indicate which subsystem needs to be enabled
51for num in "${!ssr_array[@]}"
52do
53 case "${ssr_array[$num]}" in
54 "1")
55 subsys_mask=0
56 ;;
57 "riva")
58 subsys_mask=$subsys_mask+1
59 ;;
60 "3")
61 subsys_mask=63
62 ;;
63 "adsp")
64 ssr_name=adsp
65 if ( ssr_check_subsystem_name ); then
66 subsys_mask=$subsys_mask+2
67 fi
68 ;;
69 "modem")
70 ssr_name=modem
71 if ( ssr_check_subsystem_name ); then
72 subsys_mask=$subsys_mask+4
73 fi
74 ;;
75 "wcnss")
76 ssr_name=wcnss
77 if ( ssr_check_subsystem_name ); then
78 subsys_mask=$subsys_mask+8
79 fi
80 ;;
81 "venus")
82 ssr_name=venus
83 if ( ssr_check_subsystem_name ); then
84 subsys_mask=$subsys_mask+16
85 fi
86 ;;
87 "external_modem")
88 ssr_name=external_modem
89 if ( ssr_check_subsystem_name ); then
90 subsys_mask=$subsys_mask+32
91 fi
92 ;;
93 esac
94done
95
96# enable selected subsystem restart
97if [ $((subsys_mask & 1)) == 1 ]; then
98 echo 1 > /sys/module/wcnss_ssr_8960/parameters/enable_riva_ssr
99else
100 echo 0 > /sys/module/wcnss_ssr_8960/parameters/enable_riva_ssr
101fi
102
103if [ $((subsys_mask & 2)) == 2 ]; then
104 echo "related" > /sys/bus/msm_subsys/devices/subsys0/restart_level
105else
106 echo "system" > /sys/bus/msm_subsys/devices/subsys0/restart_level
107fi
108
109if [ $((subsys_mask & 4)) == 4 ]; then
110 echo "related" > /sys/bus/msm_subsys/devices/subsys1/restart_level
111else
112 echo "system" > /sys/bus/msm_subsys/devices/subsys1/restart_level
113fi
114
115if [ $((subsys_mask & 8)) == 8 ]; then
116 echo "related" > /sys/bus/msm_subsys/devices/subsys2/restart_level
117else
118 echo "system" > /sys/bus/msm_subsys/devices/subsys2/restart_level
119fi
120
121if [ $((subsys_mask & 16)) == 16 ]; then
122 echo "related" > /sys/bus/msm_subsys/devices/subsys3/restart_level
123else
124 echo "system" > /sys/bus/msm_subsys/devices/subsys3/restart_level
125fi
126
127if [ $((subsys_mask & 32)) == 32 ]; then
128 echo "related" > /sys/bus/msm_subsys/devices/subsys4/restart_level
129else
130 echo "system" > /sys/bus/msm_subsys/devices/subsys4/restart_level
131fi
132
133if [ $((subsys_mask & 63)) == 63 ]; then
134 echo 3 > /sys/module/subsystem_restart/parameters/restart_level
135else
136 echo 1 > /sys/module/subsystem_restart/parameters/restart_level
137fi