[U-Boot] [PATCH] MAINTAINERS: Transfer openrd_base maintainership to Prafulla Wadaskar

2010-11-30 Thread Simon Kagstrom
Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
I no longer work on OpenRD base, so transfer the maintainership to
Prafulla at Marvell.

 MAINTAINERS |5 +
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f47fca5..ed07052 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -663,10 +663,6 @@ Matthias Kaehlcke matth...@kaehlcke.net
 Konstantin Kletschke kletsc...@synertronixx.de
scb9328 ARM920T
 
-Simon Kagstrom simon.kagst...@netinsight.net
-
-   openrd_base ARM926EJS (Kirkwood SoC)
-
 Nishant Kamat nska...@ti.com
 
omap1610h2  ARM926EJS
@@ -837,6 +833,7 @@ Matt Waddel matt.wad...@linaro.org
 Prafulla Wadaskar prafu...@marvell.com
 
mv88f6281gtw_ge ARM926EJS (Kirkwood SoC)
+   openrd_base ARM926EJS (Kirkwood SoC)
rd6281a ARM926EJS (Kirkwood SoC)
sheevaplug  ARM926EJS (Kirkwood SoC)
 
-- 
1.7.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: Kirkwood: Add support for OpenRD-Client OpenRD-Ultimate

2010-06-10 Thread Simon Kagstrom
On Thu, 10 Jun 2010 14:42:24 +0530
Tanmay Upadhyay tanmay.upadh...@einfochips.com wrote:

 This patch modifies existing OpenRD-Base support to deal with all
 the three OpenRD boards (OpenRD-Base, OpenRD-Client  OpenRD-Ultimate).

Yes, that's a good change!

 diff --git a/arch/arm/include/asm/mach-types.h 
 b/arch/arm/include/asm/mach-types.h
 index 940d814..19114b0 100644
 --- a/arch/arm/include/asm/mach-types.h
 +++ b/arch/arm/include/asm/mach-types.h
 @@ -2862,6 +2862,7 @@ extern unsigned int __machine_arch_type;
  #define MACH_TYPE_MATRIX5182879
  #define MACH_TYPE_TINY_GURNARD 2880
  #define MACH_TYPE_SPEAR13102881
 +#define MACH_TYPE_OPENRD_ULTIMATE  2884

I don't think this file is supposed to be edited in patches, but rather
synched from arm-linux by Wolfgang from time to time.

 diff --git a/include/configs/openrd_client.h b/include/configs/openrd_client.h
 new file mode 100644
 index 000..d936ffa

Perhaps common parts of this...

 diff --git a/include/configs/openrd_ultimate.h 
 b/include/configs/openrd_ultimate.h
 new file mode 100644
 index 000..a0e0417

and this and openrd_base.h can be merged into a common file. Most stuff
should be identical, right?

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: Kirkwood: Add support for OpenRD-Client OpenRD-Ultimate

2010-06-10 Thread Simon Kagstrom
On Thu, 10 Jun 2010 15:08:00 +0530
Tanmay Upadhyay tanmay.upadh...@einfochips.com wrote:

  +#define MACH_TYPE_OPENRD_ULTIMATE  2884
   
  I don't think this file is supposed to be edited in patches, but rather
  synched from arm-linux by Wolfgang from time to time.

 Sorry, I didn't know about that. However, as the number is already 
 registered, is that ok to have it here?

Probably Wolfgang or Tom Rix (the ARM maintainer) can synch it if you
ask them to.

 I agree with you. But auto-generated 'config.h' file includes 
 board_name.h. So there has to be one for each board. However, there 
 could be one 'openrd.h'  in the configs and three board specific files 
 include it. This will increase the number of files, but would decrease 
 LOC. What do you think?

Personally I'd prefer to keep the common parts in a common file, so I'd
vote for that solution.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] net, kirkwood_egiga: init mac address before using network commands

2010-03-30 Thread Simon Kagstrom
On Tue, 30 Mar 2010 07:38:39 +0200
Heiko Schocher h...@denx.de wrote:

 initialize mac address with the value from ethaddr, before
 doing some network commands. This is not in line with u-boot
 design principle not to initalize not used devices, and
 maybe should go away, if there is a solution for passing
 the mac address to arm linux kernels.

I also tried this change half a year ago, but it got NACK:ed. The
discussion is here if you are interested:

  http://www.mail-archive.com/u-boot@lists.denx.de/msg16994.html

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] net, kirkwood_egiga: init mac address before using network commands

2010-03-30 Thread Simon Kagstrom
On Tue, 30 Mar 2010 09:52:29 +0200
Detlev Zundel d...@denx.de wrote:

 I also actively request the U-Boot community to give feedback here -
 after all, this _is_ a community project and fixing real problems is one
 of the main tasks of a bootloader.

Personally, I'd prefer using Heikos approach until Arm Linux has moved
to device trees. I know it's a deviation from how it's supposed to
work, but it also solves a real problem without introducing kludges
elsewhere.

I think most people (myself included) would just solve the problem by
carrying a private patch to setup the MAC address in U-boot anyway.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] net, kirkwood_egiga: init mac address before using network commands

2010-03-30 Thread Simon Kagstrom
On Tue, 30 Mar 2010 10:26:59 +0200
Wolfgang Denk w...@denx.de wrote:

  Personally, I'd prefer using Heikos approach until Arm Linux has moved
  to device trees. I know it's a deviation from how it's supposed to
  work, but it also solves a real problem without introducing kludges
  elsewhere.
 
 If we do not even raise issues with the current Linux code with the
 Linux developers they will not even be aware that there are problems.
 In the end, things will never change.  

I believe they are aware of this especially since many developers work
on both projects anyway. If I remember the discussion on ARM device
trees a year ago or so correct, this was one of the issues brought up
in support of the device trees (or it should have, anyway).

  I think most people (myself included) would just solve the problem by
  carrying a private patch to setup the MAC address in U-boot anyway.
 
 Interesting.  Why would you do this?  Why would you not rather fix the
 Linux driver instead? [This is what I would do.]

Basically two reasons: First, it's a simpler fix in U-boot (a oneliner
for Kirkwood), and secondly because (as far as I understand, correct me
if I'm wrong), it lacks any well-defined protocol to transfer this
knowledge to the kernel driver.

I know mostly how it looks on the OpenRD board, where the MAC address
is stored in the U-boot environment. Easy to access in U-boot, but a
lot trickier from Linux. Sure, you could transfer it via a command-line
parameter or something, but personally I think this is uglier than
setting it up in U-boot anyway.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Killed Sheeva Plug

2010-03-26 Thread Simon Kagstrom
On Thu, 25 Mar 2010 20:57:10 +0100
Norbert Wegener n...@wegener-net.de wrote:

 While trying to learn about it, at the U-Boot prompt I issued a command
 I'd better not issued:
 nand erase
 It seems, U-Boot did what I asked to do...
 No U-Boot prompt any more and nothing else:-(

You can reflash it with OpenOCD, see

  http://www.plugcomputer.org/plugwiki/index.php/Setting_Up_OpenOCD_Under_Linux

I've only tested this on an OpenRD board, but the Sheevaplug should
work in the same way. Quite convenient.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] EABI 4.2

2010-03-17 Thread Simon Kagstrom
(Sorry if this has already been taken up, I've not been following the
discussion closely)

On Thu, 11 Mar 2010 11:11:09 +0100
Martin Krause martin.kra...@tqs.de wrote:

  Does this mean, my toolchain is broken? I use ELDK4.2 for ARM.
  
  I belive so, how many bytes is in dirent.namelen? alloca can not

 I compiled the original code with VLA with ELDK4.1 and there 
 everything works. And also the '__builtin_alloca' Version works
 with ELDK4.1.

I had a similar problem a few months ago, which turned out to be a
stack alignment issue:

  http://www.mail-archive.com/u-boot@lists.denx.de/msg23202.html

the behavior was pretty similar, with code built with some compilers
working (by chance) and some others breaking.

(The patch above is in U-boot since november something I think)

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] EABI 4.2

2010-03-17 Thread Simon Kagstrom
On Wed, 17 Mar 2010 09:53:36 -0500
Praveen G K praveen...@gmail.com wrote:

  I had a similar problem a few months ago, which turned out to be a
  stack alignment issue:
 
   http://www.mail-archive.com/u-boot@lists.denx.de/msg23202.html
 
  the behavior was pretty similar, with code built with some compilers
  working (by chance) and some others breaking.
 
 Great! This does work when added to cpu/arm1176/start.S
 Is there any specific reason why this was not added to the arm11 stream?

Well, none other than that I didn't realise it affected other platforms
as well. Looking at the tip, it seems like pretty much all ARM
platforms are susceptible to this issue. So a mass-fix would probably
be in place.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Does ubifs in u-boot is only for ppc

2009-11-11 Thread Simon Kagstrom
On Wed, 11 Nov 2009 18:21:25 +0800
Lv Terry-R65388 r65...@freescale.com wrote:

 I'm trying to build a u-boot image for our arm board with ubifs
 support.
 [...]
 fs/ubifs/libubifs.a(lpt.o):/home/r65388/uboot-v2009.08/uboot-imx/fs/ubif
 s/lpt.c:87: more undefined references to `fls' follow
  
 The function fls is defined in include/asm-ppc and there's no such
 functions in include/asm-arm.
  
 Is ubifs a common code or specified for ppc?

No, I submitted a few patches a few months ago to fix this for other
architectures (ARM in particular). If you update to current U-boot git
it should work.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2]: common: Add a watchdog CLI command

2009-11-06 Thread Simon Kagstrom
(Ping!)

On Thu, 29 Oct 2009 09:09:23 +0100
Simon Kagstrom simon.kagst...@netinsight.net wrote:

 A watchdog command to enable the watchdog with a timeout from the CLI
 can sometimes be useful. Add that. This also adds a common API for
 enabling watchdogs. The API is simple:
 
 int watchdog_enable(unsigned int timeout);
 
 the timeout range vary depending on hardware, and the driver should
 return a negative value if the call failed.

Wolfgang: Do you have any additional comments on this patch?

// Simon

 Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
 ---
 ChangeLog:
  v2:
 * Passing zero as timeout is invalid (Prafulla)
 * Add return value from watchdog_enable(), negative means failure 
 (Prafulla, Wolfgang)
 * Remove watchdog_disable() (Wolfgang)
 * Use weak default function for watchdog_enable() (Wolfgang)
 * Provide friendly and helpful printouts when invalid parameters are
   passed to the CLI command
 
  common/Makefile   |1 +
  common/cmd_watchdog.c |   62 
 +
  common/main.c |7 +
  include/watchdog.h|2 +
  4 files changed, 72 insertions(+), 0 deletions(-)
  create mode 100644 common/cmd_watchdog.c
 
 diff --git a/common/Makefile b/common/Makefile
 index 3781738..f14ba0e 100644
 --- a/common/Makefile
 +++ b/common/Makefile
 @@ -160,6 +160,7 @@ COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o
  COBJS-$(CONFIG_MODEM_SUPPORT) += modem.o
  COBJS-$(CONFIG_UPDATE_TFTP) += update.o
  COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 +COBJS-$(CONFIG_CMD_WATCHDOG) += cmd_watchdog.o
  
  
  COBJS:= $(sort $(COBJS-y))
 diff --git a/common/cmd_watchdog.c b/common/cmd_watchdog.c
 new file mode 100644
 index 000..ca1a8fd
 --- /dev/null
 +++ b/common/cmd_watchdog.c
 @@ -0,0 +1,62 @@
 +/*
 + * (C) Copyright 2009
 + * Net Insight www.netinsight.net
 + * Written-by: Simon Kagstrom simon.kagst...@netinsight.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., 51 Franklin Street, Fifth Floor, Boston,
 + * MA 02110-1301 USA
 + */
 +
 +#include common.h
 +#include watchdog.h
 +
 +static int do_watchdog(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 +{
 + const char *cmd;
 + char *endp;
 + unsigned long timeout;
 +
 + /* need one argument */
 + if (argc != 2)
 + goto usage;
 +
 + cmd = argv[1];
 + timeout = simple_strtoul(cmd, endp, 0);
 + if (endp == cmd) {
 + printf(Error: Could not convert `%s' to a number\n\n, cmd);
 + goto usage;
 + }
 + if (timeout  1) {
 + printf(Error: zero timeouts are invalid\n\n);
 + goto usage;
 + }
 +
 + /* Everything fine, enable the watchdog */
 + if (watchdog_enable(timeout)  0) {
 + printf(Error: Could not enable watchdog, check timeout 
 parameter\n\n);
 + goto usage;
 + }
 +
 + return 0;
 +usage:
 + cmd_usage(cmdtp);
 + return 1;
 +}
 +
 +U_BOOT_CMD(
 + watchdog, 2, 0, do_watchdog,
 + Watchdog commands,
 + timeout  - start the watchdog with `timeout' seconds timeout\n
 +);
 diff --git a/common/main.c b/common/main.c
 index 10d8904..47e867b 100644
 --- a/common/main.c
 +++ b/common/main.c
 @@ -1446,3 +1446,10 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, 
 char *argv[])
   return 0;
  }
  #endif
 +
 +
 +inline int __watchdog_enable(unsigned int timeout_secs)
 +{
 + return -1;
 +}
 +int watchdog_enable(unsigned int timeout_secs) __attribute__((weak, 
 alias(__watchdog_enable)));
 diff --git a/include/watchdog.h b/include/watchdog.h
 index 9265be9..74c2bda 100644
 --- a/include/watchdog.h
 +++ b/include/watchdog.h
 @@ -70,6 +70,8 @@
   #endif /* CONFIG_WATCHDOG  !__ASSEMBLY__ */
  #endif /* CONFIG_HW_WATCHDOG */
  
 +extern int watchdog_enable(unsigned int timeout_secs);
 +
  /*
   * Prototypes from $(CPU)/cpu.c.
   */

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/2]: Watchdog support from the command line

2009-10-29 Thread Simon Kagstrom
Hi!

These two patches add a generic watchdog CLI command and a driver for
the watchdog on Marvell Kirkwood that uses it.

The command usage is

  watchdog - Watchdog commands

  Usage:
  watchdog timeout- start the watchdog with `timeout' seconds timeout


ChangeLog:
  v2: Adapt according to comments from Prafulla and Wolfgang
* Passing zero as timeout is invalid (Prafulla)
* Add return value from watchdog_enable(), negative means failure 
(Prafulla, Wolfgang)
* Remove watchdog_disable() (Wolfgang)
* Use weak default function for watchdog_enable() (Wolfgang)
* Provide friendly and helpful printouts when invalid parameters are
  passed to the CLI command

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/2]: common: Add a watchdog CLI command

2009-10-29 Thread Simon Kagstrom
A watchdog command to enable the watchdog with a timeout from the CLI
can sometimes be useful. Add that. This also adds a common API for
enabling watchdogs. The API is simple:

int watchdog_enable(unsigned int timeout);

the timeout range vary depending on hardware, and the driver should
return a negative value if the call failed.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:
 v2:
* Passing zero as timeout is invalid (Prafulla)
* Add return value from watchdog_enable(), negative means failure 
(Prafulla, Wolfgang)
* Remove watchdog_disable() (Wolfgang)
* Use weak default function for watchdog_enable() (Wolfgang)
* Provide friendly and helpful printouts when invalid parameters are
  passed to the CLI command

 common/Makefile   |1 +
 common/cmd_watchdog.c |   62 +
 common/main.c |7 +
 include/watchdog.h|2 +
 4 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_watchdog.c

diff --git a/common/Makefile b/common/Makefile
index 3781738..f14ba0e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -160,6 +160,7 @@ COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o
 COBJS-$(CONFIG_MODEM_SUPPORT) += modem.o
 COBJS-$(CONFIG_UPDATE_TFTP) += update.o
 COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
+COBJS-$(CONFIG_CMD_WATCHDOG) += cmd_watchdog.o
 
 
 COBJS  := $(sort $(COBJS-y))
diff --git a/common/cmd_watchdog.c b/common/cmd_watchdog.c
new file mode 100644
index 000..ca1a8fd
--- /dev/null
+++ b/common/cmd_watchdog.c
@@ -0,0 +1,62 @@
+/*
+ * (C) Copyright 2009
+ * Net Insight www.netinsight.net
+ * Written-by: Simon Kagstrom simon.kagst...@netinsight.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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include common.h
+#include watchdog.h
+
+static int do_watchdog(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+   const char *cmd;
+   char *endp;
+   unsigned long timeout;
+
+   /* need one argument */
+   if (argc != 2)
+   goto usage;
+
+   cmd = argv[1];
+   timeout = simple_strtoul(cmd, endp, 0);
+   if (endp == cmd) {
+   printf(Error: Could not convert `%s' to a number\n\n, cmd);
+   goto usage;
+   }
+   if (timeout  1) {
+   printf(Error: zero timeouts are invalid\n\n);
+   goto usage;
+   }
+
+   /* Everything fine, enable the watchdog */
+   if (watchdog_enable(timeout)  0) {
+   printf(Error: Could not enable watchdog, check timeout 
parameter\n\n);
+   goto usage;
+   }
+
+   return 0;
+usage:
+   cmd_usage(cmdtp);
+   return 1;
+}
+
+U_BOOT_CMD(
+   watchdog, 2, 0, do_watchdog,
+   Watchdog commands,
+   timeout  - start the watchdog with `timeout' seconds timeout\n
+);
diff --git a/common/main.c b/common/main.c
index 10d8904..47e867b 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1446,3 +1446,10 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char 
*argv[])
return 0;
 }
 #endif
+
+
+inline int __watchdog_enable(unsigned int timeout_secs)
+{
+   return -1;
+}
+int watchdog_enable(unsigned int timeout_secs) __attribute__((weak, 
alias(__watchdog_enable)));
diff --git a/include/watchdog.h b/include/watchdog.h
index 9265be9..74c2bda 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -70,6 +70,8 @@
#endif /* CONFIG_WATCHDOG  !__ASSEMBLY__ */
 #endif /* CONFIG_HW_WATCHDOG */
 
+extern int watchdog_enable(unsigned int timeout_secs);
+
 /*
  * Prototypes from $(CPU)/cpu.c.
  */
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/2]: arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-10-29 Thread Simon Kagstrom
Initialize by calling the generic API watchdog_enable() with the number
of seconds for the watchdog to timeout. It's not possible to disable the
watchdog once it's on.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:
  v2:
 * Remove watchdog_disable()
 * Add check to see that the maximum timeout supported by the hardware
   is not exceeded

 cpu/arm926ejs/kirkwood/timer.c |   38 ++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/kirkwood/timer.c b/cpu/arm926ejs/kirkwood/timer.c
index 817ff42..69a5cb7 100644
--- a/cpu/arm926ejs/kirkwood/timer.c
+++ b/cpu/arm926ejs/kirkwood/timer.c
@@ -23,8 +23,10 @@
 
 #include common.h
 #include asm/arch/kirkwood.h
+#include watchdog.h
 
 #define UBOOT_CNTR 0   /* counter to use for uboot timer */
+#define WATCHDOG_TMR   2
 
 /* Timer reload and current value registers */
 struct kwtmr_val {
@@ -166,3 +168,39 @@ int timer_init(void)
 
return 0;
 }
+
+#if defined(CONFIG_HW_WATCHDOG)
+static unsigned long watchdog_timeout = 5;
+void hw_watchdog_reset(void)
+{
+   u32 time = CONFIG_SYS_TCLK * watchdog_timeout;
+
+   writel(time, CNTMR_VAL_REG(WATCHDOG_TMR));
+}
+
+#define MAX_TIMEOUT (0x / CONFIG_SYS_TCLK)
+int watchdog_enable(unsigned int timeout_secs)
+{
+   struct kwcpu_registers *cpureg =
+   (struct kwcpu_registers *)KW_CPU_REG_BASE;
+   u32 rstoutn_mask;
+   u32 cntmrctrl;
+
+   if (timeout_secs  MAX_TIMEOUT)
+   return -1;
+
+   watchdog_timeout = timeout_secs;
+   /* Enable CPU reset if watchdog expires */
+   rstoutn_mask = readl(cpureg-rstoutn_mask);
+   writel(rstoutn_mask |= 2, cpureg-rstoutn_mask);
+   hw_watchdog_reset();
+
+   /* Enable the watchdog */
+   cntmrctrl = readl(CNTMR_CTRL_REG);
+   cntmrctrl |= CTCR_ARM_TIMER_EN(WATCHDOG_TMR);
+   cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(WATCHDOG_TMR);
+   writel(cntmrctrl, CNTMR_CTRL_REG);
+
+   return 0;
+}
+#endif
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-10-28 Thread Simon Kagstrom
Hi again Prafulla and the list!

On Mon, 28 Sep 2009 09:06:26 +0200
Simon Kagstrom simon.kagst...@netinsight.net wrote:

 Initialize by calling kw_watchdog_init() with the number of seconds for
 the watchdog to timeout.
 
 Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net

Were there any particular problems with this patch that I should
rework? It's not enabled by default.

// Simon

 ---
  cpu/arm926ejs/kirkwood/timer.c  |   29 +
  include/asm-arm/arch-kirkwood/cpu.h |2 ++
  2 files changed, 31 insertions(+), 0 deletions(-)
 
 diff --git a/cpu/arm926ejs/kirkwood/timer.c b/cpu/arm926ejs/kirkwood/timer.c
 index 817ff42..f3397e7 100644
 --- a/cpu/arm926ejs/kirkwood/timer.c
 +++ b/cpu/arm926ejs/kirkwood/timer.c
 @@ -25,6 +25,7 @@
  #include asm/arch/kirkwood.h
  
  #define UBOOT_CNTR   0   /* counter to use for uboot timer */
 +#define WATCHDOG_CNTR2
  
  /* Timer reload and current value registers */
  struct kwtmr_val {
 @@ -166,3 +167,31 @@ int timer_init(void)
  
   return 0;
  }
 +
 +#if defined(CONFIG_HW_WATCHDOG)
 +static unsigned long watchdog_timeout = 5;
 +void hw_watchdog_reset(void)
 +{
 + unsigned long time = CONFIG_SYS_TCLK * watchdog_timeout;
 +
 + writel(time, CNTMR_VAL_REG(WATCHDOG_CNTR));
 +}
 +
 +void kw_watchdog_init(unsigned long timeout_secs)
 +{
 + struct kwcpu_registers *cpureg =
 + (struct kwcpu_registers *)KW_CPU_REG_BASE;
 + unsigned int cntmrctrl;
 +
 + watchdog_timeout = timeout_secs;
 + /* Enable CPU reset if watchdog expires */
 + cpureg-rstoutn_mask |= WATCHDOG_CNTR;
 + hw_watchdog_reset();
 +
 + /* Enable the watchdog */
 + cntmrctrl = readl(CNTMR_CTRL_REG);
 + cntmrctrl |= CTCR_ARM_TIMER_EN(WATCHDOG_CNTR);
 + cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(WATCHDOG_CNTR);
 + writel(cntmrctrl, CNTMR_CTRL_REG);
 +}
 +#endif
 diff --git a/include/asm-arm/arch-kirkwood/cpu.h 
 b/include/asm-arm/arch-kirkwood/cpu.h
 index b3022a3..df49c3f 100644
 --- a/include/asm-arm/arch-kirkwood/cpu.h
 +++ b/include/asm-arm/arch-kirkwood/cpu.h
 @@ -165,5 +165,7 @@ int kw_config_mpp(unsigned int mpp0_7, unsigned int 
 mpp8_15,
   unsigned int mpp32_39, unsigned int mpp40_47,
   unsigned int mpp48_55);
  unsigned int kw_winctrl_calcsize(unsigned int sizeval);
 +void kw_watchdog_init(unsigned long timeout_secs);
 +
  #endif /* __ASSEMBLY__ */
  #endif /* _KWCPU_H */

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-10-28 Thread Simon Kagstrom
Thanks for the comments!

On Wed, 28 Oct 2009 02:24:43 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:


#define UBOOT_CNTR   0   /* counter to use for uboot timer */
   +#define WATCHDOG_CNTR2
 
 BTW, this declaration will not be required if you see struct kwtmr_register 

Well, to me it makes the code more clear, so I'd prefer to keep it.


/* Timer reload and current value registers */
struct kwtmr_val {
   @@ -166,3 +167,31 @@ int timer_init(void)

 return 0;
}
   +
   +#if defined(CONFIG_HW_WATCHDOG)
   +static unsigned long watchdog_timeout = 5;
 
 Please get rid of this magic number, Pls provide some comments
 I think just u8 are sufficient here since the time is in seconds.
 I suggest variable name as wdt_tout to keep it small

I'll make it configurable through config.h, and a u8. However, I think
watchdog_timeout is a more descriptive name here.

   +
   + writel(time, CNTMR_VAL_REG(WATCHDOG_CNTR));
 
 Please check struct kwtmr_registers, wdt regs are named differently, pls use 
 them

I can do that, but CNTMR_VAL_REG is actually defined higher up in the
file as

   #define CNTMR_VAL_REG(tmrnum)kwtmr_regs-tmr[tmrnum].val

and used for the regular timer support. I'm not sure I like that, but
at least the file should be internally consistent.

   --- a/include/asm-arm/arch-kirkwood/cpu.h
   +++ b/include/asm-arm/arch-kirkwood/cpu.h
   @@ -165,5 +165,7 @@ int kw_config_mpp(unsigned int mpp0_7, 
  unsigned int mpp8_15,
 unsigned int mpp32_39, unsigned int mpp40_47,
 unsigned int mpp48_55);
unsigned int kw_winctrl_calcsize(unsigned int sizeval);
   +void kw_watchdog_init(unsigned long timeout_secs);
 
 Functions declared here are suppose to be in cpu.c
 Moreover I think we don't need this function at all,
 You can club kw_watchdog_init with hw_watchdog_reset so that at very first 
 WATCHDOG_RESET() function call,
 watchdog timer it will be initialized.

But then it's unconditionally turned on as soon as the first
WATCHDOG_RESET() is called, which might not be what you want.

In the long run, we should probably add command line support for
enabling the watchdog (some might want to do it just before starting
Linux for example).

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-10-28 Thread Simon Kagstrom
On Wed, 28 Oct 2009 04:34:10 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

 #define CNTMR_VAL_REG(tmrnum)
  kwtmr_regs-tmr[tmrnum].val
  
  and used for the regular timer support. I'm not sure I like that, but
  at least the file should be internally consistent.
 
 You can update the structure to use WDT timer in the same way as other timers,
 there is no sense putting additional names in structure.

But I'm not - the WDT timer is used in the same way as the other timer.
The only difference is the added WATCHDOG_TMR define which specifies
which Kirkwood timer to use as a watchdog.

  But then it's unconditionally turned on as soon as the first
  WATCHDOG_RESET() is called, which might not be what you want.
  
  In the long run, we should probably add command line support for
  enabling the watchdog (some might want to do it just before starting
  Linux for example).
 
 You can even call WATCHDOG_RESET() from wherever from your code to enable it

Sure, but WATCHDOG_RESET() will be called anyway (and probably before
my code), so it will be enabled anyhow in that case. My point is that
sometimes you don't want the watchdog to get started directly, hence
the function to enable it.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-10-28 Thread Simon Kagstrom
On Wed, 28 Oct 2009 05:57:34 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

  Sure, but WATCHDOG_RESET() will be called anyway (and probably before
  my code), so it will be enabled anyhow in that case. My point is that
  sometimes you don't want the watchdog to get started directly, hence
  the function to enable it.
 
 That is also valid point,
 This will be the generic need for all architectures.
 Lets introduce WATCHDOG_INIT() as new generic interface.

Yes, something like that. What I was thinking was a 

   void watchdog_enable(unsigned int timeout_secs);

   void watchdog_disable(void);

and a command-line interface to go with these. I'm cooking up a patch
with this.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/2]: Watchdog support from the command line

2009-10-28 Thread Simon Kagstrom
Hi!

These two patches add a generic watchdog CLI command and a driver for
the watchdog on Marvell Kirkwood that uses it.

The command usage is

  watchdog - Watchdog commands

  Usage:
  watchdog timeout- start the watchdog with `timeout' seconds timeout
  watchdog off  - stop the watchdog (can't be done on all boards)

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2]: common: Add a watchdog CLI command

2009-10-28 Thread Simon Kagstrom
A watchdog command to enable the watchdog with a timeout or disable it
can sometimes be useful. Add that. This also adds a common API for
enabling or disabling watchdogs. The API is simple:

void watchdog_enable(unsigned int timeout);
void watchdog_disable(void);

disabling the watchdog might or might not be possible depending on the
hardware, and the timeout range can also vary in the same way.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 common/Makefile   |1 +
 common/cmd_watchdog.c |   61 +
 include/watchdog.h|9 +++
 3 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_watchdog.c

diff --git a/common/Makefile b/common/Makefile
index 3781738..f14ba0e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -160,6 +160,7 @@ COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o
 COBJS-$(CONFIG_MODEM_SUPPORT) += modem.o
 COBJS-$(CONFIG_UPDATE_TFTP) += update.o
 COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
+COBJS-$(CONFIG_CMD_WATCHDOG) += cmd_watchdog.o
 
 
 COBJS  := $(sort $(COBJS-y))
diff --git a/common/cmd_watchdog.c b/common/cmd_watchdog.c
new file mode 100644
index 000..d26be4f
--- /dev/null
+++ b/common/cmd_watchdog.c
@@ -0,0 +1,61 @@
+/*
+ * (C) Copyright 2009
+ * Net Insight www.netinsight.net
+ * Written-by: Simon Kagstrom simon.kagst...@netinsight.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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include common.h
+#include watchdog.h
+
+static int do_watchdog(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+   const char *cmd;
+   char *endp;
+   int timeout;
+
+   /* need one argument */
+   if (argc != 2)
+   goto usage;
+
+   cmd = argv[1];
+
+   if (strcmp(cmd, off) == 0) {
+   watchdog_disable();
+   return 0;
+   }
+   timeout = simple_strtoul(cmd, endp, 0);
+   if (endp == cmd)
+   goto usage;
+   if (timeout  0)
+   goto usage;
+
+   /* Everything fine, enable the watchdog */
+   watchdog_enable(timeout);
+
+   return 0;
+usage:
+   cmd_usage(cmdtp);
+   return 1;
+}
+
+U_BOOT_CMD(
+   watchdog, 2, 0, do_watchdog,
+   Watchdog commands,
+   timeout  - start the watchdog with `timeout' seconds timeout\n
+   watchdog off   - stop the watchdog (can't be done on all 
boards)\n
+);
diff --git a/include/watchdog.h b/include/watchdog.h
index 9265be9..953cf61 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -70,6 +70,15 @@
#endif /* CONFIG_WATCHDOG  !__ASSEMBLY__ */
 #endif /* CONFIG_HW_WATCHDOG */
 
+#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
+extern void watchdog_enable(unsigned int timeout_secs);
+
+extern void watchdog_disable(void);
+#else
+static inline void watchdog_enable(unsigned int timeout_secs) { }
+static inline void watchdog_disable(void) { }
+#endif
+
 /*
  * Prototypes from $(CPU)/cpu.c.
  */
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2]: arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-10-28 Thread Simon Kagstrom
Initialize by calling the generic API watchdog_enable() with the number
of seconds for the watchdog to timeout. It's not possible to disable the
watchdog once it's on.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:

 v2: (Some of the comments from Prafulla)
   * Use readl/writel
   * Rename WATCHDOG_CNTR - WATCHDOG_TMR

 cpu/arm926ejs/kirkwood/timer.c |   37 +
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/kirkwood/timer.c b/cpu/arm926ejs/kirkwood/timer.c
index 817ff42..797ab04 100644
--- a/cpu/arm926ejs/kirkwood/timer.c
+++ b/cpu/arm926ejs/kirkwood/timer.c
@@ -23,8 +23,10 @@
 
 #include common.h
 #include asm/arch/kirkwood.h
+#include watchdog.h
 
 #define UBOOT_CNTR 0   /* counter to use for uboot timer */
+#define WATCHDOG_TMR   2
 
 /* Timer reload and current value registers */
 struct kwtmr_val {
@@ -166,3 +168,38 @@ int timer_init(void)
 
return 0;
 }
+
+#if defined(CONFIG_HW_WATCHDOG)
+static unsigned long watchdog_timeout = 5;
+void hw_watchdog_reset(void)
+{
+   u32 time = CONFIG_SYS_TCLK * watchdog_timeout;
+
+   writel(time, CNTMR_VAL_REG(WATCHDOG_TMR));
+}
+
+void watchdog_enable(unsigned int timeout_secs)
+{
+   struct kwcpu_registers *cpureg =
+   (struct kwcpu_registers *)KW_CPU_REG_BASE;
+   u32 rstoutn_mask;
+   u32 cntmrctrl;
+
+   watchdog_timeout = timeout_secs;
+   /* Enable CPU reset if watchdog expires */
+   rstoutn_mask = readl(cpureg-rstoutn_mask);
+   writel(rstoutn_mask |= WATCHDOG_TMR, cpureg-rstoutn_mask);
+   hw_watchdog_reset();
+
+   /* Enable the watchdog */
+   cntmrctrl = readl(CNTMR_CTRL_REG);
+   cntmrctrl |= CTCR_ARM_TIMER_EN(WATCHDOG_TMR);
+   cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(WATCHDOG_TMR);
+   writel(cntmrctrl, CNTMR_CTRL_REG);
+}
+
+void watchdog_disable(void)
+{
+   /* Can't be done */
+}
+#endif
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2]: common: Add a watchdog CLI command

2009-10-28 Thread Simon Kagstrom
On Wed, 28 Oct 2009 07:29:35 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

  +static int do_watchdog(cmd_tbl_t *cmdtp, int flag, int argc, 
 
  +   if (timeout  0)
  +   goto usage;
 
 How about passing zero value here, will it be a correct input for 
 watchdog_enable?

Good point, I'll update the patch.

  +
  +   /* Everything fine, enable the watchdog */
  +   watchdog_enable(timeout);
 
 Can we check for some error code here from lower layer and dump some error 
 message?
 For ex. Specified timeout value may be invalid for specific h/w

We could, but I'd like to keep the interface simple. Basically: tell
the hardware driver to enable the watchdog as good as possible, and
then the hardware will enable a watchdog that will timeout sometime.

This is hardly an end-user issue anyway: he/she will test the board
properly to find a good timeout value anyway, and I believe the
interface can be kept simple. I just like it since it makes it simple
to enable the watchdog where you like it in boot scripts etc.

  +#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
  +extern void watchdog_enable(unsigned int timeout_secs);
  +
  +extern void watchdog_disable(void);
  +#else
  +static inline void watchdog_enable(unsigned int timeout_secs) { }
  +static inline void watchdog_disable(void) { }
  +#endif
  +

 What does this means?

It was just a way of making the interface calls valid (but empty) if
the watchdog support isn't there. The idea is to avoid #ifdefs in the
code (like for WATCHDOG_RESET).

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] ARM pull request v3

2009-10-23 Thread Simon Kagstrom
Hi Tom and Wolfgang!

On Sun, 18 Oct 2009 17:58:48 -0500
Tom tom@windriver.com wrote:

 [...]
 The following changes since commit a380279b2abe130c2d3d2c8de36f8ff98bc6b3b0:
Daniel Gorsulowski (1):
  at91: Update MEESC board support
 
 are available in the git repository at:
 
git://git.denx.de/u-boot-arm master-sync

Has this pull been forgotten or is it in the works still?

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] ARM pull request v3

2009-10-14 Thread Simon Kagstrom
On Wed, 14 Oct 2009 06:18:30 -0500
Tom Rix t...@bumblecow.com wrote:

  Tom: Perhaps you could pick up [PATCH v3] arm926ejs: 8-byte align
  stack to avoid LDRD/STRD problems for the ARM repo as well then?
  
  I know it could go via Prafullas tree, but it's not really
  Marvell-specific, just fixes an issue for Sheevaplug and OpenRD. I also
  don't see how it could do any harm to other ARM boards.
 
 Yes I think this fix is fine.
 Did it make it into the marvell tree?  Do you have a commit id I could
 cherry pick from?  Else I will find it

I believe it's in the testing branch in Prafullas Marvell tree.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] ARM pull request v3

2009-10-13 Thread Simon Kagstrom
On Tue, 13 Oct 2009 16:51:14 +0200
Wolfgang Denk w...@denx.de wrote:

  I want to let you know that there will probably be some compilation
  warnings. These are patches for these. These have been sent to the
  list and ACK'ed by Tom and currently in my master. This will be part
  of my next pull request.
 
 Thanks for the heads-up. Indeed there are lots of warning.
 
 OK, so I will wait until Tom sends another pull request that includes
 these fixes.

Tom: Perhaps you could pick up [PATCH v3] arm926ejs: 8-byte align
stack to avoid LDRD/STRD problems for the ARM repo as well then?

I know it could go via Prafullas tree, but it's not really
Marvell-specific, just fixes an issue for Sheevaplug and OpenRD. I also
don't see how it could do any harm to other ARM boards.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] arm/master merged

2009-10-12 Thread Simon Kagstrom
On Sun, 11 Oct 2009 14:00:15 -0500
Tom Rix t...@bumblecow.com wrote:

 I have merged arm/next into arm/master.
 
 There are new warnings in
 CPU9260 , CONFIG_SYS_64BIT_VSPRINTF
 CPU9G20 , CONFIG_SYS_64BIT_VSPRINTF
 GPUAT91 , CONFIG_NET_MULTI,
 davinci_dm355evm , CONFIG_SYS_64BIT_VSPRINTF, generic_set_bit
   I have ack-ed patches for these..
 openrd_base , kwgbe_init breaking strict aliasing rules

But not [PATCH v3] arm926ejs: 8-byte align stack to avoid LDRD/STRD
problems? It would be very nice to have since both sheevaplug and
openrd_base are broken without it.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3] arm926ejs: 8-byte align stack to avoid LDRD/STRD problems

2009-10-06 Thread Simon Kagstrom
U-boot for Marvell Kirkwood boards no longer work after the EABI changes
introduced in commit f772acf8a584067033eff1e231fcd1fb3a00d3d9. This
turns out to be caused by a stack alignment issue. The armv5te
instructions ldrd/strd instructions require 8-byte alignment to work
properly (otherwise undefined behavior).

Tested on an OpenRD base board, where both printouts and ubifs stuff now
works.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:
 v2: Update after Andrews comments
   * Mask away the low address bits to get 16-byte alignment
 v3: Update after Andrews and Måns comments
   * Use bic instruction to clear low address bits (I'm a ARM asm newbie as
 you can see)
   * Update description to actually match the code

Thanks again for all the comments!

 cpu/arm926ejs/start.S |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/start.S b/cpu/arm926ejs/start.S
index 8043322..4421b6a 100644
--- a/cpu/arm926ejs/start.S
+++ b/cpu/arm926ejs/start.S
@@ -172,6 +172,7 @@ stack_setup:
sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
sub sp, r0, #12 /* leave 3 words for abort-stack*/
+   bic sp, r0, #7  /* 8-byte align stack for ABI 
compliance */
 
 clear_bss:
ldr r0, _bss_start  /* find start of bss segment*/
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] arm926ejs: 16-byte align stack to avoid LDRD/STRD problems

2009-10-06 Thread Simon Kagstrom
On Mon, 05 Oct 2009 13:37:36 -0500
Tom tom@windriver.com wrote:

 Simon Kagstrom wrote:
  U-boot for Marvell Kirkwood boards no longer work after the EABI changes
  introduced in commit f772acf8a584067033eff1e231fcd1fb3a00d3d9. This
  turns out to be caused by a stack alignment issue. The armv5te
  instructions ldrd/strd instructions require 8-byte alignment to work
  properly (otherwise undefined behavior), and start.S gave the stack a
  12-byte alignment.
  
  Tested on an OpenRD base board, where both printouts and ubifs stuff now
  works.
 
 Has this patch been tested on any other boards ?
 This patch looks ok, I am just concerned about regressions.

It would probably be good to have it tested on non-Kirkwood boards as
well. I can't see that it should do any harm to other boards though -
it's just aligning the stack to 8 bytes (disregard the Subject for now
and see v3 of the patch :-)).

The strange thing is really why it worked before on other boards.
Perhaps the stack by change was already 8-byte aligned there, or
perhaps ldrd/strd with non-8-byte alignment is handled. The
architecture manual says that the behavior of ldrd/strd is undefined
unless the address is 8-byte aligned, but I suppose that allows for it
to actually work.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] arm926ejs: 16-byte align stack to avoid LDRD/STRD problems

2009-10-05 Thread Simon Kagstrom
U-boot for Marvell Kirkwood boards no longer work after the EABI changes
introduced in commit f772acf8a584067033eff1e231fcd1fb3a00d3d9. This
turns out to be caused by a stack alignment issue. The armv5te
instructions ldrd/strd instructions require 8-byte alignment to work
properly (otherwise undefined behavior), and start.S gave the stack a
12-byte alignment.

Tested on an OpenRD base board, where both printouts and ubifs stuff now
works.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 cpu/arm926ejs/start.S |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/cpu/arm926ejs/start.S b/cpu/arm926ejs/start.S
index 8043322..ca520eb 100644
--- a/cpu/arm926ejs/start.S
+++ b/cpu/arm926ejs/start.S
@@ -171,7 +171,8 @@ stack_setup:
 #ifdef CONFIG_USE_IRQ
sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
-   sub sp, r0, #12 /* leave 3 words for abort-stack*/
+   sub sp, r0, #16 /* leave 3 words for abort-stack and */
+   /* align stack for ldrd/strd */
 
 clear_bss:
ldr r0, _bss_start  /* find start of bss segment*/
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm926ejs: 16-byte align stack to avoid LDRD/STRD problems

2009-10-05 Thread Simon Kagstrom
On Mon, 5 Oct 2009 09:30:54 -0500
Andrew Dyer amd...@gmail.com wrote:

         sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
   #endif
  -       sub     sp, r0, #12             /* leave 3 words for abort-stack    
  */
  +       sub     sp, r0, #16             /* leave 3 words for abort-stack 
  and */
  +                                       /* align stack for ldrd/strd */
 
 This doesn't guarantee an alignment.  Right above this code is a
 series of subtractions by constants, any one of which could throw the
 alignment out of whack and be difficult to figure out.
 
 IMHO it's much safer to do the subtraction to R0, then mask the bottom
 address bits out to guarantee alignment, then stuff the results into
 sp.

Right, new patch coming up.

Thanks,
// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2] arm926ejs: 16-byte align stack to avoid LDRD/STRD problems

2009-10-05 Thread Simon Kagstrom
U-boot for Marvell Kirkwood boards no longer work after the EABI changes
introduced in commit f772acf8a584067033eff1e231fcd1fb3a00d3d9. This
turns out to be caused by a stack alignment issue. The armv5te
instructions ldrd/strd instructions require 8-byte alignment to work
properly (otherwise undefined behavior), and start.S gave the stack a
12-byte alignment.

Tested on an OpenRD base board, where both printouts and ubifs stuff now
works.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:
 v2: Update after Andrews comments
   * Mask away the low address bits to get 16-byte alignment

 cpu/arm926ejs/start.S |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/cpu/arm926ejs/start.S b/cpu/arm926ejs/start.S
index 8043322..cd3a6bd 100644
--- a/cpu/arm926ejs/start.S
+++ b/cpu/arm926ejs/start.S
@@ -171,7 +171,10 @@ stack_setup:
 #ifdef CONFIG_USE_IRQ
sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
-   sub sp, r0, #12 /* leave 3 words for abort-stack*/
+   sub r0, r0, #12 /* leave 3 words for abort-stack and */
+   mov r1, #7  /* 8-byte align stack for ldrd/strd */
+   and r1, r0
+   sub sp, r0, r1
 
 clear_bss:
ldr r0, _bss_start  /* find start of bss segment*/
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] Make arm926ejs use -mabi=apcs-gnu to avoid EABI problems

2009-10-02 Thread Simon Kagstrom
On Thu, 01 Oct 2009 20:27:11 +0200
Wolfgang Denk w...@denx.de wrote:

 -PLATFORM_CPPFLAGS += -march=armv5te
 +PLATFORM_CPPFLAGS += -march=armv5te -mabi=apcs-gnu

 I have to admit that I really hesitate ifwe should add this - the
 longer I think about it, the more I tend to say no.

 I call upon everybody who has some time and resources and who is able
 to reproduce the problem (so far I was not) to help and dig into this,
 so we can understand what's going on, and finally fix the cause of the
 problem, instead of trying to hush it up.

OK, I understand. I meant to take a look at this today again, but got
busy with other things. I'll try to get some time for this again next
week.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] Make arm926ejs use -mabi=apcs-gnu to avoid EABI problems

2009-10-01 Thread Simon Kagstrom
Using -mabi=apcs-gnu allows Marvell Kirkwood-based boards to boot with
the EABI changes introduced in commit
f772acf8a584067033eff1e231fcd1fb3a00d3d9.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
Wolfgang can live with this change to make Kirkwood builds work again:

On Wed, 30 Sep 2009 22:32:08 +0200
Wolfgang Denk w...@denx.de wrote:

  -PLATFORM_CPPFLAGS += -march=armv5te
  +PLATFORM_CPPFLAGS += -march=armv5te -mabi=apcs-gnu
 
 I could live with this part, if it was thoroughly tested and does not
 cause problems with the most frequently used tool chains (which I'm
 afraid it would - I think I remember that I saw errors or unexpected
 behaviour when using multiple, different -mabi settings).

