From: David Gibson <david@gibson.dropbear.id.au>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH 10/13] Derive ebc ranges property from EBC registers
Date: Wed, 13 Jun 2007 14:52:59 +1000 (EST) [thread overview]
Message-ID: <20070613045259.CFD2FDDF15@ozlabs.org> (raw)
In-Reply-To: <20070613045031.GD16148@localhost.localdomain>
In the device tree for Ebony, the 'ranges' property in the node for
the EBC bridge shows the mappings from the chip select / address lines
actually used for the EBC peripherals into the address space of the
OPB. At present, these mappings are hardcoded in ebony.dts for the
mappings set up by the OpenBIOS firmware when it configures the EBC
bridge.
This patch replaces the hardcoded mappings with code in the zImage to
read the EBC configuration registers and create an appropriate ranges
property based on them. This should make the zImage and kernel more
robust to changes in firmware configuration. In particular, some of
the Ebony's DIP switches can change the effective address of the Flash
and other peripherals in OPB space. With this patch, the kernel will
be able to cope with at least some of the possible variations.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
arch/powerpc/boot/44x.c | 29 +++++++++++++++++++++++++++++
arch/powerpc/boot/44x.h | 1 +
arch/powerpc/boot/dcr.h | 37 +++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/dts/ebony.dts | 8 +++-----
arch/powerpc/boot/ebony.c | 1 +
5 files changed, 71 insertions(+), 5 deletions(-)
Index: working-2.6/arch/powerpc/boot/dcr.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/dcr.h 2007-05-08 15:07:45.000000000 +1000
+++ working-2.6/arch/powerpc/boot/dcr.h 2007-05-28 15:42:37.000000000 +1000
@@ -26,6 +26,43 @@ static const unsigned long sdram_bxcr[]
#define SDRAM_CONFIG_BANK_SIZE(reg) \
(0x00400000 << ((reg & SDRAM_CONFIG_SIZE_MASK) >> 17))
+/* 440GP External Bus Controller (EBC) */
+#define DCRN_EBC0_CFGADDR 0x012
+#define DCRN_EBC0_CFGDATA 0x013
+#define EBC_NUM_BANKS 8
+#define EBC_B0CR 0x00
+#define EBC_B1CR 0x01
+#define EBC_B2CR 0x02
+#define EBC_B3CR 0x03
+#define EBC_B4CR 0x04
+#define EBC_B5CR 0x05
+#define EBC_B6CR 0x06
+#define EBC_B7CR 0x07
+#define EBC_BXCR(n) (n)
+#define EBC_BXCR_BAS 0xfff00000
+#define EBC_BXCR_BS 0x000e0000
+#define EBC_BXCR_BANK_SIZE(reg) \
+ (0x100000 << (((reg) & EBC_BXCR_BS) >> 17))
+#define EBC_BXCR_BU 0x00018000
+#define EBC_BXCR_BU_OFF 0x00000000
+#define EBC_BXCR_BU_RO 0x00008000
+#define EBC_BXCR_BU_WO 0x00010000
+#define EBC_BXCR_BU_RW 0x00018000
+#define EBC_BXCR_BW 0x00006000
+#define EBC_B0AP 0x10
+#define EBC_B1AP 0x11
+#define EBC_B2AP 0x12
+#define EBC_B3AP 0x13
+#define EBC_B4AP 0x14
+#define EBC_B5AP 0x15
+#define EBC_B6AP 0x16
+#define EBC_B7AP 0x17
+#define EBC_BXAP(n) (0x10+(n))
+#define EBC_BEAR 0x20
+#define EBC_BESR 0x21
+#define EBC_CFG 0x23
+#define EBC_CID 0x24
+
/* 440GP Clock, PM, chip control */
#define DCRN_CPC0_SR 0x0b0
#define DCRN_CPC0_ER 0x0b1
Index: working-2.6/arch/powerpc/boot/ebony.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/ebony.c 2007-05-28 15:42:37.000000000 +1000
+++ working-2.6/arch/powerpc/boot/ebony.c 2007-05-28 15:54:59.000000000 +1000
@@ -100,6 +100,7 @@ static void ebony_fixups(void)
ibm440gp_fixup_clocks(sysclk, 6 * 1843200);
ibm44x_fixup_memsize();
dt_fixup_mac_addresses(ebony_mac0, ebony_mac1);
+ ibm4xx_fixup_ebc_ranges("/plb/opb/ebc");
}
void ebony_init(void *mac0, void *mac1)
Index: working-2.6/arch/powerpc/boot/dts/ebony.dts
===================================================================
--- working-2.6.orig/arch/powerpc/boot/dts/ebony.dts 2007-05-21 12:47:17.000000000 +1000
+++ working-2.6/arch/powerpc/boot/dts/ebony.dts 2007-05-28 15:54:59.000000000 +1000
@@ -135,11 +135,9 @@
#address-cells = <2>;
#size-cells = <1>;
clock-frequency = <0>; // Filled in by zImage
- ranges = <0 00000000 fff00000 100000
- 1 00000000 48000000 100000
- 2 00000000 ff800000 400000
- 3 00000000 48200000 100000
- 7 00000000 48300000 100000>;
+ // ranges property is supplied by zImage
+ // based on firmware's configuration of the
+ // EBC bridge
interrupts = <5 4>;
interrupt-parent = <&UIC1>;
Index: working-2.6/arch/powerpc/boot/44x.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/44x.c 2007-05-28 15:42:37.000000000 +1000
+++ working-2.6/arch/powerpc/boot/44x.c 2007-05-28 15:42:37.000000000 +1000
@@ -54,3 +54,32 @@ void ibm44x_dbcr_reset(void)
);
}
+
+/* Read 4xx EBC bus bridge registers to get mappings of the peripheral
+ * banks into the OPB address space */
+void ibm4xx_fixup_ebc_ranges(const char *ebc)
+{
+ void *devp;
+ u32 bxcr;
+ u32 ranges[EBC_NUM_BANKS*4];
+ u32 *p = ranges;
+ int i;
+
+ for (i = 0; i < EBC_NUM_BANKS; i++) {
+ mtdcr(DCRN_EBC0_CFGADDR, EBC_BXCR(i));
+ bxcr = mfdcr(DCRN_EBC0_CFGDATA);
+
+ if ((bxcr & EBC_BXCR_BU) != EBC_BXCR_BU_OFF) {
+ *p++ = i;
+ *p++ = 0;
+ *p++ = bxcr & EBC_BXCR_BAS;
+ *p++ = EBC_BXCR_BANK_SIZE(bxcr);
+ }
+ }
+
+ devp = finddevice(ebc);
+ if (! devp)
+ fatal("Couldn't locate EBC node %s\n\r", ebc);
+
+ setprop(devp, "ranges", ranges, (p - ranges) * sizeof(u32));
+}
Index: working-2.6/arch/powerpc/boot/44x.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/44x.h 2007-05-28 15:42:37.000000000 +1000
+++ working-2.6/arch/powerpc/boot/44x.h 2007-05-28 15:42:37.000000000 +1000
@@ -11,6 +11,7 @@
#define _PPC_BOOT_44X_H_
void ibm44x_fixup_memsize(void);
+void ibm4xx_fixup_ebc_ranges(const char *ebc);
void ibm44x_dbcr_reset(void);
void ebony_init(void *mac0, void *mac1);
next prev parent reply other threads:[~2007-06-13 4:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-13 4:50 [0/13] Queued patches for 2.6.13 David Gibson
2007-06-13 4:52 ` [PATCH 2/13] Split out asm-ppc/mmu.h portions for the "classic" hash-based MMU David Gibson
2007-06-13 4:52 ` [PATCH 4/13] Remove the dregs of APUS support from arch/powerpc David Gibson
2007-06-13 4:52 ` [PATCH 3/13] Abolish iopa(), mm_ptov(), io_block_mapping() " David Gibson
2007-06-16 0:55 ` Benjamin Herrenschmidt
2007-06-13 4:52 ` [PATCH 1/13] Split low-level OF-related bootloader code into separate files David Gibson
2007-06-13 4:52 ` [PATCH 6/13] Start factoring pgtable-ppc32.h and pgtable-ppc64.h David Gibson
2007-06-14 14:05 ` Segher Boessenkool
2007-06-13 4:52 ` [PATCH 5/13] Remove a couple of unused definitions from pgtable_32.c David Gibson
2007-06-14 21:04 ` Kumar Gala
2007-06-14 21:50 ` Andy Fleming
2007-06-15 15:40 ` Kumar Gala
2007-06-13 4:52 ` [PATCH 7/13] Kill typedef-ed structs for hash PTEs and BATs David Gibson
2007-06-13 4:52 ` [PATCH 8/13] Merge CPU features pertaining to icache coherency David Gibson
2007-06-13 4:52 ` [PATCH 9/13] Factor zImage's 44x reset code out of ebony.c David Gibson
2007-06-13 4:52 ` David Gibson [this message]
2007-06-14 14:12 ` [PATCH 10/13] Derive ebc ranges property from EBC registers Segher Boessenkool
2007-06-14 14:14 ` Segher Boessenkool
2007-06-13 4:53 ` [PATCH 12/13] Don't store a command line in the Holly device tree David Gibson
2007-06-13 4:53 ` [PATCH 13/13] Fix problems with device tree representation of TSI-1xx bridges David Gibson
2007-06-14 14:24 ` Segher Boessenkool
2007-06-13 4:53 ` [PATCH 11/13] Consolidate cuboot initialization code David Gibson
2007-06-13 5:10 ` [0/13] Queued patches for 2.6.13 Segher Boessenkool
2007-06-13 6:09 ` [0/13] Queued patches for 2.6.23 David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070613045259.CFD2FDDF15@ozlabs.org \
--to=david@gibson.dropbear.id.au \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).