12 #include <linux/slab.h>
15 #include <linux/module.h>
118 for (i = 0; i < len; i++) {
132 static void au_read_buf(
struct mtd_info *mtd,
u_char *buf,
int len)
137 for (i = 0; i < len; i++) {
151 static void au_write_buf16(
struct mtd_info *mtd,
const u_char *buf,
int len)
158 for (i = 0; i < len; i++) {
173 static void au_read_buf16(
struct mtd_info *mtd,
u_char *buf,
int len)
180 for (i = 0; i < len; i++) {
187 #define NAND_CTL_SETNCE 1
189 #define NAND_CTL_CLRNCE 2
191 #define NAND_CTL_SETCLE 3
193 #define NAND_CTL_CLRCLE 4
195 #define NAND_CTL_SETALE 5
197 #define NAND_CTL_CLRALE 6
199 static void au1550_hwcontrol(
struct mtd_info *mtd,
int cmd)
244 int ret = (au_readl(
MEM_STSTAT) & 0x1) ? 1 : 0;
261 static void au1550_select_chip(
struct mtd_info *mtd,
int chip)
272 static void au1550_command(
struct mtd_info *mtd,
unsigned command,
int column,
int page_addr)
276 int ce_override = 0,
i;
277 unsigned long flags = 0;
291 }
else if (column < 256) {
305 if (column != -1 || page_addr != -1) {
315 if (page_addr != -1) {
339 ((page_addr >> 16) & 0x0f));
385 static int __devinit find_nand_cs(
unsigned long nand_base)
392 for (i = 0; i < 4; i++) {
393 addr = 0x1000 + (i * 0x10);
396 start = (staddr << 4) & 0xfffc0000;
397 mask = (staddr << 18) & 0xfffc0000;
398 end = (start | (start - 1)) & ~(start ^
mask);
399 if ((nand_base >= start) && (nand_base <
end))
414 pd = pdev->
dev.platform_data;
416 dev_err(&pdev->
dev,
"missing platform data\n");
422 dev_err(&pdev->
dev,
"no memory for NAND context\n");
428 dev_err(&pdev->
dev,
"no NAND memory resource\n");
433 dev_err(&pdev->
dev,
"cannot claim NAND memory area\n");
440 dev_err(&pdev->
dev,
"cannot remap NAND memory area\n");
446 ctx->
info.priv =
this;
450 cs = find_nand_cs(r->
start);
452 dev_err(&pdev->
dev,
"cannot detect NAND chipselect\n");
459 this->select_chip = au1550_select_chip;
460 this->cmdfunc = au1550_command;
463 this->chip_delay = 30;
469 this->read_byte = (pd->
devwidth) ? au_read_byte16 : au_read_byte;
471 this->read_word = au_read_word;
473 this->read_buf = (pd->
devwidth) ? au_read_buf16 : au_read_buf;
477 dev_err(&pdev->
dev,
"NAND scan failed with %d\n", ret);
508 .name =
"au1550-nand",
511 .probe = au1550nd_probe,