2007-01-15 12:41:04 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2007
|
|
|
|
* Heiko Schocher, DENX Software Engineering, hs@denx.de.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
|
2007-07-09 23:45:16 +00:00
|
|
|
#if defined(CONFIG_CMD_NAND)
|
2007-01-15 12:41:04 +00:00
|
|
|
|
|
|
|
#include <nand.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
|
|
|
|
#define readb(addr) *(volatile u_char *)(addr)
|
|
|
|
#define readl(addr) *(volatile u_long *)(addr)
|
|
|
|
#define writeb(d,addr) *(volatile u_char *)(addr) = (d)
|
|
|
|
|
|
|
|
#define SC3_NAND_ALE 29 /* GPIO PIN 3 */
|
|
|
|
#define SC3_NAND_CLE 30 /* GPIO PIN 2 */
|
|
|
|
#define SC3_NAND_CE 27 /* GPIO PIN 5 */
|
|
|
|
|
|
|
|
static void *sc3_io_base;
|
|
|
|
static void *sc3_control_base = (void *)0xEF600700;
|
|
|
|
|
2007-10-31 12:53:06 +00:00
|
|
|
static void sc3_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
2007-01-15 12:41:04 +00:00
|
|
|
{
|
2007-11-09 12:32:30 +00:00
|
|
|
struct nand_chip *this = mtd->priv;
|
|
|
|
if (ctrl & NAND_CTRL_CHANGE) {
|
2007-10-31 12:53:06 +00:00
|
|
|
if ( ctrl & NAND_CLE )
|
|
|
|
set_bit (SC3_NAND_CLE, sc3_control_base);
|
|
|
|
else
|
2007-11-08 09:39:53 +00:00
|
|
|
clear_bit (SC3_NAND_CLE, sc3_control_base);
|
2007-10-31 12:53:06 +00:00
|
|
|
if ( ctrl & NAND_ALE )
|
|
|
|
set_bit (SC3_NAND_ALE, sc3_control_base);
|
|
|
|
else
|
|
|
|
clear_bit (SC3_NAND_ALE, sc3_control_base);
|
|
|
|
if ( ctrl & NAND_NCE )
|
|
|
|
set_bit (SC3_NAND_CE, sc3_control_base);
|
|
|
|
else
|
2007-11-08 09:39:53 +00:00
|
|
|
clear_bit (SC3_NAND_CE, sc3_control_base);
|
2007-01-15 12:41: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-01-15 12:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int sc3_nand_dev_ready(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
if (!(readl(sc3_control_base + 0x1C) & 0x4000))
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sc3_select_chip(struct mtd_info *mtd, int chip)
|
|
|
|
{
|
|
|
|
clear_bit (SC3_NAND_CE, sc3_control_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_nand_init(struct nand_chip *nand)
|
|
|
|
{
|
2007-10-31 12:53:06 +00:00
|
|
|
nand->ecc.mode = NAND_ECC_SOFT;
|
2007-01-15 12:41:04 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
sc3_io_base = (void *) CONFIG_SYS_NAND_BASE;
|
2007-01-15 12:41:04 +00:00
|
|
|
/* Set address of NAND IO lines (Using Linear Data Access Region) */
|
|
|
|
nand->IO_ADDR_R = (void __iomem *) sc3_io_base;
|
|
|
|
nand->IO_ADDR_W = (void __iomem *) sc3_io_base;
|
|
|
|
/* Reference hardware control function */
|
2007-10-31 12:53:06 +00:00
|
|
|
nand->cmd_ctrl = sc3_nand_hwcontrol;
|
2007-01-15 12:41:04 +00:00
|
|
|
nand->dev_ready = sc3_nand_dev_ready;
|
|
|
|
nand->select_chip = sc3_select_chip;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|