Skip to contentSkip to conversation

PPC4xx: Add support for Korat PPC440EPx board

PATCH New Larry Johnson 1 participant 2 messages Nov 2, 2007 1 message not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 PPC4xx: Add support for Korat PPC440EPx board

These patches add support for the PPC440EPx-based "Korat" board to U-Boot. They are based primarily on the Sequoia board support.

---

 MAINTAINERS            |    4 +
 MAKEALL                |    1 +
 Makefile               |    3 +
 board/korat/Makefile   |   51 ++++
 board/korat/config.mk  |   37 +++
 board/korat/init.S     |  123 ++++++++
 board/korat/korat.c    |  762 ++++++++++++++++++++++++++++++++++++++++++++++++
 board/korat/u-boot.lds |  145 +++++++++
 8 files changed, 1126 insertions(+), 0 deletions(-)
MAINTAINERS +4 -0
index b8c1fdc..16caa75 100644
@@ -204,6 +204,10 @@ Murray Jensen <[email protected]>
 	cogent_mpc8260		MPC8260
 	hymod			MPC8260
 
+Larry Johnson <[email protected]>
+
+	korat			PPC440EPx
+
 Brad Kemp <[email protected]>
 
 	ppmc8260		MPC8260
MAKEALL +1 -0
index 20e8137..a0567c5 100755
@@ -187,6 +187,7 @@ LIST_4xx="		\
 	JSE		\
 	KAREF		\
 	katmai		\
+	korat		\
 	luan		\
 	lwmon5		\
 	METROBOX	\
Makefile +3 -0
index 5643aa9..8862ed0 100644
@@ -1168,6 +1168,9 @@ KAREF_config: unconfig
 katmai_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc ppc4xx katmai amcc
 
+korat_config: unconfig
+	@$(MKCONFIG) $(@:_config=) ppc ppc4xx korat
+
 luan_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc ppc4xx luan amcc
 
board/korat/Makefile new file +51 -0

51 lines not on this page · raw message

board/korat/config.mk new file +37 -0
new file mode 100644
index 0000000..39966e0
@@ -0,0 +1,37 @@
+#
+# (C) Copyright 2002
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Korat (PPC440EPx) board
+#
+
+TEXT_BASE = 0xFFFA0000
+
+PLATFORM_CPPFLAGS += -DCONFIG_440=1
+
+ifeq ($(debug),1)
+PLATFORM_CPPFLAGS += -DDEBUG
+endif
+
+ifeq ($(dbcr),1)
+PLATFORM_CPPFLAGS += -DCFG_INIT_DBCR=0x8cff0000
+endif
board/korat/init.S new file +123 -0

123 lines not on this page · raw message

board/korat/korat.c new file +762 -0

762 lines not on this page · raw message

board/korat/u-boot.lds new file +145 -0

145 lines not on this page · raw message

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 4/4 PPC4xx: Add support for Korat PPC440EPx board

Quoted 1 line · Stefan Roese

On Friday 02 November 2007, Larry Johnson wrote:

[...]

