blob: 132205aff9bc5dbed792cd6974225efa427af1e5 [file] [log] [blame]
Matt Spinlerd4cf3a32016-12-20 10:59:13 -06001#!/bin/sh
2
3i2cset -y 4 0x12 0x2E 0x23 b # VDD/VCS 0
4i2cset -y 4 0x13 0x2E 0x23 b # VDN 0
5i2cset -y 5 0x12 0x2E 0x23 b # VDD/VCS 1
6i2cset -y 5 0x13 0x2E 0x23 b # VDN 1
7
Andrew Geissler7e9e9f02017-07-28 15:55:06 -05008# A side VDDR - set to 1.23V
9i2cset -y 4 0x71 0x00 0x01
10i2cset -y 4 0x71 0x21 0x3B 0x01 i
11i2cset -y 4 0x71 0x00 0x00
12
13# B side VDDR - set to 1.23V
14i2cset -y 5 0x71 0x00 0x01
15i2cset -y 5 0x71 0x21 0x3B 0x01 i
16i2cset -y 5 0x71 0x00 0x00
Andrew Geissler7e1ed0c2017-07-28 16:07:27 -050017
18# VDN A - PGOOD_ON threshold
19i2cset -y 4 0x71 0x00 0x00 b # PAGE
20i2cset -y 4 0x71 0x5E 0xCD 0x00 i # set to 0.8V
21
22# VDN B - PGOOD_ON threshold
23i2cset -y 5 0x71 0x00 0x00 b # PAGE
24i2cset -y 5 0x71 0x5E 0xCD 0x00 i # set to 0.8V
Andrew Geissler2bba0b82017-08-07 16:26:39 -050025
26# unbind ucd driver to permit i2cset
27ucd_retries=5
28ucd=
29
30ucdpath="/sys/bus/i2c/drivers/ucd9000"
31if [ -e $ucdpath ]
32then
33 ucd=`ls -1 $ucdpath | grep 64`
34 if [ -n "$ucd" ]
35 then
36 echo $ucd > $ucdpath/unbind
37 fi
38fi
39
40# Raise AVDD +100mV
41i2cset -y 11 0x64 0x00 0x09 i # set PAGE
42i2cset -y 11 0x64 0xF5 0x81 i # set margin_config
43i2cset -y 11 0x64 0x21 0x85 0x33 i # set VOUT_COMMAND
44
Andrew Geisslerff44a262017-10-02 10:46:42 -050045# Increase over-current settings
46#VDD A phase current
47i2cset -y 4 0x12 0xFF 0x04 b # set window register high byte to 4
48i2cset -y 4 0x12 0x3C 0xFF b # Disable
49#VDD B phase current
50i2cset -y 5 0x12 0xFF 0x04 b # set window register high byte to 4
51i2cset -y 5 0x12 0x3C 0xFF b # Disable
52#VDD A master OC fault to 445A
53i2cset -y 4 0x70 0x00 0x00 b # PAGE
54i2cset -y 4 0x70 0x46 0x08DE w
55# VDD A master OC warn to 384A
56i2cset -y 4 0x70 0x4A 0x08C0 w
57#VDD B master OC fault to 445A
58i2cset -y 5 0x70 0x00 0x00 b # PAGE
59i2cset -y 5 0x70 0x46 0x08DE w
60# VDD B master OC warn to 384A
61i2cset -y 5 0x70 0x4A 0x08C0 w
62
Andrew Geissler2bba0b82017-08-07 16:26:39 -050063# re-bind ucd driver only if we unbound it (i.e. ucd has been set with a value)
64if [ -e $ucdpath -a -n "$ucd" ]; then
65 j=0
66 until [ $j -ge $ucd_retries ] || [ -e $ucdpath/$ucd ]; do
67 j=$((j+1))
68 echo $ucd > $ucdpath/bind || ret=$?
69 if [ $j -gt 1 ]; then
70 echo "rebinding UCD driver. Retry number $j"
71 sleep 1
72 fi
73 done
74 if [ ! -e $ucdpath/$ucd ]; then exit $ret; fi
75fi