Skip to contentSkip to conversation

Misc patches to support clocks for SDM845

PATCH Applied Amit Nischal 2 participants 7 messages May 7, 2018 – May 8, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v7 cover Misc patches to support clocks for SDM845

Changes in v7:
1. Addressed review comments from Stephen and Rob for GCC driver.
- Split dt-bindings to a separate patch from the driver patch.
- Change the 'halt_check' type to BRANCH_HALT_SKIP for pipe and ufs_card tx/rx symbol clocks.
- Remove 'halt_reg' for the clocks where 'halt_check' type is BRANCH_HALT_DELAY. For such clocks, there is no status bit to poll. For e.g. gcc_disp_gpll0_clk_src clock.
2. Implemented rcg2_shared_ops as suggested by Stephen in
https://lkml.org/lkml/2018/5/2/91.
3. The GCC clock driver(patch 3) depends upon the below patches related to GDSC operation and RPMh clock driver, which are under review.
https://lkml.org/lkml/2018/4/27/110
https://lkml.org/lkml/2018/4/24/390

Changes in v6:
1. Addressed review comments for v3 and v4 version of GCC driver for SDM845.
https://lkml.org/lkml/2018/4/16/1129.
2. Add support for new flag 'BRANCH_NO_DELAY' for branch clocks.
3. Addressed review comments for v5 version of rcg2_shared_ops patch.
https://lkml.org/lkml/2018/4/19/86
4. The GCC clock driver(patch 3) depends upon the below patches related to GDSC operation and RPMh clock driver, which are under review.
https://lkml.org/lkml/2018/4/27/110
https://lkml.org/lkml/2018/4/24/390

Changes in v5:
1. Addressed review comments for v3 and v4 version of GCC driver for SDM845
https://lkml.org/lkml/2018/4/16/1129
2. Removed bi_tcxo clock being modelled from the GCC driver, as RPMH clock driver would provide the same. https://lkml.org/lkml/2018/4/13/685
3. The GCC clock driver(patch 2) depends upon the below patches related to GDSC operation and RPMh clock driver, which are under review.
https://lkml.org/lkml/2018/4/2/143
https://lkml.org/lkml/2018/4/13/685

Changes in v4:
1. Addressed review comments for v2 version of GCC driver for SDM845
https://lkml.org/lkml/2018/4/9/55.
2. The GCC clock driver(patch 3) depends upon the below patches related to GDSC operation and are under review.

https://lkml.org/lkml/2018/4/2/142

Changes in v3:
1. Addressed review comments given for v2 series.
2. The GCC clock driver(patch 3) depends upon the below patches related to GDSC operation and are under review.

https://lkml.org/lkml/2018/4/2/142

Changes in v2:
Fixup for recalc_rate ops for clk_rcg2_shared_ops:
There could be few scenarios where shared clocks are configured at rate other than CXO by boot. In those cases there would be a mismatch between the rate calculated by the recalc shared ops and the actual HW register configuration. Fix the same by adding an additional check to read current src from CFG register and make a decision based on that.

Changes in v1:
https://lkml.org/lkml/2018/1/31/209

This patch series does the miscellaneous changes to support clock nodes for SDM845. Below are the major changes for which the existing code does not have support.

1. Clear hardware clock control bit of RCGs where HW clock control bit is set by default so that software can control those root clocks.
2. Introduces clk_rcg2_shared_ops to support clock controller drivers for SDM845. With new shared ops, RCGs with shared branches will be configured to a safe source in disable path and actual RCG update configuration will be done in enable path instead of doing config update in set_rate. In set_rate(), just cache the rate instead of doing actual configuration update. Also each RCG in clock controller driver will have their own safe configuration frequency table to switch to safe frequency.
3. Add support for controlling Fabia PLL for which the support is not available in existing alpha PLL code.
4. Add Global Clock controller (GCC) driver for SDM845. This should allow most non-multimedia device drivers to probe and control their clocks.

