Skip to contentSkip to conversation

Introduce MediaTek frequency hopping driver

PATCH Superseded Johnson Wang 3 participants 13 messages Sep 29, 2022 – Oct 11, 2022

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Introduce MediaTek frequency hopping driver

The purpose of this serie is to enhance frequency hopping and spread spectrum clocking feature for MT8186.
We introduce new PLL register APIs and some helpers for FHCTL hardware control. For MT8186 PLL driver, we replace mtk_clk_register_plls() with newly added API to support frequency hopping and SSC function for specific PLLs.

Changes in v3:
- Change binding file name.
- Add some constraints for properties.
- Rename "mediatek,hopping-ssc-percents" to "mediatek,hopping-ssc-percent".
- Add new config symbol.

Changes in v2:
- Use SoC-specific compatible instead of generic one.
- Use standard clocks property and vendor-specific property in dt-binding.
- Remove some unused arguments and fix some coding style.

Johnson Wang (4):
clk: mediatek: Export PLL operations symbols
dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency
hopping
clk: mediatek: Add new clock driver to handle FHCTL hardware
clk: mediatek: Change PLL register API for MT8186

 .../arm/mediatek/mediatek,mt8186-fhctl.yaml   |  53 ++++
 drivers/clk/mediatek/Kconfig                  |   8 +
 drivers/clk/mediatek/Makefile                 |   1 +
 drivers/clk/mediatek/clk-fhctl.c              | 244 ++++++++++++++++
 drivers/clk/mediatek/clk-fhctl.h              |  26 ++
 drivers/clk/mediatek/clk-mt8186-apmixedsys.c  |  66 ++++-
 drivers/clk/mediatek/clk-pll.c                |  84 +++---
 drivers/clk/mediatek/clk-pll.h                |  56 ++++
 drivers/clk/mediatek/clk-pllfh.c              | 268 ++++++++++++++++++
 drivers/clk/mediatek/clk-pllfh.h              |  82 ++++++
 10 files changed, 835 insertions(+), 53 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml
 create mode 100644 drivers/clk/mediatek/clk-fhctl.c
 create mode 100644 drivers/clk/mediatek/clk-fhctl.h
 create mode 100644 drivers/clk/mediatek/clk-pllfh.c
 create mode 100644 drivers/clk/mediatek/clk-pllfh.h
Signature · 1 line
2.18.0
#1 lore raw

PATCH v3 1/4 clk: mediatek: Export PLL operations symbols

Export PLL operations and register functions for different type of clock driver used.

---
 drivers/clk/mediatek/clk-pll.c | 84 ++++++++++++++--------------------
 drivers/clk/mediatek/clk-pll.h | 56 +++++++++++++++++++++++
 2 files changed, 90 insertions(+), 50 deletions(-)
drivers/clk/mediatek/clk-pll.c +34 -50
index 54e6cfd29dfc..a4eca5fd539c 100644
@@ -27,37 +27,10 @@
 
 #define AUDPLL_TUNER_EN		BIT(31)
 
-#define POSTDIV_MASK		0x7
-
 /* default 7 bits integer, can be overridden with pcwibits. */
 #define INTEGER_BITS		7
 
-/*
- * MediaTek PLLs are configured through their pcw value. The pcw value describes
- * a divider in the PLL feedback loop which consists of 7 bits for the integer
- * part and the remaining bits (if present) for the fractional part. Also they
- * have a 3 bit power-of-two post divider.
- */
-
-struct mtk_clk_pll {
-	struct clk_hw	hw;
-	void __iomem	*base_addr;
-	void __iomem	*pd_addr;
-	void __iomem	*pwr_addr;
-	void __iomem	*tuner_addr;
-	void __iomem	*tuner_en_addr;
-	void __iomem	*pcw_addr;
-	void __iomem	*pcw_chg_addr;
-	void __iomem	*en_addr;
-	const struct mtk_pll_data *data;
-};
-
-static inline struct mtk_clk_pll *to_mtk_clk_pll(struct clk_hw *hw)
-{
-	return container_of(hw, struct mtk_clk_pll, hw);
-}
-
-static int mtk_pll_is_prepared(struct clk_hw *hw)
+int mtk_pll_is_prepared(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
@@ -161,8 +134,8 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw,
  * @fin:	The input frequency
  *
  */
-static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
-		u32 freq, u32 fin)
+void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
+			 u32 freq, u32 fin)
 {
 	unsigned long fmin = pll->data->fmin ? pll->data->fmin : (1000 * MHZ);
 	const struct mtk_pll_div_table *div_table = pll->data->div_table;
@@ -198,8 +171,8 @@ static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
 	*pcw = (u32)_pcw;
 }
 
-static int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
-		unsigned long parent_rate)
+int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
+		     unsigned long parent_rate)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 	u32 pcw = 0;
@@ -211,8 +184,7 @@ static int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 	return 0;
 }
 
-static unsigned long mtk_pll_recalc_rate(struct clk_hw *hw,
-		unsigned long parent_rate)
+unsigned long mtk_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 	u32 postdiv;
@@ -227,8 +199,8 @@ static unsigned long mtk_pll_recalc_rate(struct clk_hw *hw,
 	return __mtk_pll_recalc_rate(pll, parent_rate, pcw, postdiv);
 }
 
-static long mtk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
-		unsigned long *prate)
+long mtk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+			unsigned long *prate)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 	u32 pcw = 0;
@@ -239,7 +211,7 @@ static long mtk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
 	return __mtk_pll_recalc_rate(pll, *prate, pcw, postdiv);
 }
 
-static int mtk_pll_prepare(struct clk_hw *hw)
+int mtk_pll_prepare(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 	u32 r;
@@ -273,7 +245,7 @@ static int mtk_pll_prepare(struct clk_hw *hw)
 	return 0;
 }
 
-static void mtk_pll_unprepare(struct clk_hw *hw)
+void mtk_pll_unprepare(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 	u32 r;
@@ -301,7 +273,7 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
 	writel(r, pll->pwr_addr);
 }
 
