目录
1. clk设备树定义
2. Clock providers
3. clock consumers
4. fixed clock device node
内核中的说明文档Documentation/devicetree/bindings/clock/clock-bindings.txt
#clock-cells: 必要属性,若属性值为0,表示provider就提供一个clock output输出,若属性值为1,表示provider就提供多个clock output输出。
clock-output-names: 可选属性,表示clock output的名字,#clock-cells定义为1后,provider虽然提供多个clock output,但不一定都在clock-output-names中列出每一个clock output名字。clock consumer节点不能直接使用provider的clock-output-names属性。
For example: oscillator { #clock-cells = <1>; clock-output-names = "ckil", "ckih"; }; this node defines a device with two clock outputs, the first named "ckil" and the second named "ckih". Consumer nodes always reference clocks by index. The names should reflect(表明) the clock output signal names for the device.clock-indices:
clock-indices: If the identifying number for the clocks in the node is not linear from zero, then this allows the mapping of identifiers into the clock-output-names array. For example, if we have two clocks <&oscillator 1> and <&oscillator 3>: oscillator { compatible = "myclocktype"; #clock-cells = <1>; clock-indices = <1>, <3>; clock-output-names = "clka", "clkb"; } This ensures we do not have any empty strings in clock-output-namesclocks: 必要属性,List of phandle and clock specifier pairs, one pair for each clock input to the device. Note: if the clock provider specifies '0' for #clock-cells, then only the phandle portion of the pair will appear.
clock-names: 可选属性,List of clock input name strings sorted in the same order as the clocks property. Consumers drivers will use clock-names to match clock input names with clocks specifiers.
clock-ranges: 可选属性, Empty property indicating that child nodes can inherit named clocks from this node. Useful for bus nodes to provide a clock to their children.
For example: device { clocks = <&osc 1>, <&ref 0>; clock-names = "baud", "register"; }; This represents a device with two clock inputs, named "baud" and "register". The baud clock is connected to output 1 of the &osc device, and the register clock is connected to output 0 of the &ref. ==Example== /* external oscillator */ osc: oscillator { compatible = "fixed-clock"; #clock-cells = <1>; clock-frequency = <32678>; clock-output-names = "osc"; }; /* phase-locked-loop device, generates a higher frequency clock * from the external oscillator reference */ pll: pll@4c000 { compatible = "vendor,some-pll-interface" #clock-cells = <1>; clocks = <&osc 0>; clock-names = "ref"; reg = <0x4c000 0x1000>; clock-output-names = "pll", "pll-switched"; }; /* UART, using the low frequency oscillator for the baud clock, * and the high frequency switched PLL output for register * clocking */ uart@a000 { compatible = "fsl,imx-uart"; reg = <0xa000 0x1000>; interrupts = <33>; clocks = <&osc 0>, <&pll 1>; clock-names = "baud", "register"; }; This DT fragment defines three devices: an external oscillator to provide a low-frequency reference clock, a PLL device to generate a higher frequency clock signal, and a UART. * The oscillator is fixed-frequency, and provides one clock output, named "osc". * The PLL is both a clock provider and a clock consumer. It uses the clock signal generated by the external oscillator, and provides two output signals ("pll" and "pll-switched"). * The UART has its baud clock connected the external oscillator and its register clock connected to the PLL clock (the "pll-switched" signal)内核中的说明文档Documentation/devicetree/bindings/clock/fixed-clock.txt
Required properties: - compatible : shall be "fixed-clock". - #clock-cells : from common clock binding; shall be set to 0. - clock-frequency : frequency of clock in Hz. Should be a single cell. Optional properties: - clock-accuracy : accuracy(准确性) of clock in ppb (parts per billion). Should be a single cell. - clock-output-names : From common clock binding. Example: clock { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <1000000000>; clock-accuracy = <100>; }; ~