diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2006-03-28 07:15:54 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-03-28 07:15:54 -0500 |
commit | e8222502ee6157e2713da9e0792c21f4ad458d50 (patch) | |
tree | 0f970fb99912c257a7e5254f863a53f79d22ab14 /arch/powerpc/kernel/prom_init.c | |
parent | 056cb48a2fb6fb31debf665695a9f97b45cfb8ec (diff) |
[PATCH] powerpc: Kill _machine and hard-coded platform numbers
This removes statically assigned platform numbers and reworks the
powerpc platform probe code to use a better mechanism. With this,
board support files can simply declare a new machine type with a
macro, and implement a probe() function that uses the flattened
device-tree to detect if they apply for a given machine.
We now have a machine_is() macro that replaces the comparisons of
_machine with the various PLATFORM_* constants. This commit also
changes various drivers to use the new macro instead of looking at
_machine.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/prom_init.c')
-rw-r--r-- | arch/powerpc/kernel/prom_init.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 0d0887844501..d66c5e77fcff 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c | |||
@@ -180,6 +180,16 @@ static unsigned long __initdata prom_tce_alloc_start; | |||
180 | static unsigned long __initdata prom_tce_alloc_end; | 180 | static unsigned long __initdata prom_tce_alloc_end; |
181 | #endif | 181 | #endif |
182 | 182 | ||
183 | /* Platforms codes are now obsolete in the kernel. Now only used within this | ||
184 | * file and ultimately gone too. Feel free to change them if you need, they | ||
185 | * are not shared with anything outside of this file anymore | ||
186 | */ | ||
187 | #define PLATFORM_PSERIES 0x0100 | ||
188 | #define PLATFORM_PSERIES_LPAR 0x0101 | ||
189 | #define PLATFORM_LPAR 0x0001 | ||
190 | #define PLATFORM_POWERMAC 0x0400 | ||
191 | #define PLATFORM_GENERIC 0x0500 | ||
192 | |||
183 | static int __initdata of_platform; | 193 | static int __initdata of_platform; |
184 | 194 | ||
185 | static char __initdata prom_cmd_line[COMMAND_LINE_SIZE]; | 195 | static char __initdata prom_cmd_line[COMMAND_LINE_SIZE]; |
@@ -1492,7 +1502,10 @@ static int __init prom_find_machine_type(void) | |||
1492 | int len, i = 0; | 1502 | int len, i = 0; |
1493 | #ifdef CONFIG_PPC64 | 1503 | #ifdef CONFIG_PPC64 |
1494 | phandle rtas; | 1504 | phandle rtas; |
1505 | int x; | ||
1495 | #endif | 1506 | #endif |
1507 | |||
1508 | /* Look for a PowerMac */ | ||
1496 | len = prom_getprop(_prom->root, "compatible", | 1509 | len = prom_getprop(_prom->root, "compatible", |
1497 | compat, sizeof(compat)-1); | 1510 | compat, sizeof(compat)-1); |
1498 | if (len > 0) { | 1511 | if (len > 0) { |
@@ -1505,28 +1518,36 @@ static int __init prom_find_machine_type(void) | |||
1505 | if (strstr(p, RELOC("Power Macintosh")) || | 1518 | if (strstr(p, RELOC("Power Macintosh")) || |
1506 | strstr(p, RELOC("MacRISC"))) | 1519 | strstr(p, RELOC("MacRISC"))) |
1507 | return PLATFORM_POWERMAC; | 1520 | return PLATFORM_POWERMAC; |
1508 | #ifdef CONFIG_PPC64 | ||
1509 | if (strstr(p, RELOC("Momentum,Maple"))) | ||
1510 | return PLATFORM_MAPLE; | ||
1511 | if (strstr(p, RELOC("IBM,CPB"))) | ||
1512 | return PLATFORM_CELL; | ||
1513 | #endif | ||
1514 | i += sl + 1; | 1521 | i += sl + 1; |
1515 | } | 1522 | } |
1516 | } | 1523 | } |
1517 | #ifdef CONFIG_PPC64 | 1524 | #ifdef CONFIG_PPC64 |
1525 | /* If not a mac, try to figure out if it's an IBM pSeries or any other | ||
1526 | * PAPR compliant platform. We assume it is if : | ||
1527 | * - /device_type is "chrp" (please, do NOT use that for future | ||
1528 | * non-IBM designs ! | ||
1529 | * - it has /rtas | ||
1530 | */ | ||
1531 | len = prom_getprop(_prom->root, "model", | ||
1532 | compat, sizeof(compat)-1); | ||
1533 | if (len <= 0) | ||
1534 | return PLATFORM_GENERIC; | ||
1535 | compat[len] = 0; | ||
1536 | if (strcmp(compat, "chrp")) | ||
1537 | return PLATFORM_GENERIC; | ||
1538 | |||
1518 | /* Default to pSeries. We need to know if we are running LPAR */ | 1539 | /* Default to pSeries. We need to know if we are running LPAR */ |
1519 | rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); | 1540 | rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); |
1520 | if (PHANDLE_VALID(rtas)) { | 1541 | if (!PHANDLE_VALID(rtas)) |
1521 | int x = prom_getproplen(rtas, "ibm,hypertas-functions"); | 1542 | return PLATFORM_GENERIC; |
1522 | if (x != PROM_ERROR) { | 1543 | x = prom_getproplen(rtas, "ibm,hypertas-functions"); |
1523 | prom_printf("Hypertas detected, assuming LPAR !\n"); | 1544 | if (x != PROM_ERROR) { |
1524 | return PLATFORM_PSERIES_LPAR; | 1545 | prom_printf("Hypertas detected, assuming LPAR !\n"); |
1525 | } | 1546 | return PLATFORM_PSERIES_LPAR; |
1526 | } | 1547 | } |
1527 | return PLATFORM_PSERIES; | 1548 | return PLATFORM_PSERIES; |
1528 | #else | 1549 | #else |
1529 | return PLATFORM_CHRP; | 1550 | return PLATFORM_GENERIC; |
1530 | #endif | 1551 | #endif |
1531 | } | 1552 | } |
1532 | 1553 | ||
@@ -2034,7 +2055,6 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4, | |||
2034 | { | 2055 | { |
2035 | struct prom_t *_prom; | 2056 | struct prom_t *_prom; |
2036 | unsigned long hdr; | 2057 | unsigned long hdr; |
2037 | u32 getprop_rval; | ||
2038 | unsigned long offset = reloc_offset(); | 2058 | unsigned long offset = reloc_offset(); |
2039 | 2059 | ||
2040 | #ifdef CONFIG_PPC32 | 2060 | #ifdef CONFIG_PPC32 |
@@ -2070,9 +2090,6 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4, | |||
2070 | * between pSeries SMP and pSeries LPAR | 2090 | * between pSeries SMP and pSeries LPAR |
2071 | */ | 2091 | */ |
2072 | RELOC(of_platform) = prom_find_machine_type(); | 2092 | RELOC(of_platform) = prom_find_machine_type(); |
2073 | getprop_rval = RELOC(of_platform); | ||
2074 | prom_setprop(_prom->chosen, "/chosen", "linux,platform", | ||
2075 | &getprop_rval, sizeof(getprop_rval)); | ||
2076 | 2093 | ||
2077 | /* Bail if this is a kdump kernel. */ | 2094 | /* Bail if this is a kdump kernel. */ |
2078 | if (PHYSICAL_START > 0) | 2095 | if (PHYSICAL_START > 0) |