-static const struct clk_ops mtk_pll_ops = {
+const struct clk_ops mtk_pll_ops = {
 	.is_prepared	= mtk_pll_is_prepared,
 	.prepare	= mtk_pll_prepare,
 	.unprepare	= mtk_pll_unprepare,
@@ -310,18 +282,15 @@ static const struct clk_ops mtk_pll_ops = {
 	.set_rate	= mtk_pll_set_rate,
 };
 
-static struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
-		void __iomem *base)
+struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
+					const struct mtk_pll_data *data,
+					void __iomem *base,
+					const struct clk_ops *pll_ops)
 {
-	struct mtk_clk_pll *pll;
 	struct clk_init_data init = {};
 	int ret;
 	const char *parent_name = "clk26m";
 
-	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
-	if (!pll)
-		return ERR_PTR(-ENOMEM);
-
 	pll->base_addr = base + data->reg;
 	pll->pwr_addr = base + data->pwr_reg;
 	pll->pd_addr = base + data->pd_reg;
@@ -343,7 +312,7 @@ static struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
 
 	init.name = data->name;
 	init.flags = (data->flags & PLL_AO) ? CLK_IS_CRITICAL : 0;
-	init.ops = &mtk_pll_ops;
+	init.ops = pll_ops;
 	if (data->parent_name)
 		init.parent_names = &data->parent_name;
 	else
@@ -360,7 +329,22 @@ static struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
 	return &pll->hw;
 }
 
-static void mtk_clk_unregister_pll(struct clk_hw *hw)
+struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
+				    void __iomem *base)
+{
+	struct mtk_clk_pll *pll;
+	struct clk_hw *hw;
+
+	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+	if (!pll)
+		return ERR_PTR(-ENOMEM);
+
+	hw = mtk_clk_register_pll_ops(pll, data, base, &mtk_pll_ops);
+
+	return hw;
+}
+
+void mtk_clk_unregister_pll(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll;
 
@@ -423,8 +407,8 @@ int mtk_clk_register_plls(struct device_node *node,
 }
 EXPORT_SYMBOL_GPL(mtk_clk_register_plls);
 
-static __iomem void *mtk_clk_pll_get_base(struct clk_hw *hw,
-					  const struct mtk_pll_data *data)
+__iomem void *mtk_clk_pll_get_base(struct clk_hw *hw,
+				   const struct mtk_pll_data *data)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
drivers/clk/mediatek/clk-pll.h +56 -0

78 lines not on this page · raw message

Signature · 1 line
2.18.0
#2 lore raw

Re: [PATCH v3 1/4] clk: mediatek: Export PLL operations symbols

Il 29/09/22 13:46, Johnson Wang ha scritto:

Quoted 204 lines

Export PLL operations and register functions for different type of clock driver used.

---
  drivers/clk/mediatek/clk-pll.c | 84 ++++++++++++++--------------------
  drivers/clk/mediatek/clk-pll.h | 56 +++++++++++++++++++++++
  2 files changed, 90 insertions(+), 50 deletions(-)
drivers/clk/mediatek/clk-pll.c +34 -50
index 54e6cfd29dfc..a4eca5fd539c 100644
@@ -27,37 +27,10 @@
 
  #define AUDPLL_TUNER_EN		BIT(31)
 
-#define POSTDIV_MASK		0x7
-
  /* default 7 bits integer, can be overridden with pcwibits. */
  #define INTEGER_BITS		7
 
-/*
- * MediaTek PLLs are configured through their pcw value. The pcw value describes
- * a divider in the PLL feedback loop which consists of 7 bits for the integer
- * part and the remaining bits (if present) for the fractional part. Also they
- * have a 3 bit power-of-two post divider.
- */
-
-struct mtk_clk_pll {
-	struct clk_hw	hw;
-	void __iomem	*base_addr;
-	void __iomem	*pd_addr;
-	void __iomem	*pwr_addr;
-	void __iomem	*tuner_addr;
-	void __iomem	*tuner_en_addr;
-	void __iomem	*pcw_addr;
-	void __iomem	*pcw_chg_addr;
-	void __iomem	*en_addr;
-	const struct mtk_pll_data *data;
-};
-
-static inline struct mtk_clk_pll *to_mtk_clk_pll(struct clk_hw *hw)
-{
-	return container_of(hw, struct mtk_clk_pll, hw);
-}
-
-static int mtk_pll_is_prepared(struct clk_hw *hw)
+int mtk_pll_is_prepared(struct clk_hw *hw)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
@@ -161,8 +134,8 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw,
   * @fin:	The input frequency
   *
   */
-static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
-		u32 freq, u32 fin)
+void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
+			 u32 freq, u32 fin)
  {
  	unsigned long fmin = pll->data->fmin ? pll->data->fmin : (1000 * MHZ);
  	const struct mtk_pll_div_table *div_table = pll->data->div_table;
@@ -198,8 +171,8 @@ static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
  	*pcw = (u32)_pcw;
  }
 
-static int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
-		unsigned long parent_rate)
+int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
+		     unsigned long parent_rate)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 pcw = 0;
@@ -211,8 +184,7 @@ static int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
  	return 0;
  }
 
-static unsigned long mtk_pll_recalc_rate(struct clk_hw *hw,
-		unsigned long parent_rate)
+unsigned long mtk_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 postdiv;
@@ -227,8 +199,8 @@ static unsigned long mtk_pll_recalc_rate(struct clk_hw *hw,
  	return __mtk_pll_recalc_rate(pll, parent_rate, pcw, postdiv);
  }
 
-static long mtk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
-		unsigned long *prate)
+long mtk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+			unsigned long *prate)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 pcw = 0;
@@ -239,7 +211,7 @@ static long mtk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
  	return __mtk_pll_recalc_rate(pll, *prate, pcw, postdiv);
  }
 
-static int mtk_pll_prepare(struct clk_hw *hw)
+int mtk_pll_prepare(struct clk_hw *hw)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 r;
@@ -273,7 +245,7 @@ static int mtk_pll_prepare(struct clk_hw *hw)
  	return 0;
  }
 
