* [PATCH] powerpc: MPIC init get address from device-tree
@ 2006-10-16 7:45 Benjamin Herrenschmidt
0 siblings, 0 replies; only message in thread
From: Benjamin Herrenschmidt @ 2006-10-16 7:45 UTC (permalink / raw)
To: linuxppc-dev list; +Cc: cbe-oss-dev@ozlabs.org
This patch applies on top of the MPIC DCR support. It makes the MPIC
driver capable of a lot more auto-configuration based on the device-tree,
for example, it can retreive it's own physical address if not passed as
an argument, find out if it's DCR or MMIO mapped, and set the BIG_ENDIAN
flag automatically in the presence of a "big-endian" property in the
device-tree node.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Index: linux-cell/arch/powerpc/sysdev/mpic.c
===================================================================
--- linux-cell.orig/arch/powerpc/sysdev/mpic.c 2006-10-16 17:29:50.000000000 +1000
+++ linux-cell/arch/powerpc/sysdev/mpic.c 2006-10-16 17:29:57.000000000 +1000
@@ -943,6 +943,11 @@ struct mpic * __init mpic_alloc(struct d
mpic->irq_count = irq_count;
mpic->num_sources = 0; /* so far */
+ /* Check for "big-endian" in device-tree */
+ if (node && get_property(node, "big-endian", NULL) != NULL)
+ mpic->flags |= MPIC_BIG_ENDIAN;
+
+
#ifdef CONFIG_MPIC_WEIRD
mpic->hw_set = mpic_infos[MPIC_GET_REGSET(flags)];
#endif
@@ -951,11 +956,17 @@ struct mpic * __init mpic_alloc(struct d
mpic->reg_type = (flags & MPIC_BIG_ENDIAN) ?
mpic_access_mmio_be : mpic_access_mmio_le;
+ /* If no physical address is passed in, a device-node is mandatory */
+ BUG_ON(phys_addr == 0 && node == NULL);
+
+ /* If no physical address passed in, check if it's dcr based */
+ if (phys_addr == 0 && get_property(node, "dcr-reg", NULL) != NULL)
+ mpic->flags |= MPIC_USES_DCR;
+
#ifdef CONFIG_PPC_DCR
if (mpic->flags & MPIC_USES_DCR) {
const u32 *dbasep;
- BUG_ON(mpic->of_node == NULL);
- dbasep = get_property(mpic->of_node, "dcr-reg", NULL);
+ dbasep = get_property(node, "dcr-reg", NULL);
BUG_ON(dbasep == NULL);
mpic->dcr_base = *dbasep;
mpic->reg_type = mpic_access_dcr;
@@ -964,6 +975,17 @@ struct mpic * __init mpic_alloc(struct d
BUG_ON (mpic->flags & MPIC_USES_DCR);
#endif /* CONFIG_PPC_DCR */
+ /* If the MPIC is not DCR based, and no physical address was passed
+ * in, try to obtain one
+ */
+ if (phys_addr == 0 && !(mpic->flags & MPIC_USES_DCR)) {
+ const u32 *reg;
+ reg = get_property(node, "reg", NULL);
+ BUG_ON(reg == NULL);
+ phys_addr = of_translate_address(node, reg);
+ BUG_ON(phys_addr == OF_BAD_ADDR);
+ }
+
/* Map the global registers */
mpic_map(mpic, phys_addr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
mpic_map(mpic, phys_addr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-10-16 7:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-16 7:45 [PATCH] powerpc: MPIC init get address from device-tree Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).