From 76e58431485ad6b9d78eb0eec449c723dec1ecff Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Thu, 19 Jun 2014 11:42:41 +0200
Subject: [PATCH 10/10] sam9m10g45ek (for wrs): new partitioning

This moves environment to the first meg of nand so we can later ubify
the rest of the nand memory.  Such placement if compatible with
current partitioning, which is unchanged.

Also, it prepare partitions in the dataflash, to reflect actual
placement of the stuff and ease replacing barebox or at91boot from a
running system (useful for me and Benoit for release work, nobody else
is expected to change dataflash).

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
 arch/arm/mach-at91/board-sam9m10g45ek.c |   46 +++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index d40aa3c..afc6418 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -25,6 +25,7 @@
 #include <linux/leds.h>
 #include <linux/clk.h>
 #include <linux/atmel-mci.h>
+#include <linux/spi/flash.h>
 
 #include <mach/hardware.h>
 #include <video/atmel_lcdc.h>
@@ -88,12 +89,42 @@ static struct usba_platform_data __initdata ek_usba_udc_data = {
 /*
  * SPI devices.
  */
+static struct mtd_partition wrs_df_parts[] = {
+	{
+		.name	= "at91boot",
+		.offset	= 0,
+		.size	= 0x8400,
+	},
+	{
+		.name	= "Barebox",
+		.offset	= MTDPART_OFS_APPEND,
+		.size	= 0x84000,
+	},
+	{
+		.name	= "Barebox-Environment",
+		.offset	= MTDPART_OFS_APPEND,
+		.size	= 0x8400,
+	},
+	{
+		.name	= "Available-dataflash",
+		.offset	= MTDPART_OFS_APPEND,
+		.size	= MTDPART_SIZ_FULL,
+	},
+};
+
+static struct flash_platform_data wrs_df_pdata = {
+	.name = "wrs-dataflash",
+	.parts = wrs_df_parts,
+	.nr_parts = ARRAY_SIZE(wrs_df_parts),
+};
+
 static struct spi_board_info ek_spi_devices[] = {
 	{	/* DataFlash chip */
 		.modalias	= "mtd_dataflash",
 		.chip_select	= 0,
 		.max_speed_hz	= 15 * 1000 * 1000,
 		.bus_num	= 0,
+		.platform_data	= &wrs_df_pdata,
 	},
 };
 
@@ -131,6 +162,11 @@ static struct at91_eth_data __initdata ek_macb_data = {
  */
 static struct mtd_partition __initdata ek_nand_partition[] = {
 	{
+		.name	= "Barebox-environment-backup",
+		.offset	= 0,
+		.size	= SZ_1M,
+	},
+	{
 		.name	= "Kernel",
 		.offset	= 1 << 20,
 		.size	= SZ_8M,
@@ -141,14 +177,8 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
 		.size	= SZ_128M,
 	},
 	{
-		.name	= "Barebox Environment",
-		.offset	= 256 << 10,
-		.size	= SZ_256K,
-	},
-	/* This is actuallywas MTDPART_OFS_APPEND over the filesystem */
-	{
-		.name	= "Available",
-		.offset	= (128+64) << 20,
+		.name	= "Available-nand",
+		.offset	= MTDPART_OFS_APPEND,
 		.size	= MTDPART_SIZ_FULL,
 	},
 };
-- 
1.7.7.2

