From patchwork Fri Oct 16 19:27:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sripathy, Vishwanath" X-Patchwork-Id: 54407 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9GJRr6d014340 for ; Fri, 16 Oct 2009 19:27:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbZJPT1o (ORCPT ); Fri, 16 Oct 2009 15:27:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752374AbZJPT1o (ORCPT ); Fri, 16 Oct 2009 15:27:44 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:49559 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751439AbZJPT1n (ORCPT ); Fri, 16 Oct 2009 15:27:43 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id n9GJRju4025172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 16 Oct 2009 14:27:47 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id n9GJRiPx009192 for ; Sat, 17 Oct 2009 00:57:44 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Sat, 17 Oct 2009 00:57:44 +0530 From: "Sripathy, Vishwanath" To: "Sripathy, Vishwanath" , "linux-omap@vger.kernel.org" , "Hilman, Kevin" Date: Sat, 17 Oct 2009 00:57:40 +0530 Subject: RE: [RFC][Patch] OMAP3 PM: sysfs vdd_opp change to use Constraint Framework Thread-Topic: [RFC][Patch] OMAP3 PM: sysfs vdd_opp change to use Constraint Framework Thread-Index: AcpOloifucAjLXpJQ3ezXFlwlquN/gAABadw Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index 13783f3..bcdc00d 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c @@ -47,6 +47,8 @@ static ssize_t idle_store(struct kobject *k, struct kobj_attribute *, static ssize_t vdd_opp_show(struct kobject *, struct kobj_attribute *, char *); static ssize_t vdd_opp_store(struct kobject *k, struct kobj_attribute *, const char *buf, size_t n); +static ssize_t vdd_opp_lock_store(struct kobject *k, struct kobj_attribute *, + const char *buf, size_t n); static struct kobj_attribute vdd1_opp_attr = __ATTR(vdd1_opp, 0644, vdd_opp_show, vdd_opp_store); @@ -103,6 +105,41 @@ static ssize_t vdd_opp_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n) { unsigned short value; + struct omap_opp *opp_table; + + if (sscanf(buf, "%hu", &value) != 1) + return -EINVAL; + + if (attr == &vdd1_opp_attr) { + if (value < MIN_VDD1_OPP || value > MAX_VDD1_OPP) { + printk(KERN_ERR "vdd_opp_store: Invalid value\n"); + return -EINVAL; + } + opp_table = omap_get_mpu_rate_table(); + omap_pm_cpu_set_freq(&sysfs_cpufreq_dev, + opp_table[value].rate); + } else if (attr == &vdd2_opp_attr) { + if (value < MIN_VDD2_OPP || (value > MAX_VDD2_OPP)) { + printk(KERN_ERR "vdd_opp_store: Invalid value\n"); + return -EINVAL; + } + if (value == VDD2_OPP2) + omap_pm_set_min_bus_tput(&sysfs_cpufreq_dev, + OCP_INITIATOR_AGENT, 83*1000*4); + else if (value == VDD2_OPP3) + omap_pm_set_min_bus_tput(&sysfs_cpufreq_dev, + OCP_INITIATOR_AGENT, 166*1000*4); + + } else { + return -EINVAL; + } + return n; +} + +static ssize_t vdd_opp_lock_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t n) +{ + unsigned short value; int flags = 0; if (sscanf(buf, "%hu", &value) != 1) @@ -121,6 +158,11 @@ static ssize_t vdd_opp_store(struct kobject *kobj, struct kobj_attribute *attr, if (vdd1_locked == 0 && value != 0) { resource_lock_opp(VDD1_OPP); vdd1_locked = 1; + if (value < MIN_VDD1_OPP || value > MAX_VDD1_OPP) { + printk(KERN_ERR "vdd_opp_store: Invalid value\n"); + return -EINVAL; + } + resource_set_opp_level(VDD1_OPP, value, flags); } } else if (attr == &vdd2_lock_attr) { flags = OPP_IGNORE_LOCK; @@ -134,21 +176,12 @@ static ssize_t vdd_opp_store(struct kobject *kobj, struct kobj_attribute *attr, if (vdd2_locked == 0 && value != 0) { resource_lock_opp(VDD2_OPP); vdd2_locked = 1; + if (value < MIN_VDD2_OPP || value > MAX_VDD2_OPP) { + printk(KERN_ERR "vdd_opp_store: Invalid value\n"); + return -EINVAL; + } + resource_set_opp_level(VDD2_OPP, value, flags); } - } - - if (attr == &vdd1_opp_attr) { - if (value < 1 || value > 5) { - printk(KERN_ERR "vdd_opp_store: Invalid value\n"); - return -EINVAL; - } - resource_set_opp_level(VDD1_OPP, value, flags); - } else if (attr == &vdd2_opp_attr) { - if (value < 2 || value > 3) { - printk(KERN_ERR "vdd_opp_store: Invalid value\n"); - return -EINVAL; - } - resource_set_opp_level(VDD2_OPP, value, flags); } else { return -EINVAL; }