Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
imx_ccm_rev3.h File Reference

SoC-agnostic clock-specifier encoding for the NXP i.MX CCM rev3. More...

Go to the source code of this file.

Macros

#define IMX_CCM_ID_BITS   16U
 Width of each identifier field, in bits.
#define IMX_CCM_ID_MASK   0xFFFFU
 Mask of a single identifier field.
#define IMX_CCM_GATE_SHIFT   0U
 Bit position of the gate identifier within a clock specifier.
#define IMX_CCM_ROOT_SHIFT   16U
 Bit position of the clock-root identifier within a clock specifier.
#define IMX_CCM_GATE_NONE   IMX_CCM_ID_MASK
 This peripheral has no clock gate of its own.
#define IMX_CCM_ROOT_NONE   IMX_CCM_ID_MASK
 This peripheral has no dedicated clock root, so its rate is unknown.
#define IMX_CCM_CLK(gate, root)
 Compose a peripheral clock specifier from a gate and a clock root.
#define IMX_CCM_CLK_GATE(spec)
 Extract the gate identifier from a clock specifier.
#define IMX_CCM_CLK_ROOT(spec)
 Extract the clock-root identifier from a clock specifier.
Per-device clock-root configuration cell

A peripheral that wants to own its clock root's mux/divider settings – rather than inherit a fixed root programmed by SoC clock init – adds a SECOND entry to its clocks property, named "source" in clock-names, following the established Zephyr clock-binding idiom of a second "source-select" clocks entry beyond the gate (clocks = <&ctlr GATE>, <&ctlr SRC SEL>;).

That entry is a single packed IMX_CCM_ROOT_CFG cell. The IP driver reads it and passes it verbatim, by value, as the clock_control_configure() subsystem argument (data NULL); the rev3 controller unpacks it and issues one CLOCK_SetRootClock.

The cell must be distinguishable from a legacy IMX_CCM_CLK gate cell, because the shared drivers also pass the gate cell to clock_control_configure() (the pre-existing tolerant call). A gate cell fills all 32 bits with two 16-bit ids; its top nibble is the clock-root id's high nibble, which is 0 for every real root (max id 217) and 0xF only for IMX_CCM_ROOT_NONE. A root-config cell uses the low 28 bits for its fields and stamps a fixed 0xA tag into the top nibble – a value a gate cell can never produce – so IMX_CCM_ROOT_CFG_IS() tells the two kinds apart by construction.

Field widths: root 8 bits (max id 217), mux 4 bits (max 3), div 8 bits, snd_div 8 bits = 28 bits, verified sufficient for all RT2660 peripheral roots. A divider value of 0 is illegal: the HAL programs value - 1, so 0 would reach the register as an all-ones field (slowest divide). Divide-by-one is 1.

#define IMX_CCM_ROOT_CFG_ROOT_SHIFT   0U
 Bit position of the root id within a root-config cell.
#define IMX_CCM_ROOT_CFG_MUX_SHIFT   8U
 Bit position of the mux selector within a root-config cell.
#define IMX_CCM_ROOT_CFG_DIV_SHIFT   12U
 Bit position of the primary divider within a root-config cell.
#define IMX_CCM_ROOT_CFG_SND_DIV_SHIFT   20U
 Bit position of the secondary divider within a root-config cell.
#define IMX_CCM_ROOT_CFG_TAG_SHIFT   28U
 Bit position of the discriminator tag within a root-config cell.
#define IMX_CCM_ROOT_CFG_ROOT_MASK   0xFFU
 Field masks (before shifting).
#define IMX_CCM_ROOT_CFG_MUX_MASK   0xFU
#define IMX_CCM_ROOT_CFG_DIV_MASK   0xFFU
#define IMX_CCM_ROOT_CFG_SND_DIV_MASK   0xFFU
#define IMX_CCM_ROOT_CFG_TAG_MASK   0xFU
#define IMX_CCM_ROOT_CFG_TAG   0xAU
 Tag value stamped into the top nibble to mark a root-config cell.
#define IMX_CCM_ROOT_CFG(root, mux, div, snd_div)
 Compose a per-device clock-root configuration specifier.
#define IMX_CCM_ROOT_CFG_IS(cell)
 True if cell is a root-config cell (not a legacy gate cell).
#define IMX_CCM_ROOT_CFG_ROOT(cell)
 Extract the root id from a root-config cell.
#define IMX_CCM_ROOT_CFG_MUX(cell)
 Extract the mux selector from a root-config cell.
