Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * drivers/mtd/nand/gpio.c |
| 3 | * |
| 4 | * Updated, and converted to generic GPIO based driver by Russell King. |
| 5 | * |
| 6 | * Written by Ben Dooks <ben@simtec.co.uk> |
| 7 | * Based on 2.4 version by Mark Whittaker |
| 8 | * |
| 9 | * © 2004 Simtec Electronics |
| 10 | * |
| 11 | * Device driver for NAND connected via GPIO |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License version 2 as |
| 15 | * published by the Free Software Foundation. |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #include <linux/kernel.h> |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 20 | #include <linux/err.h> |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 21 | #include <linux/init.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/gpio.h> |
| 26 | #include <linux/io.h> |
| 27 | #include <linux/mtd/mtd.h> |
| 28 | #include <linux/mtd/nand.h> |
| 29 | #include <linux/mtd/partitions.h> |
| 30 | #include <linux/mtd/nand-gpio.h> |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 31 | #include <linux/of.h> |
| 32 | #include <linux/of_address.h> |
| 33 | #include <linux/of_gpio.h> |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 34 | |
| 35 | struct gpiomtd { |
| 36 | void __iomem *io_sync; |
| 37 | struct mtd_info mtd_info; |
| 38 | struct nand_chip nand_chip; |
| 39 | struct gpio_nand_platdata plat; |
| 40 | }; |
| 41 | |
| 42 | #define gpio_nand_getpriv(x) container_of(x, struct gpiomtd, mtd_info) |
| 43 | |
| 44 | |
| 45 | #ifdef CONFIG_ARM |
| 46 | /* gpio_nand_dosync() |
| 47 | * |
| 48 | * Make sure the GPIO state changes occur in-order with writes to NAND |
| 49 | * memory region. |
| 50 | * Needed on PXA due to bus-reordering within the SoC itself (see section on |
| 51 | * I/O ordering in PXA manual (section 2.3, p35) |
| 52 | */ |
| 53 | static void gpio_nand_dosync(struct gpiomtd *gpiomtd) |
| 54 | { |
| 55 | unsigned long tmp; |
| 56 | |
| 57 | if (gpiomtd->io_sync) { |
| 58 | /* |
| 59 | * Linux memory barriers don't cater for what's required here. |
| 60 | * What's required is what's here - a read from a separate |
| 61 | * region with a dependency on that read. |
| 62 | */ |
| 63 | tmp = readl(gpiomtd->io_sync); |
| 64 | asm volatile("mov %1, %0\n" : "=r" (tmp) : "r" (tmp)); |
| 65 | } |
| 66 | } |
| 67 | #else |
| 68 | static inline void gpio_nand_dosync(struct gpiomtd *gpiomtd) {} |
| 69 | #endif |
| 70 | |
| 71 | static void gpio_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
| 72 | { |
| 73 | struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd); |
| 74 | |
| 75 | gpio_nand_dosync(gpiomtd); |
| 76 | |
| 77 | if (ctrl & NAND_CTRL_CHANGE) { |
| 78 | gpio_set_value(gpiomtd->plat.gpio_nce, !(ctrl & NAND_NCE)); |
| 79 | gpio_set_value(gpiomtd->plat.gpio_cle, !!(ctrl & NAND_CLE)); |
| 80 | gpio_set_value(gpiomtd->plat.gpio_ale, !!(ctrl & NAND_ALE)); |
| 81 | gpio_nand_dosync(gpiomtd); |
| 82 | } |
| 83 | if (cmd == NAND_CMD_NONE) |
| 84 | return; |
| 85 | |
| 86 | writeb(cmd, gpiomtd->nand_chip.IO_ADDR_W); |
| 87 | gpio_nand_dosync(gpiomtd); |
| 88 | } |
| 89 | |
| 90 | static void gpio_nand_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
| 91 | { |
| 92 | struct nand_chip *this = mtd->priv; |
| 93 | |
Matthew Leach | 8204536 | 2012-12-10 19:12:39 +0000 | [diff] [blame] | 94 | iowrite8_rep(this->IO_ADDR_W, buf, len); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | static void gpio_nand_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
| 98 | { |
| 99 | struct nand_chip *this = mtd->priv; |
| 100 | |
Matthew Leach | 8204536 | 2012-12-10 19:12:39 +0000 | [diff] [blame] | 101 | ioread8_rep(this->IO_ADDR_R, buf, len); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 102 | } |
| 103 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 104 | static void gpio_nand_writebuf16(struct mtd_info *mtd, const u_char *buf, |
| 105 | int len) |
| 106 | { |
| 107 | struct nand_chip *this = mtd->priv; |
| 108 | |
| 109 | if (IS_ALIGNED((unsigned long)buf, 2)) { |
Matthew Leach | 8204536 | 2012-12-10 19:12:39 +0000 | [diff] [blame] | 110 | iowrite16_rep(this->IO_ADDR_W, buf, len>>1); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 111 | } else { |
| 112 | int i; |
| 113 | unsigned short *ptr = (unsigned short *)buf; |
| 114 | |
| 115 | for (i = 0; i < len; i += 2, ptr++) |
| 116 | writew(*ptr, this->IO_ADDR_W); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | static void gpio_nand_readbuf16(struct mtd_info *mtd, u_char *buf, int len) |
| 121 | { |
| 122 | struct nand_chip *this = mtd->priv; |
| 123 | |
| 124 | if (IS_ALIGNED((unsigned long)buf, 2)) { |
Matthew Leach | 8204536 | 2012-12-10 19:12:39 +0000 | [diff] [blame] | 125 | ioread16_rep(this->IO_ADDR_R, buf, len>>1); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 126 | } else { |
| 127 | int i; |
| 128 | unsigned short *ptr = (unsigned short *)buf; |
| 129 | |
| 130 | for (i = 0; i < len; i += 2, ptr++) |
| 131 | *ptr = readw(this->IO_ADDR_R); |
| 132 | } |
| 133 | } |
| 134 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 135 | static int gpio_nand_devready(struct mtd_info *mtd) |
| 136 | { |
| 137 | struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd); |
Alexander Shiyan | 18afbc5 | 2012-10-17 10:08:27 +0400 | [diff] [blame] | 138 | |
Alexander Shiyan | c85d32d5 | 2013-05-06 17:53:49 +0400 | [diff] [blame] | 139 | return gpio_get_value(gpiomtd->plat.gpio_rdy); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 140 | } |
| 141 | |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 142 | #ifdef CONFIG_OF |
| 143 | static const struct of_device_id gpio_nand_id_table[] = { |
| 144 | { .compatible = "gpio-control-nand" }, |
| 145 | {} |
| 146 | }; |
| 147 | MODULE_DEVICE_TABLE(of, gpio_nand_id_table); |
| 148 | |
| 149 | static int gpio_nand_get_config_of(const struct device *dev, |
| 150 | struct gpio_nand_platdata *plat) |
| 151 | { |
| 152 | u32 val; |
| 153 | |
Alexander Shiyan | ee4f366 | 2013-05-06 17:53:50 +0400 | [diff] [blame^] | 154 | if (!dev->of_node) |
| 155 | return -ENODEV; |
| 156 | |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 157 | if (!of_property_read_u32(dev->of_node, "bank-width", &val)) { |
| 158 | if (val == 2) { |
| 159 | plat->options |= NAND_BUSWIDTH_16; |
| 160 | } else if (val != 1) { |
| 161 | dev_err(dev, "invalid bank-width %u\n", val); |
| 162 | return -EINVAL; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | plat->gpio_rdy = of_get_gpio(dev->of_node, 0); |
| 167 | plat->gpio_nce = of_get_gpio(dev->of_node, 1); |
| 168 | plat->gpio_ale = of_get_gpio(dev->of_node, 2); |
| 169 | plat->gpio_cle = of_get_gpio(dev->of_node, 3); |
| 170 | plat->gpio_nwp = of_get_gpio(dev->of_node, 4); |
| 171 | |
| 172 | if (!of_property_read_u32(dev->of_node, "chip-delay", &val)) |
| 173 | plat->chip_delay = val; |
| 174 | |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | static struct resource *gpio_nand_get_io_sync_of(struct platform_device *pdev) |
| 179 | { |
| 180 | struct resource *r = devm_kzalloc(&pdev->dev, sizeof(*r), GFP_KERNEL); |
| 181 | u64 addr; |
| 182 | |
| 183 | if (!r || of_property_read_u64(pdev->dev.of_node, |
| 184 | "gpio-control-nand,io-sync-reg", &addr)) |
| 185 | return NULL; |
| 186 | |
| 187 | r->start = addr; |
| 188 | r->end = r->start + 0x3; |
| 189 | r->flags = IORESOURCE_MEM; |
| 190 | |
| 191 | return r; |
| 192 | } |
| 193 | #else /* CONFIG_OF */ |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 194 | static inline int gpio_nand_get_config_of(const struct device *dev, |
| 195 | struct gpio_nand_platdata *plat) |
| 196 | { |
| 197 | return -ENOSYS; |
| 198 | } |
| 199 | |
| 200 | static inline struct resource * |
| 201 | gpio_nand_get_io_sync_of(struct platform_device *pdev) |
| 202 | { |
| 203 | return NULL; |
| 204 | } |
| 205 | #endif /* CONFIG_OF */ |
| 206 | |
| 207 | static inline int gpio_nand_get_config(const struct device *dev, |
| 208 | struct gpio_nand_platdata *plat) |
| 209 | { |
| 210 | int ret = gpio_nand_get_config_of(dev, plat); |
| 211 | |
| 212 | if (!ret) |
| 213 | return ret; |
| 214 | |
| 215 | if (dev->platform_data) { |
| 216 | memcpy(plat, dev->platform_data, sizeof(*plat)); |
| 217 | return 0; |
| 218 | } |
| 219 | |
| 220 | return -EINVAL; |
| 221 | } |
| 222 | |
| 223 | static inline struct resource * |
| 224 | gpio_nand_get_io_sync(struct platform_device *pdev) |
| 225 | { |
| 226 | struct resource *r = gpio_nand_get_io_sync_of(pdev); |
| 227 | |
| 228 | if (r) |
| 229 | return r; |
| 230 | |
| 231 | return platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 232 | } |
| 233 | |
Bill Pemberton | 810b7e0 | 2012-11-19 13:26:04 -0500 | [diff] [blame] | 234 | static int gpio_nand_remove(struct platform_device *dev) |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 235 | { |
| 236 | struct gpiomtd *gpiomtd = platform_get_drvdata(dev); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 237 | |
| 238 | nand_release(&gpiomtd->mtd_info); |
| 239 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 240 | if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) |
| 241 | gpio_set_value(gpiomtd->plat.gpio_nwp, 0); |
| 242 | gpio_set_value(gpiomtd->plat.gpio_nce, 1); |
| 243 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 244 | return 0; |
| 245 | } |
| 246 | |
Bill Pemberton | 06f2551 | 2012-11-19 13:23:07 -0500 | [diff] [blame] | 247 | static int gpio_nand_probe(struct platform_device *dev) |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 248 | { |
| 249 | struct gpiomtd *gpiomtd; |
| 250 | struct nand_chip *this; |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 251 | struct resource *res; |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 252 | struct mtd_part_parser_data ppdata = {}; |
| 253 | int ret = 0; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 254 | |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 255 | if (!dev->dev.of_node && !dev->dev.platform_data) |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 256 | return -EINVAL; |
| 257 | |
Sachin Kamat | b60c724 | 2013-03-14 15:37:02 +0530 | [diff] [blame] | 258 | gpiomtd = devm_kzalloc(&dev->dev, sizeof(*gpiomtd), GFP_KERNEL); |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 259 | if (!gpiomtd) { |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 260 | dev_err(&dev->dev, "failed to create NAND MTD\n"); |
| 261 | return -ENOMEM; |
| 262 | } |
| 263 | |
| 264 | this = &gpiomtd->nand_chip; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 265 | |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 266 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
| 267 | this->IO_ADDR_R = devm_ioremap_resource(&dev->dev, res); |
| 268 | if (IS_ERR(this->IO_ADDR_R)) |
| 269 | return PTR_ERR(this->IO_ADDR_R); |
| 270 | |
| 271 | res = gpio_nand_get_io_sync(dev); |
| 272 | if (res) { |
| 273 | gpiomtd->io_sync = devm_ioremap_resource(&dev->dev, res); |
| 274 | if (IS_ERR(gpiomtd->io_sync)) |
| 275 | return PTR_ERR(gpiomtd->io_sync); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 276 | } |
| 277 | |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 278 | ret = gpio_nand_get_config(&dev->dev, &gpiomtd->plat); |
| 279 | if (ret) |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 280 | return ret; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 281 | |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 282 | ret = devm_gpio_request(&dev->dev, gpiomtd->plat.gpio_nce, "NAND NCE"); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 283 | if (ret) |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 284 | return ret; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 285 | gpio_direction_output(gpiomtd->plat.gpio_nce, 1); |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 286 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 287 | if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) { |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 288 | ret = devm_gpio_request(&dev->dev, gpiomtd->plat.gpio_nwp, |
| 289 | "NAND NWP"); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 290 | if (ret) |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 291 | return ret; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 292 | } |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 293 | |
| 294 | ret = devm_gpio_request(&dev->dev, gpiomtd->plat.gpio_ale, "NAND ALE"); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 295 | if (ret) |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 296 | return ret; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 297 | gpio_direction_output(gpiomtd->plat.gpio_ale, 0); |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 298 | |
| 299 | ret = devm_gpio_request(&dev->dev, gpiomtd->plat.gpio_cle, "NAND CLE"); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 300 | if (ret) |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 301 | return ret; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 302 | gpio_direction_output(gpiomtd->plat.gpio_cle, 0); |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 303 | |
Alexander Shiyan | 18afbc5 | 2012-10-17 10:08:27 +0400 | [diff] [blame] | 304 | if (gpio_is_valid(gpiomtd->plat.gpio_rdy)) { |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 305 | ret = devm_gpio_request(&dev->dev, gpiomtd->plat.gpio_rdy, |
| 306 | "NAND RDY"); |
Alexander Shiyan | 18afbc5 | 2012-10-17 10:08:27 +0400 | [diff] [blame] | 307 | if (ret) |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 308 | return ret; |
Alexander Shiyan | 18afbc5 | 2012-10-17 10:08:27 +0400 | [diff] [blame] | 309 | gpio_direction_input(gpiomtd->plat.gpio_rdy); |
Alexander Shiyan | c85d32d5 | 2013-05-06 17:53:49 +0400 | [diff] [blame] | 310 | this->dev_ready = gpio_nand_devready; |
Alexander Shiyan | 18afbc5 | 2012-10-17 10:08:27 +0400 | [diff] [blame] | 311 | } |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 312 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 313 | this->IO_ADDR_W = this->IO_ADDR_R; |
| 314 | this->ecc.mode = NAND_ECC_SOFT; |
| 315 | this->options = gpiomtd->plat.options; |
| 316 | this->chip_delay = gpiomtd->plat.chip_delay; |
| 317 | |
| 318 | /* install our routines */ |
| 319 | this->cmd_ctrl = gpio_nand_cmd_ctrl; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 320 | |
| 321 | if (this->options & NAND_BUSWIDTH_16) { |
| 322 | this->read_buf = gpio_nand_readbuf16; |
| 323 | this->write_buf = gpio_nand_writebuf16; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 324 | } else { |
| 325 | this->read_buf = gpio_nand_readbuf; |
| 326 | this->write_buf = gpio_nand_writebuf; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | /* set the mtd private data for the nand driver */ |
| 330 | gpiomtd->mtd_info.priv = this; |
| 331 | gpiomtd->mtd_info.owner = THIS_MODULE; |
| 332 | |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 333 | platform_set_drvdata(dev, gpiomtd); |
| 334 | |
| 335 | if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) |
| 336 | gpio_direction_output(gpiomtd->plat.gpio_nwp, 1); |
| 337 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 338 | if (nand_scan(&gpiomtd->mtd_info, 1)) { |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 339 | ret = -ENXIO; |
| 340 | goto err_wp; |
| 341 | } |
| 342 | |
| 343 | if (gpiomtd->plat.adjust_parts) |
| 344 | gpiomtd->plat.adjust_parts(&gpiomtd->plat, |
| 345 | gpiomtd->mtd_info.size); |
| 346 | |
Jamie Iles | 775c3220 | 2011-12-18 10:00:49 +0000 | [diff] [blame] | 347 | ppdata.of_node = dev->dev.of_node; |
| 348 | ret = mtd_device_parse_register(&gpiomtd->mtd_info, NULL, &ppdata, |
| 349 | gpiomtd->plat.parts, |
| 350 | gpiomtd->plat.num_parts); |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 351 | if (!ret) |
| 352 | return 0; |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 353 | |
| 354 | err_wp: |
| 355 | if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) |
| 356 | gpio_set_value(gpiomtd->plat.gpio_nwp, 0); |
Alexander Shiyan | 283df42 | 2013-05-06 17:53:48 +0400 | [diff] [blame] | 357 | |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 358 | return ret; |
| 359 | } |
| 360 | |
| 361 | static struct platform_driver gpio_nand_driver = { |
| 362 | .probe = gpio_nand_probe, |
| 363 | .remove = gpio_nand_remove, |
| 364 | .driver = { |
| 365 | .name = "gpio-nand", |
Sachin Kamat | b57d43f | 2013-03-14 15:37:03 +0530 | [diff] [blame] | 366 | .of_match_table = of_match_ptr(gpio_nand_id_table), |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 367 | }, |
| 368 | }; |
| 369 | |
Sachin Kamat | 2fe87ae | 2012-09-05 15:31:32 +0530 | [diff] [blame] | 370 | module_platform_driver(gpio_nand_driver); |
Mike Rapoport | aaf7ea2 | 2008-10-15 08:38:49 +0200 | [diff] [blame] | 371 | |
| 372 | MODULE_LICENSE("GPL"); |
| 373 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
| 374 | MODULE_DESCRIPTION("GPIO NAND Driver"); |