1#!/bin/sh 2 3# ensure VCS ON_OFF_CONFIG set correctly from prior FW drivers 4# A side 5i2cset -y 4 0x70 0x00 0x01 b 6i2cset -y 4 0x70 0x02 0x16 b #respond to ENABLE pin 7i2cset -y 4 0x70 0x00 0x00 b 8# B side 9i2cset -y 5 0x70 0x00 0x01 b 10i2cset -y 5 0x70 0x02 0x16 b #respond to ENABLE pin 11i2cset -y 5 0x70 0x00 0x00 b 12 13# vddio = 1.0V, mdat/sdat PU enabled 14i2cset -y 4 0x12 0xFF 0x00 b # VDD/VCS 0 15i2cset -y 4 0x12 0x2E 0x03 b # VDD/VCS 0 16i2cset -y 4 0x13 0xFF 0x00 b # VDN 0 17i2cset -y 4 0x13 0x2E 0x03 b # VDN 0 18i2cset -y 5 0x12 0xFF 0x00 b # VDD/VCS 1 19i2cset -y 5 0x12 0x2E 0x03 b # VDD/VCS 1 20i2cset -y 5 0x13 0xFF 0x00 b # VDN 1 21i2cset -y 5 0x13 0x2E 0x03 b # VDN 1 22 23# A side VDDR - set to 1.23V 24i2cset -y 4 0x71 0x00 0x01 25i2cset -y 4 0x71 0x21 0x3B 0x01 i 26i2cset -y 4 0x71 0x00 0x00 27 28# B side VDDR - set to 1.23V 29i2cset -y 5 0x71 0x00 0x01 30i2cset -y 5 0x71 0x21 0x3B 0x01 i 31i2cset -y 5 0x71 0x00 0x00 32 33# VDN A - PGOOD_ON threshold 34i2cset -y 4 0x71 0x00 0x00 b # PAGE 35i2cset -y 4 0x71 0x5E 0xCD 0x00 i # set to 0.8V 36 37# VDN B - PGOOD_ON threshold 38i2cset -y 5 0x71 0x00 0x00 b # PAGE 39i2cset -y 5 0x71 0x5E 0xCD 0x00 i # set to 0.8V 40 41# unbind ucd driver to permit i2cset 42ucd_retries=5 43ucd= 44 45ucdpath="/sys/bus/i2c/drivers/ucd9000" 46if [ -e $ucdpath ] 47then 48 # shellcheck disable=SC2010 49 ucd=$(ls -1 $ucdpath | grep 64) 50 if [ -n "$ucd" ] 51 then 52 echo "$ucd" > $ucdpath/unbind 53 fi 54fi 55 56# make sure VCS ON_OFF_CONFIG set correctly from old FW releases 57i2cset -y 11 0x64 0x00 0x0E i 58i2cset -y 11 0x64 0x02 0x16 i 59i2cset -y 11 0x64 0x00 0x0F i 60i2cset -y 11 0x64 0x02 0x16 i 61 62## move memory enables to align with VDN (VDN to VDDR leakage issue) 63#GPO_CONFIG_1 (GPIO15) : mem 0 reg enables 64i2cset -y 11 0x64 0xF7 0x00 i 65i2cset -y 11 0x64 0xF8 0x15 0x6E 0x80 0x08 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i 66#GPO_CONFIG_2 (GPIO7) : mem 1 reg enables 67i2cset -y 11 0x64 0xF7 0x01 i 68i2cset -y 11 0x64 0xF8 0x15 0x16 0x80 0x08 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 i 69 70# change VDN delays based on UCD MFR_REVISION setting 71REV=$(i2cget -y 11 0x64 0x9B i 2|cut -f2 -d' ') 72if [ "$REV" = "0x01" ] || [ "$REV" = "0x02" ] ; then 73 # use 20ms delay for VDN 74 #TON_DELAY rail 8 75 i2cset -y 11 0x64 0x00 0x07 i 76 i2cset -y 11 0x64 0x60 0x80 0xDA i 77 #TON_DELAY rail 9 78 i2cset -y 11 0x64 0x00 0x08 i 79 i2cset -y 11 0x64 0x60 0x80 0xDA i 80else 81 # use 70ms delay for VDN 82 #TON_DELAY rail 8 83 i2cset -y 11 0x64 0x00 0x07 i 84 i2cset -y 11 0x64 0x60 0x30 0xEA i 85 #TON_DELAY rail 9 86 i2cset -y 11 0x64 0x00 0x08 i 87 i2cset -y 11 0x64 0x60 0x30 0xEA i 88fi 89 90# Raise AVDD +100mV 91i2cset -y 11 0x64 0x00 0x09 i # set PAGE 92i2cset -y 11 0x64 0xF5 0x81 i # set margin_config 93i2cset -y 11 0x64 0x21 0x85 0x33 i # set VOUT_COMMAND 94 95# Increase over-current settings 96#VDD A phase current 97i2cset -y 4 0x12 0xFF 0x04 b # set window register high byte to 4 98i2cset -y 4 0x12 0x3C 0x80 b # Set to 64A 99#VDD B phase current 100i2cset -y 5 0x12 0xFF 0x04 b # set window register high byte to 4 101i2cset -y 5 0x12 0x3C 0x80 b # Set to 64A 102#VDD A master OC fault to 445A 103i2cset -y 4 0x70 0x00 0x00 b # PAGE 104i2cset -y 4 0x70 0x46 0x08DE w 105# VDD A master OC warn to 326A 106i2cset -y 4 0x70 0x4A 0x08A3 w # A308 107#VDD B master OC fault to 445A 108i2cset -y 5 0x70 0x00 0x00 b # PAGE 109i2cset -y 5 0x70 0x46 0x08DE w 110# VDD B master OC warn to 326A 111i2cset -y 5 0x70 0x4A 0x08A3 w 112#VCS phase current to 30A C/C 113i2cset -y 4 0x12 0xFF 0x08 b # set window register to 8 114i2cset -y 4 0x12 0x3C 0x3C b # 30A 115i2cset -y 5 0x12 0xFF 0x08 b # set window register to 8 116i2cset -y 5 0x12 0x3C 0x3C b # 30A 117#VCS master OC to 43A 118i2cset -y 4 0x70 0x00 0x01 # PAGE 1 119i2cset -y 4 0x70 0x46 0x0816 w # OC to 43A 120i2cset -y 5 0x70 0x00 0x01 # PAGE 1 121i2cset -y 5 0x70 0x46 0x0816 w # OC to 43A 122 123# re-bind ucd driver only if we unbound it (i.e. ucd has been set with a value) 124if [ -e $ucdpath ] && [ -n "$ucd" ]; then 125 j=0 126 until [ $j -ge $ucd_retries ] || [ -e "$ucdpath/$ucd" ]; do 127 j=$((j+1)) 128 # shellcheck disable=2320 129 echo "$ucd" > $ucdpath/bind || ret=$? 130 if [ $j -gt 1 ]; then 131 echo "rebinding UCD driver. Retry number $j" 132 sleep 1 133 fi 134 done 135 if [ ! -e "$ucdpath/$ucd" ]; then exit "$ret"; fi 136fi 137