Quoted 80 lines
Quoted 19 lines
board/korat/init.S new file +13 -0
new file mode 100644
index 0000000..f44db6c
@@ -0,0 +1,123 @@
+/*
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the

board/korat/init.S line 23

Quoted 10 lines
board/korat/init.S new file +10 -0
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppc_asm.tmpl>
+#include <config.h>

Please add #include <asm-ppc/mmu.h> here and remove all the following defines.

Quoted 48 lines
board/korat/init.S new file +48 -0
+/* General */
+#define TLB_VALID   0x00000200
+#define _256M       0x10000000
+
+/* Supported page sizes */
+
+#define SZ_1K	    0x00000000
+#define SZ_4K	    0x00000010
+#define SZ_16K	    0x00000020
+#define SZ_64K	    0x00000030
+#define SZ_256K	    0x00000040
+#define SZ_1M	    0x00000050
+#define SZ_8M       0x00000060
+#define SZ_16M	    0x00000070
+#define SZ_256M	    0x00000090
+
+/* Storage attributes */
+#define SA_W	    0x00000800	    /* Write-through */
+#define SA_I	    0x00000400	    /* Caching inhibited */
+#define SA_M	    0x00000200	    /* Memory coherence */
+#define SA_G	    0x00000100	    /* Guarded */
+#define SA_E	    0x00000080	    /* Endian */
+
+/* Access control */
+#define AC_X	    0x00000024	    /* Execute */
+#define AC_W	    0x00000012	    /* Write */
+#define AC_R	    0x00000009	    /* Read */
+
+/* Some handy macros */
+
+#define EPN(e)		((e) & 0xfffffc00)
+#define TLB0(epn,sz)	( (EPN((epn)) | (sz) | TLB_VALID ) )
+#define TLB1(rpn,erpn)	( ((rpn)&0xfffffc00) | (erpn) )
+#define TLB2(a)		( (a)&0x00000fbf )
+
+#define tlbtab_start\
+	mflr    r1  ;\
+	bl 0f	    ;
+
+#define tlbtab_end\
+	.long 0, 0, 0	;   \
+0:	mflr    r0	;   \
+	mtlr    r1	;   \
+	blr		;
+
+#define tlbentry(epn,sz,rpn,erpn,attr)\
+	.long TLB0(epn,sz),TLB1(rpn,erpn),TLB2(attr)
+

[...]

Quoted 165 lines

board/korat/init.S

Quoted 3 lines
board/korat/init.S new file +3 -0
+
+	/* take sim card reader and CF controller out of reset */
+	*(unsigned char *)(CFG_CPLD_BASE + 0x04) = 0x80;

Don't use volatile pointer access for peripheral access. Use in_be32() and friends instead.

board/korat/init.S

Quoted 10 lines
board/korat/init.S new file +10 -0
+	/* Configure the two Ethernet PHYs.  For each PHY, configure for fiber
+	 * if the SFP module is present, and for copper if it is not present.
+	 */
+	gpio0_ir = in32(GPIO0_IR);
+	for (eth = 0; eth < 2; ++eth) {
+		if (gpio0_ir & (0x00000001 << (1 - eth))) {
+			/* SFP module not present: configure PHY for copper. */
+			/* Set PHY to autonegotate 10 MB, 100MB, or 1 GB */
+			*(unsigned char *)(CFG_CPLD_BASE + 0x06) |=
+			    0x06 << (4 * eth);

out_8()

board/korat/init.S

Quoted 7 lines
board/korat/init.S new file +7 -0
+		} else {
+			/* SFP module present: configure PHY for fiber and
+			   enable output */
+			out32(GPIO0_OR,
+			      in32(GPIO0_OR) | (0x00000001 << (4 - eth)));
+			out32(GPIO1_OR,
+			      in32(GPIO1_OR) & ~(0x00000001 << (31 - eth)));

out_be32()

board/korat/init.S

Quoted 4 lines
board/korat/init.S new file +4 -0
+		}
+	}
+	/* enable Ethernet: set GPIO45 and GPIO46 to 1 */
+	out32(GPIO1_OR, in32(GPIO1_OR) | 0x00060000);

out_b32()