-static void mtk_pll_unprepare(struct clk_hw *hw)
+void mtk_pll_unprepare(struct clk_hw *hw)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 r;
@@ -301,7 +273,7 @@ static void mtk_pll_unprepare(struct clk_hw *hw)
  	writel(r, pll->pwr_addr);
  }
 
-static const struct clk_ops mtk_pll_ops = {
+const struct clk_ops mtk_pll_ops = {
  	.is_prepared	= mtk_pll_is_prepared,
  	.prepare	= mtk_pll_prepare,
  	.unprepare	= mtk_pll_unprepare,
@@ -310,18 +282,15 @@ static const struct clk_ops mtk_pll_ops = {
  	.set_rate	= mtk_pll_set_rate,
  };
 
-static struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
-		void __iomem *base)
+struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
+					const struct mtk_pll_data *data,
+					void __iomem *base,
+					const struct clk_ops *pll_ops)
  {
-	struct mtk_clk_pll *pll;
  	struct clk_init_data init = {};
  	int ret;
  	const char *parent_name = "clk26m";
 
-	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
-	if (!pll)
-		return ERR_PTR(-ENOMEM);
-
  	pll->base_addr = base + data->reg;
  	pll->pwr_addr = base + data->pwr_reg;
  	pll->pd_addr = base + data->pd_reg;
@@ -343,7 +312,7 @@ static struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
 
  	init.name = data->name;
  	init.flags = (data->flags & PLL_AO) ? CLK_IS_CRITICAL : 0;
-	init.ops = &mtk_pll_ops;
+	init.ops = pll_ops;
  	if (data->parent_name)
  		init.parent_names = &data->parent_name;
  	else
@@ -360,7 +329,22 @@ static struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
  	return &pll->hw;
  }
 
-static void mtk_clk_unregister_pll(struct clk_hw *hw)
+struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
+				    void __iomem *base)
+{
+	struct mtk_clk_pll *pll;
+	struct clk_hw *hw;
+
+	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+	if (!pll)
+		return ERR_PTR(-ENOMEM);
+
+	hw = mtk_clk_register_pll_ops(pll, data, base, &mtk_pll_ops);
+
+	return hw;
+}
+
+void mtk_clk_unregister_pll(struct clk_hw *hw)
  {
  	struct mtk_clk_pll *pll;
 
@@ -423,8 +407,8 @@ int mtk_clk_register_plls(struct device_node *node,
  }
  EXPORT_SYMBOL_GPL(mtk_clk_register_plls);
 
-static __iomem void *mtk_clk_pll_get_base(struct clk_hw *hw,
-					  const struct mtk_pll_data *data)
+__iomem void *mtk_clk_pll_get_base(struct clk_hw *hw,
+				   const struct mtk_pll_data *data)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
drivers/clk/mediatek/clk-pll.h +1 -0
index fe3199715688..e87ab08eea9b 100644
@@ -7,6 +7,7 @@
  #ifndef __DRV_CLK_MTK_PLL_H
  #define __DRV_CLK_MTK_PLL_H
 
+#include <linux/clk-provider.h>
  #include <linux/types.h>
 
  struct clk_ops;

drivers/clk/mediatek/clk-pll.h struct mtk_pll_div_table { · line 24

Quoted 4 lines
drivers/clk/mediatek/clk-pll.h +1 -0
@@ -20,6 +21,7 @@ struct mtk_pll_div_table {
 
  #define HAVE_RST_BAR	BIT(0)
  #define PLL_AO		BIT(1)
+#define POSTDIV_MASK	0x7

While moving this, can you please also fixup declaring this mask as GENMASK()?

#define POSTDIV_MASK GENMASK(2, 0)

Quoted 18 lines
drivers/clk/mediatek/clk-pll.h +11 -0
  struct mtk_pll_data {
  	int id;
@@ -48,10 +50,64 @@ struct mtk_pll_data {
  	u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */
  };
 
+/*
+ * MediaTek PLLs are configured through their pcw value. The pcw value describes
+ * a divider in the PLL feedback loop which consists of 7 bits for the integer
+ * part and the remaining bits (if present) for the fractional part. Also they
+ * have a 3 bit power-of-two post divider.
+ */
+
+struct mtk_clk_pll {
+	struct clk_hw	hw;
+	void __iomem	*base_addr;
+	void __iomem	*pd_addr;

drivers/clk/mediatek/clk-pll.h struct mtk_pll_data { · line 73

Quoted 10 lines
drivers/clk/mediatek/clk-pll.h +10 -0
+	void __iomem	*pwr_addr;
+	void __iomem	*tuner_addr;
+	void __iomem	*tuner_en_addr;
+	void __iomem	*pcw_addr;
+	void __iomem	*pcw_chg_addr;
+	void __iomem	*en_addr;
+	const struct mtk_pll_data *data;
+};
+
+

Please drop this extra newline.

Thanks,
Angelo

#3 lore raw

Re: [PATCH v3 1/4] clk: mediatek: Export PLL operations symbols

Quoted 275 lines · AngeloGioacchino Del Regno

Il 29/09/22 13:46, Johnson Wang ha scritto:

Quoted 230 lines

Export PLL operations and register functions for different type of clock driver used.

---
  drivers/clk/mediatek/clk-pll.c | 84 ++++++++++++++---------------
-----
  drivers/clk/mediatek/clk-pll.h | 56 +++++++++++++++++++++++
  2 files changed, 90 insertions(+), 50 deletions(-)
drivers/clk/mediatek/clk-pll.c +0 -4
index 54e6cfd29dfc..a4eca5fd539c 100644
@@ -27,37 +27,10 @@
 
  #define AUDPLL_TUNER_EN		BIT(31)
 
-#define POSTDIV_MASK		0x7
-
  /* default 7 bits integer, can be overridden with pcwibits. */
  #define INTEGER_BITS		7
 
-/*
- * MediaTek PLLs are configured through their pcw value. The pcw

value describes
- * a divider in the PLL feedback loop which consists of 7 bits for the integer
- * part and the remaining bits (if present) for the fractional part. Also they
- * have a 3 bit power-of-two post divider.
- */

drivers/clk/mediatek/clk-pll.c +0 -15
-
-struct mtk_clk_pll {
-	struct clk_hw	hw;
-	void __iomem	*base_addr;
-	void __iomem	*pd_addr;
-	void __iomem	*pwr_addr;
-	void __iomem	*tuner_addr;
-	void __iomem	*tuner_en_addr;
-	void __iomem	*pcw_addr;
-	void __iomem	*pcw_chg_addr;
-	void __iomem	*en_addr;
-	const struct mtk_pll_data *data;
-};
-
-static inline struct mtk_clk_pll *to_mtk_clk_pll(struct clk_hw

*hw)

drivers/clk/mediatek/clk-pll.c +3 -7
-{
-	return container_of(hw, struct mtk_clk_pll, hw);
-}
-
-static int mtk_pll_is_prepared(struct clk_hw *hw)
+int mtk_pll_is_prepared(struct clk_hw *hw)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
@@ -161,8 +134,8 @@ static void mtk_pll_set_rate_regs(struct
 mtk_clk_pll *pll, u32 pcw,
   * @fin:	The input frequency
   *
   */
-static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw,
 u32 *postdiv,
-		u32 freq, u32 fin)
+void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32
 *postdiv,
+			 u32 freq, u32 fin)

{
unsigned long fmin = pll->data->fmin ? pll->data->fmin : (1000
* MHZ);
const struct mtk_pll_div_table *div_table = pll->data-

Quoted 1 line

div_table;

drivers/clk/mediatek/clk-pll.c +2 -2
@@ -198,8 +171,8 @@ static void mtk_pll_calc_values(struct
 mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
  	*pcw = (u32)_pcw;
  }
 
-static int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
-		unsigned long parent_rate)
+int mtk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
+		     unsigned long parent_rate)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 pcw = 0;
drivers/clk/mediatek/clk-pll.c +1 -2
@@ -211,8 +184,7 @@ static int mtk_pll_set_rate(struct clk_hw *hw,
 unsigned long rate,
  	return 0;
  }
 
-static unsigned long mtk_pll_recalc_rate(struct clk_hw *hw,
-		unsigned long parent_rate)
+unsigned long mtk_pll_recalc_rate(struct clk_hw *hw, unsigned long
 parent_rate)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 postdiv;
drivers/clk/mediatek/clk-pll.c +2 -2
@@ -227,8 +199,8 @@ static unsigned long mtk_pll_recalc_rate(struct
 clk_hw *hw,
  	return __mtk_pll_recalc_rate(pll, parent_rate, pcw, postdiv);
  }
 
-static long mtk_pll_round_rate(struct clk_hw *hw, unsigned long
 rate,
-		unsigned long *prate)
+long mtk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+			unsigned long *prate)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 pcw = 0;
drivers/clk/mediatek/clk-pll.c +1 -1
@@ -239,7 +211,7 @@ static long mtk_pll_round_rate(struct clk_hw
 *hw, unsigned long rate,
  	return __mtk_pll_recalc_rate(pll, *prate, pcw, postdiv);
  }
 
-static int mtk_pll_prepare(struct clk_hw *hw)
+int mtk_pll_prepare(struct clk_hw *hw)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);

u32 r;

drivers/clk/mediatek/clk-pll.c +2 -2
@@ -273,7 +245,7 @@ static int mtk_pll_prepare(struct clk_hw *hw)
  	return 0;
  }
 
