[ARM] Kirkwood: remove duplicated code in LaCie setup files

Signed-off-by: Simon Guinot <sguinot@lacie.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
diff --git a/arch/arm/mach-kirkwood/d2net_v2-setup.c b/arch/arm/mach-kirkwood/d2net_v2-setup.c
index 310c6a0..cd62d0f 100644
--- a/arch/arm/mach-kirkwood/d2net_v2-setup.c
+++ b/arch/arm/mach-kirkwood/d2net_v2-setup.c
@@ -23,56 +23,19 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/mtd/physmap.h>
-#include <linux/spi/flash.h>
-#include <linux/spi/spi.h>
 #include <linux/ata_platform.h>
 #include <linux/mv643xx_eth.h>
-#include <linux/i2c.h>
-#include <linux/i2c/at24.h>
 #include <linux/input.h>
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
 #include <linux/leds.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
-#include <asm/mach/time.h>
 #include <mach/kirkwood.h>
 #include <mach/leds-ns2.h>
-#include <plat/time.h>
 #include "common.h"
 #include "mpp.h"
-
-/*****************************************************************************
- * 512KB SPI Flash on Boot Device
- ****************************************************************************/
-
-static struct mtd_partition d2net_v2_flash_parts[] = {
-	{
-		.name = "u-boot",
-		.size = MTDPART_SIZ_FULL,
-		.offset = 0,
-		.mask_flags = MTD_WRITEABLE,
-	},
-};
-
-static const struct flash_platform_data d2net_v2_flash = {
-	.type		= "mx25l4005a",
-	.name		= "spi_flash",
-	.parts		= d2net_v2_flash_parts,
-	.nr_parts	= ARRAY_SIZE(d2net_v2_flash_parts),
-};
-
-static struct spi_board_info __initdata d2net_v2_spi_slave_info[] = {
-	{
-		.modalias	= "m25p80",
-		.platform_data	= &d2net_v2_flash,
-		.irq		= -1,
-		.max_speed_hz	= 20000000,
-		.bus_num	= 0,
-		.chip_select	= 0,
-	},
-};
+#include "lacie_v2-common.h"
 
 /*****************************************************************************
  * Ethernet
@@ -83,27 +46,6 @@
 };
 
 /*****************************************************************************
- * I2C devices
- ****************************************************************************/
-
-static struct at24_platform_data at24c04 = {
-	.byte_len	= SZ_4K / 8,
-	.page_size	= 16,
-};
-
-/*
- * i2c addr | chip         | description
- * 0x50     | HT24LC04     | eeprom (512B)
- */
-
-static struct i2c_board_info __initdata d2net_v2_i2c_info[] = {
-	{
-		I2C_BOARD_INFO("24c04", 0x50),
-		.platform_data  = &at24c04,
-	}
-};
-
-/*****************************************************************************
  * SATA
  ****************************************************************************/
 
@@ -111,22 +53,6 @@
 	.n_ports	= 2,
 };
 
-#define D2NET_V2_GPIO_SATA0_POWER	16
-
-static void __init d2net_v2_sata_power_init(void)
-{
-	int err;
-
-	err = gpio_request(D2NET_V2_GPIO_SATA0_POWER, "SATA0 power");
-	if (err == 0) {
-		err = gpio_direction_output(D2NET_V2_GPIO_SATA0_POWER, 1);
-		if (err)
-			gpio_free(D2NET_V2_GPIO_SATA0_POWER);
-	}
-	if (err)
-		pr_err("d2net_v2: failed to configure SATA0 power GPIO\n");
-}
-
 /*****************************************************************************
  * GPIO keys
  ****************************************************************************/
@@ -229,20 +155,6 @@
 };
 
 /*****************************************************************************
- * Timer
- ****************************************************************************/
-
-static void d2net_v2_timer_init(void)
-{
-	kirkwood_tclk = 166666667;
-	orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
-}
-
-struct sys_timer d2net_v2_timer = {
-	.init = d2net_v2_timer_init,
-};
-
-/*****************************************************************************
  * General Setup
  ****************************************************************************/
 
@@ -288,18 +200,14 @@
 	kirkwood_init();
 	kirkwood_mpp_conf(d2net_v2_mpp_config);
 
-	d2net_v2_sata_power_init();
+	lacie_v2_hdd_power_init(1);
 
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&d2net_v2_ge00_data);
 	kirkwood_sata_init(&d2net_v2_sata_data);
 	kirkwood_uart0_init();
-	spi_register_board_info(d2net_v2_spi_slave_info,
-				ARRAY_SIZE(d2net_v2_spi_slave_info));
-	kirkwood_spi_init();
-	kirkwood_i2c_init();
-	i2c_register_board_info(0, d2net_v2_i2c_info,
-				ARRAY_SIZE(d2net_v2_i2c_info));
+	lacie_v2_register_flash();
+	lacie_v2_register_i2c_devices();
 
 	platform_device_register(&d2net_v2_leds);
 	platform_device_register(&d2net_v2_gpio_leds);
@@ -319,5 +227,5 @@
 	.init_machine	= d2net_v2_init,
 	.map_io		= kirkwood_map_io,
 	.init_irq	= kirkwood_init_irq,
-	.timer		= &d2net_v2_timer,
+	.timer		= &lacie_v2_timer,
 MACHINE_END