• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/vendor/bin/sh
2build_type="$(getprop ro.build.type)"
3echo "\n------ Power Stats Times ------"
4echo -n "Boot: " && /vendor/bin/uptime -s && echo -n "Now: " && date;
5
6echo "\n------ ACPM stats ------"
7for f in /sys/devices/platform/acpm_stats/*_stats ; do
8  echo "\n\n$f"
9  cat $f
10done
11
12echo "\n------ CPU PM stats ------"
13cat "/sys/devices/system/cpu/cpupm/cpupm/time_in_state"
14
15echo "\n------ GENPD summary ------"
16cat "/d/pm_genpd/pm_genpd_summary"
17
18echo "\n------ Power supply property battery ------"
19cat "/sys/class/power_supply/battery/uevent"
20echo "\n------ Power supply property dc ------"
21cat "/sys/class/power_supply/dc/uevent"
22echo "\n------ Power supply property gcpm ------"
23cat "/sys/class/power_supply/gcpm/uevent"
24echo "\n------ Power supply property gcpm_pps ------"
25cat "/sys/class/power_supply/gcpm_pps/uevent"
26echo "\n------ Power supply property main-charger ------"
27cat "/sys/class/power_supply/main-charger/uevent"
28echo "\n------ Power supply property dc-mains ------"
29cat "/sys/class/power_supply/dc-mains/uevent"
30echo "\n------ Power supply property tcpm ------"
31cat "/sys/class/power_supply/tcpm-source-psy-8-0025/uevent"
32echo "\n------ Power supply property usb ------"
33cat "/sys/class/power_supply/usb/uevent"
34echo "\n------ Power supply property wireless ------"
35cat "/sys/class/power_supply/wireless/uevent"
36
37if [ -d "/sys/class/power_supply/maxfg" ]
38then
39  echo "\n------ Power supply property maxfg ------"
40  cat "/sys/class/power_supply/maxfg/uevent"
41  echo "\n------ m5_state ------"
42  cat "/sys/class/power_supply/maxfg/m5_model_state"
43  echo "\n------ maxfg ------"
44  cat "/dev/logbuffer_maxfg"
45  echo "\n------ maxfg ------"
46  cat "/dev/logbuffer_maxfg_monitor"
47else
48  echo "\n------ Power supply property maxfg_base ------"
49  cat "/sys/class/power_supply/maxfg_base/uevent"
50  echo "\n------ Power supply property maxfg_flip ------"
51  cat "/sys/class/power_supply/maxfg_flip/uevent"
52  echo "\n------ m5_state ------"
53  cat "/sys/class/power_supply/maxfg_base/m5_model_state"
54  echo "\n------ maxfg_base ------"
55  cat "/dev/logbuffer_maxfg_base"
56  echo "\n------ maxfg_flip ------"
57  cat "/dev/logbuffer_maxfg_flip"
58  echo "\n------ maxfg_base ------"
59  cat "/dev/logbuffer_maxfg_base_monitor"
60  echo "\n------ maxfg_flip ------"
61  cat "/dev/logbuffer_maxfg_flip_monitor"
62fi
63
64if [ -e "/dev/maxfg_history" ]
65then
66  echo "\n------ Maxim FG History ------"
67  cat "/dev/maxfg_history"
68fi
69
70if [ -d "/sys/class/power_supply/dock" ]
71then
72  echo "\n------ Power supply property dock ------"
73  cat "/sys/class/power_supply/dock/uevent"
74fi
75
76if [ -e "/dev/logbuffer_tcpm" ]
77then
78  echo "\n------ Logbuffer TCPM ------"
79  cat "/dev/logbuffer_tcpm"
80  if [ -d "/sys/kernel/debug/tcpm" ]
81  then
82    echo "\n------ TCPM logs ------"
83    cat /sys/kernel/debug/tcpm/*
84  else
85    echo "\n------ TCPM logs ------"
86    cat /sys/kernel/debug/usb/tcpm*
87  fi
88fi
89
90echo "\n------ TCPC ------"
91for f in /sys/devices/platform/10d60000.hsi2c/i2c-*/i2c-max77759tcpc
92do
93  echo "registers:"
94  cat $f/registers
95  echo "frs:"
96  cat $f/frs
97  echo "auto_discharge:"
98  cat $f/auto_discharge
99  echo "bc12_enabled:"
100  cat $f/bc12_enabled
101  echo "cc_toggle_enable:"
102  cat $f/cc_toggle_enable
103  echo "contaminant_detection:"
104  cat $f/contaminant_detection
105  echo "contaminant_detection_status:"
106  cat $f/contaminant_detection_status
107done
108
109echo "\n------ PD Engine ------"
110cat "/dev/logbuffer_usbpd"
111echo "\n------ PPS-google_cpm ------"
112cat "/dev/logbuffer_cpm"
113echo "\n------ PPS-dc ------"
114cat "/dev/logbuffer_pca9468"
115
116if [ -e "/dev/logbuffer_wc68" ]
117then
118  echo "\n------ WC68 ------"
119  cat "/dev/logbuffer_wc68"
120fi
121
122if [ -e "/dev/logbuffer_ln8411" ]
123then
124  echo "\n------ LN8411 ------"
125  cat "/dev/logbuffer_ln8411"
126fi
127
128echo "\n------ Battery Health ------"
129cat "/sys/class/power_supply/battery/health_index_stats"
130echo "\n------ BMS ------"
131cat "/dev/logbuffer_ssoc"
132echo "\n------ TTF ------"
133cat "/dev/logbuffer_ttf"
134echo "\n------ TTF details ------"
135cat "/sys/class/power_supply/battery/ttf_details"
136echo "\n------ TTF stats ------"
137cat "/sys/class/power_supply/battery/ttf_stats"
138echo "\n------ aacr_state ------"
139cat "/sys/class/power_supply/battery/aacr_state"
140echo "\n------ maxq ------"
141cat "/dev/logbuffer_maxq"
142echo "\n------ TEMP/DOCK-DEFEND ------"
143cat "/dev/logbuffer_bd"
144
145echo "\n------ TRICKLE-DEFEND Config ------"
146cd /sys/devices/platform/google,battery/power_supply/battery/
147for f in `ls bd_*`
148do
149  echo $f: `cat $f`
150done
151
152echo "\n------ DWELL-DEFEND Config ------"
153cd /sys/devices/platform/google,charger/
154for f in `ls charge_s*`
155do
156  echo "$f: `cat $f`"
157done
158
159echo "\n------ TEMP-DEFEND Config ------"
160cd /sys/devices/platform/google,charger/
161for f in `ls bd_*`
162do
163  echo "$f: `cat $f`"
164done
165
166if [ $build_type = "userdebug" ]
167then
168  echo "\n------ DC_registers dump ------"
169  cat "/sys/class/power_supply/dc-mains/device/registers_dump"
170  echo "\n------ max77759_chg registers dump ------"
171  cat "/d/max77759_chg/registers"
172  echo "\n------ max77729_pmic registers dump ------"
173  cat "/d/max77729_pmic/registers"
174  echo "\n------ Charging table dump ------"
175  cat "/d/google_battery/chg_raw_profile"
176
177  echo "\n------ fg_model ------"
178  for f in /d/maxfg*
179  do
180    regs=`cat $f/fg_model`
181    echo $f:
182    echo "$regs"
183  done
184
185  echo "\n------ fg_alo_ver ------"
186  for f in /d/maxfg*
187  do
188    regs=`cat $f/algo_ver`
189    echo $f:
190    echo "$regs"
191  done
192
193  echo "\n------ fg_model_ok ------"
194  for f in /d/maxfg*
195  do
196    regs=`cat $f/model_ok`
197    echo $f:
198    echo "$regs"
199  done
200
201  echo "\n------ fg registers ------"
202  for f in /d/maxfg*
203  do
204    regs=`cat $f/registers`
205    echo $f:
206    echo "$regs"
207  done
208
209  echo "\n------ Maxim FG NV RAM ------"
210  for f in /d/maxfg*
211  do
212    regs=`cat $f/nv_registers`
213    echo $f:
214    echo "$regs"
215  done
216fi
217
218echo "\n------ Battery EEPROM ------"
219if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom" ]
220then
221  xxd /sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom
222fi
223
224if [ -e "/sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom" ]
225then
226  xxd /sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom
227fi
228
229if [ -e "/sys/devices/platform/10da0000.hsi2c/i2c-6/6-0050/eeprom" ]
230then
231  xxd /sys/devices/platform/10da0000.hsi2c/i2c-6/6-0050/eeprom
232fi
233
234if [ -e "/sys/devices/platform/10da0000.hsi2c/i2c-7/7-0050/eeprom" ]
235then
236  xxd /sys/devices/platform/10da0000.hsi2c/i2c-7/7-0050/eeprom
237fi
238
239if [ -e "/sys/devices/platform/10c90000.hsi2c/i2c-7/7-0050/eeprom" ]
240then
241  xxd /sys/devices/platform/10c90000.hsi2c/i2c-7/7-0050/eeprom
242fi
243
244if [ -e "/sys/devices/platform/10c90000.hsi2c/i2c-6/6-0050/eeprom" ]
245then
246  xxd /sys/devices/platform/10c90000.hsi2c/i2c-6/6-0050/eeprom
247fi
248
249echo "\n------ Charger Stats ------"
250cat "/sys/class/power_supply/battery/charge_details"
251if [ $build_type = "userdebug" ]
252then
253  echo "\n------ Google Charger ------"
254  cd /sys/kernel/debug/google_charger/
255  for f in `ls pps_*`
256  do
257    echo "$f: `cat $f`"
258  done
259  echo "\n------ Google Battery ------"
260  cd /sys/kernel/debug/google_battery/
261  for f in `ls ssoc_*`
262  do
263    echo "$f: `cat $f`"
264  done
265fi
266
267echo "\n------ WLC logs ------"
268cat "/dev/logbuffer_wireless"
269echo "\n------ WLC VER ------"
270cat "/sys/class/power_supply/wireless/device/version"
271echo "\n------ WLC STATUS ------"
272cat "/sys/class/power_supply/wireless/device/status"
273echo "\n------ WLC FW Version ------"
274cat "/sys/class/power_supply/wireless/device/fw_rev"
275echo "\n------ RTX ------"
276cat "/dev/logbuffer_rtx"
277
278if [ $build_type = "userdebug" ]
279then
280  echo "\n------ gvotables ------"
281  cat /sys/kernel/debug/gvotables/*/status
282fi
283
284echo "\n------ Lastmeal ------"
285cat "/data/vendor/mitigation/lastmeal.txt"
286echo "\n------ Thismeal ------"
287cat "/data/vendor/mitigation/thismeal.txt"
288echo "\n------ Mitigation Stats ------"
289echo "Source\t\tCount\tSOC\tTime\tVoltage"
290for f in `ls /sys/devices/virtual/pmic/mitigation/last_triggered_count/*`
291do
292  count=`cat $f`
293  a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/last_triggered_count\//}
294  b=${f/last_triggered_count/last_triggered_capacity}
295  c=${f/last_triggered_count/last_triggered_timestamp/}
296  d=${f/last_triggered_count/last_triggered_voltage/}
297  cnt=`cat $f`
298  cap=`cat ${b/count/cap}`
299  ti=`cat ${c/count/time}`
300  volt=`cat ${d/count/volt}`
301  echo "${a/_count/} \t$cnt\t$cap\t$ti\t$volt"
302done
303
304echo "\n------ Clock Divider Ratio ------"
305echo \"Source\t\tRatio\"
306for f in `ls /sys/devices/virtual/pmic/mitigation/clock_ratio/*`
307do ratio=`cat $f`
308  a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/clock_ratio\//}
309  echo "${a/_ratio/} \t$ratio"
310done
311
312echo "\n------ Clock Stats ------"
313echo "Source\t\tStats"
314for f in `ls /sys/devices/virtual/pmic/mitigation/clock_stats/*`
315do
316  stats=`cat $f`
317  a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/clock_stats\//};
318  echo "${a/_stats/} \t$stats"
319done
320
321echo "\n------ Triggered Level ------"
322echo "Source\t\tLevel"
323for f in `ls /sys/devices/virtual/pmic/mitigation/triggered_lvl/*`
324do
325  lvl=`cat $f`
326  a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/triggered_lvl\//}
327  echo "${a/_lvl/} \t$lvl"
328done
329
330echo "\n------ Instruction ------"
331for f in `ls /sys/devices/virtual/pmic/mitigation/instruction/*`
332do
333  val=`cat $f`
334  a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/instruction\//}
335  echo "$a=$val"
336done
337
338echo "\n------ IRQ Duration Counts ------"
339echo "Source\t\t\t\tlt_5ms_cnt\tbt_5ms_to_10ms_cnt\tgt_10ms_cnt\tCode\tCurrent Threshold (uA)\tCurrent Reading (uA)"
340
341lt=`cat /sys/devices/virtual/pmic/mitigation/irq_dur_cnt/less_than_5ms_count`
342bt=`cat /sys/devices/virtual/pmic/mitigation/irq_dur_cnt/between_5ms_to_10ms_count`
343gt=`cat /sys/devices/virtual/pmic/mitigation/irq_dur_cnt/greater_than_10ms_count`
344lpf_cur_m=`cat /sys/devices/platform/acpm_mfd_bus@15500000/i2c-0/0-001f/s2mpg14-meter/s2mpg14-odpm/iio:device0/lpf_current`
345lpf_cur_s=`cat /sys/devices/platform/acpm_mfd_bus@15510000/i2c-1/1-002f/s2mpg15-meter/s2mpg15-odpm/iio:device1/lpf_current`
346
347lpf_cur_main=(${lpf_cur_m/\\n/;})
348lpf_cur_sub=(${lpf_cur_s/\\n/;})
349
350IFS_PRE=$IFS
351IFS=$'\n'
352lt_a=($lt)
353bt_a=($bt)
354gt_a=($gt)
355IFS=$IFS_PRE
356
357
358for f in `ls /sys/devices/virtual/pmic/mitigation/main_pwrwarn/*`
359do
360  count=`cat $f`
361  a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/main_pwrwarn\//}
362  s=${a/main_pwrwarn_threshold/}
363  arr=(${count//=/ })
364  code=${arr[0]}
365  threshold=${arr[1]}
366  main_array[$s]="$code\t$threshold"
367done
368
369i=1
370main_current=()
371for f in "${main_array[@]}"
372do
373  idx=$i
374  idx2=$idx+1
375  main_current+=(${lpf_cur_main[$idx2]})
376  i=$i+2
377done
378
379for f in `ls /sys/devices/virtual/pmic/mitigation/sub_pwrwarn/*`
380do
381  count=`cat $f`
382  a=${f/\/sys\/devices\/virtual\/pmic\/mitigation\/sub_pwrwarn\//}
383  s=${a/sub_pwrwarn_threshold/}
384  arr=(${count//=/ })
385  code=${arr[0]};
386  threshold=${arr[1]};
387  sub_array[$s]="$code\t$threshold"
388done
389i=1
390sub_current=()
391for f in "${sub_array[@]}"
392do
393  idx=$i
394  idx2=$idx+1
395  sub_current+=(${lpf_cur_sub[$idx2]})
396  i=$i+2
397done
398
399rows=${#lt_a[@]}
400for i in `seq 0 $rows`
401do
402  n="${lt_a[i]%:*}"
403  l="${lt_a[i]#*": "}"
404  b="${bt_a[i]#*": "}"
405  g="${gt_a[i]#*": "}"
406  if [ $i -lt 9 ]
407  then
408    echo "$n     \t\t$l\t\t$b\t\t\t$g"
409  elif [ $i -ge 9 ] && [ $i -lt 21 ]
410  then
411    j=$i-9
412    thresh="${main_array[j]}"
413    current="${main_current[j]}"
414    echo "$n     \t$l\t\t$b\t\t\t$g\t\t$thresh      \t\t$current"
415  else
416    j=$i-21
417    thresh="${sub_array[j]}"
418    current="${sub_current[j]}"
419    echo "$n     \t$l\t\t$b\t\t\t$g\t\t$thresh      \t\t$current"
420  fi
421done
422