Re: [U-Boot-Users] [PATCH 07/08] Socrates: NAND support added. Changed the U-Boot base address and

2008-06-10 Thread Andy Fleming
On Sat, Jun 7, 2008 at 10:02 AM, Sergei Poselenov
[EMAIL PROTECTED] wrote:
 Hello,

 +#include asm/io.h
 +
 +int state;

 Can that variable be made static?

 Regards, Magnus


 Yes, it can.

 Wolfgang, what is the best way to handle this? Should I re-do the
 patch?


I have made the change in my tree.

Andy

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users


Re: [U-Boot-Users] [PATCH 07/08] Socrates: NAND support added. Changed the U-Boot base address and

2008-06-07 Thread Magnus Lilja
Hi

On Fri, Jun 6, 2008 at 3:42 PM, Wolfgang Denk [EMAIL PROTECTED] wrote:
 From: Sergei Poselenov [EMAIL PROTECTED]

 Signed-off-by: Sergei Poselenov [EMAIL PROTECTED]
 ---
  board/socrates/Makefile|2 +-
  board/socrates/config.mk   |3 +-
  board/socrates/nand.c  |  218 
 
  include/configs/socrates.h |8 ++-
  4 files changed, 227 insertions(+), 4 deletions(-)
  create mode 100644 board/socrates/nand.c

 diff --git a/board/socrates/Makefile b/board/socrates/Makefile
 index 6453f24..11503eb 100644
 --- a/board/socrates/Makefile
 +++ b/board/socrates/Makefile
 @@ -28,7 +28,7 @@ include $(TOPDIR)/config.mk
  LIB= $(obj)lib$(BOARD).a
  #

 -COBJS  := $(BOARD).o law.o tlb.o sdram.o
 +COBJS  := $(BOARD).o law.o tlb.o sdram.o nand.o

  SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
  OBJS   := $(addprefix $(obj),$(COBJS))
 diff --git a/board/socrates/config.mk b/board/socrates/config.mk
 index 1cf5d38..4f17294 100644
 --- a/board/socrates/config.mk
 +++ b/board/socrates/config.mk
 @@ -25,6 +25,5 @@
  #
  # socrates board
  # default CCARBAR is at 0xff70
 -# assume U-Boot is less than 256k
  #
 -TEXT_BASE = 0xfffc
 +TEXT_BASE = 0xfffa
 diff --git a/board/socrates/nand.c b/board/socrates/nand.c
 new file mode 100644
 index 000..960f847
 --- /dev/null
 +++ b/board/socrates/nand.c
 @@ -0,0 +1,218 @@
 +/*
 + * (C) Copyright 2008
 + * Sergei Poselenov, Emcraft Systems, [EMAIL PROTECTED]
 + *
 + * See file CREDITS for list of people who contributed to this
 + * project.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License as
 + * published by the Free Software Foundation; either version 2 of
 + * the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 + * MA 02111-1307 USA
 + */
 +
 +#include common.h
 +
 +#if defined(CFG_NAND_BASE)
 +#include nand.h
 +#include asm/errno.h
 +#include asm/io.h
 +
 +int state;

Can that variable be made static?

Regards, Magnus

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users


Re: [U-Boot-Users] [PATCH 07/08] Socrates: NAND support added. Changed the U-Boot base address and

2008-06-07 Thread Sergei Poselenov
Hello,

 +#include asm/io.h
 +
 +int state;
 
 Can that variable be made static?
 
 Regards, Magnus
 

Yes, it can.

Wolfgang, what is the best way to handle this? Should I re-do the
patch?

Regards,
Sergei

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users


[U-Boot-Users] [PATCH 07/08] Socrates: NAND support added. Changed the U-Boot base address and

2008-06-06 Thread Wolfgang Denk
From: Sergei Poselenov [EMAIL PROTECTED]

Signed-off-by: Sergei Poselenov [EMAIL PROTECTED]
---
 board/socrates/Makefile|2 +-
 board/socrates/config.mk   |3 +-
 board/socrates/nand.c  |  218 
 include/configs/socrates.h |8 ++-
 4 files changed, 227 insertions(+), 4 deletions(-)
 create mode 100644 board/socrates/nand.c

