diff mbox

[U-Boot,3/4] arm:exynos4: Set common code for trats and universal_c210 boards

Message ID 1344593542-17485-4-git-send-email-p.wilczek@samsung.com
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Commit Message

Piotr Wilczek Aug. 10, 2012, 10:12 a.m. UTC
Boards trats and universal are very similar resulting in some common code.
That common code is moved to exynos4_common/exynos4_common.c

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Minkyu Kang <mk7.kang@samsung.com>
---
 board/samsung/exynos4_common/exynos4_common.c |  139 +++++++++++++++++++++++++
 board/samsung/trats/trats.c                   |  104 +------------------
 board/samsung/universal_c210/universal.c      |   98 +-----------------
 3 files changed, 143 insertions(+), 198 deletions(-)
 create mode 100644 board/samsung/exynos4_common/exynos4_common.c

Comments

Minkyu Kang Aug. 16, 2012, 9:09 a.m. UTC | #1
Dear Piotr Wilczek,

On 10 August 2012 19:12, Piotr Wilczek <p.wilczek@samsung.com> wrote:
> Boards trats and universal are very similar resulting in some common code.
> That common code is moved to exynos4_common/exynos4_common.c
>
> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Minkyu Kang <mk7.kang@samsung.com>
> ---
>  board/samsung/exynos4_common/exynos4_common.c |  139 +++++++++++++++++++++++++
>  board/samsung/trats/trats.c                   |  104 +------------------
>  board/samsung/universal_c210/universal.c      |   98 +-----------------
>  3 files changed, 143 insertions(+), 198 deletions(-)
>  create mode 100644 board/samsung/exynos4_common/exynos4_common.c
>
> diff --git a/board/samsung/exynos4_common/exynos4_common.c b/board/samsung/exynos4_common/exynos4_common.c
> new file mode 100644
> index 0000000..f2413e5
> --- /dev/null
> +++ b/board/samsung/exynos4_common/exynos4_common.c

I'll reject your patch.
It's not a standard way, I think..

> +#ifdef CONFIG_REVISION_TAG
> +u32 get_board_rev(void)
> +{
> +       return board_rev;
> +}
> +#endif
> +
> +int dram_init(void)
> +{
> +       gd->ram_size    = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
> +                       + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
> +#if CONFIG_NR_DRAM_BANKS == 4
> +       gd->ram_size    += get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
> +                       + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
> +#endif
> +       return 0;
> +}
> +
> +void dram_init_banksize(void)
> +{
> +       gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
> +       gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \
> +                                                       PHYS_SDRAM_1_SIZE);
> +       gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
> +       gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
> +                                                       PHYS_SDRAM_2_SIZE);
> +#if CONFIG_NR_DRAM_BANKS == 4
> +       gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
> +       gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \
> +                                                       PHYS_SDRAM_3_SIZE);
> +       gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
> +       gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \
> +                                                       PHYS_SDRAM_4_SIZE);
> +#endif
> +}

also, this is not a common function.
Although they are almost same, but I think it's a board specific.
Please don't move it.

> +
> +int exynos4_mmc_init(struct exynos4_gpio_part2 *gpio2)

How about using pinmux instead?

Thanks.
Minkyu Kang.
Piotr Wilczek Aug. 16, 2012, 1:55 p.m. UTC | #2
Dear Minkyu Kang,

Thank you for your comments. My motivation to move the dram_init functions
was that they looked the same for every board. I keep them in the board
specific file. I'll fix all the other issues and prepare new version.

Best regards
Piotr Wilczek

-----Original Message-----
From: Minkyu Kang [mailto:promsoft@gmail.com] 
Sent: Thursday, August 16, 2012 11:10 AM
To: Piotr Wilczek
Cc: u-boot@lists.denx.de; Kyungmin Park
Subject: Re: [U-Boot] [PATCH 3/4] arm:exynos4: Set common code for trats and
universal_c210 boards

Dear Piotr Wilczek,

On 10 August 2012 19:12, Piotr Wilczek <p.wilczek@samsung.com> wrote:
> Boards trats and universal are very similar resulting in some common code.
> That common code is moved to exynos4_common/exynos4_common.c
>
> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Minkyu Kang <mk7.kang@samsung.com>
> ---
>  board/samsung/exynos4_common/exynos4_common.c |  139
+++++++++++++++++++++++++
>  board/samsung/trats/trats.c                   |  104 +------------------
>  board/samsung/universal_c210/universal.c      |   98 +-----------------
>  3 files changed, 143 insertions(+), 198 deletions(-)  create mode 
> 100644 board/samsung/exynos4_common/exynos4_common.c
>
> diff --git a/board/samsung/exynos4_common/exynos4_common.c 
> b/board/samsung/exynos4_common/exynos4_common.c
> new file mode 100644
> index 0000000..f2413e5
> --- /dev/null
> +++ b/board/samsung/exynos4_common/exynos4_common.c

