Imagination_BXM-4-64

Power Management, APM, Clock, and DVFS

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).


1. Power State Machine (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

Key Transitions


2. Unit / Dust Power Control (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).

2.1 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

2.2 Exact 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)

2.3 Exact Sequence of a Power Request

To power on (DIR = 1) or power off (DIR = 0) with mask req_val:

  1. BCAST[0x0100] = 0xF3FFFC1D; BCAST[0x0104] = 0xFFEFFFF8 (asserts reset — §2.2); reads CR[0x0100].
  2. CR[0x0890] = 1 (broadcast core selection; restored afterwards to (1 << n_cores) - 1, 1 on K3).
  3. CR[0x0038] = req_val.
  4. Wait 1 tick of ROGUE_CR_TIMER (0x0160).
  5. CR[0x0038] = req_val | 2 (trigger).
  6. Poll 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).
  7. CR[0x0890] = 1.
  8. BCAST[0x0100] = 0; BCAST[0x0104] = 0 (releases reset); reads CR[0x0100].
  9. CR[0x0038] = 0.
  10. Poll CR[0x0130] & 0xC00 == 0 (with finite timeout); then BCAST[0x0138] = 0xC00 (clears POWER_COMPLETE/POWER_ABORT).
  11. If the result was POWER_ABORT (0x800), retry the request up to a finite attempt limit; once exhausted, report power transition failure to host/trace.
  12. If units/dusts were powered on (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_val observed at initial power-up is ((1 << n_units) - 1) << 10 | 0x200 | 1 with n_dusts bits at [24+]; on power-down it uses the same value with DIR = 0. Writing without TRIGGER (step 3) followed by TRIGGER (step 5) is mandatory — the controller ignores the mask if it only appears together with the trigger.


3. Final Power-Off Sequence (POW_OFF) ([P][D])

When the firmware confirms that all DMs are idle and approves the definitive transition to ROGUE_FWIF_POW_OFF:

  1. Verify that all DMs are idle and no events are pending in EVENT_STATUS.
  2. Power down units/dusts via CR[0x0038] if applicable.
  3. Perform SLC flush/invalidation (BCAST[0x3818] + poll 0x3820) and wait for ROGUE_CR_SLC_IDLE (0x3898) with bits [7:0] == 0xFF.
  4. Update sysdata.pow_state = ROGUE_FWIF_POW_OFF.
  5. Write *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.
  6. Mandatory visibility order ([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.
  7. Perform a full MIPS D-cache flush (0x80000000..0x800007F0, stride 0x10).
  8. Trigger the host interrupt (hwirq 75) notifying that the GPU is ready for clock/power gating.
  9. Enter an infinite loop executing 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 the POW_OFF request had activated.


4. ROGUE_CR_TIMER and Clock/DVFS Correlation ([P][O][D])

ROGUE_CR_TIMER Counter (0x0160 / 0x0164)

Time Conversion and OPP Changes (DVFS)

On the SpacemiT K3, the CLK_APMU_GPU clock dynamically scales between 409.6 MHz (idle) and 1228.8 MHz (heavy load, 6 OPPs):

Measured Timings on SpacemiT K3 Pico ITX Board ([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) |