diff options
Diffstat (limited to 'drivers/mtd/nand/gpio.c')
-rw-r--r-- | drivers/mtd/nand/gpio.c | 34 |
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 | ||
96 | static void gpio_nand_readbuf(struct mtd_info *mtd, u_char *buf, int len) | 96 | static 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 | ||
103 | static void gpio_nand_writebuf16(struct mtd_info *mtd, const u_char *buf, | 103 | static 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) | |||
134 | static int gpio_nand_devready(struct mtd_info *mtd) | 134 | static 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 | ||
230 | static int __devexit gpio_nand_remove(struct platform_device *dev) | 234 | static 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 | ||
280 | static int __devinit gpio_nand_probe(struct platform_device *dev) | 285 | static 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) | |||
386 | err_wp: | 393 | err_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); | ||
390 | err_rdy: | 398 | err_rdy: |
391 | gpio_free(gpiomtd->plat.gpio_cle); | 399 | gpio_free(gpiomtd->plat.gpio_cle); |
392 | err_cle: | 400 | err_cle: |