I'll reject your patch.
It's not a standard way, I think..

> +#ifdef CONFIG_REVISION_TAG
> +u32 get_board_rev(void)
> +{
> +       return board_rev;
> +}
> +#endif
> +
> +int dram_init(void)
> +{
> +       gd->ram_size    = get_ram_size((long *)PHYS_SDRAM_1,
PHYS_SDRAM_1_SIZE)
> +                       + get_ram_size((long *)PHYS_SDRAM_2, 
> +PHYS_SDRAM_2_SIZE); #if CONFIG_NR_DRAM_BANKS == 4
> +       gd->ram_size    += get_ram_size((long *)PHYS_SDRAM_3,
PHYS_SDRAM_3_SIZE)
> +                       + get_ram_size((long *)PHYS_SDRAM_4, 
> +PHYS_SDRAM_4_SIZE); #endif
> +       return 0;
> +}
> +
> +void dram_init_banksize(void)
> +{
> +       gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
> +       gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \
> +
PHYS_SDRAM_1_SIZE);
> +       gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
> +       gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
> +                                                       
> +PHYS_SDRAM_2_SIZE); #if CONFIG_NR_DRAM_BANKS == 4
> +       gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
> +       gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \
> +
PHYS_SDRAM_3_SIZE);
> +       gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
> +       gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \
> +                                                       
> +PHYS_SDRAM_4_SIZE); #endif }

also, this is not a common function.
Although they are almost same, but I think it's a board specific.
Please don't move it.

> +
> +int exynos4_mmc_init(struct exynos4_gpio_part2 *gpio2)

How about using pinmux instead?

Thanks.
Minkyu Kang.
--
from. prom.
www.promsoft.net
Piotr Wilczek Aug. 23, 2012, 12:01 p.m. UTC | #3
This patch fixes SDRAM configuration and size visibility fot Trats board.

Code for MMC initialisation is moved from board file to pinmux.
MMC0 and MMC2 are supported. Both tested on Trats and Universal C210 boards.
MMC initialisation for boards Trats and Universal C210 is done using pinmux.

Low level initialisation in u-boot is eliminated as it done by
previous bootloader.

Piotr Wilczek (6):
  arm:exynos4:trats: Correct SDRAM configuration for trats
  arm:exynos4:trats: Fix SDRAM size
  arm:exynos4:pinmux: Modify the gpio function for mmc
  arm:exynos4:trats: Use pinmux for mmc configuration
  arm:exynos4:universal: Use pinmux for mmc configuration
  arm:exynos4:universal: Eliminated low level init

 arch/arm/cpu/armv7/exynos/pinmux.c           |   56 ++++
 arch/arm/include/asm/arch-exynos/periph.h    |    1 +
 board/samsung/trats/trats.c                  |   70 ++----
 board/samsung/universal_c210/Makefile        |    1 -
 board/samsung/universal_c210/lowlevel_init.S |  395 --------------------------
 board/samsung/universal_c210/universal.c     |   78 ++----
 include/configs/s5pc210_universal.h          |    2 +
 include/configs/trats.h                      |   17 +-
 8 files changed, 111 insertions(+), 509 deletions(-)
 delete mode 100644 board/samsung/universal_c210/lowlevel_init.S
diff mbox

Patch

