Skip to contentSkip to conversation

clk: qcom: clk-alpha-pll: Add support for Trion PLLs

PATCH In review Vinod Koul 3 participants 11 messages Jun 7, 2019 – Jul 9, 2019

Subsystems (4)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

PATCH 1/2 clk: qcom: clk-alpha-pll: Add support for Trion PLLs

From: Deepak Katragadda <[email protected]>

Add programming sequence support for managing the Trion PLLs.

[vkoul: port to upstream and tidy-up]
---
 drivers/clk/qcom/clk-alpha-pll.c | 266 +++++++++++++++++++++++++++++++
 drivers/clk/qcom/clk-alpha-pll.h |   9 ++
 2 files changed, 275 insertions(+)
drivers/clk/qcom/clk-alpha-pll.c +266 -0
index 0ced4a5a9a17..bf36a929458b 100644
@@ -32,6 +32,7 @@
 # define PLL_LOCK_DET		BIT(31)
 
 #define PLL_L_VAL(p)		((p)->offset + (p)->regs[PLL_OFF_L_VAL])
+#define PLL_CAL_L_VAL(p)	((p)->offset + (p)->regs[PLL_OFF_CAL_L_VAL])
 #define PLL_ALPHA_VAL(p)	((p)->offset + (p)->regs[PLL_OFF_ALPHA_VAL])
 #define PLL_ALPHA_VAL_U(p)	((p)->offset + (p)->regs[PLL_OFF_ALPHA_VAL_U])
 
@@ -44,14 +45,17 @@
 # define PLL_VCO_MASK		0x3
 
 #define PLL_USER_CTL_U(p)	((p)->offset + (p)->regs[PLL_OFF_USER_CTL_U])
+#define PLL_USER_CTL_U1(p)	((p)->offset + (p)->regs[PLL_OFF_USER_CTL_U1])
 
 #define PLL_CONFIG_CTL(p)	((p)->offset + (p)->regs[PLL_OFF_CONFIG_CTL])
 #define PLL_CONFIG_CTL_U(p)	((p)->offset + (p)->regs[PLL_OFF_CONFIG_CTL_U])
+#define PLL_CONFIG_CTL_U1(p)	((p)->offset + (p)->regs[PLL_OFF_CONFIG_CTL_U11])
 #define PLL_TEST_CTL(p)		((p)->offset + (p)->regs[PLL_OFF_TEST_CTL])
 #define PLL_TEST_CTL_U(p)	((p)->offset + (p)->regs[PLL_OFF_TEST_CTL_U])
 #define PLL_STATUS(p)		((p)->offset + (p)->regs[PLL_OFF_STATUS])
 #define PLL_OPMODE(p)		((p)->offset + (p)->regs[PLL_OFF_OPMODE])
 #define PLL_FRAC(p)		((p)->offset + (p)->regs[PLL_OFF_FRAC])
+#define PLL_CAL_VAL(p)		((p)->offset + (p)->regs[PLL_OFF_CAL_VAL])
 
 const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = {
 	[CLK_ALPHA_PLL_TYPE_DEFAULT] =  {
@@ -96,6 +100,22 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = {
 		[PLL_OFF_OPMODE] = 0x2c,
 		[PLL_OFF_FRAC] = 0x38,
 	},
+	[CLK_ALPHA_PLL_TYPE_TRION] = {
+		[PLL_OFF_L_VAL] = 0x04,
+		[PLL_OFF_CAL_L_VAL] = 0x08,
+		[PLL_OFF_USER_CTL] = 0x0c,
+		[PLL_OFF_USER_CTL_U] = 0x10,
+		[PLL_OFF_USER_CTL_U1] = 0x14,
+		[PLL_OFF_CONFIG_CTL] = 0x18,
+		[PLL_OFF_CONFIG_CTL_U] = 0x1c,
+		[PLL_OFF_CONFIG_CTL_U1] = 0x20,
+		[PLL_OFF_TEST_CTL] = 0x24,
+		[PLL_OFF_TEST_CTL_U] = 0x28,
+		[PLL_OFF_STATUS] = 0x30,
+		[PLL_OFF_OPMODE] = 0x38,
+		[PLL_OFF_ALPHA_VAL] = 0x40,
+		[PLL_OFF_CAL_VAL] = 0x44,
+	},
 };
 EXPORT_SYMBOL_GPL(clk_alpha_pll_regs);
 
@@ -120,6 +140,15 @@ EXPORT_SYMBOL_GPL(clk_alpha_pll_regs);
 #define FABIA_PLL_OUT_MASK	0x7
 #define FABIA_PLL_RATE_MARGIN	500
 
+#define TRION_PLL_CAL_VAL	0x44
+#define TRION_PLL_STANDBY	0x0
+#define TRION_PLL_RUN		0x1
+#define TRION_PLL_OUT_MASK	0x7
+#define TRION_PCAL_DONE		BIT(26)
+#define TRION_PLL_RATE_MARGIN	500
+
+#define XO_RATE			19200000
+
 #define pll_alpha_width(p)					\
 		((PLL_ALPHA_VAL_U(p) - PLL_ALPHA_VAL(p) == 4) ?	\
 				 ALPHA_REG_BITWIDTH : ALPHA_REG_16BIT_WIDTH)
@@ -392,6 +421,15 @@ alpha_pll_round_rate(unsigned long rate, unsigned long prate, u32 *l, u64 *a,
 	u64 remainder;
 	u64 quotient;
 
+	/*
+	 * The PLLs parent rate is zero probably since the parent hasn't
+	 * registered yet. Return early with the requested rate.
+	 */
+	if (!prate) {
+		pr_warn("PLLs parent rate hasn't been initialized.\n");
+		return rate;
+	}
+
 	quotient = rate;
 	remainder = do_div(quotient, prate);
 	*l = quotient;
@@ -730,6 +768,136 @@ static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate,
 	return alpha_huayra_pll_round_rate(rate, *prate, &l, &a);
 }
 
+static int trion_pll_is_enabled(struct clk_alpha_pll *pll,
+				struct regmap *regmap)
+{
+	u32 mode_regval, opmode_regval;
+	int ret;
+
+	ret = regmap_read(regmap, PLL_MODE(pll), &mode_regval);
+	ret |= regmap_read(regmap, PLL_OPMODE(pll), &opmode_regval);
+	if (ret)
+		return 0;
+
+	return ((opmode_regval & TRION_PLL_RUN) && (mode_regval & PLL_OUTCTRL));
+}
+
+static int clk_trion_pll_enable(struct clk_hw *hw)
+{
+	struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+	struct regmap *regmap = pll->clkr.regmap;
+	u32 val;
+	int ret;
+
+	ret = regmap_read(regmap, PLL_MODE(pll), &val);
+	if (ret)
+		return ret;
+
+	/* If in FSM mode, just vote for it */
+	if (val & PLL_VOTE_FSM_ENA) {
+		ret = clk_enable_regmap(hw);
+		if (ret)
+			return ret;
+		return wait_for_pll_enable_active(pll);
+	}
+
+	/* Set operation mode to RUN */
+	regmap_write(regmap, PLL_OPMODE(pll), TRION_PLL_RUN);
+
+	ret = wait_for_pll_enable_lock(pll);
+	if (ret)
+		return ret;
+
+	/* Enable the PLL outputs */
+	ret = regmap_update_bits(regmap, PLL_USER_CTL(pll),
+				 TRION_PLL_OUT_MASK, TRION_PLL_OUT_MASK);
+	if (ret)
+		return ret;
+
+	/* Enable the global PLL outputs */
+	ret = regmap_update_bits(regmap, PLL_MODE(pll),
+				 PLL_OUTCTRL, PLL_OUTCTRL);
+	if (ret)
+		return ret;
+
+	/* Ensure that the write above goes through before returning. */
+	mb();
+	return ret;
+}
+
+static void clk_trion_pll_disable(struct clk_hw *hw)
+{
+	struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+	struct regmap *regmap = pll->clkr.regmap;
+	u32 val;
+	int ret;
+
+	ret = regmap_read(regmap, PLL_MODE(pll), &val);
+	if (ret)
+		return;
+
+	/* If in FSM mode, just unvote it */
+	if (val & PLL_VOTE_FSM_ENA) {
+		clk_disable_regmap(hw);
+		return;
+	}
+
+	/* Disable the global PLL output */
+	ret = regmap_update_bits(regmap, PLL_MODE(pll), PLL_OUTCTRL, 0);
+	if (ret)
+		return;
+
+	/* Disable the PLL outputs */
+	ret = regmap_update_bits(regmap, PLL_USER_CTL(pll),
+				 TRION_PLL_OUT_MASK, 0);
+	if (ret)
+		return;
+
+	/* Place the PLL mode in STANDBY */
+	regmap_write(regmap, PLL_OPMODE(pll), TRION_PLL_STANDBY);
+	regmap_update_bits(regmap, PLL_MODE(pll), PLL_RESET_N, PLL_RESET_N);
+}
+
+static unsigned long
+clk_trion_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
+{
+	struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+	struct regmap *regmap = pll->clkr.regmap;
+	u32 l, frac;
+	u64 prate = parent_rate;
+
+	regmap_read(regmap, PLL_L_VAL(pll), &l);
+	regmap_read(regmap, PLL_ALPHA_VAL(pll), &frac);
+
+	return alpha_pll_calc_rate(prate, l, frac, ALPHA_REG_16BIT_WIDTH);
+}
+
+static int clk_trion_pll_is_enabled(struct clk_hw *hw)
+{
+	struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+
+	return trion_pll_is_enabled(pll, pll->clkr.regmap);
+}
+
+static long clk_trion_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+				     unsigned long *prate)
+{
+	struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+	unsigned long min_freq, max_freq;
+	u32 l;
+	u64 a;
+
+	rate = alpha_pll_round_rate(rate, *prate,
+				    &l, &a, ALPHA_REG_16BIT_WIDTH);
+	if (!pll->vco_table || alpha_pll_find_vco(pll, rate))
+		return rate;
+
+	min_freq = pll->vco_table[0].min_freq;
+	max_freq = pll->vco_table[pll->num_vco - 1].max_freq;
+
+	return clamp(rate, min_freq, max_freq);
+}
+
 const struct clk_ops clk_alpha_pll_ops = {
 	.enable = clk_alpha_pll_enable,
 	.disable = clk_alpha_pll_disable,
@@ -760,6 +928,15 @@ const struct clk_ops clk_alpha_pll_hwfsm_ops = {
 };
 EXPORT_SYMBOL_GPL(clk_alpha_pll_hwfsm_ops);
 
+const struct clk_ops clk_trion_fixed_pll_ops = {
+	.enable = clk_trion_pll_enable,
+	.disable = clk_trion_pll_disable,
+	.is_enabled = clk_trion_pll_is_enabled,
+	.recalc_rate = clk_trion_pll_recalc_rate,
+	.round_rate = clk_trion_pll_round_rate,
+};
+EXPORT_SYMBOL_GPL(clk_trion_fixed_pll_ops);
+
 static unsigned long
 clk_alpha_pll_postdiv_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
 {
@@ -902,6 +1079,10 @@ static int alpha_pll_fabia_enable(struct clk_hw *hw)
 	ret = regmap_read(regmap, PLL_OPMODE(pll), &opmode_val);
 	if (ret)
 		return ret;
+	ret = regmap_update_bits(regmap, PLL_MODE(pll),
+				 PLL_BYPASSNL, PLL_BYPASSNL);
+	if (ret)
+		return ret;
 
 	/* Skip If PLL is already running */
 	if ((opmode_val & FABIA_OPMODE_RUN) && (val & PLL_OUTCTRL))
@@ -1058,6 +1239,91 @@ static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw,
 	return (parent_rate / div);
 }
 
+static unsigned long
+clk_trion_pll_postdiv_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
+{
+	struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw);
+	struct regmap *regmap = pll->clkr.regmap;
+	u32 i, div = 1, val;
+
+	if (!pll->post_div_table) {
+		pr_err("Missing the post_div_table for the PLL\n");
+		return -EINVAL;
+	}
+
+	regmap_read(regmap, PLL_USER_CTL(pll), &val);
+
+	val >>= pll->post_div_shift;
+	val &= PLL_POST_DIV_MASK(pll);
+
+	for (i = 0; i < pll->num_post_div; i++) {
+		if (pll->post_div_table[i].val == val) {
+			div = pll->post_div_table[i].div;
+			break;
+		}
+	}
+
+	return (parent_rate / div);
+}
+
+static long
+clk_trion_pll_postdiv_round_rate(struct clk_hw *hw, unsigned long rate,
+				 unsigned long *prate)
+{
+	struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw);
+
+	if (!pll->post_div_table) {
+		pr_err("Missing the post_div_table for the PLL\n");
+		return -EINVAL;
+	}
+
+	return divider_round_rate(hw, rate, prate, pll->post_div_table,
+				  pll->width, CLK_DIVIDER_ROUND_CLOSEST);
+};
+
+static int
+clk_trion_pll_postdiv_set_rate(struct clk_hw *hw, unsigned long rate,
+			       unsigned long parent_rate)
+{
+	struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw);
+	struct regmap *regmap = pll->clkr.regmap;
+	int i, val = 0, div, ret;
+
+	/*
+	 * If the PLL is in FSM mode, then treat the set_rate callback
+	 * as a no-operation.
+	 */
+	ret = regmap_read(regmap, PLL_MODE(pll), &val);
+	if (ret)
+		return ret;
+
+	if (val & PLL_VOTE_FSM_ENA)
+		return 0;
+
+	if (!pll->post_div_table) {
+		pr_err("Missing the post_div_table for the PLL\n");
+		return -EINVAL;
+	}
+
+	div = DIV_ROUND_UP_ULL((u64)parent_rate, rate);
+	for (i = 0; i < pll->num_post_div; i++) {
+		if (pll->post_div_table[i].div == div) {
+			val = pll->post_div_table[i].val;
+			break;
+		}
+	}
+	return regmap_update_bits(regmap, PLL_USER_CTL(pll),
+				  PLL_POST_DIV_MASK(pll) << PLL_POST_DIV_SHIFT,
+				  val << PLL_POST_DIV_SHIFT);
+}
+
+const struct clk_ops clk_trion_pll_postdiv_ops = {
+	.recalc_rate = clk_trion_pll_postdiv_recalc_rate,
+	.round_rate = clk_trion_pll_postdiv_round_rate,
+	.set_rate = clk_trion_pll_postdiv_set_rate,
+};
+EXPORT_SYMBOL_GPL(clk_trion_pll_postdiv_ops);
+
 static long clk_alpha_pll_postdiv_fabia_round_rate(struct clk_hw *hw,
 				unsigned long rate, unsigned long *prate)
 {
drivers/clk/qcom/clk-alpha-pll.h +9 -0
index 66755f0f84fc..a2f844c66207 100644
@@ -13,22 +13,27 @@ enum {
 	CLK_ALPHA_PLL_TYPE_HUAYRA,
 	CLK_ALPHA_PLL_TYPE_BRAMMO,
 	CLK_ALPHA_PLL_TYPE_FABIA,
+	CLK_ALPHA_PLL_TYPE_TRION,
 	CLK_ALPHA_PLL_TYPE_MAX,
 };
 
 enum {
 	PLL_OFF_L_VAL,
+	PLL_OFF_CAL_L_VAL,
 	PLL_OFF_ALPHA_VAL,
 	PLL_OFF_ALPHA_VAL_U,
 	PLL_OFF_USER_CTL,
 	PLL_OFF_USER_CTL_U,
+	PLL_OFF_USER_CTL_U1,
 	PLL_OFF_CONFIG_CTL,
 	PLL_OFF_CONFIG_CTL_U,
+	PLL_OFF_CONFIG_CTL_U1,
 	PLL_OFF_TEST_CTL,
 	PLL_OFF_TEST_CTL_U,
 	PLL_OFF_STATUS,
 	PLL_OFF_OPMODE,
 	PLL_OFF_FRAC,
+	PLL_OFF_CAL_VAL,
 	PLL_OFF_MAX_REGS
 };
 
@@ -43,6 +48,7 @@ struct pll_vco {
 /**
  * struct clk_alpha_pll - phase locked loop (PLL)
  * @offset: base address of registers
+ * @inited: flag that's set when the PLL is initialized
  * @vco_table: array of VCO settings
  * @regs: alpha pll register map (see @clk_alpha_pll_regs)
  * @clkr: regmap clock handle
@@ -50,6 +56,7 @@ struct pll_vco {
 struct clk_alpha_pll {
 	u32 offset;
 	const u8 *regs;
+	bool inited;
 
 	const struct pll_vco *vco_table;
 	size_t num_vco;
@@ -117,5 +124,7 @@ void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
 			     const struct alpha_pll_config *config);
 void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
 				const struct alpha_pll_config *config);
+extern const struct clk_ops clk_trion_fixed_pll_ops;
+extern const struct clk_ops clk_trion_pll_postdiv_ops;
 
 #endif
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 2/2 clk: qcom: gcc: Add global clock controller driver for SM8150

From: Deepak Katragadda <[email protected]>

Add the clocks supported in global clock controller which clock the peripherals like BLSPs, SDCC, USB, MDSS etc. Register all the clocks to the clock framework for the clients to be able to request for them.

[vkoul: port to upstream and tidy-up]
---
 .../devicetree/bindings/clock/qcom,gcc.txt    |    1 +
 drivers/clk/qcom/Kconfig                      |    7 +
 drivers/clk/qcom/Makefile                     |    1 +
 drivers/clk/qcom/gcc-sm8150.c                 | 3649 +++++++++++++++++
 include/dt-bindings/clock/qcom,gcc-sm8150.h   |  243 ++
 5 files changed, 3901 insertions(+)
 create mode 100644 drivers/clk/qcom/gcc-sm8150.c
 create mode 100644 include/dt-bindings/clock/qcom,gcc-sm8150.h
Documentation/devicetree/bindings/clock/qcom,gcc.txt +1 -0
index 8661c3cd3ccf..1b39d949e63d 100644
@@ -23,6 +23,7 @@ Required properties :
 			"qcom,gcc-sdm630"
 			"qcom,gcc-sdm660"
 			"qcom,gcc-sdm845"
+			"qcom,gcc-sm8150"
 
 - reg : shall contain base register location and length
 - #clock-cells : shall contain 1
drivers/clk/qcom/Kconfig +7 -0
index 18bdf34d5e64..076872d195fd 100644
@@ -291,6 +291,13 @@ config SDM_LPASSCC_845
 	  Say Y if you want to use the LPASS branch clocks of the LPASS clock
 	  controller to reset the LPASS subsystem.
 
+config SM_GCC_8150
+	tristate "SM8150 Global Clock Controller"
+	help
+	  Support for the global clock controller on SM8150 devices.
+	  Say Y if you want to use peripheral devices such as UART,
+	  SPI, I2C, USB, SD/eMMC, PCIe etc.
+
 config SPMI_PMIC_CLKDIV
 	tristate "SPMI PMIC clkdiv Support"
 	depends on SPMI || COMPILE_TEST
drivers/clk/qcom/Makefile +1 -0
index f0768fb1f037..4a813b4055d0 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
 obj-$(CONFIG_SDM_GPUCC_845) += gpucc-sdm845.o
 obj-$(CONFIG_SDM_LPASSCC_845) += lpasscc-sdm845.o
 obj-$(CONFIG_SDM_VIDEOCC_845) += videocc-sdm845.o
+obj-$(CONFIG_SM_GCC_8150) += gcc-sm8150.o
 obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
 obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
 obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
drivers/clk/qcom/gcc-sm8150.c new file +3649 -0

2,973 lines not on this page · raw message

include/dt-bindings/clock/qcom,gcc-sm8150.h new file +243 -0

243 lines not on this page · raw message

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

Signature · 1 line
2.20.1

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

maintainer
#2 lore raw

Re: [PATCH 2/2] clk: qcom: gcc: Add global clock controller driver for SM8150

Quoting Vinod Koul (2019-06-07 03:12:34)

drivers/clk/qcom/gcc-sm8150.c line 52

Quoted 13 lines
drivers/clk/qcom/gcc-sm8150.c new file +8 -0
new file mode 100644
index 000000000000..1cbc884444c9
+static const struct parent_map gcc_parent_map_0[] = {
+       { P_BI_TCXO, 0 },
+       { P_GPLL0_OUT_MAIN, 1 },
+       { P_GPLL0_OUT_EVEN, 6 },
+       { P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const gcc_parent_names_0[] = {

We have a new way of specifying clk parents now. Can you use that instead of using strings everywhere?

Quoted 4 lines
drivers/clk/qcom/gcc-sm8150.c new file +4 -0
+       "bi_tcxo",
+       "gpll0",
+       "gpll0_out_even",
+       "core_bi_pll_test_se",
author
#3 lore raw

Re: [PATCH 2/2] clk: qcom: gcc: Add global clock controller driver for SM8150

Quoted 17 lines · Stephen Boyd

Quoting Vinod Koul (2019-06-07 03:12:34)

drivers/clk/qcom/gcc-sm8150.c line 52

Quoted 13 lines
drivers/clk/qcom/gcc-sm8150.c new file +8 -0
new file mode 100644
index 000000000000..1cbc884444c9
+static const struct parent_map gcc_parent_map_0[] = {
+       { P_BI_TCXO, 0 },
+       { P_GPLL0_OUT_MAIN, 1 },
+       { P_GPLL0_OUT_EVEN, 6 },
+       { P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const gcc_parent_names_0[] = {

We have a new way of specifying clk parents now. Can you use that instead of using strings everywhere?

Okay I will update, any pointers on new implementation I can look up?

Thanks

Signature · 1 line
~Vinod
maintainer
#4 lore raw

Re: [PATCH 2/2] clk: qcom: gcc: Add global clock controller driver for SM8150

Quoting Vinod Koul (2019-06-08 02:15:37)

Quoted 19 lines · Stephen Boyd
Quoted 17 lines

Quoting Vinod Koul (2019-06-07 03:12:34)

drivers/clk/qcom/gcc-sm8150.c line 52

Quoted 13 lines
drivers/clk/qcom/gcc-sm8150.c new file +8 -0
new file mode 100644
index 000000000000..1cbc884444c9
+static const struct parent_map gcc_parent_map_0[] = {
+       { P_BI_TCXO, 0 },
+       { P_GPLL0_OUT_MAIN, 1 },
+       { P_GPLL0_OUT_EVEN, 6 },
+       { P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const gcc_parent_names_0[] = {

We have a new way of specifying clk parents now. Can you use that instead of using strings everywhere?

Quoted 2 lines

Okay I will update, any pointers on new implementation I can look up?

Not really yet. Chen-Yu is working on the Allwinner driver (drivers/clk/sunxi-ng/) and some work from Jeff for MSM8998 is on the list that you can look at.

author
#5 lore raw

Re: [PATCH 2/2] clk: qcom: gcc: Add global clock controller driver for SM8150

Quoted 20 lines · Stephen Boyd

Quoting Vinod Koul (2019-06-08 02:15:37)

Quoted 19 lines · Stephen Boyd
Quoted 17 lines

Quoting Vinod Koul (2019-06-07 03:12:34)

drivers/clk/qcom/gcc-sm8150.c line 52

Quoted 13 lines
drivers/clk/qcom/gcc-sm8150.c new file +8 -0
new file mode 100644
index 000000000000..1cbc884444c9
+static const struct parent_map gcc_parent_map_0[] = {
+       { P_BI_TCXO, 0 },
+       { P_GPLL0_OUT_MAIN, 1 },
+       { P_GPLL0_OUT_EVEN, 6 },
+       { P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const gcc_parent_names_0[] = {

We have a new way of specifying clk parents now. Can you use that instead of using strings everywhere?

Quoted 6 lines
Quoted 2 lines

Okay I will update, any pointers on new implementation I can look up?

Not really yet. Chen-Yu is working on the Allwinner driver (drivers/clk/sunxi-ng/) and some work from Jeff for MSM8998 is on the list that you can look at.

Thanks for the pointer, I have done the conversion and will post the update in v2

Signature · 1 line
~Vinod
maintainer Acked-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] clk: qcom: gcc: Add global clock controller driver for SM8150

In reply to Vinod Koul
Quoted 10 lines · Vinod Koul

From: Deepak Katragadda <[email protected]>

Add the clocks supported in global clock controller which clock the peripherals like BLSPs, SDCC, USB, MDSS etc. Register all the clocks to the clock framework for the clients to be able to request for them.

[vkoul: port to upstream and tidy-up]
Quoted 8 lines
---
 .../devicetree/bindings/clock/qcom,gcc.txt    |    1 +
 drivers/clk/qcom/Kconfig                      |    7 +
 drivers/clk/qcom/Makefile                     |    1 +
 drivers/clk/qcom/gcc-sm8150.c                 | 3649 +++++++++++++++++
 include/dt-bindings/clock/qcom,gcc-sm8150.h   |  243 ++

Next time, please split bindings to separate patch.

For the DT parts,

Quoted 3 lines
 5 files changed, 3901 insertions(+)
 create mode 100644 drivers/clk/qcom/gcc-sm8150.c
 create mode 100644 include/dt-bindings/clock/qcom,gcc-sm8150.h
maintainer
#7 lore raw
In reply to Vinod Koul

Quoting Vinod Koul (2019-06-07 03:12:33)

Quoted 8 lines

From: Deepak Katragadda <[email protected]>

Add programming sequence support for managing the Trion PLLs.

[vkoul: port to upstream and tidy-up]

This tag isn't very useful. Maybe you can list out what you actually did instead of just "tidying"?

Quoted 5 lines
drivers/clk/qcom/clk-alpha-pll.c +0 -0
index 0ced4a5a9a17..bf36a929458b 100644

drivers/clk/qcom/clk-alpha-pll.c EXPORT_SYMBOL_GPL(clk_alpha_pll_regs); · line 148

Quoted 9 lines
drivers/clk/qcom/clk-alpha-pll.c +6 -0
@@ -120,6 +140,15 @@ EXPORT_SYMBOL_GPL(clk_alpha_pll_regs);
 #define FABIA_PLL_OUT_MASK     0x7
 #define FABIA_PLL_RATE_MARGIN  500
 
+#define TRION_PLL_CAL_VAL      0x44
+#define TRION_PLL_STANDBY      0x0
+#define TRION_PLL_RUN          0x1
+#define TRION_PLL_OUT_MASK     0x7
+#define TRION_PCAL_DONE                BIT(26)
+#define TRION_PLL_RATE_MARGIN  500

These last two aren't used. Do we need them?

drivers/clk/qcom/clk-alpha-pll.c EXPORT_SYMBOL_GPL(clk_alpha_pll_regs); · line 150

Quoted 2 lines
drivers/clk/qcom/clk-alpha-pll.c +2 -0
+
+#define XO_RATE                        19200000

Please remove this define. It isn't used (thankfully!).

drivers/clk/qcom/clk-alpha-pll.c alpha_pll_round_rate(unsigned long rate, unsigned long prate, u32 *l, u64 *a, · line 428

Quoted 13 lines
drivers/clk/qcom/clk-alpha-pll.c +6 -0
+
 #define pll_alpha_width(p)                                     \
                ((PLL_ALPHA_VAL_U(p) - PLL_ALPHA_VAL(p) == 4) ? \
                                 ALPHA_REG_BITWIDTH : ALPHA_REG_16BIT_WIDTH)
@@ -392,6 +421,15 @@ alpha_pll_round_rate(unsigned long rate, unsigned long prate, u32 *l, u64 *a,
        u64 remainder;
        u64 quotient;
 
+       /*
+        * The PLLs parent rate is zero probably since the parent hasn't
+        * registered yet. Return early with the requested rate.
+        */
+       if (!prate) {

This hasn't been a problem before. Why is it a problem now?

Quoted 52 lines
drivers/clk/qcom/clk-alpha-pll.c +45 -0
+               pr_warn("PLLs parent rate hasn't been initialized.\n");
+               return rate;
+       }
+
        quotient = rate;
        remainder = do_div(quotient, prate);
        *l = quotient;
@@ -730,6 +768,136 @@ static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate,
        return alpha_huayra_pll_round_rate(rate, *prate, &l, &a);
 }
 
+static int trion_pll_is_enabled(struct clk_alpha_pll *pll,
+                               struct regmap *regmap)
+{
+       u32 mode_regval, opmode_regval;
+       int ret;
+
+       ret = regmap_read(regmap, PLL_MODE(pll), &mode_regval);
+       ret |= regmap_read(regmap, PLL_OPMODE(pll), &opmode_regval);
+       if (ret)
+               return 0;
+
+       return ((opmode_regval & TRION_PLL_RUN) && (mode_regval & PLL_OUTCTRL));
+}
+
+static int clk_trion_pll_enable(struct clk_hw *hw)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+       struct regmap *regmap = pll->clkr.regmap;
+       u32 val;
+       int ret;
+
+       ret = regmap_read(regmap, PLL_MODE(pll), &val);
+       if (ret)
+               return ret;
+
+       /* If in FSM mode, just vote for it */
+       if (val & PLL_VOTE_FSM_ENA) {
+               ret = clk_enable_regmap(hw);
+               if (ret)
+                       return ret;
+               return wait_for_pll_enable_active(pll);
+       }
+
+       /* Set operation mode to RUN */
+       regmap_write(regmap, PLL_OPMODE(pll), TRION_PLL_RUN);
+
+       ret = wait_for_pll_enable_lock(pll);
+       if (ret)
+               return ret;
+
+       /* Enable the PLL outputs */

drivers/clk/qcom/clk-alpha-pll.c static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate, · line 821

Quoted 10 lines
drivers/clk/qcom/clk-alpha-pll.c +10 -0
+       ret = regmap_update_bits(regmap, PLL_USER_CTL(pll),
+                                TRION_PLL_OUT_MASK, TRION_PLL_OUT_MASK);
+       if (ret)
+               return ret;
+
+       /* Enable the global PLL outputs */
+       ret = regmap_update_bits(regmap, PLL_MODE(pll),
+                                PLL_OUTCTRL, PLL_OUTCTRL);
+       if (ret)
+               return ret;

This if (ret) can be removed.

drivers/clk/qcom/clk-alpha-pll.c static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate, · line 824

Quoted 3 lines
drivers/clk/qcom/clk-alpha-pll.c +3 -0
+
+       /* Ensure that the write above goes through before returning. */
+       mb();

As far as I recall mb() does nothing to ensure the write above goes through, just that writes after this one are ordered with the write above.

Quoted 46 lines
drivers/clk/qcom/clk-alpha-pll.c +46 -0
+       return ret;
+}
+
+static void clk_trion_pll_disable(struct clk_hw *hw)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+       struct regmap *regmap = pll->clkr.regmap;
+       u32 val;
+       int ret;
+
+       ret = regmap_read(regmap, PLL_MODE(pll), &val);
+       if (ret)
+               return;
+
+       /* If in FSM mode, just unvote it */
+       if (val & PLL_VOTE_FSM_ENA) {
+               clk_disable_regmap(hw);
+               return;
+       }
+
+       /* Disable the global PLL output */
+       ret = regmap_update_bits(regmap, PLL_MODE(pll), PLL_OUTCTRL, 0);
+       if (ret)
+               return;
+
+       /* Disable the PLL outputs */
+       ret = regmap_update_bits(regmap, PLL_USER_CTL(pll),
+                                TRION_PLL_OUT_MASK, 0);
+       if (ret)
+               return;
+
+       /* Place the PLL mode in STANDBY */
+       regmap_write(regmap, PLL_OPMODE(pll), TRION_PLL_STANDBY);
+       regmap_update_bits(regmap, PLL_MODE(pll), PLL_RESET_N, PLL_RESET_N);
+}
+
+static unsigned long
+clk_trion_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+       struct regmap *regmap = pll->clkr.regmap;
+       u32 l, frac;
+       u64 prate = parent_rate;
+
+       regmap_read(regmap, PLL_L_VAL(pll), &l);
+       regmap_read(regmap, PLL_ALPHA_VAL(pll), &frac);

