CCM Clock Gates, Pad Mux Modes, and SION
Understand from silicon physics why peripherals sit behind two-bit CCM clock gates (CCGR0..CCGR6) and per-ball IOMUXC crossbar multiplexers, what SION bit 4 and SELECT_INPUT daisy chains actually wire inside the I/O ring, and how to update each field without disturbing neighbors.
What you'll learn
- Locate CCGR0–CCGR6 fields without enabling every peripheral.
- Derive a legal pad mux value from the selected pad's function table.
- Explain what SION forces and what it does not connect.
Why SoCs Gate Peripheral Clocks and Multiplex Package Balls
Why can't you just write *gpio1_dr = 0 immediately after reset and watch GPIO1_IO03 pull low? Two physical constraints of modern CMOS silicon stand between a peripheral register and a package pin, both mapped in Figure 3.1a:
- Dynamic Switching Power &
CCM_CCGR0..CCGR6Clock Gates (0x020C4068..0x020C4080): Every CMOS flip-flop burns dynamic power proportional to capacitance, voltage squared, and clock frequency (P = C * V^2 * f). Ani.MX6ULLintegrates over50peripheral blocks (UART1..8,I2C1..4,SPI1..4,GPIO1..5,USDHC1..2,ENET1..2,CAN1..2). Clocking all of them continuously would waste power in battery and industrial gateways, so the Clock Control Module (CCM) places16two-bit Clock Gate (CG0..CG15) latches inside each of the seven32-bitCCGR0..CCGR6words (00= clock off,01= clock on inRUNmode only,10= reserved,11= clock on inRUNandWAITlow-power idle). Crucially, if a peripheral'sCGfield is00, its internalIPGbus interface flip-flops receive zero clock edges—so reading or writing its registers either hangs/aborts on the bus or drops your write silently! Resist the tutorial anti-pattern of blasting0xFFFFFFFFUintoCCGR0..CCGR6: update only the2-bitCGslot you own so power policy and missing-clock bugs remain diagnosable. - BGA Pin Scarcity &
IOMUXCAlternate-Function Crossbars (0x020E0000+): A14 x 14 mmi.MX6ULLpackage has roughly100+general I/O balls, yet its internal peripherals expose over600distinct I/O signals! Silicon solves this by placing an I/O Multiplexer (IOMUXC_SW_MUX_CTL_PAD_*) behind each package ball. Each ball physically wires only a small subset ofALT0..ALT8functions (for ballGPIO1_IO03,ALT0=I2C1_SDA,ALT5=GPIO1_IO03, etc.—not everyALTnumber0..8exists on every ball!). UntilMUX_MODE[3:0]selectsALT5(5),GPIO1's data latch can toggle all day while the physical ball remains connected toI2C1orUART!
Figure 3.1a. End-to-end silicon signal graph — CCM clock gate (CG13), peripheral block, MUX_MODE + SION loopback, and SELECT_INPUT daisy routing.
mental model: Driving a package ball requires both powering the pump (CCM_CCGR clock gate) and turning the manifold selector (IOMUXC MUX_MODE): running an unrouted peripheral or routing an unclocked peripheral leaves the external pin dead.
Where it stops working: Unlike plumbing valves, reading or writing a clock-gated peripheral register can stall or fault on the internal IPG bus immediately, and forcing SION=1 only activates that ball's input buffer rather than wiring arbitrary peripherals together.
definition (CCM Clock Gates (CCGR0..6), IOMUXC MUX_MODE, SION & SELECT_INPUT): CCM_CCGR0..CCGR6 (0x020C4068..0x020C4080) divide each 32-bit word into 16 two-bit CGk fields (bits [2k+1 : 2k]; GPIO1 is CCGR1 CG13 at [27:26]). Per-ball IOMUXC_SW_MUX_CTL_PAD_* (0x020E0068 for GPIO1_IO03) selects one of that pad's implemented functions in MUX_MODE[3:0] (ALT5 = 5 for GPIO1_IO03) and provides SION (bit 4, 0x10), which forces that ball's input receiver path active even when an output function drives the pin. When multiple balls can feed one peripheral input (UART_RX, I2C_SDA), a separate *_SELECT_INPUT (DAISY) register selects which ball reaches the receiver.
Step through the four hardware dependencies in order before writing register code:
- Step 1. Step 1 (CCM Policy): Update only CCGR1[27:26] = 0b11 (mask 0x0C000000) and issue DSB SY before touching GPIO1.
- Step 2. Step 2 (Pad Function Table): Confirm the exact ball implements the target ALT mode (not all pads implement ALT0..ALT8).
- Step 3. Step 3 (Mux Register): Replace MUX_MODE[3:0] + SION[4] via (*mux & ~0x1FU); set SION=1 only when output pad readback is needed.
- Step 4. Step 4 (Observable Pad): Program SELECT_INPUT DAISY for shared RX inputs, then configure pad electricals and GPIO direction.
Figure 3.1b. Enable the peripheral clock first, then select a pad-supported ALT mode, SION policy, and SELECT_INPUT daisy source.
What SION and Daisy-Chain Input Muxes Physically Connect
Demystify two IOMUXC features that trip up experienced engineers—both drawn in Figure 3.1a and bit-mapped in Figure 3.1b:
- What
SION(Software Input On,bit 4) Does—and Does Not—Do: Inside every bidirectional pad cell sit two buffers: an output tri-state driver (peripheral -> ball) and an input receiver (ball -> peripheral). When a peripheral drives an output, hardware normally turns off the input feedback path unless that protocol expects it. SettingSION = 1(0x15=SION | ALT5) forces that single ball's input receiver ON, lettingGPIO1_PSRobserve actual wire voltage while driving an output or letting anI2Ccontroller monitor open-drain bus arbitration!SIONis not a magic internal wire connectingUART1_TXtoSPI2_RX; it only enables input sampling of that physical ball. - Why
SELECT_INPUT(DAISY) Exists: An output mux (1ball choosing among8peripherals) lives at the ball. What about an input signal likeUART1_RX_DATAthati.MX6ULLallows you to wire to2or4different package balls? TheUART1receiver needs its ownN-to-1multiplexer (IOMUXC_UART1_RX_DATA_SELECT_INPUT) whoseDAISYbits tellUART1which ball to listen to! ForgettingSELECT_INPUTleavesTXworking whileRXlistens to an unconnected pin.
Figure 3.1b. Exact 32-bit bitfields for CCM_CCGR1 (top) and IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO03 + SELECT_INPUT (bottom).
Trace gpio1_clock_and_mux in target.S below: first it updates CCM_CCGR1 (0x020C406C) bits [27:26] (3 << 26 = 0x0C000000) via bic + orr and drains the store buffer with dsb sy so GPIO1 is clocked before any GPIO1 access; second it clears 0x1F (SION | MUX_MODE) in SW_MUX_CTL_PAD_GPIO1_IO03 (0x020E0068), installs ALT5 (#5 with SION = 0), and executes dsb sy.
learner@ksa:~/gl-e01/m03-l01$ bat target.S File: target.S .syntax unified .cpu cortex-a7 .arm .text .global gpio1_clock_and_mux gpio1_clock_and_mux: ldr r0, =0x020c406c ldr r1, [r0] bic r1, r1, #(3 << 26) orr r1, r1, #(3 << 26) str r1, [r0] dsb sy ldr r0, =0x020e0068 ldr r1, [r0] bic r1, r1, #0x1f orr r1, r1, #5 str r1, [r0] dsb sy bx lrValidating CCGR Slots, Per-Ball ALT Tables, and Daisy Bounds in C11
In iomuxc_mux_daisy_audit.c, notice how we validate hardware capability, not just bit width! Even though MUX_MODE[3:0] can represent 0..15, iomuxc_set_mux() checks (allowed_alts & (UINT16_C(1) << alt)) != 0U so requesting unimplemented ALT8 on GPIO1_IO03 fails cleanly without touching *mux_ctl. Likewise, ccgr_set_gate() rejects reserved mode == 2 (0b10) and index >= 16, while iomuxc_set_daisy() enforces choice < daisy_count.
learner@ksa:~/gl-e01/m03-l01$ bat -H 7 -H 8 -H 9 -H 10 -H 11 -H 12 -H 13 -H 15 -H 16 -H 17 -H 18 -H 19 -H 20 -H 21 -H 23 -H 24 -H 25 -H 26 -H 27 -H 28 -H 29 iomuxc_mux_daisy_audit.c File: iomuxc_mux_daisy_audit.c #include <assert.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> static bool ccgr_set_gate(uint32_t *ccgr, unsigned index, unsigned mode) { if (index >= 16U || mode > 3U || mode == 2U) return false; uint32_t shift = index * 2U, mask = UINT32_C(3) << shift; *ccgr = (*ccgr & ~mask) | ((uint32_t)mode << shift); return true; } static bool iomuxc_set_mux(uint32_t *mux_ctl, unsigned alt, bool sion, uint16_t allowed_alts) { if (alt > 8U || (allowed_alts & (UINT16_C(1) << alt)) == 0U) return false; *mux_ctl = (*mux_ctl & ~UINT32_C(0x1f)) | alt | (sion ? 0x10U : 0U); return true; } static bool iomuxc_set_daisy(uint32_t *sel_inp, unsigned choice, unsigned daisy_count) { if (daisy_count == 0U || daisy_count > 4U || choice >= daisy_count) return false; *sel_inp = (*sel_inp & ~UINT32_C(3)) | choice; return true; } int main(void) { uint32_t ccgr1 = 0xa5a5a5a5U, old = ccgr1; assert(ccgr_set_gate(&ccgr1, 13U, 3U)); assert((ccgr1 & 0x0c000000U) == 0x0c000000U); assert((ccgr1 & ~0x0c000000U) == (old & ~0x0c000000U)); old = ccgr1; assert(!ccgr_set_gate(&ccgr1, 16U, 3U) && ccgr1 == old); assert(!ccgr_set_gate(&ccgr1, 13U, 2U) && ccgr1 == old); uint32_t mux = 0xa5a5a5a5U; uint16_t pad_io03_alts = (UINT16_C(1) << 0) | (UINT16_C(1) << 5); assert(iomuxc_set_mux(&mux, 5U, true, pad_io03_alts) && (mux & 0x1fU) == 0x15U); old = mux; assert(!iomuxc_set_mux(&mux, 8U, false, pad_io03_alts) && mux == old); assert(iomuxc_set_mux(&mux, 5U, false, pad_io03_alts) && (mux & 0x1fU) == 0x05U); uint32_t daisy = 0x00000002U; assert(iomuxc_set_daisy(&daisy, 1U, 4U) && (daisy & 3U) == 1U); assert(!iomuxc_set_daisy(&daisy, 4U, 4U) && (daisy & 3U) == 1U); printf("CCGR1_CG13=0x%08X MUX_ALT5_SION=0x15 MUX_ALT5=0x%02X DAISY=%u\n", ccgr1 & 0x0c000000U, mux & 0x1fU, daisy & 3U); return 0; }- Update only the 2-bit CG[index] field in CCGRx while rejecting index >= 16 or reserved mode 2.
- Check (allowed_alts & (1U << alt)) before writing MUX_MODE[3:0] and compose SION at bit 4.
- Validate SELECT_INPUT daisy-chain choice against the receiver's pad count when an input signal has multiple pad sources.
Running the Clock-Gate and Pinmux Verifier
Compile and run iomuxc_mux_daisy_audit.c on the workstation and cross-assemble target.S into target.o. Notice how MUX_ALT5_SION=0x15 (0x10 | 0x05) and MUX_ALT5=0x05 clear stale SION bits cleanly because & ~0x1FU wipes both [4] and [3:0] before ORing.
learner@ksa:~/gl-e01/m03-l01gcc -std=c11 -Wall -Wextra -Werror -pedantic iomuxc_mux_daisy_audit.c -o iomuxc_mux_daisy_auditlearner@ksa:~/gl-e01/m03-l01./iomuxc_mux_daisy_auditCCGR1_CG13=0x0C000000 MUX_ALT5_SION=0x15 MUX_ALT5=0x05 DAISY=1learner@ksa:~/gl-e01/m03-l01clang --target=armv7a-none-eabi -mcpu=cortex-a7 -marm -c target.S -o target.olearner@ksa:~/gl-e01/m03-l01learner@ksa:~/gl-e01/m03-l01strace -e trace=write,exit_group \./iomuxc_mux_daisy_auditwrite(1, "CCGR1_CG13=0x0C000000 MUX_ALT5_S"..., 63) = 63exit_group(0) = ?+++ exited with 0 +++Clock-Gate and Pin-Routing Policy Matrix
Compare narrow field updates against blanket register writes below. When U-Boot or the Linux kernel pinctrl-imx6ul driver takes over later in the boot chain, clean per-peripheral gates make power and pin-conflict debugging immediate.
| Bring-Up Practice | Register Effect | Side-Effect / Power Scope | Engineering Verdict |
|---|---|---|---|
Masked CGk update (~(3U << 2k)) | Updates 2 bits in 1 CCGR word | Neighboring 15 peripheral clocks untouched | Recommended: explicit dependency and minimal power waste |
Blanket CCGR0..6 = 0xFFFFFFFFU | Forces all 112 CG slots to 0b11 | Masks missing-clock bugs; clocks unused IP in WAIT | Avoid: hides broken driver clock claims |
MUX_MODE = ALT5, SION = 0 (0x05) | Routes GPIO mux; normal dir-controlled input | Standard unidirectional input or output | Default for pure outputs/inputs |
MUX_MODE = ALT5, SION = 1 (0x15) | Forces pad input buffer active (PSR live) | Slightly higher receiver switching activity | Use when: reading actual wire state (PSR / I2C) on driven net |
Later: Lesson m03-l02 opens the electrical pad cell right behind SW_MUX_CTL—decoding Schmitt hysteresis (HYS), hierarchical pull vs bus keeper bias (PKE/PUE/PUS), open-drain (ODE), and DSE drive impedance.
Common Production Pitfalls
warning: Symptom: UART1 or I2C1 transmits clean waveforms on an oscilloscope, yet its receive FIFO stays completely empty even though SW_MUX_CTL_PAD_* selected the documented ALT mode and RX pulses arrive at the ball. Root Cause: Multiple package balls can supply that RX line, and the peripheral's IOMUXC_*_SELECT_INPUT (DAISY) register still points at a different default pad. Fix: Always check whether an input signal has a SELECT_INPUT register and program its DAISY index alongside SW_MUX_CTL_PAD_*.
warning: Symptom: Firmware writes GPIO1_DR and GPIO1_GDIR before enabling CCM_CCGR1[27:26], triggering a synchronous external Data Abort or leaving GPIO1 latches stuck at reset values. Root Cause: Without IPG clock edges (CG13 == 0b00), the peripheral's bus slave logic cannot complete or latch register transactions. Fix: Enable the peripheral's CCM_CCGRx CG field and execute dsb sy before reading or writing any register inside that peripheral.
Practice & Retrieval
Guided Practice: Deriving GPIO5 Clock Gates & SION Masks
Step 1 (CCGR1 CG15): Given CCM_CCGR0 at 0x020C4068, verify CCM_CCGR1 is 0x020C406C and compute the 32-bit clear mask and RUN-only (0b01) value for CG15 (GPIO5, shift = 30: mask 0xC0000000U, RUN-only 0x40000000U). Step 2 (SION Byte): Compute the SW_MUX_CTL low byte for ALT0 (I2C1_SDA) with SION = 1 (0x10U | 0x00U = 0x10U) and state why I2C open-drain arbitration needs SION = 1. Step 3 (Allowed ALTs): Write allowed_alts in hex for a pad implementing ALT0, ALT1, ALT3, ALT5, and ALT8 (0x012BU).
Independent Practice: Board Pinmux & Daisy-Chain Conflict Linter (pinmux_table_audit.c)
Write a standalone ISO C11 verifier pinmux_table_audit.c auditing an array of struct pin_cfg board entries. Reject duplicate mux_addr collisions (two drivers claiming one ball!), unimplemented alt modes, missing sel_inp_addr when daisy_max > 1, daisy >= daisy_max, ccgr_idx > 6, or cg_slot >= 16 across 1 valid 4-pin table and 4 faulted configurations.
Key takeaways
CCM_CCGR0..CCGR6(0x020C4068..0x020C4080) gate peripheral clocks using16two-bitCGfields per word (00off,01RUN,11RUN+WAIT); enable the clock +dsb sybefore accessing peripheral .- Peripheral clocking (
CCM) and ball signal routing (IOMUXC_SW_MUX_CTL_PAD_*) are independent hardware requirements. MUX_MODE[3:0]must select anALTfunction actually implemented on that exact ball (ALT5forGPIO1_IO03).SION(bit 4) forces the pad's input receiver active for pin loopback/monitoring, while*_SELECT_INPUT(DAISY) chooses which ball drives a multi-pad peripheral RX input.- The i.MX6ULL CCM exposes CCGR0 through CCGR6 for peripheral clock-gating policy.
- A peripheral's clock-gate field and its pad mux route are independent configuration requirements.
- It forces the selected pad input path on, not arbitrary wiring.