From dac3c6f625e03be0b5017b0d436c73aeeb1a673e Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Fri, 14 Oct 2022 12:54:50 +0200 Subject: board: cssi: Add new board MCR3000_2G This adds a new board from CS GROUP. The board is called MCR3000_2G, and has a CPU board called CMPC885. That CPU board is shared with another equipment that will be added in a later patch. That board stores Ethernet MAC addresses in an EEPROM which is accessed using SPI bus. This patch was originally written by Charles Frey who's email address is not valid anymore as he left the company. Signed-off-by: Christophe Leroy Reviewed-by: FRANJOU Stephane --- board/cssi/cmpc885/nand.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 board/cssi/cmpc885/nand.c (limited to 'board/cssi/cmpc885/nand.c') diff --git a/board/cssi/cmpc885/nand.c b/board/cssi/cmpc885/nand.c new file mode 100644 index 0000000000..38100046df --- /dev/null +++ b/board/cssi/cmpc885/nand.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2010-2020 CS Group + * Florent Trinh Thai + * Christophe Leroy + * Charles Frey + */ + +#include +#include +#include +#include +#include +#include + +#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; +} -- cgit v1.2.3