Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4065141ybg; Fri, 25 Oct 2019 12:49:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwozU57HNH8uXi8qRuLqHXwlbOczXu3PAdHK9AtbDzNe/dQ4hTTCIlagt/c7klWNLJDO6wd X-Received: by 2002:a50:8969:: with SMTP id f38mr5886951edf.211.1572032945302; Fri, 25 Oct 2019 12:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572032945; cv=none; d=google.com; s=arc-20160816; b=b7cFWq9+l3QSXt/9cCEvU/ACT8nYxe3VaUwIAcAgVWlP3Ol3wOGbsj9zSfJXJX+W8j 3bjy5fCWsDi6B9ZxbrWoxp7cRHOYdSPau4Drxq9CpAzJhTBc347k8cFz+vVk985tIwNx AFeEWP/R4g+WYPWzzLRR6F1C4PPzxPF4MIyF8Dd3dL9evexwzLC6G15IwIGYJTSyODSx hUvBJkkH5XQm/4yEwAu3ehI4MXVGW2hENl2QuS7FS8YxYr3yJvjuQi1PuyjkpIpnfL36 4jOgOYy6GjGbyPRSJMwz1qfQmGtBMaNOBHmxK/sBAMbfLaG4Yj7m7tHb34IQegcQjBHJ S+mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=I5jvp1vMdHYTwirtevZ0RZPQEpLTg6gznNHjNSh5RRI=; b=GCIIFn0UTgkIPg6YAA6sxIMFGFGzvMlGU6fbbOqZRsOpSj25/uNC9FfFSV8j7qFC1B wJx89x5mv5rL7V2ulD2YCxvjwTTL+aT7YazpBTB0OkfuAhOvhIwLGBWd84bx6UBtQst6 LN0Se0AZnBIDXWIjK2zzWZm+LaorqzIxWTL+uMoE31UhvoO4YhmIyvpktmzXsW3saM++ HoiAFEPjcC0gWk44ZagWJOaLR/OVNsWMHBaJ+VzH1tzC0VVEZGKL5hSEis5UGOFF19dZ 5CVqYO56a3vxyiYzu2sxRhoYtJ1uGwKX/2ae62ASRtLUNAIse1zCzoNOzH1s7DnhDkXT Nt6g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si1753070ejx.254.2019.10.25.12.48.41; Fri, 25 Oct 2019 12:49:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439815AbfJYLOg (ORCPT + 99 others); Fri, 25 Oct 2019 07:14:36 -0400 Received: from sci-ig2.spreadtrum.com ([222.66.158.135]:63301 "EHLO SHSQR01.spreadtrum.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2439286AbfJYLOf (ORCPT ); Fri, 25 Oct 2019 07:14:35 -0400 Received: from ig2.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTPS id x9PBE1TC066720 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Fri, 25 Oct 2019 19:14:01 +0800 (CST) (envelope-from Chunyan.Zhang@unisoc.com) Received: from localhost (10.0.74.79) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.847.32; Fri, 25 Oct 2019 19:13:55 +0800 From: Chunyan Zhang To: Stephen Boyd , Michael Turquette , Rob Herring , Mark Rutland CC: , , , Orson Zhai , Baolin Wang , Chunyan Zhang , Xiaolong Zhang , Chunyan Zhang Subject: [PATCH 1/5] clk: sprd: add gate for pll clocks Date: Fri, 25 Oct 2019 19:13:34 +0800 Message-ID: <20191025111338.27324-2-chunyan.zhang@unisoc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191025111338.27324-1-chunyan.zhang@unisoc.com> References: <20191025111338.27324-1-chunyan.zhang@unisoc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.74.79] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com x9PBE1TC066720 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaolong Zhang Some sprd's gate clocks are used to the switch of pll, which need to wait a certain time for stable after being enabled. Signed-off-by: Xiaolong Zhang Signed-off-by: Chunyan Zhang --- drivers/clk/sprd/gate.c | 19 +++++++++++++++++++ drivers/clk/sprd/gate.h | 21 +++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/clk/sprd/gate.c b/drivers/clk/sprd/gate.c index f59d1936b412..d8b480f852f3 100644 --- a/drivers/clk/sprd/gate.c +++ b/drivers/clk/sprd/gate.c @@ -79,6 +79,17 @@ static int sprd_sc_gate_enable(struct clk_hw *hw) return 0; } + +static int sprd_pll_sc_gate_prepare(struct clk_hw *hw) +{ + struct sprd_gate *sg = hw_to_sprd_gate(hw); + + clk_sc_gate_toggle(sg, true); + udelay(sg->udelay); + + return 0; +} + static int sprd_gate_is_enabled(struct clk_hw *hw) { struct sprd_gate *sg = hw_to_sprd_gate(hw); @@ -109,3 +120,11 @@ const struct clk_ops sprd_sc_gate_ops = { }; EXPORT_SYMBOL_GPL(sprd_sc_gate_ops); +#define sprd_pll_sc_gate_unprepare sprd_sc_gate_disable + +const struct clk_ops sprd_pll_sc_gate_ops = { + .unprepare = sprd_pll_sc_gate_unprepare, + .prepare = sprd_pll_sc_gate_prepare, + .is_enabled = sprd_gate_is_enabled, +}; +EXPORT_SYMBOL_GPL(sprd_pll_sc_gate_ops); diff --git a/drivers/clk/sprd/gate.h b/drivers/clk/sprd/gate.h index dc352ea55e1f..598ce607ca0a 100644 --- a/drivers/clk/sprd/gate.h +++ b/drivers/clk/sprd/gate.h @@ -14,16 +14,19 @@ struct sprd_gate { u32 enable_mask; u16 flags; u16 sc_offset; + u32 udelay; struct sprd_clk_common common; }; -#define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \ - _enable_mask, _flags, _gate_flags, _ops) \ +#define SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \ + _sc_offset, _enable_mask, _flags, \ + _gate_flags, _udelay, _ops) \ struct sprd_gate _struct = { \ .enable_mask = _enable_mask, \ .sc_offset = _sc_offset, \ .flags = _gate_flags, \ + .udelay = _udelay, \ .common = { \ .regmap = NULL, \ .reg = _reg, \ @@ -34,6 +37,12 @@ struct sprd_gate { } \ } +#define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \ + _enable_mask, _flags, _gate_flags, _ops) \ + SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \ + _sc_offset, _enable_mask, _flags, \ + _gate_flags, 0, _ops) + #define SPRD_GATE_CLK(_struct, _name, _parent, _reg, \ _enable_mask, _flags, _gate_flags) \ SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, 0, \ @@ -46,6 +55,13 @@ struct sprd_gate { _enable_mask, _flags, _gate_flags, \ &sprd_sc_gate_ops) +#define SPRD_PLL_SC_GATE_CLK(_struct, _name, _parent, _reg, _sc_offset, \ + _enable_mask, _flags, _gate_flags, _udelay) \ + SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \ + _sc_offset, _enable_mask, _flags, \ + _gate_flags, _udelay, \ + &sprd_pll_sc_gate_ops) + static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw) { struct sprd_clk_common *common = hw_to_sprd_clk_common(hw); @@ -55,5 +71,6 @@ static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw) extern const struct clk_ops sprd_gate_ops; extern const struct clk_ops sprd_sc_gate_ops; +extern const struct clk_ops sprd_pll_sc_gate_ops; #endif /* _SPRD_GATE_H_ */ -- 2.20.1