[v1] : https://lkml.org/lkml/2018/1/31/209
[v2] : https://lkml.org/lkml/2018/3/8/495
[v3] : https://lkml.org/lkml/2018/4/3/356
[v4] : https://lkml.org/lkml/2018/4/9/79
[v5] : https://lkml.org/lkml/2018/4/18/367
[v6] : https://lkml.org/lkml/2018/4/30/533

Amit Nischal (2):
clk: qcom: Configure the RCGs to a safe source as needed
clk: qcom: Add DT bindings for SDM845 gcc clock controller

Taniya Das (1):
clk: qcom: Add Global Clock controller (GCC) driver for SDM845

 .../devicetree/bindings/clock/qcom,gcc.txt         |    1 +
 drivers/clk/qcom/Kconfig                           |    9 +
 drivers/clk/qcom/Makefile                          |    1 +
 drivers/clk/qcom/clk-rcg.h                         |   17 +-
 drivers/clk/qcom/clk-rcg2.c                        |  170 +-
 drivers/clk/qcom/gcc-sdm845.c                      | 3465 ++++++++++++++++++++
 include/dt-bindings/clock/qcom,gcc-sdm845.h        |  239 ++
 7 files changed, 3878 insertions(+), 24 deletions(-)
 create mode 100644 drivers/clk/qcom/gcc-sdm845.c
 create mode 100644 include/dt-bindings/clock/qcom,gcc-sdm845.h

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

#1 lore raw

PATCH v7 1/3 clk: qcom: Configure the RCGs to a safe source as needed

For some root clock generators, there could be child branches which are controlled by an entity other than application processor subsystem. For such RCGs, as per application processor subsystem clock driver, all of its downstream clocks are disabled and RCG is in disabled state but in reality downstream clocks can be left enabled before.

So in this scenario, when RCG is disabled as per clock driver's point of view and when rate scaling request comes before downstream clock enable request, then RCG fails to update its configuration because in reality RCG is on and it expects its new source to already be in enable state but in reality new source is off. In order to avoid having the RCG to go into an invalid state, add support to update the CFG, M, N and D registers during set_rate() without configuration update and defer the actual RCG configuration update to be done during clk_enable() as at this point of time, both its new parent and safe source will be already enabled and RCG can safely switch to new parent.

During clk_disable() request, configure it to safe source as both its parents, safe source and current parent will be enabled and RCG can safely execute a switch.

---
 drivers/clk/qcom/clk-rcg.h  |  17 ++---
 drivers/clk/qcom/clk-rcg2.c | 170 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 163 insertions(+), 24 deletions(-)
drivers/clk/qcom/clk-rcg.h +5 -12
index 2a7489a..b209a2f 100644
@@ -1,15 +1,5 @@
-/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2013, 2018, The Linux Foundation. All rights reserved. */
 
 #ifndef __QCOM_CLK_RCG_H__
 #define __QCOM_CLK_RCG_H__
@@ -144,6 +134,7 @@ struct clk_dyn_rcg {
  * @cmd_rcgr: corresponds to *_CMD_RCGR
  * @mnd_width: number of bits in m/n/d values
  * @hid_width: number of bits in half integer divider
+ * @safe_src_index: safe src index value
  * @parent_map: map from software's parent index to hardware's src_sel field
  * @freq_tbl: frequency table
  * @clkr: regmap clock handle
@@ -153,6 +144,7 @@ struct clk_rcg2 {
 	u32			cmd_rcgr;
 	u8			mnd_width;
 	u8			hid_width;
+	u8			safe_src_index;
 	const struct parent_map	*parent_map;
 	const struct freq_tbl	*freq_tbl;
 	struct clk_regmap	clkr;
@@ -167,5 +159,6 @@ struct clk_rcg2 {
 extern const struct clk_ops clk_byte2_ops;
 extern const struct clk_ops clk_pixel_ops;
 extern const struct clk_ops clk_gfx3d_ops;
+extern const struct clk_ops clk_rcg2_shared_ops;
 
 #endif
drivers/clk/qcom/clk-rcg2.c +158 -12

190 lines not on this page · raw message

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

maintainer Applied
#2 lore raw

Re: [PATCH v7 1/3] clk: qcom: Configure the RCGs to a safe source as needed

Quoting Amit Nischal (2018-05-07 03:50:18)

Quoted 17 lines

For some root clock generators, there could be child branches which are controlled by an entity other than application processor subsystem. For such RCGs, as per application processor subsystem clock driver, all of its downstream clocks are disabled and RCG is in disabled state but in reality downstream clocks can be left enabled before.

So in this scenario, when RCG is disabled as per clock driver's point of view and when rate scaling request comes before downstream clock enable request, then RCG fails to update its configuration because in reality RCG is on and it expects its new source to already be in enable state but in reality new source is off. In order to avoid having the RCG to go into an invalid state, add support to update the CFG, M, N and D registers during set_rate() without configuration update and defer the actual RCG configuration update to be done during clk_enable() as at this point of time, both its new parent and safe source will be already enabled and RCG can safely switch to new parent.

Quoted 7 lines

During clk_disable() request, configure it to safe source as both its parents, safe source and current parent will be enabled and RCG can safely execute a switch.

---

Applied to clk-next. I squashed some style fixups and logic simplifications in too.

drivers/clk/qcom/clk-rcg2.c +7 -15
index 6827ab32c82c..e63911cbfef9 100644
@@ -797,7 +797,6 @@ static int clk_rcg2_set_force_enable(struct clk_hw *hw)
 	const char *name = clk_hw_get_name(hw);
 	int ret, count;
 
-	/* Force enable bit */
 	ret = regmap_update_bits(rcg->clkr.regmap, rcg->cmd_rcgr + CMD_REG,
 				 CMD_ROOT_EN, CMD_ROOT_EN);
 	if (ret)
@@ -808,12 +807,10 @@ static int clk_rcg2_set_force_enable(struct clk_hw *hw)
 		if (clk_rcg2_is_enabled(hw))
 			return 0;
 
-		/* Delay for 1usec and retry polling the status bit */
 		udelay(1);
 	}
-	if (!count)
-		pr_err("%s: RCG did not turn on\n", name);
 
+	pr_err("%s: RCG did not turn on\n", name);
 	return -ETIMEDOUT;
 }
 
@@ -821,7 +818,6 @@ static int clk_rcg2_clear_force_enable(struct clk_hw *hw)
 {
 	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
 
-	/* Clear force enable bit */
 	return regmap_update_bits(rcg->clkr.regmap, rcg->cmd_rcgr + CMD_REG,
 					CMD_ROOT_EN, 0);
 }
@@ -832,9 +828,6 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)
 	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
 	int ret;
 
-	if (!f)
-		return -EINVAL;
-
 	ret = clk_rcg2_set_force_enable(hw);
 	if (ret)
 		return ret;
@@ -858,10 +851,9 @@ static int clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
 
 	/*
 	 * In case clock is disabled, update the CFG, M, N and D registers
-	 * and do not hit the update bit of CMD register.
+	 * and don't hit the update bit of CMD register.
 	 */
 	if (!__clk_is_enabled(hw->clk))
-		/* Skip the configuration update */
 		return __clk_rcg2_configure(rcg, f);
 
 	return clk_rcg2_shared_force_enable_clear(hw, f);
@@ -879,8 +871,8 @@ static int clk_rcg2_shared_enable(struct clk_hw *hw)
 	int ret;
 
 	/*
-	 * Set the update bit only.
-	 * As required configuration has been already written in set_rate() op.
+	 * Set the update bit because required configuration has already
+	 * been written in set_rate() op.
 	 */
 	ret = clk_rcg2_set_force_enable(hw);
 	if (ret)
