2 * Genericish driver for memory mapped NAND devices
4 * Copyright (c) 2006-2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
8 /* Your board must implement the following macros:
9 * NAND_PLAT_WRITE_CMD(chip, cmd)
10 * NAND_PLAT_WRITE_ADR(chip, cmd)
13 * It may also implement the following:
14 * NAND_PLAT_DEV_READY(chip)
19 #ifdef NAND_PLAT_GPIO_DEV_READY
20 # include <asm/gpio.h>
21 # define NAND_PLAT_DEV_READY(chip) gpio_get_value(NAND_PLAT_GPIO_DEV_READY)
26 static void plat_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
28 struct nand_chip *this = mtd->priv;
30 if (cmd == NAND_CMD_NONE)
34 NAND_PLAT_WRITE_CMD(this, cmd);
36 NAND_PLAT_WRITE_ADR(this, cmd);
39 #ifdef NAND_PLAT_DEV_READY
40 static int plat_dev_ready(struct mtd_info *mtd)
42 return NAND_PLAT_DEV_READY((struct nand_chip *)mtd->priv);
45 # define plat_dev_ready NULL
48 int board_nand_init(struct nand_chip *nand)
50 #ifdef NAND_PLAT_GPIO_DEV_READY
51 gpio_request(NAND_PLAT_GPIO_DEV_READY, "nand-plat");
52 gpio_direction_input(NAND_PLAT_GPIO_DEV_READY);
59 nand->cmd_ctrl = plat_cmd_ctrl;
60 nand->dev_ready = plat_dev_ready;
61 nand->ecc.mode = NAND_ECC_SOFT;