mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-26 21:13:48 +00:00
48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
|
// SPDX-License-Identifier: GPL-2.0+
|
||
|
/*
|
||
|
* Copyright (C) 2010-2020 CS Group
|
||
|
* Florent Trinh Thai <florent.trinh-thai@c-s.fr>
|
||
|
* Christophe Leroy <christophe.leroy@c-s.fr>
|
||
|
* Charles Frey <charles.frey@c-s.fr>
|
||
|
*/
|
||
|
|
||
|
#include <config.h>
|
||
|
#include <common.h>
|
||
|
#include <nand.h>
|
||
|
#include <linux/bitops.h>
|
||
|
#include <linux/mtd/rawnand.h>
|
||
|
#include <asm/io.h>
|
||
|
|
||
|
#define BIT_CLE BIT(3)
|
||
|
#define BIT_ALE BIT(2)
|
||
|
#define BIT_NCE BIT(0)
|
||
|
|
||
|
static u32 nand_mask(unsigned int ctrl)
|
||
|
{
|
||
|
return ((ctrl & NAND_CLE) ? BIT_CLE : 0) |
|
||
|
((ctrl & NAND_ALE) ? BIT_ALE : 0) |
|
||
|
(!(ctrl & NAND_NCE) ? BIT_NCE : 0);
|
||
|
}
|
||
|
|
||
|
static void nand_hwcontrol(struct mtd_info *mtdinfo, int cmd, unsigned int ctrl)
|
||
|
{
|
||
|
immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR;
|
||
|
struct nand_chip *chip = mtd_to_nand(mtdinfo);
|
||
|
|
||
|
if (ctrl & NAND_CTRL_CHANGE)
|
||
|
clrsetbits_be16(&immr->im_ioport.iop_pddat,
|
||
|
BIT_CLE | BIT_ALE | BIT_NCE, nand_mask(ctrl));
|
||
|
|
||
|
if (cmd != NAND_CMD_NONE)
|
||
|
out_8(chip->IO_ADDR_W, cmd);
|
||
|
}
|
||
|
|
||
|
int board_nand_init(struct nand_chip *chip)
|
||
|
{
|
||
|
chip->chip_delay = 60;
|
||
|
chip->ecc.mode = NAND_ECC_SOFT;
|
||
|
chip->cmd_ctrl = nand_hwcontrol;
|
||
|
|
||
|
return 0;
|
||
|
}
|