aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/gpio.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-19 15:47:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-19 15:47:41 -0500
commitca2a88f56aa385890c7fd4ce9d2722b0848ca990 (patch)
tree935fd9cec938677d6529db203f24d803ed5f0b19 /drivers/mtd/nand/gpio.c
parent3935e89505a1c3ab3f3b0c7ef0eae54124f48905 (diff)
parentd4d4f1bf6a343b25220fdcdf559fd593dd3e25a7 (diff)
Merge tag 'for-linus-20121219' of git://git.infradead.org/linux-mtd
Pull MTD updates from David Woodhouse: - Various cleanups especially in NAND tests - Add support for NAND flash on BCMA bus - DT support for sh_flctl and denali NAND drivers - Kill obsolete/superceded drivers (fortunet, nomadik_nand) - Fix JFFS2 locking bug in ENOMEM failure path - New SPI flash chips, as usual - Support writing in 'reliable mode' for DiskOnChip G4 - Debugfs support in nandsim * tag 'for-linus-20121219' of git://git.infradead.org/linux-mtd: (96 commits) mtd: nand: typo in nand_id_has_period() comments mtd: nand/gpio: use io{read,write}*_rep accessors mtd: block2mtd: throttle writes by calling balance_dirty_pages_ratelimited. mtd: nand: gpmi: reset BCH earlier, too, to avoid NAND startup problems mtd: nand/docg4: fix and improve read of factory bbt mtd: nand/docg4: reserve bb marker area in ecclayout mtd: nand/docg4: add support for writing in reliable mode mtd: mxc_nand: reorder part_probes to let cmdline override other sources mtd: mxc_nand: fix unbalanced clk_disable() in error path mtd: nandsim: Introduce debugfs infrastructure mtd: physmap_of: error checking to prevent a NULL pointer dereference mtg: docg3: potential divide by zero in doc_write_oob() mtd: bcm47xxnflash: writing support mtd: tests/read: initialize buffer for whole next page mtd: at91: atmel_nand: return bit flips for the PMECC read_page() mtd: fix recovery after failed write-buffer operation in cfi_cmdset_0002.c mtd: nand: onfi need to be probed in 8 bits mode mtd: nand: add NAND_BUSWIDTH_AUTO to autodetect bus width mtd: nand: print flash size during detection mted: nand_wait_ready timeout fix ...
Diffstat (limited to 'drivers/mtd/nand/gpio.c')
-rw-r--r--drivers/mtd/nand/gpio.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/mtd/nand/gpio.c b/drivers/mtd/nand/gpio.c
index bc73bc5f2713..e789e3f51710 100644
--- a/drivers/mtd/nand/gpio.c
+++ b/drivers/mtd/nand/gpio.c
@@ -90,14 +90,14 @@ static void gpio_nand_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
90{ 90{
91 struct nand_chip *this = mtd->priv; 91 struct nand_chip *this = mtd->priv;
92 92
93 writesb(this->IO_ADDR_W, buf, len); 93 iowrite8_rep(this->IO_ADDR_W, buf, len);
94} 94}
95 95
96static void gpio_nand_readbuf(struct mtd_info *mtd, u_char *buf, int len) 96static void gpio_nand_readbuf(struct mtd_info *mtd, u_char *buf, int len)
97{ 97{
98 struct nand_chip *this = mtd->priv; 98 struct nand_chip *this = mtd->priv;
99 99
100 readsb(this->IO_ADDR_R, buf, len); 100 ioread8_rep(this->IO_ADDR_R, buf, len);
101} 101}
102 102
103static void gpio_nand_writebuf16(struct mtd_info *mtd, const u_char *buf, 103static void gpio_nand_writebuf16(struct mtd_info *mtd, const u_char *buf,
@@ -106,7 +106,7 @@ static void gpio_nand_writebuf16(struct mtd_info *mtd, const u_char *buf,
106 struct nand_chip *this = mtd->priv; 106 struct nand_chip *this = mtd->priv;
107 107
108 if (IS_ALIGNED((unsigned long)buf, 2)) { 108 if (IS_ALIGNED((unsigned long)buf, 2)) {
109 writesw(this->IO_ADDR_W, buf, len>>1); 109 iowrite16_rep(this->IO_ADDR_W, buf, len>>1);
110 } else { 110 } else {
111 int i; 111 int i;
112 unsigned short *ptr = (unsigned short *)buf; 112 unsigned short *ptr = (unsigned short *)buf;
@@ -121,7 +121,7 @@ static void gpio_nand_readbuf16(struct mtd_info *mtd, u_char *buf, int len)
121 struct nand_chip *this = mtd->priv; 121 struct nand_chip *this = mtd->priv;
122 122
123 if (IS_ALIGNED((unsigned long)buf, 2)) { 123 if (IS_ALIGNED((unsigned long)buf, 2)) {
124 readsw(this->IO_ADDR_R, buf, len>>1); 124 ioread16_rep(this->IO_ADDR_R, buf, len>>1);
125 } else { 125 } else {
126 int i; 126 int i;
127 unsigned short *ptr = (unsigned short *)buf; 127 unsigned short *ptr = (unsigned short *)buf;
@@ -134,7 +134,11 @@ static void gpio_nand_readbuf16(struct mtd_info *mtd, u_char *buf, int len)
134static int gpio_nand_devready(struct mtd_info *mtd) 134static int gpio_nand_devready(struct mtd_info *mtd)
135{ 135{
136 struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd); 136 struct gpiomtd *gpiomtd = gpio_nand_getpriv(mtd);
137 return gpio_get_value(gpiomtd->plat.gpio_rdy); 137
138 if (gpio_is_valid(gpiomtd->plat.gpio_rdy))
139 return gpio_get_value(gpiomtd->plat.gpio_rdy);
140
141 return 1;
138} 142}
139 143
140#ifdef CONFIG_OF 144#ifdef CONFIG_OF
@@ -227,7 +231,7 @@ gpio_nand_get_io_sync(struct platform_device *pdev)
227 return platform_get_resource(pdev, IORESOURCE_MEM, 1); 231 return platform_get_resource(pdev, IORESOURCE_MEM, 1);
228} 232}
229 233
230static int __devexit gpio_nand_remove(struct platform_device *dev) 234static int gpio_nand_remove(struct platform_device *dev)
231{ 235{
232 struct gpiomtd *gpiomtd = platform_get_drvdata(dev); 236 struct gpiomtd *gpiomtd = platform_get_drvdata(dev);
233 struct resource *res; 237 struct resource *res;
@@ -252,7 +256,8 @@ static int __devexit gpio_nand_remove(struct platform_device *dev)
252 gpio_free(gpiomtd->plat.gpio_nce); 256 gpio_free(gpiomtd->plat.gpio_nce);
253 if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) 257 if (gpio_is_valid(gpiomtd->plat.gpio_nwp))
254 gpio_free(gpiomtd->plat.gpio_nwp); 258 gpio_free(gpiomtd->plat.gpio_nwp);
255 gpio_free(gpiomtd->plat.gpio_rdy); 259 if (gpio_is_valid(gpiomtd->plat.gpio_rdy))
260 gpio_free(gpiomtd->plat.gpio_rdy);
256 261
257 kfree(gpiomtd); 262 kfree(gpiomtd);
258 263
@@ -277,7 +282,7 @@ static void __iomem *request_and_remap(struct resource *res, size_t size,
277 return ptr; 282 return ptr;
278} 283}
279 284
280static int __devinit gpio_nand_probe(struct platform_device *dev) 285static int gpio_nand_probe(struct platform_device *dev)
281{ 286{
282 struct gpiomtd *gpiomtd; 287 struct gpiomtd *gpiomtd;
283 struct nand_chip *this; 288 struct nand_chip *this;
@@ -336,10 +341,12 @@ static int __devinit gpio_nand_probe(struct platform_device *dev)
336 if (ret) 341 if (ret)
337 goto err_cle; 342 goto err_cle;
338 gpio_direction_output(gpiomtd->plat.gpio_cle, 0); 343 gpio_direction_output(gpiomtd->plat.gpio_cle, 0);
339 ret = gpio_request(gpiomtd->plat.gpio_rdy, "NAND RDY"); 344 if (gpio_is_valid(gpiomtd->plat.gpio_rdy)) {
340 if (ret) 345 ret = gpio_request(gpiomtd->plat.gpio_rdy, "NAND RDY");
341 goto err_rdy; 346 if (ret)
342 gpio_direction_input(gpiomtd->plat.gpio_rdy); 347 goto err_rdy;
348 gpio_direction_input(gpiomtd->plat.gpio_rdy);
349 }
343 350
344 351
345 this->IO_ADDR_W = this->IO_ADDR_R; 352 this->IO_ADDR_W = this->IO_ADDR_R;
@@ -386,7 +393,8 @@ static int __devinit gpio_nand_probe(struct platform_device *dev)
386err_wp: 393err_wp:
387 if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) 394 if (gpio_is_valid(gpiomtd->plat.gpio_nwp))
388 gpio_set_value(gpiomtd->plat.gpio_nwp, 0); 395 gpio_set_value(gpiomtd->plat.gpio_nwp, 0);
389 gpio_free(gpiomtd->plat.gpio_rdy); 396 if (gpio_is_valid(gpiomtd->plat.gpio_rdy))
397 gpio_free(gpiomtd->plat.gpio_rdy);
390err_rdy: 398err_rdy:
391 gpio_free(gpiomtd->plat.gpio_cle); 399 gpio_free(gpiomtd->plat.gpio_cle);
392err_cle: 400err_cle: