Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
set -e
write_to () {
echo $2 | sudo tee $1 > /dev/null
set_rate () {
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)
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
exit 1
set_rate $CLK $FREQ

This comment has been minimized.

Copy link

@ghost ghost 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:
Any comments are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment