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

soc: ti: pruss: Refactor the CFG sub-module init

The CFG sub-module is not present on some earlier SoCs like the
DA850/OMAPL-138 in the TI Davinci family. Refactor out the CFG
sub-module parse and initialization logic into a separate function
to make it easier to add logic for the PRUSS IP on the above legacy
SoC families.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

authored by

Suman Anna and committed by
Santosh Shilimkar
ea797f69 822be879

+50 -41
+50 -41
drivers/soc/ti/pruss.c
··· 161 161 .reg_stride = 4, 162 162 }; 163 163 164 + static int pruss_cfg_of_init(struct device *dev, struct pruss *pruss) 165 + { 166 + struct device_node *np = dev_of_node(dev); 167 + struct device_node *child; 168 + struct resource res; 169 + int ret; 170 + 171 + child = of_get_child_by_name(np, "cfg"); 172 + if (!child) { 173 + dev_err(dev, "%pOF is missing its 'cfg' node\n", child); 174 + return -ENODEV; 175 + } 176 + 177 + if (of_address_to_resource(child, 0, &res)) { 178 + ret = -ENOMEM; 179 + goto node_put; 180 + } 181 + 182 + pruss->cfg_base = devm_ioremap(dev, res.start, resource_size(&res)); 183 + if (!pruss->cfg_base) { 184 + ret = -ENOMEM; 185 + goto node_put; 186 + } 187 + 188 + regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child, 189 + (u64)res.start); 190 + regmap_conf.max_register = resource_size(&res) - 4; 191 + 192 + pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base, 193 + &regmap_conf); 194 + kfree(regmap_conf.name); 195 + if (IS_ERR(pruss->cfg_regmap)) { 196 + dev_err(dev, "regmap_init_mmio failed for cfg, ret = %ld\n", 197 + PTR_ERR(pruss->cfg_regmap)); 198 + ret = PTR_ERR(pruss->cfg_regmap); 199 + goto node_put; 200 + } 201 + 202 + ret = pruss_clk_init(pruss, child); 203 + if (ret) 204 + dev_err(dev, "pruss_clk_init failed, ret = %d\n", ret); 205 + 206 + node_put: 207 + of_node_put(child); 208 + return ret; 209 + } 210 + 164 211 static int pruss_probe(struct platform_device *pdev) 165 212 { 166 213 struct device *dev = &pdev->dev; ··· 286 239 goto rpm_disable; 287 240 } 288 241 289 - child = of_get_child_by_name(np, "cfg"); 290 - if (!child) { 291 - dev_err(dev, "%pOF is missing its 'cfg' node\n", child); 292 - ret = -ENODEV; 242 + ret = pruss_cfg_of_init(dev, pruss); 243 + if (ret < 0) 293 244 goto rpm_put; 294 - } 295 - 296 - if (of_address_to_resource(child, 0, &res)) { 297 - ret = -ENOMEM; 298 - goto node_put; 299 - } 300 - 301 - pruss->cfg_base = devm_ioremap(dev, res.start, resource_size(&res)); 302 - if (!pruss->cfg_base) { 303 - ret = -ENOMEM; 304 - goto node_put; 305 - } 306 - 307 - regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child, 308 - (u64)res.start); 309 - regmap_conf.max_register = resource_size(&res) - 4; 310 - 311 - pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base, 312 - &regmap_conf); 313 - kfree(regmap_conf.name); 314 - if (IS_ERR(pruss->cfg_regmap)) { 315 - dev_err(dev, "regmap_init_mmio failed for cfg, ret = %ld\n", 316 - PTR_ERR(pruss->cfg_regmap)); 317 - ret = PTR_ERR(pruss->cfg_regmap); 318 - goto node_put; 319 - } 320 - 321 - ret = pruss_clk_init(pruss, child); 322 - if (ret) { 323 - dev_err(dev, "pruss_clk_init failed, ret = %d\n", ret); 324 - goto node_put; 325 - } 326 245 327 246 ret = devm_of_platform_populate(dev); 328 247 if (ret) { 329 248 dev_err(dev, "failed to register child devices\n"); 330 - goto node_put; 249 + goto rpm_put; 331 250 } 332 - 333 - of_node_put(child); 334 251 335 252 return 0; 336 253 337 - node_put: 338 - of_node_put(child); 339 254 rpm_put: 340 255 pm_runtime_put_sync(dev); 341 256 rpm_disable: