]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Clean up dataflash partitioning
authorUlf Samuelsson <ulf@atmel.com>
Sat, 12 Apr 2008 18:29:44 +0000 (20:29 +0200)
committerWolfgang Denk <wd@denx.de>
Fri, 18 Apr 2008 07:24:05 +0000 (00:24 -0700)
This patch removes the board dependent parts from
"drivers/mtd/dataflash.c".
Each board relying on this, will have the appropriate
code in a new file, "partition.c" in the board directory.
board Makefiles updated to use the file.

The dataflash partitions are aligned on sector/page boundaries.

The CONFIG_NEW_DF_PARTITION was used to create named partitions
This is now the default operation, and the CONFIG variable is removed.

Signed-off-by: Ulf Samuelsson <ulf@atmel.com>
board/atmel/at91cap9adk/Makefile
board/atmel/at91cap9adk/partition.c [new file with mode: 0644]
board/atmel/at91rm9200dk/Makefile
board/atmel/at91rm9200dk/partition.c [new file with mode: 0644]
board/atmel/at91sam9260ek/Makefile
board/atmel/at91sam9260ek/partition.c [new file with mode: 0644]
drivers/mtd/dataflash.c
include/dataflash.h

index 3961030359f5e253647030d19fcccfe70c2bae11..6b4b4b035e4d127ce4653e85439ca16ee1835636 100644 (file)
@@ -27,6 +27,7 @@ LIB   = $(obj)lib$(BOARD).a
 
 COBJS-y        += at91cap9adk.o
 COBJS-y        += led.o
+COBJS-y        += partition.o
 COBJS-$(CONFIG_CMD_NAND) += nand.o
 
 SRCS    := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
diff --git a/board/atmel/at91cap9adk/partition.c b/board/atmel/at91cap9adk/partition.c
new file mode 100644 (file)
index 0000000..3bffd71
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+#include <common.h>
+#include <config.h>
+#include <asm/hardware.h>
+#include <dataflash.h>
+
+AT91S_DATAFLASH_INFO dataflash_info[CFG_MAX_DATAFLASH_BANKS];
+
+struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS] = {
+       {CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},      /* Logical adress, CS */
+};
+
+/*define the area offsets*/
+dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
+       {0x00000000, 0x000041FF, FLAG_PROTECT_SET,   0, "Bootstrap"},
+       {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"},
+       {0x00008400, 0x00041FFF, FLAG_PROTECT_SET,   0, "U-Boot"},
+       {0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"},
+       {0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"},
+};
index 01f3bc30a32e29cc392b6dabe777a4fd2873f585..5b4cdcfc391f1923c18ced61dedfe5609b487a5a 100755 (executable)
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := at91rm9200dk.o flash.o led.o mux.o
+COBJS  := at91rm9200dk.o flash.o led.o mux.o partition.o
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
diff --git a/board/atmel/at91rm9200dk/partition.c b/board/atmel/at91rm9200dk/partition.c
new file mode 100644 (file)
index 0000000..a8a5fe6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+#include <common.h>
+#include <config.h>
+#include <asm/hardware.h>
+#include <dataflash.h>
+
+AT91S_DATAFLASH_INFO dataflash_info[CFG_MAX_DATAFLASH_BANKS];
+
+struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS] = {
+       {CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},      /* Logical adress, CS */
+       {CFG_DATAFLASH_LOGIC_ADDR_CS3, 3}
+};
+
+/*define the area offsets*/
+dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
+       {0x00000000, 0x000041FF, FLAG_PROTECT_SET,   0, "Bootstrap"},
+       {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"},
+       {0x00008400, 0x00041FFF, FLAG_PROTECT_SET,   0, "U-Boot"},
+       {0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"},
+       {0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"},
+};
index 8a629b9c8f8f2992d785291fd6bb423b76f6f40b..defc08519313b4a13cb422310b73047915d0b248 100644 (file)
@@ -27,6 +27,7 @@ LIB   = $(obj)lib$(BOARD).a
 
 COBJS-y        += at91sam9260ek.o
 COBJS-y        += led.o
+COBJS-y        += partition.o
 COBJS-$(CONFIG_CMD_NAND) += nand.o
 
 SRCS   := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
diff --git a/board/atmel/at91sam9260ek/partition.c b/board/atmel/at91sam9260ek/partition.c
new file mode 100644 (file)
index 0000000..389fb2c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+#include <common.h>
+#include <config.h>
+#include <asm/hardware.h>
+#include <dataflash.h>
+
+AT91S_DATAFLASH_INFO dataflash_info[CFG_MAX_DATAFLASH_BANKS];
+
+struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS] = {
+       {CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},      /* Logical adress, CS */
+       {CFG_DATAFLASH_LOGIC_ADDR_CS1, 1}
+};
+
+/*define the area offsets*/
+dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
+       {0x00000000, 0x000041FF, FLAG_PROTECT_SET,   0, "Bootstrap"},
+       {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"},
+       {0x00008400, 0x00041FFF, FLAG_PROTECT_SET,   0, "U-Boot"},
+       {0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"},
+       {0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"},
+};
index d8f78f20a8a192df41d3ab3b7eb3592f6bff3bfa..8247aa03b5f30df32a39f598b79d172f8b497870 100644 (file)
 #include <asm/hardware.h>
 #include <dataflash.h>
 
-AT91S_DATAFLASH_INFO dataflash_info[CFG_MAX_DATAFLASH_BANKS];
 static AT91S_DataFlash DataFlashInst;
 
-struct dataflash_addr {
-       unsigned long addr;
-       int cs;
-};
-
-#if defined(CONFIG_AT91SAM9260EK)
-struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS] = {
-       {CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},      /* Logical adress, CS */
-       {CFG_DATAFLASH_LOGIC_ADDR_CS1, 1}
-};
-#elif defined(CONFIG_AT91SAM9263EK) || defined(CONFIG_AT91CAP9ADK)
-struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS] = {
-       {CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},      /* Logical adress, CS */
-};
-#else
-struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS] = {
-       {CFG_DATAFLASH_LOGIC_ADDR_CS0, 0},      /* Logical adress, CS */
-       {CFG_DATAFLASH_LOGIC_ADDR_CS3, 3}
-};
-#endif
-
-/*define the area offsets*/
-dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
-       {0x00000000, 0x000041FF, FLAG_PROTECT_SET,   0, "Bootstrap"},
-       {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"},
-       {0x00008400, 0x0003DDFF, FLAG_PROTECT_SET,   0, "U-Boot"},
-       {0x0003DE00, 0x0023DE3F, FLAG_PROTECT_CLEAR, 0, "Kernel"},
-       {0x0023DE40, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"},
-};
-
 extern void AT91F_SpiInit (void);
 extern int AT91F_DataflashProbe (int i, AT91PS_DataflashDesc pDesc);
 extern int AT91F_DataFlashRead (AT91PS_DataFlash pDataFlash,
@@ -178,8 +147,7 @@ int AT91F_DataflashInit (void)
        return found[0];
 }
 
-#ifdef CONFIG_NEW_DF_PARTITION
-int AT91F_DataflashSetEnv (void)
+void AT91F_DataflashSetEnv (void)
 {
        int i, j;
        int part;
@@ -194,14 +162,13 @@ int AT91F_DataflashSetEnv (void)
                        if((env & FLAG_SETENV) == FLAG_SETENV) {
                                start =
                                dataflash_info[i].Device.area_list[j].start;
-                               sprintf(s,"%X",start);
-                               setenv(area_list[part].label,s);
+                               sprintf((char*) s,"%X",start);
+                               setenv((char*) area_list[part].label,(char*) s);
                        }
                        part++;
                }
        }
 }
