From patchwork Tue Jun 19 04:28:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 10473101 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 C7333603B5 for ; Tue, 19 Jun 2018 04:29:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0134287CF for ; Tue, 19 Jun 2018 04:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 932972876E; Tue, 19 Jun 2018 04:29:05 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3458D28746 for ; Tue, 19 Jun 2018 04:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750917AbeFSE25 (ORCPT ); Tue, 19 Jun 2018 00:28:57 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:9215 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965048AbeFSE2x (ORCPT ); Tue, 19 Jun 2018 00:28:53 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w5J4SnGK012519; Mon, 18 Jun 2018 23:28:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1529382529; bh=SVt5qUG69WEdc0+DdygbTAchqGoRyD18Xs3bDpFHZEA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yasODeEUukFOCLYQ0ER6vXYoMxE1MOWzMXyqHcVTTF7dVb2CC/mz0yeAxp4YPbJFb MmXAclOVqelSGFdJTvfpkNIMjIVB4LnsJqs25pjhEGWa2dt93AmFzFlFuI3yv0FjR9 7lfrH9mVDPQ/do3P0nOjjA/YW+bgyPT0dpuD0Kw0= 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 w5J4Snqr023090; Mon, 18 Jun 2018 23:28:49 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) 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.1466.3; Mon, 18 Jun 2018 23:28:49 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 18 Jun 2018 23:28:49 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w5J4SeQs004959; Mon, 18 Jun 2018 23:28:47 -0500 From: Keerthy To: , , CC: , , , , , Subject: [PATCH 2/4] clk: clk: Add clk_dflt_restore Date: Tue, 19 Jun 2018 09:58:23 +0530 Message-ID: <1529382505-3069-3-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1529382505-3069-1-git-send-email-j-keerthy@ti.com> References: <1529382505-3069-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The default restore context function enables or disables the clock based on the enable_count. This is done in cases where the clock context is lost and based on the enable_count the clock either needs to be enabled/disabled. This particularly helps restore the state of gate clocks. Signed-off-by: Keerthy --- drivers/clk/clk.c | 19 +++++++++++++++++++ include/linux/clk-provider.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 7347e06..c201b8b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -910,6 +910,25 @@ static int clk_core_enable_lock(struct clk_core *core) return ret; } +/** + * clk_dflt_restore_context - restore context for poweroff + * @hw: the clk_hw pointer of clock whose state is to be restored + * + * The default restore context function enables or disables + * the clock based on the enable_count. This is done in cases + * where the clock context is lost and based on the enable_count + * the clock either needs to be enabled/disabled. This particularly + * helps restore the state of gate clocks. + */ +void clk_dflt_restore_context(struct clk_hw *hw) +{ + if (hw->clk->core->enable_count) + hw->clk->core->ops->enable(hw); + else + hw->clk->core->ops->disable(hw); +} +EXPORT_SYMBOL_GPL(clk_dflt_restore_context); + static int _clk_save_context(struct clk_core *clk) { struct clk_core *child; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 7f30d62..3e0c61a 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -992,5 +992,7 @@ static inline void clk_writel(u32 val, u32 __iomem *reg) #endif /* platform dependent I/O accessors */ +void clk_dflt_restore_context(struct clk_hw *hw); + #endif /* CONFIG_COMMON_CLK */ #endif /* CLK_PROVIDER_H */