drivers/clk/qcom/clk-alpha-pll.c static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate, · line 880

Quoted 10 lines
drivers/clk/qcom/clk-alpha-pll.c +10 -0
+
+       return alpha_pll_calc_rate(prate, l, frac, ALPHA_REG_16BIT_WIDTH);
+}
+
+static int clk_trion_pll_is_enabled(struct clk_hw *hw)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+
+       return trion_pll_is_enabled(pll, pll->clkr.regmap);
+}

Can you move this function right below trion_pll_is_enabled()?

Quoted 24 lines
drivers/clk/qcom/clk-alpha-pll.c +20 -0
+
+static long clk_trion_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+                                    unsigned long *prate)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+       unsigned long min_freq, max_freq;
+       u32 l;
+       u64 a;
+
+       rate = alpha_pll_round_rate(rate, *prate,
+                                   &l, &a, ALPHA_REG_16BIT_WIDTH);
+       if (!pll->vco_table || alpha_pll_find_vco(pll, rate))
+               return rate;
+
+       min_freq = pll->vco_table[0].min_freq;
+       max_freq = pll->vco_table[pll->num_vco - 1].max_freq;
+
+       return clamp(rate, min_freq, max_freq);
+}
+
 const struct clk_ops clk_alpha_pll_ops = {
        .enable = clk_alpha_pll_enable,
        .disable = clk_alpha_pll_disable,

drivers/clk/qcom/clk-alpha-pll.c static int alpha_pll_fabia_enable(struct clk_hw *hw) · line 1085

Quoted 7 lines
drivers/clk/qcom/clk-alpha-pll.c +4 -0
@@ -902,6 +1079,10 @@ static int alpha_pll_fabia_enable(struct clk_hw *hw)
        ret = regmap_read(regmap, PLL_OPMODE(pll), &opmode_val);
        if (ret)
                return ret;
+       ret = regmap_update_bits(regmap, PLL_MODE(pll),
+                                PLL_BYPASSNL, PLL_BYPASSNL);
+       if (ret)
+               return ret;

What is this?

Quoted 6 lines
drivers/clk/qcom/clk-alpha-pll.c +0 -0
        /* Skip If PLL is already running */
        if ((opmode_val & FABIA_OPMODE_RUN) && (val & PLL_OUTCTRL))
@@ -1058,6 +1239,91 @@ static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw,
        return (parent_rate / div);
 }

