Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6240699ybi; Sun, 21 Jul 2019 12:43:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaAJQbfsYtrq/4aiXVb/9oXI7YLChbl0XJIjwQmYfeA/Ywej8ajKk/xFu0CWNbi+Q4wxh6 X-Received: by 2002:a65:44cc:: with SMTP id g12mr55565046pgs.409.1563738224684; Sun, 21 Jul 2019 12:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563738224; cv=none; d=google.com; s=arc-20160816; b=SZzXi0t8RKT7OdTIwp4k+lqsH9PH6urO1iDwy1/XPiUZwyveh4Uskjaiku3QDnF85B yDkqXEaxfWbekhCzGjGzIp6YACyEXaRUxq6cwl5o43rmMMjRxLbdZp0lPL53bMg98XOj eQ2skks45i6e4tZ424GBcXfRla5daoiPD02BiVMggzZz1bz+UrrhQnCS7M9bE5CsDkid uxfwV30BlbrwHlGCFAP0t0MPUBPeqJi4Y5ZyLfLEG8EZ5qIF9ilnS1rCluIt4lNkHVAr Xm93GogzQl2wM7CkioAyaCPoVbclbIUi+N5LrnlZE6GiT0N/tSqf9mcvrSHGcXNcVCkT BRxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=Nd1v90bh7Ho/ojHQIob7we6JLN3yOOpS5vD9L3b3q98=; b=e537WHF3CxGbT7uhpYBBwjsR3ma6p1erb0u74PjjAupNr6ay5wPwSCBX4XbSeOmBDO AN7zzXwMsyuyWlnRRya0p50kbXbOL+pOKVn/yJYOpwVQunbqAQuGDk3N2ljEBZjzA/b8 xDSdWWLoifeOzO5QkK03zrHAKb5gPZT1CP981bc0gF/rH+6yhwjLBmTpgJHQb5f/N9Nz MH/v4kJT6JM0dxYn3oz8Bs14FGN7pcUVlQgewCoHWmM+DMFcH93WxZwhwZdQZbn4Hw2+ YLU3EYGxN6hdxjpdDVRMOz0rBV6rnpRylpV6foSeQHo5fz2lbsOSnBO8gak1UWZpARqN mPnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=sT6G6U4q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m189si8429333pgm.443.2019.07.21.12.43.29; Sun, 21 Jul 2019 12:43:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=sT6G6U4q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727473AbfGUTk7 (ORCPT + 99 others); Sun, 21 Jul 2019 15:40:59 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:12466 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727278AbfGUTk6 (ORCPT ); Sun, 21 Jul 2019 15:40:58 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 21 Jul 2019 12:40:57 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Sun, 21 Jul 2019 12:40:57 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Sun, 21 Jul 2019 12:40:57 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sun, 21 Jul 2019 19:40:56 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Sun, 21 Jul 2019 19:40:56 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.164.85]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Sun, 21 Jul 2019 12:40:56 -0700 From: Sowjanya Komatineni To: , , , , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH V6 04/21] clk: tegra: Save and restore divider rate Date: Sun, 21 Jul 2019 12:40:43 -0700 Message-ID: <1563738060-30213-5-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563738060-30213-1-git-send-email-skomatineni@nvidia.com> References: <1563738060-30213-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1563738057; bh=Nd1v90bh7Ho/ojHQIob7we6JLN3yOOpS5vD9L3b3q98=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=sT6G6U4quiCzDr/cNiyqeiylZFrOn1UvABjs7Yd4r7s7qEStzy97Bn2NC9WAqGcBf O5lrsuV5rI/F63BJmvIqezbpIgk6F7jo9McNp2yS/jePFMOJJohqZ+M3ijSdAMtxH5 OMXQRoOZ5SRxYNduehdJLmo9nYs2im5SO3FS/GmnnPZmVy0jbnkg3mhhrgp9iTjNGf xt/r/IY2qWeppBsywwBzs0sKSJ5kmHktReacw+L6T3gkXBxQJiGUf2eMsT8ubtXjht rTNkzh0G8q63dipefnAmcftWrF+WxOuzhUj9qlB27PyBi1mZ6sLNUbKnPNJKQkIK8g vj2q7DfWiVL+w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch implements context save and restore for clock divider. During system suspend, core power goes off and looses the settings of the Tegra CAR controller registers. So during suspend entry the context of clock divider is saved and on resume context is restored back for normal operation. Acked-by: Thierry Reding Signed-off-by: Sowjanya Komatineni --- drivers/clk/tegra/clk-divider.c | 23 +++++++++++++++++++++++ drivers/clk/tegra/clk.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/drivers/clk/tegra/clk-divider.c b/drivers/clk/tegra/clk-divider.c index e76731fb7d69..ecb7ff9ce97e 100644 --- a/drivers/clk/tegra/clk-divider.c +++ b/drivers/clk/tegra/clk-divider.c @@ -109,10 +109,33 @@ static int clk_frac_div_set_rate(struct clk_hw *hw, unsigned long rate, return 0; } +static int clk_divider_save_context(struct clk_hw *hw) +{ + struct tegra_clk_frac_div *divider = to_clk_frac_div(hw); + struct clk_hw *parent = clk_hw_get_parent(hw); + unsigned long parent_rate = clk_hw_get_rate(parent); + + divider->rate = clk_frac_div_recalc_rate(hw, parent_rate); + + return 0; +} + +static void clk_divider_restore_context(struct clk_hw *hw) +{ + struct tegra_clk_frac_div *divider = to_clk_frac_div(hw); + struct clk_hw *parent = clk_hw_get_parent(hw); + unsigned long parent_rate = clk_hw_get_rate(parent); + + if (clk_frac_div_set_rate(hw, divider->rate, parent_rate) < 0) + WARN_ON(1); +} + const struct clk_ops tegra_clk_frac_div_ops = { .recalc_rate = clk_frac_div_recalc_rate, .set_rate = clk_frac_div_set_rate, .round_rate = clk_frac_div_round_rate, + .save_context = clk_divider_save_context, + .restore_context = clk_divider_restore_context, }; struct clk *tegra_clk_register_divider(const char *name, diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h index 905bf1096558..83623f5f55f3 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -42,6 +42,7 @@ struct clk *tegra_clk_register_sync_source(const char *name, * @width: width of the divider bit field * @frac_width: width of the fractional bit field * @lock: register lock + * @rate: rate during suspend and resume * * Flags: * TEGRA_DIVIDER_ROUND_UP - This flags indicates to round up the divider value. @@ -62,6 +63,7 @@ struct tegra_clk_frac_div { u8 width; u8 frac_width; spinlock_t *lock; + unsigned long rate; }; #define to_clk_frac_div(_hw) container_of(_hw, struct tegra_clk_frac_div, hw) -- 2.7.4