-#endif
 
 void dataflash_print_info (void)
 {
@@ -244,16 +211,10 @@ void dataflash_print_info (void)
                                                dataflash_info[i].Device.area_list[j].start,
                                                dataflash_info[i].Device.area_list[j].end,
                                                (dataflash_info[i].Device.area_list[j].protected==FLAG_PROTECT_SET) ? "(RO)" : "    ");
-#ifdef CONFIG_NEW_DF_PARTITION
                                                printf(" %s\n", dataflash_info[i].Device.area_list[j].label);
-#else
-                                               printf("\n");
-#endif
                                        break;
-#ifdef CONFIG_NEW_DF_PARTITION
                                case    FLAG_PROTECT_INVALID:
                                        break;
-#endif
                                }
                        }
                }
index 68f0324158cb7947e8c4cead634998818960cbc5..f20c738686f387b67f7c1bebe2d3fd8dc12a6129 100644 (file)
@@ -130,7 +130,10 @@ typedef struct _AT91S_DATAFLASH_INFO {
        unsigned int id;                        /* device id */
 } AT91S_DATAFLASH_INFO, *AT91PS_DATAFLASH_INFO;
 
-
+struct dataflash_addr {
+       unsigned long addr;
+       int cs;
+};
 /*-------------------------------------------------------------------------------------------------*/
 
 #define AT45DB161      0x2c
@@ -207,9 +210,9 @@ extern int read_dataflash (unsigned long addr, unsigned long size, char *result)
 extern int write_dataflash (unsigned long addr, unsigned long dest, unsigned long size);
 extern void dataflash_print_info (void);
 extern void dataflash_perror (int err);
+extern void AT91F_DataflashSetEnv (void);
 
-#ifdef CONFIG_NEW_DF_PARTITION
-extern int AT91F_DataflashSetEnv (void); #endif
-#endif
-
+extern struct dataflash_addr cs[CFG_MAX_DATAFLASH_BANKS];
+extern dataflash_protect_t area_list[NB_DATAFLASH_AREA];
+extern AT91S_DATAFLASH_INFO dataflash_info[];
 #endif