[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>
This commit is contained in:
Benjamin Herrenschmidt
2006-03-28 23:15:54 +11:00
committed by Paul Mackerras
parent 056cb48a2f
commit e8222502ee
63 changed files with 559 additions and 542 deletions

View File

@@ -47,6 +47,7 @@ struct smp_ops_t {
#endif
struct machdep_calls {
char *name;
#ifdef CONFIG_PPC64
void (*hpte_invalidate)(unsigned long slot,
unsigned long va,
@@ -85,9 +86,9 @@ struct machdep_calls {
void (*iommu_dev_setup)(struct pci_dev *dev);
void (*iommu_bus_setup)(struct pci_bus *bus);
void (*irq_bus_setup)(struct pci_bus *bus);
#endif
#endif /* CONFIG_PPC64 */
int (*probe)(int platform);
int (*probe)(void);
void (*setup_arch)(void);
void (*init_early)(void);
/* Optional, may be NULL. */
@@ -207,8 +208,6 @@ struct machdep_calls {
/* Called at then very end of pcibios_init() */
void (*pcibios_after_init)(void);
/* this is for modules, since _machine can be a define -- Cort */
int ppc_machine;
#endif /* CONFIG_PPC32 */
/* Called to shutdown machine specific hardware not already controlled
@@ -244,7 +243,26 @@ struct machdep_calls {
extern void power4_idle(void);
extern void ppc6xx_idle(void);
/*
* ppc_md contains a copy of the machine description structure for the
* current platform. machine_id contains the initial address where the
* description was found during boot.
*/
extern struct machdep_calls ppc_md;
extern struct machdep_calls *machine_id;
#define __machine_desc __attribute__ ((__section__ (".machine.desc")))
#define define_machine(name) struct machdep_calls mach_##name __machine_desc =
#define machine_is(name) \
({ \
extern struct machdep_calls mach_##name \
__attribute__((weak)); \
machine_id == &mach_##name; \
})
extern void probe_machine(void);
extern char cmd_line[COMMAND_LINE_SIZE];
#ifdef CONFIG_PPC_PMAC

View File

@@ -305,7 +305,7 @@ extern void pmac_feature_init(void);
extern void pmac_set_early_video_resume(void (*proc)(void *data), void *data);
extern void pmac_call_early_video_resume(void);
#define PMAC_FTR_DEF(x) ((_MACH_Pmac << 16) | (x))
#define PMAC_FTR_DEF(x) ((0x6660000) | (x))
/* The AGP driver registers itself here */
extern void pmac_register_agp_pm(struct pci_dev *bridge,

View File

@@ -22,22 +22,6 @@
* -- BenH.
*/
/* Platforms codes (to be obsoleted) */
#define PLATFORM_PSERIES 0x0100
#define PLATFORM_PSERIES_LPAR 0x0101
#define PLATFORM_ISERIES_LPAR 0x0201
#define PLATFORM_LPAR 0x0001
#define PLATFORM_POWERMAC 0x0400
#define PLATFORM_MAPLE 0x0500
#define PLATFORM_PREP 0x0600
#define PLATFORM_CHRP 0x0700
#define PLATFORM_CELL 0x1000
/* Compat platform codes for 32 bits */
#define _MACH_prep PLATFORM_PREP
#define _MACH_Pmac PLATFORM_POWERMAC
#define _MACH_chrp PLATFORM_CHRP
/* PREP sub-platform types see residual.h for these */
#define _PREP_Motorola 0x01 /* motorola prep */
#define _PREP_Firm 0x02 /* firmworks prep */
@@ -49,15 +33,14 @@
#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */
#ifdef __KERNEL__
#define platform_is_pseries() (_machine == PLATFORM_PSERIES || \
_machine == PLATFORM_PSERIES_LPAR)
#if defined(__KERNEL__) && defined(CONFIG_PPC32)
extern int _chrp_type;
#ifdef CONFIG_PPC_PREP
/* what kind of prep workstation we are */
extern int _prep_type;
extern int _chrp_type;
/*
* This is used to identify the board type from a given PReP board
@@ -69,18 +52,12 @@ extern unsigned char ucBoardRevMaj, ucBoardRevMin;
#endif /* CONFIG_PPC_PREP */
#if defined(CONFIG_PPC_MULTIPLATFORM)
extern int _machine;
#elif defined(CONFIG_PPC_ISERIES)
/*
* iSeries is soon to become MULTIPLATFORM hopefully ...
*/
#define _machine PLATFORM_ISERIES_LPAR
#else
#ifndef CONFIG_PPC_MULTIPLATFORM
#define _machine 0
#endif /* CONFIG_PPC_MULTIPLATFORM */
#endif /* __KERNEL__ */
#endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
/*
* Default implementation of macro that returns current
* instruction pointer ("program counter").

View File

@@ -149,12 +149,14 @@ extern struct device_node *of_node_get(struct device_node *node);
extern void of_node_put(struct device_node *node);
/* For scanning the flat device-tree at boot time */
int __init of_scan_flat_dt(int (*it)(unsigned long node,
const char *uname, int depth,
void *data),
void *data);
void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
const char *uname, int depth,
void *data),
void *data);
extern void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int __init of_flat_dt_is_compatible(unsigned long node, const char *name);
extern unsigned long __init of_get_flat_dt_root(void);
/* For updating the device tree at runtime */
extern void of_attach_node(struct device_node *);

View File

@@ -55,6 +55,9 @@ struct vdso_data {
__u32 minor; /* Minor number 0x14 */
} version;
/* Note about the platform flags: it now only contains the lpar
* bit. The actual platform number is dead and burried
*/
__u32 platform; /* Platform flags 0x18 */
__u32 processor; /* Processor type 0x1C */
__u64 processorCount; /* # of physical processors 0x20 */