Message ID | 20200213141119.66462-2-linus.walleij@linaro.org (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | [1/2] dt-bindings: clock: Create YAML schema for ICST clocks | expand |
Quoting Linus Walleij (2020-02-13 06:11:19) > diff --git a/drivers/clk/versatile/clk-impd1.c b/drivers/clk/versatile/clk-impd1.c > index 1991f15a5db9..96b1018bcb7a 100644 > --- a/drivers/clk/versatile/clk-impd1.c > +++ b/drivers/clk/versatile/clk-impd1.c > @@ -175,3 +177,69 @@ void integrator_impd1_clk_exit(unsigned int id) > kfree(imc->pclkname); > } > EXPORT_SYMBOL_GPL(integrator_impd1_clk_exit); > + > +static void __init integrator_impd1_clk_spawn(struct device *dev, Remove __init. Kinda surprised that compile didn't complain about that. > + void __iomem *base, > + struct device_node *np) > +{ > + struct clk *clk = ERR_PTR(-EINVAL); > + const char *clk_name = np->name; > + const char *parent_name; > + const struct clk_icst_desc *desc; > + > + if (of_device_is_compatible(np, "arm,impd1-vco1")) { > + dev_info(dev, "register VCO1\n"); > + desc = &impd1_icst1_desc; > + } else if (of_device_is_compatible(np, "arm,impd1-vco2")) { > + dev_info(dev, "register VCO2\n"); Do we need these dev_infos()? > + desc = &impd1_icst2_desc; > + } else { > + dev_err(dev, "not a clock node %s\n", np->name); > + return; > + } > + > + of_property_read_string(np, "clock-output-names", &clk_name); Can you use the new way of specifying parents so that this can be parsed by the core framework? > + > + parent_name = of_clk_get_parent_name(np, 0); > + clk = icst_clk_register(NULL, desc, clk_name, parent_name, base); > + if (!IS_ERR(clk)) > + of_clk_add_provider(np, of_clk_src_simple_get, clk); Can you add a hw provider? Maybe in a followup patch? > +} > + > +static int integrator_impd1_clk_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct device_node *np = dev->of_node; > + struct device_node *child; > + void __iomem *base; > + > + base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(base)) { > + dev_err(dev, "unable to remap syscon base\n"); > + return PTR_ERR(base); > + } > + dev_info(dev, "located syscon base\n"); More debug? > + > + for_each_available_child_of_node(np, child) > + integrator_impd1_clk_spawn(dev, base, child); > + > + return 0; > +} > + > +static const struct of_device_id impd1_syscon_match[] = { > + { .compatible = "arm,im-pd1-syscon", }, > + {} > +}; > + Add a module device table? > +static struct platform_driver impd1_clk_driver = { > + .driver = { > + .name = "impd1-clk", > + .of_match_table = impd1_syscon_match, > + }, > + .probe = integrator_impd1_clk_probe, > +}; > +builtin_platform_driver(impd1_clk_driver); > +
diff --git a/drivers/clk/versatile/clk-impd1.c b/drivers/clk/versatile/clk-impd1.c index 1991f15a5db9..96b1018bcb7a 100644 --- a/drivers/clk/versatile/clk-impd1.c +++ b/drivers/clk/versatile/clk-impd1.c @@ -7,7 +7,9 @@ #include <linux/clkdev.h> #include <linux/err.h> #include <linux/io.h> +#include <linux/platform_device.h> #include <linux/platform_data/clk-integrator.h> +#include <linux/module.h> #include "icst.h" #include "clk-icst.h" @@ -175,3 +177,69 @@ void integrator_impd1_clk_exit(unsigned int id) kfree(imc->pclkname); } EXPORT_SYMBOL_GPL(integrator_impd1_clk_exit); + +static void __init integrator_impd1_clk_spawn(struct device *dev, + void __iomem *base, + struct device_node *np) +{ + struct clk *clk = ERR_PTR(-EINVAL); + const char *clk_name = np->name; + const char *parent_name; + const struct clk_icst_desc *desc; + + if (of_device_is_compatible(np, "arm,impd1-vco1")) { + dev_info(dev, "register VCO1\n"); + desc = &impd1_icst1_desc; + } else if (of_device_is_compatible(np, "arm,impd1-vco2")) { + dev_info(dev, "register VCO2\n"); + desc = &impd1_icst2_desc; + } else { + dev_err(dev, "not a clock node %s\n", np->name); + return; + } + + of_property_read_string(np, "clock-output-names", &clk_name); + + parent_name = of_clk_get_parent_name(np, 0); + clk = icst_clk_register(NULL, desc, clk_name, parent_name, base); + if (!IS_ERR(clk)) + of_clk_add_provider(np, of_clk_src_simple_get, clk); +} + +static int integrator_impd1_clk_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct device_node *child; + void __iomem *base; + + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) { + dev_err(dev, "unable to remap syscon base\n"); + return PTR_ERR(base); + } + dev_info(dev, "located syscon base\n"); + + for_each_available_child_of_node(np, child) + integrator_impd1_clk_spawn(dev, base, child); + + return 0; +} + +static const struct of_device_id impd1_syscon_match[] = { + { .compatible = "arm,im-pd1-syscon", }, + {} +}; + +static struct platform_driver impd1_clk_driver = { + .driver = { + .name = "impd1-clk", + .of_match_table = impd1_syscon_match, + }, + .probe = integrator_impd1_clk_probe, +}; +builtin_platform_driver(impd1_clk_driver); + +MODULE_AUTHOR("Linus Walleij <linusw@kernel.org>"); +MODULE_DESCRIPTION("Arm IM-PD1 module clock driver"); +MODULE_LICENSE("GPL v2");
As we want to move these clocks over to probe from the device tree we add a device tree probing path. The old platform data path will be deleted once we have the device tree overall code in place. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/clk/versatile/clk-impd1.c | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)