From patchwork Thu Apr 3 06:01:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 336520 X-Patchwork-Delegate: sbabic@denx.de 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 C70C414010A for ; Thu, 3 Apr 2014 17:02:03 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2FC454BBB6; Thu, 3 Apr 2014 08:01:59 +0200 (CEST) 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 jZff-qCQ7v8T; Thu, 3 Apr 2014 08:01:58 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4E86F4BB6A; Thu, 3 Apr 2014 08:01:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C47474BAF7 for ; Thu, 3 Apr 2014 08:01:27 +0200 (CEST) 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 1CpDfD30B6MM for ; Thu, 3 Apr 2014 08:01:24 +0200 (CEST) X-Greylist: delayed 2589 seconds by postgrey-1.27 at theia; Thu, 03 Apr 2014 08:01:21 CEST 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 mail-pb0-f48.google.com (mail-pb0-f48.google.com [209.85.160.48]) by theia.denx.de (Postfix) with ESMTPS id 241994BA7B for ; Thu, 3 Apr 2014 08:01:21 +0200 (CEST) Received: by mail-pb0-f48.google.com with SMTP id md12so1321526pbc.21 for ; Wed, 02 Apr 2014 23:01:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sV7tXatpCHZ0AtTDcb4bIgnLhTwQx4/MDSIne05SZBo=; b=lQRHJQxJ8+cTXeLB+7rRRQtKOqPF2wxYvnjE59VF/fgw0b9X3fCw57qW6rXiUJDjOL wr0GxyglHNzbGr9JvdbFrrVSquYc3q3rFc5SyPaX2IdFvb+vsBH+4mgrQdykvpvxLbOL 3UvwdHL85bqupDecLi0ILrOq01anDN/3W/KVUv2wDEcxmeqf0jF/iJPAZbvN0KtB7o1K S9hIONPx70WXoA+NvrtVi7ikXBFGq9mUTY3NfvIc7DAtFTcgRB2Qtnoyrb6s/bihiu3b 9eOBdukMAyyfivz0GlviVqUh1PMTYIjzAtT1AByhON+QdZUA9C0CevyUZ4JDkuArUwhC L2tg== X-Gm-Message-State: ALoCoQnCCgbvztB4r4E6U1wcTL2KT3VpYgRFU7B/euPaqHaLssKI1hQZi2RJ5hOKJ5zaVCOcka6E X-Received: by 10.68.76.68 with SMTP id i4mr4981271pbw.73.1396504879648; Wed, 02 Apr 2014 23:01:19 -0700 (PDT) Received: from tharvey-gw.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by mx.google.com with ESMTPSA id ug9sm8598838pbc.11.2014.04.02.23.01.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Apr 2014 23:01:19 -0700 (PDT) From: Tim Harvey To: Stefano Babic Date: Wed, 2 Apr 2014 23:01:02 -0700 Message-Id: <1396504871-1454-3-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1396504871-1454-1-git-send-email-tharvey@gateworks.com> References: <1396504871-1454-1-git-send-email-tharvey@gateworks.com> Cc: Otavio Salvador , u-boot@lists.denx.de, Tom Rini , Stefan Roese Subject: [U-Boot] [PATCH 02/11] SPL: NAND: add support for mxs nand X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 This utilizes existing nand support, including the mtd layer to provide a a method to load an image off nand for SPL. It is somewhat bulky but avoids duplicating code. This will need to be split out and re-based on top of Tom's recent patch to add MTD NAND support which is needed here. Signed-off-by: Tim Harvey --- drivers/mtd/Makefile | 11 ++++++++++ drivers/mtd/nand/Makefile | 9 ++++++++ drivers/mtd/nand/mxs_nand_spl.c | 46 +++++++++++++++++++++++++++++++++++++++++ spl/Makefile | 1 + 4 files changed, 67 insertions(+) create mode 100644 drivers/mtd/nand/mxs_nand_spl.c diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index 5467a95..10ec470 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile @@ -5,6 +5,15 @@ # SPDX-License-Identifier: GPL-2.0+ # +ifdef CONFIG_SPL_BUILD + +ifdef CONFIG_SPL_NAND_MXS +obj-y += mtdcore.o +obj-y += mtdpart.o +endif + +else # not spl + ifneq (,$(findstring y,$(CONFIG_MTD_DEVICE)$(CONFIG_CMD_NAND)$(CONFIG_CMD_ONENAND))) obj-y += mtdcore.o endif @@ -18,3 +27,5 @@ obj-$(CONFIG_FTSMC020) += ftsmc020.o obj-$(CONFIG_FLASH_CFI_LEGACY) += jedec_flash.o obj-$(CONFIG_MW_EEPROM) += mw_eeprom.o obj-$(CONFIG_ST_SMI) += st_smi.o + +endif diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 02b149c..8b1a37a 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -19,6 +19,14 @@ obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o obj-$(CONFIG_SPL_NAND_INIT) += nand.o +ifdef CONFIG_SPL_NAND_MXS +obj-y += mxs_nand_spl.o +obj-y += nand_bbt.o +obj-y += nand_ids.o +obj-y += nand_util.o +obj-y += nand_ecc.o +endif + else # not spl NORMAL_DRIVERS=y @@ -65,5 +73,6 @@ else # minimal SPL drivers obj-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_spl.o obj-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_spl.o obj-$(CONFIG_NAND_MXC) += mxc_nand_spl.o +obj-$(CONFIG_NAND_MXS) += mxs_nand_spl.o mxs_nand.o endif # drivers diff --git a/drivers/mtd/nand/mxs_nand_spl.c b/drivers/mtd/nand/mxs_nand_spl.c new file mode 100644 index 0000000..ec07eb1 --- /dev/null +++ b/drivers/mtd/nand/mxs_nand_spl.c @@ -0,0 +1,46 @@ +/* + * (C) Copyright 2014 + * Tim Harvey, Gateworks Corporation, tharvey@gateworks.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +static nand_info_t mtd; +static struct nand_chip nand_chip; + +int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) +{ + size_t sz, actual; + + debug("%s offset:0x%08x len:%d\n", __func__, offs, size); + sz = size; + nand_read_skip_bad(&mtd, (loff_t) offs, &sz, &actual, size, dst); + debug("read %d/%d bytes\n", sz, actual); + + return 0; +} + +void nand_init(void) +{ + int ret; + + board_nand_init(&nand_chip); + mtd.priv = &nand_chip; + if (nand_chip.select_chip) + nand_chip.select_chip(&mtd, 0); + + ret = nand_scan(&mtd, 1); + if (!ret) + ret = nand_scan_tail(&mtd); + debug("oobsize=%d pagesize=%d\n", mtd.oobsize, mtd.writesize); + printf("NAND: %llu MiB\n", (mtd.size / (1024 * 1024))); +} + +void nand_deselect(void) +{ + if (nand_chip.select_chip) + nand_chip.select_chip(&mtd, -1); +} diff --git a/spl/Makefile b/spl/Makefile index 346d0aa..6a2c80f 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -103,6 +103,7 @@ libs-y += fs/ libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/ libs-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/ +libs-$(CONFIG_SPL_NAND_MXS) += drivers/mtd/ libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/ libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/ libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/