Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/32: Pass device tree address as u64 to machine_init

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>

authored by

Scott Wood and committed by
Benjamin Herrenschmidt
6dece0eb 6c493685

+39 -56
+3 -4
arch/powerpc/kernel/head_32.S
··· 139 139 trap 140 140 #endif /* CONFIG_PPC_PMAC */ 141 141 142 - 1: mr r31,r3 /* save parameters */ 143 - mr r30,r4 142 + 1: mr r31,r3 /* save device tree ptr */ 144 143 li r24,0 /* cpu # */ 145 144 146 145 /* ··· 963 964 * Do early platform-specific initialization, 964 965 * and set up the MMU. 965 966 */ 966 - mr r3,r31 967 - mr r4,r30 967 + li r3,0 968 + mr r4,r31 968 969 bl machine_init 969 970 bl __save_cpu_setup 970 971 bl MMU_init
+3 -12
arch/powerpc/kernel/head_40x.S
··· 58 58 _ENTRY(_stext); 59 59 _ENTRY(_start); 60 60 61 - /* Save parameters we are passed. 62 - */ 63 - mr r31,r3 64 - mr r30,r4 65 - mr r29,r5 66 - mr r28,r6 67 - mr r27,r7 61 + mr r31,r3 /* save device tree ptr */ 68 62 69 63 /* We have to turn on the MMU right away so we get cache modes 70 64 * set correctly. ··· 843 849 /* 844 850 * Decide what sort of machine this is and initialize the MMU. 845 851 */ 846 - mr r3,r31 847 - mr r4,r30 848 - mr r5,r29 849 - mr r6,r28 850 - mr r7,r27 852 + li r3,0 853 + mr r4,r31 851 854 bl machine_init 852 855 bl MMU_init 853 856
+3 -13
arch/powerpc/kernel/head_44x.S
··· 61 61 * of abatron_pteptrs 62 62 */ 63 63 nop 64 - /* 65 - * Save parameters we are passed 66 - */ 67 - mr r31,r3 68 - mr r30,r4 69 - mr r29,r5 70 - mr r28,r6 71 - mr r27,r7 64 + mr r31,r3 /* save device tree ptr */ 72 65 li r24,0 /* CPU number */ 73 66 74 67 bl init_cpu_state ··· 113 120 /* 114 121 * Decide what sort of machine this is and initialize the MMU. 115 122 */ 116 - mr r3,r31 117 - mr r4,r30 118 - mr r5,r29 119 - mr r6,r28 120 - mr r7,r27 123 + li r3,0 124 + mr r4,r31 121 125 bl machine_init 122 126 bl MMU_init 123 127
+3 -10
arch/powerpc/kernel/head_8xx.S
··· 76 76 */ 77 77 .globl __start 78 78 __start: 79 - mr r31,r3 /* save parameters */ 80 - mr r30,r4 81 - mr r29,r5 82 - mr r28,r6 83 - mr r27,r7 79 + mr r31,r3 /* save device tree ptr */ 84 80 85 81 /* We have to turn on the MMU right away so we get cache modes 86 82 * set correctly. ··· 719 723 /* 720 724 * Decide what sort of machine this is and initialize the MMU. 721 725 */ 722 - mr r3,r31 723 - mr r4,r30 724 - mr r5,r29 725 - mr r6,r28 726 - mr r7,r27 726 + li r3,0 727 + mr r4,r31 727 728 bl machine_init 728 729 bl MMU_init 729 730
+26 -16
arch/powerpc/kernel/head_fsl_booke.S
··· 63 63 * of abatron_pteptrs 64 64 */ 65 65 nop 66 - /* 67 - * Save parameters we are passed 68 - */ 69 - mr r31,r3 70 - mr r30,r4 71 - mr r29,r5 72 - mr r28,r6 73 - mr r27,r7 74 - li r25,0 /* phys kernel start (low) */ 75 - li r24,0 /* CPU number */ 76 - li r23,0 /* phys kernel start (high) */ 66 + 67 + /* Translate device tree address to physical, save in r30/r31 */ 68 + mfmsr r16 69 + mfspr r17,SPRN_PID 70 + rlwinm r17,r17,16,0x3fff0000 /* turn PID into MAS6[SPID] */ 71 + rlwimi r17,r16,28,0x00000001 /* turn MSR[DS] into MAS6[SAS] */ 72 + mtspr SPRN_MAS6,r17 73 + 74 + tlbsx 0,r3 /* must succeed */ 75 + 76 + mfspr r16,SPRN_MAS1 77 + mfspr r20,SPRN_MAS3 78 + rlwinm r17,r16,25,0x1f /* r17 = log2(page size) */ 79 + li r18,1024 80 + slw r18,r18,r17 /* r18 = page size */ 81 + addi r18,r18,-1 82 + and r19,r3,r18 /* r19 = page offset */ 83 + andc r31,r20,r18 /* r3 = page base */ 84 + or r31,r31,r19 /* r3 = devtree phys addr */ 85 + mfspr r30,SPRN_MAS7 86 + 87 + li r25,0 /* phys kernel start (low) */ 88 + li r24,0 /* CPU number */ 89 + li r23,0 /* phys kernel start (high) */ 77 90 78 91 /* We try to not make any assumptions about how the boot loader 79 92 * setup or used the TLBs. We invalidate all mappings from the ··· 211 198 /* 212 199 * Decide what sort of machine this is and initialize the MMU. 213 200 */ 214 - mr r3,r31 215 - mr r4,r30 216 - mr r5,r29 217 - mr r6,r28 218 - mr r7,r27 201 + mr r3,r30 202 + mr r4,r31 219 203 bl machine_init 220 204 bl MMU_init 221 205
+1 -1
arch/powerpc/kernel/setup_32.c
··· 117 117 * This is called very early on the boot process, after a minimal 118 118 * MMU environment has been set up but before MMU_init is called. 119 119 */ 120 - notrace void __init machine_init(unsigned long dt_ptr) 120 + notrace void __init machine_init(u64 dt_ptr) 121 121 { 122 122 lockdep_init(); 123 123