Skip to contentSkip to conversation

Add support for the digsy MTC board.

PATCH New Grzegorz Bernacki 2 participants 2 messages Feb 12, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for the digsy MTC board.

This is the InterControl custom device based on the MPC5200B chip.

---
Version 4:
- rebased to Ben's FEC changes
Version 3:
- updated (c)
Version 2:
- use I/O accessor functions instead of volatile pointer
- set ethernet address only if not set in environment
- add some comments and some style cleanup

 MAKEALL                          |    1 +
 Makefile                         |   16 ++
 board/digsy_mtc/Makefile         |   32 ++++
 board/digsy_mtc/config.mk        |   24 +++
 board/digsy_mtc/digsy_mtc.c      |  333 ++++++++++++++++++++++++++++++++++++
 board/digsy_mtc/eeprom.h         |   32 ++++
 board/digsy_mtc/is42s16800a-7t.h |   28 +++
 cpu/mpc5xxx/ide.c                |    2 +-
 include/configs/digsy_mtc.h      |  346 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 813 insertions(+), 1 deletions(-)
 create mode 100644 board/digsy_mtc/Makefile
 create mode 100644 board/digsy_mtc/config.mk
 create mode 100644 board/digsy_mtc/digsy_mtc.c
 create mode 100644 board/digsy_mtc/eeprom.h
 create mode 100644 board/digsy_mtc/is42s16800a-7t.h
 create mode 100644 include/configs/digsy_mtc.h
MAKEALL +1 -0
index cf05133..cd64823 100755
@@ -47,6 +47,7 @@ LIST_5xxx="		\
 	BC3450		\
 	cm5200		\
 	cpci5200	\
+	digsy_mtc	\
 	EVAL5200	\
 	fo300		\
 	icecube_5100	\
Makefile +16 -0
index 787c5f2..424b0d9 100644
@@ -527,6 +527,22 @@ cm5200_config:	unconfig
 cpci5200_config:  unconfig
 	@$(MKCONFIG) -a cpci5200  ppc mpc5xxx cpci5200 esd
 
+digsy_mtc_config \
+digsy_mtc_LOWBOOT_config	\
+digsy_mtc_RAMBOOT_config:	unconfig
+	@mkdir -p $(obj)include
+	@mkdir -p $(obj)board/digsy_mtc
+	@ >$(obj)include/config.h
+	@[ -z "$(findstring LOWBOOT_,$@)" ] || \
+		{ echo "TEXT_BASE = 0xFF000000" >$(obj)board/digsy_mtc/config.tmp ; \
+		  echo "... with LOWBOOT configuration" ; \
+		}
+	@[ -z "$(findstring RAMBOOT_,$@)" ] || \
+		{ echo "TEXT_BASE = 0x00100000" >$(obj)board/digsy_mtc/config.tmp ; \
+		  echo "... with RAMBOOT configuration" ; \
+		}
+	@$(MKCONFIG) -a digsy_mtc  ppc mpc5xxx digsy_mtc
+
 hmi1001_config:	unconfig
 	@$(MKCONFIG) hmi1001 ppc mpc5xxx hmi1001
 
board/digsy_mtc/Makefile new file +32 -0
new file mode 100644
index 0000000..7d659e5
@@ -0,0 +1,32 @@
+
+#
+# Author: Grzegorz Bernacki, Semihalf, gjb at semihalf.com
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).a
+
+COBJS	:= $(BOARD).o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+clean:
+	rm -f $(SOBJS) $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak .depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
board/digsy_mtc/config.mk new file +24 -0
new file mode 100644
index 0000000..e2f14b0
@@ -0,0 +1,24 @@
+#
+# Author: Grzegorz Bernacki, Semihalf, gjb at semihalf.com
+#
+
+#
+# digsyMTC board:
+#
+#	Valid values for TEXT_BASE are:
+#
+#	0xFFF00000   boot high (standard configuration)
+#	0xFE000000   boot low
+#	0x00100000   boot from RAM (for testing only)
+#
+
+sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp
+
+ifndef TEXT_BASE
+## Standard: boot high
+TEXT_BASE = 0xFFF00000
+## For testing: boot from RAM
+# TEXT_BASE = 0x00100000
+endif
+
+PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) -I$(TOPDIR)/board
board/digsy_mtc/digsy_mtc.c new file +333 -0

