Zvikomborero VIncent Zvikaramba | a25011a | 2016-07-21 16:32:35 -0400 | [diff] [blame] | 1 | #!/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 | |
| 29 | ssr_str="$1" |
| 30 | IFS=, |
| 31 | ssr_array=($ssr_str) |
| 32 | declare -i subsys_mask=0 |
| 33 | |
| 34 | # check user input subsystem with system device |
| 35 | ssr_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 |
| 51 | for num in "${!ssr_array[@]}" |
| 52 | do |
| 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 |
| 94 | done |
| 95 | |
| 96 | # enable selected subsystem restart |
| 97 | if [ $((subsys_mask & 1)) == 1 ]; then |
| 98 | echo 1 > /sys/module/wcnss_ssr_8960/parameters/enable_riva_ssr |
| 99 | else |
| 100 | echo 0 > /sys/module/wcnss_ssr_8960/parameters/enable_riva_ssr |
| 101 | fi |
| 102 | |
| 103 | if [ $((subsys_mask & 2)) == 2 ]; then |
| 104 | echo "related" > /sys/bus/msm_subsys/devices/subsys0/restart_level |
| 105 | else |
| 106 | echo "system" > /sys/bus/msm_subsys/devices/subsys0/restart_level |
| 107 | fi |
| 108 | |
| 109 | if [ $((subsys_mask & 4)) == 4 ]; then |
| 110 | echo "related" > /sys/bus/msm_subsys/devices/subsys1/restart_level |
| 111 | else |
| 112 | echo "system" > /sys/bus/msm_subsys/devices/subsys1/restart_level |
| 113 | fi |
| 114 | |
| 115 | if [ $((subsys_mask & 8)) == 8 ]; then |
| 116 | echo "related" > /sys/bus/msm_subsys/devices/subsys2/restart_level |
| 117 | else |
| 118 | echo "system" > /sys/bus/msm_subsys/devices/subsys2/restart_level |
| 119 | fi |
| 120 | |
| 121 | if [ $((subsys_mask & 16)) == 16 ]; then |
| 122 | echo "related" > /sys/bus/msm_subsys/devices/subsys3/restart_level |
| 123 | else |
| 124 | echo "system" > /sys/bus/msm_subsys/devices/subsys3/restart_level |
| 125 | fi |
| 126 | |
| 127 | if [ $((subsys_mask & 32)) == 32 ]; then |
| 128 | echo "related" > /sys/bus/msm_subsys/devices/subsys4/restart_level |
| 129 | else |
| 130 | echo "system" > /sys/bus/msm_subsys/devices/subsys4/restart_level |
| 131 | fi |
| 132 | |
| 133 | if [ $((subsys_mask & 63)) == 63 ]; then |
| 134 | echo 3 > /sys/module/subsystem_restart/parameters/restart_level |
| 135 | else |
| 136 | echo 1 > /sys/module/subsystem_restart/parameters/restart_level |
| 137 | fi |