[U-Boot-Users] [PATCH 2/2] Add board specific files for BUBBATWO

Tor Krill tor at excito.com
Mon Jun 2 15:16:02 CEST 2008


Signed-off-by: Tor Krill <tor at excito.com>
---
 board/excito/bubbatwo/Makefile         |   50 +++++++++
 board/excito/bubbatwo/bubba_commands.c |   93 +++++++++++++++++
 board/excito/bubbatwo/bubbatwo.c       |  175 ++++++++++++++++++++++++++++++++
 board/excito/bubbatwo/bubbatwo.h       |   30 ++++++
 board/excito/bubbatwo/config.mk        |    1 +
 board/excito/bubbatwo/sdram.c          |  167 ++++++++++++++++++++++++++++++
 6 files changed, 516 insertions(+), 0 deletions(-)
 create mode 100644 board/excito/bubbatwo/Makefile
 create mode 100644 board/excito/bubbatwo/bubba_commands.c
 create mode 100644 board/excito/bubbatwo/bubbatwo.c
 create mode 100644 board/excito/bubbatwo/bubbatwo.h
 create mode 100644 board/excito/bubbatwo/config.mk
 create mode 100644 board/excito/bubbatwo/sdram.c

diff --git a/board/excito/bubbatwo/Makefile b/board/excito/bubbatwo/Makefile
new file mode 100644
index 0000000..e379e0e
--- /dev/null
+++ b/board/excito/bubbatwo/Makefile
@@ -0,0 +1,50 @@
+#
+# (C) Copyright 2006
+# 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
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).a
+
+COBJS	:= $(BOARD).o sdram.o bubba_commands.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
+
+#########################################################################
diff --git a/board/excito/bubbatwo/bubba_commands.c b/board/excito/bubbatwo/bubba_commands.c
new file mode 100644
index 0000000..7ac76e4
--- /dev/null
+++ b/board/excito/bubbatwo/bubba_commands.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) Excito Elektronik i Skåne AB, All rights reserved.
+ * Author: Tor Krill <tor at excito.com>
+ *
+ * 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
+ */
+
+#ifndef BUBBA_COMMANDS_H
+#define BUBBA_COMMANDS_H
+
+#include <common.h>
+#include <config.h>
+#include <command.h>
+
+#include <mpc83xx.h>
+
+#include "bubbatwo.h"
+
+/* Prototypes from sata_sil3114.c */
+
+u8 sil3114_spin_up (int num);
+u8 sil3114_spin_down (int num);
+
+static int pollbutton ()
+{
+	volatile immap_t *im = (immap_t *) CFG_IMMR;
+
+	return im->gpio[0].dat & BUTTON;
+}
+
+int do_bubbacmd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	int ret = 0, dev;
+
+	switch (argc) {
+	case 0:
+	case 1:
+	case 2:
+		if (strncmp (argv[1], "button", 6) == 0) {
+			printf ("Button status: %d\n", pollbutton ());
+		} else {
+			printf ("Usage:\n%s\n", cmdtp->usage);
+			return 1;
+		}
+		break;
+	case 3:
+		if (strncmp (argv[1], "spindown", 8) == 0) {
+			dev = (int)simple_strtoul (argv[2], NULL, 10);
+			if (dev >= CFG_SATA_MAX_DEVICE) {
+				puts ("Unknown device\n");
+				return 1;
+			}
+			ret = sil3114_spin_down (dev);
+		} else if (strncmp (argv[1], "spinup", 6) == 0) {
+			dev = (int)simple_strtoul (argv[2], NULL, 10);
+			if (dev >= CFG_SATA_MAX_DEVICE) {
+				puts ("Unknown device\n");
+				return 1;
+			}
+			ret = sil3114_spin_up (dev);
+		} else {
+			printf ("Usage:\n%s\n", cmdtp->usage);
+			return 1;
+		}
+		break;
+	default:
+		printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	return ret;
+
+}
+
+U_BOOT_CMD (bubbacmd, 3, 1, do_bubbacmd,
+		"bubbacmd- Board specific commands for Bubba TWO\n",
+		"spindown [dev] - spin down disk dev\n"
+		"bubbacmd spinup [dev] - spin up disk dev\n"
+		"bubbacmd button - read button status\n");
+#endif
diff --git a/board/excito/bubbatwo/bubbatwo.c b/board/excito/bubbatwo/bubbatwo.c
new file mode 100644
index 0000000..5975822
--- /dev/null
+++ b/board/excito/bubbatwo/bubbatwo.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
+ * Copyright (C) Excito Elektronik i Skåne, 2008.
+ *
+ * Author: Scott Wood <scottwood at freescale.com>
+ * Modified for Bubba board: Tor Krill <tor at excito.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>
+#if defined(CONFIG_OF_LIBFDT)
+#include <libfdt.h>
+#endif
+#include <pci.h>
+#include <mpc83xx.h>
+
+#include "bubbatwo.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_early_init_f (void)
+{
+	volatile immap_t *im = (immap_t *) CFG_IMMR;
+
+#ifndef CFG_8313ERDB_BROKEN_PMC
+	if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
+		gd->flags |= GD_FLG_SILENT;
+#endif
+
+	/* Setup iopins and check button */
+	/* Disable open drain on pwr on */
+	im->gpio[0].odr &= ~(1 << 0);
+	/* Set pwr on direction to output */
+	im->gpio[0].dir |= (1 << 0);
+	/* Set HW-ID[0,1,2] and pwr btn to input */
+	im->gpio[0].dir &= ~(HW_ID0 | HW_ID1 | HW_ID2 | BUTTON);
+	/* Set pwr on high */
+	im->gpio[0].dat |= (1 << 0);
+
+	/* Program PVM for LED */
+
+	/* Reset timer 1 and 2 */
+	im->gtm[0].cfr1 = 0x00;
+	/* Enable timer 1, stopped and choose normal operation */
+	im->gtm[0].cfr1 = 0x03;
+
+	/* Timer prescaler set to 0x0f
+	 * resulting in a prescale of 0x10
+	 */
+	im->gtm[0].psr1 = 0x0f;
+
+	/* Set prescale value and set restart 
+	 * when timer meets reference value 
+	 * Use internal system clock*/
+	im->gtm[0].mdr1 |= 0x800a;
+
+	/* Set reference value */
+	im->gtm[0].rfr1 = 0x8000;
+
+	/* Start timer1 */
+	im->gtm[0].cfr1 = 0x01;
+
+	return 0;
+}
+
+int getboardversion (void)
+{
+	volatile immap_t *im = (immap_t *) CFG_IMMR;
+	int rev = im->gpio[0].dat & (HW_ID0 | HW_ID1 | HW_ID2);
+
+	rev =
+		((rev & HW_ID0) >> 3) | ((rev & HW_ID1) >> 2) | ((rev & HW_ID2) <<
+								1);
+
+	return rev;
+}
+
+int checkboard (void)
+{
+	printf ("Board: Excito BUBBA|TWO (rev %d)\n", getboardversion ());
+	return 0;
+}
+
+static struct pci_region pci_regions[] = {
+	{
+		bus_start:CFG_PCI1_MEM_BASE,
+		phys_start:CFG_PCI1_MEM_PHYS,
+		size:CFG_PCI1_MEM_SIZE,
+		flags:PCI_REGION_MEM | PCI_REGION_PREFETCH},
+	{
+		bus_start:CFG_PCI1_MMIO_BASE,
+		phys_start:CFG_PCI1_MMIO_PHYS,
+		size:CFG_PCI1_MMIO_SIZE,
+		flags:PCI_REGION_MEM},
+	{
+		bus_start:CFG_PCI1_IO_BASE,
+		phys_start:CFG_PCI1_IO_PHYS,
+		size:CFG_PCI1_IO_SIZE,
+		flags:PCI_REGION_IO}
+};
+
+void pci_init_board (void)
+{
+	volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
+	volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
+	volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+	struct pci_region *reg[] = { pci_regions };
+	int warmboot;
+
+	/* Enable all 3 PCI_CLK_OUTPUTs. */
+	clk->occr |= 0xe0000000;
+
+	/*
+	 * Configure PCI Local Access Windows
+	 */
+	pci_law[0].bar = CFG_PCI1_MEM_PHYS & LAWBAR_BAR;
+	pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
+
+	pci_law[1].bar = CFG_PCI1_IO_PHYS & LAWBAR_BAR;
+	pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
+
+	warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
+#ifndef CFG_8313ERDB_BROKEN_PMC
+	warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF;
+#endif
+
+	mpc83xx_pci_init (1, reg, warmboot);
+}
+
+#ifdef CONFIG_FLASH_CFI_LEGACY
+
+/*
+ * Hardcoded flash setup:
+ * Flash 0 is a non-CFI Spansion S29AL004D flash, 16 bit flash / 16 bit bus.
+ */
+ulong board_flash_get_legacy (ulong base, int banknum, flash_info_t * info)
+{
+	if (banknum == 0) {	/* non-CFI boot flash */
+		info->portwidth = FLASH_CFI_16BIT;
+		info->chipwidth = FLASH_CFI_BY16;
+		info->interface = FLASH_CFI_X16;
+		return 1;
+	} else {
+		return 0;
+	}
+}
+
+#endif
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+void ft_board_setup (void *blob, bd_t * bd)
+{
+	ft_cpu_setup (blob, bd);
+#ifdef CONFIG_PCI
+	ft_pci_setup (blob, bd);
+#endif
+}
+#endif
diff --git a/board/excito/bubbatwo/bubbatwo.h b/board/excito/bubbatwo/bubbatwo.h
new file mode 100644
index 0000000..972819d
--- /dev/null
+++ b/board/excito/bubbatwo/bubbatwo.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) Excito Elektronik i Skåne AB, All rights reserved.
+ * Author: Tor Krill <tor at excito.com>
+ *
+ * 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
+ */
+
+/* GPIO definitions */
+#define HW_IDMASK	0x07
+#define HW_ID0	(1<<3)
+#define HW_ID1	(1<<2)
+#define HW_ID2	(1<<0)
+
+#define BUTTON	(1<<1)
+
+int getboardversion(void);
+
diff --git a/board/excito/bubbatwo/config.mk b/board/excito/bubbatwo/config.mk
new file mode 100644
index 0000000..f768264
--- /dev/null
+++ b/board/excito/bubbatwo/config.mk
@@ -0,0 +1 @@
+TEXT_BASE = 0xFE000000
diff --git a/board/excito/bubbatwo/sdram.c b/board/excito/bubbatwo/sdram.c
new file mode 100644
index 0000000..5169893
--- /dev/null
+++ b/board/excito/bubbatwo/sdram.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
+ * Copyright (C) Excito Elektronik i Skåne, 2008.
+ *
+ * Authors: Nick.Spence at freescale.com
+ *          Wilson.Lo at freescale.com
+ *          scottwood at freescale.com
+ *          tor at excito.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 <mpc83xx.h>
+#include <spd_sdram.h>
+
+#include <asm/bitops.h>
+#include <asm/io.h>
+
+#include <asm/processor.h>
+
+#include "bubbatwo.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef CFG_8313ERDB_BROKEN_PMC
+static void resume_from_sleep (void)
+{
+	u32 magic = *(u32 *) 0;
+
+	typedef void (*func_t) (void);
+	func_t resume = *(func_t *) 4;
+
+	if (magic == 0xf5153ae5)
+		resume ();
+
+	gd->flags &= ~GD_FLG_SILENT;
+	puts ("\nResume from sleep failed: bad magic word\n");
+}
+#endif
+
+/* Lookup table for the different boardversions */
+static struct {
+	u32 memsize;
+	u32 config;
+} meminfo[] = {
+	/* 0 - revA  prototypes */
+	{
+		memsize: 128, config:CFG_DDR_CONFIG_128},
+	/* 1 - revB */
+	{
+		memsize: 256, config:CFG_DDR_CONFIG_256},
+	/* 2 - empty */
+	{
+		memsize: 128, config:CFG_DDR_CONFIG_128},
+	/* 3 - empty */
+	{
+		memsize: 128, config:CFG_DDR_CONFIG_128},
+	/* 4 - empty */
+	{
+		memsize: 128, config:CFG_DDR_CONFIG_128},
+	/* 5 - empty */
+	{
+		memsize: 128, config:CFG_DDR_CONFIG_128},
+	/* 6 - empty */
+	{
+		memsize: 128, config:CFG_DDR_CONFIG_128},
+	/* 7 - empty */
+	{
+		memsize: 128, config:CFG_DDR_CONFIG_128}
+};
+
+/* Fixed sdram init -- doesn't use serial presence detect.
+ *
+ * This is useful for faster booting in configs where the RAM is unlikely
+ * to be changed, or for things like NAND booting where space is tight.
+ */
+static long fixed_sdram (void)
+{
+	volatile immap_t *im = (volatile immap_t *)CFG_IMMR;
+	int bver = getboardversion () & HW_IDMASK;
+	u32 msize = meminfo[bver].memsize * 1024 * 1024;
+	u32 msize_log2 = __ilog2 (msize);
+
+	im->sysconf.ddrlaw[0].bar = CFG_DDR_SDRAM_BASE >> 12;
+	im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1);
+	im->sysconf.ddrcdr = CFG_DDRCDR_VALUE;
+
+	/*
+	 * Erratum DDR3 requires a 50ms delay after clearing DDRCDR[DDR_cfg],
+	 * or the DDR2 controller may fail to initialize correctly.
+	 */
+	udelay (50000);
+
+	im->ddr.csbnds[0].csbnds = (msize - 1) >> 24;
+	im->ddr.cs_config[0] = meminfo[bver].config;
+
+	/* Currently we use only one CS, so disable the other bank. */
+	im->ddr.cs_config[1] = 0;
+
+	im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
+	im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
+	im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
+	im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
+	im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
+
+#ifndef CFG_8313ERDB_BROKEN_PMC
+	if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
+		im->ddr.sdram_cfg = CFG_SDRAM_CFG | SDRAM_CFG_BI;
+	else
+#endif
+		im->ddr.sdram_cfg = CFG_SDRAM_CFG;
+
+	im->ddr.sdram_cfg2 = CFG_SDRAM_CFG2;
+	im->ddr.sdram_mode = CFG_DDR_MODE;
+	im->ddr.sdram_mode2 = CFG_DDR_MODE_2;
+
+	im->ddr.sdram_interval = CFG_DDR_INTERVAL;
+	sync ();
+
+	/* enable DDR controller */
+	im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
+
+	return msize;
+}
+
+long int initdram (int board_type)
+{
+	volatile immap_t *im = (volatile immap_t *)CFG_IMMR;
+	volatile lbus83xx_t *lbc = &im->lbus;
+	u32 msize;
+
+	if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
+		return -1;
+
+	/* DDR SDRAM - Main SODIMM */
+	msize = fixed_sdram ();
+
+	/* Local Bus setup lbcr and mrtpr */
+	lbc->lbcr = CFG_LBC_LBCR;
+	lbc->mrtpr = CFG_LBC_MRTPR;
+	sync ();
+
+#ifndef CFG_8313ERDB_BROKEN_PMC
+	if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
+		resume_from_sleep ();
+#endif
+
+	/* return total bus SDRAM size(bytes)  -- DDR */
+	return msize;
+}
-- 
1.5.5.3




More information about the U-Boot mailing list