Skip to content

Commit

Permalink
powerpc/32: Pass device tree address as u64 to machine_init
Browse files Browse the repository at this point in the history
u64 is used rather than phys_addr_t to keep things simple, as
this is called from assembly code.

Update callers to pass a 64-bit address in r3/r4.  Other unused
register assignments that were once parameters to machine_init
are dropped.

For FSL BookE, look up the physical address of the device tree from the
effective address passed in r3 by the loader.  This is required for
situations where memory does not start at zero (due to AMP or IOMMU-less
virtualization), and thus the IMA doesn't start at zero, and thus the
device tree effective address does not equal the physical address.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Scott Wood authored and Benjamin Herrenschmidt committed Sep 19, 2011
1 parent 6c49368 commit 6dece0e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 56 deletions.
7 changes: 3 additions & 4 deletions arch/powerpc/kernel/head_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ __start:
trap
#endif /* CONFIG_PPC_PMAC */

1: mr r31,r3 /* save parameters */
mr r30,r4
1: mr r31,r3 /* save device tree ptr */
li r24,0 /* cpu # */

/*
Expand Down Expand Up @@ -964,8 +963,8 @@ start_here:
* Do early platform-specific initialization,
* and set up the MMU.
*/
mr r3,r31
mr r4,r30
li r3,0
mr r4,r31
bl machine_init
bl __save_cpu_setup
bl MMU_init
Expand Down
15 changes: 3 additions & 12 deletions arch/powerpc/kernel/head_40x.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@
_ENTRY(_stext);
_ENTRY(_start);

/* Save parameters we are passed.
*/
mr r31,r3
mr r30,r4
mr r29,r5
mr r28,r6
mr r27,r7
mr r31,r3 /* save device tree ptr */

/* We have to turn on the MMU right away so we get cache modes
* set correctly.
Expand Down Expand Up @@ -849,11 +843,8 @@ start_here:
/*
* Decide what sort of machine this is and initialize the MMU.
*/
mr r3,r31
mr r4,r30
mr r5,r29
mr r6,r28
mr r7,r27
li r3,0
mr r4,r31
bl machine_init
bl MMU_init

Expand Down
16 changes: 3 additions & 13 deletions arch/powerpc/kernel/head_44x.S
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,7 @@ _ENTRY(_start);
* of abatron_pteptrs
*/
nop
/*
* Save parameters we are passed
*/
mr r31,r3
mr r30,r4
mr r29,r5
mr r28,r6
mr r27,r7
mr r31,r3 /* save device tree ptr */
li r24,0 /* CPU number */

bl init_cpu_state
Expand Down Expand Up @@ -120,11 +113,8 @@ _ENTRY(_start);
/*
* Decide what sort of machine this is and initialize the MMU.
*/
mr r3,r31
mr r4,r30
mr r5,r29
mr r6,r28
mr r7,r27
li r3,0
mr r4,r31
bl machine_init
bl MMU_init

Expand Down
13 changes: 3 additions & 10 deletions arch/powerpc/kernel/head_8xx.S
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ _ENTRY(_start);
*/
.globl __start
__start:
mr r31,r3 /* save parameters */
mr r30,r4
mr r29,r5
mr r28,r6
mr r27,r7
mr r31,r3 /* save device tree ptr */

/* We have to turn on the MMU right away so we get cache modes
* set correctly.
Expand Down Expand Up @@ -723,11 +719,8 @@ start_here:
/*
* Decide what sort of machine this is and initialize the MMU.
*/
mr r3,r31
mr r4,r30
mr r5,r29
mr r6,r28
mr r7,r27
li r3,0
mr r4,r31
bl machine_init
bl MMU_init

Expand Down
42 changes: 26 additions & 16 deletions arch/powerpc/kernel/head_fsl_booke.S
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,30 @@ _ENTRY(_start);
* of abatron_pteptrs
*/
nop
/*
* Save parameters we are passed
*/
mr r31,r3
mr r30,r4
mr r29,r5
mr r28,r6
mr r27,r7
li r25,0 /* phys kernel start (low) */
li r24,0 /* CPU number */
li r23,0 /* phys kernel start (high) */

/* Translate device tree address to physical, save in r30/r31 */
mfmsr r16
mfspr r17,SPRN_PID
rlwinm r17,r17,16,0x3fff0000 /* turn PID into MAS6[SPID] */
rlwimi r17,r16,28,0x00000001 /* turn MSR[DS] into MAS6[SAS] */
mtspr SPRN_MAS6,r17

tlbsx 0,r3 /* must succeed */

mfspr r16,SPRN_MAS1
mfspr r20,SPRN_MAS3
rlwinm r17,r16,25,0x1f /* r17 = log2(page size) */
li r18,1024
slw r18,r18,r17 /* r18 = page size */
addi r18,r18,-1
and r19,r3,r18 /* r19 = page offset */
andc r31,r20,r18 /* r3 = page base */
or r31,r31,r19 /* r3 = devtree phys addr */
mfspr r30,SPRN_MAS7

li r25,0 /* phys kernel start (low) */
li r24,0 /* CPU number */
li r23,0 /* phys kernel start (high) */

/* We try to not make any assumptions about how the boot loader
* setup or used the TLBs. We invalidate all mappings from the
Expand Down Expand Up @@ -198,11 +211,8 @@ _ENTRY(__early_start)
/*
* Decide what sort of machine this is and initialize the MMU.
*/
mr r3,r31
mr r4,r30
mr r5,r29
mr r6,r28
mr r7,r27
mr r3,r30
mr r4,r31
bl machine_init
bl MMU_init

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/setup_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ notrace unsigned long __init early_init(unsigned long dt_ptr)
* This is called very early on the boot process, after a minimal
* MMU environment has been set up but before MMU_init is called.
*/
notrace void __init machine_init(unsigned long dt_ptr)
notrace void __init machine_init(u64 dt_ptr)
{
lockdep_init();

Expand Down

0 comments on commit 6dece0e

Please sign in to comment.