Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: versatile: Add device tree probing for IM-PD1 clocks

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>
Link: https://lkml.kernel.org/r/20200219103326.81120-3-linus.walleij@linaro.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Linus Walleij and committed by
Stephen Boyd
84655b76 eb9d6428

+80
+1
drivers/clk/versatile/clk-icst.h
··· 11 11 ICST_INTEGRATOR_AP_PCI, /* Odd bit pattern storage */ 12 12 ICST_INTEGRATOR_CP_CM_CORE, /* Only 8 bits of VDW and 3 bits of OD */ 13 13 ICST_INTEGRATOR_CP_CM_MEM, /* Only 8 bits of VDW and 3 bits of OD */ 14 + ICST_INTEGRATOR_IM_PD1, /* Like the Versatile, all control bits */ 14 15 }; 15 16 16 17 /**
+79
drivers/clk/versatile/clk-impd1.c
··· 7 7 #include <linux/clkdev.h> 8 8 #include <linux/err.h> 9 9 #include <linux/io.h> 10 + #include <linux/platform_device.h> 10 11 #include <linux/platform_data/clk-integrator.h> 12 + #include <linux/module.h> 13 + #include <linux/mfd/syscon.h> 14 + #include <linux/regmap.h> 11 15 12 16 #include "icst.h" 13 17 #include "clk-icst.h" ··· 179 175 kfree(imc->pclkname); 180 176 } 181 177 EXPORT_SYMBOL_GPL(integrator_impd1_clk_exit); 178 + 179 + static int integrator_impd1_clk_spawn(struct device *dev, 180 + struct device_node *parent, 181 + struct device_node *np) 182 + { 183 + struct regmap *map; 184 + struct clk *clk = ERR_PTR(-EINVAL); 185 + const char *name = np->name; 186 + const char *parent_name; 187 + const struct clk_icst_desc *desc; 188 + int ret; 189 + 190 + map = syscon_node_to_regmap(parent); 191 + if (IS_ERR(map)) { 192 + pr_err("no regmap for syscon IM-PD1 ICST clock parent\n"); 193 + return PTR_ERR(map); 194 + } 195 + 196 + if (of_device_is_compatible(np, "arm,impd1-vco1")) { 197 + desc = &impd1_icst1_desc; 198 + } else if (of_device_is_compatible(np, "arm,impd1-vco2")) { 199 + desc = &impd1_icst2_desc; 200 + } else { 201 + dev_err(dev, "not a clock node %s\n", name); 202 + return -ENODEV; 203 + } 204 + 205 + parent_name = of_clk_get_parent_name(np, 0); 206 + clk = icst_clk_setup(NULL, desc, name, parent_name, map, 207 + ICST_INTEGRATOR_IM_PD1); 208 + if (!IS_ERR(clk)) { 209 + of_clk_add_provider(np, of_clk_src_simple_get, clk); 210 + ret = 0; 211 + } else { 212 + dev_err(dev, "error setting up IM-PD1 ICST clock\n"); 213 + ret = PTR_ERR(clk); 214 + } 215 + 216 + return ret; 217 + } 218 + 219 + static int integrator_impd1_clk_probe(struct platform_device *pdev) 220 + { 221 + struct device *dev = &pdev->dev; 222 + struct device_node *np = dev->of_node; 223 + struct device_node *child; 224 + int ret = 0; 225 + 226 + for_each_available_child_of_node(np, child) { 227 + ret = integrator_impd1_clk_spawn(dev, np, child); 228 + if (ret) 229 + break; 230 + } 231 + 232 + return ret; 233 + } 234 + 235 + static const struct of_device_id impd1_syscon_match[] = { 236 + { .compatible = "arm,im-pd1-syscon", }, 237 + {} 238 + }; 239 + MODULE_DEVICE_TABLE(of, impd1_syscon_match); 240 + 241 + static struct platform_driver impd1_clk_driver = { 242 + .driver = { 243 + .name = "impd1-clk", 244 + .of_match_table = impd1_syscon_match, 245 + }, 246 + .probe = integrator_impd1_clk_probe, 247 + }; 248 + builtin_platform_driver(impd1_clk_driver); 249 + 250 + MODULE_AUTHOR("Linus Walleij <linusw@kernel.org>"); 251 + MODULE_DESCRIPTION("Arm IM-PD1 module clock driver"); 252 + MODULE_LICENSE("GPL v2");