kirkwood: dreamplug support

guruplug and dreamplug are really similar so add support for dreamplug
by modifying guruplug support to handle both devices.

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Index: linux-2.6/arch/arm/mach-kirkwood/Kconfig
===================================================================
--- linux-2.6.orig/arch/arm/mach-kirkwood/Kconfig	2011-10-28 17:57:01.000000000 +0200
+++ linux-2.6/arch/arm/mach-kirkwood/Kconfig	2011-10-28 17:58:08.000000000 +0200
@@ -44,6 +44,12 @@ config MACH_GURUPLUG
 	  Say 'Y' here if you want your kernel to support the
 	  Marvell GuruPlug Reference Board.
 
+config MACH_DREAMPLUG
+	bool "Marvell DreamPlug Reference Board"
+	help
+	  Say 'Y' here if you want your kernel to support the
+	  Marvell DreamPlug Reference Board.
+
 config MACH_TS219
 	bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS"
 	help
Index: linux-2.6/arch/arm/mach-kirkwood/Makefile
===================================================================
--- linux-2.6.orig/arch/arm/mach-kirkwood/Makefile	2011-10-28 17:57:01.000000000 +0200
+++ linux-2.6/arch/arm/mach-kirkwood/Makefile	2011-10-28 17:58:08.000000000 +0200
@@ -7,6 +7,7 @@ obj-$(CONFIG_MACH_MV88F6281GTW_GE)	+= mv
 obj-$(CONFIG_MACH_SHEEVAPLUG)		+= sheevaplug-setup.o
 obj-$(CONFIG_MACH_ESATA_SHEEVAPLUG)	+= sheevaplug-setup.o
 obj-$(CONFIG_MACH_GURUPLUG)		+= guruplug-setup.o
+obj-$(CONFIG_MACH_DREAMPLUG)		+= guruplug-setup.o
 obj-$(CONFIG_MACH_DOCKSTAR)		+= dockstar-setup.o
 obj-$(CONFIG_MACH_TS219)		+= ts219-setup.o tsx1x-common.o
 obj-$(CONFIG_MACH_TS41X)		+= ts41x-setup.o tsx1x-common.o
Index: linux-2.6/arch/arm/mach-kirkwood/guruplug-setup.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-kirkwood/guruplug-setup.c	2011-10-28 17:57:02.000000000 +0200
+++ linux-2.6/arch/arm/mach-kirkwood/guruplug-setup.c	2011-10-28 21:37:13.000000000 +0200
@@ -16,6 +16,9 @@
 #include <linux/mv643xx_eth.h>
 #include <linux/gpio.h>
 #include <linux/leds.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/orion_spi.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <mach/kirkwood.h>
@@ -23,6 +26,22 @@
 #include "common.h"
 #include "mpp.h"
 
+static const struct flash_platform_data dreamplug_spi_slave_data = {
+	.type		= "mx25l1606e",
+	.name		= "spi_flash",
+};
+
+static struct spi_board_info __initdata dreamplug_spi_slave_info[] = {
+	{
+		.modalias	= "m25p80",
+		.platform_data	= &dreamplug_spi_slave_data,
+		.irq		= -1,
+		.max_speed_hz	= 50000000,
+		.bus_num	= 0,
+		.chip_select	= 0,
+	},
+};
+
 static struct mtd_partition guruplug_nand_parts[] = {
 	{
 		.name = "u-boot",
@@ -91,6 +110,33 @@ static struct platform_device guruplug_l
 	}
 };
 
