lkml.org 
[lkml]   [2015]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mfd: syscon: fix syscon probing from dt
Hi Philipp,

On Wednesday 07 January 2015 04:27 PM, Philipp Zabel wrote:
> Am Dienstag, den 06.01.2015, 20:36 +0100 schrieb Arnd Bergmann:
>> On Tuesday 06 January 2015 16:30:36 Philipp Zabel wrote:
>>> Patch bdb0066df96e ("mfd: syscon: Decouple syscon interface from platform devices")
>>> breaks probing pure syscon devices from device tree, such as anatop and
>>> iomuxc-gpr on i.MX. This patch adds back the dt id table to match against
>>> "syscon" compatible device tree nodes.
>>>
>>> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
>>>
>>
>> I don't understand it. Why is this required?
>
> The debugfs entries vanished and I'd like to have a device to register
> platform device children to.

Yes debugfs entries will not be present for syscon, this is as per
discussion happened here [1]. At that time one suggestion came from Arnd
that we can have a different representation for syscon regmaps, instead
of based on devices just based on of_node pointer.

1: https://lkml.org/lkml/2014/9/26/73

I was just thinking, missing debugfs entry is your concern, or you want
to make child devices of syscon devices? Basically I am still trying to
understand your requirement.

I guess for i.MX iomuxc it could be argued
> that the iomuxc-gpr syscon should be merged into the iomuxc pinctrl
> device instead of probing iomuxc-gpr as a platform device by itself.
> How about allowing to register a syscon for a given device:
>
> ----8<----
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index d2280d6..2633b27 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -42,13 +42,14 @@ static struct regmap_config syscon_regmap_config = {
> .reg_stride = 4,
> };
>
> -static struct syscon *of_syscon_register(struct device_node *np)
> +struct syscon *syscon_register(struct device *dev, struct device_node *np)
> {
> struct syscon *syscon;
> struct regmap *regmap;
> void __iomem *base;
> int ret;
> struct regmap_config syscon_config = syscon_regmap_config;
> + struct resource res;
>
> if (!of_device_is_compatible(np, "syscon"))
> return ERR_PTR(-EINVAL);
> @@ -57,7 +58,12 @@ static struct syscon *of_syscon_register(struct device_node *np)
> if (!syscon)
> return ERR_PTR(-ENOMEM);
>
> - base = of_iomap(np, 0);
> + if (of_address_to_resource(np, 0, &res)) {
> + ret = -ENOMEM;
> + goto err_map;
> + }
> +
> + base = ioremap(res.start, resource_size(&res));
> if (!base) {
> ret = -ENOMEM;
> goto err_map;
> @@ -69,7 +75,8 @@ static struct syscon *of_syscon_register(struct device_node *np)
> else if (of_property_read_bool(np, "little-endian"))
> syscon_config.val_format_endian = REGMAP_ENDIAN_LITTLE;
>
> - regmap = regmap_init_mmio(NULL, base, &syscon_config);
> + syscon_regmap_config.max_register = res.end - res.start - 3;
> + regmap = regmap_init_mmio(dev, base, &syscon_config);
> if (IS_ERR(regmap)) {
> pr_err("regmap init failed\n");
> ret = PTR_ERR(regmap);
> @@ -91,6 +98,12 @@ err_map:
> kfree(syscon);
> return ERR_PTR(ret);
> }
> +EXPORT_SYMBOL_GPL(syscon_register);
> +

In past a similar approach [2] for letting device driver to register
themselves as syscon provided, has been rejected giving reason that
syscon should not need it's own platform device.

2:
https://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35744.html


Thanks,
Pankaj Dubey
> +static struct syscon *of_syscon_register(struct device_node *np)
> +{
> + return syscon_register(NULL, np);
> +}
>
> struct regmap *syscon_node_to_regmap(struct device_node *np)
> {
> diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
> index 75e543b..e0c4a86 100644
> --- a/include/linux/mfd/syscon.h
> +++ b/include/linux/mfd/syscon.h
> @@ -17,10 +17,14 @@
>
> #include <linux/err.h>
>
> +struct device;
> struct device_node;
> +struct syscon;
>
> #ifdef CONFIG_MFD_SYSCON
> extern struct regmap *syscon_node_to_regmap(struct device_node *np);
> +extern struct syscon *syscon_register(struct device *dev,
> + struct device_node *np);
> extern struct regmap *syscon_regmap_lookup_by_compatible(const char *s);
> extern struct regmap *syscon_regmap_lookup_by_pdevname(const char *s);
> extern struct regmap *syscon_regmap_lookup_by_phandle(
> @@ -32,6 +36,12 @@ static inline struct regmap *syscon_node_to_regmap(struct device_node *np)
> return ERR_PTR(-ENOSYS);
> }
>
> +static struct syscon *syscon_register(struct device *dev,
> + struct device_node *np)
> +{
> + return ERR_PTR(-ENOSYS);
> +}
> +
> static inline struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
> {
> return ERR_PTR(-ENOSYS);
> --
> ---->8----
>
> That way the syscon could be registered from iomuxc (pinctrl-imx6q):
>
> ----8<----
> diff --git a/drivers/pinctrl/freescale/pinctrl-imx6q.c b/drivers/pinctrl/freescale/pinctrl-imx6q.c
> index 4d1fcb8..74a68ec 100644
> --- a/drivers/pinctrl/freescale/pinctrl-imx6q.c
> +++ b/drivers/pinctrl/freescale/pinctrl-imx6q.c
> @@ -15,6 +15,7 @@
> #include <linux/err.h>
> #include <linux/init.h>
> #include <linux/io.h>
> +#include <linux/mfd/syscon.h>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> @@ -473,6 +474,12 @@ static const struct of_device_id imx6q_pinctrl_of_match[] = {
>
> static int imx6q_pinctrl_probe(struct platform_device *pdev)
> {
> + struct device_node *syscon_np;
> +
> + syscon_np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-iomuxc-gpr");
> + if (syscon_np)
> + syscon_register(&pdev->dev, syscon_np);
> +
> return imx_pinctrl_probe(pdev, &imx6q_pinctrl_info);
> }
>
> ---->8----
>
> which makes the regmap debugfs entry return
> as /sys/kernel/debug/regmap/20e0000.iomuxc
> and allows to register children to the iomuxc-gpr node.
>
> regards
> Philipp
>
>


\
 
 \ /
  Last update: 2015-01-07 12:41    [W:1.219 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site