2 * Platform independend driver for JZ5730.
4 * Copyright (c) 2007 Ingenic Semiconductor Inc.
5 * Author: <jlwei@ingenic.cn>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
14 #if (CONFIG_COMMANDS & CFG_CMD_NAND) && defined(CONFIG_JZ5730)
18 #include <asm/jz5730.h>
20 static void jz_hwcontrol(struct mtd_info
*mtd
, int cmd
)
22 struct nand_chip
*this = (struct nand_chip
*)(mtd
->priv
);
25 REG_EMC_NFCSR
|= EMC_NFCSR_FCE
;
29 REG_EMC_NFCSR
&= ~EMC_NFCSR_FCE
;
33 this->IO_ADDR_W
= (void __iomem
*)((unsigned long)(this->IO_ADDR_W
) | 0x00040000);
37 this->IO_ADDR_W
= (void __iomem
*)((unsigned long)(this->IO_ADDR_W
) & ~0x00040000);
41 this->IO_ADDR_W
= (void __iomem
*)((unsigned long)(this->IO_ADDR_W
) | 0x00080000);
45 this->IO_ADDR_W
= (void __iomem
*)((unsigned long)(this->IO_ADDR_W
) & ~0x00080000);
50 static int jz_device_ready(struct mtd_info
*mtd
)
53 ready
= (REG_EMC_NFCSR
& EMC_NFCSR_RB
) ? 1 : 0;
60 static void jz_device_setup(void)
63 REG_EMC_NFCSR
|= EMC_NFCSR_NFE
;
66 void board_nand_select_device(struct nand_chip
*nand
, int chip
)
69 * Don't use "chip" to address the NAND device,
70 * generate the cs from the address where it is encoded.
75 * Main initialization routine
77 void board_nand_init(struct nand_chip
*nand
)
81 nand
->eccmode
= NAND_ECC_SOFT
;
82 nand
->hwcontrol
= jz_hwcontrol
;
83 nand
->dev_ready
= jz_device_ready
;
85 /* Set address of NAND IO lines */
86 nand
->IO_ADDR_R
= (void __iomem
*) CFG_NAND_BASE
;
87 nand
->IO_ADDR_W
= (void __iomem
*) CFG_NAND_BASE
;
89 /* 20 us command delay time */
90 nand
->chip_delay
= 20;
93 #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */