This document specifies the firmware power state machine, APM (Active Power Management), the unit power control sequence via CR[0x0038], the final power-off procedure, and clock/DVFS integration on the SpacemiT K3 (36.56.104.183).
sysdata.pow_state) ([P][D])Public State (enum rogue_fwif_pow_state) |
Value | Semantics |
|---|---|---|
ROGUE_FWIF_POW_OFF |
0 |
GPU powered off; MIPS halted in final WAIT awaiting host reset/power-gate |
ROGUE_FWIF_POW_ON |
1 |
GPU powered on and scheduling work normally |
ROGUE_FWIF_POW_FORCED_IDLE |
2 |
Host requested forced idle (KCCB_CMD_POW with ROGUE_FWIF_POW_FORCED_IDLE_REQ, e.g., for DVFS or suspend); firmware drains in-flight work and dispatches no new kicks |
ROGUE_FWIF_POW_IDLE |
3 |
All queues empty and APM timer (active_pm_latency_ms) expired; firmware notified host via IRQ and awaits ROGUE_FWIF_POW_OFF_REQ or new work |
POW_ON → POW_IDLE: all DMs idle, no pending commands in KCCB/cCCB, no HWR/SPM in progress, and active_pm_latency_ms (default 100 ms on K3) elapsed since idle started. The firmware writes sysdata.pow_state = ROGUE_FWIF_POW_IDLE, ensures memory visibility, and triggers the host interrupt (hwirq 75).POW_IDLE → POW_ON: new work arrives (KCCB/cCCB kick) before the host confirms ROGUE_FWIF_POW_OFF_REQ → cancels the idle state and resumes immediately.POW_IDLE or POW_FORCED_IDLE → POW_OFF: host sends KCCB_CMD_POW (ROGUE_FWIF_POW_OFF_REQ). Firmware confirms everything is idle, executes the final power-off sequence (Section 3), and enters a clean halt (WAIT).POW_ON → POW_FORCED_IDLE → POW_ON: host sends ROGUE_FWIF_POW_FORCED_IDLE_REQ (ROGUE_FWIF_POWER_FORCE_IDLE); once all DMs finish, firmware confirms idle; host later sends ROGUE_FWIF_POWER_CANCEL_FORCED_IDLE to return to POW_ON.CR[0x0038]) ([O])The BXM-4-64 silicon (36.56.104.183) features an internal unit/dust power-gating controller accessible via CR[0x0038]. This register does not exist in either the vendor KM header (rgx_cr_defs_km.h) or the mainline header (pvr_rogue_cr_defs.h): it is firmware-private. Request completion is signaled in ROGUE_CR_EVENT_STATUS (0x0130) by bits 0x400 (POWER_COMPLETE, bit 10) and 0x800 (POWER_ABORT, bit 11).
CR[0x0038] Bit Layout (req_val)| Bits | Field | Semantics |
|---|---|---|
0 |
DIR |
1 = power on units; 0 = power off |
1 |
TRIGGER |
1 = triggers the transition (write req_val \| 2) |
9 (0x200) |
ALL |
present in all observed requests (units + dusts) |
[10 + i] |
UNIT[i] |
units mask: ((1 << n_units) - 1) << 10 |
[24 + d] |
DUST[d] |
dusts mask: ((1 << n_dusts) - 1) << 24, with n_dusts = CR[0xF308] |
Auxiliary dusts mask (BCAST[0x0050], one bit per dust):
BCAST[0x0050] = ((1 << n_dusts) - 1) & 0xFF
ROGUE_CR_SOFT_RESET Masks (0x0100/0x0104)The firmware writes this 64-bit register always in broadcast (BCAST[0x0100]/BCAST[0x0104]).
Polarity: 1 = reset asserted, 0 = reset released. The value with all blocks held in reset is ROGUE_CR_SOFT_RESET__PBE2_XE__MASKFULL = 0xFFEFFFFFFFFFFC3D (the same value the host driver writes to “set Rogue in soft-reset”).
| Phase | BCAST[0x0100] |
BCAST[0x0104] |
64-bit Value |
|---|---|---|---|
| Assert reset (before every power request) | 0xF3FFFC1D |
0xFFEFFFF8 |
0xFFEFFFF8F3FFFC1D |
| Release reset (pulse, after the request) | 0x00000000 |
0x00000000 |
0x0000000000000000 |
Difference relative to MASKFULL — bits the firmware releases (clears) during the transition while keeping the rest of the pipeline in reset:
| Bit | Block | Why It Stays Out of Reset |
|---|---|---|
5 |
SYSARB |
dispatches accesses from the firmware core itself |
26 |
TLA |
|
27 |
SLC |
keeps the SLC accessible during the transition |
32 |
CPU (GARTEN shares this bit) |
is the MIPS core itself |
33 |
BIF1 |
|
34 |
MMU |
These are precisely the blocks the firmware needs to write CR[0x0038] and poll for completion. After the pulse, 0x0 releases all blocks.
HWR path ([O]): during hardware recovery the firmware does not use the assert value; it asserts additional reset by ORing into the current value (with 1 = reset, OR asserts reset on these blocks):
BCAST[0x0100] |= 0x10610000 ; FB_TLCACHE(28), FBDC(22), FBC(21), BIF(16)
BCAST[0x0104] |= 0x00080004 ; PBE(19), TPU(2)
To power on (DIR = 1) or power off (DIR = 0) with mask req_val:
BCAST[0x0100] = 0xF3FFFC1D; BCAST[0x0104] = 0xFFEFFFF8 (asserts reset — §2.2); reads CR[0x0100].CR[0x0890] = 1 (broadcast core selection; restored afterwards to (1 << n_cores) - 1, 1 on K3).CR[0x0038] = req_val.ROGUE_CR_TIMER (0x0160).CR[0x0038] = req_val | 2 (trigger).CR[0x0130] & 0xC00 until non-zero, with a finite timeout (on timeout, records sysdata.cr_poll_addr = 0x80000130, cr_poll_mask = 0xC00, and increments cr_poll_count).CR[0x0890] = 1.BCAST[0x0100] = 0; BCAST[0x0104] = 0 (releases reset); reads CR[0x0100].CR[0x0038] = 0.CR[0x0130] & 0xC00 == 0 (with finite timeout); then BCAST[0x0138] = 0xC00 (clears POWER_COMPLETE/POWER_ABORT).POWER_ABORT (0x800), retry the request up to a finite attempt limit; once exhausted, report power transition failure to host/trace.n_dusts = 1 on K3), execute the boot-gpu-init.md sequence to reinitialize the internal registers of the powered-up blocks; if the request was a power-down, execute unit and power monitor deinit.The
req_valobserved at initial power-up is((1 << n_units) - 1) << 10 | 0x200 | 1withn_dustsbits at[24+]; on power-down it uses the same value withDIR = 0. Writing withoutTRIGGER(step 3) followed byTRIGGER(step 5) is mandatory — the controller ignores the mask if it only appears together with the trigger.
POW_OFF) ([P][D])When the firmware confirms that all DMs are idle and approves the definitive transition to ROGUE_FWIF_POW_OFF:
EVENT_STATUS.CR[0x0038] if applicable.BCAST[0x3818] + poll 0x3820) and wait for ROGUE_CR_SLC_IDLE (0x3898) with bits [7:0] == 0xFF.sysdata.pow_state = ROGUE_FWIF_POW_OFF.*osdata.power_sync_fw_addr = 1 (u32) — the driver (pvr_power.c) clears this word before the request and runs readl_poll_timeout(value != 0); the value written by the firmware is always 1.[O]): write the sync word, ehb, drain the wrapper with 0xBFC01800 = 1 + ehb + sync, and only then perform a confirming read of CR[0x0020] (CORE_ID/PBVNC) before entering the final loop. Without this ordering, the host may observe power_sync = 0 until timeout.0x80000000..0x800007F0, stride 0x10).hwirq 75) notifying that the GPU is ready for clock/power gating.ehb + WAIT (without writing CR[0x0B08] = 2), waiting for the host to cut power/clock or apply reset on the next wake-up.Before powering off, the firmware also disarms all timers, runs unit and power monitor deinit, clears the power state field in
sysdata, and clears the internal “power-off in progress” state that thePOW_OFFrequest had activated.
ROGUE_CR_TIMER and Clock/DVFS Correlation ([P][O][D])ROGUE_CR_TIMER Counter (0x0160 / 0x0164)CR[0x0160]: bits [31:0]CR[0x0164] & 0xFFFF: bits [47:32]CLK_APMU_GPU), or derived from SOC_TIMER depending on platform configuration.hi1 = CR[0x0164] & 0xFFFF, lo = CR[0x0160], hi2 = CR[0x0164] & 0xFFFF; if hi1 != hi2, re-read lo to prevent tearing on the lower 32-bit rollover.On the SpacemiT K3, the CLK_APMU_GPU clock dynamically scales between 409.6 MHz (idle) and 1228.8 MHz (heavy load, 6 OPPs):
KCCB_CMD_CORECLKSPEEDCHANGE (0x2ABC00CC) with the new frequency in Hz.runtime_cfg.core_clock_speed (+0x0C) and recalculates:
CR_TIMER ticks equivalent to active_pm_latency_ms.struct rogue_fwif_gpu_util_fwcb (IDLE / ACTIVE / BLOCKED + CR_TIMER timestamp) so the Linux driver’s devfreq governor can compute percentage utilization and scale OPPs.[O])| Event | Observed Time |
|—|—|
| Cold boot (reset → firmware_started = 1) | ~1–2 ms |
| Post-APM warm reinit (wake-up → ready) | < 2 ms |
| APM entry latency (active_pm_latency_ms) | 100 ms (default) |
| Observed DVFS scaling | 409.6 MHz (idle) → 1228.8 MHz (compute/3D) |