333 lines not on this page · raw message

board/digsy_mtc/eeprom.h new file +32 -0
new file mode 100644
index 0000000..39e0378
@@ -0,0 +1,32 @@
+/*
+ * (C) Copyright 2009 Semihalf.
+ * Written by: Grzegorz Bernacki <[email protected]>
+ *
+ * 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 anty 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
+ *
+ */
+#ifndef CMD_EEPROM_H
+#define CMD_EEPROM_H
+
+#define EEPROM_ADDR		CONFIG_SYS_I2C_EEPROM_ADDR
+#define EEPROM_LEN		1024	/* eeprom length */
+#define EEPROM_IDENT		2408	/* identification word */
+#define EEPROM_ADDR_IDENT	0	/* identification word offset */
+#define EEPROM_ADDR_LEN_SYS	2	/* system area lenght offset */
+#define EEPROM_ADDR_LEN_SYSCFG	4	/* system config area length offset */
+#define EEPROM_ADDR_ETHADDR	23	/* ethernet addres offset */
+
+#endif
board/digsy_mtc/is42s16800a-7t.h new file +28 -0
new file mode 100644
index 0000000..1873ea7
@@ -0,0 +1,28 @@
+/*
+ * (C) Copyright 2004-2009
+ * Mark Jonas, Freescale Semiconductor, mark.jonas at motorola.com.
+ *
+ * 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
+ */
+
+#define SDRAM_MODE	0x00CD0000
+#define SDRAM_CONTROL	0x505F0000
+#define SDRAM_CONFIG1	0xD2322900
+#define SDRAM_CONFIG2	0x8AD70000
+
cpu/mpc5xxx/ide.c +1 -1
index df5b4ac..88da199 100644
@@ -42,7 +42,7 @@ int ide_preinit (void)
 	struct mpc5xxx_sdma *psdma = (struct mpc5xxx_sdma *) MPC5XXX_SDMA;
 
 	reg = *(vu_long *) MPC5XXX_GPS_PORT_CONFIG;
-#if defined(CONFIG_TOTAL5200)
+#if defined(CONFIG_TOTAL5200) || defined(CONFIG_DIGSY_MTC)
 	/* ATA cs0/1 on i2c2 clk/io */
 	reg = (reg & ~0x03000000ul) | 0x02000000ul;
 #else
include/configs/digsy_mtc.h new file +346 -0

346 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#1 lore raw

PATCH 1/1 Add support for the digsy MTC board.

Quoted 3 lines · Grzegorz Bernacki

This is the InterControl custom device based on the MPC5200B chip.

Please find some comments below.

Quoted 50 lines
board/digsy_mtc/digsy_mtc.c new file +44 -0
new file mode 100644
index 0000000..0cde8a8
@@ -0,0 +1,333 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * (C) Copyright 2004
+ * Mark Jonas, Freescale Semiconductor, mark.jonas at motorola.com.
+ *
+ * (C) Copyright 2005-2009
+ * Modified for InterControl digsyMTC MPC5200 board by
+ * Frank Bodammer, GCD Hard- & Software GmbH,
+ *                 frank.bodammer at gcd-solutions.de
+ *
+ * (C) Copyright 2009
+ * Grzegorz Bernacki, Semihalf, gjb at semihalf.com
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <mpc5xxx.h>
+#include <pci.h>
+#include <asm/processor.h>
+#include <i2c.h>
+#include "eeprom.h"
+#include "is42s16800a-7t.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+

board/digsy_mtc/digsy_mtc.c line 54

