From patchwork Wed Mar 30 15:19:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 674421 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2UFJZfM002041 for ; Wed, 30 Mar 2011 15:19:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754959Ab1C3PTn (ORCPT ); Wed, 30 Mar 2011 11:19:43 -0400 Received: from mail-ww0-f42.google.com ([74.125.82.42]:60569 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754861Ab1C3PTn (ORCPT ); Wed, 30 Mar 2011 11:19:43 -0400 Received: by mail-ww0-f42.google.com with SMTP id 4so4155522wwk.1 for ; Wed, 30 Mar 2011 08:19:42 -0700 (PDT) Received: by 10.227.55.4 with SMTP id s4mr1385562wbg.228.1301498382802; Wed, 30 Mar 2011 08:19:42 -0700 (PDT) Received: from localhost.localdomain (245.207-245-81.adsl-dyn.isp.belgacom.be [81.245.207.245]) by mx.google.com with ESMTPS id w25sm104997wbd.39.2011.03.30.08.19.41 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Mar 2011 08:19:42 -0700 (PDT) From: jean.pihet@newoldbits.com To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kevin Hilman , paul@pwsan.com Cc: Jean Pihet Subject: [PATCH 7/8] OMAP: PM CONSTRAINTS: implement wake-up latency constraints Date: Wed, 30 Mar 2011 17:19:23 +0200 Message-Id: <1301498364-726-8-git-send-email-j-pihet@ti.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1301498364-726-1-git-send-email-j-pihet@ti.com> References: <1301498364-726-1-git-send-email-j-pihet@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 30 Mar 2011 15:19:44 +0000 (UTC) diff --git a/arch/arm/plat-omap/omap-pm-constraints.c b/arch/arm/plat-omap/omap-pm-constraints.c index c8b4e4c..805dba3 100644 --- a/arch/arm/plat-omap/omap-pm-constraints.c +++ b/arch/arm/plat-omap/omap-pm-constraints.c @@ -24,6 +24,7 @@ /* Interface documentation is in mach/omap-pm.h */ #include #include +#include static bool off_mode_enabled; static u32 dummy_context_loss_counter; @@ -32,119 +33,124 @@ static u32 dummy_context_loss_counter; * Device-driver-originated constraints (via board-*.c files) */ -int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t) +/* + * Generic function to omap_device layer for the constraints API. + */ +static int _set_dev_constraint(enum omap_pm_constraint_class class, + struct device *req_dev, struct device *dev, + long t) { - if (!dev || t < -1) { + int ret = 0; + + if (!req_dev || !dev || t < -1) { WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__); return -EINVAL; - }; - - if (t == -1) - pr_debug("OMAP PM: remove max MPU wakeup latency constraint: " - "dev %s\n", dev_name(dev)); - else - pr_debug("OMAP PM: add max MPU wakeup latency constraint: " - "dev %s, t = %ld usec\n", dev_name(dev), t); + } - /* - * For current Linux, this needs to map the MPU to a - * powerdomain, then go through the list of current max lat - * constraints on the MPU and find the smallest. If - * the latency constraint has changed, the code should - * recompute the state to enter for the next powerdomain - * state. - * - * TI CDP code can call constraint_set here. - */ + /* Only valid for omap_devices */ + if (dev->parent == &omap_device_parent) { + if (t == -1) + pr_debug("OMAP PM: remove constraint of class %d " + "from req_dev %s on dev %s\n", + class, dev_name(req_dev), dev_name(dev)); + else + pr_debug("OMAP PM: add constraint of class %d " + "from req_dev %s on dev %s, t = %ld\n", + class, dev_name(req_dev), dev_name(dev), t); + + ret = omap_device_set_dev_constraint(class, req_dev, dev, t); + } else { + pr_err("OMAP-PM: %s: Error: not an omap_device\n", __func__); + return -EINVAL; + } - return 0; + return ret; } +/* + * omap_pm_set_min_bus_tput - set/release bus throughput constraints + */ int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r) { + long t; + struct device *req_dev = NULL; + if (!dev || (agent_id != OCP_INITIATOR_AGENT && agent_id != OCP_TARGET_AGENT)) { WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__); return -EINVAL; }; + /* + * This code calls the generic omap_device API function + * _set_dev_constraint with the class OMAP_PM_CONSTRAINT_THROUGHPUT. + * _set_dev_constraint should manage the constraints lists and call + * the appropriate low level code that models the interconnect, + * computes the required clock frequency, converts that to a VDD2 + * OPP ID and sets the VDD2 OPP appropriately. + */ + + /* + * A value of r == 0 removes the constraint. Convert it to the + * generic _set_dev_constraint convention (-1 for constraint removal) + */ if (r == 0) - pr_debug("OMAP PM: remove min bus tput constraint: " - "dev %s for agent_id %d\n", dev_name(dev), agent_id); + t = -1; else - pr_debug("OMAP PM: add min bus tput constraint: " - "dev %s for agent_id %d: rate %ld KiB\n", - dev_name(dev), agent_id, r); + t = r; /* - * This code should model the interconnect and compute the - * required clock frequency, convert that to a VDD2 OPP ID, then - * set the VDD2 OPP appropriately. - * - * TI CDP code can call constraint_set here on the VDD2 OPP. + * Assign the device for L3 or L4 interconnect to req_dev, + * based on the value of agent_id */ + switch (agent_id) { + case OCP_INITIATOR_AGENT: + req_dev = omap2_get_l3_device(); + break; + case OCP_TARGET_AGENT: + /* Fixme: need the device for L4 interconnect */ + break; + } - return 0; + return _set_dev_constraint(OMAP_PM_CONSTRAINT_THROUGHPUT, + req_dev, dev, t); } +/* + * omap_pm_set_max_dev_wakeup_lat - set/release devices wake-up latency + * constraints + */ int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device *dev, long t) { - if (!req_dev || !dev || t < -1) { - WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__); - return -EINVAL; - }; - - if (t == -1) - pr_debug("OMAP PM: remove max device latency constraint: " - "dev %s\n", dev_name(dev)); - else - pr_debug("OMAP PM: add max device latency constraint: " - "dev %s, t = %ld usec\n", dev_name(dev), t); - - /* - * For current Linux, this needs to map the device to a - * powerdomain, then go through the list of current max lat - * constraints on that powerdomain and find the smallest. If - * the latency constraint has changed, the code should - * recompute the state to enter for the next powerdomain - * state. Conceivably, this code should also determine - * whether to actually disable the device clocks or not, - * depending on how long it takes to re-enable the clocks. - * - * TI CDP code can call constraint_set here. - */ - - return 0; + return _set_dev_constraint(OMAP_PM_CONSTRAINT_WKUP_LAT, req_dev, + dev, t); } -int omap_pm_set_max_sdma_lat(struct device *dev, long t) +/* + * omap_pm_set_max_mpu_wakeup_lat - set/release MPU wake-up latency + * constraints + * + * Maps to _set_dev_constraint with OMAP_PM_CONSTRAINT_WKUP_LAT + * as constraint class and the MPU device as constraints target. + */ +int omap_pm_set_max_mpu_wakeup_lat(struct device *req_dev, long t) { - if (!dev || t < -1) { - WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__); - return -EINVAL; - }; - - if (t == -1) - pr_debug("OMAP PM: remove max DMA latency constraint: " - "dev %s\n", dev_name(dev)); - else - pr_debug("OMAP PM: add max DMA latency constraint: " - "dev %s, t = %ld usec\n", dev_name(dev), t); - - /* - * For current Linux PM QOS params, this code should scan the - * list of maximum CPU and DMA latencies and select the - * smallest, then set cpu_dma_latency pm_qos_param - * accordingly. - * - * For future Linux PM QOS params, with separate CPU and DMA - * latency params, this code should just set the dma_latency param. - * - * TI CDP code can call constraint_set here. - */ + return _set_dev_constraint(OMAP_PM_CONSTRAINT_WKUP_LAT, req_dev, + omap2_get_mpuss_device(), t); +} - return 0; +/* + * omap_pm_set_max_sdma_lat - set/release SDMA start latency + * constraints + * + * Currently maps to _set_dev_constraint with OMAP_PM_CONSTRAINT_WKUP_LAT + * as constraint class and the L3 device as constraints target. + */ +int omap_pm_set_max_sdma_lat(struct device *req_dev, long t) +{ + return _set_dev_constraint(OMAP_PM_CONSTRAINT_WKUP_LAT, req_dev, + omap2_get_l3_device(), t); } int omap_pm_set_min_clk_rate(struct device *dev, struct clk *c, long r)