ARM: OMAP: Sync core code with linux-omap

This patch syncs omap specific core code with linux-omap.
Most of the changes are needed to fix bitrot caused by
driver updates in linux-omap tree.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 91ebdaf..a302d91 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -1,3 +1,26 @@
+/*
+ * File: arch/arm/plat-omap/fb.c
+ *
+ * Framebuffer device registration for TI OMAP platforms
+ *
+ * Copyright (C) 2006 Nokia Corporation
+ * Author: Imre Deak <imre.deak@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -34,25 +57,42 @@
 void omapfb_reserve_mem(void)
 {
 	const struct omap_fbmem_config *fbmem_conf;
+	unsigned long total_size;
+	int i;
 
-	omapfb_config.fbmem.fb_sram_start = omap_fb_sram_start;
-	omapfb_config.fbmem.fb_sram_size = omap_fb_sram_size;
-
-	fbmem_conf = omap_get_config(OMAP_TAG_FBMEM, struct omap_fbmem_config);
-
-	if (fbmem_conf != NULL) {
-		/* indicate that the bootloader already initialized the
-		 * fb device, so we'll skip that part in the fb driver
-		 */
-		omapfb_config.fbmem.fb_sdram_start = fbmem_conf->fb_sdram_start;
-		omapfb_config.fbmem.fb_sdram_size = fbmem_conf->fb_sdram_size;
-		if (fbmem_conf->fb_sdram_size) {
-			pr_info("Reserving %u bytes SDRAM for frame buffer\n",
-				fbmem_conf->fb_sdram_size);
-			reserve_bootmem(fbmem_conf->fb_sdram_start,
-					fbmem_conf->fb_sdram_size);
-		}
+	if (!omap_fb_sram_valid) {
+		/* FBMEM SRAM configuration was already found to be invalid.
+		 * Ignore the whole configuration block. */
+		omapfb_config.mem_desc.region_cnt = 0;
+		return;
 	}
+
+	i = 0;
+	total_size = 0;
+	while ((fbmem_conf = omap_get_nr_config(OMAP_TAG_FBMEM,
+				struct omap_fbmem_config, i)) != NULL) {
+		unsigned long start;
+		unsigned long size;
+
+		if (i == OMAPFB_PLANE_NUM) {
+			printk(KERN_ERR "ignoring extra plane info\n");
+			break;
+		}
+		start = fbmem_conf->start;
+		size  = fbmem_conf->size;
+		omapfb_config.mem_desc.region[i].paddr = start;
+		omapfb_config.mem_desc.region[i].size = size;
+		if (omap_fb_sram_plane != i && start) {
+			reserve_bootmem(start, size);
+			total_size += size;
+		}
+		i++;
+	}
+	omapfb_config.mem_desc.region_cnt = i;
+	if (total_size)
+		pr_info("Reserving %lu bytes SDRAM for frame buffer\n",
+			 total_size);
+
 }
 
 void omapfb_set_ctrl_platform_data(void *data)