From patchwork Fri Aug 10 18:39:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1306361 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2D41B3FC33 for ; Fri, 10 Aug 2012 18:39:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759934Ab2HJSjV (ORCPT ); Fri, 10 Aug 2012 14:39:21 -0400 Received: from na3sys009aog109.obsmtp.com ([74.125.149.201]:47888 "EHLO na3sys009aog109.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759914Ab2HJSjT (ORCPT ); Fri, 10 Aug 2012 14:39:19 -0400 Received: from mail-pb0-f51.google.com ([209.85.160.51]) (using TLSv1) by na3sys009aob109.postini.com ([74.125.148.12]) with SMTP ID DSNKUCVVVipZdcZU4biw6DqfR0axf3dNM4gV@postini.com; Fri, 10 Aug 2012 11:39:19 PDT Received: by pbbro8 with SMTP id ro8so2658191pbb.10 for ; Fri, 10 Aug 2012 11:39:18 -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:in-reply-to:references :x-gm-message-state; bh=Qa60kL2ql8T03VTX3+0U7d09yTlrYFQ5JJJ24vfYCx8=; b=bA19eqAfavcb1Y07yG9rw0x8+hX0R3SPCWDoPetVntdGg55o83jhCcAJJxsDQNLwQC uy2PuOiOQM8+yjqO4+7Iw4K89HsVj+xdy3AjEr7xVY/HgOlc8LR7dQjRm/+UtmWDfd4c XmTtrwMORTgyWPj95UBu5+P6fTt15ylssVfnX2ic9Mu1JgTMrp3WuLrLeU3StIWzzlb/ 27k8A1K+kPI/dpbv2beErxmxrFgj7tMaDqsVZgH09vg1gBusmk872+IGVK9arGpEDJvg B6LPO5q+HXyNDtZjIB3B5iFRAKqCCgpOmw0OnpuIwIF/8GdRuY19NVNeZHrNlnmxiNbe pLsg== Received: by 10.68.226.102 with SMTP id rr6mr14452624pbc.99.1344623958100; Fri, 10 Aug 2012 11:39:18 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id ro7sm3824407pbc.8.2012.08.10.11.39.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Aug 2012 11:39:17 -0700 (PDT) From: Kevin Hilman To: Paul Walmsley , linux-omap@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/3] ARM: OMAP: omap_device: idle devices with no driver bound Date: Fri, 10 Aug 2012 11:39:13 -0700 Message-Id: <1344623953-26434-4-git-send-email-khilman@ti.com> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1344623953-26434-1-git-send-email-khilman@ti.com> References: <1344623953-26434-1-git-send-email-khilman@ti.com> X-Gm-Message-State: ALoCoQk9ja2KOPmXOFWkBT5DCiNvfBhWafdSMgwIIkxbEorsTTeyB36oevtXJviN9PU0R0UdDTXG Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Under some circumstances, drivers may leave an omap_device enabled due to driver programming errors, or due to a failure in the drivers probe method. Using the recently added omap_device driver_status field, we can detect conditions where an omap_device is enabled but has no driver bound and then ensure that the device is properly idled until it can be probed again. The goal of this feature is not only to detect and warn on these error conditions, but also to ensure that devices are properly put in low-power states so they do not prevent SoC-wide low-power states. Cc: Paul Walmsley Signed-off-by: Kevin Hilman --- arch/arm/plat-omap/omap_device.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 150112e..0693260 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -1133,3 +1133,41 @@ static int __init omap_device_init(void) return 0; } core_initcall(omap_device_init); + +/** + * omap_device_late_idle - idle devices without drivers + * @dev: struct device * associated with omap_device + * @data: unused + * + * Check the driver bound status of this device, and idle it + * if there is no driver attached. + */ +static int __init omap_device_late_idle(struct device *dev, void *data) +{ + struct platform_device *pdev = to_platform_device(dev); + struct omap_device *od = to_omap_device(pdev); + + if (!od) + return 0; + + /* + * If omap_device state is enabled, but has no driver bound, + * idle it. + */ + if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) { + if (od->_state == OMAP_DEVICE_STATE_ENABLED) { + dev_warn(dev, "%s: enabled but no driver. Idling\n", + __func__); + omap_device_idle(pdev); + } + } + + return 0; +} + +static int __init omap_device_late_init(void) +{ + bus_for_each_dev(&platform_bus_type, NULL, NULL, omap_device_late_idle); + return 0; +} +late_initcall(omap_device_late_init);