summaryrefslogtreecommitdiffstats
path: root/arch/blackfin/boards/ipe337
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/boards/ipe337')
-rw-r--r--arch/blackfin/boards/ipe337/Makefile4
-rw-r--r--arch/blackfin/boards/ipe337/barebox.lds.S87
-rw-r--r--arch/blackfin/boards/ipe337/cmd_alternate.c56
-rw-r--r--arch/blackfin/boards/ipe337/config.h46
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/_alternate9
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/_update37
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/boot54
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/init24
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/magic.bin1
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/reset_ageing27
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/update_application8
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/update_bareboxenv8
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/update_kernel19
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/update_persistent8
-rw-r--r--arch/blackfin/boards/ipe337/env/bin/update_system19
-rw-r--r--arch/blackfin/boards/ipe337/env/config27
-rw-r--r--arch/blackfin/boards/ipe337/ipe337.c68
-rw-r--r--arch/blackfin/boards/ipe337/ipe337.dox10
18 files changed, 512 insertions, 0 deletions
diff --git a/arch/blackfin/boards/ipe337/Makefile b/arch/blackfin/boards/ipe337/Makefile
new file mode 100644
index 0000000000..172dfb688c
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/Makefile
@@ -0,0 +1,4 @@
+obj-y += ipe337.o
+obj-y += cmd_alternate.o
+
+extra-y += barebox.lds
diff --git a/arch/blackfin/boards/ipe337/barebox.lds.S b/arch/blackfin/boards/ipe337/barebox.lds.S
new file mode 100644
index 0000000000..4299b8208b
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/barebox.lds.S
@@ -0,0 +1,87 @@
+/*
+ * barebox - barebox.lds.S
+ *
+ * Copyright (c) 2005-2007 Analog Device Inc.
+ *
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd@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 <config.h>
+#include <asm-generic/barebox.lds.h>
+
+OUTPUT_ARCH("bfin")
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib);
+/* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+/*
+MEMORY
+{
+ ram : ORIGIN = (0x2000000), LENGTH = (256 * 1024)
+ l1_code : ORIGIN = 0xFFA00000, LENGTH = 0xC000
+ l1_data : ORIGIN = 0xFF900000, LENGTH = 0x4000
+}
+*/
+
+SECTIONS
+{
+ . = TEXT_BASE;
+
+ . = ALIGN(4);
+ .text :
+ {
+ __stext = .;
+ __text = .;
+ _text = .;
+ *(.text_entry)
+ *(.text)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata) }
+
+ __etext = .; /* End of text and rodata section */
+
+ . = ALIGN(4);
+ .data : { *(.data) }
+
+ . = ALIGN(4);
+ .got : { *(.got) }
+
+ . = .;
+ ___barebox_cmd_start = .;
+ .barebox_cmd : { BAREBOX_CMDS }
+ ___barebox_cmd_end = .;
+
+ ___barebox_initcalls_start = .;
+ .barebox_initcalls : { INITCALLS }
+ ___barebox_initcalls_end = .;
+
+ ___usymtab_start = .;
+ __usymtab : { BAREBOX_SYMS }
+ ___usymtab_end = .;
+
+ . = ALIGN(4);
+ __bss_start = .;
+ .bss : { *(.bss) }
+ _end = .;
+}
+
diff --git a/arch/blackfin/boards/ipe337/cmd_alternate.c b/arch/blackfin/boards/ipe337/cmd_alternate.c
new file mode 100644
index 0000000000..2883c77d32
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/cmd_alternate.c
@@ -0,0 +1,56 @@
+#include <common.h>
+#include <command.h>
+#include <linux/stat.h>
+#include <malloc.h>
+#include <fs.h>
+
+#define MAGIC 0x19691228
+
+static int do_alternate(struct command *cmdtp, int argc, char *argv[])
+{
+ void *buf;
+ size_t size;
+ ulong *ptr, val = 0, bitcount = 0;
+
+ if (argc != 2)
+ return COMMAND_ERROR_USAGE;
+
+ buf = read_file(argv[1], &size);
+ if (!buf)
+ return 1;
+
+ ptr = buf;
+ if ((*ptr) != MAGIC) {
+ printf("Wrong magic! Expected 0x%08x, got 0x%08x.\n", MAGIC, *ptr);
+ return 1;
+ }
+
+ ptr++;
+
+ while ((ulong)ptr <= (ulong)buf + size && !(val = *ptr++))
+ bitcount += 32;
+
+ if (val) {
+ do {
+ if (val & 1)
+ break;
+ bitcount++;
+ } while (val >>= 1);
+ }
+
+ printf("Bitcount : %d\n", bitcount);
+
+ free(buf);
+ return (bitcount & 1) ? 3 : 2;
+}
+
+static const __maybe_unused char cmd_alternate_help[] =
+"Usage: alternate <file>"
+"\n";
+
+BAREBOX_CMD_START(alternate)
+ .cmd = do_alternate,
+ .usage = "count zero bits in a file",
+ BAREBOX_CMD_HELP(cmd_alternate_help)
+BAREBOX_CMD_END
+
diff --git a/arch/blackfin/boards/ipe337/config.h b/arch/blackfin/boards/ipe337/config.h
new file mode 100644
index 0000000000..aa25d0792d
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/config.h
@@ -0,0 +1,46 @@
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * Clock settings
+ */
+
+/* CONFIG_CLKIN_HZ is any value in Hz */
+#if defined(CONFIG_MACH_IPE337_V1)
+#define CONFIG_CLKIN_HZ 25000000
+#elif defined(CONFIG_MACH_IPE337_V2)
+#define CONFIG_CLKIN_HZ 40000000
+#else
+#error "Unknown IPE337 revision"
+#endif
+
+/* CONFIG_CLKIN_HALF controls what is passed to PLL 0=CLKIN */
+/* 1=CLKIN/2 */
+#define CONFIG_CLKIN_HALF 0
+/* CONFIG_PLL_BYPASS controls if the PLL is used 0=don't bypass */
+/* 1=bypass PLL */
+#define CONFIG_PLL_BYPASS 0
+/* CONFIG_VCO_MULT controls what the multiplier of the PLL is. */
+/* Values can range from 1-64 */
+#define CONFIG_VCO_MULT 10 /* POR default */
+/* CONFIG_CCLK_DIV controls what the core clock divider is */
+/* Values can be 1, 2, 4, or 8 ONLY */
+#define CONFIG_CCLK_DIV 1 /* POR default */
+/* CONFIG_SCLK_DIV controls what the peripheral clock divider is */
+/* Values can range from 1-15 */
+#define CONFIG_SCLK_DIV 5 /* POR default */
+
+/* Frequencies selected: 400MHz CCLK / 80MHz SCLK ^= 12.5ns cycle time*/
+
+#define AMGCTLVAL 0x1F
+
+/* no need for speed, currently, leave at defaults */
+#define AMBCTL0VAL 0xFFC2FFC2
+#define AMBCTL1VAL 0xFFC2FFC2
+
+#define CONFIG_MEM_MT48LC16M16A2TG_75 1
+#define CONFIG_MEM_ADD_WDTH 9 /* 8, 9, 10, 11 */
+#define CONFIG_MEM_SIZE 64 /* 128, 64, 32, 16 */
+
+#endif /* __CONFIG_H */
diff --git a/arch/blackfin/boards/ipe337/env/bin/_alternate b/arch/blackfin/boards/ipe337/env/bin/_alternate
new file mode 100644
index 0000000000..10ae2134c0
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/_alternate
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. /env/config
+
+alternate $ageing
+if [ $? -lt 2 ]; then
+ echo "Error when accesing ageing-partition!"
+ exit 1
+fi
diff --git a/arch/blackfin/boards/ipe337/env/bin/_update b/arch/blackfin/boards/ipe337/env/bin/_update
new file mode 100644
index 0000000000..5419ece6a7
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/_update
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+if [ $# = 1 ]; then
+ image=$1
+fi
+
+if [ -z "$part" -o -z "$image" ]; then
+ echo "define \$part and \$image"
+ exit 1
+fi
+
+if [ ! -e "$part" ]; then
+ echo "Partition $part does not exist"
+ exit 1
+fi
+
+if [ x$ip = xdhcp ]; then
+ dhcp
+fi
+
+ping $eth0.serverip
+if [ $? -ne 0 ] ; then
+ echo "update aborted"
+ exit 1
+fi
+
+unprotect $part
+
+echo
+echo "Erasing partition $part"
+erase $part
+
+echo
+echo "Flashing $image to $part"
+tftp $image $part
+
+protect $part
diff --git a/arch/blackfin/boards/ipe337/env/bin/boot b/arch/blackfin/boards/ipe337/env/bin/boot
new file mode 100644
index 0000000000..62807d211f
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/boot
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+. /env/config
+
+alternate $ageing
+ret=$?
+
+if [ $ret = 0 ]; then
+ echo "Error when accesing ageing-partition!"
+ exit 1
+elif [ $ret = 2 ]; then
+ act_kernel=/dev/nor0.kernel0
+ act_rootfs=/dev/mtdblock5
+else
+ act_kernel=/dev/nor0.kernel1
+ act_rootfs=/dev/mtdblock6
+fi
+echo "-> Active kernel: $act_kernel"
+echo "-> Active system: $act_rootfs"
+echo
+
+if [ x$1 = xflash ]; then
+ root=flash
+ kernel=flash
+fi
+
+if [ x$1 = xnet ]; then
+ root=net
+ kernel=net
+fi
+
+if [ x$ip = xdhcp ]; then
+ bootargs="$bootargs ip=dhcp"
+else
+ bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
+fi
+
+if [ x$root = xflash ]; then
+ bootargs="$bootargs root=$act_rootfs rootfstype=jffs2"
+else
+ bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
+fi
+
+bootargs="$bootargs mtdparts=physmap-flash.0:$mtdparts"
+
+if [ $kernel = net ]; then
+ if [ x$ip = xdhcp ]; then
+ dhcp
+ fi
+ tftp $uimage uImage || exit 1
+ bootm uImage
+else
+ bootm $act_kernel
+fi
diff --git a/arch/blackfin/boards/ipe337/env/bin/init b/arch/blackfin/boards/ipe337/env/bin/init
new file mode 100644
index 0000000000..e864dc5a42
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/init
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+addpart /dev/nor0 $mtdparts
+
+echo
+echo -n "Hit any key to stop autoboot: "
+timeout -a $autoboot_timeout
+if [ $? != 0 ]; then
+ echo
+ echo "Type update_kernel [<imagename>] to update kernel into flash."
+ echo "Type update_system [<imagename>] to update rootfs into flash."
+ echo "Type update_application [<imagename>] to update applications into flash."
+ echo "Type update_persistent [<imagename>] to update persistent into flash."
+ echo "Type update_bareboxenv [<imagename>] to update bareboxenv into flash (use with care!)."
+ echo "Type reset_ageing to initialize the ageing partittion (use with care!)."
+ echo
+ exit
+fi
+
+boot
diff --git a/arch/blackfin/boards/ipe337/env/bin/magic.bin b/arch/blackfin/boards/ipe337/env/bin/magic.bin
new file mode 100644
index 0000000000..f8bff393cf
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/magic.bin
@@ -0,0 +1 @@
+(i \ No newline at end of file
diff --git a/arch/blackfin/boards/ipe337/env/bin/reset_ageing b/arch/blackfin/boards/ipe337/env/bin/reset_ageing
new file mode 100644
index 0000000000..2c95ae762e
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/reset_ageing
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+. /env/config
+
+image=/env/bin/magic.bin
+part=$ageing
+
+if [ \! -e "$part" ]; then
+ echo "Partition $part does not exist"
+ exit 1
+fi
+
+unprotect $part
+
+echo
+echo "Erasing partition $part"
+erase $part
+
+echo
+echo "Creating magic"
+cp $image $part
+
+echo
+echo "Testing partition"
+. /env/bin/_alternate
+
+protect $part
diff --git a/arch/blackfin/boards/ipe337/env/bin/update_application b/arch/blackfin/boards/ipe337/env/bin/update_application
new file mode 100644
index 0000000000..46ad210e36
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/update_application
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. /env/config
+
+image=$appimage
+part=/dev/nor0.application
+
+. /env/bin/_update $1
diff --git a/arch/blackfin/boards/ipe337/env/bin/update_bareboxenv b/arch/blackfin/boards/ipe337/env/bin/update_bareboxenv
new file mode 100644
index 0000000000..b0a32c626b
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/update_bareboxenv
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. /env/config
+
+image=$envimage
+part=/dev/nor0.bareboxenv
+
+. /env/bin/_update $1
diff --git a/arch/blackfin/boards/ipe337/env/bin/update_kernel b/arch/blackfin/boards/ipe337/env/bin/update_kernel
new file mode 100644
index 0000000000..d5c210eb2b
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/update_kernel
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+. /env/config
+
+image=$uimage
+
+alternate $ageing
+ret=$?
+
+if [ $ret = 0 ]; then
+ echo "Error when accesing ageing-partition!"
+ exit 1
+elif [ $ret = 2 ]; then
+ part=/dev/nor0.kernel0
+else
+ part=/dev/nor0.kernel1
+fi
+
+. /env/bin/_update $1
diff --git a/arch/blackfin/boards/ipe337/env/bin/update_persistent b/arch/blackfin/boards/ipe337/env/bin/update_persistent
new file mode 100644
index 0000000000..a869b2218d
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/update_persistent
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. /env/config
+
+image=$perimage
+part=/dev/nor0.persistent
+
+. /env/bin/_update $1
diff --git a/arch/blackfin/boards/ipe337/env/bin/update_system b/arch/blackfin/boards/ipe337/env/bin/update_system
new file mode 100644
index 0000000000..598fc10e81
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/bin/update_system
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+. /env/config
+
+image=$jffs2
+
+alternate $ageing
+ret=$?
+
+if [ $ret = 0 ]; then
+ echo "Error when accesing ageing-partition!"
+ exit 1
+elif [ $ret = 2 ]; then
+ part=/dev/nor0.system0
+else
+ part=/dev/nor0.system1
+fi
+
+. /env/bin/_update $1
diff --git a/arch/blackfin/boards/ipe337/env/config b/arch/blackfin/boards/ipe337/env/config
new file mode 100644
index 0000000000..7c5ee76e30
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/env/config
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# can be either 'net' or 'flash'
+kernel=net
+root=net
+
+# use 'dhcp' todo dhcp in barebox and in kernel
+#ip=dhcp
+
+eth0.ipaddr=192.168.23.164
+eth0.netmask=255.255.255.0
+eth0.gateway=192.168.23.2
+eth0.serverip=192.168.23.2
+
+uimage=uImage-bfin
+jffs2=root-bfin.jffs2
+appimage=apps-bfin
+perimage=pers-bfin
+envimage=uEnv-bfin
+
+autoboot_timeout=1
+
+nfsroot="/ptx/work/octopus/wsa/svn/OSELAS.BSP-Pipetronix-ipe337-trunk/root"
+bootargs="console=ttyBF0,115200"
+
+mtdparts="128k(barebox)ro,128k(bareboxenv),128k(ageing),1280k(kernel0),1280k(kernel1),8704k(system0),8704k(system1),8320k(application),4096k(persistent)"
+ageing=/dev/nor0.ageing
diff --git a/arch/blackfin/boards/ipe337/ipe337.c b/arch/blackfin/boards/ipe337/ipe337.c
new file mode 100644
index 0000000000..269e7743fc
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/ipe337.c
@@ -0,0 +1,68 @@
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <asm/cpu/cdefBF561.h>
+#include <partition.h>
+#include <fs.h>
+
+static struct device_d cfi_dev = {
+ .name = "cfi_flash",
+ .map_base = 0x20000000,
+ .size = 32 * 1024 * 1024,
+};
+
+static struct memory_platform_data ram_pdata = {
+ .name = "ram0",
+ .flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram_dev = {
+ .name = "mem",
+ .map_base = 0x0,
+ .size = 128 * 1024 * 1024,
+ .platform_data = &ram_pdata,
+};
+
+static struct device_d smc911x_dev = {
+ .name = "smc911x",
+ .map_base = 0x24000000,
+ .size = 4096,
+};
+
+static int ipe337_devices_init(void) {
+ register_device(&cfi_dev);
+ register_device(&sdram_dev);
+
+ /* Reset smc911x */
+ *pFIO0_DIR = (1<<12);
+ *pFIO0_FLAG_C = (1<<12);
+ mdelay(100);
+ *pFIO0_FLAG_S = (1<<12);
+
+ register_device(&smc911x_dev);
+
+ devfs_add_partition("nor0", 0x00000, 0x20000, PARTITION_FIXED, "self0");
+ devfs_add_partition("nor0", 0x20000, 0x20000, PARTITION_FIXED, "env0");
+
+ protect_file("/dev/env0", 1);
+
+ return 0;
+}
+
+device_initcall(ipe337_devices_init);
+
+static struct device_d blackfin_serial_device = {
+ .name = "blackfin_serial",
+ .map_base = 0,
+ .size = 4096,
+};
+
+static int blackfin_console_init(void)
+{
+ register_device(&blackfin_serial_device);
+
+ return 0;
+}
+
+console_initcall(blackfin_console_init);
+
diff --git a/arch/blackfin/boards/ipe337/ipe337.dox b/arch/blackfin/boards/ipe337/ipe337.dox
new file mode 100644
index 0000000000..4d7925af94
--- /dev/null
+++ b/arch/blackfin/boards/ipe337/ipe337.dox
@@ -0,0 +1,10 @@
+/** @page ipe337 ipe337
+
+This CPU card is based on an Analog Device Blackfin CPU. The card is shipped
+with:
+
+- 32MiB NOR type Flash Memory
+- 128MiB synchronous dynamic RAM
+- SMSC9xxx network controller
+
+*/ \ No newline at end of file