#define IMX_CCM_ROOT_CFG_DIV(cell)
 Extract the primary divider from a root-config cell.
#define IMX_CCM_ROOT_CFG_SND_DIV(cell)
 Extract the secondary divider from a root-config cell.

Detailed Description

SoC-agnostic clock-specifier encoding for the NXP i.MX CCM rev3.

The i.MX CCM as used by the recent i.MX RT parts models a peripheral's clock as two independent things:

  • a gate (LPCG), which turns the peripheral's bus and functional clocks on and off, and
  • a clock root, whose mux and divider settings determine the frequency the peripheral actually receives.

There is no algorithmic relation between the two identifier spaces, so both have to reach the clock driver. The shared NXP peripheral drivers read a single clock cell – DT_INST_CLOCKS_CELL(n, name) – and pass that one value to clock_control_on(), clock_control_get_rate(), and clock_control_configure() alike, so a second devicetree cell would be invisible to them. Both identifiers are therefore packed into the one cell:

clocks = <&ccm IMX_CCM_CLK(<gate-id>, <root-id>)>;

Packing two identifiers into one cell is how nxp,imx-ccm-rev2 already encodes its peripheral and instance numbers.

Use IMX_CCM_GATE_NONE for a peripheral that has no gate of its own, and IMX_CCM_ROOT_NONE for one with no dedicated clock root – asking such a peripheral for its rate yields -ENOTSUP rather than a fabricated number.

The identifier values themselves are SoC-specific and generated into the hal_nxp module beside the fsl_clock.h they are derived from, for example <nxp/imxrt/imxrt266x/clock/imx_ccm_rev3_rt266x.h>.

Macro Definition Documentation

◆ IMX_CCM_CLK

#define IMX_CCM_CLK ( gate,
root )
Value:
((((root) & IMX_CCM_ID_MASK) << IMX_CCM_ROOT_SHIFT) | \
#define IMX_CCM_GATE_SHIFT
Bit position of the gate identifier within a clock specifier.
Definition imx_ccm_rev3.h:51
#define IMX_CCM_ID_MASK
Mask of a single identifier field.
Definition imx_ccm_rev3.h:48
#define IMX_CCM_ROOT_SHIFT
Bit position of the clock-root identifier within a clock specifier.
Definition imx_ccm_rev3.h:53

Compose a peripheral clock specifier from a gate and a clock root.

Parameters
gateGate (LPCG) identifier, or IMX_CCM_GATE_NONE.
rootClock-root identifier, or IMX_CCM_ROOT_NONE.

◆ IMX_CCM_CLK_GATE

#define IMX_CCM_CLK_GATE ( spec)
Value:

Extract the gate identifier from a clock specifier.

◆ IMX_CCM_CLK_ROOT

#define IMX_CCM_CLK_ROOT ( spec)
Value:

Extract the clock-root identifier from a clock specifier.

◆ IMX_CCM_GATE_NONE

#define IMX_CCM_GATE_NONE   IMX_CCM_ID_MASK

This peripheral has no clock gate of its own.

◆ IMX_CCM_GATE_SHIFT

#define IMX_CCM_GATE_SHIFT   0U

Bit position of the gate identifier within a clock specifier.

◆ IMX_CCM_ID_BITS

#define IMX_CCM_ID_BITS   16U

Width of each identifier field, in bits.

◆ IMX_CCM_ID_MASK

#define IMX_CCM_ID_MASK   0xFFFFU

Mask of a single identifier field.

◆ IMX_CCM_ROOT_CFG

#define IMX_CCM_ROOT_CFG ( root,
mux,
div,
snd_div )
Value:
#define IMX_CCM_ROOT_CFG_DIV_MASK
Definition imx_ccm_rev3.h:119
#define IMX_CCM_ROOT_CFG_TAG
Tag value stamped into the top nibble to mark a root-config cell.
Definition imx_ccm_rev3.h:124
#define IMX_CCM_ROOT_CFG_MUX_MASK
Definition imx_ccm_rev3.h:118
#define IMX_CCM_ROOT_CFG_ROOT_MASK
Field masks (before shifting).
Definition imx_ccm_rev3.h:117
#define IMX_CCM_ROOT_CFG_SND_DIV_SHIFT
Bit position of the secondary divider within a root-config cell.
Definition imx_ccm_rev3.h:112
#define IMX_CCM_ROOT_CFG_DIV_SHIFT
Bit position of the primary divider within a root-config cell.
Definition imx_ccm_rev3.h:110
#define IMX_CCM_ROOT_CFG_TAG_SHIFT
Bit position of the discriminator tag within a root-config cell.
Definition imx_ccm_rev3.h:114
#define IMX_CCM_ROOT_CFG_ROOT_SHIFT
Bit position of the root id within a root-config cell.
Definition imx_ccm_rev3.h:106
#define IMX_CCM_ROOT_CFG_MUX_SHIFT
Bit position of the mux selector within a root-config cell.
Definition imx_ccm_rev3.h:108
#define IMX_CCM_ROOT_CFG_SND_DIV_MASK
Definition imx_ccm_rev3.h:120

