Linux-Media Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/3] nand: brcmnand: rename v4 registers
@ 2020-05-10 15:14 Álvaro Fernández Rojas
  2020-05-10 15:14 ` [PATCH 2/3] nand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
                   ` (4 more replies)
  0 siblings, 5 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-10 15:14 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

These registers are also used on v3.3.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index e4e3ceeac38f..6a08dd07b058 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -338,8 +338,8 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
-/* BRCMNAND v4.0 */
-static const u16 brcmnand_regs_v40[] = {
+/* BRCMNAND v3.3-v4.0 */
+static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
 	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
 	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
@@ -591,8 +591,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v60;
 	else if (ctrl->nand_version >= 0x0500)
 		ctrl->reg_offsets = brcmnand_regs_v50;
-	else if (ctrl->nand_version >= 0x0400)
-		ctrl->reg_offsets = brcmnand_regs_v40;
+	else if (ctrl->nand_version >= 0x0303)
+		ctrl->reg_offsets = brcmnand_regs_v33;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
-- 
2.26.2


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

* [PATCH 2/3] nand: brcmnand: fix CS0 layout
  2020-05-10 15:14 [PATCH 1/3] nand: brcmnand: rename v4 registers Álvaro Fernández Rojas
@ 2020-05-10 15:14 ` Álvaro Fernández Rojas
  2020-05-11 17:01   ` Miquel Raynal
  2020-05-10 15:14 ` [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-10 15:14 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Only v3.3-v5.0 have a different CS0 layout.
v3.3- controllers use the same layout for every CS.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 6a08dd07b058..72b268d8e3a4 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -606,8 +606,9 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 	} else {
 		ctrl->cs_offsets = brcmnand_cs_offsets;
 
-		/* v5.0 and earlier has a different CS0 offset layout */
-		if (ctrl->nand_version <= 0x0500)
+		/* v3.3-5.0 have a different CS0 offset layout */
+		if (ctrl->nand_version >= 0x0303 &&
+		    ctrl->nand_version <= 0x0500)
 			ctrl->cs0_offsets = brcmnand_cs_offsets_cs0;
 	}
 
-- 
2.26.2


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

* [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers
  2020-05-10 15:14 [PATCH 1/3] nand: brcmnand: rename v4 registers Álvaro Fernández Rojas
  2020-05-10 15:14 ` [PATCH 2/3] nand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
@ 2020-05-10 15:14 ` Álvaro Fernández Rojas
  2020-05-10 15:39   ` Florian Fainelli
  2020-05-11 17:44   ` Miquel Raynal
  2020-05-11 17:03 ` [PATCH 1/3] nand: brcmnand: rename v4 registers Miquel Raynal
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-10 15:14 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Tested on Netgear DGND3700v2 (BCM6362 with v2.2 controller).

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 76 +++++++++++++++++++++---
 1 file changed, 67 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 72b268d8e3a4..718c601d0e59 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -338,6 +338,36 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
+/* BRCMNAND v2.1-v2.2 */
+static const u16 brcmnand_regs_v21[] = {
+	[BRCMNAND_CMD_START]		=  0x04,
+	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
+	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
+	[BRCMNAND_INTFC_STATUS]		=  0x5c,
+	[BRCMNAND_CS_SELECT]		=  0x14,
+	[BRCMNAND_CS_XOR]		=  0x18,
+	[BRCMNAND_LL_OP]		=     0,
+	[BRCMNAND_CS0_BASE]		=  0x40,
+	[BRCMNAND_CS1_BASE]		=     0,
+	[BRCMNAND_CORR_THRESHOLD]	=     0,
+	[BRCMNAND_CORR_THRESHOLD_EXT]	=     0,
+	[BRCMNAND_UNCORR_COUNT]		=     0,
+	[BRCMNAND_CORR_COUNT]		=     0,
+	[BRCMNAND_CORR_EXT_ADDR]	=  0x60,
+	[BRCMNAND_CORR_ADDR]		=  0x64,
+	[BRCMNAND_UNCORR_EXT_ADDR]	=  0x68,
+	[BRCMNAND_UNCORR_ADDR]		=  0x6c,
+	[BRCMNAND_SEMAPHORE]		=  0x50,
+	[BRCMNAND_ID]			=  0x54,
+	[BRCMNAND_ID_EXT]		=     0,
+	[BRCMNAND_LL_RDATA]		=     0,
+	[BRCMNAND_OOB_READ_BASE]	=  0x20,
+	[BRCMNAND_OOB_READ_10_BASE]	=     0,
+	[BRCMNAND_OOB_WRITE_BASE]	=  0x30,
+	[BRCMNAND_OOB_WRITE_10_BASE]	=     0,
+	[BRCMNAND_FC_BASE]		= 0x200,
+};
+
 /* BRCMNAND v3.3-v4.0 */
 static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
@@ -571,12 +601,16 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 {
 	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
 	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
-	static const unsigned int page_sizes[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int block_sizes_v2_2[] = { 16, 128, 8, 512, 256, 0 };
+	static const unsigned int block_sizes[] = { 16, 128, 8, 512, 0 };
+	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int page_sizes_v2_2[] = { 512, 2048, 4096, 0 };
+	static const unsigned int page_sizes[] = { 512, 2048, 0 };
 
 	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
 
-	/* Only support v4.0+? */
-	if (ctrl->nand_version < 0x0400) {
+	/* Only support v2.1+ */
+	if (ctrl->nand_version < 0x0201) {
 		dev_err(ctrl->dev, "version %#x not supported\n",
 			ctrl->nand_version);
 		return -ENODEV;
@@ -593,6 +627,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v50;
 	else if (ctrl->nand_version >= 0x0303)
 		ctrl->reg_offsets = brcmnand_regs_v33;
+	else if (ctrl->nand_version >= 0x0201)
+		ctrl->reg_offsets = brcmnand_regs_v21;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
@@ -618,14 +654,27 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->max_page_size = 16 * 1024;
 		ctrl->max_block_size = 2 * 1024 * 1024;
 	} else {
-		ctrl->page_sizes = page_sizes;
+		if (ctrl->nand_version >= 0x0304)
+			ctrl->page_sizes = page_sizes_v3_4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->page_sizes = page_sizes_v2_2;
+		else
+			ctrl->page_sizes = page_sizes;
+
 		if (ctrl->nand_version >= 0x0600)
 			ctrl->block_sizes = block_sizes_v6;
-		else
+		else if (ctrl->nand_version >= 0x0400)
 			ctrl->block_sizes = block_sizes_v4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->block_sizes = block_sizes_v2_2;
+		else
+			ctrl->block_sizes = block_sizes;
 
 		if (ctrl->nand_version < 0x0400) {
-			ctrl->max_page_size = 4096;
+			if (ctrl->nand_version < 0x0202)
+				ctrl->max_page_size = 2048;
+			else
+				ctrl->max_page_size = 4096;
 			ctrl->max_block_size = 512 * 1024;
 		}
 	}
@@ -811,6 +860,9 @@ static void brcmnand_wr_corr_thresh(struct brcmnand_host *host, u8 val)
 	enum brcmnand_reg reg = BRCMNAND_CORR_THRESHOLD;
 	int cs = host->cs;
 
+	if (!ctrl->reg_offsets[reg])
+		return;
+
 	if (ctrl->nand_version == 0x0702)
 		bits = 7;
 	else if (ctrl->nand_version >= 0x0600)
@@ -869,8 +921,10 @@ static inline u32 brcmnand_spare_area_mask(struct brcmnand_controller *ctrl)
 		return GENMASK(7, 0);
 	else if (ctrl->nand_version >= 0x0600)
 		return GENMASK(6, 0);
-	else
+	else if (ctrl->nand_version >= 0x0303)
 		return GENMASK(5, 0);
+	else
+		return GENMASK(4, 0);
 }
 
 #define NAND_ACC_CONTROL_ECC_SHIFT	16
@@ -2390,9 +2444,11 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
 
 	tmp = nand_readreg(ctrl, acc_control_offs);
 	tmp &= ~brcmnand_ecc_level_mask(ctrl);
-	tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
 	tmp &= ~brcmnand_spare_area_mask(ctrl);
-	tmp |= cfg->spare_area_size;
+	if (ctrl->nand_version >= 0x0302) {
+		tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
+		tmp |= cfg->spare_area_size;
+	}
 	nand_writereg(ctrl, acc_control_offs, tmp);
 
 	brcmnand_set_sector_size_1k(host, cfg->sector_size_1k);
@@ -2766,6 +2822,8 @@ const struct dev_pm_ops brcmnand_pm_ops = {
 EXPORT_SYMBOL_GPL(brcmnand_pm_ops);
 
 static const struct of_device_id brcmnand_of_match[] = {
+	{ .compatible = "brcm,brcmnand-v2.1" },
+	{ .compatible = "brcm,brcmnand-v2.2" },
 	{ .compatible = "brcm,brcmnand-v4.0" },
 	{ .compatible = "brcm,brcmnand-v5.0" },
 	{ .compatible = "brcm,brcmnand-v6.0" },
-- 
2.26.2


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

* Re: [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers
  2020-05-10 15:14 ` [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
@ 2020-05-10 15:39   ` Florian Fainelli
  2020-05-11 17:44   ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Florian Fainelli @ 2020-05-10 15:39 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig



On 5/10/2020 8:14 AM, Álvaro Fernández Rojas wrote:
> Tested on Netgear DGND3700v2 (BCM6362 with v2.2 controller).
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Can you fix a couple of things for your future submissions:

- for patch count > 1, please provide a cover letter introducing your
patches

- for this specific patch, you are missing a Device Tree binding
document update with the new compatible strings you are adding

Thank you!
-- 
Florian

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

* Re: [PATCH 2/3] nand: brcmnand: fix CS0 layout
  2020-05-10 15:14 ` [PATCH 2/3] nand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
@ 2020-05-11 17:01   ` Miquel Raynal
  0 siblings, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-11 17:01 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: computersforpeace, kdasu.kdev, richard, vigneshr, sumit.semwal,
	linux-mtd, bcm-kernel-feedback-list, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig

Hi Álvaro,

Álvaro Fernández Rojas <noltari@gmail.com> wrote on Sun, 10 May 2020
17:14:05 +0200:

> Only v3.3-v5.0 have a different CS0 layout.
> v3.3- controllers use the same layout for every CS.

I had a hard time what you meant here, just because of the trailing
dash. 

    "Controllers before v3.3..."

would be more understandable.

Also please add a Fixes/Cc: stable tag here.

> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index 6a08dd07b058..72b268d8e3a4 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -606,8 +606,9 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  	} else {
>  		ctrl->cs_offsets = brcmnand_cs_offsets;
>  
> -		/* v5.0 and earlier has a different CS0 offset layout */
> -		if (ctrl->nand_version <= 0x0500)
> +		/* v3.3-5.0 have a different CS0 offset layout */
> +		if (ctrl->nand_version >= 0x0303 &&
> +		    ctrl->nand_version <= 0x0500)
>  			ctrl->cs0_offsets = brcmnand_cs_offsets_cs0;
>  	}
>  


Thanks,
Miquèl

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

* Re: [PATCH 1/3] nand: brcmnand: rename v4 registers
  2020-05-10 15:14 [PATCH 1/3] nand: brcmnand: rename v4 registers Álvaro Fernández Rojas
  2020-05-10 15:14 ` [PATCH 2/3] nand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
  2020-05-10 15:14 ` [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
@ 2020-05-11 17:03 ` Miquel Raynal
  2020-05-11 17:40 ` Miquel Raynal
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  4 siblings, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-11 17:03 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: computersforpeace, kdasu.kdev, richard, vigneshr, sumit.semwal,
	linux-mtd, bcm-kernel-feedback-list, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig

Hi Álvaro,

Álvaro Fernández Rojas <noltari@gmail.com> wrote on Sun, 10 May 2020
17:14:04 +0200:

> These registers are also used on v3.3.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index e4e3ceeac38f..6a08dd07b058 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -338,8 +338,8 @@ enum brcmnand_reg {
>  	BRCMNAND_FC_BASE,
>  };
>  
> -/* BRCMNAND v4.0 */
> -static const u16 brcmnand_regs_v40[] = {
> +/* BRCMNAND v3.3-v4.0 */
> +static const u16 brcmnand_regs_v33[] = {
>  	[BRCMNAND_CMD_START]		=  0x04,
>  	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
>  	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
> @@ -591,8 +591,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  		ctrl->reg_offsets = brcmnand_regs_v60;
>  	else if (ctrl->nand_version >= 0x0500)
>  		ctrl->reg_offsets = brcmnand_regs_v50;
> -	else if (ctrl->nand_version >= 0x0400)
> -		ctrl->reg_offsets = brcmnand_regs_v40;
> +	else if (ctrl->nand_version >= 0x0303)
> +		ctrl->reg_offsets = brcmnand_regs_v33;
>  
>  	/* Chip-select stride */
>  	if (ctrl->nand_version >= 0x0701)

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

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

* Re: [PATCH 1/3] nand: brcmnand: rename v4 registers
  2020-05-10 15:14 [PATCH 1/3] nand: brcmnand: rename v4 registers Álvaro Fernández Rojas
                   ` (2 preceding siblings ...)
  2020-05-11 17:03 ` [PATCH 1/3] nand: brcmnand: rename v4 registers Miquel Raynal
@ 2020-05-11 17:40 ` Miquel Raynal
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  4 siblings, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-11 17:40 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: computersforpeace, kdasu.kdev, richard, vigneshr, sumit.semwal,
	linux-mtd, bcm-kernel-feedback-list, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig

Hi Álvaro,

Álvaro Fernández Rojas <noltari@gmail.com> wrote on Sun, 10 May 2020
17:14:04 +0200:

> These registers are also used on v3.3.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---

BTW, all your titles should start with "mtd: rawnand: brcmnand: "

Thanks,
Miquèl

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

* Re: [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers
  2020-05-10 15:14 ` [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  2020-05-10 15:39   ` Florian Fainelli
@ 2020-05-11 17:44   ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-11 17:44 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: computersforpeace, kdasu.kdev, richard, vigneshr, sumit.semwal,
	linux-mtd, bcm-kernel-feedback-list, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig

Hi Álvaro,

Álvaro Fernández Rojas <noltari@gmail.com> wrote on Sun, 10 May 2020
17:14:06 +0200:

> Tested on Netgear DGND3700v2 (BCM6362 with v2.2 controller).

I'd propose to do this in two steps:

First rename what needs to be rename to be more accurate without adding
anything specific to this version of the IP, then, in another patch,
just add the necessary bits.

> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 76 +++++++++++++++++++++---
>  1 file changed, 67 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index 72b268d8e3a4..718c601d0e59 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -338,6 +338,36 @@ enum brcmnand_reg {
>  	BRCMNAND_FC_BASE,
>  };
>  
> +/* BRCMNAND v2.1-v2.2 */
> +static const u16 brcmnand_regs_v21[] = {
> +	[BRCMNAND_CMD_START]		=  0x04,
> +	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
> +	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
> +	[BRCMNAND_INTFC_STATUS]		=  0x5c,
> +	[BRCMNAND_CS_SELECT]		=  0x14,
> +	[BRCMNAND_CS_XOR]		=  0x18,
> +	[BRCMNAND_LL_OP]		=     0,
> +	[BRCMNAND_CS0_BASE]		=  0x40,
> +	[BRCMNAND_CS1_BASE]		=     0,
> +	[BRCMNAND_CORR_THRESHOLD]	=     0,
> +	[BRCMNAND_CORR_THRESHOLD_EXT]	=     0,
> +	[BRCMNAND_UNCORR_COUNT]		=     0,
> +	[BRCMNAND_CORR_COUNT]		=     0,
> +	[BRCMNAND_CORR_EXT_ADDR]	=  0x60,
> +	[BRCMNAND_CORR_ADDR]		=  0x64,
> +	[BRCMNAND_UNCORR_EXT_ADDR]	=  0x68,
> +	[BRCMNAND_UNCORR_ADDR]		=  0x6c,
> +	[BRCMNAND_SEMAPHORE]		=  0x50,
> +	[BRCMNAND_ID]			=  0x54,
> +	[BRCMNAND_ID_EXT]		=     0,
> +	[BRCMNAND_LL_RDATA]		=     0,
> +	[BRCMNAND_OOB_READ_BASE]	=  0x20,
> +	[BRCMNAND_OOB_READ_10_BASE]	=     0,
> +	[BRCMNAND_OOB_WRITE_BASE]	=  0x30,
> +	[BRCMNAND_OOB_WRITE_10_BASE]	=     0,
> +	[BRCMNAND_FC_BASE]		= 0x200,
> +};
> +
>  /* BRCMNAND v3.3-v4.0 */
>  static const u16 brcmnand_regs_v33[] = {
>  	[BRCMNAND_CMD_START]		=  0x04,
> @@ -571,12 +601,16 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  {
>  	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
>  	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
> -	static const unsigned int page_sizes[] = { 512, 2048, 4096, 8192, 0 };
> +	static const unsigned int block_sizes_v2_2[] = { 16, 128, 8, 512, 256, 0 };
> +	static const unsigned int block_sizes[] = { 16, 128, 8, 512, 0 };
> +	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
> +	static const unsigned int page_sizes_v2_2[] = { 512, 2048, 4096, 0 };
> +	static const unsigned int page_sizes[] = { 512, 2048, 0 };

Can you name a version everywhere?

>  
>  	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
>  
> -	/* Only support v4.0+? */
> -	if (ctrl->nand_version < 0x0400) {
> +	/* Only support v2.1+ */
> +	if (ctrl->nand_version < 0x0201) {
>  		dev_err(ctrl->dev, "version %#x not supported\n",
>  			ctrl->nand_version);
>  		return -ENODEV;
> @@ -593,6 +627,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  		ctrl->reg_offsets = brcmnand_regs_v50;
>  	else if (ctrl->nand_version >= 0x0303)
>  		ctrl->reg_offsets = brcmnand_regs_v33;
> +	else if (ctrl->nand_version >= 0x0201)
> +		ctrl->reg_offsets = brcmnand_regs_v21;
>  
>  	/* Chip-select stride */
>  	if (ctrl->nand_version >= 0x0701)
> @@ -618,14 +654,27 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  		ctrl->max_page_size = 16 * 1024;
>  		ctrl->max_block_size = 2 * 1024 * 1024;
>  	} else {
> -		ctrl->page_sizes = page_sizes;
> +		if (ctrl->nand_version >= 0x0304)
> +			ctrl->page_sizes = page_sizes_v3_4;
> +		else if (ctrl->nand_version >= 0x0202)
> +			ctrl->page_sizes = page_sizes_v2_2;
> +		else
> +			ctrl->page_sizes = page_sizes;
> +
>  		if (ctrl->nand_version >= 0x0600)
>  			ctrl->block_sizes = block_sizes_v6;
> -		else
> +		else if (ctrl->nand_version >= 0x0400)
>  			ctrl->block_sizes = block_sizes_v4;
> +		else if (ctrl->nand_version >= 0x0202)
> +			ctrl->block_sizes = block_sizes_v2_2;
> +		else
> +			ctrl->block_sizes = block_sizes;
>  
>  		if (ctrl->nand_version < 0x0400) {
> -			ctrl->max_page_size = 4096;
> +			if (ctrl->nand_version < 0x0202)
> +				ctrl->max_page_size = 2048;
> +			else
> +				ctrl->max_page_size = 4096;
>  			ctrl->max_block_size = 512 * 1024;
>  		}
>  	}
> @@ -811,6 +860,9 @@ static void brcmnand_wr_corr_thresh(struct brcmnand_host *host, u8 val)
>  	enum brcmnand_reg reg = BRCMNAND_CORR_THRESHOLD;
>  	int cs = host->cs;
>  
> +	if (!ctrl->reg_offsets[reg])
> +		return;
> +
>  	if (ctrl->nand_version == 0x0702)
>  		bits = 7;
>  	else if (ctrl->nand_version >= 0x0600)
> @@ -869,8 +921,10 @@ static inline u32 brcmnand_spare_area_mask(struct brcmnand_controller *ctrl)
>  		return GENMASK(7, 0);
>  	else if (ctrl->nand_version >= 0x0600)
>  		return GENMASK(6, 0);
> -	else
> +	else if (ctrl->nand_version >= 0x0303)
>  		return GENMASK(5, 0);
> +	else
> +		return GENMASK(4, 0);
>  }
>  
>  #define NAND_ACC_CONTROL_ECC_SHIFT	16
> @@ -2390,9 +2444,11 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
>  
>  	tmp = nand_readreg(ctrl, acc_control_offs);
>  	tmp &= ~brcmnand_ecc_level_mask(ctrl);
> -	tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
>  	tmp &= ~brcmnand_spare_area_mask(ctrl);
> -	tmp |= cfg->spare_area_size;
> +	if (ctrl->nand_version >= 0x0302) {
> +		tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
> +		tmp |= cfg->spare_area_size;
> +	}
>  	nand_writereg(ctrl, acc_control_offs, tmp);
>  
>  	brcmnand_set_sector_size_1k(host, cfg->sector_size_1k);
> @@ -2766,6 +2822,8 @@ const struct dev_pm_ops brcmnand_pm_ops = {
>  EXPORT_SYMBOL_GPL(brcmnand_pm_ops);
>  
>  static const struct of_device_id brcmnand_of_match[] = {
> +	{ .compatible = "brcm,brcmnand-v2.1" },
> +	{ .compatible = "brcm,brcmnand-v2.2" },
>  	{ .compatible = "brcm,brcmnand-v4.0" },
>  	{ .compatible = "brcm,brcmnand-v5.0" },
>  	{ .compatible = "brcm,brcmnand-v6.0" },

You should also document these new bindings in a separate patch
(before this one).

Thanks,
Miquèl

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

* [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers
  2020-05-10 15:14 [PATCH 1/3] nand: brcmnand: rename v4 registers Álvaro Fernández Rojas
                   ` (3 preceding siblings ...)
  2020-05-11 17:40 ` Miquel Raynal
@ 2020-05-12  7:33 ` Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
                     ` (5 more replies)
  4 siblings, 6 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-12  7:33 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Add support for v2.1 and v2.2 NAND controllers.

v2: introduce changes suggested by Miquèl.

Álvaro Fernández Rojas (5):
  mtd: rawnand: brcmnand: rename v4 registers
  mtd: rawnand: brcmnand: fix CS0 layout
  mtd: rawnand: brcmnand: rename page sizes
  dt: bindings: brcmnand: add v2.1 and v2.2 support
  nand: brcmnand: support v2.1-v2.2 controllers

 .../devicetree/bindings/mtd/brcm,brcmnand.txt |  2 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c      | 89 +++++++++++++++----
 2 files changed, 76 insertions(+), 15 deletions(-)

-- 
2.26.2


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

* [PATCH v2 1/5] mtd: rawnand: brcmnand: rename v4 registers
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
@ 2020-05-12  7:33   ` Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-12  7:33 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

These registers are also used on v3.3.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 v2: fix commit title.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index e4e3ceeac38f..6a08dd07b058 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -338,8 +338,8 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
-/* BRCMNAND v4.0 */
-static const u16 brcmnand_regs_v40[] = {
+/* BRCMNAND v3.3-v4.0 */
+static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
 	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
 	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
@@ -591,8 +591,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v60;
 	else if (ctrl->nand_version >= 0x0500)
 		ctrl->reg_offsets = brcmnand_regs_v50;
-	else if (ctrl->nand_version >= 0x0400)
-		ctrl->reg_offsets = brcmnand_regs_v40;
+	else if (ctrl->nand_version >= 0x0303)
+		ctrl->reg_offsets = brcmnand_regs_v33;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
-- 
2.26.2


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

* [PATCH v2 2/5] mtd: rawnand: brcmnand: fix CS0 layout
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
@ 2020-05-12  7:33   ` Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-12  7:33 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Only v3.3-v5.0 have a different CS0 layout.
Controllers before v3.3 use the same layout for every CS.

Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: fix commit log.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 6a08dd07b058..72b268d8e3a4 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -606,8 +606,9 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 	} else {
 		ctrl->cs_offsets = brcmnand_cs_offsets;
 
-		/* v5.0 and earlier has a different CS0 offset layout */
-		if (ctrl->nand_version <= 0x0500)
+		/* v3.3-5.0 have a different CS0 offset layout */
+		if (ctrl->nand_version >= 0x0303 &&
+		    ctrl->nand_version <= 0x0500)
 			ctrl->cs0_offsets = brcmnand_cs_offsets_cs0;
 	}
 
-- 
2.26.2


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

* [PATCH v2 3/5] mtd: rawnand: brcmnand: rename page sizes
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
@ 2020-05-12  7:33   ` Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-12  7:33 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Current pages sizes apply to controllers after v3.4

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: add new patch.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 72b268d8e3a4..ef60dbbeac2b 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -571,7 +571,7 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 {
 	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
 	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
-	static const unsigned int page_sizes[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
 
 	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
 
@@ -618,7 +618,7 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->max_page_size = 16 * 1024;
 		ctrl->max_block_size = 2 * 1024 * 1024;
 	} else {
-		ctrl->page_sizes = page_sizes;
+		ctrl->page_sizes = page_sizes_v3_4;
 		if (ctrl->nand_version >= 0x0600)
 			ctrl->block_sizes = block_sizes_v6;
 		else
-- 
2.26.2


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

* [PATCH v2 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
                     ` (2 preceding siblings ...)
  2020-05-12  7:33   ` [PATCH v2 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
@ 2020-05-12  7:33   ` Álvaro Fernández Rojas
  2020-05-12  7:33   ` [PATCH v2 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-12  7:33 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Added brcm,brcmnand-v2.1 and brcm,brcmnand-v2.2 as possible compatible
strings to support brcmnand controllers v2.1 and v2.2.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: add new patch

 Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt b/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
index 05651a654c66..44335a4f8bfb 100644
--- a/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
+++ b/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
@@ -20,6 +20,8 @@ Required properties:
                      "brcm,brcmnand" and an appropriate version compatibility
                      string, like "brcm,brcmnand-v7.0"
                      Possible values:
+                         brcm,brcmnand-v2.1
+                         brcm,brcmnand-v2.2
                          brcm,brcmnand-v4.0
                          brcm,brcmnand-v5.0
                          brcm,brcmnand-v6.0
-- 
2.26.2


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

* [PATCH v2 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
                     ` (3 preceding siblings ...)
  2020-05-12  7:33   ` [PATCH v2 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
@ 2020-05-12  7:33   ` Álvaro Fernández Rojas
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-12  7:33 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Tested on Netgear DGND3700v2 (BCM6362 with v2.2 controller).

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: split page sizes rename into a different patch.
     name all block and page sizes versions.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 74 +++++++++++++++++++++---
 1 file changed, 66 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index ef60dbbeac2b..0af4e419ed99 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -338,6 +338,36 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
+/* BRCMNAND v2.1-v2.2 */
+static const u16 brcmnand_regs_v21[] = {
+	[BRCMNAND_CMD_START]		=  0x04,
+	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
+	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
+	[BRCMNAND_INTFC_STATUS]		=  0x5c,
+	[BRCMNAND_CS_SELECT]		=  0x14,
+	[BRCMNAND_CS_XOR]		=  0x18,
+	[BRCMNAND_LL_OP]		=     0,
+	[BRCMNAND_CS0_BASE]		=  0x40,
+	[BRCMNAND_CS1_BASE]		=     0,
+	[BRCMNAND_CORR_THRESHOLD]	=     0,
+	[BRCMNAND_CORR_THRESHOLD_EXT]	=     0,
+	[BRCMNAND_UNCORR_COUNT]		=     0,
+	[BRCMNAND_CORR_COUNT]		=     0,
+	[BRCMNAND_CORR_EXT_ADDR]	=  0x60,
+	[BRCMNAND_CORR_ADDR]		=  0x64,
+	[BRCMNAND_UNCORR_EXT_ADDR]	=  0x68,
+	[BRCMNAND_UNCORR_ADDR]		=  0x6c,
+	[BRCMNAND_SEMAPHORE]		=  0x50,
+	[BRCMNAND_ID]			=  0x54,
+	[BRCMNAND_ID_EXT]		=     0,
+	[BRCMNAND_LL_RDATA]		=     0,
+	[BRCMNAND_OOB_READ_BASE]	=  0x20,
+	[BRCMNAND_OOB_READ_10_BASE]	=     0,
+	[BRCMNAND_OOB_WRITE_BASE]	=  0x30,
+	[BRCMNAND_OOB_WRITE_10_BASE]	=     0,
+	[BRCMNAND_FC_BASE]		= 0x200,
+};
+
 /* BRCMNAND v3.3-v4.0 */
 static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
@@ -571,12 +601,16 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 {
 	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
 	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
+	static const unsigned int block_sizes_v2_2[] = { 16, 128, 8, 512, 256, 0 };
+	static const unsigned int block_sizes_v2_1[] = { 16, 128, 8, 512, 0 };
 	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int page_sizes_v2_2[] = { 512, 2048, 4096, 0 };
+	static const unsigned int page_sizes_v2_1[] = { 512, 2048, 0 };
 
 	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
 
-	/* Only support v4.0+? */
-	if (ctrl->nand_version < 0x0400) {
+	/* Only support v2.1+ */
+	if (ctrl->nand_version < 0x0201) {
 		dev_err(ctrl->dev, "version %#x not supported\n",
 			ctrl->nand_version);
 		return -ENODEV;
@@ -593,6 +627,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v50;
 	else if (ctrl->nand_version >= 0x0303)
 		ctrl->reg_offsets = brcmnand_regs_v33;
+	else if (ctrl->nand_version >= 0x0201)
+		ctrl->reg_offsets = brcmnand_regs_v21;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
@@ -618,14 +654,27 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->max_page_size = 16 * 1024;
 		ctrl->max_block_size = 2 * 1024 * 1024;
 	} else {
-		ctrl->page_sizes = page_sizes_v3_4;
+		if (ctrl->nand_version >= 0x0304)
+			ctrl->page_sizes = page_sizes_v3_4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->page_sizes = page_sizes_v2_2;
+		else
+			ctrl->page_sizes = page_sizes_v2_1;
+
 		if (ctrl->nand_version >= 0x0600)
 			ctrl->block_sizes = block_sizes_v6;
-		else
+		else if (ctrl->nand_version >= 0x0400)
 			ctrl->block_sizes = block_sizes_v4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->block_sizes = block_sizes_v2_2;
+		else
+			ctrl->block_sizes = block_sizes_v2_1;
 
 		if (ctrl->nand_version < 0x0400) {
-			ctrl->max_page_size = 4096;
+			if (ctrl->nand_version < 0x0202)
+				ctrl->max_page_size = 2048;
+			else
+				ctrl->max_page_size = 4096;
 			ctrl->max_block_size = 512 * 1024;
 		}
 	}
@@ -811,6 +860,9 @@ static void brcmnand_wr_corr_thresh(struct brcmnand_host *host, u8 val)
 	enum brcmnand_reg reg = BRCMNAND_CORR_THRESHOLD;
 	int cs = host->cs;
 
+	if (!ctrl->reg_offsets[reg])
+		return;
+
 	if (ctrl->nand_version == 0x0702)
 		bits = 7;
 	else if (ctrl->nand_version >= 0x0600)
@@ -869,8 +921,10 @@ static inline u32 brcmnand_spare_area_mask(struct brcmnand_controller *ctrl)
 		return GENMASK(7, 0);
 	else if (ctrl->nand_version >= 0x0600)
 		return GENMASK(6, 0);
-	else
+	else if (ctrl->nand_version >= 0x0303)
 		return GENMASK(5, 0);
+	else
+		return GENMASK(4, 0);
 }
 
 #define NAND_ACC_CONTROL_ECC_SHIFT	16
@@ -2390,9 +2444,11 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
 
 	tmp = nand_readreg(ctrl, acc_control_offs);
 	tmp &= ~brcmnand_ecc_level_mask(ctrl);
-	tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
 	tmp &= ~brcmnand_spare_area_mask(ctrl);
-	tmp |= cfg->spare_area_size;
+	if (ctrl->nand_version >= 0x0302) {
+		tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
+		tmp |= cfg->spare_area_size;
+	}
 	nand_writereg(ctrl, acc_control_offs, tmp);
 
 	brcmnand_set_sector_size_1k(host, cfg->sector_size_1k);
@@ -2766,6 +2822,8 @@ const struct dev_pm_ops brcmnand_pm_ops = {
 EXPORT_SYMBOL_GPL(brcmnand_pm_ops);
 
 static const struct of_device_id brcmnand_of_match[] = {
+	{ .compatible = "brcm,brcmnand-v2.1" },
+	{ .compatible = "brcm,brcmnand-v2.2" },
 	{ .compatible = "brcm,brcmnand-v4.0" },
 	{ .compatible = "brcm,brcmnand-v5.0" },
 	{ .compatible = "brcm,brcmnand-v6.0" },
-- 
2.26.2


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

* [PATCH v3 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers
  2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
                     ` (4 preceding siblings ...)
  2020-05-12  7:33   ` [PATCH v2 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
@ 2020-05-22  7:25   ` Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
                       ` (5 more replies)
  5 siblings, 6 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22  7:25 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Add support for v2.1 and v2.2 NAND controllers.

v3: fix v2.1 page size shift
v2: introduce changes suggested by Miquèl.

Álvaro Fernández Rojas (5):
  mtd: rawnand: brcmnand: rename v4 registers
  mtd: rawnand: brcmnand: fix CS0 layout
  mtd: rawnand: brcmnand: rename page sizes
  dt: bindings: brcmnand: add v2.1 and v2.2 support
  nand: brcmnand: support v2.1-v2.2 controllers

 .../devicetree/bindings/mtd/brcm,brcmnand.txt |   2 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c      | 100 +++++++++++++++---
 2 files changed, 86 insertions(+), 16 deletions(-)

-- 
2.26.2


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

* [PATCH v3 1/5] mtd: rawnand: brcmnand: rename v4 registers
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
@ 2020-05-22  7:25     ` Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22  7:25 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

These registers are also used on v3.3.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 v3: no changes.
 v2: fix commit title.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index e4e3ceeac38f..6a08dd07b058 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -338,8 +338,8 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
-/* BRCMNAND v4.0 */
-static const u16 brcmnand_regs_v40[] = {
+/* BRCMNAND v3.3-v4.0 */
+static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
 	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
 	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
@@ -591,8 +591,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v60;
 	else if (ctrl->nand_version >= 0x0500)
 		ctrl->reg_offsets = brcmnand_regs_v50;
-	else if (ctrl->nand_version >= 0x0400)
-		ctrl->reg_offsets = brcmnand_regs_v40;
+	else if (ctrl->nand_version >= 0x0303)
+		ctrl->reg_offsets = brcmnand_regs_v33;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
-- 
2.26.2


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

* [PATCH v3 2/5] mtd: rawnand: brcmnand: fix CS0 layout
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
@ 2020-05-22  7:25     ` Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22  7:25 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Only v3.3-v5.0 have a different CS0 layout.
Controllers before v3.3 use the same layout for every CS.

Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v3: no changes.
 v2: fix commit log.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 6a08dd07b058..72b268d8e3a4 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -606,8 +606,9 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 	} else {
 		ctrl->cs_offsets = brcmnand_cs_offsets;
 
-		/* v5.0 and earlier has a different CS0 offset layout */
-		if (ctrl->nand_version <= 0x0500)
+		/* v3.3-5.0 have a different CS0 offset layout */
+		if (ctrl->nand_version >= 0x0303 &&
+		    ctrl->nand_version <= 0x0500)
 			ctrl->cs0_offsets = brcmnand_cs_offsets_cs0;
 	}
 
-- 
2.26.2


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

* [PATCH v3 3/5] mtd: rawnand: brcmnand: rename page sizes
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
@ 2020-05-22  7:25     ` Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22  7:25 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Current pages sizes apply to controllers after v3.4

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v3: no changes.
 v2: add new patch.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 72b268d8e3a4..ef60dbbeac2b 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -571,7 +571,7 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 {
 	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
 	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
-	static const unsigned int page_sizes[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
 
 	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
 
@@ -618,7 +618,7 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->max_page_size = 16 * 1024;
 		ctrl->max_block_size = 2 * 1024 * 1024;
 	} else {
-		ctrl->page_sizes = page_sizes;
+		ctrl->page_sizes = page_sizes_v3_4;
 		if (ctrl->nand_version >= 0x0600)
 			ctrl->block_sizes = block_sizes_v6;
 		else
-- 
2.26.2


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

* [PATCH v3 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
                       ` (2 preceding siblings ...)
  2020-05-22  7:25     ` [PATCH v3 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
@ 2020-05-22  7:25     ` Álvaro Fernández Rojas
  2020-05-22  7:25     ` [PATCH v3 5/5] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
  5 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22  7:25 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Added brcm,brcmnand-v2.1 and brcm,brcmnand-v2.2 as possible compatible
strings to support brcmnand controllers v2.1 and v2.2.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v3: no changes.
 v2: add new patch.

 Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt b/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
index 05651a654c66..44335a4f8bfb 100644
--- a/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
+++ b/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
@@ -20,6 +20,8 @@ Required properties:
                      "brcm,brcmnand" and an appropriate version compatibility
                      string, like "brcm,brcmnand-v7.0"
                      Possible values:
+                         brcm,brcmnand-v2.1
+                         brcm,brcmnand-v2.2
                          brcm,brcmnand-v4.0
                          brcm,brcmnand-v5.0
                          brcm,brcmnand-v6.0
-- 
2.26.2


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

* [PATCH v3 5/5] nand: brcmnand: support v2.1-v2.2 controllers
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
                       ` (3 preceding siblings ...)
  2020-05-22  7:25     ` [PATCH v3 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
@ 2020-05-22  7:25     ` Álvaro Fernández Rojas
  2020-05-22 11:22       ` Miquel Raynal
  2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
  5 siblings, 1 reply; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22  7:25 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

v2.1: tested on Netgear DGND3700v1 (BCM6368)
v2.2: tested on Netgear DGND3700v2 (BCM6362)

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v3: fix page size shift for v2.1 controllers.
 v2: split page sizes rename into a different patch.
     name all block and page sizes versions.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 85 +++++++++++++++++++++---
 1 file changed, 76 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index ef60dbbeac2b..2c8a468c2e38 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -264,6 +264,7 @@ struct brcmnand_controller {
 	const unsigned int	*block_sizes;
 	unsigned int		max_page_size;
 	const unsigned int	*page_sizes;
+	unsigned int		page_size_shift;
 	unsigned int		max_oob;
 	u32			features;
 
@@ -338,6 +339,36 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
+/* BRCMNAND v2.1-v2.2 */
+static const u16 brcmnand_regs_v21[] = {
+	[BRCMNAND_CMD_START]		=  0x04,
+	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
+	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
+	[BRCMNAND_INTFC_STATUS]		=  0x5c,
+	[BRCMNAND_CS_SELECT]		=  0x14,
+	[BRCMNAND_CS_XOR]		=  0x18,
+	[BRCMNAND_LL_OP]		=     0,
+	[BRCMNAND_CS0_BASE]		=  0x40,
+	[BRCMNAND_CS1_BASE]		=     0,
+	[BRCMNAND_CORR_THRESHOLD]	=     0,
+	[BRCMNAND_CORR_THRESHOLD_EXT]	=     0,
+	[BRCMNAND_UNCORR_COUNT]		=     0,
+	[BRCMNAND_CORR_COUNT]		=     0,
+	[BRCMNAND_CORR_EXT_ADDR]	=  0x60,
+	[BRCMNAND_CORR_ADDR]		=  0x64,
+	[BRCMNAND_UNCORR_EXT_ADDR]	=  0x68,
+	[BRCMNAND_UNCORR_ADDR]		=  0x6c,
+	[BRCMNAND_SEMAPHORE]		=  0x50,
+	[BRCMNAND_ID]			=  0x54,
+	[BRCMNAND_ID_EXT]		=     0,
+	[BRCMNAND_LL_RDATA]		=     0,
+	[BRCMNAND_OOB_READ_BASE]	=  0x20,
+	[BRCMNAND_OOB_READ_10_BASE]	=     0,
+	[BRCMNAND_OOB_WRITE_BASE]	=  0x30,
+	[BRCMNAND_OOB_WRITE_10_BASE]	=     0,
+	[BRCMNAND_FC_BASE]		= 0x200,
+};
+
 /* BRCMNAND v3.3-v4.0 */
 static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
@@ -536,6 +567,9 @@ enum {
 	CFG_BUS_WIDTH			= BIT(CFG_BUS_WIDTH_SHIFT),
 	CFG_DEVICE_SIZE_SHIFT		= 24,
 
+	/* Only for v2.1 */
+	CFG_PAGE_SIZE_SHIFT_v2_1	= 30,
+
 	/* Only for pre-v7.1 (with no CFG_EXT register) */
 	CFG_PAGE_SIZE_SHIFT		= 20,
 	CFG_BLK_SIZE_SHIFT		= 28,
@@ -571,12 +605,16 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 {
 	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
 	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
+	static const unsigned int block_sizes_v2_2[] = { 16, 128, 8, 512, 256, 0 };
+	static const unsigned int block_sizes_v2_1[] = { 16, 128, 8, 512, 0 };
 	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int page_sizes_v2_2[] = { 512, 2048, 4096, 0 };
+	static const unsigned int page_sizes_v2_1[] = { 512, 2048, 0 };
 
 	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
 
-	/* Only support v4.0+? */
-	if (ctrl->nand_version < 0x0400) {
+	/* Only support v2.1+ */
+	if (ctrl->nand_version < 0x0201) {
 		dev_err(ctrl->dev, "version %#x not supported\n",
 			ctrl->nand_version);
 		return -ENODEV;
@@ -593,6 +631,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v50;
 	else if (ctrl->nand_version >= 0x0303)
 		ctrl->reg_offsets = brcmnand_regs_v33;
+	else if (ctrl->nand_version >= 0x0201)
+		ctrl->reg_offsets = brcmnand_regs_v21;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
@@ -618,14 +658,32 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->max_page_size = 16 * 1024;
 		ctrl->max_block_size = 2 * 1024 * 1024;
 	} else {
-		ctrl->page_sizes = page_sizes_v3_4;
+		if (ctrl->nand_version >= 0x0304)
+			ctrl->page_sizes = page_sizes_v3_4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->page_sizes = page_sizes_v2_2;
+		else
+			ctrl->page_sizes = page_sizes_v2_1;
+
+		if (ctrl->nand_version >= 0x0202)
+			ctrl->page_size_shift = CFG_PAGE_SIZE_SHIFT;
+		else
+			ctrl->page_size_shift = CFG_PAGE_SIZE_SHIFT_v2_1;
+
 		if (ctrl->nand_version >= 0x0600)
 			ctrl->block_sizes = block_sizes_v6;
-		else
+		else if (ctrl->nand_version >= 0x0400)
 			ctrl->block_sizes = block_sizes_v4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->block_sizes = block_sizes_v2_2;
+		else
+			ctrl->block_sizes = block_sizes_v2_1;
 
 		if (ctrl->nand_version < 0x0400) {
-			ctrl->max_page_size = 4096;
+			if (ctrl->nand_version < 0x0202)
+				ctrl->max_page_size = 2048;
+			else
+				ctrl->max_page_size = 4096;
 			ctrl->max_block_size = 512 * 1024;
 		}
 	}
@@ -811,6 +869,9 @@ static void brcmnand_wr_corr_thresh(struct brcmnand_host *host, u8 val)
 	enum brcmnand_reg reg = BRCMNAND_CORR_THRESHOLD;
 	int cs = host->cs;
 
+	if (!ctrl->reg_offsets[reg])
+		return;
+
 	if (ctrl->nand_version == 0x0702)
 		bits = 7;
 	else if (ctrl->nand_version >= 0x0600)
@@ -869,8 +930,10 @@ static inline u32 brcmnand_spare_area_mask(struct brcmnand_controller *ctrl)
 		return GENMASK(7, 0);
 	else if (ctrl->nand_version >= 0x0600)
 		return GENMASK(6, 0);
-	else
+	else if (ctrl->nand_version >= 0x0303)
 		return GENMASK(5, 0);
+	else
+		return GENMASK(4, 0);
 }
 
 #define NAND_ACC_CONTROL_ECC_SHIFT	16
@@ -2378,7 +2441,7 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
 		(!!(cfg->device_width == 16) << CFG_BUS_WIDTH_SHIFT) |
 		(device_size << CFG_DEVICE_SIZE_SHIFT);
 	if (cfg_offs == cfg_ext_offs) {
-		tmp |= (page_size << CFG_PAGE_SIZE_SHIFT) |
+		tmp |= (page_size << ctrl->page_size_shift) |
 		       (block_size << CFG_BLK_SIZE_SHIFT);
 		nand_writereg(ctrl, cfg_offs, tmp);
 	} else {
@@ -2390,9 +2453,11 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
 
 	tmp = nand_readreg(ctrl, acc_control_offs);
 	tmp &= ~brcmnand_ecc_level_mask(ctrl);
-	tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
 	tmp &= ~brcmnand_spare_area_mask(ctrl);
-	tmp |= cfg->spare_area_size;
+	if (ctrl->nand_version >= 0x0302) {
+		tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
+		tmp |= cfg->spare_area_size;
+	}
 	nand_writereg(ctrl, acc_control_offs, tmp);
 
 	brcmnand_set_sector_size_1k(host, cfg->sector_size_1k);
@@ -2766,6 +2831,8 @@ const struct dev_pm_ops brcmnand_pm_ops = {
 EXPORT_SYMBOL_GPL(brcmnand_pm_ops);
 
 static const struct of_device_id brcmnand_of_match[] = {
+	{ .compatible = "brcm,brcmnand-v2.1" },
+	{ .compatible = "brcm,brcmnand-v2.2" },
 	{ .compatible = "brcm,brcmnand-v4.0" },
 	{ .compatible = "brcm,brcmnand-v5.0" },
 	{ .compatible = "brcm,brcmnand-v6.0" },
-- 
2.26.2


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

* Re: [PATCH v3 5/5] nand: brcmnand: support v2.1-v2.2 controllers
  2020-05-22  7:25     ` [PATCH v3 5/5] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
@ 2020-05-22 11:22       ` Miquel Raynal
  2020-05-22 12:09         ` Álvaro Fernández Rojas
  0 siblings, 1 reply; 40+ messages in thread
From: Miquel Raynal @ 2020-05-22 11:22 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: computersforpeace, kdasu.kdev, richard, vigneshr, sumit.semwal,
	linux-mtd, bcm-kernel-feedback-list, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig

Hi Álvaro,

Álvaro Fernández Rojas <noltari@gmail.com> wrote on Fri, 22 May 2020
09:25:25 +0200:

> v2.1: tested on Netgear DGND3700v1 (BCM6368)
> v2.2: tested on Netgear DGND3700v2 (BCM6362)
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  v3: fix page size shift for v2.1 controllers.

You changed the subject title too which is not accurate anymore, any
reason to do that? Anything else changed in this series that I am not
aware of?

>  v2: split page sizes rename into a different patch.
>      name all block and page sizes versions.
> 
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 85 +++++++++++++++++++++---
>  1 file changed, 76 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index ef60dbbeac2b..2c8a468c2e38 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -264,6 +264,7 @@ struct brcmnand_controller {
>  	const unsigned int	*block_sizes;
>  	unsigned int		max_page_size;
>  	const unsigned int	*page_sizes;
> +	unsigned int		page_size_shift;
>  	unsigned int		max_oob;
>  	u32			features;
>  
> @@ -338,6 +339,36 @@ enum brcmnand_reg {
>  	BRCMNAND_FC_BASE,
>  };
>  
> +/* BRCMNAND v2.1-v2.2 */
> +static const u16 brcmnand_regs_v21[] = {
> +	[BRCMNAND_CMD_START]		=  0x04,
> +	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
> +	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
> +	[BRCMNAND_INTFC_STATUS]		=  0x5c,
> +	[BRCMNAND_CS_SELECT]		=  0x14,
> +	[BRCMNAND_CS_XOR]		=  0x18,
> +	[BRCMNAND_LL_OP]		=     0,
> +	[BRCMNAND_CS0_BASE]		=  0x40,
> +	[BRCMNAND_CS1_BASE]		=     0,
> +	[BRCMNAND_CORR_THRESHOLD]	=     0,
> +	[BRCMNAND_CORR_THRESHOLD_EXT]	=     0,
> +	[BRCMNAND_UNCORR_COUNT]		=     0,
> +	[BRCMNAND_CORR_COUNT]		=     0,
> +	[BRCMNAND_CORR_EXT_ADDR]	=  0x60,
> +	[BRCMNAND_CORR_ADDR]		=  0x64,
> +	[BRCMNAND_UNCORR_EXT_ADDR]	=  0x68,
> +	[BRCMNAND_UNCORR_ADDR]		=  0x6c,
> +	[BRCMNAND_SEMAPHORE]		=  0x50,
> +	[BRCMNAND_ID]			=  0x54,
> +	[BRCMNAND_ID_EXT]		=     0,
> +	[BRCMNAND_LL_RDATA]		=     0,
> +	[BRCMNAND_OOB_READ_BASE]	=  0x20,
> +	[BRCMNAND_OOB_READ_10_BASE]	=     0,
> +	[BRCMNAND_OOB_WRITE_BASE]	=  0x30,
> +	[BRCMNAND_OOB_WRITE_10_BASE]	=     0,
> +	[BRCMNAND_FC_BASE]		= 0x200,
> +};
> +
>  /* BRCMNAND v3.3-v4.0 */
>  static const u16 brcmnand_regs_v33[] = {
>  	[BRCMNAND_CMD_START]		=  0x04,
> @@ -536,6 +567,9 @@ enum {
>  	CFG_BUS_WIDTH			= BIT(CFG_BUS_WIDTH_SHIFT),
>  	CFG_DEVICE_SIZE_SHIFT		= 24,
>  
> +	/* Only for v2.1 */
> +	CFG_PAGE_SIZE_SHIFT_v2_1	= 30,
> +
>  	/* Only for pre-v7.1 (with no CFG_EXT register) */
>  	CFG_PAGE_SIZE_SHIFT		= 20,
>  	CFG_BLK_SIZE_SHIFT		= 28,
> @@ -571,12 +605,16 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  {
>  	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
>  	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
> +	static const unsigned int block_sizes_v2_2[] = { 16, 128, 8, 512, 256, 0 };
> +	static const unsigned int block_sizes_v2_1[] = { 16, 128, 8, 512, 0 };
>  	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
> +	static const unsigned int page_sizes_v2_2[] = { 512, 2048, 4096, 0 };
> +	static const unsigned int page_sizes_v2_1[] = { 512, 2048, 0 };
>  
>  	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
>  
> -	/* Only support v4.0+? */
> -	if (ctrl->nand_version < 0x0400) {
> +	/* Only support v2.1+ */
> +	if (ctrl->nand_version < 0x0201) {
>  		dev_err(ctrl->dev, "version %#x not supported\n",
>  			ctrl->nand_version);
>  		return -ENODEV;
> @@ -593,6 +631,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  		ctrl->reg_offsets = brcmnand_regs_v50;
>  	else if (ctrl->nand_version >= 0x0303)
>  		ctrl->reg_offsets = brcmnand_regs_v33;
> +	else if (ctrl->nand_version >= 0x0201)
> +		ctrl->reg_offsets = brcmnand_regs_v21;
>  
>  	/* Chip-select stride */
>  	if (ctrl->nand_version >= 0x0701)
> @@ -618,14 +658,32 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
>  		ctrl->max_page_size = 16 * 1024;
>  		ctrl->max_block_size = 2 * 1024 * 1024;
>  	} else {
> -		ctrl->page_sizes = page_sizes_v3_4;
> +		if (ctrl->nand_version >= 0x0304)
> +			ctrl->page_sizes = page_sizes_v3_4;
> +		else if (ctrl->nand_version >= 0x0202)
> +			ctrl->page_sizes = page_sizes_v2_2;
> +		else
> +			ctrl->page_sizes = page_sizes_v2_1;
> +
> +		if (ctrl->nand_version >= 0x0202)
> +			ctrl->page_size_shift = CFG_PAGE_SIZE_SHIFT;
> +		else
> +			ctrl->page_size_shift = CFG_PAGE_SIZE_SHIFT_v2_1;
> +
>  		if (ctrl->nand_version >= 0x0600)
>  			ctrl->block_sizes = block_sizes_v6;
> -		else
> +		else if (ctrl->nand_version >= 0x0400)
>  			ctrl->block_sizes = block_sizes_v4;
> +		else if (ctrl->nand_version >= 0x0202)
> +			ctrl->block_sizes = block_sizes_v2_2;
> +		else
> +			ctrl->block_sizes = block_sizes_v2_1;
>  
>  		if (ctrl->nand_version < 0x0400) {
> -			ctrl->max_page_size = 4096;
> +			if (ctrl->nand_version < 0x0202)
> +				ctrl->max_page_size = 2048;
> +			else
> +				ctrl->max_page_size = 4096;
>  			ctrl->max_block_size = 512 * 1024;
>  		}
>  	}
> @@ -811,6 +869,9 @@ static void brcmnand_wr_corr_thresh(struct brcmnand_host *host, u8 val)
>  	enum brcmnand_reg reg = BRCMNAND_CORR_THRESHOLD;
>  	int cs = host->cs;
>  
> +	if (!ctrl->reg_offsets[reg])
> +		return;
> +
>  	if (ctrl->nand_version == 0x0702)
>  		bits = 7;
>  	else if (ctrl->nand_version >= 0x0600)
> @@ -869,8 +930,10 @@ static inline u32 brcmnand_spare_area_mask(struct brcmnand_controller *ctrl)
>  		return GENMASK(7, 0);
>  	else if (ctrl->nand_version >= 0x0600)
>  		return GENMASK(6, 0);
> -	else
> +	else if (ctrl->nand_version >= 0x0303)
>  		return GENMASK(5, 0);
> +	else
> +		return GENMASK(4, 0);
>  }
>  
>  #define NAND_ACC_CONTROL_ECC_SHIFT	16
> @@ -2378,7 +2441,7 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
>  		(!!(cfg->device_width == 16) << CFG_BUS_WIDTH_SHIFT) |
>  		(device_size << CFG_DEVICE_SIZE_SHIFT);
>  	if (cfg_offs == cfg_ext_offs) {
> -		tmp |= (page_size << CFG_PAGE_SIZE_SHIFT) |
> +		tmp |= (page_size << ctrl->page_size_shift) |
>  		       (block_size << CFG_BLK_SIZE_SHIFT);
>  		nand_writereg(ctrl, cfg_offs, tmp);
>  	} else {
> @@ -2390,9 +2453,11 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
>  
>  	tmp = nand_readreg(ctrl, acc_control_offs);
>  	tmp &= ~brcmnand_ecc_level_mask(ctrl);
> -	tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
>  	tmp &= ~brcmnand_spare_area_mask(ctrl);
> -	tmp |= cfg->spare_area_size;
> +	if (ctrl->nand_version >= 0x0302) {
> +		tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
> +		tmp |= cfg->spare_area_size;
> +	}
>  	nand_writereg(ctrl, acc_control_offs, tmp);
>  
>  	brcmnand_set_sector_size_1k(host, cfg->sector_size_1k);
> @@ -2766,6 +2831,8 @@ const struct dev_pm_ops brcmnand_pm_ops = {
>  EXPORT_SYMBOL_GPL(brcmnand_pm_ops);
>  
>  static const struct of_device_id brcmnand_of_match[] = {
> +	{ .compatible = "brcm,brcmnand-v2.1" },
> +	{ .compatible = "brcm,brcmnand-v2.2" },
>  	{ .compatible = "brcm,brcmnand-v4.0" },
>  	{ .compatible = "brcm,brcmnand-v5.0" },
>  	{ .compatible = "brcm,brcmnand-v6.0" },

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

* Re: [PATCH v3 5/5] nand: brcmnand: support v2.1-v2.2 controllers
  2020-05-22 11:22       ` Miquel Raynal
@ 2020-05-22 12:09         ` Álvaro Fernández Rojas
  0 siblings, 0 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22 12:09 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: computersforpeace, kdasu.kdev, richard, vigneshr, sumit.semwal,
	linux-mtd, bcm-kernel-feedback-list, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig

Hello Miquel,

No, nothing else changed.
I will change it again with the proper subject, sorry for that.

Best regards,
Álvaro.

> El 22 may 2020, a las 13:22, Miquel Raynal <miquel.raynal@bootlin.com> escribió:
> 
>> v2.1: tested on Netgear DGND3700v1 (BCM6368)


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

* [PATCH v4 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers
  2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
                       ` (4 preceding siblings ...)
  2020-05-22  7:25     ` [PATCH v3 5/5] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
@ 2020-05-22 12:15     ` Álvaro Fernández Rojas
  2020-05-22 12:15       ` [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
                         ` (4 more replies)
  5 siblings, 5 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22 12:15 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Add support for v2.1 and v2.2 NAND controllers.

v4: fix commit subject.
v3: fix v2.1 page size shift
v2: introduce changes suggested by Miquèl.

Álvaro Fernández Rojas (5):
  mtd: rawnand: brcmnand: rename v4 registers
  mtd: rawnand: brcmnand: fix CS0 layout
  mtd: rawnand: brcmnand: rename page sizes
  dt: bindings: brcmnand: add v2.1 and v2.2 support
  nand: brcmnand: support v2.1-v2.2 controllers

 .../devicetree/bindings/mtd/brcm,brcmnand.txt |   2 +
 drivers/mtd/nand/raw/brcmnand/brcmnand.c      | 100 +++++++++++++++---
 2 files changed, 86 insertions(+), 16 deletions(-)

-- 
2.26.2


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

* [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers
  2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
@ 2020-05-22 12:15       ` Álvaro Fernández Rojas
  2020-05-22 15:33         ` Florian Fainelli
  2020-05-24 19:26         ` Miquel Raynal
  2020-05-22 12:15       ` [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
                         ` (3 subsequent siblings)
  4 siblings, 2 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22 12:15 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

These registers are also used on v3.3.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 v4: no changes.
 v3: no changes.
 v2: fix commit title.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index e4e3ceeac38f..6a08dd07b058 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -338,8 +338,8 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
-/* BRCMNAND v4.0 */
-static const u16 brcmnand_regs_v40[] = {
+/* BRCMNAND v3.3-v4.0 */
+static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
 	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
 	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
@@ -591,8 +591,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v60;
 	else if (ctrl->nand_version >= 0x0500)
 		ctrl->reg_offsets = brcmnand_regs_v50;
-	else if (ctrl->nand_version >= 0x0400)
-		ctrl->reg_offsets = brcmnand_regs_v40;
+	else if (ctrl->nand_version >= 0x0303)
+		ctrl->reg_offsets = brcmnand_regs_v33;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
-- 
2.26.2


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

* [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout
  2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
  2020-05-22 12:15       ` [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
@ 2020-05-22 12:15       ` Álvaro Fernández Rojas
  2020-05-22 15:35         ` Florian Fainelli
  2020-05-24 19:26         ` Miquel Raynal
  2020-05-22 12:15       ` [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
                         ` (2 subsequent siblings)
  4 siblings, 2 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22 12:15 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Only v3.3-v5.0 have a different CS0 layout.
Controllers before v3.3 use the same layout for every CS.

Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v4: no changes.
 v3: no changes.
 v2: fix commit log.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 6a08dd07b058..72b268d8e3a4 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -606,8 +606,9 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 	} else {
 		ctrl->cs_offsets = brcmnand_cs_offsets;
 
-		/* v5.0 and earlier has a different CS0 offset layout */
-		if (ctrl->nand_version <= 0x0500)
+		/* v3.3-5.0 have a different CS0 offset layout */
+		if (ctrl->nand_version >= 0x0303 &&
+		    ctrl->nand_version <= 0x0500)
 			ctrl->cs0_offsets = brcmnand_cs_offsets_cs0;
 	}
 
-- 
2.26.2


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

* [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes
  2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
  2020-05-22 12:15       ` [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
  2020-05-22 12:15       ` [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
@ 2020-05-22 12:15       ` Álvaro Fernández Rojas
  2020-05-22 15:35         ` Florian Fainelli
  2020-05-24 19:26         ` Miquel Raynal
  2020-05-22 12:15       ` [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
  2020-05-22 12:15       ` [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  4 siblings, 2 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22 12:15 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Current pages sizes apply to controllers after v3.4

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v4: no changes.
 v3: no changes.
 v2: add new patch.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 72b268d8e3a4..ef60dbbeac2b 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -571,7 +571,7 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 {
 	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
 	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
-	static const unsigned int page_sizes[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
 
 	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
 
@@ -618,7 +618,7 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->max_page_size = 16 * 1024;
 		ctrl->max_block_size = 2 * 1024 * 1024;
 	} else {
-		ctrl->page_sizes = page_sizes;
+		ctrl->page_sizes = page_sizes_v3_4;
 		if (ctrl->nand_version >= 0x0600)
 			ctrl->block_sizes = block_sizes_v6;
 		else
-- 
2.26.2


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

* [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support
  2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
                         ` (2 preceding siblings ...)
  2020-05-22 12:15       ` [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
@ 2020-05-22 12:15       ` Álvaro Fernández Rojas
  2020-05-22 15:36         ` Florian Fainelli
  2020-05-24 19:25         ` Miquel Raynal
  2020-05-22 12:15       ` [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  4 siblings, 2 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22 12:15 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

Added brcm,brcmnand-v2.1 and brcm,brcmnand-v2.2 as possible compatible
strings to support brcmnand controllers v2.1 and v2.2.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v4: no changes.
 v3: no changes.
 v2: add new patch.

 Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt b/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
index 05651a654c66..44335a4f8bfb 100644
--- a/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
+++ b/Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt
@@ -20,6 +20,8 @@ Required properties:
                      "brcm,brcmnand" and an appropriate version compatibility
                      string, like "brcm,brcmnand-v7.0"
                      Possible values:
+                         brcm,brcmnand-v2.1
+                         brcm,brcmnand-v2.2
                          brcm,brcmnand-v4.0
                          brcm,brcmnand-v5.0
                          brcm,brcmnand-v6.0
-- 
2.26.2


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

* [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers
  2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
                         ` (3 preceding siblings ...)
  2020-05-22 12:15       ` [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
@ 2020-05-22 12:15       ` Álvaro Fernández Rojas
  2020-05-22 15:37         ` Florian Fainelli
  2020-05-24 22:06         ` Miquel Raynal
  4 siblings, 2 replies; 40+ messages in thread
From: Álvaro Fernández Rojas @ 2020-05-22 12:15 UTC (permalink / raw)
  To: computersforpeace, kdasu.kdev, miquel.raynal, richard, vigneshr,
	sumit.semwal, linux-mtd, bcm-kernel-feedback-list, linux-kernel,
	linux-media, dri-devel, linaro-mm-sig
  Cc: Álvaro Fernández Rojas

v2.1: tested on Netgear DGND3700v1 (BCM6368)
v2.2: tested on Netgear DGND3700v2 (BCM6362)

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v4: use proper commit subject.
 v3: fix page size shift for v2.1 controllers.
 v2: split page sizes rename into a different patch.
     name all block and page sizes versions.

 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 85 +++++++++++++++++++++---
 1 file changed, 76 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index ef60dbbeac2b..2c8a468c2e38 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -264,6 +264,7 @@ struct brcmnand_controller {
 	const unsigned int	*block_sizes;
 	unsigned int		max_page_size;
 	const unsigned int	*page_sizes;
+	unsigned int		page_size_shift;
 	unsigned int		max_oob;
 	u32			features;
 
@@ -338,6 +339,36 @@ enum brcmnand_reg {
 	BRCMNAND_FC_BASE,
 };
 
+/* BRCMNAND v2.1-v2.2 */
+static const u16 brcmnand_regs_v21[] = {
+	[BRCMNAND_CMD_START]		=  0x04,
+	[BRCMNAND_CMD_EXT_ADDRESS]	=  0x08,
+	[BRCMNAND_CMD_ADDRESS]		=  0x0c,
+	[BRCMNAND_INTFC_STATUS]		=  0x5c,
+	[BRCMNAND_CS_SELECT]		=  0x14,
+	[BRCMNAND_CS_XOR]		=  0x18,
+	[BRCMNAND_LL_OP]		=     0,
+	[BRCMNAND_CS0_BASE]		=  0x40,
+	[BRCMNAND_CS1_BASE]		=     0,
+	[BRCMNAND_CORR_THRESHOLD]	=     0,
+	[BRCMNAND_CORR_THRESHOLD_EXT]	=     0,
+	[BRCMNAND_UNCORR_COUNT]		=     0,
+	[BRCMNAND_CORR_COUNT]		=     0,
+	[BRCMNAND_CORR_EXT_ADDR]	=  0x60,
+	[BRCMNAND_CORR_ADDR]		=  0x64,
+	[BRCMNAND_UNCORR_EXT_ADDR]	=  0x68,
+	[BRCMNAND_UNCORR_ADDR]		=  0x6c,
+	[BRCMNAND_SEMAPHORE]		=  0x50,
+	[BRCMNAND_ID]			=  0x54,
+	[BRCMNAND_ID_EXT]		=     0,
+	[BRCMNAND_LL_RDATA]		=     0,
+	[BRCMNAND_OOB_READ_BASE]	=  0x20,
+	[BRCMNAND_OOB_READ_10_BASE]	=     0,
+	[BRCMNAND_OOB_WRITE_BASE]	=  0x30,
+	[BRCMNAND_OOB_WRITE_10_BASE]	=     0,
+	[BRCMNAND_FC_BASE]		= 0x200,
+};
+
 /* BRCMNAND v3.3-v4.0 */
 static const u16 brcmnand_regs_v33[] = {
 	[BRCMNAND_CMD_START]		=  0x04,
@@ -536,6 +567,9 @@ enum {
 	CFG_BUS_WIDTH			= BIT(CFG_BUS_WIDTH_SHIFT),
 	CFG_DEVICE_SIZE_SHIFT		= 24,
 
+	/* Only for v2.1 */
+	CFG_PAGE_SIZE_SHIFT_v2_1	= 30,
+
 	/* Only for pre-v7.1 (with no CFG_EXT register) */
 	CFG_PAGE_SIZE_SHIFT		= 20,
 	CFG_BLK_SIZE_SHIFT		= 28,
@@ -571,12 +605,16 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 {
 	static const unsigned int block_sizes_v6[] = { 8, 16, 128, 256, 512, 1024, 2048, 0 };
 	static const unsigned int block_sizes_v4[] = { 16, 128, 8, 512, 256, 1024, 2048, 0 };
+	static const unsigned int block_sizes_v2_2[] = { 16, 128, 8, 512, 256, 0 };
+	static const unsigned int block_sizes_v2_1[] = { 16, 128, 8, 512, 0 };
 	static const unsigned int page_sizes_v3_4[] = { 512, 2048, 4096, 8192, 0 };
+	static const unsigned int page_sizes_v2_2[] = { 512, 2048, 4096, 0 };
+	static const unsigned int page_sizes_v2_1[] = { 512, 2048, 0 };
 
 	ctrl->nand_version = nand_readreg(ctrl, 0) & 0xffff;
 
-	/* Only support v4.0+? */
-	if (ctrl->nand_version < 0x0400) {
+	/* Only support v2.1+ */
+	if (ctrl->nand_version < 0x0201) {
 		dev_err(ctrl->dev, "version %#x not supported\n",
 			ctrl->nand_version);
 		return -ENODEV;
@@ -593,6 +631,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->reg_offsets = brcmnand_regs_v50;
 	else if (ctrl->nand_version >= 0x0303)
 		ctrl->reg_offsets = brcmnand_regs_v33;
+	else if (ctrl->nand_version >= 0x0201)
+		ctrl->reg_offsets = brcmnand_regs_v21;
 
 	/* Chip-select stride */
 	if (ctrl->nand_version >= 0x0701)
@@ -618,14 +658,32 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 		ctrl->max_page_size = 16 * 1024;
 		ctrl->max_block_size = 2 * 1024 * 1024;
 	} else {
-		ctrl->page_sizes = page_sizes_v3_4;
+		if (ctrl->nand_version >= 0x0304)
+			ctrl->page_sizes = page_sizes_v3_4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->page_sizes = page_sizes_v2_2;
+		else
+			ctrl->page_sizes = page_sizes_v2_1;
+
+		if (ctrl->nand_version >= 0x0202)
+			ctrl->page_size_shift = CFG_PAGE_SIZE_SHIFT;
+		else
+			ctrl->page_size_shift = CFG_PAGE_SIZE_SHIFT_v2_1;
+
 		if (ctrl->nand_version >= 0x0600)
 			ctrl->block_sizes = block_sizes_v6;
-		else
+		else if (ctrl->nand_version >= 0x0400)
 			ctrl->block_sizes = block_sizes_v4;
+		else if (ctrl->nand_version >= 0x0202)
+			ctrl->block_sizes = block_sizes_v2_2;
+		else
+			ctrl->block_sizes = block_sizes_v2_1;
 
 		if (ctrl->nand_version < 0x0400) {
-			ctrl->max_page_size = 4096;
+			if (ctrl->nand_version < 0x0202)
+				ctrl->max_page_size = 2048;
+			else
+				ctrl->max_page_size = 4096;
 			ctrl->max_block_size = 512 * 1024;
 		}
 	}
@@ -811,6 +869,9 @@ static void brcmnand_wr_corr_thresh(struct brcmnand_host *host, u8 val)
 	enum brcmnand_reg reg = BRCMNAND_CORR_THRESHOLD;
 	int cs = host->cs;
 
+	if (!ctrl->reg_offsets[reg])
+		return;
+
 	if (ctrl->nand_version == 0x0702)
 		bits = 7;
 	else if (ctrl->nand_version >= 0x0600)
@@ -869,8 +930,10 @@ static inline u32 brcmnand_spare_area_mask(struct brcmnand_controller *ctrl)
 		return GENMASK(7, 0);
 	else if (ctrl->nand_version >= 0x0600)
 		return GENMASK(6, 0);
-	else
+	else if (ctrl->nand_version >= 0x0303)
 		return GENMASK(5, 0);
+	else
+		return GENMASK(4, 0);
 }
 
 #define NAND_ACC_CONTROL_ECC_SHIFT	16
@@ -2378,7 +2441,7 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
 		(!!(cfg->device_width == 16) << CFG_BUS_WIDTH_SHIFT) |
 		(device_size << CFG_DEVICE_SIZE_SHIFT);
 	if (cfg_offs == cfg_ext_offs) {
-		tmp |= (page_size << CFG_PAGE_SIZE_SHIFT) |
+		tmp |= (page_size << ctrl->page_size_shift) |
 		       (block_size << CFG_BLK_SIZE_SHIFT);
 		nand_writereg(ctrl, cfg_offs, tmp);
 	} else {
@@ -2390,9 +2453,11 @@ static int brcmnand_set_cfg(struct brcmnand_host *host,
 
 	tmp = nand_readreg(ctrl, acc_control_offs);
 	tmp &= ~brcmnand_ecc_level_mask(ctrl);
-	tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
 	tmp &= ~brcmnand_spare_area_mask(ctrl);
-	tmp |= cfg->spare_area_size;
+	if (ctrl->nand_version >= 0x0302) {
+		tmp |= cfg->ecc_level << NAND_ACC_CONTROL_ECC_SHIFT;
+		tmp |= cfg->spare_area_size;
+	}
 	nand_writereg(ctrl, acc_control_offs, tmp);
 
 	brcmnand_set_sector_size_1k(host, cfg->sector_size_1k);
@@ -2766,6 +2831,8 @@ const struct dev_pm_ops brcmnand_pm_ops = {
 EXPORT_SYMBOL_GPL(brcmnand_pm_ops);
 
 static const struct of_device_id brcmnand_of_match[] = {
+	{ .compatible = "brcm,brcmnand-v2.1" },
+	{ .compatible = "brcm,brcmnand-v2.2" },
 	{ .compatible = "brcm,brcmnand-v4.0" },
 	{ .compatible = "brcm,brcmnand-v5.0" },
 	{ .compatible = "brcm,brcmnand-v6.0" },
-- 
2.26.2


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

* Re: [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers
  2020-05-22 12:15       ` [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
@ 2020-05-22 15:33         ` Florian Fainelli
  2020-05-24 19:26         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Florian Fainelli @ 2020-05-22 15:33 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig



On 5/22/2020 5:15 AM, Álvaro Fernández Rojas wrote:
> These registers are also used on v3.3.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout
  2020-05-22 12:15       ` [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
@ 2020-05-22 15:35         ` Florian Fainelli
  2020-05-24 19:26         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Florian Fainelli @ 2020-05-22 15:35 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig



On 5/22/2020 5:15 AM, Álvaro Fernández Rojas wrote:
> Only v3.3-v5.0 have a different CS0 layout.
> Controllers before v3.3 use the same layout for every CS.
> 
> Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes
  2020-05-22 12:15       ` [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
@ 2020-05-22 15:35         ` Florian Fainelli
  2020-05-24 19:26         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Florian Fainelli @ 2020-05-22 15:35 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig



On 5/22/2020 5:15 AM, Álvaro Fernández Rojas wrote:
> Current pages sizes apply to controllers after v3.4
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support
  2020-05-22 12:15       ` [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
@ 2020-05-22 15:36         ` Florian Fainelli
  2020-05-24 19:25         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Florian Fainelli @ 2020-05-22 15:36 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig



On 5/22/2020 5:15 AM, Álvaro Fernández Rojas wrote:
> Added brcm,brcmnand-v2.1 and brcm,brcmnand-v2.2 as possible compatible
> strings to support brcmnand controllers v2.1 and v2.2.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian

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

* Re: [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers
  2020-05-22 12:15       ` [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
@ 2020-05-22 15:37         ` Florian Fainelli
  2020-05-24 22:06         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Florian Fainelli @ 2020-05-22 15:37 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig



On 5/22/2020 5:15 AM, Álvaro Fernández Rojas wrote:
> v2.1: tested on Netgear DGND3700v1 (BCM6368)
> v2.2: tested on Netgear DGND3700v2 (BCM6362)
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support
  2020-05-22 12:15       ` [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
  2020-05-22 15:36         ` Florian Fainelli
@ 2020-05-24 19:25         ` Miquel Raynal
  2020-05-24 19:27           ` Miquel Raynal
  1 sibling, 1 reply; 40+ messages in thread
From: Miquel Raynal @ 2020-05-24 19:25 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig

On Fri, 2020-05-22 at 12:15:23 UTC, =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= wrote:
> Added brcm,brcmnand-v2.1 and brcm,brcmnand-v2.2 as possible compatible
> strings to support brcmnand controllers v2.1 and v2.2.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

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

* Re: [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes
  2020-05-22 12:15       ` [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
  2020-05-22 15:35         ` Florian Fainelli
@ 2020-05-24 19:26         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-24 19:26 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig

On Fri, 2020-05-22 at 12:15:22 UTC, =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= wrote:
> Current pages sizes apply to controllers after v3.4
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

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

* Re: [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout
  2020-05-22 12:15       ` [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
  2020-05-22 15:35         ` Florian Fainelli
@ 2020-05-24 19:26         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-24 19:26 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig

On Fri, 2020-05-22 at 12:15:21 UTC, =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= wrote:
> Only v3.3-v5.0 have a different CS0 layout.
> Controllers before v3.3 use the same layout for every CS.
> 
> Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

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

* Re: [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers
  2020-05-22 12:15       ` [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
  2020-05-22 15:33         ` Florian Fainelli
@ 2020-05-24 19:26         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-24 19:26 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig

On Fri, 2020-05-22 at 12:15:20 UTC, =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= wrote:
> These registers are also used on v3.3.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

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

* Re: [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support
  2020-05-24 19:25         ` Miquel Raynal
@ 2020-05-24 19:27           ` Miquel Raynal
       [not found]             ` <DB7PR03MB4604C2B50C013033D0CB95F8F5B20@DB7PR03MB4604.eurprd03.prod.outlook.com>
  0 siblings, 1 reply; 40+ messages in thread
From: Miquel Raynal @ 2020-05-24 19:27 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig


Miquel Raynal <miquel.raynal@bootlin.com> wrote on Sun, 24 May 2020
21:25:50 +0200:

> On Fri, 2020-05-22 at 12:15:23 UTC, =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= wrote:
> > Added brcm,brcmnand-v2.1 and brcm,brcmnand-v2.2 as possible compatible
> > strings to support brcmnand controllers v2.1 and v2.2.
> > 
> > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> > Acked-by: Florian Fainelli <f.fainelli@gmail.com>  
> 
> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

FYI I updated the commit log:
s/dt: bindings:/dt-bindings: mtd:/
s/Added/Add/

Thanks,
Miquèl

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

* Re: [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers
  2020-05-22 12:15       ` [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
  2020-05-22 15:37         ` Florian Fainelli
@ 2020-05-24 22:06         ` Miquel Raynal
  1 sibling, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-24 22:06 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, computersforpeace, kdasu.kdev,
	miquel.raynal, richard, vigneshr, sumit.semwal, linux-mtd,
	bcm-kernel-feedback-list, linux-kernel, linux-media, dri-devel,
	linaro-mm-sig

On Fri, 2020-05-22 at 12:15:24 UTC, =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= wrote:
> v2.1: tested on Netgear DGND3700v1 (BCM6368)
> v2.2: tested on Netgear DGND3700v2 (BCM6362)
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

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

* Re: [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support
       [not found]             ` <DB7PR03MB4604C2B50C013033D0CB95F8F5B20@DB7PR03MB4604.eurprd03.prod.outlook.com>
@ 2020-05-24 22:06               ` Miquel Raynal
  0 siblings, 0 replies; 40+ messages in thread
From: Miquel Raynal @ 2020-05-24 22:06 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: computersforpeace, kdasu.kdev, richard, vigneshr, sumit.semwal,
	linux-mtd, bcm-kernel-feedback-list, linux-kernel, linux-media,
	dri-devel, linaro-mm-sig


Álvaro Fernández Rojas <noltari@gmail.com> wrote on Sun, 24 May 2020
21:13:41 +0000:

> Thanks for merging the patches :).
> 
> BTW, is there something wrong with patch 5?
> I can see patches 1-4 applied in https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/log/?h=nand/next, but I can’t see patch 5.
> 

Done :)

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

end of thread, back to index

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-10 15:14 [PATCH 1/3] nand: brcmnand: rename v4 registers Álvaro Fernández Rojas
2020-05-10 15:14 ` [PATCH 2/3] nand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
2020-05-11 17:01   ` Miquel Raynal
2020-05-10 15:14 ` [PATCH 3/3] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
2020-05-10 15:39   ` Florian Fainelli
2020-05-11 17:44   ` Miquel Raynal
2020-05-11 17:03 ` [PATCH 1/3] nand: brcmnand: rename v4 registers Miquel Raynal
2020-05-11 17:40 ` Miquel Raynal
2020-05-12  7:33 ` [PATCH v2 0/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
2020-05-12  7:33   ` [PATCH v2 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
2020-05-12  7:33   ` [PATCH v2 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
2020-05-12  7:33   ` [PATCH v2 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
2020-05-12  7:33   ` [PATCH v2 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
2020-05-12  7:33   ` [PATCH v2 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
2020-05-22  7:25   ` [PATCH v3 0/5] " Álvaro Fernández Rojas
2020-05-22  7:25     ` [PATCH v3 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
2020-05-22  7:25     ` [PATCH v3 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
2020-05-22  7:25     ` [PATCH v3 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
2020-05-22  7:25     ` [PATCH v3 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
2020-05-22  7:25     ` [PATCH v3 5/5] nand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
2020-05-22 11:22       ` Miquel Raynal
2020-05-22 12:09         ` Álvaro Fernández Rojas
2020-05-22 12:15     ` [PATCH v4 0/5] mtd: rawnand: " Álvaro Fernández Rojas
2020-05-22 12:15       ` [PATCH v4 1/5] mtd: rawnand: brcmnand: rename v4 registers Álvaro Fernández Rojas
2020-05-22 15:33         ` Florian Fainelli
2020-05-24 19:26         ` Miquel Raynal
2020-05-22 12:15       ` [PATCH v4 2/5] mtd: rawnand: brcmnand: fix CS0 layout Álvaro Fernández Rojas
2020-05-22 15:35         ` Florian Fainelli
2020-05-24 19:26         ` Miquel Raynal
2020-05-22 12:15       ` [PATCH v4 3/5] mtd: rawnand: brcmnand: rename page sizes Álvaro Fernández Rojas
2020-05-22 15:35         ` Florian Fainelli
2020-05-24 19:26         ` Miquel Raynal
2020-05-22 12:15       ` [PATCH v4 4/5] dt: bindings: brcmnand: add v2.1 and v2.2 support Álvaro Fernández Rojas
2020-05-22 15:36         ` Florian Fainelli
2020-05-24 19:25         ` Miquel Raynal
2020-05-24 19:27           ` Miquel Raynal
     [not found]             ` <DB7PR03MB4604C2B50C013033D0CB95F8F5B20@DB7PR03MB4604.eurprd03.prod.outlook.com>
2020-05-24 22:06               ` Miquel Raynal
2020-05-22 12:15       ` [PATCH v4 5/5] mtd: rawnand: brcmnand: support v2.1-v2.2 controllers Álvaro Fernández Rojas
2020-05-22 15:37         ` Florian Fainelli
2020-05-24 22:06         ` Miquel Raynal

Linux-Media Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-media/0 linux-media/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-media linux-media/ https://lore.kernel.org/linux-media \
		linux-media@vger.kernel.org
	public-inbox-index linux-media

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-media


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git