Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
@ghost

This comment has been minimized.

Copy link

commented Aug 14, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.