diff --git a/board/samsung/exynos4_common/exynos4_common.c b/board/samsung/exynos4_common/exynos4_common.c
new file mode 100644
index 0000000..f2413e5
--- /dev/null
+++ b/board/samsung/exynos4_common/exynos4_common.c
@@ -0,0 +1,139 @@ 
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ * Heungjun Kim <riverful.kim@samsung.com>
+ * Kyungmin Park <kyungmin.park@samsung.com>
+ * Donghwa Lee <dh09.lee@samsung.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+#ifdef CONFIG_REVISION_TAG
+u32 get_board_rev(void)
+{
+	return board_rev;
+}
+#endif
+
+int dram_init(void)
+{
+	gd->ram_size	= get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
+			+ get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+#if CONFIG_NR_DRAM_BANKS == 4
+	gd->ram_size	+= get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
+			+ get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
+#endif
+	return 0;
+}
+
+void dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \
+							PHYS_SDRAM_1_SIZE);
+	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
+	gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
+							PHYS_SDRAM_2_SIZE);
+#if CONFIG_NR_DRAM_BANKS == 4
+	gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
+	gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \
+							PHYS_SDRAM_3_SIZE);
+	gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
+	gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \
+							PHYS_SDRAM_4_SIZE);
+#endif
+}
+
+int exynos4_mmc_init(struct exynos4_gpio_part2 *gpio2)
+{
+	int i, err;
+
+	/*
+	 * eMMC GPIO:
+	 * SDR 8-bit@48MHz at MMC0
+	 * GPK0[0]	SD_0_CLK(2)
+	 * GPK0[1]	SD_0_CMD(2)
+	 * GPK0[2]	SD_0_CDn	-> Not used
+	 * GPK0[3:6]	SD_0_DATA[0:3](2)
+	 * GPK1[3:6]	SD_0_DATA[0:3](3)
+	 *
+	 * DDR 4-bit@26MHz at MMC4
+	 * GPK0[0]	SD_4_CLK(3)
+	 * GPK0[1]	SD_4_CMD(3)
+	 * GPK0[2]	SD_4_CDn	-> Not used
+	 * GPK0[3:6]	SD_4_DATA[0:3](3)
+	 * GPK1[3:6]	SD_4_DATA[4:7](4)
+	 */
+	for (i = 0; i < 7; i++) {
+		if (i == 2)
+			continue;
+		/* GPK0[0:6] special function 2 */
+		s5p_gpio_cfg_pin(&gpio2->k0, i, 0x2);
+		/* GPK0[0:6] pull disable */
+		s5p_gpio_set_pull(&gpio2->k0, i, GPIO_PULL_NONE);
+		/* GPK0[0:6] drv 4x */
+		s5p_gpio_set_drv(&gpio2->k0, i, GPIO_DRV_4X);
+	}
+
+	for (i = 3; i < 7; i++) {
+		/* GPK1[3:6] special function 3 */
+		s5p_gpio_cfg_pin(&gpio2->k1, i, 0x3);
+		/* GPK1[3:6] pull disable */
+		s5p_gpio_set_pull(&gpio2->k1, i, GPIO_PULL_NONE);
+		/* GPK1[3:6] drv 4x */
+		s5p_gpio_set_drv(&gpio2->k1, i, GPIO_DRV_4X);
+	}
+
+	/* T-flash detect */
+	s5p_gpio_cfg_pin(&gpio2->x3, 4, 0xf);
+	s5p_gpio_set_pull(&gpio2->x3, 4, GPIO_PULL_UP);
+
+	/*
+	 * MMC device init
+	 * mmc0	 : eMMC (8-bit buswidth)
+	 * mmc2	 : SD card (4-bit buswidth)
+	 */
+	err = s5p_mmc_init(0, 8);
+
+	/*
+	 * Check the T-flash  detect pin
+	 * GPX3[4] T-flash detect pin
+	 */
+	if (!s5p_gpio_get_value(&gpio2->x3, 4)) {
+		/*
+		 * SD card GPIO:
+		 * GPK2[0]	SD_2_CLK(2)
+		 * GPK2[1]	SD_2_CMD(2)
+		 * GPK2[2]	SD_2_CDn	-> Not used
+		 * GPK2[3:6]	SD_2_DATA[0:3](2)
+		 */
+		for (i = 0; i < 7; i++) {
+			if (i == 2)
+				continue;
+			/* GPK2[0:6] special function 2 */
+			s5p_gpio_cfg_pin(&gpio2->k2, i, 0x2);
+			/* GPK2[0:6] pull disable */
+			s5p_gpio_set_pull(&gpio2->k2, i, GPIO_PULL_NONE);
+			/* GPK2[0:6] drv 4x */
+			s5p_gpio_set_drv(&gpio2->k2, i, GPIO_DRV_4X);
+		}
+		err = s5p_mmc_init(2, 4);
+	}
+
+	return err;
+}
diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index f5df56c..7425215 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -45,12 +45,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 unsigned int board_rev;
 
-#ifdef CONFIG_REVISION_TAG
-u32 get_board_rev(void)
-{
-	return board_rev;
-}
-#endif
+#include "../exynos4_common/exynos4_common.c"
 
 static void check_hw_revision(void);
 
@@ -73,28 +68,6 @@  int board_init(void)
 	return 0;
 }
 
