From patchwork Thu Sep 20 16:08:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 1486461 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 5444DDF2D2 for ; Thu, 20 Sep 2012 16:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756000Ab2ITQIT (ORCPT ); Thu, 20 Sep 2012 12:08:19 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:61150 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728Ab2ITQIS (ORCPT ); Thu, 20 Sep 2012 12:08:18 -0400 Received: by wgbdr13 with SMTP id dr13so593279wgb.1 for ; Thu, 20 Sep 2012 09:08:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=EroilmQuJr4gUt7Nr5/YX7At6eoKOwfIx8dREFDdo/w=; b=DLQmB00QyoE3TcXes6IHMSyC2cCFAIVNxV69SnucSID1RFoeNNXBwUzu4Wbkdx6C1t oLjPSPOOn7uGx0Cs0M0djL0qTvmiS9mTimc7S9qCVIyfc8hK3vw9U4aMXFIu+FtwHmto QUcYP5eVChqwQnz6WDkn3lk+4ZjUglitvNmuoIfOc9kiqScxod381eHhf0jWT1h9DZMq 1VXjRr6949b3WmMPvAbvNjLDzXdjrplniZzJdEBK7ozktPDSMFeztzEd32nuCv3PXReO mABZYdAg/vuFAHVWIMf/xk3qSPMaUrSinP7foPGn8v7RqASmkq/K+x1E54qcROdBZi+G 3yfQ== Received: by 10.180.8.41 with SMTP id o9mr5477370wia.3.1348157297088; Thu, 20 Sep 2012 09:08:17 -0700 (PDT) Received: from localhost.localdomain (179.59-66-87.adsl-dyn.isp.belgacom.be. [87.66.59.179]) by mx.google.com with ESMTPS id l6sm33219594wiz.4.2012.09.20.09.08.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 09:08:16 -0700 (PDT) From: Jean Pihet To: Tony Lindgren , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ben Dooks , Wolfram Sang , linux-i2c@vger.kernel.org Cc: Jean Pihet Subject: [PATCH] ARM: OMAP: convert I2C driver to PM QoS for MPU latency constraints Date: Thu, 20 Sep 2012 18:08:03 +0200 Message-Id: <1348157283-24119-1-git-send-email-j-pihet@ti.com> X-Mailer: git-send-email 1.7.7.6 X-Gm-Message-State: ALoCoQkfte57mADJmuQTC01cj996wL6sNBdmlXETY1qLxXtzMtODkbiJW+kp0VY8qijX1we9ME19 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat API to the new PM QoS API. Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY class of PM QoS. The resulting MPU constraints are used by cpuidle to decide the next power state of the MPU subsystem. The I2C device latency timing is derived from the FIFO size and the clock speed and so is applicable to all OMAP SoCs. Signed-off-by: Jean Pihet Acked-by: Shubhrajyoti D Acked-by: Tony Lindgren Acked-by: Kevin Hilman --- Rebased on git://git.pengutronix.de/git/wsa/linux.git, branch i2c-embedded/for-next --- arch/arm/plat-omap/i2c.c | 21 --------------------- drivers/i2c/busses/i2c-omap.c | 32 ++++++++++++++++++-------------- include/linux/i2c-omap.h | 1 - 3 files changed, 18 insertions(+), 36 deletions(-) diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c index 40bc06a..d29a2cc 100644 --- a/arch/arm/plat-omap/i2c.c +++ b/arch/arm/plat-omap/i2c.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -34,7 +33,6 @@ #include #include #include -#include #include #define OMAP_I2C_SIZE 0x3f @@ -130,16 +128,6 @@ static inline int omap1_i2c_add_bus(int bus_id) #ifdef CONFIG_ARCH_OMAP2PLUS -/* - * XXX This function is a temporary compatibility wrapper - only - * needed until the I2C driver can be converted to call - * omap_pm_set_max_dev_wakeup_lat() and handle a return code. - */ -static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t) -{ - omap_pm_set_max_mpu_wakeup_lat(dev, t); -} - static inline int omap2_i2c_add_bus(int bus_id) { int l; @@ -171,15 +159,6 @@ static inline int omap2_i2c_add_bus(int bus_id) dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr; pdata->flags = dev_attr->flags; - /* - * When waiting for completion of a i2c transfer, we need to - * set a wake up latency constraint for the MPU. This is to - * ensure quick enough wakeup from idle, when transfer - * completes. - * Only omap3 has support for constraints - */ - if (cpu_is_omap34xx()) - pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(struct omap_i2c_bus_platform_data), NULL, 0, 0); diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 0b02543..db31eae 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -43,6 +43,7 @@ #include #include #include +#include /* I2C controller revisions */ #define OMAP_I2C_OMAP1_REV_2 0x20 @@ -186,9 +187,8 @@ struct omap_i2c_dev { int reg_shift; /* bit shift for I2C register addresses */ struct completion cmd_complete; struct resource *ioarea; - u32 latency; /* maximum mpu wkup latency */ - void (*set_mpu_wkup_lat)(struct device *dev, - long latency); + u32 latency; /* maximum MPU wkup latency */ + struct pm_qos_request pm_qos_request; u32 speed; /* Speed of bus in kHz */ u32 dtrev; /* extra revision from DT */ u32 flags; @@ -494,9 +494,7 @@ static void omap_i2c_resize_fifo(struct omap_i2c_dev *dev, u8 size, bool is_rx) dev->b_hw = 1; /* Enable hardware fixes */ /* calculate wakeup latency constraint for MPU */ - if (dev->set_mpu_wkup_lat != NULL) - dev->latency = (1000000 * dev->threshold) / - (1000 * dev->speed / 8); + dev->latency = (1000000 * dev->threshold) / (1000 * dev->speed / 8); } /* @@ -631,8 +629,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) if (r < 0) goto out; - if (dev->set_mpu_wkup_lat != NULL) - dev->set_mpu_wkup_lat(dev->dev, dev->latency); + /* + * When waiting for completion of a i2c transfer, we need to + * set a wake up latency constraint for the MPU. This is to + * ensure quick enough wakeup from idle, when transfer + * completes. + */ + if (dev->latency) + pm_qos_add_request(&dev->pm_qos_request, + PM_QOS_CPU_DMA_LATENCY, + dev->latency); for (i = 0; i < num; i++) { r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1))); @@ -640,8 +646,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) break; } - if (dev->set_mpu_wkup_lat != NULL) - dev->set_mpu_wkup_lat(dev->dev, -1); + if (dev->latency) + pm_qos_remove_request(&dev->pm_qos_request); if (r == 0) r = num; @@ -1098,7 +1104,6 @@ omap_i2c_probe(struct platform_device *pdev) } else if (pdata != NULL) { dev->speed = pdata->clkrate; dev->flags = pdata->flags; - dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; dev->dtrev = pdata->rev; } @@ -1154,9 +1159,8 @@ omap_i2c_probe(struct platform_device *pdev) dev->b_hw = 1; /* Enable hardware fixes */ /* calculate wakeup latency constraint for MPU */ - if (dev->set_mpu_wkup_lat != NULL) - dev->latency = (1000000 * dev->fifo_size) / - (1000 * dev->speed / 8); + dev->latency = (1000000 * dev->fifo_size) / + (1000 * dev->speed / 8); } /* reset ASAP, clearing any IRQs */ diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h index 92a0dc7..df804ba 100644 --- a/include/linux/i2c-omap.h +++ b/include/linux/i2c-omap.h @@ -34,7 +34,6 @@ struct omap_i2c_bus_platform_data { u32 clkrate; u32 rev; u32 flags; - void (*set_mpu_wkup_lat)(struct device *dev, long set); }; #endif