It would be nice though if owners of other arm926ejs-boards could test
the patch and see that it doesn't break things. Depending on the
compiler, you might want to build with USE_PRIVATE_LIBGCC=yes.

I've tested on a OpenRD-base board.

 cpu/arm926ejs/config.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cpu/arm926ejs/config.mk b/cpu/arm926ejs/config.mk
index f8ef90f..466ccff 100644
--- a/cpu/arm926ejs/config.mk
+++ b/cpu/arm926ejs/config.mk
@@ -23,7 +23,7 @@
 
 PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
 
-PLATFORM_CPPFLAGS += -march=armv5te
+PLATFORM_CPPFLAGS += -march=armv5te -mabi=apcs-gnu
 # =
 #
 # Supply options according to compiler version
-- 
1.6.0.4
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] kirkwood (openrd): saveenv will not work with environment in NAND

2009-09-30 Thread Simon Kagstrom
On Tue, 29 Sep 2009 17:16:42 +0200
Dieter Kiermaier dk-arm-li...@gmx.de wrote:

 Hm, it looks like there is the whole nand system somewhat broken :(
 Haven't seen it earlier, but:
 U-Boot 2009.08-00208-g9ef0569-dirty (Sep 29 2009 - 15:42:42)
 OpenRD_base
 
 SoC:   Kirkwood 88F6281_A0
 DRAM:  27535155593740288 MB
 NAND:  0 MiB
 *** Warning - bad CRC or NAND, using default environment
 
 But boot message state that there is no NAND detected!
 So I assume that is the main cause for the not working saveenv command?
 Cross checked it with marvell provided u-boot - this one works. So damaged 
 hardware isn't the case.

It's a EABI problem, see this thread:

  http://lists.denx.de/pipermail/u-boot/2009-September/059896.html

(and the other one referred from here). We don't have a good solution
yet, but you have a hacky patch to revert to the old ABI at the end of
the thread above.


We still haven't found out what's actually causing this. EABI itself
should be fine since Linux works well with it, but something is causing
problems with multiple versions of GCC for U-boot. For now you can use
the patch referred to above. For me, saveenv works fine on OpenRD, so
it should be OK for you as well :-)

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] kirkwood (openrd): saveenv will not work with environment in NAND

2009-09-30 Thread Simon Kagstrom
On Wed, 30 Sep 2009 09:02:14 +0200
Dieter Kiermaier dk-arm-li...@gmx.de wrote:

 arm-none-linux-gnueabi-ld: ERROR: Source object 
 /home/dieter/ArtistaNET-III/Software/trunk/SDK/tools/gcc/bin/../lib/gcc/arm-none-linux-gnueabi/4.2.0/libgcc.a(_udivsi3.o)
  has EABI version 4, but target u-boot has EABI version 0
 
 Do you know how I can solve this problem?
 (I've read the two given mail threads but found no hint to this problem, so 
 maybe my toolchain is broken?)

Sounds like you might have problems with USE_PRIVATE_LIBGCC. See this
mail for how to test this:

  http://lists.denx.de/pipermail/u-boot/2009-August/059313.html

And see this for more info on how USE_PRIVATE_LIBGCC before trying to
set it to no:

  http://lists.denx.de/pipermail/u-boot/2009-August/059324.html

;-)

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] kirkwood (openrd): saveenv will not work with environment in NAND

2009-09-30 Thread Simon Kagstrom
On Wed, 30 Sep 2009 09:40:07 +0200
Dieter Kiermaier dk-arm-li...@gmx.de wrote:

  Sounds like you might have problems with USE_PRIVATE_LIBGCC. See this
  mail for how to test this:
  
http://lists.denx.de/pipermail/u-boot/2009-August/059313.html
 
 export USE_PRIVATE_LIBGCC=yes
 seems to solve my problem - even if I don't exactly understand what I'm doing 
 :(

You use a libgcc from uboot/lib_arm, built when you build uboot,
instead of the one you built with gcc. Basically you will build this
with the same ABI options as you build the rest of uboot, so it will
avoid the linker errors you got before.

 @Prafulla:
 Hi Prafulla,
 is there anywhere a document how to build open source u-boot for sheevaplug 
 which explains all these details?
 (haven't found some documentation about this)

(Wearing my Prafulla hat): I guess this should be described on the
plugwiki:

  
http://www.openplug.org/plugwiki/index.php/Das_U-boot_plug_support#Open_U-boot_support_for_SheevaPlug

but we really just need to solve the EABI problem.


Wolfgang/Stefan/Tom/Prafulla: Would a patch like the one below be
acceptable until we find out a proper fix? I realise that this also
affects other arm926ejs-boards, but is there some way to isolate this
to kirkwood?

// Simon


From 29ff02ca77406e820203ad27369e0684aa1a098c Mon Sep 17 00:00:00 2001
From: Simon Kagstrom simon.kagst...@netinsight.net
Date: Fri, 4 Sep 2009 11:15:20 +0200
Subject: [PATCH] Make arm926ejs use -mabi=apcs-gnu and private libgcc

Using -mabi=apcs-gnu allows Marvell Kirkwood-based boards to boot with
the EABI changes introduced in commit
f772acf8a584067033eff1e231fcd1fb3a00d3d9. Since this changes the ABI,
USE_PRIVATE_LIBGCC is also defined.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 cpu/arm926ejs/config.mk |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/cpu/arm926ejs/config.mk b/cpu/arm926ejs/config.mk
index f8ef90f..1c9d547 100644
--- a/cpu/arm926ejs/config.mk
+++ b/cpu/arm926ejs/config.mk
@@ -20,10 +20,11 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
+USE_PRIVATE_LIBGCC = yes
 
 PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
 
-PLATFORM_CPPFLAGS += -march=armv5te
+PLATFORM_CPPFLAGS += -march=armv5te -mabi=apcs-gnu
 # =
 #
 # Supply options according to compiler version
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] kirkwood (openrd): saveenv will not work with environment in NAND

2009-09-30 Thread Simon Kagstrom
On Wed, 30 Sep 2009 10:15:35 +0200
Dieter Kiermaier dk-arm-li...@gmx.de wrote:

   is there anywhere a document how to build open source u-boot for 
   sheevaplug which explains all these details?
   (haven't found some documentation about this)
  
  (Wearing my Prafulla hat): I guess this should be described on the
  plugwiki:
  

  http://www.openplug.org/plugwiki/index.php/Das_U-boot_plug_support#Open_U-boot_support_for_SheevaPlug
 Yes - I know this page but there are no information regarding the latest 
 u-boot changes (e.g. openrd support, movement from git.marvell.com to denx , 
 the
 toolchain problems...)

It's a wiki (hint, hint!) :-)

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-09-29 Thread Simon Kagstrom
On Mon, 28 Sep 2009 19:16:16 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

 But do you really need Watchdog support for u-boot?

Paranoia really has no limits :-). The main objective for me personally
is to have the watchdog on when Linux starts, but if there is a risk
(for whatever reason) that U-boot hangs, it would also help there.

 Because if you want to use the watchdog, you will need to keep it running in
 Entire code.

That's fine, the code is already sprinkled with WATCHDOG_RESET() in
many places (which calls hw_watchdog_reset()). Also note that this
patch doesn't actually turn it on, you'll have to call
kw_watchdog_init() first to do that.

 Secondly Pls have a look at drivers/watchdog/at91sam9_wdt.c and its 
 implementation,
 This will be a good way of implementation.

Well, I did look at that, and I believe the implementation is fairly
similar.

What I wonder about in that context is the use of hw_watchdog_init(). I
first thought this was generic, but it's not exported via watchdog.h
(like hw_watchdog_reset()). I think it would be nice to have a generic
interface which exports

  void hw_watchdog_init(unsigned long timeout_ms);

to initialize the watchdog and timeout. The timeout would be a bit
crude since hardware have limits to how long the timeouts would be, but
anyway.


Another good feature would be a command-line interface to turn it on
and configure it, i.e., something like

  watchdog on 5000   # Set timeout to 5000 ms
  watchdog off   # Turn off (if possible)

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-09-29 Thread Simon Kagstrom
On Tue, 29 Sep 2009 06:45:44 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

  The main objective for me personally is to have the watchdog on when Linux 
  starts,
  but if there is a risk (for whatever reason) that U-boot hangs, it would 
  also help there.
 
 Its good to have watchdog, it will be very useful for some applications.
 But I don't think we should do it at u-boot level.
 Secondly If it is supported on Kirkwood platforms in Linux,
 then the same can be triggered from OS too.

Sure, it's just nice to have it running when Linux is started, so that
the board is properly rebooted if it hangs during kernel startup. And
in the same way as a watchdog can be useful for other boards, it should
be useful for Kirkwood-based ones.

 In u-boot I didn't find much watchdog implementation for other arm 
 architectures.

Well, you pointed at at91sam9_wdt.c, which I believe is for an ARM :-)

  That's fine, the code is already sprinkled with WATCHDOG_RESET() in
  many places (which calls hw_watchdog_reset()). Also note that this
  patch doesn't actually turn it on, you'll have to call
  kw_watchdog_init() first to do that.
 
 newly added code for Kirkwood may not, we need to check and add

It works fine for me at least. I don't think any of the kirkwood code
has delays of several seconds so far :-). And again, boards which don't
need it or don't want to use it doesn't need to turn the watchdog on -
it will simply be compiled out in that case.

   Secondly Pls have a look at drivers/watchdog/at91sam9_wdt.c 
  and its implementation,
   This will be a good way of implementation.
  
  Well, I did look at that, and I believe the implementation is fairly
  similar.
 
 I think you should follow the same method to keep it as add Kirkwood 
 watchdog driver

Sorry, I'm not sure what this comment means. Do you mean to move it out
of timer.c? I put it there since it uses the timer registers and is
really just a special use of the built-in timer support.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-09-28 Thread Simon Kagstrom
Initialize by calling kw_watchdog_init() with the number of seconds for
the watchdog to timeout.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 cpu/arm926ejs/kirkwood/timer.c  |   29 +
 include/asm-arm/arch-kirkwood/cpu.h |2 ++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/kirkwood/timer.c b/cpu/arm926ejs/kirkwood/timer.c
index 817ff42..f3397e7 100644
--- a/cpu/arm926ejs/kirkwood/timer.c
+++ b/cpu/arm926ejs/kirkwood/timer.c
@@ -25,6 +25,7 @@
 #include asm/arch/kirkwood.h
 
 #define UBOOT_CNTR 0   /* counter to use for uboot timer */
+#define WATCHDOG_CNTR  2
 
 /* Timer reload and current value registers */
 struct kwtmr_val {
@@ -166,3 +167,31 @@ int timer_init(void)
 
return 0;
 }
+
+#if defined(CONFIG_HW_WATCHDOG)
+static unsigned long watchdog_timeout = 5;
+void hw_watchdog_reset(void)
+{
+   unsigned long time = CONFIG_SYS_TCLK * watchdog_timeout;
+
+   writel(time, CNTMR_VAL_REG(WATCHDOG_CNTR));
+}
+
+void kw_watchdog_init(unsigned long timeout_secs)
+{
+   struct kwcpu_registers *cpureg =
+   (struct kwcpu_registers *)KW_CPU_REG_BASE;
+   unsigned int cntmrctrl;
+
+   watchdog_timeout = timeout_secs;
+   /* Enable CPU reset if watchdog expires */
+   cpureg-rstoutn_mask |= WATCHDOG_CNTR;
+   hw_watchdog_reset();
+
+   /* Enable the watchdog */
+   cntmrctrl = readl(CNTMR_CTRL_REG);
+   cntmrctrl |= CTCR_ARM_TIMER_EN(WATCHDOG_CNTR);
+   cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(WATCHDOG_CNTR);
+   writel(cntmrctrl, CNTMR_CTRL_REG);
+}
+#endif
diff --git a/include/asm-arm/arch-kirkwood/cpu.h 
b/include/asm-arm/arch-kirkwood/cpu.h
index b3022a3..df49c3f 100644
--- a/include/asm-arm/arch-kirkwood/cpu.h
+++ b/include/asm-arm/arch-kirkwood/cpu.h
@@ -165,5 +165,7 @@ int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15,
unsigned int mpp32_39, unsigned int mpp40_47,
unsigned int mpp48_55);
 unsigned int kw_winctrl_calcsize(unsigned int sizeval);
+void kw_watchdog_init(unsigned long timeout_secs);
+
 #endif /* __ASSEMBLY__ */
 #endif /* _KWCPU_H */
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood: Add hardware watchdog support for Marvell Kirkwood boards

2009-09-28 Thread Simon Kagstrom
On Mon, 28 Sep 2009 07:36:32 -0500
Tom tom@windriver.com wrote:

  +void hw_watchdog_reset(void)
  +{
  +   unsigned long time = CONFIG_SYS_TCLK * watchdog_timeout;

  diff --git a/include/asm-arm/arch-kirkwood/cpu.h 
  b/include/asm-arm/arch-kirkwood/cpu.h
  index b3022a3..df49c3f 100644
  --- a/include/asm-arm/arch-kirkwood/cpu.h
  +++ b/include/asm-arm/arch-kirkwood/cpu.h
  @@ -165,5 +165,7 @@ int kw_config_mpp(unsigned int mpp0_7, unsigned int 
  mpp8_15,
  unsigned int mpp32_39, unsigned int mpp40_47,
  unsigned int mpp48_55);
   unsigned int kw_winctrl_calcsize(unsigned int sizeval);
  +void kw_watchdog_init(unsigned long timeout_secs);
 
 You should add hw_watchdog_reset to H the file or declare it static.

It's a public interface and defined in  include/watchdog.h (this is
what's being called by WATCHDOG_RESET), but I'll submit a new patch
which includes this.

 You may want to add #define stubs to handle the ifndef CONFIG_HW_WATCHDOG.

I'm afraid I don't understand this comment though, what is the
suggestion here?

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ubifs: Correct dereferencing of files-after-symlinks

2009-09-25 Thread Simon Kagstrom
Files in directories which are symlinked to were not dereferenced
correctly in last commit. E.g., with a symlink

   /boot/lnk - /boot/real_dir

loading

   /boot/lnk/uImage

will fail. This patch fixes that by simply seeing to it that the target
base directory has a slash after it.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 fs/ubifs/ubifs.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index b03ed0b..286739c 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -439,7 +439,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, 
char *filename)
continue;
}
/* Relative to cur dir */
-   sprintf(buf, %s%s,
+   sprintf(buf, %s/%s,
link_name, next == NULL ?  : next);
memcpy(symlinkpath, buf, sizeof(buf));
next = name = symlinkpath;
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC] Detecting coldstart on kirkwood CPUs

2009-09-25 Thread Simon Kagstrom
Hi (mostly Prafulla)!

I'm looking at detecting cold starts on the OpenRD board (and also
maintain the bootcounter via this). I've come up with a slight hack
which works in practice for me, but which feels a bit unsafe.

What I do is basically to reset the SYSRST duration counter just before
doing the soft reset in reset_cpu() (see patch below, I do a similar
thing in Linux). I've then added the following function to the board
code:

   #if defined(CONFIG_MISC_INIT_R)
   # define MS_TO_COUNT(x) ( ((x) * 1000 * 1000) / 40)
   int misc_init_r (void)
   {
   u32 rst_count = 0x1fff  readl(KW_REG_SYSRST_CNT);
   struct uboot_com *p =
   (struct uboot_com *)CONFIG_BOOTCOUNT_ADDR;

   /* clear the counter for next valid read*/
   writel(1  31, KW_REG_SYSRST_CNT);

   /* If the reset has been held for over 20ms it's a cold-start,
* wait for 40 to be sure
*
* FIXME! This should rely one some more safe metric for the future
*/
   if ( rst_count  MS_TO_COUNT(40) ) {
   printf(Start type: cold\n);
   p-bootcount_magic = 0x12345678; /* Clear the bootcount 
magic */
   p-is_coldstart = is_coldstart = 1;
   } else {
   printf(Start type: warm\n);
   p-is_coldstart = is_coldstart = 0;
   }

   return 0;
   }
   #endif

i.e., just check how long the reset was held at startup. If it's longer
than an empirically determined value (~40ms), then it's a cold start.
Pressing the reset button, I always get cold starts (even when tapping
as fast as I can), while soft resets are always warm.

But... Isn't there some better way of checking this on Kirkwood?

// Simon

[PATCH] Reset sysrst count before restarting

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 cpu/arm926ejs/kirkwood/cpu.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/kirkwood/cpu.c b/cpu/arm926ejs/kirkwood/cpu.c
index bab5faf..d0cdaf6 100644
--- a/cpu/arm926ejs/kirkwood/cpu.c
+++ b/cpu/arm926ejs/kirkwood/cpu.c
@@ -37,6 +37,7 @@ void reset_cpu(unsigned long ignored)
 
writel(readl(cpureg-rstoutn_mask) | (1  2),
cpureg-rstoutn_mask);
+   writel(1  31, KW_REG_SYSRST_CNT);
writel(readl(cpureg-sys_soft_rst) | 1,
cpureg-sys_soft_rst);
while (1) ;
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH, RFC] Make arm926ejs use -march=armv5t to avoid problems with EABI

2009-09-24 Thread Simon Kagstrom
On Thu, 24 Sep 2009 14:36:47 +0200
Stefan Roese s...@denx.de wrote:

 On Monday 14 September 2009 11:02:15 Simon Kagstrom wrote:
   Make arm926ejs use -march=armv5t to avoid problems with EABI
  
   Using -march=armv5t instead of armv5te allows Marvell Kirkwood-based
   boards to boot with the EABI changes introduced in commit
   f772acf8a584067033eff1e231fcd1fb3a00d3d9
  
  Well, further testing (with ubifs) has shown that this doesn't actually
  solve the problem - only making it disappear for some cases.
 
 Did you make any progress with this problem? And further insights here?

Not really. I currently solve the problem by using the patch below,
i.e., simply switching to the ABI before the change for arm926ejs. With
this, it works fine for me, but I understand that this maybe isn't a
good fix to the problem.

// Simon

From 4782dad55e5bde5500918cc19bae31ee3a13f6e9 Mon Sep 17 00:00:00 2001
From: Simon Kagstrom simon.kagst...@netinsight.net
Date: Fri, 4 Sep 2009 11:15:20 +0200
Subject: [PATCH] Make arm926ejs use -mabi=apcs-gnu to avoid EABI problems

Using -mabi=apcs-gnu allows Marvell Kirkwood-based boards to boot with
the EABI changes introduced in commit
f772acf8a584067033eff1e231fcd1fb3a00d3d9

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 cpu/arm926ejs/config.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cpu/arm926ejs/config.mk b/cpu/arm926ejs/config.mk
index f8ef90f..466ccff 100644
--- a/cpu/arm926ejs/config.mk
+++ b/cpu/arm926ejs/config.mk
@@ -23,7 +23,7 @@
 
 PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
 
-PLATFORM_CPPFLAGS += -march=armv5te
+PLATFORM_CPPFLAGS += -march=armv5te -mabi=apcs-gnu
 # =
 #
 # Supply options according to compiler version
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: Correct build with CONFIG_SYS_HUSH_PARSER set

2009-09-24 Thread Simon Kagstrom
Hi Prafulla!

Small reminder :-). Perhaps you missed this patch - and I also forgot
to add you under To:. It's a simple one-liner to get kirkwood/cpu.c to
build when CONFIG_SYS_HUSH_PARSER is set.

// Simon

On Thu, 17 Sep 2009 14:40:18 +0200
Simon Kagstrom simon.kagst...@netinsight.net wrote:

 arm: Correct build with CONFIG_SYS_HUSH_PARSER set
 
 FLAG_PARSE_SEMICOLON is not defined without hush.h, so include that.
 
 Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
 ---
  cpu/arm926ejs/kirkwood/cpu.c |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
 
 diff --git a/cpu/arm926ejs/kirkwood/cpu.c b/cpu/arm926ejs/kirkwood/cpu.c
 index d0cdaf6..fbe754c 100644
 --- a/cpu/arm926ejs/kirkwood/cpu.c
 +++ b/cpu/arm926ejs/kirkwood/cpu.c
 @@ -27,6 +27,7 @@
  #include asm/cache.h
  #include u-boot/md5.h
  #include asm/arch/kirkwood.h
 +#include hush.h
  
  #define BUFLEN   16
  

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4] Support for the OpenRD base board

2009-09-21 Thread Simon Kagstrom
The implementation is borrowed from the sheevaplug board and the Marvell
1.1.4 code. Unsupported (or untested) is the SD card, PCIe and SATA.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
I get run-time problems when building for armv5te for OpenRD base
(apparently the same problem occurs for other Kirkwood boards).


ChangeLog:

v2: kwbimage.cfg, which is needed to produce an image to install on the
  NAND flash, has been added
v3: Updated after Prafullas review:
  * Correct typo in comment section :-)
  * Update copyright references
  * Correct bit meaning in kwbimage.cfg according to new specification
  * Add empty line after MPP configuration
  * Use short name for board identity string in config 
  * Use CONFIG_SHEEVA_88SV131 instead of Feroceon
  * Add CONFIG_KIRKWOOD_PCIE_INIT to config
  * Use config_cmd_default.h and remove options which are not needed anymore
  * Move config address to 0x6 (384KB). I'd like it at this address since
adding UBI/UBIFS support to U-boot makes the binary a bit more than 300KB
and would thus overlap a config address at 0x4.
  Not updated in v3:
  * The default MTD options are kept (useful for UBIFS)
  * eth init is not done, this needs to be done in a generic way
v4: Updated after Prafullas second review:
  * Remove the double title line
  * Change the description to note what's not tested
  * Re-enable UBIFS since the bitops patch was merged

Thanks for the reviews, Prafulla!

 MAINTAINERS |4 +
 MAKEALL |1 +
 Makefile|3 +
 board/Marvell/openrd_base/Makefile  |   56 
 board/Marvell/openrd_base/config.mk |   33 +
 board/Marvell/openrd_base/kwbimage.cfg  |  168 +++
 board/Marvell/openrd_base/openrd_base.c |  160 ++
 board/Marvell/openrd_base/openrd_base.h |   46 +++
 include/configs/openrd_base.h   |  220 +++
 9 files changed, 691 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/openrd_base/Makefile
 create mode 100644 board/Marvell/openrd_base/config.mk
 create mode 100644 board/Marvell/openrd_base/kwbimage.cfg
 create mode 100644 board/Marvell/openrd_base/openrd_base.c
 create mode 100644 board/Marvell/openrd_base/openrd_base.h
 create mode 100644 include/configs/openrd_base.h

