ar71xx: restore rb4xx kernel partition size to the original value
[openwrt/staging/wigyori.git] / target / linux / ar71xx / files / drivers / mtd / nand / rb4xx_nand.c
index ca9d8adb59be6298ebde9d091592b76a64da4b4c..a007484b2e76c83c9b96c4be7f7b723d626e9c8d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  NAND flash driver for the MikroTik RouterBoard 4xx series
  *
- *  Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  *
  *  This file was based on the driver for Linux 2.6.22 published by
@@ -12,6 +12,8 @@
  *  by the Free Software Foundation.
  */
 
+#include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/mtd.h>
@@ -22,8 +24,8 @@
 #include <linux/gpio.h>
 #include <linux/slab.h>
 
-#include <asm/mach-ar71xx/ar71xx.h>
-#include <asm/mach-ar71xx/rb4xx_cpld.h>
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/rb4xx_cpld.h>
 
 #define DRV_NAME        "rb4xx-nand"
 #define DRV_VERSION     "0.2.0"
@@ -60,7 +62,7 @@ static struct mtd_partition rb4xx_nand_partitions[] = {
        {
                .name   = "kernel",
                .offset = (256 * 1024),
-               .size   = (6 * 1024 * 1024) - (256 * 1024),
+               .size   = (4 * 1024 * 1024) - (256 * 1024),
        },
        {
                .name   = "rootfs",
@@ -71,7 +73,7 @@ static struct mtd_partition rb4xx_nand_partitions[] = {
 
 static int rb4xx_nand_dev_ready(struct mtd_info *mtd)
 {
-       return gpio_get_value(RB4XX_NAND_GPIO_READY);
+       return gpio_get_value_cansleep(RB4XX_NAND_GPIO_READY);
 }
 
 static void rb4xx_nand_write_cmd(unsigned char cmd)
@@ -88,9 +90,12 @@ static void rb4xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
                                unsigned int ctrl)
 {
        if (ctrl & NAND_CTRL_CHANGE) {
-               gpio_set_value(RB4XX_NAND_GPIO_CLE, (ctrl & NAND_CLE) ? 1 : 0);
-               gpio_set_value(RB4XX_NAND_GPIO_ALE, (ctrl & NAND_ALE) ? 1 : 0);
-               gpio_set_value(RB4XX_NAND_GPIO_NCE, (ctrl & NAND_NCE) ? 0 : 1);
+               gpio_set_value_cansleep(RB4XX_NAND_GPIO_CLE,
+                                       (ctrl & NAND_CLE) ? 1 : 0);
+               gpio_set_value_cansleep(RB4XX_NAND_GPIO_ALE,
+                                       (ctrl & NAND_ALE) ? 1 : 0);
+               gpio_set_value_cansleep(RB4XX_NAND_GPIO_NCE,
+                                       (ctrl & NAND_NCE) ? 0 : 1);
        }
 
        if (cmd != NAND_CMD_NONE)
@@ -131,7 +136,7 @@ static void rb4xx_nand_read_buf(struct mtd_info *mtd, unsigned char *buf,
                pr_err("rb4xx_nand: read buf failed, err=%d\n", err);
 }
 
-static int __init rb4xx_nand_probe(struct platform_device *pdev)
+static int __devinit rb4xx_nand_probe(struct platform_device *pdev)
 {
        struct rb4xx_nand_info  *info;
        int ret;
@@ -210,15 +215,16 @@ static int __init rb4xx_nand_probe(struct platform_device *pdev)
        info->chip.read_byte    = rb4xx_nand_read_byte;
        info->chip.write_buf    = rb4xx_nand_write_buf;
        info->chip.read_buf     = rb4xx_nand_read_buf;
-//     info->chip.verify_buf   = rb4xx_nand_verify_buf;
+#if 0
+       info->chip.verify_buf   = rb4xx_nand_verify_buf;
+#endif
 
        info->chip.chip_delay   = 25;
        info->chip.ecc.mode     = NAND_ECC_SOFT;
-       info->chip.options      |= NAND_NO_AUTOINCR;
 
        platform_set_drvdata(pdev, info);
 
-       ret = nand_scan_ident(&info->mtd, 1);
+       ret = nand_scan_ident(&info->mtd, 1, NULL);
        if (ret) {
                ret = -ENXIO;
                goto err_free_info;
@@ -233,32 +239,28 @@ static int __init rb4xx_nand_probe(struct platform_device *pdev)
                goto err_set_drvdata;
        }
 
-#ifdef CONFIG_MTD_PARTITIONS
-       ret = add_mtd_partitions(&info->mtd, rb4xx_nand_partitions,
+       mtd_device_register(&info->mtd, rb4xx_nand_partitions,
                                ARRAY_SIZE(rb4xx_nand_partitions));
-#else
-       ret = add_mtd_device(&info->mtd);
-#endif
        if (ret)
                goto err_release_nand;
 
        return 0;
 
- err_release_nand:
+err_release_nand:
        nand_release(&info->mtd);
- err_set_drvdata:
+err_set_drvdata:
        platform_set_drvdata(pdev, NULL);
- err_free_info:
+err_free_info:
        kfree(info);
- err_free_gpio_nce:
+err_free_gpio_nce:
        gpio_free(RB4XX_NAND_GPIO_NCE);
- err_free_gpio_cle:
+err_free_gpio_cle:
        gpio_free(RB4XX_NAND_GPIO_CLE);
- err_free_gpio_ale:
+err_free_gpio_ale:
        gpio_free(RB4XX_NAND_GPIO_ALE);
- err_free_gpio_ready:
+err_free_gpio_ready:
        gpio_free(RB4XX_NAND_GPIO_READY);
- err:
+err:
        return ret;
 }