linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd : add init_size hook for NAND driver
@ 2010-09-24 11:34 Huang Shijie
  2010-09-26 12:05 ` Artem Bityutskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Huang Shijie @ 2010-09-24 11:34 UTC (permalink / raw)
  To: David.Woodhouse; +Cc: linux-mtd, linux-kernel, akpm, Huang Shijie

Not all the NAND devices have all the information in additional
id bytes.

So add a hook in the nand_chip{} is a good method to calculate the
right value of oobsize, erasesize and so on.

Without the hook,you will get the wrong value, and you have to hack
in the ->scan_bbt() to change the wrong value which make the code
mess.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
 drivers/mtd/nand/nand_base.c |    6 ++++--
 include/linux/mtd/nand.h     |    5 +++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d551ddd..0288f1f 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2848,8 +2848,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 
 	chip->chipsize = (uint64_t)type->chipsize << 20;
 
-	/* Newer devices have all the information in additional id bytes */
-	if (!type->pagesize) {
+	if (!type->pagesize && chip->init_size) {
+		/* set the pagesize, oobsize, erasesize by the driver*/
+		busw = chip->init_size(mtd, chip);
+	} else if (!type->pagesize) {
 		int extid;
 		/* The 3rd id byte holds MLC / multichip data */
 		chip->cellinfo = id_data[2];
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 102e12c..2296a7a 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -332,6 +332,9 @@ struct nand_buffers {
  * @block_markbad:	[REPLACEABLE] mark the block bad
  * @cmd_ctrl:		[BOARDSPECIFIC] hardwarespecific funtion for controlling
  *			ALE/CLE/nCE. Also used to write command and address
+ * @init_size:		[BOARDSPECIFIC] hardwarespecific funtion for setting
+ *			mtd->oobsize, mtd->writesize and so on.
+ *			Return with the bus width.
  * @dev_ready:		[BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line
  *			If set to NULL no access to ready/busy is available and the ready/busy information
  *			is read from the chip status register
@@ -386,6 +389,8 @@ struct nand_chip {
 	int		(*block_markbad)(struct mtd_info *mtd, loff_t ofs);
 	void		(*cmd_ctrl)(struct mtd_info *mtd, int dat,
 				    unsigned int ctrl);
+	int		(*init_size)(struct mtd_info *mtd,
+					struct nand_chip *this);
 	int		(*dev_ready)(struct mtd_info *mtd);
 	void		(*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
 	int		(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd : add init_size hook for NAND driver
  2010-09-24 11:34 [PATCH] mtd : add init_size hook for NAND driver Huang Shijie
@ 2010-09-26 12:05 ` Artem Bityutskiy
  2010-09-27  3:06   ` Huang Shijie
  0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2010-09-26 12:05 UTC (permalink / raw)
  To: Huang Shijie; +Cc: David.Woodhouse, linux-mtd, linux-kernel, akpm

On Fri, 2010-09-24 at 19:34 +0800, Huang Shijie wrote:
> Not all the NAND devices have all the information in additional
> id bytes.
> 
> So add a hook in the nand_chip{} is a good method to calculate the
> right value of oobsize, erasesize and so on.
> 
> Without the hook,you will get the wrong value, and you have to hack
> in the ->scan_bbt() to change the wrong value which make the code
> mess.
> 
> Signed-off-by: Huang Shijie <shijie8@gmail.com>
> ---
>  drivers/mtd/nand/nand_base.c |    6 ++++--
>  include/linux/mtd/nand.h     |    5 +++++
>  2 files changed, 9 insertions(+), 2 deletions(-)

Taken to l2-mtd-2.6.git, thanks.

-- 
Best Regards,
Artem Bityutskiy (Битюцкий Артём)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd : add init_size hook for NAND driver
  2010-09-26 12:05 ` Artem Bityutskiy
@ 2010-09-27  3:06   ` Huang Shijie
  2010-09-28  6:29     ` Artem Bityutskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Huang Shijie @ 2010-09-27  3:06 UTC (permalink / raw)
  To: dedekind1; +Cc: David.Woodhouse, linux-mtd, linux-kernel, akpm

[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]

Hi Artem:
    I think the new patch is better.

The new patch will reuse the id_data.
Even if the additional id byte does not have all the information in
some case, but other infomation such as manufacture id and device id
are also useful to the NAND driver.

Best regards
Huang Shijie


