#include <common.h>
 
 #include <nand.h>
+#include <linux/mtd/nand.h>
+
 #include <asm/arch/s3c6400.h>
 
 #include <asm/io.h>
 }
 #endif /* S3C_NAND_DEBUG */
 
-#ifdef CONFIG_NAND_SPL
-static u_char nand_read_byte(struct mtd_info *mtd)
-{
-       struct nand_chip *this = mtd->priv;
-       return readb(this->IO_ADDR_R);
-}
-
-static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i = 0; i < len; i++)
-               writeb(buf[i], this->IO_ADDR_W);
-}
-
-static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
-{
-       int i;
-       struct nand_chip *this = mtd->priv;
-
-       for (i = 0; i < len; i++)
-               buf[i] = readb(this->IO_ADDR_R);
-}
-#endif
-
 static void s3c_nand_select_chip(struct mtd_info *mtd, int chip)
 {
        int ctrl = readl(NFCONT);
 
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
-          $(LDFLAGS_FINAL)
+               $(LDFLAGS_FINAL) -gc-sections
 AFLAGS += -DCONFIG_NAND_SPL
-CFLAGS += -DCONFIG_NAND_SPL
+CFLAGS += -DCONFIG_NAND_SPL -ffunction-sections
 
 SOBJS  = start.o cpu_init.o lowlevel_init.o
-COBJS  = nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o
+COBJS  = nand_boot.o nand_ecc.o s3c64xx.o smdk6400_nand_spl.o nand_base.o
 
 SRCS   := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS   := $(addprefix $(obj),$(SOBJS) $(COBJS))
        @rm -f $@
        @ln -s $(TOPDIR)/board/samsung/smdk6400/smdk6400_nand_spl.c $@
 
+$(obj)nand_base.c:
+       @rm -f $@
+       @ln -s $(TOPDIR)/drivers/mtd/nand/nand_base.c $@
 #########################################################################
 
 $(obj)%.o:     $(obj)%.S