Quoted 113 lines
board/korat/init.S new file +113 -0
+	/* select Ethernet pins */
+	mfsdr(SDR0_PFC1, sdr0_pfc1);
+	sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) |
+	    SDR0_PFC1_SELECT_CONFIG_4;
+	mfsdr(SDR0_PFC2, sdr0_pfc2);
+	sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) |
+	    SDR0_PFC2_SELECT_CONFIG_4;
+	mtsdr(SDR0_PFC2, sdr0_pfc2);
+	mtsdr(SDR0_PFC1, sdr0_pfc1);
+
+	/* PCI arbiter enabled */
+	mfsdr(sdr_pci0, reg);
+	mtsdr(sdr_pci0, 0x80000000 | reg);
+
+	return 0;
+}
+
+static int man_data_read(unsigned int addr)
+{
+	/*
+	 * Read an octet of data from address "addr" in the manufacturer's
+	 * information serial EEPROM, or -1 on error.
+	 */
+	u8 data[2];
+
+	if (0 != i2c_probe(MAN_DATA_EEPROM_ADDR) ||
+	    0 != i2c_read(MAN_DATA_EEPROM_ADDR, addr, 1, data, 1)) {
+		debug("man_data_read(0x%02X) failed\n", addr);
+		return -1;
+	}
+	debug("man_info_read(0x%02X) returned 0x%02X\n", addr, data[0]);
+	return data[0];
+}
+
+static unsigned int man_data_field_addr(unsigned int const field)
+{
+	/*
+	 * The manufacturer's information serial EEPROM contains a sequence of
+	 * zero-delimited fields.  Return the starting address of field "field",
+	 * or 0 on error.
+	 */
+	unsigned addr, i;
+
+	if (0 == field || 'A' != man_data_read(0) || '\0' != man_data_read(1)) {
+		/* Only format "A" is currently supported */
+		return 0;
+	}
+	for (addr = 2, i = 1; i < field && addr < 256; ++addr) {
+		if ('\0' == man_data_read(addr)) {
+			++i;
+		}
+	}
+	return (addr < 256) ? addr : 0;
+}
+
+static char *man_data_read_field(char s[], unsigned const field,
+				 unsigned const length)
+{
+	/*
+	 * Place the null-terminated contents of field "field" of length
+	 * "length" from the manufacturer's information serial EEPROM into
+	 * string "s[length + 1]" and return a pointer to s, or return 0 on
+	 * error. In either case the original contents of s[] is not preserved.
+	 */
+	unsigned addr, i;
+
+	addr = man_data_field_addr(field);
+	if (0 == addr || addr + length >= 255) {
+		return 0;
+	}
+	for (i = 0; i < length; ++i) {
+		int const c = man_data_read(addr++);
+
+		if (c <= 0) {
+			return 0;
+		}
+		s[i] = (char)c;
+	}
+	if (0 != man_data_read(addr)) {
+		return 0;
+	}
+	s[i] = '\0';
+	return s;
+}
+
+static void set_serial_number(void)
+{
+	/*
+	 * If the environmental variable "serial#" is not set, try to set it
+	 * from the manufacturer's information serial EEPROM.
+	 */
+	char s[MAN_SERIAL_NO_LENGTH + 1];
+
+	if (0 == getenv("serial#") &&
+	    0 != man_data_read_field(s, MAN_SERIAL_NO_FIELD,
+				     MAN_SERIAL_NO_LENGTH)) {
+		setenv("serial#", s);
+	}
+}
+
+static void set_mac_addresses(void)
+{
+	/*
+	 * If the environmental variables "ethaddr" and/or "eth1addr" are not
+	 * set, try to set them from the manufacturer's information serial
+	 * EEPROM.
+	 */
+	char s[MAN_MAC_ADDR_LENGTH + 1];
+
+	if (0 != getenv("ethaddr") && 0 != getenv("eth1addr")) {
+		return;
+	}
+	if (0 == man_data_read_field(s, MAN_MAC_ADDR_FIELD,

board/korat/init.S

Quoted 10 lines
board/korat/init.S new file +10 -0
+				     MAN_MAC_ADDR_LENGTH)) {
+		return;
+	}
+	if (0 == getenv("ethaddr")) {
+		setenv("ethaddr", s);
+	}
+	if (0 == getenv("eth1addr")) {
+		++s[MAN_MAC_ADDR_LENGTH - 1];
+		setenv("eth1addr", s);
+	}

Single line statements without braces (as mentioned earlier).

Quoted 2 lines
board/korat/init.S new file +2 -0
+}
+

[...]

Quoted 13 lines
Quoted 10 lines

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Looks good. Thanks.

Quoted 9 lines

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

Hi Stefan,

I looks like your e-mail was too long for the mailing list (my original was close to the limit) so I've edited it down and left it above for record.

Thanks for your comments. I'll be posting updated patches soon.

-- Larry