-static void mtk_pll_unprepare(struct clk_hw *hw)
+void mtk_pll_unprepare(struct clk_hw *hw)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
  	u32 r;
@@ -301,7 +273,7 @@ static void mtk_pll_unprepare(struct clk_hw
 *hw)
  	writel(r, pll->pwr_addr);
  }
 
-static const struct clk_ops mtk_pll_ops = {
+const struct clk_ops mtk_pll_ops = {
  	.is_prepared	= mtk_pll_is_prepared,
  	.prepare	= mtk_pll_prepare,

.unprepare = mtk_pll_unprepare,

drivers/clk/mediatek/clk-pll.c +4 -7
@@ -310,18 +282,15 @@ static const struct clk_ops mtk_pll_ops = {
  	.set_rate	= mtk_pll_set_rate,
  };
 
-static struct clk_hw *mtk_clk_register_pll(const struct
 mtk_pll_data *data,
-		void __iomem *base)
+struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
+					const struct mtk_pll_data
 *data,
+					void __iomem *base,
+					const struct clk_ops *pll_ops)
  {
-	struct mtk_clk_pll *pll;
  	struct clk_init_data init = {};
  	int ret;
  	const char *parent_name = "clk26m";
 
-	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
-	if (!pll)
-		return ERR_PTR(-ENOMEM);
-
  	pll->base_addr = base + data->reg;
  	pll->pwr_addr = base + data->pwr_reg;
  	pll->pd_addr = base + data->pd_reg;
drivers/clk/mediatek/clk-pll.c +1 -1
@@ -343,7 +312,7 @@ static struct clk_hw
 *mtk_clk_register_pll(const struct mtk_pll_data *data,
 
  	init.name = data->name;
  	init.flags = (data->flags & PLL_AO) ? CLK_IS_CRITICAL : 0;
-	init.ops = &mtk_pll_ops;
+	init.ops = pll_ops;
  	if (data->parent_name)
  		init.parent_names = &data->parent_name;

else

drivers/clk/mediatek/clk-pll.c +16 -1
@@ -360,7 +329,22 @@ static struct clk_hw
 *mtk_clk_register_pll(const struct mtk_pll_data *data,
  	return &pll->hw;
  }
 
-static void mtk_clk_unregister_pll(struct clk_hw *hw)
+struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data
 *data,
+				    void __iomem *base)
+{
+	struct mtk_clk_pll *pll;
+	struct clk_hw *hw;
+
+	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+	if (!pll)
+		return ERR_PTR(-ENOMEM);
+
+	hw = mtk_clk_register_pll_ops(pll, data, base, &mtk_pll_ops);
+
+	return hw;
+}
+
+void mtk_clk_unregister_pll(struct clk_hw *hw)
  {

struct mtk_clk_pll *pll;

drivers/clk/mediatek/clk-pll.c +2 -2
@@ -423,8 +407,8 @@ int mtk_clk_register_plls(struct device_node
 *node,
  }
  EXPORT_SYMBOL_GPL(mtk_clk_register_plls);
 
-static __iomem void *mtk_clk_pll_get_base(struct clk_hw *hw,
-					  const struct mtk_pll_data
 *data)
+__iomem void *mtk_clk_pll_get_base(struct clk_hw *hw,
+				   const struct mtk_pll_data *data)
  {
  	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
drivers/clk/mediatek/clk-pll.h +1 -0
index fe3199715688..e87ab08eea9b 100644
@@ -7,6 +7,7 @@
  #ifndef __DRV_CLK_MTK_PLL_H
  #define __DRV_CLK_MTK_PLL_H
 
+#include <linux/clk-provider.h>
  #include <linux/types.h>
 
  struct clk_ops;

drivers/clk/mediatek/clk-pll.h struct mtk_pll_div_table { · line 24

Quoted 4 lines
drivers/clk/mediatek/clk-pll.h +1 -0
@@ -20,6 +21,7 @@ struct mtk_pll_div_table {
 
  #define HAVE_RST_BAR	BIT(0)
  #define PLL_AO		BIT(1)
+#define POSTDIV_MASK	0x7

While moving this, can you please also fixup declaring this mask as GENMASK()?

#define POSTDIV_MASK GENMASK(2, 0)

Quoted 21 lines
drivers/clk/mediatek/clk-pll.h +2 -0
  struct mtk_pll_data {
  	int id;
@@ -48,10 +50,64 @@ struct mtk_pll_data {
  	u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */
  };
 
+/*
+ * MediaTek PLLs are configured through their pcw value. The pcw

value describes
+ * a divider in the PLL feedback loop which consists of 7 bits for the integer
+ * part and the remaining bits (if present) for the fractional part. Also they
+ * have a 3 bit power-of-two post divider.
+ */

drivers/clk/mediatek/clk-pll.h +5 -0
+
+struct mtk_clk_pll {
+	struct clk_hw	hw;
+	void __iomem	*base_addr;
+	void __iomem	*pd_addr;

drivers/clk/mediatek/clk-pll.h struct mtk_pll_data { · line 73

Quoted 10 lines
drivers/clk/mediatek/clk-pll.h +10 -0
+	void __iomem	*pwr_addr;
+	void __iomem	*tuner_addr;
+	void __iomem	*tuner_en_addr;
+	void __iomem	*pcw_addr;
+	void __iomem	*pcw_chg_addr;
+	void __iomem	*en_addr;
+	const struct mtk_pll_data *data;
+};
+
+

Please drop this extra newline.

Quoted 2 lines

Thanks,
Angelo

Hi Angelo,

Thanks for your suggestion.
I will improve this in the next version.

BRs,
Johnson Wang

#4 lore raw

PATCH v3 2/4 dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency hopping

In reply to Johnson Wang

Add the new binding documentation for MediaTek frequency hopping and spread spectrum clocking control.

---
 .../arm/mediatek/mediatek,mt8186-fhctl.yaml   | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +53 -0
new file mode 100644
index 000000000000..258dff7ce6bc
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt8186-fhctl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek frequency hopping and spread spectrum clocking control
+
+maintainers:
+  - Edward-JW Yang <[email protected]>
+
+description: |
+  Frequency hopping control (FHCTL) is a piece of hardware that control
+  some PLLs to adopt "hopping" mechanism to adjust their frequency.
+  Spread spectrum clocking (SSC) is another function provided by this hardware.
+
+properties:
+  compatible:
+    const: mediatek,mt8186-fhctl
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Phandles of the PLL with FHCTL hardware capability.
+    minItems: 1
+    maxItems: 30
+
+  mediatek,hopping-ssc-percent:
+    description: The percentage of spread spectrum clocking for one PLL.
+    minItems: 1
+    maxItems: 30
+    items:
+      default: 0
+      minimum: 0
+      maximum: 8
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8186-clk.h>
+    fhctl: fhctl@1000ce00 {
+        compatible = "mediatek,mt8186-fhctl";
+        reg = <0x1000c000 0xe00>;
+        clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
+        mediatek,hopping-ssc-percent = <3>;
+    };
Signature · 1 line
2.18.0
maintainer Reviewed-by on v3 2/4
#5 lore raw

Re: [PATCH v3 2/4] dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency hopping

Il 29/09/22 13:46, Johnson Wang ha scritto:

Quoted 60 lines

Add the new binding documentation for MediaTek frequency hopping and spread spectrum clocking control.

---
  .../arm/mediatek/mediatek,mt8186-fhctl.yaml   | 53 +++++++++++++++++++
  1 file changed, 53 insertions(+)

create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +43 -0
new file mode 100644
index 000000000000..258dff7ce6bc
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt8186-fhctl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek frequency hopping and spread spectrum clocking control
+
+maintainers:
+  - Edward-JW Yang <[email protected]>
+
+description: |
+  Frequency hopping control (FHCTL) is a piece of hardware that control
+  some PLLs to adopt "hopping" mechanism to adjust their frequency.
+  Spread spectrum clocking (SSC) is another function provided by this hardware.
+
+properties:
+  compatible:
+    const: mediatek,mt8186-fhctl
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Phandles of the PLL with FHCTL hardware capability.
+    minItems: 1
+    maxItems: 30
+
+  mediatek,hopping-ssc-percent:
+    description: The percentage of spread spectrum clocking for one PLL.
+    minItems: 1
+    maxItems: 30
+    items:
+      default: 0
+      minimum: 0
+      maximum: 8
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+additionalProperties: false

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml line 53

Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +10 -0
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8186-clk.h>
+    fhctl: fhctl@1000ce00 {
+        compatible = "mediatek,mt8186-fhctl";
+        reg = <0x1000c000 0xe00>;
+        clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
+        mediatek,hopping-ssc-percent = <3>;
+    };

.... a more realistic example:

    #include <dt-bindings/clock/mt8186-clk.h>

    soc {
        #address-cells = <2>;
        #size-cells = <2>;

        fhctl: fhctl@1000ce00 {
            compatible = "mediatek,mt8186-fhctl";
            reg = <0 0x1000c000 0 0xe00>;
            clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
            mediatek,hopping-ssc-percent = <3>;
        };
    };

After which...

maintainer
#6 lore raw

Re: [PATCH v3 2/4] dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency hopping

Quoted 66 lines · AngeloGioacchino Del Regno

Il 29/09/22 13:46, Johnson Wang ha scritto:

Quoted 65 lines

Add the new binding documentation for MediaTek frequency hopping and spread spectrum clocking control.

---
  .../arm/mediatek/mediatek,mt8186-fhctl.yaml   | 53 +++++++++++++++++++
  1 file changed, 53 insertions(+)

create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +48 -0
new file mode 100644
index 000000000000..258dff7ce6bc
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt8186-fhctl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek frequency hopping and spread spectrum clocking control
+
+maintainers:
+  - Edward-JW Yang <[email protected]>
+
+description: |
+  Frequency hopping control (FHCTL) is a piece of hardware that control
+  some PLLs to adopt "hopping" mechanism to adjust their frequency.
+  Spread spectrum clocking (SSC) is another function provided by this hardware.
+
+properties:
+  compatible:
+    const: mediatek,mt8186-fhctl
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Phandles of the PLL with FHCTL hardware capability.
+    minItems: 1
+    maxItems: 30
+
+  mediatek,hopping-ssc-percent:
+    description: The percentage of spread spectrum clocking for one PLL.
+    minItems: 1
+    maxItems: 30
+    items:
+      default: 0
+      minimum: 0
+      maximum: 8
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8186-clk.h>
+    fhctl: fhctl@1000ce00 {
Quoted 8 lines

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml line 53

Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +5 -0
+        compatible = "mediatek,mt8186-fhctl";
+        reg = <0x1000c000 0xe00>;
+        clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
+        mediatek,hopping-ssc-percent = <3>;
+    };

.... a more realistic example:

One or 2 cells is really outside the scope of the binding as either is valid. If the parent bus only has 32-bits of address space, there's little reason to use 2 cells.

Quoted 19 lines
    #include <dt-bindings/clock/mt8186-clk.h>

    soc {
        #address-cells = <2>;
        #size-cells = <2>;

        fhctl: fhctl@1000ce00 {
            compatible = "mediatek,mt8186-fhctl";
            reg = <0 0x1000c000 0 0xe00>;
            clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
            mediatek,hopping-ssc-percent = <3>;
        };
    };

After which...

#7 lore raw

Re: [PATCH v3 2/4] dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency hopping

Quoted 96 lines · Rob Herring
Quoted 85 lines · AngeloGioacchino Del Regno

Il 29/09/22 13:46, Johnson Wang ha scritto:

Quoted 84 lines

Add the new binding documentation for MediaTek frequency hopping and spread spectrum clocking control.

---
  .../arm/mediatek/mediatek,mt8186-fhctl.yaml   | 53
+++++++++++++++++++
  1 file changed, 53 insertions(+)

create mode 100644
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml
new file mode 100644
index 000000000000..258dff7ce6bc
--- /dev/null
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/arm/mediatek/mediatek,mt8186-fhctl.yaml*__;Iw!!CTRNKA9wMg0ARbw!xVt73f8PaQKph8n0ffGHHmQIxdzooUtGr0xDNVqy_6V0vwcs5k-FLrmkB3PZupSu1ciC$

+$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!xVt73f8PaQKph8n0ffGHHmQIxdzooUtGr0xDNVqy_6V0vwcs5k-FLrmkB3PZulXwBACk$

(quoted diff) +2 -0
+
+title: MediaTek frequency hopping and spread spectrum clocking

control

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +6 -0
+
+maintainers:
+  - Edward-JW Yang <[email protected]>
+
+description: |
+  Frequency hopping control (FHCTL) is a piece of hardware that

control
+ some PLLs to adopt "hopping" mechanism to adjust their frequency.
+ Spread spectrum clocking (SSC) is another function provided by this hardware.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +10 -0
+
+properties:
+  compatible:
+    const: mediatek,mt8186-fhctl
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Phandles of the PLL with FHCTL hardware

capability.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +5 -0
+    minItems: 1
+    maxItems: 30
+
+  mediatek,hopping-ssc-percent:
+    description: The percentage of spread spectrum clocking for

one PLL.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +18 -0
+    minItems: 1
+    maxItems: 30
+    items:
+      default: 0
+      minimum: 0
+      maximum: 8
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8186-clk.h>
+    fhctl: fhctl@1000ce00 {
Quoted 8 lines

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml line 53

Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +5 -0
+        compatible = "mediatek,mt8186-fhctl";
+        reg = <0x1000c000 0xe00>;
+        clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
+        mediatek,hopping-ssc-percent = <3>;
+    };

.... a more realistic example:

Quoted 5 lines

One or 2 cells is really outside the scope of the binding as either is
valid. If the parent bus only has 32-bits of address space, there's little reason to use 2 cells.

Hi Rob,

Thanks for the explanation.

Then I will keep this example the same in the next version.

BRs,
Johnson Wang

Quoted 20 lines
Quoted 20 lines
    #include <dt-bindings/clock/mt8186-clk.h>

    soc {
        #address-cells = <2>;
        #size-cells = <2>;

        fhctl: fhctl@1000ce00 {
            compatible = "mediatek,mt8186-fhctl";
            reg = <0 0x1000c000 0 0xe00>;
            clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
            mediatek,hopping-ssc-percent = <3>;
        };
    };

After which...

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

#8 lore raw

Re: [PATCH v3 2/4] dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency hopping

Il 06/10/22 13:23, Johnson Wang (王聖鑫) ha scritto:

Quoted 103 lines · Rob Herring
Quoted 96 lines
Quoted 85 lines · AngeloGioacchino Del Regno

Il 29/09/22 13:46, Johnson Wang ha scritto:

Quoted 84 lines

Add the new binding documentation for MediaTek frequency hopping and spread spectrum clocking control.

---
   .../arm/mediatek/mediatek,mt8186-fhctl.yaml   | 53
+++++++++++++++++++
   1 file changed, 53 insertions(+)

create mode 100644
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml
new file mode 100644
index 000000000000..258dff7ce6bc
--- /dev/null
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186- fhctl.yaml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id:

https://urldefense.com/v3/__http://devicetree.org/schemas/arm/mediatek/mediatek,mt8186-fhctl.yaml*__;Iw!!CTRNKA9wMg0ARbw!xVt73f8PaQKph8n0ffGHHmQIxdzooUtGr0xDNVqy_6V0vwcs5k-FLrmkB3PZupSu1ciC$

+$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!xVt73f8PaQKph8n0ffGHHmQIxdzooUtGr0xDNVqy_6V0vwcs5k-FLrmkB3PZulXwBACk$

(quoted diff) +2 -0
+
+title: MediaTek frequency hopping and spread spectrum clocking

control

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +6 -0
+
+maintainers:
+  - Edward-JW Yang <[email protected]>
+
+description: |
+  Frequency hopping control (FHCTL) is a piece of hardware that

control
+ some PLLs to adopt "hopping" mechanism to adjust their frequency.
+ Spread spectrum clocking (SSC) is another function provided by this hardware.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +10 -0
+
+properties:
+  compatible:
+    const: mediatek,mt8186-fhctl
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Phandles of the PLL with FHCTL hardware

capability.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +5 -0
+    minItems: 1
+    maxItems: 30
+
+  mediatek,hopping-ssc-percent:
+    description: The percentage of spread spectrum clocking for

one PLL.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +18 -0
+    minItems: 1
+    maxItems: 30
+    items:
+      default: 0
+      minimum: 0
+      maximum: 8
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8186-clk.h>
+    fhctl: fhctl@1000ce00 {
Quoted 8 lines

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml line 53

Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +5 -0
+        compatible = "mediatek,mt8186-fhctl";
+        reg = <0x1000c000 0xe00>;
+        clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
+        mediatek,hopping-ssc-percent = <3>;
+    };

.... a more realistic example:

Quoted 5 lines

One or 2 cells is really outside the scope of the binding as either is
valid. If the parent bus only has 32-bits of address space, there's little reason to use 2 cells.

Quoted 5 lines

Hi Rob,

Thanks for the explanation.

Then I will keep this example the same in the next version.

That was just to have it 1:1 with how it'll be written in the devicetree.... ....in any case, Johnson, there's a discrepancy in the iospace:
1000ce00 vs 0c1000c000 - that has to be fixed anyway.

Cheers,
Angelo

Quoted 23 lines

BRs,
Johnson Wang

Quoted 20 lines
Quoted 20 lines
     #include <dt-bindings/clock/mt8186-clk.h>

     soc {
         #address-cells = <2>;
         #size-cells = <2>;

         fhctl: fhctl@1000ce00 {
             compatible = "mediatek,mt8186-fhctl";
             reg = <0 0x1000c000 0 0xe00>;
             clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
             mediatek,hopping-ssc-percent = <3>;
         };
     };

After which...

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

#9 lore raw

Re: [PATCH v3 2/4] dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency hopping

Quoted 34 lines · AngeloGioacchino Del Regno

Il 06/10/22 13:23, Johnson Wang (王聖鑫) ha scritto:

Quoted 33 lines · Rob Herring
Quoted 32 lines
Quoted 29 lines · AngeloGioacchino Del Regno

Il 29/09/22 13:46, Johnson Wang ha scritto:

Quoted 28 lines

Add the new binding documentation for MediaTek frequency hopping
and spread spectrum clocking control.

---
   .../arm/mediatek/mediatek,mt8186-fhctl.yaml   | 53
+++++++++++++++++++
   1 file changed, 53 insertions(+)

create mode 100644
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt818 6-
fhctl.yaml

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8 186-
fhctl.yaml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8 186-
fhctl.yaml
new file mode 100644
index 000000000000..258dff7ce6bc
--- /dev/null
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml line 4

Quoted 8 lines

186-
fhctl.yaml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +4 -0
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id:

https://urldefense.com/v3/__http://devicetree.org/schemas/arm/mediatek/mediatek,mt8186-fhctl.yaml*__;Iw!!CTRNKA9wMg0ARbw!xVt73f8PaQKph8n0ffGHHmQIxdzooUtGr0xDNVqy_6V0vwcs5k-FLrmkB3PZupSu1ciC$

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review line 5

Quoted 3 lines
(quoted diff) +1 -0
+$schema:

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!xVt73f8PaQKph8n0ffGHHmQIxdzooUtGr0xDNVqy_6V0vwcs5k-FLrmkB3PZulXwBACk$

Quoted 77 lines
Quoted 71 lines
Quoted 63 lines
Quoted 54 lines
Quoted 54 lines
(quoted diff) +2 -0
+
+title: MediaTek frequency hopping and spread spectrum

clocking
control

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +6 -0
+
+maintainers:
+  - Edward-JW Yang <[email protected]>
+
+description: |
+  Frequency hopping control (FHCTL) is a piece of hardware

that
control
+ some PLLs to adopt "hopping" mechanism to adjust their frequency.
+ Spread spectrum clocking (SSC) is another function provided by
this hardware.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +10 -0
+
+properties:
+  compatible:
+    const: mediatek,mt8186-fhctl
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    description: Phandles of the PLL with FHCTL hardware

capability.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +5 -0
+    minItems: 1
+    maxItems: 30
+
+  mediatek,hopping-ssc-percent:
+    description: The percentage of spread spectrum clocking

for
one PLL.

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +18 -0
+    minItems: 1
+    maxItems: 30
+    items:
+      default: 0
+      minimum: 0
+      maximum: 8
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8186-clk.h>
+    fhctl: fhctl@1000ce00 {
Quoted 8 lines

Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml line 53

Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml new file +5 -0
+        compatible = "mediatek,mt8186-fhctl";
+        reg = <0x1000c000 0xe00>;
+        clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
+        mediatek,hopping-ssc-percent = <3>;
+    };

.... a more realistic example:

Quoted 7 lines

One or 2 cells is really outside the scope of the binding as either
is
valid. If the parent bus only has 32-bits of address space, there's
little reason to use 2 cells.

Quoted 5 lines

Hi Rob,

Thanks for the explanation.

Then I will keep this example the same in the next version.

Quoted 7 lines

That was just to have it 1:1 with how it'll be written in the devicetree....
....in any case, Johnson, there's a discrepancy in the iospace:
1000ce00 vs 0c1000c000 - that has to be fixed anyway.

Cheers,
Angelo

Hi Angelo,

Thank you for reminding me.
I didn't notice the iospace typo in the example.

I will fix it in the next version.

BRs,
Johnson Wang

Quoted 26 lines
Quoted 24 lines

BRs,
Johnson Wang

Quoted 20 lines
Quoted 20 lines
     #include <dt-bindings/clock/mt8186-clk.h>

     soc {
         #address-cells = <2>;
         #size-cells = <2>;

         fhctl: fhctl@1000ce00 {
             compatible = "mediatek,mt8186-fhctl";
             reg = <0 0x1000c000 0 0xe00>;
             clocks = <&apmixedsys CLK_APMIXED_MSDCPLL>;
             mediatek,hopping-ssc-percent = <3>;
         };
     };

After which...

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

maintainer Reviewed-by on v3 2/4
#10 lore raw

Re: [PATCH v3 2/4] dt-bindings: arm: mediatek: Add new bindings of MediaTek frequency hopping

In reply to Johnson Wang
Quoted 11 lines · Johnson Wang

Add the new binding documentation for MediaTek frequency hopping and spread spectrum clocking control.

---
 .../arm/mediatek/mediatek,mt8186-fhctl.yaml   | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt8186-fhctl.yaml
#11 lore raw

PATCH v3 3/4 clk: mediatek: Add new clock driver to handle FHCTL hardware

In reply to Johnson Wang

To implement frequency hopping and spread spectrum clocking function, we introduce new clock type and APIs to handle FHCTL hardware.

---
 drivers/clk/mediatek/Kconfig     |   7 +
 drivers/clk/mediatek/Makefile    |   1 +
 drivers/clk/mediatek/clk-fhctl.c | 244 ++++++++++++++++++++++++++++
 drivers/clk/mediatek/clk-fhctl.h |  26 +++
 drivers/clk/mediatek/clk-pllfh.c | 268 +++++++++++++++++++++++++++++++
 drivers/clk/mediatek/clk-pllfh.h |  82 ++++++++++
 6 files changed, 628 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-fhctl.c
 create mode 100644 drivers/clk/mediatek/clk-fhctl.h
 create mode 100644 drivers/clk/mediatek/clk-pllfh.c
 create mode 100644 drivers/clk/mediatek/clk-pllfh.h
drivers/clk/mediatek/Kconfig +7 -0
index d5936cfb3bee..65b25082daf2 100644
@@ -11,6 +11,13 @@ config COMMON_CLK_MEDIATEK
 	help
 	  MediaTek SoCs' clock support.
 
+config COMMON_CLK_MEDIATEK_FHCTL
+	bool "clock driver for MediaTek FHCTL hardware control"
+	select COMMON_CLK_MEDIATEK
+	help
+	  This driver supports MediaTek frequency hopping and
+	  spread spectrum clocking features.
+
 config COMMON_CLK_MT2701
 	bool "Clock driver for MediaTek MT2701"
 	depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index caf2ce93d666..80a9f4a4aa03 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o clk-cpumux.o reset.o clk-mux.o
+obj-$(CONFIG_COMMON_CLK_MEDIATEK_FHCTL) += clk-fhctl.o clk-pllfh.o
 
 obj-$(CONFIG_COMMON_CLK_MT6765) += clk-mt6765.o
 obj-$(CONFIG_COMMON_CLK_MT6765_AUDIOSYS) += clk-mt6765-audio.o
drivers/clk/mediatek/clk-fhctl.c new file +244 -0

244 lines not on this page · raw message

drivers/clk/mediatek/clk-fhctl.h new file +26 -0
new file mode 100644
index 000000000000..51275febf086
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Edward-JW Yang <[email protected]>
+ */
+
+#ifndef __CLK_FHCTL_H
+#define __CLK_FHCTL_H
+
+struct fhctl_offset {
+	u32 offset_hp_en;
+	u32 offset_clk_con;
+	u32 offset_rst_con;
+	u32 offset_slope0;
+	u32 offset_slope1;
+	u32 offset_cfg;
+	u32 offset_updnlmt;
+	u32 offset_dds;
+	u32 offset_dvfs;
+	u32 offset_mon;
+};
+const struct fhctl_offset *fhctl_get_offset_table(void);
+const struct fh_operation *fhctl_get_ops(void);
+void fhctl_hw_init(struct mtk_fh *fh);
+
+#endif
drivers/clk/mediatek/clk-pllfh.c new file +268 -0

268 lines not on this page · raw message

drivers/clk/mediatek/clk-pllfh.h new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
2.18.0
#12 lore raw

PATCH v3 4/4 clk: mediatek: Change PLL register API for MT8186

In reply to Johnson Wang

Use mtk_clk_register_pllfhs() to enhance frequency hopping and spread spectrum clocking control for MT8186.

---
 drivers/clk/mediatek/Kconfig                 |  1 +
 drivers/clk/mediatek/clk-mt8186-apmixedsys.c | 66 +++++++++++++++++++-
 2 files changed, 64 insertions(+), 3 deletions(-)
drivers/clk/mediatek/Kconfig +1 -0
index 65b25082daf2..2de905aa6132 100644
@@ -523,6 +523,7 @@ config COMMON_CLK_MT8186
 	bool "Clock driver for MediaTek MT8186"
 	depends on ARM64 || COMPILE_TEST
 	select COMMON_CLK_MEDIATEK
+	select COMMON_CLK_MEDIATEK_FHCTL
 	default ARCH_MEDIATEK
 	help
 	  This driver supports MediaTek MT8186 clocks.
drivers/clk/mediatek/clk-mt8186-apmixedsys.c +63 -3

102 lines not on this page · raw message

Signature · 1 line
2.18.0