clk: uniphier: add clock drivers for UniPhier SoCs
Subsystems (6)
v6 cover clk: uniphier: add clock drivers for UniPhier SoCs
I split into two patches to make review easier.
1/2: core support code
2/2: data arrays
Changes in v6:
- Fix provided clock description a bit
Changes in v5:
- Assign each gating register bit with a separate clk
- Fix examples in binding document to add specific compatible
- Document provided clocks for system clock
Changes in v4:
- Unify module_platform_driver() boilerplate into a single place
- Add binding document
- Add USB3 clocks
Changes in v3:
- Change to platform drivers instead of OF_CLK_DECLARE
- Split into a core part + SoC drivers
SoC drivers just consist of tables of SoC-specific data. This allows reviewer to concentrate on the core-part
- Hard-code parent clock names for cascading
Changes in v2:
- split emmc_hw_reset
- make SD clock rate-controllable
- add CLK_SET_RATE_PARENT flag to mux, gate, fixed-factor clocks
Masahiro Yamada (2):
clk: uniphier: add core support code for UniPhier clock driver
clk: uniphier: add clock data for UniPhier SoCs
.../devicetree/bindings/clock/uniphier-clock.txt | 134 +++++++++++++ MAINTAINERS | 1 + drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/uniphier/Kconfig | 9 + drivers/clk/uniphier/Makefile | 9 + drivers/clk/uniphier/clk-uniphier-core.c | 215 +++++++++++++++++++++ drivers/clk/uniphier/clk-uniphier-fixed-factor.c | 49 +++++ drivers/clk/uniphier/clk-uniphier-fixed-rate.c | 48 +++++ drivers/clk/uniphier/clk-uniphier-gate.c | 97 ++++++++++ drivers/clk/uniphier/clk-uniphier-mio.c | 103 ++++++++++ drivers/clk/uniphier/clk-uniphier-mux.c | 95 +++++++++ drivers/clk/uniphier/clk-uniphier-peri.c | 59 ++++++ drivers/clk/uniphier/clk-uniphier-sys.c | 151 +++++++++++++++ drivers/clk/uniphier/clk-uniphier.h | 122 ++++++++++++ 15 files changed, 1094 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/uniphier-clock.txt create mode 100644 drivers/clk/uniphier/Kconfig create mode 100644 drivers/clk/uniphier/Makefile create mode 100644 drivers/clk/uniphier/clk-uniphier-core.c create mode 100644 drivers/clk/uniphier/clk-uniphier-fixed-factor.c create mode 100644 drivers/clk/uniphier/clk-uniphier-fixed-rate.c create mode 100644 drivers/clk/uniphier/clk-uniphier-gate.c create mode 100644 drivers/clk/uniphier/clk-uniphier-mio.c create mode 100644 drivers/clk/uniphier/clk-uniphier-mux.c create mode 100644 drivers/clk/uniphier/clk-uniphier-peri.c create mode 100644 drivers/clk/uniphier/clk-uniphier-sys.c create mode 100644 drivers/clk/uniphier/clk-uniphier.h
Signature · 1 line
1.9.1
PATCH v6 1/2 clk: uniphier: add core support code for UniPhier clock driver
This includes UniPhier clock driver code, except SoC-specific data arrays.
---
MAINTAINERS | 1 + drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/uniphier/Kconfig | 9 ++ drivers/clk/uniphier/Makefile | 6 ++ drivers/clk/uniphier/clk-uniphier-core.c | 124 +++++++++++++++++++++++ drivers/clk/uniphier/clk-uniphier-fixed-factor.c | 49 +++++++++ drivers/clk/uniphier/clk-uniphier-fixed-rate.c | 48 +++++++++ drivers/clk/uniphier/clk-uniphier-gate.c | 97 ++++++++++++++++++ drivers/clk/uniphier/clk-uniphier-mux.c | 95 +++++++++++++++++ drivers/clk/uniphier/clk-uniphier.h | 109 ++++++++++++++++++++ 11 files changed, 540 insertions(+) create mode 100644 drivers/clk/uniphier/Kconfig create mode 100644 drivers/clk/uniphier/Makefile create mode 100644 drivers/clk/uniphier/clk-uniphier-core.c create mode 100644 drivers/clk/uniphier/clk-uniphier-fixed-factor.c create mode 100644 drivers/clk/uniphier/clk-uniphier-fixed-rate.c create mode 100644 drivers/clk/uniphier/clk-uniphier-gate.c create mode 100644 drivers/clk/uniphier/clk-uniphier-mux.c create mode 100644 drivers/clk/uniphier/clk-uniphier.h
MAINTAINERS +1 -0
@@ -1821,6 +1821,7 @@ F: arch/arm/mach-uniphier/ F: arch/arm/mm/cache-uniphier.c F: arch/arm64/boot/dts/socionext/ F: drivers/bus/uniphier-system-bus.c +F: drivers/clk/uniphier/ F: drivers/i2c/busses/i2c-uniphier* F: drivers/mmc/host/uniphier-sd.c F: drivers/pinctrl/uniphier/
drivers/clk/Kconfig +1 -0
@@ -218,5 +218,6 @@ source "drivers/clk/samsung/Kconfig" source "drivers/clk/sunxi-ng/Kconfig" source "drivers/clk/tegra/Kconfig" source "drivers/clk/ti/Kconfig" +source "drivers/clk/uniphier/Kconfig" endmenu
drivers/clk/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_ARCH_SUNXI) += sunxi/ obj-$(CONFIG_ARCH_SUNXI) += sunxi-ng/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-y += ti/ +obj-$(CONFIG_CLK_UNIPHIER) += uniphier/ obj-$(CONFIG_ARCH_U8500) += ux500/ obj-$(CONFIG_COMMON_CLK_VERSATILE) += versatile/ obj-$(CONFIG_X86) += x86/
drivers/clk/uniphier/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config CLK_UNIPHIER + tristate "Clock driver for UniPhier SoCs" + depends on ARCH_UNIPHIER || COMPILE_TEST + depends on OF && MFD_SYSCON + default ARCH_UNIPHIER + help + Support for clock controllers on UniPhier SoCs. + Say Y if you want to control clocks provided by System Control + block, Media I/O block, Peripheral Block.
drivers/clk/uniphier/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +obj-$(CONFIG_CLK_UNIPHIER) += clk-uniphier.o +clk-uniphier-y += clk-uniphier-core.o +clk-uniphier-y += clk-uniphier-fixed-factor.o +clk-uniphier-y += clk-uniphier-fixed-rate.o +clk-uniphier-y += clk-uniphier-gate.o +clk-uniphier-y += clk-uniphier-mux.o
drivers/clk/uniphier/clk-uniphier-core.c new file +124 -0
124 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier-fixed-factor.c new file +49 -0
49 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier-fixed-rate.c new file +48 -0
48 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier-gate.c new file +97 -0
97 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier-mux.c new file +95 -0
95 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier.h new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Quoted 44 lines · Masahiro Yamada
drivers/clk/uniphier/clk-uniphier-core.c new file +38
-0@@ -0,0 +1,124 @@ +/* +* Copyright (C) 2016 Socionext Inc. +* Author: Masahiro Yamada <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/clk-provider.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +#include "clk-uniphier.h" + +static struct clk_hw *uniphier_clk_register (struct device *dev, +struct regmap *regmap, +const struct uniphier_clk_data *data) +{ +switch (data->type) { +case UNIPHIER_CLK_TYPE_FIXED_FACTOR : +return uniphier_clk_register_fixed_factor (dev, data->name, + &data->data.factor); +case UNIPHIER_CLK_TYPE_FIXED_RATE : +return uniphier_clk_register_fixed_rate (dev, data->name, + &data->data.rate); +case UNIPHIER_CLK_TYPE_GATE : +return uniphier_clk_register_gate (dev, regmap, data->name, + &data->data.gate); +case UNIPHIER_CLK_TYPE_MUX :
drivers/clk/uniphier/clk-uniphier-core.c line 48
Quoted 10 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +10
-0+return uniphier_clk_register_mux (dev, regmap, data->name, + &data->data.mux); +default : +dev_err (dev,"unsupported clock type\n" ); +return ERR_PTR (-EINVAL ); + } +} + +static const struct of_device_id uniphier_clk_match[] = { + {/* sentinel */ }
Looks funny but I guess we'll fill this in later so it's ok.
drivers/clk/uniphier/clk-uniphier-core.c line 52
Quoted 4 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +4
-0+}; +MODULE_DEVICE_TABLE (of, uniphier_clk_match); + +int uniphier_clk_probe (struct platform_device *pdev)
static?
drivers/clk/uniphier/clk-uniphier-core.c line 64
Quoted 12 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +12
-0+{ +struct device *dev = &pdev->dev; +const struct of_device_id *match; +struct clk_hw_onecell_data *hw_data; +struct device_node *parent; +struct regmap *regmap; +const struct uniphier_clk_data *p; +int clk_num =0 ; + + match =of_match_node (uniphier_clk_match, dev->of_node); +if (!match) +return -ENODEV ;
We can use of_driver_match_device() to make this simpler.
drivers/clk/uniphier/clk-uniphier-core.c line 68
Quoted 4 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +4
-0+ + parent =of_get_parent (dev->of_node);/* parent should be syscon node */ + regmap =syscon_node_to_regmap (parent); +of_node_put (parent);
devm_get_regmap(dev->parent) should work then? Why do we need to use OF APIs?
Quoted 27 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +27
-0+if (IS_ERR (regmap)) { +dev_err (dev,"failed to get regmap (error %ld)\n" , +PTR_ERR (regmap)); +return PTR_ERR (regmap); + } + +for (p = match->data; p->name; p++) + clk_num =max (clk_num, p->idx +1 ); + + hw_data =devm_kzalloc (dev, +sizeof (*hw_data) + clk_num *sizeof (struct clk_hw *), +GFP_KERNEL ); +if (!hw_data) +return -ENOMEM ; + + hw_data->num = clk_num; + +for (p = match->data; p->name; p++) { +struct clk_hw *hw; + +dev_dbg (dev,"register %s (index=%d)\n" , p->name, p->idx); + hw =uniphier_clk_register (dev, regmap, p); +if (IS_ERR (hw)) { +dev_err (dev,"failed to register %s (error %ld)\n" , + p->name,PTR_ERR (hw)); +return PTR_ERR (hw); + }
drivers/clk/uniphier/clk-uniphier-core.c line 105
Quoted 10 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +10
-0+ +if (p->idx >=0 ) + hw_data->hws[p->idx] = hw; + } + +return of_clk_add_hw_provider (dev->of_node, of_clk_hw_onecell_get, + hw_data); +} + +int uniphier_clk_remove (struct platform_device *pdev)
static?
Quoted 37 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +5
-0+{ +of_clk_del_provider (pdev->dev.of_node); + +return 0 ; +}drivers/clk/uniphier/clk-uniphier-fixed-factor.c new file +26
-0@@ -0,0 +1,49 @@ +/* +* Copyright (C) 2016 Socionext Inc. +* Author: Masahiro Yamada <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/clk-provider.h> +#include <linux/device.h> + +#include "clk-uniphier.h" + +struct clk_hw *uniphier_clk_register_fixed_factor (struct device *dev, +const char *name, +const struct uniphier_clk_fixed_factor_data *data) +{ +struct clk_fixed_factor *fix; +struct clk_init_data init;
drivers/clk/uniphier/clk-uniphier-fixed-factor.c line 36
Quoted 10 lines
drivers/clk/uniphier/clk-uniphier-fixed-factor.c new file +10
-0+int ret; + + fix =devm_kzalloc (dev,sizeof (*fix),GFP_KERNEL ); +if (!fix) +return ERR_PTR (-ENOMEM ); + + init.name = name; + init.ops = &clk_fixed_factor_ops; + init.flags = data->parent_name ?CLK_SET_RATE_PARENT :0 ; + init.flags |=CLK_IS_BASIC ;
Please don't use CLK_IS_BASIC unless you need it. So far we've kept it to OMAP and I'm hoping to delete it.
Quoted 13 lines
drivers/clk/uniphier/clk-uniphier-fixed-factor.c new file +13
-0+ init.parent_names = data->parent_name ? &data->parent_name :NULL ; + init.num_parents = data->parent_name ?1 :0 ; + + fix->mult = data->mult; + fix->div = data->div; + fix->hw.init = &init; + + ret =devm_clk_hw_register (dev, &fix->hw); +if (ret) +return ERR_PTR (ret); + +return &fix->hw; +}
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Hi Stephen,
2016-08-19 9:25 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 3 lines
Quoted 1 line
+int
uniphier_clk_probe(struct platform_device *pdev)static?
Thanks.
Will fix in v7.
Quoted 6 lines
Quoted 6 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +6
-0+{ +struct device *dev = &pdev->dev; +const struct of_device_id *match; +struct clk_hw_onecell_data *hw_data; +struct device_node *parent; +struct regmap *regmap;
Quoted 8 lines
drivers/clk/uniphier/clk-uniphier-core.c line 64
Quoted 6 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +6
-0+const struct uniphier_clk_data *p; +int clk_num =0 ; + + match =of_match_node (uniphier_clk_match, dev->of_node); +if (!match) +return -ENODEV ;We can use
of_driver_match_device()to make this simpler.
I want to use the returned "match".
The of_driver_match_device() just checks if it matches or not, so I do not think it can be the replacement.
I can use of_match_device() instead, if you like.
Quoted 7 lines
drivers/clk/uniphier/clk-uniphier-core.c line 68
Quoted 4 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +4
-0+ + parent =of_get_parent (dev->of_node);/* parent should be syscon node */ + regmap =syscon_node_to_regmap (parent); +of_node_put (parent);
devm_get_regmap(dev->parent)should work then? Why do we need to use OF APIs?
"git grep devm_get_regmap" did not hit anything.
Where is it defined?
Quoted 7 lines
drivers/clk/uniphier/clk-uniphier-fixed-factor.c line 36
Quoted 4 lines
drivers/clk/uniphier/clk-uniphier-fixed-factor.c new file +4
-0+ init.name = name; + init.ops = &clk_fixed_factor_ops; + init.flags = data->parent_name ?CLK_SET_RATE_PARENT :0 ; + init.flags |=CLK_IS_BASIC ;Please don't use
CLK_IS_BASICunless you need it. So far we've kept it to OMAP and I'm hoping to delete it.
Will do in v7.
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Quoted 17 lines · Masahiro Yamada
2016-08-19 9:25 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 6 lines
Quoted 6 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +6
-0+{ +struct device *dev = &pdev->dev; +const struct of_device_id *match; +struct clk_hw_onecell_data *hw_data; +struct device_node *parent; +struct regmap *regmap;Quoted 8 lines
drivers/clk/uniphier/clk-uniphier-core.c line 64
Quoted 6 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +6
-0+const struct uniphier_clk_data *p; +int clk_num =0 ; + + match =of_match_node (uniphier_clk_match, dev->of_node); +if (!match) +return -ENODEV ;We can use
of_driver_match_device()to make this simpler.
Quoted 5 lines
I want to use the returned "match".
Theof_driver_match_device()just checks if it matches or not, so I do not think it can be the replacement.I can use
of_match_device()instead, if you like.
Sorry I meant of_device_get_match_data().
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +4
-0+ + parent =of_get_parent (dev->of_node);/* parent should be syscon node */ + regmap =syscon_node_to_regmap (parent); +of_node_put (parent);
Quoted 7 lines
Quoted 2 lines
devm_get_regmap(dev->parent)should work then? Why do we need to use OF APIs?"git grep
devm_get_regmap" did not hit anything.Where is it defined?
Sorry I meant dev_get_regmap().
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Hi Stephen,
2016-08-20 4:16 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/clk/uniphier/clk-uniphier-core.c line 68
Quoted 5 lines
drivers/clk/uniphier/clk-uniphier-core.c new file +4
-0+ + parent =of_get_parent (dev->of_node);/* parent should be syscon node */ + regmap =syscon_node_to_regmap (parent); +of_node_put (parent);
devm_get_regmap(dev->parent)should work then? Why do we need to use OF APIs?
Quoted 7 lines
Quoted 4 lines
"git grep
devm_get_regmap" did not hit anything.Where is it defined?
Sorry I meant
dev_get_regmap().
I tried this, but it did not work.
To make dev_get_regmap() work,
the parent device needs to call dev_regmap_init_mmio() beforehand.
Since commit bdb0066df96e74a4002125467ebe459feff1ebef (mfd: syscon: Decouple syscon interface from platform devices), syscon_probe() is not called for platform devices,
so that never happens.
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Quoted 23 lines · Masahiro Yamada
Hi Stephen,
2016-08-20 4:16 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+ + parent = of_get_parent(dev->of_node); /* parent should be syscon node */ + regmap = syscon_node_to_regmap(parent); + of_node_put(parent);
devm_get_regmap(dev->parent)should work then? Why do we need to use OF APIs?Quoted 7 lines
Quoted 4 lines
"git grep
devm_get_regmap" did not hit anything.Where is it defined?
Sorry I meant
dev_get_regmap().I tried this, but it did not work.
Quoted 9 lines
To make
dev_get_regmap()work,
the parent device needs to calldev_regmap_init_mmio()beforehand.Since commit
bdb0066df96e74a4002125467ebe459feff1ebef(mfd: syscon: Decouple syscon interface from platform devices),syscon_probe()is not called for platform devices,
so that never happens.
Ok. Is the syscon also a simple-mfd?
It sounds like there's a device for the parent, but we've failed to attach a regmap to it. Maybe the core DT code should assign the regmap to the parent device when it creates it so that child devices don't need to know this detail? It could look for simple-mfd devices with compatible = "syscon" and then create the regmap? Here's a totally untested patch for that.
----8<----
drivers/mfd/syscon.c +11 -0
@@ -136,6 +136,17 @@ struct regmap *syscon_node_to_regmap(struct device_node *np) }EXPORT_SYMBOL_GPL (syscon_node_to_regmap); +int device_attach_syscon (struct device *dev) +{ +struct regmap *regmap; + + regmap =syscon_node_to_regmap (dev->of_node); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +return regmap_attach_dev (dev, regmap, &syscon_regmap_config); +} +struct regmap *syscon_regmap_lookup_by_compatible (const char *s) {struct device_node *syscon_np;
drivers/of/platform.c +6 -0
@@ -25,6 +25,7 @@#include <linux/of_irq.h> #include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/mfd/syscon.h> const struct of_device_id of_default_bus_match_table[] = { { .compatible ="simple-bus" , },
@@ -383,7 +384,12 @@ static int of_platform_bus_create(struct device_node *bus,return 0 ; } + dev =of_platform_device_create_pdata (bus, bus_id, platform_data, parent); +if (of_device_is_compatible (bus,"simple-mfd" ) && +of_device_is_compatible (bus,"syscon" )) +device_attach_syscon (&dev->dev); +if (!dev || !of_match_node (matches, bus))return 0 ;
include/linux/mfd/syscon.h +7 -0
@@ -18,9 +18,11 @@#include <linux/err.h> #include <linux/errno.h> +struct device ;struct device_node ;#ifdef CONFIG_MFD_SYSCON +extern int device_attach_syscon (struct device *dev);extern struct regmap *syscon_node_to_regmap (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);
@@ -28,6 +30,11 @@ extern struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np, const char *property);#else +static inline int device_attach_syscon (struct device *dev) +{ +return 0 ; +} +static inline struct regmap *syscon_node_to_regmap (struct device_node *np) {return ERR_PTR (-ENOTSUPP );
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Hi Stephen,
2016-08-30 3:22 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 109 lines · Masahiro Yamada
Quoted 23 lines
Hi Stephen,
2016-08-20 4:16 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+ + parent = of_get_parent(dev->of_node); /* parent should be syscon node */ + regmap = syscon_node_to_regmap(parent); + of_node_put(parent);
devm_get_regmap(dev->parent)should work then? Why do we need to use OF APIs?Quoted 7 lines
Quoted 4 lines
"git grep
devm_get_regmap" did not hit anything.Where is it defined?
Sorry I meant
dev_get_regmap().I tried this, but it did not work.
Quoted 9 lines
To make
dev_get_regmap()work,
the parent device needs to calldev_regmap_init_mmio()beforehand.Since commit
bdb0066df96e74a4002125467ebe459feff1ebef(mfd: syscon: Decouple syscon interface from platform devices),syscon_probe()is not called for platform devices,
so that never happens.Ok. Is the syscon also a simple-mfd?
It sounds like there's a device for the parent, but we've failed to attach a regmap to it. Maybe the core DT code should assign the regmap to the parent device when it creates it so that child devices don't need to know this detail? It could look for simple-mfd devices with compatible = "syscon" and then create the regmap? Here's a totally untested patch for that.
----8<----
drivers/mfd/syscon.c +11
-0@@ -136,6 +136,17 @@ struct regmap *syscon_node_to_regmap(struct device_node *np) }EXPORT_SYMBOL_GPL (syscon_node_to_regmap); +int device_attach_syscon (struct device *dev) +{ +struct regmap *regmap; + + regmap =syscon_node_to_regmap (dev->of_node); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +return regmap_attach_dev (dev, regmap, &syscon_regmap_config); +} +struct regmap *syscon_regmap_lookup_by_compatible (const char *s) {struct device_node *syscon_np;drivers/of/platform.c +6
-0@@ -25,6 +25,7 @@#include <linux/of_irq.h> #include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/mfd/syscon.h> const struct of_device_id of_default_bus_match_table[] = { { .compatible ="simple-bus" , },@@ -383,7 +384,12 @@ static int of_platform_bus_create(struct device_node *bus,return 0 ; } + dev =of_platform_device_create_pdata (bus, bus_id, platform_data, parent); +if (of_device_is_compatible (bus,"simple-mfd" ) && +of_device_is_compatible (bus,"syscon" )) +device_attach_syscon (&dev->dev); +if (!dev || !of_match_node (matches, bus))return 0 ;include/linux/mfd/syscon.h +2
-0@@ -18,9 +18,11 @@#include <linux/err.h> #include <linux/errno.h> +struct device ;struct device_node ;#ifdef CONFIG_MFD_SYSCON +extern int device_attach_syscon (struct device *dev);extern struct regmap *syscon_node_to_regmap (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);@@ -28,6 +30,11 @@ extern struct regmap *syscon_regmap_lookup_by_phandle( struct device_node *np,
include/linux/mfd/syscon.h extern struct regmap *syscon_regmap_lookup_by_phandle( · line 40
Quoted 10 lines
include/linux/mfd/syscon.h +5
-0const char *property);#else +static inline int device_attach_syscon (struct device *dev) +{ +return 0 ; +} +static inline struct regmap *syscon_node_to_regmap (struct device_node *np) {return ERR_PTR (-ENOTSUPP );
I was not quire sure about this,
but maybe worth submitting to DT subsystem?
Anyway, I will go with syscon_node_to_regmap() for v7. Of course, I am happy to replace it with dev_get_regmap() when the issue is solved in the mainline.
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Quoted 25 lines · Masahiro Yamada
2016-08-30 3:22 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 13 lines · Masahiro Yamada
Quoted 11 lines
I tried this, but it did not work.
To make
dev_get_regmap()work,
the parent device needs to calldev_regmap_init_mmio()beforehand.Since commit
bdb0066df96e74a4002125467ebe459feff1ebef(mfd: syscon: Decouple syscon interface from platform devices),syscon_probe()is not called for platform devices,
so that never happens.Quoted 9 lines
Ok. Is the syscon also a simple-mfd?
It sounds like there's a device for the parent, but we've failed to attach a regmap to it. Maybe the core DT code should assign the regmap to the parent device when it creates it so that child devices don't need to know this detail? It could look for simple-mfd devices with compatible = "syscon" and then create the regmap? Here's a totally untested patch for that.
Quoted 7 lines
I was not quire sure about this,
but maybe worth submitting to DT subsystem?Anyway, I will go with
syscon_node_to_regmap()for v7. Of course, I am happy to replace it withdev_get_regmap()when the issue is solved in the mainline.
Ok that's fine. Did my patch fix dev_get_regmap() for you though? That would be useful to know so that this patch can be merged in parallel to yours.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v6 1/2] clk: uniphier: add core support code for UniPhier clock driver
Hi Stephen,
2016-09-07 9:32 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 29 lines · Masahiro Yamada
Quoted 28 lines
2016-08-30 3:22 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 13 lines · Masahiro Yamada
Quoted 11 lines
I tried this, but it did not work.
To make
dev_get_regmap()work,
the parent device needs to calldev_regmap_init_mmio()beforehand.Since commit
bdb0066df96e74a4002125467ebe459feff1ebef(mfd: syscon: Decouple syscon interface from platform devices),syscon_probe()is not called for platform devices,
so that never happens.Quoted 9 lines
Ok. Is the syscon also a simple-mfd?
It sounds like there's a device for the parent, but we've failed to attach a regmap to it. Maybe the core DT code should assign the regmap to the parent device when it creates it so that child devices don't need to know this detail? It could look for simple-mfd devices with compatible = "syscon" and then create the regmap? Here's a totally untested patch for that.
I was not quire sure about this,
but maybe worth submitting to DT subsystem?
Quoted 8 lines
Quoted 4 lines
Anyway, I will go with
syscon_node_to_regmap()for v7. Of course, I am happy to replace it withdev_get_regmap()when the issue is solved in the mainline.Ok that's fine. Did my patch fix
dev_get_regmap()for you though? That would be useful to know so that this patch can be merged in parallel to yours.
Sorry for my late reply.
Yup, your patch worked fine!
And, I've posted v7 for my SoC clk driver.
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v6 2/2 clk: uniphier: add clock data for UniPhier SoCs
In reply to Masahiro YamadaAdd clock data arrays for all UniPhier SoCs.
---
.../devicetree/bindings/clock/uniphier-clock.txt | 134 ++++++++++++++++++ drivers/clk/uniphier/Makefile | 3 + drivers/clk/uniphier/clk-uniphier-core.c | 91 +++++++++++++ drivers/clk/uniphier/clk-uniphier-mio.c | 103 ++++++++++++++ drivers/clk/uniphier/clk-uniphier-peri.c | 59 ++++++++ drivers/clk/uniphier/clk-uniphier-sys.c | 151 +++++++++++++++++++++ drivers/clk/uniphier/clk-uniphier.h | 13 ++ 7 files changed, 554 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/uniphier-clock.txt create mode 100644 drivers/clk/uniphier/clk-uniphier-mio.c create mode 100644 drivers/clk/uniphier/clk-uniphier-peri.c create mode 100644 drivers/clk/uniphier/clk-uniphier-sys.c
Documentation/devicetree/bindings/clock/uniphier-clock.txt new file +134 -0
@@ -0,0 +1,134 @@ +UniPhier clock controller + + +System clock +------------ + +Required properties: +- compatible: should be one of the following: + "socionext,uniphier-sld3-clock" - for PH1-sLD3 SoC. + "socionext,uniphier-ld4-clock" - for PH1-LD4 SoC. + "socionext,uniphier-pro4-clock" - for PH1-Pro4 SoC. + "socionext,uniphier-sld8-clock" - for PH1-sLD8 SoC. + "socionext,uniphier-pro5-clock" - for PH1-Pro5 SoC. + "socionext,uniphier-pxs2-clock" - for ProXstream2/PH1-LD6b SoC. + "socionext,uniphier-ld11-clock" - for PH1-LD11 SoC. + "socionext,uniphier-ld20-clock" - for PH1-LD20 SoC. +- #clock-cells: should be 1. + +Example: + + sysctrl@61840000 { + compatible = "socionext,uniphier-ld20-sysctrl", + "simple-mfd", "syscon"; + reg = <0x61840000 0x4000>; + + clock { + compatible = "socionext,uniphier-ld20-clock"; + #clock-cells = <1>; + }; + + other nodes ... + }; + +Provided clocks: + + 8: ST DMAC +12: GIO (Giga bit stream I/O) +14: USB3 ch0 host +15: USB3 ch1 host +16: USB3 ch0 PHY0 +17: USB3 ch0 PHY1 +20: USB3 ch1 PHY0 +21: USB3 ch1 PHY1 + + +Media I/O (MIO) clock +--------------------- + +Required properties: +- compatible: should be one of the following: + "socionext,uniphier-sld3-mio-clock" - for PH1-sLD3 SoC. + "socionext,uniphier-ld4-mio-clock" - for PH1-LD4 SoC. + "socionext,uniphier-pro4-mio-clock" - for PH1-Pro4 SoC. + "socionext,uniphier-sld8-mio-clock" - for PH1-sLD8 SoC. + "socionext,uniphier-pro5-mio-clock" - for PH1-Pro5 SoC. + "socionext,uniphier-pxs2-mio-clock" - for ProXstream2/PH1-LD6b SoC. + "socionext,uniphier-ld11-mio-clock" - for PH1-LD11 SoC. + "socionext,uniphier-ld20-mio-clock" - for PH1-LD20 SoC. +- #clock-cells: should be 1. + +Example: + + mioctrl@59810000 { + compatible = "socionext,uniphier-ld20-mioctrl", + "simple-mfd", "syscon"; + reg = <0x59810000 0x800>; + + clock { + compatible = "socionext,uniphier-ld20-mio-clock"; + #clock-cells = <1>; + }; + + other nodes ... + }; + +Provided clocks: + + 0: SD ch0 host + 1: eMMC host + 2: SD ch1 host + 7: MIO DMAC + 8: USB2 ch0 host + 9: USB2 ch1 host +10: USB2 ch2 host +11: USB2 ch3 host +12: USB2 ch0 PHY +13: USB2 ch1 PHY +14: USB2 ch2 PHY +15: USB2 ch3 PHY + + +Peripheral clock +---------------- + +Required properties: +- compatible: should be one of the following: + "socionext,uniphier-sld3-peri-clock" - for PH1-sLD3 SoC. + "socionext,uniphier-ld4-peri-clock" - for PH1-LD4 SoC. + "socionext,uniphier-pro4-peri-clock" - for PH1-Pro4 SoC. + "socionext,uniphier-sld8-peri-clock" - for PH1-sLD8 SoC. + "socionext,uniphier-pro5-peri-clock" - for PH1-Pro5 SoC. + "socionext,uniphier-pxs2-peri-clock" - for ProXstream2/PH1-LD6b SoC. + "socionext,uniphier-ld11-peri-clock" - for PH1-LD11 SoC. + "socionext,uniphier-ld20-peri-clock" - for PH1-LD20 SoC. +- #clock-cells: should be 1. + +Example: + + perictrl@59820000 { + compatible = "socionext,uniphier-ld20-perictrl", + "simple-mfd", "syscon"; + reg = <0x59820000 0x200>; + + clock { + compatible = "socionext,uniphier-ld20-peri-clock"; + #clock-cells = <1>; + }; + + other nodes ... + }; + +Provided clocks: + + 0: UART ch0 + 1: UART ch1 + 2: UART ch2 + 3: UART ch3 + 4: I2C ch0 + 5: I2C ch1 + 6: I2C ch2 + 7: I2C ch3 + 8: I2C ch4 + 9: I2C ch5 +10: I2C ch6
drivers/clk/uniphier/Makefile +3 -0
@@ -4,3 +4,6 @@ clk-uniphier-y += clk-uniphier-fixed-factor.o clk-uniphier-y += clk-uniphier-fixed-rate.o clk-uniphier-y += clk-uniphier-gate.o clk-uniphier-y += clk-uniphier-mux.o +clk-uniphier-y += clk-uniphier-sys.o +clk-uniphier-y += clk-uniphier-mio.o +clk-uniphier-y += clk-uniphier-peri.o
drivers/clk/uniphier/clk-uniphier-core.c +91 -0
97 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier-mio.c new file +103 -0
103 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier-peri.c new file +59 -0
59 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier-sys.c new file +151 -0
151 lines not on this page · raw message
drivers/clk/uniphier/clk-uniphier.h +13 -0
@@ -106,4 +106,17 @@ struct clk_hw *uniphier_clk_register_mux(struct device *dev,const char *name, const struct uniphier_clk_mux_data *data); +extern const struct uniphier_clk_data uniphier_sld3_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_ld4_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_pro4_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_sld8_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_pro5_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_ld11_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data[]; +extern const struct uniphier_clk_data uniphier_sld3_mio_clk_data[]; +extern const struct uniphier_clk_data uniphier_pro5_mio_clk_data[]; +extern const struct uniphier_clk_data uniphier_ld4_peri_clk_data[]; +extern const struct uniphier_clk_data uniphier_pro4_peri_clk_data[]; +#endif /* __CLK_UNIPHIER_H__ */
Signature · 1 line
1.9.1
Re: [PATCH v6 2/2] clk: uniphier: add clock data for UniPhier SoCs
Quoted 27 lines · Masahiro Yamada
Documentation/devicetree/bindings/clock/uniphier-clock.txt new file +21
-0@@ -0,0 +1,134 @@ +UniPhier clock controller + + +System clock +------------ + +Required properties: +- compatible: should be one of the following: + "socionext,uniphier-sld3-clock" - for PH1-sLD3 SoC. + "socionext,uniphier-ld4-clock" - for PH1-LD4 SoC. + "socionext,uniphier-pro4-clock" - for PH1-Pro4 SoC. + "socionext,uniphier-sld8-clock" - for PH1-sLD8 SoC. + "socionext,uniphier-pro5-clock" - for PH1-Pro5 SoC. + "socionext,uniphier-pxs2-clock" - for ProXstream2/PH1-LD6b SoC. + "socionext,uniphier-ld11-clock" - for PH1-LD11 SoC. + "socionext,uniphier-ld20-clock" - for PH1-LD20 SoC. +- #clock-cells: should be 1. + +Example: + + sysctrl at 61840000 {
Documentation/devicetree/bindings/clock/uniphier-clock.txt line 31
Quoted 10 lines
Documentation/devicetree/bindings/clock/uniphier-clock.txt new file +10
-0+ compatible = "socionext,uniphier-ld20-sysctrl", + "simple-mfd", "syscon"; + reg = <0x61840000 0x4000>; + + clock { + compatible = "socionext,uniphier-ld20-clock"; + #clock-cells = <1>; + }; + + other nodes ...
What are the other nodes? Is there a document for the rest of the MFD?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v6 2/2] clk: uniphier: add clock data for UniPhier SoCs
Hi Stephen,
2016-08-19 9:28 GMT+09:00 Stephen Boyd <[email protected]>:
Quoted 25 lines
Quoted 25 lines
Documentation/devicetree/bindings/clock/uniphier-clock.txt new file +25
-0+ + +System clock +------------ + +Required properties: +- compatible: should be one of the following: + "socionext,uniphier-sld3-clock" - for PH1-sLD3 SoC. + "socionext,uniphier-ld4-clock" - for PH1-LD4 SoC. + "socionext,uniphier-pro4-clock" - for PH1-Pro4 SoC. + "socionext,uniphier-sld8-clock" - for PH1-sLD8 SoC. + "socionext,uniphier-pro5-clock" - for PH1-Pro5 SoC. + "socionext,uniphier-pxs2-clock" - for ProXstream2/PH1-LD6b SoC. + "socionext,uniphier-ld11-clock" - for PH1-LD11 SoC. + "socionext,uniphier-ld20-clock" - for PH1-LD20 SoC. +- #clock-cells: should be 1. + +Example: + + sysctrl at 61840000 { + compatible = "socionext,uniphier-ld20-sysctrl", + "simple-mfd", "syscon"; + reg = <0x61840000 0x4000>; + + clock {
Quoted 8 lines
Documentation/devicetree/bindings/clock/uniphier-clock.txt line 31
Quoted 5 lines
Documentation/devicetree/bindings/clock/uniphier-clock.txt new file +5
-0+ compatible = "socionext,uniphier-ld20-clock"; + #clock-cells = <1>; + }; + + other nodes ...What are the other nodes? Is there a document for the rest of the MFD?
At lease there are "clock" and "reset" in this MFD at this point. Perhaps, I may want to add more in the future.
That's why I do not want to list all of the sibling nodes.
The reset node is documented in its binding document, added by the following patch:
https://patchwork.kernel.org/patch/9255101/
Signature · 2 lines
Best Regards Masahiro Yamada