From patchwork Fri Oct 29 15:38:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 290632 X-Patchwork-Delegate: khilman@deeprootsystems.com 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 o9TFcn5i013027 for ; Fri, 29 Oct 2010 15:38:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934067Ab0J2Piv (ORCPT ); Fri, 29 Oct 2010 11:38:51 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:34611 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932801Ab0J2Pik (ORCPT ); Fri, 29 Oct 2010 11:38:40 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o9TFcZpD020203 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Oct 2010 10:38:38 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o9TFcTYp012648; Fri, 29 Oct 2010 21:08:33 +0530 (IST) From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: paul@pwsan.com, khilman@deeprootsystems.com, b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com, Thara Gopinath Subject: [PATCH v2 05/14] OMAP: Introduce device specific set rate and get rate in omap_device structure Date: Fri, 29 Oct 2010 21:08:19 +0530 Message-Id: <1288366708-32302-6-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1288366708-32302-1-git-send-email-thara@ti.com> References: <1288366708-32302-1-git-send-email-thara@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.3 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Oct 2010 15:38:52 +0000 (UTC) diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h index 28e2d1a..2a37345 100644 --- a/arch/arm/plat-omap/include/plat/omap_device.h +++ b/arch/arm/plat-omap/include/plat/omap_device.h @@ -50,6 +50,8 @@ extern struct device omap_device_parent; * @hwmods: (one .. many per omap_device) * @hwmods_cnt: ARRAY_SIZE() of @hwmods * @pm_lats: ptr to an omap_device_pm_latency table + * @set_rate: fn ptr to change the operating rate. + * @get_rate: fn ptr to retrieve the current operating rate. * @pm_lats_cnt: ARRAY_SIZE() of what is passed to @pm_lats * @pm_lat_level: array index of the last odpl entry executed - -1 if never * @dev_wakeup_lat: dev wakeup latency in nanoseconds @@ -67,6 +69,8 @@ struct omap_device { struct platform_device pdev; struct omap_hwmod **hwmods; struct omap_device_pm_latency *pm_lats; + int (*set_rate)(struct device *dev, unsigned long rate); + unsigned long (*get_rate) (struct device *dev); u32 dev_wakeup_lat; u32 _dev_wakeup_lat_limit; u8 pm_lats_cnt; @@ -107,6 +111,11 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od); int omap_device_align_pm_lat(struct platform_device *pdev, u32 new_wakeup_lat_limit); struct powerdomain *omap_device_get_pwrdm(struct omap_device *od); +int omap_device_set_rate(struct device *dev, unsigned long freq); +unsigned long omap_device_get_rate(struct device *dev); +void omap_device_populate_rate_fns(struct device *dev, + int (*set_rate)(struct device *dev, unsigned long rate), + unsigned long (*get_rate) (struct device *dev)); /* Other */ diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 7c902a6..ffe06eb 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -785,6 +785,55 @@ int omap_device_enable_clocks(struct omap_device *od) return 0; } +int omap_device_set_rate(struct device *dev, unsigned long freq) +{ + struct platform_device *pdev; + struct omap_device *od; + + pdev = container_of(dev, struct platform_device, dev); + od = _find_by_pdev(pdev); + + if (!od->set_rate) { + dev_err(dev, "%s: No set_rate API for scaling device\n", + __func__); + return -ENODATA; + } + + return od->set_rate(dev, freq); +} + +unsigned long omap_device_get_rate(struct device *dev) +{ + struct platform_device *pdev; + struct omap_device *od; + + pdev = container_of(dev, struct platform_device, dev); + od = _find_by_pdev(pdev); + + + if (!od->get_rate) { + dev_err(dev, "%s: No get rate API for the device\n", + __func__); + return 0; + } + + return od->get_rate(dev); +} + +void omap_device_populate_rate_fns(struct device *dev, + int (*set_rate)(struct device *dev, unsigned long rate), + unsigned long (*get_rate) (struct device *dev)) +{ + struct platform_device *pdev; + struct omap_device *od; + + pdev = container_of(dev, struct platform_device, dev); + od = _find_by_pdev(pdev); + + od->set_rate = set_rate; + od->get_rate = get_rate; +} + struct device omap_device_parent = { .init_name = "omap", .parent = &platform_bus,