static int arm_cmn_init_dtc(struct arm_cmn *cmn, struct arm_cmn_node *dn, int idx)
{
struct arm_cmn_dtc *dtc = cmn->dtc + idx;
+ const struct resource *cfg;
+ resource_size_t base, size;
dtc->pmu_base = dn->pmu_base;
dtc->base = dtc->pmu_base - arm_cmn_pmu_offset(cmn, dn);
if (dtc->irq < 0)
return dtc->irq;
+ cfg = platform_get_resource(to_platform_device(cmn->dev), IORESOURCE_MEM, 0);
+ base = dtc->base - cmn->base + cfg->start;
+ size = cmn->part == PART_CMN600 ? SZ_16K : SZ_64K;
+ if (!devm_request_mem_region(cmn->dev, base, size, dev_name(cmn->dev)))
+ return dev_err_probe(cmn->dev, -EBUSY,
+ "Failed to request DTC region 0x%llx\n", base);
+
writel_relaxed(CMN_DT_DTC_CTL_DT_EN, dtc->base + CMN_DT_DTC_CTL);
writel_relaxed(CMN_DT_PMCR_PMU_EN | CMN_DT_PMCR_OVFL_INTR_EN, CMN_DT_PMCR(dtc));
writeq_relaxed(0, CMN_DT_PMCCNTR(dtc));
return 0;
}
-static int arm_cmn600_acpi_probe(struct platform_device *pdev, struct arm_cmn *cmn)
+static int arm_cmn_get_root(struct arm_cmn *cmn, const struct resource *cfg)
{
- struct resource *cfg, *root;
-
- cfg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!cfg)
- return -EINVAL;
-
- root = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!root)
- return -EINVAL;
-
- if (!resource_contains(cfg, root))
- swap(cfg, root);
- /*
- * Note that devm_ioremap_resource() is dumb and won't let the platform
- * device claim cfg when the ACPI companion device has already claimed
- * root within it. But since they *are* already both claimed in the
- * appropriate name, we don't really need to do it again here anyway.
- */
- cmn->base = devm_ioremap(cmn->dev, cfg->start, resource_size(cfg));
- if (!cmn->base)
- return -ENOMEM;
+ const struct device_node *np = cmn->dev->of_node;
+ const struct resource *root;
+ u32 rootnode;
- return root->start - cfg->start;
-}
+ if (cmn->part != PART_CMN600)
+ return 0;
-static int arm_cmn600_of_probe(struct device_node *np)
-{
- u32 rootnode;
+ if (np)
+ return of_property_read_u32(np, "arm,root-node", &rootnode) ?: rootnode;
- return of_property_read_u32(np, "arm,root-node", &rootnode) ?: rootnode;
+ root = platform_get_resource(to_platform_device(cmn->dev), IORESOURCE_MEM, 1);
+ return root ? root->start - cfg->start : -EINVAL;
}
static int arm_cmn_probe(struct platform_device *pdev)
{
struct arm_cmn *cmn;
+ const struct resource *cfg;
const char *name;
static atomic_t id;
int err, rootnode, this_id;
cmn->cpu = cpumask_local_spread(0, dev_to_node(cmn->dev));
platform_set_drvdata(pdev, cmn);
- if (cmn->part == PART_CMN600 && has_acpi_companion(cmn->dev)) {
- rootnode = arm_cmn600_acpi_probe(pdev, cmn);
- } else {
- rootnode = 0;
- cmn->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(cmn->base))
- return PTR_ERR(cmn->base);
- if (cmn->part == PART_CMN600)
- rootnode = arm_cmn600_of_probe(pdev->dev.of_node);
- }
+ cfg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!cfg)
+ return -EINVAL;
+
+ /* Map the whole region now, claim the DTCs once we've found them */
+ cmn->base = devm_ioremap(cmn->dev, cfg->start, resource_size(cfg));
+ if (IS_ERR(cmn->base))
+ return PTR_ERR(cmn->base);
+
+ rootnode = arm_cmn_get_root(cmn, cfg);
if (rootnode < 0)
return rootnode;