drivers/clk/qcom/clk-alpha-pll.c static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw, · line 1250

Quoted 10 lines
drivers/clk/qcom/clk-alpha-pll.c +9 -0
 
+static unsigned long
+clk_trion_pll_postdiv_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
+{
+       struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw);
+       struct regmap *regmap = pll->clkr.regmap;
+       u32 i, div = 1, val;
+
+       if (!pll->post_div_table) {
+               pr_err("Missing the post_div_table for the PLL\n");

Ahhh!

Quoted 17 lines
drivers/clk/qcom/clk-alpha-pll.c +17 -0
+               return -EINVAL;
+       }
+
+       regmap_read(regmap, PLL_USER_CTL(pll), &val);
+
+       val >>= pll->post_div_shift;
+       val &= PLL_POST_DIV_MASK(pll);
+
+       for (i = 0; i < pll->num_post_div; i++) {
+               if (pll->post_div_table[i].val == val) {
+                       div = pll->post_div_table[i].div;
+                       break;
+               }
+       }
+
+       return (parent_rate / div);
+}

drivers/clk/qcom/clk-alpha-pll.c static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw, · line 1277

Quoted 10 lines
drivers/clk/qcom/clk-alpha-pll.c +10 -0
+
+static long
+clk_trion_pll_postdiv_round_rate(struct clk_hw *hw, unsigned long rate,
+                                unsigned long *prate)
+{
+       struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw);
+
+       if (!pll->post_div_table) {
+               pr_err("Missing the post_div_table for the PLL\n");
+               return -EINVAL;

Does this ever happen? I'd rather see this removed and the code blow up if the driver author didn't test this.

Quoted 17 lines
drivers/clk/qcom/clk-alpha-pll.c +17 -0
+       }
+
+       return divider_round_rate(hw, rate, prate, pll->post_div_table,
+                                 pll->width, CLK_DIVIDER_ROUND_CLOSEST);
+};
+
+static int
+clk_trion_pll_postdiv_set_rate(struct clk_hw *hw, unsigned long rate,
+                              unsigned long parent_rate)
+{
+       struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw);
+       struct regmap *regmap = pll->clkr.regmap;
+       int i, val = 0, div, ret;
+
+       /*
+        * If the PLL is in FSM mode, then treat the set_rate callback
+        * as a no-operation.

drivers/clk/qcom/clk-alpha-pll.c static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw, · line 1304

Quoted 10 lines
drivers/clk/qcom/clk-alpha-pll.c +10 -0
+        */
+       ret = regmap_read(regmap, PLL_MODE(pll), &val);
+       if (ret)
+               return ret;
+
+       if (val & PLL_VOTE_FSM_ENA)
+               return 0;
+
+       if (!pll->post_div_table) {
+               pr_err("Missing the post_div_table for the PLL\n");

Again!

drivers/clk/qcom/clk-alpha-pll.c static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw, · line 1308

Quoted 4 lines
drivers/clk/qcom/clk-alpha-pll.c +4 -0
+               return -EINVAL;
+       }
+
+       div = DIV_ROUND_UP_ULL((u64)parent_rate, rate);

Is the cast necessary?

Quoted 21 lines
drivers/clk/qcom/clk-alpha-pll.c +18 -0
+       for (i = 0; i < pll->num_post_div; i++) {
+               if (pll->post_div_table[i].div == div) {
+                       val = pll->post_div_table[i].val;
+                       break;
+               }
+       }
+       return regmap_update_bits(regmap, PLL_USER_CTL(pll),
+                                 PLL_POST_DIV_MASK(pll) << PLL_POST_DIV_SHIFT,
+                                 val << PLL_POST_DIV_SHIFT);
+}
+
+const struct clk_ops clk_trion_pll_postdiv_ops = {
+       .recalc_rate = clk_trion_pll_postdiv_recalc_rate,
+       .round_rate = clk_trion_pll_postdiv_round_rate,
+       .set_rate = clk_trion_pll_postdiv_set_rate,
+};
+EXPORT_SYMBOL_GPL(clk_trion_pll_postdiv_ops);
+
 static long clk_alpha_pll_postdiv_fabia_round_rate(struct clk_hw *hw,
                                unsigned long rate, unsigned long *prate)
 {
author
#8 lore raw

Thanks Stephen for a quick review

Quoted 6 lines · Stephen Boyd

Quoting Vinod Koul (2019-06-07 03:12:33)

Quoted 5 lines

From: Deepak Katragadda <[email protected]>

Add programming sequence support for managing the Trion PLLs.

Quoted 6 lines
Quoted 3 lines
[vkoul: port to upstream and tidy-up]

This tag isn't very useful. Maybe you can list out what you actually did instead of just "tidying"?

First was to port and in process remove bunch of code which cant be upstreamed and has no user in current work. Had to rewrite bunch of stuff while upstreaming. Then fix format and style issue

I will try to list..

Quoted 8 lines
Quoted 8 lines
drivers/clk/qcom/clk-alpha-pll.c +0 -0
index 0ced4a5a9a17..bf36a929458b 100644
@@ -120,6 +140,15 @@ EXPORT_SYMBOL_GPL(clk_alpha_pll_regs);
 #define FABIA_PLL_OUT_MASK     0x7
 #define FABIA_PLL_RATE_MARGIN  500
 
Quoted 8 lines

drivers/clk/qcom/clk-alpha-pll.c EXPORT_SYMBOL_GPL(clk_alpha_pll_regs); · line 148

Quoted 6 lines
drivers/clk/qcom/clk-alpha-pll.c +6 -0
+#define TRION_PLL_CAL_VAL      0x44
+#define TRION_PLL_STANDBY      0x0
+#define TRION_PLL_RUN          0x1
+#define TRION_PLL_OUT_MASK     0x7
+#define TRION_PCAL_DONE                BIT(26)
+#define TRION_PLL_RATE_MARGIN  500

These last two aren't used. Do we need them?

Not anymore, I removed the user as that was required for this, I will

Quoted 5 lines

drivers/clk/qcom/clk-alpha-pll.c EXPORT_SYMBOL_GPL(clk_alpha_pll_regs); · line 150

Quoted 3 lines
drivers/clk/qcom/clk-alpha-pll.c +2 -0
+
+#define XO_RATE                        19200000

Please remove this define. It isn't used (thankfully!).

Yes will remove this and other is the series :)

