2007-07-09 08:10:04 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2007
|
|
|
|
* Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2007-07-09 08:10:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
|
2007-08-15 19:06:27 +00:00
|
|
|
#if defined(CONFIG_CMD_NAND)
|
2007-07-09 08:10:04 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <nand.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hardware specific access to control-lines
|
|
|
|
*/
|
2007-10-31 12:53:06 +00:00
|
|
|
static void esd405ep_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
2007-07-09 08:10:04 +00:00
|
|
|
{
|
2016-05-30 18:57:56 +00:00
|
|
|
struct nand_chip *this = mtd_to_nand(mtd);
|
2007-11-09 12:32:30 +00:00
|
|
|
if (ctrl & NAND_CTRL_CHANGE) {
|
2007-10-31 12:53:06 +00:00
|
|
|
if ( ctrl & NAND_CLE )
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_CLE);
|
2007-10-31 12:53:06 +00:00
|
|
|
else
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_NAND_CLE);
|
2007-10-31 12:53:06 +00:00
|
|
|
if ( ctrl & NAND_ALE )
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_ALE);
|
2007-10-31 12:53:06 +00:00
|
|
|
else
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_NAND_ALE);
|
2007-10-31 12:53:06 +00:00
|
|
|
if ( ctrl & NAND_NCE )
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_NAND_CE);
|
2007-10-31 12:53:06 +00:00
|
|
|
else
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_CE);
|
2007-07-09 08:10:04 +00:00
|
|
|
}
|
2007-10-31 12:53:06 +00:00
|
|
|
|
2007-11-09 12:32:30 +00:00
|
|
|
if (cmd != NAND_CMD_NONE)
|
2007-10-31 12:53:06 +00:00
|
|
|
writeb(cmd, this->IO_ADDR_W);
|
2007-07-09 08:10:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* read device ready pin
|
|
|
|
*/
|
|
|
|
static int esd405ep_nand_device_ready(struct mtd_info *mtdinfo)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
if (in_be32((void *)GPIO0_IR) & CONFIG_SYS_NAND_RDY)
|
2007-07-09 08:10:04 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int board_nand_init(struct nand_chip *nand)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Set NAND-FLASH GPIO signals to defaults
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~(CONFIG_SYS_NAND_CLE | CONFIG_SYS_NAND_ALE));
|
|
|
|
out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_NAND_CE);
|
2007-07-09 08:10:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize nand_chip structure
|
|
|
|
*/
|
2007-10-31 12:53:06 +00:00
|
|
|
nand->cmd_ctrl = esd405ep_nand_hwcontrol;
|
2007-07-09 08:10:04 +00:00
|
|
|
nand->dev_ready = esd405ep_nand_device_ready;
|
2007-10-31 12:53:06 +00:00
|
|
|
nand->ecc.mode = NAND_ECC_SOFT;
|
2007-07-09 08:10:04 +00:00
|
|
|
nand->chip_delay = NAND_BIG_DELAY_US;
|
|
|
|
nand->options = NAND_SAMSUNG_LP_OPTIONS;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-08-15 19:06:27 +00:00
|
|
|
#endif
|