Created
March 16, 2016 10:41
-
-
Save Kirill888/24385a36697959924d78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
write_to () { | |
echo $2 | sudo tee $1 > /dev/null | |
} | |
set_rate () { | |
c=fclk$1 | |
rate=$2 | |
d=$(readlink -f "/sys/class/xdevcfg/xdevcfg/device") | |
[ -d $d/fclk/$c ] || write_to $d/fclk_export $c | |
write_to $d/fclk/$c/enable 1 | |
write_to $d/fclk/$c/set_rate $rate | |
echo "Set clock $c to " $(cat $d/fclk/$c/set_rate) | |
} | |
CLK=$1 | |
FREQ=$2 | |
if [ -z $CLK ] || [ -z $FREQ ]; then | |
cat <<EOL | |
Usage: $0 clk freq | |
clk -- Which clock to change 0,1,2 or 3 | |
freq -- Desired frequency in Hz | |
EOL | |
exit 1 | |
fi | |
set_rate $CLK $FREQ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not entirely related but our current system in development lacks xdevcfg drivers since we replaced it with fpga manager for programming fpga using device tree overlays. For setting clocks I patched fclk driver from staging to be able to set clocks as well. Patched file is available at: https://github.com/RedPitaya/linux-xlnx/blob/branch-redpitaya-v2017.1--rebase-xilinx-v2017.1/drivers/staging/fclk/xilinx_fclk.c
Any comments are welcome.