bcmring: mtd nand driver
PATCH 1/1 bcmring: mtd nand driver
Hi,
I've updated the patch of mtd nand driver support for bcmring arch. It's now applicable to the latest kernel git tree (Linux 2.6.32-rc1).
Please merge this patch into upstream.
If further modification needed, let me know.
Thanks,
Quoted 1 line
From
4a84726a83c091185b45927de6eb1172f69b964fMon Sep 17 00:00:00 2001
From: Leo Chen <[email protected]>
Date: Mon, 28 Sep 2009 14:11:49 -0700
Subject: [PATCH] add bcmring mtd nand driver support
Add mtd umi driver for bcmring arm arch.
Add header files, register definition files,
add entry in Kconfig and Makefile.
--- arch/arm/mach-bcmring/include/mach/reg_nand.h | 66 ++ arch/arm/mach-bcmring/include/mach/reg_umi.h | 237 ++++++++ drivers/mtd/nand/Kconfig | 16 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/bcm_umi_bch.c | 213 +++++++ drivers/mtd/nand/bcm_umi_nand.c | 792 +++++++++++++++++++++++++ drivers/mtd/nand/nand_bcm_umi.c | 149 +++++ drivers/mtd/nand/nand_bcm_umi.h | 358 +++++++++++ 8 files changed, 1832 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-bcmring/include/mach/reg_nand.h create mode 100644 arch/arm/mach-bcmring/include/mach/reg_umi.h create mode 100644 drivers/mtd/nand/bcm_umi_bch.c create mode 100644 drivers/mtd/nand/bcm_umi_nand.c create mode 100644 drivers/mtd/nand/nand_bcm_umi.c create mode 100644 drivers/mtd/nand/nand_bcm_umi.h
arch/arm/mach-bcmring/include/mach/reg_nand.h new file +66 -0
@@ -0,0 +1,66 @@ +/***************************************************************************** +* Copyright 2001 - 2008 Broadcom Corporation. All rights reserved. +* +* Unless you and Broadcom execute a separate written software license +* agreement governing use of this software, this software is licensed to you +* under the terms of the GNU General Public License version 2, available at +* http://www.broadcom.com/licenses/GPLv2.php (the "GPL"). +* +* Notwithstanding the above, under no circumstances may you combine this +* software in any way with any other Broadcom software provided under a +* license other than the GPL, without Broadcom's express prior written +* consent. +*****************************************************************************/ + +/* +* +***************************************************************************** +* +* REG_NAND.h +* +* PURPOSE: +* +* This file contains definitions for the nand registers: +* +* NOTES: +* +*****************************************************************************/ + +#if !defined(__ASM_ARCH_REG_NAND_H) +#define __ASM_ARCH_REG_NAND_H + +/* ---- Include Files ---------------------------------------------------- */ +#include <csp/reg.h> +#include <mach/reg_umi.h> + +/* ---- Constants and Types ---------------------------------------------- */ + +#define HW_NAND_BASE MM_IO_BASE_NAND/* NAND Flash */ + +/* DMA accesses by the bootstrap need hard nonvirtual addresses */ +#define REG_NAND_CMD __REG16(HW_NAND_BASE + 0) +#define REG_NAND_ADDR __REG16(HW_NAND_BASE + 4) + +#define REG_NAND_PHYS_DATA16 (HW_NAND_BASE + 8) +#define REG_NAND_PHYS_DATA8 (HW_NAND_BASE + 8) +#define REG_NAND_DATA16 __REG16(REG_NAND_PHYS_DATA16) +#define REG_NAND_DATA8 __REG8(REG_NAND_PHYS_DATA8) + +/* use appropriate offset to make sure it start at the 1K boundary */ +#define REG_NAND_PHYS_DATA_DMA (HW_NAND_BASE + 0x400) +#define REG_NAND_DATA_DMA __REG32(REG_NAND_PHYS_DATA_DMA) + +/* Linux DMA requires physical address of the data register */ +#define REG_NAND_DATA16_PADDR HW_IO_VIRT_TO_PHYS(REG_NAND_PHYS_DATA16) +#define REG_NAND_DATA8_PADDR HW_IO_VIRT_TO_PHYS(REG_NAND_PHYS_DATA8) +#define REG_NAND_DATA_PADDR HW_IO_VIRT_TO_PHYS(REG_NAND_PHYS_DATA_DMA) + +#define NAND_BUS_16BIT () (0) +#define NAND_BUS_8BIT () (!NAND_BUS_16BIT()) + +/* Register offsets */ +#define REG_NAND_CMD_OFFSET (0) +#define REG_NAND_ADDR_OFFSET (4) +#define REG_NAND_DATA8_OFFSET (8) + +#endif
arch/arm/mach-bcmring/include/mach/reg_umi.h new file +237 -0
237 lines not on this page · raw message
drivers/mtd/nand/Kconfig +16 -0
@@ -203,6 +203,22 @@ config MTD_NAND_S3C2410_CLKSTOP when the is NAND chip selected or released, but will save approximately 5mA of power when there is nothing happening. +config MTD_NAND_BCM_UMI + tristate "NAND Flash support for BCM Reference Boards" + depends on ARCH_BCMRING && MTD_NAND + help + This enables the NAND flash controller on the BCM UMI block. + + No board specfic support is done by this driver, each board + must advertise a platform_device for the driver to attach. + +config MTD_NAND_BCM_UMI_HWCS + bool "BCM UMI NAND Hardware CS" + depends on MTD_NAND_BCM_UMI + help + Enable the use of the BCM UMI block's internal CS using NAND. + This should only be used if you know the external NAND CS can toggle. + config MTD_NAND_DISKONCHIP tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)" depends on EXPERIMENTAL
drivers/mtd/nand/Makefile +1 -0
@@ -42,5 +42,6 @@ obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o obj-$(CONFIG_MTD_NAND_W90P910) += w90p910_nand.o obj-$(CONFIG_MTD_NAND_NOMADIK) += nomadik_nand.o +obj-$(CONFIG_MTD_NAND_BCM_UMI) += bcm_umi_nand.o nand_bcm_umi.o nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/bcm_umi_bch.c new file +213 -0
213 lines not on this page · raw message
drivers/mtd/nand/bcm_umi_nand.c new file +792 -0
792 lines not on this page · raw message
drivers/mtd/nand/nand_bcm_umi.c new file +149 -0
149 lines not on this page · raw message
drivers/mtd/nand/nand_bcm_umi.h new file +358 -0
358 lines not on this page · raw message
Signature · 8 lines
1.6.0.6 -- Leo Hao Chen ------------------------ Life is short, run long.
Quoted 6 lines · Leo (Hao) Chen
I've updated the patch of mtd nand driver support for bcmring arch. It's now applicable to the latest kernel git tree (Linux 2.6.32-rc1).
Please merge this patch into upstream.
If further modification needed, let me know.
Thank you. On closer inspection, this patch is actually a whole lot saner than it appears at first glance. The amount of superfluous commenting made it look bad, when I first looked.
For example, a function called 'nand_dma_write' does _not_ need a five-line comment block explaining that it 'Performs a write via DMA'.
Other comments, on a brief re-reading...
You're using a platform device, but you still hard-code the I/O address you ioremap for bcm_imi_io_base -- is it possible for you to fix that, and encode it in the platform device instead?
Also, do you need the USE_DMA and USE_HWECC macros? If they're always enabled, can we lose some ifdefs?
Finally, can you convince me that this isn't an "additional restriction" as prohibited by the GPL? :
+* Notwithstanding the above, under no circumstances may you combine this +* software in any way with any other Broadcom software provided under a +* license other than the GPL, without Broadcom's express prior written +* consent.
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Quoted 8 lines · David Woodhouse
Quoted 6 lines · Leo (Hao) Chen
I've updated the patch of mtd nand driver support for bcmring arch. It's now applicable to the latest kernel git tree (Linux 2.6.32-rc1).
Please merge this patch into upstream.
If further modification needed, let me know.
Quoted 8 lines
Thank you. On closer inspection, this patch is actually a whole lot saner than it appears at first glance. The amount of superfluous commenting made it look bad, when I first looked.
For example, a function called '
nand_dma_write' does _not_ need a five-line comment block explaining that it 'Performs a write via DMA'.Other comments, on a brief re-reading...
I'll remove those superfluous comments.
Quoted 4 lines
You're using a platform device, but you still hard-code the I/O address you ioremap for
bcm_imi_io_base-- is it possible for you to fix that, and encode it in the platform device instead?
I'll look into it to see what I can do with the platform device.
Quoted 3 lines
Also, do you need the
USE_DMAandUSE_HWECCmacros? If they're always enabled, can we lose some ifdefs?
USE_DMA is useful for us to debug DMA. USE_HWECC may be removed.
arch/arm/mach-bcmring/include/mach/reg_nand.h line 12
Quoted 9 lines
Finally, can you convince me that this isn't an "additional restriction" as prohibited by the GPL? :
arch/arm/mach-bcmring/include/mach/reg_nand.h new file +4
-0+* Notwithstanding the above, under no circumstances may you combine this +* software in any way with any other Broadcom software provided under a +* license other than the GPL, without Broadcom's express prior written +* consent.
This is what our lawyer's are making us place on
all our GPL code indicating we are releasing it as GPL.
There is no "additional restriction" -
it is being released to the kernel community under GPL.
This information is just informing our customers they can not combine this code with Broadcom proprietary licensed code that has not been released under an open-source/GPL license to them.
Thanks,
Signature · 4 lines
Leo Hao Chen ------------------------ Life is short, run long.
Hi,
Please check the updated version of this patch for bcmring nand driver support.
I've removed superfluous comments, added platform resource, added a new kernel option to replace the USE_HWECC macro.
Please comment.
Thanks,
Leo
Quoted 1 line
From
398b8fbfd219ee20f2eb76101992d6153ce8b52eMon Sep 17 00:00:00 2001
From: Leo Chen <[email protected]>
Date: Mon, 28 Sep 2009 14:11:49 -0700
Subject: [PATCH] add bcmring mtd nand driver support
Add mtd umi driver for bcmring arm arch.
Add header files, register definition files,
add entry in Kconfig and Makefile.
remove superfluous comments from bcm nand driver
use platform resource
add CONFIG_MTD_NAND_BCM_UMI_HWECC option to replace USE_HWECC macro
--- arch/arm/configs/bcmring_defconfig | 1 + arch/arm/mach-bcmring/arch.c | 10 + arch/arm/mach-bcmring/include/mach/reg_nand.h | 66 +++ arch/arm/mach-bcmring/include/mach/reg_umi.h | 237 ++++++++++ drivers/mtd/nand/Kconfig | 24 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/bcm_umi_bch.c | 213 +++++++++ drivers/mtd/nand/bcm_umi_nand.c | 592 +++++++++++++++++++++++++ drivers/mtd/nand/nand_bcm_umi.c | 149 +++++++ drivers/mtd/nand/nand_bcm_umi.h | 358 +++++++++++++++ 10 files changed, 1651 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-bcmring/include/mach/reg_nand.h create mode 100644 arch/arm/mach-bcmring/include/mach/reg_umi.h create mode 100644 drivers/mtd/nand/bcm_umi_bch.c create mode 100644 drivers/mtd/nand/bcm_umi_nand.c create mode 100644 drivers/mtd/nand/nand_bcm_umi.c create mode 100644 drivers/mtd/nand/nand_bcm_umi.h
arch/arm/configs/bcmring_defconfig +1 -0
@@ -416,6 +416,7 @@ CONFIG_MTD_NAND_VERIFY_WRITE=y CONFIG_MTD_NAND_IDS=y CONFIG_MTD_NAND_BCM_UMI=y CONFIG_MTD_NAND_BCM_UMI_HWCS=y +CONFIG_MTD_NAND_BCM_UMI_HWECC=y # CONFIG_MTD_NAND_DISKONCHIP is not set # CONFIG_MTD_NAND_NANDSIM is not set # CONFIG_MTD_NAND_PLATFORM is not set
arch/arm/mach-bcmring/arch.c +10 -0
@@ -76,9 +76,19 @@ static struct ctl_table bcmring_sysctl_reboot[] = { {} }; +static struct resource nand_resource[] = { + [0 ] = { + .start =MM_ADDR_IO_NAND , + .end =MM_ADDR_IO_NAND +0x1000 -1 , + .flags =IORESOURCE_MEM , + }, +}; +static struct platform_device nand_device = { .name ="bcm-nand" , .id =-1 , + .resource = nand_resource, + .num_resources =ARRAY_SIZE (nand_resource), };static struct platform_device *devices[]__initdata = {
arch/arm/mach-bcmring/include/mach/reg_nand.h new file +66 -0
66 lines not on this page · raw message
arch/arm/mach-bcmring/include/mach/reg_umi.h new file +237 -0
237 lines not on this page · raw message
drivers/mtd/nand/Kconfig +24 -0
@@ -203,6 +203,30 @@ config MTD_NAND_S3C2410_CLKSTOP when the is NAND chip selected or released, but will save approximately 5mA of power when there is nothing happening. +config MTD_NAND_BCM_UMI + tristate "NAND Flash support for BCM Reference Boards" + depends on ARCH_BCMRING && MTD_NAND + help + This enables the NAND flash controller on the BCM UMI block. + + No board specfic support is done by this driver, each board + must advertise a platform_device for the driver to attach. + +config MTD_NAND_BCM_UMI_HWCS + bool "BCM UMI NAND Hardware CS" + depends on MTD_NAND_BCM_UMI + help + Enable the use of the BCM UMI block's internal CS using NAND. + This should only be used if you know the external NAND CS can toggle. + +config MTD_NAND_BCM_UMI_HWECC + bool "BCM UMI NAND Hardware ECC" + default y + depends on MTD_NAND_BCM_UMI + help + Enable the use of the internal ECC generator of BCM UMI block when + using NAND. + config MTD_NAND_DISKONCHIP tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)" depends on EXPERIMENTAL
drivers/mtd/nand/Makefile +1 -0
@@ -42,5 +42,6 @@ obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o obj-$(CONFIG_MTD_NAND_W90P910) += w90p910_nand.o obj-$(CONFIG_MTD_NAND_NOMADIK) += nomadik_nand.o +obj-$(CONFIG_MTD_NAND_BCM_UMI) += bcm_umi_nand.o nand_bcm_umi.o nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/bcm_umi_bch.c new file +213 -0
213 lines not on this page · raw message
drivers/mtd/nand/bcm_umi_nand.c new file +592 -0
592 lines not on this page · raw message
drivers/mtd/nand/nand_bcm_umi.c new file +149 -0
149 lines not on this page · raw message
drivers/mtd/nand/nand_bcm_umi.h new file +358 -0
358 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Quoted 46 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Leo (Hao) Chen
Sent: September 29, 2009 5:02 PM
To: David Woodhouse
Cc: Linux MTD
Subject: Re: [PATCH] [MTD] bcmring: mtd nand driverHi,
Please check the updated version of this patch for bcmring nand driver support.
I've removed superfluous comments, added platform resource, added a new
kernel option to replace theUSE_HWECCmacro.Please comment.
Thanks,
Leo
From
398b8fbfd219ee20f2eb76101992d6153ce8b52eMon Sep 17 00:00:00 2001
From: Leo Chen <[email protected]>
Date: Mon, 28 Sep 2009 14:11:49 -0700
Subject: [PATCH] add bcmring mtd nand driver supportAdd mtd umi driver for bcmring arm arch.
Add header files, register definition files,
add entry inKconfigandMakefile.remove superfluous comments from bcm nand driver
use platform resourceadd
CONFIG_MTD_NAND_BCM_UMI_HWECCoption to replaceUSE_HWECCmacroarch/arm/configs/bcmring_defconfig +0
-0
arch/arm/configs/bcmring_defconfig CONFIG_MTD_NAND_VERIFY_WRITE=y · line 419
Quoted 4 lines
arch/arm/configs/bcmring_defconfig +1
-0@@ -416,6 +416,7 @@ CONFIG_MTD_NAND_VERIFY_WRITE=y CONFIG_MTD_NAND_IDS=y CONFIG_MTD_NAND_BCM_UMI=y CONFIG_MTD_NAND_BCM_UMI_HWCS=y +CONFIG_MTD_NAND_BCM_UMI_HWECC=y
There is no need for an additional CONFIG option. Just always use HWECC and delete the soft code.
Quoted 4 lines · Scott Branden
Quoted 1 line
+CONFIG_MTD_NAND_BCM_UMI_HWECC=y
There is no need for an additional CONFIG option. Just always use HWECC and delete the soft code.
Got it. Please check the updated patch in this email after the fix.
Quoted 1 line
From
559070fbe51d5e3d0046cb5ade5ea9280ecde8fdMon Sep 17 00:00:00 2001
From: Leo Chen <[email protected]>
Date: Mon, 28 Sep 2009 14:11:49 -0700
Subject: [PATCH] add bcmring mtd nand driver support
Add mtd umi driver for bcmring arm arch.
Add header files, register definition files,
add entry in Kconfig and Makefile.
remove superfluous comments from bcm nand driver
use platform resource
--- arch/arm/mach-bcmring/arch.c | 10 + arch/arm/mach-bcmring/include/mach/reg_nand.h | 66 +++ arch/arm/mach-bcmring/include/mach/reg_umi.h | 237 ++++++++++ drivers/mtd/nand/Kconfig | 16 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/bcm_umi_bch.c | 213 +++++++++ drivers/mtd/nand/bcm_umi_nand.c | 580 +++++++++++++++++++++++++ drivers/mtd/nand/nand_bcm_umi.c | 149 +++++++ drivers/mtd/nand/nand_bcm_umi.h | 358 +++++++++++++++ 9 files changed, 1630 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-bcmring/include/mach/reg_nand.h create mode 100644 arch/arm/mach-bcmring/include/mach/reg_umi.h create mode 100644 drivers/mtd/nand/bcm_umi_bch.c create mode 100644 drivers/mtd/nand/bcm_umi_nand.c create mode 100644 drivers/mtd/nand/nand_bcm_umi.c create mode 100644 drivers/mtd/nand/nand_bcm_umi.h
arch/arm/mach-bcmring/arch.c +10 -0
@@ -76,9 +76,19 @@ static struct ctl_table bcmring_sysctl_reboot[] = { {} }; +static struct resource nand_resource[] = { + [0 ] = { + .start =MM_ADDR_IO_NAND , + .end =MM_ADDR_IO_NAND +0x1000 -1 , + .flags =IORESOURCE_MEM , + }, +}; +static struct platform_device nand_device = { .name ="bcm-nand" , .id =-1 , + .resource = nand_resource, + .num_resources =ARRAY_SIZE (nand_resource), };static struct platform_device *devices[]__initdata = {
arch/arm/mach-bcmring/include/mach/reg_nand.h new file +66 -0
66 lines not on this page · raw message
arch/arm/mach-bcmring/include/mach/reg_umi.h new file +237 -0
237 lines not on this page · raw message
drivers/mtd/nand/Kconfig +16 -0
@@ -203,6 +203,22 @@ config MTD_NAND_S3C2410_CLKSTOP when the is NAND chip selected or released, but will save approximately 5mA of power when there is nothing happening. +config MTD_NAND_BCM_UMI + tristate "NAND Flash support for BCM Reference Boards" + depends on ARCH_BCMRING && MTD_NAND + help + This enables the NAND flash controller on the BCM UMI block. + + No board specfic support is done by this driver, each board + must advertise a platform_device for the driver to attach. + +config MTD_NAND_BCM_UMI_HWCS + bool "BCM UMI NAND Hardware CS" + depends on MTD_NAND_BCM_UMI + help + Enable the use of the BCM UMI block's internal CS using NAND. + This should only be used if you know the external NAND CS can toggle. + config MTD_NAND_DISKONCHIP tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)" depends on EXPERIMENTAL
drivers/mtd/nand/Makefile +1 -0
@@ -42,5 +42,6 @@ obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o obj-$(CONFIG_MTD_NAND_W90P910) += w90p910_nand.o obj-$(CONFIG_MTD_NAND_NOMADIK) += nomadik_nand.o +obj-$(CONFIG_MTD_NAND_BCM_UMI) += bcm_umi_nand.o nand_bcm_umi.o nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/bcm_umi_bch.c new file +213 -0
213 lines not on this page · raw message
drivers/mtd/nand/bcm_umi_nand.c new file +580 -0
580 lines not on this page · raw message
drivers/mtd/nand/nand_bcm_umi.c new file +149 -0
149 lines not on this page · raw message
drivers/mtd/nand/nand_bcm_umi.h new file +358 -0
358 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Scott Branden
Acked-byQuoted 9 lines
-----Original Message-----
From: Leo (Hao) Chen [mailto:[email protected]]
Sent: September 29, 2009 5:41 PM
To: Scott Branden
Cc: David Woodhouse; Linux MTD
Subject: Re: [PATCH] [MTD] bcmring: mtd nand driver
Quoted 10 lines
Quoted 3 lines · Scott Branden
Quoted 1 line
+CONFIG_MTD_NAND_BCM_UMI_HWECC=y
There is no need for an additional CONFIG option. Just
always use HWECC and delete the soft code.
Quoted 1 line
Got it. Please check the updated patch in this email after the fix.
Looks good.