Commit a5cc88c0 authored by Dirk Behme's avatar Dirk Behme Committed by Kevin Hilman

ARM: DAVINCI: Add NAND driver

To: davinci-linux-open-source@linux.davincidsp.com
Date: Sat, 12 Jan 2008 07:39:48 +0100

This patch adds NAND driver to recent git. Tested on DM6446 DVEVM.

It is mainly based on Sander Huijsen <Shuijsen@optelecom-nkf.com> work

http://linux.omap.com/pipermail/davinci-linux-open-source/2007-December/004788.html

and HW ECC changes from Troy Kisky <troy.kisky@boundarydevices.com>

http://linux.omap.com/pipermail/davinci-linux-open-source/2008-January/004910.htmlSigned-off-by: default avatarDirk Behme <dirk.behme@gmail.com>
Signed-off-by: default avatarKevin Hilman <khilman@mvista.com>
parent 4668a6f9
......@@ -14,6 +14,7 @@
#include <linux/dma-mapping.h>
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
......@@ -27,6 +28,7 @@
#include <asm/mach/flash.h>
#include <asm/arch/common.h>
#include <asm/arch/hardware.h>
#include <asm/arch/psc.h>
/* other misc. init functions */
......@@ -38,7 +40,7 @@ void __init davinci_init_common_hw(void);
/* NOR Flash base address set to CS0 by default */
#define NOR_FLASH_PHYS 0x02000000
static struct mtd_partition davinci_evm_partitions[] = {
static struct mtd_partition davinci_evm_norflash_partitions[] = {
/* bootloader (U-Boot, etc) in first 4 sectors */
{
.name = "bootloader",
......@@ -69,30 +71,63 @@ static struct mtd_partition davinci_evm_partitions[] = {
}
};
static struct physmap_flash_data davinci_evm_flash_data = {
static struct physmap_flash_data davinci_evm_norflash_data = {
.width = 2,
.parts = davinci_evm_partitions,
.nr_parts = ARRAY_SIZE(davinci_evm_partitions),
.parts = davinci_evm_norflash_partitions,
.nr_parts = ARRAY_SIZE(davinci_evm_norflash_partitions),
};
/* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF
* limits addresses to 16M, so using addresses past 16M will wrap */
static struct resource davinci_evm_flash_resource = {
static struct resource davinci_evm_norflash_resource = {
.start = NOR_FLASH_PHYS,
.end = NOR_FLASH_PHYS + SZ_16M - 1,
.flags = IORESOURCE_MEM,
};
static struct platform_device davinci_evm_flash_device = {
static struct platform_device davinci_evm_norflash_device = {
.name = "physmap-flash",
.id = 0,
.dev = {
.platform_data = &davinci_evm_flash_data,
.platform_data = &davinci_evm_norflash_data,
},
.num_resources = 1,
.resource = &davinci_evm_flash_resource,
.resource = &davinci_evm_norflash_resource,
};
#if defined(CONFIG_MTD_NAND_DAVINCI) || defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
struct mtd_partition davinci_evm_nandflash_partition[] = {
/* 5 MB space at the beginning for bootloader and kernel */
{
.name = "NAND filesystem",
.offset = 5 * SZ_1M,
.size = MTDPART_SIZ_FULL,
.mask_flags = 0,
}
};
static struct nand_platform_data davinci_evm_nandflash_data = {
.parts = davinci_evm_nandflash_partition,
.nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
};
static struct resource davinci_evm_nandflash_resource = {
.start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
.end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16K - 1,
.flags = IORESOURCE_MEM,
};
static struct platform_device davinci_evm_nandflash_device = {
.name = "davinci_nand",
.id = 0,
.dev = {
.platform_data = &davinci_evm_nandflash_data,
},
.num_resources = 1,
.resource = &davinci_evm_nandflash_resource,
};
#endif
#if defined(CONFIG_FB_DAVINCI) || defined(CONFIG_FB_DAVINCI_MODULE)
static u64 davinci_fb_dma_mask = DMA_32BIT_MASK;
......@@ -168,7 +203,10 @@ static struct platform_device rtc_dev = {
};
static struct platform_device *davinci_evm_devices[] __initdata = {
&davinci_evm_flash_device,
&davinci_evm_norflash_device,
#if defined(CONFIG_MTD_NAND_DAVINCI) || defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
&davinci_evm_nandflash_device,
#endif
#if defined(CONFIG_FB_DAVINCI) || defined(CONFIG_FB_DAVINCI_MODULE)
&davinci_fb_device,
#endif
......
......@@ -16,10 +16,6 @@
#include <asm/arch/mux.h>
/* System control register offsets */
#define PINMUX0 0x00
#define PINMUX1 0x04
static DEFINE_SPINLOCK(mux_lock);
void davinci_mux_peripheral(unsigned int mux, unsigned int enable)
......
......@@ -293,5 +293,17 @@ config MTD_NAND_PLATFORM
devices. You will need to provide platform-specific functions
via platform_data.
config MTD_NAND_DAVINCI
tristate "NAND Flash device on DaVinci SoC"
depends on MTD_NAND
select MTD_PARTITIONS
help
Support for NAND flash on Texas Instruments DaVinci SoC.
config NAND_FLASH_HW_ECC
bool "Hardware ECC Support on NAND Device for DaVinci"
depends on MTD_NAND_DAVINCI
help
Support for Hardware ECC on NAND device for DaVinci.
endif # MTD_NAND
......@@ -29,5 +29,6 @@ obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o
obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o
obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o
obj-$(CONFIG_MTD_NAND_PLATFORM) += plat_nand.o
obj-$(CONFIG_MTD_NAND_DAVINCI) += davinci_nand.o
nand-objs := nand_base.o nand_bbt.o
This diff is collapsed.
......@@ -2456,6 +2456,13 @@ int nand_scan_tail(struct mtd_info *mtd)
chip->ecc.write_page_raw = nand_write_page_raw;
switch (chip->ecc.mode) {
#ifdef CONFIG_NAND_FLASH_HW_ECC
case NAND_ECC_HW12_2048:
case NAND_ECC_HW8_512:
case NAND_ECC_HW6_512:
case NAND_ECC_HW3_512:
case NAND_ECC_HW3_256:
#endif
case NAND_ECC_HW:
/* Use standard hwecc read page function ? */
if (!chip->ecc.read_page)
......
......@@ -11,6 +11,11 @@
#ifndef __ASM_ARCH_MUX_H
#define __ASM_ARCH_MUX_H
/* System control register offsets */
#define PINMUX0 0x00
#define PINMUX1 0x04
/* System control register bits */
#define DAVINCI_MUX_AEAW0 0
#define DAVINCI_MUX_AEAW1 1
#define DAVINCI_MUX_AEAW2 2
......
/*
* include/asm-arm/arch-davinci/nand.h
*
* Copyright (C) 2006 Texas Instruments.
*
* ported to 2.6.23 (C) 2008 by
* Sander Huijsen <Shuijsen@optelecom-nkf.com>
* Troy Kisky <troy.kisky@boundarydevices.com>
* Dirk Behme <Dirk.Behme@gmail.com>
*
* --------------------------------------------------------------------------
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
* --------------------------------------------------------------------------
*
*/
#ifndef __ARCH_ARM_DAVINCI_NAND_H
#define __ARCH_ARM_DAVINCI_NAND_H
#define NRCSR_OFFSET 0x00
#define AWCCR_OFFSET 0x04
#define A1CR_OFFSET 0x10
#define NANDFCR_OFFSET 0x60
#define NANDFSR_OFFSET 0x64
#define NANDF1ECC_OFFSET 0x70
#define MASK_ALE 0x0A
#define MASK_CLE 0x10
#define NAND_BUSY_FLAG 0x01
#endif /* __ARCH_ARM_DAVINCI_NAND_H */
......@@ -123,6 +123,13 @@ typedef enum {
NAND_ECC_SOFT,
NAND_ECC_HW,
NAND_ECC_HW_SYNDROME,
#ifdef CONFIG_NAND_FLASH_HW_ECC
NAND_ECC_HW3_256,
NAND_ECC_HW3_512,
NAND_ECC_HW6_512,
NAND_ECC_HW8_512,
NAND_ECC_HW12_2048,
#endif
} nand_ecc_modes_t;
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment