[ar71xx] refresh 3.2 patches
[openwrt.git] / target / linux / ar71xx / patches-3.2 / 303-rb750_nand-3.2-fixes.patch
1 --- a/drivers/mtd/nand/rb750_nand.c
2 +++ b/drivers/mtd/nand/rb750_nand.c
3 @@ -1,14 +1,15 @@
4  /*
5   *  NAND flash driver for the MikroTik RouterBOARD 750
6   *
7 - *  Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
8 + *  Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
9   *
10   *  This program is free software; you can redistribute it and/or modify it
11   *  under the terms of the GNU General Public License version 2 as published
12   *  by the Free Software Foundation.
13   */
14  
15 -#include <linux/init.h>
16 +#include <linux/kernel.h>
17 +#include <linux/module.h>
18  #include <linux/mtd/nand.h>
19  #include <linux/mtd/mtd.h>
20  #include <linux/mtd/partitions.h>
21 @@ -16,8 +17,9 @@
22  #include <linux/io.h>
23  #include <linux/slab.h>
24  
25 -#include <asm/mach-ar71xx/ar71xx.h>
26 -#include <asm/mach-ar71xx/mach-rb750.h>
27 +#include <asm/mach-ath79/ar71xx_regs.h>
28 +#include <asm/mach-ath79/ath79.h>
29 +#include <asm/mach-ath79/mach-rb750.h>
30  
31  #define DRV_NAME       "rb750-nand"
32  #define DRV_VERSION    "0.1.0"
33 @@ -73,7 +75,7 @@ static struct mtd_partition rb750_nand_p
34  
35  static void rb750_nand_write(const u8 *buf, unsigned len)
36  {
37 -       void __iomem *base = ar71xx_gpio_base;
38 +       void __iomem *base = ath79_gpio_base;
39         u32 out;
40         u32 t;
41         unsigned i;
42 @@ -107,7 +109,7 @@ static void rb750_nand_write(const u8 *b
43  static int rb750_nand_read_verify(u8 *read_buf, unsigned len,
44                                   const u8 *verify_buf)
45  {
46 -       void __iomem *base = ar71xx_gpio_base;
47 +       void __iomem *base = ath79_gpio_base;
48         unsigned i;
49  
50         for (i = 0; i < len; i++) {
51 @@ -136,7 +138,7 @@ static int rb750_nand_read_verify(u8 *re
52  
53  static void rb750_nand_select_chip(struct mtd_info *mtd, int chip)
54  {
55 -       void __iomem *base = ar71xx_gpio_base;
56 +       void __iomem *base = ath79_gpio_base;
57         u32 func;
58         u32 t;
59  
60 @@ -145,9 +147,7 @@ static void rb750_nand_select_chip(struc
61                 /* disable latch */
62                 rb750_latch_change(RB750_LVC573_LE, 0);
63  
64 -               /* disable alternate functions */
65 -               ar71xx_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
66 -                                          AR724X_GPIO_FUNC_SPI_EN);
67 +               rb750_nand_pins_enable();
68  
69                 /* set input mode for data lines */
70                 t = __raw_readl(base + AR71XX_GPIO_REG_OE);
71 @@ -172,9 +172,7 @@ static void rb750_nand_select_chip(struc
72                 __raw_writel(t | RB750_NAND_IO0 | RB750_NAND_RDY,
73                              base + AR71XX_GPIO_REG_OE);
74  
75 -               /* restore alternate functions */
76 -               ar71xx_gpio_function_setup(AR724X_GPIO_FUNC_SPI_EN,
77 -                                          AR724X_GPIO_FUNC_JTAG_DISABLE);
78 +               rb750_nand_pins_disable();
79  
80                 /* enable latch */
81                 rb750_latch_change(0, RB750_LVC573_LE);
82 @@ -183,7 +181,7 @@ static void rb750_nand_select_chip(struc
83  
84  static int rb750_nand_dev_ready(struct mtd_info *mtd)
85  {
86 -       void __iomem *base = ar71xx_gpio_base;
87 +       void __iomem *base = ath79_gpio_base;
88  
89         return !!(__raw_readl(base + AR71XX_GPIO_REG_IN) & RB750_NAND_RDY);
90  }
91 @@ -192,7 +190,7 @@ static void rb750_nand_cmd_ctrl(struct m
92                                 unsigned int ctrl)
93  {
94         if (ctrl & NAND_CTRL_CHANGE) {
95 -               void __iomem *base = ar71xx_gpio_base;
96 +               void __iomem *base = ath79_gpio_base;
97                 u32 t;
98  
99                 t = __raw_readl(base + AR71XX_GPIO_REG_OUT);
100 @@ -236,7 +234,7 @@ static int rb750_nand_verify_buf(struct
101  
102  static void __init rb750_nand_gpio_init(void)
103  {
104 -       void __iomem *base = ar71xx_gpio_base;
105 +       void __iomem *base = ath79_gpio_base;
106         u32 out;
107         u32 t;
108  
109 @@ -306,12 +304,8 @@ static int __devinit rb750_nand_probe(st
110                 goto err_set_drvdata;
111         }
112  
113 -#ifdef CONFIG_MTD_PARTITIONS
114 -       ret = add_mtd_partitions(&info->mtd, rb750_nand_partitions,
115 +       ret = mtd_device_register(&info->mtd, rb750_nand_partitions,
116                                  ARRAY_SIZE(rb750_nand_partitions));
117 -#else
118 -       ret = add_mtd_device(&info->mtd);
119 -#endif
120         if (ret)
121                 goto err_release_nand;
122