Skip to content

Commit

Permalink
Bring RPM out of reset on initial boot-up
Browse files Browse the repository at this point in the history
Looking closer at the Linux kernel log I notice that all RPM regulators
seem to be suddenly broken:

  adv7511 3-0039: failed to init regulators

Poking some registers it looks like RPM is still in reset, because
0x1860000 (GCC_APSS_MISC) still has the reset bit set. Apparently,
the HYP firmware is also responsible for bringing RPM out of reset
on the initial boot-up.

Implementing this isn't that hard, so add some additional assembly
to store if this is the initial boot and clear the reset bit
if necessary.

This makes the RPM regulators work again! :)
  • Loading branch information
stephan-gh committed Mar 28, 2021
1 parent 830f754 commit 2aa3d61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions qhypstub.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ SECTIONS {
. = 0x86400000;

.text : { *(.text) }
.data : { *(.data) }
}
19 changes: 19 additions & 0 deletions qhypstub.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
.cpu cortex-a53

.equ STATE_INITIAL, 0
.equ STATE_AARCH32, 1
.equ STATE_AARCH64, 2

Expand Down Expand Up @@ -39,6 +40,7 @@ _start:
* Register allocation:
* x0 = temporary register
* x1 = STATE_AARCH32/STATE_AARCH64
* x2 = execution_state value
* x3 = temporary register
* lr = bootloader/kernel entry address
*/
Expand All @@ -50,6 +52,19 @@ _start:
mov x3, xzr
.endm

/* First, figure out if this is the initial boot-up */
adr x0, execution_state
ldrb w2, [x0]
cbnz w2, skip_init
strb w1, [x0] /* set initial execution_state based on x1 */

/* Bring RPM out of reset */
mov x0, 0x1860000 /* GCC_APSS_MISC */
ldr w3, [x0]
and w3, w3, ~0b1 /* RPM_RESET_REMOVAL */
str w3, [x0]

skip_init:
cmp x1, STATE_AARCH64
bne not_aarch64

Expand Down Expand Up @@ -83,3 +98,7 @@ not_aarch64:

panic:
b panic

.data
execution_state:
.byte 0

0 comments on commit 2aa3d61

Please sign in to comment.