Skip to content

Commit 8f101a0

Browse files
qcao-zztorvalds
authored andcommitted
edac: cpc925 MC platform device setup
Fix up the number of cells for the values of CPC925 Memory Controller, and setup related platform device during system booting up, against which CPC925 Memory Controller EDAC driver would be matched. Signed-off-by: Harry Ciao <[email protected]> Cc: Doug Thompson <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Kumar Gala <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1dc9b70 commit 8f101a0

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

arch/powerpc/kernel/prom_init.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,8 +1947,47 @@ static void __init fixup_device_tree_maple(void)
19471947
prom_setprop(isa, name, "ranges",
19481948
isa_ranges, sizeof(isa_ranges));
19491949
}
1950+
1951+
#define CPC925_MC_START 0xf8000000
1952+
#define CPC925_MC_LENGTH 0x1000000
1953+
/* The values for memory-controller don't have right number of cells */
1954+
static void __init fixup_device_tree_maple_memory_controller(void)
1955+
{
1956+
phandle mc;
1957+
u32 mc_reg[4];
1958+
char *name = "/hostbridge@f8000000";
1959+
struct prom_t *_prom = &RELOC(prom);
1960+
u32 ac, sc;
1961+
1962+
mc = call_prom("finddevice", 1, 1, ADDR(name));
1963+
if (!PHANDLE_VALID(mc))
1964+
return;
1965+
1966+
if (prom_getproplen(mc, "reg") != 8)
1967+
return;
1968+
1969+
prom_getprop(_prom->root, "#address-cells", &ac, sizeof(ac));
1970+
prom_getprop(_prom->root, "#size-cells", &sc, sizeof(sc));
1971+
if ((ac != 2) || (sc != 2))
1972+
return;
1973+
1974+
if (prom_getprop(mc, "reg", mc_reg, sizeof(mc_reg)) == PROM_ERROR)
1975+
return;
1976+
1977+
if (mc_reg[0] != CPC925_MC_START || mc_reg[1] != CPC925_MC_LENGTH)
1978+
return;
1979+
1980+
prom_printf("Fixing up bogus hostbridge on Maple...\n");
1981+
1982+
mc_reg[0] = 0x0;
1983+
mc_reg[1] = CPC925_MC_START;
1984+
mc_reg[2] = 0x0;
1985+
mc_reg[3] = CPC925_MC_LENGTH;
1986+
prom_setprop(mc, name, "reg", mc_reg, sizeof(mc_reg));
1987+
}
19501988
#else
19511989
#define fixup_device_tree_maple()
1990+
#define fixup_device_tree_maple_memory_controller()
19521991
#endif
19531992

19541993
#ifdef CONFIG_PPC_CHRP
@@ -2189,6 +2228,7 @@ static void __init fixup_device_tree_efika(void)
21892228
static void __init fixup_device_tree(void)
21902229
{
21912230
fixup_device_tree_maple();
2231+
fixup_device_tree_maple_memory_controller();
21922232
fixup_device_tree_chrp();
21932233
fixup_device_tree_pmac();
21942234
fixup_device_tree_efika();

arch/powerpc/platforms/maple/setup.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,62 @@ define_machine(maple) {
335335
.progress = maple_progress,
336336
.power_save = power4_idle,
337337
};
338+
339+
#ifdef CONFIG_EDAC
340+
/*
341+
* Register a platform device for CPC925 memory controller on
342+
* Motorola ATCA-6101 blade.
343+
*/
344+
#define MAPLE_CPC925_MODEL "Motorola,ATCA-6101"
345+
static int __init maple_cpc925_edac_setup(void)
346+
{
347+
struct platform_device *pdev;
348+
struct device_node *np = NULL;
349+
struct resource r;
350+
const unsigned char *model;
351+
int ret;
352+
353+
np = of_find_node_by_path("/");
354+
if (!np) {
355+
printk(KERN_ERR "%s: Unable to get root node\n", __func__);
356+
return -ENODEV;
357+
}
358+
359+
model = (const unsigned char *)of_get_property(np, "model", NULL);
360+
if (!model) {
361+
printk(KERN_ERR "%s: Unabel to get model info\n", __func__);
362+
return -ENODEV;
363+
}
364+
365+
ret = strcmp(model, MAPLE_CPC925_MODEL);
366+
of_node_put(np);
367+
368+
if (ret != 0)
369+
return 0;
370+
371+
np = of_find_node_by_type(NULL, "memory-controller");
372+
if (!np) {
373+
printk(KERN_ERR "%s: Unable to find memory-controller node\n",
374+
__func__);
375+
return -ENODEV;
376+
}
377+
378+
ret = of_address_to_resource(np, 0, &r);
379+
of_node_put(np);
380+
381+
if (ret < 0) {
382+
printk(KERN_ERR "%s: Unable to get memory-controller reg\n",
383+
__func__);
384+
return -ENODEV;
385+
}
386+
387+
pdev = platform_device_register_simple("cpc925_edac", 0, &r, 1);
388+
if (IS_ERR(pdev))
389+
return PTR_ERR(pdev);
390+
391+
printk(KERN_INFO "%s: CPC925 platform device created\n", __func__);
392+
393+
return 0;
394+
}
395+
machine_device_initcall(maple, maple_cpc925_edac_setup);
396+
#endif

0 commit comments

Comments
 (0)