mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority"
@ 2016-07-18 15:14 Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 2/7] mfd: syscon: Don't call request_iomem_region() Andrey Smirnov
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Andrey Smirnov @ 2016-07-18 15:14 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Fixing the i.MX6 specific issue this way breaks things on CLPS711x
target. Better fix for the problem is to follow this patch.

This reverts commit c203958f3bbf25fc3d612497057b962e96ad1c52.

Reported-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mfd/syscon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index ee62da0..9589a03 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -111,7 +111,7 @@ static int __init syscon_init(void)
 {
 	return platform_driver_register(&syscon_driver);
 }
-device_initcall(syscon_init);
+core_initcall(syscon_init);
 
 MODULE_AUTHOR("Dong Aisheng <dong.aisheng@linaro.org>");
 MODULE_DESCRIPTION("System Control driver");
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 2/7] mfd: syscon: Don't call request_iomem_region()
  2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
@ 2016-07-18 15:14 ` Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 3/7] mfd: syscon: Decouple syscon interface from platform devices Andrey Smirnov
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrey Smirnov @ 2016-07-18 15:14 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

On platforms that mix dedicated IP block register space with
miscellaneous registers it is necessary to share register window between
syscon and dedicated IP block driver. Calling request_iomem_region()
implies exclusive ownership of the region, which, in the case above
could not happen.

This change also makes this driver's behaviour to that of its Linux
kernel counterpart.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mfd/syscon.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 9589a03..ac46122 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -76,12 +76,6 @@ static int syscon_probe(struct device_d *dev)
 		return PTR_ERR(res);
 	}
 
-	res = request_iomem_region(dev_name(dev), res->start, res->end);
-	if (IS_ERR(res)) {
-		free(syscon);
-		return PTR_ERR(res);
-	}
-
 	syscon->base = (void __iomem *)res->start;
 	dev->priv = syscon;
 
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 3/7] mfd: syscon: Decouple syscon interface from platform devices
  2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 2/7] mfd: syscon: Don't call request_iomem_region() Andrey Smirnov
@ 2016-07-18 15:14 ` Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 4/7] mfd: syscon: Don't check xzalloc return for NULL Andrey Smirnov
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrey Smirnov @ 2016-07-18 15:14 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Follow Linux Kernel change introduced in
bdb0066df96e74a4002125467ebe459feff1ebef and avoid device/driver model
for DT-based platforms. See the original kernel commit for the rationale.

Also make syscon_base_lookup_by_pdevname() behave the same way as its
kernel counterpart in the case whern "property" argument is NULL.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mfd/syscon.c | 79 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 61 insertions(+), 18 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index ac46122..cf1d2df 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -17,15 +17,68 @@
 #include <driver.h>
 #include <malloc.h>
 #include <xfuncs.h>
-
+#include <of_address.h>
 #include <linux/err.h>
 
 #include <mfd/syscon.h>
 
+static LIST_HEAD(syscon_list);
+
 struct syscon {
+	struct device_node *np;
 	void __iomem *base;
+	struct list_head list;
 };
 
