From patchwork Thu May 22 05:37:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 4220431 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7E89FBEEAB for ; Thu, 22 May 2014 05:39:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F23F2026C for ; Thu, 22 May 2014 05:39:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD90E2020F for ; Thu, 22 May 2014 05:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753664AbaEVFiS (ORCPT ); Thu, 22 May 2014 01:38:18 -0400 Received: from mail-qc0-f175.google.com ([209.85.216.175]:46689 "EHLO mail-qc0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753646AbaEVFiP (ORCPT ); Thu, 22 May 2014 01:38:15 -0400 Received: by mail-qc0-f175.google.com with SMTP id w7so4908605qcr.34 for ; Wed, 21 May 2014 22:38:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=WSNbl5o2ARiy0L5xNVOMA8kgBlzlPrRNUxhfGk3jZwI=; b=mjp+kXjvmFvS+oWwiudZLN+cAS33X0fsUs/ESCA8tfgfFOGmkf+/KkvxTnHCpU6QLk t0rEyV8XMyK8ZM34ELW7zbmHdnXEvrw5lFuzgGeDaKiUGaW6Cq4w/kQR7LASeCmyoNXv dqyELFaknChyUGApjiILB0CD5DS+X18eDwgnOfVQgcL7hf8okxrXVon7mrBQhMMzt4YU 7I6qGLLlm5bOg/FnklLBtTxZPfgNRxrlVztAdGBNgpecMEW+q93guSmSDXoi8R3o7zEQ dbd0BLVd/j43WoiR5YkEF6WmDZxs+Y7aRIhIobCg0ZSTuYUZaFg+TWuTHUIo0mKIqyeb DM+A== X-Gm-Message-State: ALoCoQmlUPBzkMmJRFwZ1lzAbYzxt+J0w3VbuAM9JOZ7zK67Aq9azDMNIZrcp4ZxQDc59aahIbW+ X-Received: by 10.140.88.241 with SMTP id t104mr73347046qgd.29.1400737094508; Wed, 21 May 2014 22:38:14 -0700 (PDT) Received: from localhost (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id a13sm2102774qgf.38.2014.05.21.22.38.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 21 May 2014 22:38:14 -0700 (PDT) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, arvind.chauhan@arm.com, inderpal.s@samsung.com, nm@ti.com, chander.kashyap@linaro.org, pavel@ucw.cz, len.brown@intel.com, sudeep.holla@arm.com, Viresh Kumar , Greg Kroah-Hartman , Amit Daniel Kachhap , Kukjin Kim , Shawn Guo Subject: [PATCH V3 4/8] driver/core: cpu: initialize opp table Date: Thu, 22 May 2014 11:07:28 +0530 Message-Id: <6379a5109bf6b4875cc1656b025f9b8186bbb91a.1400736536.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Drivers expecting CPU's OPPs from device tree initialize OPP table themselves by calling of_init_opp_table() and there is nothing driver specific in that. They all do it in the same redundant way. It would be better if we can get rid of redundancy by initializing CPU OPPs from CPU core code for all CPUs (that have a "operating-points" property defined in their node). This patch adds another routine in cpu.c: of_init_cpu_opp_table() and calls it right after CPU device is registered in register_cpu(). A dummy implementation is also provided to make it lightweight for platforms that don't need it. Cc: Greg Kroah-Hartman Cc: Amit Daniel Kachhap Cc: Kukjin Kim Cc: Shawn Guo Signed-off-by: Viresh Kumar --- drivers/base/cpu.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 006b1bc..818cfe8 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "base.h" @@ -322,6 +323,25 @@ static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env) } #endif +#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) +static inline void of_init_cpu_opp_table(struct cpu *cpu) +{ + int error; + + /* Initialize CPU's OPP table */ + error = of_init_opp_table(&cpu->dev); + if (!error) + dev_dbg(&cpu->dev, "%s: created OPP table for cpu: %d\n", + __func__, cpu->dev.id); + /* Print error only if there is an issue with OPP table */ + else if (error != -ENOSYS && error != -ENODEV) + dev_err(&cpu->dev, "%s: failed to init OPP table for cpu%d, err: %d\n", + __func__, cpu->dev.id, error); +} +#else +static inline void of_init_cpu_opp_table(struct cpu *cpu) {} +#endif + /* * register_cpu - Setup a sysfs device for a CPU. * @cpu - cpu->hotpluggable field set to 1 will generate a control file in @@ -349,10 +369,12 @@ int register_cpu(struct cpu *cpu, int num) if (cpu->hotpluggable) cpu->dev.groups = hotplugable_cpu_attr_groups; error = device_register(&cpu->dev); - if (!error) - per_cpu(cpu_sys_devices, num) = &cpu->dev; - if (!error) - register_cpu_under_node(num, cpu_to_node(num)); + if (error) + return error; + + per_cpu(cpu_sys_devices, num) = &cpu->dev; + register_cpu_under_node(num, cpu_to_node(num)); + of_init_cpu_opp_table(cpu); return error; }