aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot/4xx.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-12-20 23:39:31 -0500
committerJosh Boyer <jwboyer@linux.vnet.ibm.com>2007-12-23 14:14:13 -0500
commitd23f5099297c0f017ba4fb165dc9879bda11f9ce (patch)
tree0a43ca1a2090643290f02115526875bdf6390a10 /arch/powerpc/boot/4xx.c
parent007b6aa8114550c59373c751ac9cc9f356a0a81f (diff)
[POWERPC] 4xx: Adds decoding of 440SPE memory size to boot wrapper library
This adds a function to the bootwrapper 4xx library to decode memory size on 440SPE processors. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Diffstat (limited to 'arch/powerpc/boot/4xx.c')
-rw-r--r--arch/powerpc/boot/4xx.c85
1 files changed, 70 insertions, 15 deletions
diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c
index 852992b146e3..d16ea10d7546 100644
--- a/arch/powerpc/boot/4xx.c
+++ b/arch/powerpc/boot/4xx.c
@@ -22,16 +22,14 @@
22#include "dcr.h" 22#include "dcr.h"
23 23
24/* Read the 4xx SDRAM controller to get size of system memory. */ 24/* Read the 4xx SDRAM controller to get size of system memory. */
25void ibm4xx_fixup_memsize(void) 25void ibm4xx_sdram_fixup_memsize(void)
26{ 26{
27 int i; 27 int i;
28 unsigned long memsize, bank_config; 28 unsigned long memsize, bank_config;
29 29
30 memsize = 0; 30 memsize = 0;
31 for (i = 0; i < ARRAY_SIZE(sdram_bxcr); i++) { 31 for (i = 0; i < ARRAY_SIZE(sdram_bxcr); i++) {
32 mtdcr(DCRN_SDRAM0_CFGADDR, sdram_bxcr[i]); 32 bank_config = SDRAM0_READ(sdram_bxcr[i]);
33 bank_config = mfdcr(DCRN_SDRAM0_CFGDATA);
34
35 if (bank_config & SDRAM_CONFIG_BANK_ENABLE) 33 if (bank_config & SDRAM_CONFIG_BANK_ENABLE)
36 memsize += SDRAM_CONFIG_BANK_SIZE(bank_config); 34 memsize += SDRAM_CONFIG_BANK_SIZE(bank_config);
37 } 35 }
@@ -39,6 +37,69 @@ void ibm4xx_fixup_memsize(void)
39 dt_fixup_memory(0, memsize); 37 dt_fixup_memory(0, memsize);
40} 38}
41 39
40/* Read the 440SPe MQ controller to get size of system memory. */
41#define DCRN_MQ0_B0BAS 0x40
42#define DCRN_MQ0_B1BAS 0x41
43#define DCRN_MQ0_B2BAS 0x42
44#define DCRN_MQ0_B3BAS 0x43
45
46static u64 ibm440spe_decode_bas(u32 bas)
47{
48 u64 base = ((u64)(bas & 0xFFE00000u)) << 2;
49
50 /* open coded because I'm paranoid about invalid values */
51 switch ((bas >> 4) & 0xFFF) {
52 case 0:
53 return 0;
54 case 0xffc:
55 return base + 0x000800000ull;
56 case 0xff8:
57 return base + 0x001000000ull;
58 case 0xff0:
59 return base + 0x002000000ull;
60 case 0xfe0:
61 return base + 0x004000000ull;
62 case 0xfc0:
63 return base + 0x008000000ull;
64 case 0xf80:
65 return base + 0x010000000ull;
66 case 0xf00:
67 return base + 0x020000000ull;
68 case 0xe00:
69 return base + 0x040000000ull;
70 case 0xc00:
71 return base + 0x080000000ull;
72 case 0x800:
73 return base + 0x100000000ull;
74 }
75 printf("Memory BAS value 0x%08x unsupported !\n", bas);
76 return 0;
77}
78
79void ibm440spe_fixup_memsize(void)
80{
81 u64 banktop, memsize = 0;
82
83 /* Ultimately, we should directly construct the memory node
84 * so we are able to handle holes in the memory address space
85 */
86 banktop = ibm440spe_decode_bas(mfdcr(DCRN_MQ0_B0BAS));
87 if (banktop > memsize)
88 memsize = banktop;
89 banktop = ibm440spe_decode_bas(mfdcr(DCRN_MQ0_B1BAS));
90 if (banktop > memsize)
91 memsize = banktop;
92 banktop = ibm440spe_decode_bas(mfdcr(DCRN_MQ0_B2BAS));
93 if (banktop > memsize)
94 memsize = banktop;
95 banktop = ibm440spe_decode_bas(mfdcr(DCRN_MQ0_B3BAS));
96 if (banktop > memsize)
97 memsize = banktop;
98
99 dt_fixup_memory(0, memsize);
100}
101
102
42/* 4xx DDR1/2 Denali memory controller support */ 103/* 4xx DDR1/2 Denali memory controller support */
43/* DDR0 registers */ 104/* DDR0 registers */
44#define DDR0_02 2 105#define DDR0_02 2
@@ -77,19 +138,13 @@ void ibm4xx_fixup_memsize(void)
77 138
78#define DDR_GET_VAL(val, mask, shift) (((val) >> (shift)) & (mask)) 139#define DDR_GET_VAL(val, mask, shift) (((val) >> (shift)) & (mask))
79 140
80static inline u32 mfdcr_sdram0(u32 reg)
81{
82 mtdcr(DCRN_SDRAM0_CFGADDR, reg);
83 return mfdcr(DCRN_SDRAM0_CFGDATA);
84}
85
86void ibm4xx_denali_fixup_memsize(void) 141void ibm4xx_denali_fixup_memsize(void)
87{ 142{
88 u32 val, max_cs, max_col, max_row; 143 u32 val, max_cs, max_col, max_row;
89 u32 cs, col, row, bank, dpath; 144 u32 cs, col, row, bank, dpath;
90 unsigned long memsize; 145 unsigned long memsize;
91 146
92 val = mfdcr_sdram0(DDR0_02); 147 val = SDRAM0_READ(DDR0_02);
93 if (!DDR_GET_VAL(val, DDR_START, DDR_START_SHIFT)) 148 if (!DDR_GET_VAL(val, DDR_START, DDR_START_SHIFT))
94 fatal("DDR controller is not initialized\n"); 149 fatal("DDR controller is not initialized\n");
95 150
@@ -99,7 +154,7 @@ void ibm4xx_denali_fixup_memsize(void)
99 max_row = DDR_GET_VAL(val, DDR_MAX_ROW_REG, DDR_MAX_ROW_REG_SHIFT); 154 max_row = DDR_GET_VAL(val, DDR_MAX_ROW_REG, DDR_MAX_ROW_REG_SHIFT);
100 155
101 /* get CS value */ 156 /* get CS value */
102 val = mfdcr_sdram0(DDR0_10); 157 val = SDRAM0_READ(DDR0_10);
103 158
104 val = DDR_GET_VAL(val, DDR_CS_MAP, DDR_CS_MAP_SHIFT); 159 val = DDR_GET_VAL(val, DDR_CS_MAP, DDR_CS_MAP_SHIFT);
105 cs = 0; 160 cs = 0;
@@ -115,7 +170,7 @@ void ibm4xx_denali_fixup_memsize(void)
115 fatal("DDR wrong CS configuration\n"); 170 fatal("DDR wrong CS configuration\n");
116 171
117 /* get data path bytes */ 172 /* get data path bytes */
118 val = mfdcr_sdram0(DDR0_14); 173 val = SDRAM0_READ(DDR0_14);
119 174
120 if (DDR_GET_VAL(val, DDR_REDUC, DDR_REDUC_SHIFT)) 175 if (DDR_GET_VAL(val, DDR_REDUC, DDR_REDUC_SHIFT))
121 dpath = 8; /* 64 bits */ 176 dpath = 8; /* 64 bits */
@@ -123,7 +178,7 @@ void ibm4xx_denali_fixup_memsize(void)
123 dpath = 4; /* 32 bits */ 178 dpath = 4; /* 32 bits */
124 179
125 /* get address pins (rows) */ 180 /* get address pins (rows) */
126 val = mfdcr_sdram0(DDR0_42); 181 val = SDRAM0_READ(DDR0_42);
127 182
128 row = DDR_GET_VAL(val, DDR_APIN, DDR_APIN_SHIFT); 183 row = DDR_GET_VAL(val, DDR_APIN, DDR_APIN_SHIFT);
129 if (row > max_row) 184 if (row > max_row)
@@ -131,7 +186,7 @@ void ibm4xx_denali_fixup_memsize(void)
131 row = max_row - row; 186 row = max_row - row;
132 187
133 /* get collomn size and banks */ 188 /* get collomn size and banks */
134 val = mfdcr_sdram0(DDR0_43); 189 val = SDRAM0_READ(DDR0_43);
135 190
136 col = DDR_GET_VAL(val, DDR_COL_SZ, DDR_COL_SZ_SHIFT); 191 col = DDR_GET_VAL(val, DDR_COL_SZ, DDR_COL_SZ_SHIFT);
137 if (col > max_col) 192 if (col > max_col)