diff --git a/MAINTAINERS b/MAINTAINERS
index f42c8f0..50f9260 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -588,6 +588,10 @@ Gary Jennejohn ga...@denx.de
 Konstantin Kletschke kletsc...@synertronixx.de
scb9328 ARM920T
 
+Simon Kagstrom simon.kagst...@netinsight.net
+
+   openrd_base ARM926EJS (Kirkwood SoC)
+
 Nishant Kamat nska...@ti.com
 
omap1610h2  ARM926EJS
diff --git a/MAKEALL b/MAKEALL
index 1d50c34..a0a3006 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -533,6 +533,7 @@ LIST_ARM9= \
omap1610inn \
omap5912osk \
omap730p2   \
+   openrd_base \
rd6281a \
sbc2410x\
scb9328 \
diff --git a/Makefile b/Makefile
index 0b61d05..8541b36 100644
--- a/Makefile
+++ b/Makefile
@@ -3022,6 +3022,9 @@ omap1610h2_cs_autoboot_config:unconfig
 omap5912osk_config :   unconfig
@$(MKCONFIG) $(@:_config=) arm arm926ejs omap5912osk ti omap
 
+openrd_base_config: unconfig
+   @$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 xtract_omap730p2 = $(subst _cs0boot,,$(subst _cs3boot,, $(subst _config,,$1)))
 
 omap730p2_config \
diff --git a/board/Marvell/openrd_base/Makefile 
b/board/Marvell/openrd_base/Makefile
new file mode 100644
index 000..3ef0b9b
--- /dev/null
+++ b/board/Marvell/openrd_base/Makefile
@@ -0,0 +1,56 @@
+#
+# (C) Copyright 2009
+# Net Insight www.netinsight.net
+# Written-by: Simon Kagstrom simon.kagst...@netinsight.net
+#
+# Based on sheevaplug:
+# (C) Copyright 2009
+# Marvell Semiconductor www.marvell.com
+# Written-by: Prafulla Wadaskar prafu...@marvell.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., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD

Re: [U-Boot] [PATCH v4 3/4]: Define ffs/fls for all architectures

2009-09-17 Thread Simon Kagstrom
On Wed, 16 Sep 2009 21:19:03 +0200
Stefan Roese s...@denx.de wrote:

 include/asm-ppc/bitops.h:
 @@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
  {
   return __ilog2(x  -x) + 1;
  }
 +#define ffs
 
 So after ffs() is define as an inline function, you define it to nothing. I 
 understand that you need a flag for include/linux/bitops.h, to decide if the 
 platform version of this function should be used or the generic version:
 
 include/linux/bitops.h:
 +#ifndef ffs
 +# define ffs generic_ffs
 +#endif
 
 But this only works for platforms which don't supply a platform specific ffs 
 function.

Ah, of course... What did I think of? Time to wear a funny hat I guess...

 One way to solve this would be something like this:

 include/asm-ppc/bitops.h:
 @@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
  {
   return __ilog2(x  -x) + 1;
  }
 +#define PLATFORM_FFS
 
 include/linux/bitops.h:
 +#ifndef PLATFORM_FFS
 +# define ffs generic_ffs
 +#endif

Yes, the patch should have contained something like that. Well, we'll
have to cook up a fix for this then. Sorry about that again.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 3/4]: Define ffs/fls for all architectures

2009-09-17 Thread Simon Kagstrom
On Thu, 17 Sep 2009 08:56:08 +0200

  Yes, the patch should have contained something like that. Well, we'll
  have to cook up a fix for this then. Sorry about that again.
 
 Simon, could you do this please?

Yes, absolutely. I'll try to have it done by this afternoon.

 And btw:
 
 #ifndef __set_bit
 # define __set_bit generic_set_bit
 #endif
 
 looks fishy too. Please fix this one as well.

Yes, I know about that issue as well. It will go in the same patch.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] Correct ffs/fls regression for PowerPC etc

2009-09-17 Thread Simon Kagstrom
Correct ffs/fls regression for PowerPC etc

Commits

  02f99901ed1c9d828e3ea117f94ce2264bf8389e
  52d61227b66d4099b39c8309ab37cb67ee09a405

introduced a regression where platform-specific ffs/fls implementations
were defined away. This patch corrects that by using PLATFORM_xxx
instead of the name itself.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
I've runtime tested on ARM (OpenRD base) and build-tested on MPC8536DS,
where __ilog2_u64 now at least is non-empty. It would be nice if (at
least!) some PowerPC people could test the patch.

 include/asm-arm/bitops.h|8 
 include/asm-blackfin/bitops.h   |   10 +-
 include/asm-i386/bitops.h   |2 +-
 include/asm-m68k/bitops.h   |2 +-
 include/asm-microblaze/bitops.h |3 ++-
 include/asm-mips/bitops.h   |   13 +
 include/asm-nios/bitops.h   |2 +-
 include/asm-nios2/bitops.h  |2 +-
 include/asm-ppc/bitops.h|4 ++--
 include/asm-sh/bitops.h |2 +-
 include/linux/bitops.h  |8 
 11 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 3c7b00c..270f163 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -125,14 +125,6 @@ static inline unsigned long ffz(unsigned long word)
 }
 
 /*
- * ffs: find first bit set. This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-#define ffs(x) generic_ffs(x)
-
-/*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
  */
diff --git a/include/asm-blackfin/bitops.h b/include/asm-blackfin/bitops.h
index cc3685d..f469f1c 100644
--- a/include/asm-blackfin/bitops.h
+++ b/include/asm-blackfin/bitops.h
@@ -79,7 +79,7 @@ static __inline__ void __set_bit(int nr, volatile void *addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
-#define __set_bit
+#define PLATFORM__set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
@@ -270,14 +270,6 @@ static __inline__ int find_next_zero_bit(void *addr, int 
size, int offset)
 }
 
 /*
- * ffs: find first bit set. This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-#define ffs(x) generic_ffs(x)
-
-/*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
  */
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index ac6285a..c7a38f2 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -349,7 +349,7 @@ static __inline__ int ffs(int x)
1: : =r (r) : g (x));
return r+1;
 }
-#define ffs
+#define PLATFORM_FFS
 
 /**
  * hweightN - returns the hamming weight of a N-bit word
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index e0c35fa..ad971b4 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -51,7 +51,7 @@ extern __inline__ int ffs(int x)
return r;
 }
 #define __ffs(x) (ffs(x) - 1)
-#define ffs
+#define PLATFORM_FFS
 
 #endif /* __KERNEL__ */
 
diff --git a/include/asm-microblaze/bitops.h b/include/asm-microblaze/bitops.h
index aac9061..3b39e16 100644
--- a/include/asm-microblaze/bitops.h
+++ b/include/asm-microblaze/bitops.h
@@ -23,6 +23,7 @@ extern void __set_bit(int nr, volatile void * addr);
 
 extern void clear_bit(int nr, volatile void * addr);
 #define __clear_bit(nr, addr) clear_bit(nr, addr)
+#define PLATFORM__clear_bit
 
 extern void change_bit(int nr, volatile void * addr);
 extern void __change_bit(int nr, volatile void * addr);
@@ -75,7 +76,7 @@ extern __inline__ void __set_bit(int nr, volatile void * addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
-#define __set_bit
+#define PLATFORM__set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 0c07b68..18dee51 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -90,7 +90,7 @@ static __inline__ void __set_bit(int nr, volatile void * addr)
 
*m |= 1UL  (nr  31);
 }
-#define __set_bit
+#define PLATFORM__set_bit
 
 /*
  * clear_bit - Clears a bit in memory
@@ -706,17 +706,6 @@ static __inline__ unsigned long ffz(unsigned long word)
 
 #ifdef __KERNEL__
 
-/**
- * ffs - find first bit set
- * @x: the word to search
- *
- * This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-#define ffs(x) generic_ffs(x)
-
 /*
  * hweightN - returns the hamming weight of a N-bit word
  * @x: the word to weigh
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h
index 8315fb7..2047b7c 100644
--- a/include/asm-nios/bitops.h
+++ b/include/asm-nios/bitops.h
@@ -33,6 +33,6 @@ extern int test_and_set_bit(int

[U-Boot] [PATCH] arm: Correct build with CONFIG_SYS_HUSH_PARSER set

2009-09-17 Thread Simon Kagstrom
arm: Correct build with CONFIG_SYS_HUSH_PARSER set

FLAG_PARSE_SEMICOLON is not defined without hush.h, so include that.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 cpu/arm926ejs/kirkwood/cpu.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/cpu/arm926ejs/kirkwood/cpu.c b/cpu/arm926ejs/kirkwood/cpu.c
index d0cdaf6..fbe754c 100644
--- a/cpu/arm926ejs/kirkwood/cpu.c
+++ b/cpu/arm926ejs/kirkwood/cpu.c
@@ -27,6 +27,7 @@
 #include asm/cache.h
 #include u-boot/md5.h
 #include asm/arch/kirkwood.h
+#include hush.h
 
 #define BUFLEN 16
 
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2] Correct ffs/fls regression for PowerPC etc

2009-09-17 Thread Simon Kagstrom
Correct ffs/fls regression for PowerPC etc

Commits

  02f99901ed1c9d828e3ea117f94ce2264bf8389e
  52d61227b66d4099b39c8309ab37cb67ee09a405

introduced a regression where platform-specific ffs/fls implementations
were defined away. This patch corrects that by using PLATFORM_xxx
instead of the name itself.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
I've runtime tested on ARM (OpenRD base) and build-tested on MPC8536DS,
where __ilog2_u64 now at least is non-empty. It would be nice if (at
least!) some PowerPC people could test the patch.


ChangeLog:

v2 - Make _all_ macros upper case (Stefan, Wolfgang)


 include/asm-arm/bitops.h|8 
 include/asm-blackfin/bitops.h   |   10 +-
 include/asm-i386/bitops.h   |2 +-
 include/asm-m68k/bitops.h   |2 +-
 include/asm-microblaze/bitops.h |3 ++-
 include/asm-mips/bitops.h   |   13 +
 include/asm-nios/bitops.h   |2 +-
 include/asm-nios2/bitops.h  |2 +-
 include/asm-ppc/bitops.h|4 ++--
 include/asm-sh/bitops.h |2 +-
 include/linux/bitops.h  |8 
 11 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 3c7b00c..270f163 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -125,14 +125,6 @@ static inline unsigned long ffz(unsigned long word)
 }
 
 /*
- * ffs: find first bit set. This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-#define ffs(x) generic_ffs(x)
-
-/*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
  */
diff --git a/include/asm-blackfin/bitops.h b/include/asm-blackfin/bitops.h
index cc3685d..ab1fea5 100644
--- a/include/asm-blackfin/bitops.h
+++ b/include/asm-blackfin/bitops.h
@@ -79,7 +79,7 @@ static __inline__ void __set_bit(int nr, volatile void *addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
-#define __set_bit
+#define PLATFORM__SET_BIT
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
@@ -270,14 +270,6 @@ static __inline__ int find_next_zero_bit(void *addr, int 
size, int offset)
 }
 
 /*
- * ffs: find first bit set. This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-#define ffs(x) generic_ffs(x)
-
-/*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
  */
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index ac6285a..c7a38f2 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -349,7 +349,7 @@ static __inline__ int ffs(int x)
1: : =r (r) : g (x));
return r+1;
 }
-#define ffs
+#define PLATFORM_FFS
 
 /**
  * hweightN - returns the hamming weight of a N-bit word
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index e0c35fa..ad971b4 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -51,7 +51,7 @@ extern __inline__ int ffs(int x)
return r;
 }
 #define __ffs(x) (ffs(x) - 1)
-#define ffs
+#define PLATFORM_FFS
 
 #endif /* __KERNEL__ */
 
diff --git a/include/asm-microblaze/bitops.h b/include/asm-microblaze/bitops.h
index aac9061..5d814f0 100644
--- a/include/asm-microblaze/bitops.h
+++ b/include/asm-microblaze/bitops.h
@@ -23,6 +23,7 @@ extern void __set_bit(int nr, volatile void * addr);
 
 extern void clear_bit(int nr, volatile void * addr);
 #define __clear_bit(nr, addr) clear_bit(nr, addr)
+#define PLATFORM__CLEAR_BIT
 
 extern void change_bit(int nr, volatile void * addr);
 extern void __change_bit(int nr, volatile void * addr);
@@ -75,7 +76,7 @@ extern __inline__ void __set_bit(int nr, volatile void * addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
-#define __set_bit
+#define PLATFORM__SET_BIT
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 0c07b68..1c8f4c0 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -90,7 +90,7 @@ static __inline__ void __set_bit(int nr, volatile void * addr)
 
*m |= 1UL  (nr  31);
 }
-#define __set_bit
+#define PLATFORM__SET_BIT
 
 /*
  * clear_bit - Clears a bit in memory
@@ -706,17 +706,6 @@ static __inline__ unsigned long ffz(unsigned long word)
 
 #ifdef __KERNEL__
 
-/**
- * ffs - find first bit set
- * @x: the word to search
- *
- * This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-#define ffs(x) generic_ffs(x)
-
 /*
  * hweightN - returns the hamming weight of a N-bit word
  * @x: the word to weigh
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h
index 8315fb7..0be74f4 100644
--- a/include/asm-nios/bitops.h
+++ b/include

[U-Boot] [PATCH] ubifs: Add support for looking up directory and relative symlinks

2009-09-15 Thread Simon Kagstrom
ubifs: Add support for looking up directory and relative symlinks

This patch adds support for resolving symlinks to directories as well as
relative symlinks. Symlinks are now always resolved during file lookup,
so the load stage no longer needs to special-case them.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 fs/ubifs/ubifs.c |   68 ++---
 1 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 8ede188..b03ed0b 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -379,9 +379,11 @@ static unsigned long ubifs_findfile(struct super_block 
*sb, char *filename)
int ret;
char *next;
char fpath[128];
+   char symlinkpath[128];
char *name = fpath;
unsigned long root_inum = 1;
unsigned long inum;
+   int symlink_count = 0; /* Don't allow symlink recursion */
 
strcpy(fpath, filename);
 
@@ -397,6 +399,9 @@ static unsigned long ubifs_findfile(struct super_block *sb, 
char *filename)
return inum;
 
for (;;) {
+   struct inode *inode;
+   struct ubifs_inode *ui;
+
/* Extract the actual part from the pathname.  */
next = strchr(name, '/');
if (next) {
@@ -406,18 +411,48 @@ static unsigned long ubifs_findfile(struct super_block 
*sb, char *filename)
}
 
ret = ubifs_finddir(sb, name, root_inum, inum);
+   if (!ret)
+   return 0;
+   inode = ubifs_iget(sb, inum);
+
+   if (!inode)
+   return 0;
+   ui = ubifs_inode(inode);
+
+   if ((inode-i_mode  S_IFMT) == S_IFLNK) {
+   char link_name[64];
+   char buf[128];
+
+   /* We have some sort of symlink recursion, bail out */
+   if (symlink_count++  8) {
+   printf(Symlink recursion, aborting\n);
+   return 0;
+   }
+   memcpy(link_name, ui-data, ui-data_len);
+   link_name[ui-data_len] = '\0';
+
+   if (link_name[0] == '/') {
+   /* Absolute path, redo everything without
+* the leading slash */
+   next = name = link_name + 1;
+   root_inum = 1;
+   continue;
+   }
+   /* Relative to cur dir */
+   sprintf(buf, %s%s,
+   link_name, next == NULL ?  : next);
+   memcpy(symlinkpath, buf, sizeof(buf));
+   next = name = symlinkpath;
+   continue;
+   }
 
/*
 * Check if directory with this name exists
 */
 
/* Found the node!  */
-   if (!next || *next == '\0') {
-   if (ret)
-   return inum;
-
-   break;
-   }
+   if (!next || *next == '\0')
+   return inum;
 
root_inum = inum;
name = next;
@@ -614,10 +649,10 @@ int ubifs_load(char *filename, u32 addr, u32 size)
int err = 0;
int i;
int count;
-   char link_name[64];
-   struct ubifs_inode *ui;
 
c-ubi = ubi_open_volume(c-vi.ubi_num, c-vi.vol_id, UBI_READONLY);
+   /* ubifs_findfile will resolve symlinks, so we know that we get
+* the real file here */
inum = ubifs_findfile(ubifs_sb, filename);
if (!inum) {
err = -1;
@@ -635,23 +670,6 @@ int ubifs_load(char *filename, u32 addr, u32 size)
}
 
/*
-* Check for symbolic link
-*/
-   ui = ubifs_inode(inode);
-   if (((inode-i_mode  S_IFMT) == S_IFLNK)  ui-data_len) {
-   memcpy(link_name, ui-data, ui-data_len);
-   link_name[ui-data_len] = '\0';
-   printf(%s is linked to %s!\n, filename, link_name);
-   ubifs_iput(inode);
-
-   /*
-* Now we have the real filename, call ubifs_load()
-* again (recursive call) to load this file instead
-*/
-   return ubifs_load(link_name, addr, size);
-   }
-
-   /*
 * If no size was specified or if size bigger than filesize
 * set size to filesize
 */
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] UBIFS LZO decompression failure

2009-09-15 Thread Simon Kagstrom
Hi List!

I have a slight problem with UBIFS on the OpenRD base board (an ARM
board very similar to sheevaplug). Loading files which have been
compressed with LZO by ubifs fails:

   OpenRD ubi part root; ubifsmount rootfs
   Creating 1 MTD partitions on nand0:
   0x001e-0x2000 : mtd=1
   UBI: attaching mtd1 to ubi0
   UBI: physical eraseblock size:   131072 bytes (128 KiB)
   UBI: logical eraseblock size:129024 bytes
   UBI: smallest flash I/O unit:2048
   UBI: sub-page size:  512
   UBI: VID header offset:  512 (aligned 512)
   UBI: data offset:2048
   UBI: attached mtd1 to ubi0
   UBI: MTD device name:mtd=1
   UBI: MTD device size:510 MiB
   UBI: number of good PEBs:4081
   UBI: number of bad PEBs: 0
   UBI: max. allowed volumes:   128
   UBI: wear-leveling threshold:4096
   UBI: number of internal volumes: 1
   UBI: number of user volumes: 1
   UBI: available PEBs: 54
   UBI: total number of reserved PEBs: 4027
   UBI: number of PEBs reserved for bad PEB handling: 40
   UBI: max/mean erase counter: 6/4
   UBIFS: mounted UBI device 0, volume 0, name rootfs
   UBIFS: mounted read-only
   UBIFS: file system size:   511967232 bytes (499968 KiB, 488 MiB, 3968 LEBs)
   UBIFS: journal size:   25675776 bytes (25074 KiB, 24 MiB, 199 LEBs)
   UBIFS: media format:   w4/r0 (latest is w4/r0)
   UBIFS: default compressor: LZO
   UBIFS: reserved for root:  5182151 bytes (5060 KiB)

   OpenRD ubifsload 0x800 /boot/primary/uImage
   Loading file '/boot/primary/uImage' to addr 0x0800 with size 7196920 
(0x006dd0f8)...
   UBIFS error (pid 0): ubifs_decompress: cannot decompress 3204 bytes, 
compressor LZO, error -6
   UBIFS error (pid 0): read_block: bad data node (block 0, inode 88)
   UBIFS error (pid 0): do_readpage: cannot read page 0 of inode 88, error -22
   Error reading file '/boot/primary/uImage'

I've created the filesystem in Linux on the target (v2.6.31). The
compression error -6 is LZO_E_LOOKBEHIND_OVERRUN, and it fails because
of this test in lzo1x_decompress.c:

if (HAVE_LB(m_pos, out, op))
goto lookbehind_overrun;

where HAVE_LB is defined as  (m_pos  out || m_pos = op)  and the
m_pos, out and op values are 0x07ffde77, 0x0800, 0x0883 (i.e.,
the first test fails).

The lzo1x_decompress.c file is identical to that in Linux, so something
is fishy here. Does it work for the rest of you?


In our case it doesn't matter very much since the file (an uImage) is
compressed anyway and we therefore save work anyway by marking it as
using no compression, but it would be nice if this would work anyhow.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3] Support for the OpenRD base board

2009-09-14 Thread Simon Kagstrom
Support for the OpenRD base board

The implementation is borrowed from the sheevaplug board and the Marvell
1.1.4 code and likely to be a bit incomplete.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
The configuration does not include UBIFS support, which still needs
the remaining patches for the bitops cleanup and fixes:

  http://lists.denx.de/pipermail/u-boot/2009-August/059285.html

to build. Until those are applied, it's turned off here.


I get run-time problems when building for armv5te for OpenRD base
(apparently the same problem occurs for other Kirkwood boards). This
patch fixes that:

  http://lists.denx.de/pipermail/u-boot/2009-September/059896.html


ChangeLog:

v2: kwbimage.cfg, which is needed to produce an image to install on the
  NAND flash, has been added
v3: Updated after Prafullas review:
  * Correct typo in comment section :-)
  * Update copyright references
  * Correct bit meaning in kwbimage.cfg according to new specification
  * Add empty line after MPP configuration
  * Use short name for board identity string in config 
  * Use CONFIG_SHEEVA_88SV131 instead of Feroceon
  * Add CONFIG_KIRKWOOD_PCIE_INIT to config
  * Use config_cmd_default.h and remove options which are not needed anymore
  * Move config address to 0x6 (384KB). I'd like it at this address since
adding UBI/UBIFS support to U-boot makes the binary a bit more than 300KB
and would thus overlap a config address at 0x4.
  Not updated in v3:
  * The default MTD options are kept (useful for UBIFS)
  * eth init is not done, this needs to be done in a generic way

 MAINTAINERS |4 +
 MAKEALL |1 +
 Makefile|3 +
 board/Marvell/openrd_base/Makefile  |   56 
 board/Marvell/openrd_base/config.mk |   33 +
 board/Marvell/openrd_base/kwbimage.cfg  |  168 +
 board/Marvell/openrd_base/openrd_base.c |  160 +++
 board/Marvell/openrd_base/openrd_base.h |   46 +++
 include/configs/openrd_base.h   |  209 +++
 9 files changed, 680 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/openrd_base/Makefile
 create mode 100644 board/Marvell/openrd_base/config.mk
 create mode 100644 board/Marvell/openrd_base/kwbimage.cfg
 create mode 100644 board/Marvell/openrd_base/openrd_base.c
 create mode 100644 board/Marvell/openrd_base/openrd_base.h
 create mode 100644 include/configs/openrd_base.h

diff --git a/MAINTAINERS b/MAINTAINERS
index e9db278..99cdc12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -588,6 +588,10 @@ Gary Jennejohn ga...@denx.de
 Konstantin Kletschke kletsc...@synertronixx.de
scb9328 ARM920T
 
