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: 30560 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9C95E20675 for ; Thu, 22 May 2014 05:38:34 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id 29sf11183632yhl.10 for ; Wed, 21 May 2014 22:38:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=1eHsq4VM6U3RCHKUYT8JhrZoECqtSZSoYXgxkTZvlNc=; b=RF/Up2KR2um9ktI9SKfbsFZPf66+x/InyWF7OUzxYHTZ4Tf5j+P6hQghNarM+pqekK am/OBo0Rw6+813ep8de1GV8XiVOQMqANvMU192NuSq21Z9fjrK89bTevrdG/qS13Eg56 FPR9CHJ4GtI8W55SN4BMELtHLlHehDz9ZQsRUdZxOFzlmyfKRfdEvcnjb6onRLCHkD/i iUNSr5cwEtrkbV7wY7t+V61ZsR/xkOuOyTNfOBOooibtSeZFfvGjlSrh+f2wqsaQKZIR LLxVWLa0RQe5OFXEsirZr+6KJPNb1Vx1SgrRTOIKzfoPwzlox3A3gfMseIOrolD9GMzL oR4Q== X-Gm-Message-State: ALoCoQmt8lqYyLoZXB9YnCOvb1MKxKS43Pm4QxqHlBHyPcUCqHeW8oIxzQHXnJLvPj0RS3hbI13S X-Received: by 10.58.127.66 with SMTP id ne2mr16574259veb.27.1400737114395; Wed, 21 May 2014 22:38:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.247 with SMTP id b110ls1064471qge.16.gmail; Wed, 21 May 2014 22:38:34 -0700 (PDT) X-Received: by 10.58.112.8 with SMTP id im8mr142886veb.35.1400737114299; Wed, 21 May 2014 22:38:34 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id 8si2573297vdx.54.2014.05.21.22.38.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 May 2014 22:38:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so3773248veb.35 for ; Wed, 21 May 2014 22:38:34 -0700 (PDT) X-Received: by 10.221.37.1 with SMTP id tc1mr7926796vcb.32.1400737114218; Wed, 21 May 2014 22:38:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp169760vcb; Wed, 21 May 2014 22:38:33 -0700 (PDT) X-Received: by 10.68.197.195 with SMTP id iw3mr65273038pbc.139.1400737113087; Wed, 21 May 2014 22:38:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gw10si8524279pbd.55.2014.05.21.22.38.32; Wed, 21 May 2014 22:38:32 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753719AbaEVFiU (ORCPT + 27 others); Thu, 22 May 2014 01:38:20 -0400 Received: from mail-qg0-f49.google.com ([209.85.192.49]:53538 "EHLO mail-qg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753647AbaEVFiP (ORCPT ); Thu, 22 May 2014 01:38:15 -0400 Received: by mail-qg0-f49.google.com with SMTP id a108so4810723qge.36 for ; Wed, 21 May 2014 22:38:14 -0700 (PDT) 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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; }