+static struct gpio_led dreamplug_led_pins[] = {
+	{
+		.name		= "dreamplug:blue:ap",
+		.gpio		= 46,
+		.active_low	= 1,
+	}, {
+		.name		= "dreamplug:green:wifi",
+		.gpio		= 48,
+		.active_low	= 1,
+	},
+};
+
+static struct gpio_led_platform_data dreamplug_led_data = {
+	.leds		= dreamplug_led_pins,
+	.num_leds	= ARRAY_SIZE(dreamplug_led_pins),
+};
+
+static unsigned int dreamplug_mpp_config[] __initdata = {
+	MPP0_SPI_SCn,
+	MPP1_SPI_MOSI,
+	MPP2_SPI_SCK,
+	MPP3_SPI_MISO,
+	MPP46_GPIO,	/* Wifi AP LED */
+	MPP48_GPIO,	/* Wifi LED */
+	0
+};
+
 static unsigned int guruplug_mpp_config[] __initdata = {
 	MPP46_GPIO,	/* M_RLED */
 	MPP47_GPIO,	/* M_GLED */
@@ -105,10 +151,21 @@ static void __init guruplug_init(void)
 	 * Basic setup. Needs to be called early.
 	 */
 	kirkwood_init();
-	kirkwood_mpp_conf(guruplug_mpp_config);
 
-	kirkwood_uart0_init();
-	kirkwood_nand_init(ARRAY_AND_SIZE(guruplug_nand_parts), 25);
+	if (machine_is_guruplug()) {
+		kirkwood_mpp_conf(guruplug_mpp_config);
+		kirkwood_uart0_init();
+		kirkwood_nand_init(ARRAY_AND_SIZE(guruplug_nand_parts), 25);
+	}
+
+	if (machine_is_dreamplug()) {
+		kirkwood_mpp_conf(dreamplug_mpp_config);
+		kirkwood_uart0_init();
+		spi_register_board_info(dreamplug_spi_slave_info,
+				ARRAY_SIZE(dreamplug_spi_slave_info));
+		kirkwood_spi_init();
+		guruplug_leds.dev.platform_data = &dreamplug_led_data;
+	}
 
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&guruplug_ge00_data);
@@ -119,6 +176,12 @@ static void __init guruplug_init(void)
 	platform_device_register(&guruplug_leds);
 }
 
+#ifdef CONFIG_MACH_GURUPLUG
+static const char const *guruplug_dt_board_compat[] = {
+	"marvell,guruplug",
+	NULL
+};
+
 MACHINE_START(GURUPLUG, "Marvell GuruPlug Reference Board")
 	/* Maintainer: Siddarth Gore <gores@marvell.com> */
 	.boot_params	= 0x00000100,
@@ -127,4 +190,23 @@ MACHINE_START(GURUPLUG, "Marvell GuruPlu
 	.init_early	= kirkwood_init_early,
 	.init_irq	= kirkwood_init_irq,
 	.timer		= &kirkwood_timer,
+	.dt_compat	= guruplug_dt_board_compat,
+MACHINE_END
+#endif
+
+#ifdef CONFIG_MACH_DREAMPLUG
+static const char const *dreamplug_dt_board_compat[] = {
+	"marvell,dreamplug",
+	NULL
+};
+
+MACHINE_START(DREAMPLUG, "Marvell DreamPlug Reference Board")
+	/* Maintainer: ? */
+	.init_machine	= guruplug_init,
+	.map_io		= kirkwood_map_io,
+	.init_early	= kirkwood_init_early,
+	.init_irq	= kirkwood_init_irq,
+	.timer		= &kirkwood_timer,
+	.dt_compat	= dreamplug_dt_board_compat,
 MACHINE_END
+#endif
Index: linux-2.6/arch/arm/boot/dts/marvell-dreamplug.dts
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/arch/arm/boot/dts/marvell-dreamplug.dts	2011-10-28 21:36:09.000000000 +0200
@@ -0,0 +1,8 @@
+/dts-v1/
+/include/ "skeleton.dtsi"
+
+/ {
+	model = "Marvell Dreamplug";
+	compatible = "marvell,dreamplug";
+};
+

diff --git a/include/configs/guruplug.h b/include/configs/guruplug.h
index f449da9..f1cacc4 100644
--- a/include/configs/guruplug.h
+++ b/include/configs/guruplug.h
@@ -38,6 +38,7 @@
 #define CONFIG_KW88F6281	1	/* SOC Name */
 #define CONFIG_MACH_GURUPLUG	/* Machine type */
 #define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+#define CONFIG_OF_LIBFDT		1
 
 /*
  * Commands configuration