Compose a per-device clock-root configuration specifier.

Parameters
rootClock-root identifier whose mux/dividers to program.
muxRoot mux selector (which already-running upstream source).
divPrimary root divider (1 = divide-by-one; 0 is illegal).
snd_divSecondary root divider (1 = divide-by-one; 0 is illegal).

◆ IMX_CCM_ROOT_CFG_DIV

#define IMX_CCM_ROOT_CFG_DIV ( cell)
Value:

Extract the primary divider from a root-config cell.

◆ IMX_CCM_ROOT_CFG_DIV_MASK

#define IMX_CCM_ROOT_CFG_DIV_MASK   0xFFU

◆ IMX_CCM_ROOT_CFG_DIV_SHIFT

#define IMX_CCM_ROOT_CFG_DIV_SHIFT   12U

Bit position of the primary divider within a root-config cell.

◆ IMX_CCM_ROOT_CFG_IS

#define IMX_CCM_ROOT_CFG_IS ( cell)
Value:
#define IMX_CCM_ROOT_CFG_TAG_MASK
Definition imx_ccm_rev3.h:121

True if cell is a root-config cell (not a legacy gate cell).

◆ IMX_CCM_ROOT_CFG_MUX

#define IMX_CCM_ROOT_CFG_MUX ( cell)
Value:

Extract the mux selector from a root-config cell.

◆ IMX_CCM_ROOT_CFG_MUX_MASK

#define IMX_CCM_ROOT_CFG_MUX_MASK   0xFU

◆ IMX_CCM_ROOT_CFG_MUX_SHIFT

#define IMX_CCM_ROOT_CFG_MUX_SHIFT   8U

Bit position of the mux selector within a root-config cell.

◆ IMX_CCM_ROOT_CFG_ROOT

#define IMX_CCM_ROOT_CFG_ROOT ( cell)
Value:

Extract the root id from a root-config cell.

◆ IMX_CCM_ROOT_CFG_ROOT_MASK

#define IMX_CCM_ROOT_CFG_ROOT_MASK   0xFFU

Field masks (before shifting).

◆ IMX_CCM_ROOT_CFG_ROOT_SHIFT

#define IMX_CCM_ROOT_CFG_ROOT_SHIFT   0U

Bit position of the root id within a root-config cell.

◆ IMX_CCM_ROOT_CFG_SND_DIV

#define IMX_CCM_ROOT_CFG_SND_DIV ( cell)
Value:

Extract the secondary divider from a root-config cell.

◆ IMX_CCM_ROOT_CFG_SND_DIV_MASK

#define IMX_CCM_ROOT_CFG_SND_DIV_MASK   0xFFU

◆ IMX_CCM_ROOT_CFG_SND_DIV_SHIFT

#define IMX_CCM_ROOT_CFG_SND_DIV_SHIFT   20U

Bit position of the secondary divider within a root-config cell.

◆ IMX_CCM_ROOT_CFG_TAG

#define IMX_CCM_ROOT_CFG_TAG   0xAU

Tag value stamped into the top nibble to mark a root-config cell.

◆ IMX_CCM_ROOT_CFG_TAG_MASK

#define IMX_CCM_ROOT_CFG_TAG_MASK   0xFU

◆ IMX_CCM_ROOT_CFG_TAG_SHIFT

#define IMX_CCM_ROOT_CFG_TAG_SHIFT   28U

Bit position of the discriminator tag within a root-config cell.

◆ IMX_CCM_ROOT_NONE

#define IMX_CCM_ROOT_NONE   IMX_CCM_ID_MASK

This peripheral has no dedicated clock root, so its rate is unknown.

◆ IMX_CCM_ROOT_SHIFT

#define IMX_CCM_ROOT_SHIFT   16U

Bit position of the clock-root identifier within a clock specifier.