From patchwork Wed Apr 7 17:38:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Sakoman X-Patchwork-Id: 91143 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o37Hcpoj029622 for ; Wed, 7 Apr 2010 17:38:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753609Ab0DGRid (ORCPT ); Wed, 7 Apr 2010 13:38:33 -0400 Received: from mail-qy0-f179.google.com ([209.85.221.179]:42235 "EHLO mail-qy0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752261Ab0DGRiZ (ORCPT ); Wed, 7 Apr 2010 13:38:25 -0400 Received: by qyk9 with SMTP id 9so1437255qyk.1 for ; Wed, 07 Apr 2010 10:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=qhlSJawBM0/7o33GGgvoF14IexKSAci0/DjNvFrBscU=; b=wJL1Sib1UAdk9u7VqUG54C/SvsXL+mbGLlQl62q4DAKe3aqTWrto/qrmYp/NGDNti8 g+8+/4KNSFmY8u+/pxs75ZFpcYSkGIxvntHx3bTVTAs8hNb3S/rVt8weJnEPlg6haaYX pM64WUWVn5RekVsywPJwQJYvsftaqyMhxyhxk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=L2jpUCKC8lvuh0DMmhBy10UMNzKyXIh4jVbtSLVYxJZnC91xtibWasDBOqAxWE/aXU Q4zbSxQ3TgcL+IomVEvphRevLGhQF2/Pthj0qufqbJ9p8MU872QK7fJsoVsyL36z44mH wfCzClZyk9NT2qpITMmbpWbYbW4x8L8UstFnU= MIME-Version: 1.0 Received: by 10.229.70.133 with HTTP; Wed, 7 Apr 2010 10:38:23 -0700 (PDT) Date: Wed, 7 Apr 2010 10:38:23 -0700 Received: by 10.229.213.208 with SMTP id gx16mr14617625qcb.35.1270661903684; Wed, 07 Apr 2010 10:38:23 -0700 (PDT) Message-ID: Subject: ARM: OMAP: Beagle: use new gpmc nand infrastructure From: Steve Sakoman To: linux-omap@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 07 Apr 2010 17:38:52 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c index 962d377..3ba0603 100644 --- a/arch/arm/mach-omap2/board-omap3beagle.c +++ b/arch/arm/mach-omap2/board-omap3beagle.c @@ -52,6 +52,11 @@ #define NAND_BLOCK_SIZE SZ_128K +struct flash_partitions { + struct mtd_partition *parts; + int nr_parts; +}; + static struct mtd_partition omap3beagle_nand_partitions[] = { /* All the partition sizes are listed in terms of NAND block size */ { @@ -83,28 +88,102 @@ static struct mtd_partition omap3beagle_nand_partitions[] = { }, }; +static struct flash_partitions omap3beagle_flash_partitions[] = { + { + /* NOR flash */ + }, + { + /* OneNAND */ + }, + { + /* NAND */ + .parts = omap3beagle_nand_partitions, + .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions), + }, +}; + +#if defined(CONFIG_MTD_NAND_OMAP2) || \ + defined(CONFIG_MTD_NAND_OMAP2_MODULE) + +/* Note that all values in this struct are in nanoseconds */ +static struct gpmc_timings nand_timings = { + + .sync_clk = 0, + + .cs_on = 0, + .cs_rd_off = 36, + .cs_wr_off = 36, + + .adv_on = 6, + .adv_rd_off = 24, + .adv_wr_off = 36, + + .we_off = 30, + .oe_off = 48, + + .access = 54, + .rd_cycle = 72, + .wr_cycle = 72, + + .wr_access = 30, + .wr_data_mux_bus = 0, +}; + static struct omap_nand_platform_data omap3beagle_nand_data = { - .options = NAND_BUSWIDTH_16, - .parts = omap3beagle_nand_partitions, - .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions), - .dma_channel = -1, /* disable DMA in OMAP NAND driver */ .nand_setup = NULL, + .gpmc_t = &nand_timings, + .dma_channel = -1, /* disable DMA in OMAP NAND driver */ .dev_ready = NULL, + .devsize = 1, /* '0' for 8-bit, '1' for 16-bit device */ }; -static struct resource omap3beagle_nand_resource = { - .flags = IORESOURCE_MEM, -}; +static void +__init board_nand_init(struct flash_partitions omap3beagle_nand_parts, u8 cs) +{ + omap3beagle_nand_data.cs = cs; + omap3beagle_nand_data.parts = omap3beagle_nand_parts.parts; + omap3beagle_nand_data.nr_parts = omap3beagle_nand_parts.nr_parts; + omap3beagle_nand_data.gpmc_baseaddr = (void *) (OMAP34XX_GPMC_VIRT); -static struct platform_device omap3beagle_nand_device = { - .name = "omap2-nand", - .id = -1, - .dev = { - .platform_data = &omap3beagle_nand_data, - }, - .num_resources = 1, - .resource = &omap3beagle_nand_resource, -}; + omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)(OMAP34XX_GPMC_VIRT + + GPMC_CS0_BASE + cs * GPMC_CS_SIZE); + + gpmc_nand_init(&omap3beagle_nand_data); +} +#else +static void +__init board_nand_init(struct flash_partitions omap3beagle_nand_parts, u8 cs) +{ +} +#endif /* CONFIG_MTD_NAND_OMAP2 || CONFIG_MTD_NAND_OMAP2_MODULE */ + +static void +__init omap3beagle_flash_init(struct flash_partitions partition_info[]) { + u8 cs = 0; + u8 nandcs = GPMC_CS_NUM + 1; + + /* find out the chip-select on which NAND exists */ + while (cs < GPMC_CS_NUM) { + u32 ret = 0; + ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); + + if ((ret & 0xC00) == 0x800) { + printk(KERN_INFO "Found NAND on CS%d\n", cs); + if (nandcs > GPMC_CS_NUM) + nandcs = cs; + } + cs++; + } + + if (nandcs > GPMC_CS_NUM) { + printk(KERN_INFO "NAND: Unable to find configuration " + "in GPMC\n "); + return; + } + + if (nandcs < GPMC_CS_NUM) + board_nand_init(partition_info[2], nandcs); +} #include "sdram-micron-mt46h32m32lf-6.h"