linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: denali: max_banks calculation changed in revision 5.1
@ 2015-07-21 14:39 Graham Moore
  2015-09-29 15:01 ` Graham Moore
  0 siblings, 1 reply; 4+ messages in thread
From: Graham Moore @ 2015-07-21 14:39 UTC (permalink / raw)
  To: linux-mtd
  Cc: David Woodhouse, Brian Norris, linux-kernel, Alan Tull,
	Dinh Nguyen, Yves Vandervennet, Graham Moore

Read Denali hardware revision number and use it to
calculate max_banks,  The encoding of max_banks changed
in Denali revision 5.1.

Signed-off-by: Graham Moore <grmoore@opensource.altera.com>
---
 drivers/mtd/nand/denali.c |   11 ++++++++++-
 drivers/mtd/nand/denali.h |    2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index 870c7fc..a98b41e 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -458,8 +458,17 @@ static void find_valid_banks(struct denali_nand_info *denali)
 static void detect_max_banks(struct denali_nand_info *denali)
 {
 	uint32_t features = ioread32(denali->flash_reg + FEATURES);
+	/*
+	 * Read the revision register, so we can calculate the max_banks
+	 * properly: the encoding changed from rev 5.0 to 5.1
+	 */
+	u32 revision = MAKE_COMPARABLE_REVISION(
+				ioread32(denali->flash_reg + REVISION));
 
-	denali->max_banks = 2 << (features & FEATURES__N_BANKS);
+	if (revision < REVISION_5_1)
+		denali->max_banks = 2 << (features & FEATURES__N_BANKS);
+	else
+		denali->max_banks = 1 << (features & FEATURES__N_BANKS);
 }
 
 static void detect_partition_feature(struct denali_nand_info *denali)
diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h
index 145bf88..4bf13bb 100644
--- a/drivers/mtd/nand/denali.h
+++ b/drivers/mtd/nand/denali.h
@@ -178,6 +178,8 @@
 
 #define REVISION				0x370
 #define     REVISION__VALUE				0xffff
+#define MAKE_COMPARABLE_REVISION(x)		swab16(x & REVISION__VALUE)
+#define REVISION_5_1				0x00000501
 
 #define ONFI_DEVICE_FEATURES			0x380
 #define     ONFI_DEVICE_FEATURES__VALUE			0x003f
-- 
1.7.9.5

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

* Re: [PATCH] mtd: nand: denali: max_banks calculation changed in revision 5.1
  2015-07-21 14:39 [PATCH] mtd: nand: denali: max_banks calculation changed in revision 5.1 Graham Moore
@ 2015-09-29 15:01 ` Graham Moore
  2015-09-29 18:31   ` Brian Norris
  0 siblings, 1 reply; 4+ messages in thread
From: Graham Moore @ 2015-09-29 15:01 UTC (permalink / raw)
  To: Graham Moore
  Cc: linux-mtd, David Woodhouse, Brian Norris, linux-kernel, Alan Tull,
	Dinh Nguyen, Yves Vandervennet

Howdy folks,

Any comment on this patch?  Is anyone else using Denali NAND rev 5.1 
controller?

Thanks,
Graham

On 07/21/2015 09:39 AM, Graham Moore wrote:
> Read Denali hardware revision number and use it to
> calculate max_banks,  The encoding of max_banks changed
> in Denali revision 5.1.
>
> Signed-off-by: Graham Moore <grmoore@opensource.altera.com>
> ---
>   drivers/mtd/nand/denali.c |   11 ++++++++++-
>   drivers/mtd/nand/denali.h |    2 ++
>   2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> index 870c7fc..a98b41e 100644
> --- a/drivers/mtd/nand/denali.c
> +++ b/drivers/mtd/nand/denali.c
> @@ -458,8 +458,17 @@ static void find_valid_banks(struct denali_nand_info *denali)
>   static void detect_max_banks(struct denali_nand_info *denali)
>   {
>   	uint32_t features = ioread32(denali->flash_reg + FEATURES);
> +	/*
> +	 * Read the revision register, so we can calculate the max_banks
> +	 * properly: the encoding changed from rev 5.0 to 5.1
> +	 */
> +	u32 revision = MAKE_COMPARABLE_REVISION(
> +				ioread32(denali->flash_reg + REVISION));
>
> -	denali->max_banks = 2 << (features & FEATURES__N_BANKS);
> +	if (revision < REVISION_5_1)
> +		denali->max_banks = 2 << (features & FEATURES__N_BANKS);
> +	else
> +		denali->max_banks = 1 << (features & FEATURES__N_BANKS);
>   }
>
>   static void detect_partition_feature(struct denali_nand_info *denali)
> diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h
> index 145bf88..4bf13bb 100644
> --- a/drivers/mtd/nand/denali.h
> +++ b/drivers/mtd/nand/denali.h
> @@ -178,6 +178,8 @@
>
>   #define REVISION				0x370
>   #define     REVISION__VALUE				0xffff
> +#define MAKE_COMPARABLE_REVISION(x)		swab16(x & REVISION__VALUE)
> +#define REVISION_5_1				0x00000501
>
>   #define ONFI_DEVICE_FEATURES			0x380
>   #define     ONFI_DEVICE_FEATURES__VALUE			0x003f
>

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

* Re: [PATCH] mtd: nand: denali: max_banks calculation changed in revision 5.1
  2015-09-29 15:01 ` Graham Moore
@ 2015-09-29 18:31   ` Brian Norris
  2015-09-29 19:56     ` Brian Norris
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2015-09-29 18:31 UTC (permalink / raw)
  To: Graham Moore
  Cc: linux-mtd, David Woodhouse, linux-kernel, Alan Tull, Dinh Nguyen,
	Yves Vandervennet, Enrico Jorns

On Tue, Sep 29, 2015 at 10:01:10AM -0500, Graham Moore wrote:
> Howdy folks,
> 
> Any comment on this patch?

A tiny comment below.

> Is anyone else using Denali NAND rev 5.1
> controller?

I have no devices to test, but CC'ing Enrico, who sent a denali patch
recently.

In general, MTD has a lot of drivers for various hardware, and I have
few of them to test. If anyone is interested in getting CC's (so they
can test, review, and otherwise help expedite the process), I'd be happy
to ack an addition to MAINTAINERS, perhaps as 'R:' (reviewer)...

> Thanks,
> Graham
> 
> On 07/21/2015 09:39 AM, Graham Moore wrote:
> >Read Denali hardware revision number and use it to
> >calculate max_banks,  The encoding of max_banks changed
> >in Denali revision 5.1.
> >
> >Signed-off-by: Graham Moore <grmoore@opensource.altera.com>
> >---
> >  drivers/mtd/nand/denali.c |   11 ++++++++++-
> >  drivers/mtd/nand/denali.h |    2 ++
> >  2 files changed, 12 insertions(+), 1 deletion(-)
> >
> >diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> >index 870c7fc..a98b41e 100644
> >--- a/drivers/mtd/nand/denali.c
> >+++ b/drivers/mtd/nand/denali.c
> >@@ -458,8 +458,17 @@ static void find_valid_banks(struct denali_nand_info *denali)
> >  static void detect_max_banks(struct denali_nand_info *denali)
> >  {
> >  	uint32_t features = ioread32(denali->flash_reg + FEATURES);
> >+	/*
> >+	 * Read the revision register, so we can calculate the max_banks
> >+	 * properly: the encoding changed from rev 5.0 to 5.1
> >+	 */
> >+	u32 revision = MAKE_COMPARABLE_REVISION(
> >+				ioread32(denali->flash_reg + REVISION));
> >
> >-	denali->max_banks = 2 << (features & FEATURES__N_BANKS);
> >+	if (revision < REVISION_5_1)
> >+		denali->max_banks = 2 << (features & FEATURES__N_BANKS);
> >+	else
> >+		denali->max_banks = 1 << (features & FEATURES__N_BANKS);
> >  }
> >
> >  static void detect_partition_feature(struct denali_nand_info *denali)
> >diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h
> >index 145bf88..4bf13bb 100644
> >--- a/drivers/mtd/nand/denali.h
> >+++ b/drivers/mtd/nand/denali.h
> >@@ -178,6 +178,8 @@
> >
> >  #define REVISION				0x370
> >  #define     REVISION__VALUE				0xffff
> >+#define MAKE_COMPARABLE_REVISION(x)		swab16(x & REVISION__VALUE)

It's probably best to add parentheses around the 'x'.

> >+#define REVISION_5_1				0x00000501
> >
> >  #define ONFI_DEVICE_FEATURES			0x380
> >  #define     ONFI_DEVICE_FEATURES__VALUE			0x003f
> >
> 

I can fix that up and apply, if no objections.

Brian

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

* Re: [PATCH] mtd: nand: denali: max_banks calculation changed in revision 5.1
  2015-09-29 18:31   ` Brian Norris
@ 2015-09-29 19:56     ` Brian Norris
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2015-09-29 19:56 UTC (permalink / raw)
  To: Graham Moore
  Cc: linux-mtd, David Woodhouse, linux-kernel, Alan Tull, Dinh Nguyen,
	Yves Vandervennet, Enrico Jorns

On Tue, Sep 29, 2015 at 11:31:21AM -0700, Brian Norris wrote:
> On Tue, Sep 29, 2015 at 10:01:10AM -0500, Graham Moore wrote:
> > On 07/21/2015 09:39 AM, Graham Moore wrote:
> > >diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> > >index 870c7fc..a98b41e 100644
> > >--- a/drivers/mtd/nand/denali.h
> > >+++ b/drivers/mtd/nand/denali.h
> > >@@ -178,6 +178,8 @@
> > >
> > >  #define REVISION				0x370
> > >  #define     REVISION__VALUE				0xffff
> > >+#define MAKE_COMPARABLE_REVISION(x)		swab16(x & REVISION__VALUE)
> 
> It's probably best to add parentheses around the 'x'.
> 
> > >+#define REVISION_5_1				0x00000501
> > >
> > >  #define ONFI_DEVICE_FEATURES			0x380
> > >  #define     ONFI_DEVICE_FEATURES__VALUE			0x003f
> > >
> > 
> 
> I can fix that up and apply, if no objections.

Pushed to l2-mtd.git with that fixup.

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

end of thread, other threads:[~2015-09-29 19:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-21 14:39 [PATCH] mtd: nand: denali: max_banks calculation changed in revision 5.1 Graham Moore
2015-09-29 15:01 ` Graham Moore
2015-09-29 18:31   ` Brian Norris
2015-09-29 19:56     ` Brian Norris

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).