DelayVal=30 IterationCnt=1 if [ -d "/sys/firmware/devicetree/base/firmware/zynqmp-firmware" ]; then Interface="zynqmp" echo "ZynqMP interface" PGGS_INTERFACE=/sys/firmware/zynqmp/pggs3 # Disable active wakeups echo disabled > /sys/devices/platform/amba/ffa60000.rtc/power/wakeup echo disabled > /sys/devices/platform/amba/ff000000.serial/power/wakeup echo disabled > /sys/devices/platform/amba/ff010000.serial/power/wakeup echo disabled > /sys/devices/platform/amba/ff0a0000.gpio/power/wakeup else Interface="versal" echo "Versal interface" PGGS_INTERFACE=/sys/firmware/zynqmp/pggs0 # Disable active wakeups echo disabled > /sys/devices/platform/amba/f12a0000.rtc/power/wakeup echo disabled > /sys/devices/platform/amba/ff0b0000.gpio/power/wakeup echo disabled > /sys/devices/platform/amba/f1020000.gpio/power/wakeup fi # Get higher and lower APU frequencies freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies) IFS=' ' # space is set as delimiter read -ra freq_list <<< "$freq" freq_cnt=${#freq_list[@]} low_freq=${freq_list[0]} high_freq=${freq_list[$freq_cnt - 1]} printf "Setting all APU frequency to ${high_freq}\n\n" echo ${high_freq} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed echo ${high_freq} > /sys/devices/system/cpu/cpu1/cpufreq/scaling_setspeed if [ $Interface == "zynqmp" ]; then echo ${high_freq} > /sys/devices/system/cpu/cpu2/cpufreq/scaling_setspeed echo ${high_freq} > /sys/devices/system/cpu/cpu3/cpufreq/scaling_setspeed fi yes > /dev/null & yes > /dev/null & if [ $Interface == "zynqmp" ]; then yes > /dev/null & yes > /dev/null & fi if [ $Interface == "zynqmp" ]; then echo "Latency to Power OFF PL domain" echo 0xFF 0x11 > ${PGGS_INTERFACE} fi echo "*********************** APU, RPU full load ***************************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} killall yes echo "*********************** APU Linux Idle, RPU full load ****************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} printf "\nLatency to Power OFF APU1 core\n" time echo 0 > /sys/devices/system/cpu/cpu1/online printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} if [ $Interface == "zynqmp" ]; then printf "\nLatency to Power OFF APU2 core\n" time echo 0 > /sys/devices/system/cpu/cpu2/online printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} printf "\nLatency to Power OFF APU3 core\n" time echo 0 > /sys/devices/system/cpu/cpu3/online printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} fi echo "************ APU Linux Idle (APU0 only), RPU full load ****************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} printf "Setting APU0 frequency to ${low_freq}\n" echo ${low_freq} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed echo "********** APU Linux Idle (APU0 low freq), RPU full load **************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} # Disable console suspend echo 0 > /sys/module/printk/parameters/console_suspend # Clear the PGGS register first echo 0xFFFFFFFF 0x0 > ${PGGS_INTERFACE} # Set the Delay between 2 power modes val=$(printf '%x\n' $(($DelayVal<<16))) echo 0x00FF0000 $val > ${PGGS_INTERFACE} # Set number of iterations for Latency measurement val=$(printf '%x\n' $(($IterationCnt<<24))) echo 0xFF000000 $val > ${PGGS_INTERFACE} echo "Sending sync command" echo 0xFF 0xA5 > ${PGGS_INTERFACE} while : do ggs_val=$(cat ${PGGS_INTERFACE}) ggs=$(( $ggs_val & 0xFF00 )) usleep 100 if [ $ggs == $((0xaa00)) ] then echo "Sending sync command" echo 0xFF 0xA5 > ${PGGS_INTERFACE} echo 0xFF00 0x00 > ${PGGS_INTERFACE} elif [ $ggs == $((0x5500)) ] then echo 0xFF 0xA5 > ${PGGS_INTERFACE} echo 0xFF00 0x00 > ${PGGS_INTERFACE} sleep 5 echo "Completed successfully" break fi done echo "*********************** APU Linux Idle(APU0 low freq), RPU full load ****************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} printf "\nLatency to Power ON APU1 core\n" time echo 1 > /sys/devices/system/cpu/cpu1/online printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} if [ $Interface == "zynqmp" ]; then printf "\nLatency to Power ON APU2 core\n" time echo 1 > /sys/devices/system/cpu/cpu2/online printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} printf "\nLatency to Power ON APU3 core\n" time echo 1 > /sys/devices/system/cpu/cpu3/online printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} fi echo "*********************** APU Linux Idle(all APU low freq), RPU full load ****************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} printf "Setting all APU frequency to ${high_freq}\n\n" echo ${high_freq} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed echo ${high_freq} > /sys/devices/system/cpu/cpu1/cpufreq/scaling_setspeed if [ $Interface == "zynqmp" ]; then echo ${high_freq} > /sys/devices/system/cpu/cpu2/cpufreq/scaling_setspeed echo ${high_freq} > /sys/devices/system/cpu/cpu3/cpufreq/scaling_setspeed fi echo "*********************** APU Linux Idle(all APU high freq), RPU full load ****************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} yes > /dev/null & yes > /dev/null & if [ $Interface == "zynqmp" ]; then yes > /dev/null & yes > /dev/null & fi echo "*********************** APU, RPU full load **********************" printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} if [ $Interface == "zynqmp" ]; then echo "Latency to Power ON PL domain" echo 0xFF 0x12 > ${PGGS_INTERFACE} fi printf "Delay ${DelayVal} seconds\n\n" sleep ${DelayVal} killall yes printf "Demo application is completed successfully!"