+Simon Kagstrom simon.kagst...@netinsight.net
+
+   openrd_base ARM926EJS (Kirkwood SoC)
+
 Nishant Kamat nska...@ti.com
 
omap1610h2  ARM926EJS
diff --git a/MAKEALL b/MAKEALL
index f0ed8ea..9e6eee2 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -533,6 +533,7 @@ LIST_ARM9= \
omap1610inn \
omap5912osk \
omap730p2   \
+   openrd_base \
rd6281a \
sbc2410x\
scb9328 \
diff --git a/Makefile b/Makefile
index 9764cea..6cef82a 100644
--- a/Makefile
+++ b/Makefile
@@ -3022,6 +3022,9 @@ omap1610h2_cs_autoboot_config:unconfig
 omap5912osk_config :   unconfig
@$(MKCONFIG) $(@:_config=) arm arm926ejs omap5912osk ti omap
 
+openrd_base_config: unconfig
+   @$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 xtract_omap730p2 = $(subst _cs0boot,,$(subst _cs3boot,, $(subst _config,,$1)))
 
 omap730p2_config \
diff --git a/board/Marvell/openrd_base/Makefile 
b/board/Marvell/openrd_base/Makefile
new file mode 100644
index 000..3ef0b9b
--- /dev/null
+++ b/board/Marvell/openrd_base/Makefile
@@ -0,0 +1,56 @@
+#
+# (C) Copyright 2009
+# Net Insight www.netinsight.net
+# Written-by: Simon Kagstrom simon.kagst...@netinsight.net
+#
+# Based on sheevaplug:
+# (C) Copyright 2009
+# Marvell Semiconductor www.marvell.com
+# Written-by: Prafulla Wadaskar prafu...@marvell.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

[U-Boot] [PATCH v2] Support for the OpenRD base board

2009-09-11 Thread Simon Kagstrom
Support for the OpenRD base board

The implementation is borrowed from the sheevaplug board and the Marvell
1.1.4 code and likely to be a bit incomplete.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
The configuration does not include UBIFS support, which still needs
he remaining patches for the bitops cleanup and fixes:

  http://lists.denx.de/pipermail/u-boot/2009-August/059285.html

to build. Until those are applied, it's turned off here.


I get run-time problems when building for armv5te for OpenRD base
(apparently the same problem occurs for other Kirkwood boards). This
patch fixes that:

  http://lists.denx.de/pipermail/u-boot/2009-September/059896.html


The second version contains the kwbimage.cfg needed to produce an image
to install on the NAND flash.

 MAINTAINERS |4 +
 MAKEALL |1 +
 Makefile|3 +
 board/Marvell/openrd_base/Makefile  |   51 +++
 board/Marvell/openrd_base/config.mk |   28 
 board/Marvell/openrd_base/kwbimage.cfg  |  168 
 board/Marvell/openrd_base/openrd_base.c |  158 ++
 board/Marvell/openrd_base/openrd_base.h |   46 +++
 include/configs/openrd_base.h   |  218 +++
 9 files changed, 677 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/openrd_base/Makefile
 create mode 100644 board/Marvell/openrd_base/config.mk
 create mode 100644 board/Marvell/openrd_base/kwbimage.cfg
 create mode 100644 board/Marvell/openrd_base/openrd_base.c
 create mode 100644 board/Marvell/openrd_base/openrd_base.h
 create mode 100644 include/configs/openrd_base.h

diff --git a/MAINTAINERS b/MAINTAINERS
index e9db278..99cdc12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -588,6 +588,10 @@ Gary Jennejohn ga...@denx.de
 Konstantin Kletschke kletsc...@synertronixx.de
scb9328 ARM920T
 
+Simon Kagstrom simon.kagst...@netinsight.net
+
+   openrd_base ARM926EJS (Kirkwood SoC)
+
 Nishant Kamat nska...@ti.com
 
omap1610h2  ARM926EJS
diff --git a/MAKEALL b/MAKEALL
index f0ed8ea..9e6eee2 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -533,6 +533,7 @@ LIST_ARM9= \
omap1610inn \
omap5912osk \
omap730p2   \
+   openrd_base \
rd6281a \
sbc2410x\
scb9328 \
diff --git a/Makefile b/Makefile
index 9764cea..6cef82a 100644
--- a/Makefile
+++ b/Makefile
@@ -3022,6 +3022,9 @@ omap1610h2_cs_autoboot_config:unconfig
 omap5912osk_config :   unconfig
@$(MKCONFIG) $(@:_config=) arm arm926ejs omap5912osk ti omap
 
+openrd_base_config: unconfig
+   @$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 xtract_omap730p2 = $(subst _cs0boot,,$(subst _cs3boot,, $(subst _config,,$1)))
 
 omap730p2_config \
diff --git a/board/Marvell/openrd_base/Makefile 
b/board/Marvell/openrd_base/Makefile
new file mode 100644
index 000..defbb08
--- /dev/null
+++ b/board/Marvell/openrd_base/Makefile
@@ -0,0 +1,51 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor www.marvell.com
+# Written-by: Prafulla Wadaskar prafu...@marvell.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., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).a
+
+COBJS  := openrd_base.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):$(obj).depend $(OBJS) $(SOBJS)
+   $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+clean:
+   rm -f $(SOBJS) $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak .depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/Marvell/openrd_base/config.mk 
b/board/Marvell/openrd_base/config.mk
new file mode 100644
index 000..2bd9f79
--- /dev/null
+++ b/board/Marvell/openrd_base/config.mk
@@ -0,0 +1,28 @@
+#
+# (C) Copyright 2009

Re: [U-Boot] [PATCH v2] Support for the OpenRD base board

2009-09-11 Thread Simon Kagstrom
Thanks for the comments Prafulla!

I'll update the patch according to them, but have some questions:

On Fri, 11 Sep 2009 03:43:04 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

  +#define CONFIG_ENV_SIZE  0x2 /* 128k */
  +#define CONFIG_ENV_ADDR  0xa
  +#define CONFIG_ENV_OFFSET0xa /* env starts here */
 Do you really need this address? the u-boot binary is within 256kb, at the 
 most it can go till 512kb

This is where the default environment (for the U-boot shipped by
Marvell) resides. Like on Sheevaplug, it uses 4-bit ECC, so current
U-boot won't be able to read it, but I know you're working on it.

  +#define MTDIDS_DEFAULT   nand0=nand_mtd
  +#define MTDPARTS_DEFAULT
  mtdparts=nand_mtd:0x100...@0x00(uboot),0x400...@0x10(
  uImage),\
  + 0x1fb00...@0x50(rootfs)
 This is must be the default setup in board setup file for openrd_base (if it 
 is again derived from sheevaplug)
 In that case this settings not required

I don't quite understand this. This is also the default addresses
shipped with the board.

  +#define CONFIG_EXTRA_ENV_SETTINGSx_bootargs=console\
  + =ttyS0,115200 MTDPARTS_DEFAULT  rw ubi.mtd=2,2048\0 \
  + x_bootcmd_kernel=nand read 0x640 0x10 0x30\0 \
  + x_bootcmd_usb=usb start\0 \
 You must add x_bootcmd_eth for program MAC addrss in hardware before kernel 
 boot.

Well, we need to figure out some generic way of giving Linux the MAC
address on these boards, but I've understood that initializing the
interface without using it is not popular, so in this case I'd just let
the problem remain (no x_bootcmd_eth).

Or did I misunderstand your comment?

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] Support for the OpenRD base board

2009-09-11 Thread Simon Kagstrom
On Fri, 11 Sep 2009 06:33:44 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

+#define CONFIG_ENV_SIZE  0x2 /* 128k */
+#define CONFIG_ENV_ADDR  0xa
+#define CONFIG_ENV_OFFSET0xa /* env 
  starts here */
   Do you really need this address? the u-boot binary is 
  within 256kb, at the most it can go till 512kb
  
  This is where the default environment (for the U-boot shipped by
  Marvell) resides. Like on Sheevaplug, it uses 4-bit ECC, so current
  U-boot won't be able to read it, but I know you're working on it.
 So I think, you want to retain both environment variables untouched
  ( i.e. latest u-boot and u-boot shipped by Marvell)
 But so far as mainlined u-boot is considered,
 doesn't it make sense to pack uboot-bin and environment sector together?
 like sheevaplug, I think first 2 sectors for u-boot and next once sector for 
 env should be better to choose.

Right, makes sense. I'll update that and skip the current address.

+#define MTDIDS_DEFAULT   nand0=nand_mtd
+#define MTDPARTS_DEFAULT
mtdparts=nand_mtd:0x100...@0x00(uboot),0x400...@0x10(
uImage),\
+ 0x1fb00...@0x50(rootfs)

  I don't quite understand this. This is also the default addresses
  shipped with the board.

 W..r.to line 24 at 
 http://git.marvell.com/?p=orion.git;a=blob;f=arch/arm/mach-kirkwood/openrd_base-setup.c;h=947dfb8cd5b252bf326d691ee5179e29ad07a9a9;hb=HEAD
 By default kernel has same mdtpart configuration as you are describing here.
 So you don't need this default setup here, you should skip it

OK, I understand. However, but it might also be useful from U-boot.
Locally, I've loaded the kernel from the ubifs partition, and then it's
useful to have this defined in U-boot as well. If it shouldn't be there
by default, I'll remove it though.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] Support for the OpenRD base board

2009-09-10 Thread Simon Kagstrom
Support for the OpenRD base board

The implementation is borrowed from the sheevaplug board and the Marvell
1.1.4 code and likely to be a bit incomplete.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
The configuration does not include UBIFS support, which still needs
he remaining patches for the bitops cleanup and fixes:

  http://lists.denx.de/pipermail/u-boot/2009-August/059285.html

to build. Until those are applied, it's turned off here.


I get run-time problems when building for armv5te for OpenRD base
(apparently the same problem occurs for other Kirkwood boards). This
patch fixes that:

  http://lists.denx.de/pipermail/u-boot/2009-September/059896.html

 MAINTAINERS |4 +
 MAKEALL |1 +
 Makefile|3 +
 board/Marvell/openrd_base/Makefile  |   51 +++
 board/Marvell/openrd_base/config.mk |   25 
 board/Marvell/openrd_base/openrd_base.c |  158 ++
 board/Marvell/openrd_base/openrd_base.h |   46 +++
 include/configs/openrd_base.h   |  218 +++
 8 files changed, 506 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/openrd_base/Makefile
 create mode 100644 board/Marvell/openrd_base/config.mk
 create mode 100644 board/Marvell/openrd_base/openrd_base.c
 create mode 100644 board/Marvell/openrd_base/openrd_base.h
 create mode 100644 include/configs/openrd_base.h

diff --git a/MAINTAINERS b/MAINTAINERS
index e9db278..99cdc12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -588,6 +588,10 @@ Gary Jennejohn ga...@denx.de
 Konstantin Kletschke kletsc...@synertronixx.de
scb9328 ARM920T
 
+Simon Kagstrom simon.kagst...@netinsight.net
+
+   openrd_base ARM926EJS (Kirkwood SoC)
+
 Nishant Kamat nska...@ti.com
 
omap1610h2  ARM926EJS
diff --git a/MAKEALL b/MAKEALL
index f0ed8ea..9e6eee2 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -533,6 +533,7 @@ LIST_ARM9= \
omap1610inn \
omap5912osk \
omap730p2   \
+   openrd_base \
rd6281a \
sbc2410x\
scb9328 \
diff --git a/Makefile b/Makefile
index 0449a5b..27b0179 100644
--- a/Makefile
+++ b/Makefile
@@ -3018,6 +3018,9 @@ omap1610h2_cs_autoboot_config:unconfig
 omap5912osk_config :   unconfig
@$(MKCONFIG) $(@:_config=) arm arm926ejs omap5912osk ti omap
 
+openrd_base_config: unconfig
+   @$(MKCONFIG) $(@:_config=) arm arm926ejs $(@:_config=) Marvell kirkwood
+
 xtract_omap730p2 = $(subst _cs0boot,,$(subst _cs3boot,, $(subst _config,,$1)))
 
 omap730p2_config \
diff --git a/board/Marvell/openrd_base/Makefile 
b/board/Marvell/openrd_base/Makefile
new file mode 100644
index 000..defbb08
--- /dev/null
+++ b/board/Marvell/openrd_base/Makefile
@@ -0,0 +1,51 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor www.marvell.com
+# Written-by: Prafulla Wadaskar prafu...@marvell.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., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).a
+
+COBJS  := openrd_base.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):$(obj).depend $(OBJS) $(SOBJS)
+   $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+clean:
+   rm -f $(SOBJS) $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak .depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/Marvell/openrd_base/config.mk 
b/board/Marvell/openrd_base/config.mk
new file mode 100644
index 000..a4ea769
--- /dev/null
+++ b/board/Marvell/openrd_base/config.mk
@@ -0,0 +1,25 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor www.marvell.com
+# Written-by: Prafulla Wadaskar prafu...@marvell.com
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute

Re: [U-Boot] [PATCH] ARM: compiler options cleanup - improve tool chain support

2009-09-07 Thread Simon Kagstrom
On Fri, 04 Sep 2009 22:05:45 +0200
Wolfgang Denk w...@denx.de wrote:

nand_bbt: Can't scan flash and build the RAM-based BBT
Net:   egiga0
88E1116 Initialized on egiga0
Hit any key to stop autoboot:  0 
Marvell 
  
  The 4.1 version just hangs on the NAND printout. I've tested both with
  USE_PRIVATE_LIBGCC=yes and USE_PRIVATE_LIBGCC unset, and get the same
  results.
 
 Did you make any progress an analyzing the cause of the issue?

Well, I sent a patch [PATCH, RFC] Make arm926ejs use -march=armv5t to
avoid problems with EABI, which corrects this for me, although I'd
like some input on if it really makes any sense.

The main difference I see between the two binaries is the use of
ldrd/strd instructions, which comes with the e-version of armv5t.
Obviously, that shouldn't by itself produce broken binaries, so
something is still fishy here.

// Simon

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

2009-09-07 Thread Simon Kagstrom
Hi Justin!

On Fri, 4 Sep 2009 17:27:59 -0400
Justin Waters justin.wat...@timesys.com wrote:

 I found a slight problem with this section of the patch:
 
 On Mon, 2009-08-24 at 03:10 -0400, Simon Kagstrom wrote:
  diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
  index 854e225..3c7b00c 100644
  --- a/include/asm-arm/bitops.h
  +++ b/include/asm-arm/bitops.h
  @@ -17,6 +17,8 @@
   
   #ifdef __KERNEL__
   
  +#include asm/proc/system.h
  +
 
 It causes a compiler error on the arm926ejs platform:
 
   In file included from cpu.c:34:
   /home/justin/git/u-boot/include/asm/system.h: At top level:
   /home/justin/git/u-boot/include/asm/system.h:71: error: expected
 identifier or '(' before 'asm'
 
 I did some digging, and it looks like set_cr() is implemented by both
 asm-arm/system.h and asm-arm/proc-armv/system.h.  One implements the
 function as a macro, while the other uses a standard C function, hence
 the weird error message.  The conflict occurs in cpu/arm926ejs/cpu.c.  

You are right, but I believe this was fixed an earlier patch, [PATCH]
Remove duplicate set_cr [1], which is in the ARM tree. I guess that
one hasn't shown up in Wolfgangs repository yet, so this series must be
applied to the ARM tree for now.

Thanks for testing!

// Simon

[1] 
http://git.denx.de/?p=u-boot/u-boot-arm.git;a=commit;h=f3d4f8870e69e0fd177397778d97d0751bbd020a
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] at91: Update MEESC board support

2009-09-07 Thread Simon Kagstrom
On Mon, 07 Sep 2009 09:26:17 +0200
Daniel Gorsulowski daniel.gorsulow...@esd.eu wrote:

 nack this will be done when u-boot will need to use the macb#
 Just imagine: U-boot boots a Linux kernel from NAND flash. It does NOT need 
 the
 ethernet interface, so it does NOT initialize ethernet, so the ethernet 
 address
 will NOT be written to the EMAC module!
 As a result, Linux will assign a random address, that is not acceptable!

Unfortunately, you'll have to communicate this in some other way to
Linux. I also had this problem and submitted a patch for it. In the
replies there were some suggestions on how to handle this:

  http://lists.denx.de/pipermail/u-boot/2009-July/055725.html

Unfortunately, there is no standard way of doing this on ARM. Some
people want to introduce PowerPC-style device trees on ARM as well,
where this is handled in a generic way, but that hasn't been done yet
and requires changes on both the Linux-side and U-boot.


So I believe this kind of patches will not be accepted, unfortunately.
If you depend on the behavior, you can obviously keep the patch in your
own tree.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: compiler options cleanup - improve tool chain support

2009-09-07 Thread Simon Kagstrom
On Mon, 7 Sep 2009 01:59:13 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:
  Well, I sent a patch [PATCH, RFC] Make arm926ejs use -march=armv5t to
  avoid problems with EABI, which corrects this for me, although I'd
  like some input on if it really makes any sense.

 I have tested this with Sheevaplug, this patch even works well for me too.
 The Kirkwood specification says that the core is armv5te compliant
 But this change is global, applicable for all arm926ejs based SoC which isn't 
 relevant too.
 Do anybody have similar test results with other processors?
 
 Since this is very specific NAND
 How about looking into NAND code?

I did look at it, and indeed some of the ldrd/strd's are in the NAND
code. I can't really see anything obviously wrong with the generated
code.

However, it's not NAND-specific. Depending on GCC version, I get issues
with vsprintf or complete lockups as well.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] U-boot environment on Sheevaplug

2009-09-04 Thread Simon Kagstrom
On Thu, 3 Sep 2009 23:20:02 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

  I just wanted to check if there has been any progress on the issue
  below (4-bit ECC support to read for the kernel / U-boot) during the
  summer.
 
 I am restarting work on this issue for u-boot,
 Does anybody have any suggestions? Those are welcomed..

Good to hear!

I guess a starting point could be Nicolas patch for this to OpenOCD:

  http://lists.berlios.de/pipermail/openocd-development/2009-May/006413.html

and/or the Reed-Solomon library in the Linux kernel,
lib/reed_solomon/{reed_solomon.c, decode_rs.c, encode_rs.c} (I guess
this will be needed to perform error correction and decoding as well).

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)

2009-09-04 Thread Simon Kagstrom
Hi Prafulla!

I see the complications and understand that it might be difficult to
get it running.

On Thu, 3 Sep 2009 07:15:48 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

  I think it could also be useful to be able to produce just the boot
  header without the U-boot image. For example if you want to place
  U-boot at some other location on the flash or (as a developer)
  frequently re-flash U-boot, but don't want to write to the first block
  all the time (you only need to rewrite it when moving U-boot).

 This is not possible.
 Boot Header is a part of Kirkwood boot image,
 Header contains u-boot imagesize so for this, first block need to be written 
 each time.

Understandable. On the other hand, it should be possible to pad the
U-boot image to some specific size to keep the size constant. Typically
to the erase size.

 Secondly u-boot header is of 512bytes only whereas minimum sector size could 
 be 4kbytes (typical),
 so rest part of first sector will be a waste.

I'd be prepared to waste a couple of bytes :-)

 Also at the end of boot image checksum need to be calculated on entire image 
 including header.

This is not how I read the documentation. I thought the 32-bit checksum
is for the image only, not the headers? Anyway, if it does include the
headers, then I see why this would be impossible.


Thanks for the explanation!

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)

2009-09-04 Thread Simon Kagstrom
On Fri, 4 Sep 2009 00:17:57 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

  I see the complications and understand that it might be difficult to
  get it running.

 So we can keep this complex enhancement for future updates, keeping this 
 patch simpler

I agree, let's merge this patch first before thinking of some
enhancements.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)

2009-09-04 Thread Simon Kagstrom
On Fri, 04 Sep 2009 10:24:38 +0200
Wolfgang Denk w...@denx.de wrote:

 Dear Simon Kagstrom,
 
 In message 20090904083003.3f7f0...@marrow.netinsight.se you wrote:
  
  Understandable. On the other hand, it should be possible to pad the
  U-boot image to some specific size to keep the size constant. Typically
  to the erase size.
 
 This makes no sense. Why would such padding be needed? It only adds
 overhead everywhere where the image needs to be processed, stored,
 downloaded, programmed, etc.

In this case to have keep the kirkwood boot header unchanged, and to
just update the U-boot image.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH, RFC] Make arm926ejs use -march=armv5t to avoid problems with EABI

2009-09-04 Thread Simon Kagstrom
Make arm926ejs use -march=armv5t to avoid problems with EABI

Using -march=armv5t instead of armv5te allows Marvell Kirkwood-based
boards to boot with the EABI changes introduced in commit
f772acf8a584067033eff1e231fcd1fb3a00d3d9

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---

This allows me to build with -mabi=aapcs-linux again. I still haven't
found out what exactly causes the issues I had reported here

   http://www.mail-archive.com/u-boot@lists.denx.de/msg20517.html

but with this patch it works fine again. Disassembling the binary, I
see that ldrd/strd instructions are gone (as expected), although I
don't know if that is the issue.

 cpu/arm926ejs/config.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cpu/arm926ejs/config.mk b/cpu/arm926ejs/config.mk
index 90eb3c0..94f1c17 100644
--- a/cpu/arm926ejs/config.mk
+++ b/cpu/arm926ejs/config.mk
@@ -24,7 +24,7 @@
 PLATFORM_RELFLAGS += -fno-strict-aliasing  -fno-common -ffixed-r8 \
-msoft-float
 
-PLATFORM_CPPFLAGS += -march=armv5te
+PLATFORM_CPPFLAGS += -march=armv5t
 # =
 #
 # Supply options according to compiler version
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)

2009-09-04 Thread Simon Kagstrom
On Fri, 04 Sep 2009 12:57:57 +0200
Wolfgang Denk w...@denx.de wrote:

 Dear Simon Kagstrom,
 
 In message 20090904103602.7a0ec...@marrow.netinsight.se you wrote:
  
Understandable. On the other hand, it should be possible to pad the
U-boot image to some specific size to keep the size constant. Typically
to the erase size.
   
   This makes no sense. Why would such padding be needed? It only adds
   overhead everywhere where the image needs to be processed, stored,
   downloaded, programmed, etc.
  
  In this case to have keep the kirkwood boot header unchanged, and to
  just update the U-boot image.
 
 Doesn't the header contain checksums and such? And what would that
 save you?  Building the image with header is supposed to be a very
 cheap operation.

I believe the checksums are for the header and the header extension -
the image itself contains a checksum in the last 4 bytes.

The idea was to avoid having to rewrite the same block all the time.
Anyway, Prafulla has explained why it's difficult (or maybe impossible)
to use this method, so I think we can safely drop this subject for now.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)

2009-09-03 Thread Simon Kagstrom
On Mon, 24 Aug 2009 23:03:59 +0530
Prafulla Wadaskar prafu...@marvell.com wrote:

 This patch adds type kwbimabe support for new mkimage core
 For more details refer docs/README.kwbimage

 +Command syntax:
 +--
 +./tools/mkimage -l kwboot_file
 + to list the kwb image file details
 +
 +./tools/mkimage -n board specific configuration file \
 +-T kwbimage -a start address -e execution address \
 + -d input_raw_binary output_kwboot_file
 +
 +for ex.
 +./tools/mkimage -n ./board/Marvell/openrd_base/kwbimage.cfg \
 +-T kwbimage -a 0x0060 -e 0x0060 \
 + -d u-boot.bin u-boot.kwb

I think it could also be useful to be able to produce just the boot
header without the U-boot image. For example if you want to place
U-boot at some other location on the flash or (as a developer)
frequently re-flash U-boot, but don't want to write to the first block
all the time (you only need to rewrite it when moving U-boot).

Perhaps something like

 +Typical example of kwimage.cfg file:
 +---
 +
 +# Boot Media configurations
 +BOOT_FROMnand
 +NAND_ECC_MODEdefault
 +NAND_PAGE_SIZE   0x0800

SOURCE_OFFSET 0x0   # Relative to the header or NAND start?

 +static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
 + struct mkimage_params *params)
 +{
 + struct kwb_header *hdr = (struct kwb_header *)ptr;
 [...]
 + mhdr-srcaddr = sizeof(struct kwb_header);

and this could then be changed to have this info.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: compiler options cleanup - improve tool chain support

2009-08-25 Thread Simon Kagstrom
On Mon, 24 Aug 2009 12:01:54 +0200
Wolfgang Denk w...@denx.de wrote:

 Dear Simon Kagstrom,
 
 In message 20090824105935.038bd...@marrow.netinsight.se you wrote:
  
  I updated my git tree today and got this patch (among other things). It
  does not work very well for me, unfortunately. I've tried three
  toolchains (4.3.3, 4.3.4, 4.4.1) built with crosstool-ng, and all of
  them build an image which doesn't run correct.
 
 Hm... aren't there known issues with these compiler versions on ARM?

Small update: I've tried with the ELDK toolchains 4.1 and 4.2
(2007-01-21 and 2008-11-24). Both these fail as well, albeit in a
slightly different way. The printfs are correct, but 4.2 still has the
nand_bbt issue:

  U-Boot 2009.08-rc3-00013-g853ae64 (Aug 25 2009 - 08:28:05)
  Marvell-OpenRD_base

  SoC:   Kirkwood 88F6281_A0
  DRAM:  512 MB
  NAND:  512 MiB
  nand_bbt: Can't scan flash and build the RAM-based BBT
  Net:   egiga0
  88E1116 Initialized on egiga0
  Hit any key to stop autoboot:  0 
  Marvell 

The 4.1 version just hangs on the NAND printout. I've tested both with
USE_PRIVATE_LIBGCC=yes and USE_PRIVATE_LIBGCC unset, and get the same
results.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] U-boot environment on Sheevaplug

2009-08-25 Thread Simon Kagstrom
Hi again!

I just wanted to check if there has been any progress on the issue
below (4-bit ECC support to read for the kernel / U-boot) during the
summer.

On Wed, 8 Jul 2009 15:59:27 +0200
Simon Kagstrom simon.kagst...@netinsight.net wrote:

 Hi Prafulla (and the list)!
 
 I'm wondering a bit how Sheevaplug handles the U-boot environment area.
 On OpenRD base it's stored on the NAND flash, and is protected by a
 4-bit ECC as required when read by the boot prom - it just goes
 together with the rest of the u-boot image.
 
 The Marvell-supplied 1.1.4 version has code to handle this (basically
 switches to Reed-Solomon when reading/saving the environment), but it
 doesn't work with upstream U-boot. If I disable ECC altogether (in
 kirkwood_nand.c) I can read the environment, but since U-boot doesn't
 use Reed-Solomon, the soft ECC option doesn't cut it.
 
 
 Is the situation the same with sheevaplug? I see there are patches for
 OpenOCD to handle the same thing there,
 
   http://lists.berlios.de/pipermail/openocd-development/2009-May/006413.html
 
 so perhaps something similar is bound for U-boot as well?

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 0/4]: bitops cleanup and fixes

2009-08-24 Thread Simon Kagstrom
Hi yet again!

This update to the patch series just cleans up the commit messages to
have the comments in the git comments section.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 3/4]: Define ffs/fls for all architectures

2009-08-24 Thread Simon Kagstrom
Define ffs/fls for all architectures

UBIFS requires fls(), which is not defined for arm (and some other
architectures) and this patch adds it. The implementation is taken from
Linux and is generic. ffs() is also defined for those that miss it.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:
v2: Unify code style (empty line between ffs/fls)
v3: Move the definition to generic code (Mike Frysinger)

 include/asm-i386/bitops.h  |1 +
 include/asm-m68k/bitops.h  |1 +
 include/asm-nios/bitops.h  |1 +
 include/asm-nios2/bitops.h |1 +
 include/asm-ppc/bitops.h   |2 +
 include/asm-sh/bitops.h|2 +
 include/linux/bitops.h |   45 
 7 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index b768e20..ac6285a 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -349,6 +349,7 @@ static __inline__ int ffs(int x)
1: : =r (r) : g (x));
return r+1;
 }
+#define ffs
 
 /**
  * hweightN - returns the hamming weight of a N-bit word
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index 0f9e8ab..e0c35fa 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -51,6 +51,7 @@ extern __inline__ int ffs(int x)
return r;
 }
 #define __ffs(x) (ffs(x) - 1)
+#define ffs
 
 #endif /* __KERNEL__ */
 
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h
index 7744212..8315fb7 100644
--- a/include/asm-nios/bitops.h
+++ b/include/asm-nios/bitops.h
@@ -33,5 +33,6 @@ extern int test_and_set_bit(int nr, volatile void * a);
 extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
 extern int ffs(int i);
+#define ffs
 
 #endif /* _ASM_NIOS_BITOPS_H */
diff --git a/include/asm-nios2/bitops.h b/include/asm-nios2/bitops.h
index e6c1a85..b01a89d 100644
--- a/include/asm-nios2/bitops.h
+++ b/include/asm-nios2/bitops.h
@@ -33,5 +33,6 @@ extern int test_and_set_bit(int nr, volatile void * a);
 extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
 extern int ffs(int i);
+#define ffs
 
 #endif /* __ASM_NIOS2_BITOPS_H */
diff --git a/include/asm-ppc/bitops.h b/include/asm-ppc/bitops.h
index daa66cf..9ed2f5d 100644
--- a/include/asm-ppc/bitops.h
+++ b/include/asm-ppc/bitops.h
@@ -178,6 +178,7 @@ static __inline__ int fls(unsigned int x)
 {
return __ilog2(x) + 1;
 }
+#define fls
 
 /**
  * fls64 - find last set bit in a 64-bit word
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
return __ilog2(x  -x) + 1;
 }
+#define ffs
 
 /*
  * hweightN: returns the hamming weight (i.e. the number
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
index 410fba4..95167bd 100644
--- a/include/asm-sh/bitops.h
+++ b/include/asm-sh/bitops.h
@@ -146,6 +146,8 @@ static inline int ffs (int x)
}
return r;
 }
+#define ffs
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_SH_BITOPS_H */
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 387a818..e14e6c7 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -38,6 +38,43 @@ static inline int generic_ffs(int x)
return r;
 }
 
+/**
+ * fls - find last (most-significant) bit set
+ * @x: the word to search
+ *
+ * This is defined the same way as ffs.
+ * Note fls(0) = 0, fls(1) = 1, fls(0x8000) = 32.
+ */
+static inline int generic_fls(int x)
+{
+   int r = 32;
+
+   if (!x)
+   return 0;
+   if (!(x  0xu)) {
+   x = 16;
+   r -= 16;
+   }
+   if (!(x  0xff00u)) {
+   x = 8;
+   r -= 8;
+   }
+   if (!(x  0xf000u)) {
+   x = 4;
+   r -= 4;
+   }
+   if (!(x  0xc000u)) {
+   x = 2;
+   r -= 2;
+   }
+   if (!(x  0x8000u)) {
+   x = 1;
+   r -= 1;
+   }
+   return r;
+}
+
+
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
@@ -82,6 +119,14 @@ static inline unsigned int generic_hweight8(unsigned int w)
 # define __clear_bit generic_clear_bit
 #endif
 
+#ifndef ffs
+# define ffs generic_ffs
+#endif
+
+#ifndef fls
+# define fls generic_fls
+#endif
+
 /**
  * __set_bit - Set a bit in memory
  * @nr: the bit to set
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/4]: Move __set/clear_bit from ubifs.h to bitops.h

2009-08-24 Thread Simon Kagstrom
Move __set/clear_bit from ubifs.h to bitops.h

__set_bit and __clear_bit are defined in ubifs.h as well as in
asm/include/bitops.h for some architectures. This patch moves
the generic implementation to include/linux/bitops.h and uses
that unless it's defined by the architecture.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:
v2: Unify code style (newline between __set_bit and __clear_bit)
v3: Move BIT_MASK and BIT_WORD above the include of asm/bitops.h
v4: Move the definition to generic code (Mike Frysinger)

 fs/ubifs/ubifs.h|   32 
 include/asm-arm/bitops.h|2 ++
 include/asm-blackfin/bitops.h   |1 +
 include/asm-microblaze/bitops.h |1 +
 include/asm-mips/bitops.h   |1 +
 include/linux/bitops.h  |   38 ++
 6 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 43865aa..06772af 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -449,38 +449,6 @@ static inline ino_t parent_ino(struct dentry *dentry)
return res;
 }
 
-/* linux/include/linux/bitops.h */
-
-#define BIT_MASK(nr)   (1UL  ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr)   ((nr) / BITS_PER_LONG)
-
-/* linux/include/asm-generic/bitops/non-atomic.h */
-
-/**
- * __set_bit - Set a bit in memory
- * @nr: the bit to set
- * @addr: the address to start counting from
- *
- * Unlike set_bit(), this function is non-atomic and may be reordered.
- * If it's called on the same region of memory simultaneously, the effect
- * may be that only one operation succeeds.
- */
-static inline void __set_bit(int nr, volatile unsigned long *addr)
-{
-   unsigned long mask = BIT_MASK(nr);
-   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
-
-   *p  |= mask;
-}
-
-static inline void __clear_bit(int nr, volatile unsigned long *addr)
-{
-   unsigned long mask = BIT_MASK(nr);
-   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
-
-   *p = ~mask;
-}
-
 /* debug.c */
 
 #define DEFINE_SPINLOCK(...)
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 4b8bab2..1549da1 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -29,6 +29,7 @@ static inline void __set_bit(int nr, volatile void *addr)
 {
((unsigned char *) addr)[nr  3] |= (1U  (nr  7));
 }
+#define __set_bit
 
 extern void clear_bit(int nr, volatile void * addr);
 
@@ -36,6 +37,7 @@ static inline void __clear_bit(int nr, volatile void *addr)
 {
((unsigned char *) addr)[nr  3] = ~(1U  (nr  7));
 }
+#define __clear_bit
 
 extern void change_bit(int nr, volatile void * addr);
 
diff --git a/include/asm-blackfin/bitops.h b/include/asm-blackfin/bitops.h
index 2e55b6a..cc3685d 100644
--- a/include/asm-blackfin/bitops.h
+++ b/include/asm-blackfin/bitops.h
@@ -79,6 +79,7 @@ static __inline__ void __set_bit(int nr, volatile void *addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
+#define __set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
diff --git a/include/asm-microblaze/bitops.h b/include/asm-microblaze/bitops.h
index 04ea020..aac9061 100644
--- a/include/asm-microblaze/bitops.h
+++ b/include/asm-microblaze/bitops.h
@@ -75,6 +75,7 @@ extern __inline__ void __set_bit(int nr, volatile void * addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
+#define __set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 659ac9d..0c07b68 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -90,6 +90,7 @@ static __inline__ void __set_bit(int nr, volatile void * addr)
 
*m |= 1UL  (nr  31);
 }
+#define __set_bit
 
 /*
  * clear_bit - Clears a bit in memory
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 7d41ae6..387a818 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
 
+#include asm/types.h
 
 /*
  * ffs: find first bit set. This is defined the same way as
@@ -66,7 +67,44 @@ static inline unsigned int generic_hweight8(unsigned int w)
return (res  0x0F) + ((res  4)  0x0F);
 }
 
+#define BIT_MASK(nr)   (1UL  ((nr) % BITS_PER_LONG))
+#define BIT_WORD(nr)   ((nr) / BITS_PER_LONG)
+
 #include asm/bitops.h
 
+/* linux/include/asm-generic/bitops/non-atomic.h */
+
+#ifndef __set_bit
+# define __set_bit generic_set_bit
+#endif
+
+#ifndef __clear_bit
+# define __clear_bit generic_clear_bit
+#endif
+
+/**
+ * __set_bit - Set a bit in memory
+ * @nr: the bit to set
+ * @addr: the address to start counting from
+ *
+ * Unlike set_bit(), this function is non-atomic and may be reordered.
+ * If it's called on the same region of memory simultaneously, the effect
+ * may be that only one operation succeeds.
+ */
+static inline void

[U-Boot] [PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

2009-08-24 Thread Simon Kagstrom
arm: Define test_and_set_bit and test_and_clear bit for ARM

Needed for (e.g.) ubifs support to work.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 include/asm-arm/bitops.h |   28 +---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 854e225..3c7b00c 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -17,6 +17,8 @@
 
 #ifdef __KERNEL__
 
+#include asm/proc/system.h
+
 #define smp_mb__before_clear_bit() do { } while (0)
 #define smp_mb__after_clear_bit()  do { } while (0)
 
@@ -37,8 +39,6 @@ static inline void __change_bit(int nr, volatile void *addr)
*p ^= mask;
 }
 
-extern int test_and_set_bit(int nr, volatile void * addr);
-
 static inline int __test_and_set_bit(int nr, volatile void *addr)
 {
unsigned long mask = BIT_MASK(nr);
@@ -49,7 +49,17 @@ static inline int __test_and_set_bit(int nr, volatile void 
*addr)
return (old  mask) != 0;
 }
 
-extern int test_and_clear_bit(int nr, volatile void * addr);
+static inline int test_and_set_bit(int nr, volatile void * addr)
+{
+   unsigned long flags;
+   int out;
+
+   local_irq_save(flags);
+   out = __test_and_set_bit(nr, addr);
+   local_irq_restore(flags);
+
+   return out;
+}
 
 static inline int __test_and_clear_bit(int nr, volatile void *addr)
 {
@@ -61,6 +71,18 @@ static inline int __test_and_clear_bit(int nr, volatile void 
*addr)
return (old  mask) != 0;
 }
 
+static inline int test_and_clear_bit(int nr, volatile void * addr)
+{
+   unsigned long flags;
+   int out;
+
+   local_irq_save(flags);
+   out = __test_and_clear_bit(nr, addr);
+   local_irq_restore(flags);
+
+   return out;
+}
+
 extern int test_and_change_bit(int nr, volatile void * addr);
 
 static inline int __test_and_change_bit(int nr, volatile void *addr)
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 2/4]: arm: Make arm bitops endianness-independent

2009-08-24 Thread Simon Kagstrom
arm: Make arm bitops endianness-independent

Bring over the bitop implementations from the Linux
include/asm-generic/bitops/non-atomic.h to provide
endianness-independence.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
ChangeLog:
v2: Use generic __set_bit and __clear_bit for ARM

 include/asm-arm/bitops.h |   47 ++---
 1 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 1549da1..854e225 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -25,61 +25,52 @@
  */
 extern void set_bit(int nr, volatile void * addr);
 
-static inline void __set_bit(int nr, volatile void *addr)
-{
-   ((unsigned char *) addr)[nr  3] |= (1U  (nr  7));
-}
-#define __set_bit
-
 extern void clear_bit(int nr, volatile void * addr);
 
-static inline void __clear_bit(int nr, volatile void *addr)
-{
-   ((unsigned char *) addr)[nr  3] = ~(1U  (nr  7));
-}
-#define __clear_bit
-
 extern void change_bit(int nr, volatile void * addr);
 
 static inline void __change_bit(int nr, volatile void *addr)
 {
-   ((unsigned char *) addr)[nr  3] ^= (1U  (nr  7));
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p ^= mask;
 }
 
 extern int test_and_set_bit(int nr, volatile void * addr);
 
 static inline int __test_and_set_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval | mask;
-   return oldval  mask;
+   *p = old | mask;
+   return (old  mask) != 0;
 }
 
 extern int test_and_clear_bit(int nr, volatile void * addr);
 
 static inline int __test_and_clear_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval  ~mask;
-   return oldval  mask;
+   *p = old  ~mask;
+   return (old  mask) != 0;
 }
 
 extern int test_and_change_bit(int nr, volatile void * addr);
 
 static inline int __test_and_change_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval ^ mask;
-   return oldval  mask;
+   *p = old ^ mask;
+   return (old  mask) != 0;
 }
 
 extern int find_first_zero_bit(void * addr, unsigned size);
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: compiler options cleanup - improve tool chain support

2009-08-24 Thread Simon Kagstrom
Hi,

On Fri, 21 Aug 2009 23:12:45 +0200
Wolfgang Denk w...@denx.de wrote:

 For some time there have been repeated reports about build problems
 with some ARM (cross) tool chains.  Especially issues about
 (in)compatibility with the tool chain provided runtime support
 library libgcc.a caused to add and support a private implementation
 of such runtime support code in U-Boot.  A closer look at the code
 indicated that some of these issues are actually home-made.  This
 patch attempts to clean up some of the most obvious problems and make
 building of U-Boot with different tool chains easier:

I updated my git tree today and got this patch (among other things). It
does not work very well for me, unfortunately. I've tried three
toolchains (4.3.3, 4.3.4, 4.4.1) built with crosstool-ng, and all of
them build an image which doesn't run correct.

It appears to be 64-bit issue:

  U-Boot 2009.08-rc3-00014-gcea1f2a (Aug 24 2009 - 10:31:57)
  Marvell-OpenRD_base

  SoC:   Kirkwood 88F6281_A0
  DRAM:  27507994220560384 MB
  NAND:  27510416582115328 MiB
  nand_bbt: Can't scan flash and build the RAM-based BBT
  Net:   egiga0
  88E1116 Initialized on egiga0
  Hit any key to stop autoboot: 6871947673 0 
  Marvell 
  Marvell 
  Marvell 

(I have 64-bit vsnprintf, and DRAM/NAND is reported correct without
it). If I change PLATFORM_CPPFLAGS in lib_arm/config.mk to use
apcs-linux instead of aapcs-linux it works again.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: compiler options cleanup - improve tool chain support

2009-08-24 Thread Simon Kagstrom
On Mon, 24 Aug 2009 12:01:54 +0200
Wolfgang Denk w...@denx.de wrote:

  I updated my git tree today and got this patch (among other things). It
  does not work very well for me, unfortunately. I've tried three
  toolchains (4.3.3, 4.3.4, 4.4.1) built with crosstool-ng, and all of
  them build an image which doesn't run correct.
 
 Hm... aren't there known issues with these compiler versions on ARM?

I don't know, not that I've heard of at least, but perhaps someone else
knows of something?

  It appears to be 64-bit issue:
  
U-Boot 2009.08-rc3-00014-gcea1f2a (Aug 24 2009 - 10:31:57)
Marvell-OpenRD_base
  
SoC:   Kirkwood 88F6281_A0
DRAM:  27507994220560384 MB
NAND:  27510416582115328 MiB
 
 Is this with or without USE_PRIVATE_LIBGCC=yes ?

Yes, I believe so. If compiling with USE_PRIVATE_LIBGCC=no, the linker
can't find libgcc.

 Do you see any compiler warnings?

No.

 And - which board / configuration name is this?

Sorry. As Prafulla said, it's openrd_base. I sent patches from this
some time back,

  http://lists.denx.de/pipermail/u-boot/2009-July/055374.html

I'll send an updated version of the patch, but it can't go in until
mach-types.h has been updated at least. It's very similar to sheevaplug
though, but uses 64-bit vsnprintf since it needs UBIFS support. I guess
the nand_bbt problem is a similar issue.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: compiler options cleanup - improve tool chain support

2009-08-24 Thread Simon Kagstrom
On Mon, 24 Aug 2009 14:01:20 +0200
Wolfgang Denk w...@denx.de wrote:

 Please re-run the tests with
 
   $ USE_PRIVATE_LIBGCC=yes
   $ export USE_PRIVATE_LIBGCC
   $ make mrproper
   $ make ..._config
   $ make all
 
 and with
 
   $ unset USE_PRIVATE_LIBGCC
   $ make mrproper
   $ make ..._config
   $ make all

Same result both ways.

  I'll send an updated version of the patch, but it can't go in until
  mach-types.h has been updated at least. It's very similar to sheevaplug
  though, but uses 64-bit vsnprintf since it needs UBIFS support. I guess
  the nand_bbt problem is a similar issue.
 
 Again, guesses are simply not good enough to spend any efforts. We
 need clear, reliable facts.

Well, since I can't say what's causing the problem, it's a guess.

The hard facts are that the printf issue goes away if I compile without
CONFIG_SYS_64BIT_VSPRINTF, but the nand_bbt problem is always there.
I've tried looking at the disassembled source code, in particular of
the number() function and the calls of it in vsprintf.c, but I can't
easily spot where it goes wrong.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: compiler options cleanup - improve tool chain support

2009-08-24 Thread Simon Kagstrom
On Mon, 24 Aug 2009 05:41:59 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

 I get following erro only if I execute following build command
 make mrproper; make sheevaplug_config; make USE_PRIVATE_LIBGCC=no
 CROSS_COMPILE=armv5tel-redhat-linux-gnueabi- 2 warn.txt
 
 And cat warn.txt 
 armv5tel-redhat-linux-gnueabi-ld: cannot find -lgcc
 make: *** [u-boot] Error 1
 
 Whereas,
 if I unset first USE_PRIVATE_LIBGCC then I do not get this error and build is 
 through
 My invocation may be wrong but shouldn't it treat USE_PRIVATE_LIBGCC=no as 
 unset?

Well, I also got confused by this, but went through Wolfgangs exercise
program. The top-level Makefile treats USE_PRIVATE_LIBGCC like this:

   # Add GCC lib
   ifdef USE_PRIVATE_LIBGCC
   ifeq ($(USE_PRIVATE_LIBGCC), yes)
   PLATFORM_LIBGCC = -L $(OBJTREE)/lib_$(ARCH) -lgcc
   else
   PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
   endif
   else
   PLATFORM_LIBGCC = -L $(shell dirname `$(CC) $(CFLAGS) 
-print-libgcc-file-name`) -lgcc
   endif
   PLATFORM_LIBS += $(PLATFORM_LIBGCC)
   export PLATFORM_LIBS

