* [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
@ 2008-08-08 2:06 Hong Xu
2008-08-08 2:41 ` Jerry Van Baren
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Hong Xu @ 2008-08-08 2:06 UTC (permalink / raw)
To: u-boot
Sometimes, board module needs to know some information about the NAND
chip e.g. page size to continue it's initialization. This short patch
give board module a chance to continue its initialization after the
NAND chip is scaned.
best regards,
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index e44470e..f795d2e 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -41,6 +41,10 @@ static const char default_nand_name[] = "nand";
extern int board_nand_init(struct nand_chip *nand);
+int __board_nand_init_tail(struct nand_chip *nand) { return 0; }
+int inline board_nand_init_tail (struct nand_chip *) __attribute__
+ ((weak, alias("__board_nand_init_tail")));
+
static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
ulong base_addr)
{
@@ -48,7 +52,7 @@ static void nand_init_chip(struct mtd_info *mtd,
struct nand_chip *nand,
nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;
if (board_nand_init(nand) == 0) {
- if (nand_scan(mtd, 1) == 0) {
+ if ((nand_scan(mtd, 1) == 0) && (board_nand_init_tail(nand) == 0)) {
if (!mtd->name)
mtd->name = (char *)default_nand_name;
} else
^ permalink raw reply related [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
2008-08-08 2:06 [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned Hong Xu
@ 2008-08-08 2:41 ` Jerry Van Baren
2008-08-08 9:27 ` Wolfgang Denk
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jerry Van Baren @ 2008-08-08 2:41 UTC (permalink / raw)
To: u-boot
Hong Xu wrote:
> Sometimes, board module needs to know some information about the NAND
> chip e.g. page size to continue it's initialization. This short patch
> give board module a chance to continue its initialization after the
> NAND chip is scaned.
>
> best regards,
>
> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
> index e44470e..f795d2e 100644
* You need a "Signed-off-by" line
* Typo s/scaned/scanned/ (both in the subject and the comment)
* The "best regards," line should be deleted from the comment.
Thanks,
gvb
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
2008-08-08 2:06 [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned Hong Xu
2008-08-08 2:41 ` Jerry Van Baren
@ 2008-08-08 9:27 ` Wolfgang Denk
2008-08-08 11:39 ` Haavard Skinnemoen
2008-08-08 14:49 ` Scott Wood
3 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Denk @ 2008-08-08 9:27 UTC (permalink / raw)
To: u-boot
In message <1516faed0808071906g118e3bf1ted560f41ad4dec12@mail.gmail.com> you wrote:
>
> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
> index e44470e..f795d2e 100644
> --- a/drivers/mtd/nand/nand.c
> +++ b/drivers/mtd/nand/nand.c
> @@ -41,6 +41,10 @@ static const char default_nand_name[] = "nand";
>
> extern int board_nand_init(struct nand_chip *nand);
>
> +int __board_nand_init_tail(struct nand_chip *nand) { return 0; }
> +int inline board_nand_init_tail (struct nand_chip *) __attribute__
> + ((weak, alias("__board_nand_init_tail")));
> +
I don't like the "_tail" name. Maybe board_nand_init2() or so would be
better?
> static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
> ulong base_addr)
> {
> @@ -48,7 +52,7 @@ static void nand_init_chip(struct mtd_info *mtd,
> struct nand_chip *nand,
>
> nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;
> if (board_nand_init(nand) == 0) {
> - if (nand_scan(mtd, 1) == 0) {
> + if ((nand_scan(mtd, 1) == 0) && (board_nand_init_tail(nand) == 0)) {
> if (!mtd->name)
> mtd->name = (char *)default_nand_name;
> } else
The logic is becoming pretty intricate. Maybe you can rewrite this to
be more readable?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The rule on staying alive as a program manager is to give 'em a num-
ber or give 'em a date, but never give 'em both at once.
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
2008-08-08 2:06 [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned Hong Xu
2008-08-08 2:41 ` Jerry Van Baren
2008-08-08 9:27 ` Wolfgang Denk
@ 2008-08-08 11:39 ` Haavard Skinnemoen
2008-08-08 14:49 ` Scott Wood
3 siblings, 0 replies; 5+ messages in thread
From: Haavard Skinnemoen @ 2008-08-08 11:39 UTC (permalink / raw)
To: u-boot
"Hong Xu" <hongxu.cn@gmail.com> wrote:
> +int __board_nand_init_tail(struct nand_chip *nand) { return 0; }
> +int inline board_nand_init_tail (struct nand_chip *) __attribute__
> + ((weak, alias("__board_nand_init_tail")));
A globally visible inline weak alias. How does that work?
Haavard
^ permalink raw reply [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned.
2008-08-08 2:06 [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned Hong Xu
` (2 preceding siblings ...)
2008-08-08 11:39 ` Haavard Skinnemoen
@ 2008-08-08 14:49 ` Scott Wood
3 siblings, 0 replies; 5+ messages in thread
From: Scott Wood @ 2008-08-08 14:49 UTC (permalink / raw)
To: u-boot
On Fri, Aug 08, 2008 at 10:06:03AM +0800, Hong Xu wrote:
> Sometimes, board module needs to know some information about the NAND
> chip e.g. page size to continue it's initialization. This short patch
> give board module a chance to continue its initialization after the
> NAND chip is scaned.
[snip]
> nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;
> if (board_nand_init(nand) == 0) {
> - if (nand_scan(mtd, 1) == 0) {
> + if ((nand_scan(mtd, 1) == 0) && (board_nand_init_tail(nand) == 0)) {
> if (!mtd->name)
> mtd->name = (char *)default_nand_name;
> } else
This doesn't give the board driver a chance to run before the bad block
scan, though. The MTD code itself does (nand_scan_ident and nand_scan_tail,
around which nand_scan is a wrapper), but the u-boot glue code doesn't
currently let board drivers take advantage of that.
I'd like to transition away from having a centralized nand_init(), and
instead have the board drivers call nand_scan*() themselves.
-Scott
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-08-08 14:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-08 2:06 [U-Boot] [PATCH] [NAND] Add board_nand_init_tail to give board module a chance to init after NAND chip is scaned Hong Xu
2008-08-08 2:41 ` Jerry Van Baren
2008-08-08 9:27 ` Wolfgang Denk
2008-08-08 11:39 ` Haavard Skinnemoen
2008-08-08 14:49 ` Scott Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox