aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-10-05 05:14:35 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2009-11-12 02:33:03 -0500
commitc6de7e1bb8d6e1b3ae318bf9fbe84557d7c8baec (patch)
tree04500f49a91cb3e8931536828b27390106c0ba1a /drivers/mtd/nand
parent0e60c7c4015f051ff921e6c30844f31e17f8ad95 (diff)
mxc_nand: Make main/spare areas runtime configurable
The main/spare areas are on different addresses on later versions of the controller, so make them configurable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/mxc_nand.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index ab6db698cbd..c84fd6c3549 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -52,18 +52,6 @@
52#define NFC_CONFIG1 0xE1A 52#define NFC_CONFIG1 0xE1A
53#define NFC_CONFIG2 0xE1C 53#define NFC_CONFIG2 0xE1C
54 54
55/* Addresses for NFC RAM BUFFER Main area 0 */
56#define MAIN_AREA0 0x000
57#define MAIN_AREA1 0x200
58#define MAIN_AREA2 0x400
59#define MAIN_AREA3 0x600
60
61/* Addresses for NFC SPARE BUFFER Spare area 0 */
62#define SPARE_AREA0 0x800
63#define SPARE_AREA1 0x810
64#define SPARE_AREA2 0x820
65#define SPARE_AREA3 0x830
66
67/* Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register 55/* Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register
68 * for Command operation */ 56 * for Command operation */
69#define NFC_CMD 0x1 57#define NFC_CMD 0x1
@@ -106,6 +94,11 @@ struct mxc_nand_host {
106 struct mtd_partition *parts; 94 struct mtd_partition *parts;
107 struct device *dev; 95 struct device *dev;
108 96
97 void *spare0;
98 void *main_area0;
99 void *main_area1;
100
101 void __iomem *base;
109 void __iomem *regs; 102 void __iomem *regs;
110 int status_request; 103 int status_request;
111 int pagesize_2k; 104 int pagesize_2k;
@@ -262,7 +255,7 @@ static void send_read_id(struct mxc_nand_host *host)
262 wait_op_done(host, TROP_US_DELAY, true); 255 wait_op_done(host, TROP_US_DELAY, true);
263 256
264 if (this->options & NAND_BUSWIDTH_16) { 257 if (this->options & NAND_BUSWIDTH_16) {
265 void __iomem *main_buf = host->regs + MAIN_AREA0; 258 void __iomem *main_buf = host->main_area0;
266 /* compress the ID info */ 259 /* compress the ID info */
267 writeb(readb(main_buf + 2), main_buf + 1); 260 writeb(readb(main_buf + 2), main_buf + 1);
268 writeb(readb(main_buf + 4), main_buf + 2); 261 writeb(readb(main_buf + 4), main_buf + 2);
@@ -270,14 +263,14 @@ static void send_read_id(struct mxc_nand_host *host)
270 writeb(readb(main_buf + 8), main_buf + 4); 263 writeb(readb(main_buf + 8), main_buf + 4);
271 writeb(readb(main_buf + 10), main_buf + 5); 264 writeb(readb(main_buf + 10), main_buf + 5);
272 } 265 }
273 memcpy(host->data_buf, host->regs + MAIN_AREA0, 16); 266 memcpy(host->data_buf, host->main_area0, 16);
274} 267}
275 268
276/* This function requests the NANDFC to perform a read of the 269/* This function requests the NANDFC to perform a read of the
277 * NAND device status and returns the current status. */ 270 * NAND device status and returns the current status. */
278static uint16_t get_dev_status(struct mxc_nand_host *host) 271static uint16_t get_dev_status(struct mxc_nand_host *host)
279{ 272{
280 void __iomem *main_buf = host->regs + MAIN_AREA1; 273 void __iomem *main_buf = host->main_area1;
281 uint32_t store; 274 uint32_t store;
282 uint16_t ret, tmp; 275 uint16_t ret, tmp;
283 /* Issue status request to NAND device */ 276 /* Issue status request to NAND device */
@@ -462,7 +455,7 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
462 u16 i, j; 455 u16 i, j;
463 u16 n = mtd->writesize >> 9; 456 u16 n = mtd->writesize >> 9;
464 u8 *d = host->data_buf + mtd->writesize; 457 u8 *d = host->data_buf + mtd->writesize;
465 u8 *s = host->regs + SPARE_AREA0; 458 u8 *s = host->spare0;
466 u16 t = host->spare_len; 459 u16 t = host->spare_len;
467 460
468 j = (mtd->oobsize / n >> 1) << 1; 461 j = (mtd->oobsize / n >> 1) << 1;
@@ -572,7 +565,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
572 565
573 send_page(host, NFC_OUTPUT); 566 send_page(host, NFC_OUTPUT);
574 567
575 memcpy(host->data_buf, host->regs + MAIN_AREA0, mtd->writesize); 568 memcpy(host->data_buf, host->main_area0, mtd->writesize);
576 copy_spare(mtd, true); 569 copy_spare(mtd, true);
577 break; 570 break;
578 571
@@ -608,7 +601,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
608 break; 601 break;
609 602
610 case NAND_CMD_PAGEPROG: 603 case NAND_CMD_PAGEPROG:
611 memcpy(host->regs + MAIN_AREA0, host->data_buf, mtd->writesize); 604 memcpy(host->main_area0, host->data_buf, mtd->writesize);
612 copy_spare(mtd, false); 605 copy_spare(mtd, false);
613 send_page(host, NFC_INPUT); 606 send_page(host, NFC_INPUT);
614 send_cmd(host, command, true); 607 send_cmd(host, command, true);
@@ -686,12 +679,17 @@ static int __init mxcnd_probe(struct platform_device *pdev)
686 goto eres; 679 goto eres;
687 } 680 }
688 681
689 host->regs = ioremap(res->start, resource_size(res)); 682 host->base = ioremap(res->start, resource_size(res));
690 if (!host->regs) { 683 if (!host->base) {
691 err = -ENOMEM; 684 err = -ENOMEM;
692 goto eres; 685 goto eres;
693 } 686 }
694 687
688 host->regs = host->base;
689 host->main_area0 = host->base;
690 host->main_area1 = host->base + 0x200;
691 host->spare0 = host->base + 0x800;
692
695 tmp = readw(host->regs + NFC_CONFIG1); 693 tmp = readw(host->regs + NFC_CONFIG1);
696 tmp |= NFC_INT_MSK; 694 tmp |= NFC_INT_MSK;
697 writew(tmp, host->regs + NFC_CONFIG1); 695 writew(tmp, host->regs + NFC_CONFIG1);
@@ -778,7 +776,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
778escan: 776escan:
779 free_irq(host->irq, host); 777 free_irq(host->irq, host);
780eirq: 778eirq:
781 iounmap(host->regs); 779 iounmap(host->base);
782eres: 780eres:
783 clk_put(host->clk); 781 clk_put(host->clk);
784eclk: 782eclk:
@@ -797,7 +795,7 @@ static int __exit mxcnd_remove(struct platform_device *pdev)
797 795
798 nand_release(&host->mtd); 796 nand_release(&host->mtd);
799 free_irq(host->irq, host); 797 free_irq(host->irq, host);
800 iounmap(host->regs); 798 iounmap(host->base);
801 kfree(host); 799 kfree(host);
802 800
803 return 0; 801 return 0;