and in this case, since USE_PRIVATE_LIBGCC is defined, but is not
yes, we will use it to set the linker search path. And indeed, it
tries to link with

   arm-unknown-linux-gnu-ld -Bstatic -T u-boot.lds [...] -L no -lgcc -Map 
u-boot.map -o u-boot

which ... will fail.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/4]: Move __set/clear_bit from ubifs.h to bitops.h

2009-08-21 Thread Simon Kagstrom
On Thu, 20 Aug 2009 13:44:35 -0400
Mike Frysinger vap...@gentoo.org wrote:

 On Thursday 20 August 2009 04:52:50 Simon Kagstrom wrote:
  --- a/include/asm-sh/bitops.h
  +++ b/include/asm-sh/bitops.h
  @@ -146,6 +146,11 @@ static inline int ffs (int x)
  }
  return r;
   }
  +
  +#define __set_bit(nr, addr) generic_set_bit(nr, addr)
  +
  +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
 
 this is just silly to put into every arch header.  why not do in the common 
 code:
 #ifndef __set_bit
 # define __set_bit generice_set_bit
 #endif

It's a function (static inline) in some architectures.

// Simon

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/4]: Move __set/clear_bit from ubifs.h to bitops.h

2009-08-21 Thread Simon Kagstrom
On Fri, 21 Aug 2009 02:29:30 -0400
Mike Frysinger vap...@gentoo.org wrote:

   this is just silly to put into every arch header.  why not do in the
   common code:
   #ifndef __set_bit
   # define __set_bit generice_set_bit
   #endif
 
  It's a function (static inline) in some architectures.
 
 add the obvious #define i already posted in a later e-mail.  it makes a lot 
 more sense for the non-common behavior of providing a custom implementation 
 to 
 add one more line per func than to try and update (and keep up-to-date) every 
 arch using the common code.

Yep, I saw your mail too late. I'll rework the patch series and resubmit.

// Simon

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 0/4]: bitops cleanup and fixes

2009-08-21 Thread Simon Kagstrom
Hi yet again!

This patch series is an update to [PATCH 0/4]: bitops cleanup and fixes:

  http://article.gmane.org/gmane.comp.boot-loaders.u-boot/66184

and contains the patches which were not accepted. The patches are:

  0001-Move-__set-clear_bit-from-ubifs.h-to-bitops.h.patch
- Code style updates. I chose to not create
  asm-generic/include/bitops/ (Jean-Christophes comment) since I
  feel that should go together with a larger restructuring.
- Updated to put BIT_MASK above the include of asm/bitops.h
- More generic code (comment from Mike Frysinger)

  0002-Make-arm-bitops-endianness-independent.patch
- New patch which takes on the endianeess issue in arm bitops

  0003-Define-ffs-fls-for-all-architectures.patch
- Code style updates (Wolfgangs comment).
- More generic code (comment from Mike Frysinger)

  0004-Define-test_and_set_bit-and-test_and_clear-bit-for-A.patch
- Defines test_and_set_bit etc for ARM. Uses the non-atomic
  __test_and_set_bit.

remove-dupliace-cr.patch was accepted into the u-boot-arm tree, so I'm
not reposting it.


Tested on ARM (OpenRD base), and compile tested on PowerPC.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 1/4]: Move __set/clear_bit from ubifs.h to bitops.h

2009-08-21 Thread Simon Kagstrom
Move __set/clear_bit from ubifs.h to bitops.h

__set_bit and __clear_bit are defined in ubifs.h as well as in
asm/include/bitops.h for some architectures. This patch moves
the generic implementation to include/linux/bitops.h and uses
that unless it's defined by the architecture.

v2: Unify code style (newline between __set_bit and __clear_bit)
v3: Move BIT_MASK and BIT_WORD above the include of asm/bitops.h
v4: Move the definition to generic code (Mike Frysinger)

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 fs/ubifs/ubifs.h|   32 
 include/asm-arm/bitops.h|2 ++
 include/asm-blackfin/bitops.h   |1 +
 include/asm-microblaze/bitops.h |1 +
 include/asm-mips/bitops.h   |1 +
 include/linux/bitops.h  |   38 ++
 6 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 43865aa..06772af 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -449,38 +449,6 @@ static inline ino_t parent_ino(struct dentry *dentry)
return res;
 }
 
-/* linux/include/linux/bitops.h */
-
-#define BIT_MASK(nr)   (1UL  ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr)   ((nr) / BITS_PER_LONG)
-
-/* linux/include/asm-generic/bitops/non-atomic.h */
-
-/**
- * __set_bit - Set a bit in memory
- * @nr: the bit to set
- * @addr: the address to start counting from
- *
- * Unlike set_bit(), this function is non-atomic and may be reordered.
- * If it's called on the same region of memory simultaneously, the effect
- * may be that only one operation succeeds.
- */
-static inline void __set_bit(int nr, volatile unsigned long *addr)
-{
-   unsigned long mask = BIT_MASK(nr);
-   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
-
-   *p  |= mask;
-}
-
-static inline void __clear_bit(int nr, volatile unsigned long *addr)
-{
-   unsigned long mask = BIT_MASK(nr);
-   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
-
-   *p = ~mask;
-}
-
 /* debug.c */
 
 #define DEFINE_SPINLOCK(...)
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 4b8bab2..1549da1 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -29,6 +29,7 @@ static inline void __set_bit(int nr, volatile void *addr)
 {
((unsigned char *) addr)[nr  3] |= (1U  (nr  7));
 }
+#define __set_bit
 
 extern void clear_bit(int nr, volatile void * addr);
 
@@ -36,6 +37,7 @@ static inline void __clear_bit(int nr, volatile void *addr)
 {
((unsigned char *) addr)[nr  3] = ~(1U  (nr  7));
 }
+#define __clear_bit
 
 extern void change_bit(int nr, volatile void * addr);
 
diff --git a/include/asm-blackfin/bitops.h b/include/asm-blackfin/bitops.h
index 2e55b6a..cc3685d 100644
--- a/include/asm-blackfin/bitops.h
+++ b/include/asm-blackfin/bitops.h
@@ -79,6 +79,7 @@ static __inline__ void __set_bit(int nr, volatile void *addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
+#define __set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
diff --git a/include/asm-microblaze/bitops.h b/include/asm-microblaze/bitops.h
index 04ea020..aac9061 100644
--- a/include/asm-microblaze/bitops.h
+++ b/include/asm-microblaze/bitops.h
@@ -75,6 +75,7 @@ extern __inline__ void __set_bit(int nr, volatile void * addr)
mask = 1  (nr  0x1f);
*a |= mask;
 }
+#define __set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 659ac9d..0c07b68 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -90,6 +90,7 @@ static __inline__ void __set_bit(int nr, volatile void * addr)
 
*m |= 1UL  (nr  31);
 }
+#define __set_bit
 
 /*
  * clear_bit - Clears a bit in memory
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 7d41ae6..387a818 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
 
+#include asm/types.h
 
 /*
  * ffs: find first bit set. This is defined the same way as
@@ -66,7 +67,44 @@ static inline unsigned int generic_hweight8(unsigned int w)
return (res  0x0F) + ((res  4)  0x0F);
 }
 
+#define BIT_MASK(nr)   (1UL  ((nr) % BITS_PER_LONG))
+#define BIT_WORD(nr)   ((nr) / BITS_PER_LONG)
+
 #include asm/bitops.h
 
+/* linux/include/asm-generic/bitops/non-atomic.h */
+
+#ifndef __set_bit
+# define __set_bit generic_set_bit
+#endif
+
+#ifndef __clear_bit
+# define __clear_bit generic_clear_bit
+#endif
+
+/**
+ * __set_bit - Set a bit in memory
+ * @nr: the bit to set
+ * @addr: the address to start counting from
+ *
+ * Unlike set_bit(), this function is non-atomic and may be reordered.
+ * If it's called on the same region of memory simultaneously, the effect
+ * may be that only one operation succeeds.
+ */
+static inline void generic_set_bit(int nr, volatile

[U-Boot] [PATCH v3 2/4]: arm: Make arm bitops endianness-independent

2009-08-21 Thread Simon Kagstrom
arm: Make arm bitops endianness-independent

Bring over the bitop implementations from the Linux
include/asm-generic/bitops/non-atomic.h to provide
endianness-independence.

v2: Use generic __set_bit and __clear_bit for ARM

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 include/asm-arm/bitops.h |   47 ++---
 1 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 1549da1..854e225 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -25,61 +25,52 @@
  */
 extern void set_bit(int nr, volatile void * addr);
 
-static inline void __set_bit(int nr, volatile void *addr)
-{
-   ((unsigned char *) addr)[nr  3] |= (1U  (nr  7));
-}
-#define __set_bit
-
 extern void clear_bit(int nr, volatile void * addr);
 
-static inline void __clear_bit(int nr, volatile void *addr)
-{
-   ((unsigned char *) addr)[nr  3] = ~(1U  (nr  7));
-}
-#define __clear_bit
-
 extern void change_bit(int nr, volatile void * addr);
 
 static inline void __change_bit(int nr, volatile void *addr)
 {
-   ((unsigned char *) addr)[nr  3] ^= (1U  (nr  7));
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p ^= mask;
 }
 
 extern int test_and_set_bit(int nr, volatile void * addr);
 
 static inline int __test_and_set_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval | mask;
-   return oldval  mask;
+   *p = old | mask;
+   return (old  mask) != 0;
 }
 
 extern int test_and_clear_bit(int nr, volatile void * addr);
 
 static inline int __test_and_clear_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval  ~mask;
-   return oldval  mask;
+   *p = old  ~mask;
+   return (old  mask) != 0;
 }
 
 extern int test_and_change_bit(int nr, volatile void * addr);
 
 static inline int __test_and_change_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval ^ mask;
-   return oldval  mask;
+   *p = old ^ mask;
+   return (old  mask) != 0;
 }
 
 extern int find_first_zero_bit(void * addr, unsigned size);
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/4]: Define ffs/fls for all architectures

2009-08-21 Thread Simon Kagstrom
arm: Define ffs/fls for all architectures

UBIFS requires fls(), which is not defined for arm (and some other
architectures) and this patch adds it. The implementation is taken from
Linux and is generic. ffs() is also defined for those that miss it.

v2: Unify code style (empty line between ffs/fls)
v3: Move the definition to generic code (Mike Frysinger)

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 include/asm-i386/bitops.h  |1 +
 include/asm-m68k/bitops.h  |1 +
 include/asm-nios/bitops.h  |1 +
 include/asm-nios2/bitops.h |1 +
 include/asm-ppc/bitops.h   |2 +
 include/asm-sh/bitops.h|2 +
 include/linux/bitops.h |   45 
 7 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index b768e20..ac6285a 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -349,6 +349,7 @@ static __inline__ int ffs(int x)
1: : =r (r) : g (x));
return r+1;
 }
+#define ffs
 
 /**
  * hweightN - returns the hamming weight of a N-bit word
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index 0f9e8ab..e0c35fa 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -51,6 +51,7 @@ extern __inline__ int ffs(int x)
return r;
 }
 #define __ffs(x) (ffs(x) - 1)
+#define ffs
 
 #endif /* __KERNEL__ */
 
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h
index 7744212..8315fb7 100644
--- a/include/asm-nios/bitops.h
+++ b/include/asm-nios/bitops.h
@@ -33,5 +33,6 @@ extern int test_and_set_bit(int nr, volatile void * a);
 extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
 extern int ffs(int i);
+#define ffs
 
 #endif /* _ASM_NIOS_BITOPS_H */
diff --git a/include/asm-nios2/bitops.h b/include/asm-nios2/bitops.h
index e6c1a85..b01a89d 100644
--- a/include/asm-nios2/bitops.h
+++ b/include/asm-nios2/bitops.h
@@ -33,5 +33,6 @@ extern int test_and_set_bit(int nr, volatile void * a);
 extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
 extern int ffs(int i);
+#define ffs
 
 #endif /* __ASM_NIOS2_BITOPS_H */
diff --git a/include/asm-ppc/bitops.h b/include/asm-ppc/bitops.h
index daa66cf..9ed2f5d 100644
--- a/include/asm-ppc/bitops.h
+++ b/include/asm-ppc/bitops.h
@@ -178,6 +178,7 @@ static __inline__ int fls(unsigned int x)
 {
return __ilog2(x) + 1;
 }
+#define fls
 
 /**
  * fls64 - find last set bit in a 64-bit word
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
return __ilog2(x  -x) + 1;
 }
+#define ffs
 
 /*
  * hweightN: returns the hamming weight (i.e. the number
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
index 410fba4..95167bd 100644
--- a/include/asm-sh/bitops.h
+++ b/include/asm-sh/bitops.h
@@ -146,6 +146,8 @@ static inline int ffs (int x)
}
return r;
 }
+#define ffs
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_SH_BITOPS_H */
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 387a818..e14e6c7 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -38,6 +38,43 @@ static inline int generic_ffs(int x)
return r;
 }
 
+/**
+ * fls - find last (most-significant) bit set
+ * @x: the word to search
+ *
+ * This is defined the same way as ffs.
+ * Note fls(0) = 0, fls(1) = 1, fls(0x8000) = 32.
+ */
+static inline int generic_fls(int x)
+{
+   int r = 32;
+
+   if (!x)
+   return 0;
+   if (!(x  0xu)) {
+   x = 16;
+   r -= 16;
+   }
+   if (!(x  0xff00u)) {
+   x = 8;
+   r -= 8;
+   }
+   if (!(x  0xf000u)) {
+   x = 4;
+   r -= 4;
+   }
+   if (!(x  0xc000u)) {
+   x = 2;
+   r -= 2;
+   }
+   if (!(x  0x8000u)) {
+   x = 1;
+   r -= 1;
+   }
+   return r;
+}
+
+
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
@@ -82,6 +119,14 @@ static inline unsigned int generic_hweight8(unsigned int w)
 # define __clear_bit generic_clear_bit
 #endif
 
+#ifndef ffs
+# define ffs generic_ffs
+#endif
+
+#ifndef fls
+# define fls generic_fls
+#endif
+
 /**
  * __set_bit - Set a bit in memory
  * @nr: the bit to set
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

2009-08-21 Thread Simon Kagstrom
arm: Define test_and_set_bit and test_and_clear bit for ARM

Needed for (e.g.) ubifs support to work.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 include/asm-arm/bitops.h |   28 +---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 854e225..3c7b00c 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -17,6 +17,8 @@
 
 #ifdef __KERNEL__
 
+#include asm/proc/system.h
+
 #define smp_mb__before_clear_bit() do { } while (0)
 #define smp_mb__after_clear_bit()  do { } while (0)
 
@@ -37,8 +39,6 @@ static inline void __change_bit(int nr, volatile void *addr)
*p ^= mask;
 }
 
-extern int test_and_set_bit(int nr, volatile void * addr);
-
 static inline int __test_and_set_bit(int nr, volatile void *addr)
 {
unsigned long mask = BIT_MASK(nr);
@@ -49,7 +49,17 @@ static inline int __test_and_set_bit(int nr, volatile void 
*addr)
return (old  mask) != 0;
 }
 
-extern int test_and_clear_bit(int nr, volatile void * addr);
+static inline int test_and_set_bit(int nr, volatile void * addr)
+{
+   unsigned long flags;
+   int out;
+
+   local_irq_save(flags);
+   out = __test_and_set_bit(nr, addr);
+   local_irq_restore(flags);
+
+   return out;
+}
 
 static inline int __test_and_clear_bit(int nr, volatile void *addr)
 {
@@ -61,6 +71,18 @@ static inline int __test_and_clear_bit(int nr, volatile void 
*addr)
return (old  mask) != 0;
 }
 
+static inline int test_and_clear_bit(int nr, volatile void * addr)
+{
+   unsigned long flags;
+   int out;
+
+   local_irq_save(flags);
+   out = __test_and_clear_bit(nr, addr);
+   local_irq_restore(flags);
+
+   return out;
+}
+
 extern int test_and_change_bit(int nr, volatile void * addr);
 
 static inline int __test_and_change_bit(int nr, volatile void *addr)
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3]: arm:kirkwood Define kirkwood phy address magic number

2009-08-21 Thread Simon Kagstrom
On Thu, 20 Aug 2009 20:20:08 -0700
Prafulla Wadaskar prafu...@marvell.com wrote:

+#define KIRKWOOD_PHY_ADR_REQUEST 0xee
   define this in header file
   
   Basically this is needed in drivers/net/phy/mv88e61xx.c for 
  multi chip support
   in this case we need to define this in include/miiphy.h.
   which conflicts with other phy address definition, that's 
  why not done earlier
   
   It makes more sense to add APIs miiphy_read/write_phyadr to miiutils
  
  But is this really general functionality? miiphy.h is something I
  suppose should be generic between phys and not contain device-specific
  things like this.
 Agreed,
 Current PHY support need to be re-architected to support switches in generic 
 ways
 This is old pending issue, may be we should re-trigger it again after 
 scheduled release

Right. But for now, perhaps it's OK to merge the patch as-is and then
correct the location of the define when the restructuring is done?

In the same way, I guess we should postspone moving out PHY
initialization from sheevaplug and keep it duplicated until it's clear
what to do there?

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] net: See to it that sent data is aligned to the ethernet controllers wishes

2009-08-20 Thread Simon Kagstrom
On Wed, 19 Aug 2009 09:55:46 -0700
Ben Warren biggerbadder...@gmail.com wrote:

 My preference is for the drivers to handle alignment.

OK, I'm fine with that. I'd like to withdraw this patch then.

 I like Dave's  idea of creating a buffer (or multiple buffers) in 
 initialization(), 
 then memcpy'ing to to it in the send() routine.  You could make it smart 
 to only memcpy if the frame is not aligned as needed.

It already only memcpys unaligned buffers, but I'll go with Daves
suggestion and allocate it at startup instead.

 Your original patch created a buffer of size 9000, which I commented was 
 probably bigger than necessary.  I didn't see a response to that (which 
 doesn't mean you didn't send one, but I get a lot of e-mail :)

I was off for vacation [*], so I only sent it this week. I'll rework this
patch a bit to address a small bug I found.

Thanks for the comments!
// Simon
[*] By now the U-boot list is probably tired of hearing about my
vacation, but I can assure you that I had a good time!
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4] arm: kirkwood: See to it that sent data is 8-byte aligned

2009-08-20 Thread Simon Kagstrom
U-boot might use non-8-byte-aligned addresses for sending data, which
the kwgbe_send doesn't accept (bootp does this for me). This patch
copies the data to be sent to a malloced temporary buffer if it is
non-aligned.

v2: Malloc send buffer
v3: No need to use jumbo frames, use 1518 bytes buffer instead
v4: Correct alignment passed to memalign (should be 8!),
allocate buffer at initialization(), use PKTSIZE_ALIGN

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 drivers/net/kirkwood_egiga.c |   21 +
 drivers/net/kirkwood_egiga.h |1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
index 9ac9c1f..008c5dd 100644
--- a/drivers/net/kirkwood_egiga.c
+++ b/drivers/net/kirkwood_egiga.c
@@ -494,18 +494,26 @@ static int kwgbe_send(struct eth_device *dev, volatile 
void *dataptr,
struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
struct kwgbe_registers *regs = dkwgbe-regs;
struct kwgbe_txdesc *p_txdesc = dkwgbe-p_txdesc;
+   void *p = (void *)dataptr;
u32 cmd_sts;
 
+   /* Copy buffer if it's misaligned */
if ((u32) dataptr  0x07) {
-   printf(Err..(%s) xmit dataptr not 64bit aligned\n,
-   __FUNCTION__);
-   return -1;
+   if (datasize  PKTSIZE_ALIGN) {
+   printf(Non-aligned data too large (%d)\n,
+   datasize);
+   return -1;
+   }
+
+   memcpy(dkwgbe-p_aligned_txbuf, p, datasize);
+   p = dkwgbe-p_aligned_txbuf;
}
+
p_txdesc-cmd_sts = KWGBE_ZERO_PADDING | KWGBE_GEN_CRC;
p_txdesc-cmd_sts |= KWGBE_TX_FIRST_DESC | KWGBE_TX_LAST_DESC;
p_txdesc-cmd_sts |= KWGBE_BUFFER_OWNED_BY_DMA;
p_txdesc-cmd_sts |= KWGBE_TX_EN_INTERRUPT;
-   p_txdesc-buf_ptr = (u8 *) dataptr;
+   p_txdesc-buf_ptr = (u8 *) p;
p_txdesc-byte_cnt = datasize;
 
/* Apply send command using zeroth RXUQ */
@@ -622,8 +630,13 @@ int kirkwood_egiga_initialize(bd_t * bis)
* PKTSIZE_ALIGN + 1)))
goto error3;
 
