linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: jz4780_nemc: Only request IO memory the driver will use
@ 2020-07-27 16:20 Paul Cercueil
  2020-07-28  9:21 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Cercueil @ 2020-07-27 16:20 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: od, linux-kernel, Paul Cercueil, H . Nikolaus Schaller

The driver only uses the registers up to offset 0x54. Since the EFUSE
registers are in the middle of the NEMC registers, we only request
the registers we will use for now - that way the EFUSE driver can
probe too.

Tested-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/memory/jz4780-nemc.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c
index b232ed279fc3..647267ea8c63 100644
--- a/drivers/memory/jz4780-nemc.c
+++ b/drivers/memory/jz4780-nemc.c
@@ -8,6 +8,7 @@
 
 #include <linux/clk.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/math64.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -288,7 +289,19 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
 	nemc->dev = dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	nemc->base = devm_ioremap_resource(dev, res);
+
+	/*
+	 * The driver only uses the registers up to offset 0x54. Since the EFUSE
+	 * registers are in the middle of the NEMC registers, we only request
+	 * the registers we will use for now - that way the EFUSE driver can
+	 * probe too.
+	 */
+	if (!devm_request_mem_region(dev, res->start, 0x54, dev_name(dev))) {
+		dev_err(dev, "unable to request I/O memory region\n");
+		return -EBUSY;
+	}
+
+	nemc->base = devm_ioremap(dev, res->start, resource_size(res));
 	if (IS_ERR(nemc->base)) {
 		dev_err(dev, "failed to get I/O memory\n");
 		return PTR_ERR(nemc->base);
-- 
2.27.0


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

* Re: [PATCH] memory: jz4780_nemc: Only request IO memory the driver will use
  2020-07-27 16:20 [PATCH] memory: jz4780_nemc: Only request IO memory the driver will use Paul Cercueil
@ 2020-07-28  9:21 ` Krzysztof Kozlowski
  2020-07-28 12:52   ` Paul Cercueil
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2020-07-28  9:21 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: od, linux-kernel, H . Nikolaus Schaller

On Mon, Jul 27, 2020 at 06:20:34PM +0200, Paul Cercueil wrote:
> The driver only uses the registers up to offset 0x54. Since the EFUSE
> registers are in the middle of the NEMC registers, we only request
> the registers we will use for now - that way the EFUSE driver can
> probe too.
> 
> Tested-by: H. Nikolaus Schaller <hns@goldelico.com>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/memory/jz4780-nemc.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c
> index b232ed279fc3..647267ea8c63 100644
> --- a/drivers/memory/jz4780-nemc.c
> +++ b/drivers/memory/jz4780-nemc.c
> @@ -8,6 +8,7 @@
>  
>  #include <linux/clk.h>
>  #include <linux/init.h>
> +#include <linux/io.h>
>  #include <linux/math64.h>
>  #include <linux/of.h>
>  #include <linux/of_address.h>
> @@ -288,7 +289,19 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
>  	nemc->dev = dev;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	nemc->base = devm_ioremap_resource(dev, res);
> +
> +	/*
> +	 * The driver only uses the registers up to offset 0x54. Since the EFUSE
> +	 * registers are in the middle of the NEMC registers, we only request
> +	 * the registers we will use for now - that way the EFUSE driver can
> +	 * probe too.
> +	 */
> +	if (!devm_request_mem_region(dev, res->start, 0x54, dev_name(dev))) {
> +		dev_err(dev, "unable to request I/O memory region\n");
> +		return -EBUSY;
> +	}
> +
> +	nemc->base = devm_ioremap(dev, res->start, resource_size(res));

Shouldn't you map only 0x54 size as well?

Best regards,
Krzysztof

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

* Re: [PATCH] memory: jz4780_nemc: Only request IO memory the driver will use
  2020-07-28  9:21 ` Krzysztof Kozlowski
@ 2020-07-28 12:52   ` Paul Cercueil
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Cercueil @ 2020-07-28 12:52 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: od, linux-kernel, H . Nikolaus Schaller



Le mar. 28 juil. 2020 à 11:21, Krzysztof Kozlowski <krzk@kernel.org> a 
écrit :
> On Mon, Jul 27, 2020 at 06:20:34PM +0200, Paul Cercueil wrote:
>>  The driver only uses the registers up to offset 0x54. Since the 
>> EFUSE
>>  registers are in the middle of the NEMC registers, we only request
>>  the registers we will use for now - that way the EFUSE driver can
>>  probe too.
>> 
>>  Tested-by: H. Nikolaus Schaller <hns@goldelico.com>
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  ---
>>   drivers/memory/jz4780-nemc.c | 15 ++++++++++++++-
>>   1 file changed, 14 insertions(+), 1 deletion(-)
>> 
>>  diff --git a/drivers/memory/jz4780-nemc.c 
>> b/drivers/memory/jz4780-nemc.c
>>  index b232ed279fc3..647267ea8c63 100644
>>  --- a/drivers/memory/jz4780-nemc.c
>>  +++ b/drivers/memory/jz4780-nemc.c
>>  @@ -8,6 +8,7 @@
>> 
>>   #include <linux/clk.h>
>>   #include <linux/init.h>
>>  +#include <linux/io.h>
>>   #include <linux/math64.h>
>>   #include <linux/of.h>
>>   #include <linux/of_address.h>
>>  @@ -288,7 +289,19 @@ static int jz4780_nemc_probe(struct 
>> platform_device *pdev)
>>   	nemc->dev = dev;
>> 
>>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>  -	nemc->base = devm_ioremap_resource(dev, res);
>>  +
>>  +	/*
>>  +	 * The driver only uses the registers up to offset 0x54. Since 
>> the EFUSE
>>  +	 * registers are in the middle of the NEMC registers, we only 
>> request
>>  +	 * the registers we will use for now - that way the EFUSE driver 
>> can
>>  +	 * probe too.
>>  +	 */
>>  +	if (!devm_request_mem_region(dev, res->start, 0x54, 
>> dev_name(dev))) {
>>  +		dev_err(dev, "unable to request I/O memory region\n");
>>  +		return -EBUSY;
>>  +	}
>>  +
>>  +	nemc->base = devm_ioremap(dev, res->start, resource_size(res));
> 
> Shouldn't you map only 0x54 size as well?

I can do that.

Cheers,
-Paul



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

end of thread, other threads:[~2020-07-28 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 16:20 [PATCH] memory: jz4780_nemc: Only request IO memory the driver will use Paul Cercueil
2020-07-28  9:21 ` Krzysztof Kozlowski
2020-07-28 12:52   ` Paul Cercueil

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