Zephyr Clocking Wizard Driver Support

This page gives an overview of the Xilinx AXI Clocking Wizard (xlnx,clkx5-wiz-1.0) Zephyr driver.

HW Features

  • Single MMCM/PLL driven from one reference input clock, generating up to seven independent output clocks (xlnx,num-out-clks, 1-7) that share the same VCO.

  • Dynamic reconfiguration of output clock rate at runtime through an AXI4-Lite control interface, without requiring a device reset.

  • Per-output clock enable/disable.

  • MMCM lock-status polling after a reconfiguration request.

Design Notes

  • All output clocks of a given instance share one VCO. When more than one output is active at the same time, requesting a new rate on one output does not change the VCO; it only reprograms that output’s divider against the VCO already locked for the other active outputs.

Implementation

Features Supported

  • clock_control_on / clock_control_off: per-output clock gating, for any of the 1-7 outputs configured in the device tree node.

  • clock_control_set_rate: dynamic MMCM reconfiguration (closest-match M/D/O divisor search) for a single target output frequency.

  • clock_control_get_rate: reads the currently programmed divisors back from hardware and reports the resulting output frequency.

Missing Features

  • clock_control_async_on, clock_control_get_status, and clock_control_configure are not implemented; the driver leaves the .async_on, .get_status, and .configure callbacks NULL in its API table.

Known Issues

  • N/A

Limitations

  • clock_control_set_rate selects the M/D/O divisor combination closest to the requested frequency within the VCO (2.16-4.32 GHz), M (4-432), D (1-123), and O (2-511) ranges supported by the IP; the achieved rate may therefore differ from the requested rate and should be read back with clock_control_get_rate. It returns -EINVAL if no combination exists in range.

  • When another output of the same instance is already active, a rate change on a different output must be exactly reachable by adjusting only that output’s divider against the already-locked VCO; otherwise it returns -EINVAL without changing the current configuration.

Kernel Configuration

CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_CONTROL_XCLK_WIZ=y

Device Tree

clk_wiz_0: clock-controller@b2000000 {
        compatible = "xlnx,clkx5-wiz-1.0";
        reg = <0x0 0xb2000000 0x0 0x10000>;
        clocks = <&ref_clk_100mhz>;
        #clock-cells = <1>;
        xlnx,num-out-clks = <1>;
        status = "okay";
};

Driver Stack Size

  • The driver does not use a dedicated thread or workqueue. All clock_control API calls execute synchronously in the context of the calling thread, serialized by a per-instance mutex and spinlock.

  • Footprint: TBA

Test Platform

  • versal2_apu

  • versal2_rpu

Test SoC Architecture

  • APU - A78 core

  • RPU - R52 core

Testing Sequence

  • Hardware prerequisites: the Clocking Wizard is a PL IP, so no shipped board device tree enables it by default. Without the following, the sample/test report No enabled xlnx,clkx5-wiz-1.0 node found in devicetree.

    • An AMD Versal Gen 2 board (versal2_apu or versal2_rpu, for example VEK385 or equivalent) with a Vivado bitstream that instantiates the Clocking Wizard IP at the base address shown under Device Tree, with a 100 MHz reference clock input.

    • A device tree overlay enabling the clk_wiz_0 node shown under Device Tree, together with its ref_clk_100mhz fixed-clock parent, for example:

      ref_clk_100mhz: ref-clk-100mhz {
              compatible = "fixed-clock";
              #clock-cells = <0>;
              clock-frequency = <100000000>;
      };
      
  • Build zephyr application for R52 or A78 core

    • west build -p -b <board> <sample application path>

  • Run zephyr elf on the APU or RPU.

Example Tests

Test Name

Example Source

Description

Clocking Wizard EA Sample

samples/boards/amd/xclk_wiz/

Exercises clock_control_on/off, set_rate, and get_rate on CLKOUT0, stepping through 100/200/300 MHz target rates.

xlnx_clk_wiz_device, xlnx_clk_wiz_on_off, xlnx_clk_wiz_get_rate, xlnx_clk_wiz_set_rate, xlnx_clk_wiz_roundtrip

tests/drivers/clock_control/xclk_wiz/

Ztest suites covering device readiness, per-output enable/disable (including invalid clock-ID negative cases), get_rate (including invalid clock ID), set_rate at 100/200/300 MHz with negative cases (zero rate, null pointer, invalid clock ID), and set/get-rate round-trip.

Code Coverage

  • Functional: drivers.clock_control.xclk_wiz Ztest suite passes 100% (23/23 tests) on versal2_apu and versal2_rpu.

  • Line/branch coverage percentage: TBA

Expected Output

Clocking Wizard Example

  • west build -p always -b versal2_apu samples/boards/amd/xclk_wiz/

  • Log:

    Clocking Wizard sample application
    Device: clock-controller@b2000000, testing CLKOUT0
    Initial CLKOUT0 rate: 100000000 Hz
    CLKOUT0 enabled (clock_control_on OK)
    Requesting CLKOUT0 = 100000000 Hz ...
    Actual  CLKOUT0 = 100000000 Hz
    Requesting CLKOUT0 = 200000000 Hz ...
    Actual  CLKOUT0 = 200000000 Hz
    Requesting CLKOUT0 = 300000000 Hz ...
    Actual  CLKOUT0 = 300000000 Hz
    CLKOUT0 disabled (clock_control_off OK)
    

Performance Metric

  • TBA

Mainline Status

Driver Source Path

  • drivers/clock_control/clock_control_xclk_wiz.c

Misra C Report

  • Per coding guidelines of zephyr (subset of MISRA-C)

  • TBA