From patchwork Thu Apr 12 03:53:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 10337847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A443C60153 for ; Thu, 12 Apr 2018 03:57:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 930D726E55 for ; Thu, 12 Apr 2018 03:57:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8803426E76; Thu, 12 Apr 2018 03:57:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1707826E55 for ; Thu, 12 Apr 2018 03:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m5ASmJmwLx5QcZuWQiWnjD67c+z4Bfwdh1IVZeJWFfU=; b=i53SaGxlaiTP51 rKGB6CFW/Qt9dVtLBCp6RtQf3awmMlezGzM1qvJRRsfyFfayUarlVt/3X6qKEZ/JAKnI0it9keX5Z 7VHIU9cNB/RSpnSMpAeaf0znAH43K2P2qttXzoQ5ux8E0q5EnWQLlFmHh0xuc4aFTdl0bDyts0AvI YDIzovpQq8+ygfxWPTuPF2+2tb2RzsxeJ/kxrweDVNqiD8LQ1a9dgxDZOCM93GCcjdgMBNkm84rmU Z1/cqXMpgN4PixM2dtu+aX05YN8rYjKxJG/U4PZQr9T81XZX+EP2zno7H9VLZhTIcE/Ss/w+cpR1D Jauq51eTe6ZhF4YnMOgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f6TMl-0001jF-Ly; Thu, 12 Apr 2018 03:57:43 +0000 Received: from lelnx194.ext.ti.com ([198.47.27.80]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f6TK7-0007T3-PZ for linux-arm-kernel@lists.infradead.org; Thu, 12 Apr 2018 03:55:01 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3C3sjlJ026984; Wed, 11 Apr 2018 22:54:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1523505285; bh=3VCpqp6HgGvMlq/0jAtzaWUjjztLVV9+EyzxwuVptCw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=j2GFnBlpZIgx6Byao9Yvx3S5oSyMW1oRvBt3Md9eQaJzqpPYUbTMmwn/0RxVtzZRC IvBCEQLW//egz3hyVXWwLfQYBH1Rdb763E0+KD93Pa7p0ygwXE16s7Aj422u/jgDR/ Od7liPFl6bT6apDFCPGQdIgoRm6t9VeVg0JRIrXk= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3C3sjUm026195; Wed, 11 Apr 2018 22:54:45 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 11 Apr 2018 22:54:45 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Wed, 11 Apr 2018 22:54:45 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3C3sQpl010150; Wed, 11 Apr 2018 22:54:42 -0500 From: Keerthy To: , , Subject: [PATCH 04/14] ARM: OMAP2: Add functions to save and restore omap hwmod context en-masse. Date: Thu, 12 Apr 2018 09:23:49 +0530 Message-ID: <1523505239-16229-5-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1523505239-16229-1-git-send-email-j-keerthy@ti.com> References: <1523505239-16229-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180411_205459_948301_BE9D60A9 X-CRM114-Status: GOOD ( 21.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: d-gerlach@ti.com, j-keerthy@ti.com, linux-kernel@vger.kernel.org, t-kristo@ti.com, Russ.Dill@ti.com, haojian.zhuang@linaro.org, ssantosh@kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Russ Dill This is used to support suspend modes like RTC-only and hibernate where the state of these registers is lost. After the PRCM loses context in the case of an RTC+DDR cycle omap_hwmod attempts to return all hwmods to their previous state, however certain hwmods cannot just be disabled when in their default state, which is why they need the special handling present in that patch when no driver is present. In RTC+DDR mode, even if all drivers are present, the modules are all returned to their previous state before any driver resume happens so we will still face the issue described above. This can be prevented by calling _reidle on all hwmods that need it for any module that is being disabled to return to it's previous state. Signed-off-by: Dave Gerlach Signed-off-by: Russ Dill Signed-off-by: Keerthy --- arch/arm/mach-omap2/omap_hwmod.c | 67 ++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod.h | 4 +++ 2 files changed, 71 insertions(+) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 90ad8e7..f6782b4 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -4096,3 +4096,70 @@ const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh) return oh->main_clk; } + +/** + * omap_hwmod_save_context - Saves the HW reset line state of submodules + * @oh: struct omap_hwmod * + * @unused: (unused, caller should pass NULL) + * + * Saves the HW reset line state of all the submodules in the hwmod + */ +static int omap_hwmod_save_context(struct omap_hwmod *oh, void *unused) +{ + int i; + + for (i = 0; i < oh->rst_lines_cnt; i++) + oh->rst_lines[i].context = + _read_hardreset(oh, oh->rst_lines[i].name); + return 0; +} + +/** + * omap_hwmod_restore_context - Restores the HW reset line state of submodules + * @oh: struct omap_hwmod * + * @unused: (unused, caller should pass NULL) + * + * Restores the HW reset line state of all the submodules in the hwmod + */ +static int omap_hwmod_restore_context(struct omap_hwmod *oh, void *unused) +{ + int i; + + for (i = 0; i < oh->rst_lines_cnt; i++) + if (oh->rst_lines[i].context) + _assert_hardreset(oh, oh->rst_lines[i].name); + else + _deassert_hardreset(oh, oh->rst_lines[i].name); + + if (oh->_state == _HWMOD_STATE_ENABLED) { + if (soc_ops.enable_module) + soc_ops.enable_module(oh); + } else { + if (oh->flags & HWMOD_NEEDS_REIDLE) + _reidle(oh); + else if (soc_ops.disable_module) + soc_ops.disable_module(oh); + } + + return 0; +} + +/** + * omap_hwmods_save_context - Saves the HW reset line state for all hwmods + * + * Saves the HW reset line state of all the registered hwmods + */ +void omap_hwmods_save_context(void) +{ + omap_hwmod_for_each(omap_hwmod_save_context, NULL); +} + +/** + * omap_hwmods_restore_context - Restores the HW reset line state for all hwmods + * + * Restores the HW reset line state of all the registered hwmods + */ +void omap_hwmods_restore_context(void) +{ + omap_hwmod_for_each(omap_hwmod_restore_context, NULL); +} diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h index f35638b..b5e050e 100644 --- a/arch/arm/mach-omap2/omap_hwmod.h +++ b/arch/arm/mach-omap2/omap_hwmod.h @@ -168,6 +168,7 @@ struct omap_hwmod_rst_info { const char *name; u8 rst_shift; u8 st_shift; + u8 context; }; /** @@ -678,6 +679,9 @@ int omap_hwmod_for_each_by_class(const char *classname, const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh); +void omap_hwmods_save_context(void); +void omap_hwmods_restore_context(void); + /* * */