Quoted 10 lines
board/digsy_mtc/digsy_mtc.c new file +10 -0
+extern int usb_cpu_init(void);
+
+#ifndef CONFIG_SYS_RAMBOOT
+static void sdram_start(int hi_addr)
+{
+	long hi_addr_bit = hi_addr ? 0x01000000 : 0;
+	long control = SDRAM_CONTROL | hi_addr_bit;
+
+	/* unlock mode register */
+	out32(MPC5XXX_SDRAM_CTRL, control | 0x80000000);

Please use the out_be32()/in_be32() accessor functions for accessing SoC perepherals instead. They have the io-barriers included. You could git into trouble by "just" using out/in32(). This is a general comment meant for the complete patch.

Quoted 43 lines
board/digsy_mtc/digsy_mtc.c new file +17 -0
+
+	/* precharge all banks */
+	out32(MPC5XXX_SDRAM_CTRL, control | 0x80000002);
+
+	/* auto refresh */
+	out32(MPC5XXX_SDRAM_CTRL, control | 0x80000004);
+
+	/* set mode register */
+	out32(MPC5XXX_SDRAM_MODE, SDRAM_MODE);
+
+	/* normal operation */
+	out32(MPC5XXX_SDRAM_CTRL, control);
+}
+#endif
+
+/*
+ * ATTENTION: Although partially referenced initdram does NOT make real

use + * use of CONFIG_SYS_SDRAM_BASE. The code does not work if
+ * CONFIG_SYS_SDRAM_BASE is something else than 0x00000000. +
*/

board/digsy_mtc/digsy_mtc.c new file +23 -0
+
+phys_size_t initdram(int board_type)
+{
+	ulong dramsize = 0;
+	ulong dramsize2 = 0;
+	uint svr, pvr;
+#ifndef CONFIG_SYS_RAMBOOT
+	ulong test1, test2;
+
+	/* setup SDRAM chip selects */
+	out32(MPC5XXX_SDRAM_CS0CFG, 0x0000001C);	/* 512MB at 0x0 */
+	out32(MPC5XXX_SDRAM_CS1CFG, 0x80000000);	/* disabled */
+
+	/* setup config registers */
+	out32(MPC5XXX_SDRAM_CONFIG1, SDRAM_CONFIG1);
+	out32(MPC5XXX_SDRAM_CONFIG2, SDRAM_CONFIG2);
+
+	/* find RAM size using SDRAM CS0 only */
+	sdram_start(0);
+	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
+	sdram_start(1);
+	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
+	if (test1 > test2) {

board/digsy_mtc/digsy_mtc.c line 107

Quoted 10 lines
board/digsy_mtc/digsy_mtc.c new file +10 -0
+		sdram_start(0);
+		dramsize = test1;
+	} else {
+		dramsize = test2;
+	}
+
+	/* memory smaller than 1MB is impossible */
+	if (dramsize < (1 << 20)) {
+		dramsize = 0;
+	}

Nitpicking: Remove the curly braces for single-line statements.

Quoted 11 lines
board/digsy_mtc/digsy_mtc.c new file +11 -0
+
+	/* set SDRAM CS0 size according to the amount of RAM found */
+	if (dramsize > 0) {
+		out32(MPC5XXX_SDRAM_CS0CFG,
+			(0x13 + __builtin_ffs(dramsize >> 20) - 1));
+	} else {
+		out32(MPC5XXX_SDRAM_CS0CFG, 0); /* disabled */
+	}
+
+	/* let SDRAM CS1 start right after CS0 */
+	out32(MPC5XXX_SDRAM_CS1CFG, dramsize + 0x0000001C); /* 512MB */

board/digsy_mtc/digsy_mtc.c line 128

Quoted 10 lines
board/digsy_mtc/digsy_mtc.c new file +10 -0
+
+	/* find RAM size using SDRAM CS1 only */
+	test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
+			0x08000000);
+		dramsize2 = test1;
+
+	/* memory smaller than 1MB is impossible */
+	if (dramsize2 < (1 << 20)) {
+		dramsize2 = 0;
+	}

Again. Not curly braces here.

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
=====================================================================