aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLei Wen <leiwen@marvell.com>2011-02-27 21:32:12 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-03-11 09:22:50 -0500
commit38caf7f68e6b4ad84094095887a490e3fa2ec501 (patch)
treea0e6be540775df886a67d6e2102d133f949008a9 /drivers
parentf8155a404db95656f1519b28fdb96cb68f8b2364 (diff)
mtd: pxa3xx_nand: discard wait_for_event,write_cmd,__readid function
Since we have rework the irq process, we don't need additional delay in wait_for_event. Also write_cmd and __readid is also discarded for the same reason. Signed-off-by: Lei Wen <leiwen@marvell.com> Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com> Acked-by: Eric Miao <eric.y.miao@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c77
1 files changed, 1 insertions, 76 deletions
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 3264b1d5a638..be0aa44ada42 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -258,25 +258,6 @@ static void pxa3xx_nand_set_timing(struct pxa3xx_nand_info *info,
258 nand_writel(info, NDTR1CS0, ndtr1); 258 nand_writel(info, NDTR1CS0, ndtr1);
259} 259}
260 260
261#define WAIT_EVENT_TIMEOUT 10
262
263static int wait_for_event(struct pxa3xx_nand_info *info, uint32_t event)
264{
265 int timeout = WAIT_EVENT_TIMEOUT;
266 uint32_t ndsr;
267
268 while (timeout--) {
269 ndsr = nand_readl(info, NDSR) & NDSR_MASK;
270 if (ndsr & event) {
271 nand_writel(info, NDSR, ndsr);
272 return 0;
273 }
274 udelay(10);
275 }
276
277 return -ETIMEDOUT;
278}
279
280static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info) 261static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info)
281{ 262{
282 int oob_enable = info->reg_ndcr & NDCR_SPARE_EN; 263 int oob_enable = info->reg_ndcr & NDCR_SPARE_EN;
@@ -414,35 +395,6 @@ static void disable_int(struct pxa3xx_nand_info *info, uint32_t int_mask)
414 nand_writel(info, NDCR, ndcr | int_mask); 395 nand_writel(info, NDCR, ndcr | int_mask);
415} 396}
416 397
417/* NOTE: it is a must to set ND_RUN firstly, then write command buffer
418 * otherwise, it does not work
419 */
420static int write_cmd(struct pxa3xx_nand_info *info)
421{
422 uint32_t ndcr;
423
424 /* clear status bits and run */
425 nand_writel(info, NDSR, NDSR_MASK);
426
427 ndcr = info->reg_ndcr;
428
429 ndcr |= info->use_ecc ? NDCR_ECC_EN : 0;
430 ndcr |= info->use_dma ? NDCR_DMA_EN : 0;
431 ndcr |= NDCR_ND_RUN;
432
433 nand_writel(info, NDCR, ndcr);
434
435 if (wait_for_event(info, NDSR_WRCMDREQ)) {
436 printk(KERN_ERR "timed out writing command\n");
437 return -ETIMEDOUT;
438 }
439
440 nand_writel(info, NDCB0, info->ndcb0);
441 nand_writel(info, NDCB0, info->ndcb1);
442 nand_writel(info, NDCB0, info->ndcb2);
443 return 0;
444}
445
446static void handle_data_pio(struct pxa3xx_nand_info *info) 398static void handle_data_pio(struct pxa3xx_nand_info *info)
447{ 399{
448 switch (info->state) { 400 switch (info->state) {
@@ -778,33 +730,6 @@ static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this)
778 return 0; 730 return 0;
779} 731}
780 732
781static int __readid(struct pxa3xx_nand_info *info, uint32_t *id)
782{
783 const struct pxa3xx_nand_cmdset *cmdset = info->cmdset;
784 uint32_t ndcr;
785 uint8_t id_buff[8];
786
787 prepare_other_cmd(info, cmdset->read_id);
788
789 /* Send command */
790 if (write_cmd(info))
791 goto fail_timeout;
792
793 /* Wait for CMDDM(command done successfully) */
794 if (wait_for_event(info, NDSR_RDDREQ))
795 goto fail_timeout;
796
797 __raw_readsl(info->mmio_base + NDDB, id_buff, 2);
798 *id = id_buff[0] | (id_buff[1] << 8);
799 return 0;
800
801fail_timeout:
802 ndcr = nand_readl(info, NDCR);
803 nand_writel(info, NDCR, ndcr & ~NDCR_ND_RUN);
804 udelay(10);
805 return -ETIMEDOUT;
806}
807
808static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info, 733static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info,
809 const struct pxa3xx_nand_flash *f) 734 const struct pxa3xx_nand_flash *f)
810{ 735{
@@ -857,7 +782,7 @@ static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info)
857 782
858 page_per_block = ndcr & NDCR_PG_PER_BLK ? 64 : 32; 783 page_per_block = ndcr & NDCR_PG_PER_BLK ? 64 : 32;
859 info->page_size = ndcr & NDCR_PAGE_SZ ? 2048 : 512; 784 info->page_size = ndcr & NDCR_PAGE_SZ ? 2048 : 512;
860 /* set info fields needed to __readid */ 785 /* set info fields needed to read id */
861 info->read_id_bytes = (info->page_size == 2048) ? 4 : 2; 786 info->read_id_bytes = (info->page_size == 2048) ? 4 : 2;
862 info->reg_ndcr = ndcr; 787 info->reg_ndcr = ndcr;
863 info->cmdset = &default_cmdset; 788 info->cmdset = &default_cmdset;