From patchwork Tue Dec 21 07:12:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 423651 X-Patchwork-Delegate: paul@pwsan.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 oBL7EJnm026136 for ; Tue, 21 Dec 2010 07:14:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753163Ab0LUHOS (ORCPT ); Tue, 21 Dec 2010 02:14:18 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:42640 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752481Ab0LUHOS (ORCPT ); Tue, 21 Dec 2010 02:14:18 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id oBL7EB8T000921 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 21 Dec 2010 01:14:14 -0600 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id oBL7Dxrt027940; Tue, 21 Dec 2010 12:44:09 +0530 (IST) From: Kishon Vijay Abraham I To: linux-omap@vger.kernel.org Cc: paul@pwsan.com, khilman@deeprootsystems.com, p-basak2@ti.com, b-cousson@ti.com, kishon@ti.com Subject: [PATCH v1 2/2] OMAP: omap_device: API to modify AUTOIDLE and SMARTIDLE bits Date: Tue, 21 Dec 2010 12:42:40 +0530 Message-Id: <1292915560-13601-3-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1292915560-13601-1-git-send-email-kishon@ti.com> References: <1292915560-13601-1-git-send-email-kishon@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]); Tue, 21 Dec 2010 07:14:19 +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..3895ab4 100644 --- a/arch/arm/plat-omap/include/plat/omap_device.h +++ b/arch/arm/plat-omap/include/plat/omap_device.h @@ -109,6 +109,12 @@ int omap_device_align_pm_lat(struct platform_device *pdev, struct powerdomain *omap_device_get_pwrdm(struct omap_device *od); /* Other */ +int omap_device_noidle(struct omap_device *od); +int omap_device_smartidle(struct omap_device *od); +int omap_device_forceidle(struct omap_device *od); +int omap_device_default_idle(struct omap_device *od); +int omap_device_enable_autoidle(struct omap_device *od); +int omap_device_disable_autoidle(struct omap_device *od); int omap_device_idle_hwmods(struct omap_device *od); int omap_device_enable_hwmods(struct omap_device *od); diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index abe933c..f2c6b3d 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -698,6 +698,182 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od) return omap_hwmod_get_mpu_rt_va(od->hwmods[0]); } +/** + * omap_device_noidle - set the device's slave idlemode to no idle + * @od: struct omap_device * + * + * Sets the IP block's OCP slave idlemode in hardware to no idle. + * Intended to be used by drivers that have some erratum that requires direct + * manipulation of the SIDLEMODE bits. Returns -EINVAL if @od is in invalid + * state, or passes along the return value from + * omap_hwmod_set_slave_idlemode(). + */ +int omap_device_noidle(struct omap_device *od) +{ + int retval = 0, i; + + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { + WARN(1, "omap_device: %s.%d: %s() called from invalid state " + "%d\n", od->pdev.name, od->pdev.id, __func__, + od->_state); + return -EINVAL; + } + + for (i = 0; i < od->hwmods_cnt; i++) + retval |= omap_hwmod_set_slave_idlemode(od->hwmods[i], + HWMOD_IDLEMODE_NO); + + return retval; +} + + +/** + * omap_device_smartidle - set the device's slave idlemode to smart idle + * @od: struct omap_device * + * + * Sets the IP block's OCP slave idlemode in hardware to smart idle. + * Intended to be used by drivers that have some erratum that requires direct + * manipulation of the SIDLEMODE bits. Returns -EINVAL if @od is in invalid + * state, or passes along the return value from + * omap_hwmod_set_slave_idlemode(). + */ +int omap_device_smartidle(struct omap_device *od) +{ + int retval = 0, i; + + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { + WARN(1, "omap_device: %s.%d: %s() called from invalid state " + "%d\n", od->pdev.name, od->pdev.id, __func__, + od->_state); + return -EINVAL; + } + + for (i = 0; i < od->hwmods_cnt; i++) + retval |= omap_hwmod_set_slave_idlemode(od->hwmods[i], + HWMOD_IDLEMODE_SMART); + + return retval; +} + + +/** + * omap_device_forceidle - set the device's slave idlemode to force idle + * @od: struct omap_device * + * + * Sets the IP block's OCP slave idlemode in hardware to force idle. + * Intended to be used by drivers that have some erratum that requires direct + * manipulation of the SIDLEMODE bits. Returns -EINVAL if @od is in invalid + * state, or passes along the return value from + * omap_hwmod_set_slave_idlemode(). + */ +int omap_device_forceidle(struct omap_device *od) +{ + int retval = 0, i; + + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { + WARN(1, "omap_device: %s.%d: %s() called from invalid state " + "%d\n", od->pdev.name, od->pdev.id, __func__, + od->_state); + return -EINVAL; + } + + for (i = 0; i < od->hwmods_cnt; i++) + retval |= omap_hwmod_set_slave_idlemode(od->hwmods[i], + HWMOD_IDLEMODE_FORCE); + + return retval; +} + +/** + * omap_device_default_idle - set the device's slave idlemode to no idle or + * smart idle based on the hwmod flag + * @od: struct omap_device * + * + * Sets the IP block's OCP slave idlemode in hardware to no idle or smart idle + * depending on status of the flag HWMOD_SWSUP_SIDLE. + * Intended to be used by drivers that have some erratum that requires direct + * manipulation of the SIDLEMODE bits. Returns -EINVAL if @od is in invalid + * state, or passes along the return value from + * omap_hwmod_set_slave_idlemode(). + */ +int omap_device_default_idle(struct omap_device *od) +{ + int retval = 0, i; + u8 idlemode; + + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { + WARN(1, "omap_device: %s.%d: %s() called from invalid state " + "%d\n", od->pdev.name, od->pdev.id, __func__, + od->_state); + return -EINVAL; + } + + for (i = 0; i < od->hwmods_cnt; i++) { + idlemode = (od->hwmods[i]->flags & HWMOD_SWSUP_SIDLE) ? + HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; + retval |= omap_hwmod_set_slave_idlemode(od->hwmods[i], + idlemode); + } + + return retval; +} + +/* + * omap_device_enable_autoidle - enable the device's OCP slave autoidle + * @od: struct omap_device * + * + * Sets the IP block's OCP slave autoidle in hardware. + * Intended to be used by drivers that have some erratum that requires direct + * manipulation of the AUTOIDLE bits. Returns -EINVAL if @od is in invalid + * state, or passes along the return value from + * omap_hwmod_set_slave_autoidle(). + */ +int omap_device_enable_autoidle(struct omap_device *od) +{ + int retval = 0, i; + + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { + WARN(1, "omap_device: %s.%d: %s() called from invalid state " + "%d\n", od->pdev.name, od->pdev.id, __func__, + od->_state); + return -EINVAL; + } + + for (i = 0; i < od->hwmods_cnt; i++) + retval |= omap_hwmod_set_slave_autoidle(od->hwmods[i], + true); + + return retval; +} + +/* + * omap_device_disable_autoidle - disable the device's OCP slave autoidle + * @od: struct omap_device * + * + * Disables the IP block's OCP slave autoidle in hardware. + * Intended to be used by drivers that have some erratum that requires direct + * manipulation of the AUTOIDLE bits. Returns -EINVAL if @od is in invalid + * state, or passes along the return value from + * omap_hwmod_set_slave_autoidle(). + */ +int omap_device_disable_autoidle(struct omap_device *od) +{ + int retval = 0, i; + + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { + WARN(1, "omap_device: %s.%d: %s() called from invalid state " + "%d\n", od->pdev.name, od->pdev.id, __func__, + od->_state); + return -EINVAL; + } + + for (i = 0; i < od->hwmods_cnt; i++) + retval |= omap_hwmod_set_slave_autoidle(od->hwmods[i], + false); + + return retval; +} + /* * Public functions intended for use in omap_device_pm_latency * .activate_func and .deactivate_func function pointers