From matthias at kaehlcke.net  Fri Jan  1 14:48:22 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Fri, 1 Jan 2010 20:48:22 +0100
Subject: confusion about relocation (ARM)
Message-ID: <20100101194822.GR5093@darwin>

hi,

i'm trying to run barebox on an EP93xx (ARM) board, but don't get
beyond the invocation of some initcalls from start_barebox(). at the
moment i have no JTAG for debugging and rely on LEDs for hints whats
going on. my suspicion is that the stack or SDRAM isn't set up
correctly.

a comment in start_barebox() says 'We are running from RAM now', so i
deduced SDRAM must work. but after having a look at start-arm.S i'm a
little bit confused. as far as i understand the barebox code is copied
to RAM in copy_loop(). what i don't see is where the program counter
is set to the address in RAM?

any insights?

-- 
Matthias Kaehlcke
Embedded Linux Developer
Barcelona

    Me lo contaron y lo olvid?, lo vi y lo entend?, lo hice y lo aprend?
                              (Confucio)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-


From eric at eukrea.com  Fri Jan  1 15:36:29 2010
From: eric at eukrea.com (=?ISO-8859-1?Q?Eric_B=E9nard?=)
Date: Fri, 01 Jan 2010 21:36:29 +0100
Subject: confusion about relocation (ARM)
In-Reply-To: <20100101194822.GR5093@darwin>
References: <20100101194822.GR5093@darwin>
Message-ID: <4B3E5CCD.60400@eukrea.com>

Hi Matthias,

Le 01/01/2010 20:48, Matthias Kaehlcke a ?crit :
> a comment in start_barebox() says 'We are running from RAM now', so i
> deduced SDRAM must work. but after having a look at start-arm.S i'm a
> little bit confused. as far as i understand the barebox code is copied
> to RAM in copy_loop(). what i don't see is where the program counter
> is set to the address in RAM?
>
in arch/arm/cpu/start-arm.S @ line 245 :
         ldr     pc, _start_armboot

Eric


From matthias at kaehlcke.net  Fri Jan  1 16:48:26 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Fri, 1 Jan 2010 22:48:26 +0100
Subject: confusion about relocation (ARM)
In-Reply-To: <4B3E5CCD.60400@eukrea.com>
References: <20100101194822.GR5093@darwin> <4B3E5CCD.60400@eukrea.com>
Message-ID: <20100101214826.GS5093@darwin>

hi eric,

thanks for your reply

El Fri, Jan 01, 2010 at 09:36:29PM +0100 Eric B?nard ha dit:

> Le 01/01/2010 20:48, Matthias Kaehlcke a ?crit :
>> a comment in start_barebox() says 'We are running from RAM now', so i
>> deduced SDRAM must work. but after having a look at start-arm.S i'm a
>> little bit confused. as far as i understand the barebox code is copied
>> to RAM in copy_loop(). what i don't see is where the program counter
>> is set to the address in RAM?
>>
> in arch/arm/cpu/start-arm.S @ line 245 :
>         ldr     pc, _start_armboot

i saw this line, but i don't understand how it comes that
the address at _start_armboot points to RAM and not to the flash.

another question: how does ARCH_TEXT_BASE fit in here? i defined it as
0x05700000, but in the barebox image _TEXT_BASE is 0x00000000

kind regards

-- 
Matthias Kaehlcke
Embedded Linux Developer
Barcelona

             You must have a plan. If you don't have a plan,
               you'll become part of somebody else's plan
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-


From s.hauer at pengutronix.de  Mon Jan  4 05:08:31 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 4 Jan 2010 11:08:31 +0100
Subject: [PATCH 1/1] net: Exclude code based on selected protocol
In-Reply-To: <1261662937-31474-2-git-send-email-premi@ti.com>
References: <1261662937-31474-1-git-send-email-premi@ti.com>
	<1261662937-31474-2-git-send-email-premi@ti.com>
Message-ID: <20100104100831.GD8799@pengutronix.de>

Hi,

On Thu, Dec 24, 2009 at 07:25:37PM +0530, Sanjeev Premi wrote:
> Exclude the code for TFTP/NFS if either of the
> protocols is not selected.

Ok, this should be fixed. I would rather use the following patch to do
it. It adds a few bytes of binary space but it moves the code which
belongs together to the appropriate files.

Sascha



From s.hauer at pengutronix.de  Mon Jan  4 04:08:52 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 4 Jan 2010 10:08:52 +0100
Subject: [PATCH] remove tftp/nfs specific code to net/*
Message-ID: <mailman.113.1262599754.2170.barebox@lists.infradead.org>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/net.c |  108 --------------------------------------------------------
 net/nfs.c      |   56 ++++++++++++++++++++++++++++-
 net/tftp.c     |   72 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 126 insertions(+), 110 deletions(-)

diff --git a/commands/net.c b/commands/net.c
index 902c8bb..5fa49cf 100644
--- a/commands/net.c
+++ b/commands/net.c
@@ -32,12 +32,8 @@
 #include <driver.h>
 #include <net.h>
 #include <fs.h>
-#include <fcntl.h>
 #include <errno.h>
 #include <libbb.h>
-#include <libgen.h>
-
-static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]);
 
 void netboot_update_env(void)
 {
@@ -77,37 +73,6 @@ void netboot_update_env(void)
 		setenv ("domain", NetOurNISDomain);
 }
 
-static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
-{
-	return netboot_common (TFTP, cmdtp, argc, argv);
-}
-
-static const __maybe_unused char cmd_tftp_help[] =
-"Usage: tftp <file> [localfile]\n"
-"Load a file via network using BootP/TFTP protocol.\n";
-
-BAREBOX_CMD_START(tftp)
-	.cmd		= do_tftpb,
-	.usage		= "Load file using tftp protocol",
-	BAREBOX_CMD_HELP(cmd_tftp_help)
-BAREBOX_CMD_END
-
-/**
- * @page tftp_command tftp
- *
- * Usage is: tftp \<filename\> [\<localfilename\>]
- *
- * Load a file via network using BootP/TFTP protocol. The loaded file you
- * can find after download in you current ramdisk. Refer \b ls command.
- *
- * \<localfile> can be the local filename only, or also a device name. In the
- * case of a device name, the will gets stored there. This works also for
- * partitions of flash memory. Refer \b erase, \b unprotect for flash
- * preparation.
- *
- * Note: This command is available only, if enabled in the menuconfig.
- */
-
 #ifdef CONFIG_NET_RARP
 extern void RarpRequest(void);
 
@@ -137,79 +102,6 @@ BAREBOX_CMD_START(rarpboot)
 BAREBOX_CMD_END
 #endif /* CONFIG_NET_RARP */
 
-#ifdef CONFIG_NET_NFS
-static int do_nfs (cmd_tbl_t *cmdtp, int argc, char *argv[])
-{
-	return netboot_common(NFS, cmdtp, argc, argv);
-}
-
-static const __maybe_unused char cmd_nfs_help[] =
-"Usage: nfs <file> [localfile]\n"
-"Load a file via network using nfs protocol.\n";
-
-BAREBOX_CMD_START(nfs)
-	.cmd		= do_nfs,
-	.usage		= "boot image via network using nfs protocol",
-	BAREBOX_CMD_HELP(cmd_nfs_help)
-BAREBOX_CMD_END
-
-#endif	/* CONFIG_NET_NFS */
-
-int net_store_fd;
-
-extern void TftpStart(char *);       /* Begin TFTP get */
-extern void NfsStart(char *);
-
-static int
-netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
-{
-	int   rcode = 0;
-	int   size;
-	char  *localfile;
-	char  *remotefile;
-
-	if (argc < 2)
-		return COMMAND_ERROR_USAGE;
-
-	remotefile = argv[1];
-
-	if (argc == 2)
-		localfile = basename(remotefile);
-	else
-		localfile = argv[2];
-
-	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
-	if (net_store_fd < 0) {
-		perror("open");
-		return 1;
-	}
-
-	if (NetLoopInit(proto) < 0)
-		goto out;
-
-	switch (proto) {
-	case TFTP:
-		TftpStart(remotefile);
-		break;
-	case NFS:
-		NfsStart(remotefile);
-	default:
-		break;
-	}
-
-	if ((size = NetLoop()) < 0) {
-		rcode = size;
-		goto out;
-	}
-
-	/* NetLoop ok, update environment */
-	netboot_update_env();
-
-out:
-	close(net_store_fd);
-	return rcode;
-}
-
 static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
 {
 	struct eth_device *edev;
diff --git a/net/nfs.c b/net/nfs.c
index fe0bc70..f68741a 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -29,6 +29,9 @@
 #include <malloc.h>
 #include <libgen.h>
 #include <fs.h>
+#include <libgen.h>
+#include <fcntl.h>
+#include <errno.h>
 #include "nfs.h"
 
 /*#define NFS_DEBUG*/
@@ -63,7 +66,7 @@ static char *nfs_filename;
 static char *nfs_path;
 static char nfs_path_buff[2048];
 
-extern int net_store_fd;
+static int net_store_fd;
 
 static __inline__ int
 store_block (uchar * src, unsigned offset, unsigned len)
@@ -703,3 +706,54 @@ NfsStart (char *p)
 	NfsSend ();
 }
 
+static int do_nfs (cmd_tbl_t *cmdtp, int argc, char *argv[])
+{
+	int   rcode = 0;
+	char  *localfile;
+	char  *remotefile;
+
+	if (argc < 2)
+		return COMMAND_ERROR_USAGE;
+
+	remotefile = argv[1];
+
+	if (argc == 2)
+		localfile = basename(remotefile);
+	else
+		localfile = argv[2];
+
+	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
+	if (net_store_fd < 0) {
+		perror("open");
+		return 1;
+	}
+
+	if (NetLoopInit(NFS) < 0)
+		goto out;
+
+	NfsStart(remotefile);
+
+	rcode = NetLoop();
+	if (rcode < 0) {
+		rcode = 1;
+		goto out;
+	}
+
+	/* NetLoop ok, update environment */
+	netboot_update_env();
+
+out:
+	close(net_store_fd);
+	return rcode;
+}
+
+static const __maybe_unused char cmd_nfs_help[] =
+"Usage: nfs <file> [localfile]\n"
+"Load a file via network using nfs protocol.\n";
+
+BAREBOX_CMD_START(nfs)
+	.cmd		= do_nfs,
+	.usage		= "boot image via network using nfs protocol",
+	BAREBOX_CMD_HELP(cmd_nfs_help)
+BAREBOX_CMD_END
+
diff --git a/net/tftp.c b/net/tftp.c
index 169855f..b9c6fdd 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -11,6 +11,8 @@
 #include <clock.h>
 #include <fs.h>
 #include <errno.h>
+#include <libgen.h>
+#include <fcntl.h>
 #include "tftp.h"
 
 #undef	ET_DEBUG
@@ -49,7 +51,7 @@ static int	TftpState;
 
 static char *tftp_filename;
 
-extern int net_store_fd;
+static int net_store_fd;
 
 static int store_block(unsigned block, uchar * src, unsigned len)
 {
@@ -253,3 +255,71 @@ void TftpStart(char *filename)
 
 	TftpSend();
 }
+
+static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
+{
+	int   rcode = 0;
+	char  *localfile;
+	char  *remotefile;
+
+	if (argc < 2)
+		return COMMAND_ERROR_USAGE;
+
+	remotefile = argv[1];
+
+	if (argc == 2)
+		localfile = basename(remotefile);
+	else
+		localfile = argv[2];
+
+	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
+	if (net_store_fd < 0) {
+		perror("open");
+		return 1;
+	}
+
+	if (NetLoopInit(TFTP) < 0)
+		goto out;
+
+	TftpStart(remotefile);
+
+	rcode = NetLoop();
+	if (rcode < 0) {
+		rcode = 1;
+		goto out;
+	}
+
+	/* NetLoop ok, update environment */
+	netboot_update_env();
+
+out:
+	close(net_store_fd);
+	return rcode;
+}
+
+static const __maybe_unused char cmd_tftp_help[] =
+"Usage: tftp <file> [localfile]\n"
+"Load a file via network using BootP/TFTP protocol.\n";
+
+BAREBOX_CMD_START(tftp)
+	.cmd		= do_tftpb,
+	.usage		= "Load file using tftp protocol",
+	BAREBOX_CMD_HELP(cmd_tftp_help)
+BAREBOX_CMD_END
+
+/**
+ * @page tftp_command tftp
+ *
+ * Usage is: tftp \<filename\> [\<localfilename\>]
+ *
+ * Load a file via network using BootP/TFTP protocol. The loaded file you
+ * can find after download in you current ramdisk. Refer \b ls command.
+ *
+ * \<localfile> can be the local filename only, or also a device name. In the
+ * case of a device name, the will gets stored there. This works also for
+ * partitions of flash memory. Refer \b erase, \b unprotect for flash
+ * preparation.
+ *
+ * Note: This command is available only, if enabled in the menuconfig.
+ */
+
-- 
1.6.5.2


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Jan  4 05:12:22 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 4 Jan 2010 11:12:22 +0100
Subject: [PATCH] fix path specs in arch/arm/mach-arm.dox
In-Reply-To: <20091229193411.GB5093@darwin>
References: <20091229193411.GB5093@darwin>
Message-ID: <20100104101222.GE8799@pengutronix.de>

Hi Matthias,

On Tue, Dec 29, 2009 at 08:34:11PM +0100, Matthias Kaehlcke wrote:
> Fix incorrect path specs in the documentation for adding an ARM based
> CPU (MACH) to the tree
> 
> Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>

Ok, applied

Thanks,
  Sascha

> 
> --
> 
> diff --git a/arch/arm/mach-arm.dox b/arch/arm/mach-arm.dox
> index 76b6883..758df3f 100644
> --- a/arch/arm/mach-arm.dox
> +++ b/arch/arm/mach-arm.dox
> @@ -40,12 +40,12 @@ target address is the first C instruction in barebox. At this point of time:\n
>  
>  Lets call the new MACH new_cpu.
>  
> - - create a new subdirectory in /arch/arm/new_cpu
> - - create a new subdirectory in /include/asm-arm/new_cpu
> - - add CPU specific definitions into /include/asm-arm/new_cpu/
> - - add /arch/arm/new_cpu/Kconfig
> - - add /arch/arm/new_cpu/Makfile
> - - add other CPU specific code into /arch/arm/new_cpu/
> + - create a new subdirectory in /arch/arm/mach-new_cpu
> + - create a new subdirectory in /arch/arm/mach-new_cpu/include
> + - add CPU specific definitions into /arch/arm/mach-new_cpu/include
> + - add /arch/arm/mach-new_cpu/Kconfig
> + - add /arch/arm/mach-new_cpu/Makfile
> + - add other CPU specific code into /arch/arm/mach-new_cpu/
>   - modify /arch/arm/Kconfig
>   - modify /arch/arm/Makfile
> 
> -- 
> Matthias Kaehlcke
> Embedded Linux Developer
> Barcelona
> 
>              You must have a plan. If you don't have a plan,
>                you'll become part of somebody else's plan
>                                                                  .''`.
>     using free software / Debian GNU/Linux | http://debian.org  : :'  :
>                                                                 `. `'`
> gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Jan  4 05:13:15 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 4 Jan 2010 11:13:15 +0100
Subject: [PATCH] Fix typo in board.dox
In-Reply-To: <20091231215521.GO5093@darwin>
References: <20091231215521.GO5093@darwin>
Message-ID: <20100104101315.GF8799@pengutronix.de>

On Thu, Dec 31, 2009 at 10:55:21PM +0100, Matthias Kaehlcke wrote:
> Fix a typo in documentation file about adapting a new board which
> misnames the linker script template file
> 
> Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>

Ok, applied

Sascha

> 
> --
> 
> diff --git a/board/board.dox b/board/board.dox
> index 9c32682..76bff45 100644
> --- a/board/board.dox
> +++ b/board/board.dox
> @@ -58,7 +58,7 @@ at the right architecture.
>  
>  @note Consider to use an unique page lable.
>  
> - at subsection board_lscript board/\<boardname\>/barebox.ld.S
> + at subsection board_lscript board/\<boardname\>/barebox.lds.S
>  
>  If your board needs a special binary @a barebox layout, you can provide a local
>  board linker script file. This will replace the generic one provided by your
> 
> -- 
> Matthias Kaehlcke
> Embedded Linux Developer
> Barcelona
> 
>      Nationalism is an infantile disease. It is the measles of mankind
>                          (Albert Einstein)
>                                                                  .''`.
>     using free software / Debian GNU/Linux | http://debian.org  : :'  :
>                                                                 `. `'`
> gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Jan  4 07:07:58 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 4 Jan 2010 13:07:58 +0100
Subject: confusion about relocation (ARM)
In-Reply-To: <20100101214826.GS5093@darwin>
References: <20100101194822.GR5093@darwin> <4B3E5CCD.60400@eukrea.com>
	<20100101214826.GS5093@darwin>
Message-ID: <20100104120758.GC4976@pengutronix.de>

On Fri, Jan 01, 2010 at 10:48:26PM +0100, Matthias Kaehlcke wrote:
> hi eric,
> 
> thanks for your reply
> 
> El Fri, Jan 01, 2010 at 09:36:29PM +0100 Eric B?nard ha dit:
> 
> > Le 01/01/2010 20:48, Matthias Kaehlcke a ?crit :
> >> a comment in start_barebox() says 'We are running from RAM now', so i
> >> deduced SDRAM must work. but after having a look at start-arm.S i'm a
> >> little bit confused. as far as i understand the barebox code is copied
> >> to RAM in copy_loop(). what i don't see is where the program counter
> >> is set to the address in RAM?
> >>
> > in arch/arm/cpu/start-arm.S @ line 245 :
> >         ldr     pc, _start_armboot
> 
> i saw this line, but i don't understand how it comes that
> the address at _start_armboot points to RAM and not to the flash.

When your barebox image is linked to RAM (that is 0x05700000 in your
case) _start_armboot is in RAM, too.

> 
> another question: how does ARCH_TEXT_BASE fit in here? i defined it as
> 0x05700000, but in the barebox image _TEXT_BASE is 0x00000000

Have a look at barebox.S, it should look like:

barebox:     file format elf32-littlearm


Disassembly of section .text:

87f00000 <_start>:
87f00000:	ea000014 	b	87f00058 <reset>
87f00004:	e59ff014 	ldr	pc, [pc, #20]	; 87f00020<_end+0xfffe07c4>
87f00008:	e59ff014 	ldr	pc, [pc, #20]	; 87f00024<_end+0xfffe07c8>
87f0000c:	e59ff014 	ldr	pc, [pc, #20]	; 87f00028<_end+0xfffe07cc>
87f00010:	e59ff014 	ldr	pc, [pc, #20]	; 87f0002c<_end+0xfffe07d0>
87f00014:	e59ff014 	ldr	pc, [pc, #20]	; 87f00030<_end+0xfffe07d4>
87f00018:	e59ff014 	ldr	pc, [pc, #20]	; 87f00034<_end+0xfffe07d8>
87f0001c:	e59ff014 	ldr	pc, [pc, #20]	; 87f00038<_end+0xfffe07dc>

87f00020 <_undefined_instruction>:
87f00020:	87f14a20 	.word	0x87f14a20

87f00024 <_software_interrupt>:
87f00024:	87f14a80 	.word	0x87f14a80

87f00028 <_prefetch_abort>:
87f00028:	87f14ae0 	.word	0x87f14ae0

87f0002c <_data_abort>:
87f0002c:	87f14b40 	.word	0x87f14b40

87f00030 <_not_used>:
87f00030:	87f14ba0 	.word	0x87f14ba0

87f00034 <_irq>:
87f00034:	87f14c00 	.word	0x87f14c00

87f00038 <_fiq>:
87f00038:	87f14c60 	.word	0x87f14c60
87f0003c:	deadbeef 	.word	0xdeadbeef

87f00040 <_barebox_start>:
87f00040:	87f00000 	.word	0x87f00000

87f00044 <_bss_start>:
87f00044:	87f1a908 	.word	0x87f1a908

87f00048 <_bss_end>:
87f00048:	87f1f85c 	.word	0x87f1f85c

87f0004c <_TEXT_BASE>:
87f0004c:	87f00000 	.word	0x87f00000

87f00050 <_MALLOC_BASE>:
87f00050:	87b00000 	.word	0x87b00000

(With 87fxxxx replaced with 0570xxxx of course)

Since EP93xx is not in mainline maybe you can provide us your patches
and I think we should be able to help you.

Regards
  Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From premi at ti.com  Mon Jan  4 11:18:22 2010
From: premi at ti.com (Premi, Sanjeev)
Date: Mon, 4 Jan 2010 21:48:22 +0530
Subject: [PATCH 1/1] net: Exclude code based on selected protocol
In-Reply-To: <20100104100831.GD8799@pengutronix.de>
Message-ID: <B85A65D85D7EB246BE421B3FB0FBB59301E1D30FB3@dbde02.ent.ti.com>

> -----Original Message-----
> From: Sascha Hauer [mailto:s.hauer at pengutronix.de] 
> Sent: Monday, January 04, 2010 3:39 PM
> To: Premi, Sanjeev
> Cc: barebox at lists.infradead.org
> Subject: Re: [PATCH 1/1] net: Exclude code based on selected protocol
> 
> Hi,
> 
> On Thu, Dec 24, 2009 at 07:25:37PM +0530, Sanjeev Premi wrote:
> > Exclude the code for TFTP/NFS if either of the
> > protocols is not selected.
> 
> Ok, this should be fixed. I would rather use the following patch to do
> it. It adds a few bytes of binary space but it moves the code which
> belongs together to the appropriate files.
> 
> Sascha

I thought there was specific reason to keep the code as it existed.

Will be able to try it in couple of days.
Many things to catch up after vacation...

Best regards,
Sanjeev

> 
> 
> From 6c312514f8272409a84b4f235e56262ace283ea8 Mon Sep 17 00:00:00 2001
> From: Sascha Hauer <s.hauer at pengutronix.de>
> Date: Mon, 4 Jan 2010 10:08:52 +0100
> Subject: [PATCH] remove tftp/nfs specific code to net/*
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  commands/net.c |  108 
> --------------------------------------------------------
>  net/nfs.c      |   56 ++++++++++++++++++++++++++++-
>  net/tftp.c     |   72 ++++++++++++++++++++++++++++++++++++-
>  3 files changed, 126 insertions(+), 110 deletions(-)
> 
> diff --git a/commands/net.c b/commands/net.c
> index 902c8bb..5fa49cf 100644
> --- a/commands/net.c
> +++ b/commands/net.c
> @@ -32,12 +32,8 @@
>  #include <driver.h>
>  #include <net.h>
>  #include <fs.h>
> -#include <fcntl.h>
>  #include <errno.h>
>  #include <libbb.h>
> -#include <libgen.h>
> -
> -static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]);
>  
>  void netboot_update_env(void)
>  {
> @@ -77,37 +73,6 @@ void netboot_update_env(void)
>  		setenv ("domain", NetOurNISDomain);
>  }
>  
> -static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
> -{
> -	return netboot_common (TFTP, cmdtp, argc, argv);
> -}
> -
> -static const __maybe_unused char cmd_tftp_help[] =
> -"Usage: tftp <file> [localfile]\n"
> -"Load a file via network using BootP/TFTP protocol.\n";
> -
> -BAREBOX_CMD_START(tftp)
> -	.cmd		= do_tftpb,
> -	.usage		= "Load file using tftp protocol",
> -	BAREBOX_CMD_HELP(cmd_tftp_help)
> -BAREBOX_CMD_END
> -
> -/**
> - * @page tftp_command tftp
> - *
> - * Usage is: tftp \<filename\> [\<localfilename\>]
> - *
> - * Load a file via network using BootP/TFTP protocol. The 
> loaded file you
> - * can find after download in you current ramdisk. Refer \b 
> ls command.
> - *
> - * \<localfile> can be the local filename only, or also a 
> device name. In the
> - * case of a device name, the will gets stored there. This 
> works also for
> - * partitions of flash memory. Refer \b erase, \b unprotect for flash
> - * preparation.
> - *
> - * Note: This command is available only, if enabled in the 
> menuconfig.
> - */
> -
>  #ifdef CONFIG_NET_RARP
>  extern void RarpRequest(void);
>  
> @@ -137,79 +102,6 @@ BAREBOX_CMD_START(rarpboot)
>  BAREBOX_CMD_END
>  #endif /* CONFIG_NET_RARP */
>  
> -#ifdef CONFIG_NET_NFS
> -static int do_nfs (cmd_tbl_t *cmdtp, int argc, char *argv[])
> -{
> -	return netboot_common(NFS, cmdtp, argc, argv);
> -}
> -
> -static const __maybe_unused char cmd_nfs_help[] =
> -"Usage: nfs <file> [localfile]\n"
> -"Load a file via network using nfs protocol.\n";
> -
> -BAREBOX_CMD_START(nfs)
> -	.cmd		= do_nfs,
> -	.usage		= "boot image via network using nfs protocol",
> -	BAREBOX_CMD_HELP(cmd_nfs_help)
> -BAREBOX_CMD_END
> -
> -#endif	/* CONFIG_NET_NFS */
> -
> -int net_store_fd;
> -
> -extern void TftpStart(char *);       /* Begin TFTP get */
> -extern void NfsStart(char *);
> -
> -static int
> -netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, 
> char *argv[])
> -{
> -	int   rcode = 0;
> -	int   size;
> -	char  *localfile;
> -	char  *remotefile;
> -
> -	if (argc < 2)
> -		return COMMAND_ERROR_USAGE;
> -
> -	remotefile = argv[1];
> -
> -	if (argc == 2)
> -		localfile = basename(remotefile);
> -	else
> -		localfile = argv[2];
> -
> -	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
> -	if (net_store_fd < 0) {
> -		perror("open");
> -		return 1;
> -	}
> -
> -	if (NetLoopInit(proto) < 0)
> -		goto out;
> -
> -	switch (proto) {
> -	case TFTP:
> -		TftpStart(remotefile);
> -		break;
> -	case NFS:
> -		NfsStart(remotefile);
> -	default:
> -		break;
> -	}
> -
> -	if ((size = NetLoop()) < 0) {
> -		rcode = size;
> -		goto out;
> -	}
> -
> -	/* NetLoop ok, update environment */
> -	netboot_update_env();
> -
> -out:
> -	close(net_store_fd);
> -	return rcode;
> -}
> -
>  static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
>  {
>  	struct eth_device *edev;
> diff --git a/net/nfs.c b/net/nfs.c
> index fe0bc70..f68741a 100644
> --- a/net/nfs.c
> +++ b/net/nfs.c
> @@ -29,6 +29,9 @@
>  #include <malloc.h>
>  #include <libgen.h>
>  #include <fs.h>
> +#include <libgen.h>
> +#include <fcntl.h>
> +#include <errno.h>
>  #include "nfs.h"
>  
>  /*#define NFS_DEBUG*/
> @@ -63,7 +66,7 @@ static char *nfs_filename;
>  static char *nfs_path;
>  static char nfs_path_buff[2048];
>  
> -extern int net_store_fd;
> +static int net_store_fd;
>  
>  static __inline__ int
>  store_block (uchar * src, unsigned offset, unsigned len)
> @@ -703,3 +706,54 @@ NfsStart (char *p)
>  	NfsSend ();
>  }
>  
> +static int do_nfs (cmd_tbl_t *cmdtp, int argc, char *argv[])
> +{
> +	int   rcode = 0;
> +	char  *localfile;
> +	char  *remotefile;
> +
> +	if (argc < 2)
> +		return COMMAND_ERROR_USAGE;
> +
> +	remotefile = argv[1];
> +
> +	if (argc == 2)
> +		localfile = basename(remotefile);
> +	else
> +		localfile = argv[2];
> +
> +	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
> +	if (net_store_fd < 0) {
> +		perror("open");
> +		return 1;
> +	}
> +
> +	if (NetLoopInit(NFS) < 0)
> +		goto out;
> +
> +	NfsStart(remotefile);
> +
> +	rcode = NetLoop();
> +	if (rcode < 0) {
> +		rcode = 1;
> +		goto out;
> +	}
> +
> +	/* NetLoop ok, update environment */
> +	netboot_update_env();
> +
> +out:
> +	close(net_store_fd);
> +	return rcode;
> +}
> +
> +static const __maybe_unused char cmd_nfs_help[] =
> +"Usage: nfs <file> [localfile]\n"
> +"Load a file via network using nfs protocol.\n";
> +
> +BAREBOX_CMD_START(nfs)
> +	.cmd		= do_nfs,
> +	.usage		= "boot image via network using nfs protocol",
> +	BAREBOX_CMD_HELP(cmd_nfs_help)
> +BAREBOX_CMD_END
> +
> diff --git a/net/tftp.c b/net/tftp.c
> index 169855f..b9c6fdd 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -11,6 +11,8 @@
>  #include <clock.h>
>  #include <fs.h>
>  #include <errno.h>
> +#include <libgen.h>
> +#include <fcntl.h>
>  #include "tftp.h"
>  
>  #undef	ET_DEBUG
> @@ -49,7 +51,7 @@ static int	TftpState;
>  
>  static char *tftp_filename;
>  
> -extern int net_store_fd;
> +static int net_store_fd;
>  
>  static int store_block(unsigned block, uchar * src, unsigned len)
>  {
> @@ -253,3 +255,71 @@ void TftpStart(char *filename)
>  
>  	TftpSend();
>  }
> +
> +static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
> +{
> +	int   rcode = 0;
> +	char  *localfile;
> +	char  *remotefile;
> +
> +	if (argc < 2)
> +		return COMMAND_ERROR_USAGE;
> +
> +	remotefile = argv[1];
> +
> +	if (argc == 2)
> +		localfile = basename(remotefile);
> +	else
> +		localfile = argv[2];
> +
> +	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
> +	if (net_store_fd < 0) {
> +		perror("open");
> +		return 1;
> +	}
> +
> +	if (NetLoopInit(TFTP) < 0)
> +		goto out;
> +
> +	TftpStart(remotefile);
> +
> +	rcode = NetLoop();
> +	if (rcode < 0) {
> +		rcode = 1;
> +		goto out;
> +	}
> +
> +	/* NetLoop ok, update environment */
> +	netboot_update_env();
> +
> +out:
> +	close(net_store_fd);
> +	return rcode;
> +}
> +
> +static const __maybe_unused char cmd_tftp_help[] =
> +"Usage: tftp <file> [localfile]\n"
> +"Load a file via network using BootP/TFTP protocol.\n";
> +
> +BAREBOX_CMD_START(tftp)
> +	.cmd		= do_tftpb,
> +	.usage		= "Load file using tftp protocol",
> +	BAREBOX_CMD_HELP(cmd_tftp_help)
> +BAREBOX_CMD_END
> +
> +/**
> + * @page tftp_command tftp
> + *
> + * Usage is: tftp \<filename\> [\<localfilename\>]
> + *
> + * Load a file via network using BootP/TFTP protocol. The 
> loaded file you
> + * can find after download in you current ramdisk. Refer \b 
> ls command.
> + *
> + * \<localfile> can be the local filename only, or also a 
> device name. In the
> + * case of a device name, the will gets stored there. This 
> works also for
> + * partitions of flash memory. Refer \b erase, \b unprotect for flash
> + * preparation.
> + *
> + * Note: This command is available only, if enabled in the 
> menuconfig.
> + */
> +
> -- 
> 1.6.5.2
> 
> 
> -- 
> Pengutronix e.K.                           |                  
>            |
> Industrial Linux Solutions                 | 
> http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: 
> +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   
> +49-5121-206917-5555 |
> 

From matthias at kaehlcke.net  Mon Jan  4 14:21:53 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 4 Jan 2010 20:21:53 +0100
Subject: confusion about relocation (ARM)
In-Reply-To: <20100104120758.GC4976@pengutronix.de>
References: <20100101194822.GR5093@darwin> <4B3E5CCD.60400@eukrea.com>
	<20100101214826.GS5093@darwin>
	<20100104120758.GC4976@pengutronix.de>
Message-ID: <20100104192153.GA30824@darwin>

hi sascha,

El Mon, Jan 04, 2010 at 01:07:58PM +0100 Sascha Hauer ha dit:

> On Fri, Jan 01, 2010 at 10:48:26PM +0100, Matthias Kaehlcke wrote:
> > El Fri, Jan 01, 2010 at 09:36:29PM +0100 Eric B?nard ha dit:
> > 
> > > Le 01/01/2010 20:48, Matthias Kaehlcke a ?crit :
> > >> a comment in start_barebox() says 'We are running from RAM now', so i
> > >> deduced SDRAM must work. but after having a look at start-arm.S i'm a
> > >> little bit confused. as far as i understand the barebox code is copied
> > >> to RAM in copy_loop(). what i don't see is where the program counter
> > >> is set to the address in RAM?
> > >>
> > > in arch/arm/cpu/start-arm.S @ line 245 :
> > >         ldr     pc, _start_armboot
> > 
> > i saw this line, but i don't understand how it comes that
> > the address at _start_armboot points to RAM and not to the flash.
> 
> When your barebox image is linked to RAM (that is 0x05700000 in your
> case) _start_armboot is in RAM, too.
> 
> > 
> > another question: how does ARCH_TEXT_BASE fit in here? i defined it as
> > 0x05700000, but in the barebox image _TEXT_BASE is 0x00000000
> 
> Have a look at barebox.S, it should look like:
> 
> barebox:     file format elf32-littlearm
> 
> 
> Disassembly of section .text:
> 
> 87f00000 <_start>:
> ...

thanks for your reply!

finally i figured out what was going wrong: after getting compiler errors
when using a config file created from scratch, i took a defconfig of
another ARM board as starting point. this board defines
CONFIG_TEXT_BASE as 0x00000000, in consequence ARCH_TEXT_BASE
(0x05700000) of the edb93xx board wasn't used.

after setting CONFIG_TEST_BASE to the correct value i got a barebox
prompt :)

-- 
Matthias Kaehlcke
Embedded Linux Developer
Barcelona

      Debugging is like alien abduction. Large blocks of time disappear,
                    for which you have no explanation
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-


From r.schwebel at pengutronix.de  Mon Jan  4 15:13:11 2010
From: r.schwebel at pengutronix.de (Robert Schwebel)
Date: Mon, 4 Jan 2010 21:13:11 +0100
Subject: confusion about relocation (ARM)
In-Reply-To: <20100104192153.GA30824@darwin>
References: <20100101194822.GR5093@darwin> <4B3E5CCD.60400@eukrea.com>
	<20100101214826.GS5093@darwin>
	<20100104120758.GC4976@pengutronix.de>
	<20100104192153.GA30824@darwin>
Message-ID: <20100104201311.GN17262@pengutronix.de>

On Mon, Jan 04, 2010 at 08:21:53PM +0100, Matthias Kaehlcke wrote:
> after getting compiler errors when using a config file created from
> scratch,

Can you reproduce that and send us the offending config file? Looks like
a bug somewhere.

rsc
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From matthias at kaehlcke.net  Mon Jan  4 14:42:46 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 4 Jan 2010 20:42:46 +0100
Subject: [PATCH 0/2] CFI flash drivers: Fix misleading trace when
	unprotecting a sector
Message-ID: <20100104194246.GA19855@darwin>

When (un)protecting a flash sector with the CFI flash drivers a
trace "protect 0x..." is generated, independently of the type of
operation. This is misleading in case of an unprotect. Tell the truth
when unprotecting a sector.

Matthias Kaehlcke (2):
  CFI flash driver: Fix misleading trace when unprotecting a sector
  New CFI flash driver: Fix misleading trace when unprotecting a sector

 drivers/nor/cfi_flash.c     |    3 ++-
 drivers/nor/cfi_flash_new.c |    4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)



From matthias at kaehlcke.net  Mon Jan  4 14:42:52 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 4 Jan 2010 20:42:52 +0100
Subject: [PATCH 1/2] CFI flash driver: Fix misleading trace when
	unprotecting a sector
Message-ID: <20100104194252.GB19855@darwin>

When (un)protecting a flash sector with the CFI flash driver a trace
"protect 0x..." is generated, independently of the type of operation. This is
misleading in case of an unprotect. Tell the truth when unprotecting a sector.

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 drivers/nor/cfi_flash.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
index 37206d0..938e2cb 100644
--- a/drivers/nor/cfi_flash.c
+++ b/drivers/nor/cfi_flash.c
@@ -380,7 +380,8 @@ static int cfi_protect(struct cdev *cdev, size_t count, unsigned long offset, in
 	unsigned long start, end;
 	int i, ret = 0;
 
-	debug("%s: protect 0x%08x (size %d)\n", __FUNCTION__, offset, count);
+	debug("%s: %sprotect 0x%08x (size %d)\n",
+		__FUNCTION__, (prot? "" : "un"), offset, count);
 
 	start = flash_find_sector(finfo, cdev->dev->map_base + offset);
 	end   = flash_find_sector(finfo, cdev->dev->map_base + offset + count - 1);
-- 
1.6.3.1



From matthias at kaehlcke.net  Mon Jan  4 14:42:57 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 4 Jan 2010 20:42:57 +0100
Subject: [PATCH 2/2] New CFI flash driver: Fix misleading trace when
	unprotecting a sector
Message-ID: <20100104194257.GC19855@darwin>

When (un)protecting a flash sector with the new CFI flash driver a trace
"protect 0x..." is generated, independently of the type of operation. This is
misleading in case of an unprotect. Tell the truth when unprotecting a sector.

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 drivers/nor/cfi_flash_new.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/nor/cfi_flash_new.c b/drivers/nor/cfi_flash_new.c
index c9910ed..d85e0be 100644
--- a/drivers/nor/cfi_flash_new.c
+++ b/drivers/nor/cfi_flash_new.c
@@ -664,8 +664,10 @@ static int cfi_protect(struct cdev *cdev, size_t count, unsigned long offset, in
 	flash_info_t *finfo = (flash_info_t *)cdev->priv;
 	unsigned long start, end;
 	int i, ret = 0;
+	const char *action = (prot? "protect" : "unprotect");
 
-	printf("%s: protect 0x%08x (size %d)\n", __FUNCTION__, cdev->dev->map_base + offset, count);
+	printf("%s: %s 0x%08x (size %d)\n", __FUNCTION__,
+		action, cdev->dev->map_base + offset, count);
 
 	start = find_sector(finfo, cdev->dev->map_base + offset);
 	end   = find_sector(finfo, cdev->dev->map_base + offset + count - 1);
-- 
1.6.3.1



From matthias at kaehlcke.net  Mon Jan  4 16:10:37 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 4 Jan 2010 22:10:37 +0100
Subject: confusion about relocation (ARM)
In-Reply-To: <20100104201311.GN17262@pengutronix.de>
References: <20100101194822.GR5093@darwin> <4B3E5CCD.60400@eukrea.com>
	<20100101214826.GS5093@darwin>
	<20100104120758.GC4976@pengutronix.de>
	<20100104192153.GA30824@darwin>
	<20100104201311.GN17262@pengutronix.de>
Message-ID: <20100104211037.GD19855@darwin>

El Mon, Jan 04, 2010 at 09:13:11PM +0100 Robert Schwebel ha dit:

> On Mon, Jan 04, 2010 at 08:21:53PM +0100, Matthias Kaehlcke wrote:
> > after getting compiler errors when using a config file created from
> > scratch,
> 
> Can you reproduce that and send us the offending config file? Looks like
> a bug somewhere.

the first problem i faced was the Makefile complaining about an empty
default environment path, though CONFIG_DEFAULT_ENVIRONMENT is not defined:

# CONFIG_DEFAULT_ENVIRONMENT is not set

matze at darwin:/tmp/barebox-2009.12.0$ make
Makefile:1274: *** default environment path empty.  Stop.

this one was easy to work around by commenting the offending section
in the Makefile

reproducing it is as easy as "make ARCH=sandbox menuconfig;
<exit_and_save>; make" from a clean environment

i wasn't able to solve or work around the next one:

make[1]: `arch/arm/include/asm/mach-types.h' is up to date.
  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  SYMLINK include/config.h -> board/at91sam9260ek/config.h
  CC      scripts/mod/empty.o
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  CC      /tmp/barebox-2009.12.0/scripts/mod/empty.o
  CC      /tmp/barebox-2009.12.0/scripts/mod/modpost.o
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:14:19: error: ctype.h: No such file or directory
In file included from /tmp/barebox-2009.12.0/scripts/mod/modpost.c:15:
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:2:20: error: stdlib.h: No such file or directory
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:5:23: error: sys/types.h: No such file or directory
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:6:22: error: sys/stat.h: No such file or directory
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:7:22: error: sys/mman.h: No such file or directory
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:9:20: error: unistd.h: No such file or directory
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:21:1: warning: "ELF_ST_BIND" redefined
In file included from /tmp/barebox-2009.12.0/scripts/mod/modpost.h:10,
                 from /tmp/barebox-2009.12.0/scripts/mod/modpost.c:15:
include/elf.h:119:1: warning: this is the location of the previous definition
In file included from /tmp/barebox-2009.12.0/scripts/mod/modpost.c:15:
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:22:1: warning: "ELF_ST_TYPE" redefined
In file included from /tmp/barebox-2009.12.0/scripts/mod/modpost.h:10,
                 from /tmp/barebox-2009.12.0/scripts/mod/modpost.c:15:
include/elf.h:120:1: warning: this is the location of the previous definition
In file included from /tmp/barebox-2009.12.0/scripts/mod/modpost.c:15:
/tmp/barebox-2009.12.0/scripts/mod/modpost.h:122: error: expected specifier-qualifier-list before 'Elf32_Section'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'fatal':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:57: warning: implicit declaration of function 'vfprintf'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:60: warning: implicit declaration of function 'exit'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'new_module':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:125: warning: implicit declaration of function 'malloc'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:125: warning: passing argument 1 of 'do_nofail' makes pointer from integer without a cast
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'alloc_symbol':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:184: warning: passing argument 1 of 'do_nofail' makes pointer from integer without a cast
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: At top level:
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:252: error: expected declaration specifiers or '...' before 'Elf32_Section'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'export_from_sec':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:254: error: 'sec' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:254: error: (Each undeclared identifier is reported only once
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:254: error: for each function it appears in.)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:254: error: 'struct elf_info' has no member named 'export_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:256: error: 'struct elf_info' has no member named 'export_unused_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:258: error: 'struct elf_info' has no member named 'export_gpl_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:260: error: 'struct elf_info' has no member named 'export_unused_gpl_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:262: error: 'struct elf_info' has no member named 'export_gpl_future_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'grab_file':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:307: error: storage size of 'st' isn't known
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:311: warning: implicit declaration of function 'open'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:312: warning: implicit declaration of function 'fstat'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:316: warning: implicit declaration of function 'mmap'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:316: error: 'PROT_READ' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:316: error: 'PROT_WRITE' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:316: error: 'MAP_PRIVATE' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:316: warning: assignment makes pointer from integer without a cast
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:317: warning: implicit declaration of function 'close'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:319: error: 'MAP_FAILED' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:307: warning: unused variable 'st'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'get_next_line':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:339: warning: implicit declaration of function 'isspace'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'release_file':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:361: warning: implicit declaration of function 'munmap'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'parse_elf':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:373: warning: implicit declaration of function 'perror'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:420: error: 'struct elf_info' has no member named 'modinfo'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:421: error: 'struct elf_info' has no member named 'modinfo_len'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:423: error: 'struct elf_info' has no member named 'export_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:425: error: 'struct elf_info' has no member named 'export_unused_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:427: error: 'struct elf_info' has no member named 'export_gpl_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:429: error: 'struct elf_info' has no member named 'export_unused_gpl_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:431: error: 'struct elf_info' has no member named 'export_gpl_future_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:439: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'handle_modversions':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:467: error: too many arguments to function 'export_from_sec'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:483: warning: implicit declaration of function 'ELF32_ST_BIND'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'find_elf_symbol':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:733: warning: implicit declaration of function 'ELF32_ST_TYPE'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'is_valid_name':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:758: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'warn_sec_mismatch':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:837: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:838: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:843: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:851: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:852: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:858: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:864: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'addend_386_rel':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:888: error: 'R_386_32' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:891: error: 'R_386_PC32' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'addend_mips_rel':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:927: error: 'R_MIPS_HI16' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:931: error: 'R_MIPS_LO16' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:934: error: 'R_MIPS_26' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:937: error: 'R_MIPS_32' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'check_sec_ref':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1039: error: 'EM_386' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1047: error: 'EM_MIPS' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'read_symbols':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1258: error: 'struct elf_info' has no member named 'modinfo'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1258: error: 'struct elf_info' has no member named 'modinfo_len'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1266: error: 'struct elf_info' has no member named 'modinfo'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1266: error: 'struct elf_info' has no member named 'modinfo_len'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1270: error: 'struct elf_info' has no member named 'strtab'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1279: error: 'struct elf_info' has no member named 'modinfo'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1279: error: 'struct elf_info' has no member named 'modinfo_len'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1281: error: 'struct elf_info' has no member named 'modinfo'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'buf_write':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1320: warning: implicit declaration of function 'realloc'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1320: warning: assignment makes pointer from integer without a cast
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'write_if_changed':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1511: error: 'FILE' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1511: error: 'file' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1512: error: storage size of 'st' isn't known
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1512: warning: ISO C90 forbids mixed declarations and code
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1514: warning: implicit declaration of function 'fopen'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1518: warning: implicit declaration of function 'fileno'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1524: warning: passing argument 1 of 'do_nofail' makes pointer from integer without a cast
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1525: warning: implicit declaration of function 'fread'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1531: warning: implicit declaration of function 'free'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1532: warning: implicit declaration of function 'fclose'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1545: warning: implicit declaration of function 'fwrite'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1512: warning: unused variable 'st'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'read_dump':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1581: warning: implicit declaration of function 'strtoul'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c: In function 'main':
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1645: warning: implicit declaration of function 'getopt'
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1648: error: 'optarg' undeclared (first use in this function)
/tmp/barebox-2009.12.0/scripts/mod/modpost.c:1676: error: 'optind' undeclared (first use in this function)
make[1]: *** [/tmp/barebox-2009.12.0/scripts/mod/modpost.o] Error 1
make: *** [common] Error 2

to reproduce from a clean environment:

make ARCH=arm menuconfig
<exit_and_save>
make ARCH=arm CROSS_COMPILE=<your_prefix>

-- 
Matthias Kaehlcke
Embedded Linux Developer
Barcelona

    Yo soy como soy y t? eres como eres, construyamos un mundo donde yo
    pueda ser sin dejar de ser yo, donde t? puedas ser sin dejar de ser
    t?, y donde ni yo ni t? obliguemos al otro a ser como yo o como t?
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-


From s.hauer at pengutronix.de  Tue Jan  5 07:15:02 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 5 Jan 2010 13:15:02 +0100
Subject: [PATCH 0/2] CFI flash drivers: Fix misleading trace when
	unprotecting a sector
In-Reply-To: <20100104194246.GA19855@darwin>
References: <20100104194246.GA19855@darwin>
Message-ID: <20100105121502.GH6923@pengutronix.de>

On Mon, Jan 04, 2010 at 08:42:46PM +0100, Matthias Kaehlcke wrote:
> When (un)protecting a flash sector with the CFI flash drivers a
> trace "protect 0x..." is generated, independently of the type of
> operation. This is misleading in case of an unprotect. Tell the truth
> when unprotecting a sector.
> 
> Matthias Kaehlcke (2):
>   CFI flash driver: Fix misleading trace when unprotecting a sector
>   New CFI flash driver: Fix misleading trace when unprotecting a sector

Ok, applied.

Thanks
 Sascha

> 
>  drivers/nor/cfi_flash.c     |    3 ++-
>  drivers/nor/cfi_flash_new.c |    4 +++-
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From premi at ti.com  Fri Jan  8 04:18:24 2010
From: premi at ti.com (Premi, Sanjeev)
Date: Fri, 8 Jan 2010 14:48:24 +0530
Subject: Query on default environment
In-Reply-To: <B85A65D85D7EB246BE421B3FB0FBB59301E1C30908@dbde02.ent.ti.com>
Message-ID: <B85A65D85D7EB246BE421B3FB0FBB59301E1DFE8A7@dbde02.ent.ti.com>

> From: barebox-bounces at lists.infradead.org [mailto:barebox-bounces at lists.infradead.org] On Behalf Of Premi, Sanjeev
> Sent: Monday, December 28, 2009 7:55 PM
> To: barebox at lists.infradead.org
> Subject: Query on default environment
>
> Hi,
>  
> I was trying to create a default environment for the OMAP3EVM to contain
> basic settings and a 'hello world' script before I could do/add something
> useful. My changes were:
>  
> -# CONFIG_PARTITION is not set
> -# CONFIG_DEFAULT_ENVIRONMENT is not set
> +CONFIG_PARTITION=y
> +CONFIG_DEFAULT_ENVIRONMENT="board/omap/omap3evm/env"
>  
> But, I did come across this error:
>  
> premi # make
> scripts/kconfig/conf -s arch/arm/Kconfig
> Makefile:1261: *** default environment path empty.  Stop.
> 
> make distclean did not help as well. Somehow, the value of
> CONFIG_DEFAULT_ENVIRONMENT in the defconfig seem to take
> precedence over .config. Though, i can;t be sure as I
> was tinkering all over. But finally when the defconfig
> and .config were same, build was successful.
>  
> Will try to see if i can create a reproducible scenario;
> but, if it give hints, may be a problem to look at. Or
> simple ignore as user error.
>  
>  
> Now, I have "barebox_default_env" built alongside barebox.bin
> How do I get this envronment on the EVM?
>  
> Did go thru docs (http://barebox.org/documentation/barebox-2009.12.0/)
> but did not find the next step.

I plan to spend some time this weekend to update the environment and
post updated. Any pointers will be useful.

Best regards,
Sanjeev


From matthias at kaehlcke.net  Sat Jan  9 18:28:38 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Sun, 10 Jan 2010 00:28:38 +0100
Subject: [PATCH 0/5] Add support for EDB93xx boards
Message-ID: <20100109232838.GB14051@darwin>

Add support for the following Cirrus Logic EDB93xx boards:

EDB9301
EDB9302
EDB9302A
EDB9307
EDB9307A
EDB93012
EDB9315
EDB9315A

This patchset has been tested on boards based on the EDB9301 and EDB9307A designs

Matthias Kaehlcke (5):
  ARM: Add support for EP93xx SoCs
  Add EP93xx ethernet driver
  Add support for EP9xx GPIOs
  Add PrimeCell PL010 serial driver
  Add support for EDB93xx boards

 Documentation/boards.dox                        |    8 +
 MAINTAINERS                                     |   11 +
 arch/arm/Kconfig                                |    6 +
 arch/arm/Makefile                               |    9 +
 arch/arm/configs/edb93xx_defconfig              |  237 ++++++++
 arch/arm/mach-ep93xx/Kconfig                    |  446 +++++++++++++++
 arch/arm/mach-ep93xx/Makefile                   |    3 +
 arch/arm/mach-ep93xx/clocksource.c              |   96 ++++
 arch/arm/mach-ep93xx/gpio.c                     |  136 +++++
 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |  600 ++++++++++++++++++++
 arch/arm/mach-ep93xx/include/mach/gpio.h        |   29 +
 arch/arm/mach-ep93xx/led.c                      |   62 ++
 arch/arm/mach-ep93xx/led.h                      |   26 +
 arch/arm/mach-ep93xx/lowlevel_init.S            |   64 +++
 board/edb93xx/Makefile                          |    4 +
 board/edb93xx/barebox.lds.S                     |   79 +++
 board/edb93xx/config.h                          |    4 +
 board/edb93xx/early_udelay.h                    |   34 ++
 board/edb93xx/edb93xx.c                         |  172 ++++++
 board/edb93xx/edb93xx.dox                       |  108 ++++
 board/edb93xx/edb93xx.h                         |   48 ++
 board/edb93xx/env/bin/boot                      |   48 ++
 board/edb93xx/env/bin/flash_partition           |   22 +
 board/edb93xx/env/bin/init                      |   19 +
 board/edb93xx/env/bin/set_nor_parts             |    3 +
 board/edb93xx/env/bin/update_kernel             |   16 +
 board/edb93xx/env/bin/update_rootfs             |   16 +
 board/edb93xx/env/config                        |   16 +
 board/edb93xx/flash_cfg.c                       |   38 ++
 board/edb93xx/pll_cfg.c                         |   58 ++
 board/edb93xx/pll_cfg.h                         |   72 +++
 board/edb93xx/sdram_cfg.c                       |  127 +++++
 board/edb93xx/sdram_cfg.h                       |  144 +++++
 drivers/net/Kconfig                             |    5 +
 drivers/net/Makefile                            |    1 +
 drivers/net/ep93xx.c                            |  686 +++++++++++++++++++++++
 drivers/net/ep93xx.h                            |  155 +++++
 drivers/serial/Kconfig                          |    7 +
 drivers/serial/Makefile                         |    2 +-
 drivers/serial/serial_pl010.c                   |  172 ++++++
 drivers/serial/serial_pl010.h                   |  100 ++++
 include/common.h                                |    1 +
 42 files changed, 3889 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/configs/edb93xx_defconfig
 create mode 100644 arch/arm/mach-ep93xx/Kconfig
 create mode 100644 arch/arm/mach-ep93xx/Makefile
 create mode 100644 arch/arm/mach-ep93xx/clocksource.c
 create mode 100644 arch/arm/mach-ep93xx/gpio.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
 create mode 100644 arch/arm/mach-ep93xx/include/mach/gpio.h
 create mode 100644 arch/arm/mach-ep93xx/led.c
 create mode 100644 arch/arm/mach-ep93xx/led.h
 create mode 100644 arch/arm/mach-ep93xx/lowlevel_init.S
 create mode 100644 board/edb93xx/Makefile
 create mode 100644 board/edb93xx/barebox.lds.S
 create mode 100644 board/edb93xx/config.h
 create mode 100644 board/edb93xx/early_udelay.h
 create mode 100644 board/edb93xx/edb93xx.c
 create mode 100644 board/edb93xx/edb93xx.dox
 create mode 100644 board/edb93xx/edb93xx.h
 create mode 100644 board/edb93xx/env/bin/boot
 create mode 100644 board/edb93xx/env/bin/flash_partition
 create mode 100644 board/edb93xx/env/bin/init
 create mode 100644 board/edb93xx/env/bin/set_nor_parts
 create mode 100644 board/edb93xx/env/bin/update_kernel
 create mode 100644 board/edb93xx/env/bin/update_rootfs
 create mode 100644 board/edb93xx/env/config
 create mode 100644 board/edb93xx/flash_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.h
 create mode 100644 board/edb93xx/sdram_cfg.c
 create mode 100644 board/edb93xx/sdram_cfg.h
 create mode 100644 drivers/net/ep93xx.c
 create mode 100644 drivers/net/ep93xx.h
 create mode 100644 drivers/serial/serial_pl010.c
 create mode 100644 drivers/serial/serial_pl010.h



From matthias at kaehlcke.net  Sat Jan  9 18:28:46 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Sun, 10 Jan 2010 00:28:46 +0100
Subject: [PATCH 1/5] ARM: Add support for EP93xx SoCs
Message-ID: <20100109232846.GC14051@darwin>

Add support for the Cirrus Logic EP93xx platform

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 arch/arm/Kconfig                                |    5 +
 arch/arm/Makefile                               |    9 +
 arch/arm/mach-ep93xx/Kconfig                    |  446 +++++++++++++++++
 arch/arm/mach-ep93xx/Makefile                   |    3 +
 arch/arm/mach-ep93xx/clocksource.c              |   96 ++++
 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |  600 +++++++++++++++++++++++
 arch/arm/mach-ep93xx/led.c                      |   62 +++
 arch/arm/mach-ep93xx/led.h                      |   26 +
 arch/arm/mach-ep93xx/lowlevel_init.S            |   64 +++
 9 files changed, 1311 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/Kconfig
 create mode 100644 arch/arm/mach-ep93xx/Makefile
 create mode 100644 arch/arm/mach-ep93xx/clocksource.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
 create mode 100644 arch/arm/mach-ep93xx/led.c
 create mode 100644 arch/arm/mach-ep93xx/led.h
 create mode 100644 arch/arm/mach-ep93xx/lowlevel_init.S

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c091a99..414a013 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -31,6 +31,10 @@ config ARCH_AT91RM9200
 	bool "Atmel AT91RM9200"
 	select CPU_ARM920T
 
+config ARCH_EP93XX
+	bool "Cirrus Logic EP93xx"
+	select CPU_ARM920T
+
 config ARCH_IMX
 	bool "Freescale iMX-based"
 	select GENERIC_GPIO
@@ -51,6 +55,7 @@ endchoice
 source arch/arm/cpu/Kconfig
 source arch/arm/mach-at91/Kconfig
 source arch/arm/mach-at91rm9200/Kconfig
+source arch/arm/mach-ep93xx/Kconfig
 source arch/arm/mach-imx/Kconfig
 source arch/arm/mach-netx/Kconfig
 source arch/arm/mach-omap/Kconfig
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 47b002f..ede2085 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -39,6 +39,7 @@ CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y)
 # by CONFIG_* macro name.
 machine-$(CONFIG_ARCH_AT91)		:= at91
 machine-$(CONFIG_ARCH_AT91RM9200)	:= at91rm9200
+machine-$(CONFIG_ARCH_EP93XX)		:= ep93xx
 machine-$(CONFIG_ARCH_IMX)		:= imx
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_OMAP)		:= omap
@@ -51,6 +52,14 @@ board-$(CONFIG_MACH_A9M2440)			:= a9m2440
 board-$(CONFIG_MACH_AT91SAM9260EK)		:= at91sam9260ek
 board-$(CONFIG_MACH_AT91SAM9263EK)		:= at91sam9263ek
 board-$(CONFIG_MACH_ECO920)			:= eco920
+board-$(CONFIG_MACH_EDB9301)			:= edb93xx
+board-$(CONFIG_MACH_EDB9302)			:= edb93xx
+board-$(CONFIG_MACH_EDB9302A)			:= edb93xx
+board-$(CONFIG_MACH_EDB9307)			:= edb93xx
+board-$(CONFIG_MACH_EDB9307A)			:= edb93xx
+board-$(CONFIG_MACH_EDB93012)			:= edb93xx
+board-$(CONFIG_MACH_EDB9315)			:= edb93xx
+board-$(CONFIG_MACH_EDB9315A)			:= edb93xx
 board-$(CONFIG_MACH_EUKREA_CPUIMX27)		:= eukrea_cpuimx27
 board-$(CONFIG_MACH_FREESCALE_MX35_3STACK)	:= freescale-mx35-3-stack
 board-$(CONFIG_MACH_FREESCALE_MX25_3STACK)	:= freescale-mx25-3-stack
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
new file mode 100644
index 0000000..139b08d
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -0,0 +1,446 @@
+if ARCH_EP93XX
+
+config EP93XX_SDCE0_PHYS_OFFSET
+	bool
+
+config EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	bool
+
+comment "Cirrus EP93xx System-on-Chip"
+
+choice
+	prompt "Cirrus Logic EP93XX Processor"
+
+config ARCH_EP9301
+	bool "EP9301"
+
+config ARCH_EP9302
+	bool "EP9302"
+
+config ARCH_EP9307
+	bool "EP9307"
+
+config ARCH_EP9312
+	bool "EP9312"
+
+config ARCH_EP9315
+	bool "EP9315"
+
+endchoice
+
+# ----------------------------------------------------------
+
+if ARCH_EP9301
+
+choice
+	prompt "EP9301 Board Type"
+
+config MACH_EDB9301
+	bool "Cirrus Logic EDB9301"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9301 Evaluation board
+
+endchoice
+
+if MACH_EDB9301
+
+config BOARDINFO
+	default "Cirrus Logic EDB9301"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x05700000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 4
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x01000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK2_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK2_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK3_BASE
+	hex
+	default 0x05000000
+
+config EP93XX_SDRAM_BANK3_SIZE
+	hex
+	default 0x00800000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9302
+
+choice
+	prompt "EP9302 Board Type"
+
+config MACH_EDB9302
+	bool "Cirrus Logic EDB9302"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9302 Evaluation board
+
+config MACH_EDB9302A
+	bool "Cirrus Logic EDB9302A"
+	select EP93XX_SDCE0_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9302A Evaluation board
+
+endchoice
+
+if MACH_EDB9302
+
+config BOARDINFO
+	default "Cirrus Logic EDB9302"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x05700000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 4
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x01000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK2_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK2_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK3_BASE
+	hex
+	default 0x05000000
+
+config EP93XX_SDRAM_BANK3_SIZE
+	hex
+	default 0x00800000
+
+endif
+
+if MACH_EDB9302A
+
+config BOARDINFO
+	default "Cirrus Logic EDB9302A"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0xc5700000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 4
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0xc0000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0xc1000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK2_BASE
+	hex
+	default 0xc4000000
+
+config EP93XX_SDRAM_BANK2_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK3_BASE
+	hex
+	default 0xc5000000
+
+config EP93XX_SDRAM_BANK3_SIZE
+	hex
+	default 0x00800000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9307
+
+choice
+	prompt "EP9307 Board Type"
+
+config MACH_EDB9307
+	bool "Cirrus Logic EDB9307"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9307 Evaluation board
+
+config MACH_EDB9307A
+	bool "Cirrus Logic EDB9307A"
+	select EP93XX_SDCE0_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9307A Evaluation board
+
+endchoice
+
+if MACH_EDB9307
+
+config BOARDINFO
+	default "Cirrus Logic EDB9307"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x01f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+if MACH_EDB9307A
+
+config BOARDINFO
+	default "Cirrus Logic EDB9307A"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0xc1f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0xc0000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0xc4000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9312
+
+choice
+	prompt "EP9312 Board Type"
+
+config MACH_EDB9312
+	bool "Cirrus Logic EDB9312"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9312 Evaluation board
+
+endchoice
+
+if MACH_EDB9312
+
+config BOARDINFO
+	default "Cirrus Logic EDB9312"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x01f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9315
+
+choice
+	prompt "EP9315 Board Type"
+
+config MACH_EDB9315
+	bool "Cirrus Logic EDB9315"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9315 Evaluation board
+
+config MACH_EDB9315A
+	bool "Cirrus Logic EDB9315A"
+	select EP93XX_SDCE0_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	select BOARD_LINKER_SCRIPT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9315A Evaluation board
+
+endchoice
+
+if MACH_EDB9315
+
+config BOARDINFO
+	default "Cirrus Logic EDB9315"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x01f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+if MACH_EDB9315A
+
+config BOARDINFO
+	default "Cirrus Logic EDB9315A"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0xc1f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0xc0000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0xc4000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+endif
+
+endif
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
new file mode 100644
index 0000000..d5786db
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -0,0 +1,3 @@
+obj-y += clocksource.o led.o
+
+obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o
diff --git a/arch/arm/mach-ep93xx/clocksource.c b/arch/arm/mach-ep93xx/clocksource.c
new file mode 100644
index 0000000..2a7d90e
--- /dev/null
+++ b/arch/arm/mach-ep93xx/clocksource.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <init.h>
+#include <clock.h>
+#include <asm/io.h>
+#include <mach/ep93xx-regs.h>
+
+#define TIMER_CLKSEL		(1 << 3)
+#define TIMER_MODE		(1 << 6)
+#define TIMER_ENABLE		(1 << 7)
+
+#define TIMER_FREQ		508469
+
+static uint64_t ep93xx_clocksource_read(void)
+{
+	struct timer_regs *timer = (struct timer_regs *)TIMER_BASE;
+
+	return 0xffffffff - readl(&timer->timer3.value);
+}
+
+static struct clocksource cs = {
+	.read	= ep93xx_clocksource_read,
+	.mask	= 0xffffffff,
+	.shift	= 10,
+};
+
+static int clocksource_init(void)
+{
+	struct timer_regs *timer = (struct timer_regs *)TIMER_BASE;
+
+	/* use timer 3 with 508KHz and free running */
+	writel(TIMER_CLKSEL,
+	       &timer->timer3.control);
+
+	/* load timer 3 with max value */
+	writel(0xffffffff, &timer->timer3.load);
+
+	/* enable timer 3 with 508KHz and periodic mode */
+	writel(TIMER_ENABLE | TIMER_MODE | TIMER_CLKSEL,
+	       &timer->timer3.control);
+
+	cs.mult = clocksource_hz2mult(TIMER_FREQ, cs.shift);
+
+	init_clock(&cs);
+
+	return 0;
+}
+
+core_initcall(clocksource_init);
+
+/*
+ * Reset the cpu
+ */
+void reset_cpu(ulong ignored)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+	uint32_t value;
+
+	/* Unlock DeviceCfg and set SWRST */
+	writel(0xAA, &syscon->sysswlock);
+	value = readl(&syscon->devicecfg);
+	value |= SYSCON_DEVICECFG_SWRST;
+	writel(value, &syscon->devicecfg);
+
+	/* Unlock DeviceCfg and clear SWRST */
+	writel(0xAA, &syscon->sysswlock);
+	value = readl(&syscon->devicecfg);
+	value &= ~SYSCON_DEVICECFG_SWRST;
+	writel(value, &syscon->devicecfg);
+
+	/* Dying... */
+	while (1)
+		; /* noop */
+}
+EXPORT_SYMBOL(reset_cpu);
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
new file mode 100644
index 0000000..50bb0eb
--- /dev/null
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -0,0 +1,600 @@
+/* -----------------------------------------------------------------------------
+ * Cirrus Logic EP93xx register definitions.
+ *
+ * Copyright (C) 2009
+ * Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006
+ * Dominic Rath <Dominic.Rath at gmx.de>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.com>
+ *
+ * Based in large part on linux/include/asm-arm/arch-ep93xx/regmap.h, which is
+ *
+ * Copyright (C) 2004 Ray Lehtiniemi
+ * Copyright (C) 2003 Cirrus Logic, Inc
+ * Copyright (C) 1999 ARM Limited.
+ *
+ * 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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#endif
+
+#define EP93XX_AHB_BASE			0x80000000
+#define EP93XX_APB_BASE			0x80800000
+
+/* -----------------------------------------------------------------------------
+ * 0x80000000 - 0x8000FFFF: DMA
+ */
+#define DMA_OFFSET			0x000000
+#define DMA_BASE			(EP93XX_AHB_BASE | DMA_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct dma_channel {
+	uint32_t control;
+	uint32_t interrupt;
+	uint32_t ppalloc;
+	uint32_t status;
+	uint32_t reserved0;
+	uint32_t remain;
+	uint32_t reserved1[2];
+	uint32_t maxcnt0;
+	uint32_t base0;
+	uint32_t current0;
+	uint32_t reserved2;
+	uint32_t maxcnt1;
+	uint32_t base1;
+	uint32_t current1;
+	uint32_t reserved3;
+};
+
+struct dma_regs {
+	struct dma_channel m2p_channel_0;
+	struct dma_channel m2p_channel_1;
+	struct dma_channel m2p_channel_2;
+	struct dma_channel m2p_channel_3;
+	struct dma_channel m2m_channel_0;
+	struct dma_channel m2m_channel_1;
+	struct dma_channel reserved0[2];
+	struct dma_channel m2p_channel_5;
+	struct dma_channel m2p_channel_4;
+	struct dma_channel m2p_channel_7;
+	struct dma_channel m2p_channel_6;
+	struct dma_channel m2p_channel_9;
+	struct dma_channel m2p_channel_8;
+	uint32_t channel_arbitration;
+	uint32_t reserved[15];
+	uint32_t global_interrupt;
+};
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80010000 - 0x8001FFFF: Ethernet MAC
+ */
+#define MAC_OFFSET			0x010000
+#define MAC_BASE			(EP93XX_AHB_BASE | MAC_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct mac_queue {
+	uint32_t badd;
+	union { /* deal with half-word aligned registers */
+		uint32_t blen;
+		union {
+			uint16_t filler;
+			uint16_t curlen;
+		};
+	};
+	uint32_t curadd;
+};
+
+struct mac_regs {
+	uint32_t rxctl;
+	uint32_t txctl;
+	uint32_t testctl;
+	uint32_t reserved0;
+	uint32_t miicmd;
+	uint32_t miidata;
+	uint32_t miists;
+	uint32_t reserved1;
+	uint32_t selfctl;
+	uint32_t inten;
+	uint32_t intstsp;
+	uint32_t intstsc;
+	uint32_t reserved2[2];
+	uint32_t diagad;
+	uint32_t diagdata;
+	uint32_t gt;
+	uint32_t fct;
+	uint32_t fcf;
+	uint32_t afp;
+	union {
+		struct {
+			uint32_t indad;
+			uint32_t indad_upper;
+		};
+		uint32_t hashtbl;
+	};
+	uint32_t reserved3[2];
+	uint32_t giintsts;
+	uint32_t giintmsk;
+	uint32_t giintrosts;
+	uint32_t giintfrc;
+	uint32_t txcollcnt;
+	uint32_t rxmissnct;
+	uint32_t rxruntcnt;
+	uint32_t reserved4;
+	uint32_t bmctl;
+	uint32_t bmsts;
+	uint32_t rxbca;
+	uint32_t reserved5;
+	struct mac_queue rxdq;
+	uint32_t rxdqenq;
+	struct mac_queue rxstsq;
+	uint32_t rxstsqenq;
+	struct mac_queue txdq;
+	uint32_t txdqenq;
+	struct mac_queue txstsq;
+	uint32_t reserved6;
+	uint32_t rxbufthrshld;
+	uint32_t txbufthrshld;
+	uint32_t rxststhrshld;
+	uint32_t txststhrshld;
+	uint32_t rxdthrshld;
+	uint32_t txdthrshld;
+	uint32_t maxfrmlen;
+	uint32_t maxhdrlen;
+};
+#endif
+
+#define SELFCTL_RWP		(1 << 7)
+#define SELFCTL_GPO0		(1 << 5)
+#define SELFCTL_PUWE		(1 << 4)
+#define SELFCTL_PDWE		(1 << 3)
+#define SELFCTL_MIIL		(1 << 2)
+#define SELFCTL_RESET		(1 << 0)
+
+#define INTSTS_RWI		(1 << 30)
+#define INTSTS_RXMI		(1 << 29)
+#define INTSTS_RXBI		(1 << 28)
+#define INTSTS_RXSQI		(1 << 27)
+#define INTSTS_TXLEI		(1 << 26)
+#define INTSTS_ECIE		(1 << 25)
+#define INTSTS_TXUHI		(1 << 24)
+#define INTSTS_MOI		(1 << 18)
+#define INTSTS_TXCOI		(1 << 17)
+#define INTSTS_RXROI		(1 << 16)
+#define INTSTS_MIII		(1 << 12)
+#define INTSTS_PHYI		(1 << 11)
+#define INTSTS_TI		(1 << 10)
+#define INTSTS_AHBE		(1 << 8)
+#define INTSTS_OTHER		(1 << 4)
+#define INTSTS_TXSQ		(1 << 3)
+#define INTSTS_RXSQ		(1 << 2)
+
+#define BMCTL_MT		(1 << 13)
+#define BMCTL_TT		(1 << 12)
+#define BMCTL_UNH		(1 << 11)
+#define BMCTL_TXCHR		(1 << 10)
+#define BMCTL_TXDIS		(1 << 9)
+#define BMCTL_TXEN		(1 << 8)
+#define BMCTL_EH2		(1 << 6)
+#define BMCTL_EH1		(1 << 5)
+#define BMCTL_EEOB		(1 << 4)
+#define BMCTL_RXCHR		(1 << 2)
+#define BMCTL_RXDIS		(1 << 1)
+#define BMCTL_RXEN		(1 << 0)
+
+#define BMSTS_TXACT		(1 << 7)
+#define BMSTS_TP		(1 << 4)
+#define BMSTS_RXACT		(1 << 3)
+#define BMSTS_QID_MASK		0x07
+#define BMSTS_QID_RXDATA	0x00
+#define BMSTS_QID_TXDATA	0x01
+#define BMSTS_QID_RXSTS		0x02
+#define BMSTS_QID_TXSTS		0x03
+#define BMSTS_QID_RXDESC	0x04
+#define BMSTS_QID_TXDESC	0x05
+
+#define AFP_MASK		0x07
+#define AFP_IAPRIMARY		0x00
+#define AFP_IASECONDARY1	0x01
+#define AFP_IASECONDARY2	0x02
+#define AFP_IASECONDARY3	0x03
+#define AFP_TX			0x06
+#define AFP_HASH		0x07
+
+#define RXCTL_PAUSEA		(1 << 20)
+#define RXCTL_RXFCE1		(1 << 19)
+#define RXCTL_RXFCE0		(1 << 18)
+#define RXCTL_BCRC		(1 << 17)
+#define RXCTL_SRXON		(1 << 16)
+#define RXCTL_RCRCA		(1 << 13)
+#define RXCTL_RA		(1 << 12)
+#define RXCTL_PA		(1 << 11)
+#define RXCTL_BA		(1 << 10)
+#define RXCTL_MA		(1 << 9)
+#define RXCTL_IAHA		(1 << 8)
+#define RXCTL_IA3		(1 << 3)
+#define RXCTL_IA2		(1 << 2)
+#define RXCTL_IA1		(1 << 1)
+#define RXCTL_IA0		(1 << 0)
+
+#define TXCTL_DEFDIS		(1 << 7)
+#define TXCTL_MBE		(1 << 6)
+#define TXCTL_ICRC		(1 << 5)
+#define TXCTL_TPD		(1 << 4)
+#define TXCTL_OCOLL		(1 << 3)
+#define TXCTL_SP		(1 << 2)
+#define TXCTL_PB		(1 << 1)
+#define TXCTL_STXON		(1 << 0)
+
+#define MIICMD_REGAD_MASK	(0x001F)
+#define MIICMD_PHYAD_MASK	(0x03E0)
+#define MIICMD_OPCODE_MASK	(0xC000)
+#define MIICMD_PHYAD_8950	(0x0000)
+#define MIICMD_OPCODE_READ	(0x8000)
+#define MIICMD_OPCODE_WRITE	(0x4000)
+
+#define MIISTS_BUSY		(1 << 0)
+
+/* -----------------------------------------------------------------------------
+ * 0x80020000 - 0x8002FFFF: USB OHCI
+ */
+#define USB_OFFSET			0x020000
+#define USB_BASE			(EP93XX_AHB_BASE | USB_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80030000 - 0x8003FFFF: Raster engine
+ */
+#if (defined(CONFIG_EP9307) || defined(CONFIG_EP9312) || defined(CONFIG_EP9315))
+#define RASTER_OFFSET			0x030000
+#define RASTER_BASE			(EP93XX_AHB_BASE | RASTER_OFFSET)
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80040000 - 0x8004FFFF: Graphics accelerator
+ */
+#if defined(CONFIG_EP9315)
+#define GFX_OFFSET			0x040000
+#define GFX_BASE			(EP93XX_AHB_BASE | GFX_OFFSET)
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80050000 - 0x8005FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80060000 - 0x8006FFFF: SDRAM controller
+ */
+#define SDRAM_OFFSET			0x060000
+#define SDRAM_BASE			(EP93XX_AHB_BASE | SDRAM_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct sdram_regs {
+	uint32_t reserved;
+	uint32_t glconfig;
+	uint32_t refrshtimr;
+	uint32_t bootsts;
+	uint32_t devcfg0;
+	uint32_t devcfg1;
+	uint32_t devcfg2;
+	uint32_t devcfg3;
+};
+#endif
+
+#define SDRAM_DEVCFG_EXTBUSWIDTH	(1 << 2)
+#define SDRAM_DEVCFG_BANKCOUNT		(1 << 3)
+#define SDRAM_DEVCFG_SROMLL		(1 << 5)
+#define SDRAM_DEVCFG_CASLAT_2		0x00010000
+#define SDRAM_DEVCFG_RASTOCAS_2		0x00200000
+
+#define GLCONFIG_INIT			(1 << 0)
+#define GLCONFIG_MRS			(1 << 1)
+#define GLCONFIG_SMEMBUSY		(1 << 5)
+#define GLCONFIG_LCR			(1 << 6)
+#define GLCONFIG_REARBEN		(1 << 7)
+#define GLCONFIG_CLKSHUTDOWN		(1 << 30)
+#define GLCONFIG_CKE			(1 << 31)
+
+/* -----------------------------------------------------------------------------
+ * 0x80070000 - 0x8007FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80080000 - 0x8008FFFF: SRAM controller & PCMCIA
+ */
+#define SMC_OFFSET			0x080000
+#define SMC_BASE			(EP93XX_AHB_BASE | SMC_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct smc_regs {
+	uint32_t bcr0;
+	uint32_t bcr1;
+	uint32_t bcr2;
+	uint32_t bcr3;
+	uint32_t reserved0[2];
+	uint32_t bcr6;
+	uint32_t bcr7;
+#if defined(CONFIG_EP9315)
+	uint32_t pcattribute;
+	uint32_t pccommon;
+	uint32_t pcio;
+	uint32_t reserved1[5];
+	uint32_t pcmciactrl;
+#endif
+};
+#endif
+
+#define SMC_BCR_IDCY_SHIFT	0
+#define SMC_BCR_WST1_SHIFT	5
+#define SMC_BCR_BLE		(1 << 10)
+#define SMC_BCR_WST2_SHIFT	11
+#define SMC_BCR_MW_SHIFT	28
+
+/* -----------------------------------------------------------------------------
+ * 0x80090000 - 0x8009FFFF: Boot ROM
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800A0000 - 0x800AFFFF: IDE interface
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800B0000 - 0x800BFFFF: VIC1
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800C0000 - 0x800CFFFF: VIC2
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800D0000 - 0x800FFFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80800000 - 0x8080FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80810000 - 0x8081FFFF: Timers
+ */
+#define TIMER_OFFSET		0x010000
+#define TIMER_BASE		(EP93XX_APB_BASE | TIMER_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct timer {
+	uint32_t load;
+	uint32_t value;
+	uint32_t control;
+	uint32_t clear;
+};
+
+struct timer4 {
+	uint32_t value_low;
+	uint32_t value_high;
+};
+
+struct timer_regs {
+	struct timer timer1;
+	uint32_t reserved0[4];
+	struct timer timer2;
+	uint32_t reserved1[12];
+	struct timer4 timer4;
+	uint32_t reserved2[6];
+	struct timer timer3;
+};
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80820000 - 0x8082FFFF: I2S
+ */
+#define I2S_OFFSET		0x020000
+#define I2S_BASE		(EP93XX_APB_BASE | I2S_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80830000 - 0x8083FFFF: Security
+ */
+#define SECURITY_OFFSET		0x030000
+#define SECURITY_BASE		(EP93XX_APB_BASE | SECURITY_OFFSET)
+
+#define EXTENSIONID		(SECURITY_BASE + 0x2714)
+
+/* -----------------------------------------------------------------------------
+ * 0x80840000 - 0x8084FFFF: GPIO
+ */
+#define GPIO_OFFSET		0x040000
+#define GPIO_BASE		(EP93XX_APB_BASE | GPIO_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct gpio_int {
+	uint32_t inttype1;
+	uint32_t inttype2;
+	uint32_t eoi;
+	uint32_t inten;
+	uint32_t intsts;
+	uint32_t rawintsts;
+	uint32_t db;
+};
+
+struct gpio_regs {
+	uint32_t padr;
+	uint32_t pbdr;
+	uint32_t pcdr;
+	uint32_t pddr;
+	uint32_t paddr;
+	uint32_t pbddr;
+	uint32_t pcddr;
+	uint32_t pdddr;
+	uint32_t pedr;
+	uint32_t peddr;
+	uint32_t reserved0[2];
+	uint32_t pfdr;
+	uint32_t pfddr;
+	uint32_t pgdr;
+	uint32_t pgddr;
+	uint32_t phdr;
+	uint32_t phddr;
+	uint32_t reserved1;
+	uint32_t finttype1;
+	uint32_t finttype2;
+	uint32_t reserved2;
+	struct gpio_int pfint;
+	uint32_t reserved3[10];
+	struct gpio_int paint;
+	struct gpio_int pbint;
+	uint32_t eedrive;
+};
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80850000 - 0x8087FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80880000 - 0x8088FFFF: AAC
+ */
+#define AAC_OFFSET		0x080000
+#define AAC_BASE		(EP93XX_APB_BASE | AAC_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80890000 - 0x8089FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x808A0000 - 0x808AFFFF: SPI
+ */
+#define SPI_OFFSET		0x0A0000
+#define SPI_BASE		(EP93XX_APB_BASE | SPI_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808B0000 - 0x808BFFFF: IrDA
+ */
+#define IRDA_OFFSET		0x0B0000
+#define IRDA_BASE		(EP93XX_APB_BASE | IRDA_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808C0000 - 0x808CFFFF: UART1
+ */
+#define UART1_OFFSET		0x0C0000
+#define UART1_BASE		(EP93XX_APB_BASE | UART1_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808D0000 - 0x808DFFFF: UART2
+ */
+#define UART2_OFFSET		0x0D0000
+#define UART2_BASE		(EP93XX_APB_BASE | UART2_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808E0000 - 0x808EFFFF: UART3
+ */
+#define UART3_OFFSET		0x0E0000
+#define UART3_BASE		(EP93XX_APB_BASE | UART3_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808F0000 - 0x808FFFFF: Key Matrix
+ */
+#define KEY_OFFSET		0x0F0000
+#define KEY_BASE		(EP93XX_APB_BASE | KEY_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80900000 - 0x8090FFFF: Touchscreen
+ */
+#define TOUCH_OFFSET		0x900000
+#define TOUCH_BASE		(EP93XX_APB_BASE | TOUCH_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80910000 - 0x8091FFFF: Pulse Width Modulation
+ */
+#define PWM_OFFSET		0x910000
+#define PWM_BASE		(EP93XX_APB_BASE | PWM_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80920000 - 0x8092FFFF: Real time clock
+ */
+#define RTC_OFFSET		0x920000
+#define RTC_BASE		(EP93XX_APB_BASE | RTC_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80930000 - 0x8093FFFF: Syscon
+ */
+#define SYSCON_OFFSET		0x930000
+#define SYSCON_BASE		(EP93XX_APB_BASE | SYSCON_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct syscon_regs {
+	uint32_t pwrsts;
+	uint32_t pwrcnt;
+	uint32_t halt;
+	uint32_t stby;
+	uint32_t reserved0[2];
+	uint32_t teoi;
+	uint32_t stfclr;
+	uint32_t clkset1;
+	uint32_t clkset2;
+	uint32_t reserved1[6];
+	uint32_t scratch0;
+	uint32_t scratch1;
+	uint32_t reserved2[2];
+	uint32_t apbwait;
+	uint32_t bustmstrarb;
+	uint32_t bootmodeclr;
+	uint32_t reserved3[9];
+	uint32_t devicecfg;
+	uint32_t vidclkdiv;
+	uint32_t mirclkdiv;
+	uint32_t i2sclkdiv;
+	uint32_t keytchclkdiv;
+	uint32_t chipid;
+	uint32_t syscfg;
+	uint32_t reserved4[8];
+	uint32_t sysswlock;
+};
+#else
+#define SYSCON_SCRATCH0		(SYSCON_BASE + 0x0040)
+#endif
+
+#define SYSCON_PWRCNT_UART_BAUD			(1 << 29)
+
+#define SYSCON_CLKSET_PLL_X2IPD_SHIFT		0
+#define SYSCON_CLKSET_PLL_X2FBD2_SHIFT		5
+#define SYSCON_CLKSET_PLL_X1FBD1_SHIFT		11
+#define SYSCON_CLKSET_PLL_PS_SHIFT		16
+#define SYSCON_CLKSET1_PCLK_DIV_SHIFT		18
+#define SYSCON_CLKSET1_HCLK_DIV_SHIFT		20
+#define SYSCON_CLKSET1_NBYP1			(1 << 23)
+#define SYSCON_CLKSET1_FCLK_DIV_SHIFT		25
+
+#define SYSCON_CLKSET2_PLL2_EN			(1 << 18)
+#define SYSCON_CLKSET2_NBYP2			(1 << 19)
+#define SYSCON_CLKSET2_USB_DIV_SHIFT		28
+
+#define SYSCON_CHIPID_REV_MASK			0xF0000000
+#define SYSCON_DEVICECFG_SWRST			(1 << 31)
+
+/* -----------------------------------------------------------------------------
+ * 0x80930000 - 0x8093FFFF: Watchdog Timer
+ */
+#define WATCHDOG_OFFSET		0x940000
+#define WATCHDOG_BASE		(EP93XX_APB_BASE | WATCHDOG_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80950000 - 0x9000FFFF: Reserved
+ */
+
diff --git a/arch/arm/mach-ep93xx/led.c b/arch/arm/mach-ep93xx/led.c
new file mode 100644
index 0000000..6d6b902
--- /dev/null
+++ b/arch/arm/mach-ep93xx/led.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <asm/io.h>
+#include <mach/ep93xx-regs.h>
+
+#define GREEN_LED_POS		0x01
+#define RED_LED_POS		0x02
+
+inline void switch_LED_on(uint32_t bit_pos)
+{
+	register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
+
+	writel(readl(&gpio->pedr) | bit_pos, &gpio->pedr);
+}
+
+inline void switch_LED_off(uint32_t bit_pos)
+{
+	register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
+
+	writel(readl(&gpio->pedr) & ~bit_pos, &gpio->pedr);
+}
+
+void red_LED_on(void)
+{
+	switch_LED_on(RED_LED_POS);
+}
+
+void red_LED_off(void)
+{
+	switch_LED_off(RED_LED_POS);
+}
+
+void green_LED_on(void)
+{
+	switch_LED_on(GREEN_LED_POS);
+}
+
+void green_LED_off(void)
+{
+	switch_LED_off(GREEN_LED_POS);
+}
diff --git a/arch/arm/mach-ep93xx/led.h b/arch/arm/mach-ep93xx/led.h
new file mode 100644
index 0000000..db9512f
--- /dev/null
+++ b/arch/arm/mach-ep93xx/led.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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
+ */
+
+extern void red_LED_on(void);
+extern void red_LED_off(void);
+extern void green_LED_on(void);
+extern void green_LED_off(void);
diff --git a/arch/arm/mach-ep93xx/lowlevel_init.S b/arch/arm/mach-ep93xx/lowlevel_init.S
new file mode 100644
index 0000000..27c2c90
--- /dev/null
+++ b/arch/arm/mach-ep93xx/lowlevel_init.S
@@ -0,0 +1,64 @@
+/*
+ * Low-level initialization for EP93xx
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <mach/ep93xx-regs.h>
+
+.globl board_init_lowlevel
+board_init_lowlevel:
+	/* backup return address */
+	ldr r1, =SYSCON_SCRATCH0
+	str lr, [r1]
+
+	/* Turn on both LEDs */
+	bl red_LED_on
+	bl green_LED_on
+
+	/* Configure flash wait states before we switch to the PLL */
+	bl flash_cfg
+
+	/* Set up PLL */
+	bl pll_cfg
+
+	/* Turn off the Green LED and leave the Red LED on */
+	bl green_LED_off
+
+	/* Setup SDRAM */
+	bl sdram_cfg
+
+	/* Turn on Green LED, Turn off the Red LED */
+	bl green_LED_on
+	bl red_LED_off
+
+	/* switch to async mode */
+	mrc p15, 0, r0, c1, c0, 0
+	orr r0, r0, #0xc0000000
+	mcr p15, 0, r0, c1, c0, 0
+
+	/* restore return address */
+	ldr r1, =SYSCON_SCRATCH0
+	ldr lr, [r1]
+
+	mov pc, lr
-- 
1.6.3.1



From matthias at kaehlcke.net  Sat Jan  9 18:28:52 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Sun, 10 Jan 2010 00:28:52 +0100
Subject: [PATCH 2/5] Add EP93xx ethernet driver
Message-ID: <20100109232852.GD14051@darwin>

Added ethernet driver for EP93xx SoCs

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 drivers/net/Kconfig  |    5 +
 drivers/net/Makefile |    1 +
 drivers/net/ep93xx.c |  686 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ep93xx.h |  155 ++++++++++++
 include/common.h     |    1 +
 5 files changed, 848 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ep93xx.c
 create mode 100644 drivers/net/ep93xx.h

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ed7656e..0955562 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -64,6 +64,11 @@ config DRIVER_NET_FEC_IMX
 	depends on ARCH_HAS_FEC_IMX
 	select MIIPHY
 
+config DRIVER_NET_EP93XX
+	bool "EP93xx Ethernet driver"
+	depends on ARCH_EP93XX
+	select MIIPHY
+
 config DRIVER_NET_MACB
 	bool "macb Ethernet driver"
 	depends on ARCH_AT91
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6751920..1b6f104 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_DRIVER_NET_NETX)		+= netx_eth.o
 obj-$(CONFIG_DRIVER_NET_AT91_ETHER)	+= at91_ether.o
 obj-$(CONFIG_DRIVER_NET_MPC5200)	+= fec_mpc5200.o
 obj-$(CONFIG_DRIVER_NET_FEC_IMX)	+= fec_imx.o
+obj-$(CONFIG_DRIVER_NET_EP93XX)		+= ep93xx.o
 obj-$(CONFIG_DRIVER_NET_MACB)		+= macb.o
 obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
 obj-$(CONFIG_MIIPHY)			+= miiphy.o
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
new file mode 100644
index 0000000..63a0d1b
--- /dev/null
+++ b/drivers/net/ep93xx.c
@@ -0,0 +1,686 @@
+/*
+ * Cirrus Logic EP93xx ethernet MAC / MII driver.
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.com>
+ *
+ * Based on the original eth.[ch] Cirrus Logic EP93xx Rev D. Ethernet Driver,
+ * which is
+ *
+ * (C) Copyright 2002 2003
+ * Adam Bezanson, Network Audio Technologies, Inc.
+ * <bezanson at netaudiotech.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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <init.h>
+#include <malloc.h>
+#include <miiphy.h>
+#include <asm/io.h>
+#include <linux/types.h>
+#include <mach/ep93xx-regs.h>
+#include "ep93xx.h"
+
+static int ep93xx_eth_send_packet(struct eth_device *edev,
+				void *packet, int length);
+static int ep93xx_eth_rcv_packet(struct eth_device *edev);
+
+static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t *value);
+static int ep93xx_phy_write(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t value);
+
+static inline struct ep93xx_eth_priv *ep93xx_get_priv(struct eth_device *edev)
+{
+	return (struct ep93xx_eth_priv *)edev->priv;
+}
+
+static inline struct mac_regs *ep93xx_get_regs(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+
+	return priv->regs;
+}
+
+#if defined(EP93XX_MAC_DEBUG)
+/**
+ * Dump ep93xx_mac values to the terminal.
+ */
+inline void dump_dev(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_dev()\n");
+	printf("  rx_dq.base	     %08X\n", priv->rx_dq.base);
+	printf("  rx_dq.current	     %08X\n", priv->rx_dq.current);
+	printf("  rx_dq.end	     %08X\n", priv->rx_dq.end);
+	printf("  rx_sq.base	     %08X\n", priv->rx_sq.base);
+	printf("  rx_sq.current	     %08X\n", priv->rx_sq.current);
+	printf("  rx_sq.end	     %08X\n", priv->rx_sq.end);
+
+	for (i = 0; i < NUMRXDESC; i++)
+		printf("  rx_buffer[%2.d]      %08X\n", i, NetRxPackets[i]);
+
+	printf("  tx_dq.base	     %08X\n", priv->tx_dq.base);
+	printf("  tx_dq.current	     %08X\n", priv->tx_dq.current);
+	printf("  tx_dq.end	     %08X\n", priv->tx_dq.end);
+	printf("  tx_sq.base	     %08X\n", priv->tx_sq.base);
+	printf("  tx_sq.current	     %08X\n", priv->tx_sq.current);
+	printf("  tx_sq.end	     %08X\n", priv->tx_sq.end);
+}
+
+/**
+ * Dump all RX descriptor queue entries to the terminal.
+ */
+inline void dump_rx_descriptor_queue(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_rx_descriptor_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMRXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->rx_dq.base + i),
+			(priv->rx_dq.base + i)->word1,
+			(priv->rx_dq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all RX status queue entries to the terminal.
+ */
+inline void dump_rx_status_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_rx_status_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMRXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->rx_sq.base + i),
+			(priv->rx_sq.base + i)->word1,
+			(priv->rx_sq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all TX descriptor queue entries to the terminal.
+ */
+inline void dump_tx_descriptor_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_tx_descriptor_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMTXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->tx_dq.base + i),
+			(priv->tx_dq.base + i)->word1,
+			(priv->tx_dq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all TX status queue entries to the terminal.
+ */
+inline void dump_tx_status_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_tx_status_queue()\n");
+	printf("  descriptor address	 word1\n");
+	for (i = 0; i < NUMTXDESC; i++) {
+		printf("  [ %08X ]	     %08X\n",
+			(priv->rx_sq.base + i),
+			(priv->rx_sq.base + i)->word1);
+	}
+}
+#else
+#define dump_dev(x)
+#define dump_rx_descriptor_queue()
+#define dump_rx_status_queue()
+#define dump_tx_descriptor_queue()
+#define dump_tx_status_queue()
+#endif	/* defined(EP93XX_MAC_DEBUG) */
+
+/**
+ * Reset the EP93xx MAC by twiddling the soft reset bit and spinning until
+ * it's cleared.
+ */
+static void ep93xx_eth_reset(struct eth_device *edev)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	uint32_t value;
+
+	pr_debug("+ep93xx_eth_reset\n");
+
+	value = readl(&regs->selfctl);
+	value |= SELFCTL_RESET;
+	writel(value, &regs->selfctl);
+
+	while (readl(&regs->selfctl) & SELFCTL_RESET)
+		; /* noop */
+
+	pr_debug("-ep93xx_eth_reset\n");
+}
+
+static int ep93xx_eth_init_dev(struct eth_device *edev)
+{
+	pr_debug("+ep93xx_eth_init_dev\n");
+
+	pr_debug("-ep93xx_eth_init_dev\n");
+
+	return 0;
+}
+
+static int ep93xx_eth_open(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int i;
+
+	pr_debug("+ep93xx_eth_open\n");
+
+	ep93xx_eth_reset(edev);
+
+	/* Reset the descriptor queues' current and end address values */
+	priv->tx_dq.current = priv->tx_dq.base;
+	priv->tx_dq.end = (priv->tx_dq.base + NUMTXDESC);
+
+	priv->tx_sq.current = priv->tx_sq.base;
+	priv->tx_sq.end = (priv->tx_sq.base + NUMTXDESC);
+
+	priv->rx_dq.current = priv->rx_dq.base;
+	priv->rx_dq.end = (priv->rx_dq.base + NUMRXDESC);
+
+	priv->rx_sq.current = priv->rx_sq.base;
+	priv->rx_sq.end = (priv->rx_sq.base + NUMRXDESC);
+
+	/*
+	 * Set the transmit descriptor and status queues' base address,
+	 * current address, and length registers.  Set the maximum frame
+	 * length and threshold. Enable the transmit descriptor processor.
+	 */
+	writel((uint32_t)priv->tx_dq.base, &regs->txdq.badd);
+	writel((uint32_t)priv->tx_dq.base, &regs->txdq.curadd);
+	writel(sizeof(struct tx_descriptor) * NUMTXDESC, &regs->txdq.blen);
+
+	writel((uint32_t)priv->tx_sq.base, &regs->txstsq.badd);
+	writel((uint32_t)priv->tx_sq.base, &regs->txstsq.curadd);
+	writel(sizeof(struct tx_status) * NUMTXDESC, &regs->txstsq.blen);
+
+	writel(0x00040000, &regs->txdthrshld);
+	writel(0x00040000, &regs->txststhrshld);
+
+	writel((TXSTARTMAX << 0) | (PKTSIZE_ALIGN << 16), &regs->maxfrmlen);
+	writel(BMCTL_TXEN, &regs->bmctl);
+
+	/*
+	 * Set the receive descriptor and status queues' base address,
+	 * current address, and length registers.  Enable the receive
+	 * descriptor processor.
+	 */
+	writel((uint32_t)priv->rx_dq.base, &regs->rxdq.badd);
+	writel((uint32_t)priv->rx_dq.base, &regs->rxdq.curadd);
+	writel(sizeof(struct rx_descriptor) * NUMRXDESC, &regs->rxdq.blen);
+
+	writel((uint32_t)priv->rx_sq.base, &regs->rxstsq.badd);
+	writel((uint32_t)priv->rx_sq.base, &regs->rxstsq.curadd);
+	writel(sizeof(struct rx_status) * NUMRXDESC, &regs->rxstsq.blen);
+
+	writel(0x00040000, &regs->rxdthrshld);
+
+	writel(BMCTL_RXEN, &regs->bmctl);
+
+	writel(0x00040000, &regs->rxststhrshld);
+
+	/* Wait until the receive descriptor processor is active */
+	while (!(readl(&regs->bmsts) & BMSTS_RXACT))
+		; /* noop */
+
+	/*
+	 * Initialize the RX descriptor queue. Clear the TX descriptor queue.
+	 * Clear the RX and TX status queues. Enqueue the RX descriptor and
+	 * status entries to the MAC.
+	 */
+	for (i = 0; i < NUMRXDESC; i++) {
+		/* set buffer address */
+		(priv->rx_dq.base + i)->word1 = (uint32_t)NetRxPackets[i];
+
+		/* set buffer length, clear buffer index and NSOF */
+		(priv->rx_dq.base + i)->word2 = PKTSIZE_ALIGN;
+	}
+
+	memset(priv->tx_dq.base, 0,
+		(sizeof(struct tx_descriptor) * NUMTXDESC));
+	memset(priv->rx_sq.base, 0,
+		(sizeof(struct rx_status) * NUMRXDESC));
+	memset(priv->tx_sq.base, 0,
+		(sizeof(struct tx_status) * NUMTXDESC));
+
+	writel(NUMRXDESC, &regs->rxdqenq);
+	writel(NUMRXDESC, &regs->rxstsqenq);
+
+	/* Turn on RX and TX */
+	writel(RXCTL_IA0 | RXCTL_BA | RXCTL_SRXON |
+		RXCTL_RCRCA | RXCTL_MA, &regs->rxctl);
+	writel(TXCTL_STXON, &regs->txctl);
+
+	/* Dump data structures if we're debugging */
+	dump_dev();
+	dump_rx_descriptor_queue();
+	dump_rx_status_queue();
+	dump_tx_descriptor_queue();
+	dump_tx_status_queue();
+
+	pr_debug("-ep93xx_eth_open\n");
+
+	return 0;
+}
+
+/**
+ * Halt EP93xx MAC transmit and receive by clearing the TxCTL and RxCTL
+ * registers.
+ */
+static void ep93xx_eth_halt(struct eth_device *edev)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+
+	pr_debug("+ep93xx_eth_halt\n");
+
+	writel(0x00000000, &regs->rxctl);
+	writel(0x00000000, &regs->txctl);
+
+	pr_debug("-ep93xx_eth_halt\n");
+}
+
+static int ep93xx_eth_get_ethaddr(struct eth_device *edev,
+				unsigned char *mac_addr)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	uint32_t value;
+
+	value = readl(&regs->indad);
+	mac_addr[0] = value & 0xFF;
+	mac_addr[1] = (value >> 8) & 0xFF;
+	mac_addr[2] = (value >> 16) & 0xFF;
+	mac_addr[3] = (value >> 24) & 0xFF;
+
+	value = readl(&regs->indad_upper);
+	mac_addr[4] = value & 0xFF;
+	mac_addr[5] = (value >> 8) & 0xFF;
+
+	return 0;
+}
+
+static int ep93xx_eth_set_ethaddr(struct eth_device *edev,
+				unsigned char *mac_addr)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+
+	writel(AFP_IAPRIMARY, &regs->afp);
+
+	writel(mac_addr[0] | (mac_addr[1] << 8) |
+		(mac_addr[2] << 16) | (mac_addr[3] << 24),
+		&regs->indad);
+	writel(mac_addr[4] | (mac_addr[5] << 8), &regs->indad_upper);
+
+	return 0;
+}
+
+static int ep93xx_eth_probe(struct device_d *dev)
+{
+	struct eth_device *edev;
+	struct ep93xx_eth_priv *priv;
+	int ret = ETH_STATUS_FAILURE;
+
+	pr_debug("ep93xx_eth_probe()\n");
+
+	edev = xzalloc(sizeof(struct eth_device) +
+		sizeof(struct ep93xx_eth_priv));
+	dev->type_data = edev;
+	edev->priv = (struct ep93xx_eth_priv *)(edev + 1);
+
+	priv = edev->priv;
+	priv->regs = (struct mac_regs *)MAC_BASE;
+
+	edev->init = ep93xx_eth_init_dev;
+	edev->open = ep93xx_eth_open;
+	edev->send = ep93xx_eth_send_packet;
+	edev->recv = ep93xx_eth_rcv_packet;
+	edev->halt = ep93xx_eth_halt;
+	edev->get_ethaddr = ep93xx_eth_get_ethaddr;
+	edev->set_ethaddr = ep93xx_eth_set_ethaddr;
+
+	priv->miiphy.read = ep93xx_phy_read;
+	priv->miiphy.write = ep93xx_phy_write;
+	priv->miiphy.address = 0;
+	priv->miiphy.flags = 0;
+
+	priv->tx_dq.base = calloc(NUMTXDESC,
+				sizeof(struct tx_descriptor));
+	if (priv->tx_dq.base == NULL) {
+		pr_err("calloc() failed: tx_dq.base");
+		goto eth_probe_failed_0;
+	}
+
+	priv->tx_sq.base = calloc(NUMTXDESC,
+				sizeof(struct tx_status));
+	if (priv->tx_sq.base == NULL) {
+		pr_err("calloc() failed: tx_sq.base");
+		goto eth_probe_failed_1;
+	}
+
+	priv->rx_dq.base = calloc(NUMRXDESC,
+				sizeof(struct rx_descriptor));
+	if (priv->rx_dq.base == NULL) {
+		pr_err("calloc() failed: rx_dq.base");
+		goto eth_probe_failed_2;
+	}
+
+	priv->rx_sq.base = calloc(NUMRXDESC,
+				sizeof(struct rx_status));
+	if (priv->rx_sq.base == NULL) {
+		pr_err("calloc() failed: rx_sq.base");
+		goto eth_probe_failed_3;
+	}
+
+	miiphy_register(&priv->miiphy);
+	eth_register(edev);
+
+	ret = ETH_STATUS_SUCCESS;
+
+	goto eth_probe_done;
+
+eth_probe_failed_3:
+	free(priv->rx_dq.base);
+	/* Fall through */
+
+eth_probe_failed_2:
+	free(priv->tx_sq.base);
+	/* Fall through */
+
+eth_probe_failed_1:
+	free(priv->tx_dq.base);
+	/* Fall through */
+
+eth_probe_failed_0:
+	/* Fall through */
+
+eth_probe_done:
+	return ret;
+}
+
+/**
+ * Copy a frame of data from the MAC into the protocol layer for further
+ * processing.
+ *
+ * TODO: Enhance this to deal with as many packets as are available at
+ * the MAC at one time? */
+static int ep93xx_eth_rcv_packet(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int ret = ETH_STATUS_FAILURE;
+
+	pr_debug("+ep93xx_eth_rcv_packet\n");
+
+	if (RX_STATUS_RFP(priv->rx_sq.current)) {
+		if (RX_STATUS_RWE(priv->rx_sq.current)) {
+			/*
+			 * We have a good frame. Extract the frame's length
+			 * from the current rx_status_queue entry, and copy
+			 * the frame's data into NetRxPackets[] of the
+			 * protocol stack. We track the total number of
+			 * bytes in the frame (nbytes_frame) which will be
+			 * used when we pass the data off to the protocol
+			 * layer via NetReceive().
+			 */
+			NetReceive((uchar *)priv->rx_dq.current->word1,
+				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
+			pr_debug("reporting %d bytes...\n",
+				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
+
+			ret = ETH_STATUS_SUCCESS;
+
+		} else {
+			/* Do we have an erroneous packet? */
+			pr_err("packet rx error, status %08X %08X\n",
+				priv->rx_sq.current->word1,
+				priv->rx_sq.current->word2);
+			dump_rx_descriptor_queue();
+			dump_rx_status_queue();
+		}
+
+		/*
+		 * Clear the associated status queue entry, and
+		 * increment our current pointers to the next RX
+		 * descriptor and status queue entries (making sure
+		 * we wrap properly).
+		 */
+		memset((void *)priv->rx_sq.current, 0,
+			sizeof(struct rx_status));
+
+		priv->rx_sq.current++;
+		if (priv->rx_sq.current >= priv->rx_sq.end)
+			priv->rx_sq.current = priv->rx_sq.base;
+
+		priv->rx_dq.current++;
+		if (priv->rx_dq.current >= priv->rx_dq.end)
+			priv->rx_dq.current = priv->rx_dq.base;
+
+		/*
+		 * Finally, return the RX descriptor and status entries
+		 * back to the MAC engine, and loop again, checking for
+		 * more descriptors to process.
+		 */
+		writel(1, &regs->rxdqenq);
+		writel(1, &regs->rxstsqenq);
+	} else {
+		ret = ETH_STATUS_SUCCESS;
+	}
+
+	pr_debug("-ep93xx_eth_rcv_packet %d\n", ret);
+
+	return ret;
+}
+
+/**
+ * Send a block of data via ethernet.
+ *
+ * TODO: Enhance this to deal with as much data as are available at one time? */
+static int ep93xx_eth_send_packet(struct eth_device *edev,
+				void *packet, int length)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int ret = ETH_STATUS_FAILURE;
+
+	pr_debug("+ep93xx_eth_send_packet\n");
+
+	/*
+	 * Initialize the TX descriptor queue with the new packet's info.
+	 * Clear the associated status queue entry. Enqueue the packet
+	 * to the MAC for transmission.
+	 */
+
+	/* set buffer address */
+	priv->tx_dq.current->word1 = (uint32_t)packet;
+
+	/* set buffer length and EOF bit */
+	priv->tx_dq.current->word2 = length | TX_DESC_EOF;
+
+	/* clear tx status */
+	priv->tx_sq.current->word1 = 0;
+
+	/* enqueue the TX descriptor */
+	writel(1, &regs->txdqenq);
+
+	/* wait for the frame to become processed */
+	while (!TX_STATUS_TXFP(priv->tx_sq.current))
+		; /* noop */
+
+	if (!TX_STATUS_TXWE(priv->tx_sq.current)) {
+		pr_err("packet tx error, status %08X\n",
+			priv->tx_sq.current->word1);
+		dump_tx_descriptor_queue();
+		dump_tx_status_queue();
+
+		/* TODO: Add better error handling? */
+		goto eth_send_failed_0;
+	}
+
+	ret = ETH_STATUS_SUCCESS;
+	/* Fall through */
+
+eth_send_failed_0:
+	pr_debug("-ep93xx_eth_send_packet %d\n", ret);
+	return ret;
+}
+
+/* -----------------------------------------------------------------------------
+ * EP93xx ethernet MII functionality.
+ */
+
+/**
+ * Maximum MII address we support
+ */
+#define MII_ADDRESS_MAX			(31)
+
+/**
+ * Maximum MII register address we support
+ */
+#define MII_REGISTER_MAX		(31)
+
+/**
+ * Ethernet MII interface return values for public functions.
+ */
+enum mii_status {
+	MII_STATUS_SUCCESS = 0,
+	MII_STATUS_FAILURE = 1,
+};
+
+/**
+ * Read a 16-bit value from an MII register.
+ */
+static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t *value)
+{
+	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	int ret = MII_STATUS_FAILURE;
+	uint32_t self_ctl;
+
+	pr_debug("+ep93xx_phy_read\n");
+
+	/*
+	 * Save the current SelfCTL register value.  Set MAC to suppress
+	 * preamble bits.  Wait for any previous MII command to complete
+	 * before issuing the new command.
+	 */
+	self_ctl = readl(&regs->selfctl);
+#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */
+	writel(self_ctl & ~(1 << 8), &regs->selfctl);
+#endif	/* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */
+
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/*
+	 * Issue the MII 'read' command.  Wait for the command to complete.
+	 * Read the MII data value.
+	 */
+	writel(MIICMD_OPCODE_READ | ((uint32_t)phy_addr << 5) |
+		(uint32_t)phy_reg, &regs->miicmd);
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	*value = (unsigned short)readl(&regs->miidata);
+
+	/* Restore the saved SelfCTL value and return. */
+	writel(self_ctl, &regs->selfctl);
+
+	ret = MII_STATUS_SUCCESS;
+	/* Fall through */
+
+	pr_debug("-ep93xx_phy_read\n");
+	return ret;
+}
+
+/**
+ * Write a 16-bit value to an MII register.
+ */
+static int ep93xx_phy_write(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t value)
+{
+	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	int ret = MII_STATUS_FAILURE;
+	uint32_t self_ctl;
+
+	pr_debug("+ep93xx_phy_write\n");
+
+	/*
+	 * Save the current SelfCTL register value.  Set MAC to suppress
+	 * preamble bits.  Wait for any previous MII command to complete
+	 * before issuing the new command.
+	 */
+	self_ctl = readl(&regs->selfctl);
+#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */
+	writel(self_ctl & ~(1 << 8), &regs->selfctl);
+#endif	/* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */
+
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/* Issue the MII 'write' command.  Wait for the command to complete. */
+	writel((uint32_t)value, &regs->miidata);
+	writel(MIICMD_OPCODE_WRITE | ((uint32_t)phy_addr << 5) | phy_reg,
+		&regs->miicmd);
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/* Restore the saved SelfCTL value and return. */
+	writel(self_ctl, &regs->selfctl);
+
+	ret = MII_STATUS_SUCCESS;
+	/* Fall through */
+
+	pr_debug("-ep93xx_phy_write\n");
+	return ret;
+}
+
+static struct driver_d ep93xx_eth_driver = {
+	.name  = "ep93xx_eth",
+	.probe = ep93xx_eth_probe,
+};
+
+static int ep93xx_eth_init(void)
+{
+	register_driver(&ep93xx_eth_driver);
+	return 0;
+}
+
+device_initcall(ep93xx_eth_init);
diff --git a/drivers/net/ep93xx.h b/drivers/net/ep93xx.h
new file mode 100644
index 0000000..827e28a
--- /dev/null
+++ b/drivers/net/ep93xx.h
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.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
+ *
+ */
+
+#ifndef _ETH_H
+#define _ETH_H
+
+#include <net.h>
+
+/**
+ * #define this to dump device status and queue info during initialization and
+ * following errors.
+ */
+#undef EP93XX_MAC_DEBUG
+
+/**
+ * Number of descriptor and status entries in our RX queues.
+ * It must be power of 2 !
+ */
+#define NUMRXDESC		PKTBUFSRX
+
+/**
+ * Number of descriptor and status entries in our TX queues.
+ */
+#define NUMTXDESC		1
+
+/**
+ * 944 = (1024 - 64) - 16, Fifo size - Minframesize - 16 (Chip FACT)
+ */
+#define TXSTARTMAX		944
+
+/**
+ * Ethernet MAC interface return values for public functions.
+ */
+enum eth_status {
+	ETH_STATUS_SUCCESS = 0,
+	ETH_STATUS_FAILURE = 1,
+};
+
+/**
+ * Receive descriptor queue entry
+ */
+struct rx_descriptor {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+/**
+ * Receive status queue entry
+ */
+struct rx_status {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+#define RX_STATUS_RWE(rx_status) ((rx_status->word1 >> 30) & 0x01)
+#define RX_STATUS_RFP(rx_status) ((rx_status->word1 >> 31) & 0x01)
+#define RX_STATUS_FRAME_LEN(rx_status) (rx_status->word2 & 0xFFFF)
+
+
+/**
+ * Transmit descriptor queue entry
+ */
+struct tx_descriptor {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+#define TX_DESC_EOF (1 << 31)
+
+/**
+ * Transmit status queue entry
+ */
+struct tx_status {
+	uint32_t word1;
+} __attribute__((packed));
+
+#define TX_STATUS_TXWE(tx_status) (((tx_status)->word1 >> 30) & 0x01)
+#define TX_STATUS_TXFP(tx_status) (((tx_status)->word1 >> 31) & 0x01)
+
+/**
+ * Transmit descriptor queue
+ */
+struct tx_descriptor_queue {
+	struct tx_descriptor *base;
+	struct tx_descriptor *current;
+	struct tx_descriptor *end;
+};
+
+/**
+ * Transmit status queue
+ */
+struct tx_status_queue {
+	struct tx_status *base;
+	volatile struct tx_status *current;
+	struct tx_status *end;
+};
+
+/**
+ * Receive descriptor queue
+ */
+struct rx_descriptor_queue {
+	struct rx_descriptor *base;
+	struct rx_descriptor *current;
+	struct rx_descriptor *end;
+};
+
+/**
+ * Receive status queue
+ */
+struct rx_status_queue {
+	struct rx_status *base;
+	volatile struct rx_status *current;
+	struct rx_status *end;
+};
+
+/**
+ * EP93xx MAC private data structure
+ */
+struct ep93xx_eth_priv {
+	struct mac_regs			*regs;
+
+	struct rx_descriptor_queue	rx_dq;
+	struct rx_status_queue		rx_sq;
+	void				*rx_buffer[NUMRXDESC];
+
+	struct tx_descriptor_queue	tx_dq;
+	struct tx_status_queue		tx_sq;
+
+	struct miiphy_device miiphy;
+};
+
+#endif
diff --git a/include/common.h b/include/common.h
index 0c49d95..2b40954 100644
--- a/include/common.h
+++ b/include/common.h
@@ -31,6 +31,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/stddef.h>
 #include <asm/common.h>
 
 #define pr_info(fmt, arg...)	printf(fmt, ##arg)
-- 
1.6.3.1



From matthias at kaehlcke.net  Sat Jan  9 18:28:59 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Sun, 10 Jan 2010 00:28:59 +0100
Subject: [PATCH 3/5] Add support for EP9xx GPIOs
Message-ID: <20100109232859.GE14051@darwin>

Added generic GPIO support for EP93xx SoCs

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 arch/arm/Kconfig                         |    1 +
 arch/arm/mach-ep93xx/Makefile            |    2 +-
 arch/arm/mach-ep93xx/gpio.c              |  136 ++++++++++++++++++++++++++++++
 arch/arm/mach-ep93xx/include/mach/gpio.h |   29 +++++++
 4 files changed, 167 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/gpio.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/gpio.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 414a013..9cad224 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -34,6 +34,7 @@ config ARCH_AT91RM9200
 config ARCH_EP93XX
 	bool "Cirrus Logic EP93xx"
 	select CPU_ARM920T
+	select GENERIC_GPIO
 
 config ARCH_IMX
 	bool "Freescale iMX-based"
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
index d5786db..dac6571 100644
--- a/arch/arm/mach-ep93xx/Makefile
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -1,3 +1,3 @@
-obj-y += clocksource.o led.o
+obj-y += clocksource.o gpio.o led.o
 
 obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o
diff --git a/arch/arm/mach-ep93xx/gpio.c b/arch/arm/mach-ep93xx/gpio.c
new file mode 100644
index 0000000..5d57434
--- /dev/null
+++ b/arch/arm/mach-ep93xx/gpio.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <errno.h>
+#include <init.h>
+#include <asm/io.h>
+#include <mach/ep93xx-regs.h>
+
+#define EP93XX_GPIO_NUM_PORTS	8
+#define EP93XX_GPIO_NUM_GPIOS	(EP93XX_GPIO_NUM_PORTS * 8)
+
+struct gpio_port {
+	uint32_t *dr;
+	uint32_t *ddr;
+};
+
+struct gpio_port gpio_ports[EP93XX_GPIO_NUM_PORTS];
+
+static int ep93xx_gpio_init(void)
+{
+	struct gpio_regs *gpio_regs = (struct gpio_regs *)GPIO_BASE;
+
+	gpio_ports[0].dr = &gpio_regs->padr;
+	gpio_ports[0].ddr = &gpio_regs->paddr;
+	gpio_ports[1].dr = &gpio_regs->pbdr;
+	gpio_ports[1].ddr = &gpio_regs->pbddr;
+	gpio_ports[2].dr = &gpio_regs->pcdr;
+	gpio_ports[2].ddr = &gpio_regs->pcddr;
+	gpio_ports[3].dr = &gpio_regs->pddr;
+	gpio_ports[3].ddr = &gpio_regs->pdddr;
+	gpio_ports[4].dr = &gpio_regs->pedr;
+	gpio_ports[4].ddr = &gpio_regs->peddr;
+	gpio_ports[5].dr = &gpio_regs->pfdr;
+	gpio_ports[5].ddr = &gpio_regs->pfddr;
+	gpio_ports[6].dr = &gpio_regs->pgdr;
+	gpio_ports[6].ddr = &gpio_regs->pgddr;
+	gpio_ports[7].dr = &gpio_regs->phdr;
+	gpio_ports[7].ddr = &gpio_regs->phddr;
+
+	return 0;
+}
+
+postcore_initcall(ep93xx_gpio_init);
+
+static struct gpio_port *gpio_get_port(unsigned gpio)
+{
+	if (gpio >= EP93XX_GPIO_NUM_GPIOS)
+		return 0;
+
+	return &gpio_ports[gpio / 8];
+}
+
+void gpio_set_value(unsigned gpio, int value)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return;
+
+	val = readl(port->dr);
+
+	if (value)
+		val |= 1 << shift;
+	else
+		val &= ~(1 << shift);
+
+	writel(val, port->dr);
+}
+
+int gpio_direction_input(unsigned gpio)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return -EINVAL;
+
+	val = readl(port->ddr);
+	val &= ~(1 << shift);
+	writel(val, port->ddr);
+
+	return 0;
+}
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return -EINVAL;
+
+	gpio_set_value(gpio, value);
+
+	val = readl(port->ddr);
+	val |= 1 << shift;
+	writel(val, port->ddr);
+
+	return 0;
+}
+
+int gpio_get_value(unsigned gpio)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return -EINVAL;
+
+	val = readl(port->dr);
+
+	return val & (1 << shift) ? 1 : 0;
+}
+
diff --git a/arch/arm/mach-ep93xx/include/mach/gpio.h b/arch/arm/mach-ep93xx/include/mach/gpio.h
new file mode 100644
index 0000000..a305f27
--- /dev/null
+++ b/arch/arm/mach-ep93xx/include/mach/gpio.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 __ASM_ARCH_GPIO_H
+#define __ASM_ARCH_GPIO_H
+
+void gpio_set_value(unsigned gpio, int value);
+int gpio_get_value(unsigned gpio);
+int gpio_direction_output(unsigned gpio, int value);
+int gpio_direction_input(unsigned gpio);
+
+#endif /* __ASM_ARCH_GPIO_H */
+
-- 
1.6.3.1



From matthias at kaehlcke.net  Sat Jan  9 18:29:07 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Sun, 10 Jan 2010 00:29:07 +0100
Subject: [PATCH 4/5] Add PrimeCell PL010 serial driver
Message-ID: <20100109232907.GF14051@darwin>

Added driver for ARM PrimeCell PL010 UART

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 drivers/serial/Kconfig        |    7 ++
 drivers/serial/Makefile       |    2 +-
 drivers/serial/serial_pl010.c |  172 +++++++++++++++++++++++++++++++++++++++++
 drivers/serial/serial_pl010.h |  100 ++++++++++++++++++++++++
 4 files changed, 280 insertions(+), 1 deletions(-)
 create mode 100644 drivers/serial/serial_pl010.c
 create mode 100644 drivers/serial/serial_pl010.h

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b0ff5fa..8a5056b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -47,6 +47,13 @@ config DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
 	help
 	  Say Y here if you are using OMAP extensions to NS16550
 
+config DRIVER_SERIAL_PL010
+	depends on ARCH_EP93XX
+	default y
+	bool "ARM AMBA PL010 support"
+	help
+	  Enable this to get support for AMBA PL010 based serial devices
+
 config DRIVER_SERIAL_S3C24X0
 	bool "Samsung S3C24X0 serial driver"
 	depends on ARCH_S3C24xx
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 8ab680d..9f203bb 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -3,7 +3,6 @@
 # s3c4510b_uart.o
 # serial_max3100.o
 # serial_pl010.o
-# serial_pl011.o
 # serial_xuartlite.o
 obj-$(CONFIG_DRIVER_SERIAL_ARM_DCC)		+= arm_dcc.o
 obj-$(CONFIG_DRIVER_SERIAL_IMX)			+= serial_imx.o
@@ -13,4 +12,5 @@ obj-$(CONFIG_DRIVER_SERIAL_LINUX_COMSOLE)	+= linux_console.o
 obj-$(CONFIG_DRIVER_SERIAL_MPC5XXX)		+= serial_mpc5xxx.o
 obj-$(CONFIG_DRIVER_SERIAL_BLACKFIN)		+= serial_blackfin.o
 obj-$(CONFIG_DRIVER_SERIAL_NS16550)		+= serial_ns16550.o
+obj-$(CONFIG_DRIVER_SERIAL_PL010)		+= serial_pl010.o
 obj-$(CONFIG_DRIVER_SERIAL_S3C24X0)		+= serial_s3c24x0.o
diff --git a/drivers/serial/serial_pl010.c b/drivers/serial/serial_pl010.c
new file mode 100644
index 0000000..1a6366f
--- /dev/null
+++ b/drivers/serial/serial_pl010.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * (C) Copyright 2000
+ * Rob Taylor, Flying Pig Systems. robt at flyingpig.com.
+ *
+ * (C) Copyright 2004
+ * ARM Ltd.
+ * Philippe Robin, <philippe.robin at arm.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
+ */
+
+/* Simple U-Boot driver for the PrimeCell PL010/PL011 UARTs */
+
+#include <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include "serial_pl010.h"
+
+static int pl010_setbaudrate(struct console_device *cdev, int baudrate)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	unsigned int divisor;
+
+	switch (baudrate) {
+	case 9600:
+		divisor = UART_PL010_BAUD_9600;
+		break;
+
+	case 19200:
+		divisor = UART_PL010_BAUD_9600;
+		break;
+
+	case 38400:
+		divisor = UART_PL010_BAUD_38400;
+		break;
+
+	case 57600:
+		divisor = UART_PL010_BAUD_57600;
+		break;
+
+	case 115200:
+		divisor = UART_PL010_BAUD_115200;
+		break;
+
+	default:
+		divisor = UART_PL010_BAUD_38400;
+	}
+
+	writel((divisor & 0xf00) >> 8, &pl010->linctrlmid);
+	writel(divisor & 0xff, &pl010->linctrllow);
+
+	/* high register must always be written */
+	writel(readl(&pl010->linctrlhigh), &pl010->linctrlhigh);
+
+	return 0;
+}
+
+static int pl010_init_port(struct console_device *cdev)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+
+	/*
+	 * First, disable everything.
+	 */
+	writel(0x00, &pl010->ctrl);
+
+	/*
+	 * Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled.
+	 */
+	writel(UART_PL010_LCRH_WLEN_8 | UART_PL010_LCRH_FEN,
+		&pl010->linctrlhigh);
+
+	/*
+	 * Finally, enable the UART
+	 */
+	writel(UART_PL010_CR_UARTEN, &pl010->ctrl);
+
+	return 0;
+}
+
+static void pl010_putc(struct console_device *cdev, char c)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+
+	/* Wait until there is space in the FIFO */
+	while (readl(&pl010->flag) & UART_PL010_FR_TXFF)
+		; /* noop */
+
+	/* Send the character */
+	writel(c, &pl010->data);
+}
+
+static int pl010_getc(struct console_device *cdev)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	unsigned int data;
+
+	/* Wait until there is data in the FIFO */
+	while (readl(&pl010->flag) & UART_PL010_FR_RXFE)
+		; /* noop */
+
+	data = readl(&pl010->data);
+
+	/* Check for an error flag */
+	if (data & 0xFFFFFF00) {
+		/* Clear the error */
+		writel(0xFFFFFFFF, &pl010->errclr);
+		return -1;
+	}
+
+	return (int)data;
+}
+
+static int pl010_tstc(struct console_device *cdev)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+
+	return !(readl(&pl010->flag) & UART_PL010_FR_RXFE);
+}
+
+static int pl010_probe(struct device_d *dev)
+{
+	struct console_device *cdev;
+
+	cdev = malloc(sizeof(struct console_device));
+	dev->type_data = cdev;
+	cdev->dev = dev;
+	cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+	cdev->tstc = pl010_tstc;
+	cdev->putc = pl010_putc;
+	cdev->getc = pl010_getc;
+	cdev->setbrg = pl010_setbaudrate;
+
+	pl010_init_port(cdev);
+
+	console_register(cdev);
+
+	return 0;
+}
+
+static struct driver_d pl010_driver = {
+	.name  = "pl010_serial",
+	.probe = pl010_probe,
+};
+
+static int pl010_init(void)
+{
+	register_driver(&pl010_driver);
+
+	return 0;
+}
+
+console_initcall(pl010_init);
diff --git a/drivers/serial/serial_pl010.h b/drivers/serial/serial_pl010.h
new file mode 100644
index 0000000..6124e0e
--- /dev/null
+++ b/drivers/serial/serial_pl010.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * (C) Copyright 2003, 2004
+ * ARM Ltd.
+ * Philippe Robin, <philippe.robin at arm.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
+ */
+
+struct hldc_struct {
+	uint32_t ctrl;
+	uint32_t addmtchval;
+	uint32_t addmask;
+	uint32_t rxinfobuf;
+	uint32_t sts;
+};
+
+struct pl010_struct {
+	uint32_t data;
+	union {
+		uint32_t rxsts;
+		uint32_t errclr;
+	};
+	uint32_t linctrlhigh;
+	uint32_t linctrlmid;
+	uint32_t linctrllow;
+	uint32_t ctrl;
+	uint32_t flag;
+	union {
+		uint32_t intid;
+		uint32_t intclr;
+	};
+	uint32_t not_used0[2];
+	uint32_t dmactrl;
+	uint32_t not_used1[53];
+	uint32_t modemctrl;
+	uint32_t modemsts;
+	uint32_t not_used2[65];
+	struct hldc_struct hldc;
+};
+
+#define UART_PL010_RSR_OE	(1 << 3)
+#define UART_PL010_RSR_BE	(1 << 2)
+#define UART_PL010_RSR_PE	(1 << 1)
+#define UART_PL010_RSR_FE	(1 << 0)
+
+#define UART_PL010_FR_TXFE	(1 << 7)
+#define UART_PL010_FR_RXFF	(1 << 6)
+#define UART_PL010_FR_TXFF	(1 << 5)
+#define UART_PL010_FR_RXFE	(1 << 4)
+#define UART_PL010_FR_BUSY	(1 << 3)
+#define UART_PL010_FR_TMSK	(UART_PL010_FR_TXFF + UART_PL010_FR_BUSY)
+
+#define UART_PL010_CR_LPE	(1 << 7)
+#define UART_PL010_CR_RTIE	(1 << 6)
+#define UART_PL010_CR_TIE	(1 << 5)
+#define UART_PL010_CR_RIE	(1 << 4)
+#define UART_PL010_CR_MSIE	(1 << 3)
+#define UART_PL010_CR_IIRLP	(1 << 2)
+#define UART_PL010_CR_SIREN	(1 << 1)
+#define UART_PL010_CR_UARTEN	(1 << 0)
+
+#define UART_PL010_LCRH_WLEN_8	(3 << 5)
+#define UART_PL010_LCRH_WLEN_7	(2 << 5)
+#define UART_PL010_LCRH_WLEN_6	(1 << 5)
+#define UART_PL010_LCRH_WLEN_5	(0 << 5)
+#define UART_PL010_LCRH_FEN	(1 << 4)
+#define UART_PL010_LCRH_STP2	(1 << 3)
+#define UART_PL010_LCRH_EPS	(1 << 2)
+#define UART_PL010_LCRH_PEN	(1 << 1)
+#define UART_PL010_LCRH_BRK	(1 << 0)
+
+#define UART_PL010_BAUD_460800	1
+#define UART_PL010_BAUD_230400	3
+#define UART_PL010_BAUD_115200	7
+#define UART_PL010_BAUD_57600	15
+#define UART_PL010_BAUD_38400	23
+#define UART_PL010_BAUD_19200	47
+#define UART_PL010_BAUD_14400	63
+#define UART_PL010_BAUD_9600	95
+#define UART_PL010_BAUD_4800	191
+#define UART_PL010_BAUD_2400	383
+#define UART_PL010_BAUD_1200	767
-- 
1.6.3.1



From matthias at kaehlcke.net  Sat Jan  9 18:29:14 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Sun, 10 Jan 2010 00:29:14 +0100
Subject: [PATCH 5/5] Add support for EDB93xx boards
Message-ID: <20100109232914.GG14051@darwin>

Added support for the following Cirrus Logic EDB93xx boards:

EDB9301
EDB9302
EDB9302A
EDB9307
EDB9307A
EDB93012
EDB9315
EDB9315A

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 Documentation/boards.dox              |    8 +
 MAINTAINERS                           |   11 ++
 arch/arm/configs/edb93xx_defconfig    |  237 +++++++++++++++++++++++++++++++++
 board/edb93xx/Makefile                |    4 +
 board/edb93xx/barebox.lds.S           |   79 +++++++++++
 board/edb93xx/config.h                |    4 +
 board/edb93xx/early_udelay.h          |   34 +++++
 board/edb93xx/edb93xx.c               |  172 ++++++++++++++++++++++++
 board/edb93xx/edb93xx.dox             |  108 +++++++++++++++
 board/edb93xx/edb93xx.h               |   48 +++++++
 board/edb93xx/env/bin/boot            |   48 +++++++
 board/edb93xx/env/bin/flash_partition |   22 +++
 board/edb93xx/env/bin/init            |   19 +++
 board/edb93xx/env/bin/set_nor_parts   |    3 +
 board/edb93xx/env/bin/update_kernel   |   16 +++
 board/edb93xx/env/bin/update_rootfs   |   16 +++
 board/edb93xx/env/config              |   16 +++
 board/edb93xx/flash_cfg.c             |   38 ++++++
 board/edb93xx/pll_cfg.c               |   58 ++++++++
 board/edb93xx/pll_cfg.h               |   72 ++++++++++
 board/edb93xx/sdram_cfg.c             |  127 ++++++++++++++++++
 board/edb93xx/sdram_cfg.h             |  144 ++++++++++++++++++++
 22 files changed, 1284 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/configs/edb93xx_defconfig
 create mode 100644 board/edb93xx/Makefile
 create mode 100644 board/edb93xx/barebox.lds.S
 create mode 100644 board/edb93xx/config.h
 create mode 100644 board/edb93xx/early_udelay.h
 create mode 100644 board/edb93xx/edb93xx.c
 create mode 100644 board/edb93xx/edb93xx.dox
 create mode 100644 board/edb93xx/edb93xx.h
 create mode 100644 board/edb93xx/env/bin/boot
 create mode 100644 board/edb93xx/env/bin/flash_partition
 create mode 100644 board/edb93xx/env/bin/init
 create mode 100644 board/edb93xx/env/bin/set_nor_parts
 create mode 100644 board/edb93xx/env/bin/update_kernel
 create mode 100644 board/edb93xx/env/bin/update_rootfs
 create mode 100644 board/edb93xx/env/config
 create mode 100644 board/edb93xx/flash_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.h
 create mode 100644 board/edb93xx/sdram_cfg.c
 create mode 100644 board/edb93xx/sdram_cfg.h

diff --git a/Documentation/boards.dox b/Documentation/boards.dox
index dba547f..7c7f4d1 100644
--- a/Documentation/boards.dox
+++ b/Documentation/boards.dox
@@ -20,6 +20,14 @@ ARM type:
 @li @subpage a9m2440
 @li @subpage a9m2410
 @li @subpage eukrea_cpuimx27
+ at li @subpage edb9301
+ at li @subpage edb9302
+ at li @subpage edb9302a
+ at li @subpage edb9307
+ at li @subpage edb9307a
+ at li @subpage edb9312
+ at li @subpage edb9315
+ at li @subpage edb9315a
 
 Blackfin type:
 
diff --git a/MAINTAINERS b/MAINTAINERS
index 6f56ebe..d3d33fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -439,6 +439,17 @@ Gary Jennejohn <gj at denx.de>
 	smdk2400		ARM920T
 	trab			ARM920T
 
+Matthias Kaehlcke <matthias at kaehlcke.net>
+
+	edb9301			ARM920T (EP9301)
+	edb9302			ARM920T (EP9302)
+	edb9302a		ARM920T (EP9302)
+	edb9307			ARM920T (EP9307)
+	edb9307a		ARM920T (EP9307)
+	edb9312			ARM920T (EP9312)
+	edb9315			ARM920T (EP9315)
+	edb9315a		ARM920T (EP9315)
+
 Nishant Kamat <nskamat at ti.com>
 
 	omap1610h2		ARM926EJS
diff --git a/arch/arm/configs/edb93xx_defconfig b/arch/arm/configs/edb93xx_defconfig
new file mode 100644
index 0000000..ddaf53c
--- /dev/null
+++ b/arch/arm/configs/edb93xx_defconfig
@@ -0,0 +1,237 @@
+#
+# Automatically generated make config: don't edit
+# barebox version: 2009.12.0
+# Fri Jan  8 17:27:15 2010
+#
+CONFIG_BOARD_LINKER_SCRIPT=y
+CONFIG_ARM=y
+
+#
+# System Type
+#
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_AT91RM9200 is not set
+CONFIG_ARCH_EP93XX=y
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_S3C24xx is not set
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_ARM920T=y
+CONFIG_CPU_32v4T=y
+
+#
+# processor features
+#
+CONFIG_ARCH_TEXT_BASE=0x05700000
+CONFIG_BOARDINFO="Cirrus Logic EDB9301"
+CONFIG_EP93XX_SDCE3_SYNC_PHYS_OFFSET=y
+
+#
+# Cirrus EP93xx System-on-Chip
+#
+CONFIG_ARCH_EP9301=y
+# CONFIG_ARCH_EP9302 is not set
+# CONFIG_ARCH_EP9307 is not set
+# CONFIG_ARCH_EP9312 is not set
+# CONFIG_ARCH_EP9315 is not set
+CONFIG_MACH_EDB9301=y
+CONFIG_EP93XX_SDRAM_NUM_BANKS=4
+CONFIG_EP93XX_SDRAM_BANK0_BASE=0x00000000
+CONFIG_EP93XX_SDRAM_BANK0_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK1_BASE=0x01000000
+CONFIG_EP93XX_SDRAM_BANK1_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK2_BASE=0x04000000
+CONFIG_EP93XX_SDRAM_BANK2_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK3_BASE=0x05000000
+CONFIG_EP93XX_SDRAM_BANK3_SIZE=0x00800000
+CONFIG_AEABI=y
+
+#
+# Arm specific settings         
+#
+CONFIG_CMD_ARM_CPUINFO=y
+CONFIG_CMDLINE_TAG=y
+CONFIG_SETUP_MEMORY_TAGS=y
+# CONFIG_INITRD_TAG is not set
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_GREGORIAN_CALENDER=y
+CONFIG_HAS_KALLSYMS=y
+CONFIG_HAS_MODULES=y
+CONFIG_CMD_MEMORY=y
+CONFIG_ENV_HANDLING=y
+CONFIG_GENERIC_GPIO=y
+
+#
+# General Settings              
+#
+CONFIG_LOCALVERSION_AUTO=y
+
+#
+# memory layout                 
+#
+CONFIG_HAVE_CONFIGURABLE_TEXT_BASE=y
+CONFIG_TEXT_BASE=0x05700000
+CONFIG_HAVE_CONFIGURABLE_MEMORY_LAYOUT=y
+CONFIG_MEMORY_LAYOUT_DEFAULT=y
+# CONFIG_MEMORY_LAYOUT_FIXED is not set
+CONFIG_STACK_SIZE=0x8000
+CONFIG_MALLOC_SIZE=0x400000
+# CONFIG_BROKEN is not set
+# CONFIG_EXPERIMENTAL is not set
+CONFIG_MACH_HAS_LOWLEVEL_INIT=y
+CONFIG_MACH_DO_LOWLEVEL_INIT=y
+CONFIG_PROMPT="barebox:"
+CONFIG_BAUDRATE=115200
+CONFIG_LONGHELP=y
+CONFIG_CBSIZE=1024
+CONFIG_MAXARGS=16
+CONFIG_SHELL_HUSH=y
+# CONFIG_SHELL_SIMPLE is not set
+CONFIG_GLOB=y
+CONFIG_PROMPT_HUSH_PS2="> "
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DYNAMIC_CRC_TABLE=y
+CONFIG_ERRNO_MESSAGES=y
+CONFIG_TIMESTAMP=y
+CONFIG_CONSOLE_FULL=y
+CONFIG_CONSOLE_ACTIVATE_FIRST=y
+# CONFIG_OF_FLAT_TREE is not set
+CONFIG_PARTITION=y
+CONFIG_DEFAULT_ENVIRONMENT=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="board/edb93xx/env"
+
+#
+# Debugging                     
+#
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_ENABLE_FLASH_NOISE is not set
+# CONFIG_ENABLE_PARTITION_NOISE is not set
+# CONFIG_ENABLE_DEVICE_NOISE is not set
+
+#
+# Commands                      
+#
+
+#
+# scripting                     
+#
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_LOADENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TRUE=y
+CONFIG_CMD_FALSE=y
+
+#
+# file commands                 
+#
+CONFIG_CMD_LS=y
+CONFIG_CMD_RM=y
+CONFIG_CMD_CAT=y
+CONFIG_CMD_MKDIR=y
+CONFIG_CMD_RMDIR=y
+CONFIG_CMD_CP=y
+CONFIG_CMD_PWD=y
+CONFIG_CMD_CD=y
+CONFIG_CMD_MOUNT=y
+CONFIG_CMD_UMOUNT=y
+
+#
+# console                       
+#
+CONFIG_CMD_CLEAR=y
+CONFIG_CMD_ECHO=y
+
+#
+# memory                        
+#
+# CONFIG_CMD_LOADB is not set
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_MTEST=y
+# CONFIG_CMD_MTEST_ALTERNATIVE is not set
+
+#
+# flash                         
+#
+CONFIG_CMD_FLASH=y
+
+#
+# booting                       
+#
+CONFIG_CMD_BOOTM=y
+# CONFIG_CMD_BOOTM_ZLIB is not set
+# CONFIG_CMD_BOOTM_BZLIB is not set
+# CONFIG_CMD_BOOTM_SHOW_TYPE is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTU=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_TEST=y
+CONFIG_CMD_VERSION=y
+CONFIG_CMD_HELP=y
+CONFIG_CMD_DEVINFO=y
+CONFIG_CMD_GPIO=y
+CONFIG_NET=y
+CONFIG_NET_DHCP=y
+# CONFIG_NET_RARP is not set
+# CONFIG_NET_NFS is not set
+CONFIG_NET_PING=y
+CONFIG_NET_TFTP=y
+
+#
+# Drivers                       
+#
+
+#
+# serial drivers                
+#
+# CONFIG_DRIVER_SERIAL_ARM_DCC is not set
+# CONFIG_DRIVER_SERIAL_NS16550 is not set
+CONFIG_DRIVER_SERIAL_PL010=y
+CONFIG_MIIPHY=y
+
+#
+# Network drivers               
+#
+# CONFIG_DRIVER_NET_SMC911X is not set
+# CONFIG_DRIVER_NET_SMC91111 is not set
+CONFIG_DRIVER_NET_EP93XX=y
+
+#
+# SPI drivers                   
+#
+# CONFIG_SPI is not set
+# CONFIG_I2C is not set
+
+#
+# flash drivers                 
+#
+CONFIG_DRIVER_CFI=y
+# CONFIG_DRIVER_CFI_NEW is not set
+CONFIG_DRIVER_CFI_OLD=y
+# CONFIG_CFI_BUFFER_WRITE is not set
+# CONFIG_NAND is not set
+# CONFIG_USB is not set
+# CONFIG_USB_GADGET is not set
+# CONFIG_VIDEO is not set
+
+#
+# Filesystem support            
+#
+# CONFIG_FS_CRAMFS is not set
+CONFIG_FS_RAMFS=y
+CONFIG_FS_DEVFS=y
+CONFIG_CRC32=y
+# CONFIG_GENERIC_FIND_NEXT_BIT is not set
diff --git a/board/edb93xx/Makefile b/board/edb93xx/Makefile
new file mode 100644
index 0000000..b8a5060
--- /dev/null
+++ b/board/edb93xx/Makefile
@@ -0,0 +1,4 @@
+
+obj-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o
+
+extra-y += barebox.lds
\ No newline at end of file
diff --git a/board/edb93xx/barebox.lds.S b/board/edb93xx/barebox.lds.S
new file mode 100644
index 0000000..259882b
--- /dev/null
+++ b/board/edb93xx/barebox.lds.S
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * (C) Copyright 2000-2004
+ * 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 <asm-generic/barebox.lds.h>
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	. = TEXT_BASE;
+
+	PRE_IMAGE
+
+	. = ALIGN(4);
+	.text      :
+	{
+		_stext = .;
+		_text = .;
+		*(.text_entry*)
+		/* the EP93xx expects to find the pattern 'CRUS' at 0x1000 */
+	  . = 0x1000;
+	  LONG(0x53555243) /* 'CRUS' */
+		*(.text_bare_init*)
+		*(.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/board/edb93xx/config.h b/board/edb93xx/config.h
new file mode 100644
index 0000000..6ae9a40
--- /dev/null
+++ b/board/edb93xx/config.h
@@ -0,0 +1,4 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#endif  /* __CONFIG_H */
diff --git a/board/edb93xx/early_udelay.h b/board/edb93xx/early_udelay.h
new file mode 100644
index 0000000..3b26b3f
--- /dev/null
+++ b/board/edb93xx/early_udelay.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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>
+
+/* delay execution before timers are initialized */
+static inline void early_udelay(uint32_t usecs)
+{
+	/* loop takes 4 cycles at 5.0ns (fastest case, running at 200MHz) */
+	register uint32_t loops = (usecs * 1000) / 20;
+
+	__asm__ volatile ("1:\n"
+			"subs %0, %1, #1\n"
+			"bne 1b":"=r" (loops):"0" (loops));
+}
diff --git a/board/edb93xx/edb93xx.c b/board/edb93xx/edb93xx.c
new file mode 100644
index 0000000..add88e1
--- /dev/null
+++ b/board/edb93xx/edb93xx.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <driver.h>
+#include <environment.h>
+#include <fs.h>
+#include <init.h>
+#include <partition.h>
+#include <asm/armlinux.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <mach/ep93xx-regs.h>
+#include "edb93xx.h"
+
+/*
+ * Up to 32MiB NOR type flash, connected to
+ * CS line 6, data width is 16 bit
+ */
+static struct device_d cfi_dev = {
+	.name     = "cfi_flash",
+	.map_base = 0x60000000,
+	.size     = EDB93XX_CFI_FLASH_SIZE,
+};
+
+static struct memory_platform_data ram_dev_pdata0 = {
+	.name = "ram0",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram0_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK0_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK0_SIZE,
+	.platform_data = &ram_dev_pdata0,
+};
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+static struct memory_platform_data ram_dev_pdata1 = {
+	.name = "ram1",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram1_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK1_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK1_SIZE,
+	.platform_data = &ram_dev_pdata1,
+};
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+static struct memory_platform_data ram_dev_pdata2 = {
+	.name = "ram2",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram2_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK2_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK2_SIZE,
+	.platform_data = &ram_dev_pdata2,
+};
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+static struct memory_platform_data ram_dev_pdata3 = {
+	.name = "ram3",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram3_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK3_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK3_SIZE,
+	.platform_data = &ram_dev_pdata3,
+};
+#endif
+
+static struct device_d eth_dev = {
+	.name     = "ep93xx_eth",
+};
+
+static int ep93xx_devices_init(void)
+{
+	register_device(&cfi_dev);
+
+	/*
+	 * Create partitions that should be
+	 * not touched by any regular user
+	 */
+	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
+	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
+
+	protect_file("/dev/env0", 1);
+
+	register_device(&sdram0_dev);
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	register_device(&sdram1_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	register_device(&sdram2_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	register_device(&sdram3_dev);
+#endif
+
+	armlinux_add_dram(&sdram0_dev);
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	armlinux_add_dram(&sdram1_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	armlinux_add_dram(&sdram2_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	armlinux_add_dram(&sdram3_dev);
+#endif
+
+	register_device(&eth_dev);
+
+	armlinux_set_bootparams((void *)CONFIG_EP93XX_SDRAM_BANK0_BASE + 0x100);
+
+	armlinux_set_architecture(MACH_TYPE);
+
+	return 0;
+}
+
+device_initcall(ep93xx_devices_init);
+
+static struct device_d edb93xx_serial_device = {
+	.name     = "pl010_serial",
+	.map_base = UART1_BASE,
+	.size     = 4096,
+};
+
+static int edb93xx_console_init(void)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+
+	/*
+	 * set UARTBAUD bit to drive UARTs with 14.7456MHz instead of
+	 * 14.7456/2 MHz
+	 */
+	uint32_t value = readl(&syscon->pwrcnt);
+	value |= SYSCON_PWRCNT_UART_BAUD;
+	writel(value, &syscon->pwrcnt);
+
+	register_device(&edb93xx_serial_device);
+
+	return 0;
+}
+
+console_initcall(edb93xx_console_init);
diff --git a/board/edb93xx/edb93xx.dox b/board/edb93xx/edb93xx.dox
new file mode 100644
index 0000000..3964d55
--- /dev/null
+++ b/board/edb93xx/edb93xx.dox
@@ -0,0 +1,108 @@
+/** @page edb9301 Cirrus Logic EDB9301
+
+This boards is based on a Cirrus Logic EP9301 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS3
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9302 Cirrus Logic EDB9302
+
+This board is based on a Cirrus Logic EP9302 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS3
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9302a Cirrus Logic EDB9302A
+
+This board is based on a Cirrus Logic EP9302 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS0
+- 512kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9307 Cirrus Logic EDB9307
+
+This board is based on a Cirrus Logic EP9307 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9307a Cirrus Logic EDB9307A
+
+This board is based on a Cirrus Logic EP9307 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS0
+- 512kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9312 Cirrus Logic EDB9312
+
+This board is based on a Cirrus Logic EP9312 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9315 Cirrus Logic EDB9315
+
+This board is based on a Cirrus Logic EP9315 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9315a Cirrus Logic EDB9315A
+
+This board is based on a Cirrus Logic EP9315 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS0
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
\ No newline at end of file
diff --git a/board/edb93xx/edb93xx.h b/board/edb93xx/edb93xx.h
new file mode 100644
index 0000000..5e5c6f5
--- /dev/null
+++ b/board/edb93xx/edb93xx.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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
+ */
+
+#if defined(CONFIG_MACH_EDB9301)
+#define MACH_TYPE MACH_TYPE_EDB9301
+#elif defined(CONFIG_MACH_EDB9302)
+#define MACH_TYPE MACH_TYPE_EDB9302
+#elif defined(CONFIG_MACH_EDB9302A)
+#define MACH_TYPE MACH_TYPE_EDB9302A
+#elif defined(CONFIG_MACH_EDB9307)
+#define MACH_TYPE MACH_TYPE_EDB9307
+#elif defined(CONFIG_MACH_EDB9307A)
+#define MACH_TYPE MACH_TYPE_EDB9307A
+#elif defined(CONFIG_MACH_EDB9312)
+#define MACH_TYPE MACH_TYPE_EDB9312
+#elif defined(CONFIG_MACH_EDB9315)
+#define MACH_TYPE MACH_TYPE_EDB9315
+#elif defined(CONFIG_MACH_EDB9315A)
+#define MACH_TYPE MACH_TYPE_EDB9315A
+#endif
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) || \
+	defined(CONFIG_MACH_EDB9302A)
+#define EDB93XX_CFI_FLASH_SIZE (16 * 1024 * 1024)
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) || \
+	defined(CONFIG_MACH_EDB9312) || defined(CONFIG_MACH_EDB9315) ||	\
+	defined(CONFIG_MACH_EDB9315A)
+#define EDB93XX_CFI_FLASH_SIZE (32 * 1024 * 1024)
+#endif
diff --git a/board/edb93xx/env/bin/boot b/board/edb93xx/env/bin/boot
new file mode 100644
index 0000000..143f3d0
--- /dev/null
+++ b/board/edb93xx/env/bin/boot
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+. /env/config
+
+if [ x${rootfs_boot_media} = xflash ];
+then
+		rootfs_img=/dev/nor0.rootfs_${active_cfg}
+
+		if [ x${active_cfg} = x1 ];
+		then
+				rootfs_blkdev=/dev/mtdblock4
+				cfg_1_ro="ro"
+				cfg_2_ro=""
+		else
+				rootfs_blkdev=/dev/mtdblock6
+				cfg_1_ro=""
+				cfg_2_ro="ro"
+		fi
+
+		bootargs_rootfs="root=${rootfs_blkdev} rootfstype=squashfs ro"
+elif [ x${rootfs_boot_media} = xnet ];
+then
+		bootargs_rootfs="root=/dev/nfs nfsroot=${eth0.serverip}:/srv/nfs/${board},v3,nolock,tcp ip=${eth0.ipaddr}"
+else
+		echo "ERROR: \$rootfs_boot_media invalid: ${rootfs_boot_media}"
+		exit 1
+fi
+
+if [ x${kernel_boot_media} = xflash ];
+then
+		kernel_img=/dev/nor0.kernel_${active_cfg}
+elif [ x${kernel_boot_media} = xnet ];
+then
+		cd /
+		tftp ${board}/kernel.img || exit 1
+		kernel_img=/kernel.img
+else
+		echo "ERROR: \$kernel_boot_media invalid: ${kernel_boot_media}"
+		exit 1
+fi
+
+source /env/bin/set_nor_parts
+
+bootargs_mtd="mtdparts=physmap-flash.0:${nor_parts}"
+
+bootargs="${bootargs_common} ${bootargs_mtd} ${bootargs_rootfs}"
+
+bootm ${kernel_img}
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/flash_partition b/board/edb93xx/env/bin/flash_partition
new file mode 100644
index 0000000..ded40aa
--- /dev/null
+++ b/board/edb93xx/env/bin/flash_partition
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $# != 2 ];
+then
+				echo "Usage: $0 <image> <partition>"
+				exit 1
+fi
+
+image=$1
+partition=$2
+
+echo "Unlocking ${partition}"
+unprotect ${partition}
+
+echo "Erasing ${partition}"
+erase ${partition}
+
+echo "Flashing ${image} to ${partition}"
+cp ${image} ${partition}
+
+echo "Locking ${partition}"
+protect ${partition}
diff --git a/board/edb93xx/env/bin/init b/board/edb93xx/env/bin/init
new file mode 100644
index 0000000..c6b5aed
--- /dev/null
+++ b/board/edb93xx/env/bin/init
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+
+# add partitions to barebox
+. /env/bin/set_nor_parts
+addpart /dev/nor0 ${nor_parts}
+
+echo
+echo -n "Hit any key to stop autoboot: "
+timeout -a $autoboot_timeout
+if [ $? != 0 ]; then
+	exit
+fi
+
+boot
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/set_nor_parts b/board/edb93xx/env/bin/set_nor_parts
new file mode 100644
index 0000000..38321fa
--- /dev/null
+++ b/board/edb93xx/env/bin/set_nor_parts
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+nor_parts="256k(barebox)ro,128k(env_boot),128k(env_boot.bak),1664k(kernel_1)${cfg_1_ro},6144k(rootfs_1)${cfg_1_ro},1664k(kernel_2)${cfg_2_ro},6144k(rootfs_2)${cfg_2_ro},128k(cfg_app),128k(cfg_app.bak)"
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/update_kernel b/board/edb93xx/env/bin/update_kernel
new file mode 100644
index 0000000..3e4b9b0
--- /dev/null
+++ b/board/edb93xx/env/bin/update_kernel
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. /env/config
+
+if [ $# != 1 ];
+then
+				echo "Usage: $0 <1/2>"
+				exit 1
+fi
+
+partition=/dev/nor0.kernel_$1
+
+cd /
+tftp ${board}/kernel.img || exit 1
+
+flash_partition kernel.img ${partition}
diff --git a/board/edb93xx/env/bin/update_rootfs b/board/edb93xx/env/bin/update_rootfs
new file mode 100644
index 0000000..52a3699
--- /dev/null
+++ b/board/edb93xx/env/bin/update_rootfs
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. /env/config
+
+if [ $# != 1 ];
+then
+				echo "Usage: $0 <1/2>"
+				exit 1
+fi
+
+partition=/dev/nor0.rootfs_$1
+
+cd /
+tftp ${board}/rootfs.img || exit 1
+
+flash_partition rootfs.img ${partition}
diff --git a/board/edb93xx/env/config b/board/edb93xx/env/config
new file mode 100644
index 0000000..47ab209
--- /dev/null
+++ b/board/edb93xx/env/config
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+eth0.ipaddr=192.168.0.50
+eth0.netmask=255.255.0.0
+eth0.serverip=192.168.0.8
+eth0.ethaddr=80:81:82:83:84:85
+
+board=edb9301
+autoboot_timeout=3
+active_cfg=1
+bootargs_common="console=ttyAM0,115200"
+
+# valid media: flash/net
+kernel_boot_media=flash
+rootfs_boot_media=flash
+
diff --git a/board/edb93xx/flash_cfg.c b/board/edb93xx/flash_cfg.c
new file mode 100644
index 0000000..91a6a4e
--- /dev/null
+++ b/board/edb93xx/flash_cfg.c
@@ -0,0 +1,38 @@
+/*
+ * Flash setup for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <mach/ep93xx-regs.h>
+#include <asm/io.h>
+
+#define SMC_BCR6_VALUE	(2 << SMC_BCR_IDCY_SHIFT | 5 << SMC_BCR_WST1_SHIFT | \
+				SMC_BCR_BLE | 2 << SMC_BCR_WST2_SHIFT | \
+				1 << SMC_BCR_MW_SHIFT)
+
+void flash_cfg(void)
+{
+	struct smc_regs *smc = (struct smc_regs *)SMC_BASE;
+
+	writel(SMC_BCR6_VALUE, &smc->bcr6);
+}
diff --git a/board/edb93xx/pll_cfg.c b/board/edb93xx/pll_cfg.c
new file mode 100644
index 0000000..a687af0
--- /dev/null
+++ b/board/edb93xx/pll_cfg.c
@@ -0,0 +1,58 @@
+/*
+ * PLL setup for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <common.h>
+#include <asm/io.h>
+#include "pll_cfg.h"
+#include "early_udelay.h"
+
+void pll_cfg(void)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+
+	/* setup PLL1 */
+	writel(CLKSET1_VAL, &syscon->clkset1);
+
+	/*
+	 * flush the pipeline
+	 * writing to CLKSET1 causes the EP93xx to enter standby for between
+	 * 8 ms to 16 ms, until PLL1 stabilizes
+	 */
+	asm("nop");
+	asm("nop");
+	asm("nop");
+	asm("nop");
+	asm("nop");
+
+	/* setup PLL2 */
+	writel(CLKSET2_VAL, &syscon->clkset2);
+
+	/*
+	 * the user's guide recommends to wait at least 1 ms for PLL2 to
+	 * stabilize
+	 */
+	early_udelay(1000);
+}
diff --git a/board/edb93xx/pll_cfg.h b/board/edb93xx/pll_cfg.h
new file mode 100644
index 0000000..9691339
--- /dev/null
+++ b/board/edb93xx/pll_cfg.h
@@ -0,0 +1,72 @@
+/*
+ * PLL register values for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <mach/ep93xx-regs.h>
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) || \
+	defined(CONFIG_MACH_EDB9302A)
+/*
+ * fclk_div: 2, nbyp1: 1, hclk_div: 5, pclk_div: 2
+ * pll1_x1: 294912000.000000, pll1_x2ip: 36864000.000000,
+ * pll1_x2: 331776000.000000, pll1_out: 331776000.000000
+ */
+#define CLKSET1_VAL	(7 << SYSCON_CLKSET_PLL_X2IPD_SHIFT |      \
+			8 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT |	   \
+			19 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT |	   \
+			1 << SYSCON_CLKSET1_PCLK_DIV_SHIFT |	   \
+			3 << SYSCON_CLKSET1_HCLK_DIV_SHIFT |	   \
+			SYSCON_CLKSET1_NBYP1 |			   \
+			1 << SYSCON_CLKSET1_FCLK_DIV_SHIFT)
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) ||\
+	defined CONFIG_MACH_EDB9312 || defined(CONFIG_MACH_EDB9315) ||\
+	defined(CONFIG_MACH_EDB9315A)
+/*
+ * fclk_div: 2, nbyp1: 1, hclk_div: 4, pclk_div: 2
+ * pll1_x1: 3096576000.000000, pll1_x2ip: 129024000.000000,
+ * pll1_x2: 3999744000.000000, pll1_out: 1999872000.000000
+ */
+#define CLKSET1_VAL	(23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+			30 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+			20 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+			1 << SYSCON_CLKSET1_PCLK_DIV_SHIFT |   \
+			2 << SYSCON_CLKSET1_HCLK_DIV_SHIFT |   \
+			SYSCON_CLKSET1_NBYP1 |		       \
+			1 << SYSCON_CLKSET1_FCLK_DIV_SHIFT)
+#else
+#error "Undefined board"
+#endif
+
+/*
+ * usb_div: 4, nbyp2: 1, pll2_en: 1
+ * pll2_x1: 368640000.000000, pll2_x2ip: 15360000.000000,
+ * pll2_x2: 384000000.000000, pll2_out: 192000000.000000
+ */
+#define CLKSET2_VAL	(23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+			24 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+			24 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+			1 << SYSCON_CLKSET_PLL_PS_SHIFT |      \
+			SYSCON_CLKSET2_PLL2_EN |	       \
+			SYSCON_CLKSET2_NBYP2 |		       \
+			3 << SYSCON_CLKSET2_USB_DIV_SHIFT)
diff --git a/board/edb93xx/sdram_cfg.c b/board/edb93xx/sdram_cfg.c
new file mode 100644
index 0000000..9f56f72
--- /dev/null
+++ b/board/edb93xx/sdram_cfg.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <common.h>
+#include <asm/io.h>
+#include "sdram_cfg.h"
+#include "early_udelay.h"
+
+#define PROGRAM_MODE_REG(bank)		(*(volatile uint32_t *)		\
+		(SDRAM_BASE_ADDR | SDRAM_BANK_SEL_##bank | SDRAM_MODE_REG_VAL))
+
+#define PRECHARGE_BANK(bank)		(*(volatile uint32_t *)	\
+				(SDRAM_BASE_ADDR | SDRAM_BANK_SEL_##bank))
+
+static void force_precharge(void);
+static void setup_refresh_timer(void);
+static void program_mode_registers(void);
+
+void sdram_cfg(void)
+{
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	writel(SDRAM_DEVCFG_VAL, &sdram->SDRAM_DEVCFG_REG);
+
+	/* Issue continous NOP commands */
+	writel(GLCONFIG_INIT | GLCONFIG_MRS | GLCONFIG_CKE, &sdram->glconfig);
+
+	early_udelay(200);
+
+	force_precharge();
+
+	setup_refresh_timer();
+
+	program_mode_registers();
+
+	/* Select normal operation mode */
+	writel(GLCONFIG_CKE, &sdram->glconfig);
+}
+
+static void force_precharge(void)
+{
+	/*
+	 * Errata most EP93xx revisions say that PRECHARGE ALL isn't always
+	 * issued.
+	 *
+	 * Do a read from each bank to make sure they're precharged
+	 */
+
+	PRECHARGE_BANK(0);
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	PRECHARGE_BANK(1);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	PRECHARGE_BANK(2);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	PRECHARGE_BANK(3);
+#endif
+}
+
+static void setup_refresh_timer(void)
+{
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	/* Load refresh timer with 10 to issue refresh every 10 cycles */
+	writel(0x0a, &sdram->refrshtimr);
+
+	/*
+	 * Wait at least 80 clock cycles to provide 8 refresh cycles
+	 * to all SDRAMs
+	 */
+	early_udelay(1);
+
+	/*
+	 * Program refresh timer with normal value
+	 * We need 8192 refresh cycles every 64ms
+	 * at 15ns (HCLK >= 66MHz) per cycle:
+	 * 64ms / 8192 = 7.8125us
+	 * 7.8125us / 15ns = 520 (0x208)
+	 */
+	/*
+	 * TODO: redboot uses 0x1e0 for the slowest possible device
+	 * but i don't understand how this value is calculated
+	 */
+	writel(0x208, &sdram->refrshtimr);
+}
+
+static void program_mode_registers(void)
+{
+	PROGRAM_MODE_REG(0);
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	PROGRAM_MODE_REG(1);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	PROGRAM_MODE_REG(2);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	PROGRAM_MODE_REG(3);
+#endif
+}
diff --git a/board/edb93xx/sdram_cfg.h b/board/edb93xx/sdram_cfg.h
new file mode 100644
index 0000000..7babee8
--- /dev/null
+++ b/board/edb93xx/sdram_cfg.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <mach/ep93xx-regs.h>
+
+#define SDRAM_BASE_ADDR		CONFIG_EP93XX_SDRAM_BANK0_BASE
+
+#ifdef CONFIG_EP93XX_SDCE0_PHYS_OFFSET
+#define SDRAM_DEVCFG_REG	devcfg0
+#elif defined(CONFIG_EP93XX_SDCE3_SYNC_PHYS_OFFSET)
+#define SDRAM_DEVCFG_REG	devcfg3
+#else
+#error "SDRAM bank configuration"
+#endif
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) ||\
+	defined(CONFIG_MACH_EDB9302A)
+/*
+ * 1x Samsung K4S561632C-TC/L75 4M x 16bit x 4 banks SDRAM
+ *
+ * CLK cycle time min:
+ *	@ CAS latency = 3: 7.5ns
+ *	@ CAS latency = 2: 10ns
+ * We're running at 66MHz (15ns cycle time) external bus speed (HCLK),
+ * so it's safe to use CAS latency = 2
+ *
+ * RAS-to-CAS delay min:
+ *	20ns
+ * At 15ns cycle time, we use RAS-to-CAS delay = 2
+ *
+ * SROMLL = 1: Swap BA[1:0] with A[13:12], making the SDRAM appear
+ * as four blocks of 8MB size, instead of eight blocks of 4MB size:
+ *
+ * EDB9301/EDB9302:
+ *
+ * 0x00000000 - 0x007fffff
+ * 0x01000000 - 0x017fffff
+ * 0x04000000 - 0x047fffff
+ * 0x05000000 - 0x057fffff
+ *
+ *
+ * EDB9302a:
+ *
+ * 0xc0000000 - 0xc07fffff
+ * 0xc1000000 - 0xc17fffff
+ * 0xc4000000 - 0xc47fffff
+ * 0xc5000000 - 0xc57fffff
+ *
+ * BANKCOUNT = 1: This is a device with four banks
+ */
+
+#define SDRAM_DEVCFG_VAL (SDRAM_DEVCFG_BANKCOUNT |			\
+				SDRAM_DEVCFG_SROMLL |			\
+				SDRAM_DEVCFG_CASLAT_2 |			\
+				SDRAM_DEVCFG_RASTOCAS_2 |		\
+				SDRAM_DEVCFG_EXTBUSWIDTH)
+
+/*
+ * 16 bit ext. bus
+ *
+ * A[22:09] is output as SYA[13:0]
+ * CAS latency: 2
+ * Burst type: sequential
+ * Burst length: 8 (required for 16 bit ext. bus)
+ * SYA[13:0] = 0x0023
+ */
+#define SDRAM_MODE_REG_VAL	0x4600
+
+#define SDRAM_BANK_SEL_0	0x00000000 /* A[22:21] = b00 */
+#define SDRAM_BANK_SEL_1	0x00200000 /* A[22:21] = b01 */
+#define SDRAM_BANK_SEL_2	0x00400000 /* A[22:21] = b10 */
+#define SDRAM_BANK_SEL_3	0x00600000 /* A[22:21] = b11 */
+
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) ||\
+	defined CONFIG_MACH_EDB9312 || defined(CONFIG_MACH_EDB9315) ||\
+	defined(CONFIG_MACH_EDB9315A)
+/*
+ * 2x Samsung K4S561632C-TC/L75 4M x 16bit x 4 banks SDRAM
+ *
+ * CLK cycle time min:
+ *	@ CAS latency = 3: 7.5ns
+ *	@ CAS latency = 2: 10ns
+ * We're running at 100MHz (10ns cycle time) external bus speed (HCLK),
+ * so it's safe to use CAS latency = 2
+ *
+ * RAS-to-CAS delay min:
+ *	20ns
+ * At 10ns cycle time, we use RAS-to-CAS delay = 2
+ *
+ * EDB9307, EDB9312, EDB9315:
+ *
+ * 0x00000000 - 0x01ffffff
+ * 0x04000000 - 0x05ffffff
+ *
+ *
+ * EDB9307a, EDB9315a:
+ *
+ * 0xc0000000 - 0xc1ffffff
+ * 0xc4000000 - 0xc5ffffff
+ */
+
+#define SDRAM_DEVCFG_VAL	(SDRAM_DEVCFG_BANKCOUNT |		\
+				SDRAM_DEVCFG_SROMLL |			\
+				SDRAM_DEVCFG_CASLAT_2 |			\
+				SDRAM_DEVCFG_RASTOCAS_2)
+
+/*
+ * 32 bit ext. bus
+ *
+ * A[23:10] is output as SYA[13:0]
+ * CAS latency: 2
+ * Burst type: sequential
+ * Burst length: 4
+ * SYA[13:0] = 0x0022
+ */
+#define SDRAM_MODE_REG_VAL	0x8800
+
+#define SDRAM_BANK_SEL_0	0x00000000 /* A[23:22] = b00 */
+#define SDRAM_BANK_SEL_1	0x00400000 /* A[23:22] = b01 */
+#define SDRAM_BANK_SEL_2	0x00800000 /* A[23:22] = b10 */
+#define SDRAM_BANK_SEL_3	0x00c00000 /* A[23:22] = b11 */
+#endif
-- 
1.6.3.1



From s.hauer at pengutronix.de  Mon Jan 11 04:49:02 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 11 Jan 2010 10:49:02 +0100
Subject: [PATCH 0/5] Add support for EDB93xx boards
In-Reply-To: <20100109232838.GB14051@darwin>
References: <20100109232838.GB14051@darwin>
Message-ID: <20100111094902.GR6923@pengutronix.de>

Hello Matthias,

Thanks for the nice work. The patches look mostly fine. I wonder that
U-Boot ep93xx support has never made it to the mainline. Some comments
about the patches inline.

Sascha

On Sun, Jan 10, 2010 at 12:28:38AM +0100, Matthias Kaehlcke wrote:
> Add support for the following Cirrus Logic EDB93xx boards:
> 
> EDB9301
> EDB9302
> EDB9302A
> EDB9307
> EDB9307A
> EDB93012
> EDB9315
> EDB9315A
> 
> This patchset has been tested on boards based on the EDB9301 and EDB9307A designs
> 
> Matthias Kaehlcke (5):
>   ARM: Add support for EP93xx SoCs
>   Add EP93xx ethernet driver
>   Add support for EP9xx GPIOs
>   Add PrimeCell PL010 serial driver
>   Add support for EDB93xx boards
> 
>  Documentation/boards.dox                        |    8 +
>  MAINTAINERS                                     |   11 +
>  arch/arm/Kconfig                                |    6 +
>  arch/arm/Makefile                               |    9 +
>  arch/arm/configs/edb93xx_defconfig              |  237 ++++++++
>  arch/arm/mach-ep93xx/Kconfig                    |  446 +++++++++++++++
>  arch/arm/mach-ep93xx/Makefile                   |    3 +
>  arch/arm/mach-ep93xx/clocksource.c              |   96 ++++
>  arch/arm/mach-ep93xx/gpio.c                     |  136 +++++
>  arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |  600 ++++++++++++++++++++
>  arch/arm/mach-ep93xx/include/mach/gpio.h        |   29 +
>  arch/arm/mach-ep93xx/led.c                      |   62 ++
>  arch/arm/mach-ep93xx/led.h                      |   26 +
>  arch/arm/mach-ep93xx/lowlevel_init.S            |   64 +++

Aren't the LED functions and thus the lowlevel_init board specific?
I can imagine many custom boards do not have LEDs connected to these
gpio pins.

>  board/edb93xx/Makefile                          |    4 +
>  board/edb93xx/barebox.lds.S                     |   79 +++

I think it's better to add a

#ifdef CONFIG_ARCH_EP93XX
		/* the EP93xx expects to find the pattern 'CRUS' at
		 * 0x1000
		 */
		. = 0x1000;
		LONG(0x53555243) /* 'CRUS' */
#endif

to the generic linker script. We might have to revert this when we're
heading to an ifdeffery here, but for now I think it's better be able to
make changes to the linker script in only one file.

>  board/edb93xx/config.h                          |    4 +
>  board/edb93xx/early_udelay.h                    |   34 ++
>  board/edb93xx/edb93xx.c                         |  172 ++++++
>  board/edb93xx/edb93xx.dox                       |  108 ++++
>  board/edb93xx/edb93xx.h                         |   48 ++
>  board/edb93xx/env/bin/boot                      |   48 ++
>  board/edb93xx/env/bin/flash_partition           |   22 +
>  board/edb93xx/env/bin/init                      |   19 +
>  board/edb93xx/env/bin/set_nor_parts             |    3 +
>  board/edb93xx/env/bin/update_kernel             |   16 +
>  board/edb93xx/env/bin/update_rootfs             |   16 +
>  board/edb93xx/env/config                        |   16 +
>  board/edb93xx/flash_cfg.c                       |   38 ++
>  board/edb93xx/pll_cfg.c                         |   58 ++
>  board/edb93xx/pll_cfg.h                         |   72 +++
>  board/edb93xx/sdram_cfg.c                       |  127 +++++
>  board/edb93xx/sdram_cfg.h                       |  144 +++++
>  drivers/net/Kconfig                             |    5 +
>  drivers/net/Makefile                            |    1 +
>  drivers/net/ep93xx.c                            |  686 +++++++++++++++++++++++
>  drivers/net/ep93xx.h                            |  155 +++++
>  drivers/serial/Kconfig                          |    7 +
>  drivers/serial/Makefile                         |    2 +-
>  drivers/serial/serial_pl010.c                   |  172 ++++++
>  drivers/serial/serial_pl010.h                   |  100 ++++
>  include/common.h                                |    1 +
>  42 files changed, 3889 insertions(+), 1 deletions(-)
>  create mode 100644 arch/arm/configs/edb93xx_defconfig
>  create mode 100644 arch/arm/mach-ep93xx/Kconfig
>  create mode 100644 arch/arm/mach-ep93xx/Makefile
>  create mode 100644 arch/arm/mach-ep93xx/clocksource.c
>  create mode 100644 arch/arm/mach-ep93xx/gpio.c
>  create mode 100644 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
>  create mode 100644 arch/arm/mach-ep93xx/include/mach/gpio.h
>  create mode 100644 arch/arm/mach-ep93xx/led.c
>  create mode 100644 arch/arm/mach-ep93xx/led.h
>  create mode 100644 arch/arm/mach-ep93xx/lowlevel_init.S
>  create mode 100644 board/edb93xx/Makefile
>  create mode 100644 board/edb93xx/barebox.lds.S
>  create mode 100644 board/edb93xx/config.h
>  create mode 100644 board/edb93xx/early_udelay.h
>  create mode 100644 board/edb93xx/edb93xx.c
>  create mode 100644 board/edb93xx/edb93xx.dox
>  create mode 100644 board/edb93xx/edb93xx.h
>  create mode 100644 board/edb93xx/env/bin/boot
>  create mode 100644 board/edb93xx/env/bin/flash_partition
>  create mode 100644 board/edb93xx/env/bin/init
>  create mode 100644 board/edb93xx/env/bin/set_nor_parts
>  create mode 100644 board/edb93xx/env/bin/update_kernel
>  create mode 100644 board/edb93xx/env/bin/update_rootfs
>  create mode 100644 board/edb93xx/env/config
>  create mode 100644 board/edb93xx/flash_cfg.c
>  create mode 100644 board/edb93xx/pll_cfg.c
>  create mode 100644 board/edb93xx/pll_cfg.h
>  create mode 100644 board/edb93xx/sdram_cfg.c
>  create mode 100644 board/edb93xx/sdram_cfg.h
>  create mode 100644 drivers/net/ep93xx.c
>  create mode 100644 drivers/net/ep93xx.h
>  create mode 100644 drivers/serial/serial_pl010.c
>  create mode 100644 drivers/serial/serial_pl010.h
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Jan 11 05:12:43 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 11 Jan 2010 11:12:43 +0100
Subject: [PATCH 2/5] Add EP93xx ethernet driver
In-Reply-To: <20100109232852.GD14051@darwin>
References: <20100109232852.GD14051@darwin>
Message-ID: <20100111101243.GS6923@pengutronix.de>

On Sun, Jan 10, 2010 at 12:28:52AM +0100, Matthias Kaehlcke wrote:
> Added ethernet driver for EP93xx SoCs
> 
> Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
> ---
>  drivers/net/Kconfig  |    5 +
>  drivers/net/Makefile |    1 +
>  drivers/net/ep93xx.c |  686 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/net/ep93xx.h |  155 ++++++++++++
>  include/common.h     |    1 +
>  5 files changed, 848 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/net/ep93xx.c
>  create mode 100644 drivers/net/ep93xx.h
> 
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index ed7656e..0955562 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -64,6 +64,11 @@ config DRIVER_NET_FEC_IMX
>  	depends on ARCH_HAS_FEC_IMX
>  	select MIIPHY
>  
> +config DRIVER_NET_EP93XX
> +	bool "EP93xx Ethernet driver"
> +	depends on ARCH_EP93XX
> +	select MIIPHY
> +
>  config DRIVER_NET_MACB
>  	bool "macb Ethernet driver"
>  	depends on ARCH_AT91
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 6751920..1b6f104 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_DRIVER_NET_NETX)		+= netx_eth.o
>  obj-$(CONFIG_DRIVER_NET_AT91_ETHER)	+= at91_ether.o
>  obj-$(CONFIG_DRIVER_NET_MPC5200)	+= fec_mpc5200.o
>  obj-$(CONFIG_DRIVER_NET_FEC_IMX)	+= fec_imx.o
> +obj-$(CONFIG_DRIVER_NET_EP93XX)		+= ep93xx.o
>  obj-$(CONFIG_DRIVER_NET_MACB)		+= macb.o
>  obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
>  obj-$(CONFIG_MIIPHY)			+= miiphy.o
> diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
> new file mode 100644
> index 0000000..63a0d1b
> --- /dev/null
> +++ b/drivers/net/ep93xx.c

[snip]

> +
> +/**
> + * Copy a frame of data from the MAC into the protocol layer for further
> + * processing.
> + *
> + * TODO: Enhance this to deal with as many packets as are available at
> + * the MAC at one time? */

Probably not. I do not know what the network stack does when NetReceive
is called multiple times. Even if it does handle it I do not expect any
performance gains.

> +static int ep93xx_eth_rcv_packet(struct eth_device *edev)
> +{
> +	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
> +	struct mac_regs *regs = ep93xx_get_regs(edev);
> +	int ret = ETH_STATUS_FAILURE;
> +
> +	pr_debug("+ep93xx_eth_rcv_packet\n");
> +
> +	if (RX_STATUS_RFP(priv->rx_sq.current)) {
> +		if (RX_STATUS_RWE(priv->rx_sq.current)) {
> +			/*
> +			 * We have a good frame. Extract the frame's length
> +			 * from the current rx_status_queue entry, and copy
> +			 * the frame's data into NetRxPackets[] of the
> +			 * protocol stack. We track the total number of
> +			 * bytes in the frame (nbytes_frame) which will be
> +			 * used when we pass the data off to the protocol
> +			 * layer via NetReceive().
> +			 */
> +			NetReceive((uchar *)priv->rx_dq.current->word1,
> +				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
> +			pr_debug("reporting %d bytes...\n",
> +				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
> +
> +			ret = ETH_STATUS_SUCCESS;
> +
> +		} else {
> +			/* Do we have an erroneous packet? */
> +			pr_err("packet rx error, status %08X %08X\n",
> +				priv->rx_sq.current->word1,
> +				priv->rx_sq.current->word2);
> +			dump_rx_descriptor_queue();
> +			dump_rx_status_queue();
> +		}
> +
> +		/*
> +		 * Clear the associated status queue entry, and
> +		 * increment our current pointers to the next RX
> +		 * descriptor and status queue entries (making sure
> +		 * we wrap properly).
> +		 */
> +		memset((void *)priv->rx_sq.current, 0,
> +			sizeof(struct rx_status));
> +
> +		priv->rx_sq.current++;
> +		if (priv->rx_sq.current >= priv->rx_sq.end)
> +			priv->rx_sq.current = priv->rx_sq.base;
> +
> +		priv->rx_dq.current++;
> +		if (priv->rx_dq.current >= priv->rx_dq.end)
> +			priv->rx_dq.current = priv->rx_dq.base;
> +
> +		/*
> +		 * Finally, return the RX descriptor and status entries
> +		 * back to the MAC engine, and loop again, checking for
> +		 * more descriptors to process.
> +		 */
> +		writel(1, &regs->rxdqenq);
> +		writel(1, &regs->rxstsqenq);
> +	} else {
> +		ret = ETH_STATUS_SUCCESS;
> +	}
> +
> +	pr_debug("-ep93xx_eth_rcv_packet %d\n", ret);
> +
> +	return ret;
> +}
> +
> +/**
> + * Send a block of data via ethernet.
> + *
> + * TODO: Enhance this to deal with as much data as are available at one time? */

You are only given one packet, so you can't send more here.

> +static int ep93xx_eth_send_packet(struct eth_device *edev,
> +				void *packet, int length)
> +{
> +	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
> +	struct mac_regs *regs = ep93xx_get_regs(edev);
> +	int ret = ETH_STATUS_FAILURE;
> +
> +	pr_debug("+ep93xx_eth_send_packet\n");
> +
> +	/*
> +	 * Initialize the TX descriptor queue with the new packet's info.
> +	 * Clear the associated status queue entry. Enqueue the packet
> +	 * to the MAC for transmission.
> +	 */
> +
> +	/* set buffer address */
> +	priv->tx_dq.current->word1 = (uint32_t)packet;
> +
> +	/* set buffer length and EOF bit */
> +	priv->tx_dq.current->word2 = length | TX_DESC_EOF;
> +
> +	/* clear tx status */
> +	priv->tx_sq.current->word1 = 0;
> +
> +	/* enqueue the TX descriptor */
> +	writel(1, &regs->txdqenq);
> +
> +	/* wait for the frame to become processed */
> +	while (!TX_STATUS_TXFP(priv->tx_sq.current))
> +		; /* noop */
> +
> +	if (!TX_STATUS_TXWE(priv->tx_sq.current)) {
> +		pr_err("packet tx error, status %08X\n",
> +			priv->tx_sq.current->word1);
> +		dump_tx_descriptor_queue();
> +		dump_tx_status_queue();
> +
> +		/* TODO: Add better error handling? */
> +		goto eth_send_failed_0;
> +	}
> +
> +	ret = ETH_STATUS_SUCCESS;
> +	/* Fall through */
> +
> +eth_send_failed_0:
> +	pr_debug("-ep93xx_eth_send_packet %d\n", ret);
> +	return ret;
> +}
> +
> +/* -----------------------------------------------------------------------------
> + * EP93xx ethernet MII functionality.
> + */
> +
> +/**
> + * Maximum MII address we support
> + */
> +#define MII_ADDRESS_MAX			(31)
> +
> +/**
> + * Maximum MII register address we support
> + */
> +#define MII_REGISTER_MAX		(31)
> +
> +/**
> + * Ethernet MII interface return values for public functions.
> + */
> +enum mii_status {
> +	MII_STATUS_SUCCESS = 0,
> +	MII_STATUS_FAILURE = 1,
> +};
> +
> +/**
> + * Read a 16-bit value from an MII register.
> + */
> +static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
> +			uint8_t phy_reg, uint16_t *value)
> +{
> +	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
> +	int ret = MII_STATUS_FAILURE;
> +	uint32_t self_ctl;
> +
> +	pr_debug("+ep93xx_phy_read\n");
> +
> +	/*
> +	 * Save the current SelfCTL register value.  Set MAC to suppress
> +	 * preamble bits.  Wait for any previous MII command to complete
> +	 * before issuing the new command.
> +	 */
> +	self_ctl = readl(&regs->selfctl);
> +#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */
> +	writel(self_ctl & ~(1 << 8), &regs->selfctl);
> +#endif	/* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */
> +
> +	while (readl(&regs->miists) & MIISTS_BUSY)
> +		; /* noop */
> +
> +	/*
> +	 * Issue the MII 'read' command.  Wait for the command to complete.
> +	 * Read the MII data value.
> +	 */
> +	writel(MIICMD_OPCODE_READ | ((uint32_t)phy_addr << 5) |
> +		(uint32_t)phy_reg, &regs->miicmd);
> +	while (readl(&regs->miists) & MIISTS_BUSY)
> +		; /* noop */
> +
> +	*value = (unsigned short)readl(&regs->miidata);
> +
> +	/* Restore the saved SelfCTL value and return. */
> +	writel(self_ctl, &regs->selfctl);
> +
> +	ret = MII_STATUS_SUCCESS;
> +	/* Fall through */
> +
> +	pr_debug("-ep93xx_phy_read\n");
> +	return ret;

You can return 0 unconditionally here, the function never returns an
error. Please remove the MII_STATUS_* and ETH_STATUS_* macros. If we
ever decide add timeouts to the while loops -ETIMEDOUT would be the
correct return value, not 1.

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From matthias at kaehlcke.net  Mon Jan 11 05:37:00 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 11 Jan 2010 11:37:00 +0100
Subject: [PATCH 0/5] Add support for EDB93xx boards
In-Reply-To: <20100111094902.GR6923@pengutronix.de>
References: <20100109232838.GB14051@darwin>
	<20100111094902.GR6923@pengutronix.de>
Message-ID: <20100111103700.GH14051@darwin>

Hi Sascha,

El Mon, Jan 11, 2010 at 10:49:02AM +0100 Sascha Hauer ha dit:

> Thanks for the nice work. The patches look mostly fine. I wonder that
> U-Boot ep93xx support has never made it to the mainline. Some comments
> about the patches inline.

in late december i sent a (new) set of patches to the U-Boot mailing
list. i still havn't received feedback, i suppose due to christmas,
new year, ... my aim is to mainline ep93xx support, i am confident
this will be accomplished soon.

> On Sun, Jan 10, 2010 at 12:28:38AM +0100, Matthias Kaehlcke wrote:
> > Add support for the following Cirrus Logic EDB93xx boards:
> > 
> > EDB9301
> > EDB9302
> > EDB9302A
> > EDB9307
> > EDB9307A
> > EDB93012
> > EDB9315
> > EDB9315A
> > 
> > This patchset has been tested on boards based on the EDB9301 and EDB9307A designs
> > 
> > Matthias Kaehlcke (5):
> >   ARM: Add support for EP93xx SoCs
> >   Add EP93xx ethernet driver
> >   Add support for EP9xx GPIOs
> >   Add PrimeCell PL010 serial driver
> >   Add support for EDB93xx boards
> > 
> >  Documentation/boards.dox                        |    8 +
> >  MAINTAINERS                                     |   11 +
> >  arch/arm/Kconfig                                |    6 +
> >  arch/arm/Makefile                               |    9 +
> >  arch/arm/configs/edb93xx_defconfig              |  237 ++++++++
> >  arch/arm/mach-ep93xx/Kconfig                    |  446 +++++++++++++++
> >  arch/arm/mach-ep93xx/Makefile                   |    3 +
> >  arch/arm/mach-ep93xx/clocksource.c              |   96 ++++
> >  arch/arm/mach-ep93xx/gpio.c                     |  136 +++++
> >  arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |  600 ++++++++++++++++++++
> >  arch/arm/mach-ep93xx/include/mach/gpio.h        |   29 +
> >  arch/arm/mach-ep93xx/led.c                      |   62 ++
> >  arch/arm/mach-ep93xx/led.h                      |   26 +
> >  arch/arm/mach-ep93xx/lowlevel_init.S            |   64 +++
> 
> Aren't the LED functions and thus the lowlevel_init board specific?
> I can imagine many custom boards do not have LEDs connected to these
> gpio pins.

custom board could do this, but probably shouldn't. the EP93xx
explicitly 'reserves' specific GPIOs for a red and a green LED. these
LEDs are used by the boot algorithm to give feed back before the
bootloader is started.

please tell me if this convinces you to leave the LED functions and
lowlevel_init in the SoC part or if you prefer moving them to the
board directory.

> >  board/edb93xx/Makefile                          |    4 +
> >  board/edb93xx/barebox.lds.S                     |   79 +++
> 
> I think it's better to add a
> 
> #ifdef CONFIG_ARCH_EP93XX
> 		/* the EP93xx expects to find the pattern 'CRUS' at
> 		 * 0x1000
> 		 */
> 		. = 0x1000;
> 		LONG(0x53555243) /* 'CRUS' */
> #endif
> 
> to the generic linker script. We might have to revert this when we're
> heading to an ifdeffery here, but for now I think it's better be able to
> make changes to the linker script in only one file.

that's fine for me

thanks for your review!

-- 
Matthias Kaehlcke
Embedded Linux Developer
Barcelona

             If God had not intended for us to eat animals,
                  how come He made them out of meat?
                           (Sarah Palin)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-


From s.hauer at pengutronix.de  Mon Jan 11 06:25:57 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 11 Jan 2010 12:25:57 +0100
Subject: [PATCH 0/5] Add support for EDB93xx boards
In-Reply-To: <20100111103700.GH14051@darwin>
References: <20100109232838.GB14051@darwin>
	<20100111094902.GR6923@pengutronix.de>
	<20100111103700.GH14051@darwin>
Message-ID: <20100111112557.GU6923@pengutronix.de>

On Mon, Jan 11, 2010 at 11:37:00AM +0100, Matthias Kaehlcke wrote:
> Hi Sascha,
> 
> El Mon, Jan 11, 2010 at 10:49:02AM +0100 Sascha Hauer ha dit:
> 
> > Thanks for the nice work. The patches look mostly fine. I wonder that
> > U-Boot ep93xx support has never made it to the mainline. Some comments
> > about the patches inline.
> 
> in late december i sent a (new) set of patches to the U-Boot mailing
> list. i still havn't received feedback, i suppose due to christmas,
> new year, ... my aim is to mainline ep93xx support, i am confident
> this will be accomplished soon.
> 
> > On Sun, Jan 10, 2010 at 12:28:38AM +0100, Matthias Kaehlcke wrote:
> > > Add support for the following Cirrus Logic EDB93xx boards:
> > > 
> > > EDB9301
> > > EDB9302
> > > EDB9302A
> > > EDB9307
> > > EDB9307A
> > > EDB93012
> > > EDB9315
> > > EDB9315A
> > > 
> > > This patchset has been tested on boards based on the EDB9301 and EDB9307A designs
> > > 
> > > Matthias Kaehlcke (5):
> > >   ARM: Add support for EP93xx SoCs
> > >   Add EP93xx ethernet driver
> > >   Add support for EP9xx GPIOs
> > >   Add PrimeCell PL010 serial driver
> > >   Add support for EDB93xx boards
> > > 
> > >  Documentation/boards.dox                        |    8 +
> > >  MAINTAINERS                                     |   11 +
> > >  arch/arm/Kconfig                                |    6 +
> > >  arch/arm/Makefile                               |    9 +
> > >  arch/arm/configs/edb93xx_defconfig              |  237 ++++++++
> > >  arch/arm/mach-ep93xx/Kconfig                    |  446 +++++++++++++++
> > >  arch/arm/mach-ep93xx/Makefile                   |    3 +
> > >  arch/arm/mach-ep93xx/clocksource.c              |   96 ++++
> > >  arch/arm/mach-ep93xx/gpio.c                     |  136 +++++
> > >  arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |  600 ++++++++++++++++++++
> > >  arch/arm/mach-ep93xx/include/mach/gpio.h        |   29 +
> > >  arch/arm/mach-ep93xx/led.c                      |   62 ++
> > >  arch/arm/mach-ep93xx/led.h                      |   26 +
> > >  arch/arm/mach-ep93xx/lowlevel_init.S            |   64 +++
> > 
> > Aren't the LED functions and thus the lowlevel_init board specific?
> > I can imagine many custom boards do not have LEDs connected to these
> > gpio pins.
> 
> custom board could do this, but probably shouldn't. the EP93xx
> explicitly 'reserves' specific GPIOs for a red and a green LED. these
> LEDs are used by the boot algorithm to give feed back before the
> bootloader is started.

Ah, I didn't know this. A good move from Cirrus that the software
developer can rely on some debug LEDs.

> 
> please tell me if this convinces you to leave the LED functions and
> lowlevel_init in the SoC part or if you prefer moving them to the
> board directory.

I'm fine with the LEDs being available for all ep93xx then.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From eric at eukrea.com  Mon Jan 11 09:32:15 2010
From: eric at eukrea.com (Eric Benard)
Date: Mon, 11 Jan 2010 15:32:15 +0100
Subject: [PATCH] Fix a data abort with fec_imx
Message-ID: <1263220335-26307-1-git-send-email-eric@eukrea.com>

From: Eric Benard <ebenard at 1720eb.(none)>

edev was allocated using malloc. On one board (NOR boot), we met data abort
in eth_register (at dev_add_param(dev, &edev->param_ip);).
Allocating edev with xzalloc (as in several other drivers) fixed the problem.

Signed-off-by: Eric Benard <eric at eukrea.com>
---
 drivers/net/fec_imx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 4893291..49140e7 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -542,7 +542,7 @@ static int fec_probe(struct device_d *dev)
 #ifdef CONFIG_ARCH_IMX27
 	PCCR0 |= PCCR0_FEC_EN;
 #endif
-        edev = (struct eth_device *)malloc(sizeof(struct eth_device));
+        edev = (struct eth_device *)xzalloc(sizeof(struct eth_device));
         dev->type_data = edev;
 	fec = (struct fec_priv *)malloc(sizeof(*fec));
         edev->priv = fec;
-- 
1.6.3.3



From s.hauer at pengutronix.de  Mon Jan 11 12:58:35 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 11 Jan 2010 18:58:35 +0100
Subject: [PATCH] Fix a data abort with fec_imx
In-Reply-To: <1263220335-26307-1-git-send-email-eric@eukrea.com>
References: <1263220335-26307-1-git-send-email-eric@eukrea.com>
Message-ID: <20100111175835.GY6923@pengutronix.de>

On Mon, Jan 11, 2010 at 03:32:15PM +0100, Eric Benard wrote:
> From: Eric Benard <ebenard at 1720eb.(none)>
> 
> edev was allocated using malloc. On one board (NOR boot), we met data abort
> in eth_register (at dev_add_param(dev, &edev->param_ip);).
> Allocating edev with xzalloc (as in several other drivers) fixed the problem.

Ok, applied.

Sascha

> 
> Signed-off-by: Eric Benard <eric at eukrea.com>
> ---
>  drivers/net/fec_imx.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> index 4893291..49140e7 100644
> --- a/drivers/net/fec_imx.c
> +++ b/drivers/net/fec_imx.c
> @@ -542,7 +542,7 @@ static int fec_probe(struct device_d *dev)
>  #ifdef CONFIG_ARCH_IMX27
>  	PCCR0 |= PCCR0_FEC_EN;
>  #endif
> -        edev = (struct eth_device *)malloc(sizeof(struct eth_device));
> +        edev = (struct eth_device *)xzalloc(sizeof(struct eth_device));
>          dev->type_data = edev;
>  	fec = (struct fec_priv *)malloc(sizeof(*fec));
>          edev->priv = fec;
> -- 
> 1.6.3.3
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From matthias at kaehlcke.net  Mon Jan 11 16:27:12 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 11 Jan 2010 22:27:12 +0100
Subject: [PATCH] Add EP93xx ethernet driver [rev2]
In-Reply-To: <20100111101243.GS6923@pengutronix.de>
References: <20100109232852.GD14051@darwin>
	<20100111101243.GS6923@pengutronix.de>
Message-ID: <20100111212712.GI14051@darwin>

Added ethernet driver for EP93xx SoCs

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---

Changes with respect to rev1:

 * remove TODO comments about impossible enhancements
 * remove MII_STATUS_* and ETH_STATUS_* macros

 drivers/net/Kconfig  |    5 +
 drivers/net/Makefile |    1 +
 drivers/net/ep93xx.c |  676 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ep93xx.h |  147 +++++++++++
 include/common.h     |    1 +
 5 files changed, 830 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ep93xx.c
 create mode 100644 drivers/net/ep93xx.h

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ed7656e..0955562 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -64,6 +64,11 @@ config DRIVER_NET_FEC_IMX
 	depends on ARCH_HAS_FEC_IMX
 	select MIIPHY
 
+config DRIVER_NET_EP93XX
+	bool "EP93xx Ethernet driver"
+	depends on ARCH_EP93XX
+	select MIIPHY
+
 config DRIVER_NET_MACB
 	bool "macb Ethernet driver"
 	depends on ARCH_AT91
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6751920..1b6f104 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_DRIVER_NET_NETX)		+= netx_eth.o
 obj-$(CONFIG_DRIVER_NET_AT91_ETHER)	+= at91_ether.o
 obj-$(CONFIG_DRIVER_NET_MPC5200)	+= fec_mpc5200.o
 obj-$(CONFIG_DRIVER_NET_FEC_IMX)	+= fec_imx.o
+obj-$(CONFIG_DRIVER_NET_EP93XX)		+= ep93xx.o
 obj-$(CONFIG_DRIVER_NET_MACB)		+= macb.o
 obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
 obj-$(CONFIG_MIIPHY)			+= miiphy.o
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
new file mode 100644
index 0000000..aa1a005
--- /dev/null
+++ b/drivers/net/ep93xx.c
@@ -0,0 +1,676 @@
+/*
+ * Cirrus Logic EP93xx ethernet MAC / MII driver.
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.com>
+ *
+ * Based on the original eth.[ch] Cirrus Logic EP93xx Rev D. Ethernet Driver,
+ * which is
+ *
+ * (C) Copyright 2002 2003
+ * Adam Bezanson, Network Audio Technologies, Inc.
+ * <bezanson at netaudiotech.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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <init.h>
+#include <malloc.h>
+#include <miiphy.h>
+#include <asm/io.h>
+#include <linux/types.h>
+#include <mach/ep93xx-regs.h>
+#include "ep93xx.h"
+
+static int ep93xx_eth_send_packet(struct eth_device *edev,
+				void *packet, int length);
+static int ep93xx_eth_rcv_packet(struct eth_device *edev);
+
+static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t *value);
+static int ep93xx_phy_write(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t value);
+
+static inline struct ep93xx_eth_priv *ep93xx_get_priv(struct eth_device *edev)
+{
+	return (struct ep93xx_eth_priv *)edev->priv;
+}
+
+static inline struct mac_regs *ep93xx_get_regs(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+
+	return priv->regs;
+}
+
+#if defined(EP93XX_MAC_DEBUG)
+/**
+ * Dump ep93xx_mac values to the terminal.
+ */
+inline void dump_dev(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_dev()\n");
+	printf("  rx_dq.base	     %08X\n", priv->rx_dq.base);
+	printf("  rx_dq.current	     %08X\n", priv->rx_dq.current);
+	printf("  rx_dq.end	     %08X\n", priv->rx_dq.end);
+	printf("  rx_sq.base	     %08X\n", priv->rx_sq.base);
+	printf("  rx_sq.current	     %08X\n", priv->rx_sq.current);
+	printf("  rx_sq.end	     %08X\n", priv->rx_sq.end);
+
+	for (i = 0; i < NUMRXDESC; i++)
+		printf("  rx_buffer[%2.d]      %08X\n", i, NetRxPackets[i]);
+
+	printf("  tx_dq.base	     %08X\n", priv->tx_dq.base);
+	printf("  tx_dq.current	     %08X\n", priv->tx_dq.current);
+	printf("  tx_dq.end	     %08X\n", priv->tx_dq.end);
+	printf("  tx_sq.base	     %08X\n", priv->tx_sq.base);
+	printf("  tx_sq.current	     %08X\n", priv->tx_sq.current);
+	printf("  tx_sq.end	     %08X\n", priv->tx_sq.end);
+}
+
+/**
+ * Dump all RX descriptor queue entries to the terminal.
+ */
+inline void dump_rx_descriptor_queue(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_rx_descriptor_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMRXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->rx_dq.base + i),
+			(priv->rx_dq.base + i)->word1,
+			(priv->rx_dq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all RX status queue entries to the terminal.
+ */
+inline void dump_rx_status_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_rx_status_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMRXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->rx_sq.base + i),
+			(priv->rx_sq.base + i)->word1,
+			(priv->rx_sq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all TX descriptor queue entries to the terminal.
+ */
+inline void dump_tx_descriptor_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_tx_descriptor_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMTXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->tx_dq.base + i),
+			(priv->tx_dq.base + i)->word1,
+			(priv->tx_dq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all TX status queue entries to the terminal.
+ */
+inline void dump_tx_status_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_tx_status_queue()\n");
+	printf("  descriptor address	 word1\n");
+	for (i = 0; i < NUMTXDESC; i++) {
+		printf("  [ %08X ]	     %08X\n",
+			(priv->rx_sq.base + i),
+			(priv->rx_sq.base + i)->word1);
+	}
+}
+#else
+#define dump_dev(x)
+#define dump_rx_descriptor_queue()
+#define dump_rx_status_queue()
+#define dump_tx_descriptor_queue()
+#define dump_tx_status_queue()
+#endif	/* defined(EP93XX_MAC_DEBUG) */
+
+/**
+ * Reset the EP93xx MAC by twiddling the soft reset bit and spinning until
+ * it's cleared.
+ */
+static void ep93xx_eth_reset(struct eth_device *edev)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	uint32_t value;
+
+	pr_debug("+ep93xx_eth_reset\n");
+
+	value = readl(&regs->selfctl);
+	value |= SELFCTL_RESET;
+	writel(value, &regs->selfctl);
+
+	while (readl(&regs->selfctl) & SELFCTL_RESET)
+		; /* noop */
+
+	pr_debug("-ep93xx_eth_reset\n");
+}
+
+static int ep93xx_eth_init_dev(struct eth_device *edev)
+{
+	pr_debug("+ep93xx_eth_init_dev\n");
+
+	pr_debug("-ep93xx_eth_init_dev\n");
+
+	return 0;
+}
+
+static int ep93xx_eth_open(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int i;
+
+	pr_debug("+ep93xx_eth_open\n");
+
+	ep93xx_eth_reset(edev);
+
+	/* Reset the descriptor queues' current and end address values */
+	priv->tx_dq.current = priv->tx_dq.base;
+	priv->tx_dq.end = (priv->tx_dq.base + NUMTXDESC);
+
+	priv->tx_sq.current = priv->tx_sq.base;
+	priv->tx_sq.end = (priv->tx_sq.base + NUMTXDESC);
+
+	priv->rx_dq.current = priv->rx_dq.base;
+	priv->rx_dq.end = (priv->rx_dq.base + NUMRXDESC);
+
+	priv->rx_sq.current = priv->rx_sq.base;
+	priv->rx_sq.end = (priv->rx_sq.base + NUMRXDESC);
+
+	/*
+	 * Set the transmit descriptor and status queues' base address,
+	 * current address, and length registers.  Set the maximum frame
+	 * length and threshold. Enable the transmit descriptor processor.
+	 */
+	writel((uint32_t)priv->tx_dq.base, &regs->txdq.badd);
+	writel((uint32_t)priv->tx_dq.base, &regs->txdq.curadd);
+	writel(sizeof(struct tx_descriptor) * NUMTXDESC, &regs->txdq.blen);
+
+	writel((uint32_t)priv->tx_sq.base, &regs->txstsq.badd);
+	writel((uint32_t)priv->tx_sq.base, &regs->txstsq.curadd);
+	writel(sizeof(struct tx_status) * NUMTXDESC, &regs->txstsq.blen);
+
+	writel(0x00040000, &regs->txdthrshld);
+	writel(0x00040000, &regs->txststhrshld);
+
+	writel((TXSTARTMAX << 0) | (PKTSIZE_ALIGN << 16), &regs->maxfrmlen);
+	writel(BMCTL_TXEN, &regs->bmctl);
+
+	/*
+	 * Set the receive descriptor and status queues' base address,
+	 * current address, and length registers.  Enable the receive
+	 * descriptor processor.
+	 */
+	writel((uint32_t)priv->rx_dq.base, &regs->rxdq.badd);
+	writel((uint32_t)priv->rx_dq.base, &regs->rxdq.curadd);
+	writel(sizeof(struct rx_descriptor) * NUMRXDESC, &regs->rxdq.blen);
+
+	writel((uint32_t)priv->rx_sq.base, &regs->rxstsq.badd);
+	writel((uint32_t)priv->rx_sq.base, &regs->rxstsq.curadd);
+	writel(sizeof(struct rx_status) * NUMRXDESC, &regs->rxstsq.blen);
+
+	writel(0x00040000, &regs->rxdthrshld);
+
+	writel(BMCTL_RXEN, &regs->bmctl);
+
+	writel(0x00040000, &regs->rxststhrshld);
+
+	/* Wait until the receive descriptor processor is active */
+	while (!(readl(&regs->bmsts) & BMSTS_RXACT))
+		; /* noop */
+
+	/*
+	 * Initialize the RX descriptor queue. Clear the TX descriptor queue.
+	 * Clear the RX and TX status queues. Enqueue the RX descriptor and
+	 * status entries to the MAC.
+	 */
+	for (i = 0; i < NUMRXDESC; i++) {
+		/* set buffer address */
+		(priv->rx_dq.base + i)->word1 = (uint32_t)NetRxPackets[i];
+
+		/* set buffer length, clear buffer index and NSOF */
+		(priv->rx_dq.base + i)->word2 = PKTSIZE_ALIGN;
+	}
+
+	memset(priv->tx_dq.base, 0,
+		(sizeof(struct tx_descriptor) * NUMTXDESC));
+	memset(priv->rx_sq.base, 0,
+		(sizeof(struct rx_status) * NUMRXDESC));
+	memset(priv->tx_sq.base, 0,
+		(sizeof(struct tx_status) * NUMTXDESC));
+
+	writel(NUMRXDESC, &regs->rxdqenq);
+	writel(NUMRXDESC, &regs->rxstsqenq);
+
+	/* Turn on RX and TX */
+	writel(RXCTL_IA0 | RXCTL_BA | RXCTL_SRXON |
+		RXCTL_RCRCA | RXCTL_MA, &regs->rxctl);
+	writel(TXCTL_STXON, &regs->txctl);
+
+	/* Dump data structures if we're debugging */
+	dump_dev();
+	dump_rx_descriptor_queue();
+	dump_rx_status_queue();
+	dump_tx_descriptor_queue();
+	dump_tx_status_queue();
+
+	pr_debug("-ep93xx_eth_open\n");
+
+	return 0;
+}
+
+/**
+ * Halt EP93xx MAC transmit and receive by clearing the TxCTL and RxCTL
+ * registers.
+ */
+static void ep93xx_eth_halt(struct eth_device *edev)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+
+	pr_debug("+ep93xx_eth_halt\n");
+
+	writel(0x00000000, &regs->rxctl);
+	writel(0x00000000, &regs->txctl);
+
+	pr_debug("-ep93xx_eth_halt\n");
+}
+
+static int ep93xx_eth_get_ethaddr(struct eth_device *edev,
+				unsigned char *mac_addr)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	uint32_t value;
+
+	value = readl(&regs->indad);
+	mac_addr[0] = value & 0xFF;
+	mac_addr[1] = (value >> 8) & 0xFF;
+	mac_addr[2] = (value >> 16) & 0xFF;
+	mac_addr[3] = (value >> 24) & 0xFF;
+
+	value = readl(&regs->indad_upper);
+	mac_addr[4] = value & 0xFF;
+	mac_addr[5] = (value >> 8) & 0xFF;
+
+	return 0;
+}
+
+static int ep93xx_eth_set_ethaddr(struct eth_device *edev,
+				unsigned char *mac_addr)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+
+	writel(AFP_IAPRIMARY, &regs->afp);
+
+	writel(mac_addr[0] | (mac_addr[1] << 8) |
+		(mac_addr[2] << 16) | (mac_addr[3] << 24),
+		&regs->indad);
+	writel(mac_addr[4] | (mac_addr[5] << 8), &regs->indad_upper);
+
+	return 0;
+}
+
+static int ep93xx_eth_probe(struct device_d *dev)
+{
+	struct eth_device *edev;
+	struct ep93xx_eth_priv *priv;
+	int ret = -1;
+
+	pr_debug("ep93xx_eth_probe()\n");
+
+	edev = xzalloc(sizeof(struct eth_device) +
+		sizeof(struct ep93xx_eth_priv));
+	dev->type_data = edev;
+	edev->priv = (struct ep93xx_eth_priv *)(edev + 1);
+
+	priv = edev->priv;
+	priv->regs = (struct mac_regs *)MAC_BASE;
+
+	edev->init = ep93xx_eth_init_dev;
+	edev->open = ep93xx_eth_open;
+	edev->send = ep93xx_eth_send_packet;
+	edev->recv = ep93xx_eth_rcv_packet;
+	edev->halt = ep93xx_eth_halt;
+	edev->get_ethaddr = ep93xx_eth_get_ethaddr;
+	edev->set_ethaddr = ep93xx_eth_set_ethaddr;
+
+	priv->miiphy.read = ep93xx_phy_read;
+	priv->miiphy.write = ep93xx_phy_write;
+	priv->miiphy.address = 0;
+	priv->miiphy.flags = 0;
+
+	priv->tx_dq.base = calloc(NUMTXDESC,
+				sizeof(struct tx_descriptor));
+	if (priv->tx_dq.base == NULL) {
+		pr_err("calloc() failed: tx_dq.base");
+		goto eth_probe_failed_0;
+	}
+
+	priv->tx_sq.base = calloc(NUMTXDESC,
+				sizeof(struct tx_status));
+	if (priv->tx_sq.base == NULL) {
+		pr_err("calloc() failed: tx_sq.base");
+		goto eth_probe_failed_1;
+	}
+
+	priv->rx_dq.base = calloc(NUMRXDESC,
+				sizeof(struct rx_descriptor));
+	if (priv->rx_dq.base == NULL) {
+		pr_err("calloc() failed: rx_dq.base");
+		goto eth_probe_failed_2;
+	}
+
+	priv->rx_sq.base = calloc(NUMRXDESC,
+				sizeof(struct rx_status));
+	if (priv->rx_sq.base == NULL) {
+		pr_err("calloc() failed: rx_sq.base");
+		goto eth_probe_failed_3;
+	}
+
+	miiphy_register(&priv->miiphy);
+	eth_register(edev);
+
+	ret = 0;
+
+	goto eth_probe_done;
+
+eth_probe_failed_3:
+	free(priv->rx_dq.base);
+	/* Fall through */
+
+eth_probe_failed_2:
+	free(priv->tx_sq.base);
+	/* Fall through */
+
+eth_probe_failed_1:
+	free(priv->tx_dq.base);
+	/* Fall through */
+
+eth_probe_failed_0:
+	/* Fall through */
+
+eth_probe_done:
+	return ret;
+}
+
+/**
+ * Copy a frame of data from the MAC into the protocol layer for further
+ * processing.
+ */
+static int ep93xx_eth_rcv_packet(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int ret = -1;
+
+	pr_debug("+ep93xx_eth_rcv_packet\n");
+
+	if (RX_STATUS_RFP(priv->rx_sq.current)) {
+		if (RX_STATUS_RWE(priv->rx_sq.current)) {
+			/*
+			 * We have a good frame. Extract the frame's length
+			 * from the current rx_status_queue entry, and copy
+			 * the frame's data into NetRxPackets[] of the
+			 * protocol stack. We track the total number of
+			 * bytes in the frame (nbytes_frame) which will be
+			 * used when we pass the data off to the protocol
+			 * layer via NetReceive().
+			 */
+			NetReceive((uchar *)priv->rx_dq.current->word1,
+				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
+			pr_debug("reporting %d bytes...\n",
+				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
+
+			ret = 0;
+
+		} else {
+			/* Do we have an erroneous packet? */
+			pr_err("packet rx error, status %08X %08X\n",
+				priv->rx_sq.current->word1,
+				priv->rx_sq.current->word2);
+			dump_rx_descriptor_queue();
+			dump_rx_status_queue();
+		}
+
+		/*
+		 * Clear the associated status queue entry, and
+		 * increment our current pointers to the next RX
+		 * descriptor and status queue entries (making sure
+		 * we wrap properly).
+		 */
+		memset((void *)priv->rx_sq.current, 0,
+			sizeof(struct rx_status));
+
+		priv->rx_sq.current++;
+		if (priv->rx_sq.current >= priv->rx_sq.end)
+			priv->rx_sq.current = priv->rx_sq.base;
+
+		priv->rx_dq.current++;
+		if (priv->rx_dq.current >= priv->rx_dq.end)
+			priv->rx_dq.current = priv->rx_dq.base;
+
+		/*
+		 * Finally, return the RX descriptor and status entries
+		 * back to the MAC engine, and loop again, checking for
+		 * more descriptors to process.
+		 */
+		writel(1, &regs->rxdqenq);
+		writel(1, &regs->rxstsqenq);
+	} else {
+		ret = 0;
+	}
+
+	pr_debug("-ep93xx_eth_rcv_packet %d\n", ret);
+
+	return ret;
+}
+
+/**
+ * Send a block of data via ethernet.
+ */
+static int ep93xx_eth_send_packet(struct eth_device *edev,
+				void *packet, int length)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int ret = -1;
+
+	pr_debug("+ep93xx_eth_send_packet\n");
+
+	/*
+	 * Initialize the TX descriptor queue with the new packet's info.
+	 * Clear the associated status queue entry. Enqueue the packet
+	 * to the MAC for transmission.
+	 */
+
+	/* set buffer address */
+	priv->tx_dq.current->word1 = (uint32_t)packet;
+
+	/* set buffer length and EOF bit */
+	priv->tx_dq.current->word2 = length | TX_DESC_EOF;
+
+	/* clear tx status */
+	priv->tx_sq.current->word1 = 0;
+
+	/* enqueue the TX descriptor */
+	writel(1, &regs->txdqenq);
+
+	/* wait for the frame to become processed */
+	while (!TX_STATUS_TXFP(priv->tx_sq.current))
+		; /* noop */
+
+	if (!TX_STATUS_TXWE(priv->tx_sq.current)) {
+		pr_err("packet tx error, status %08X\n",
+			priv->tx_sq.current->word1);
+		dump_tx_descriptor_queue();
+		dump_tx_status_queue();
+
+		/* TODO: Add better error handling? */
+		goto eth_send_failed_0;
+	}
+
+	ret = 0;
+	/* Fall through */
+
+eth_send_failed_0:
+	pr_debug("-ep93xx_eth_send_packet %d\n", ret);
+
+	return ret;
+}
+
+/* -----------------------------------------------------------------------------
+ * EP93xx ethernet MII functionality.
+ */
+
+/**
+ * Maximum MII address we support
+ */
+#define MII_ADDRESS_MAX			(31)
+
+/**
+ * Maximum MII register address we support
+ */
+#define MII_REGISTER_MAX		(31)
+
+/**
+ * Read a 16-bit value from an MII register.
+ */
+static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t *value)
+{
+	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	int ret = -1;
+	uint32_t self_ctl;
+
+	pr_debug("+ep93xx_phy_read\n");
+
+	/*
+	 * Save the current SelfCTL register value.  Set MAC to suppress
+	 * preamble bits.  Wait for any previous MII command to complete
+	 * before issuing the new command.
+	 */
+	self_ctl = readl(&regs->selfctl);
+#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */
+	writel(self_ctl & ~(1 << 8), &regs->selfctl);
+#endif	/* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */
+
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/*
+	 * Issue the MII 'read' command.  Wait for the command to complete.
+	 * Read the MII data value.
+	 */
+	writel(MIICMD_OPCODE_READ | ((uint32_t)phy_addr << 5) |
+		(uint32_t)phy_reg, &regs->miicmd);
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	*value = (unsigned short)readl(&regs->miidata);
+
+	/* Restore the saved SelfCTL value and return. */
+	writel(self_ctl, &regs->selfctl);
+
+	ret = 0;
+
+	pr_debug("-ep93xx_phy_read\n");
+
+	return ret;
+}
+
+/**
+ * Write a 16-bit value to an MII register.
+ */
+static int ep93xx_phy_write(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t value)
+{
+	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	int ret = -1;
+	uint32_t self_ctl;
+
+	pr_debug("+ep93xx_phy_write\n");
+
+	/*
+	 * Save the current SelfCTL register value.  Set MAC to suppress
+	 * preamble bits.  Wait for any previous MII command to complete
+	 * before issuing the new command.
+	 */
+	self_ctl = readl(&regs->selfctl);
+#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */
+	writel(self_ctl & ~(1 << 8), &regs->selfctl);
+#endif	/* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */
+
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/* Issue the MII 'write' command.  Wait for the command to complete. */
+	writel((uint32_t)value, &regs->miidata);
+	writel(MIICMD_OPCODE_WRITE | ((uint32_t)phy_addr << 5) | phy_reg,
+		&regs->miicmd);
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/* Restore the saved SelfCTL value and return. */
+	writel(self_ctl, &regs->selfctl);
+
+	ret = 0;
+
+	pr_debug("-ep93xx_phy_write\n");
+
+	return ret;
+}
+
+static struct driver_d ep93xx_eth_driver = {
+	.name  = "ep93xx_eth",
+	.probe = ep93xx_eth_probe,
+};
+
+static int ep93xx_eth_init(void)
+{
+	register_driver(&ep93xx_eth_driver);
+	return 0;
+}
+
+device_initcall(ep93xx_eth_init);
diff --git a/drivers/net/ep93xx.h b/drivers/net/ep93xx.h
new file mode 100644
index 0000000..ae45c54
--- /dev/null
+++ b/drivers/net/ep93xx.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.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
+ *
+ */
+
+#ifndef _ETH_H
+#define _ETH_H
+
+#include <net.h>
+
+/**
+ * #define this to dump device status and queue info during initialization and
+ * following errors.
+ */
+#undef EP93XX_MAC_DEBUG
+
+/**
+ * Number of descriptor and status entries in our RX queues.
+ * It must be power of 2 !
+ */
+#define NUMRXDESC		PKTBUFSRX
+
+/**
+ * Number of descriptor and status entries in our TX queues.
+ */
+#define NUMTXDESC		1
+
+/**
+ * 944 = (1024 - 64) - 16, Fifo size - Minframesize - 16 (Chip FACT)
+ */
+#define TXSTARTMAX		944
+
+/**
+ * Receive descriptor queue entry
+ */
+struct rx_descriptor {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+/**
+ * Receive status queue entry
+ */
+struct rx_status {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+#define RX_STATUS_RWE(rx_status) ((rx_status->word1 >> 30) & 0x01)
+#define RX_STATUS_RFP(rx_status) ((rx_status->word1 >> 31) & 0x01)
+#define RX_STATUS_FRAME_LEN(rx_status) (rx_status->word2 & 0xFFFF)
+
+
+/**
+ * Transmit descriptor queue entry
+ */
+struct tx_descriptor {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+#define TX_DESC_EOF (1 << 31)
+
+/**
+ * Transmit status queue entry
+ */
+struct tx_status {
+	uint32_t word1;
+} __attribute__((packed));
+
+#define TX_STATUS_TXWE(tx_status) (((tx_status)->word1 >> 30) & 0x01)
+#define TX_STATUS_TXFP(tx_status) (((tx_status)->word1 >> 31) & 0x01)
+
+/**
+ * Transmit descriptor queue
+ */
+struct tx_descriptor_queue {
+	struct tx_descriptor *base;
+	struct tx_descriptor *current;
+	struct tx_descriptor *end;
+};
+
+/**
+ * Transmit status queue
+ */
+struct tx_status_queue {
+	struct tx_status *base;
+	volatile struct tx_status *current;
+	struct tx_status *end;
+};
+
+/**
+ * Receive descriptor queue
+ */
+struct rx_descriptor_queue {
+	struct rx_descriptor *base;
+	struct rx_descriptor *current;
+	struct rx_descriptor *end;
+};
+
+/**
+ * Receive status queue
+ */
+struct rx_status_queue {
+	struct rx_status *base;
+	volatile struct rx_status *current;
+	struct rx_status *end;
+};
+
+/**
+ * EP93xx MAC private data structure
+ */
+struct ep93xx_eth_priv {
+	struct mac_regs			*regs;
+
+	struct rx_descriptor_queue	rx_dq;
+	struct rx_status_queue		rx_sq;
+	void				*rx_buffer[NUMRXDESC];
+
+	struct tx_descriptor_queue	tx_dq;
+	struct tx_status_queue		tx_sq;
+
+	struct miiphy_device miiphy;
+};
+
+#endif
diff --git a/include/common.h b/include/common.h
index 0c49d95..2b40954 100644
--- a/include/common.h
+++ b/include/common.h
@@ -31,6 +31,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/stddef.h>
 #include <asm/common.h>
 
 #define pr_info(fmt, arg...)	printf(fmt, ##arg)
-- 
1.6.3.1



From matthias at kaehlcke.net  Mon Jan 11 16:31:12 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Mon, 11 Jan 2010 22:31:12 +0100
Subject: [PATCH] Add support for EDB93xx boards [rev2]
In-Reply-To: <20100111112557.GU6923@pengutronix.de>
References: <20100109232838.GB14051@darwin>
	<20100111094902.GR6923@pengutronix.de>
	<20100111103700.GH14051@darwin>
	<20100111112557.GU6923@pengutronix.de>
Message-ID: <20100111213112.GJ14051@darwin>

Added support for the following Cirrus Logic EDB93xx boards:

EDB9301
EDB9302
EDB9302A
EDB9307
EDB9307A
EDB93012
EDB9315
EDB9315A

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---

Changes with respect to rev1:
  * Use global linker script with EP93xx ifdef instead of a	board
		specific one

 Documentation/boards.dox              |    8 +
 arch/arm/configs/edb93xx_defconfig    |  236 +++++++++++++++++++++++++++++++++
 arch/arm/lib/barebox.lds.S            |    5 +
 arch/arm/mach-ep93xx/Kconfig          |    8 -
 board/edb93xx/Makefile                |    2 +
 board/edb93xx/config.h                |    4 +
 board/edb93xx/early_udelay.h          |   34 +++++
 board/edb93xx/edb93xx.c               |  172 ++++++++++++++++++++++++
 board/edb93xx/edb93xx.dox             |  108 +++++++++++++++
 board/edb93xx/edb93xx.h               |   48 +++++++
 board/edb93xx/env/bin/boot            |   48 +++++++
 board/edb93xx/env/bin/flash_partition |   22 +++
 board/edb93xx/env/bin/init            |   19 +++
 board/edb93xx/env/bin/set_nor_parts   |    3 +
 board/edb93xx/env/bin/update_kernel   |   16 +++
 board/edb93xx/env/bin/update_rootfs   |   16 +++
 board/edb93xx/env/config              |   16 +++
 board/edb93xx/flash_cfg.c             |   38 ++++++
 board/edb93xx/pll_cfg.c               |   58 ++++++++
 board/edb93xx/pll_cfg.h               |   72 ++++++++++
 board/edb93xx/sdram_cfg.c             |  127 ++++++++++++++++++
 board/edb93xx/sdram_cfg.h             |  144 ++++++++++++++++++++
 22 files changed, 1196 insertions(+), 8 deletions(-)
 create mode 100644 arch/arm/configs/edb93xx_defconfig
 create mode 100644 board/edb93xx/Makefile
 create mode 100644 board/edb93xx/config.h
 create mode 100644 board/edb93xx/early_udelay.h
 create mode 100644 board/edb93xx/edb93xx.c
 create mode 100644 board/edb93xx/edb93xx.dox
 create mode 100644 board/edb93xx/edb93xx.h
 create mode 100644 board/edb93xx/env/bin/boot
 create mode 100644 board/edb93xx/env/bin/flash_partition
 create mode 100644 board/edb93xx/env/bin/init
 create mode 100644 board/edb93xx/env/bin/set_nor_parts
 create mode 100644 board/edb93xx/env/bin/update_kernel
 create mode 100644 board/edb93xx/env/bin/update_rootfs
 create mode 100644 board/edb93xx/env/config
 create mode 100644 board/edb93xx/flash_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.h
 create mode 100644 board/edb93xx/sdram_cfg.c
 create mode 100644 board/edb93xx/sdram_cfg.h

diff --git a/Documentation/boards.dox b/Documentation/boards.dox
index dba547f..7c7f4d1 100644
--- a/Documentation/boards.dox
+++ b/Documentation/boards.dox
@@ -20,6 +20,14 @@ ARM type:
 @li @subpage a9m2440
 @li @subpage a9m2410
 @li @subpage eukrea_cpuimx27
+ at li @subpage edb9301
+ at li @subpage edb9302
+ at li @subpage edb9302a
+ at li @subpage edb9307
+ at li @subpage edb9307a
+ at li @subpage edb9312
+ at li @subpage edb9315
+ at li @subpage edb9315a
 
 Blackfin type:
 
diff --git a/arch/arm/configs/edb93xx_defconfig b/arch/arm/configs/edb93xx_defconfig
new file mode 100644
index 0000000..d6b4b19
--- /dev/null
+++ b/arch/arm/configs/edb93xx_defconfig
@@ -0,0 +1,236 @@
+#
+# Automatically generated make config: don't edit
+# barebox version: 2009.12.0
+# Fri Jan  8 17:27:15 2010
+#
+CONFIG_ARM=y
+
+#
+# System Type
+#
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_AT91RM9200 is not set
+CONFIG_ARCH_EP93XX=y
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_S3C24xx is not set
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_ARM920T=y
+CONFIG_CPU_32v4T=y
+
+#
+# processor features
+#
+CONFIG_ARCH_TEXT_BASE=0x05700000
+CONFIG_BOARDINFO="Cirrus Logic EDB9301"
+CONFIG_EP93XX_SDCE3_SYNC_PHYS_OFFSET=y
+
+#
+# Cirrus EP93xx System-on-Chip
+#
+CONFIG_ARCH_EP9301=y
+# CONFIG_ARCH_EP9302 is not set
+# CONFIG_ARCH_EP9307 is not set
+# CONFIG_ARCH_EP9312 is not set
+# CONFIG_ARCH_EP9315 is not set
+CONFIG_MACH_EDB9301=y
+CONFIG_EP93XX_SDRAM_NUM_BANKS=4
+CONFIG_EP93XX_SDRAM_BANK0_BASE=0x00000000
+CONFIG_EP93XX_SDRAM_BANK0_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK1_BASE=0x01000000
+CONFIG_EP93XX_SDRAM_BANK1_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK2_BASE=0x04000000
+CONFIG_EP93XX_SDRAM_BANK2_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK3_BASE=0x05000000
+CONFIG_EP93XX_SDRAM_BANK3_SIZE=0x00800000
+CONFIG_AEABI=y
+
+#
+# Arm specific settings         
+#
+CONFIG_CMD_ARM_CPUINFO=y
+CONFIG_CMDLINE_TAG=y
+CONFIG_SETUP_MEMORY_TAGS=y
+# CONFIG_INITRD_TAG is not set
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_GREGORIAN_CALENDER=y
+CONFIG_HAS_KALLSYMS=y
+CONFIG_HAS_MODULES=y
+CONFIG_CMD_MEMORY=y
+CONFIG_ENV_HANDLING=y
+CONFIG_GENERIC_GPIO=y
+
+#
+# General Settings              
+#
+CONFIG_LOCALVERSION_AUTO=y
+
+#
+# memory layout                 
+#
+CONFIG_HAVE_CONFIGURABLE_TEXT_BASE=y
+CONFIG_TEXT_BASE=0x05700000
+CONFIG_HAVE_CONFIGURABLE_MEMORY_LAYOUT=y
+CONFIG_MEMORY_LAYOUT_DEFAULT=y
+# CONFIG_MEMORY_LAYOUT_FIXED is not set
+CONFIG_STACK_SIZE=0x8000
+CONFIG_MALLOC_SIZE=0x400000
+# CONFIG_BROKEN is not set
+# CONFIG_EXPERIMENTAL is not set
+CONFIG_MACH_HAS_LOWLEVEL_INIT=y
+CONFIG_MACH_DO_LOWLEVEL_INIT=y
+CONFIG_PROMPT="barebox:"
+CONFIG_BAUDRATE=115200
+CONFIG_LONGHELP=y
+CONFIG_CBSIZE=1024
+CONFIG_MAXARGS=16
+CONFIG_SHELL_HUSH=y
+# CONFIG_SHELL_SIMPLE is not set
+CONFIG_GLOB=y
+CONFIG_PROMPT_HUSH_PS2="> "
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DYNAMIC_CRC_TABLE=y
+CONFIG_ERRNO_MESSAGES=y
+CONFIG_TIMESTAMP=y
+CONFIG_CONSOLE_FULL=y
+CONFIG_CONSOLE_ACTIVATE_FIRST=y
+# CONFIG_OF_FLAT_TREE is not set
+CONFIG_PARTITION=y
+CONFIG_DEFAULT_ENVIRONMENT=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="board/edb93xx/env"
+
+#
+# Debugging                     
+#
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_ENABLE_FLASH_NOISE is not set
+# CONFIG_ENABLE_PARTITION_NOISE is not set
+# CONFIG_ENABLE_DEVICE_NOISE is not set
+
+#
+# Commands                      
+#
+
+#
+# scripting                     
+#
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_LOADENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TRUE=y
+CONFIG_CMD_FALSE=y
+
+#
+# file commands                 
+#
+CONFIG_CMD_LS=y
+CONFIG_CMD_RM=y
+CONFIG_CMD_CAT=y
+CONFIG_CMD_MKDIR=y
+CONFIG_CMD_RMDIR=y
+CONFIG_CMD_CP=y
+CONFIG_CMD_PWD=y
+CONFIG_CMD_CD=y
+CONFIG_CMD_MOUNT=y
+CONFIG_CMD_UMOUNT=y
+
+#
+# console                       
+#
+CONFIG_CMD_CLEAR=y
+CONFIG_CMD_ECHO=y
+
+#
+# memory                        
+#
+# CONFIG_CMD_LOADB is not set
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_MTEST=y
+# CONFIG_CMD_MTEST_ALTERNATIVE is not set
+
+#
+# flash                         
+#
+CONFIG_CMD_FLASH=y
+
+#
+# booting                       
+#
+CONFIG_CMD_BOOTM=y
+# CONFIG_CMD_BOOTM_ZLIB is not set
+# CONFIG_CMD_BOOTM_BZLIB is not set
+# CONFIG_CMD_BOOTM_SHOW_TYPE is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTU=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_TEST=y
+CONFIG_CMD_VERSION=y
+CONFIG_CMD_HELP=y
+CONFIG_CMD_DEVINFO=y
+CONFIG_CMD_GPIO=y
+CONFIG_NET=y
+CONFIG_NET_DHCP=y
+# CONFIG_NET_RARP is not set
+# CONFIG_NET_NFS is not set
+CONFIG_NET_PING=y
+CONFIG_NET_TFTP=y
+
+#
+# Drivers                       
+#
+
+#
+# serial drivers                
+#
+# CONFIG_DRIVER_SERIAL_ARM_DCC is not set
+# CONFIG_DRIVER_SERIAL_NS16550 is not set
+CONFIG_DRIVER_SERIAL_PL010=y
+CONFIG_MIIPHY=y
+
+#
+# Network drivers               
+#
+# CONFIG_DRIVER_NET_SMC911X is not set
+# CONFIG_DRIVER_NET_SMC91111 is not set
+CONFIG_DRIVER_NET_EP93XX=y
+
+#
+# SPI drivers                   
+#
+# CONFIG_SPI is not set
+# CONFIG_I2C is not set
+
+#
+# flash drivers                 
+#
+CONFIG_DRIVER_CFI=y
+# CONFIG_DRIVER_CFI_NEW is not set
+CONFIG_DRIVER_CFI_OLD=y
+# CONFIG_CFI_BUFFER_WRITE is not set
+# CONFIG_NAND is not set
+# CONFIG_USB is not set
+# CONFIG_USB_GADGET is not set
+# CONFIG_VIDEO is not set
+
+#
+# Filesystem support            
+#
+# CONFIG_FS_CRAMFS is not set
+CONFIG_FS_RAMFS=y
+CONFIG_FS_DEVFS=y
+CONFIG_CRC32=y
+# CONFIG_GENERIC_FIND_NEXT_BIT is not set
diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index c8d1bb9..a5eaefa 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -39,6 +39,11 @@ SECTIONS
 		_stext = .;
 		_text = .;
 		*(.text_entry*)
+#ifdef CONFIG_ARCH_EP93XX
+		/* the EP93xx expects to find the pattern 'CRUS' at 0x1000 */
+	  . = 0x1000;
+	  LONG(0x53555243) /* 'CRUS' */
+#endif
 		*(.text_bare_init*)
 		*(.text*)
 	}
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
index 139b08d..ed6e986 100644
--- a/arch/arm/mach-ep93xx/Kconfig
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -39,7 +39,6 @@ config MACH_EDB9301
 	bool "Cirrus Logic EDB9301"
 	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9301 Evaluation board
 
@@ -105,7 +104,6 @@ config MACH_EDB9302
 	bool "Cirrus Logic EDB9302"
 	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9302 Evaluation board
 
@@ -113,7 +111,6 @@ config MACH_EDB9302A
 	bool "Cirrus Logic EDB9302A"
 	select EP93XX_SDCE0_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9302A Evaluation board
 
@@ -226,7 +223,6 @@ config MACH_EDB9307
 	bool "Cirrus Logic EDB9307"
 	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9307 Evaluation board
 
@@ -234,7 +230,6 @@ config MACH_EDB9307A
 	bool "Cirrus Logic EDB9307A"
 	select EP93XX_SDCE0_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9307A Evaluation board
 
@@ -315,7 +310,6 @@ config MACH_EDB9312
 	bool "Cirrus Logic EDB9312"
 	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9312 Evaluation board
 
@@ -365,7 +359,6 @@ config MACH_EDB9315
 	bool "Cirrus Logic EDB9315"
 	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9315 Evaluation board
 
@@ -373,7 +366,6 @@ config MACH_EDB9315A
 	bool "Cirrus Logic EDB9315A"
 	select EP93XX_SDCE0_PHYS_OFFSET
 	select MACH_HAS_LOWLEVEL_INIT
-	select BOARD_LINKER_SCRIPT
 	help
 	  Say y here if you are using Cirrus Logic's EDB9315A Evaluation board
 
diff --git a/board/edb93xx/Makefile b/board/edb93xx/Makefile
new file mode 100644
index 0000000..e19cd7b
--- /dev/null
+++ b/board/edb93xx/Makefile
@@ -0,0 +1,2 @@
+
+obj-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o
diff --git a/board/edb93xx/config.h b/board/edb93xx/config.h
new file mode 100644
index 0000000..6ae9a40
--- /dev/null
+++ b/board/edb93xx/config.h
@@ -0,0 +1,4 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#endif  /* __CONFIG_H */
diff --git a/board/edb93xx/early_udelay.h b/board/edb93xx/early_udelay.h
new file mode 100644
index 0000000..3b26b3f
--- /dev/null
+++ b/board/edb93xx/early_udelay.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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>
+
+/* delay execution before timers are initialized */
+static inline void early_udelay(uint32_t usecs)
+{
+	/* loop takes 4 cycles at 5.0ns (fastest case, running at 200MHz) */
+	register uint32_t loops = (usecs * 1000) / 20;
+
+	__asm__ volatile ("1:\n"
+			"subs %0, %1, #1\n"
+			"bne 1b":"=r" (loops):"0" (loops));
+}
diff --git a/board/edb93xx/edb93xx.c b/board/edb93xx/edb93xx.c
new file mode 100644
index 0000000..add88e1
--- /dev/null
+++ b/board/edb93xx/edb93xx.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <driver.h>
+#include <environment.h>
+#include <fs.h>
+#include <init.h>
+#include <partition.h>
+#include <asm/armlinux.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <mach/ep93xx-regs.h>
+#include "edb93xx.h"
+
+/*
+ * Up to 32MiB NOR type flash, connected to
+ * CS line 6, data width is 16 bit
+ */
+static struct device_d cfi_dev = {
+	.name     = "cfi_flash",
+	.map_base = 0x60000000,
+	.size     = EDB93XX_CFI_FLASH_SIZE,
+};
+
+static struct memory_platform_data ram_dev_pdata0 = {
+	.name = "ram0",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram0_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK0_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK0_SIZE,
+	.platform_data = &ram_dev_pdata0,
+};
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+static struct memory_platform_data ram_dev_pdata1 = {
+	.name = "ram1",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram1_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK1_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK1_SIZE,
+	.platform_data = &ram_dev_pdata1,
+};
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+static struct memory_platform_data ram_dev_pdata2 = {
+	.name = "ram2",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram2_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK2_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK2_SIZE,
+	.platform_data = &ram_dev_pdata2,
+};
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+static struct memory_platform_data ram_dev_pdata3 = {
+	.name = "ram3",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram3_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK3_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK3_SIZE,
+	.platform_data = &ram_dev_pdata3,
+};
+#endif
+
+static struct device_d eth_dev = {
+	.name     = "ep93xx_eth",
+};
+
+static int ep93xx_devices_init(void)
+{
+	register_device(&cfi_dev);
+
+	/*
+	 * Create partitions that should be
+	 * not touched by any regular user
+	 */
+	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
+	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
+
+	protect_file("/dev/env0", 1);
+
+	register_device(&sdram0_dev);
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	register_device(&sdram1_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	register_device(&sdram2_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	register_device(&sdram3_dev);
+#endif
+
+	armlinux_add_dram(&sdram0_dev);
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	armlinux_add_dram(&sdram1_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	armlinux_add_dram(&sdram2_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	armlinux_add_dram(&sdram3_dev);
+#endif
+
+	register_device(&eth_dev);
+
+	armlinux_set_bootparams((void *)CONFIG_EP93XX_SDRAM_BANK0_BASE + 0x100);
+
+	armlinux_set_architecture(MACH_TYPE);
+
+	return 0;
+}
+
+device_initcall(ep93xx_devices_init);
+
+static struct device_d edb93xx_serial_device = {
+	.name     = "pl010_serial",
+	.map_base = UART1_BASE,
+	.size     = 4096,
+};
+
+static int edb93xx_console_init(void)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+
+	/*
+	 * set UARTBAUD bit to drive UARTs with 14.7456MHz instead of
+	 * 14.7456/2 MHz
+	 */
+	uint32_t value = readl(&syscon->pwrcnt);
+	value |= SYSCON_PWRCNT_UART_BAUD;
+	writel(value, &syscon->pwrcnt);
+
+	register_device(&edb93xx_serial_device);
+
+	return 0;
+}
+
+console_initcall(edb93xx_console_init);
diff --git a/board/edb93xx/edb93xx.dox b/board/edb93xx/edb93xx.dox
new file mode 100644
index 0000000..3964d55
--- /dev/null
+++ b/board/edb93xx/edb93xx.dox
@@ -0,0 +1,108 @@
+/** @page edb9301 Cirrus Logic EDB9301
+
+This boards is based on a Cirrus Logic EP9301 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS3
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9302 Cirrus Logic EDB9302
+
+This board is based on a Cirrus Logic EP9302 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS3
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9302a Cirrus Logic EDB9302A
+
+This board is based on a Cirrus Logic EP9302 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS0
+- 512kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9307 Cirrus Logic EDB9307
+
+This board is based on a Cirrus Logic EP9307 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9307a Cirrus Logic EDB9307A
+
+This board is based on a Cirrus Logic EP9307 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS0
+- 512kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9312 Cirrus Logic EDB9312
+
+This board is based on a Cirrus Logic EP9312 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9315 Cirrus Logic EDB9315
+
+This board is based on a Cirrus Logic EP9315 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9315a Cirrus Logic EDB9315A
+
+This board is based on a Cirrus Logic EP9315 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS0
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
\ No newline at end of file
diff --git a/board/edb93xx/edb93xx.h b/board/edb93xx/edb93xx.h
new file mode 100644
index 0000000..5e5c6f5
--- /dev/null
+++ b/board/edb93xx/edb93xx.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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
+ */
+
+#if defined(CONFIG_MACH_EDB9301)
+#define MACH_TYPE MACH_TYPE_EDB9301
+#elif defined(CONFIG_MACH_EDB9302)
+#define MACH_TYPE MACH_TYPE_EDB9302
+#elif defined(CONFIG_MACH_EDB9302A)
+#define MACH_TYPE MACH_TYPE_EDB9302A
+#elif defined(CONFIG_MACH_EDB9307)
+#define MACH_TYPE MACH_TYPE_EDB9307
+#elif defined(CONFIG_MACH_EDB9307A)
+#define MACH_TYPE MACH_TYPE_EDB9307A
+#elif defined(CONFIG_MACH_EDB9312)
+#define MACH_TYPE MACH_TYPE_EDB9312
+#elif defined(CONFIG_MACH_EDB9315)
+#define MACH_TYPE MACH_TYPE_EDB9315
+#elif defined(CONFIG_MACH_EDB9315A)
+#define MACH_TYPE MACH_TYPE_EDB9315A
+#endif
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) || \
+	defined(CONFIG_MACH_EDB9302A)
+#define EDB93XX_CFI_FLASH_SIZE (16 * 1024 * 1024)
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) || \
+	defined(CONFIG_MACH_EDB9312) || defined(CONFIG_MACH_EDB9315) ||	\
+	defined(CONFIG_MACH_EDB9315A)
+#define EDB93XX_CFI_FLASH_SIZE (32 * 1024 * 1024)
+#endif
diff --git a/board/edb93xx/env/bin/boot b/board/edb93xx/env/bin/boot
new file mode 100644
index 0000000..143f3d0
--- /dev/null
+++ b/board/edb93xx/env/bin/boot
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+. /env/config
+
+if [ x${rootfs_boot_media} = xflash ];
+then
+		rootfs_img=/dev/nor0.rootfs_${active_cfg}
+
+		if [ x${active_cfg} = x1 ];
+		then
+				rootfs_blkdev=/dev/mtdblock4
+				cfg_1_ro="ro"
+				cfg_2_ro=""
+		else
+				rootfs_blkdev=/dev/mtdblock6
+				cfg_1_ro=""
+				cfg_2_ro="ro"
+		fi
+
+		bootargs_rootfs="root=${rootfs_blkdev} rootfstype=squashfs ro"
+elif [ x${rootfs_boot_media} = xnet ];
+then
+		bootargs_rootfs="root=/dev/nfs nfsroot=${eth0.serverip}:/srv/nfs/${board},v3,nolock,tcp ip=${eth0.ipaddr}"
+else
+		echo "ERROR: \$rootfs_boot_media invalid: ${rootfs_boot_media}"
+		exit 1
+fi
+
+if [ x${kernel_boot_media} = xflash ];
+then
+		kernel_img=/dev/nor0.kernel_${active_cfg}
+elif [ x${kernel_boot_media} = xnet ];
+then
+		cd /
+		tftp ${board}/kernel.img || exit 1
+		kernel_img=/kernel.img
+else
+		echo "ERROR: \$kernel_boot_media invalid: ${kernel_boot_media}"
+		exit 1
+fi
+
+source /env/bin/set_nor_parts
+
+bootargs_mtd="mtdparts=physmap-flash.0:${nor_parts}"
+
+bootargs="${bootargs_common} ${bootargs_mtd} ${bootargs_rootfs}"
+
+bootm ${kernel_img}
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/flash_partition b/board/edb93xx/env/bin/flash_partition
new file mode 100644
index 0000000..ded40aa
--- /dev/null
+++ b/board/edb93xx/env/bin/flash_partition
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $# != 2 ];
+then
+				echo "Usage: $0 <image> <partition>"
+				exit 1
+fi
+
+image=$1
+partition=$2
+
+echo "Unlocking ${partition}"
+unprotect ${partition}
+
+echo "Erasing ${partition}"
+erase ${partition}
+
+echo "Flashing ${image} to ${partition}"
+cp ${image} ${partition}
+
+echo "Locking ${partition}"
+protect ${partition}
diff --git a/board/edb93xx/env/bin/init b/board/edb93xx/env/bin/init
new file mode 100644
index 0000000..c6b5aed
--- /dev/null
+++ b/board/edb93xx/env/bin/init
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+
+# add partitions to barebox
+. /env/bin/set_nor_parts
+addpart /dev/nor0 ${nor_parts}
+
+echo
+echo -n "Hit any key to stop autoboot: "
+timeout -a $autoboot_timeout
+if [ $? != 0 ]; then
+	exit
+fi
+
+boot
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/set_nor_parts b/board/edb93xx/env/bin/set_nor_parts
new file mode 100644
index 0000000..38321fa
--- /dev/null
+++ b/board/edb93xx/env/bin/set_nor_parts
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+nor_parts="256k(barebox)ro,128k(env_boot),128k(env_boot.bak),1664k(kernel_1)${cfg_1_ro},6144k(rootfs_1)${cfg_1_ro},1664k(kernel_2)${cfg_2_ro},6144k(rootfs_2)${cfg_2_ro},128k(cfg_app),128k(cfg_app.bak)"
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/update_kernel b/board/edb93xx/env/bin/update_kernel
new file mode 100644
index 0000000..3e4b9b0
--- /dev/null
+++ b/board/edb93xx/env/bin/update_kernel
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. /env/config
+
+if [ $# != 1 ];
+then
+				echo "Usage: $0 <1/2>"
+				exit 1
+fi
+
+partition=/dev/nor0.kernel_$1
+
+cd /
+tftp ${board}/kernel.img || exit 1
+
+flash_partition kernel.img ${partition}
diff --git a/board/edb93xx/env/bin/update_rootfs b/board/edb93xx/env/bin/update_rootfs
new file mode 100644
index 0000000..52a3699
--- /dev/null
+++ b/board/edb93xx/env/bin/update_rootfs
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. /env/config
+
+if [ $# != 1 ];
+then
+				echo "Usage: $0 <1/2>"
+				exit 1
+fi
+
+partition=/dev/nor0.rootfs_$1
+
+cd /
+tftp ${board}/rootfs.img || exit 1
+
+flash_partition rootfs.img ${partition}
diff --git a/board/edb93xx/env/config b/board/edb93xx/env/config
new file mode 100644
index 0000000..47ab209
--- /dev/null
+++ b/board/edb93xx/env/config
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+eth0.ipaddr=192.168.0.50
+eth0.netmask=255.255.0.0
+eth0.serverip=192.168.0.8
+eth0.ethaddr=80:81:82:83:84:85
+
+board=edb9301
+autoboot_timeout=3
+active_cfg=1
+bootargs_common="console=ttyAM0,115200"
+
+# valid media: flash/net
+kernel_boot_media=flash
+rootfs_boot_media=flash
+
diff --git a/board/edb93xx/flash_cfg.c b/board/edb93xx/flash_cfg.c
new file mode 100644
index 0000000..91a6a4e
--- /dev/null
+++ b/board/edb93xx/flash_cfg.c
@@ -0,0 +1,38 @@
+/*
+ * Flash setup for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <mach/ep93xx-regs.h>
+#include <asm/io.h>
+
+#define SMC_BCR6_VALUE	(2 << SMC_BCR_IDCY_SHIFT | 5 << SMC_BCR_WST1_SHIFT | \
+				SMC_BCR_BLE | 2 << SMC_BCR_WST2_SHIFT | \
+				1 << SMC_BCR_MW_SHIFT)
+
+void flash_cfg(void)
+{
+	struct smc_regs *smc = (struct smc_regs *)SMC_BASE;
+
+	writel(SMC_BCR6_VALUE, &smc->bcr6);
+}
diff --git a/board/edb93xx/pll_cfg.c b/board/edb93xx/pll_cfg.c
new file mode 100644
index 0000000..a687af0
--- /dev/null
+++ b/board/edb93xx/pll_cfg.c
@@ -0,0 +1,58 @@
+/*
+ * PLL setup for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <common.h>
+#include <asm/io.h>
+#include "pll_cfg.h"
+#include "early_udelay.h"
+
+void pll_cfg(void)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+
+	/* setup PLL1 */
+	writel(CLKSET1_VAL, &syscon->clkset1);
+
+	/*
+	 * flush the pipeline
+	 * writing to CLKSET1 causes the EP93xx to enter standby for between
+	 * 8 ms to 16 ms, until PLL1 stabilizes
+	 */
+	asm("nop");
+	asm("nop");
+	asm("nop");
+	asm("nop");
+	asm("nop");
+
+	/* setup PLL2 */
+	writel(CLKSET2_VAL, &syscon->clkset2);
+
+	/*
+	 * the user's guide recommends to wait at least 1 ms for PLL2 to
+	 * stabilize
+	 */
+	early_udelay(1000);
+}
diff --git a/board/edb93xx/pll_cfg.h b/board/edb93xx/pll_cfg.h
new file mode 100644
index 0000000..9691339
--- /dev/null
+++ b/board/edb93xx/pll_cfg.h
@@ -0,0 +1,72 @@
+/*
+ * PLL register values for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <mach/ep93xx-regs.h>
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) || \
+	defined(CONFIG_MACH_EDB9302A)
+/*
+ * fclk_div: 2, nbyp1: 1, hclk_div: 5, pclk_div: 2
+ * pll1_x1: 294912000.000000, pll1_x2ip: 36864000.000000,
+ * pll1_x2: 331776000.000000, pll1_out: 331776000.000000
+ */
+#define CLKSET1_VAL	(7 << SYSCON_CLKSET_PLL_X2IPD_SHIFT |      \
+			8 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT |	   \
+			19 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT |	   \
+			1 << SYSCON_CLKSET1_PCLK_DIV_SHIFT |	   \
+			3 << SYSCON_CLKSET1_HCLK_DIV_SHIFT |	   \
+			SYSCON_CLKSET1_NBYP1 |			   \
+			1 << SYSCON_CLKSET1_FCLK_DIV_SHIFT)
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) ||\
+	defined CONFIG_MACH_EDB9312 || defined(CONFIG_MACH_EDB9315) ||\
+	defined(CONFIG_MACH_EDB9315A)
+/*
+ * fclk_div: 2, nbyp1: 1, hclk_div: 4, pclk_div: 2
+ * pll1_x1: 3096576000.000000, pll1_x2ip: 129024000.000000,
+ * pll1_x2: 3999744000.000000, pll1_out: 1999872000.000000
+ */
+#define CLKSET1_VAL	(23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+			30 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+			20 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+			1 << SYSCON_CLKSET1_PCLK_DIV_SHIFT |   \
+			2 << SYSCON_CLKSET1_HCLK_DIV_SHIFT |   \
+			SYSCON_CLKSET1_NBYP1 |		       \
+			1 << SYSCON_CLKSET1_FCLK_DIV_SHIFT)
+#else
+#error "Undefined board"
+#endif
+
+/*
+ * usb_div: 4, nbyp2: 1, pll2_en: 1
+ * pll2_x1: 368640000.000000, pll2_x2ip: 15360000.000000,
+ * pll2_x2: 384000000.000000, pll2_out: 192000000.000000
+ */
+#define CLKSET2_VAL	(23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+			24 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+			24 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+			1 << SYSCON_CLKSET_PLL_PS_SHIFT |      \
+			SYSCON_CLKSET2_PLL2_EN |	       \
+			SYSCON_CLKSET2_NBYP2 |		       \
+			3 << SYSCON_CLKSET2_USB_DIV_SHIFT)
diff --git a/board/edb93xx/sdram_cfg.c b/board/edb93xx/sdram_cfg.c
new file mode 100644
index 0000000..9f56f72
--- /dev/null
+++ b/board/edb93xx/sdram_cfg.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <common.h>
+#include <asm/io.h>
+#include "sdram_cfg.h"
+#include "early_udelay.h"
+
+#define PROGRAM_MODE_REG(bank)		(*(volatile uint32_t *)		\
+		(SDRAM_BASE_ADDR | SDRAM_BANK_SEL_##bank | SDRAM_MODE_REG_VAL))
+
+#define PRECHARGE_BANK(bank)		(*(volatile uint32_t *)	\
+				(SDRAM_BASE_ADDR | SDRAM_BANK_SEL_##bank))
+
+static void force_precharge(void);
+static void setup_refresh_timer(void);
+static void program_mode_registers(void);
+
+void sdram_cfg(void)
+{
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	writel(SDRAM_DEVCFG_VAL, &sdram->SDRAM_DEVCFG_REG);
+
+	/* Issue continous NOP commands */
+	writel(GLCONFIG_INIT | GLCONFIG_MRS | GLCONFIG_CKE, &sdram->glconfig);
+
+	early_udelay(200);
+
+	force_precharge();
+
+	setup_refresh_timer();
+
+	program_mode_registers();
+
+	/* Select normal operation mode */
+	writel(GLCONFIG_CKE, &sdram->glconfig);
+}
+
+static void force_precharge(void)
+{
+	/*
+	 * Errata most EP93xx revisions say that PRECHARGE ALL isn't always
+	 * issued.
+	 *
+	 * Do a read from each bank to make sure they're precharged
+	 */
+
+	PRECHARGE_BANK(0);
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	PRECHARGE_BANK(1);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	PRECHARGE_BANK(2);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	PRECHARGE_BANK(3);
+#endif
+}
+
+static void setup_refresh_timer(void)
+{
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	/* Load refresh timer with 10 to issue refresh every 10 cycles */
+	writel(0x0a, &sdram->refrshtimr);
+
+	/*
+	 * Wait at least 80 clock cycles to provide 8 refresh cycles
+	 * to all SDRAMs
+	 */
+	early_udelay(1);
+
+	/*
+	 * Program refresh timer with normal value
+	 * We need 8192 refresh cycles every 64ms
+	 * at 15ns (HCLK >= 66MHz) per cycle:
+	 * 64ms / 8192 = 7.8125us
+	 * 7.8125us / 15ns = 520 (0x208)
+	 */
+	/*
+	 * TODO: redboot uses 0x1e0 for the slowest possible device
+	 * but i don't understand how this value is calculated
+	 */
+	writel(0x208, &sdram->refrshtimr);
+}
+
+static void program_mode_registers(void)
+{
+	PROGRAM_MODE_REG(0);
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	PROGRAM_MODE_REG(1);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	PROGRAM_MODE_REG(2);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	PROGRAM_MODE_REG(3);
+#endif
+}
diff --git a/board/edb93xx/sdram_cfg.h b/board/edb93xx/sdram_cfg.h
new file mode 100644
index 0000000..7babee8
--- /dev/null
+++ b/board/edb93xx/sdram_cfg.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <mach/ep93xx-regs.h>
+
+#define SDRAM_BASE_ADDR		CONFIG_EP93XX_SDRAM_BANK0_BASE
+
+#ifdef CONFIG_EP93XX_SDCE0_PHYS_OFFSET
+#define SDRAM_DEVCFG_REG	devcfg0
+#elif defined(CONFIG_EP93XX_SDCE3_SYNC_PHYS_OFFSET)
+#define SDRAM_DEVCFG_REG	devcfg3
+#else
+#error "SDRAM bank configuration"
+#endif
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) ||\
+	defined(CONFIG_MACH_EDB9302A)
+/*
+ * 1x Samsung K4S561632C-TC/L75 4M x 16bit x 4 banks SDRAM
+ *
+ * CLK cycle time min:
+ *	@ CAS latency = 3: 7.5ns
+ *	@ CAS latency = 2: 10ns
+ * We're running at 66MHz (15ns cycle time) external bus speed (HCLK),
+ * so it's safe to use CAS latency = 2
+ *
+ * RAS-to-CAS delay min:
+ *	20ns
+ * At 15ns cycle time, we use RAS-to-CAS delay = 2
+ *
+ * SROMLL = 1: Swap BA[1:0] with A[13:12], making the SDRAM appear
+ * as four blocks of 8MB size, instead of eight blocks of 4MB size:
+ *
+ * EDB9301/EDB9302:
+ *
+ * 0x00000000 - 0x007fffff
+ * 0x01000000 - 0x017fffff
+ * 0x04000000 - 0x047fffff
+ * 0x05000000 - 0x057fffff
+ *
+ *
+ * EDB9302a:
+ *
+ * 0xc0000000 - 0xc07fffff
+ * 0xc1000000 - 0xc17fffff
+ * 0xc4000000 - 0xc47fffff
+ * 0xc5000000 - 0xc57fffff
+ *
+ * BANKCOUNT = 1: This is a device with four banks
+ */
+
+#define SDRAM_DEVCFG_VAL (SDRAM_DEVCFG_BANKCOUNT |			\
+				SDRAM_DEVCFG_SROMLL |			\
+				SDRAM_DEVCFG_CASLAT_2 |			\
+				SDRAM_DEVCFG_RASTOCAS_2 |		\
+				SDRAM_DEVCFG_EXTBUSWIDTH)
+
+/*
+ * 16 bit ext. bus
+ *
+ * A[22:09] is output as SYA[13:0]
+ * CAS latency: 2
+ * Burst type: sequential
+ * Burst length: 8 (required for 16 bit ext. bus)
+ * SYA[13:0] = 0x0023
+ */
+#define SDRAM_MODE_REG_VAL	0x4600
+
+#define SDRAM_BANK_SEL_0	0x00000000 /* A[22:21] = b00 */
+#define SDRAM_BANK_SEL_1	0x00200000 /* A[22:21] = b01 */
+#define SDRAM_BANK_SEL_2	0x00400000 /* A[22:21] = b10 */
+#define SDRAM_BANK_SEL_3	0x00600000 /* A[22:21] = b11 */
+
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) ||\
+	defined CONFIG_MACH_EDB9312 || defined(CONFIG_MACH_EDB9315) ||\
+	defined(CONFIG_MACH_EDB9315A)
+/*
+ * 2x Samsung K4S561632C-TC/L75 4M x 16bit x 4 banks SDRAM
+ *
+ * CLK cycle time min:
+ *	@ CAS latency = 3: 7.5ns
+ *	@ CAS latency = 2: 10ns
+ * We're running at 100MHz (10ns cycle time) external bus speed (HCLK),
+ * so it's safe to use CAS latency = 2
+ *
+ * RAS-to-CAS delay min:
+ *	20ns
+ * At 10ns cycle time, we use RAS-to-CAS delay = 2
+ *
+ * EDB9307, EDB9312, EDB9315:
+ *
+ * 0x00000000 - 0x01ffffff
+ * 0x04000000 - 0x05ffffff
+ *
+ *
+ * EDB9307a, EDB9315a:
+ *
+ * 0xc0000000 - 0xc1ffffff
+ * 0xc4000000 - 0xc5ffffff
+ */
+
+#define SDRAM_DEVCFG_VAL	(SDRAM_DEVCFG_BANKCOUNT |		\
+				SDRAM_DEVCFG_SROMLL |			\
+				SDRAM_DEVCFG_CASLAT_2 |			\
+				SDRAM_DEVCFG_RASTOCAS_2)
+
+/*
+ * 32 bit ext. bus
+ *
+ * A[23:10] is output as SYA[13:0]
+ * CAS latency: 2
+ * Burst type: sequential
+ * Burst length: 4
+ * SYA[13:0] = 0x0022
+ */
+#define SDRAM_MODE_REG_VAL	0x8800
+
+#define SDRAM_BANK_SEL_0	0x00000000 /* A[23:22] = b00 */
+#define SDRAM_BANK_SEL_1	0x00400000 /* A[23:22] = b01 */
+#define SDRAM_BANK_SEL_2	0x00800000 /* A[23:22] = b10 */
+#define SDRAM_BANK_SEL_3	0x00c00000 /* A[23:22] = b11 */
+#endif
-- 
1.6.3.1



From s.hauer at pengutronix.de  Tue Jan 12 04:52:33 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 12 Jan 2010 10:52:33 +0100
Subject: [PATCH] Add support for EDB93xx boards [rev2]
In-Reply-To: <20100111213112.GJ14051@darwin>
References: <20100109232838.GB14051@darwin>
	<20100111094902.GR6923@pengutronix.de>
	<20100111103700.GH14051@darwin>
	<20100111112557.GU6923@pengutronix.de>
	<20100111213112.GJ14051@darwin>
Message-ID: <20100112095233.GD6923@pengutronix.de>

Hi Matthias,

On Mon, Jan 11, 2010 at 10:31:12PM +0100, Matthias Kaehlcke wrote:
> diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
> index 139b08d..ed6e986 100644
> --- a/arch/arm/mach-ep93xx/Kconfig
> +++ b/arch/arm/mach-ep93xx/Kconfig
> @@ -39,7 +39,6 @@ config MACH_EDB9301
>  	bool "Cirrus Logic EDB9301"
>  	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
>  	select MACH_HAS_LOWLEVEL_INIT
> -	select BOARD_LINKER_SCRIPT
>  	help

Something went wrong here, this seems to be a fixup patch, at least
these hunks.
The rest of the patches is ok now. Can you please resend the whole
series? It's easier to apply when it's clear that the original messages
are the patches than to dig through the thread and look for patches in
replies.

Thanks
  Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From jbe at pengutronix.de  Tue Jan 12 05:15:34 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:34 +0100
Subject: [PATCHv2 00/14] Bring in basic x86 support into 'barebox'
Message-ID: <20100112101534.868276907@pengutronix.de>

This patch series brings in some basic x86 support into the tree.
At first this support can act as a boot loader on a BIOS based
x86 machine like GRUB is. E.g. barebox will be stored in the MBR of
a boot media the BIOS supports to boot from. This implementation still
talks to the BIOS in real mode, to load or store data from/to a disk
drive, but the barebox core itself runs in 32 bit flat mode.

Currently only a serial console is supported.

v2 of this patch series comes with some clean ups and also uses the discussed
naming convention for BIOS based disk access. The whole series is updated to
'barebox' (instead of u-boot-v2). Note: Its tested only with QEMU yet. We are
going to port it to real hardware now.

Comments are welcome.

jbe



From jbe at pengutronix.de  Tue Jan 12 05:15:36 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:36 +0100
Subject: [PATCHv2 02/14] Consider real and protected mode in the dump file
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102053.993635547@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: consider_code_type.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/14b80320/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:43 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:43 +0100
Subject: [PATCHv2 09/14] Bring in the time reference for the x86 platforms
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102055.221848267@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_timer.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/49270ccb/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:39 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:39 +0100
Subject: [PATCHv2 05/14] Bring in the first x86 specific code
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102054.503300176@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_mach_code.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/3d02feec/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:37 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:37 +0100
Subject: [PATCHv2 03/14] Adding x86 usage documentation to the tree
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102054.163194713@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_x86_documentation.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/d1e7b543/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:48 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:48 +0100
Subject: [PATCHv2 14/14] Add the whole x86 architecture to the build system
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102056.083255566@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_x86_architecture.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/897ad563/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:46 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:46 +0100
Subject: [PATCHv2 12/14] Add a low level disk drive access driver
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102055.772999146@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_bios_disk-driver.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/dab7f9e7/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:45 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:45 +0100
Subject: [PATCHv2 11/14] Add the main disk driver
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102055.560775020@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_ata_disk.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/d21b429f/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:42 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:42 +0100
Subject: [PATCHv2 08/14] Add a generic PC platform
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102055.014154409@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_generic_platform.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/f13206b1/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:40 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:40 +0100
Subject: [PATCHv2 06/14] Add some generic functions to make x86 work
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102054.672384188@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_lib_code.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/3557f0c6/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:38 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:38 +0100
Subject: [PATCHv2 04/14] Adding required architecture header files
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102054.332735890@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: x86_headers.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/9c4608dc/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:47 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:47 +0100
Subject: [PATCHv2 13/14] Add a special command to load and start a bzImage on
	x86
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102055.910948506@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_linux16_command.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/62e2fbe0/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:35 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:35 +0100
Subject: [PATCHv2 01/14] Add a tool to activate barebox as a boot loader on
	x86 architectures
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102053.822036694@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_install_tool.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/78f53175/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:44 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:44 +0100
Subject: [PATCHv2 10/14] Start to add ATA support to barebox
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102055.391035883@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: ata_devices.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/9fe38413/attachment.el>

From jbe at pengutronix.de  Tue Jan 12 05:15:41 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Tue, 12 Jan 2010 11:15:41 +0100
Subject: [PATCHv2 07/14] Add functions to be able to boot with BIOSs help
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100112102054.844290281@pengutronix.de>

An embedded and charset-unspecified text was scrubbed...
Name: add_boot_code.diff
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100112/11e25eba/attachment.el>

From matthias at kaehlcke.net  Tue Jan 12 14:30:19 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Tue, 12 Jan 2010 20:30:19 +0100
Subject: [PATCH] Add support for EDB93xx boards [rev2]
In-Reply-To: <20100112095233.GD6923@pengutronix.de>
References: <20100109232838.GB14051@darwin>
	<20100111094902.GR6923@pengutronix.de>
	<20100111103700.GH14051@darwin>
	<20100111112557.GU6923@pengutronix.de>
	<20100111213112.GJ14051@darwin>
	<20100112095233.GD6923@pengutronix.de>
Message-ID: <20100112193019.GK14051@darwin>

Hi Sascha,

El Tue, Jan 12, 2010 at 10:52:33AM +0100 Sascha Hauer ha dit:

> On Mon, Jan 11, 2010 at 10:31:12PM +0100, Matthias Kaehlcke wrote:
> > diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
> > index 139b08d..ed6e986 100644
> > --- a/arch/arm/mach-ep93xx/Kconfig
> > +++ b/arch/arm/mach-ep93xx/Kconfig
> > @@ -39,7 +39,6 @@ config MACH_EDB9301
> >  	bool "Cirrus Logic EDB9301"
> >  	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
> >  	select MACH_HAS_LOWLEVEL_INIT
> > -	select BOARD_LINKER_SCRIPT
> >  	help
> 
> Something went wrong here, this seems to be a fixup patch, at least
> these hunks.

sorry, i added applied these changes to the wrong patch of the set

> The rest of the patches is ok now. Can you please resend the whole
> series? It's easier to apply when it's clear that the original messages
> are the patches than to dig through the thread and look for patches in
> replies.

sure, and thanks for pointing me to the right way to send revisions of
a patch

-- 
Matthias Kaehlcke
Embedded Linux Developer
Barcelona

    Ma patrie est o? je suis, o? personne ne me d?range, o? personne
    ne me demande que je suis, d'o? je viens et ce que je fais
                              (B. Traven)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-


From matthias at kaehlcke.net  Tue Jan 12 14:30:30 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Tue, 12 Jan 2010 20:30:30 +0100
Subject: [PATCH 0/5] Add support for EDB93xx boards [rev2]
Message-ID: <20100112193030.GL14051@darwin>

Add support for the following Cirrus Logic EDB93xx boards:

EDB9301
EDB9302
EDB9302A
EDB9307
EDB9307A
EDB93012
EDB9315
EDB9315A

This patchset has been tested on boards based on the EDB9301 and
EDB9307A designs

Changes with respect to rev1:

 * use global linker script with EP93xx specific ifdef instead of a
   board specific one
 * eth driver: remove TODO comments about impossible enhancements
 * eth driver: remove MII_STATUS_* and ETH_STATUS_* macros

Matthias Kaehlcke (5):
  ARM: Add support for EP93xx SoCs
  Add EP93xx ethernet driver
  Add support for EP9xx GPIOs
  Add PrimeCell PL010 serial driver
  Add support for EDB93xx boards

 Documentation/boards.dox                        |    8 +
 arch/arm/Kconfig                                |    6 +
 arch/arm/Makefile                               |    9 +
 arch/arm/configs/edb93xx_defconfig              |  236 ++++++++
 arch/arm/lib/barebox.lds.S                      |    5 +
 arch/arm/mach-ep93xx/Kconfig                    |  438 +++++++++++++++
 arch/arm/mach-ep93xx/Makefile                   |    3 +
 arch/arm/mach-ep93xx/clocksource.c              |   96 ++++
 arch/arm/mach-ep93xx/gpio.c                     |  136 +++++
 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |  600 ++++++++++++++++++++
 arch/arm/mach-ep93xx/include/mach/gpio.h        |   29 +
 arch/arm/mach-ep93xx/led.c                      |   62 ++
 arch/arm/mach-ep93xx/led.h                      |   26 +
 arch/arm/mach-ep93xx/lowlevel_init.S            |   64 +++
 board/edb93xx/Makefile                          |    2 +
 board/edb93xx/config.h                          |    4 +
 board/edb93xx/early_udelay.h                    |   34 ++
 board/edb93xx/edb93xx.c                         |  172 ++++++
 board/edb93xx/edb93xx.dox                       |  108 ++++
 board/edb93xx/edb93xx.h                         |   48 ++
 board/edb93xx/env/bin/boot                      |   48 ++
 board/edb93xx/env/bin/flash_partition           |   22 +
 board/edb93xx/env/bin/init                      |   19 +
 board/edb93xx/env/bin/set_nor_parts             |    3 +
 board/edb93xx/env/bin/update_kernel             |   16 +
 board/edb93xx/env/bin/update_rootfs             |   16 +
 board/edb93xx/env/config                        |   16 +
 board/edb93xx/flash_cfg.c                       |   38 ++
 board/edb93xx/pll_cfg.c                         |   58 ++
 board/edb93xx/pll_cfg.h                         |   72 +++
 board/edb93xx/sdram_cfg.c                       |  127 +++++
 board/edb93xx/sdram_cfg.h                       |  144 +++++
 drivers/net/Kconfig                             |    5 +
 drivers/net/Makefile                            |    1 +
 drivers/net/ep93xx.c                            |  676 +++++++++++++++++++++++
 drivers/net/ep93xx.h                            |  147 +++++
 drivers/serial/Kconfig                          |    7 +
 drivers/serial/Makefile                         |    2 +-
 drivers/serial/serial_pl010.c                   |  172 ++++++
 drivers/serial/serial_pl010.h                   |  100 ++++
 include/common.h                                |    1 +
 41 files changed, 3775 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/configs/edb93xx_defconfig
 create mode 100644 arch/arm/mach-ep93xx/Kconfig
 create mode 100644 arch/arm/mach-ep93xx/Makefile
 create mode 100644 arch/arm/mach-ep93xx/clocksource.c
 create mode 100644 arch/arm/mach-ep93xx/gpio.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
 create mode 100644 arch/arm/mach-ep93xx/include/mach/gpio.h
 create mode 100644 arch/arm/mach-ep93xx/led.c
 create mode 100644 arch/arm/mach-ep93xx/led.h
 create mode 100644 arch/arm/mach-ep93xx/lowlevel_init.S
 create mode 100644 board/edb93xx/Makefile
 create mode 100644 board/edb93xx/config.h
 create mode 100644 board/edb93xx/early_udelay.h
 create mode 100644 board/edb93xx/edb93xx.c
 create mode 100644 board/edb93xx/edb93xx.dox
 create mode 100644 board/edb93xx/edb93xx.h
 create mode 100644 board/edb93xx/env/bin/boot
 create mode 100644 board/edb93xx/env/bin/flash_partition
 create mode 100644 board/edb93xx/env/bin/init
 create mode 100644 board/edb93xx/env/bin/set_nor_parts
 create mode 100644 board/edb93xx/env/bin/update_kernel
 create mode 100644 board/edb93xx/env/bin/update_rootfs
 create mode 100644 board/edb93xx/env/config
 create mode 100644 board/edb93xx/flash_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.h
 create mode 100644 board/edb93xx/sdram_cfg.c
 create mode 100644 board/edb93xx/sdram_cfg.h
 create mode 100644 drivers/net/ep93xx.c
 create mode 100644 drivers/net/ep93xx.h
 create mode 100644 drivers/serial/serial_pl010.c
 create mode 100644 drivers/serial/serial_pl010.h



From matthias at kaehlcke.net  Tue Jan 12 14:30:36 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Tue, 12 Jan 2010 20:30:36 +0100
Subject: [PATCH 1/5] ARM: Add support for EP93xx SoCs
Message-ID: <20100112193036.GM14051@darwin>

Add support for the Cirrus Logic EP93xx platform

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 arch/arm/Kconfig                                |    5 +
 arch/arm/Makefile                               |    9 +
 arch/arm/lib/barebox.lds.S                      |    5 +
 arch/arm/mach-ep93xx/Kconfig                    |  438 +++++++++++++++++
 arch/arm/mach-ep93xx/Makefile                   |    3 +
 arch/arm/mach-ep93xx/clocksource.c              |   96 ++++
 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |  600 +++++++++++++++++++++++
 arch/arm/mach-ep93xx/led.c                      |   62 +++
 arch/arm/mach-ep93xx/led.h                      |   26 +
 arch/arm/mach-ep93xx/lowlevel_init.S            |   64 +++
 10 files changed, 1308 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/Kconfig
 create mode 100644 arch/arm/mach-ep93xx/Makefile
 create mode 100644 arch/arm/mach-ep93xx/clocksource.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
 create mode 100644 arch/arm/mach-ep93xx/led.c
 create mode 100644 arch/arm/mach-ep93xx/led.h
 create mode 100644 arch/arm/mach-ep93xx/lowlevel_init.S

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c091a99..414a013 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -31,6 +31,10 @@ config ARCH_AT91RM9200
 	bool "Atmel AT91RM9200"
 	select CPU_ARM920T
 
+config ARCH_EP93XX
+	bool "Cirrus Logic EP93xx"
+	select CPU_ARM920T
+
 config ARCH_IMX
 	bool "Freescale iMX-based"
 	select GENERIC_GPIO
@@ -51,6 +55,7 @@ endchoice
 source arch/arm/cpu/Kconfig
 source arch/arm/mach-at91/Kconfig
 source arch/arm/mach-at91rm9200/Kconfig
+source arch/arm/mach-ep93xx/Kconfig
 source arch/arm/mach-imx/Kconfig
 source arch/arm/mach-netx/Kconfig
 source arch/arm/mach-omap/Kconfig
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 47b002f..ede2085 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -39,6 +39,7 @@ CPPFLAGS += $(CFLAGS_ABI) $(arch-y) $(tune-y)
 # by CONFIG_* macro name.
 machine-$(CONFIG_ARCH_AT91)		:= at91
 machine-$(CONFIG_ARCH_AT91RM9200)	:= at91rm9200
+machine-$(CONFIG_ARCH_EP93XX)		:= ep93xx
 machine-$(CONFIG_ARCH_IMX)		:= imx
 machine-$(CONFIG_ARCH_NETX)		:= netx
 machine-$(CONFIG_ARCH_OMAP)		:= omap
@@ -51,6 +52,14 @@ board-$(CONFIG_MACH_A9M2440)			:= a9m2440
 board-$(CONFIG_MACH_AT91SAM9260EK)		:= at91sam9260ek
 board-$(CONFIG_MACH_AT91SAM9263EK)		:= at91sam9263ek
 board-$(CONFIG_MACH_ECO920)			:= eco920
+board-$(CONFIG_MACH_EDB9301)			:= edb93xx
+board-$(CONFIG_MACH_EDB9302)			:= edb93xx
+board-$(CONFIG_MACH_EDB9302A)			:= edb93xx
+board-$(CONFIG_MACH_EDB9307)			:= edb93xx
+board-$(CONFIG_MACH_EDB9307A)			:= edb93xx
+board-$(CONFIG_MACH_EDB93012)			:= edb93xx
+board-$(CONFIG_MACH_EDB9315)			:= edb93xx
+board-$(CONFIG_MACH_EDB9315A)			:= edb93xx
 board-$(CONFIG_MACH_EUKREA_CPUIMX27)		:= eukrea_cpuimx27
 board-$(CONFIG_MACH_FREESCALE_MX35_3STACK)	:= freescale-mx35-3-stack
 board-$(CONFIG_MACH_FREESCALE_MX25_3STACK)	:= freescale-mx25-3-stack
diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index c8d1bb9..a5eaefa 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -39,6 +39,11 @@ SECTIONS
 		_stext = .;
 		_text = .;
 		*(.text_entry*)
+#ifdef CONFIG_ARCH_EP93XX
+		/* the EP93xx expects to find the pattern 'CRUS' at 0x1000 */
+	  . = 0x1000;
+	  LONG(0x53555243) /* 'CRUS' */
+#endif
 		*(.text_bare_init*)
 		*(.text*)
 	}
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
new file mode 100644
index 0000000..ed6e986
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -0,0 +1,438 @@
+if ARCH_EP93XX
+
+config EP93XX_SDCE0_PHYS_OFFSET
+	bool
+
+config EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	bool
+
+comment "Cirrus EP93xx System-on-Chip"
+
+choice
+	prompt "Cirrus Logic EP93XX Processor"
+
+config ARCH_EP9301
+	bool "EP9301"
+
+config ARCH_EP9302
+	bool "EP9302"
+
+config ARCH_EP9307
+	bool "EP9307"
+
+config ARCH_EP9312
+	bool "EP9312"
+
+config ARCH_EP9315
+	bool "EP9315"
+
+endchoice
+
+# ----------------------------------------------------------
+
+if ARCH_EP9301
+
+choice
+	prompt "EP9301 Board Type"
+
+config MACH_EDB9301
+	bool "Cirrus Logic EDB9301"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9301 Evaluation board
+
+endchoice
+
+if MACH_EDB9301
+
+config BOARDINFO
+	default "Cirrus Logic EDB9301"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x05700000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 4
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x01000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK2_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK2_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK3_BASE
+	hex
+	default 0x05000000
+
+config EP93XX_SDRAM_BANK3_SIZE
+	hex
+	default 0x00800000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9302
+
+choice
+	prompt "EP9302 Board Type"
+
+config MACH_EDB9302
+	bool "Cirrus Logic EDB9302"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9302 Evaluation board
+
+config MACH_EDB9302A
+	bool "Cirrus Logic EDB9302A"
+	select EP93XX_SDCE0_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9302A Evaluation board
+
+endchoice
+
+if MACH_EDB9302
+
+config BOARDINFO
+	default "Cirrus Logic EDB9302"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x05700000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 4
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x01000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK2_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK2_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK3_BASE
+	hex
+	default 0x05000000
+
+config EP93XX_SDRAM_BANK3_SIZE
+	hex
+	default 0x00800000
+
+endif
+
+if MACH_EDB9302A
+
+config BOARDINFO
+	default "Cirrus Logic EDB9302A"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0xc5700000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 4
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0xc0000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0xc1000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK2_BASE
+	hex
+	default 0xc4000000
+
+config EP93XX_SDRAM_BANK2_SIZE
+	hex
+	default 0x00800000
+
+config EP93XX_SDRAM_BANK3_BASE
+	hex
+	default 0xc5000000
+
+config EP93XX_SDRAM_BANK3_SIZE
+	hex
+	default 0x00800000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9307
+
+choice
+	prompt "EP9307 Board Type"
+
+config MACH_EDB9307
+	bool "Cirrus Logic EDB9307"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9307 Evaluation board
+
+config MACH_EDB9307A
+	bool "Cirrus Logic EDB9307A"
+	select EP93XX_SDCE0_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9307A Evaluation board
+
+endchoice
+
+if MACH_EDB9307
+
+config BOARDINFO
+	default "Cirrus Logic EDB9307"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x01f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+if MACH_EDB9307A
+
+config BOARDINFO
+	default "Cirrus Logic EDB9307A"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0xc1f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0xc0000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0xc4000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9312
+
+choice
+	prompt "EP9312 Board Type"
+
+config MACH_EDB9312
+	bool "Cirrus Logic EDB9312"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9312 Evaluation board
+
+endchoice
+
+if MACH_EDB9312
+
+config BOARDINFO
+	default "Cirrus Logic EDB9312"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x01f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+endif
+
+# ----------------------------------------------------------
+
+if ARCH_EP9315
+
+choice
+	prompt "EP9315 Board Type"
+
+config MACH_EDB9315
+	bool "Cirrus Logic EDB9315"
+	select EP93XX_SDCE3_SYNC_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9315 Evaluation board
+
+config MACH_EDB9315A
+	bool "Cirrus Logic EDB9315A"
+	select EP93XX_SDCE0_PHYS_OFFSET
+	select MACH_HAS_LOWLEVEL_INIT
+	help
+	  Say y here if you are using Cirrus Logic's EDB9315A Evaluation board
+
+endchoice
+
+if MACH_EDB9315
+
+config BOARDINFO
+	default "Cirrus Logic EDB9315"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0x01f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0x00000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0x04000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+if MACH_EDB9315A
+
+config BOARDINFO
+	default "Cirrus Logic EDB9315A"
+
+config ARCH_TEXT_BASE
+	hex
+	default 0xc1f00000
+
+config EP93XX_SDRAM_NUM_BANKS
+	int
+	default 2
+
+config EP93XX_SDRAM_BANK0_BASE
+	hex
+	default 0xc0000000
+
+config EP93XX_SDRAM_BANK0_SIZE
+	hex
+	default 0x02000000
+
+config EP93XX_SDRAM_BANK1_BASE
+	hex
+	default 0xc4000000
+
+config EP93XX_SDRAM_BANK1_SIZE
+	hex
+	default 0x02000000
+
+endif
+
+endif
+
+endif
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
new file mode 100644
index 0000000..d5786db
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -0,0 +1,3 @@
+obj-y += clocksource.o led.o
+
+obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o
diff --git a/arch/arm/mach-ep93xx/clocksource.c b/arch/arm/mach-ep93xx/clocksource.c
new file mode 100644
index 0000000..2a7d90e
--- /dev/null
+++ b/arch/arm/mach-ep93xx/clocksource.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <init.h>
+#include <clock.h>
+#include <asm/io.h>
+#include <mach/ep93xx-regs.h>
+
+#define TIMER_CLKSEL		(1 << 3)
+#define TIMER_MODE		(1 << 6)
+#define TIMER_ENABLE		(1 << 7)
+
+#define TIMER_FREQ		508469
+
+static uint64_t ep93xx_clocksource_read(void)
+{
+	struct timer_regs *timer = (struct timer_regs *)TIMER_BASE;
+
+	return 0xffffffff - readl(&timer->timer3.value);
+}
+
+static struct clocksource cs = {
+	.read	= ep93xx_clocksource_read,
+	.mask	= 0xffffffff,
+	.shift	= 10,
+};
+
+static int clocksource_init(void)
+{
+	struct timer_regs *timer = (struct timer_regs *)TIMER_BASE;
+
+	/* use timer 3 with 508KHz and free running */
+	writel(TIMER_CLKSEL,
+	       &timer->timer3.control);
+
+	/* load timer 3 with max value */
+	writel(0xffffffff, &timer->timer3.load);
+
+	/* enable timer 3 with 508KHz and periodic mode */
+	writel(TIMER_ENABLE | TIMER_MODE | TIMER_CLKSEL,
+	       &timer->timer3.control);
+
+	cs.mult = clocksource_hz2mult(TIMER_FREQ, cs.shift);
+
+	init_clock(&cs);
+
+	return 0;
+}
+
+core_initcall(clocksource_init);
+
+/*
+ * Reset the cpu
+ */
+void reset_cpu(ulong ignored)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+	uint32_t value;
+
+	/* Unlock DeviceCfg and set SWRST */
+	writel(0xAA, &syscon->sysswlock);
+	value = readl(&syscon->devicecfg);
+	value |= SYSCON_DEVICECFG_SWRST;
+	writel(value, &syscon->devicecfg);
+
+	/* Unlock DeviceCfg and clear SWRST */
+	writel(0xAA, &syscon->sysswlock);
+	value = readl(&syscon->devicecfg);
+	value &= ~SYSCON_DEVICECFG_SWRST;
+	writel(value, &syscon->devicecfg);
+
+	/* Dying... */
+	while (1)
+		; /* noop */
+}
+EXPORT_SYMBOL(reset_cpu);
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
new file mode 100644
index 0000000..50bb0eb
--- /dev/null
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -0,0 +1,600 @@
+/* -----------------------------------------------------------------------------
+ * Cirrus Logic EP93xx register definitions.
+ *
+ * Copyright (C) 2009
+ * Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006
+ * Dominic Rath <Dominic.Rath at gmx.de>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.com>
+ *
+ * Based in large part on linux/include/asm-arm/arch-ep93xx/regmap.h, which is
+ *
+ * Copyright (C) 2004 Ray Lehtiniemi
+ * Copyright (C) 2003 Cirrus Logic, Inc
+ * Copyright (C) 1999 ARM Limited.
+ *
+ * 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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#endif
+
+#define EP93XX_AHB_BASE			0x80000000
+#define EP93XX_APB_BASE			0x80800000
+
+/* -----------------------------------------------------------------------------
+ * 0x80000000 - 0x8000FFFF: DMA
+ */
+#define DMA_OFFSET			0x000000
+#define DMA_BASE			(EP93XX_AHB_BASE | DMA_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct dma_channel {
+	uint32_t control;
+	uint32_t interrupt;
+	uint32_t ppalloc;
+	uint32_t status;
+	uint32_t reserved0;
+	uint32_t remain;
+	uint32_t reserved1[2];
+	uint32_t maxcnt0;
+	uint32_t base0;
+	uint32_t current0;
+	uint32_t reserved2;
+	uint32_t maxcnt1;
+	uint32_t base1;
+	uint32_t current1;
+	uint32_t reserved3;
+};
+
+struct dma_regs {
+	struct dma_channel m2p_channel_0;
+	struct dma_channel m2p_channel_1;
+	struct dma_channel m2p_channel_2;
+	struct dma_channel m2p_channel_3;
+	struct dma_channel m2m_channel_0;
+	struct dma_channel m2m_channel_1;
+	struct dma_channel reserved0[2];
+	struct dma_channel m2p_channel_5;
+	struct dma_channel m2p_channel_4;
+	struct dma_channel m2p_channel_7;
+	struct dma_channel m2p_channel_6;
+	struct dma_channel m2p_channel_9;
+	struct dma_channel m2p_channel_8;
+	uint32_t channel_arbitration;
+	uint32_t reserved[15];
+	uint32_t global_interrupt;
+};
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80010000 - 0x8001FFFF: Ethernet MAC
+ */
+#define MAC_OFFSET			0x010000
+#define MAC_BASE			(EP93XX_AHB_BASE | MAC_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct mac_queue {
+	uint32_t badd;
+	union { /* deal with half-word aligned registers */
+		uint32_t blen;
+		union {
+			uint16_t filler;
+			uint16_t curlen;
+		};
+	};
+	uint32_t curadd;
+};
+
+struct mac_regs {
+	uint32_t rxctl;
+	uint32_t txctl;
+	uint32_t testctl;
+	uint32_t reserved0;
+	uint32_t miicmd;
+	uint32_t miidata;
+	uint32_t miists;
+	uint32_t reserved1;
+	uint32_t selfctl;
+	uint32_t inten;
+	uint32_t intstsp;
+	uint32_t intstsc;
+	uint32_t reserved2[2];
+	uint32_t diagad;
+	uint32_t diagdata;
+	uint32_t gt;
+	uint32_t fct;
+	uint32_t fcf;
+	uint32_t afp;
+	union {
+		struct {
+			uint32_t indad;
+			uint32_t indad_upper;
+		};
+		uint32_t hashtbl;
+	};
+	uint32_t reserved3[2];
+	uint32_t giintsts;
+	uint32_t giintmsk;
+	uint32_t giintrosts;
+	uint32_t giintfrc;
+	uint32_t txcollcnt;
+	uint32_t rxmissnct;
+	uint32_t rxruntcnt;
+	uint32_t reserved4;
+	uint32_t bmctl;
+	uint32_t bmsts;
+	uint32_t rxbca;
+	uint32_t reserved5;
+	struct mac_queue rxdq;
+	uint32_t rxdqenq;
+	struct mac_queue rxstsq;
+	uint32_t rxstsqenq;
+	struct mac_queue txdq;
+	uint32_t txdqenq;
+	struct mac_queue txstsq;
+	uint32_t reserved6;
+	uint32_t rxbufthrshld;
+	uint32_t txbufthrshld;
+	uint32_t rxststhrshld;
+	uint32_t txststhrshld;
+	uint32_t rxdthrshld;
+	uint32_t txdthrshld;
+	uint32_t maxfrmlen;
+	uint32_t maxhdrlen;
+};
+#endif
+
+#define SELFCTL_RWP		(1 << 7)
+#define SELFCTL_GPO0		(1 << 5)
+#define SELFCTL_PUWE		(1 << 4)
+#define SELFCTL_PDWE		(1 << 3)
+#define SELFCTL_MIIL		(1 << 2)
+#define SELFCTL_RESET		(1 << 0)
+
+#define INTSTS_RWI		(1 << 30)
+#define INTSTS_RXMI		(1 << 29)
+#define INTSTS_RXBI		(1 << 28)
+#define INTSTS_RXSQI		(1 << 27)
+#define INTSTS_TXLEI		(1 << 26)
+#define INTSTS_ECIE		(1 << 25)
+#define INTSTS_TXUHI		(1 << 24)
+#define INTSTS_MOI		(1 << 18)
+#define INTSTS_TXCOI		(1 << 17)
+#define INTSTS_RXROI		(1 << 16)
+#define INTSTS_MIII		(1 << 12)
+#define INTSTS_PHYI		(1 << 11)
+#define INTSTS_TI		(1 << 10)
+#define INTSTS_AHBE		(1 << 8)
+#define INTSTS_OTHER		(1 << 4)
+#define INTSTS_TXSQ		(1 << 3)
+#define INTSTS_RXSQ		(1 << 2)
+
+#define BMCTL_MT		(1 << 13)
+#define BMCTL_TT		(1 << 12)
+#define BMCTL_UNH		(1 << 11)
+#define BMCTL_TXCHR		(1 << 10)
+#define BMCTL_TXDIS		(1 << 9)
+#define BMCTL_TXEN		(1 << 8)
+#define BMCTL_EH2		(1 << 6)
+#define BMCTL_EH1		(1 << 5)
+#define BMCTL_EEOB		(1 << 4)
+#define BMCTL_RXCHR		(1 << 2)
+#define BMCTL_RXDIS		(1 << 1)
+#define BMCTL_RXEN		(1 << 0)
+
+#define BMSTS_TXACT		(1 << 7)
+#define BMSTS_TP		(1 << 4)
+#define BMSTS_RXACT		(1 << 3)
+#define BMSTS_QID_MASK		0x07
+#define BMSTS_QID_RXDATA	0x00
+#define BMSTS_QID_TXDATA	0x01
+#define BMSTS_QID_RXSTS		0x02
+#define BMSTS_QID_TXSTS		0x03
+#define BMSTS_QID_RXDESC	0x04
+#define BMSTS_QID_TXDESC	0x05
+
+#define AFP_MASK		0x07
+#define AFP_IAPRIMARY		0x00
+#define AFP_IASECONDARY1	0x01
+#define AFP_IASECONDARY2	0x02
+#define AFP_IASECONDARY3	0x03
+#define AFP_TX			0x06
+#define AFP_HASH		0x07
+
+#define RXCTL_PAUSEA		(1 << 20)
+#define RXCTL_RXFCE1		(1 << 19)
+#define RXCTL_RXFCE0		(1 << 18)
+#define RXCTL_BCRC		(1 << 17)
+#define RXCTL_SRXON		(1 << 16)
+#define RXCTL_RCRCA		(1 << 13)
+#define RXCTL_RA		(1 << 12)
+#define RXCTL_PA		(1 << 11)
+#define RXCTL_BA		(1 << 10)
+#define RXCTL_MA		(1 << 9)
+#define RXCTL_IAHA		(1 << 8)
+#define RXCTL_IA3		(1 << 3)
+#define RXCTL_IA2		(1 << 2)
+#define RXCTL_IA1		(1 << 1)
+#define RXCTL_IA0		(1 << 0)
+
+#define TXCTL_DEFDIS		(1 << 7)
+#define TXCTL_MBE		(1 << 6)
+#define TXCTL_ICRC		(1 << 5)
+#define TXCTL_TPD		(1 << 4)
+#define TXCTL_OCOLL		(1 << 3)
+#define TXCTL_SP		(1 << 2)
+#define TXCTL_PB		(1 << 1)
+#define TXCTL_STXON		(1 << 0)
+
+#define MIICMD_REGAD_MASK	(0x001F)
+#define MIICMD_PHYAD_MASK	(0x03E0)
+#define MIICMD_OPCODE_MASK	(0xC000)
+#define MIICMD_PHYAD_8950	(0x0000)
+#define MIICMD_OPCODE_READ	(0x8000)
+#define MIICMD_OPCODE_WRITE	(0x4000)
+
+#define MIISTS_BUSY		(1 << 0)
+
+/* -----------------------------------------------------------------------------
+ * 0x80020000 - 0x8002FFFF: USB OHCI
+ */
+#define USB_OFFSET			0x020000
+#define USB_BASE			(EP93XX_AHB_BASE | USB_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80030000 - 0x8003FFFF: Raster engine
+ */
+#if (defined(CONFIG_EP9307) || defined(CONFIG_EP9312) || defined(CONFIG_EP9315))
+#define RASTER_OFFSET			0x030000
+#define RASTER_BASE			(EP93XX_AHB_BASE | RASTER_OFFSET)
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80040000 - 0x8004FFFF: Graphics accelerator
+ */
+#if defined(CONFIG_EP9315)
+#define GFX_OFFSET			0x040000
+#define GFX_BASE			(EP93XX_AHB_BASE | GFX_OFFSET)
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80050000 - 0x8005FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80060000 - 0x8006FFFF: SDRAM controller
+ */
+#define SDRAM_OFFSET			0x060000
+#define SDRAM_BASE			(EP93XX_AHB_BASE | SDRAM_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct sdram_regs {
+	uint32_t reserved;
+	uint32_t glconfig;
+	uint32_t refrshtimr;
+	uint32_t bootsts;
+	uint32_t devcfg0;
+	uint32_t devcfg1;
+	uint32_t devcfg2;
+	uint32_t devcfg3;
+};
+#endif
+
+#define SDRAM_DEVCFG_EXTBUSWIDTH	(1 << 2)
+#define SDRAM_DEVCFG_BANKCOUNT		(1 << 3)
+#define SDRAM_DEVCFG_SROMLL		(1 << 5)
+#define SDRAM_DEVCFG_CASLAT_2		0x00010000
+#define SDRAM_DEVCFG_RASTOCAS_2		0x00200000
+
+#define GLCONFIG_INIT			(1 << 0)
+#define GLCONFIG_MRS			(1 << 1)
+#define GLCONFIG_SMEMBUSY		(1 << 5)
+#define GLCONFIG_LCR			(1 << 6)
+#define GLCONFIG_REARBEN		(1 << 7)
+#define GLCONFIG_CLKSHUTDOWN		(1 << 30)
+#define GLCONFIG_CKE			(1 << 31)
+
+/* -----------------------------------------------------------------------------
+ * 0x80070000 - 0x8007FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80080000 - 0x8008FFFF: SRAM controller & PCMCIA
+ */
+#define SMC_OFFSET			0x080000
+#define SMC_BASE			(EP93XX_AHB_BASE | SMC_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct smc_regs {
+	uint32_t bcr0;
+	uint32_t bcr1;
+	uint32_t bcr2;
+	uint32_t bcr3;
+	uint32_t reserved0[2];
+	uint32_t bcr6;
+	uint32_t bcr7;
+#if defined(CONFIG_EP9315)
+	uint32_t pcattribute;
+	uint32_t pccommon;
+	uint32_t pcio;
+	uint32_t reserved1[5];
+	uint32_t pcmciactrl;
+#endif
+};
+#endif
+
+#define SMC_BCR_IDCY_SHIFT	0
+#define SMC_BCR_WST1_SHIFT	5
+#define SMC_BCR_BLE		(1 << 10)
+#define SMC_BCR_WST2_SHIFT	11
+#define SMC_BCR_MW_SHIFT	28
+
+/* -----------------------------------------------------------------------------
+ * 0x80090000 - 0x8009FFFF: Boot ROM
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800A0000 - 0x800AFFFF: IDE interface
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800B0000 - 0x800BFFFF: VIC1
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800C0000 - 0x800CFFFF: VIC2
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x800D0000 - 0x800FFFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80800000 - 0x8080FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80810000 - 0x8081FFFF: Timers
+ */
+#define TIMER_OFFSET		0x010000
+#define TIMER_BASE		(EP93XX_APB_BASE | TIMER_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct timer {
+	uint32_t load;
+	uint32_t value;
+	uint32_t control;
+	uint32_t clear;
+};
+
+struct timer4 {
+	uint32_t value_low;
+	uint32_t value_high;
+};
+
+struct timer_regs {
+	struct timer timer1;
+	uint32_t reserved0[4];
+	struct timer timer2;
+	uint32_t reserved1[12];
+	struct timer4 timer4;
+	uint32_t reserved2[6];
+	struct timer timer3;
+};
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80820000 - 0x8082FFFF: I2S
+ */
+#define I2S_OFFSET		0x020000
+#define I2S_BASE		(EP93XX_APB_BASE | I2S_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80830000 - 0x8083FFFF: Security
+ */
+#define SECURITY_OFFSET		0x030000
+#define SECURITY_BASE		(EP93XX_APB_BASE | SECURITY_OFFSET)
+
+#define EXTENSIONID		(SECURITY_BASE + 0x2714)
+
+/* -----------------------------------------------------------------------------
+ * 0x80840000 - 0x8084FFFF: GPIO
+ */
+#define GPIO_OFFSET		0x040000
+#define GPIO_BASE		(EP93XX_APB_BASE | GPIO_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct gpio_int {
+	uint32_t inttype1;
+	uint32_t inttype2;
+	uint32_t eoi;
+	uint32_t inten;
+	uint32_t intsts;
+	uint32_t rawintsts;
+	uint32_t db;
+};
+
+struct gpio_regs {
+	uint32_t padr;
+	uint32_t pbdr;
+	uint32_t pcdr;
+	uint32_t pddr;
+	uint32_t paddr;
+	uint32_t pbddr;
+	uint32_t pcddr;
+	uint32_t pdddr;
+	uint32_t pedr;
+	uint32_t peddr;
+	uint32_t reserved0[2];
+	uint32_t pfdr;
+	uint32_t pfddr;
+	uint32_t pgdr;
+	uint32_t pgddr;
+	uint32_t phdr;
+	uint32_t phddr;
+	uint32_t reserved1;
+	uint32_t finttype1;
+	uint32_t finttype2;
+	uint32_t reserved2;
+	struct gpio_int pfint;
+	uint32_t reserved3[10];
+	struct gpio_int paint;
+	struct gpio_int pbint;
+	uint32_t eedrive;
+};
+#endif
+
+/* -----------------------------------------------------------------------------
+ * 0x80850000 - 0x8087FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x80880000 - 0x8088FFFF: AAC
+ */
+#define AAC_OFFSET		0x080000
+#define AAC_BASE		(EP93XX_APB_BASE | AAC_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80890000 - 0x8089FFFF: Reserved
+ */
+
+/* -----------------------------------------------------------------------------
+ * 0x808A0000 - 0x808AFFFF: SPI
+ */
+#define SPI_OFFSET		0x0A0000
+#define SPI_BASE		(EP93XX_APB_BASE | SPI_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808B0000 - 0x808BFFFF: IrDA
+ */
+#define IRDA_OFFSET		0x0B0000
+#define IRDA_BASE		(EP93XX_APB_BASE | IRDA_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808C0000 - 0x808CFFFF: UART1
+ */
+#define UART1_OFFSET		0x0C0000
+#define UART1_BASE		(EP93XX_APB_BASE | UART1_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808D0000 - 0x808DFFFF: UART2
+ */
+#define UART2_OFFSET		0x0D0000
+#define UART2_BASE		(EP93XX_APB_BASE | UART2_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808E0000 - 0x808EFFFF: UART3
+ */
+#define UART3_OFFSET		0x0E0000
+#define UART3_BASE		(EP93XX_APB_BASE | UART3_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x808F0000 - 0x808FFFFF: Key Matrix
+ */
+#define KEY_OFFSET		0x0F0000
+#define KEY_BASE		(EP93XX_APB_BASE | KEY_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80900000 - 0x8090FFFF: Touchscreen
+ */
+#define TOUCH_OFFSET		0x900000
+#define TOUCH_BASE		(EP93XX_APB_BASE | TOUCH_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80910000 - 0x8091FFFF: Pulse Width Modulation
+ */
+#define PWM_OFFSET		0x910000
+#define PWM_BASE		(EP93XX_APB_BASE | PWM_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80920000 - 0x8092FFFF: Real time clock
+ */
+#define RTC_OFFSET		0x920000
+#define RTC_BASE		(EP93XX_APB_BASE | RTC_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80930000 - 0x8093FFFF: Syscon
+ */
+#define SYSCON_OFFSET		0x930000
+#define SYSCON_BASE		(EP93XX_APB_BASE | SYSCON_OFFSET)
+
+#ifndef __ASSEMBLY__
+struct syscon_regs {
+	uint32_t pwrsts;
+	uint32_t pwrcnt;
+	uint32_t halt;
+	uint32_t stby;
+	uint32_t reserved0[2];
+	uint32_t teoi;
+	uint32_t stfclr;
+	uint32_t clkset1;
+	uint32_t clkset2;
+	uint32_t reserved1[6];
+	uint32_t scratch0;
+	uint32_t scratch1;
+	uint32_t reserved2[2];
+	uint32_t apbwait;
+	uint32_t bustmstrarb;
+	uint32_t bootmodeclr;
+	uint32_t reserved3[9];
+	uint32_t devicecfg;
+	uint32_t vidclkdiv;
+	uint32_t mirclkdiv;
+	uint32_t i2sclkdiv;
+	uint32_t keytchclkdiv;
+	uint32_t chipid;
+	uint32_t syscfg;
+	uint32_t reserved4[8];
+	uint32_t sysswlock;
+};
+#else
+#define SYSCON_SCRATCH0		(SYSCON_BASE + 0x0040)
+#endif
+
+#define SYSCON_PWRCNT_UART_BAUD			(1 << 29)
+
+#define SYSCON_CLKSET_PLL_X2IPD_SHIFT		0
+#define SYSCON_CLKSET_PLL_X2FBD2_SHIFT		5
+#define SYSCON_CLKSET_PLL_X1FBD1_SHIFT		11
+#define SYSCON_CLKSET_PLL_PS_SHIFT		16
+#define SYSCON_CLKSET1_PCLK_DIV_SHIFT		18
+#define SYSCON_CLKSET1_HCLK_DIV_SHIFT		20
+#define SYSCON_CLKSET1_NBYP1			(1 << 23)
+#define SYSCON_CLKSET1_FCLK_DIV_SHIFT		25
+
+#define SYSCON_CLKSET2_PLL2_EN			(1 << 18)
+#define SYSCON_CLKSET2_NBYP2			(1 << 19)
+#define SYSCON_CLKSET2_USB_DIV_SHIFT		28
+
+#define SYSCON_CHIPID_REV_MASK			0xF0000000
+#define SYSCON_DEVICECFG_SWRST			(1 << 31)
+
+/* -----------------------------------------------------------------------------
+ * 0x80930000 - 0x8093FFFF: Watchdog Timer
+ */
+#define WATCHDOG_OFFSET		0x940000
+#define WATCHDOG_BASE		(EP93XX_APB_BASE | WATCHDOG_OFFSET)
+
+/* -----------------------------------------------------------------------------
+ * 0x80950000 - 0x9000FFFF: Reserved
+ */
+
diff --git a/arch/arm/mach-ep93xx/led.c b/arch/arm/mach-ep93xx/led.c
new file mode 100644
index 0000000..6d6b902
--- /dev/null
+++ b/arch/arm/mach-ep93xx/led.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <asm/io.h>
+#include <mach/ep93xx-regs.h>
+
+#define GREEN_LED_POS		0x01
+#define RED_LED_POS		0x02
+
+inline void switch_LED_on(uint32_t bit_pos)
+{
+	register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
+
+	writel(readl(&gpio->pedr) | bit_pos, &gpio->pedr);
+}
+
+inline void switch_LED_off(uint32_t bit_pos)
+{
+	register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE;
+
+	writel(readl(&gpio->pedr) & ~bit_pos, &gpio->pedr);
+}
+
+void red_LED_on(void)
+{
+	switch_LED_on(RED_LED_POS);
+}
+
+void red_LED_off(void)
+{
+	switch_LED_off(RED_LED_POS);
+}
+
+void green_LED_on(void)
+{
+	switch_LED_on(GREEN_LED_POS);
+}
+
+void green_LED_off(void)
+{
+	switch_LED_off(GREEN_LED_POS);
+}
diff --git a/arch/arm/mach-ep93xx/led.h b/arch/arm/mach-ep93xx/led.h
new file mode 100644
index 0000000..db9512f
--- /dev/null
+++ b/arch/arm/mach-ep93xx/led.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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
+ */
+
+extern void red_LED_on(void);
+extern void red_LED_off(void);
+extern void green_LED_on(void);
+extern void green_LED_off(void);
diff --git a/arch/arm/mach-ep93xx/lowlevel_init.S b/arch/arm/mach-ep93xx/lowlevel_init.S
new file mode 100644
index 0000000..27c2c90
--- /dev/null
+++ b/arch/arm/mach-ep93xx/lowlevel_init.S
@@ -0,0 +1,64 @@
+/*
+ * Low-level initialization for EP93xx
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <mach/ep93xx-regs.h>
+
+.globl board_init_lowlevel
+board_init_lowlevel:
+	/* backup return address */
+	ldr r1, =SYSCON_SCRATCH0
+	str lr, [r1]
+
+	/* Turn on both LEDs */
+	bl red_LED_on
+	bl green_LED_on
+
+	/* Configure flash wait states before we switch to the PLL */
+	bl flash_cfg
+
+	/* Set up PLL */
+	bl pll_cfg
+
+	/* Turn off the Green LED and leave the Red LED on */
+	bl green_LED_off
+
+	/* Setup SDRAM */
+	bl sdram_cfg
+
+	/* Turn on Green LED, Turn off the Red LED */
+	bl green_LED_on
+	bl red_LED_off
+
+	/* switch to async mode */
+	mrc p15, 0, r0, c1, c0, 0
+	orr r0, r0, #0xc0000000
+	mcr p15, 0, r0, c1, c0, 0
+
+	/* restore return address */
+	ldr r1, =SYSCON_SCRATCH0
+	ldr lr, [r1]
+
+	mov pc, lr
-- 
1.6.3.1



From matthias at kaehlcke.net  Tue Jan 12 14:30:41 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Tue, 12 Jan 2010 20:30:41 +0100
Subject: [PATCH 2/5] Add EP93xx ethernet driver
Message-ID: <20100112193041.GN14051@darwin>

Added ethernet driver for EP93xx SoCs

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 drivers/net/Kconfig  |    5 +
 drivers/net/Makefile |    1 +
 drivers/net/ep93xx.c |  676 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ep93xx.h |  147 +++++++++++
 include/common.h     |    1 +
 5 files changed, 830 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ep93xx.c
 create mode 100644 drivers/net/ep93xx.h

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ed7656e..0955562 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -64,6 +64,11 @@ config DRIVER_NET_FEC_IMX
 	depends on ARCH_HAS_FEC_IMX
 	select MIIPHY
 
+config DRIVER_NET_EP93XX
+	bool "EP93xx Ethernet driver"
+	depends on ARCH_EP93XX
+	select MIIPHY
+
 config DRIVER_NET_MACB
 	bool "macb Ethernet driver"
 	depends on ARCH_AT91
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6751920..1b6f104 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_DRIVER_NET_NETX)		+= netx_eth.o
 obj-$(CONFIG_DRIVER_NET_AT91_ETHER)	+= at91_ether.o
 obj-$(CONFIG_DRIVER_NET_MPC5200)	+= fec_mpc5200.o
 obj-$(CONFIG_DRIVER_NET_FEC_IMX)	+= fec_imx.o
+obj-$(CONFIG_DRIVER_NET_EP93XX)		+= ep93xx.o
 obj-$(CONFIG_DRIVER_NET_MACB)		+= macb.o
 obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
 obj-$(CONFIG_MIIPHY)			+= miiphy.o
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
new file mode 100644
index 0000000..aa1a005
--- /dev/null
+++ b/drivers/net/ep93xx.c
@@ -0,0 +1,676 @@
+/*
+ * Cirrus Logic EP93xx ethernet MAC / MII driver.
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.com>
+ *
+ * Based on the original eth.[ch] Cirrus Logic EP93xx Rev D. Ethernet Driver,
+ * which is
+ *
+ * (C) Copyright 2002 2003
+ * Adam Bezanson, Network Audio Technologies, Inc.
+ * <bezanson at netaudiotech.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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <init.h>
+#include <malloc.h>
+#include <miiphy.h>
+#include <asm/io.h>
+#include <linux/types.h>
+#include <mach/ep93xx-regs.h>
+#include "ep93xx.h"
+
+static int ep93xx_eth_send_packet(struct eth_device *edev,
+				void *packet, int length);
+static int ep93xx_eth_rcv_packet(struct eth_device *edev);
+
+static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t *value);
+static int ep93xx_phy_write(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t value);
+
+static inline struct ep93xx_eth_priv *ep93xx_get_priv(struct eth_device *edev)
+{
+	return (struct ep93xx_eth_priv *)edev->priv;
+}
+
+static inline struct mac_regs *ep93xx_get_regs(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+
+	return priv->regs;
+}
+
+#if defined(EP93XX_MAC_DEBUG)
+/**
+ * Dump ep93xx_mac values to the terminal.
+ */
+inline void dump_dev(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_dev()\n");
+	printf("  rx_dq.base	     %08X\n", priv->rx_dq.base);
+	printf("  rx_dq.current	     %08X\n", priv->rx_dq.current);
+	printf("  rx_dq.end	     %08X\n", priv->rx_dq.end);
+	printf("  rx_sq.base	     %08X\n", priv->rx_sq.base);
+	printf("  rx_sq.current	     %08X\n", priv->rx_sq.current);
+	printf("  rx_sq.end	     %08X\n", priv->rx_sq.end);
+
+	for (i = 0; i < NUMRXDESC; i++)
+		printf("  rx_buffer[%2.d]      %08X\n", i, NetRxPackets[i]);
+
+	printf("  tx_dq.base	     %08X\n", priv->tx_dq.base);
+	printf("  tx_dq.current	     %08X\n", priv->tx_dq.current);
+	printf("  tx_dq.end	     %08X\n", priv->tx_dq.end);
+	printf("  tx_sq.base	     %08X\n", priv->tx_sq.base);
+	printf("  tx_sq.current	     %08X\n", priv->tx_sq.current);
+	printf("  tx_sq.end	     %08X\n", priv->tx_sq.end);
+}
+
+/**
+ * Dump all RX descriptor queue entries to the terminal.
+ */
+inline void dump_rx_descriptor_queue(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_rx_descriptor_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMRXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->rx_dq.base + i),
+			(priv->rx_dq.base + i)->word1,
+			(priv->rx_dq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all RX status queue entries to the terminal.
+ */
+inline void dump_rx_status_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_rx_status_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMRXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->rx_sq.base + i),
+			(priv->rx_sq.base + i)->word1,
+			(priv->rx_sq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all TX descriptor queue entries to the terminal.
+ */
+inline void dump_tx_descriptor_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_tx_descriptor_queue()\n");
+	printf("  descriptor address	 word1		 word2\n");
+	for (i = 0; i < NUMTXDESC; i++) {
+		printf("  [ %08X ]	     %08X	 %08X\n",
+			(priv->tx_dq.base + i),
+			(priv->tx_dq.base + i)->word1,
+			(priv->tx_dq.base + i)->word2);
+	}
+}
+
+/**
+ * Dump all TX status queue entries to the terminal.
+ */
+inline void dump_tx_status_queue(void)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	int i;
+
+	printf("\ndump_tx_status_queue()\n");
+	printf("  descriptor address	 word1\n");
+	for (i = 0; i < NUMTXDESC; i++) {
+		printf("  [ %08X ]	     %08X\n",
+			(priv->rx_sq.base + i),
+			(priv->rx_sq.base + i)->word1);
+	}
+}
+#else
+#define dump_dev(x)
+#define dump_rx_descriptor_queue()
+#define dump_rx_status_queue()
+#define dump_tx_descriptor_queue()
+#define dump_tx_status_queue()
+#endif	/* defined(EP93XX_MAC_DEBUG) */
+
+/**
+ * Reset the EP93xx MAC by twiddling the soft reset bit and spinning until
+ * it's cleared.
+ */
+static void ep93xx_eth_reset(struct eth_device *edev)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	uint32_t value;
+
+	pr_debug("+ep93xx_eth_reset\n");
+
+	value = readl(&regs->selfctl);
+	value |= SELFCTL_RESET;
+	writel(value, &regs->selfctl);
+
+	while (readl(&regs->selfctl) & SELFCTL_RESET)
+		; /* noop */
+
+	pr_debug("-ep93xx_eth_reset\n");
+}
+
+static int ep93xx_eth_init_dev(struct eth_device *edev)
+{
+	pr_debug("+ep93xx_eth_init_dev\n");
+
+	pr_debug("-ep93xx_eth_init_dev\n");
+
+	return 0;
+}
+
+static int ep93xx_eth_open(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int i;
+
+	pr_debug("+ep93xx_eth_open\n");
+
+	ep93xx_eth_reset(edev);
+
+	/* Reset the descriptor queues' current and end address values */
+	priv->tx_dq.current = priv->tx_dq.base;
+	priv->tx_dq.end = (priv->tx_dq.base + NUMTXDESC);
+
+	priv->tx_sq.current = priv->tx_sq.base;
+	priv->tx_sq.end = (priv->tx_sq.base + NUMTXDESC);
+
+	priv->rx_dq.current = priv->rx_dq.base;
+	priv->rx_dq.end = (priv->rx_dq.base + NUMRXDESC);
+
+	priv->rx_sq.current = priv->rx_sq.base;
+	priv->rx_sq.end = (priv->rx_sq.base + NUMRXDESC);
+
+	/*
+	 * Set the transmit descriptor and status queues' base address,
+	 * current address, and length registers.  Set the maximum frame
+	 * length and threshold. Enable the transmit descriptor processor.
+	 */
+	writel((uint32_t)priv->tx_dq.base, &regs->txdq.badd);
+	writel((uint32_t)priv->tx_dq.base, &regs->txdq.curadd);
+	writel(sizeof(struct tx_descriptor) * NUMTXDESC, &regs->txdq.blen);
+
+	writel((uint32_t)priv->tx_sq.base, &regs->txstsq.badd);
+	writel((uint32_t)priv->tx_sq.base, &regs->txstsq.curadd);
+	writel(sizeof(struct tx_status) * NUMTXDESC, &regs->txstsq.blen);
+
+	writel(0x00040000, &regs->txdthrshld);
+	writel(0x00040000, &regs->txststhrshld);
+
+	writel((TXSTARTMAX << 0) | (PKTSIZE_ALIGN << 16), &regs->maxfrmlen);
+	writel(BMCTL_TXEN, &regs->bmctl);
+
+	/*
+	 * Set the receive descriptor and status queues' base address,
+	 * current address, and length registers.  Enable the receive
+	 * descriptor processor.
+	 */
+	writel((uint32_t)priv->rx_dq.base, &regs->rxdq.badd);
+	writel((uint32_t)priv->rx_dq.base, &regs->rxdq.curadd);
+	writel(sizeof(struct rx_descriptor) * NUMRXDESC, &regs->rxdq.blen);
+
+	writel((uint32_t)priv->rx_sq.base, &regs->rxstsq.badd);
+	writel((uint32_t)priv->rx_sq.base, &regs->rxstsq.curadd);
+	writel(sizeof(struct rx_status) * NUMRXDESC, &regs->rxstsq.blen);
+
+	writel(0x00040000, &regs->rxdthrshld);
+
+	writel(BMCTL_RXEN, &regs->bmctl);
+
+	writel(0x00040000, &regs->rxststhrshld);
+
+	/* Wait until the receive descriptor processor is active */
+	while (!(readl(&regs->bmsts) & BMSTS_RXACT))
+		; /* noop */
+
+	/*
+	 * Initialize the RX descriptor queue. Clear the TX descriptor queue.
+	 * Clear the RX and TX status queues. Enqueue the RX descriptor and
+	 * status entries to the MAC.
+	 */
+	for (i = 0; i < NUMRXDESC; i++) {
+		/* set buffer address */
+		(priv->rx_dq.base + i)->word1 = (uint32_t)NetRxPackets[i];
+
+		/* set buffer length, clear buffer index and NSOF */
+		(priv->rx_dq.base + i)->word2 = PKTSIZE_ALIGN;
+	}
+
+	memset(priv->tx_dq.base, 0,
+		(sizeof(struct tx_descriptor) * NUMTXDESC));
+	memset(priv->rx_sq.base, 0,
+		(sizeof(struct rx_status) * NUMRXDESC));
+	memset(priv->tx_sq.base, 0,
+		(sizeof(struct tx_status) * NUMTXDESC));
+
+	writel(NUMRXDESC, &regs->rxdqenq);
+	writel(NUMRXDESC, &regs->rxstsqenq);
+
+	/* Turn on RX and TX */
+	writel(RXCTL_IA0 | RXCTL_BA | RXCTL_SRXON |
+		RXCTL_RCRCA | RXCTL_MA, &regs->rxctl);
+	writel(TXCTL_STXON, &regs->txctl);
+
+	/* Dump data structures if we're debugging */
+	dump_dev();
+	dump_rx_descriptor_queue();
+	dump_rx_status_queue();
+	dump_tx_descriptor_queue();
+	dump_tx_status_queue();
+
+	pr_debug("-ep93xx_eth_open\n");
+
+	return 0;
+}
+
+/**
+ * Halt EP93xx MAC transmit and receive by clearing the TxCTL and RxCTL
+ * registers.
+ */
+static void ep93xx_eth_halt(struct eth_device *edev)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+
+	pr_debug("+ep93xx_eth_halt\n");
+
+	writel(0x00000000, &regs->rxctl);
+	writel(0x00000000, &regs->txctl);
+
+	pr_debug("-ep93xx_eth_halt\n");
+}
+
+static int ep93xx_eth_get_ethaddr(struct eth_device *edev,
+				unsigned char *mac_addr)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	uint32_t value;
+
+	value = readl(&regs->indad);
+	mac_addr[0] = value & 0xFF;
+	mac_addr[1] = (value >> 8) & 0xFF;
+	mac_addr[2] = (value >> 16) & 0xFF;
+	mac_addr[3] = (value >> 24) & 0xFF;
+
+	value = readl(&regs->indad_upper);
+	mac_addr[4] = value & 0xFF;
+	mac_addr[5] = (value >> 8) & 0xFF;
+
+	return 0;
+}
+
+static int ep93xx_eth_set_ethaddr(struct eth_device *edev,
+				unsigned char *mac_addr)
+{
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+
+	writel(AFP_IAPRIMARY, &regs->afp);
+
+	writel(mac_addr[0] | (mac_addr[1] << 8) |
+		(mac_addr[2] << 16) | (mac_addr[3] << 24),
+		&regs->indad);
+	writel(mac_addr[4] | (mac_addr[5] << 8), &regs->indad_upper);
+
+	return 0;
+}
+
+static int ep93xx_eth_probe(struct device_d *dev)
+{
+	struct eth_device *edev;
+	struct ep93xx_eth_priv *priv;
+	int ret = -1;
+
+	pr_debug("ep93xx_eth_probe()\n");
+
+	edev = xzalloc(sizeof(struct eth_device) +
+		sizeof(struct ep93xx_eth_priv));
+	dev->type_data = edev;
+	edev->priv = (struct ep93xx_eth_priv *)(edev + 1);
+
+	priv = edev->priv;
+	priv->regs = (struct mac_regs *)MAC_BASE;
+
+	edev->init = ep93xx_eth_init_dev;
+	edev->open = ep93xx_eth_open;
+	edev->send = ep93xx_eth_send_packet;
+	edev->recv = ep93xx_eth_rcv_packet;
+	edev->halt = ep93xx_eth_halt;
+	edev->get_ethaddr = ep93xx_eth_get_ethaddr;
+	edev->set_ethaddr = ep93xx_eth_set_ethaddr;
+
+	priv->miiphy.read = ep93xx_phy_read;
+	priv->miiphy.write = ep93xx_phy_write;
+	priv->miiphy.address = 0;
+	priv->miiphy.flags = 0;
+
+	priv->tx_dq.base = calloc(NUMTXDESC,
+				sizeof(struct tx_descriptor));
+	if (priv->tx_dq.base == NULL) {
+		pr_err("calloc() failed: tx_dq.base");
+		goto eth_probe_failed_0;
+	}
+
+	priv->tx_sq.base = calloc(NUMTXDESC,
+				sizeof(struct tx_status));
+	if (priv->tx_sq.base == NULL) {
+		pr_err("calloc() failed: tx_sq.base");
+		goto eth_probe_failed_1;
+	}
+
+	priv->rx_dq.base = calloc(NUMRXDESC,
+				sizeof(struct rx_descriptor));
+	if (priv->rx_dq.base == NULL) {
+		pr_err("calloc() failed: rx_dq.base");
+		goto eth_probe_failed_2;
+	}
+
+	priv->rx_sq.base = calloc(NUMRXDESC,
+				sizeof(struct rx_status));
+	if (priv->rx_sq.base == NULL) {
+		pr_err("calloc() failed: rx_sq.base");
+		goto eth_probe_failed_3;
+	}
+
+	miiphy_register(&priv->miiphy);
+	eth_register(edev);
+
+	ret = 0;
+
+	goto eth_probe_done;
+
+eth_probe_failed_3:
+	free(priv->rx_dq.base);
+	/* Fall through */
+
+eth_probe_failed_2:
+	free(priv->tx_sq.base);
+	/* Fall through */
+
+eth_probe_failed_1:
+	free(priv->tx_dq.base);
+	/* Fall through */
+
+eth_probe_failed_0:
+	/* Fall through */
+
+eth_probe_done:
+	return ret;
+}
+
+/**
+ * Copy a frame of data from the MAC into the protocol layer for further
+ * processing.
+ */
+static int ep93xx_eth_rcv_packet(struct eth_device *edev)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int ret = -1;
+
+	pr_debug("+ep93xx_eth_rcv_packet\n");
+
+	if (RX_STATUS_RFP(priv->rx_sq.current)) {
+		if (RX_STATUS_RWE(priv->rx_sq.current)) {
+			/*
+			 * We have a good frame. Extract the frame's length
+			 * from the current rx_status_queue entry, and copy
+			 * the frame's data into NetRxPackets[] of the
+			 * protocol stack. We track the total number of
+			 * bytes in the frame (nbytes_frame) which will be
+			 * used when we pass the data off to the protocol
+			 * layer via NetReceive().
+			 */
+			NetReceive((uchar *)priv->rx_dq.current->word1,
+				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
+			pr_debug("reporting %d bytes...\n",
+				RX_STATUS_FRAME_LEN(priv->rx_sq.current));
+
+			ret = 0;
+
+		} else {
+			/* Do we have an erroneous packet? */
+			pr_err("packet rx error, status %08X %08X\n",
+				priv->rx_sq.current->word1,
+				priv->rx_sq.current->word2);
+			dump_rx_descriptor_queue();
+			dump_rx_status_queue();
+		}
+
+		/*
+		 * Clear the associated status queue entry, and
+		 * increment our current pointers to the next RX
+		 * descriptor and status queue entries (making sure
+		 * we wrap properly).
+		 */
+		memset((void *)priv->rx_sq.current, 0,
+			sizeof(struct rx_status));
+
+		priv->rx_sq.current++;
+		if (priv->rx_sq.current >= priv->rx_sq.end)
+			priv->rx_sq.current = priv->rx_sq.base;
+
+		priv->rx_dq.current++;
+		if (priv->rx_dq.current >= priv->rx_dq.end)
+			priv->rx_dq.current = priv->rx_dq.base;
+
+		/*
+		 * Finally, return the RX descriptor and status entries
+		 * back to the MAC engine, and loop again, checking for
+		 * more descriptors to process.
+		 */
+		writel(1, &regs->rxdqenq);
+		writel(1, &regs->rxstsqenq);
+	} else {
+		ret = 0;
+	}
+
+	pr_debug("-ep93xx_eth_rcv_packet %d\n", ret);
+
+	return ret;
+}
+
+/**
+ * Send a block of data via ethernet.
+ */
+static int ep93xx_eth_send_packet(struct eth_device *edev,
+				void *packet, int length)
+{
+	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
+	struct mac_regs *regs = ep93xx_get_regs(edev);
+	int ret = -1;
+
+	pr_debug("+ep93xx_eth_send_packet\n");
+
+	/*
+	 * Initialize the TX descriptor queue with the new packet's info.
+	 * Clear the associated status queue entry. Enqueue the packet
+	 * to the MAC for transmission.
+	 */
+
+	/* set buffer address */
+	priv->tx_dq.current->word1 = (uint32_t)packet;
+
+	/* set buffer length and EOF bit */
+	priv->tx_dq.current->word2 = length | TX_DESC_EOF;
+
+	/* clear tx status */
+	priv->tx_sq.current->word1 = 0;
+
+	/* enqueue the TX descriptor */
+	writel(1, &regs->txdqenq);
+
+	/* wait for the frame to become processed */
+	while (!TX_STATUS_TXFP(priv->tx_sq.current))
+		; /* noop */
+
+	if (!TX_STATUS_TXWE(priv->tx_sq.current)) {
+		pr_err("packet tx error, status %08X\n",
+			priv->tx_sq.current->word1);
+		dump_tx_descriptor_queue();
+		dump_tx_status_queue();
+
+		/* TODO: Add better error handling? */
+		goto eth_send_failed_0;
+	}
+
+	ret = 0;
+	/* Fall through */
+
+eth_send_failed_0:
+	pr_debug("-ep93xx_eth_send_packet %d\n", ret);
+
+	return ret;
+}
+
+/* -----------------------------------------------------------------------------
+ * EP93xx ethernet MII functionality.
+ */
+
+/**
+ * Maximum MII address we support
+ */
+#define MII_ADDRESS_MAX			(31)
+
+/**
+ * Maximum MII register address we support
+ */
+#define MII_REGISTER_MAX		(31)
+
+/**
+ * Read a 16-bit value from an MII register.
+ */
+static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t *value)
+{
+	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	int ret = -1;
+	uint32_t self_ctl;
+
+	pr_debug("+ep93xx_phy_read\n");
+
+	/*
+	 * Save the current SelfCTL register value.  Set MAC to suppress
+	 * preamble bits.  Wait for any previous MII command to complete
+	 * before issuing the new command.
+	 */
+	self_ctl = readl(&regs->selfctl);
+#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */
+	writel(self_ctl & ~(1 << 8), &regs->selfctl);
+#endif	/* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */
+
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/*
+	 * Issue the MII 'read' command.  Wait for the command to complete.
+	 * Read the MII data value.
+	 */
+	writel(MIICMD_OPCODE_READ | ((uint32_t)phy_addr << 5) |
+		(uint32_t)phy_reg, &regs->miicmd);
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	*value = (unsigned short)readl(&regs->miidata);
+
+	/* Restore the saved SelfCTL value and return. */
+	writel(self_ctl, &regs->selfctl);
+
+	ret = 0;
+
+	pr_debug("-ep93xx_phy_read\n");
+
+	return ret;
+}
+
+/**
+ * Write a 16-bit value to an MII register.
+ */
+static int ep93xx_phy_write(struct miiphy_device *mdev, uint8_t phy_addr,
+			uint8_t phy_reg, uint16_t value)
+{
+	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	int ret = -1;
+	uint32_t self_ctl;
+
+	pr_debug("+ep93xx_phy_write\n");
+
+	/*
+	 * Save the current SelfCTL register value.  Set MAC to suppress
+	 * preamble bits.  Wait for any previous MII command to complete
+	 * before issuing the new command.
+	 */
+	self_ctl = readl(&regs->selfctl);
+#if defined(CONFIG_MII_SUPPRESS_PREAMBLE) /* TODO */
+	writel(self_ctl & ~(1 << 8), &regs->selfctl);
+#endif	/* defined(CONFIG_MII_SUPPRESS_PREAMBLE) */
+
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/* Issue the MII 'write' command.  Wait for the command to complete. */
+	writel((uint32_t)value, &regs->miidata);
+	writel(MIICMD_OPCODE_WRITE | ((uint32_t)phy_addr << 5) | phy_reg,
+		&regs->miicmd);
+	while (readl(&regs->miists) & MIISTS_BUSY)
+		; /* noop */
+
+	/* Restore the saved SelfCTL value and return. */
+	writel(self_ctl, &regs->selfctl);
+
+	ret = 0;
+
+	pr_debug("-ep93xx_phy_write\n");
+
+	return ret;
+}
+
+static struct driver_d ep93xx_eth_driver = {
+	.name  = "ep93xx_eth",
+	.probe = ep93xx_eth_probe,
+};
+
+static int ep93xx_eth_init(void)
+{
+	register_driver(&ep93xx_eth_driver);
+	return 0;
+}
+
+device_initcall(ep93xx_eth_init);
diff --git a/drivers/net/ep93xx.h b/drivers/net/ep93xx.h
new file mode 100644
index 0000000..ae45c54
--- /dev/null
+++ b/drivers/net/ep93xx.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2004, 2005
+ * Cory T. Tusar, Videon Central, Inc., <ctusar at videon-central.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
+ *
+ */
+
+#ifndef _ETH_H
+#define _ETH_H
+
+#include <net.h>
+
+/**
+ * #define this to dump device status and queue info during initialization and
+ * following errors.
+ */
+#undef EP93XX_MAC_DEBUG
+
+/**
+ * Number of descriptor and status entries in our RX queues.
+ * It must be power of 2 !
+ */
+#define NUMRXDESC		PKTBUFSRX
+
+/**
+ * Number of descriptor and status entries in our TX queues.
+ */
+#define NUMTXDESC		1
+
+/**
+ * 944 = (1024 - 64) - 16, Fifo size - Minframesize - 16 (Chip FACT)
+ */
+#define TXSTARTMAX		944
+
+/**
+ * Receive descriptor queue entry
+ */
+struct rx_descriptor {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+/**
+ * Receive status queue entry
+ */
+struct rx_status {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+#define RX_STATUS_RWE(rx_status) ((rx_status->word1 >> 30) & 0x01)
+#define RX_STATUS_RFP(rx_status) ((rx_status->word1 >> 31) & 0x01)
+#define RX_STATUS_FRAME_LEN(rx_status) (rx_status->word2 & 0xFFFF)
+
+
+/**
+ * Transmit descriptor queue entry
+ */
+struct tx_descriptor {
+	uint32_t word1;
+	uint32_t word2;
+} __attribute__((packed));
+
+#define TX_DESC_EOF (1 << 31)
+
+/**
+ * Transmit status queue entry
+ */
+struct tx_status {
+	uint32_t word1;
+} __attribute__((packed));
+
+#define TX_STATUS_TXWE(tx_status) (((tx_status)->word1 >> 30) & 0x01)
+#define TX_STATUS_TXFP(tx_status) (((tx_status)->word1 >> 31) & 0x01)
+
+/**
+ * Transmit descriptor queue
+ */
+struct tx_descriptor_queue {
+	struct tx_descriptor *base;
+	struct tx_descriptor *current;
+	struct tx_descriptor *end;
+};
+
+/**
+ * Transmit status queue
+ */
+struct tx_status_queue {
+	struct tx_status *base;
+	volatile struct tx_status *current;
+	struct tx_status *end;
+};
+
+/**
+ * Receive descriptor queue
+ */
+struct rx_descriptor_queue {
+	struct rx_descriptor *base;
+	struct rx_descriptor *current;
+	struct rx_descriptor *end;
+};
+
+/**
+ * Receive status queue
+ */
+struct rx_status_queue {
+	struct rx_status *base;
+	volatile struct rx_status *current;
+	struct rx_status *end;
+};
+
+/**
+ * EP93xx MAC private data structure
+ */
+struct ep93xx_eth_priv {
+	struct mac_regs			*regs;
+
+	struct rx_descriptor_queue	rx_dq;
+	struct rx_status_queue		rx_sq;
+	void				*rx_buffer[NUMRXDESC];
+
+	struct tx_descriptor_queue	tx_dq;
+	struct tx_status_queue		tx_sq;
+
+	struct miiphy_device miiphy;
+};
+
+#endif
diff --git a/include/common.h b/include/common.h
index 0c49d95..2b40954 100644
--- a/include/common.h
+++ b/include/common.h
@@ -31,6 +31,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/stddef.h>
 #include <asm/common.h>
 
 #define pr_info(fmt, arg...)	printf(fmt, ##arg)
-- 
1.6.3.1



From matthias at kaehlcke.net  Tue Jan 12 14:30:47 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Tue, 12 Jan 2010 20:30:47 +0100
Subject: [PATCH 3/5] Add support for EP9xx GPIOs
Message-ID: <20100112193047.GO14051@darwin>

Added generic GPIO support for EP93xx SoCs

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 arch/arm/Kconfig                         |    1 +
 arch/arm/mach-ep93xx/Makefile            |    2 +-
 arch/arm/mach-ep93xx/gpio.c              |  136 ++++++++++++++++++++++++++++++
 arch/arm/mach-ep93xx/include/mach/gpio.h |   29 +++++++
 4 files changed, 167 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/gpio.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/gpio.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 414a013..9cad224 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -34,6 +34,7 @@ config ARCH_AT91RM9200
 config ARCH_EP93XX
 	bool "Cirrus Logic EP93xx"
 	select CPU_ARM920T
+	select GENERIC_GPIO
 
 config ARCH_IMX
 	bool "Freescale iMX-based"
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
index d5786db..dac6571 100644
--- a/arch/arm/mach-ep93xx/Makefile
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -1,3 +1,3 @@
-obj-y += clocksource.o led.o
+obj-y += clocksource.o gpio.o led.o
 
 obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o
diff --git a/arch/arm/mach-ep93xx/gpio.c b/arch/arm/mach-ep93xx/gpio.c
new file mode 100644
index 0000000..5d57434
--- /dev/null
+++ b/arch/arm/mach-ep93xx/gpio.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <errno.h>
+#include <init.h>
+#include <asm/io.h>
+#include <mach/ep93xx-regs.h>
+
+#define EP93XX_GPIO_NUM_PORTS	8
+#define EP93XX_GPIO_NUM_GPIOS	(EP93XX_GPIO_NUM_PORTS * 8)
+
+struct gpio_port {
+	uint32_t *dr;
+	uint32_t *ddr;
+};
+
+struct gpio_port gpio_ports[EP93XX_GPIO_NUM_PORTS];
+
+static int ep93xx_gpio_init(void)
+{
+	struct gpio_regs *gpio_regs = (struct gpio_regs *)GPIO_BASE;
+
+	gpio_ports[0].dr = &gpio_regs->padr;
+	gpio_ports[0].ddr = &gpio_regs->paddr;
+	gpio_ports[1].dr = &gpio_regs->pbdr;
+	gpio_ports[1].ddr = &gpio_regs->pbddr;
+	gpio_ports[2].dr = &gpio_regs->pcdr;
+	gpio_ports[2].ddr = &gpio_regs->pcddr;
+	gpio_ports[3].dr = &gpio_regs->pddr;
+	gpio_ports[3].ddr = &gpio_regs->pdddr;
+	gpio_ports[4].dr = &gpio_regs->pedr;
+	gpio_ports[4].ddr = &gpio_regs->peddr;
+	gpio_ports[5].dr = &gpio_regs->pfdr;
+	gpio_ports[5].ddr = &gpio_regs->pfddr;
+	gpio_ports[6].dr = &gpio_regs->pgdr;
+	gpio_ports[6].ddr = &gpio_regs->pgddr;
+	gpio_ports[7].dr = &gpio_regs->phdr;
+	gpio_ports[7].ddr = &gpio_regs->phddr;
+
+	return 0;
+}
+
+postcore_initcall(ep93xx_gpio_init);
+
+static struct gpio_port *gpio_get_port(unsigned gpio)
+{
+	if (gpio >= EP93XX_GPIO_NUM_GPIOS)
+		return 0;
+
+	return &gpio_ports[gpio / 8];
+}
+
+void gpio_set_value(unsigned gpio, int value)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return;
+
+	val = readl(port->dr);
+
+	if (value)
+		val |= 1 << shift;
+	else
+		val &= ~(1 << shift);
+
+	writel(val, port->dr);
+}
+
+int gpio_direction_input(unsigned gpio)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return -EINVAL;
+
+	val = readl(port->ddr);
+	val &= ~(1 << shift);
+	writel(val, port->ddr);
+
+	return 0;
+}
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return -EINVAL;
+
+	gpio_set_value(gpio, value);
+
+	val = readl(port->ddr);
+	val |= 1 << shift;
+	writel(val, port->ddr);
+
+	return 0;
+}
+
+int gpio_get_value(unsigned gpio)
+{
+	struct gpio_port *port = gpio_get_port(gpio);
+	const int shift = gpio % 8;
+	u32 val;
+
+	if (!port)
+		return -EINVAL;
+
+	val = readl(port->dr);
+
+	return val & (1 << shift) ? 1 : 0;
+}
+
diff --git a/arch/arm/mach-ep93xx/include/mach/gpio.h b/arch/arm/mach-ep93xx/include/mach/gpio.h
new file mode 100644
index 0000000..a305f27
--- /dev/null
+++ b/arch/arm/mach-ep93xx/include/mach/gpio.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 __ASM_ARCH_GPIO_H
+#define __ASM_ARCH_GPIO_H
+
+void gpio_set_value(unsigned gpio, int value);
+int gpio_get_value(unsigned gpio);
+int gpio_direction_output(unsigned gpio, int value);
+int gpio_direction_input(unsigned gpio);
+
+#endif /* __ASM_ARCH_GPIO_H */
+
-- 
1.6.3.1



From matthias at kaehlcke.net  Tue Jan 12 14:30:51 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Tue, 12 Jan 2010 20:30:51 +0100
Subject: [PATCH 4/5] Add PrimeCell PL010 serial driver
Message-ID: <20100112193051.GP14051@darwin>

Added driver for ARM PrimeCell PL010 UART

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 drivers/serial/Kconfig        |    7 ++
 drivers/serial/Makefile       |    2 +-
 drivers/serial/serial_pl010.c |  172 +++++++++++++++++++++++++++++++++++++++++
 drivers/serial/serial_pl010.h |  100 ++++++++++++++++++++++++
 4 files changed, 280 insertions(+), 1 deletions(-)
 create mode 100644 drivers/serial/serial_pl010.c
 create mode 100644 drivers/serial/serial_pl010.h

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b0ff5fa..8a5056b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -47,6 +47,13 @@ config DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
 	help
 	  Say Y here if you are using OMAP extensions to NS16550
 
+config DRIVER_SERIAL_PL010
+	depends on ARCH_EP93XX
+	default y
+	bool "ARM AMBA PL010 support"
+	help
+	  Enable this to get support for AMBA PL010 based serial devices
+
 config DRIVER_SERIAL_S3C24X0
 	bool "Samsung S3C24X0 serial driver"
 	depends on ARCH_S3C24xx
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 8ab680d..9f203bb 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -3,7 +3,6 @@
 # s3c4510b_uart.o
 # serial_max3100.o
 # serial_pl010.o
-# serial_pl011.o
 # serial_xuartlite.o
 obj-$(CONFIG_DRIVER_SERIAL_ARM_DCC)		+= arm_dcc.o
 obj-$(CONFIG_DRIVER_SERIAL_IMX)			+= serial_imx.o
@@ -13,4 +12,5 @@ obj-$(CONFIG_DRIVER_SERIAL_LINUX_COMSOLE)	+= linux_console.o
 obj-$(CONFIG_DRIVER_SERIAL_MPC5XXX)		+= serial_mpc5xxx.o
 obj-$(CONFIG_DRIVER_SERIAL_BLACKFIN)		+= serial_blackfin.o
 obj-$(CONFIG_DRIVER_SERIAL_NS16550)		+= serial_ns16550.o
+obj-$(CONFIG_DRIVER_SERIAL_PL010)		+= serial_pl010.o
 obj-$(CONFIG_DRIVER_SERIAL_S3C24X0)		+= serial_s3c24x0.o
diff --git a/drivers/serial/serial_pl010.c b/drivers/serial/serial_pl010.c
new file mode 100644
index 0000000..1a6366f
--- /dev/null
+++ b/drivers/serial/serial_pl010.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * (C) Copyright 2000
+ * Rob Taylor, Flying Pig Systems. robt at flyingpig.com.
+ *
+ * (C) Copyright 2004
+ * ARM Ltd.
+ * Philippe Robin, <philippe.robin at arm.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
+ */
+
+/* Simple U-Boot driver for the PrimeCell PL010/PL011 UARTs */
+
+#include <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include "serial_pl010.h"
+
+static int pl010_setbaudrate(struct console_device *cdev, int baudrate)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	unsigned int divisor;
+
+	switch (baudrate) {
+	case 9600:
+		divisor = UART_PL010_BAUD_9600;
+		break;
+
+	case 19200:
+		divisor = UART_PL010_BAUD_9600;
+		break;
+
+	case 38400:
+		divisor = UART_PL010_BAUD_38400;
+		break;
+
+	case 57600:
+		divisor = UART_PL010_BAUD_57600;
+		break;
+
+	case 115200:
+		divisor = UART_PL010_BAUD_115200;
+		break;
+
+	default:
+		divisor = UART_PL010_BAUD_38400;
+	}
+
+	writel((divisor & 0xf00) >> 8, &pl010->linctrlmid);
+	writel(divisor & 0xff, &pl010->linctrllow);
+
+	/* high register must always be written */
+	writel(readl(&pl010->linctrlhigh), &pl010->linctrlhigh);
+
+	return 0;
+}
+
+static int pl010_init_port(struct console_device *cdev)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+
+	/*
+	 * First, disable everything.
+	 */
+	writel(0x00, &pl010->ctrl);
+
+	/*
+	 * Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled.
+	 */
+	writel(UART_PL010_LCRH_WLEN_8 | UART_PL010_LCRH_FEN,
+		&pl010->linctrlhigh);
+
+	/*
+	 * Finally, enable the UART
+	 */
+	writel(UART_PL010_CR_UARTEN, &pl010->ctrl);
+
+	return 0;
+}
+
+static void pl010_putc(struct console_device *cdev, char c)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+
+	/* Wait until there is space in the FIFO */
+	while (readl(&pl010->flag) & UART_PL010_FR_TXFF)
+		; /* noop */
+
+	/* Send the character */
+	writel(c, &pl010->data);
+}
+
+static int pl010_getc(struct console_device *cdev)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	unsigned int data;
+
+	/* Wait until there is data in the FIFO */
+	while (readl(&pl010->flag) & UART_PL010_FR_RXFE)
+		; /* noop */
+
+	data = readl(&pl010->data);
+
+	/* Check for an error flag */
+	if (data & 0xFFFFFF00) {
+		/* Clear the error */
+		writel(0xFFFFFFFF, &pl010->errclr);
+		return -1;
+	}
+
+	return (int)data;
+}
+
+static int pl010_tstc(struct console_device *cdev)
+{
+	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+
+	return !(readl(&pl010->flag) & UART_PL010_FR_RXFE);
+}
+
+static int pl010_probe(struct device_d *dev)
+{
+	struct console_device *cdev;
+
+	cdev = malloc(sizeof(struct console_device));
+	dev->type_data = cdev;
+	cdev->dev = dev;
+	cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+	cdev->tstc = pl010_tstc;
+	cdev->putc = pl010_putc;
+	cdev->getc = pl010_getc;
+	cdev->setbrg = pl010_setbaudrate;
+
+	pl010_init_port(cdev);
+
+	console_register(cdev);
+
+	return 0;
+}
+
+static struct driver_d pl010_driver = {
+	.name  = "pl010_serial",
+	.probe = pl010_probe,
+};
+
+static int pl010_init(void)
+{
+	register_driver(&pl010_driver);
+
+	return 0;
+}
+
+console_initcall(pl010_init);
diff --git a/drivers/serial/serial_pl010.h b/drivers/serial/serial_pl010.h
new file mode 100644
index 0000000..6124e0e
--- /dev/null
+++ b/drivers/serial/serial_pl010.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * (C) Copyright 2003, 2004
+ * ARM Ltd.
+ * Philippe Robin, <philippe.robin at arm.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
+ */
+
+struct hldc_struct {
+	uint32_t ctrl;
+	uint32_t addmtchval;
+	uint32_t addmask;
+	uint32_t rxinfobuf;
+	uint32_t sts;
+};
+
+struct pl010_struct {
+	uint32_t data;
+	union {
+		uint32_t rxsts;
+		uint32_t errclr;
+	};
+	uint32_t linctrlhigh;
+	uint32_t linctrlmid;
+	uint32_t linctrllow;
+	uint32_t ctrl;
+	uint32_t flag;
+	union {
+		uint32_t intid;
+		uint32_t intclr;
+	};
+	uint32_t not_used0[2];
+	uint32_t dmactrl;
+	uint32_t not_used1[53];
+	uint32_t modemctrl;
+	uint32_t modemsts;
+	uint32_t not_used2[65];
+	struct hldc_struct hldc;
+};
+
+#define UART_PL010_RSR_OE	(1 << 3)
+#define UART_PL010_RSR_BE	(1 << 2)
+#define UART_PL010_RSR_PE	(1 << 1)
+#define UART_PL010_RSR_FE	(1 << 0)
+
+#define UART_PL010_FR_TXFE	(1 << 7)
+#define UART_PL010_FR_RXFF	(1 << 6)
+#define UART_PL010_FR_TXFF	(1 << 5)
+#define UART_PL010_FR_RXFE	(1 << 4)
+#define UART_PL010_FR_BUSY	(1 << 3)
+#define UART_PL010_FR_TMSK	(UART_PL010_FR_TXFF + UART_PL010_FR_BUSY)
+
+#define UART_PL010_CR_LPE	(1 << 7)
+#define UART_PL010_CR_RTIE	(1 << 6)
+#define UART_PL010_CR_TIE	(1 << 5)
+#define UART_PL010_CR_RIE	(1 << 4)
+#define UART_PL010_CR_MSIE	(1 << 3)
+#define UART_PL010_CR_IIRLP	(1 << 2)
+#define UART_PL010_CR_SIREN	(1 << 1)
+#define UART_PL010_CR_UARTEN	(1 << 0)
+
+#define UART_PL010_LCRH_WLEN_8	(3 << 5)
+#define UART_PL010_LCRH_WLEN_7	(2 << 5)
+#define UART_PL010_LCRH_WLEN_6	(1 << 5)
+#define UART_PL010_LCRH_WLEN_5	(0 << 5)
+#define UART_PL010_LCRH_FEN	(1 << 4)
+#define UART_PL010_LCRH_STP2	(1 << 3)
+#define UART_PL010_LCRH_EPS	(1 << 2)
+#define UART_PL010_LCRH_PEN	(1 << 1)
+#define UART_PL010_LCRH_BRK	(1 << 0)
+
+#define UART_PL010_BAUD_460800	1
+#define UART_PL010_BAUD_230400	3
+#define UART_PL010_BAUD_115200	7
+#define UART_PL010_BAUD_57600	15
+#define UART_PL010_BAUD_38400	23
+#define UART_PL010_BAUD_19200	47
+#define UART_PL010_BAUD_14400	63
+#define UART_PL010_BAUD_9600	95
+#define UART_PL010_BAUD_4800	191
+#define UART_PL010_BAUD_2400	383
+#define UART_PL010_BAUD_1200	767
-- 
1.6.3.1



From matthias at kaehlcke.net  Tue Jan 12 14:30:56 2010
From: matthias at kaehlcke.net (Matthias Kaehlcke)
Date: Tue, 12 Jan 2010 20:30:56 +0100
Subject: [PATCH 5/5] Add support for EDB93xx boards
Message-ID: <20100112193056.GQ14051@darwin>

Added support for the following Cirrus Logic EDB93xx boards:

EDB9301
EDB9302
EDB9302A
EDB9307
EDB9307A
EDB93012
EDB9315
EDB9315A

Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
---
 Documentation/boards.dox              |    8 +
 arch/arm/configs/edb93xx_defconfig    |  236 +++++++++++++++++++++++++++++++++
 board/edb93xx/Makefile                |    2 +
 board/edb93xx/config.h                |    4 +
 board/edb93xx/early_udelay.h          |   34 +++++
 board/edb93xx/edb93xx.c               |  172 ++++++++++++++++++++++++
 board/edb93xx/edb93xx.dox             |  108 +++++++++++++++
 board/edb93xx/edb93xx.h               |   48 +++++++
 board/edb93xx/env/bin/boot            |   48 +++++++
 board/edb93xx/env/bin/flash_partition |   22 +++
 board/edb93xx/env/bin/init            |   19 +++
 board/edb93xx/env/bin/set_nor_parts   |    3 +
 board/edb93xx/env/bin/update_kernel   |   16 +++
 board/edb93xx/env/bin/update_rootfs   |   16 +++
 board/edb93xx/env/config              |   16 +++
 board/edb93xx/flash_cfg.c             |   38 ++++++
 board/edb93xx/pll_cfg.c               |   58 ++++++++
 board/edb93xx/pll_cfg.h               |   72 ++++++++++
 board/edb93xx/sdram_cfg.c             |  127 ++++++++++++++++++
 board/edb93xx/sdram_cfg.h             |  144 ++++++++++++++++++++
 20 files changed, 1191 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/configs/edb93xx_defconfig
 create mode 100644 board/edb93xx/Makefile
 create mode 100644 board/edb93xx/config.h
 create mode 100644 board/edb93xx/early_udelay.h
 create mode 100644 board/edb93xx/edb93xx.c
 create mode 100644 board/edb93xx/edb93xx.dox
 create mode 100644 board/edb93xx/edb93xx.h
 create mode 100644 board/edb93xx/env/bin/boot
 create mode 100644 board/edb93xx/env/bin/flash_partition
 create mode 100644 board/edb93xx/env/bin/init
 create mode 100644 board/edb93xx/env/bin/set_nor_parts
 create mode 100644 board/edb93xx/env/bin/update_kernel
 create mode 100644 board/edb93xx/env/bin/update_rootfs
 create mode 100644 board/edb93xx/env/config
 create mode 100644 board/edb93xx/flash_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.c
 create mode 100644 board/edb93xx/pll_cfg.h
 create mode 100644 board/edb93xx/sdram_cfg.c
 create mode 100644 board/edb93xx/sdram_cfg.h

diff --git a/Documentation/boards.dox b/Documentation/boards.dox
index dba547f..7c7f4d1 100644
--- a/Documentation/boards.dox
+++ b/Documentation/boards.dox
@@ -20,6 +20,14 @@ ARM type:
 @li @subpage a9m2440
 @li @subpage a9m2410
 @li @subpage eukrea_cpuimx27
+ at li @subpage edb9301
+ at li @subpage edb9302
+ at li @subpage edb9302a
+ at li @subpage edb9307
+ at li @subpage edb9307a
+ at li @subpage edb9312
+ at li @subpage edb9315
+ at li @subpage edb9315a
 
 Blackfin type:
 
diff --git a/arch/arm/configs/edb93xx_defconfig b/arch/arm/configs/edb93xx_defconfig
new file mode 100644
index 0000000..d6b4b19
--- /dev/null
+++ b/arch/arm/configs/edb93xx_defconfig
@@ -0,0 +1,236 @@
+#
+# Automatically generated make config: don't edit
+# barebox version: 2009.12.0
+# Fri Jan  8 17:27:15 2010
+#
+CONFIG_ARM=y
+
+#
+# System Type
+#
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_AT91RM9200 is not set
+CONFIG_ARCH_EP93XX=y
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_S3C24xx is not set
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_ARM920T=y
+CONFIG_CPU_32v4T=y
+
+#
+# processor features
+#
+CONFIG_ARCH_TEXT_BASE=0x05700000
+CONFIG_BOARDINFO="Cirrus Logic EDB9301"
+CONFIG_EP93XX_SDCE3_SYNC_PHYS_OFFSET=y
+
+#
+# Cirrus EP93xx System-on-Chip
+#
+CONFIG_ARCH_EP9301=y
+# CONFIG_ARCH_EP9302 is not set
+# CONFIG_ARCH_EP9307 is not set
+# CONFIG_ARCH_EP9312 is not set
+# CONFIG_ARCH_EP9315 is not set
+CONFIG_MACH_EDB9301=y
+CONFIG_EP93XX_SDRAM_NUM_BANKS=4
+CONFIG_EP93XX_SDRAM_BANK0_BASE=0x00000000
+CONFIG_EP93XX_SDRAM_BANK0_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK1_BASE=0x01000000
+CONFIG_EP93XX_SDRAM_BANK1_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK2_BASE=0x04000000
+CONFIG_EP93XX_SDRAM_BANK2_SIZE=0x00800000
+CONFIG_EP93XX_SDRAM_BANK3_BASE=0x05000000
+CONFIG_EP93XX_SDRAM_BANK3_SIZE=0x00800000
+CONFIG_AEABI=y
+
+#
+# Arm specific settings         
+#
+CONFIG_CMD_ARM_CPUINFO=y
+CONFIG_CMDLINE_TAG=y
+CONFIG_SETUP_MEMORY_TAGS=y
+# CONFIG_INITRD_TAG is not set
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_GREGORIAN_CALENDER=y
+CONFIG_HAS_KALLSYMS=y
+CONFIG_HAS_MODULES=y
+CONFIG_CMD_MEMORY=y
+CONFIG_ENV_HANDLING=y
+CONFIG_GENERIC_GPIO=y
+
+#
+# General Settings              
+#
+CONFIG_LOCALVERSION_AUTO=y
+
+#
+# memory layout                 
+#
+CONFIG_HAVE_CONFIGURABLE_TEXT_BASE=y
+CONFIG_TEXT_BASE=0x05700000
+CONFIG_HAVE_CONFIGURABLE_MEMORY_LAYOUT=y
+CONFIG_MEMORY_LAYOUT_DEFAULT=y
+# CONFIG_MEMORY_LAYOUT_FIXED is not set
+CONFIG_STACK_SIZE=0x8000
+CONFIG_MALLOC_SIZE=0x400000
+# CONFIG_BROKEN is not set
+# CONFIG_EXPERIMENTAL is not set
+CONFIG_MACH_HAS_LOWLEVEL_INIT=y
+CONFIG_MACH_DO_LOWLEVEL_INIT=y
+CONFIG_PROMPT="barebox:"
+CONFIG_BAUDRATE=115200
+CONFIG_LONGHELP=y
+CONFIG_CBSIZE=1024
+CONFIG_MAXARGS=16
+CONFIG_SHELL_HUSH=y
+# CONFIG_SHELL_SIMPLE is not set
+CONFIG_GLOB=y
+CONFIG_PROMPT_HUSH_PS2="> "
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DYNAMIC_CRC_TABLE=y
+CONFIG_ERRNO_MESSAGES=y
+CONFIG_TIMESTAMP=y
+CONFIG_CONSOLE_FULL=y
+CONFIG_CONSOLE_ACTIVATE_FIRST=y
+# CONFIG_OF_FLAT_TREE is not set
+CONFIG_PARTITION=y
+CONFIG_DEFAULT_ENVIRONMENT=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="board/edb93xx/env"
+
+#
+# Debugging                     
+#
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_ENABLE_FLASH_NOISE is not set
+# CONFIG_ENABLE_PARTITION_NOISE is not set
+# CONFIG_ENABLE_DEVICE_NOISE is not set
+
+#
+# Commands                      
+#
+
+#
+# scripting                     
+#
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_LOADENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TRUE=y
+CONFIG_CMD_FALSE=y
+
+#
+# file commands                 
+#
+CONFIG_CMD_LS=y
+CONFIG_CMD_RM=y
+CONFIG_CMD_CAT=y
+CONFIG_CMD_MKDIR=y
+CONFIG_CMD_RMDIR=y
+CONFIG_CMD_CP=y
+CONFIG_CMD_PWD=y
+CONFIG_CMD_CD=y
+CONFIG_CMD_MOUNT=y
+CONFIG_CMD_UMOUNT=y
+
+#
+# console                       
+#
+CONFIG_CMD_CLEAR=y
+CONFIG_CMD_ECHO=y
+
+#
+# memory                        
+#
+# CONFIG_CMD_LOADB is not set
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_MTEST=y
+# CONFIG_CMD_MTEST_ALTERNATIVE is not set
+
+#
+# flash                         
+#
+CONFIG_CMD_FLASH=y
+
+#
+# booting                       
+#
+CONFIG_CMD_BOOTM=y
+# CONFIG_CMD_BOOTM_ZLIB is not set
+# CONFIG_CMD_BOOTM_BZLIB is not set
+# CONFIG_CMD_BOOTM_SHOW_TYPE is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_BOOTU=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_TEST=y
+CONFIG_CMD_VERSION=y
+CONFIG_CMD_HELP=y
+CONFIG_CMD_DEVINFO=y
+CONFIG_CMD_GPIO=y
+CONFIG_NET=y
+CONFIG_NET_DHCP=y
+# CONFIG_NET_RARP is not set
+# CONFIG_NET_NFS is not set
+CONFIG_NET_PING=y
+CONFIG_NET_TFTP=y
+
+#
+# Drivers                       
+#
+
+#
+# serial drivers                
+#
+# CONFIG_DRIVER_SERIAL_ARM_DCC is not set
+# CONFIG_DRIVER_SERIAL_NS16550 is not set
+CONFIG_DRIVER_SERIAL_PL010=y
+CONFIG_MIIPHY=y
+
+#
+# Network drivers               
+#
+# CONFIG_DRIVER_NET_SMC911X is not set
+# CONFIG_DRIVER_NET_SMC91111 is not set
+CONFIG_DRIVER_NET_EP93XX=y
+
+#
+# SPI drivers                   
+#
+# CONFIG_SPI is not set
+# CONFIG_I2C is not set
+
+#
+# flash drivers                 
+#
+CONFIG_DRIVER_CFI=y
+# CONFIG_DRIVER_CFI_NEW is not set
+CONFIG_DRIVER_CFI_OLD=y
+# CONFIG_CFI_BUFFER_WRITE is not set
+# CONFIG_NAND is not set
+# CONFIG_USB is not set
+# CONFIG_USB_GADGET is not set
+# CONFIG_VIDEO is not set
+
+#
+# Filesystem support            
+#
+# CONFIG_FS_CRAMFS is not set
+CONFIG_FS_RAMFS=y
+CONFIG_FS_DEVFS=y
+CONFIG_CRC32=y
+# CONFIG_GENERIC_FIND_NEXT_BIT is not set
diff --git a/board/edb93xx/Makefile b/board/edb93xx/Makefile
new file mode 100644
index 0000000..e19cd7b
--- /dev/null
+++ b/board/edb93xx/Makefile
@@ -0,0 +1,2 @@
+
+obj-y += edb93xx.o flash_cfg.o pll_cfg.o sdram_cfg.o
diff --git a/board/edb93xx/config.h b/board/edb93xx/config.h
new file mode 100644
index 0000000..6ae9a40
--- /dev/null
+++ b/board/edb93xx/config.h
@@ -0,0 +1,4 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#endif  /* __CONFIG_H */
diff --git a/board/edb93xx/early_udelay.h b/board/edb93xx/early_udelay.h
new file mode 100644
index 0000000..3b26b3f
--- /dev/null
+++ b/board/edb93xx/early_udelay.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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>
+
+/* delay execution before timers are initialized */
+static inline void early_udelay(uint32_t usecs)
+{
+	/* loop takes 4 cycles at 5.0ns (fastest case, running at 200MHz) */
+	register uint32_t loops = (usecs * 1000) / 20;
+
+	__asm__ volatile ("1:\n"
+			"subs %0, %1, #1\n"
+			"bne 1b":"=r" (loops):"0" (loops));
+}
diff --git a/board/edb93xx/edb93xx.c b/board/edb93xx/edb93xx.c
new file mode 100644
index 0000000..add88e1
--- /dev/null
+++ b/board/edb93xx/edb93xx.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <driver.h>
+#include <environment.h>
+#include <fs.h>
+#include <init.h>
+#include <partition.h>
+#include <asm/armlinux.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <mach/ep93xx-regs.h>
+#include "edb93xx.h"
+
+/*
+ * Up to 32MiB NOR type flash, connected to
+ * CS line 6, data width is 16 bit
+ */
+static struct device_d cfi_dev = {
+	.name     = "cfi_flash",
+	.map_base = 0x60000000,
+	.size     = EDB93XX_CFI_FLASH_SIZE,
+};
+
+static struct memory_platform_data ram_dev_pdata0 = {
+	.name = "ram0",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram0_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK0_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK0_SIZE,
+	.platform_data = &ram_dev_pdata0,
+};
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+static struct memory_platform_data ram_dev_pdata1 = {
+	.name = "ram1",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram1_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK1_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK1_SIZE,
+	.platform_data = &ram_dev_pdata1,
+};
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+static struct memory_platform_data ram_dev_pdata2 = {
+	.name = "ram2",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram2_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK2_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK2_SIZE,
+	.platform_data = &ram_dev_pdata2,
+};
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+static struct memory_platform_data ram_dev_pdata3 = {
+	.name = "ram3",
+	.flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram3_dev = {
+	.name     = "mem",
+	.map_base = CONFIG_EP93XX_SDRAM_BANK3_BASE,
+	.size     = CONFIG_EP93XX_SDRAM_BANK3_SIZE,
+	.platform_data = &ram_dev_pdata3,
+};
+#endif
+
+static struct device_d eth_dev = {
+	.name     = "ep93xx_eth",
+};
+
+static int ep93xx_devices_init(void)
+{
+	register_device(&cfi_dev);
+
+	/*
+	 * Create partitions that should be
+	 * not touched by any regular user
+	 */
+	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
+	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
+
+	protect_file("/dev/env0", 1);
+
+	register_device(&sdram0_dev);
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	register_device(&sdram1_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	register_device(&sdram2_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	register_device(&sdram3_dev);
+#endif
+
+	armlinux_add_dram(&sdram0_dev);
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	armlinux_add_dram(&sdram1_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	armlinux_add_dram(&sdram2_dev);
+#endif
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	armlinux_add_dram(&sdram3_dev);
+#endif
+
+	register_device(&eth_dev);
+
+	armlinux_set_bootparams((void *)CONFIG_EP93XX_SDRAM_BANK0_BASE + 0x100);
+
+	armlinux_set_architecture(MACH_TYPE);
+
+	return 0;
+}
+
+device_initcall(ep93xx_devices_init);
+
+static struct device_d edb93xx_serial_device = {
+	.name     = "pl010_serial",
+	.map_base = UART1_BASE,
+	.size     = 4096,
+};
+
+static int edb93xx_console_init(void)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+
+	/*
+	 * set UARTBAUD bit to drive UARTs with 14.7456MHz instead of
+	 * 14.7456/2 MHz
+	 */
+	uint32_t value = readl(&syscon->pwrcnt);
+	value |= SYSCON_PWRCNT_UART_BAUD;
+	writel(value, &syscon->pwrcnt);
+
+	register_device(&edb93xx_serial_device);
+
+	return 0;
+}
+
+console_initcall(edb93xx_console_init);
diff --git a/board/edb93xx/edb93xx.dox b/board/edb93xx/edb93xx.dox
new file mode 100644
index 0000000..3964d55
--- /dev/null
+++ b/board/edb93xx/edb93xx.dox
@@ -0,0 +1,108 @@
+/** @page edb9301 Cirrus Logic EDB9301
+
+This boards is based on a Cirrus Logic EP9301 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS3
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9302 Cirrus Logic EDB9302
+
+This board is based on a Cirrus Logic EP9302 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS3
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9302a Cirrus Logic EDB9302A
+
+This board is based on a Cirrus Logic EP9302 CPU. The board is shipped with:
+
+- 16MiB NOR type Flash Memory
+- 32MiB synchronous dynamic RAM on CS0
+- 512kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+
+*/
+
+/** @page edb9307 Cirrus Logic EDB9307
+
+This board is based on a Cirrus Logic EP9307 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9307a Cirrus Logic EDB9307A
+
+This board is based on a Cirrus Logic EP9307 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS0
+- 512kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9312 Cirrus Logic EDB9312
+
+This board is based on a Cirrus Logic EP9312 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9315 Cirrus Logic EDB9315
+
+This board is based on a Cirrus Logic EP9315 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS3
+- 512kiB asynchronous SRAM
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
+
+/** @page edb9315a Cirrus Logic EDB9315A
+
+This board is based on a Cirrus Logic EP9315 CPU. The board is shipped with:
+
+- 32MiB NOR type Flash Memory
+- 64MiB synchronous dynamic RAM on CS0
+- 128kiB serial EEPROM
+- MII 10/100 Ethernet PHY
+- Stereo audio codec
+- Real-Time Clock
+- IR receiver
+
+*/
\ No newline at end of file
diff --git a/board/edb93xx/edb93xx.h b/board/edb93xx/edb93xx.h
new file mode 100644
index 0000000..5e5c6f5
--- /dev/null
+++ b/board/edb93xx/edb93xx.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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
+ */
+
+#if defined(CONFIG_MACH_EDB9301)
+#define MACH_TYPE MACH_TYPE_EDB9301
+#elif defined(CONFIG_MACH_EDB9302)
+#define MACH_TYPE MACH_TYPE_EDB9302
+#elif defined(CONFIG_MACH_EDB9302A)
+#define MACH_TYPE MACH_TYPE_EDB9302A
+#elif defined(CONFIG_MACH_EDB9307)
+#define MACH_TYPE MACH_TYPE_EDB9307
+#elif defined(CONFIG_MACH_EDB9307A)
+#define MACH_TYPE MACH_TYPE_EDB9307A
+#elif defined(CONFIG_MACH_EDB9312)
+#define MACH_TYPE MACH_TYPE_EDB9312
+#elif defined(CONFIG_MACH_EDB9315)
+#define MACH_TYPE MACH_TYPE_EDB9315
+#elif defined(CONFIG_MACH_EDB9315A)
+#define MACH_TYPE MACH_TYPE_EDB9315A
+#endif
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) || \
+	defined(CONFIG_MACH_EDB9302A)
+#define EDB93XX_CFI_FLASH_SIZE (16 * 1024 * 1024)
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) || \
+	defined(CONFIG_MACH_EDB9312) || defined(CONFIG_MACH_EDB9315) ||	\
+	defined(CONFIG_MACH_EDB9315A)
+#define EDB93XX_CFI_FLASH_SIZE (32 * 1024 * 1024)
+#endif
diff --git a/board/edb93xx/env/bin/boot b/board/edb93xx/env/bin/boot
new file mode 100644
index 0000000..143f3d0
--- /dev/null
+++ b/board/edb93xx/env/bin/boot
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+. /env/config
+
+if [ x${rootfs_boot_media} = xflash ];
+then
+		rootfs_img=/dev/nor0.rootfs_${active_cfg}
+
+		if [ x${active_cfg} = x1 ];
+		then
+				rootfs_blkdev=/dev/mtdblock4
+				cfg_1_ro="ro"
+				cfg_2_ro=""
+		else
+				rootfs_blkdev=/dev/mtdblock6
+				cfg_1_ro=""
+				cfg_2_ro="ro"
+		fi
+
+		bootargs_rootfs="root=${rootfs_blkdev} rootfstype=squashfs ro"
+elif [ x${rootfs_boot_media} = xnet ];
+then
+		bootargs_rootfs="root=/dev/nfs nfsroot=${eth0.serverip}:/srv/nfs/${board},v3,nolock,tcp ip=${eth0.ipaddr}"
+else
+		echo "ERROR: \$rootfs_boot_media invalid: ${rootfs_boot_media}"
+		exit 1
+fi
+
+if [ x${kernel_boot_media} = xflash ];
+then
+		kernel_img=/dev/nor0.kernel_${active_cfg}
+elif [ x${kernel_boot_media} = xnet ];
+then
+		cd /
+		tftp ${board}/kernel.img || exit 1
+		kernel_img=/kernel.img
+else
+		echo "ERROR: \$kernel_boot_media invalid: ${kernel_boot_media}"
+		exit 1
+fi
+
+source /env/bin/set_nor_parts
+
+bootargs_mtd="mtdparts=physmap-flash.0:${nor_parts}"
+
+bootargs="${bootargs_common} ${bootargs_mtd} ${bootargs_rootfs}"
+
+bootm ${kernel_img}
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/flash_partition b/board/edb93xx/env/bin/flash_partition
new file mode 100644
index 0000000..ded40aa
--- /dev/null
+++ b/board/edb93xx/env/bin/flash_partition
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $# != 2 ];
+then
+				echo "Usage: $0 <image> <partition>"
+				exit 1
+fi
+
+image=$1
+partition=$2
+
+echo "Unlocking ${partition}"
+unprotect ${partition}
+
+echo "Erasing ${partition}"
+erase ${partition}
+
+echo "Flashing ${image} to ${partition}"
+cp ${image} ${partition}
+
+echo "Locking ${partition}"
+protect ${partition}
diff --git a/board/edb93xx/env/bin/init b/board/edb93xx/env/bin/init
new file mode 100644
index 0000000..c6b5aed
--- /dev/null
+++ b/board/edb93xx/env/bin/init
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+
+# add partitions to barebox
+. /env/bin/set_nor_parts
+addpart /dev/nor0 ${nor_parts}
+
+echo
+echo -n "Hit any key to stop autoboot: "
+timeout -a $autoboot_timeout
+if [ $? != 0 ]; then
+	exit
+fi
+
+boot
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/set_nor_parts b/board/edb93xx/env/bin/set_nor_parts
new file mode 100644
index 0000000..38321fa
--- /dev/null
+++ b/board/edb93xx/env/bin/set_nor_parts
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+nor_parts="256k(barebox)ro,128k(env_boot),128k(env_boot.bak),1664k(kernel_1)${cfg_1_ro},6144k(rootfs_1)${cfg_1_ro},1664k(kernel_2)${cfg_2_ro},6144k(rootfs_2)${cfg_2_ro},128k(cfg_app),128k(cfg_app.bak)"
\ No newline at end of file
diff --git a/board/edb93xx/env/bin/update_kernel b/board/edb93xx/env/bin/update_kernel
new file mode 100644
index 0000000..3e4b9b0
--- /dev/null
+++ b/board/edb93xx/env/bin/update_kernel
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. /env/config
+
+if [ $# != 1 ];
+then
+				echo "Usage: $0 <1/2>"
+				exit 1
+fi
+
+partition=/dev/nor0.kernel_$1
+
+cd /
+tftp ${board}/kernel.img || exit 1
+
+flash_partition kernel.img ${partition}
diff --git a/board/edb93xx/env/bin/update_rootfs b/board/edb93xx/env/bin/update_rootfs
new file mode 100644
index 0000000..52a3699
--- /dev/null
+++ b/board/edb93xx/env/bin/update_rootfs
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. /env/config
+
+if [ $# != 1 ];
+then
+				echo "Usage: $0 <1/2>"
+				exit 1
+fi
+
+partition=/dev/nor0.rootfs_$1
+
+cd /
+tftp ${board}/rootfs.img || exit 1
+
+flash_partition rootfs.img ${partition}
diff --git a/board/edb93xx/env/config b/board/edb93xx/env/config
new file mode 100644
index 0000000..47ab209
--- /dev/null
+++ b/board/edb93xx/env/config
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+eth0.ipaddr=192.168.0.50
+eth0.netmask=255.255.0.0
+eth0.serverip=192.168.0.8
+eth0.ethaddr=80:81:82:83:84:85
+
+board=edb9301
+autoboot_timeout=3
+active_cfg=1
+bootargs_common="console=ttyAM0,115200"
+
+# valid media: flash/net
+kernel_boot_media=flash
+rootfs_boot_media=flash
+
diff --git a/board/edb93xx/flash_cfg.c b/board/edb93xx/flash_cfg.c
new file mode 100644
index 0000000..91a6a4e
--- /dev/null
+++ b/board/edb93xx/flash_cfg.c
@@ -0,0 +1,38 @@
+/*
+ * Flash setup for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <mach/ep93xx-regs.h>
+#include <asm/io.h>
+
+#define SMC_BCR6_VALUE	(2 << SMC_BCR_IDCY_SHIFT | 5 << SMC_BCR_WST1_SHIFT | \
+				SMC_BCR_BLE | 2 << SMC_BCR_WST2_SHIFT | \
+				1 << SMC_BCR_MW_SHIFT)
+
+void flash_cfg(void)
+{
+	struct smc_regs *smc = (struct smc_regs *)SMC_BASE;
+
+	writel(SMC_BCR6_VALUE, &smc->bcr6);
+}
diff --git a/board/edb93xx/pll_cfg.c b/board/edb93xx/pll_cfg.c
new file mode 100644
index 0000000..a687af0
--- /dev/null
+++ b/board/edb93xx/pll_cfg.c
@@ -0,0 +1,58 @@
+/*
+ * PLL setup for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <common.h>
+#include <asm/io.h>
+#include "pll_cfg.h"
+#include "early_udelay.h"
+
+void pll_cfg(void)
+{
+	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;
+
+	/* setup PLL1 */
+	writel(CLKSET1_VAL, &syscon->clkset1);
+
+	/*
+	 * flush the pipeline
+	 * writing to CLKSET1 causes the EP93xx to enter standby for between
+	 * 8 ms to 16 ms, until PLL1 stabilizes
+	 */
+	asm("nop");
+	asm("nop");
+	asm("nop");
+	asm("nop");
+	asm("nop");
+
+	/* setup PLL2 */
+	writel(CLKSET2_VAL, &syscon->clkset2);
+
+	/*
+	 * the user's guide recommends to wait at least 1 ms for PLL2 to
+	 * stabilize
+	 */
+	early_udelay(1000);
+}
diff --git a/board/edb93xx/pll_cfg.h b/board/edb93xx/pll_cfg.h
new file mode 100644
index 0000000..9691339
--- /dev/null
+++ b/board/edb93xx/pll_cfg.h
@@ -0,0 +1,72 @@
+/*
+ * PLL register values for Cirrus edb93xx boards
+ *
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * 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 <mach/ep93xx-regs.h>
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) || \
+	defined(CONFIG_MACH_EDB9302A)
+/*
+ * fclk_div: 2, nbyp1: 1, hclk_div: 5, pclk_div: 2
+ * pll1_x1: 294912000.000000, pll1_x2ip: 36864000.000000,
+ * pll1_x2: 331776000.000000, pll1_out: 331776000.000000
+ */
+#define CLKSET1_VAL	(7 << SYSCON_CLKSET_PLL_X2IPD_SHIFT |      \
+			8 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT |	   \
+			19 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT |	   \
+			1 << SYSCON_CLKSET1_PCLK_DIV_SHIFT |	   \
+			3 << SYSCON_CLKSET1_HCLK_DIV_SHIFT |	   \
+			SYSCON_CLKSET1_NBYP1 |			   \
+			1 << SYSCON_CLKSET1_FCLK_DIV_SHIFT)
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) ||\
+	defined CONFIG_MACH_EDB9312 || defined(CONFIG_MACH_EDB9315) ||\
+	defined(CONFIG_MACH_EDB9315A)
+/*
+ * fclk_div: 2, nbyp1: 1, hclk_div: 4, pclk_div: 2
+ * pll1_x1: 3096576000.000000, pll1_x2ip: 129024000.000000,
+ * pll1_x2: 3999744000.000000, pll1_out: 1999872000.000000
+ */
+#define CLKSET1_VAL	(23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+			30 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+			20 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+			1 << SYSCON_CLKSET1_PCLK_DIV_SHIFT |   \
+			2 << SYSCON_CLKSET1_HCLK_DIV_SHIFT |   \
+			SYSCON_CLKSET1_NBYP1 |		       \
+			1 << SYSCON_CLKSET1_FCLK_DIV_SHIFT)
+#else
+#error "Undefined board"
+#endif
+
+/*
+ * usb_div: 4, nbyp2: 1, pll2_en: 1
+ * pll2_x1: 368640000.000000, pll2_x2ip: 15360000.000000,
+ * pll2_x2: 384000000.000000, pll2_out: 192000000.000000
+ */
+#define CLKSET2_VAL	(23 << SYSCON_CLKSET_PLL_X2IPD_SHIFT | \
+			24 << SYSCON_CLKSET_PLL_X2FBD2_SHIFT | \
+			24 << SYSCON_CLKSET_PLL_X1FBD1_SHIFT | \
+			1 << SYSCON_CLKSET_PLL_PS_SHIFT |      \
+			SYSCON_CLKSET2_PLL2_EN |	       \
+			SYSCON_CLKSET2_NBYP2 |		       \
+			3 << SYSCON_CLKSET2_USB_DIV_SHIFT)
diff --git a/board/edb93xx/sdram_cfg.c b/board/edb93xx/sdram_cfg.c
new file mode 100644
index 0000000..9f56f72
--- /dev/null
+++ b/board/edb93xx/sdram_cfg.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <common.h>
+#include <asm/io.h>
+#include "sdram_cfg.h"
+#include "early_udelay.h"
+
+#define PROGRAM_MODE_REG(bank)		(*(volatile uint32_t *)		\
+		(SDRAM_BASE_ADDR | SDRAM_BANK_SEL_##bank | SDRAM_MODE_REG_VAL))
+
+#define PRECHARGE_BANK(bank)		(*(volatile uint32_t *)	\
+				(SDRAM_BASE_ADDR | SDRAM_BANK_SEL_##bank))
+
+static void force_precharge(void);
+static void setup_refresh_timer(void);
+static void program_mode_registers(void);
+
+void sdram_cfg(void)
+{
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	writel(SDRAM_DEVCFG_VAL, &sdram->SDRAM_DEVCFG_REG);
+
+	/* Issue continous NOP commands */
+	writel(GLCONFIG_INIT | GLCONFIG_MRS | GLCONFIG_CKE, &sdram->glconfig);
+
+	early_udelay(200);
+
+	force_precharge();
+
+	setup_refresh_timer();
+
+	program_mode_registers();
+
+	/* Select normal operation mode */
+	writel(GLCONFIG_CKE, &sdram->glconfig);
+}
+
+static void force_precharge(void)
+{
+	/*
+	 * Errata most EP93xx revisions say that PRECHARGE ALL isn't always
+	 * issued.
+	 *
+	 * Do a read from each bank to make sure they're precharged
+	 */
+
+	PRECHARGE_BANK(0);
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	PRECHARGE_BANK(1);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	PRECHARGE_BANK(2);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	PRECHARGE_BANK(3);
+#endif
+}
+
+static void setup_refresh_timer(void)
+{
+	struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE;
+
+	/* Load refresh timer with 10 to issue refresh every 10 cycles */
+	writel(0x0a, &sdram->refrshtimr);
+
+	/*
+	 * Wait at least 80 clock cycles to provide 8 refresh cycles
+	 * to all SDRAMs
+	 */
+	early_udelay(1);
+
+	/*
+	 * Program refresh timer with normal value
+	 * We need 8192 refresh cycles every 64ms
+	 * at 15ns (HCLK >= 66MHz) per cycle:
+	 * 64ms / 8192 = 7.8125us
+	 * 7.8125us / 15ns = 520 (0x208)
+	 */
+	/*
+	 * TODO: redboot uses 0x1e0 for the slowest possible device
+	 * but i don't understand how this value is calculated
+	 */
+	writel(0x208, &sdram->refrshtimr);
+}
+
+static void program_mode_registers(void)
+{
+	PROGRAM_MODE_REG(0);
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
+	PROGRAM_MODE_REG(1);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
+	PROGRAM_MODE_REG(2);
+#endif
+
+#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
+	PROGRAM_MODE_REG(3);
+#endif
+}
diff --git a/board/edb93xx/sdram_cfg.h b/board/edb93xx/sdram_cfg.h
new file mode 100644
index 0000000..7babee8
--- /dev/null
+++ b/board/edb93xx/sdram_cfg.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2009 Matthias Kaehlcke <matthias at kaehlcke.net>
+ *
+ * Copyright (C) 2006 Dominic Rath <Dominic.Rath at gmx.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 <mach/ep93xx-regs.h>
+
+#define SDRAM_BASE_ADDR		CONFIG_EP93XX_SDRAM_BANK0_BASE
+
+#ifdef CONFIG_EP93XX_SDCE0_PHYS_OFFSET
+#define SDRAM_DEVCFG_REG	devcfg0
+#elif defined(CONFIG_EP93XX_SDCE3_SYNC_PHYS_OFFSET)
+#define SDRAM_DEVCFG_REG	devcfg3
+#else
+#error "SDRAM bank configuration"
+#endif
+
+#if defined(CONFIG_MACH_EDB9301) || defined(CONFIG_MACH_EDB9302) ||\
+	defined(CONFIG_MACH_EDB9302A)
+/*
+ * 1x Samsung K4S561632C-TC/L75 4M x 16bit x 4 banks SDRAM
+ *
+ * CLK cycle time min:
+ *	@ CAS latency = 3: 7.5ns
+ *	@ CAS latency = 2: 10ns
+ * We're running at 66MHz (15ns cycle time) external bus speed (HCLK),
+ * so it's safe to use CAS latency = 2
+ *
+ * RAS-to-CAS delay min:
+ *	20ns
+ * At 15ns cycle time, we use RAS-to-CAS delay = 2
+ *
+ * SROMLL = 1: Swap BA[1:0] with A[13:12], making the SDRAM appear
+ * as four blocks of 8MB size, instead of eight blocks of 4MB size:
+ *
+ * EDB9301/EDB9302:
+ *
+ * 0x00000000 - 0x007fffff
+ * 0x01000000 - 0x017fffff
+ * 0x04000000 - 0x047fffff
+ * 0x05000000 - 0x057fffff
+ *
+ *
+ * EDB9302a:
+ *
+ * 0xc0000000 - 0xc07fffff
+ * 0xc1000000 - 0xc17fffff
+ * 0xc4000000 - 0xc47fffff
+ * 0xc5000000 - 0xc57fffff
+ *
+ * BANKCOUNT = 1: This is a device with four banks
+ */
+
+#define SDRAM_DEVCFG_VAL (SDRAM_DEVCFG_BANKCOUNT |			\
+				SDRAM_DEVCFG_SROMLL |			\
+				SDRAM_DEVCFG_CASLAT_2 |			\
+				SDRAM_DEVCFG_RASTOCAS_2 |		\
+				SDRAM_DEVCFG_EXTBUSWIDTH)
+
+/*
+ * 16 bit ext. bus
+ *
+ * A[22:09] is output as SYA[13:0]
+ * CAS latency: 2
+ * Burst type: sequential
+ * Burst length: 8 (required for 16 bit ext. bus)
+ * SYA[13:0] = 0x0023
+ */
+#define SDRAM_MODE_REG_VAL	0x4600
+
+#define SDRAM_BANK_SEL_0	0x00000000 /* A[22:21] = b00 */
+#define SDRAM_BANK_SEL_1	0x00200000 /* A[22:21] = b01 */
+#define SDRAM_BANK_SEL_2	0x00400000 /* A[22:21] = b10 */
+#define SDRAM_BANK_SEL_3	0x00600000 /* A[22:21] = b11 */
+
+#elif defined(CONFIG_MACH_EDB9307) || defined(CONFIG_MACH_EDB9307A) ||\
+	defined CONFIG_MACH_EDB9312 || defined(CONFIG_MACH_EDB9315) ||\
+	defined(CONFIG_MACH_EDB9315A)
+/*
+ * 2x Samsung K4S561632C-TC/L75 4M x 16bit x 4 banks SDRAM
+ *
+ * CLK cycle time min:
+ *	@ CAS latency = 3: 7.5ns
+ *	@ CAS latency = 2: 10ns
+ * We're running at 100MHz (10ns cycle time) external bus speed (HCLK),
+ * so it's safe to use CAS latency = 2
+ *
+ * RAS-to-CAS delay min:
+ *	20ns
+ * At 10ns cycle time, we use RAS-to-CAS delay = 2
+ *
+ * EDB9307, EDB9312, EDB9315:
+ *
+ * 0x00000000 - 0x01ffffff
+ * 0x04000000 - 0x05ffffff
+ *
+ *
+ * EDB9307a, EDB9315a:
+ *
+ * 0xc0000000 - 0xc1ffffff
+ * 0xc4000000 - 0xc5ffffff
+ */
+
+#define SDRAM_DEVCFG_VAL	(SDRAM_DEVCFG_BANKCOUNT |		\
+				SDRAM_DEVCFG_SROMLL |			\
+				SDRAM_DEVCFG_CASLAT_2 |			\
+				SDRAM_DEVCFG_RASTOCAS_2)
+
+/*
+ * 32 bit ext. bus
+ *
+ * A[23:10] is output as SYA[13:0]
+ * CAS latency: 2
+ * Burst type: sequential
+ * Burst length: 4
+ * SYA[13:0] = 0x0022
+ */
+#define SDRAM_MODE_REG_VAL	0x8800
+
+#define SDRAM_BANK_SEL_0	0x00000000 /* A[23:22] = b00 */
+#define SDRAM_BANK_SEL_1	0x00400000 /* A[23:22] = b01 */
+#define SDRAM_BANK_SEL_2	0x00800000 /* A[23:22] = b10 */
+#define SDRAM_BANK_SEL_3	0x00c00000 /* A[23:22] = b11 */
+#endif
-- 
1.6.3.1



From s.hauer at pengutronix.de  Thu Jan 14 04:29:00 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 14 Jan 2010 10:29:00 +0100
Subject: [PATCHv2 00/14] Bring in basic x86 support into 'barebox'
In-Reply-To: <20100112101534.868276907@pengutronix.de>
References: <20100112101534.868276907@pengutronix.de>
Message-ID: <20100114092900.GB23110@pengutronix.de>

On Tue, Jan 12, 2010 at 11:15:34AM +0100, Juergen Beisert wrote:
> This patch series brings in some basic x86 support into the tree.
> At first this support can act as a boot loader on a BIOS based
> x86 machine like GRUB is. E.g. barebox will be stored in the MBR of
> a boot media the BIOS supports to boot from. This implementation still
> talks to the BIOS in real mode, to load or store data from/to a disk
> drive, but the barebox core itself runs in 32 bit flat mode.
> 
> Currently only a serial console is supported.
> 
> v2 of this patch series comes with some clean ups and also uses the discussed
> naming convention for BIOS based disk access. The whole series is updated to
> 'barebox' (instead of u-boot-v2). Note: Its tested only with QEMU yet. We are
> going to port it to real hardware now.
> 
> Comments are welcome.

Applied to -next.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Jan 14 04:29:32 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 14 Jan 2010 10:29:32 +0100
Subject: [PATCH 0/5] Add support for EDB93xx boards [rev2]
In-Reply-To: <20100112193030.GL14051@darwin>
References: <20100112193030.GL14051@darwin>
Message-ID: <20100114092932.GC23110@pengutronix.de>

On Tue, Jan 12, 2010 at 08:30:30PM +0100, Matthias Kaehlcke wrote:
> Add support for the following Cirrus Logic EDB93xx boards:
> 
> EDB9301
> EDB9302
> EDB9302A
> EDB9307
> EDB9307A
> EDB93012
> EDB9315
> EDB9315A
> 
> This patchset has been tested on boards based on the EDB9301 and
> EDB9307A designs
> 
> Changes with respect to rev1:
> 
>  * use global linker script with EP93xx specific ifdef instead of a
>    board specific one
>  * eth driver: remove TODO comments about impossible enhancements
>  * eth driver: remove MII_STATUS_* and ETH_STATUS_* macros
> 
> Matthias Kaehlcke (5):
>   ARM: Add support for EP93xx SoCs
>   Add EP93xx ethernet driver
>   Add support for EP9xx GPIOs
>   Add PrimeCell PL010 serial driver
>   Add support for EDB93xx boards

Applied to -next

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From pgmspam20101 at verizon.net  Thu Jan 14 14:02:39 2010
From: pgmspam20101 at verizon.net (pgmspam20101 at verizon.net)
Date: Thu, 14 Jan 2010 13:02:39 -0600 (CST)
Subject: compiling barebox/u-boot-v2 for beagleboard
Message-ID: <31940835.15183.1263495759571.JavaMail.root@vms064.mailsrvcs.net>

An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20100114/dd66ae75/attachment.htm>

From s.hauer at pengutronix.de  Fri Jan 15 03:05:15 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 15 Jan 2010 09:05:15 +0100
Subject: compiling barebox/u-boot-v2 for beagleboard
In-Reply-To: <31940835.15183.1263495759571.JavaMail.root@vms064.mailsrvcs.net>
References: <31940835.15183.1263495759571.JavaMail.root@vms064.mailsrvcs.net>
Message-ID: <20100115080515.GG23110@pengutronix.de>

Hello,

On Thu, Jan 14, 2010 at 01:02:39PM -0600, pgmspam20101 at verizon.net wrote:
> Hello,
>  
> I am trying to do the next stage of my build: i.e. building xloader(u-boot-v2)
> that I can load over USB using Nishant Menon's utilities (pusb).
>  
> I went and downloaded the beagleboard version of uboot-v2 from:
>               http://www.pengutronix.de/software/u-boot/v2/download/

Please get the newer version here (or directly from git):
http://barebox.org/download/barebox-2009.12.0.tar.bz2

> 
> [pgmutasi@ u-boot-2.0.0-rc10]$ make -f Makefile ARCH=arm CROSS_COMPILE=/opt/
> WindRiver/wrlinux-3.0/layers/wrll-toolchain-4.3-85/arm/toolchain/x86-linux2/bin
> /arm-wrs-linux-gnueabi-
> scripts/kconfig/conf -s arch/arm/Kconfig
>   SYMLINK include/asm-arm/arch -> include/asm-arm/arch-omap
>   SYMLINK include/asm-arm/proc -> include/asm-arm/proc-armv
>   CHK     include/linux/version.h
>   UPD     include/linux/version.h
>   CHK     include/linux/utsrelease.h
>   UPD     include/linux/utsrelease.h
>   SYMLINK include/asm -> include/asm-arm
>   SYMLINK include/config.h -> board/omap/config.h
>   CC      scripts/mod/empty.o
> scripts/mod/empty.c:1: error: bad value (armv7a) for -march= switch
> make[2]: *** [scripts/mod/empty.o] Error 1
> make[1]: *** [scripts/mod] Error 2
> make: *** [scripts] Error 2

It seems you compiler is too old. I get the same error with our
gcc-4.1.2 based toolchain, but I do not with a gcc-4.3.2 based
toolchain.

As an alternative you might wan't to use the following patch (untested):



From s.hauer at pengutronix.de  Fri Jan 15 03:01:34 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 15 Jan 2010 09:01:34 +0100
Subject: [PATCH] armv7: use -march=armv6 to compile v7 code
Message-ID: <mailman.152.1263542727.2170.barebox@lists.infradead.org>

-march=armv7-a is available only in in newer gccs (>=4.3.2?)
To make this work use 'mcr     p15, 0, r10, c7, c5, 4' instead
of isb as seen in the kernel head.S

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/Makefile        |    2 +-
 arch/arm/cpu/start-arm.S |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index ede2085..ab241dc 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -19,7 +19,7 @@ comma = ,
 # Note that GCC does not numerically define an architecture version
 # macro, but instead defines a whole series of macros which makes
 # testing for a specific architecture or later rather impossible.
-arch-$(CONFIG_CPU_32v7)		:=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
+arch-$(CONFIG_CPU_32v7)		:=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv6)
 arch-$(CONFIG_CPU_32v5)		:=-D__LINUX_ARM_ARCH__=5 $(call cc-option,-march=armv5te,-march=armv4t)
 arch-$(CONFIG_CPU_32v4T)	:=-D__LINUX_ARM_ARCH__=4 -march=armv4t
 
diff --git a/arch/arm/cpu/start-arm.S b/arch/arm/cpu/start-arm.S
index a30b281..6858dbc 100644
--- a/arch/arm/cpu/start-arm.S
+++ b/arch/arm/cpu/start-arm.S
@@ -152,7 +152,7 @@ inval_loop1:
 	cmp	r1, #2			/* see what cache we have at this level */
 	blt	skip_inval		/* skip if no cache, or just i-cache */
 	mcr	p15, 2, r10, c0, c0, 0	/* select current cache level in cssr */
-	isb				/* isb to sych the new cssr&csidr */
+	mcr     p15, 0, r10, c7, c5, 4	/* isb to sych the new cssr&csidr */
 	mrc	p15, 1, r1, c0, c0, 0	/* read the new csidr */
 	and	r2, r1, #7		/* extract the length of the cache lines */
 	add	r2, r2, #4		/* add 4 (line length offset) */
@@ -178,7 +178,7 @@ skip_inval:
 finished_inval:
 	mov	r10, #0			/* swith back to cache level 0 */
 	mcr	p15, 2, r10, c0, c0, 0	/* select current cache level in cssr */
-	isb
+	mcr     p15, 0, r10, c7, c5, 4  /* isb */
 #endif /* CONFIG_CPU_V7_DCACHE_SKIP */
 
 #else
-- 
1.6.6


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From jacmet at sunsite.dk  Fri Jan 15 05:39:33 2010
From: jacmet at sunsite.dk (Peter Korsgaard)
Date: Fri, 15 Jan 2010 11:39:33 +0100
Subject: [PATCH] documentation: It's U-Boot that doesn't have getopt,
	not Barebox
Message-ID: <1263551973-14588-1-git-send-email-jacmet@sunsite.dk>

Commit a3ffa97f (rename U-Boot-v2 project to barebox) also changed the
U-Boot references to Barebox in the getopt description, which doesn't
make much sense.

Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
---
 Documentation/barebox-main.dox |    2 +-
 README                         |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/barebox-main.dox b/Documentation/barebox-main.dox
index 42d1256..743add8 100644
--- a/Documentation/barebox-main.dox
+++ b/Documentation/barebox-main.dox
@@ -64,7 +64,7 @@ things right - without caring about losing support for old boards.
 
 - getopt
   - There is a small getopt implementation. Some commands got really
-    complicated (both in code and in usage) due to the fact that @a barebox only
+    complicated (both in code and in usage) due to the fact that @a U-Boot only
     allowed positional parameters.
 
 - editor
diff --git a/README b/README
index 6f5fb26..9b5317d 100644
--- a/README
+++ b/README
@@ -61,7 +61,7 @@ Features
 
 - getopt
   There is a small getopt implementation. Some commands got really
-  complicated (both in code and in usage) due to the fact that barebox only
+  complicated (both in code and in usage) due to the fact that U-Boot only
   allowed positional parameters.
 
 - editor
-- 
1.6.5



From eric at eukrea.com  Fri Jan 15 05:50:17 2010
From: eric at eukrea.com (Eric Benard)
Date: Fri, 15 Jan 2010 11:50:17 +0100
Subject: [PATCH 2/4] Add necessary clocks & defines to get I2C support for
	i.MX27
In-Reply-To: <1263552619-4601-1-git-send-email-eric@eukrea.com>
References: <1263552619-4601-1-git-send-email-eric@eukrea.com>
Message-ID: <1263552619-4601-2-git-send-email-eric@eukrea.com>

Signed-off-by: Eric Benard <eric at eukrea.com>
---
 arch/arm/mach-imx/include/mach/imx27-regs.h |    1 +
 arch/arm/mach-imx/speed-imx27.c             |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/imx27-regs.h b/arch/arm/mach-imx/include/mach/imx27-regs.h
index 33d67d6..6c31ccd 100644
--- a/arch/arm/mach-imx/include/mach/imx27-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx27-regs.h
@@ -16,6 +16,7 @@
 #define IMX_UART2_BASE             (0x0b000 + IMX_IO_BASE)
 #define IMX_UART3_BASE             (0x0c000 + IMX_IO_BASE)
 #define IMX_UART4_BASE             (0x0d000 + IMX_IO_BASE)
+#define IMX_I2C1_BASE              (0x12000 + IMX_IO_BASE)
 #define IMX_GPIO_BASE              (0x15000 + IMX_IO_BASE)
 #define IMX_TIM4_BASE              (0x19000 + IMX_IO_BASE)
 #define IMX_TIM5_BASE              (0x1a000 + IMX_IO_BASE)
diff --git a/arch/arm/mach-imx/speed-imx27.c b/arch/arm/mach-imx/speed-imx27.c
index deaca1e..cdcd419 100644
--- a/arch/arm/mach-imx/speed-imx27.c
+++ b/arch/arm/mach-imx/speed-imx27.c
@@ -154,6 +154,11 @@ ulong imx_get_lcdclk(void)
 	return imx_get_perclk3();
 }
 
+ulong imx_get_i2cclk(void)
+{
+	return imx_get_ipgclk();
+}
+
 void imx_dump_clocks(void)
 {
 	uint32_t	cid = CID;
-- 
1.6.3.3



From eric at eukrea.com  Fri Jan 15 05:50:16 2010
From: eric at eukrea.com (Eric Benard)
Date: Fri, 15 Jan 2010 11:50:16 +0100
Subject: [PATCH 1/4] eukrea_cpuimx27 : update timings
Message-ID: <1263552619-4601-1-git-send-email-eric@eukrea.com>

use optimized DDR, NOR & QuadUART timings

Signed-off-by: Eric Benard <eric at eukrea.com>
---
 board/eukrea_cpuimx27/eukrea_cpuimx27.c |   12 ++++++------
 board/eukrea_cpuimx27/lowlevel_init.S   |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/board/eukrea_cpuimx27/eukrea_cpuimx27.c b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
index 6878044..629399f 100644
--- a/board/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -198,9 +198,9 @@ static int eukrea_cpuimx27_devices_init(void)
 	eukrea_cpuimx27_mmu_init();
 
 	/* configure 16 bit nor flash on cs0 */
-	CS0U = 0x0000CC03;
-	CS0L = 0xa0330D01;
-	CS0A = 0x00220800;
+	CS0U = 0x00008F03;
+	CS0L = 0xA0330D01;
+	CS0A = 0x002208C0;
 
 	/* initizalize gpios */
 	for (i = 0; i < ARRAY_SIZE(mode); i++)
@@ -244,9 +244,9 @@ static int eukrea_cpuimx27_console_init(void)
 #endif
 	/* configure 8 bit UART on cs3 */
 	FMCR &= ~0x2;
-	CS3U = 0x0000DCF6;
-	CS3L = 0x444A4541;
-	CS3A = 0x44443302;
+	CS3U = 0x0000D603;
+	CS3L = 0x0D1D0D01;
+	CS3A = 0x00D20000;
 #ifdef CONFIG_DRIVER_SERIAL_NS16550
 	register_device(&quad_uart_serial_device);
 #endif
diff --git a/board/eukrea_cpuimx27/lowlevel_init.S b/board/eukrea_cpuimx27/lowlevel_init.S
index 4622af8..5295a8a 100644
--- a/board/eukrea_cpuimx27/lowlevel_init.S
+++ b/board/eukrea_cpuimx27/lowlevel_init.S
@@ -8,10 +8,10 @@
 
 #if defined CONFIG_EUKREA_CPUIMX27_SDRAM_256MB
 #define ROWS0	ESDCTL_ROW14
-#define CFG0	0x00695729
+#define CFG0	0x0029572D
 #elif defined CONFIG_EUKREA_CPUIMX27_SDRAM_128MB
 #define ROWS0	ESDCTL_ROW13
-#define CFG0	0x00395B28
+#define CFG0	0x00095728
 #endif
 
 #define ESDCTL0_VAL (ESDCTL0_SDE | ROWS0 | ESDCTL0_COL10)
-- 
1.6.3.3



From eric at eukrea.com  Fri Jan 15 05:50:18 2010
From: eric at eukrea.com (Eric Benard)
Date: Fri, 15 Jan 2010 11:50:18 +0100
Subject: [PATCH 3/4] I2C : add NS LP3972 PMIC support
In-Reply-To: <1263552619-4601-2-git-send-email-eric@eukrea.com>
References: <1263552619-4601-1-git-send-email-eric@eukrea.com>
	<1263552619-4601-2-git-send-email-eric@eukrea.com>
Message-ID: <1263552619-4601-3-git-send-email-eric@eukrea.com>

Signed-off-by: Eric Benard <eric at eukrea.com>
---
 drivers/i2c/Kconfig  |    3 +
 drivers/i2c/Makefile |    1 +
 drivers/i2c/lp3972.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/i2c/lp3972.h |    7 +++
 4 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/lp3972.c
 create mode 100644 include/i2c/lp3972.h

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 46723ed..f1b2949 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -13,4 +13,7 @@ config DRIVER_I2C_MC13892
 config DRIVER_I2C_MC9SDZ60
 	bool "MC9SDZ60 driver"
 
+config DRIVER_I2C_LP3972
+	bool "LP3972 driver"
+
 endif
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 5dd642f..62d030b 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRIVER_I2C_IMX) += i2c-imx.o
 
 obj-$(CONFIG_DRIVER_I2C_MC13892) += mc13892.o
 obj-$(CONFIG_DRIVER_I2C_MC9SDZ60) += mc9sdz60.o
+obj-$(CONFIG_DRIVER_I2C_LP3972) += lp3972.o
diff --git a/drivers/i2c/lp3972.c b/drivers/i2c/lp3972.c
new file mode 100644
index 0000000..9826699
--- /dev/null
+++ b/drivers/i2c/lp3972.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2007 Sascha Hauer, Pengutronix
+ *               2009 Marc Kleine-Budde <mkl at pengutronix.de>
+ *               2009 Eric Benard <eric at eukrea.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
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+
+#include <i2c/i2c.h>
+
+#include <asm/byteorder.h>
+
+#define DRIVERNAME		"lp3972"
+
+struct lp_priv {
+	struct cdev		cdev;
+	struct i2c_client	*client;
+};
+
+#define to_lp_priv(a)		container_of(a, struct lp_priv, cdev)
+
+static struct lp_priv *lp_dev;
+
+struct i2c_client *lp3972_get_client(void)
+{
+	if (!lp_dev)
+		return NULL;
+
+	return lp_dev->client;
+}
+
+static u32 lp_read_reg(struct lp_priv *lp, int reg)
+{
+	u8 buf;
+
+	i2c_read_reg(lp->client, reg, &buf, sizeof(buf));
+
+	return buf;
+}
+
+static ssize_t lp_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
+{
+	struct lp_priv *priv = to_lp_priv(cdev);
+	int i = count;
+	u8 *buf = _buf;
+
+	while (i) {
+		*buf = lp_read_reg(priv, offset);
+		buf++;
+		i--;
+		offset++;
+	}
+
+	return count;
+}
+
+static struct file_operations lp_fops = {
+	.lseek	= dev_lseek_default,
+	.read	= lp_read,
+};
+
+static int lp_probe(struct device_d *dev)
+{
+	if (lp_dev)
+		return -EBUSY;
+
+	lp_dev = xzalloc(sizeof(struct lp_priv));
+	lp_dev->cdev.name = DRIVERNAME;
+	lp_dev->client = to_i2c_client(dev);
+	lp_dev->cdev.size = 256;
+	lp_dev->cdev.dev = dev;
+	lp_dev->cdev.ops = &lp_fops;
+
+	devfs_create(&lp_dev->cdev);
+
+	return 0;
+}
+
+static struct driver_d lp_driver = {
+	.name  = DRIVERNAME,
+	.probe = lp_probe,
+};
+
+static int lp_init(void)
+{
+	register_driver(&lp_driver);
+	return 0;
+}
+
+device_initcall(lp_init);
diff --git a/include/i2c/lp3972.h b/include/i2c/lp3972.h
new file mode 100644
index 0000000..edb5801
--- /dev/null
+++ b/include/i2c/lp3972.h
@@ -0,0 +1,7 @@
+#ifndef __ASM_ARCH_LP3972_H
+#define __ASM_ARCH_LP3972_H
+
+extern struct i2c_client *lp3972_get_client(void);
+
+#endif /* __ASM_ARCH_LP3972_H */
+
-- 
1.6.3.3



From eric at eukrea.com  Fri Jan 15 05:50:19 2010
From: eric at eukrea.com (Eric Benard)
Date: Fri, 15 Jan 2010 11:50:19 +0100
Subject: [PATCH 4/4] Eukrea CPUIMX27 : add I2C and LP3972 support
In-Reply-To: <1263552619-4601-3-git-send-email-eric@eukrea.com>
References: <1263552619-4601-1-git-send-email-eric@eukrea.com>
	<1263552619-4601-2-git-send-email-eric@eukrea.com>
	<1263552619-4601-3-git-send-email-eric@eukrea.com>
Message-ID: <1263552619-4601-4-git-send-email-eric@eukrea.com>

This allows to properly setup the voltage on LCD pins at boot.

Signed-off-by: Eric Benard <eric at eukrea.com>
---
 board/eukrea_cpuimx27/eukrea_cpuimx27.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/board/eukrea_cpuimx27/eukrea_cpuimx27.c b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
index 629399f..0908dca 100644
--- a/board/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -21,6 +21,7 @@
  */
 
 #include <common.h>
+#include <errno.h>
 #include <net.h>
 #include <cfi_flash.h>
 #include <init.h>
@@ -42,6 +43,8 @@
 #include <mach/imx-pll.h>
 #include <ns16550.h>
 #include <asm/mmu.h>
+#include <i2c/i2c.h>
+#include <i2c/lp3972.h>
 
 static struct device_d cfi_dev = {
 	.name     = "cfi_flash",
@@ -140,6 +143,17 @@ static struct device_d quad_uart_serial_device = {
 };
 #endif
 
+static struct i2c_board_info i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("lp3972", 0x34),
+	},
+};
+
+static struct device_d i2c_dev = {
+	.name		= "i2c-imx",
+	.map_base	= IMX_I2C1_BASE,
+};
+
 #ifdef CONFIG_MMU
 static void eukrea_cpuimx27_mmu_init(void)
 {
@@ -187,6 +201,8 @@ static int eukrea_cpuimx27_devices_init(void)
 		PD15_AOUT_FEC_COL,
 		PD16_AIN_FEC_TX_ER,
 		PF23_AIN_FEC_TX_EN,
+		PD17_PF_I2C_DATA,
+		PD18_PF_I2C_CLK,
 #ifdef CONFIG_DRIVER_SERIAL_IMX
 		PE12_PF_UART1_TXD,
 		PE13_PF_UART1_RXD,
@@ -213,6 +229,10 @@ static int eukrea_cpuimx27_devices_init(void)
 	register_device(&nand_dev);
 	register_device(&sdram_dev);
 
+	PCCR0 |= PCCR0_I2C1_EN;
+	i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+	register_device(&i2c_dev);
+
 	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
 	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
 	protect_file("/dev/env0", 1);
@@ -257,9 +277,18 @@ console_initcall(eukrea_cpuimx27_console_init);
 
 static int eukrea_cpuimx27_late_init(void)
 {
+	struct i2c_client *client;
+	u8 reg[1];
+
 	console_flush();
 	register_device(&fec_dev);
 
+	client = lp3972_get_client();
+	if (!client)
+		return -ENODEV;
+	reg[0] = 0xa0;
+	i2c_write_reg(client, 0x39, reg, sizeof(reg));
+
 	return 0;
 }
 
-- 
1.6.3.3



From jacmet at sunsite.dk  Fri Jan 15 08:26:51 2010
From: jacmet at sunsite.dk (Peter Korsgaard)
Date: Fri, 15 Jan 2010 14:26:51 +0100
Subject: [PATCH] addpart: support @<offset>
Message-ID: <1263562011-20130-1-git-send-email-jacmet@sunsite.dk>

We claim to be compatible with the kernel's cmdlinepart parser, so
support <size>@<offset> like the kernel does.

Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
---
 commands/partition.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/commands/partition.c b/commands/partition.c
index 3cb7b61..b7e2031 100755
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -41,8 +41,10 @@
 #include <linux/stat.h>
 #include <libgen.h>
 
+#define SIZE_REMAINING ((ulong)-1)
+
 static int mtd_part_do_parse_one(char *devname, const char *partstr,
-				 char **endp, unsigned long offset,
+				 char **endp, unsigned long *offset,
 				 off_t devsize, size_t *retsize)
 {
 	ulong size;
@@ -54,12 +56,18 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 	memset(buf, 0, PATH_MAX);
 
 	if (*partstr == '-') {
-		size = devsize - offset;
+		size = SIZE_REMAINING;
 		end = (char *)partstr + 1;
 	} else {
 		size = strtoul_suffix(partstr, &end, 0);
 	}
 
+	if (*end == '@')
+		*offset = strtoul_suffix(end+1, &end, 0);
+
+	if (size == SIZE_REMAINING)
+		size = devsize - *offset;
+
 	partstr = end;
 
 	if (*partstr == '(') {
@@ -76,7 +84,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 		end++;
 	}
 
-	if (size + offset > devsize) {
+	if (size + *offset > devsize) {
 		printf("%s: partition end is beyond device\n", buf);
 		return -EINVAL;
 	}
@@ -93,7 +101,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 
 	*retsize = size;
 
-	ret = devfs_add_partition(devname, offset, size, flags, buf);
+	ret = devfs_add_partition(devname, *offset, size, flags, buf);
 	if (ret)
 		printf("cannot create %s: %s\n", buf, strerror(-ret));
 	return ret;
@@ -123,7 +131,7 @@ static int do_addpart(cmd_tbl_t * cmdtp, int argc, char *argv[])
 	while (1) {
 		size_t size = 0;
 
-		if (mtd_part_do_parse_one(devname, endp, &endp, offset, devsize, &size))
+		if (mtd_part_do_parse_one(devname, endp, &endp, &offset, devsize, &size))
 			return 1;
 
 		offset += size;
-- 
1.6.5



From jacmet at sunsite.dk  Fri Jan 15 08:31:29 2010
From: jacmet at sunsite.dk (Peter Korsgaard)
Date: Fri, 15 Jan 2010 14:31:29 +0100
Subject: [PATCHV2] addpart: support @<offset>
Message-ID: <1263562289-20302-1-git-send-email-jacmet@sunsite.dk>

We claim to be compatible with the kernel's cmdlinepart parser, so
support <size>@<offset> like the kernel does.

Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
---
 Changes since v1:
 - Update doxygen documentation to match.

 commands/partition.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/commands/partition.c b/commands/partition.c
index 3cb7b61..d7bd940 100755
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -41,8 +41,10 @@
 #include <linux/stat.h>
 #include <libgen.h>
 
+#define SIZE_REMAINING ((ulong)-1)
+
 static int mtd_part_do_parse_one(char *devname, const char *partstr,
-				 char **endp, unsigned long offset,
+				 char **endp, unsigned long *offset,
 				 off_t devsize, size_t *retsize)
 {
 	ulong size;
@@ -54,12 +56,18 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 	memset(buf, 0, PATH_MAX);
 
 	if (*partstr == '-') {
-		size = devsize - offset;
+		size = SIZE_REMAINING;
 		end = (char *)partstr + 1;
 	} else {
 		size = strtoul_suffix(partstr, &end, 0);
 	}
 
+	if (*end == '@')
+		*offset = strtoul_suffix(end+1, &end, 0);
+
+	if (size == SIZE_REMAINING)
+		size = devsize - *offset;
+
 	partstr = end;
 
 	if (*partstr == '(') {
@@ -76,7 +84,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 		end++;
 	}
 
-	if (size + offset > devsize) {
+	if (size + *offset > devsize) {
 		printf("%s: partition end is beyond device\n", buf);
 		return -EINVAL;
 	}
@@ -93,7 +101,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 
 	*retsize = size;
 
-	ret = devfs_add_partition(devname, offset, size, flags, buf);
+	ret = devfs_add_partition(devname, *offset, size, flags, buf);
 	if (ret)
 		printf("cannot create %s: %s\n", buf, strerror(-ret));
 	return ret;
@@ -123,7 +131,7 @@ static int do_addpart(cmd_tbl_t * cmdtp, int argc, char *argv[])
 	while (1) {
 		size_t size = 0;
 
-		if (mtd_part_do_parse_one(devname, endp, &endp, offset, devsize, &size))
+		if (mtd_part_do_parse_one(devname, endp, &endp, &offset, devsize, &size))
 			return 1;
 
 		offset += size;
@@ -167,12 +175,12 @@ BAREBOX_CMD_END
  * Adds a partition description to a device. The partition description has the
  * form
  *
- * size1(name1)[ro],size2(name2)[ro],...
+ * size1[@offset1](name1)[ro],size2[@offset2](name2)[ro],...
  *
- * \<device> is the device name under. Sizes can be given in decimal or - if
- * prefixed with 0x - in hex. Sizes can have an optional suffix K,M,G. The
- * size of the last partition can be specified as '-' for the remaining space
- * of the device.
+ * \<device> is the device name under. Sizes and offsets can be given in
+ * decimal or - if prefixed with 0x - in hex. Both can have an optional suffix
+ * K,M,G. The size of the last partition can be specified as '-' for the
+ * remaining space of the device.
  *
  * @note The format is the same as used in the Linux kernel for cmdline mtd
  * partitions.
-- 
1.6.5



From jacmet at sunsite.dk  Fri Jan 15 08:43:51 2010
From: jacmet at sunsite.dk (Peter Korsgaard)
Date: Fri, 15 Jan 2010 14:43:51 +0100
Subject: [PATCHV2] addpart: support @<offset>
In-Reply-To: <1263562289-20302-1-git-send-email-jacmet@sunsite.dk> (Peter
	Korsgaard's message of "Fri, 15 Jan 2010 14:31:29 +0100")
References: <1263562289-20302-1-git-send-email-jacmet@sunsite.dk>
Message-ID: <87pr5bpjoo.fsf@macbook.be.48ers.dk>

>>>>> "Peter" == Peter Korsgaard <jacmet at sunsite.dk> writes:

 Peter> We claim to be compatible with the kernel's cmdlinepart parser, so
 Peter> support <size>@<offset> like the kernel does.

Sigh, and I *STILL* forgot the long help - Good thing it's Friday.
v3 comming up..

-- 
Bye, Peter Korsgaard


From jacmet at sunsite.dk  Fri Jan 15 08:44:54 2010
From: jacmet at sunsite.dk (Peter Korsgaard)
Date: Fri, 15 Jan 2010 14:44:54 +0100
Subject: [PATCHv3] addpart: support @<offset>
Message-ID: <1263563094-21391-1-git-send-email-jacmet@sunsite.dk>

We claim to be compatible with the kernel's cmdlinepart parser, so
support <size>@<offset> like the kernel does.

Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
---
Changes since v1:
 - Update doxygen documentation to match.
Changes since v2:
 - Update longhelp to match.

 commands/partition.c |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/commands/partition.c b/commands/partition.c
index 3cb7b61..bc0bbf9 100755
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -41,8 +41,10 @@
 #include <linux/stat.h>
 #include <libgen.h>
 
+#define SIZE_REMAINING ((ulong)-1)
+
 static int mtd_part_do_parse_one(char *devname, const char *partstr,
-				 char **endp, unsigned long offset,
+				 char **endp, unsigned long *offset,
 				 off_t devsize, size_t *retsize)
 {
 	ulong size;
@@ -54,12 +56,18 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 	memset(buf, 0, PATH_MAX);
 
 	if (*partstr == '-') {
-		size = devsize - offset;
+		size = SIZE_REMAINING;
 		end = (char *)partstr + 1;
 	} else {
 		size = strtoul_suffix(partstr, &end, 0);
 	}
 
+	if (*end == '@')
+		*offset = strtoul_suffix(end+1, &end, 0);
+
+	if (size == SIZE_REMAINING)
+		size = devsize - *offset;
+
 	partstr = end;
 
 	if (*partstr == '(') {
@@ -76,7 +84,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 		end++;
 	}
 
-	if (size + offset > devsize) {
+	if (size + *offset > devsize) {
 		printf("%s: partition end is beyond device\n", buf);
 		return -EINVAL;
 	}
@@ -93,7 +101,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 
 	*retsize = size;
 
-	ret = devfs_add_partition(devname, offset, size, flags, buf);
+	ret = devfs_add_partition(devname, *offset, size, flags, buf);
 	if (ret)
 		printf("cannot create %s: %s\n", buf, strerror(-ret));
 	return ret;
@@ -123,7 +131,7 @@ static int do_addpart(cmd_tbl_t * cmdtp, int argc, char *argv[])
 	while (1) {
 		size_t size = 0;
 
-		if (mtd_part_do_parse_one(devname, endp, &endp, offset, devsize, &size))
+		if (mtd_part_do_parse_one(devname, endp, &endp, &offset, devsize, &size))
 			return 1;
 
 		offset += size;
@@ -146,10 +154,11 @@ static const __maybe_unused char cmd_addpart_help[] =
 "\n"
 "addpart adds a partition description to a device. The partition description\n"
 "has the form\n"
-"size1(name1)[ro],size2(name2)[ro],...\n"
-"<device> is the device name under. Size can be given in decimal or if prefixed\n"
-"with 0x in hex. Sizes can have an optional suffix K,M,G. The size of the last\n"
-"partition can be specified as '-' for the remaining space of the device.\n"
+"size1[@offset1](name1)[ro],size2[@offset2](name2)[ro],...\n"
+"<device> is the device name under. Size and offset can be given in decimal\n"
+"or - if prefixed with 0x in hex. Both can have an optional suffix K,M,G.\n"
+"The size of the last partition can be specified as '-' for the remaining\n"
+"space of the device.\n"
 "This format is the same as used in the Linux kernel for cmdline mtd partitions.\n"
 "\n"
 "Note: That this command has to be reworked and will probably change it's API.";
@@ -167,12 +176,12 @@ BAREBOX_CMD_END
  * Adds a partition description to a device. The partition description has the
  * form
  *
- * size1(name1)[ro],size2(name2)[ro],...
+ * size1[@offset1](name1)[ro],size2[@offset2](name2)[ro],...
  *
- * \<device> is the device name under. Sizes can be given in decimal or - if
- * prefixed with 0x - in hex. Sizes can have an optional suffix K,M,G. The
- * size of the last partition can be specified as '-' for the remaining space
- * of the device.
+ * \<device> is the device name under. Size and offset can be given in decimal
+ * or - if prefixed with 0x - in hex. Both can have an optional suffix K,M,G.
+ * The size of the last partition can be specified as '-' for the remaining
+ * space of the device.
  *
  * @note The format is the same as used in the Linux kernel for cmdline mtd
  * partitions.
-- 
1.6.5



From s.hauer at pengutronix.de  Sat Jan 16 06:30:05 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Sat, 16 Jan 2010 12:30:05 +0100
Subject: [PATCHv3] addpart: support @<offset>
In-Reply-To: <1263563094-21391-1-git-send-email-jacmet@sunsite.dk>
References: <1263563094-21391-1-git-send-email-jacmet@sunsite.dk>
Message-ID: <20100116113005.GQ23110@pengutronix.de>

On Fri, Jan 15, 2010 at 02:44:54PM +0100, Peter Korsgaard wrote:
> We claim to be compatible with the kernel's cmdlinepart parser, so
> support <size>@<offset> like the kernel does.

This is nice to have. Applied to -next.

Thanks
  Sascha

> 
> Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
> ---
> Changes since v1:
>  - Update doxygen documentation to match.
> Changes since v2:
>  - Update longhelp to match.
> 
>  commands/partition.c |   37 +++++++++++++++++++++++--------------
>  1 files changed, 23 insertions(+), 14 deletions(-)
> 
> diff --git a/commands/partition.c b/commands/partition.c
> index 3cb7b61..bc0bbf9 100755
> --- a/commands/partition.c
> +++ b/commands/partition.c
> @@ -41,8 +41,10 @@
>  #include <linux/stat.h>
>  #include <libgen.h>
>  
> +#define SIZE_REMAINING ((ulong)-1)
> +
>  static int mtd_part_do_parse_one(char *devname, const char *partstr,
> -				 char **endp, unsigned long offset,
> +				 char **endp, unsigned long *offset,
>  				 off_t devsize, size_t *retsize)
>  {
>  	ulong size;
> @@ -54,12 +56,18 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
>  	memset(buf, 0, PATH_MAX);
>  
>  	if (*partstr == '-') {
> -		size = devsize - offset;
> +		size = SIZE_REMAINING;
>  		end = (char *)partstr + 1;
>  	} else {
>  		size = strtoul_suffix(partstr, &end, 0);
>  	}
>  
> +	if (*end == '@')
> +		*offset = strtoul_suffix(end+1, &end, 0);
> +
> +	if (size == SIZE_REMAINING)
> +		size = devsize - *offset;
> +
>  	partstr = end;
>  
>  	if (*partstr == '(') {
> @@ -76,7 +84,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
>  		end++;
>  	}
>  
> -	if (size + offset > devsize) {
> +	if (size + *offset > devsize) {
>  		printf("%s: partition end is beyond device\n", buf);
>  		return -EINVAL;
>  	}
> @@ -93,7 +101,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
>  
>  	*retsize = size;
>  
> -	ret = devfs_add_partition(devname, offset, size, flags, buf);
> +	ret = devfs_add_partition(devname, *offset, size, flags, buf);
>  	if (ret)
>  		printf("cannot create %s: %s\n", buf, strerror(-ret));
>  	return ret;
> @@ -123,7 +131,7 @@ static int do_addpart(cmd_tbl_t * cmdtp, int argc, char *argv[])
>  	while (1) {
>  		size_t size = 0;
>  
> -		if (mtd_part_do_parse_one(devname, endp, &endp, offset, devsize, &size))
> +		if (mtd_part_do_parse_one(devname, endp, &endp, &offset, devsize, &size))
>  			return 1;
>  
>  		offset += size;
> @@ -146,10 +154,11 @@ static const __maybe_unused char cmd_addpart_help[] =
>  "\n"
>  "addpart adds a partition description to a device. The partition description\n"
>  "has the form\n"
> -"size1(name1)[ro],size2(name2)[ro],...\n"
> -"<device> is the device name under. Size can be given in decimal or if prefixed\n"
> -"with 0x in hex. Sizes can have an optional suffix K,M,G. The size of the last\n"
> -"partition can be specified as '-' for the remaining space of the device.\n"
> +"size1[@offset1](name1)[ro],size2[@offset2](name2)[ro],...\n"
> +"<device> is the device name under. Size and offset can be given in decimal\n"
> +"or - if prefixed with 0x in hex. Both can have an optional suffix K,M,G.\n"
> +"The size of the last partition can be specified as '-' for the remaining\n"
> +"space of the device.\n"
>  "This format is the same as used in the Linux kernel for cmdline mtd partitions.\n"
>  "\n"
>  "Note: That this command has to be reworked and will probably change it's API.";
> @@ -167,12 +176,12 @@ BAREBOX_CMD_END
>   * Adds a partition description to a device. The partition description has the
>   * form
>   *
> - * size1(name1)[ro],size2(name2)[ro],...
> + * size1[@offset1](name1)[ro],size2[@offset2](name2)[ro],...
>   *
> - * \<device> is the device name under. Sizes can be given in decimal or - if
> - * prefixed with 0x - in hex. Sizes can have an optional suffix K,M,G. The
> - * size of the last partition can be specified as '-' for the remaining space
> - * of the device.
> + * \<device> is the device name under. Size and offset can be given in decimal
> + * or - if prefixed with 0x - in hex. Both can have an optional suffix K,M,G.
> + * The size of the last partition can be specified as '-' for the remaining
> + * space of the device.
>   *
>   * @note The format is the same as used in the Linux kernel for cmdline mtd
>   * partitions.
> -- 
> 1.6.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Sat Jan 16 06:31:10 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Sat, 16 Jan 2010 12:31:10 +0100
Subject: [PATCH] documentation: It's U-Boot that doesn't have getopt,
	not Barebox
In-Reply-To: <1263551973-14588-1-git-send-email-jacmet@sunsite.dk>
References: <1263551973-14588-1-git-send-email-jacmet@sunsite.dk>
Message-ID: <20100116113110.GR23110@pengutronix.de>

On Fri, Jan 15, 2010 at 11:39:33AM +0100, Peter Korsgaard wrote:
> Commit a3ffa97f (rename U-Boot-v2 project to barebox) also changed the
> U-Boot references to Barebox in the getopt description, which doesn't
> make much sense.

Ok, applied.

Sascha

> 
> Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
> ---
>  Documentation/barebox-main.dox |    2 +-
>  README                         |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/barebox-main.dox b/Documentation/barebox-main.dox
> index 42d1256..743add8 100644
> --- a/Documentation/barebox-main.dox
> +++ b/Documentation/barebox-main.dox
> @@ -64,7 +64,7 @@ things right - without caring about losing support for old boards.
>  
>  - getopt
>    - There is a small getopt implementation. Some commands got really
> -    complicated (both in code and in usage) due to the fact that @a barebox only
> +    complicated (both in code and in usage) due to the fact that @a U-Boot only
>      allowed positional parameters.
>  
>  - editor
> diff --git a/README b/README
> index 6f5fb26..9b5317d 100644
> --- a/README
> +++ b/README
> @@ -61,7 +61,7 @@ Features
>  
>  - getopt
>    There is a small getopt implementation. Some commands got really
> -  complicated (both in code and in usage) due to the fact that barebox only
> +  complicated (both in code and in usage) due to the fact that U-Boot only
>    allowed positional parameters.
>  
>  - editor
> -- 
> 1.6.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Sat Jan 16 06:33:09 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Sat, 16 Jan 2010 12:33:09 +0100
Subject: [PATCH 1/4] eukrea_cpuimx27 : update timings
In-Reply-To: <1263552619-4601-1-git-send-email-eric@eukrea.com>
References: <1263552619-4601-1-git-send-email-eric@eukrea.com>
Message-ID: <20100116113309.GS23110@pengutronix.de>

Hi Eric,

On Fri, Jan 15, 2010 at 11:50:16AM +0100, Eric Benard wrote:
> use optimized DDR, NOR & QuadUART timings

Ok, applied for -next.

Sascha

> 
> Signed-off-by: Eric Benard <eric at eukrea.com>
> ---
>  board/eukrea_cpuimx27/eukrea_cpuimx27.c |   12 ++++++------
>  board/eukrea_cpuimx27/lowlevel_init.S   |    4 ++--
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/board/eukrea_cpuimx27/eukrea_cpuimx27.c b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
> index 6878044..629399f 100644
> --- a/board/eukrea_cpuimx27/eukrea_cpuimx27.c
> +++ b/board/eukrea_cpuimx27/eukrea_cpuimx27.c
> @@ -198,9 +198,9 @@ static int eukrea_cpuimx27_devices_init(void)
>  	eukrea_cpuimx27_mmu_init();
>  
>  	/* configure 16 bit nor flash on cs0 */
> -	CS0U = 0x0000CC03;
> -	CS0L = 0xa0330D01;
> -	CS0A = 0x00220800;
> +	CS0U = 0x00008F03;
> +	CS0L = 0xA0330D01;
> +	CS0A = 0x002208C0;
>  
>  	/* initizalize gpios */
>  	for (i = 0; i < ARRAY_SIZE(mode); i++)
> @@ -244,9 +244,9 @@ static int eukrea_cpuimx27_console_init(void)
>  #endif
>  	/* configure 8 bit UART on cs3 */
>  	FMCR &= ~0x2;
> -	CS3U = 0x0000DCF6;
> -	CS3L = 0x444A4541;
> -	CS3A = 0x44443302;
> +	CS3U = 0x0000D603;
> +	CS3L = 0x0D1D0D01;
> +	CS3A = 0x00D20000;
>  #ifdef CONFIG_DRIVER_SERIAL_NS16550
>  	register_device(&quad_uart_serial_device);
>  #endif
> diff --git a/board/eukrea_cpuimx27/lowlevel_init.S b/board/eukrea_cpuimx27/lowlevel_init.S
> index 4622af8..5295a8a 100644
> --- a/board/eukrea_cpuimx27/lowlevel_init.S
> +++ b/board/eukrea_cpuimx27/lowlevel_init.S
> @@ -8,10 +8,10 @@
>  
>  #if defined CONFIG_EUKREA_CPUIMX27_SDRAM_256MB
>  #define ROWS0	ESDCTL_ROW14
> -#define CFG0	0x00695729
> +#define CFG0	0x0029572D
>  #elif defined CONFIG_EUKREA_CPUIMX27_SDRAM_128MB
>  #define ROWS0	ESDCTL_ROW13
> -#define CFG0	0x00395B28
> +#define CFG0	0x00095728
>  #endif
>  
>  #define ESDCTL0_VAL (ESDCTL0_SDE | ROWS0 | ESDCTL0_COL10)
> -- 
> 1.6.3.3
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From mkl at pengutronix.de  Mon Jan 18 06:56:23 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:23 +0100
Subject: [PATCH 0/8] update i.MX35 3stack and i2c drivers
Message-ID: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>

Hey,

this is a patch series updating the driver interface of the two i2c
chips (mc13892 and mc9sdz60) needed to boot the i.MX35 3stack board.
They no longer export their i2c interface but export now much cleaner
_reg_read, _reg_write and _set_bits functions.

The next pach adopts the i.MX35 to the new driver interface.

Two cleanup patches follow. Then the environment partition is increased
to hold a splash image. The environemnt itself is updated to support
jffs2 and ubi/ubifs. The last patch updates the defconfig.

Please review and consider to apply.

This patch series (based on v2009.12.0) can be pulled, too.

Cheers, Marc

---

The following changes since commit c68c06cb0e5f9913473ab9cfbf7c48af79582c99:
  Sascha Hauer (1):
        barebox-2009.12.0

are available in the git repository at:

  ssh://git.pengutronix.de/git/mkl/barebox.git for-sha-mx35-3-stack-updates

Marc Kleine-Budde (8):
      mc9sdz60: clean up driver interface
      mc13892: clean up driver interface
      i.MX35 3stack: adopt board to new mc13892 and mc9sdz60 driver interface
      i.MX35 3stack: clean up indention
      i.MX35 3stack: clean up indention of lowlevel_init
      i.MX35 3stack: increase env partition to hold splash image
      i.MX35 3stack: update environemnt to support jffs and ubi/ubifs
      i.MX35 3stack: update of defconfig

 arch/arm/configs/freescale_mx35_3stack_defconfig   |   67 ++--
 board/freescale-mx35-3-stack/3stack.c              |  113 ++++---
 board/freescale-mx35-3-stack/env/bin/_update       |    5 +-
 board/freescale-mx35-3-stack/env/bin/boot          |   50 ++--
 board/freescale-mx35-3-stack/env/bin/init          |   15 +-
 board/freescale-mx35-3-stack/env/bin/update_kernel |    2 +-
 .../env/bin/{update_root => update_rootfs}         |    8 +-
 board/freescale-mx35-3-stack/env/config            |   41 ++-
 board/freescale-mx35-3-stack/lowlevel_init.S       |  340 ++++++++++----------
 drivers/i2c/mc13892.c                              |   91 ++++--
 drivers/i2c/mc9sdz60.c                             |   84 ++++--
 include/i2c/mc13892.h                              |   90 +++++-
 include/i2c/mc9sdz60.h                             |   61 ++++-
 13 files changed, 623 insertions(+), 344 deletions(-)
 rename board/freescale-mx35-3-stack/env/bin/{update_root => update_rootfs} (68%)



From mkl at pengutronix.de  Mon Jan 18 06:56:24 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:24 +0100
Subject: [PATCH 1/8] mc9sdz60: clean up driver interface
In-Reply-To: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-2-git-send-email-mkl@pengutronix.de>

Export mc9sdz60_reg_read, mc9sdz60_reg_write and mc9sdz60_set_bits
function instead of exposing the i2c interface.

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 drivers/i2c/mc9sdz60.c |   84 ++++++++++++++++++++++++++++++++++++-----------
 include/i2c/mc9sdz60.h |   61 +++++++++++++++++++++++++++++++++-
 2 files changed, 123 insertions(+), 22 deletions(-)

diff --git a/drivers/i2c/mc9sdz60.c b/drivers/i2c/mc9sdz60.c
index 4b1068d..3580af8 100644
--- a/drivers/i2c/mc9sdz60.c
+++ b/drivers/i2c/mc9sdz60.c
@@ -26,45 +26,88 @@
 #include <errno.h>
 
 #include <i2c/i2c.h>
-
-#include <asm/byteorder.h>
+#include <i2c/mc9sdz60.h>
 
 #define DRIVERNAME		"mc9sdz60"
 
-struct mc_priv {
-	struct cdev		cdev;
-	struct i2c_client	*client;
-};
-
-#define to_mc_priv(a)		container_of(a, struct mc_priv, cdev)
+#define to_mc9sdz60(a)		container_of(a, struct mc9sdz60, cdev)
 
-static struct mc_priv *mc_dev;
+static struct mc9sdz60 *mc_dev;
 
-struct i2c_client *mc9sdz60_get_client(void)
+struct mc9sdz60 *mc9sdz60_get(void)
 {
 	if (!mc_dev)
 		return NULL;
 
-	return mc_dev->client;
+	return mc_dev;
 }
+EXPORT_SYMBOL(mc9sdz60_get);
 
-static u32 mc_read_reg(struct mc_priv *mc, int reg)
+int mc9sdz60_reg_read(struct mc9sdz60 *mc9sdz60, enum mc9sdz60_reg reg, u8 *val)
 {
-	u8 buf;
+	int ret;
 
-	i2c_read_reg(mc->client, reg, &buf, sizeof(buf));
+	ret = i2c_read_reg(mc9sdz60->client, reg, val, 1);
 
-	return buf;
+	return ret == 1 ? 0 : ret;
 }
+EXPORT_SYMBOL(mc9sdz60_reg_read)
+
+int mc9sdz60_reg_write(struct mc9sdz60 *mc9sdz60, enum mc9sdz60_reg reg, u8 val)
+{
+	int ret;
+
+	ret = i2c_write_reg(mc9sdz60->client, reg, &val, 1);
+
+	return ret == 1 ? 0 : ret;
+}
+EXPORT_SYMBOL(mc9sdz60_reg_write)
+
+int mc9sdz60_set_bits(struct mc9sdz60 *mc9sdz60, enum mc9sdz60_reg reg, u8 mask, u8 val)
+{
+	u8 tmp;
+	int err;
+
+	err = mc9sdz60_reg_read(mc9sdz60, reg, &tmp);
+	tmp = (tmp & ~mask) | val;
+
+	if (!err)
+		err = mc9sdz60_reg_write(mc9sdz60, reg, tmp);
+
+	return err;
+}
+EXPORT_SYMBOL(mc9sdz60_set_bits);
 
 static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
 {
-	struct mc_priv *priv = to_mc_priv(cdev);
-	int i = count;
+	struct mc9sdz60 *mc9sdz60 = to_mc9sdz60(cdev);
 	u8 *buf = _buf;
+	size_t i = count;
+	int err;
+
+	while (i) {
+		err = mc9sdz60_reg_read(mc9sdz60, offset, buf);
+		if (err)
+			return (ssize_t)err;
+		buf++;
+		i--;
+		offset++;
+	}
+
+	return count;
+}
+
+static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, ulong offset, ulong flags)
+{
+	struct mc9sdz60 *mc9sdz60 = to_mc9sdz60(cdev);
+	const u8 *buf = _buf;
+	size_t i = count;
+	int err;
 
 	while (i) {
-		*buf = mc_read_reg(priv, offset);
+		err = mc9sdz60_reg_write(mc9sdz60, offset, *buf);
+		if (err)
+			return (ssize_t)err;
 		buf++;
 		i--;
 		offset++;
@@ -76,6 +119,7 @@ static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset
 static struct file_operations mc_fops = {
 	.lseek	= dev_lseek_default,
 	.read	= mc_read,
+	.write	= mc_write,
 };
 
 static int mc_probe(struct device_d *dev)
@@ -83,10 +127,10 @@ static int mc_probe(struct device_d *dev)
 	if (mc_dev)
 		return -EBUSY;
 
-	mc_dev = xzalloc(sizeof(struct mc_priv));
+	mc_dev = xzalloc(sizeof(struct mc9sdz60));
 	mc_dev->cdev.name = DRIVERNAME;
 	mc_dev->client = to_i2c_client(dev);
-	mc_dev->cdev.size = 256;
+	mc_dev->cdev.size = 64;		/* 35 known registers */
 	mc_dev->cdev.dev = dev;
 	mc_dev->cdev.ops = &mc_fops;
 
diff --git a/include/i2c/mc9sdz60.h b/include/i2c/mc9sdz60.h
index 04cfca0..4cc233e 100644
--- a/include/i2c/mc9sdz60.h
+++ b/include/i2c/mc9sdz60.h
@@ -1,7 +1,64 @@
+/*
+ * Copyright (C) 2009 Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ * Derived from:
+ * - mcu_max8660-bus.h --  contains interface of the mc9sdz60 and max8660
+ *   Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ */
+
 #ifndef __ASM_ARCH_MC9SDZ60_H
 #define __ASM_ARCH_MC9SDZ60_H
 
-extern struct i2c_client *mc9sdz60_get_client(void);
+enum mc9sdz60_reg {
+	MC9SDZ60_REG_VERSION		= 0x00,
+	MC9SDZ60_REG_SECS		= 0x01,
+	MC9SDZ60_REG_MINS		= 0x02,
+	MC9SDZ60_REG_HRS		= 0x03,
+	MC9SDZ60_REG_DAY		= 0x04,
+	MC9SDZ60_REG_DATE		= 0x05,
+	MC9SDZ60_REG_MONTH		= 0x06,
+	MC9SDZ60_REG_YEAR		= 0x07,
+	MC9SDZ60_REG_ALARM_SECS		= 0x08,
+	MC9SDZ60_REG_ALARM_MINS		= 0x09,
+	MC9SDZ60_REG_ALARM_HRS		= 0x0a,
+	MC9SDZ60_REG_TS_CONTROL		= 0x0b,
+	MC9SDZ60_REG_X_LOW		= 0x0c,
+	MC9SDZ60_REG_Y_LOW		= 0x0d,
+	MC9SDZ60_REG_XY_HIGH		= 0x0e,
+	MC9SDZ60_REG_X_LEFT_LOW		= 0x0f,
+	MC9SDZ60_REG_X_LEFT_HIGH	= 0x10,
+	MC9SDZ60_REG_X_RIGHT		= 0x11,
+	MC9SDZ60_REG_Y_TOP_LOW		= 0x12,
+	MC9SDZ60_REG_Y_TOP_HIGH		= 0x13,
+	MC9SDZ60_REG_Y_BOTTOM		= 0x14,
+	MC9SDZ60_REG_RESET_1		= 0x15,
+	MC9SDZ60_REG_RESET_2		= 0x16,
+	MC9SDZ60_REG_POWER_CTL		= 0x17,
+	MC9SDZ60_REG_DELAY_CONFIG	= 0x18,
+	MC9SDZ60_REG_GPIO_1		= 0x19,
+	MC9SDZ60_REG_GPIO_2		= 0x1a,
+	MC9SDZ60_REG_KPD_1		= 0x1b,
+	MC9SDZ60_REG_KPD_2		= 0x1c,
+	MC9SDZ60_REG_KPD_CONTROL	= 0x1d,
+	MC9SDZ60_REG_INT_ENABLE_1	= 0x1e,
+	MC9SDZ60_REG_INT_ENABLE_2	= 0x1f,
+	MC9SDZ60_REG_INT_FLAG_1		= 0x20,
+	MC9SDZ60_REG_INT_FLAG_2		= 0x21,
+	MC9SDZ60_REG_DES_FLAG		= 0x22,
+};
 
-#endif /* __ASM_ARCH_MC9SDZ60_H */
+struct mc9sdz60 {
+	struct cdev		cdev;
+	struct i2c_client	*client;
+};
+
+extern struct mc9sdz60 *mc9sdz60_get(void);
 
+extern int mc9sdz60_reg_read(struct mc9sdz60 *priv, enum mc9sdz60_reg reg, u8 *val);
+extern int mc9sdz60_reg_write(struct mc9sdz60 *priv, enum mc9sdz60_reg reg, u8 val);
+extern int mc9sdz60_set_bits(struct mc9sdz60 *priv, enum mc9sdz60_reg reg, u8 mask, u8 val);
+
+#endif /* __ASM_ARCH_MC9SDZ60_H */
-- 
1.6.6



From mkl at pengutronix.de  Mon Jan 18 06:56:25 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:25 +0100
Subject: [PATCH 2/8] mc13892: clean up driver interface
In-Reply-To: <1263815791-10839-2-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-2-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-3-git-send-email-mkl@pengutronix.de>

Export mc13892_reg_read, mc13892_reg_write and mc13892_set_bits
function instead of exposing the i2c interface.

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 drivers/i2c/mc13892.c |   91 ++++++++++++++++++++++++++++++++++++++----------
 include/i2c/mc13892.h |   90 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 160 insertions(+), 21 deletions(-)

diff --git a/drivers/i2c/mc13892.c b/drivers/i2c/mc13892.c
index 54661d4..67d4232 100644
--- a/drivers/i2c/mc13892.c
+++ b/drivers/i2c/mc13892.c
@@ -26,47 +26,99 @@
 #include <errno.h>
 
 #include <i2c/i2c.h>
-
-#include <asm/byteorder.h>
+#include <i2c/mc13892.h>
 
 #define DRIVERNAME		"mc13892"
 
-struct mc_priv {
-	struct cdev		cdev;
-	struct i2c_client	*client;
-};
-
-#define to_mc_priv(a)		container_of(a, struct mc_priv, cdev)
+#define to_mc13892(a)		container_of(a, struct mc13892, cdev)
 
-static struct mc_priv *mc_dev;
+static struct mc13892 *mc_dev;
 
-struct i2c_client *mc13892_get_client(void)
+struct mc13892 *mc13892_get(void)
 {
 	if (!mc_dev)
 		return NULL;
 
-	return mc_dev->client;
+	return mc_dev;
+}
+EXPORT_SYMBOL(mc13892_get);
+
+int mc13892_reg_read(struct mc13892 *mc13892, enum mc13892_reg reg, u32 *val)
+{
+	u8 buf[3];
+	int ret;
+
+	ret = i2c_read_reg(mc13892->client, reg, buf, 3);
+	*val = buf[0] << 16 | buf[1] << 8 | buf[2] << 0;
+
+	return ret == 3 ? 0 : ret;
 }
+EXPORT_SYMBOL(mc13892_reg_read)
 
-static u32 mc_read_reg(struct mc_priv *mc, int reg)
+int mc13892_reg_write(struct mc13892 *mc13892, enum mc13892_reg reg, u32 val)
 {
-	u32 buf;
+	u8 buf[] = {
+		val >> 16,
+		val >>  8,
+		val >>  0,
+	};
+	int ret;
+
+	ret = i2c_write_reg(mc13892->client, reg, buf, 3);
+
+	return ret == 3 ? 0 : ret;
+}
+EXPORT_SYMBOL(mc13892_reg_write)
+
+int mc13892_set_bits(struct mc13892 *mc13892, enum mc13892_reg reg, u32 mask, u32 val)
+{
+	u32 tmp;
+	int err;
+
+	err = mc13892_reg_read(mc13892, reg, &tmp);
+	tmp = (tmp & ~mask) | val;
 
-	i2c_read_reg(mc->client, reg, (u8 *)&buf, sizeof(buf));
+	if (!err)
+		err = mc13892_reg_write(mc13892, reg, tmp);
 
-	return buf;
+	return err;
 }
+EXPORT_SYMBOL(mc13892_set_bits);
 
 static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset, ulong flags)
 {
-	struct mc_priv *priv = to_mc_priv(cdev);
-	int i = count >> 2;
+	struct mc13892 *priv = to_mc13892(cdev);
 	u32 *buf = _buf;
+	size_t i = count >> 2;
+	int err;
+
+	offset >>= 2;
+
+	while (i) {
+		err = mc13892_reg_read(priv, offset, buf);
+		if (err)
+			return (ssize_t)err;
+		buf++;
+		i--;
+		offset++;
+	}
+
+	return count;
+}
+
+static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, ulong offset, ulong flags)
+{
+	struct mc13892 *mc13892 = to_mc13892(cdev);
+	const u32 *buf = _buf;
+	size_t i = count >> 2;
+	int err;
 
 	offset >>= 2;
 
 	while (i) {
-		*buf = mc_read_reg(priv, offset);
+		err = mc13892_reg_write(mc13892, offset, *buf);
+		if (err)
+			return (ssize_t)err;
 		buf++;
 		i--;
 		offset++;
@@ -78,6 +130,7 @@ static ssize_t mc_read(struct cdev *cdev, void *_buf, size_t count, ulong offset
 static struct file_operations mc_fops = {
 	.lseek	= dev_lseek_default,
 	.read	= mc_read,
+	.write	= mc_write,
 };
 
 static int mc_probe(struct device_d *dev)
@@ -85,7 +138,7 @@ static int mc_probe(struct device_d *dev)
 	if (mc_dev)
 		return -EBUSY;
 
-	mc_dev = xzalloc(sizeof(struct mc_priv));
+	mc_dev = xzalloc(sizeof(struct mc13892));
 	mc_dev->cdev.name = DRIVERNAME;
 	mc_dev->client = to_i2c_client(dev);
 	mc_dev->cdev.size = 256;
diff --git a/include/i2c/mc13892.h b/include/i2c/mc13892.h
index 2f44f6c..112d05b 100644
--- a/include/i2c/mc13892.h
+++ b/include/i2c/mc13892.h
@@ -1,7 +1,93 @@
+/*
+ * Copyright (C) 2009 Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ * Derived from:
+ * - arch-mxc/pmic_external.h --  contains interface of the PMIC protocol driver
+ *   Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ */
+
 #ifndef __ASM_ARCH_MC13892_H
 #define __ASM_ARCH_MC13892_H
 
-extern struct i2c_client *mc13892_get_client(void);
+enum mc13892_reg {
+	MC13892_REG_INT_STATUS0		= 0x00,
+	MC13892_REG_INT_MASK0		= 0x01,
+	MC13892_REG_INT_SENSE0		= 0x02,
+	MC13892_REG_INT_STATUS1		= 0x03,
+	MC13892_REG_INT_MASK1		= 0x04,
+	MC13892_REG_INT_SENSE1		= 0x05,
+	MC13892_REG_PU_MODE_S		= 0x06,
+	MC13892_REG_IDENTIFICATION	= 0x07,
+	MC13892_REG_UNUSED0		= 0x08,
+	MC13892_REG_ACC0		= 0x09,
+	MC13892_REG_ACC1		= 0x0a,
+	MC13892_REG_UNUSED1		= 0x0b,
+	MC13892_REG_UNUSED2		= 0x0c,
+	MC13892_REG_POWER_CTL0		= 0x0d,
+	MC13892_REG_POWER_CTL1		= 0x0e,
+	MC13892_REG_POWER_CTL2		= 0x0f,
+	MC13892_REG_REGEN_ASSIGN	= 0x10,
+	MC13892_REG_UNUSED3		= 0x11,
+	MC13892_REG_MEM_A		= 0x12,
+	MC13892_REG_MEM_B		= 0x13,
+	MC13892_REG_RTC_TIME		= 0x14,
+	MC13892_REG_RTC_ALARM		= 0x15,
+	MC13892_REG_RTC_DAY		= 0x16,
+	MC13892_REG_RTC_DAY_ALARM	= 0x17,
+	MC13892_REG_SW_0		= 0x18,
+	MC13892_REG_SW_1		= 0x19,
+	MC13892_REG_SW_2		= 0x1a,
+	MC13892_REG_SW_3		= 0x1b,
+	MC13892_REG_SW_4		= 0x1c,
+	MC13892_REG_SW_5		= 0x1d,
+	MC13892_REG_SETTING_0		= 0x1e,
+	MC13892_REG_SETTING_1		= 0x1f,
+	MC13892_REG_MODE_0		= 0x20,
+	MC13892_REG_MODE_1		= 0x21,
+	MC13892_REG_POWER_MISC		= 0x22,
+	MC13892_REG_UNUSED4		= 0x23,
+	MC13892_REG_UNUSED5		= 0x24,
+	MC13892_REG_UNUSED6		= 0x25,
+	MC13892_REG_UNUSED7		= 0x26,
+	MC13892_REG_UNUSED8		= 0x27,
+	MC13892_REG_UNUSED9		= 0x28,
+	MC13892_REG_UNUSED10		= 0x29,
+	MC13892_REG_UNUSED11		= 0x2a,
+	MC13892_REG_ADC0		= 0x2b,
+	MC13892_REG_ADC1		= 0x2c,
+	MC13892_REG_ADC2		= 0x2d,
+	MC13892_REG_ADC3		= 0x2e,
+	MC13892_REG_ADC4		= 0x2f,
+	MC13892_REG_CHARGE		= 0x30,
+	MC13892_REG_USB0		= 0x31,
+	MC13892_REG_USB1		= 0x32,
+	MC13892_REG_LED_CTL0		= 0x33,
+	MC13892_REG_LED_CTL1		= 0x34,
+	MC13892_REG_LED_CTL2		= 0x35,
+	MC13892_REG_LED_CTL3		= 0x36,
+	MC13892_REG_UNUSED12		= 0x37,
+	MC13892_REG_UNUSED13		= 0x38,
+	MC13892_REG_TRIM0		= 0x39,
+	MC13892_REG_TRIM1		= 0x3a,
+	MC13892_REG_TEST0		= 0x3b,
+	MC13892_REG_TEST1		= 0x3c,
+	MC13892_REG_TEST2		= 0x3d,
+	MC13892_REG_TEST3		= 0x3e,
+	MC13892_REG_TEST4		= 0x3f,
+};
 
-#endif /* __ASM_ARCH_MC13892_H */
+struct mc13892 {
+	struct cdev		cdev;
+	struct i2c_client	*client;
+};
+
+extern struct mc13892 *mc13892_get(void);
 
+extern int mc13892_reg_read(struct mc13892 *mc13892, enum mc13892_reg reg, u32 *val);
+extern int mc13892_reg_write(struct mc13892 *mc13892, enum mc13892_reg reg, u32 val);
+extern int mc13892_set_bits(struct mc13892 *mc13892, enum mc13892_reg reg, u32 mask, u32 val);
+
+#endif /* __ASM_ARCH_MC13892_H */
-- 
1.6.6



From mkl at pengutronix.de  Mon Jan 18 06:56:27 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:27 +0100
Subject: [PATCH 4/8] i.MX35 3stack: clean up indention
In-Reply-To: <1263815791-10839-4-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-2-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-3-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-4-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-5-git-send-email-mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 board/freescale-mx35-3-stack/3stack.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/board/freescale-mx35-3-stack/3stack.c b/board/freescale-mx35-3-stack/3stack.c
index f671936..d87808a 100644
--- a/board/freescale-mx35-3-stack/3stack.c
+++ b/board/freescale-mx35-3-stack/3stack.c
@@ -60,8 +60,8 @@ static struct device_d cfi_dev = {
 };
 
 static struct fec_platform_data fec_info = {
-	.xcv_type = MII100,
-	.phy_addr = 0x1F,
+	.xcv_type	= MII100,
+	.phy_addr	= 0x1F,
 };
 
 static struct device_d fec_dev = {
@@ -71,8 +71,8 @@ static struct device_d fec_dev = {
 };
 
 static struct memory_platform_data sdram_pdata = {
-	.name = "ram0",
-	.flags = DEVFS_RDWR,
+	.name	= "ram0",
+	.flags	= DEVFS_RDWR,
 };
 
 static struct device_d sdram_dev = {
@@ -167,7 +167,7 @@ static int f3s_devices_init(void)
 	register_device(&nand_dev);
 	register_device(&cfi_dev);
 
-	switch ( (reg >> 25) & 0x3) {
+	switch ((reg >> 25) & 0x3) {
 	case 0x01:		/* NAND is the source */
 		devfs_add_partition("nand0", 0x00000, 0x40000, PARTITION_FIXED, "self_raw");
 		dev_add_bb_dev("self_raw", "self0");
@@ -332,7 +332,7 @@ static int f3s_core_init(void)
 
 	/* MPR - priority is M4 > M2 > M3 > M5 > M0 > M1 */
 #define MAX_PARAM1 0x00302154
-	writel(MAX_PARAM1, IMX_MAX_BASE + 0x0);   /* for S0 */
+	writel(MAX_PARAM1, IMX_MAX_BASE + 0x000); /* for S0 */
 	writel(MAX_PARAM1, IMX_MAX_BASE + 0x100); /* for S1 */
 	writel(MAX_PARAM1, IMX_MAX_BASE + 0x200); /* for S2 */
 	writel(MAX_PARAM1, IMX_MAX_BASE + 0x300); /* for S3 */
-- 
1.6.6



From mkl at pengutronix.de  Mon Jan 18 06:56:26 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:26 +0100
Subject: [PATCH 3/8] i.MX35 3stack: adopt board to new mc13892 and mc9sdz60
	driver interface
In-Reply-To: <1263815791-10839-3-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-2-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-3-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-4-git-send-email-mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 board/freescale-mx35-3-stack/3stack.c |   97 ++++++++++++++++++---------------
 1 files changed, 53 insertions(+), 44 deletions(-)

diff --git a/board/freescale-mx35-3-stack/3stack.c b/board/freescale-mx35-3-stack/3stack.c
index e541966..f671936 100644
--- a/board/freescale-mx35-3-stack/3stack.c
+++ b/board/freescale-mx35-3-stack/3stack.c
@@ -157,7 +157,7 @@ static int f3s_devices_init(void)
 	reg = readl(IMX_CCM_BASE + CCM_RCSR);
 	/* some fuses provide us vital information about connected hardware */
 	if (reg & 0x20000000)
-		nand_info.width = 2;	/* bit */
+		nand_info.width = 2;	/* 16 bit */
 	else
 		nand_info.width = 1;	/* 8 bit */
 
@@ -358,74 +358,84 @@ static int f3s_core_init(void)
 
 core_initcall(f3s_core_init);
 
-static int f3s_get_rev(struct i2c_client *client)
+static int f3s_get_rev(struct mc13892 *mc13892)
 {
-	u8 reg[3];
-	int rev;
+	u32 rev;
+	int err;
 
-	i2c_read_reg(client, 0x7, reg, sizeof(reg));
+	err = mc13892_reg_read(mc13892, MC13892_REG_IDENTIFICATION, &rev);
+	if (err)
+		return err;
 
-	rev = reg[0] << 16 | reg [1] << 8 | reg[2];
-	dev_info(&client->dev, "revision: 0x%x\n", rev);
+	dev_info(&mc13892->client->dev, "revision: 0x%x\n", rev);
+	if (rev == 0x00ffffff)
+		return -ENODEV;
 
-	/* just return '0' or '1' */
-	return !!((rev >> 6) & 0x7);
+	return ((rev >> 6) & 0x7) ? 20 : 10;
 }
 
-static void f3s_pmic_init_v2(struct i2c_client *client)
+static int f3s_pmic_init_v2(struct mc13892 *mc13892)
 {
-	u8 reg[3];
+	int err = 0;
 
-	i2c_read_reg(client, 0x1e, reg, sizeof(reg));
-	reg[2] |= 0x03;
-	i2c_write_reg(client, 0x1e, reg, sizeof(reg));
+	err |= mc13892_set_bits(mc13892, MC13892_REG_SETTING_0, 0x03, 0x03);
+	err |= mc13892_set_bits(mc13892, MC13892_REG_MODE_0, 0x01, 0x01);
+	if (err)
+		dev_err(&mc13892->client->dev,
+			"Init sequence failed, the system might not be working!\n");
 
-	i2c_read_reg(client, 0x20, reg, sizeof(reg));
-	reg[2] |= 0x01;
-	i2c_write_reg(client, 0x20, reg, sizeof(reg));
+	return err;
 }
 
-static void f3s_pmic_init_all(struct i2c_client *client)
+static int f3s_pmic_init_all(struct mc9sdz60 *mc9sdz60)
 {
-	u8 reg[1];
+	int err = 0;
 
-	i2c_read_reg(client, 0x20, reg, sizeof(reg));
-	reg[0] |= 0x04;
-	i2c_write_reg(client, 0x20, reg, sizeof(reg));
+	err |= mc9sdz60_set_bits(mc9sdz60, MC9SDZ60_REG_INT_FLAG_1, 0x04, 0x04);
 
+	err |= mc9sdz60_set_bits(mc9sdz60, MC9SDZ60_REG_GPIO_2, 0x80, 0x00);
 	mdelay(200);
+	err |= mc9sdz60_set_bits(mc9sdz60, MC9SDZ60_REG_GPIO_2, 0x80, 0x80);
 
-	i2c_read_reg(client, 0x1a, reg, sizeof(reg));
-	reg[0] &= 0x7f;
-	i2c_write_reg(client, 0x1a, reg, sizeof(reg));
-
-	mdelay(200);
+	if (err)
+		dev_err(&mc9sdz60->client->dev,
+			"Init sequence failed, the system might not be working!\n");
 
-	reg[0] |= 0x80;
-	i2c_write_reg(client, 0x1a, reg, sizeof(reg));
+	return err;
 }
 
 static int f3s_pmic_init(void)
 {
-	struct i2c_client *client;
+	struct mc13892 *mc13892;
+	struct mc9sdz60 *mc9sdz60;
 	int rev;
 
-	client = mc13892_get_client();
-	if (!client)
-		return -ENODEV;
+	mc13892 = mc13892_get();
+	if (!mc13892) {
+		printf("FAILED to get mc13892 handle!\n");
+		return 0;
+	}
 
-	rev = f3s_get_rev(client);
-	if (rev) {
-		printf("i.MX35 CPU board version 2.0\n");
-		f3s_pmic_init_v2(client);
-	} else {
-		printf("i.MX35 CPU board version 1.0\n");
+	rev = f3s_get_rev(mc13892);
+	switch (rev) {
+	case 10:
+		break;
+	case 20:
+		f3s_pmic_init_v2(mc13892);
+		break;
+	default:
+		printf("FAILED to identify board revision!\n");
+		return 0;
 	}
+	printf("i.MX35 PDK CPU board version %d.%d\n", rev / 10, rev % 10);
 
-	client = mc9sdz60_get_client();
-	if (!client)
-		return -ENODEV;
-	f3s_pmic_init_all(client);
+	mc9sdz60 = mc9sdz60_get();
+	if (!mc9sdz60) {
+		printf("FAILED to get mc9sdz60 handle!\n");
+		return 0;
+	}
+
+	f3s_pmic_init_all(mc9sdz60);
 
 	return 0;
 }
@@ -442,4 +452,3 @@ void __bare_init nand_boot(void)
 	imx_nand_load_image((void *)TEXT_BASE, 256 * 1024);
 }
 #endif
-
-- 
1.6.6



From mkl at pengutronix.de  Mon Jan 18 06:56:28 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:28 +0100
Subject: [PATCH 5/8] i.MX35 3stack: clean up indention of lowlevel_init
In-Reply-To: <1263815791-10839-5-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-2-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-3-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-4-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-5-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-6-git-send-email-mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 board/freescale-mx35-3-stack/lowlevel_init.S |  340 +++++++++++++-------------
 1 files changed, 170 insertions(+), 170 deletions(-)

diff --git a/board/freescale-mx35-3-stack/lowlevel_init.S b/board/freescale-mx35-3-stack/lowlevel_init.S
index 4e0a102..1680579 100644
--- a/board/freescale-mx35-3-stack/lowlevel_init.S
+++ b/board/freescale-mx35-3-stack/lowlevel_init.S
@@ -27,9 +27,9 @@
 #include <asm/cache-l2x0.h>
 #include "board-mx35_3stack.h"
 
-#define CSD0_BASE_ADDR             0x80000000
-#define ESDCTL_BASE_ADDR        0xB8001000
-#define CSD1_BASE_ADDR             0x90000000
+#define CSD0_BASE_ADDR		0x80000000
+#define ESDCTL_BASE_ADDR	0xB8001000
+#define CSD1_BASE_ADDR		0x90000000
 
 #define writel(val, reg) \
 	ldr		r0,	=reg;	\
@@ -42,84 +42,84 @@
 	strb		r1,	[r0];
 
 /* Assuming 24MHz input clock */
-#define MPCTL_PARAM_399     (IMX_PLL_PD(0) | IMX_PLL_MFD(15) | IMX_PLL_MFI(8) | IMX_PLL_MFN(5))
-#define MPCTL_PARAM_532     ((1 << 31) | IMX_PLL_PD(0) | IMX_PLL_MFD(11) | IMX_PLL_MFI(11) | IMX_PLL_MFN(1))
-#define PPCTL_PARAM_300     (IMX_PLL_PD(0) | IMX_PLL_MFD(3) | IMX_PLL_MFI(6) | IMX_PLL_MFN(1))
+#define MPCTL_PARAM_399	(IMX_PLL_PD(0) | IMX_PLL_MFD(15) | IMX_PLL_MFI(8) | IMX_PLL_MFN(5))
+#define MPCTL_PARAM_532	((1 << 31) | IMX_PLL_PD(0) | IMX_PLL_MFD(11) | IMX_PLL_MFI(11) | IMX_PLL_MFN(1))
+#define PPCTL_PARAM_300	(IMX_PLL_PD(0) | IMX_PLL_MFD(3) | IMX_PLL_MFI(6) | IMX_PLL_MFN(1))
 
 	.section ".text_bare_init","ax"
 
-ARM_PPMRR:              .word   0x40000015
-L2CACHE_PARAM:          .word   0x00030024
-CCM_CCMR_W:             .word   0x003F4208
-CCM_PDR0_W:             .word   0x00001000
-MPCTL_PARAM_399_W:      .word   MPCTL_PARAM_399
-MPCTL_PARAM_532_W:      .word   MPCTL_PARAM_532
-PPCTL_PARAM_W:    	.word   PPCTL_PARAM_300
-CCM_BASE_ADDR_W:        .word   IMX_CCM_BASE
+ARM_PPMRR:		.word	0x40000015
+L2CACHE_PARAM:		.word	0x00030024
+CCM_CCMR_W:		.word	0x003F4208
+CCM_PDR0_W:		.word	0x00001000
+MPCTL_PARAM_399_W:	.word	MPCTL_PARAM_399
+MPCTL_PARAM_532_W:	.word	MPCTL_PARAM_532
+PPCTL_PARAM_W:		.word	PPCTL_PARAM_300
+CCM_BASE_ADDR_W:	.word	IMX_CCM_BASE
 
 .globl board_init_lowlevel
 board_init_lowlevel:
-	mov     r10, lr
+	mov	r10, lr
 
-	mrc 15, 0, r1, c1, c0, 0
+	mrc	15, 0, r1, c1, c0, 0
 
-	mrc 15, 0, r0, c1, c0, 1
-	orr r0, r0, #7
-	mcr 15, 0, r0, c1, c0, 1
+	mrc	15, 0, r0, c1, c0, 1
+	orr	r0, r0, #7
+	mcr	15, 0, r0, c1, c0, 1
 
-	orr r1, r1, #(1<<11) /* Flow prediction (Z) */
-	orr r1, r1, #(1<<22) /* unaligned accesses  */
-	orr r1, r1, #(1<<21) /* Low Int Latency     */
+	orr	r1, r1, #(1 << 11)		/* Flow prediction (Z) */
+	orr	r1, r1, #(1 << 22)		/* unaligned accesses */
+	orr	r1, r1, #(1 << 21)		/* Low Int Latency */
 
-	mcr 15, 0, r1, c1, c0, 0
+	mcr	15, 0, r1, c1, c0, 0
 
-	mov r0, #0
-	mcr 15, 0, r0, c15, c2, 4
+	mov	r0, #0
+	mcr	15, 0, r0, c15, c2, 4
 
 	/*
-	 * Branch predicition is now enabled.  Flush the BTAC to ensure a valid
-	 * starting point.  Don't flush BTAC while it is disabled to avoid
+	 * Branch predicition is now enabled. Flush the BTAC to ensure a valid
+	 * starting point. Don't flush BTAC while it is disabled to avoid
 	 * ARM1136 erratum 408023.
 	 */
-	mov     r0, #0
-	mcr     p15, 0, r0, c7, c5, 6	/* flush entire BTAC */
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 6		/* flush entire BTAC */
 
-	mov r0, #0
-	mcr 15, 0, r0, c7, c7, 0        /* invalidate I cache and D cache */
-	mcr 15, 0, r0, c8, c7, 0        /* invalidate TLBs */
-	mcr 15, 0, r0, c7, c10, 4       /* Drain the write buffer */
+	mov	r0, #0
+	mcr	15, 0, r0, c7, c7, 0		/* invalidate I cache and D cache */
+	mcr	15, 0, r0, c8, c7, 0		/* invalidate TLBs */
+	mcr	15, 0, r0, c7, c10, 4		/* Drain the write buffer */
 
 	/* Also setup the Peripheral Port Remap register inside the core */
-	ldr r0, ARM_PPMRR        /* start from AIPS 2GB region */
-	mcr p15, 0, r0, c15, c2, 4
+	ldr	r0, ARM_PPMRR			/* start from AIPS 2GB region */
+	mcr	p15, 0, r0, c15, c2, 4
 
 /*
  * End of ARM1136 init
  */
-	ldr r0, CCM_BASE_ADDR_W
+	ldr	r0, CCM_BASE_ADDR_W
 
-	ldr r2, CCM_CCMR_W
-	str r2, [r0, #CCM_CCMR]
+	ldr	r2, CCM_CCMR_W
+	str	r2, [r0, #CCM_CCMR]
 
-	ldr r3, MPCTL_PARAM_532_W  /* consumer path*/
+	ldr	r3, MPCTL_PARAM_532_W		/* consumer path*/
 
-	/* Set MPLL , arm clock and ahb clock*/
-	str r3, [r0, #CCM_MPCTL]
+	/* Set MPLL, arm clock and ahb clock */
+	str	r3, [r0, #CCM_MPCTL]
 
-	ldr r1, PPCTL_PARAM_W
-	str r1, [r0, #CCM_PPCTL]
+	ldr	r1, PPCTL_PARAM_W
+	str	r1, [r0, #CCM_PPCTL]
 
-	ldr r1, CCM_PDR0_W
-	str r1, [r0, #CCM_PDR0]
+	ldr	r1, CCM_PDR0_W
+	str	r1, [r0, #CCM_PDR0]
 
-	ldr r1, [r0, #CCM_CGR0]
-	orr r1, r1, #0x00300000
-	str r1, [r0, #CCM_CGR0]
+	ldr	r1, [r0, #CCM_CGR0]
+	orr	r1, r1, #0x00300000
+	str	r1, [r0, #CCM_CGR0]
 
-	ldr r1, [r0, #CCM_CGR1]
-	orr r1, r1, #0x00000C00
-	orr r1, r1, #0x00000003
-	str r1, [r0, #CCM_CGR1]
+	ldr	r1, [r0, #CCM_CGR1]
+	orr	r1, r1, #0x00000C00
+	orr	r1, r1, #0x00000003
+	str	r1, [r0, #CCM_CGR1]
 
 	/* Skip SDRAM initialization if we run from RAM */
 	cmp	pc, #0x80000000
@@ -130,33 +130,33 @@ board_init_lowlevel:
 	mov	pc, r10
 
 1:
-	ldr r0, =ESDCTL_BASE_ADDR
-	mov r3, #0x2000
-	str r3, [r0, #0x0]
-	str r3, [r0, #0x8]
+	ldr	r0, =ESDCTL_BASE_ADDR
+	mov	r3, #0x2000
+	str	r3, [r0, #0x0]
+	str	r3, [r0, #0x8]
 
-	/* ip(r12) has used to save lr register in upper calling*/
-	mov fp, lr
+	/* ip(r12) has used to save lr register in upper calling */
+	mov	fp, lr
 
-	mov r5, #0x00
-	mov r2, #0x00
-	mov r1, #CSD0_BASE_ADDR
-	bl setup_sdram_bank
-	cmp r3, #0x0
-	orreq r5, r5, #1
-	eorne r2, r2, #0x1
-	blne setup_sdram_bank
+	mov	r5, #0x00
+	mov	r2, #0x00
+	mov	r1, #CSD0_BASE_ADDR
+	bl	setup_sdram_bank
+	cmp	r3, #0x0
+	orreq	r5, r5, #1
+	eorne	r2, r2, #0x1
+	blne	setup_sdram_bank
 
-	mov lr, fp
+	mov	lr, fp
 
-	ldr r3, =ESDCTL_DELAY_LINE5
-	str r3, [r0, #0x30]
+	ldr	r3, =ESDCTL_DELAY_LINE5
+	str	r3, [r0, #0x30]
 
 #ifdef CONFIG_NAND_IMX_BOOT
-	ldr	sp, =TEXT_BASE - 4	/* Setup a temporary stack in SDRAM */
+	ldr	sp, =TEXT_BASE - 4		/* Setup a temporary stack in SDRAM */
 
-	ldr	r0, =IMX_NFC_BASE		/* start of NFC SRAM                */
-	ldr	r2, =IMX_NFC_BASE + 0x800	/* end of NFC SRAM                  */
+	ldr	r0, =IMX_NFC_BASE		/* start of NFC SRAM */
+	ldr	r2, =IMX_NFC_BASE + 0x800	/* end of NFC SRAM */
 
 	/* skip NAND boot if not running from NFC space */
 	cmp	pc, r0
@@ -165,119 +165,119 @@ board_init_lowlevel:
 	bhs	ret
 
 	/* Move ourselves out of NFC SRAM */
-	ldr	r1, =TEXT_BASE
+	ldr r1, =TEXT_BASE
 
 copy_loop:
-	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
-	stmia	r1!, {r3-r9}		/* copy to   target address [r1]    */
-	cmp	r0, r2			/* until source end addreee [r2]    */
+	ldmia	r0!, {r3-r9}			/* copy from source address [r0] */
+	stmia	r1!, {r3-r9}			/* copy to   target address [r1] */
+	cmp	r0, r2				/* until source end addreee [r2] */
 	ble	copy_loop
 
-	ldr	pc, =1f			/* Jump to SDRAM                    */
+	ldr	pc, =1f				/* Jump to SDRAM */
 1:
-	bl	nand_boot		/* Load barebox from NAND Flash      */
+	bl	nand_boot			/* Load barebox from NAND Flash */
 
 	/* rebase the return address */
 	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
-	sub	r10, r10, r1		/* adjust return address from NFC SRAM */
+	sub	r10, r10, r1			/* adjust return address from NFC SRAM */
 ret:
 #endif /* CONFIG_NAND_IMX_BOOT */
 
-	mov pc, r10
+	mov	pc, r10
 
 /*
  * r0: ESDCTL control base, r1: sdram slot base
- * r2: DDR type(0:DDR2, 1:MDDR) r3, r4:working base
+ * r2: DDR type (0: DDR2, 1: MDDR) r3, r4: working base
  */
 setup_sdram_bank:
-	mov r3, #0xE /*0xA + 0x4*/
-	tst r2, #0x1
-	orreq r3, r3, #0x300 /*DDR2*/
-	str r3, [r0, #0x10]
-	bic r3, r3, #0x00A
-	str r3, [r0, #0x10]
-	beq 2f
-
-	mov r3, #0x20000
-1:	subs r3, r3, #1
-	bne 1b
-
-2:	tst r2, #0x1
-	ldreq r3, =ESDCTL_DDR2_CONFIG
-	ldrne r3, =ESDCTL_MDDR_CONFIG
-	cmp r1, #CSD1_BASE_ADDR
-	strlo r3, [r0, #0x4]
-	strhs r3, [r0, #0xC]
-
-	ldr r3, =ESDCTL_0x92220000
-	strlo r3, [r0, #0x0]
-	strhs r3, [r0, #0x8]
-	mov r3, #0xDA
-	ldr r4, =ESDCTL_PRECHARGE
-	strb r3, [r1, r4]
-
-	tst r2, #0x1
-	bne skip_set_mode
-
-	cmp r1, #CSD1_BASE_ADDR
-	ldr r3, =ESDCTL_0xB2220000
-	strlo r3, [r0, #0x0]
-	strhs r3, [r0, #0x8]
-	mov r3, #0xDA
-	ldr r4, =ESDCTL_DDR2_EMR2
-	strb r3, [r1, r4]
-	ldr r4, =ESDCTL_DDR2_EMR3
-	strb r3, [r1, r4]
-	ldr r4, =ESDCTL_DDR2_EN_DLL
-	strb r3, [r1, r4]
-	ldr r4, =ESDCTL_DDR2_RESET_DLL
-	strb r3, [r1, r4]
-
-	ldr r3, =ESDCTL_0x92220000
-	strlo r3, [r0, #0x0]
-	strhs r3, [r0, #0x8]
-	mov r3, #0xDA
-	ldr r4, =ESDCTL_PRECHARGE
-	strb r3, [r1, r4]
+	mov	r3, #0xE			/* 0xA + 0x4 */
+	tst	r2, #0x1
+	orreq	r3, r3, #0x300			/* DDR2 */
+	str	r3, [r0, #0x10]
+	bic	r3, r3, #0x00A
+	str	r3, [r0, #0x10]
+	beq	2f
+
+	mov	r3, #0x20000
+1:	subs	r3, r3, #1
+	bne	1b
+
+2:	tst	r2, #0x1
+	ldreq	r3, =ESDCTL_DDR2_CONFIG
+	ldrne	r3, =ESDCTL_MDDR_CONFIG
+	cmp	r1, #CSD1_BASE_ADDR
+	strlo	r3, [r0, #0x4]
+	strhs	r3, [r0, #0xC]
+
+	ldr	r3, =ESDCTL_0x92220000
+	strlo	r3, [r0, #0x0]
+	strhs	r3, [r0, #0x8]
+	mov	r3, #0xDA
+	ldr	r4, =ESDCTL_PRECHARGE
+	strb	r3, [r1, r4]
+
+	tst	r2, #0x1
+	bne	skip_set_mode
+
+	cmp	r1, #CSD1_BASE_ADDR
+	ldr	r3, =ESDCTL_0xB2220000
+	strlo	r3, [r0, #0x0]
+	strhs	r3, [r0, #0x8]
+	mov	r3, #0xDA
+	ldr	r4, =ESDCTL_DDR2_EMR2
+	strb	r3, [r1, r4]
+	ldr	r4, =ESDCTL_DDR2_EMR3
+	strb	r3, [r1, r4]
+	ldr	r4, =ESDCTL_DDR2_EN_DLL
+	strb	r3, [r1, r4]
+	ldr	r4, =ESDCTL_DDR2_RESET_DLL
+	strb	r3, [r1, r4]
+
+	ldr	r3, =ESDCTL_0x92220000
+	strlo	r3, [r0, #0x0]
+	strhs	r3, [r0, #0x8]
+	mov	r3, #0xDA
+	ldr	r4, =ESDCTL_PRECHARGE
+	strb	r3, [r1, r4]
 
 skip_set_mode:
-	cmp r1, #CSD1_BASE_ADDR
-	ldr r3, =ESDCTL_0xA2220000
-	strlo r3, [r0, #0x0]
-	strhs r3, [r0, #0x8]
-	mov r3, #0xDA
-	strb r3, [r1]
-	strb r3, [r1]
-
-	ldr r3, =ESDCTL_0xB2220000
-	strlo r3, [r0, #0x0]
-	strhs r3, [r0, #0x8]
-	tst r2, #0x1
-	ldreq r4, =ESDCTL_DDR2_MR
-	ldrne r4, =ESDCTL_MDDR_MR
-	mov r3, #0xDA
-	strb r3, [r1, r4]
-	ldreq r4, =ESDCTL_DDR2_OCD_DEFAULT
-	streqb r3, [r1, r4]
-	ldreq r4, =ESDCTL_DDR2_EN_DLL
-	ldrne r4, =ESDCTL_MDDR_EMR
-	strb r3, [r1, r4]
-
-	cmp r1, #CSD1_BASE_ADDR
-	ldr r3, =ESDCTL_0x82228080
-	strlo r3, [r0, #0x0]
-	strhs r3, [r0, #0x8]
-
-	tst r2, #0x1
-	moveq r4, #0x20000
-	movne r4, #0x200
-1:	subs r4, r4, #1
-	bne 1b
-
-	str r3, [r1, #0x100]
-	ldr r4, [r1, #0x100]
-	cmp r3, r4
-	movne r3, #1
-	moveq r3, #0
-
-	mov pc, lr
+	cmp	r1, #CSD1_BASE_ADDR
+	ldr	r3, =ESDCTL_0xA2220000
+	strlo	r3, [r0, #0x0]
+	strhs	r3, [r0, #0x8]
+	mov	r3, #0xDA
+	strb	r3, [r1]
+	strb	r3, [r1]
+
+	ldr	r3, =ESDCTL_0xB2220000
+	strlo	r3, [r0, #0x0]
+	strhs	r3, [r0, #0x8]
+	tst	r2, #0x1
+	ldreq	r4, =ESDCTL_DDR2_MR
+	ldrne	r4, =ESDCTL_MDDR_MR
+	mov	r3, #0xDA
+	strb	r3, [r1, r4]
+	ldreq	r4, =ESDCTL_DDR2_OCD_DEFAULT
+	streqb	r3, [r1, r4]
+	ldreq	r4, =ESDCTL_DDR2_EN_DLL
+	ldrne	r4, =ESDCTL_MDDR_EMR
+	strb	r3, [r1, r4]
+
+	cmp	r1, #CSD1_BASE_ADDR
+	ldr	r3, =ESDCTL_0x82228080
+	strlo	r3, [r0, #0x0]
+	strhs	r3, [r0, #0x8]
+
+	tst	r2, #0x1
+	moveq	r4, #0x20000
+	movne	r4, #0x200
+1:	subs	r4, r4, #1
+	bne	1b
+
+	str	r3, [r1, #0x100]
+	ldr	r4, [r1, #0x100]
+	cmp	r3, r4
+	movne	r3, #1
+	moveq	r3, #0
+
+	mov	pc, lr
-- 
1.6.6



From mkl at pengutronix.de  Mon Jan 18 06:56:29 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:29 +0100
Subject: [PATCH 6/8] i.MX35 3stack: increase env partition to hold splash image
In-Reply-To: <1263815791-10839-6-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-2-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-3-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-4-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-5-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-6-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-7-git-send-email-mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 board/freescale-mx35-3-stack/3stack.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/freescale-mx35-3-stack/3stack.c b/board/freescale-mx35-3-stack/3stack.c
index d87808a..e6fa0f0 100644
--- a/board/freescale-mx35-3-stack/3stack.c
+++ b/board/freescale-mx35-3-stack/3stack.c
@@ -171,13 +171,13 @@ static int f3s_devices_init(void)
 	case 0x01:		/* NAND is the source */
 		devfs_add_partition("nand0", 0x00000, 0x40000, PARTITION_FIXED, "self_raw");
 		dev_add_bb_dev("self_raw", "self0");
-		devfs_add_partition("nand0", 0x40000, 0x20000, PARTITION_FIXED, "env_raw");
+		devfs_add_partition("nand0", 0x40000, 0x80000, PARTITION_FIXED, "env_raw");
 		dev_add_bb_dev("env_raw", "env0");
 		break;
 
 	case 0x00:		/* NOR is the source */
 		devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
-		devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");
+		devfs_add_partition("nor0", 0x40000, 0x80000, PARTITION_FIXED, "env0");
 		protect_file("/dev/env0", 1);
 		break;
 	}
-- 
1.6.6



From mkl at pengutronix.de  Mon Jan 18 06:56:30 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:30 +0100
Subject: [PATCH 7/8] i.MX35 3stack: update environemnt to support jffs and
	ubi/ubifs
In-Reply-To: <1263815791-10839-7-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-2-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-3-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-4-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-5-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-6-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-7-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-8-git-send-email-mkl@pengutronix.de>

ubifs from nand is default

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 board/freescale-mx35-3-stack/env/bin/_update       |    5 ++-
 board/freescale-mx35-3-stack/env/bin/boot          |   50 ++++++++++++--------
 board/freescale-mx35-3-stack/env/bin/init          |   15 +++---
 board/freescale-mx35-3-stack/env/bin/update_kernel |    2 +-
 board/freescale-mx35-3-stack/env/bin/update_root   |   16 ------
 board/freescale-mx35-3-stack/env/bin/update_rootfs |   20 ++++++++
 board/freescale-mx35-3-stack/env/config            |   41 +++++++++-------
 7 files changed, 87 insertions(+), 62 deletions(-)
 delete mode 100644 board/freescale-mx35-3-stack/env/bin/update_root
 create mode 100644 board/freescale-mx35-3-stack/env/bin/update_rootfs

diff --git a/board/freescale-mx35-3-stack/env/bin/_update b/board/freescale-mx35-3-stack/env/bin/_update
index fb7cbe8..4f0839f 100644
--- a/board/freescale-mx35-3-stack/env/bin/_update
+++ b/board/freescale-mx35-3-stack/env/bin/_update
@@ -20,7 +20,7 @@ fi
 
 ping $eth0.serverip
 if [ $? -ne 0 ] ; then
-	echo "update aborted"
+	echo "Server did not reply! Update aborted."
 	exit 1
 fi
 
@@ -28,9 +28,12 @@ unprotect $part
 
 echo
 echo "erasing partition $part"
+echo
 erase $part
 
 echo
 echo "flashing $image to $part"
 echo
 tftp $image $part
+
+protect $part
diff --git a/board/freescale-mx35-3-stack/env/bin/boot b/board/freescale-mx35-3-stack/env/bin/boot
index dfb59aa..fb2fe61 100644
--- a/board/freescale-mx35-3-stack/env/bin/boot
+++ b/board/freescale-mx35-3-stack/env/bin/boot
@@ -3,43 +3,53 @@
 . /env/config
 
 if [ x$1 = xnand ]; then
-	root=nand
-	kernel=nand
+	rootfs_loc=nand
+	kernel_loc=nand
+elif [ x$1 = xnor ]; then
+	rootfs_loc=nor
+	kernel_loc=nor
+elif [ x$1 = xnet ]; then
+	rootfs_loc=net
+	kernel_loc=net
 fi
 
-if [ x$1 = xnet ]; then
-	root=net
-	kernel=net
-fi
-
-if [ x$1 = xnor ]; then
-	root=nor
-	kernel=nor
-fi
 
 if [ x$ip = xdhcp ]; then
 	bootargs="$bootargs ip=dhcp"
-else
+elif [ x$ip != xno ]; then
 	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
 fi
 
-if [ x$root = xnand ]; then
-	bootargs="$bootargs root=$rootpart_nand rootfstype=jffs2"
-elif [ x$root = xnor ]; then
-	bootargs="$bootargs root=$rootpart_nor rootfstype=jffs2"
+
+if [ $rootfs_loc != net ]; then
+	if [ x$rootfs_loc = xnand ]; then
+		rootfs_mtdblock=$rootfs_mtdblock_nand
+	else
+		rootfs_mtdblock=$rootfs_mtdblock_nor
+	fi
+
+
+	if [ $rootfs_type = ubifs ]; then
+		bootargs="$bootargs root=ubi0:root ubi.mtd=$rootfs_mtdblock"
+	else
+		bootargs="$bootargs root=/dev/mtdblock$rootfs_mtdblock"
+	fi
+
+	bootargs="$bootargs rootfstype=$rootfs_type"
 else
 	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
 fi
 
-bootargs="$bootargs mtdparts=physmap-flash.0:$nor_parts;imx_nand:$nand_parts"
 
-if [ $kernel = net ]; then
+bootargs="$bootargs mtdparts=\"physmap-flash.0:$nor_parts;mxc_nand:$nand_parts\""
+
+if [ $kernel_loc = net ]; then
 	if [ x$ip = xdhcp ]; then
 		dhcp
 	fi
-	tftp $uimage uImage || exit 1
+	tftp $kernel uImage || exit 1
 	bootm uImage
-elif [ $kernel = nor ]; then
+elif [ $kernel_loc = nor ]; then
 	bootm /dev/nor0.kernel
 else
 	bootm /dev/nand0.kernel.bb
diff --git a/board/freescale-mx35-3-stack/env/bin/init b/board/freescale-mx35-3-stack/env/bin/init
index cdf0f6b..c982f22 100644
--- a/board/freescale-mx35-3-stack/env/bin/init
+++ b/board/freescale-mx35-3-stack/env/bin/init
@@ -16,12 +16,13 @@ if [ -e /dev/nand0 ]; then
 	source /env/bin/hush_hack 
 fi
 
-#if [ -z $eth0.ethaddr ]; then
-#	while [ -z $eth0.ethaddr ]; do
-#		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
-#	done
-#	echo -a /env/config "eth0.ethaddr=$eth0.ethaddr"
-#fi
+if [ -z $eth0.ethaddr ]; then
+	while [ -z $eth0.ethaddr ]; do
+		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
+	done
+	echo -a /env/config "eth0.ethaddr=$eth0.ethaddr"
+	saveenv
+fi
 
 echo
 echo -n "Hit any key to stop autoboot: "
@@ -29,7 +30,7 @@ timeout -a $autoboot_timeout
 if [ $? != 0 ]; then
 	echo
 	echo "type update_kernel nand|nor [<imagename>] to update kernel into flash"
-	echo "type update_root nand|nor [<imagename>] to update rootfs into flash"
+	echo "type update_rootfs nand|nor [<imagename>] to update rootfs into flash"
 	echo
 	exit
 fi
diff --git a/board/freescale-mx35-3-stack/env/bin/update_kernel b/board/freescale-mx35-3-stack/env/bin/update_kernel
index 05c822d..63ad11a 100644
--- a/board/freescale-mx35-3-stack/env/bin/update_kernel
+++ b/board/freescale-mx35-3-stack/env/bin/update_kernel
@@ -1,8 +1,8 @@
 #!/bin/sh
 
 . /env/config
+image=$kernel
 
-image=$uimage
 if [ x$1 = xnand ]; then
 	part=/dev/nand0.kernel.bb
 elif [ x$1 = xnor ]; then
diff --git a/board/freescale-mx35-3-stack/env/bin/update_root b/board/freescale-mx35-3-stack/env/bin/update_root
deleted file mode 100644
index eaf36eb..0000000
--- a/board/freescale-mx35-3-stack/env/bin/update_root
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-if [ x$1 = xnand ]; then
-	part=/dev/nand0.root.bb
-elif [ x$1 = xnor ]; then
-	part=/dev/nor0.root
-else
-	echo "usage: $0 nor|nand [imagename]"
-	exit 1
-fi
-
-. /env/bin/_update $2
-
diff --git a/board/freescale-mx35-3-stack/env/bin/update_rootfs b/board/freescale-mx35-3-stack/env/bin/update_rootfs
new file mode 100644
index 0000000..53dd2ca
--- /dev/null
+++ b/board/freescale-mx35-3-stack/env/bin/update_rootfs
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. /env/config
+
+if [ $rootfs_type = ubifs ]; then
+	image=${rootfs}.ubi
+else
+	image=${rootfs}.$rootfs_type
+fi
+
+if [ x$1 = xnand ]; then
+	part=/dev/nand0.root.bb
+elif [ x$1 = xnor ]; then
+	part=/dev/nor0.root
+else
+	echo "usage: $0 nor|nand [imagename]"
+	exit 1
+fi
+
+. /env/bin/_update $2
diff --git a/board/freescale-mx35-3-stack/env/config b/board/freescale-mx35-3-stack/env/config
index 9fcb3dc..51195f7 100644
--- a/board/freescale-mx35-3-stack/env/config
+++ b/board/freescale-mx35-3-stack/env/config
@@ -1,28 +1,35 @@
 #!/bin/sh
 
+# use 'dhcp' to do dhcp in barebox and in kernel
+# use 'no' if you don't want to pass the ip from barebox to the kernel
+#ip=dhcp
+
+# or set your networking parameters here
+#eth0.ipaddr=a.b.c.d
+#eth0.netmask=a.b.c.d
+#eth0.gateway=a.b.c.d
+#eth0.serverip=a.b.c.d
+
 # can be either 'net', 'nor' or 'nand''
-kernel=net
-root=net
+kernel_loc=nand
+rootfs_loc=nand
 
-uimage=uImage-pcm038
-jffs2=root-pcm038.jffs2
+# can be either 'jffs2', or 'ubifs'
+rootfs_type=ubifs
+
+kernel=uImage-mx35-3-stack
+rootfs=root-mx35-3-stack
+envimage=u-boot-v2-environment-mx35-3-stack
 
 autoboot_timeout=3
 
-nfsroot="/ptx/work/octopus/rsc/svn/oselas/bsp/phytec/phyCORE-i.MX27/OSELAS.BSP-Phytec-phyCORE-i.MX27-trunk/root"
+nfsroot="/path/to/nfs/root"
 bootargs="console=ttymxc0,115200"
 
-nor_parts="256k(barebox)ro,128k(bareboxenv),1536k(kernel),-(root)"
-rootpart_nor="/dev/mtdblock3"
-
-nand_parts="256k(barebox)ro,128k(bareboxenv),1536k(kernel),-(root)"
-rootpart_nand="/dev/mtdblock7"
+bootargs="$bootargs video=mx3fb:CTP-CLAA070LC0ACW"
 
-# use 'dhcp' to do dhcp in barebox and in kernel
-ip=dhcp
+nor_parts="256k(barebox)ro,512k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nor=3
 
-# or set your networking parameters here
-#eth0.ipaddr=a.b.c.d
-#eth0.netmask=a.b.c.d
-#eth0.gateway=a.b.c.d
-#eth0.serverip=a.b.c.d
+nand_parts="256k(barebox)ro,512k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nand=7
-- 
1.6.6



From mkl at pengutronix.de  Mon Jan 18 06:56:31 2010
From: mkl at pengutronix.de (Marc Kleine-Budde)
Date: Mon, 18 Jan 2010 12:56:31 +0100
Subject: [PATCH 8/8] i.MX35 3stack: update of defconfig
In-Reply-To: <1263815791-10839-8-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-2-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-3-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-4-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-5-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-6-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-7-git-send-email-mkl@pengutronix.de>
	<1263815791-10839-8-git-send-email-mkl@pengutronix.de>
Message-ID: <1263815791-10839-9-git-send-email-mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 arch/arm/configs/freescale_mx35_3stack_defconfig |   67 ++++++++++++----------
 1 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/arch/arm/configs/freescale_mx35_3stack_defconfig b/arch/arm/configs/freescale_mx35_3stack_defconfig
index 1319a69..17a2fdc 100644
--- a/arch/arm/configs/freescale_mx35_3stack_defconfig
+++ b/arch/arm/configs/freescale_mx35_3stack_defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# barebox version: 2.0.0-rc10
-# Fri Dec 18 11:47:45 2009
+# barebox version: 2009.12.0-pre
+# Tue Dec 22 17:43:43 2009
 #
 # CONFIG_BOARD_LINKER_SCRIPT is not set
 CONFIG_GENERIC_LINKER_SCRIPT=y
@@ -43,17 +43,17 @@ CONFIG_MACH_FREESCALE_MX35_3STACK=y
 # CONFIG_MACH_PCM043 is not set
 
 #
-# Board specific settings
+# Board specific settings       
 #
 
 #
-# i.MX specific settings
+# i.MX specific settings        
 #
 # CONFIG_IMX_CLKO is not set
-# CONFIG_AEABI is not set
+CONFIG_AEABI=y
 
 #
-# Arm specific settings
+# Arm specific settings         
 #
 CONFIG_CMD_ARM_CPUINFO=y
 CONFIG_CMDLINE_TAG=y
@@ -68,12 +68,12 @@ CONFIG_ENV_HANDLING=y
 CONFIG_GENERIC_GPIO=y
 
 #
-# General Settings
+# General Settings              
 #
 CONFIG_LOCALVERSION_AUTO=y
 
 #
-# memory layout
+# memory layout                 
 #
 CONFIG_HAVE_CONFIGURABLE_TEXT_BASE=y
 CONFIG_TEXT_BASE=0x87F00000
@@ -81,7 +81,7 @@ CONFIG_HAVE_CONFIGURABLE_MEMORY_LAYOUT=y
 CONFIG_MEMORY_LAYOUT_DEFAULT=y
 # CONFIG_MEMORY_LAYOUT_FIXED is not set
 CONFIG_STACK_SIZE=0x8000
-CONFIG_MALLOC_SIZE=0x400000
+CONFIG_MALLOC_SIZE=0x1000000
 # CONFIG_BROKEN is not set
 # CONFIG_EXPERIMENTAL is not set
 CONFIG_MACH_HAS_LOWLEVEL_INIT=y
@@ -105,10 +105,10 @@ CONFIG_CONSOLE_ACTIVATE_FIRST=y
 # CONFIG_OF_FLAT_TREE is not set
 CONFIG_PARTITION=y
 CONFIG_DEFAULT_ENVIRONMENT=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="board/pcm043/env/"
+CONFIG_DEFAULT_ENVIRONMENT_PATH="board/freescale-mx35-3-stack/env/"
 
 #
-# Debugging
+# Debugging                     
 #
 # CONFIG_DEBUG_INFO is not set
 # CONFIG_ENABLE_FLASH_NOISE is not set
@@ -116,11 +116,11 @@ CONFIG_DEFAULT_ENVIRONMENT_PATH="board/pcm043/env/"
 # CONFIG_ENABLE_DEVICE_NOISE is not set
 
 #
-# Commands
+# Commands                      
 #
 
 #
-# scripting
+# scripting                     
 #
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_SLEEP=y
@@ -133,7 +133,7 @@ CONFIG_CMD_TRUE=y
 CONFIG_CMD_FALSE=y
 
 #
-# file commands
+# file commands                 
 #
 CONFIG_CMD_LS=y
 CONFIG_CMD_RM=y
@@ -147,13 +147,13 @@ CONFIG_CMD_MOUNT=y
 CONFIG_CMD_UMOUNT=y
 
 #
-# console
+# console                       
 #
 CONFIG_CMD_CLEAR=y
 CONFIG_CMD_ECHO=y
 
 #
-# memory
+# memory                        
 #
 # CONFIG_CMD_LOADB is not set
 CONFIG_CMD_MEMINFO=y
@@ -161,12 +161,12 @@ CONFIG_CMD_CRC=y
 # CONFIG_CMD_MTEST is not set
 
 #
-# flash
+# flash                         
 #
 CONFIG_CMD_FLASH=y
 
 #
-# booting
+# booting                       
 #
 CONFIG_CMD_BOOTM=y
 # CONFIG_CMD_BOOTM_ZLIB is not set
@@ -182,7 +182,8 @@ CONFIG_CMD_TEST=y
 CONFIG_CMD_VERSION=y
 CONFIG_CMD_HELP=y
 CONFIG_CMD_DEVINFO=y
-CONFIG_CMD_GPIO=y
+CONFIG_CMD_BMP=y
+# CONFIG_CMD_GPIO is not set
 CONFIG_NET=y
 CONFIG_NET_DHCP=y
 # CONFIG_NET_RARP is not set
@@ -191,11 +192,11 @@ CONFIG_NET_PING=y
 CONFIG_NET_TFTP=y
 
 #
-# Drivers
+# Drivers                       
 #
 
 #
-# serial drivers
+# serial drivers                
 #
 # CONFIG_DRIVER_SERIAL_ARM_DCC is not set
 CONFIG_DRIVER_SERIAL_IMX=y
@@ -203,39 +204,43 @@ CONFIG_DRIVER_SERIAL_IMX=y
 CONFIG_MIIPHY=y
 
 #
-# Network drivers
+# Network drivers               
 #
 CONFIG_DRIVER_NET_SMC911X=y
 CONFIG_DRIVER_NET_SMC911X_ADDRESS_SHIFT=0
 # CONFIG_DRIVER_NET_SMC91111 is not set
-# CONFIG_DRIVER_NET_FEC_IMX is not set
+CONFIG_DRIVER_NET_FEC_IMX=y
 
 #
-# SPI drivers
+# SPI drivers                   
 #
-CONFIG_SPI=y
-# CONFIG_DRIVER_SPI_IMX is not set
-# CONFIG_DRIVER_SPI_MC13783 is not set
+# CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_DRIVER_I2C_IMX=y
 CONFIG_DRIVER_I2C_MC13892=y
 CONFIG_DRIVER_I2C_MC9SDZ60=y
 
 #
-# flash drivers
+# flash drivers                 
 #
 CONFIG_HAS_CFI=y
 CONFIG_DRIVER_CFI=y
 # CONFIG_DRIVER_CFI_NEW is not set
 CONFIG_DRIVER_CFI_OLD=y
 CONFIG_CFI_BUFFER_WRITE=y
-# CONFIG_NAND is not set
+CONFIG_NAND=y
+CONFIG_NAND_IMX=y
+CONFIG_NAND_IMX_BOOT=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+CONFIG_MTD_NAND_IDS=y
 # CONFIG_USB is not set
 # CONFIG_USB_GADGET is not set
-# CONFIG_VIDEO is not set
+CONFIG_VIDEO=y
+CONFIG_DRIVER_VIDEO_IMX_IPU=y
 
 #
-# Filesystem support
+# Filesystem support            
 #
 # CONFIG_FS_CRAMFS is not set
 CONFIG_FS_RAMFS=y
-- 
1.6.6



From sha at pengutronix.de  Tue Jan 19 03:26:09 2010
From: sha at pengutronix.de (Sascha Hauer)
Date: Tue, 19 Jan 2010 09:26:09 +0100
Subject: [PATCH 0/8] update i.MX35 3stack and i2c drivers
In-Reply-To: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
References: <1263815791-10839-1-git-send-email-mkl@pengutronix.de>
Message-ID: <20100119082609.GF7200@pengutronix.de>

On Mon, Jan 18, 2010 at 12:56:23PM +0100, Marc Kleine-Budde wrote:
> Hey,
> 
> this is a patch series updating the driver interface of the two i2c
> chips (mc13892 and mc9sdz60) needed to boot the i.MX35 3stack board.
> They no longer export their i2c interface but export now much cleaner
> _reg_read, _reg_write and _set_bits functions.
> 
> The next pach adopts the i.MX35 to the new driver interface.
> 
> Two cleanup patches follow. Then the environment partition is increased
> to hold a splash image. The environemnt itself is updated to support
> jffs2 and ubi/ubifs. The last patch updates the defconfig.
> 
> Please review and consider to apply.
> 
> This patch series (based on v2009.12.0) can be pulled, too.
> 
> Cheers, Marc
> 
> ---
> 
> The following changes since commit c68c06cb0e5f9913473ab9cfbf7c48af79582c99:
>   Sascha Hauer (1):
>         barebox-2009.12.0
> 
> are available in the git repository at:
> 
>   ssh://git.pengutronix.de/git/mkl/barebox.git for-sha-mx35-3-stack-updates

Nice. Applied to -next.

Sascha


> 
> Marc Kleine-Budde (8):
>       mc9sdz60: clean up driver interface
>       mc13892: clean up driver interface
>       i.MX35 3stack: adopt board to new mc13892 and mc9sdz60 driver interface
>       i.MX35 3stack: clean up indention
>       i.MX35 3stack: clean up indention of lowlevel_init
>       i.MX35 3stack: increase env partition to hold splash image
>       i.MX35 3stack: update environemnt to support jffs and ubi/ubifs
>       i.MX35 3stack: update of defconfig
> 
>  arch/arm/configs/freescale_mx35_3stack_defconfig   |   67 ++--
>  board/freescale-mx35-3-stack/3stack.c              |  113 ++++---
>  board/freescale-mx35-3-stack/env/bin/_update       |    5 +-
>  board/freescale-mx35-3-stack/env/bin/boot          |   50 ++--
>  board/freescale-mx35-3-stack/env/bin/init          |   15 +-
>  board/freescale-mx35-3-stack/env/bin/update_kernel |    2 +-
>  .../env/bin/{update_root => update_rootfs}         |    8 +-
>  board/freescale-mx35-3-stack/env/config            |   41 ++-
>  board/freescale-mx35-3-stack/lowlevel_init.S       |  340 ++++++++++----------
>  drivers/i2c/mc13892.c                              |   91 ++++--
>  drivers/i2c/mc9sdz60.c                             |   84 ++++--
>  include/i2c/mc13892.h                              |   90 +++++-
>  include/i2c/mc9sdz60.h                             |   61 ++++-
>  13 files changed, 623 insertions(+), 344 deletions(-)
>  rename board/freescale-mx35-3-stack/env/bin/{update_root => update_rootfs} (68%)
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From jacmet at sunsite.dk  Tue Jan 19 03:54:25 2010
From: jacmet at sunsite.dk (Peter Korsgaard)
Date: Tue, 19 Jan 2010 09:54:25 +0100
Subject: [PATCH] mach-at91: reset_cpu: fix confusing reference to watchdog
Message-ID: <1263891265-15350-1-git-send-email-jacmet@sunsite.dk>

On at91 we talk directly to the reset controller to reset the cpu,
rather than use the watchdog, so update the comment to match.

Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
---
 arch/arm/mach-at91/clocksource.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-at91/clocksource.c b/arch/arm/mach-at91/clocksource.c
index b5886f9..564b560 100644
--- a/arch/arm/mach-at91/clocksource.c
+++ b/arch/arm/mach-at91/clocksource.c
@@ -71,7 +71,7 @@ static int clocksource_init (void)
 core_initcall(clocksource_init);
 
 /*
- * Reset the cpu by setting up the watchdog timer and let it time out
+ * Reset the cpu through the reset controller
  */
 void reset_cpu (ulong ignored)
 {
-- 
1.6.5



From list at lucaceresoli.net  Thu Jan 21 05:55:00 2010
From: list at lucaceresoli.net (Luca Ceresoli)
Date: Thu, 21 Jan 2010 11:55:00 +0100
Subject: Current status of barebox for OMAP3530/beagle
Message-ID: <KWLFNO$562DC6F7DC09B93F03CC58E59048B3DD@aruba.it>

Hi all,

after reading the docs and searching the list, it is still not clear to me how much barebox currently supports OMAP3530 (BeagleBoard in particular).

The omap3530_beagle_per_uart_defconfig is working great as a first stage UART loader, as well as adding a few commands. But I failed to go much further, i.e. to enable NAND support.

Is it expected to be working (and thus worth reporting problems), or is it just like "not done, and not expected to be there anytime soon"?

Thanks,
Luca




From s.hauer at pengutronix.de  Thu Jan 21 08:42:49 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 21 Jan 2010 14:42:49 +0100
Subject: Current status of barebox for OMAP3530/beagle
In-Reply-To: <KWLFNO$562DC6F7DC09B93F03CC58E59048B3DD@aruba.it>
References: <KWLFNO$562DC6F7DC09B93F03CC58E59048B3DD@aruba.it>
Message-ID: <20100121134249.GQ7200@pengutronix.de>

Hi,

On Thu, Jan 21, 2010 at 11:55:00AM +0100, Luca Ceresoli wrote:
> Hi all,
> 
> after reading the docs and searching the list, it is still not clear
> to me how much barebox currently supports OMAP3530 (BeagleBoard in
> particular).
> 
> The omap3530_beagle_per_uart_defconfig is working great as a first
> stage UART loader, as well as adding a few commands. But I failed to
> go much further, i.e. to enable NAND support.

I would expect NAND to be working, though I haven't tested it. What's
going wrong on your board?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From u.kleine-koenig at pengutronix.de  Fri Jan 22 10:06:28 2010
From: u.kleine-koenig at pengutronix.de (Uwe =?iso-8859-1?Q?Kleine-K=F6nig?=)
Date: Fri, 22 Jan 2010 16:06:28 +0100
Subject: [PATCH] arm cache fixes
Message-ID: <20100122150628.GA12856@pengutronix.de>

Hi,

while digging around in Linux' early boot code for ARM I noticed that
the mmu hasn't been disabled on iMX27 when giving control to Linux.

The other patch mostly cosmetic to print out when barebox.bin (and
barebox.S) are updated.

I send the patches as reply to this mail.  Shortlog and diffstat are
below.

Best regards
Uwe

The following changes since commit 0dde20da20411bf4dcd5593601d2f36e9ba04f66:
  Peter Korsgaard (1):
        documentation: It's U-Boot that doesn't have getopt, not Barebox

are available in the git repository at:

  git://git.pengutronix.de/git/ukl/barebox.git master

Uwe Kleine-K?nig (2):
      give nice output when generating barebox.bin and barebox.S
      arm: make disabling the cache actually work

 Makefile           |   15 ++++++++++++---
 arch/arm/cpu/mmu.c |   29 ++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 4 deletions(-)

-- 
Pengutronix e.K.                              | Uwe Kleine-K?nig            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |


From u.kleine-koenig at pengutronix.de  Fri Jan 22 10:14:35 2010
From: u.kleine-koenig at pengutronix.de (=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=)
Date: Fri, 22 Jan 2010 16:14:35 +0100
Subject: [PATCH 2/2] arm: make disabling the cache actually work
In-Reply-To: <20100122150628.GA12856@pengutronix.de>
References: <20100122150628.GA12856@pengutronix.de>
Message-ID: <1264173275-1858-2-git-send-email-u.kleine-koenig@pengutronix.de>

The code before looks to me like work in progress.  It only drained the
write buffer and skipped disabling mmu and caches by an early return
from inline assembler (which is broken in itself as it doesn't restore
frame pointer, stack pointer and other saved registers).

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig at pengutronix.de>
---
 arch/arm/cpu/mmu.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 9e00927..95b8302 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -54,7 +54,7 @@ void mmu_enable(void)
 {
 	asm volatile (
 		"mrc p15, 0, r1, c1, c0, 0;"
-		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache */
+		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache + alignment fault checking */
 		"mcr p15, 0, r1, c1, c0, 0"
 		:
 		:
@@ -67,6 +67,30 @@ void mmu_enable(void)
  */
 void mmu_disable(void)
 {
+#if defined(CONFIG_CPU_ARM926T)
+	unsigned int tmp = 0;
+	asm volatile (
+		/* test, clean and invalidate D cache */
+		"1:	mrc	p15, 0, r15, c7, c14, 3\n"
+		"	bne	1b\n"
+		/* invalidate I cache (Rd SBZ) */
+		"	mcr	p15, 0, %1, c7, c5, 0\n"
+		/* drain write buffer (Rd SBZ) */
+		"	mcr	p15, 0, %1, c7, c10, 4\n"
+
+		/* read control register */
+		"	mrc	p15, 0, %0, c1, c0\n"
+		/* clear C and M */
+		"	bic	%0, %0, #0x0005\n"
+		/* write back control register */
+		"	mcr	p15, 0, %0, c1, c0\n"
+
+		/* invalidate TLBs (Rd SBZ) */
+		"	mcr p15, 0, %1, c8, c7, 0;"
+		: "=&r" (tmp) : "r" (tmp) : "cc" );
+
+#else
+	/* ??? */
 	asm volatile (
 		"nop; "
 		"nop; "
@@ -75,9 +99,11 @@ void mmu_disable(void)
 		"nop; "
 		"nop; "
 		/* test, clean and invalidate cache */
+		/* mrc     p15, 0, $rd, c7, c14, 3; is armv5tej specific */
 		"1:	mrc	p15, 0, r15, c7, c14, 3;" 
 		"	bne	1b;"
 		"	mov	pc, lr;"
+		/* the following code is never reached */
 		"	mov r0, #0x0;"
 		"	mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer   */
 		"	mcr p15, 0, r1, c7, c6, 0;"  /* clear data cache         */
@@ -90,6 +116,7 @@ void mmu_disable(void)
 		:
 		: "r0" /* Clobber list */
 	);
+#endif
 }
 
 /*
-- 
1.6.6



From u.kleine-koenig at pengutronix.de  Fri Jan 22 10:14:34 2010
From: u.kleine-koenig at pengutronix.de (=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=)
Date: Fri, 22 Jan 2010 16:14:34 +0100
Subject: [PATCH 1/2] give nice output when generating barebox.bin and barebox.S
In-Reply-To: <20100122150628.GA12856@pengutronix.de>
References: <20100122150628.GA12856@pengutronix.de>
Message-ID: <1264173275-1858-1-git-send-email-u.kleine-koenig@pengutronix.de>

As a side effect don't build barebox.S when barebox.bin is updated.  I
didn't manage to keep the old behaviour and I consider it cleaner this
way.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig at pengutronix.de>
---
 Makefile |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 0c00829..5b5c2e8 100644
--- a/Makefile
+++ b/Makefile
@@ -641,9 +641,18 @@ define rule_barebox-modpost
 	$(Q)echo 'cmd_$@ := $(cmd_barebox-modpost)' > $(dot-target).cmd
 endef
 
-barebox.bin: barebox
-	$(Q)$(OBJCOPY) -O binary barebox barebox.bin
-	$(Q)$(OBJDUMP) -d barebox > barebox.S
+quiet_cmd_objcopy = OBJCOPY $@
+      cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
+
+OBJCOPYFLAGS_barebox.bin = -O binary
+barebox.bin: barebox FORCE
+	$(call if_changed,objcopy)
+#$(Q)$(OBJCOPY) -O binary barebox barebox.bin
+
+quiet_cmd_disasm = DISASM  $@
+      cmd_disasm = $(OBJDUMP) -d $< > $@
+barebox.S: barebox FORCE
+	$(call if_changed,disasm)
 
 # barebox image
 barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE
-- 
1.6.6



From eric at eukrea.com  Fri Jan 22 11:35:34 2010
From: eric at eukrea.com (=?ISO-8859-1?Q?Eric_B=E9nard?=)
Date: Fri, 22 Jan 2010 17:35:34 +0100
Subject: Barbox in OpenEmbedded
Message-ID: <4B59D3D6.5000900@eukrea.com>

Hi,

barebox now has its recipes in OpenEbmedded :
http://git.openembedded.org/cgit.cgi/openembedded/tree/recipes/barebox?id=3020a58f3e1c178a850b4a23d37c3829ecaa3ca9

which can build 2009.12 or git versions.

Eric


From luca at lucaceresoli.net  Fri Jan 22 16:57:31 2010
From: luca at lucaceresoli.net (Luca Ceresoli)
Date: Fri, 22 Jan 2010 22:57:31 +0100
Subject: Current status of barebox for OMAP3530/beagle
In-Reply-To: <20100121134249.GQ7200@pengutronix.de>
References: <KWLFNO$562DC6F7DC09B93F03CC58E59048B3DD@aruba.it>
	<20100121134249.GQ7200@pengutronix.de>
Message-ID: <4B5A1F4B.50907@lucaceresoli.net>

Sascha Hauer wrote:
 > I would expect NAND to be working, though I haven't tested it. What's
 > going wrong on your board?
Actually nothing about NAND, I think. Only, barebox with NAND support
does not run (no prompt). Detailed report follows.

Hardware: BeagleBoard (actually EBVBeagle) rev C2.
Toolchain: CodeSourcery 2009q3.
No JTAG device, sorry.

I set up a UART boot script that follows these steps:
1. 1st stage loader is the OMAP3530 boot ROM.
USER button is pressed, so it will boot from UART and receive
the 2nd stage loader.
2. 2nd stage is barebox with omap3530_beagle_per_uart_defconfig,
which is working great for transferring stage3 in SDRAM.
3. For 3rd stage loader I'm trying both U-boot (V1) and barebox.
4. The 3rd stage must load in NAND a signed image for regular
(non-UART) booting, for which I'm also trying V1 and barebox.

U-boot-v1 (omap3_beagle_config) as 3rd stage is working.
Also, using the V1 stage3 in SDRAM to burn a signed V1 in NAND works,
and after a normal reboot (user button not pressed) I get the prompt.

At step 3 I replace V1 with barebox, config
omap3530_beagle_per_uart_defconfig plus a few commands (config2.patch).

The result:

...
# go 0x80000000 [at the stage2 prompt]
## Starting application at 0x80000000 ...


barebox 2009.12.0 (Jan 22 2010 - 10:26:45) [now in stage3!]

Board: Texas Instrument's Beagle
Malloc space: 0x87bfff10 -> 0x87ffff10 (size 4 MB)
Stack space : 0x87bf7f10 -> 0x87bfff10 (size 32 kB)
running /env/bin/init...
not found
barebox-full>help [different prompt]
? - alias for help
bootu - bootu - start a raw linux image
...
barebox-full>cpuinfo
implementer: ARM
architecture: Unknown
cache: no cache
Control register: A W P D L Z I U XP
barebox-full>devinfo
devices:
|----serial_ns165500
|----cs0
|----ramfs0
|----devfs0
|----mem0 (mem)
|----mem1 (ram0)

drivers:
serial_ns16550
ramfs
devfs
mem
barebox-full>meminfo
max system bytes = 16624
system bytes = 16624
in use bytes = 9336
barebox-full>mtest 0x84000000 0x87bf0000
Testing 0x84000000 ... 0x87bf0000:
Pattern 0xFFFFFFED Writing... Reading... [10 minutes, no error]
barebox-full>

Great.
Now I add NAND support (config3.patch), restart the whole procedure
and suddenly stage3 barebox does not start:

...
# go 0x80000000 [at the stage2 prompt]
## Starting application at 0x80000000 ...

[nothing else]

This time barebox.bin is 83544 bytes big. In the previous test it was
less than 64KB. May this be the issue?
I tried another config, without NAND but with some totally useless
options, just to increase bin size. I got one that's 68908 bytes and
it does not boot, exactly as the NAND version.

A variant to all of the above consists in using U-boot V1 as a
3rd stage loader, to burn barebox in NAND.
The results are the same: without NAND support and below 64 kB it
boots, with NAND support or useless stuff and above 64 kB it does't.

Luca


From list at lucaceresoli.net  Fri Jan 22 12:34:17 2010
From: list at lucaceresoli.net (Luca Ceresoli)
Date: Fri, 22 Jan 2010 18:34:17 +0100
Subject: Current status of barebox for OMAP3530/beagle
Message-ID: <KWNST5$F3E5C74A9E7804703269FDE3154F494E@aruba.it>

Sascha Hauer wrote:
> I would expect NAND to be working, though I haven't tested it. What's
> going wrong on your board?
Actually nothing about NAND, I think. Only, barebox with NAND support
does not run (no prompt). Detailed report follows.

Hardware: BeagleBoard (actually EBVBeagle) rev C2.
Toolchain: CodeSourcery 2009q3.
No JTAG device, sorry.

I set up a UART boot script that follows these steps:
1. 1st stage loader is the OMAP3530 boot ROM.
USER button is pressed, so it will boot from UART and receive
the 2nd stage loader.
2. 2nd stage is barebox with omap3530_beagle_per_uart_defconfig,
which is working great for transferring stage3 in SDRAM.
3. For 3rd stage loader I'm trying both U-boot (V1) and barebox.
4. The 3rd stage must load in NAND a signed image for regular
(non-UART) booting, for which I'm also trying V1 and barebox.

U-boot-v1 (omap3_beagle_config) as 3rd stage is working.
Also, using the V1 stage3 in SDRAM to burn a signed V1 in NAND works,
and after a normal reboot (user button not pressed) I get the prompt.

At step 3 I replace V1 with barebox, config
omap3530_beagle_per_uart_defconfig plus a few commands (config2.patch).

The result:

 ...
 # go 0x80000000 [at the stage2 prompt]
 ## Starting application at 0x80000000 ...


 barebox 2009.12.0 (Jan 22 2010 - 10:26:45) [now in stage3!]

 Board: Texas Instrument's Beagle
 Malloc space: 0x87bfff10 -> 0x87ffff10 (size 4 MB)
 Stack space : 0x87bf7f10 -> 0x87bfff10 (size 32 kB)
 running /env/bin/init...
 not found
 barebox-full>help [different prompt]
 ? - alias for help
 bootu - bootu - start a raw linux image
 ...
 barebox-full>cpuinfo
 implementer: ARM
 architecture: Unknown
 cache: no cache
 Control register: A W P D L Z I U XP
 barebox-full>devinfo
 devices:
 |----serial_ns165500
 |----cs0
 |----ramfs0
 |----devfs0
 |----mem0 (mem)
 |----mem1 (ram0)

 drivers:
 serial_ns16550
 ramfs
 devfs
 mem
 barebox-full>meminfo
 max system bytes = 16624
 system bytes = 16624
 in use bytes = 9336
 barebox-full>mtest 0x84000000 0x87bf0000
 Testing 0x84000000 ... 0x87bf0000:
 Pattern 0xFFFFFFED Writing... Reading... [10 minutes, no error]
 barebox-full>

Great.
Now I add NAND support (config3.patch), restart the whole procedure
and suddenly stage3 barebox does not start:

 ...
 # go 0x80000000 [at the stage2 prompt]
 ## Starting application at 0x80000000 ...

 [nothing else]

This time barebox.bin is 83544 bytes big. In the previous test it was
less than 64KB. May this be the issue?
I tried another config, without NAND but with some totally useless
options, just to increase bin size. I got one that's 68908 bytes and
it does not boot, exactly as the NAND version.

A variant to all of the above consists in using U-boot V1 as a
3rd stage loader, to burn barebox in NAND.
The results are the same: without NAND support and below 64 kB it
boots, with NAND support or useless stuff and above 64 kB it does't.

Luca




From s.hauer at pengutronix.de  Mon Jan 25 02:32:20 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:20 +0100
Subject: [PATCH 02/12] remove obsolete comment
In-Reply-To: <1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 include/command.h |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/include/command.h b/include/command.h
index f103045..393438d 100644
--- a/include/command.h
+++ b/include/command.h
@@ -79,11 +79,6 @@ void barebox_cmd_usage(cmd_tbl_t *cmdtp);
 
 #endif	/* __ASSEMBLY__ */
 
-/*
- * Configurable monitor commands definitions have been moved
- * to include/cmd_confdefs.h
- */
-
 #define __stringify_1(x)	#x
 #define __stringify(x)		__stringify_1(x)
 
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:18 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:18 +0100
Subject: Patches for -next
Message-ID: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>

Hi all,

Here are some patches to review for -next

Sascha




From s.hauer at pengutronix.de  Mon Jan 25 02:32:22 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:22 +0100
Subject: [PATCH 04/12] remove unused NETCONSOLE stuff
In-Reply-To: <1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 net/net.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/net/net.c b/net/net.c
index 214685c..9818f42 100644
--- a/net/net.c
+++ b/net/net.c
@@ -576,9 +576,6 @@ NetReceive(uchar * inpkt, int len)
 				/* save address for later use */
 				memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6);
 
-#ifdef CONFIG_NETCONSOLE
-				(*packetHandler)(0,0,0,0);
-#endif
 				/* modify header, and transmit it */
 				memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, NetArpWaitPacketMAC, 6);
 				(void) eth_send(NetArpWaitTxPacket, NetArpWaitTxPacketSize);
@@ -737,13 +734,6 @@ NetReceive(uchar * inpkt, int len)
 			}
 		}
 #endif
-
-#ifdef CONFIG_NETCONSOLE
-		nc_input_packet((uchar *)ip +IP_HDR_SIZE,
-						ntohs(ip->udp_dst),
-						ntohs(ip->udp_src),
-						ntohs(ip->udp_len) - 8);
-#endif
 		/*
 		 *	IP header OK.  Pass the packet to the current handler.
 		 */
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:19 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:19 +0100
Subject: [PATCH 01/12] remove unused cdp code
In-Reply-To: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/net.c |   48 ------------------------------------------------
 include/net.h  |    8 --------
 2 files changed, 0 insertions(+), 56 deletions(-)

diff --git a/commands/net.c b/commands/net.c
index df06227..902c8bb 100644
--- a/commands/net.c
+++ b/commands/net.c
@@ -210,54 +210,6 @@ out:
 	return rcode;
 }
 
-#ifdef CONFIG_NET_CDP
-
-static void cdp_update_env(void)
-{
-	char tmp[16];
-
-	if (CDPApplianceVLAN != htons(-1)) {
-		printf("CDP offered appliance VLAN %d\n", ntohs(CDPApplianceVLAN));
-		VLAN_to_string(CDPApplianceVLAN, tmp);
-		setenv("vlan", tmp);
-		NetOurVLAN = CDPApplianceVLAN;
-	}
-
-	if (CDPNativeVLAN != htons(-1)) {
-		printf("CDP offered native VLAN %d\n", ntohs(CDPNativeVLAN));
-		VLAN_to_string(CDPNativeVLAN, tmp);
-		setenv("nvlan", tmp);
-		NetOurNativeVLAN = CDPNativeVLAN;
-	}
-
-}
-
-static int do_cdp (cmd_tbl_t *cmdtp, int argc, char *argv[])
-{
-	int r;
-
-	if (NetLoopInit(CDP) < 0)
-		return 1;
-
-	r = NetLoop();
-	if (r < 0) {
-		printf("cdp failed; perhaps not a CISCO switch?\n");
-		return 1;
-	}
-
-	cdp_update_env();
-
-	return 0;
-}
-
-BAREBOX_CMD_START(cdp)
-	.cmd		= do_cdp,
-	.usage		= "Perform CDP network configuration",
-	BAREBOX_CMD_HELP("[loadAddress] [host ip addr:bootfilename]\n")
-BAREBOX_CMD_END
-
-#endif	/* CONFIG_NET_CDP */
-
 static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
 {
 	struct eth_device *edev;
diff --git a/include/net.h b/include/net.h
index c689a43..7353c8f 100644
--- a/include/net.h
+++ b/include/net.h
@@ -279,10 +279,6 @@ extern uchar		NetEtherNullAddr[6];
 extern ushort		NetOurVLAN;		/* Our VLAN 			*/
 extern ushort		NetOurNativeVLAN;	/* Our Native VLAN 		*/
 
-extern uchar		NetCDPAddr[6]; 		/* Ethernet CDP address		*/
-extern ushort		CDPNativeVLAN;		/* CDP returned native VLAN	*/
-extern ushort		CDPApplianceVLAN;	/* CDP returned appliance VLAN	*/
-
 extern int		NetState;		/* Network loop state		*/
 
 /* ---------- Added by sha ------------ */
@@ -301,10 +297,6 @@ extern void ArpRequest (void);
 
 typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP } proto_t;
 
-/* when CDP completes these hold the return values */
-extern ushort CDPNativeVLAN;
-extern ushort CDPApplianceVLAN;
-
 /* Initialize the network adapter */
 int	NetLoopInit(proto_t);
 
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:23 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:23 +0100
Subject: [PATCH 05/12] remove unused file common/flash.c
In-Reply-To: <1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/flash.c |   73 --------------------------------------------------------
 1 files changed, 0 insertions(+), 73 deletions(-)
 delete mode 100644 common/flash.c

diff --git a/common/flash.c b/common/flash.c
deleted file mode 100644
index 4e3d9a3..0000000
--- a/common/flash.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * (C) Copyright 2000
- * 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
- */
-
-/* #define DEBUG */
-
-#include <common.h>
-#include <command.h>
-#include <cfi_flash.h>
-
-extern flash_info_t  flash_info[]; /* info for FLASH chips */
-
-flash_info_t *
-addr2info (ulong addr)
-{
-	printf("%s is broken\n",__FUNCTION__);
-
-	return (NULL);
-}
-
-void flash_perror (int err)
-{
-	switch (err) {
-	case ERR_OK:
-		break;
-	case ERR_TIMOUT:
-		puts ("Timeout writing to Flash\n");
-		break;
-	case ERR_NOT_ERASED:
-		puts ("Flash not Erased\n");
-		break;
-	case ERR_PROTECTED:
-		puts ("Can't write to protected Flash sectors\n");
-		break;
-	case ERR_INVAL:
-		puts ("Outside available Flash\n");
-		break;
-	case ERR_ALIGN:
-		puts ("Start and/or end address not on sector boundary\n");
-		break;
-	case ERR_UNKNOWN_FLASH_VENDOR:
-		puts ("Unknown Vendor of Flash\n");
-		break;
-	case ERR_UNKNOWN_FLASH_TYPE:
-		puts ("Unknown Type of Flash\n");
-		break;
-	case ERR_PROG_ERROR:
-		puts ("General Flash Programming Error\n");
-		break;
-	default:
-		printf ("%s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err);
-		break;
-	}
-}
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:30 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:30 +0100
Subject: [PATCH 12/12] i.MX: select armv6 for i.MX31/35
In-Reply-To: <1264404750-11596-12-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-8-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-9-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-10-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-11-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-12-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-13-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/Kconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index a1b2c1c..eeb392a 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -57,10 +57,12 @@ config ARCH_IMX27
 	select ARCH_HAS_FEC_IMX
 
 config ARCH_IMX31
+	select CPU_V6
 	bool "i.MX31"
 
 config ARCH_IMX35
 	bool "i.MX35"
+	select CPU_V6
 	select ARCH_HAS_FEC_IMX
 
 endchoice
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:28 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:28 +0100
Subject: [PATCH 10/12] put only once used function inline
In-Reply-To: <1264404750-11596-10-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-8-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-9-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-10-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-11-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 net/net.c |   19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/net/net.c b/net/net.c
index 7dc1bc6..4554d49 100644
--- a/net/net.c
+++ b/net/net.c
@@ -189,18 +189,6 @@ void ArpRequest (void)
 	(void) eth_send (NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
 }
 
-static void ArpTimeoutCheck(void)
-{
-	if (!NetArpWaitPacketIP)
-		return;
-
-	/* check for arp timeout */
-	if (is_timeout(NetArpWaitTimerStart, ARP_TIMEOUT)) {
-		NetArpWaitTimerStart = get_time_ns();
-		ArpRequest();
-	}
-}
-
 /**********************************************************************/
 /*
  *	Main network processing loop.
@@ -298,7 +286,12 @@ int NetLoop(void)
 			return -1;
 		}
 
-		ArpTimeoutCheck();
+		/* check for arp timeout */
+		if (NetArpWaitPacketIP &&
+				is_timeout(NetArpWaitTimerStart, ARP_TIMEOUT)) {
+			NetArpWaitTimerStart = get_time_ns();
+			ArpRequest();
+		}
 
 		/*
 		 *	Check for a timeout, and run the timeout handler
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:26 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:26 +0100
Subject: [PATCH 08/12] pcm043: initialize cpufreq to 532MHz
In-Reply-To: <1264404750-11596-8-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-8-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-9-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 board/pcm043/lowlevel_init.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/board/pcm043/lowlevel_init.S b/board/pcm043/lowlevel_init.S
index 9df064c..abbc72c 100644
--- a/board/pcm043/lowlevel_init.S
+++ b/board/pcm043/lowlevel_init.S
@@ -96,7 +96,7 @@ board_init_lowlevel:
 	ldr r2, CCM_CCMR_W
 	str r2, [r0, #CCM_CCMR]
 
-	ldr r3, MPCTL_PARAM_399_W  /* consumer path*/
+	ldr r3, MPCTL_PARAM_532_W  /* consumer path*/
 
 	/*Set MPLL , arm clock and ahb clock*/
 	str r3, [r0, #CCM_MPCTL]
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:29 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:29 +0100
Subject: [PATCH 11/12] add armv6 support to the konfig system
In-Reply-To: <1264404750-11596-11-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-8-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-9-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-10-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-11-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-12-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/cpu/Kconfig |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index cbec793..be01f3d 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -35,6 +35,11 @@ config CPU_ARM926T
 	  Say Y if you want support for the ARM926T processor.
 	  Otherwise, say N.
 
+# ARMv6
+config CPU_V6
+	bool
+	select CPU_32v6
+
 # ARMv7
 config CPU_V7
 	bool
@@ -48,6 +53,9 @@ config CPU_32v4T
 config CPU_32v5
 	bool
 
+config CPU_32v6
+	bool
+
 config CPU_32v7
 	bool
 
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:27 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:27 +0100
Subject: [PATCH 09/12] replace ET_DEBUG with pr_debug
In-Reply-To: <1264404750-11596-9-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-8-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-9-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-10-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 net/net.c  |   69 ++++++++++++++++++++---------------------------------------
 net/ping.c |    4 +--
 net/tftp.c |    2 -
 3 files changed, 25 insertions(+), 50 deletions(-)

diff --git a/net/net.c b/net/net.c
index 9818f42..7dc1bc6 100644
--- a/net/net.c
+++ b/net/net.c
@@ -153,9 +153,8 @@ void ArpRequest (void)
 	uchar *pkt;
 	ARP_t *arp;
 
-#ifdef ET_DEBUG
-	printf ("ARP broadcast\n");
-#endif
+	pr_debug("ARP broadcast\n");
+
 	pkt = NetTxPacket;
 
 	pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
@@ -379,10 +378,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 
 	/* if MAC address was not discovered yet, save the packet and do an ARP request */
 	if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
+		pr_debug("sending ARP for %08lx\n", dest);
 
-#ifdef ET_DEBUG
-		printf("sending ARP for %08lx\n", dest);
-#endif
 		NetArpWaitPacketIP = dest;
 		NetArpWaitPacketMAC = ether;
 
@@ -401,10 +398,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 		return 1;	/* waiting */
 	}
 
-#ifdef ET_DEBUG
-	printf("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n",
+	pr_debug("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n",
 		dest, ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]);
-#endif
 
 	pkt = (uchar *)NetTxPacket;
 	pkt += NetSetEther (pkt, ether, PROT_IP);
@@ -425,9 +420,7 @@ NetReceive(uchar * inpkt, int len)
 	uchar *pkt;
 	ushort cti = 0, vlanid = VLAN_NONE, myvlanid, mynvlanid;
 
-#ifdef ET_DEBUG
-	printf("packet received\n");
-#endif
+	pr_debug("packet received\n");
 
 	NetRxPkt = inpkt;
 	NetRxPktLen = len;
@@ -446,9 +439,7 @@ NetReceive(uchar * inpkt, int len)
 
 	x = ntohs(et->et_protlen);
 
-#ifdef ET_DEBUG
-	printf("packet received\n");
-#endif
+	pr_debug("packet received\n");
 
 	if (x < 1514) {
 		/*
@@ -466,9 +457,8 @@ NetReceive(uchar * inpkt, int len)
 	} else {			/* VLAN packet */
 		VLAN_Ethernet_t *vet = (VLAN_Ethernet_t *)et;
 
-#ifdef ET_DEBUG
-		printf("VLAN packet received\n");
-#endif
+		pr_debug("VLAN packet received\n");
+
 		/* too small packet? */
 		if (len < VLAN_ETHER_HDR_SIZE)
 			return;
@@ -486,9 +476,7 @@ NetReceive(uchar * inpkt, int len)
 		len -= VLAN_ETHER_HDR_SIZE;
 	}
 
-#ifdef ET_DEBUG
-	printf("Receive from protocol 0x%x\n", x);
-#endif
+	pr_debug("Receive from protocol 0x%x\n", x);
 
 	if ((myvlanid & VLAN_IDMASK) != VLAN_NONE) {
 		if (vlanid == VLAN_NONE)
@@ -510,9 +498,8 @@ NetReceive(uchar * inpkt, int len)
 		 *   address; so if we receive such a packet, we set
 		 *   the server ethernet address
 		 */
-#ifdef ET_DEBUG
-		puts ("Got ARP\n");
-#endif
+		pr_debug("Got ARP\n");
+
 		arp = (ARP_t *)ip;
 		if (len < ARP_HDR_SIZE) {
 			printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
@@ -541,9 +528,8 @@ NetReceive(uchar * inpkt, int len)
 
 		switch (ntohs(arp->ar_op)) {
 		case ARPOP_REQUEST:		/* reply with our IP address	*/
-#ifdef ET_DEBUG
-			puts ("Got ARP REQUEST, return our IP\n");
-#endif
+			pr_debug("Got ARP REQUEST, return our IP\n");
+
 			pkt = (uchar *)et;
 			pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
 			arp->ar_op = htons(ARPOP_REPLY);
@@ -559,20 +545,17 @@ NetReceive(uchar * inpkt, int len)
 			/* are we waiting for a reply */
 			if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC)
 				break;
-#ifdef ET_DEBUG
-			printf("Got ARP REPLY, set server/gtwy eth addr (%02x:%02x:%02x:%02x:%02x:%02x)\n",
+			pr_debug("Got ARP REPLY, set server/gtwy eth addr (%02x:%02x:%02x:%02x:%02x:%02x)\n",
 				arp->ar_data[0], arp->ar_data[1],
 				arp->ar_data[2], arp->ar_data[3],
 				arp->ar_data[4], arp->ar_data[5]);
-#endif
 
 			tmp = NetReadIP(&arp->ar_data[6]);
 
 			/* matched waiting packet's address */
 			if (tmp == NetArpWaitReplyIP) {
-#ifdef ET_DEBUG
-				puts ("Got it\n");
-#endif
+				pr_debug("Got it\n");
+
 				/* save address for later use */
 				memcpy(NetArpWaitPacketMAC, &arp->ar_data[0], 6);
 
@@ -588,17 +571,14 @@ NetReceive(uchar * inpkt, int len)
 			}
 			return;
 		default:
-#ifdef ET_DEBUG
-			printf("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
-#endif
+			pr_debug("Unexpected ARP opcode 0x%x\n", ntohs(arp->ar_op));
 			return;
 		}
 		break;
 
 	case PROT_RARP:
-#ifdef ET_DEBUG
-		puts ("Got RARP\n");
-#endif
+		pr_debug("Got RARP\n");
+
 		arp = (ARP_t *)ip;
 		if (len < ARP_HDR_SIZE) {
 			printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
@@ -622,9 +602,8 @@ NetReceive(uchar * inpkt, int len)
 		break;
 
 	case PROT_IP:
-#ifdef ET_DEBUG
-		puts ("Got IP\n");
-#endif
+		pr_debug("Got IP\n");
+
 		if (len < IP_HDR_SIZE) {
 			debug ("len bad %d < %d\n", len, IP_HDR_SIZE);
 			return;
@@ -634,9 +613,9 @@ NetReceive(uchar * inpkt, int len)
 			return;
 		}
 		len = ntohs(ip->ip_len);
-#ifdef ET_DEBUG
-		printf("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
-#endif
+
+		pr_debug("len=%d, v=%02x\n", len, ip->ip_hl_v & 0xff);
+
 		if ((ip->ip_hl_v & 0xf0) != 0x40) {
 			return;
 		}
diff --git a/net/ping.c b/net/ping.c
index 8759fd7..1bc481a 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -18,9 +18,7 @@ static int PingSend(void)
 
 	memcpy(mac, NetEtherNullAddr, 6);
 
-#ifdef ET_DEBUG
-	printf("sending ARP for %08lx\n", NetPingIP);
-#endif
+	pr_debug("sending ARP for %08lx\n", NetPingIP);
 
 	NetArpWaitPacketIP = NetPingIP;
 	NetArpWaitPacketMAC = mac;
diff --git a/net/tftp.c b/net/tftp.c
index 897bc48..26f0c43 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -15,8 +15,6 @@
 #include <fcntl.h>
 #include "tftp.h"
 
-#undef	ET_DEBUG
-
 #define WELL_KNOWN_PORT	69		/* Well known TFTP port #		*/
 #define TIMEOUT		5		/* Seconds to timeout for a lost pkt	*/
 # define TIMEOUT_COUNT	10		/* # of timeouts before giving up  */
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:24 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:24 +0100
Subject: [PATCH 06/12] Move tftp/nfs specific code to net/*
In-Reply-To: <1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>

This adds a few bytes of binary space but is done to put
the code where it belongs to.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/net.c |  108 --------------------------------------------------------
 net/nfs.c      |   56 ++++++++++++++++++++++++++++-
 net/tftp.c     |   72 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 126 insertions(+), 110 deletions(-)

diff --git a/commands/net.c b/commands/net.c
index 902c8bb..5fa49cf 100644
--- a/commands/net.c
+++ b/commands/net.c
@@ -32,12 +32,8 @@
 #include <driver.h>
 #include <net.h>
 #include <fs.h>
-#include <fcntl.h>
 #include <errno.h>
 #include <libbb.h>
-#include <libgen.h>
-
-static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]);
 
 void netboot_update_env(void)
 {
@@ -77,37 +73,6 @@ void netboot_update_env(void)
 		setenv ("domain", NetOurNISDomain);
 }
 
-static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
-{
-	return netboot_common (TFTP, cmdtp, argc, argv);
-}
-
-static const __maybe_unused char cmd_tftp_help[] =
-"Usage: tftp <file> [localfile]\n"
-"Load a file via network using BootP/TFTP protocol.\n";
-
-BAREBOX_CMD_START(tftp)
-	.cmd		= do_tftpb,
-	.usage		= "Load file using tftp protocol",
-	BAREBOX_CMD_HELP(cmd_tftp_help)
-BAREBOX_CMD_END
-
-/**
- * @page tftp_command tftp
- *
- * Usage is: tftp \<filename\> [\<localfilename\>]
- *
- * Load a file via network using BootP/TFTP protocol. The loaded file you
- * can find after download in you current ramdisk. Refer \b ls command.
- *
- * \<localfile> can be the local filename only, or also a device name. In the
- * case of a device name, the will gets stored there. This works also for
- * partitions of flash memory. Refer \b erase, \b unprotect for flash
- * preparation.
- *
- * Note: This command is available only, if enabled in the menuconfig.
- */
-
 #ifdef CONFIG_NET_RARP
 extern void RarpRequest(void);
 
@@ -137,79 +102,6 @@ BAREBOX_CMD_START(rarpboot)
 BAREBOX_CMD_END
 #endif /* CONFIG_NET_RARP */
 
-#ifdef CONFIG_NET_NFS
-static int do_nfs (cmd_tbl_t *cmdtp, int argc, char *argv[])
-{
-	return netboot_common(NFS, cmdtp, argc, argv);
-}
-
-static const __maybe_unused char cmd_nfs_help[] =
-"Usage: nfs <file> [localfile]\n"
-"Load a file via network using nfs protocol.\n";
-
-BAREBOX_CMD_START(nfs)
-	.cmd		= do_nfs,
-	.usage		= "boot image via network using nfs protocol",
-	BAREBOX_CMD_HELP(cmd_nfs_help)
-BAREBOX_CMD_END
-
-#endif	/* CONFIG_NET_NFS */
-
-int net_store_fd;
-
-extern void TftpStart(char *);       /* Begin TFTP get */
-extern void NfsStart(char *);
-
-static int
-netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
-{
-	int   rcode = 0;
-	int   size;
-	char  *localfile;
-	char  *remotefile;
-
-	if (argc < 2)
-		return COMMAND_ERROR_USAGE;
-
-	remotefile = argv[1];
-
-	if (argc == 2)
-		localfile = basename(remotefile);
-	else
-		localfile = argv[2];
-
-	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
-	if (net_store_fd < 0) {
-		perror("open");
-		return 1;
-	}
-
-	if (NetLoopInit(proto) < 0)
-		goto out;
-
-	switch (proto) {
-	case TFTP:
-		TftpStart(remotefile);
-		break;
-	case NFS:
-		NfsStart(remotefile);
-	default:
-		break;
-	}
-
-	if ((size = NetLoop()) < 0) {
-		rcode = size;
-		goto out;
-	}
-
-	/* NetLoop ok, update environment */
-	netboot_update_env();
-
-out:
-	close(net_store_fd);
-	return rcode;
-}
-
 static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
 {
 	struct eth_device *edev;
diff --git a/net/nfs.c b/net/nfs.c
index fe0bc70..f68741a 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -29,6 +29,9 @@
 #include <malloc.h>
 #include <libgen.h>
 #include <fs.h>
+#include <libgen.h>
+#include <fcntl.h>
+#include <errno.h>
 #include "nfs.h"
 
 /*#define NFS_DEBUG*/
@@ -63,7 +66,7 @@ static char *nfs_filename;
 static char *nfs_path;
 static char nfs_path_buff[2048];
 
-extern int net_store_fd;
+static int net_store_fd;
 
 static __inline__ int
 store_block (uchar * src, unsigned offset, unsigned len)
@@ -703,3 +706,54 @@ NfsStart (char *p)
 	NfsSend ();
 }
 
+static int do_nfs (cmd_tbl_t *cmdtp, int argc, char *argv[])
+{
+	int   rcode = 0;
+	char  *localfile;
+	char  *remotefile;
+
+	if (argc < 2)
+		return COMMAND_ERROR_USAGE;
+
+	remotefile = argv[1];
+
+	if (argc == 2)
+		localfile = basename(remotefile);
+	else
+		localfile = argv[2];
+
+	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
+	if (net_store_fd < 0) {
+		perror("open");
+		return 1;
+	}
+
+	if (NetLoopInit(NFS) < 0)
+		goto out;
+
+	NfsStart(remotefile);
+
+	rcode = NetLoop();
+	if (rcode < 0) {
+		rcode = 1;
+		goto out;
+	}
+
+	/* NetLoop ok, update environment */
+	netboot_update_env();
+
+out:
+	close(net_store_fd);
+	return rcode;
+}
+
+static const __maybe_unused char cmd_nfs_help[] =
+"Usage: nfs <file> [localfile]\n"
+"Load a file via network using nfs protocol.\n";
+
+BAREBOX_CMD_START(nfs)
+	.cmd		= do_nfs,
+	.usage		= "boot image via network using nfs protocol",
+	BAREBOX_CMD_HELP(cmd_nfs_help)
+BAREBOX_CMD_END
+
diff --git a/net/tftp.c b/net/tftp.c
index 169855f..b9c6fdd 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -11,6 +11,8 @@
 #include <clock.h>
 #include <fs.h>
 #include <errno.h>
+#include <libgen.h>
+#include <fcntl.h>
 #include "tftp.h"
 
 #undef	ET_DEBUG
@@ -49,7 +51,7 @@ static int	TftpState;
 
 static char *tftp_filename;
 
-extern int net_store_fd;
+static int net_store_fd;
 
 static int store_block(unsigned block, uchar * src, unsigned len)
 {
@@ -253,3 +255,71 @@ void TftpStart(char *filename)
 
 	TftpSend();
 }
+
+static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
+{
+	int   rcode = 0;
+	char  *localfile;
+	char  *remotefile;
+
+	if (argc < 2)
+		return COMMAND_ERROR_USAGE;
+
+	remotefile = argv[1];
+
+	if (argc == 2)
+		localfile = basename(remotefile);
+	else
+		localfile = argv[2];
+
+	net_store_fd = open(localfile, O_WRONLY | O_CREAT);
+	if (net_store_fd < 0) {
+		perror("open");
+		return 1;
+	}
+
+	if (NetLoopInit(TFTP) < 0)
+		goto out;
+
+	TftpStart(remotefile);
+
+	rcode = NetLoop();
+	if (rcode < 0) {
+		rcode = 1;
+		goto out;
+	}
+
+	/* NetLoop ok, update environment */
+	netboot_update_env();
+
+out:
+	close(net_store_fd);
+	return rcode;
+}
+
+static const __maybe_unused char cmd_tftp_help[] =
+"Usage: tftp <file> [localfile]\n"
+"Load a file via network using BootP/TFTP protocol.\n";
+
+BAREBOX_CMD_START(tftp)
+	.cmd		= do_tftpb,
+	.usage		= "Load file using tftp protocol",
+	BAREBOX_CMD_HELP(cmd_tftp_help)
+BAREBOX_CMD_END
+
+/**
+ * @page tftp_command tftp
+ *
+ * Usage is: tftp \<filename\> [\<localfilename\>]
+ *
+ * Load a file via network using BootP/TFTP protocol. The loaded file you
+ * can find after download in you current ramdisk. Refer \b ls command.
+ *
+ * \<localfile> can be the local filename only, or also a device name. In the
+ * case of a device name, the will gets stored there. This works also for
+ * partitions of flash memory. Refer \b erase, \b unprotect for flash
+ * preparation.
+ *
+ * Note: This command is available only, if enabled in the menuconfig.
+ */
+
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:21 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:21 +0100
Subject: [PATCH 03/12] cache functions from kernel
In-Reply-To: <1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/cpu/Makefile      |    6 +-
 arch/arm/cpu/cache-armv4.S |  137 ++++++++++++++++++++++++++++++++
 arch/arm/cpu/cache-armv6.S |  131 +++++++++++++++++++++++++++++++
 arch/arm/cpu/cache-armv7.S |  185 ++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/mmu.c         |   29 ++------
 5 files changed, 463 insertions(+), 25 deletions(-)
 create mode 100644 arch/arm/cpu/cache-armv4.S
 create mode 100644 arch/arm/cpu/cache-armv6.S
 create mode 100644 arch/arm/cpu/cache-armv7.S

diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 538ab57..2273e45 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -11,5 +11,7 @@ obj-$(CONFIG_ARCH_IMX31) += start-arm.o
 obj-$(CONFIG_ARCH_IMX35) += start-arm.o
 obj-$(CONFIG_CMD_ARM_CPUINFO) += cpuinfo.o
 obj-$(CONFIG_MMU) += mmu.o
-obj-$(CONFIG_MMU) += cache.o
-
+obj-$(CONFIG_CPU_32v4T)	+= cache-armv4.o
+obj-$(CONFIG_CPU_32v5)	+= cache-armv4.o
+obj-$(CONFIG_CPU_32v6)	+= cache-armv6.o
+obj-$(CONFIG_CPU_32v7)	+= cache-armv7.o
diff --git a/arch/arm/cpu/cache-armv4.S b/arch/arm/cpu/cache-armv4.S
new file mode 100644
index 0000000..a0ab256
--- /dev/null
+++ b/arch/arm/cpu/cache-armv4.S
@@ -0,0 +1,137 @@
+#include <linux/linkage.h>
+
+#define CACHE_DLINESIZE 32
+
+ENTRY(__mmu_cache_on)
+		mov	r12, lr
+#ifdef CONFIG_MMU
+		mov	r0, #0
+		mcr	p15, 0, r0, c7, c10, 4	@ drain write buffer
+		mcr	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
+		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
+		orr	r0, r0, #0x5000		@ I-cache enable, RR cache replacement
+		orr	r0, r0, #0x0030
+#ifdef CONFIG_CPU_ENDIAN_BE8
+		orr	r0, r0, #1 << 25	@ big-endian page tables
+#endif
+		bl	__common_mmu_cache_on
+		mov	r0, #0
+		mcr	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
+#endif
+		mov	pc, r12
+ENDPROC(__mmu_cache_on)
+
+__common_mmu_cache_on:
+		orr	r0, r0, #0x000d		@ Write buffer, mmu
+		b	1f
+		.align	5			@ cache line aligned
+1:		mcr	p15, 0, r0, c1, c0, 0	@ load control register
+		mrc	p15, 0, r0, c1, c0, 0	@ and read it back to
+		sub	pc, lr, r0, lsr #32	@ properly flush pipeline
+
+ENTRY(__mmu_cache_off)
+#ifdef CONFIG_MMU
+		mrc	p15, 0, r0, c1, c0
+		bic	r0, r0, #0x000d
+		mcr	p15, 0, r0, c1, c0	@ turn MMU and cache off
+		mov	r0, #0
+		mcr	p15, 0, r0, c7, c7	@ invalidate whole cache v4
+		mcr	p15, 0, r0, c8, c7	@ invalidate whole TLB v4
+#endif
+		mov	pc, lr
+ENDPROC(__mmu_cache_off)
+
+ENTRY(__mmu_cache_flush)
+		mrc	p15, 0, r6, c0, c0	@ get processor ID
+		mov	r2, #64*1024		@ default: 32K dcache size (*2)
+		mov	r11, #32		@ default: 32 byte line size
+		mrc	p15, 0, r3, c0, c0, 1	@ read cache type
+		teq	r3, r6			@ cache ID register present?
+		beq	no_cache_id
+		mov	r1, r3, lsr #18
+		and	r1, r1, #7
+		mov	r2, #1024
+		mov	r2, r2, lsl r1		@ base dcache size *2
+		tst	r3, #1 << 14		@ test M bit
+		addne	r2, r2, r2, lsr #1	@ +1/2 size if M == 1
+		mov	r3, r3, lsr #12
+		and	r3, r3, #3
+		mov	r11, #8
+		mov	r11, r11, lsl r3	@ cache line size in bytes
+no_cache_id:
+		mov	r1, pc
+		bic	r1, r1, #63		@ align to longest cache line
+		add	r2, r1, r2
+1:
+		ldr	r3, [r1], r11		@ s/w flush D cache
+		teq	r1, r2
+		bne	1b
+
+		mcr	p15, 0, r1, c7, c5, 0	@ flush I cache
+		mcr	p15, 0, r1, c7, c6, 0	@ flush D cache
+		mcr	p15, 0, r1, c7, c10, 4	@ drain WB
+		mov	pc, lr
+ENDPROC(__mmu_cache_flush)
+
+/*
+ *	dma_inv_range(start, end)
+ *
+ *	Invalidate (discard) the specified virtual address range.
+ *	May not write back any entries.  If 'start' or 'end'
+ *	are not cache line aligned, those lines must be written
+ *	back.
+ *
+ *	- start	- virtual start address
+ *	- end	- virtual end address
+ *
+ * (same as v4wb)
+ */
+ENTRY(dma_inv_range)
+	tst	r0, #CACHE_DLINESIZE - 1
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
+	tst	r1, #CACHE_DLINESIZE - 1
+	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
+1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
+	mov	pc, lr
+
+/*
+ *	dma_clean_range(start, end)
+ *
+ *	Clean the specified virtual address range.
+ *
+ *	- start	- virtual start address
+ *	- end	- virtual end address
+ *
+ * (same as v4wb)
+ */
+ENTRY(dma_clean_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
+	mov	pc, lr
+
+/*
+ *	dma_flush_range(start, end)
+ *
+ *	Clean and invalidate the specified virtual address range.
+ *
+ *	- start	- virtual start address
+ *	- end	- virtual end address
+ */
+ENTRY(dma_flush_range)
+	bic	r0, r0, #CACHE_DLINESIZE - 1
+1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
+	add	r0, r0, #CACHE_DLINESIZE
+	cmp	r0, r1
+	blo	1b
+	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
+	mov	pc, lr
+
diff --git a/arch/arm/cpu/cache-armv6.S b/arch/arm/cpu/cache-armv6.S
new file mode 100644
index 0000000..ceabd52
--- /dev/null
+++ b/arch/arm/cpu/cache-armv6.S
@@ -0,0 +1,131 @@
+#include <linux/linkage.h>
+
+#define HARVARD_CACHE
+#define CACHE_LINE_SIZE		32
+#define D_CACHE_LINE_SIZE	32
+
+ENTRY(__mmu_cache_on)
+		mov	r12, lr
+#ifdef CONFIG_MMU
+		mov	r0, #0
+		mcr	p15, 0, r0, c7, c10, 4	@ drain write buffer
+		mcr	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
+		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
+		orr	r0, r0, #0x5000		@ I-cache enable, RR cache replacement
+		orr	r0, r0, #0x0030
+#ifdef CONFIG_CPU_ENDIAN_BE8
+		orr	r0, r0, #1 << 25	@ big-endian page tables
+#endif
+		bl	__common_mmu_cache_on
+		mov	r0, #0
+		mcr	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
+#endif
+		mov	pc, r12
+ENDPROC(__mmu_cache_on)
+
+__common_mmu_cache_on:
+		orr	r0, r0, #0x000d		@ Write buffer, mmu
+		b	1f
+		.align	5			@ cache line aligned
+1:		mcr	p15, 0, r0, c1, c0, 0	@ load control register
+		mrc	p15, 0, r0, c1, c0, 0	@ and read it back to
+		sub	pc, lr, r0, lsr #32	@ properly flush pipeline
+
+ENTRY(__mmu_cache_off)
+#ifdef CONFIG_MMU
+		mrc	p15, 0, r0, c1, c0
+		bic	r0, r0, #0x000d
+		mcr	p15, 0, r0, c1, c0	@ turn MMU and cache off
+		mov	r0, #0
+		mcr	p15, 0, r0, c7, c7	@ invalidate whole cache v4
+		mcr	p15, 0, r0, c8, c7	@ invalidate whole TLB v4
+#endif
+		mov	pc, lr
+
+ENTRY(__mmu_cache_flush)
+		mov	r1, #0
+		mcr	p15, 0, r1, c7, c14, 0	@ clean+invalidate D
+		mcr	p15, 0, r1, c7, c5, 0	@ invalidate I+BTB
+		mcr	p15, 0, r1, c7, c15, 0	@ clean+invalidate unified
+		mcr	p15, 0, r1, c7, c10, 4	@ drain WB
+		mov	pc, lr
+ENDPROC(__mmu_cache_flush)
+
+/*
+ *	v6_dma_inv_range(start,end)
+ *
+ *	Invalidate the data cache within the specified region; we will
+ *	be performing a DMA operation in this region and we want to
+ *	purge old data in the cache.
+ *
+ *	- start   - virtual start address of region
+ *	- end     - virtual end address of region
+ */
+ENTRY(dma_inv_range)
+	tst	r0, #D_CACHE_LINE_SIZE - 1
+	bic	r0, r0, #D_CACHE_LINE_SIZE - 1
+#ifdef HARVARD_CACHE
+	mcrne	p15, 0, r0, c7, c10, 1		@ clean D line
+#else
+	mcrne	p15, 0, r0, c7, c11, 1		@ clean unified line
+#endif
+	tst	r1, #D_CACHE_LINE_SIZE - 1
+	bic	r1, r1, #D_CACHE_LINE_SIZE - 1
+#ifdef HARVARD_CACHE
+	mcrne	p15, 0, r1, c7, c14, 1		@ clean & invalidate D line
+#else
+	mcrne	p15, 0, r1, c7, c15, 1		@ clean & invalidate unified line
+#endif
+1:
+#ifdef HARVARD_CACHE
+	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D line
+#else
+	mcr	p15, 0, r0, c7, c7, 1		@ invalidate unified line
+#endif
+	add	r0, r0, #D_CACHE_LINE_SIZE
+	cmp	r0, r1
+	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
+	mov	pc, lr
+
+/*
+ *	v6_dma_clean_range(start,end)
+ *	- start   - virtual start address of region
+ *	- end     - virtual end address of region
+ */
+ENTRY(dma_clean_range)
+	bic	r0, r0, #D_CACHE_LINE_SIZE - 1
+1:
+#ifdef HARVARD_CACHE
+	mcr	p15, 0, r0, c7, c10, 1		@ clean D line
+#else
+	mcr	p15, 0, r0, c7, c11, 1		@ clean unified line
+#endif
+	add	r0, r0, #D_CACHE_LINE_SIZE
+	cmp	r0, r1
+	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
+	mov	pc, lr
+
+/*
+ *	v6_dma_flush_range(start,end)
+ *	- start   - virtual start address of region
+ *	- end     - virtual end address of region
+ */
+ENTRY(dma_flush_range)
+	bic	r0, r0, #D_CACHE_LINE_SIZE - 1
+1:
+#ifdef HARVARD_CACHE
+	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D line
+#else
+	mcr	p15, 0, r0, c7, c15, 1		@ clean & invalidate line
+#endif
+	add	r0, r0, #D_CACHE_LINE_SIZE
+	cmp	r0, r1
+	blo	1b
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
+	mov	pc, lr
+
diff --git a/arch/arm/cpu/cache-armv7.S b/arch/arm/cpu/cache-armv7.S
new file mode 100644
index 0000000..b370acd
--- /dev/null
+++ b/arch/arm/cpu/cache-armv7.S
@@ -0,0 +1,185 @@
+#include <linux/linkage.h>
+
+ENTRY(__mmu_cache_on)
+		mov	r12, lr
+#ifdef CONFIG_MMU
+		mrc	p15, 0, r11, c0, c1, 4	@ read ID_MMFR0
+		tst	r11, #0xf		@ VMSA
+		mov	r0, #0
+		mcr	p15, 0, r0, c7, c10, 4	@ drain write buffer
+		tst	r11, #0xf		@ VMSA
+		mcrne	p15, 0, r0, c8, c7, 0	@ flush I,D TLBs
+#endif
+		mrc	p15, 0, r0, c1, c0, 0	@ read control reg
+		orr	r0, r0, #0x5000		@ I-cache enable, RR cache replacement
+		orr	r0, r0, #0x003c		@ write buffer
+#ifdef CONFIG_MMU
+#ifdef CONFIG_CPU_ENDIAN_BE8
+		orr	r0, r0, #1 << 25	@ big-endian page tables
+#endif
+		orrne	r0, r0, #1		@ MMU enabled
+		movne	r1, #-1
+		mcrne	p15, 0, r3, c2, c0, 0	@ load page table pointer
+		mcrne	p15, 0, r1, c3, c0, 0	@ load domain access control
+#endif
+		mcr	p15, 0, r0, c1, c0, 0	@ load control register
+		mrc	p15, 0, r0, c1, c0, 0	@ and read it back
+		mov	r0, #0
+		mcr	p15, 0, r0, c7, c5, 4	@ ISB
+		mov	pc, r12
+ENDPROC(__mmu_cache_on)
+
+ENTRY(__mmu_cache_off)
+		mrc	p15, 0, r0, c1, c0
+#ifdef CONFIG_MMU
+		bic	r0, r0, #0x000d
+#else
+		bic	r0, r0, #0x000c
+#endif
+		mcr	p15, 0, r0, c1, c0	@ turn MMU and cache off
+		mov	r12, lr
+		bl	__mmu_cache_flush
+		mov	r0, #0
+#ifdef CONFIG_MMU
+		mcr	p15, 0, r0, c8, c7, 0	@ invalidate whole TLB
+#endif
+		mcr	p15, 0, r0, c7, c5, 6	@ invalidate BTC
+		mcr	p15, 0, r0, c7, c10, 4	@ DSB
+		mcr	p15, 0, r0, c7, c5, 4	@ ISB
+		mov	pc, r12
+ENDPROC(__mmu_cache_on)
+
+ENTRY(__mmu_cache_flush)
+		mrc	p15, 0, r10, c0, c1, 5	@ read ID_MMFR1
+		tst	r10, #0xf << 16		@ hierarchical cache (ARMv7)
+		mov	r10, #0
+		beq	hierarchical
+		mcr	p15, 0, r10, c7, c14, 0	@ clean+invalidate D
+		b	iflush
+hierarchical:
+		mcr	p15, 0, r10, c7, c10, 5	@ DMB
+		stmfd	sp!, {r0-r7, r9-r11}
+		mrc	p15, 1, r0, c0, c0, 1	@ read clidr
+		ands	r3, r0, #0x7000000	@ extract loc from clidr
+		mov	r3, r3, lsr #23		@ left align loc bit field
+		beq	finished		@ if loc is 0, then no need to clean
+		mov	r10, #0			@ start clean at cache level 0
+loop1:
+		add	r2, r10, r10, lsr #1	@ work out 3x current cache level
+		mov	r1, r0, lsr r2		@ extract cache type bits from clidr
+		and	r1, r1, #7		@ mask of the bits for current cache only
+		cmp	r1, #2			@ see what cache we have at this level
+		blt	skip			@ skip if no cache, or just i-cache
+		mcr	p15, 2, r10, c0, c0, 0	@ select current cache level in cssr
+		mcr	p15, 0, r10, c7, c5, 4	@ isb to sych the new cssr&csidr
+		mrc	p15, 1, r1, c0, c0, 0	@ read the new csidr
+		and	r2, r1, #7		@ extract the length of the cache lines
+		add	r2, r2, #4		@ add 4 (line length offset)
+		ldr	r4, =0x3ff
+		ands	r4, r4, r1, lsr #3	@ find maximum number on the way size
+		clz	r5, r4			@ find bit position of way size increment
+		ldr	r7, =0x7fff
+		ands	r7, r7, r1, lsr #13	@ extract max number of the index size
+loop2:
+		mov	r9, r4			@ create working copy of max way size
+loop3:
+		orr	r11, r10, r9, lsl r5	@ factor way and cache number into r11
+		orr	r11, r11, r7, lsl r2	@ factor index number into r11
+		mcr	p15, 0, r11, c7, c14, 2	@ clean & invalidate by set/way
+		subs	r9, r9, #1		@ decrement the way
+		bge	loop3
+		subs	r7, r7, #1		@ decrement the index
+		bge	loop2
+skip:
+		add	r10, r10, #2		@ increment cache number
+		cmp	r3, r10
+		bgt	loop1
+finished:
+		ldmfd	sp!, {r0-r7, r9-r11}
+		mov	r10, #0			@ swith back to cache level 0
+		mcr	p15, 2, r10, c0, c0, 0	@ select current cache level in cssr
+iflush:
+		mcr	p15, 0, r10, c7, c10, 4	@ DSB
+		mcr	p15, 0, r10, c7, c5, 0	@ invalidate I+BTB
+		mcr	p15, 0, r10, c7, c10, 4	@ DSB
+		mcr	p15, 0, r10, c7, c5, 4	@ ISB
+		mov	pc, lr
+ENDPROC(__mmu_cache_flush)
+
+/*
+ * cache_line_size - get the cache line size from the CSIDR register
+ * (available on ARMv7+). It assumes that the CSSR register was configured
+ * to access the L1 data cache CSIDR.
+ */
+	.macro	dcache_line_size, reg, tmp
+	mrc	p15, 1, \tmp, c0, c0, 0		@ read CSIDR
+	and	\tmp, \tmp, #7			@ cache line size encoding
+	mov	\reg, #16			@ size offset
+	mov	\reg, \reg, lsl \tmp		@ actual cache line size
+	.endm
+
+/*
+ *	v7_dma_inv_range(start,end)
+ *
+ *	Invalidate the data cache within the specified region; we will
+ *	be performing a DMA operation in this region and we want to
+ *	purge old data in the cache.
+ *
+ *	- start   - virtual start address of region
+ *	- end     - virtual end address of region
+ */
+ENTRY(dma_inv_range)
+	dcache_line_size r2, r3
+	sub	r3, r2, #1
+	tst	r0, r3
+	bic	r0, r0, r3
+	mcrne	p15, 0, r0, c7, c14, 1		@ clean & invalidate D / U line
+
+	tst	r1, r3
+	bic	r1, r1, r3
+	mcrne	p15, 0, r1, c7, c14, 1		@ clean & invalidate D / U line
+1:
+	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D / U line
+	add	r0, r0, r2
+	cmp	r0, r1
+	blo	1b
+	dsb
+	mov	pc, lr
+ENDPROC(dma_inv_range)
+
+/*
+ *	v7_dma_clean_range(start,end)
+ *	- start   - virtual start address of region
+ *	- end     - virtual end address of region
+ */
+ENTRY(dma_clean_range)
+	dcache_line_size r2, r3
+	sub	r3, r2, #1
+	bic	r0, r0, r3
+1:
+	mcr	p15, 0, r0, c7, c10, 1		@ clean D / U line
+	add	r0, r0, r2
+	cmp	r0, r1
+	blo	1b
+	dsb
+	mov	pc, lr
+ENDPROC(dma_clean_range)
+
+/*
+ *	v7_dma_flush_range(start,end)
+ *	- start   - virtual start address of region
+ *	- end     - virtual end address of region
+ */
+ENTRY(dma_flush_range)
+	dcache_line_size r2, r3
+	sub	r3, r2, #1
+	bic	r0, r0, r3
+1:
+	mcr	p15, 0, r0, c7, c14, 1		@ clean & invalidate D / U line
+	add	r0, r0, r2
+	cmp	r0, r1
+	blo	1b
+	dsb
+	mov	pc, lr
+ENDPROC(dma_flush_range)
+
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 9e00927..fff7ddf 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -53,12 +53,10 @@ void mmu_init(void)
 void mmu_enable(void)
 {
 	asm volatile (
-		"mrc p15, 0, r1, c1, c0, 0;"
-		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache */
-		"mcr p15, 0, r1, c1, c0, 0"
+		"bl __mmu_cache_on;"
 		:
 		:
-		: "r1" /* Clobber list */
+		: "r0", "r1", "r2", "r3", "r6", "r10", "r12"
         );
 }
 
@@ -67,28 +65,13 @@ void mmu_enable(void)
  */
 void mmu_disable(void)
 {
+
 	asm volatile (
-		"nop; "
-		"nop; "
-		"nop; "
-		"nop; "
-		"nop; "
-		"nop; "
-		/* test, clean and invalidate cache */
-		"1:	mrc	p15, 0, r15, c7, c14, 3;" 
-		"	bne	1b;"
-		"	mov	pc, lr;"
-		"	mov r0, #0x0;"
-		"	mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer   */
-		"	mcr p15, 0, r1, c7, c6, 0;"  /* clear data cache         */
-		"	mrc p15, 0, r1, c1, c0, 0;"
-		"	bic r1, r1, #0x0007;"        /* disable MMU + DCache     */
-		"	mcr p15, 0, r1, c1, c0, 0;"
-		"	mcr p15, 0, r0, c7, c6, 0;" /* flush d-cache             */
-		"	mcr p15, 0, r0, c8, c7, 0;" /* flush i+d-TLBs            */
+		"bl __mmu_cache_flush;"
+		"bl __mmu_cache_off;"
 		:
 		:
-		: "r0" /* Clobber list */
+		: "r0", "r1", "r2", "r3", "r6", "r10", "r12"
 	);
 }
 
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:32:25 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:32:25 +0100
Subject: [PATCH 07/12] remove typedef cmd_tbl_t and replace it with struct
	command
In-Reply-To: <1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-5-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-6-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-7-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1264404750-11596-8-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/cpu/cpu.c                 |    2 +-
 arch/arm/cpu/cpuinfo.c             |    2 +-
 arch/arm/lib/armlinux.c            |    4 ++--
 arch/arm/mach-imx/clko.c           |    2 +-
 arch/arm/mach-imx/speed.c          |    2 +-
 arch/arm/mach-netx/generic.c       |    2 +-
 arch/ppc/mach-mpc5xxx/interrupts.c |    2 +-
 board/ipe337/cmd_alternate.c       |    2 +-
 board/pcm043/pcm043.c              |    2 +-
 commands/bmp.c                     |    2 +-
 commands/bootm.c                   |    6 +++---
 commands/cat.c                     |    2 +-
 commands/cd.c                      |    2 +-
 commands/clear.c                   |    2 +-
 commands/cp.c                      |    2 +-
 commands/crc.c                     |    2 +-
 commands/dfu.c                     |    2 +-
 commands/echo.c                    |    2 +-
 commands/edit.c                    |    2 +-
 commands/exec.c                    |    2 +-
 commands/export.c                  |    2 +-
 commands/false.c                   |    2 +-
 commands/flash.c                   |    4 ++--
 commands/go.c                      |    2 +-
 commands/gpio.c                    |    8 ++++----
 commands/help.c                    |    2 +-
 commands/insmod.c                  |    2 +-
 commands/loadb.c                   |    2 +-
 commands/loadenv.c                 |    2 +-
 commands/loads.c                   |    4 ++--
 commands/ls.c                      |    2 +-
 commands/lsmod.c                   |    2 +-
 commands/mem.c                     |   10 +++++-----
 commands/meminfo.c                 |    2 +-
 commands/memtest.c                 |    2 +-
 commands/mkdir.c                   |    2 +-
 commands/mount.c                   |    2 +-
 commands/nand.c                    |    2 +-
 commands/net.c                     |    4 ++--
 commands/partition.c               |    4 ++--
 commands/printenv.c                |    2 +-
 commands/pwd.c                     |    2 +-
 commands/readline.c                |    2 +-
 commands/reginfo.c                 |    2 +-
 commands/reset.c                   |    2 +-
 commands/rm.c                      |    2 +-
 commands/rmdir.c                   |    2 +-
 commands/saveenv.c                 |    2 +-
 commands/setenv.c                  |    2 +-
 commands/sleep.c                   |    2 +-
 commands/test.c                    |    2 +-
 commands/timeout.c                 |    2 +-
 commands/true.c                    |    2 +-
 commands/umount.c                  |    2 +-
 commands/version.c                 |    2 +-
 common/command.c                   |   26 +++++++++++++-------------
 common/complete.c                  |    2 +-
 common/hush.c                      |    6 +++---
 common/module.c                    |    4 ++--
 drivers/nand/nand_imx.c            |    2 +-
 drivers/nand/nand_s3c2410.c        |    2 +-
 drivers/usb/gadget/u_serial.c      |    2 +-
 drivers/usb/usb.c                  |    2 +-
 include/command.h                  |   20 ++++++++------------
 lib/driver.c                       |    2 +-
 net/dhcp.c                         |    2 +-
 net/nfs.c                          |    2 +-
 net/ping.c                         |    2 +-
 net/tftp.c                         |    2 +-
 69 files changed, 105 insertions(+), 109 deletions(-)

diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c
index 501e9b9..1b8fc97 100644
--- a/arch/arm/cpu/cpu.c
+++ b/arch/arm/cpu/cpu.c
@@ -162,7 +162,7 @@ int cleanup_before_linux (void)
  * required.
  */
 
-static int do_icache(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_icache(struct command *cmdtp, int argc, char *argv[])
 {
 	if (argc == 1) {
 		printf("icache is %sabled\n", icache_status() ? "en" : "dis");
diff --git a/arch/arm/cpu/cpuinfo.c b/arch/arm/cpu/cpuinfo.c
index e7bcda9..e19b8de 100644
--- a/arch/arm/cpu/cpuinfo.c
+++ b/arch/arm/cpu/cpuinfo.c
@@ -41,7 +41,7 @@ static char *crbits[] = {"M", "A", "C", "W", "P", "D", "L", "B", "S", "R",
 	"F", "Z", "I", "V", "RR", "L4", "", "", "", "", "", "FI", "U", "XP",
 	"VE", "EE", "L2"};
 
-static int do_cpuinfo(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_cpuinfo(struct command *cmdtp, int argc, char *argv[])
 {
 	unsigned long mainid, cache, cr;
 	char *architecture, *implementer;
diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c
index 25b7744..2415c29 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -235,7 +235,7 @@ struct zimage_header {
 	u32	end;
 };
 
-static int do_bootz(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_bootz(struct command *cmdtp, int argc, char *argv[])
 {
 	void (*theKernel)(int zero, int arch, void *params);
 	const char *commandline = getenv("bootargs");
@@ -308,7 +308,7 @@ BAREBOX_CMD_END
 #endif /* CONFIG_CMD_BOOTZ */
 
 #ifdef CONFIG_CMD_BOOTU
-static int do_bootu(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_bootu(struct command *cmdtp, int argc, char *argv[])
 {
 	void (*theKernel)(int zero, int arch, void *params);
 	const char *commandline = getenv("bootargs");
diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c
index b6efe87..37e17fe 100644
--- a/arch/arm/mach-imx/clko.c
+++ b/arch/arm/mach-imx/clko.c
@@ -4,7 +4,7 @@
 #include <mach/imx-regs.h>
 #include <mach/clock.h>
 
-static int do_clko (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_clko(struct command *cmdtp, int argc, char *argv[])
 {
 	int opt, div = 0, src = -2, ret;
 
diff --git a/arch/arm/mach-imx/speed.c b/arch/arm/mach-imx/speed.c
index 76ab6b9..e024733 100644
--- a/arch/arm/mach-imx/speed.c
+++ b/arch/arm/mach-imx/speed.c
@@ -69,7 +69,7 @@ unsigned int imx_decode_pll(unsigned int reg_val, unsigned int freq)
 
 extern void imx_dump_clocks(void);
 
-static int do_clocks (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_clocks(struct command *cmdtp, int argc, char *argv[])
 {
 	imx_dump_clocks();
 
diff --git a/arch/arm/mach-netx/generic.c b/arch/arm/mach-netx/generic.c
index 76ae6bd..69cf196 100644
--- a/arch/arm/mach-netx/generic.c
+++ b/arch/arm/mach-netx/generic.c
@@ -116,7 +116,7 @@ int loadxc(int xcno) {
 	return 0;
 }
 
-int do_loadxc (cmd_tbl_t *cmdtp, int argc, char *argv[])
+int do_loadxc(struct command *cmdtp, int argc, char *argv[])
 {
 	int xcno;
 
diff --git a/arch/ppc/mach-mpc5xxx/interrupts.c b/arch/ppc/mach-mpc5xxx/interrupts.c
index 58f4530..e484b6e 100644
--- a/arch/ppc/mach-mpc5xxx/interrupts.c
+++ b/arch/ppc/mach-mpc5xxx/interrupts.c
@@ -314,7 +314,7 @@ void irq_free_handler(int irq)
 /****************************************************************************/
 
 #if (CONFIG_COMMANDS & CFG_CMD_IRQ)
-void do_irqinfo(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
+void do_irqinfo(struct command * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
 {
 	int irq, re_enable;
 	u32 intr_ctrl;
diff --git a/board/ipe337/cmd_alternate.c b/board/ipe337/cmd_alternate.c
index 538f0bf..2883c77 100644
--- a/board/ipe337/cmd_alternate.c
+++ b/board/ipe337/cmd_alternate.c
@@ -6,7 +6,7 @@
 
 #define MAGIC		0x19691228
 
-static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_alternate(struct command *cmdtp, int argc, char *argv[])
 {
 	void *buf;
 	size_t size;
diff --git a/board/pcm043/pcm043.c b/board/pcm043/pcm043.c
index 0e7f6d3..7b0bad1 100644
--- a/board/pcm043/pcm043.c
+++ b/board/pcm043/pcm043.c
@@ -353,7 +353,7 @@ core_initcall(pcm043_core_setup);
 #define MPCTL_PARAM_399     (IMX_PLL_PD(0) | IMX_PLL_MFD(15) | IMX_PLL_MFI(8) | IMX_PLL_MFN(5))
 #define MPCTL_PARAM_532     ((1 << 31) | IMX_PLL_PD(0) | IMX_PLL_MFD(11) | IMX_PLL_MFI(11) | IMX_PLL_MFN(1))
 
-static int do_cpufreq(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_cpufreq(struct command *cmdtp, int argc, char *argv[])
 {
 	unsigned long freq;
 
diff --git a/commands/bmp.c b/commands/bmp.c
index 51989e1..6e17200 100644
--- a/commands/bmp.c
+++ b/commands/bmp.c
@@ -29,7 +29,7 @@ static inline void set_pixel(struct fb_info *info, void *adr, int r, int g, int
 	}
 }
 
-static int do_bmp(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_bmp(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret, opt, fd;
 	char *fbdev = "/dev/fb0";
diff --git a/commands/bootm.c b/commands/bootm.c
index 849d4c2..11325dc 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -52,7 +52,7 @@
  *  - loaded (first part of) image to header load address,
  *  - disabled interrupts.
  */
-typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, int flag,
+typedef void boot_os_Fcn(struct command *cmdtp, int flag,
 			  int	argc, char *argv[],
 			  ulong	addr,		/* of image to boot */
 			  ulong	*len_ptr,	/* multi-file image length table */
@@ -364,7 +364,7 @@ static int handler_parse_options(struct image_data *data, int opt, char *optarg)
 	return -1;
 }
 
-static int do_bootm (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_bootm(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong	iflag;
 	int	opt;
@@ -464,7 +464,7 @@ BAREBOX_CMD_START(bootm)
 BAREBOX_CMD_END
 
 #ifdef CONFIG_CMD_IMI
-static int do_iminfo ( cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_iminfo(struct command *cmdtp, int argc, char *argv[])
 {
 	int	arg;
 	ulong	addr;
diff --git a/commands/cat.c b/commands/cat.c
index c0a93d8..41b3324 100644
--- a/commands/cat.c
+++ b/commands/cat.c
@@ -39,7 +39,7 @@
  * @param[in] argc Argument count from command line
  * @param[in] argv List of input arguments
  */
-static int do_cat(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_cat(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret;
 	int fd, i;
diff --git a/commands/cd.c b/commands/cd.c
index 50e40b6..a842f4d 100644
--- a/commands/cd.c
+++ b/commands/cd.c
@@ -30,7 +30,7 @@
 #include <fs.h>
 #include <errno.h>
 
-static int do_cd (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_cd(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret;
 
diff --git a/commands/clear.c b/commands/clear.c
index 1788428..7589a0c 100644
--- a/commands/clear.c
+++ b/commands/clear.c
@@ -24,7 +24,7 @@
 #include <command.h>
 #include <readkey.h>
 
-static int do_clear (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_clear(struct command *cmdtp, int argc, char *argv[])
 {
 	printf(ANSI_CLEAR_SCREEN);
 
diff --git a/commands/cp.c b/commands/cp.c
index aa7b410..a0c7c84 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -37,7 +37,7 @@
  * @param[in] argc Argument count from command line
  * @param[in] argv List of input arguments
  */
-static int do_cp ( cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_cp(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret = 1;
 	struct stat statbuf;
diff --git a/commands/crc.c b/commands/crc.c
index 17188c7..4842cdc 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -30,7 +30,7 @@
 #include <malloc.h>
 #include <linux/ctype.h>
 
-static int do_crc (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_crc(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong start = 0, size = ~0, total = 0;
 	ulong crc = 0, vcrc = 0;
diff --git a/commands/dfu.c b/commands/dfu.c
index fe865ef..66fd6ea 100644
--- a/commands/dfu.c
+++ b/commands/dfu.c
@@ -95,7 +95,7 @@ static int dfu_do_parse_one(char *partstr, char **endstr, struct usb_dfu_dev *df
  * s = save mode (download whole image before flashing)
  * r = read back (firmware image can be downloaded back from host)
  */
-static int do_dfu(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_dfu(struct command *cmdtp, int argc, char *argv[])
 {
 	int opt, n = 0;
 	struct usb_dfu_pdata pdata;
diff --git a/commands/echo.c b/commands/echo.c
index 49bd44e..d5640a0 100644
--- a/commands/echo.c
+++ b/commands/echo.c
@@ -26,7 +26,7 @@
 #include <fcntl.h>
 #include <errno.h>
 
-static int do_echo (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_echo(struct command *cmdtp, int argc, char *argv[])
 {
 	int i, optind = 1;
 	int fd = stdout, opt, newline = 1;
diff --git a/commands/edit.c b/commands/edit.c
index d292a52..e851f0f 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -389,7 +389,7 @@ static void getwinsize(void) {
 }
 #endif
 
-static int do_edit(cmd_tbl_t * cmdtp, int argc, char *argv[])
+static int do_edit(struct command * cmdtp, int argc, char *argv[])
 {
 	int lastscrcol;
 	int i;
diff --git a/commands/exec.c b/commands/exec.c
index ce0a0a9..5f093b7 100644
--- a/commands/exec.c
+++ b/commands/exec.c
@@ -29,7 +29,7 @@
 #include <malloc.h>
 #include <xfuncs.h>
 
-static int do_exec(cmd_tbl_t * cmdtp, int argc, char *argv[])
+static int do_exec(struct command * cmdtp, int argc, char *argv[])
 {
 	int i;
 	char *script;
diff --git a/commands/export.c b/commands/export.c
index 3e2f84d..31259cc 100644
--- a/commands/export.c
+++ b/commands/export.c
@@ -28,7 +28,7 @@
 #include <errno.h>
 #include <environment.h>
 
-static int do_export ( cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_export(struct command *cmdtp, int argc, char *argv[])
 {
 	int i = 1;
 	char *ptr;
diff --git a/commands/false.c b/commands/false.c
index fec3fdf..a90eadc 100644
--- a/commands/false.c
+++ b/commands/false.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-static int do_false (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_false(struct command *cmdtp, int argc, char *argv[])
 {
 	return 1;
 }
diff --git a/commands/flash.c b/commands/flash.c
index ec793c5..f92b604 100644
--- a/commands/flash.c
+++ b/commands/flash.c
@@ -37,7 +37,7 @@
 #include <fcntl.h>
 #include <linux/stat.h>
 
-static int do_flerase (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_flerase(struct command *cmdtp, int argc, char *argv[])
 {
 	int fd;
 	char *filename = NULL;
@@ -107,7 +107,7 @@ BAREBOX_CMD_END
  * Refer \b addpart, \b delpart and \b devinfo for partition handling.
  */
 
-static int do_protect (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_protect(struct command *cmdtp, int argc, char *argv[])
 {
 	int fd;
 	char *filename = NULL;
diff --git a/commands/go.c b/commands/go.c
index e720e32..588d6fc 100644
--- a/commands/go.c
+++ b/commands/go.c
@@ -30,7 +30,7 @@
 #include <linux/ctype.h>
 #include <errno.h>
 
-static int do_go (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_go(struct command *cmdtp, int argc, char *argv[])
 {
 	void	*addr;
 	int     rcode = 1;
diff --git a/commands/gpio.c b/commands/gpio.c
index 58bf8b6..2575c1e 100644
--- a/commands/gpio.c
+++ b/commands/gpio.c
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <gpio.h>
 
-static int do_gpio_get_value(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_gpio_get_value(struct command *cmdtp, int argc, char *argv[])
 {
 	int gpio, value;
 
@@ -45,7 +45,7 @@ BAREBOX_CMD_START(gpio_get_value)
 	BAREBOX_CMD_HELP(cmd_gpio_get_value_help)
 BAREBOX_CMD_END
 
-static int do_gpio_set_value(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_gpio_set_value(struct command *cmdtp, int argc, char *argv[])
 {
 	int gpio, value;
 
@@ -69,7 +69,7 @@ BAREBOX_CMD_START(gpio_set_value)
 	BAREBOX_CMD_HELP(cmd_gpio_set_value_help)
 BAREBOX_CMD_END
 
-static int do_gpio_direction_input(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_gpio_direction_input(struct command *cmdtp, int argc, char *argv[])
 {
 	int gpio, ret;
 
@@ -94,7 +94,7 @@ BAREBOX_CMD_START(gpio_direction_input)
 	BAREBOX_CMD_HELP(cmd_do_gpio_direction_input_help)
 BAREBOX_CMD_END
 
-static int do_gpio_direction_output(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_gpio_direction_output(struct command *cmdtp, int argc, char *argv[])
 {
 	int gpio, value, ret;
 
diff --git a/commands/help.c b/commands/help.c
index d8c67cd..f8387bd 100644
--- a/commands/help.c
+++ b/commands/help.c
@@ -28,7 +28,7 @@
  * Use puts() instead of printf() to avoid printf buffer overflow
  * for long help messages
  */
-static int do_help (cmd_tbl_t * cmdtp, int argc, char *argv[])
+static int do_help(struct command * cmdtp, int argc, char *argv[])
 {
 	if (argc == 1) {	/* show list of commands */
 		for_each_command(cmdtp) {
diff --git a/commands/insmod.c b/commands/insmod.c
index e14af49..d3b4d1a 100644
--- a/commands/insmod.c
+++ b/commands/insmod.c
@@ -5,7 +5,7 @@
 #include <fs.h>
 #include <malloc.h>
 
-static int do_insmod (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_insmod(struct command *cmdtp, int argc, char *argv[])
 {
 	struct module *module;
 	void *buf;
diff --git a/commands/loadb.c b/commands/loadb.c
index efb1a3c..6740ef4 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -688,7 +688,7 @@ static struct console_device *get_current_console(void)
  *
  * @return success or failure
  */
-static int do_load_serial_bin(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_load_serial_bin(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong offset = 0;
 	ulong addr;
diff --git a/commands/loadenv.c b/commands/loadenv.c
index 8b885ab..14fbf1e 100644
--- a/commands/loadenv.c
+++ b/commands/loadenv.c
@@ -27,7 +27,7 @@
 #include <command.h>
 #include <environment.h>
 
-static int do_loadenv(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_loadenv(struct command *cmdtp, int argc, char *argv[])
 {
 	char *filename, *dirname;
 
diff --git a/commands/loads.c b/commands/loads.c
index 2578c15..8269af1 100644
--- a/commands/loads.c
+++ b/commands/loads.c
@@ -42,7 +42,7 @@ static int save_serial (ulong offset, ulong size);
 static int write_record (char *buf);
 # endif /* CFG_CMD_SAVES */
 
-int do_load_serial (cmd_tbl_t *cmdtp, int argc, char *argv[])
+int do_load_serial(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong offset = 0;
 	ulong addr;
@@ -233,7 +233,7 @@ read_record (char *buf, ulong len)
 
 #if (CONFIG_COMMANDS & CFG_CMD_SAVES)
 
-int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_save_serial(struct command *cmdtp, int flag, int argc, char *argv[])
 {
 	ulong offset = 0;
 	ulong size   = 0;
diff --git a/commands/ls.c b/commands/ls.c
index 4d880e5..a02ccfe 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -111,7 +111,7 @@ out:
 	return 0;
 }
 
-static int do_ls (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_ls(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret, opt, o;
 	struct stat s;
diff --git a/commands/lsmod.c b/commands/lsmod.c
index 696304d..26d2fe4 100644
--- a/commands/lsmod.c
+++ b/commands/lsmod.c
@@ -2,7 +2,7 @@
 #include <command.h>
 #include <module.h>
 
-static int do_lsmod (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_lsmod(struct command *cmdtp, int argc, char *argv[])
 {
 	struct module *mod;
 
diff --git a/commands/mem.c b/commands/mem.c
index f06bc64..6192466 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -163,7 +163,7 @@ static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode,
 	return 0;
 }
 
-static int do_mem_md(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mem_md(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong	start = 0, size = 0x100;
 	int	r, now;
@@ -238,7 +238,7 @@ BAREBOX_CMD_START(md)
 	BAREBOX_CMD_HELP(cmd_md_help)
 BAREBOX_CMD_END
 
-static int do_mem_mw ( cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mem_mw(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret = 0;
 	int fd;
@@ -301,7 +301,7 @@ BAREBOX_CMD_START(mw)
 	BAREBOX_CMD_HELP(cmd_mw_help)
 BAREBOX_CMD_END
 
-static int do_mem_cmp(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mem_cmp(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong	addr1, addr2, count = ~0;
 	int	mode  = O_RWSIZE_1;
@@ -410,7 +410,7 @@ BAREBOX_CMD_START(memcmp)
 	BAREBOX_CMD_HELP(cmd_memcmp_help)
 BAREBOX_CMD_END
 
-static int do_mem_cp(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mem_cp(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong count;
 	ulong	dest, src;
@@ -506,7 +506,7 @@ BAREBOX_CMD_START(memcpy)
 	BAREBOX_CMD_HELP(cmd_memcpy_help)
 BAREBOX_CMD_END
 
-static int do_memset(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_memset(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong	s, c, n;
 	int     fd;
diff --git a/commands/meminfo.c b/commands/meminfo.c
index 76caf0a..abbaf9c 100644
--- a/commands/meminfo.c
+++ b/commands/meminfo.c
@@ -23,7 +23,7 @@
 #include <command.h>
 #include <malloc.h>
 
-static int do_meminfo (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_meminfo(struct command *cmdtp, int argc, char *argv[])
 {
 	malloc_stats();
 
diff --git a/commands/memtest.c b/commands/memtest.c
index 4038ace..d9c8b3d 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -322,7 +322,7 @@ static int mem_test(ulong _start, ulong _end, ulong pattern)
 }
 #endif
 
-static int do_mem_mtest (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mem_mtest(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong start, end, pattern = 0;
 
diff --git a/commands/mkdir.c b/commands/mkdir.c
index d5f58f0..b66795b 100644
--- a/commands/mkdir.c
+++ b/commands/mkdir.c
@@ -26,7 +26,7 @@
 #include <errno.h>
 #include <getopt.h>
 
-static int do_mkdir (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mkdir(struct command *cmdtp, int argc, char *argv[])
 {
 	int opt, parent = 0, ret;
 
diff --git a/commands/mount.c b/commands/mount.c
index 41735c8..8e4388e 100644
--- a/commands/mount.c
+++ b/commands/mount.c
@@ -30,7 +30,7 @@
 #include <fs.h>
 #include <errno.h>
 
-static int do_mount (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mount(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret = 0;
 	struct mtab_entry *entry = NULL;
diff --git a/commands/nand.c b/commands/nand.c
index 55b89af..7a4e995 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -279,7 +279,7 @@ out1:
 #define NAND_DEL (1 << 1)
 #define NAND_MARKBAD (1 << 2)
 
-static int do_nand(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_nand(struct command *cmdtp, int argc, char *argv[])
 {
 	int opt;
 	struct nand_bb *bb;
diff --git a/commands/net.c b/commands/net.c
index 5fa49cf..815a566 100644
--- a/commands/net.c
+++ b/commands/net.c
@@ -76,7 +76,7 @@ void netboot_update_env(void)
 #ifdef CONFIG_NET_RARP
 extern void RarpRequest(void);
 
-static int do_rarpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_rarpb(struct command *cmdtp, int argc, char *argv[])
 {
 	int size;
 
@@ -102,7 +102,7 @@ BAREBOX_CMD_START(rarpboot)
 BAREBOX_CMD_END
 #endif /* CONFIG_NET_RARP */
 
-static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_ethact(struct command *cmdtp, int argc, char *argv[])
 {
 	struct eth_device *edev;
 
diff --git a/commands/partition.c b/commands/partition.c
index 3cb7b61..e4645e8 100755
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -99,7 +99,7 @@ static int mtd_part_do_parse_one(char *devname, const char *partstr,
 	return ret;
 }
 
-static int do_addpart(cmd_tbl_t * cmdtp, int argc, char *argv[])
+static int do_addpart(struct command * cmdtp, int argc, char *argv[])
 {
 	char *devname;
 	char *endp;
@@ -180,7 +180,7 @@ BAREBOX_CMD_END
  * @note This command has to be reworked and will probably change it's API.
  */
 
-static int do_delpart(cmd_tbl_t * cmdtp, int argc, char *argv[])
+static int do_delpart(struct command * cmdtp, int argc, char *argv[])
 {
 	int i, err;
 
diff --git a/commands/printenv.c b/commands/printenv.c
index 5490980..e6fc0e4 100644
--- a/commands/printenv.c
+++ b/commands/printenv.c
@@ -28,7 +28,7 @@
 #include <errno.h>
 #include <environment.h>
 
-static int do_printenv (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_printenv(struct command *cmdtp, int argc, char *argv[])
 {
 	struct variable_d *var;
 	struct env_context *c, *current_c;
diff --git a/commands/pwd.c b/commands/pwd.c
index 6c3cbb9..d51fa1a 100644
--- a/commands/pwd.c
+++ b/commands/pwd.c
@@ -23,7 +23,7 @@
 #include <command.h>
 #include <fs.h>
 
-static int do_pwd (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_pwd(struct command *cmdtp, int argc, char *argv[])
 {
 	printf("%s\n", getcwd());
 	return 0;
diff --git a/commands/readline.c b/commands/readline.c
index 55c288c..cf2625f 100644
--- a/commands/readline.c
+++ b/commands/readline.c
@@ -27,7 +27,7 @@
 #include <xfuncs.h>
 #include <environment.h>
 
-static int do_readline (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_readline(struct command *cmdtp, int argc, char *argv[])
 {
 	char *buf = xzalloc(CONFIG_CBSIZE);
 
diff --git a/commands/reginfo.c b/commands/reginfo.c
index f11a73c..90651d5 100644
--- a/commands/reginfo.c
+++ b/commands/reginfo.c
@@ -23,7 +23,7 @@
 #include <common.h>
 #include <command.h>
 
-static int do_reginfo (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_reginfo(struct command *cmdtp, int argc, char *argv[])
 {
 	reginfo();
 	return 0;
diff --git a/commands/reset.c b/commands/reset.c
index f148623..46ab901 100644
--- a/commands/reset.c
+++ b/commands/reset.c
@@ -23,7 +23,7 @@
 #include <common.h>
 #include <command.h>
 
-static int cmd_reset (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int cmd_reset(struct command *cmdtp, int argc, char *argv[])
 {
 	reset_cpu(0);
 
diff --git a/commands/rm.c b/commands/rm.c
index 8694606..3437ae5 100644
--- a/commands/rm.c
+++ b/commands/rm.c
@@ -24,7 +24,7 @@
 #include <fs.h>
 #include <errno.h>
 
-static int do_rm (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_rm(struct command *cmdtp, int argc, char *argv[])
 {
 	int i = 1;
 
diff --git a/commands/rmdir.c b/commands/rmdir.c
index 3531f32..83a0b02 100644
--- a/commands/rmdir.c
+++ b/commands/rmdir.c
@@ -3,7 +3,7 @@
 #include <fs.h>
 #include <errno.h>
 
-static int do_rmdir (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_rmdir(struct command *cmdtp, int argc, char *argv[])
 {
 	int i = 1;
 
diff --git a/commands/saveenv.c b/commands/saveenv.c
index 6a9da5c..42ea58f 100644
--- a/commands/saveenv.c
+++ b/commands/saveenv.c
@@ -30,7 +30,7 @@
 #include <fcntl.h>
 #include <environment.h>
 
-static int do_saveenv(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_saveenv(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret, fd;
 	char *filename, *dirname;
diff --git a/commands/setenv.c b/commands/setenv.c
index 16b8177..257348f 100644
--- a/commands/setenv.c
+++ b/commands/setenv.c
@@ -28,7 +28,7 @@
 #include <errno.h>
 #include <environment.h>
 
-static int do_setenv ( cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_setenv(struct command *cmdtp, int argc, char *argv[])
 {
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
diff --git a/commands/sleep.c b/commands/sleep.c
index d88f39e..40a3a47 100644
--- a/commands/sleep.c
+++ b/commands/sleep.c
@@ -24,7 +24,7 @@
 #include <command.h>
 #include <clock.h>
 
-static int do_sleep (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_sleep(struct command *cmdtp, int argc, char *argv[])
 {
 	uint64_t start;
 	ulong delay;
diff --git a/commands/test.c b/commands/test.c
index afabe12..4af3515 100644
--- a/commands/test.c
+++ b/commands/test.c
@@ -76,7 +76,7 @@ static int parse_opt(const char *opt)
 	return -1;
 }
 
-static int do_test (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_test(struct command *cmdtp, int argc, char *argv[])
 {
 	char **ap;
 	int left, adv, expr, last_expr, neg, last_cmp, opt, zero;
diff --git a/commands/timeout.c b/commands/timeout.c
index dfbefc9..5f2ab9a 100644
--- a/commands/timeout.c
+++ b/commands/timeout.c
@@ -31,7 +31,7 @@
 #define TIMEOUT_ANYKEY	(1 << 2)
 #define TIMEOUT_SILENT	(1 << 3)
 
-static int do_timeout(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_timeout(struct command *cmdtp, int argc, char *argv[])
 {
 	int timeout = 3, ret = 1;
 	int flags = 0, opt, countdown;
diff --git a/commands/true.c b/commands/true.c
index 4697a81..8c77dec 100644
--- a/commands/true.c
+++ b/commands/true.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-static int do_true (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_true(struct command *cmdtp, int argc, char *argv[])
 {
 	return 0;
 }
diff --git a/commands/umount.c b/commands/umount.c
index 0dc517a..6ae5844 100644
--- a/commands/umount.c
+++ b/commands/umount.c
@@ -24,7 +24,7 @@
 #include <fs.h>
 #include <errno.h>
 
-static int do_umount (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_umount(struct command *cmdtp, int argc, char *argv[])
 {
 	int ret = 0;
 
diff --git a/commands/version.c b/commands/version.c
index 425f430..6c683d9 100644
--- a/commands/version.c
+++ b/commands/version.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 
-static int do_version (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_version(struct command *cmdtp, int argc, char *argv[])
 {
 	extern char version_string[];
 	printf ("\n%s\n", version_string);
diff --git a/common/command.c b/common/command.c
index e21e80d..8ed1072 100644
--- a/common/command.c
+++ b/common/command.c
@@ -44,7 +44,7 @@ EXPORT_SYMBOL(command_list);
 
 #ifdef CONFIG_SHELL_HUSH
 
-static int do_exit (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_exit(struct command *cmdtp, int argc, char *argv[])
 {
 	int r;
 
@@ -62,7 +62,7 @@ BAREBOX_CMD_END
 
 #endif
 
-void barebox_cmd_usage(cmd_tbl_t *cmdtp)
+void barebox_cmd_usage(struct command *cmdtp)
 {
 #ifdef	CONFIG_LONGHELP
 		/* found - print (long) help info */
@@ -85,15 +85,15 @@ EXPORT_SYMBOL(barebox_cmd_usage);
 
 static int compare(struct list_head *a, struct list_head *b)
 {
-	char *na = (char*)list_entry(a, cmd_tbl_t, list)->name;
-	char *nb = (char*)list_entry(b, cmd_tbl_t, list)->name;
+	char *na = (char*)list_entry(a, struct command, list)->name;
+	char *nb = (char*)list_entry(b, struct command, list)->name;
 
 	return strcmp(na, nb);
 }
 
 int execute_command(int argc, char **argv)
 {
-	cmd_tbl_t *cmdtp;
+	struct command *cmdtp;
 	int ret;
 
 	getopt_reset();
@@ -117,7 +117,7 @@ int execute_command(int argc, char **argv)
 	}
 }
 
-int register_command(cmd_tbl_t *cmd)
+int register_command(struct command *cmd)
 {
 	/*
 	 * We do not check if the command already exists.
@@ -133,9 +133,9 @@ int register_command(cmd_tbl_t *cmd)
 		char **aliases = (char**)cmd->aliases;
 		while(*aliases) {
 			char *usage = "alias for ";
-			cmd_tbl_t *c = xzalloc(sizeof(cmd_tbl_t));
+			struct command *c = xzalloc(sizeof(struct command));
 
-			memcpy(c, cmd, sizeof(cmd_tbl_t));
+			memcpy(c, cmd, sizeof(struct command));
 
 			c->name = *aliases;
 			c->usage = xmalloc(strlen(usage) + strlen(cmd->name) + 1);
@@ -156,15 +156,15 @@ EXPORT_SYMBOL(register_command);
 /*
  * find command table entry for a command
  */
-cmd_tbl_t *find_cmd (const char *cmd)
+struct command *find_cmd (const char *cmd)
 {
-	cmd_tbl_t *cmdtp;
-	cmd_tbl_t *cmdtp_temp = &__barebox_cmd_start;	/*Init value */
+	struct command *cmdtp;
+	struct command *cmdtp_temp = &__barebox_cmd_start;	/*Init value */
 	int len;
 	int n_found = 0;
 	len = strlen (cmd);
 
-	cmdtp = list_entry(&command_list, cmd_tbl_t, list);
+	cmdtp = list_entry(&command_list, struct command, list);
 
 	for_each_command(cmdtp) {
 		if (strncmp (cmd, cmdtp->name, len) == 0) {
@@ -191,7 +191,7 @@ cmd_tbl_t *find_cmd (const char *cmd)
  */
 static int init_command_list(void)
 {
-	cmd_tbl_t *cmdtp;
+	struct command *cmdtp;
 
 	for (cmdtp = &__barebox_cmd_start;
 			cmdtp != &__barebox_cmd_end;
diff --git a/common/complete.c b/common/complete.c
index 87435ee..46ba871 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -69,7 +69,7 @@ out:
 
 static int command_complete(struct string_list *sl, char *instr)
 {
-	cmd_tbl_t *cmdtp;
+	struct command *cmdtp;
 	char cmd[128];
 
 	for_each_command(cmdtp) {
diff --git a/common/hush.c b/common/hush.c
index e7a13c2..cf6704b 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -122,7 +122,7 @@
 #include <glob.h>
 
 /*cmd_boot.c*/
-extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);      /* do_bootd */
+extern int do_bootd(struct command *cmdtp, int flag, int argc, char *argv[]);      /* do_bootd */
 #define SPECIAL_VAR_SYMBOL 03
 
 
@@ -1583,7 +1583,7 @@ int run_shell(void)
 	return rcode;
 }
 
-static int do_sh(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_sh(struct command *cmdtp, int argc, char *argv[])
 {
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
@@ -1602,7 +1602,7 @@ BAREBOX_CMD_START(sh)
 	BAREBOX_CMD_HELP(cmd_sh_help)
 BAREBOX_CMD_END
 
-static int do_source(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_source(struct command *cmdtp, int argc, char *argv[])
 {
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
diff --git a/common/module.c b/common/module.c
index cedd702..29f3eb7 100644
--- a/common/module.c
+++ b/common/module.c
@@ -297,8 +297,8 @@ struct module * load_module(void *mod_image, unsigned long len)
 #ifdef CONFIG_COMMAND
 	cmdindex = find_sec(ehdr, sechdrs, secstrings, ".barebox_cmd");
 	if (cmdindex) {
-		cmd_tbl_t *cmd = (cmd_tbl_t *)sechdrs[cmdindex].sh_addr;
-		for (i = 0; i < sechdrs[cmdindex].sh_size / sizeof(cmd_tbl_t); i++) {
+		struct command *cmd =(struct command *)sechdrs[cmdindex].sh_addr;
+		for (i = 0; i < sechdrs[cmdindex].sh_size / sizeof(struct command); i++) {
 			register_command(cmd);
 			cmd++;
 		}
diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
index 5811e27..5b3b002 100644
--- a/drivers/nand/nand_imx.c
+++ b/drivers/nand/nand_imx.c
@@ -1129,7 +1129,7 @@ void __nand_boot_init imx_nand_load_image(void *dest, int size)
 #ifdef CONFIG_NAND_IMX_BOOT_DEBUG
 #include <command.h>
 
-static int do_nand_boot_test(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_nand_boot_test(struct command *cmdtp, int argc, char *argv[])
 {
 	void *dest;
 	int size;
diff --git a/drivers/nand/nand_s3c2410.c b/drivers/nand/nand_s3c2410.c
index 2f98c76..b989583 100644
--- a/drivers/nand/nand_s3c2410.c
+++ b/drivers/nand/nand_s3c2410.c
@@ -484,7 +484,7 @@ void __nand_boot_init s3c24x0_nand_load_image(void *dest, int size, int page, in
 #ifdef CONFIG_NAND_S3C24XX_BOOT_DEBUG
 #include <command.h>
 
-static int do_nand_boot_test(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_nand_boot_test(struct command *cmdtp, int argc, char *argv[])
 {
 	void *dest;
 	int size, pagesize;
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index d3b49ed..cb65b19 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -470,7 +470,7 @@ fail_out:
 }
 #include <command.h>
 
-static int do_mycdev (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_mycdev(struct command *cmdtp, int argc, char *argv[])
 {
 
 	int i,j;
diff --git a/drivers/usb/usb.c b/drivers/usb/usb.c
index decdbdd..1ad4bab 100644
--- a/drivers/usb/usb.c
+++ b/drivers/usb/usb.c
@@ -478,7 +478,7 @@ static int __usb_init(void)
 	return 0;
 }
 
-static int do_usb(cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_usb(struct command *cmdtp, int argc, char *argv[])
 {
 	__usb_init();
 
diff --git a/include/command.h b/include/command.h
index 393438d..a612d65 100644
--- a/include/command.h
+++ b/include/command.h
@@ -42,12 +42,11 @@ extern struct list_head command_list;
 /*
  * Monitor Command Table
  */
-
-struct cmd_tbl_s {
+struct command {
 	const char	*name;		/* Command Name			*/
 	const char	**aliases;
 					/* Implementation function	*/
-	int		(*cmd)(struct cmd_tbl_s *, int, char *[]);
+	int		(*cmd)(struct command *, int, char *[]);
 	const char	*usage;		/* Usage message	(short)	*/
 
 	struct list_head list;		/* List of commands		*/
@@ -61,17 +60,14 @@ __attribute__((aligned(64)))
 #endif
 ;
 
-
-typedef struct cmd_tbl_s	cmd_tbl_t;
-
-extern cmd_tbl_t  __barebox_cmd_start;
-extern cmd_tbl_t  __barebox_cmd_end;
+extern struct command __barebox_cmd_start;
+extern struct command __barebox_cmd_end;
 
 
 /* common/command.c */
-cmd_tbl_t *find_cmd(const char *cmd);
+struct command *find_cmd(const char *cmd);
 int execute_command(int argc, char **argv);
-void barebox_cmd_usage(cmd_tbl_t *cmdtp);
+void barebox_cmd_usage(struct command *cmdtp);
 
 #define COMMAND_SUCCESS		0
 #define COMMAND_ERROR		1
@@ -86,7 +82,7 @@ void barebox_cmd_usage(cmd_tbl_t *cmdtp);
 #define Struct_Section  __attribute__ ((unused,section (".barebox_cmd")))
 
 #define BAREBOX_CMD_START(_name)				\
-const cmd_tbl_t __barebox_cmd_##_name	\
+const struct command __barebox_cmd_##_name	\
 	__attribute__ ((unused,section (".barebox_cmd_" __stringify(_name)))) = {				\
 	.name		= #_name,
 
@@ -99,6 +95,6 @@ const cmd_tbl_t __barebox_cmd_##_name	\
 #define BAREBOX_CMD_HELP(text)
 #endif
 
-int register_command(cmd_tbl_t *);
+int register_command(struct command *);
 
 #endif	/* __COMMAND_H */
diff --git a/lib/driver.c b/lib/driver.c
index b3115de..f433c3e 100644
--- a/lib/driver.c
+++ b/lib/driver.c
@@ -280,7 +280,7 @@ void devices_shutdown(void)
 
 #ifdef CONFIG_CMD_DEVINFO
 
-static int do_devinfo ( cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_devinfo(struct command *cmdtp, int argc, char *argv[])
 {
 	struct device_d *dev;
 	struct driver_d *drv;
diff --git a/net/dhcp.c b/net/dhcp.c
index 1c479cf..f27a696 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -589,7 +589,7 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
 
 }
 
-static int do_dhcp (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_dhcp(struct command *cmdtp, int argc, char *argv[])
 {
 	int size;
 
diff --git a/net/nfs.c b/net/nfs.c
index f68741a..15f91ab 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -706,7 +706,7 @@ NfsStart (char *p)
 	NfsSend ();
 }
 
-static int do_nfs (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_nfs(struct command *cmdtp, int argc, char *argv[])
 {
 	int   rcode = 0;
 	char  *localfile;
diff --git a/net/ping.c b/net/ping.c
index 7a1fda2..8759fd7 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -81,7 +81,7 @@ PingHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
 	NetState = NETLOOP_SUCCESS;
 }
 
-int do_ping (cmd_tbl_t *cmdtp, int argc, char *argv[])
+int do_ping(struct command *cmdtp, int argc, char *argv[])
 {
 	if (argc < 2 || string_to_ip(argv[1], &NetPingIP))
 		return COMMAND_ERROR_USAGE;
diff --git a/net/tftp.c b/net/tftp.c
index b9c6fdd..897bc48 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -256,7 +256,7 @@ void TftpStart(char *filename)
 	TftpSend();
 }
 
-static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[])
+static int do_tftpb(struct command *cmdtp, int argc, char *argv[])
 {
 	int   rcode = 0;
 	char  *localfile;
-- 
1.6.6



From s.hauer at pengutronix.de  Mon Jan 25 02:37:34 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:37:34 +0100
Subject: [PATCH] Fix typo in board.dox
In-Reply-To: <20091231215521.GO5093@darwin>
References: <20091231215521.GO5093@darwin>
Message-ID: <20100125073734.GA10139@pengutronix.de>

Hi Matthias,

On Thu, Dec 31, 2009 at 10:55:21PM +0100, Matthias Kaehlcke wrote:
> Fix a typo in documentation file about adapting a new board which
> misnames the linker script template file
> 
> Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>

This one is already in master. Maybe I forgot to notice you that time.

Sascha

> 
> --
> 
> diff --git a/board/board.dox b/board/board.dox
> index 9c32682..76bff45 100644
> --- a/board/board.dox
> +++ b/board/board.dox
> @@ -58,7 +58,7 @@ at the right architecture.
>  
>  @note Consider to use an unique page lable.
>  
> - at subsection board_lscript board/\<boardname\>/barebox.ld.S
> + at subsection board_lscript board/\<boardname\>/barebox.lds.S
>  
>  If your board needs a special binary @a barebox layout, you can provide a local
>  board linker script file. This will replace the generic one provided by your
> 
> -- 
> Matthias Kaehlcke
> Embedded Linux Developer
> Barcelona
> 
>      Nationalism is an infantile disease. It is the measles of mankind
>                          (Albert Einstein)
>                                                                  .''`.
>     using free software / Debian GNU/Linux | http://debian.org  : :'  :
>                                                                 `. `'`
> gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Jan 25 02:39:13 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:39:13 +0100
Subject: Patches for -next
In-Reply-To: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <20100125073912.GB10139@pengutronix.de>

On Mon, Jan 25, 2010 at 08:32:18AM +0100, Sascha Hauer wrote:
> Hi all,
> 
> Here are some patches to review for -next
> 
> Sascha

And here's a changelog for these patches. Damn, it's too early for me :)

Sascha

The following changes since commit 0dde20da20411bf4dcd5593601d2f36e9ba04f66:
  Peter Korsgaard (1):
        documentation: It's U-Boot that doesn't have getopt, not Barebox

are available in the git repository at:

  git://git.pengutronix.de/git/barebox.git pu

Sascha Hauer (12):
      remove unused cdp code
      remove obsolete comment
      cache functions from kernel
      remove unused NETCONSOLE stuff
      remove unused file common/flash.c
      Move tftp/nfs specific code to net/*
      remove typedef cmd_tbl_t and replace it with struct command
      pcm043: initialize cpufreq to 532MHz
      replace ET_DEBUG with pr_debug
      put only once used function inline
      add armv6 support to the konfig system
      i.MX: select armv6 for i.MX31/35

 arch/arm/cpu/Kconfig               |    8 ++
 arch/arm/cpu/Makefile              |    6 +-
 arch/arm/cpu/cache-armv4.S         |  137 ++++++++++++++++++++++++++
 arch/arm/cpu/cache-armv6.S         |  131 +++++++++++++++++++++++++
 arch/arm/cpu/cache-armv7.S         |  185 ++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/cpu.c                 |    2 +-
 arch/arm/cpu/cpuinfo.c             |    2 +-
 arch/arm/cpu/mmu.c                 |   29 +-----
 arch/arm/lib/armlinux.c            |    4 +-
 arch/arm/mach-imx/Kconfig          |    2 +
 arch/arm/mach-imx/clko.c           |    2 +-
 arch/arm/mach-imx/speed.c          |    2 +-
 arch/arm/mach-netx/generic.c       |    2 +-
 arch/ppc/mach-mpc5xxx/interrupts.c |    2 +-
 board/ipe337/cmd_alternate.c       |    2 +-
 board/pcm043/lowlevel_init.S       |    2 +-
 board/pcm043/pcm043.c              |    2 +-
 commands/bmp.c                     |    2 +-
 commands/bootm.c                   |    6 +-
 commands/cat.c                     |    2 +-
 commands/cd.c                      |    2 +-
 commands/clear.c                   |    2 +-
 commands/cp.c                      |    2 +-
 commands/crc.c                     |    2 +-
 commands/dfu.c                     |    2 +-
 commands/echo.c                    |    2 +-
 commands/edit.c                    |    2 +-
 commands/exec.c                    |    2 +-
 commands/export.c                  |    2 +-
 commands/false.c                   |    2 +-
 commands/flash.c                   |    4 +-
 commands/go.c                      |    2 +-
 commands/gpio.c                    |    8 +-
 commands/help.c                    |    2 +-
 commands/insmod.c                  |    2 +-
 commands/loadb.c                   |    2 +-
 commands/loadenv.c                 |    2 +-
 commands/loads.c                   |    4 +-
 commands/ls.c                      |    2 +-
 commands/lsmod.c                   |    2 +-
 commands/mem.c                     |   10 +-
 commands/meminfo.c                 |    2 +-
 commands/memtest.c                 |    2 +-
 commands/mkdir.c                   |    2 +-
 commands/mount.c                   |    2 +-
 commands/nand.c                    |    2 +-
 commands/net.c                     |  160 +------------------------------
 commands/partition.c               |    4 +-
 commands/printenv.c                |    2 +-
 commands/pwd.c                     |    2 +-
 commands/readline.c                |    2 +-
 commands/reginfo.c                 |    2 +-
 commands/reset.c                   |    2 +-
 commands/rm.c                      |    2 +-
 commands/rmdir.c                   |    2 +-
 commands/saveenv.c                 |    2 +-
 commands/setenv.c                  |    2 +-
 commands/sleep.c                   |    2 +-
 commands/test.c                    |    2 +-
 commands/timeout.c                 |    2 +-
 commands/true.c                    |    2 +-
 commands/umount.c                  |    2 +-
 commands/version.c                 |    2 +-
 common/command.c                   |   26 +++---
 common/complete.c                  |    2 +-
 common/flash.c                     |   73 --------------
 common/hush.c                      |    6 +-
 common/module.c                    |    4 +-
 drivers/nand/nand_imx.c            |    2 +-
 drivers/nand/nand_s3c2410.c        |    2 +-
 drivers/usb/gadget/u_serial.c      |    2 +-
 drivers/usb/usb.c                  |    2 +-
 include/command.h                  |   25 ++----
 include/net.h                      |    8 --
 lib/driver.c                       |    2 +-
 net/dhcp.c                         |    2 +-
 net/net.c                          |   98 ++++++-------------
 net/nfs.c                          |   56 +++++++++++-
 net/ping.c                         |    6 +-
 net/tftp.c                         |   74 ++++++++++++++-
 80 files changed, 734 insertions(+), 450 deletions(-)
 create mode 100644 arch/arm/cpu/cache-armv4.S
 create mode 100644 arch/arm/cpu/cache-armv6.S
 create mode 100644 arch/arm/cpu/cache-armv7.S
 delete mode 100644 common/flash.c


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Jan 25 02:49:57 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 25 Jan 2010 08:49:57 +0100
Subject: [PATCH] Fix typo in board.dox
In-Reply-To: <20100125073734.GA10139@pengutronix.de>
References: <20091231215521.GO5093@darwin>
	<20100125073734.GA10139@pengutronix.de>
Message-ID: <20100125074957.GA19551@pengutronix.de>

On Mon, Jan 25, 2010 at 08:37:34AM +0100, Sascha Hauer wrote:
> Hi Matthias,
> 
> On Thu, Dec 31, 2009 at 10:55:21PM +0100, Matthias Kaehlcke wrote:
> > Fix a typo in documentation file about adapting a new board which
> > misnames the linker script template file
> > 
> > Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
> 
> This one is already in master. Maybe I forgot to notice you that time.

Forget this one, I accidently opened an last years mailbox

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From u.kleine-koenig at pengutronix.de  Mon Jan 25 03:57:00 2010
From: u.kleine-koenig at pengutronix.de (Uwe =?iso-8859-1?Q?Kleine-K=F6nig?=)
Date: Mon, 25 Jan 2010 09:57:00 +0100
Subject: [PATCH 03/12] cache functions from kernel
In-Reply-To: <1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
References: <1264404750-11596-1-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-2-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-3-git-send-email-s.hauer@pengutronix.de>
	<1264404750-11596-4-git-send-email-s.hauer@pengutronix.de>
Message-ID: <20100125085700.GB12480@pengutronix.de>

Hello Sascha,

On Mon, Jan 25, 2010 at 08:32:21AM +0100, Sascha Hauer wrote:
>  void mmu_enable(void)
>  {
>  	asm volatile (
> -		"mrc p15, 0, r1, c1, c0, 0;"
> -		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache */
> -		"mcr p15, 0, r1, c1, c0, 0"
> +		"bl __mmu_cache_on;"
>  		:
>  		:
> -		: "r1" /* Clobber list */
> +		: "r0", "r1", "r2", "r3", "r6", "r10", "r12"
You should add "cc" and "mem" to the list of clobbered registers.

>          );
>  }
>  
> @@ -67,28 +65,13 @@ void mmu_enable(void)
>   */
>  void mmu_disable(void)
>  {
> +
>  	asm volatile (
> -		"nop; "
> -		"nop; "
> -		"nop; "
> -		"nop; "
> -		"nop; "
> -		"nop; "
> -		/* test, clean and invalidate cache */
> -		"1:	mrc	p15, 0, r15, c7, c14, 3;" 
> -		"	bne	1b;"
> -		"	mov	pc, lr;"
> -		"	mov r0, #0x0;"
> -		"	mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer   */
> -		"	mcr p15, 0, r1, c7, c6, 0;"  /* clear data cache         */
> -		"	mrc p15, 0, r1, c1, c0, 0;"
> -		"	bic r1, r1, #0x0007;"        /* disable MMU + DCache     */
> -		"	mcr p15, 0, r1, c1, c0, 0;"
> -		"	mcr p15, 0, r0, c7, c6, 0;" /* flush d-cache             */
> -		"	mcr p15, 0, r0, c8, c7, 0;" /* flush i+d-TLBs            */
> +		"bl __mmu_cache_flush;"
> +		"bl __mmu_cache_off;"
>  		:
>  		:
> -		: "r0" /* Clobber list */
> +		: "r0", "r1", "r2", "r3", "r6", "r10", "r12"
ditto

Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-K?nig            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |


From s.hauer at pengutronix.de  Tue Jan 26 13:01:09 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 26 Jan 2010 19:01:09 +0100
Subject: [PATCH] mach-at91: reset_cpu: fix confusing reference to watchdog
In-Reply-To: <1263891265-15350-1-git-send-email-jacmet@sunsite.dk>
References: <1263891265-15350-1-git-send-email-jacmet@sunsite.dk>
Message-ID: <20100126180109.GF19551@pengutronix.de>

On Tue, Jan 19, 2010 at 09:54:25AM +0100, Peter Korsgaard wrote:
> On at91 we talk directly to the reset controller to reset the cpu,
> rather than use the watchdog, so update the comment to match.

Ok, applied.

Sascha

> 
> Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
> ---
>  arch/arm/mach-at91/clocksource.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/clocksource.c b/arch/arm/mach-at91/clocksource.c
> index b5886f9..564b560 100644
> --- a/arch/arm/mach-at91/clocksource.c
> +++ b/arch/arm/mach-at91/clocksource.c
> @@ -71,7 +71,7 @@ static int clocksource_init (void)
>  core_initcall(clocksource_init);
>  
>  /*
> - * Reset the cpu by setting up the watchdog timer and let it time out
> + * Reset the cpu through the reset controller
>   */
>  void reset_cpu (ulong ignored)
>  {
> -- 
> 1.6.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From ivo.clarysse at gmail.com  Thu Jan 28 06:21:18 2010
From: ivo.clarysse at gmail.com (Ivo Clarysse)
Date: Thu, 28 Jan 2010 12:21:18 +0100
Subject: [PATCH 1/1] Fix nand_imx for i.MX21
Message-ID: <ba216b431001280321i1e649402v7ca0dd9c2661a2f8@mail.gmail.com>

Recent changes to the nand_imx driver broke it for i.MX21 systems;
the i.MX21 NAND controller is more akin to the one in i.MX27/i.MX31,
than to the one in i.MX25/i.MX35.

Signed-off-by: Ivo Clarysse <ivo.clarysse at gmail.com>
---
diff --git a/arch/arm/mach-imx/include/mach/imx21-regs.h
b/arch/arm/mach-imx/include/mach/imx21-regs.h
index b8cb060..904177b 100644
--- a/arch/arm/mach-imx/include/mach/imx21-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx21-regs.h
@@ -107,6 +107,7 @@
 #define MPCTL1_BRMO		(1 << 6)
 #define MPCTL1_LF		(1 << 15)

+#define PCCR0_NFC_EN   (1 << 19)
 #define PCCR1_GPT1_EN	(1 << 25)

 #define CCSR_32K_SR		(1 << 15)
diff --git a/arch/arm/mach-imx/nand.c b/arch/arm/mach-imx/nand.c
index 7c57ec4..c228f96 100644
--- a/arch/arm/mach-imx/nand.c
+++ b/arch/arm/mach-imx/nand.c
@@ -59,7 +59,7 @@ void imx_nand_set_layout(int writesize, int datawidth)
 	writel(rcsr, IMX_CCM_BASE + CCM_RCSR);
 }

-#elif defined CONFIG_ARCH_IMX27
+#elif defined(CONFIG_ARCH_IMX21) || defined (CONFIG_ARCH_IMX27)

 #define FMCR_NF_FMS		(1 << 5)
 #define FMCR_NF_16BIT_SEL	(1 << 4)
diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
index 5811e27..70db8f9 100644
--- a/drivers/nand/nand_imx.c
+++ b/drivers/nand/nand_imx.c
@@ -32,8 +32,8 @@

 #define DVR_VER "2.0"

-#define nfc_is_v21()		(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx21())
-#define nfc_is_v1()		(cpu_is_mx31() || cpu_is_mx27())
+#define nfc_is_v21()		(cpu_is_mx25() || cpu_is_mx35())
+#define nfc_is_v1()		(cpu_is_mx31() || cpu_is_mx27() || cpu_is_mx21())

 /*
  * Addresses for NFC registers
@@ -249,6 +249,16 @@ static void __nand_boot_init send_cmd(struct
imx_nand_host *host, u16 cmd)
 	writew(cmd, host->regs + NFC_FLASH_CMD);
 	writew(NFC_CMD, host->regs + NFC_CONFIG2);

+	if (cpu_is_mx21() && (cmd == NAND_CMD_RESET)) {
+		/* Reset completion is indicated by NFC_CONFIG2 */
+		/* being set to 0 */
+		int i;
+		for (i = 0; i < 100000; i++) {
+			if (readw(host->regs + NFC_CONFIG2) == 0) {
+				break;
+			}
+		}
+	} else
 	/* Wait for operation to complete */
 	wait_op_done(host);
 }
@@ -826,9 +836,13 @@ static int __init imxnd_probe(struct device_d *dev)
 	struct nand_ecclayout *oob_smallpage, *oob_largepage;
 	u16 tmp;
 	int err = 0;
+
 #ifdef CONFIG_ARCH_IMX27
 	PCCR1 |= PCCR1_NFC_BAUDEN;
 #endif
+#ifdef CONFIG_ARCH_IMX21
+	PCCR0 |= PCCR0_NFC_EN;
+#endif
 	/* Allocate memory for MTD device structure and private data */
 	host = kzalloc(sizeof(struct imx_nand_host) + NAND_MAX_PAGESIZE +
 			NAND_MAX_OOBSIZE, GFP_KERNEL);
@@ -1015,7 +1029,13 @@ void __nand_boot_init imx_nand_load_image(void
*dest, int size)
 {
 	struct imx_nand_host host;
 	u32 tmp, page, block, blocksize, pagesize;
-
+#ifdef CONFIG_ARCH_IMX21
+	tmp = readl(IMX_SYSTEM_CTL_BASE + 0x14);
+	if (tmp & (1 << 5))
+		host.pagesize_2k = 1;
+	else
+		host.pagesize_2k = 0;
+#endif
 #ifdef CONFIG_ARCH_IMX27
 	tmp = readl(IMX_SYSTEM_CTL_BASE + 0x14);
 	if (tmp & (1 << 5))


From s.hauer at pengutronix.de  Fri Jan 29 03:33:48 2010
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 29 Jan 2010 09:33:48 +0100
Subject: [PATCH 1/1] Fix nand_imx for i.MX21
In-Reply-To: <ba216b431001280321i1e649402v7ca0dd9c2661a2f8@mail.gmail.com>
References: <ba216b431001280321i1e649402v7ca0dd9c2661a2f8@mail.gmail.com>
Message-ID: <20100129083348.GL19551@pengutronix.de>

On Thu, Jan 28, 2010 at 12:21:18PM +0100, Ivo Clarysse wrote:
> Recent changes to the nand_imx driver broke it for i.MX21 systems;
> the i.MX21 NAND controller is more akin to the one in i.MX27/i.MX31,
> than to the one in i.MX25/i.MX35.

Thanks. Applied.

Sascha

> 
> Signed-off-by: Ivo Clarysse <ivo.clarysse at gmail.com>
> ---
> diff --git a/arch/arm/mach-imx/include/mach/imx21-regs.h
> b/arch/arm/mach-imx/include/mach/imx21-regs.h
> index b8cb060..904177b 100644
> --- a/arch/arm/mach-imx/include/mach/imx21-regs.h
> +++ b/arch/arm/mach-imx/include/mach/imx21-regs.h
> @@ -107,6 +107,7 @@
>  #define MPCTL1_BRMO		(1 << 6)
>  #define MPCTL1_LF		(1 << 15)
> 
> +#define PCCR0_NFC_EN   (1 << 19)
>  #define PCCR1_GPT1_EN	(1 << 25)
> 
>  #define CCSR_32K_SR		(1 << 15)
> diff --git a/arch/arm/mach-imx/nand.c b/arch/arm/mach-imx/nand.c
> index 7c57ec4..c228f96 100644
> --- a/arch/arm/mach-imx/nand.c
> +++ b/arch/arm/mach-imx/nand.c
> @@ -59,7 +59,7 @@ void imx_nand_set_layout(int writesize, int datawidth)
>  	writel(rcsr, IMX_CCM_BASE + CCM_RCSR);
>  }
> 
> -#elif defined CONFIG_ARCH_IMX27
> +#elif defined(CONFIG_ARCH_IMX21) || defined (CONFIG_ARCH_IMX27)
> 
>  #define FMCR_NF_FMS		(1 << 5)
>  #define FMCR_NF_16BIT_SEL	(1 << 4)
> diff --git a/drivers/nand/nand_imx.c b/drivers/nand/nand_imx.c
> index 5811e27..70db8f9 100644
> --- a/drivers/nand/nand_imx.c
> +++ b/drivers/nand/nand_imx.c
> @@ -32,8 +32,8 @@
> 
>  #define DVR_VER "2.0"
> 
> -#define nfc_is_v21()		(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx21())
> -#define nfc_is_v1()		(cpu_is_mx31() || cpu_is_mx27())
> +#define nfc_is_v21()		(cpu_is_mx25() || cpu_is_mx35())
> +#define nfc_is_v1()		(cpu_is_mx31() || cpu_is_mx27() || cpu_is_mx21())
> 
>  /*
>   * Addresses for NFC registers
> @@ -249,6 +249,16 @@ static void __nand_boot_init send_cmd(struct
> imx_nand_host *host, u16 cmd)
>  	writew(cmd, host->regs + NFC_FLASH_CMD);
>  	writew(NFC_CMD, host->regs + NFC_CONFIG2);
> 
> +	if (cpu_is_mx21() && (cmd == NAND_CMD_RESET)) {
> +		/* Reset completion is indicated by NFC_CONFIG2 */
> +		/* being set to 0 */
> +		int i;
> +		for (i = 0; i < 100000; i++) {
> +			if (readw(host->regs + NFC_CONFIG2) == 0) {
> +				break;
> +			}
> +		}
> +	} else
>  	/* Wait for operation to complete */
>  	wait_op_done(host);
>  }
> @@ -826,9 +836,13 @@ static int __init imxnd_probe(struct device_d *dev)
>  	struct nand_ecclayout *oob_smallpage, *oob_largepage;
>  	u16 tmp;
>  	int err = 0;
> +
>  #ifdef CONFIG_ARCH_IMX27
>  	PCCR1 |= PCCR1_NFC_BAUDEN;
>  #endif
> +#ifdef CONFIG_ARCH_IMX21
> +	PCCR0 |= PCCR0_NFC_EN;
> +#endif
>  	/* Allocate memory for MTD device structure and private data */
>  	host = kzalloc(sizeof(struct imx_nand_host) + NAND_MAX_PAGESIZE +
>  			NAND_MAX_OOBSIZE, GFP_KERNEL);
> @@ -1015,7 +1029,13 @@ void __nand_boot_init imx_nand_load_image(void
> *dest, int size)
>  {
>  	struct imx_nand_host host;
>  	u32 tmp, page, block, blocksize, pagesize;
> -
> +#ifdef CONFIG_ARCH_IMX21
> +	tmp = readl(IMX_SYSTEM_CTL_BASE + 0x14);
> +	if (tmp & (1 << 5))
> +		host.pagesize_2k = 1;
> +	else
> +		host.pagesize_2k = 0;
> +#endif
>  #ifdef CONFIG_ARCH_IMX27
>  	tmp = readl(IMX_SYSTEM_CTL_BASE + 0x14);
>  	if (tmp & (1 << 5))
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From jbe at pengutronix.de  Fri Jan 29 06:51:16 2010
From: jbe at pengutronix.de (Juergen Beisert)
Date: Fri, 29 Jan 2010 12:51:16 +0100
Subject: [PATCH] i.MX35: Fix pad control bit positions
Message-ID: <201001291251.16655.jbe@pengutronix.de>

Using these macros simplify the configuration for special GPIO usage. But they
should use correct bit positions for usage in the IOMUX_PAD() macro.

Note: These are the bit positions of the i.MX35 CPU. Not checked for the other
i.MX3x CPUs.

Signed-off-by: Juergen Beisert <jbe at pengutronix.de>

---
 arch/arm/mach-imx/include/mach/iomux-v3.h |   34 +++++++++++++++---------------
 1 file changed, 17 insertions(+), 17 deletions(-)

Index: u-boot-v2/arch/arm/mach-imx/include/mach/iomux-v3.h
===================================================================
--- u-boot-v2.orig/arch/arm/mach-imx/include/mach/iomux-v3.h
+++ u-boot-v2/arch/arm/mach-imx/include/mach/iomux-v3.h
@@ -68,25 +68,25 @@ struct pad_desc {
 /*
  * Use to set PAD control
  */
-#define PAD_CTL_DRIVE_VOLTAGE_3_3_V	0
-#define PAD_CTL_DRIVE_VOLTAGE_1_8_V	1
+#define PAD_CTL_DRIVE_VOLTAGE_3_3_V	(0)
+#define PAD_CTL_DRIVE_VOLTAGE_1_8_V	(1 << 13)
 
-#define PAD_CTL_NO_HYSTERESIS		0
-#define PAD_CTL_HYSTERESIS		1
+#define PAD_CTL_NO_HYSTERESIS		(0)
+#define PAD_CTL_HYSTERESIS		(1 << 8)
 
-#define PAD_CTL_PULL_DISABLED		0x0
-#define PAD_CTL_PULL_KEEPER		0xa
-#define PAD_CTL_PULL_DOWN_100K		0xc
-#define PAD_CTL_PULL_UP_47K		0xd
-#define PAD_CTL_PULL_UP_100K		0xe
-#define PAD_CTL_PULL_UP_22K		0xf
-
-#define PAD_CTL_OUTPUT_CMOS		0
-#define PAD_CTL_OUTPUT_OPEN_DRAIN	1
-
-#define PAD_CTL_DRIVE_STRENGTH_NORM	0
-#define PAD_CTL_DRIVE_STRENGTH_HIGH	1
-#define PAD_CTL_DRIVE_STRENGTH_MAX	2
+#define PAD_CTL_PULL_DISABLED		(0)
+#define PAD_CTL_PULL_KEEPER		(0xa << 4)
+#define PAD_CTL_PULL_DOWN_100K		(0xc << 4)
+#define PAD_CTL_PULL_UP_47K		(0xd << 4)
+#define PAD_CTL_PULL_UP_100K		(0xe << 4)
+#define PAD_CTL_PULL_UP_22K		(0xf << 4)
+
+#define PAD_CTL_OUTPUT_CMOS		(0)
+#define PAD_CTL_OUTPUT_OPEN_DRAIN	(1 << 3)
+
+#define PAD_CTL_DRIVE_STRENGTH_NORM	(0)
+#define PAD_CTL_DRIVE_STRENGTH_HIGH	(1 << 1)
+#define PAD_CTL_DRIVE_STRENGTH_MAX	(2 << 1)
 
 #define PAD_CTL_SLEW_RATE_SLOW		0
 #define PAD_CTL_SLEW_RATE_FAST		1

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |


