mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] memory: atmel-ebi: Fixes
@ 2017-01-27  9:10 Boris Brezillon
  2017-01-27  9:10 ` [PATCH 1/2] memory: atmel-ebi: Fix the test to enable generic SMC logic Boris Brezillon
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Boris Brezillon @ 2017-01-27  9:10 UTC (permalink / raw)
  To: Nicolas Ferre, Alexandre Belloni
  Cc: linux-arm-kernel, linux-kernel, Boris Brezillon

Hello,

Here are 2 simple EBI fixes to prepare landing of the Atmel NAND
controller driver and bindings rework.

No need to backport them since no one is using the EBI right now.

Nicolas, Alexandre, that'd be great if you could queue it for 4.11
since I plan to take the NAND driver rework for 4.12. If that's not
possible, I'll probably ask you to let me take these fixes into the
NAND tree.

Thanks,

Boris

Boris Brezillon (2):
  memory: atmel-ebi: Fix the test to enable generic SMC logic
  memory: atmel-ebi: Properly handle multiple reference to the same CS

 drivers/memory/atmel-ebi.c | 48 +++++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 20 deletions(-)

-- 
2.7.4

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

* [PATCH 1/2] memory: atmel-ebi: Fix the test to enable generic SMC logic
  2017-01-27  9:10 [PATCH 0/2] memory: atmel-ebi: Fixes Boris Brezillon
@ 2017-01-27  9:10 ` Boris Brezillon
  2017-01-27  9:10 ` [PATCH 2/2] memory: atmel-ebi: Properly handle multiple reference to the same CS Boris Brezillon
  2017-01-27  9:16 ` [PATCH 0/2] memory: atmel-ebi: Fixes Alexandre Belloni
  2 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2017-01-27  9:10 UTC (permalink / raw)
  To: Nicolas Ferre, Alexandre Belloni
  Cc: linux-arm-kernel, linux-kernel, Boris Brezillon

We should test the apply value and not the ret one here.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Fixes: 6a4ec4cd0888 ("memory: add Atmel EBI (External Bus Interface) driver")
---
 drivers/memory/atmel-ebi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index 1eaaa2be8ff2..2c4c9a1978bc 100644
--- a/drivers/memory/atmel-ebi.c
+++ b/drivers/memory/atmel-ebi.c
@@ -503,7 +503,7 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
 		 * Attach the EBI device to the generic SMC logic if at least
 		 * one "atmel,smc-" property is present.
 		 */
-		if (ebi->ebi_csa && ret)
+		if (ebi->ebi_csa && apply)
 			regmap_field_update_bits(ebi->ebi_csa,
 						 BIT(cs), 0);
 	}
-- 
2.7.4

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

* [PATCH 2/2] memory: atmel-ebi: Properly handle multiple reference to the same CS
  2017-01-27  9:10 [PATCH 0/2] memory: atmel-ebi: Fixes Boris Brezillon
  2017-01-27  9:10 ` [PATCH 1/2] memory: atmel-ebi: Fix the test to enable generic SMC logic Boris Brezillon
@ 2017-01-27  9:10 ` Boris Brezillon
  2017-01-27  9:16 ` [PATCH 0/2] memory: atmel-ebi: Fixes Alexandre Belloni
  2 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2017-01-27  9:10 UTC (permalink / raw)
  To: Nicolas Ferre, Alexandre Belloni
  Cc: linux-arm-kernel, linux-kernel, Boris Brezillon

Some devices are defining several sub-ranges within the same CS iomem
range. In this case, we should not duplicate the EBI device config.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/memory/atmel-ebi.c | 46 +++++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index 2c4c9a1978bc..46657eaaedf6 100644
--- a/drivers/memory/atmel-ebi.c
+++ b/drivers/memory/atmel-ebi.c
@@ -449,12 +449,31 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
 	struct at91_ebi_dev_config conf = { };
 	struct device *dev = ebi->dev;
 	struct at91_ebi_dev *ebid;
-	int ret, numcs = 0, i;
+	unsigned long cslines = 0;
+	int ret, numcs = 0, nentries, i;
 	bool apply = false;
+	u32 cs;
 
-	numcs = of_property_count_elems_of_size(np, "reg",
-						reg_cells * sizeof(u32));
-	if (numcs <= 0) {
+	nentries = of_property_count_elems_of_size(np, "reg",
+						   reg_cells * sizeof(u32));
+	for (i = 0; i < nentries; i++) {
+		ret = of_property_read_u32_index(np, "reg", i * reg_cells,
+						 &cs);
+		if (ret)
+			return ret;
+
+		if (cs >= AT91_MATRIX_EBI_NUM_CS ||
+		    !(ebi->caps->available_cs & BIT(cs))) {
+			dev_err(dev, "invalid reg property in %s\n",
+				np->full_name);
+			return -EINVAL;
+		}
+
+		if (!test_and_set_bit(cs, &cslines))
+			numcs++;
+	}
+
+	if (!numcs) {
 		dev_err(dev, "invalid reg property in %s\n", np->full_name);
 		return -EINVAL;
 	}
@@ -473,21 +492,8 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
 	else if (ret)
 		apply = true;
 
-	for (i = 0; i < numcs; i++) {
-		u32 cs;
-
-		ret = of_property_read_u32_index(np, "reg", i * reg_cells,
-						 &cs);
-		if (ret)
-			return ret;
-
-		if (cs > AT91_MATRIX_EBI_NUM_CS ||
-		    !(ebi->caps->available_cs & BIT(cs))) {
-			dev_err(dev, "invalid reg property in %s\n",
-				np->full_name);
-			return -EINVAL;
-		}
-
+	i = 0;
+	for_each_set_bit(cs, &cslines, AT91_MATRIX_EBI_NUM_CS) {
 		ebid->configs[i].cs = cs;
 
 		if (apply) {
@@ -506,6 +512,8 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
 		if (ebi->ebi_csa && apply)
 			regmap_field_update_bits(ebi->ebi_csa,
 						 BIT(cs), 0);
+
+		i++;
 	}
 
 	list_add_tail(&ebid->node, &ebi->devs);
-- 
2.7.4

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

* Re: [PATCH 0/2] memory: atmel-ebi: Fixes
  2017-01-27  9:10 [PATCH 0/2] memory: atmel-ebi: Fixes Boris Brezillon
  2017-01-27  9:10 ` [PATCH 1/2] memory: atmel-ebi: Fix the test to enable generic SMC logic Boris Brezillon
  2017-01-27  9:10 ` [PATCH 2/2] memory: atmel-ebi: Properly handle multiple reference to the same CS Boris Brezillon
@ 2017-01-27  9:16 ` Alexandre Belloni
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2017-01-27  9:16 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: Nicolas Ferre, linux-arm-kernel, linux-kernel

On 27/01/2017 at 10:10:35 +0100, Boris Brezillon wrote:
> Hello,
> 
> Here are 2 simple EBI fixes to prepare landing of the Atmel NAND
> controller driver and bindings rework.
> 
> No need to backport them since no one is using the EBI right now.
> 
> Nicolas, Alexandre, that'd be great if you could queue it for 4.11
> since I plan to take the NAND driver rework for 4.12. If that's not
> possible, I'll probably ask you to let me take these fixes into the
> NAND tree.
> 
> Thanks,
> 
> Boris
> 
> Boris Brezillon (2):
>   memory: atmel-ebi: Fix the test to enable generic SMC logic
>   memory: atmel-ebi: Properly handle multiple reference to the same CS
> 
>  drivers/memory/atmel-ebi.c | 48 +++++++++++++++++++++++++++-------------------
>  1 file changed, 28 insertions(+), 20 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

end of thread, other threads:[~2017-01-27  9:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27  9:10 [PATCH 0/2] memory: atmel-ebi: Fixes Boris Brezillon
2017-01-27  9:10 ` [PATCH 1/2] memory: atmel-ebi: Fix the test to enable generic SMC logic Boris Brezillon
2017-01-27  9:10 ` [PATCH 2/2] memory: atmel-ebi: Properly handle multiple reference to the same CS Boris Brezillon
2017-01-27  9:16 ` [PATCH 0/2] memory: atmel-ebi: Fixes Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®