mtd: nand: Allow NAND chip ids to be included standalone.
PATCH 1/2 mtd: nand: Allow NAND chip ids to be included standalone.
Lets non-standard NAND drivers take advantage of known NAND chip information.
--- drivers/mtd/nand/Kconfig | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/mtd/nand/Kconfig +7 -3
@@ -1,3 +1,10 @@ +config MTD_NAND_IDS + tristate "Include chip ids for known NAND devices." + depends on MTD + help + Useful for NAND drivers that do not use the NAND subsystem but + still like to take advantage of the known chip information. + config MTD_NAND_ECC tristate
@@ -123,9 +130,6 @@ config MTD_NAND_OMAP_PREFETCH_DMA or in DMA interrupt mode. Say y for DMA mode or MPU mode will be used -config MTD_NAND_IDS - tristate - config MTD_NAND_RICOH tristate "Ricoh xD card reader" default n
Signature · 5 lines
1.7.1.1 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 2/2 mtd: msm_nand: Add initial msm nand driver support.
Add initial msm nand driver support for Qualcomm MSM platforms. This driver is capable of handling both 2k and 4k page support nand devices.
This driver was originally developed by Arve Hjønnevåg at google. Its source is available at
http://android.git.kernel.org/?p=kernel/msm.git under android-msm-2.6.35 branch.
--- drivers/mtd/devices/Kconfig | 11 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/msm_nand.c | 1597 ++++++++++++++++++++++++++++++++++++++++ drivers/mtd/devices/msm_nand.h | 77 ++ 4 files changed, 1686 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/devices/msm_nand.c create mode 100644 drivers/mtd/devices/msm_nand.h
drivers/mtd/devices/Kconfig +11 -0
@@ -49,6 +49,17 @@ config MTD_MS02NV say M here and read <file:Documentation/kbuild/modules.txt>. The module will be called ms02-nv. +config MTD_MSM_NAND + tristate "MSM on-chip NAND Flash Controller driver" + depends on MTD && ARCH_MSM + select MTD_NAND_IDS + help + This enables the on-chip NAND flash controller driver on Qualcomm's + MSM and QSD platforms. + + MSM NAND controller is capable of interfacing to all leading nand + flash vendor devices ie Samsung, Micron, Hynix etc. + config MTD_DATAFLASH tristate "Support for AT45xxx DataFlash" depends on SPI_MASTER && EXPERIMENTAL
drivers/mtd/devices/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_MTD_SLRAM) += slram.o obj-$(CONFIG_MTD_PHRAM) += phram.o obj-$(CONFIG_MTD_PMC551) += pmc551.o obj-$(CONFIG_MTD_MS02NV) += ms02-nv.o +obj-$(CONFIG_MTD_MSM_NAND) += msm_nand.o obj-$(CONFIG_MTD_MTDRAM) += mtdram.o obj-$(CONFIG_MTD_LART) += lart.o obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o
drivers/mtd/devices/msm_nand.c new file +1597 -0
1,597 lines not on this page · raw message
drivers/mtd/devices/msm_nand.h new file +77 -0
77 lines not on this page · raw message
Signature · 5 lines
1.7.1.1 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 5 lines · Murali Nalajala
Lets non-standard NAND drivers take advantage of known NAND chip information.
Signed-off-by Dima Zavin <[email protected]>Signed-off-by Murali Nalajala <[email protected]>
Please, make the description more descriptive. Please, make it explain which problem you are solving and how. What do you mean by non-standard drivers? Why they are non-standard?
Signature · 2 lines
Best Regards, Artem Bityutskiy (????? ????????)
Re: [PATCH 2/2] mtd: msm_nand: Add initial msm nand driver support.
In reply to Murali NalajalaQuoted 6 lines · Murali Nalajala
drivers/mtd/devices/msm_nand.c new file +6
-0+#define pr_fmt (fmt) "%s:" fmt, __func__ + +#include <linux/kernel.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/nand.h> +#include <linux/mtd/partitions.h>
drivers/mtd/devices/msm_nand.c line 31
Quoted 10 lines
drivers/mtd/devices/msm_nand.c new file +10
-0+#include <linux/platform_device.h> +#include <linux/sched.h> +#include <linux/slab.h> +#include <linux/dma-mapping.h> +#include <asm/mach/flash.h> +#include <mach/dma.h> + +#include "msm_nand.h" + +unsigned long msm_nand_phys;
No global variables like this please. Here is how you use them:
+extern unsigned long msm_nand_phys; +#define MSM_NAND_REG(off) (msm_nand_phys + (off)) +
+#define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000)
+#define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004)
Could you please make the macros to take the "struct msm_nand_chip *chip" argument instead, and store the pase address there. Do not hide the fact that those macros are actually functions, not constant - this is error prone.
Besides, I'm do not know your HW, but if you have several controllers with various base addresses - your driver won't work.
drivers/mtd/devices/msm_nand.c line 1417
Quoted 5 lines
drivers/mtd/devices/msm_nand.c new file +5
-0+pr_info ("Save cfg0 = %x cfg1 = %x\n" , chip->cfg0, chip->cfg1); +pr_info ("cfg0: cw/page=%d ud_sz=%d ecc_sz=%d spare_sz=%d " +"num_addr_cycles=%d\n" , (chip->cfg0 >>6 ) &7 , + (chip->cfg0 >>9 ) &0x3ff , (chip->cfg0 >>19 ) &15 , + (chip->cfg0 >>23 ) &15 , (chip->cfg0 >>27 ) &7 );
Please, revise all your pr_info() calls and turn most of them into dev_dbg() or pr_debug. Your driver should be completely silent by default, except of error messages and some information messages when it is initialized.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 2/2] mtd: msm_nand: Add initial msm nand driver support.
Quoted 20 lines · Artem Bityutskiy
Quoted 6 lines · Murali Nalajala
(quoted diff) +6
-0+#define pr_fmt(fmt) "%s:" fmt, __func__ + +#include<linux/kernel.h> +#include<linux/mtd/mtd.h> +#include<linux/mtd/nand.h> +#include<linux/mtd/partitions.h>Review
Quoted 10 lines
(quoted diff) +10
-0+#include<linux/platform_device.h> +#include<linux/sched.h> +#include<linux/slab.h> +#include<linux/dma-mapping.h> +#include<asm/mach/flash.h> +#include<mach/dma.h> + +#include "msm_nand.h" + +unsigned long msm_nand_phys;No global variables like this please. Here is how you use them:
Quoted 1 line
+extern unsigned long
msm_nand_phys;
extern declaration in the 'C' file causing warning. We are in plan to upload the OneNAND changes soon which makes use of the same .h file.
Quoted 5 lines
drivers/mtd/devices/msm_nand.h new file +4
-0+#define MSM_NAND_REG (off) (msm_nand_phys + (off)) + +#define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000) +#define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004)
Quoted 7 lines
Could you please make the macros to take the "struct
msm_nand_chip*chip" argument instead, and store the pase address there. Do not hide the fact that those macros are actually functions, not constant - this is error prone.Besides, I'm do not know your HW, but if you have several controllers with various base addresses - your driver won't work.
you are correct, we have multiple controllers, which breaks this logic in future.
Quoted 13 lines
Review
Quoted 6 lines
(quoted diff) +5
-0+ pr_info("Save cfg0 = %x cfg1 = %x\n", chip->cfg0, chip->cfg1); + pr_info("cfg0: cw/page=%d ud_sz=%d ecc_sz=%d spare_sz=%d " + "num_addr_cycles=%d\n", (chip->cfg0>> 6)& 7, + (chip->cfg0>> 9)& 0x3ff, (chip->cfg0>> 19)& 15, + (chip->cfg0>> 23)& 15, (chip->cfg0>> 27)& 7);Please, revise all your
pr_info()calls and turn most of them intodev_dbg()orpr_debug. Your driver should be completely silent by default, except of error messages and some information messages when it is initialized.
I will revise all the pr_info calls and change the inappropriate calls to pr_debug.
Thanks,
Murali N
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/2] mtd: msm_nand: Add initial msm nand driver support.
Quoted 21 lines · Murali Nalajala
Quoted 20 lines · Artem Bityutskiy
Quoted 6 lines · Murali Nalajala
(quoted diff) +6
-0+#define pr_fmt(fmt) "%s:" fmt, __func__ + +#include<linux/kernel.h> +#include<linux/mtd/mtd.h> +#include<linux/mtd/nand.h> +#include<linux/mtd/partitions.h>Review
Quoted 10 lines
(quoted diff) +10
-0+#include<linux/platform_device.h> +#include<linux/sched.h> +#include<linux/slab.h> +#include<linux/dma-mapping.h> +#include<asm/mach/flash.h> +#include<mach/dma.h> + +#include "msm_nand.h" + +unsigned long msm_nand_phys;No global variables like this please. Here is how you use them:
Quoted 4 lines
Quoted 1 line
+extern unsigned long
msm_nand_phys;extern declaration in the 'C' file causing warning. We are in plan to upload the OneNAND changes soon which makes use of the same .h file.
So you say that OneNAND (an independent driver) is going to use this variable? Are you also going to export it?
Quoted 10 lines
Quoted 10 lines
drivers/mtd/devices/msm_nand.h new file +4
-0+#define MSM_NAND_REG (off) (msm_nand_phys + (off)) + +#define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000) +#define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004)Could you please make the macros to take the "struct
msm_nand_chip*chip" argument instead, and store the pase address there. Do not hide the fact that those macros are actually functions, not constant - this is error prone.
Quoted 5 lines
Quoted 2 lines
Besides, I'm do not know your HW, but if you have several controllers with various base addresses - your driver won't work.
you are correct, we have multiple controllers, which breaks this logic in future.
So then make your macros to accept the base address as an argument instead please.
Signature · 2 lines
Best Regards, Artem Bityutskiy (???????? ?????)
Re: [PATCH 2/2] mtd: msm_nand: Add initial msm nand driver support.
Quoted 10 lines · Artem Bityutskiy
Quoted 10 lines
Quoted 10 lines
drivers/mtd/devices/msm_nand.h new file +4
-0+#define MSM_NAND_REG (off) (msm_nand_phys + (off)) + +#define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000) +#define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004)Could you please make the macros to take the "struct
msm_nand_chip*chip" argument instead, and store the pase address there. Do not hide the fact that those macros are actually functions, not constant - this is error prone.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Besides, I'm do not know your HW, but if you have several controllers with various base addresses - your driver won't work.
you are correct, we have multiple controllers, which breaks this logic in future.
So then make your macros to accept the base address as an argument instead please.
Or better make macros to be constants, and always use something like base + MSM_NAND_FLASH_CMD - this is the standard approach.
Signature · 2 lines
Best Regards, Artem Bityutskiy (???????? ?????)
Re: [PATCH 2/2] mtd: msm_nand: Add initial msm nand driver support.
In reply to Artem BityutskiyQuoted 22 lines · Artem Bityutskiy
Quoted 21 lines · Murali Nalajala
Quoted 20 lines · Artem Bityutskiy
Quoted 6 lines · Murali Nalajala
(quoted diff) +6
-0+#define pr_fmt(fmt) "%s:" fmt, __func__ + +#include<linux/kernel.h> +#include<linux/mtd/mtd.h> +#include<linux/mtd/nand.h> +#include<linux/mtd/partitions.h>Review
Quoted 10 lines
(quoted diff) +10
-0+#include<linux/platform_device.h> +#include<linux/sched.h> +#include<linux/slab.h> +#include<linux/dma-mapping.h> +#include<asm/mach/flash.h> +#include<mach/dma.h> + +#include "msm_nand.h" + +unsigned long msm_nand_phys;No global variables like this please. Here is how you use them:
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+extern unsigned long
msm_nand_phys;extern declaration in the 'C' file causing warning. We are in plan to upload the OneNAND changes soon which makes use of the same .h file.
So you say that OneNAND (an independent driver) is going to use this variable? Are you also going to export it?
I haven't decided yet when oneNAND driver come in still it is under discussion. There is a chance that if OneNAND comes as an individual driver then i have to export this variable.
Can i export this variable now? What is your suggestion?
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/mtd/devices/msm_nand.h new file +4
-0+#define MSM_NAND_REG (off) (msm_nand_phys + (off)) + +#define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000) +#define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004)Could you please make the macros to take the "struct
msm_nand_chip*chip" argument instead, and store the pase address there. Do not hide the fact that those macros are actually functions, not constant - this is error prone.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Besides, I'm do not know your HW, but if you have several controllers with various base addresses - your driver won't work.
you are correct, we have multiple controllers, which breaks this logic in future.
So then make your macros to accept the base address as an argument instead please.
Thanks,
Murali N
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/2] mtd: msm_nand: Add initial msm nand driver support.
In reply to Artem BityutskiyQuoted 17 lines · Artem Bityutskiy
Quoted 16 lines · Artem Bityutskiy
Quoted 15 lines
Quoted 5 lines
drivers/mtd/devices/msm_nand.h new file +4
-0+#define MSM_NAND_REG (off) (msm_nand_phys + (off)) + +#define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000) +#define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004)Quoted 7 lines
Could you please make the macros to take the "struct
msm_nand_chip*chip" argument instead, and store the pase address there. Do not hide the fact that those macros are actually functions, not constant - this is error prone.Besides, I'm do not know your HW, but if you have several controllers with various base addresses - your driver won't work.
you are correct, we have multiple controllers, which breaks this logic in future.
Quoted 5 lines
Quoted 2 lines
So then make your macros to accept the base address as an argument instead please.
Or better make macros to be constants, and always use something like base +
MSM_NAND_FLASH_CMD- this is the standard approach.
Here all the registers expands to 'base + register offset'. In the code we are directly using the macro names (these are register names on my controller) i.e. MSM_NAND_FLASH_CMD & MSM_NAND_ADDR0 without thinking of what the controller base is and what controller it is.
Currently, this code we have targeted for the single NAND controller solution for some of the MSM's. There are other targets which uses multiple NAND controllers which we haven't done much work yet to submit those patches.
Thanks,
Murali N
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/2] mtd: msm_nand: Add initial msm nand driver support.
In reply to Murali NalajalaQuoted 1 line
Can i export this variable now?
I do not think so, we do not export random variables.
Quoted 1 line
What is your suggestion?
But I already did provide you suggestions - kill this global variable completely. I provided the reasons:
1. It is error prone to hide functions behind something which looks like a constant.
2. Multiple controllers with different base addresses wouldn't work - your driver has to be able to at least theoretically handle multiple controllers with different bases.
Signature · 2 lines
Best Regards, Artem Bityutskiy (???????? ?????)