Quoted 7 lines
Quoted 7 lines
drivers/clk/qcom/clk-alpha-pll.c +0 -0
 #define pll_alpha_width(p)                                     \
                ((PLL_ALPHA_VAL_U(p) - PLL_ALPHA_VAL(p) == 4) ? \
                                 ALPHA_REG_BITWIDTH : ALPHA_REG_16BIT_WIDTH)
@@ -392,6 +421,15 @@ alpha_pll_round_rate(unsigned long rate, unsigned long prate, u32 *l, u64 *a,
        u64 remainder;
        u64 quotient;
 
Quoted 7 lines

drivers/clk/qcom/clk-alpha-pll.c alpha_pll_round_rate(unsigned long rate, unsigned long prate, u32 *l, u64 *a, · line 428

Quoted 5 lines
drivers/clk/qcom/clk-alpha-pll.c +5 -0
+       /*
+        * The PLLs parent rate is zero probably since the parent hasn't
+        * registered yet. Return early with the requested rate.
+        */
+       if (!prate) {

This hasn't been a problem before. Why is it a problem now?

Good point, some how downstream thinks so, I will remove these checks

Quoted 31 lines
Quoted 31 lines
drivers/clk/qcom/clk-alpha-pll.c +31 -0
+static int clk_trion_pll_enable(struct clk_hw *hw)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+       struct regmap *regmap = pll->clkr.regmap;
+       u32 val;
+       int ret;
+
+       ret = regmap_read(regmap, PLL_MODE(pll), &val);
+       if (ret)
+               return ret;
+
+       /* If in FSM mode, just vote for it */
+       if (val & PLL_VOTE_FSM_ENA) {
+               ret = clk_enable_regmap(hw);
+               if (ret)
+                       return ret;
+               return wait_for_pll_enable_active(pll);
+       }
+
+       /* Set operation mode to RUN */
+       regmap_write(regmap, PLL_OPMODE(pll), TRION_PLL_RUN);
+
+       ret = wait_for_pll_enable_lock(pll);
+       if (ret)
+               return ret;
+
+       /* Enable the PLL outputs */
+       ret = regmap_update_bits(regmap, PLL_USER_CTL(pll),
+                                TRION_PLL_OUT_MASK, TRION_PLL_OUT_MASK);
+       if (ret)
+               return ret;
Quoted 8 lines

drivers/clk/qcom/clk-alpha-pll.c static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate, · line 821

Quoted 6 lines
drivers/clk/qcom/clk-alpha-pll.c +6 -0
+
+       /* Enable the global PLL outputs */
+       ret = regmap_update_bits(regmap, PLL_MODE(pll),
+                                PLL_OUTCTRL, PLL_OUTCTRL);
+       if (ret)
+               return ret;

This if (ret) can be removed.

Yes we should return!

Quoted 7 lines

drivers/clk/qcom/clk-alpha-pll.c static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate, · line 824

Quoted 3 lines
drivers/clk/qcom/clk-alpha-pll.c +3 -0
+
+       /* Ensure that the write above goes through before returning. */
+       mb();

As far as I recall mb() does nothing to ensure the write above goes through, just that writes after this one are ordered with the write above.

Agreed someone wasn't convinced, will remove this.

Quoted 8 lines

drivers/clk/qcom/clk-alpha-pll.c static long alpha_pll_huayra_round_rate(struct clk_hw *hw, unsigned long rate, · line 880

Quoted 6 lines
drivers/clk/qcom/clk-alpha-pll.c +6 -0
+static int clk_trion_pll_is_enabled(struct clk_hw *hw)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+
+       return trion_pll_is_enabled(pll, pll->clkr.regmap);
+}

Can you move this function right below trion_pll_is_enabled()?

Sure

Quoted 5 lines
Quoted 5 lines

const struct clk_ops clk_alpha_pll_ops = {
.enable = clk_alpha_pll_enable,
.disable = clk_alpha_pll_disable,

drivers/clk/qcom/clk-alpha-pll.c +0 -0
@@ -902,6 +1079,10 @@ static int alpha_pll_fabia_enable(struct clk_hw *hw)
        ret = regmap_read(regmap, PLL_OPMODE(pll), &opmode_val);
Quoted 8 lines

drivers/clk/qcom/clk-alpha-pll.c static int alpha_pll_fabia_enable(struct clk_hw *hw) · line 1085

Quoted 6 lines
drivers/clk/qcom/clk-alpha-pll.c +4 -0
        if (ret)
                return ret;
+       ret = regmap_update_bits(regmap, PLL_MODE(pll),
+                                PLL_BYPASSNL, PLL_BYPASSNL);
+       if (ret)
+               return ret;

What is this?

Sorry am not sure I understood the question. care to elaborate please?

Quoted 4 lines
Quoted 4 lines
drivers/clk/qcom/clk-alpha-pll.c +4 -0
+static long
+clk_trion_pll_postdiv_round_rate(struct clk_hw *hw, unsigned long rate,
+                                unsigned long *prate)
+{
Quoted 8 lines

drivers/clk/qcom/clk-alpha-pll.c static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw, · line 1251

Quoted 5 lines
drivers/clk/qcom/clk-alpha-pll.c +5 -0
+       struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw);
+
+       if (!pll->post_div_table) {
+               pr_err("Missing the post_div_table for the PLL\n");
+               return -EINVAL;

Does this ever happen? I'd rather see this removed and the code blow up if the driver author didn't test this.

Sounds right! will remove this and others.

Quoted 6 lines

drivers/clk/qcom/clk-alpha-pll.c static unsigned long clk_alpha_pll_postdiv_fabia_recalc_rate(struct clk_hw *hw, · line 1308

Quoted 4 lines
drivers/clk/qcom/clk-alpha-pll.c +4 -0
+               return -EINVAL;
+       }
+
+       div = DIV_ROUND_UP_ULL((u64)parent_rate, rate);

Is the cast necessary?

Dont think so, will remove

Signature · 1 line
~Vinod
maintainer
#9 lore raw

Quoting Vinod Koul (2019-06-08 02:14:36)

Quoted 17 lines · Stephen Boyd
Quoted 15 lines

Quoting Vinod Koul (2019-06-07 03:12:33)

drivers/clk/qcom/clk-alpha-pll.c static int alpha_pll_fabia_enable(struct clk_hw *hw) · line 1085

Quoted 11 lines

const struct clk_ops clk_alpha_pll_ops = {
.enable = clk_alpha_pll_enable,
.disable = clk_alpha_pll_disable,

drivers/clk/qcom/clk-alpha-pll.c +4 -0
@@ -902,6 +1079,10 @@ static int alpha_pll_fabia_enable(struct clk_hw *hw)
        ret = regmap_read(regmap, PLL_OPMODE(pll), &opmode_val);
        if (ret)
                return ret;
+       ret = regmap_update_bits(regmap, PLL_MODE(pll),
+                                PLL_BYPASSNL, PLL_BYPASSNL);
+       if (ret)
+               return ret;

What is this?

Quoted 1 line

Sorry am not sure I understood the question. care to elaborate please?

The bypass bit of a PLL is very generic so I'm confused why the enable function is only gaining this bit setting logic now. Plus, it's all grouped together with the previous line so it looks like a possible stray addition to the code? And after this there's an early exit from the function if the PLL is already running, so we would put the PLL into bypass and then return? What's going on here?

author
#10 lore raw
Quoted 18 lines · Stephen Boyd

Quoting Vinod Koul (2019-06-08 02:14:36)

Quoted 17 lines · Stephen Boyd
Quoted 15 lines

Quoting Vinod Koul (2019-06-07 03:12:33)

drivers/clk/qcom/clk-alpha-pll.c static int alpha_pll_fabia_enable(struct clk_hw *hw) · line 1085

Quoted 11 lines

const struct clk_ops clk_alpha_pll_ops = {
.enable = clk_alpha_pll_enable,
.disable = clk_alpha_pll_disable,

drivers/clk/qcom/clk-alpha-pll.c +4 -0
@@ -902,6 +1079,10 @@ static int alpha_pll_fabia_enable(struct clk_hw *hw)
        ret = regmap_read(regmap, PLL_OPMODE(pll), &opmode_val);
        if (ret)
                return ret;
+       ret = regmap_update_bits(regmap, PLL_MODE(pll),
+                                PLL_BYPASSNL, PLL_BYPASSNL);
+       if (ret)
+               return ret;

What is this?

Quoted 8 lines
Quoted 1 line

Sorry am not sure I understood the question. care to elaborate please?

The bypass bit of a PLL is very generic so I'm confused why the enable function is only gaining this bit setting logic now. Plus, it's all grouped together with the previous line so it looks like a possible stray addition to the code? And after this there's an early exit from the function if the PLL is already running, so we would put the PLL into bypass and then return? What's going on here?

Thanks for spotting that is wrong. I am not sure why this crept in , I am not supposed to change this, will fix it in v2

Signature · 1 line
~Vinod