+   if (!(dkwgbe-p_aligned_txbuf = memalign(8, PKTSIZE_ALIGN)))
+   goto error4;
+
if (!(dkwgbe-p_txdesc = (struct kwgbe_txdesc *)
  memalign(PKTALIGN, sizeof(struct kwgbe_txdesc) + 1))) {
+   free(dkwgbe-p_aligned_txbuf);
+ error4:
free(dkwgbe-p_rxbuf);
  error3:
free(dkwgbe-p_rxdesc);
diff --git a/drivers/net/kirkwood_egiga.h b/drivers/net/kirkwood_egiga.h
index 9c893d1..16d5214 100644
--- a/drivers/net/kirkwood_egiga.h
+++ b/drivers/net/kirkwood_egiga.h
@@ -499,6 +499,7 @@ struct kwgbe_device {
struct kwgbe_rxdesc *p_rxdesc;
struct kwgbe_rxdesc *p_rxdesc_curr;
u8 *p_rxbuf;
+   u8 *p_aligned_txbuf;
 };
 
 #endif /* __EGIGA_H__ */
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm:kirkwood Wait for the link to come up on kirkwood network init

2009-08-20 Thread Simon Kagstrom
On Wed, 19 Aug 2009 10:08:02 -0700
Ben Warren biggerbadder...@gmail.com wrote:

  -   u16 phyadr;
  -   miiphy_read(dev-name, 0xEE, 0xEE, phyadr);
  -   if (!miiphy_link(dev-name, phyadr)) {
  -   printf(%s: No link on %s\n, __FUNCTION__, dev-name);

 Please use __func__ instead.  It's defined in C99, while __FUNCTION__ 
 isn't (or so I've read)

I'll remove the function name part completely.

  -   return -1;
  +   /* Wait up to 5s for the link status */
  +   for (i = 0; i  5; i++) {
  +   u16 phyadr;

 Please put this variable declaration outside of the 'for' loop
  +   miiphy_read(dev-name, 0xEE, 0xEE, phyadr);

 What does '0xEE' mean?  I know you didn't write it, but magic numbers 
 are bad.

Good question. After looking around a bit, I end up in smi_reg_read in
the same file:

  static int smi_reg_read(char *devname, u8 phy_adr, u8 reg_ofs, u16 * data)
  {
[...]
/* Phyadr read request */
if (phy_adr == 0xEE  reg_ofs == 0xEE) {
/* */
*data = (u16) (KWGBEREG_RD(regs-phyadr)  PHYADR_MASK);
return 0;
[...]
  }

which is registered for the PHY reads with miiphy_register. So it's a
file-local magic number. I'll cook up another patch which adresses this.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/3] [repost]: arm: kirkwood: See to it that sent data is 8-byte aligned

2009-08-20 Thread Simon Kagstrom
U-boot might use non-8-byte-aligned addresses for sending data, which
the kwgbe_send doesn't accept (bootp does this for me). This patch
copies the data to be sent to a malloced temporary buffer if it is
non-aligned.

v2: Malloc send buffer
v3: No need to use jumbo frames, use 1518 bytes buffer instead
v4: Correct alignment passed to memalign (should be 8!),
allocate buffer at initialization(), use PKTSIZE_ALIGN

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 drivers/net/kirkwood_egiga.c |   21 +
 drivers/net/kirkwood_egiga.h |1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
index 9f36633..479035d 100644
--- a/drivers/net/kirkwood_egiga.c
+++ b/drivers/net/kirkwood_egiga.c
@@ -500,18 +500,26 @@ static int kwgbe_send(struct eth_device *dev, volatile 
void *dataptr,
struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
struct kwgbe_registers *regs = dkwgbe-regs;
struct kwgbe_txdesc *p_txdesc = dkwgbe-p_txdesc;
+   void *p = (void *)dataptr;
u32 cmd_sts;
 
+   /* Copy buffer if it's misaligned */
if ((u32) dataptr  0x07) {
-   printf(Err..(%s) xmit dataptr not 64bit aligned\n,
-   __FUNCTION__);
-   return -1;
+   if (datasize  PKTSIZE_ALIGN) {
+   printf(Non-aligned data too large (%d)\n,
+   datasize);
+   return -1;
+   }
+
+   memcpy(dkwgbe-p_aligned_txbuf, p, datasize);
+   p = dkwgbe-p_aligned_txbuf;
}
+
p_txdesc-cmd_sts = KWGBE_ZERO_PADDING | KWGBE_GEN_CRC;
p_txdesc-cmd_sts |= KWGBE_TX_FIRST_DESC | KWGBE_TX_LAST_DESC;
p_txdesc-cmd_sts |= KWGBE_BUFFER_OWNED_BY_DMA;
p_txdesc-cmd_sts |= KWGBE_TX_EN_INTERRUPT;
-   p_txdesc-buf_ptr = (u8 *) dataptr;
+   p_txdesc-buf_ptr = (u8 *) p;
p_txdesc-byte_cnt = datasize;
 
/* Apply send command using zeroth RXUQ */
@@ -628,8 +636,13 @@ int kirkwood_egiga_initialize(bd_t * bis)
* PKTSIZE_ALIGN + 1)))
goto error3;
 
+   if (!(dkwgbe-p_aligned_txbuf = memalign(8, PKTSIZE_ALIGN)))
+   goto error4;
+
if (!(dkwgbe-p_txdesc = (struct kwgbe_txdesc *)
  memalign(PKTALIGN, sizeof(struct kwgbe_txdesc) + 1))) {
+   free(dkwgbe-p_aligned_txbuf);
+ error4:
free(dkwgbe-p_rxbuf);
  error3:
free(dkwgbe-p_rxdesc);
diff --git a/drivers/net/kirkwood_egiga.h b/drivers/net/kirkwood_egiga.h
index 9c893d1..16d5214 100644
--- a/drivers/net/kirkwood_egiga.h
+++ b/drivers/net/kirkwood_egiga.h
@@ -499,6 +499,7 @@ struct kwgbe_device {
struct kwgbe_rxdesc *p_rxdesc;
struct kwgbe_rxdesc *p_rxdesc_curr;
u8 *p_rxbuf;
+   u8 *p_aligned_txbuf;
 };
 
 #endif /* __EGIGA_H__ */
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/3]: Wait for the link to come up on kirkwood network init

2009-08-20 Thread Simon Kagstrom
This patch makes the device wait for up to 5 seconds for the link to
come up, similar to what many of the other network drivers do. This
avoids confusing situations where, e.g., a tftp fails when initiated
early after U-boot has started (before the link has come up).

v2: Remove function name from printout

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 drivers/net/kirkwood_egiga.c |   20 ++--
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
index 065e335..9f36633 100644
--- a/drivers/net/kirkwood_egiga.c
+++ b/drivers/net/kirkwood_egiga.c
@@ -400,6 +400,7 @@ static int kwgbe_init(struct eth_device *dev)
 {
struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
struct kwgbe_registers *regs = dkwgbe-regs;
+   int i;
 
/* setup RX rings */
kwgbe_init_rx_desc_ring(dkwgbe);
@@ -447,13 +448,20 @@ static int kwgbe_init(struct eth_device *dev)
 
 #if (defined (CONFIG_MII) || defined (CONFIG_CMD_MII)) \
  defined (CONFIG_SYS_FAULT_ECHO_LINK_DOWN)
-   u16 phyadr;
-   miiphy_read(dev-name, KIRKWOOD_PHY_ADR_REQUEST,
-   KIRKWOOD_PHY_ADR_REQUEST, phyadr);
-   if (!miiphy_link(dev-name, phyadr)) {
-   printf(%s: No link on %s\n, __FUNCTION__, dev-name);
-   return -1;
+   /* Wait up to 5s for the link status */
+   for (i = 0; i  5; i++) {
+   u16 phyadr;
+
+   miiphy_read(dev-name, KIRKWOOD_PHY_ADR_REQUEST,
+   KIRKWOOD_PHY_ADR_REQUEST, phyadr);
+   /* Return if we get link up */
+   if (miiphy_link(dev-name, phyadr))
+   return 0;
+   udelay(100);
}
+
+   printf(No link on %s\n, dev-name);
+   return -1;
 #endif
return 0;
 }
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/3]: arm:Kirkwood network driver fixes

2009-08-20 Thread Simon Kagstrom
Hi!

Three patches to fix various network driver issues on kirkwood. Patch 3
is a repost of the patch sent earlier today which is rebased on top of
the other two.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/3]: arm:kirkwood Define kirkwood phy address magic number

2009-08-20 Thread Simon Kagstrom
Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 drivers/net/kirkwood_egiga.c |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
index f31fefc..065e335 100644
--- a/drivers/net/kirkwood_egiga.c
+++ b/drivers/net/kirkwood_egiga.c
@@ -38,6 +38,8 @@
 #include asm/arch/kirkwood.h
 #include kirkwood_egiga.h
 
+#define KIRKWOOD_PHY_ADR_REQUEST 0xee
+
 /*
  * smi_reg_read - miiphy_read callback function.
  *
@@ -52,7 +54,8 @@ static int smi_reg_read(char *devname, u8 phy_adr, u8 
reg_ofs, u16 * data)
u32 timeout;
 
/* Phyadr read request */
-   if (phy_adr == 0xEE  reg_ofs == 0xEE) {
+   if (phy_adr == KIRKWOOD_PHY_ADR_REQUEST 
+   reg_ofs == KIRKWOOD_PHY_ADR_REQUEST) {
/* */
*data = (u16) (KWGBEREG_RD(regs-phyadr)  PHYADR_MASK);
return 0;
@@ -127,7 +130,8 @@ static int smi_reg_write(char *devname, u8 phy_adr, u8 
reg_ofs, u16 data)
u32 timeout;
 
/* Phyadr write request*/
-   if (phy_adr == 0xEE  reg_ofs == 0xEE) {
+   if (phy_adr == KIRKWOOD_PHY_ADR_REQUEST 
+   reg_ofs == KIRKWOOD_PHY_ADR_REQUEST) {
KWGBEREG_WR(regs-phyadr, data);
return 0;
}
@@ -444,7 +448,8 @@ static int kwgbe_init(struct eth_device *dev)
 #if (defined (CONFIG_MII) || defined (CONFIG_CMD_MII)) \
  defined (CONFIG_SYS_FAULT_ECHO_LINK_DOWN)
u16 phyadr;
-   miiphy_read(dev-name, 0xEE, 0xEE, phyadr);
+   miiphy_read(dev-name, KIRKWOOD_PHY_ADR_REQUEST,
+   KIRKWOOD_PHY_ADR_REQUEST, phyadr);
if (!miiphy_link(dev-name, phyadr)) {
printf(%s: No link on %s\n, __FUNCTION__, dev-name);
return -1;
@@ -670,7 +675,8 @@ int kirkwood_egiga_initialize(bd_t * bis)
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
miiphy_register(dev-name, smi_reg_read, smi_reg_write);
/* Set phy address of the port */
-   miiphy_write(dev-name, 0xEE, 0xEE, PHY_BASE_ADR + devnum);
+   miiphy_write(dev-name, KIRKWOOD_PHY_ADR_REQUEST,
+   KIRKWOOD_PHY_ADR_REQUEST, PHY_BASE_ADR + 
devnum);
 #endif
}
return 0;
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures

2009-08-20 Thread Simon Kagstrom
On Thu, 20 Aug 2009 01:11:09 +0200
Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com wrote:

 On 11:13 Tue 18 Aug , Simon Kagstrom wrote:
  Define ffs/fls for all architectures
  
  UBIFS requires fls(), which is not defined for arm (and some other
  architectures) and this patch adds it. The implementation is taken from
  Linux and is generic. ffs() is also defined for those that miss it.
  
  v2: Unify code style (empty line between ffs/fls)
 please this
  
  Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
  ---
 here

I didn't add that myself - it's  git format-patch  that put it there.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/4]: bitops cleanup and fixes

2009-08-20 Thread Simon Kagstrom
Hi again!

This patch series is an update to [PATCH 0/4]: bitops cleanup and fixes:

  http://article.gmane.org/gmane.comp.boot-loaders.u-boot/66184

and contains the patches which were not accepted. The patches are:

  0001-Move-__set-clear_bit-from-ubifs.h-to-bitops.h.patch
- Code style updates. I chose to not create
  asm-generic/include/bitops/ (Jean-Christophes comment) since I
  feel that should go together with a larger restructuring.
- Updated to put BIT_MASK above the include of asm/bitops.h

  0002-Make-arm-bitops-endianness-independent.patch
- New patch which takes on the endianeess issue in arm bitops

  0003-Define-ffs-fls-for-all-architectures.patch
- Code style updates (Wolfgangs comment).

  0004-Define-test_and_set_bit-and-test_and_clear-bit-for-A.patch
- Defines test_and_set_bit etc for ARM. Uses the non-atomic
  __test_and_set_bit.

remove-dupliace-cr.patch was accepted into the u-boot-arm tree, so I'm
not reposting it.

// Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/4]: Move __set/clear_bit from ubifs.h to bitops.h

2009-08-20 Thread Simon Kagstrom
__set_bit and __clear_bit are defined in ubifs.h as well as in
asm/include/bitops.h for some architectures. This patch moves
the generic implementation to include/linux/bitops.h and uses
that unless it's defined by the architecture.

v2: Unify code style (newline between __set_bit and __clear_bit)
v3: Move BIT_MASK and BIT_WORD above the include of asm/bitops.h

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 fs/ubifs/ubifs.h   |   32 
 include/asm-avr32/bitops.h |4 
 include/asm-m68k/bitops.h  |4 
 include/asm-nios/bitops.h  |4 
 include/asm-nios2/bitops.h |4 
 include/asm-ppc/bitops.h   |4 
 include/asm-sh/bitops.h|5 +
 include/asm-sparc/bitops.h |4 
 include/linux/bitops.h |   29 +
 9 files changed, 58 insertions(+), 32 deletions(-)

diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 43865aa..06772af 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -449,38 +449,6 @@ static inline ino_t parent_ino(struct dentry *dentry)
return res;
 }
 
-/* linux/include/linux/bitops.h */
-
-#define BIT_MASK(nr)   (1UL  ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr)   ((nr) / BITS_PER_LONG)
-
-/* linux/include/asm-generic/bitops/non-atomic.h */
-
-/**
- * __set_bit - Set a bit in memory
- * @nr: the bit to set
- * @addr: the address to start counting from
- *
- * Unlike set_bit(), this function is non-atomic and may be reordered.
- * If it's called on the same region of memory simultaneously, the effect
- * may be that only one operation succeeds.
- */
-static inline void __set_bit(int nr, volatile unsigned long *addr)
-{
-   unsigned long mask = BIT_MASK(nr);
-   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
-
-   *p  |= mask;
-}
-
-static inline void __clear_bit(int nr, volatile unsigned long *addr)
-{
-   unsigned long mask = BIT_MASK(nr);
-   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
-
-   *p = ~mask;
-}
-
 /* debug.c */
 
 #define DEFINE_SPINLOCK(...)
diff --git a/include/asm-avr32/bitops.h b/include/asm-avr32/bitops.h
index f15fd46..b1cf2fb 100644
--- a/include/asm-avr32/bitops.h
+++ b/include/asm-avr32/bitops.h
@@ -22,4 +22,8 @@
 #ifndef __ASM_AVR32_BITOPS_H
 #define __ASM_AVR32_BITOPS_H
 
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+
 #endif /* __ASM_AVR32_BITOPS_H */
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index 0f9e8ab..fb472e6 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -15,6 +15,10 @@ extern int test_and_set_bit(int nr, volatile void *addr);
 extern int test_and_clear_bit(int nr, volatile void *addr);
 extern int test_and_change_bit(int nr, volatile void *addr);
 
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+
 #ifdef __KERNEL__
 
 /*
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h
index 7744212..76c52c2 100644
--- a/include/asm-nios/bitops.h
+++ b/include/asm-nios/bitops.h
@@ -34,4 +34,8 @@ extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
 extern int ffs(int i);
 
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+
 #endif /* _ASM_NIOS_BITOPS_H */
diff --git a/include/asm-nios2/bitops.h b/include/asm-nios2/bitops.h
index e6c1a85..da04b40 100644
--- a/include/asm-nios2/bitops.h
+++ b/include/asm-nios2/bitops.h
@@ -34,4 +34,8 @@ extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
 extern int ffs(int i);
 
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+
 #endif /* __ASM_NIOS2_BITOPS_H */
diff --git a/include/asm-ppc/bitops.h b/include/asm-ppc/bitops.h
index daa66cf..fd7f599 100644
--- a/include/asm-ppc/bitops.h
+++ b/include/asm-ppc/bitops.h
@@ -144,6 +144,10 @@ extern __inline__ int test_and_change_bit(int nr, volatile 
void *addr)
 }
 #endif /* __INLINE_BITOPS */
 
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+
 extern __inline__ int test_bit(int nr, __const__ volatile void *addr)
 {
__const__ unsigned int *p = (__const__ unsigned int *) addr;
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
index 410fba4..f102e7e 100644
--- a/include/asm-sh/bitops.h
+++ b/include/asm-sh/bitops.h
@@ -146,6 +146,11 @@ static inline int ffs (int x)
}
return r;
 }
+
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_SH_BITOPS_H */
diff --git a/include/asm-sparc/bitops.h b/include/asm-sparc/bitops.h
index ceb39f2

[U-Boot] [PATCH v2 2/4]: Make arm bitops endianness-independent

2009-08-20 Thread Simon Kagstrom
Bring over the bitop implementations from the Linux
include/asm-generic/bitops/non-atomic.h to provide
endianness-independence.

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 include/asm-arm/bitops.h |   45 +++--
 1 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 4b8bab2..04ae68c 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -27,57 +27,66 @@ extern void set_bit(int nr, volatile void * addr);
 
 static inline void __set_bit(int nr, volatile void *addr)
 {
-   ((unsigned char *) addr)[nr  3] |= (1U  (nr  7));
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p  |= mask;
 }
 
 extern void clear_bit(int nr, volatile void * addr);
 
 static inline void __clear_bit(int nr, volatile void *addr)
 {
-   ((unsigned char *) addr)[nr  3] = ~(1U  (nr  7));
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p = ~mask;
 }
 
 extern void change_bit(int nr, volatile void * addr);
 
 static inline void __change_bit(int nr, volatile void *addr)
 {
-   ((unsigned char *) addr)[nr  3] ^= (1U  (nr  7));
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p ^= mask;
 }
 
 extern int test_and_set_bit(int nr, volatile void * addr);
 
 static inline int __test_and_set_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval | mask;
-   return oldval  mask;
+   *p = old | mask;
+   return (old  mask) != 0;
 }
 
 extern int test_and_clear_bit(int nr, volatile void * addr);
 
 static inline int __test_and_clear_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval  ~mask;
-   return oldval  mask;
+   *p = old  ~mask;
+   return (old  mask) != 0;
 }
 
 extern int test_and_change_bit(int nr, volatile void * addr);
 
 static inline int __test_and_change_bit(int nr, volatile void *addr)
 {
-   unsigned int mask = 1  (nr  7);
-   unsigned int oldval;
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
 
-   oldval = ((unsigned char *) addr)[nr  3];
-   ((unsigned char *) addr)[nr  3] = oldval ^ mask;
-   return oldval  mask;
+   *p = old ^ mask;
+   return (old  mask) != 0;
 }
 
 extern int find_first_zero_bit(void * addr, unsigned size);
-- 
1.6.0.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/4]: Define ffs/fls for all architectures

2009-08-20 Thread Simon Kagstrom
UBIFS requires fls(), which is not defined for arm (and some other
architectures) and this patch adds it. The implementation is taken from
Linux and is generic. ffs() is also defined for those that miss it.

v2: Unify code style (empty line between ffs/fls)

Signed-off-by: Simon Kagstrom simon.kagst...@netinsight.net
---
 include/asm-arm/bitops.h|4 
 include/asm-avr32/bitops.h  |4 
 include/asm-i386/bitops.h   |2 ++
 include/asm-m68k/bitops.h   |2 ++
 include/asm-microblaze/bitops.h |2 ++
 include/asm-mips/bitops.h   |2 ++
 include/asm-nios/bitops.h   |5 -
 include/asm-nios2/bitops.h  |5 -
 include/asm-sh/bitops.h |2 ++
 include/asm-sparc/bitops.h  |4 
 include/linux/bitops.h  |   37 +
 11 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 04ae68c..b3a9578 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -17,6 +17,8 @@
 
 #ifdef __KERNEL__
 
+#include asm/types.h
+
 #define smp_mb__before_clear_bit() do { } while (0)
 #define smp_mb__after_clear_bit()  do { } while (0)
 
@@ -126,6 +128,8 @@ static inline unsigned long ffz(unsigned long word)
 
 #define ffs(x) generic_ffs(x)
 
+#define fls(x) generic_fls(x)
+
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
diff --git a/include/asm-avr32/bitops.h b/include/asm-avr32/bitops.h
index b1cf2fb..5fa20e2 100644
--- a/include/asm-avr32/bitops.h
+++ b/include/asm-avr32/bitops.h
@@ -26,4 +26,8 @@
 
 #define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
 
+#define ffs(x) generic_ffs(x)
+
+#define fls(x) generic_fls(x)
+
 #endif /* __ASM_AVR32_BITOPS_H */
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index b768e20..71c2256 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -350,6 +350,8 @@ static __inline__ int ffs(int x)
return r+1;
 }
 
+#define fls(x) generic_fls(x)
+
 /**
  * hweightN - returns the hamming weight of a N-bit word
  * @x: the word to weigh
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index fb472e6..a38a62a 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -56,6 +56,8 @@ extern __inline__ int ffs(int x)
 }
 #define __ffs(x) (ffs(x) - 1)
 
+#define fls(x) generic_fls(x)
+
 #endif /* __KERNEL__ */
 
 #endif /* _M68K_BITOPS_H */
diff --git a/include/asm-microblaze/bitops.h b/include/asm-microblaze/bitops.h
index 04ea020..e277ab8 100644
--- a/include/asm-microblaze/bitops.h
+++ b/include/asm-microblaze/bitops.h
@@ -266,6 +266,8 @@ found_middle:
 
 #define ffs(x) generic_ffs(x)
 
+#define fls(x) generic_fls(x)
+
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 659ac9d..76b9baa 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -716,6 +716,8 @@ static __inline__ unsigned long ffz(unsigned long word)
 
 #define ffs(x) generic_ffs(x)
 
+#define fls(x) generic_fls(x)
+
 /*
  * hweightN - returns the hamming weight of a N-bit word
  * @x: the word to weigh
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h
index 76c52c2..33714c4 100644
--- a/include/asm-nios/bitops.h
+++ b/include/asm-nios/bitops.h
@@ -32,7 +32,10 @@ extern void change_bit(unsigned long nr, volatile void 
*addr);
 extern int test_and_set_bit(int nr, volatile void * a);
 extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
-extern int ffs(int i);
+
+#define ffs(x) generic_ffs(x)
+
+#define fls(x) generic_fls(x)
 
 #define __set_bit(nr, addr) generic_set_bit(nr, addr)
 
diff --git a/include/asm-nios2/bitops.h b/include/asm-nios2/bitops.h
index da04b40..1fac52c 100644
--- a/include/asm-nios2/bitops.h
+++ b/include/asm-nios2/bitops.h
@@ -32,7 +32,10 @@ extern void change_bit(unsigned long nr, volatile void 
*addr);
 extern int test_and_set_bit(int nr, volatile void * a);
 extern int test_and_change_bit(int nr, volatile void * addr);
 extern int test_bit(int nr, volatile void * a);
-extern int ffs(int i);
+
+#define ffs(x) generic_ffs(x)
+
+#define fls(x) generic_fls(x)
 
 #define __set_bit(nr, addr) generic_set_bit(nr, addr)
 
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
index f102e7e..8021455 100644
--- a/include/asm-sh/bitops.h
+++ b/include/asm-sh/bitops.h
@@ -147,6 +147,8 @@ static inline int ffs (int x)
return r;
 }
 
+#define fls(x) generic_fls(x)
+
 #define __set_bit(nr, addr) generic_set_bit(nr, addr)
 
 #define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
diff --git a/include/asm-sparc/bitops.h b/include/asm-sparc/bitops.h
index b1bcb53..942029f 100644
--- a/include/asm-sparc/bitops.h
+++ b/include/asm-sparc/bitops.h
@@ -30,4 +30,8 @@
 
 #define __clear_bit

  1   2   >