2010/9/26 Artem Bityutskiy <dedekind1@gmail.com>:
> On Fri, 2010-09-24 at 19:34 +0800, Huang Shijie wrote:
>> Not all the NAND devices have all the information in additional
>> id bytes.
>>
>> So add a hook in the nand_chip{} is a good method to calculate the
>> right value of oobsize, erasesize and so on.
>>
>> Without the hook,you will get the wrong value, and you have to hack
>> in the ->scan_bbt() to change the wrong value which make the code
>> mess.
>>
>> Signed-off-by: Huang Shijie <shijie8@gmail.com>
>> ---
>>  drivers/mtd/nand/nand_base.c |    6 ++++--
>>  include/linux/mtd/nand.h     |    5 +++++
>>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> Taken to l2-mtd-2.6.git, thanks.
>
> --
> Best Regards,
> Artem Bityutskiy (Битюцкий Артём)
>
>

[-- Attachment #2: 0001-mtd-add-init_size-hook-for-NAND-driver.patch --]
[-- Type: application/octet-stream, Size: 2723 bytes --]

From b11a9b99f7775da32a3f4c71a281fac661af6ad4 Mon Sep 17 00:00:00 2001
From: Huang Shijie <shijie8@gmail.com>
Date: Mon, 27 Sep 2010 10:43:53 +0800
Subject: [PATCH] mtd : add init_size hook for NAND driver

Not all the NAND devices have all the information in additional
id bytes.

So add a hook in the nand_chip{} is a good method to calculate the
right value of oobsize, erasesize and so on.

Without the hook,you will get the wrong value, and you have to hack
in the ->scan_bbt() to change the wrong value which make the code
mess.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
 drivers/mtd/nand/nand_base.c |    6 ++++--
 include/linux/mtd/nand.h     |    6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d551ddd..bf31e2c 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2848,8 +2848,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 
 	chip->chipsize = (uint64_t)type->chipsize << 20;
 
-	/* Newer devices have all the information in additional id bytes */
-	if (!type->pagesize) {
+	if (!type->pagesize && chip->init_size) {
+		/* set the pagesize, oobsize, erasesize by the driver*/
+		busw = chip->init_size(mtd, chip, id_data);
+	} else if (!type->pagesize) {
 		int extid;
 		/* The 3rd id byte holds MLC / multichip data */
 		chip->cellinfo = id_data[2];
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 102e12c..1b39edd 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -332,6 +332,10 @@ struct nand_buffers {
  * @block_markbad:	[REPLACEABLE] mark the block bad
  * @cmd_ctrl:		[BOARDSPECIFIC] hardwarespecific funtion for controlling
  *			ALE/CLE/nCE. Also used to write command and address
+ * @init_size:		[BOARDSPECIFIC] hardwarespecific funtion for setting
+ *			mtd->oobsize, mtd->writesize and so on.
+ *			@id_data contains the 8 bytes values of NAND_CMD_READID.
+ *			Return with the bus width.
  * @dev_ready:		[BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line
  *			If set to NULL no access to ready/busy is available and the ready/busy information
  *			is read from the chip status register
@@ -386,6 +390,8 @@ struct nand_chip {
 	int		(*block_markbad)(struct mtd_info *mtd, loff_t ofs);
 	void		(*cmd_ctrl)(struct mtd_info *mtd, int dat,
 				    unsigned int ctrl);
+	int		(*init_size)(struct mtd_info *mtd,
+					struct nand_chip *this, u8 *id_data);
 	int		(*dev_ready)(struct mtd_info *mtd);
 	void		(*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
 	int		(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd : add init_size hook for NAND driver
  2010-09-27  3:06   ` Huang Shijie
@ 2010-09-28  6:29     ` Artem Bityutskiy
  0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2010-09-28  6:29 UTC (permalink / raw)
  To: Huang Shijie; +Cc: David.Woodhouse, linux-mtd, linux-kernel, akpm

On Mon, 2010-09-27 at 11:06 +0800, Huang Shijie wrote:
> Hi Artem:
>     I think the new patch is better.
> 
> The new patch will reuse the id_data.
> Even if the additional id byte does not have all the information in
> some case, but other infomation such as manufacture id and device id
> are also useful to the NAND driver.

OK, pushed this one to l2-mtd-2.6.git, thanks.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-28  6:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-24 11:34 [PATCH] mtd : add init_size hook for NAND driver Huang Shijie
2010-09-26 12:05 ` Artem Bityutskiy
2010-09-27  3:06   ` Huang Shijie
2010-09-28  6:29     ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).