On 18-07-18, 11:07, Taniya Das wrote:
+static int qcom_cpu_resources_init(struct platform_device *pdev,
+ struct device_node *np, unsigned int cpu,
+ unsigned long xo_rate)
+{
+ struct cpufreq_qcom *c;
+ struct resource res;
+ struct device *dev = &pdev->dev;
+ const u16 *offsets;
+ cpumask_t cpus_related;
+ int ret, i, cpu_r;
+ void __iomem *base;
+
+ cpumask_clear(&cpus_related);
+
+ ret = qcom_get_related_cpus(np, &cpus_related);
+ if (ret) {
+ dev_err(dev, "%s failed to get related CPUs\n", np->name);
+ return ret;
+ }
+
+ /* Related CPUs */
+ cpu_r = cpumask_first(&cpus_related);
+ if (cpu != cpu_r) {
+ qcom_freq_domain_map[cpu] = qcom_freq_domain_map[cpu_r];
+ return 0;
+ }
+
+ c = devm_kzalloc(dev, sizeof(*c), GFP_KERNEL);
+ if (!c)
+ return -ENOMEM;
+
+ offsets = of_device_get_match_data(&pdev->dev);
+ if (!offsets)
+ return -EINVAL;
+
+ if (of_address_to_resource(np, 0, &res))
+ return -ENOMEM;
+
+ base = devm_ioremap_resource(dev, &res);
+ if (!base)
+ return -ENOMEM;
+
+ for (i = REG_ENABLE; i < REG_ARRAY_SIZE; i++)
+ c->reg_bases[i] = base + offsets[i];
+
+ /* HW should be in enabled state to proceed */
+ if (!(readl_relaxed(c->reg_bases[REG_ENABLE]) & 0x1)) {
+ dev_err(dev, "%s cpufreq hardware not enabled\n", np->name);
+ return -ENODEV;
+ }
+
+ cpumask_copy(&c->related_cpus, &cpus_related);
+
+ c->max_cores = cpumask_weight(&c->related_cpus);
+ if (!c->max_cores)
+ return -ENOENT;
+
+ c->xo_rate = xo_rate;
+
+ ret = qcom_cpufreq_hw_read_lut(pdev, c);
+ if (ret) {
+ dev_err(dev, "%s failed to read LUT\n", np->name);
+ return ret;
+ }
+
+ qcom_freq_domain_map[cpu] = c;
Set this for all related CPUs here and then the check at the top of
this routine will be simply:
if (qcom_freq_domain_map[cpu])
return 0;
+
+ return 0;
+}
+