+static struct syscon *of_syscon_register(struct device_node *np)
+{
+	int ret;
+	struct syscon *syscon;
+	struct resource res;
+
+	if (!of_device_is_compatible(np, "syscon"))
+		return ERR_PTR(-EINVAL);
+
+	syscon = xzalloc(sizeof(*syscon));
+
+	if (of_address_to_resource(np, 0, &res)) {
+		ret = -ENOMEM;
+		goto err_map;
+	}
+
+	syscon->base = IOMEM(res.start);
+	syscon->np   = np;
+
+	list_add_tail(&syscon->list, &syscon_list);
+
+	return syscon;
+
+err_map:
+	kfree(syscon);
+	return ERR_PTR(ret);
+}
+
+static void __iomem *syscon_node_to_base(struct device_node *np)
+{
+	struct syscon *entry, *syscon = NULL;
+
+	list_for_each_entry(entry, &syscon_list, list)
+		if (entry->np == np) {
+			syscon = entry;
+			break;
+		}
+
+	if (!syscon)
+		syscon = of_syscon_register(np);
+
+	if (IS_ERR(syscon))
+		return ERR_CAST(syscon);
+
+	return syscon->base;
+}
+EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
+
+
 void __iomem *syscon_base_lookup_by_pdevname(const char *s)
 {
 	struct syscon *syscon;
@@ -44,21 +97,17 @@ void __iomem *syscon_base_lookup_by_pdevname(const char *s)
 void __iomem *syscon_base_lookup_by_phandle(struct device_node *np,
 					    const char *property)
 {
-	struct device_node *node;
-	struct syscon *syscon;
-	struct device_d *dev;
+	struct device_node *syscon_np;
 
-	node = of_parse_phandle(np, property, 0);
-	if (!node)
-		return ERR_PTR(-ENODEV);
+	if (property)
+		syscon_np = of_parse_phandle(np, property, 0);
+	else
+		syscon_np = np;
 
-	dev = of_find_device_by_node(node);
-	if (!dev)
+	if (!syscon_np)
 		return ERR_PTR(-ENODEV);
 
-	syscon = dev->priv;
-
-	return syscon->base;
+	return syscon_node_to_base(syscon_np);
 }
 
 static int syscon_probe(struct device_d *dev)
@@ -89,16 +138,10 @@ static struct platform_device_id syscon_ids[] = {
 	{ }
 };
 
-static struct of_device_id of_syscon_match[] = {
-	{ .compatible = "syscon" },
-	{ },
-};
-
 static struct driver_d syscon_driver = {
 	.name		= "syscon",
 	.probe		= syscon_probe,
 	.id_table	= syscon_ids,
-	.of_compatible	= DRV_OF_COMPAT(of_syscon_match),
 };
 
 static int __init syscon_init(void)
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 4/7] mfd: syscon: Don't check xzalloc return for NULL
  2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 2/7] mfd: syscon: Don't call request_iomem_region() Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 3/7] mfd: syscon: Decouple syscon interface from platform devices Andrey Smirnov
@ 2016-07-18 15:14 ` Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 5/7] mfd: syscon: Use IOMEM instead of explicit cast Andrey Smirnov
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrey Smirnov @ 2016-07-18 15:14 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Xzalloc never returns NULL, so this check does not bring any value.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mfd/syscon.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index cf1d2df..487fa9e 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -116,8 +116,6 @@ static int syscon_probe(struct device_d *dev)
 	struct resource *res;
 
 	syscon = xzalloc(sizeof(struct syscon));
-	if (!syscon)
-		return -ENOMEM;
 
 	res = dev_get_resource(dev, IORESOURCE_MEM, 0);
 	if (IS_ERR(res)) {
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 5/7] mfd: syscon: Use IOMEM instead of explicit cast
  2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
                   ` (2 preceding siblings ...)
  2016-07-18 15:14 ` [PATCH v2 4/7] mfd: syscon: Don't check xzalloc return for NULL Andrey Smirnov
@ 2016-07-18 15:14 ` Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 6/7] imx_thermal: Remove leftover debug output Andrey Smirnov
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Andrey Smirnov @ 2016-07-18 15:14 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mfd/syscon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 487fa9e..295e210 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -123,7 +123,7 @@ static int syscon_probe(struct device_d *dev)
 		return PTR_ERR(res);
 	}
 
-	syscon->base = (void __iomem *)res->start;
+	syscon->base = IOMEM(res->start);
 	dev->priv = syscon;
 
 	dev_dbg(dev, "map 0x%x-0x%x registered\n", res->start, res->end);
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 6/7] imx_thermal: Remove leftover debug output
  2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
                   ` (3 preceding siblings ...)
  2016-07-18 15:14 ` [PATCH v2 5/7] mfd: syscon: Use IOMEM instead of explicit cast Andrey Smirnov
@ 2016-07-18 15:14 ` Andrey Smirnov
  2016-07-18 15:14 ` [PATCH v2 7/7] i.MX: ocotp: Register regmap against orignal device Andrey Smirnov
  2016-07-19  4:51 ` [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Andrey Smirnov @ 2016-07-18 15:14 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/aiodev/imx_thermal.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/aiodev/imx_thermal.c b/drivers/aiodev/imx_thermal.c
index 08532a7..f8b59c2 100644
--- a/drivers/aiodev/imx_thermal.c
+++ b/drivers/aiodev/imx_thermal.c
@@ -133,8 +133,6 @@ static int imx_thermal_probe(struct device_d *dev)
 		return -ENODEV;
 	}
 
-	printf("node = %p\n", node);
-
 	ocotp = cdev_by_device_node(node);
 	if (!ocotp) {
 		dev_err(dev, "No OCOTP character device\n");
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH v2 7/7] i.MX: ocotp: Register regmap against orignal device
  2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
                   ` (4 preceding siblings ...)
  2016-07-18 15:14 ` [PATCH v2 6/7] imx_thermal: Remove leftover debug output Andrey Smirnov
@ 2016-07-18 15:14 ` Andrey Smirnov
  2016-07-19  4:51 ` [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Andrey Smirnov @ 2016-07-18 15:14 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Register regmap against orignal device passed to probe, this way further
in the code/call-chain cdev's device_node will be correctly populated
and it will be discoverable via cdev_by_device_node()

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/ocotp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c
index 1dc9108..17b944b 100644
--- a/arch/arm/mach-imx/ocotp.c
+++ b/arch/arm/mach-imx/ocotp.c
@@ -404,7 +404,7 @@ static int imx_ocotp_probe(struct device_d *dev)
 	priv->map_config.reg_stride = 4;
 	priv->map_config.max_register = data->num_regs - 1;
 
-	priv->map = regmap_init(&priv->dev, &imx_ocotp_regmap_bus, priv, &priv->map_config);
+	priv->map = regmap_init(dev, &imx_ocotp_regmap_bus, priv, &priv->map_config);
 	if (IS_ERR(priv->map))
 		return PTR_ERR(priv->map);
 
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority"
  2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
                   ` (5 preceding siblings ...)
  2016-07-18 15:14 ` [PATCH v2 7/7] i.MX: ocotp: Register regmap against orignal device Andrey Smirnov
@ 2016-07-19  4:51 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-07-19  4:51 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Mon, Jul 18, 2016 at 08:14:43AM -0700, Andrey Smirnov wrote:
> Fixing the i.MX6 specific issue this way breaks things on CLPS711x
> target. Better fix for the problem is to follow this patch.
> 
> This reverts commit c203958f3bbf25fc3d612497057b962e96ad1c52.
> 
> Reported-by: Alexander Shiyan <shc_work@mail.ru>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---

Applied the first two patches to master and the rest for next.

Sascha

>  drivers/mfd/syscon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index ee62da0..9589a03 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -111,7 +111,7 @@ static int __init syscon_init(void)
>  {
>  	return platform_driver_register(&syscon_driver);
>  }
> -device_initcall(syscon_init);
> +core_initcall(syscon_init);
>  
>  MODULE_AUTHOR("Dong Aisheng <dong.aisheng@linaro.org>");
>  MODULE_DESCRIPTION("System Control driver");
> -- 
> 2.5.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2016-07-19  4:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 15:14 [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Andrey Smirnov
2016-07-18 15:14 ` [PATCH v2 2/7] mfd: syscon: Don't call request_iomem_region() Andrey Smirnov
2016-07-18 15:14 ` [PATCH v2 3/7] mfd: syscon: Decouple syscon interface from platform devices Andrey Smirnov
2016-07-18 15:14 ` [PATCH v2 4/7] mfd: syscon: Don't check xzalloc return for NULL Andrey Smirnov
2016-07-18 15:14 ` [PATCH v2 5/7] mfd: syscon: Use IOMEM instead of explicit cast Andrey Smirnov
2016-07-18 15:14 ` [PATCH v2 6/7] imx_thermal: Remove leftover debug output Andrey Smirnov
2016-07-18 15:14 ` [PATCH v2 7/7] i.MX: ocotp: Register regmap against orignal device Andrey Smirnov
2016-07-19  4:51 ` [PATCH v2 1/7] Revert "syscon: Decrease driver registration priority" Sascha Hauer

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