From patchwork Sat Jan 29 01:00:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Spang X-Patchwork-Id: 80916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 30489B7110 for ; Sat, 29 Jan 2011 12:11:53 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 48C7F2807F; Sat, 29 Jan 2011 02:11:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5jfcxG6TLCo8; Sat, 29 Jan 2011 02:11:07 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8638F280C2; Sat, 29 Jan 2011 02:10:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5646C28082 for ; Sat, 29 Jan 2011 02:10:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 84aPuH3qupCt for ; Sat, 29 Jan 2011 02:10:19 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from caffeine.csclub.uwaterloo.ca (caffeine.csclub.uwaterloo.ca [129.97.134.17]) by theia.denx.de (Postfix) with ESMTP id 0700F2807B for ; Sat, 29 Jan 2011 02:10:14 +0100 (CET) Received: from caffeine.csclub.uwaterloo.ca (localhost [127.0.0.1]) by caffeine.csclub.uwaterloo.ca (Postfix) with ESMTP id 524F8816E0; Fri, 28 Jan 2011 20:01:07 -0500 (EST) Received: from corn-syrup (corn-syrup.csclub.uwaterloo.ca [129.97.134.72]) by caffeine.csclub.uwaterloo.ca (Postfix) with SMTP id 3FC5A816DD; Fri, 28 Jan 2011 20:01:06 -0500 (EST) Received: by corn-syrup (sSMTP sendmail emulation); Fri, 28 Jan 2011 20:01:06 -0500 From: Michael Spang To: u-boot@lists.denx.de Date: Fri, 28 Jan 2011 20:00:40 -0500 Message-Id: <1296262841-8819-7-git-send-email-mspang@csclub.uwaterloo.ca> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1296262841-8819-1-git-send-email-mspang@csclub.uwaterloo.ca> References: <1296262841-8819-1-git-send-email-mspang@csclub.uwaterloo.ca> X-Virus-Scanned: ClamAV using ClamSMTP Cc: Michael Spang , Alexander Clouter Subject: [U-Boot] [PATCH 7/8] Add NAND support for TS-7800 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The NAND control functions were written by Alexander Clouter and copied here from Linux. Signed-off-by: Michael Spang --- drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/ts7800_nand.c | 68 ++++++++++++++++++++++++++++++++++++++++ include/configs/ts7800.h | 46 +++++++++++++++++++++++++-- 3 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 drivers/mtd/nand/ts7800_nand.c diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 8b598f6..897e6c2 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -49,6 +49,7 @@ COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o +COBJS-$(CONFIG_NAND_TS7800) += ts7800_nand.o COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o endif diff --git a/drivers/mtd/nand/ts7800_nand.c b/drivers/mtd/nand/ts7800_nand.c new file mode 100644 index 0000000..12ee207 --- /dev/null +++ b/drivers/mtd/nand/ts7800_nand.c @@ -0,0 +1,68 @@ +/* + * Based on arch/arm/mach-orion5x/ts78xx-setup.c from Linux + * by Alexander Clouter . + * + * 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 +#include +#include + +/* + * hardware specific access to control-lines + * + * ctrl: + * NAND_NCE: bit 0 -> bit 2 + * NAND_CLE: bit 1 -> bit 1 + * NAND_ALE: bit 2 -> bit 0 + */ +static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, + unsigned int ctrl) +{ + struct nand_chip *this = mtd->priv; + + if (ctrl & NAND_CTRL_CHANGE) { + unsigned char bits; + + bits = (ctrl & NAND_NCE) << 2; + bits |= ctrl & NAND_CLE; + bits |= (ctrl & NAND_ALE) >> 2; + + writeb((readb(TS_NAND_CTRL) & ~0x7) | bits, TS_NAND_CTRL); + } + + if (cmd != NAND_CMD_NONE) + writeb(cmd, this->IO_ADDR_W); +} + +static int ts78xx_ts_nand_dev_ready(struct mtd_info *mtd) +{ + return readb(TS_NAND_CTRL) & 0x20; +} + +int board_nand_init(struct nand_chip *nand) +{ + nand->options = NAND_USE_FLASH_BBT; + nand->ecc.mode = NAND_ECC_SOFT; + nand->cmd_ctrl = ts78xx_ts_nand_cmd_ctrl; + nand->dev_ready = ts78xx_ts_nand_dev_ready; + nand->chip_delay = 15; + return 0; +} diff --git a/include/configs/ts7800.h b/include/configs/ts7800.h index dc7e3e2..76409ab 100644 --- a/include/configs/ts7800.h +++ b/include/configs/ts7800.h @@ -33,10 +33,11 @@ #define CONFIG_BOOTDELAY 3 /* - * Flash Driver + * Flash Configuration */ -#define CONFIG_SYS_NO_FLASH +#define CONFIG_SYS_NO_FLASH /* TS-7800 has only NAND flash */ +#define CONFIG_USE_NAND 0 /* Disable NAND by default */ /* * Commands Configuration @@ -46,6 +47,11 @@ #define CONFIG_CMD_PING #define CONFIG_CMD_MII +#if CONFIG_USE_NAND +#define CONFIG_CMD_NAND +#define CONFIG_CMD_MTDPARTS +#endif + /* * Serial Port Configuration */ @@ -57,9 +63,21 @@ * Environment Configuration */ -#define CONFIG_ENV_IS_NOWHERE 1 +#if CONFIG_USE_NAND + +#define CONFIG_ENV_IS_IN_NAND + +#define CONFIG_ENV_OFFSET 0x00320000 /* 128k(mbr) + 3m(kernel) */ +#define CONFIG_ENV_SIZE 0x00020000 /* 128k */ +#define CONFIG_ENV_RANGE 0x00100000 /* 1m(env) */ + +#else + +#define CONFIG_ENV_IS_NOWHERE #define CONFIG_ENV_SIZE 0x2000 +#endif + /* * Limits */ @@ -109,6 +127,28 @@ #define CONFIG_SYS_MEMTEST_START 0x00001000 /* Memtest starts after vectors */ #define CONFIG_SYS_MEMTEST_END 0x07e00000 /* Memtest ends before U-Boot */ +#define ORION5X_ADR_PCI_MEM 0xe8000000 /* Match PCI memory mapping to Linux (FPGA) */ +#define ORION5X_SZ_PCI_MEM 0x08000000 + +/* + * Flash Driver + */ + +#ifdef CONFIG_CMD_NAND + +#define TS_NAND_CTRL 0xe8000800 +#define TS_NAND_DATA 0xe8000804 + +#define CONFIG_NAND_TS7800 +#define CONFIG_SYS_NAND_BASE TS_NAND_DATA +#define CONFIG_SYS_MAX_NAND_DEVICE 1 + +#define CONFIG_MTD_DEVICE +#define MTDIDS_DEFAULT "nand0=gen_nand" +#define MTDPARTS_DEFAULT "mtdparts=gen_nand:128k(mbr),3m(uboot),1m(env),4m(linux),-(rootfs)" + +#endif + /* * UART Driver */