diff --git a/board/socrates/Makefile b/board/socrates/Makefile
index 6453f24..11503eb 100644
--- a/board/socrates/Makefile
+++ b/board/socrates/Makefile
@@ -28,7 +28,7 @@ include $(TOPDIR)/config.mk
 LIB= $(obj)lib$(BOARD).a
 #
 
-COBJS  := $(BOARD).o law.o tlb.o sdram.o
+COBJS  := $(BOARD).o law.o tlb.o sdram.o nand.o
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/socrates/config.mk b/board/socrates/config.mk
index 1cf5d38..4f17294 100644
--- a/board/socrates/config.mk
+++ b/board/socrates/config.mk
@@ -25,6 +25,5 @@
 #
 # socrates board
 # default CCARBAR is at 0xff70
-# assume U-Boot is less than 256k
 #
-TEXT_BASE = 0xfffc
+TEXT_BASE = 0xfffa
diff --git a/board/socrates/nand.c b/board/socrates/nand.c
new file mode 100644
index 000..960f847
--- /dev/null
+++ b/board/socrates/nand.c
@@ -0,0 +1,218 @@
+/*
+ * (C) Copyright 2008
+ * Sergei Poselenov, Emcraft Systems, [EMAIL PROTECTED]
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include common.h
+
+#if defined(CFG_NAND_BASE)
+#include nand.h
+#include asm/errno.h
+#include asm/io.h
+
+int state;
+static void nand_write_byte(struct mtd_info *mtd, u_char byte);
+static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len);
+static void nand_write_word(struct mtd_info *mtd, u16 word);
+static u_char nand_read_byte(struct mtd_info *mtd);
+static u16 nand_read_word(struct mtd_info *mtd);
+static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len);
+static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len);
+static int nand_device_ready(struct mtd_info *mtdinfo);
+static void nand_hwcontrol(struct mtd_info *mtdinfo, int cmd);
+
+#define FPGA_NAND_CMD_MASK (0x7  28)
+#define FPGA_NAND_CMD_COMMAND  (0x0  28)
+#define FPGA_NAND_CMD_ADDR (0x1  28)
+#define FPGA_NAND_CMD_READ (0x2  28)
+#define FPGA_NAND_CMD_WRITE(0x3  28)
+#define FPGA_NAND_BUSY (0x1  15)
+#define FPGA_NAND_ENABLE   (0x1  31)
+#define FPGA_NAND_DATA_SHIFT   16
+
+/**
+ * nand_write_byte -  write one byte to the chip
+ * @mtd:   MTD device structure
+ * @byte:  pointer to data byte to write
+ */
+static void nand_write_byte(struct mtd_info *mtd, u_char byte)
+{
+   nand_write_buf(mtd, (const uchar *)byte, sizeof(byte));
+}
+
+/**
+ * nand_write_word -  write one word to the chip
+ * @mtd:   MTD device structure
+ * @word:  data word to write
+ */
+static void nand_write_word(struct mtd_info *mtd, u16 word)
+{
+   nand_write_buf(mtd, (const uchar *)word, sizeof(word));
+}
+
+/**
+ * nand_write_buf -  write buffer to chip
+ * @mtd:   MTD device structure
+ * @buf:   data buffer
+ * @len:   number of bytes to write
+ */
+static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
+{
+   int i;
+   struct nand_chip *this = mtd-priv;
+   long val;
+
+   if ((state  FPGA_NAND_CMD_MASK) == FPGA_NAND_CMD_MASK) {
+   /* Write data */
+   val = (state  FPGA_NAND_ENABLE) | FPGA_NAND_CMD_WRITE;
+   } else {
+   /* Write address or command */
+   val = state;
+   }
+
+   for (i = 0; i  len; i++) {
+   out_be32(this-IO_ADDR_W, val | (buf[i]  
FPGA_NAND_DATA_SHIFT));
+   }
+}
+
+
+/**
+ * nand_read_byte -  read one byte from the chip
+ * @mtd:   MTD device structure
+ */
+static u_char nand_read_byte(struct mtd_info *mtd)
+{
+   u8 byte;
+   nand_read_buf(mtd, (uchar *)byte, sizeof(byte));
+   return byte;
+}
+
+/**
+ * nand_read_word -  read one word from the chip
+ * @mtd:   MTD device structure
+ */
+static u16 nand_read_word(struct mtd_info *mtd)
+{
+   u16 word;
+   nand_read_buf(mtd, (uchar *)word,