@@ -899,8 +891,8 @@ static void clk_rcg2_shared_disable(struct clk_hw *hw)
 	u32 cfg;
 
 	/*
-	 * Store current configuration as switching to safe source
-	 * would clear the SRC and DIV of CFG register.
+	 * Store current configuration as switching to safe source would clear
+	 * the SRC and DIV of CFG register.
 	 */
 	regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG, &cfg);
 
@@ -915,7 +907,7 @@ static void clk_rcg2_shared_disable(struct clk_hw *hw)
 	clk_rcg2_set_force_enable(hw);
 
 	regmap_write(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG,
-				rcg->safe_src_index << CFG_SRC_SEL_SHIFT);
+		     rcg->safe_src_index << CFG_SRC_SEL_SHIFT);
 
 	update_config(rcg);
 
#3 lore raw

PATCH v7 2/3 clk: qcom: Add DT bindings for SDM845 gcc clock controller

In reply to Amit Nischal

Add compatible string and the include file for gcc clock controller for SDM845.

---
 .../devicetree/bindings/clock/qcom,gcc.txt         |   1 +
 include/dt-bindings/clock/qcom,gcc-sdm845.h        | 239 +++++++++++++++++++++
 2 files changed, 240 insertions(+)
 create mode 100644 include/dt-bindings/clock/qcom,gcc-sdm845.h
Documentation/devicetree/bindings/clock/qcom,gcc.txt +1 -0
index d1fb8b2..664ea1f 100644
@@ -19,6 +19,7 @@ Required properties :
 			"qcom,gcc-msm8996"
 			"qcom,gcc-msm8998"
 			"qcom,gcc-mdm9615"
+			"qcom,gcc-sdm845"
 
 - reg : shall contain base register location and length
 - #clock-cells : shall contain 1
include/dt-bindings/clock/qcom,gcc-sdm845.h new file +239 -0

239 lines not on this page · raw message

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

#5 lore raw

PATCH v7 3/3 clk: qcom: Add Global Clock controller (GCC) driver for SDM845

In reply to Amit Nischal

From: Taniya Das <[email protected]>

Add support for the global clock controller found on SDM845 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.

---
 drivers/clk/qcom/Kconfig      |    9 +
 drivers/clk/qcom/Makefile     |    1 +
 drivers/clk/qcom/gcc-sdm845.c | 3465 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 3475 insertions(+)
 create mode 100644 drivers/clk/qcom/gcc-sdm845.c
drivers/clk/qcom/Kconfig +9 -0
index e42e1af..aec69d2 100644
@@ -226,6 +226,15 @@ config MSM_GCC_8998
 	  Say Y if you want to use peripheral devices such as UART, SPI,
 	  i2c, USB, UFS, SD/eMMC, PCIe, etc.
 
+config SDM_GCC_845
+	tristate "SDM845 Global Clock Controller"
+	select QCOM_GDSC
+	depends on COMMON_CLK_QCOM
+	help
+	  Support for the global clock controller on msm8998 devices.
+	  Say Y if you want to use peripheral devices such as UART, SPI,
+	  I2C, USB, UFS, SDDC, PCIe, etc.
+
 config SPMI_PMIC_CLKDIV
 	tristate "SPMI PMIC clkdiv Support"
 	depends on (COMMON_CLK_QCOM && SPMI) || COMPILE_TEST
drivers/clk/qcom/Makefile +1 -0
index 7c09ab1..bf8fb25 100644
@@ -38,4 +38,5 @@ obj-$(CONFIG_QCOM_A53PLL) += a53-pll.o
 obj-$(CONFIG_QCOM_CLK_APCS_MSM8916) += apcs-msm8916.o
 obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o
 obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o
+obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
 obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
drivers/clk/qcom/gcc-sdm845.c new file +3465 -0

2,980 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

Part of the diff is not shown here. View the raw message.

maintainer Applied
#6 lore raw

Re: [PATCH v7 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SDM845

Quoting Amit Nischal (2018-05-07 03:50:20)

Quoted 9 lines

From: Taniya Das <[email protected]>

Add support for the global clock controller found on SDM845 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.

---

Applied to clk-next