-int dram_init(void)
-{
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
-
-	return 0;
-}
-
-void dram_init_banksize(void)
-{
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
-	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
-	gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
-	gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
-	gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
-	gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
-	gd->bd->bi_dram[3].size = PHYS_SDRAM_4_SIZE;
-}
-
 static unsigned int get_hw_revision(void)
 {
 	struct exynos4_gpio_part1 *gpio =
@@ -140,85 +113,12 @@  int board_mmc_init(bd_t *bis)
 {
 	struct exynos4_gpio_part2 *gpio =
 		(struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
-	int i, err;
 
 	/* eMMC_EN: SD_0_CDn: GPK0[2] Output High */
 	s5p_gpio_direction_output(&gpio->k0, 2, 1);
 	s5p_gpio_set_pull(&gpio->k0, 2, GPIO_PULL_NONE);
 
-	/*
-	 * eMMC GPIO:
-	 * SDR 8-bit@48MHz at MMC0
-	 * GPK0[0]	SD_0_CLK(2)
-	 * GPK0[1]	SD_0_CMD(2)
-	 * GPK0[2]	SD_0_CDn	-> Not used
-	 * GPK0[3:6]	SD_0_DATA[0:3](2)
-	 * GPK1[3:6]	SD_0_DATA[0:3](3)
-	 *
-	 * DDR 4-bit@26MHz at MMC4
-	 * GPK0[0]	SD_4_CLK(3)
-	 * GPK0[1]	SD_4_CMD(3)
-	 * GPK0[2]	SD_4_CDn	-> Not used
-	 * GPK0[3:6]	SD_4_DATA[0:3](3)
-	 * GPK1[3:6]	SD_4_DATA[4:7](4)
-	 */
-	for (i = 0; i < 7; i++) {
-		if (i == 2)
-			continue;
-		/* GPK0[0:6] special function 2 */
-		s5p_gpio_cfg_pin(&gpio->k0, i, 0x2);
-		/* GPK0[0:6] pull disable */
-		s5p_gpio_set_pull(&gpio->k0, i, GPIO_PULL_NONE);
-		/* GPK0[0:6] drv 4x */
-		s5p_gpio_set_drv(&gpio->k0, i, GPIO_DRV_4X);
-	}
-
-	for (i = 3; i < 7; i++) {
-		/* GPK1[3:6] special function 3 */
-		s5p_gpio_cfg_pin(&gpio->k1, i, 0x3);
-		/* GPK1[3:6] pull disable */
-		s5p_gpio_set_pull(&gpio->k1, i, GPIO_PULL_NONE);
-		/* GPK1[3:6] drv 4x */
-		s5p_gpio_set_drv(&gpio->k1, i, GPIO_DRV_4X);
-	}
-
-	/*
-	 * MMC device init
-	 * mmc0	 : eMMC (8-bit buswidth)
-	 * mmc2	 : SD card (4-bit buswidth)
-	 */
-	err = s5p_mmc_init(0, 8);
-
-	/* T-flash detect */
-	s5p_gpio_cfg_pin(&gpio->x3, 4, 0xf);
-	s5p_gpio_set_pull(&gpio->x3, 4, GPIO_PULL_UP);
-
-	/*
-	 * Check the T-flash  detect pin
-	 * GPX3[4] T-flash detect pin
-	 */
-	if (!s5p_gpio_get_value(&gpio->x3, 4)) {
-		/*
-		 * SD card GPIO:
-		 * GPK2[0]	SD_2_CLK(2)
-		 * GPK2[1]	SD_2_CMD(2)
-		 * GPK2[2]	SD_2_CDn	-> Not used
-		 * GPK2[3:6]	SD_2_DATA[0:3](2)
-		 */
-		for (i = 0; i < 7; i++) {
-			if (i == 2)
-				continue;
-			/* GPK2[0:6] special function 2 */
-			s5p_gpio_cfg_pin(&gpio->k2, i, 0x2);
-			/* GPK2[0:6] pull disable */
-			s5p_gpio_set_pull(&gpio->k2, i, GPIO_PULL_NONE);
-			/* GPK2[0:6] drv 4x */
-			s5p_gpio_set_drv(&gpio->k2, i, GPIO_DRV_4X);
-		}
-		err = s5p_mmc_init(2, 4);
-	}
-
-	return err;
+	return exynos4_mmc_init(gpio);
 }
 #endif
 
diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index 90fff5c..a64eba0 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -38,10 +38,7 @@  struct exynos4_gpio_part1 *gpio1;
 struct exynos4_gpio_part2 *gpio2;
 unsigned int board_rev;
 
-u32 get_board_rev(void)
-{
-	return board_rev;
-}
+#include "../exynos4_common/exynos4_common.c"
 
 static int get_hwrev(void)
 {
@@ -68,22 +65,6 @@  int board_init(void)
 	return 0;
 }
 
-int dram_init(void)
-{
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
-
-	return 0;
-}
-
-void dram_init_banksize(void)
-{
-	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
-	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
-	gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
-}
-
 static unsigned short get_adc_value(int channel)
 {
 	struct s5p_adc *adc = (struct s5p_adc *)samsung_get_base_adc();
@@ -177,8 +158,6 @@  int checkboard(void)
 #ifdef CONFIG_GENERIC_MMC
 int board_mmc_init(bd_t *bis)
 {
-	int i, err;
-
 	switch (get_hwrev()) {
 	case 0:
 		/*
@@ -199,80 +178,7 @@  int board_mmc_init(bd_t *bis)
 		break;
 	}
 
-	/*
-	 * eMMC GPIO:
-	 * SDR 8-bit@48MHz at MMC0
-	 * GPK0[0]	SD_0_CLK(2)
-	 * GPK0[1]	SD_0_CMD(2)
-	 * GPK0[2]	SD_0_CDn	-> Not used
-	 * GPK0[3:6]	SD_0_DATA[0:3](2)
-	 * GPK1[3:6]	SD_0_DATA[0:3](3)
-	 *
-	 * DDR 4-bit@26MHz at MMC4
-	 * GPK0[0]	SD_4_CLK(3)
-	 * GPK0[1]	SD_4_CMD(3)
-	 * GPK0[2]	SD_4_CDn	-> Not used
-	 * GPK0[3:6]	SD_4_DATA[0:3](3)
-	 * GPK1[3:6]	SD_4_DATA[4:7](4)
-	 */
-	for (i = 0; i < 7; i++) {
-		if (i == 2)
-			continue;
-		/* GPK0[0:6] special function 2 */
-		s5p_gpio_cfg_pin(&gpio2->k0, i, 0x2);
-		/* GPK0[0:6] pull disable */
-		s5p_gpio_set_pull(&gpio2->k0, i, GPIO_PULL_NONE);
-		/* GPK0[0:6] drv 4x */
-		s5p_gpio_set_drv(&gpio2->k0, i, GPIO_DRV_4X);
-	}
-
-	for (i = 3; i < 7; i++) {
-		/* GPK1[3:6] special function 3 */
-		s5p_gpio_cfg_pin(&gpio2->k1, i, 0x3);
-		/* GPK1[3:6] pull disable */
-		s5p_gpio_set_pull(&gpio2->k1, i, GPIO_PULL_NONE);
-		/* GPK1[3:6] drv 4x */
-		s5p_gpio_set_drv(&gpio2->k1, i, GPIO_DRV_4X);
-	}
-
-	/* T-flash detect */
-	s5p_gpio_cfg_pin(&gpio2->x3, 4, 0xf);
-	s5p_gpio_set_pull(&gpio2->x3, 4, GPIO_PULL_UP);
-
-	/*
-	 * MMC device init
-	 * mmc0	 : eMMC (8-bit buswidth)
-	 * mmc2	 : SD card (4-bit buswidth)
-	 */
-	err = s5p_mmc_init(0, 8);
-
-	/*
-	 * Check the T-flash  detect pin
-	 * GPX3[4] T-flash detect pin
-	 */
-	if (!s5p_gpio_get_value(&gpio2->x3, 4)) {
-		/*
-		 * SD card GPIO:
-		 * GPK2[0]	SD_2_CLK(2)
-		 * GPK2[1]	SD_2_CMD(2)
-		 * GPK2[2]	SD_2_CDn	-> Not used
-		 * GPK2[3:6]	SD_2_DATA[0:3](2)
-		 */
-		for (i = 0; i < 7; i++) {
-			if (i == 2)
-				continue;
-			/* GPK2[0:6] special function 2 */
-			s5p_gpio_cfg_pin(&gpio2->k2, i, 0x2);
-			/* GPK2[0:6] pull disable */
-			s5p_gpio_set_pull(&gpio2->k2, i, GPIO_PULL_NONE);
-			/* GPK2[0:6] drv 4x */
-			s5p_gpio_set_drv(&gpio2->k2, i, GPIO_DRV_4X);
-		}
-		err = s5p_mmc_init(2, 4);
-	}
-
-	return err;
-
+	return exynos4_mmc_init(gpio2);
 }
 #endif