Skip to contentSkip to conversation

clk: qcom: clk-alpha-pll: Add support for controlling Agera PLLs

PATCH Superseded Taniya Das 3 participants 8 messages Sep 8, 2020 – Oct 13, 2020 3 messages not in the archive

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Taniya Das

author
#1 lore raw

PATCH 1/3 clk: qcom: clk-alpha-pll: Add support for controlling Agera PLLs

Add programming sequence support for managing the Agera PLLs.

---
 drivers/clk/qcom/clk-alpha-pll.c | 82 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/qcom/clk-alpha-pll.h |  4 ++
 2 files changed, 86 insertions(+)
drivers/clk/qcom/clk-alpha-pll.c +82 -0
index 26139ef..fb27fcf 100644
@@ -116,6 +116,16 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = {
 		[PLL_OFF_OPMODE] = 0x38,
 		[PLL_OFF_ALPHA_VAL] = 0x40,
 	},
+	[CLK_ALPHA_PLL_TYPE_AGERA] =  {
+		[PLL_OFF_L_VAL] = 0x04,
+		[PLL_OFF_ALPHA_VAL] = 0x08,
+		[PLL_OFF_USER_CTL] = 0x0c,
+		[PLL_OFF_CONFIG_CTL] = 0x10,
+		[PLL_OFF_CONFIG_CTL_U] = 0x14,
+		[PLL_OFF_TEST_CTL] = 0x18,
+		[PLL_OFF_TEST_CTL_U] = 0x1c,
+		[PLL_OFF_STATUS] = 0x2c,
+	},
 };
 EXPORT_SYMBOL_GPL(clk_alpha_pll_regs);
 
@@ -1561,3 +1571,75 @@ const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = {
 	.set_rate = clk_alpha_pll_postdiv_fabia_set_rate,
 };
 EXPORT_SYMBOL_GPL(clk_alpha_pll_postdiv_lucid_ops);
+
+void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
+			const struct alpha_pll_config *config)
+{
+	if (config->l)
+		regmap_write(regmap, PLL_L_VAL(pll), config->l);
+
+	if (config->alpha)
+		regmap_write(regmap, PLL_ALPHA_VAL(pll), config->alpha);
+
+	if (config->user_ctl_val)
+		regmap_write(regmap, PLL_USER_CTL(pll), config->user_ctl_val);
+
+	if (config->config_ctl_val)
+		regmap_write(regmap, PLL_CONFIG_CTL(pll),
+						config->config_ctl_val);
+
+	if (config->config_ctl_hi_val)
+		regmap_write(regmap, PLL_CONFIG_CTL_U(pll),
+						config->config_ctl_hi_val);
+
+	if (config->test_ctl_val)
+		regmap_write(regmap, PLL_TEST_CTL(pll),
+						config->test_ctl_val);
+
+	if (config->test_ctl_hi_val)
+		regmap_write(regmap,  PLL_TEST_CTL_U(pll),
+						config->test_ctl_hi_val);
+}
+EXPORT_SYMBOL_GPL(clk_agera_pll_configure);
+
+static int alpha_pll_agera_set_rate(struct clk_hw *hw, unsigned long rate,
+							unsigned long prate)
+{
+	struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+	u32 l, alpha_width = pll_alpha_width(pll);
+	unsigned long rrate;
+	u64 a;
+
+	rrate = alpha_pll_round_rate(rate, prate, &l, &a, alpha_width);
+
+	/*
+	 * Due to limited number of bits for fractional rate programming, the
+	 * rounded up rate could be marginally higher than the requested rate.
+	 */
+	if (rrate > (rate + PLL_RATE_MARGIN) || rrate < rate) {
+		pr_err("Call set rate on the PLL with rounded rates!\n");
+		return -EINVAL;
+	}
+
+	/* change L_VAL without having to go through the power on sequence */
+	regmap_write(pll->clkr.regmap, PLL_L_VAL(pll), l);
+	regmap_write(pll->clkr.regmap, PLL_ALPHA_VAL(pll), a);
+
+	/* Ensure that the write above goes through before proceeding. */
+	mb();
+
+	if (clk_hw_is_enabled(hw))
+		return wait_for_pll_enable_lock(pll);
+
+	return 0;
+}
+
+const struct clk_ops clk_alpha_pll_agera_ops = {
+	.enable = clk_alpha_pll_enable,
+	.disable = clk_alpha_pll_disable,
+	.is_enabled = clk_alpha_pll_is_enabled,
+	.recalc_rate = alpha_pll_fabia_recalc_rate,
+	.round_rate = clk_alpha_pll_round_rate,
+	.set_rate = alpha_pll_agera_set_rate,
+};
+EXPORT_SYMBOL_GPL(clk_alpha_pll_agera_ops);
drivers/clk/qcom/clk-alpha-pll.h +4 -0
index d3201b8..0ea30d2 100644
@@ -15,6 +15,7 @@ enum {
 	CLK_ALPHA_PLL_TYPE_FABIA,
 	CLK_ALPHA_PLL_TYPE_TRION,
 	CLK_ALPHA_PLL_TYPE_LUCID = CLK_ALPHA_PLL_TYPE_TRION,
+	CLK_ALPHA_PLL_TYPE_AGERA,
 	CLK_ALPHA_PLL_TYPE_MAX,
 };
 
@@ -141,6 +142,7 @@ extern const struct clk_ops clk_alpha_pll_postdiv_trion_ops;
 extern const struct clk_ops clk_alpha_pll_lucid_ops;
 #define clk_alpha_pll_fixed_lucid_ops clk_alpha_pll_fixed_trion_ops
 extern const struct clk_ops clk_alpha_pll_postdiv_lucid_ops;
+extern const struct clk_ops clk_alpha_pll_agera_ops;
 
 void clk_alpha_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
 			     const struct alpha_pll_config *config);
@@ -148,6 +150,8 @@ void clk_fabia_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
 				const struct alpha_pll_config *config);
 void clk_trion_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
 			     const struct alpha_pll_config *config);
+void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
+				const struct alpha_pll_config *config);
 #define clk_lucid_pll_configure(pll, regmap, config) \
 	clk_trion_pll_configure(pll, regmap, config)
 

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

author
#2 lore raw

PATCH 2/3 dt-bindings: clock: Add YAML schemas for the QCOM Camera clock bindings.

In reply to a message not in the archive

The Camera Subsystem clock provider have a bunch of generic properties that are needed in a device tree. Add a YAML schemas for those.

Add clock ids for Camera clocks which are required to bring the camera subsystem out of reset.

---
 .../bindings/clock/qcom,sc7180-camcc.yaml          |  73 +++++++++++++
 include/dt-bindings/clock/qcom,camcc-sc7180.h      | 121 +++++++++++++++++++++
 2 files changed, 194 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml
 create mode 100644 include/dt-bindings/clock/qcom,camcc-sc7180.h
Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml new file +73 -0
new file mode 100644
index 0000000..07bd38e
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/qcom,sc7180-camcc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Camera Clock & Reset Controller Binding for SC7180
+
+maintainers:
+  - Taniya Das <[email protected]>
+
+description: |
+  Qualcomm camera clock control module which supports the clocks, resets and
+  power domains on SC7180.
+
+  See also:
+  - dt-bindings/clock/qcom,camcc-sc7180.h.
+
+properties:
+  compatible:
+    const: qcom,sc7180-camcc
+
+  clocks:
+    items:
+      - description: Board XO source
+      - description: Camera_ahb clock from GCC
+      - description: Camera XO clock from GCC
+
+  clock-names:
+    items:
+      - const: bi_tcxo
+      - const: iface
+      - const: xo
+
+  '#clock-cells':
+    const: 1
+
+  '#reset-cells':
+    const: 1
+
+  '#power-domain-cells':
+    const: 1
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+  - '#reset-cells'
+  - '#power-domain-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/qcom,gcc-sc7180.h>
+    #include <dt-bindings/clock/qcom,rpmh.h>
+    clock-controller@ad00000 {
+      compatible = "qcom,sc7180-camcc";
+      reg = <0x0ad00000 0x10000>;
+      clocks = <&rpmhcc RPMH_CXO_CLK>,
+               <&gcc GCC_CAMERA_AHB_CLK>,
+               <&gcc GCC_CAMERA_XO_CLK>;
+      clock-names = "bi_tcxo", "iface", "xo";
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+      #power-domain-cells = <1>;
+    };
+...
include/dt-bindings/clock/qcom,camcc-sc7180.h new file +121 -0

121 lines not on this page · raw message

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

author
#3 lore raw

PATCH 3/3 clk: qcom: camcc: Add camera clock controller driver for SC7180

In reply to a message not in the archive

Add support for the camera clock controller found on SC7180 based devices. This would allow camera drivers to probe and control their clocks.

---
 drivers/clk/qcom/Kconfig        |    9 +
 drivers/clk/qcom/Makefile       |    1 +
 drivers/clk/qcom/camcc-sc7180.c | 1737 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 1747 insertions(+)
 create mode 100644 drivers/clk/qcom/camcc-sc7180.c
drivers/clk/qcom/Kconfig +9 -0
index 0583273..7aeebe6 100644
@@ -290,6 +290,15 @@ config QCS_GCC_404
 	  Say Y if you want to use multimedia devices or peripheral
 	  devices such as UART, SPI, I2C, USB, SD/eMMC, PCIe etc.
 
+config SC_CAMCC_7180
+	tristate "SC7180 Camera Clock Controller"
+	select SC_GCC_7180
+	help
+	  Support for the camera clock controller on Qualcomm Technologies, Inc
+	  SC7180 devices.
+	  Say Y if you want to support camera devices and functionality such as
+	  capturing pictures.
+
 config SC_DISPCC_7180
 	tristate "SC7180 Display Clock Controller"
 	select SC_GCC_7180
drivers/clk/qcom/Makefile +1 -0
index 9677e76..8e0579f 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o
 obj-$(CONFIG_QCS_GCC_404) += gcc-qcs404.o
 obj-$(CONFIG_QCS_Q6SSTOP_404) += q6sstop-qcs404.o
 obj-$(CONFIG_QCS_TURING_404) += turingcc-qcs404.o
+obj-$(CONFIG_SC_CAMCC_7180) += camcc-sc7180.o
 obj-$(CONFIG_SC_DISPCC_7180) += dispcc-sc7180.o
 obj-$(CONFIG_SC_GCC_7180) += gcc-sc7180.o
 obj-$(CONFIG_SC_GPUCC_7180) += gpucc-sc7180.o
drivers/clk/qcom/camcc-sc7180.c new file +1737 -0

1,737 lines not on this page · raw message

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

#4 lore raw

Re: [PATCH v1 3/3] clk: qcom: camcc: Add camera clock controller driver for SC7180

Thank you for the patch! Yet something to improve:

Hi Taniya,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on clk/clk-next]
[also build test ERROR on v5.9-rc6 next-20200921]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Taniya-Das/clk-qcom-clk-alpha-pll-Add-support-for-controlling-Agera-PLLs/20200909-011101
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: h8300-allyesconfig (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=h8300

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/clk/qcom/camcc-sc7180.c:36:2: warning: this decimal constant is unsigned only in ISO C90

      36 |  { 600000000, 3300000000, 0 },
         |  ^
   drivers/clk/qcom/camcc-sc7180.c: In function 'cam_cc_sc7180_probe':
>> drivers/clk/qcom/camcc-sc7180.c:1672:8: error: implicit declaration of function 'pm_clk_runtime_resume'; did you mean 'pm_runtime_resume'? [-Werror=implicit-function-declaration]
    1672 |  ret = pm_clk_runtime_resume(&pdev->dev);
         |        ^~~~~~~~~~~~~~~~~~~~~
         |        pm_runtime_resume
>> drivers/clk/qcom/camcc-sc7180.c:1696:8: error: implicit declaration of function 'pm_clk_runtime_suspend'; did you mean 'pm_runtime_suspend'? [-Werror=implicit-function-declaration]
    1696 |  ret = pm_clk_runtime_suspend(&pdev->dev);
         |        ^~~~~~~~~~~~~~~~~~~~~~
         |        pm_runtime_suspend

cc1: some warnings being treated as errors

# https://github.com/0day-ci/linux/commit/05a7fc252efe1fcdd278d22893ea689d8b5f1f1e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Taniya-Das/clk-qcom-clk-alpha-pll-Add-support-for-controlling-Agera-PLLs/20200909-011101 git checkout 05a7fc252efe1fcdd278d22893ea689d8b5f1f1e
vim +1672 drivers/clk/qcom/camcc-sc7180.c

1649
1650 static int cam_cc_sc7180_probe(struct platform_device *pdev)
1651 {
1652 struct regmap *regmap;
1653 int ret;
1654
1655 pm_runtime_enable(&pdev->dev);
1656 ret = pm_clk_create(&pdev->dev);
1657 if (ret)
1658 return ret;
1659
1660 ret = pm_clk_add(&pdev->dev, "xo");
1661 if (ret < 0) {
1662 dev_err(&pdev->dev, "Failed to acquire XO clock\n");
1663 goto disable_pm_runtime;
1664 }
1665
1666 ret = pm_clk_add(&pdev->dev, "iface");
1667 if (ret < 0) {
1668 dev_err(&pdev->dev, "Failed to acquire iface clock\n");
1669 goto disable_pm_runtime;
1670 }
1671

> 1672		ret = pm_clk_runtime_resume(&pdev->dev);
  1673		if (ret) {
  1674			dev_err(&pdev->dev, "pm runtime resume failed\n");
  1675			goto destroy_pm_clk;
  1676		}
  1677	
  1678		regmap = qcom_cc_map(pdev, &cam_cc_sc7180_desc);
  1679		if (IS_ERR(regmap)) {
  1680			ret = PTR_ERR(regmap);
  1681			goto destroy_pm_clk;
  1682		}
  1683	
  1684		clk_fabia_pll_configure(&cam_cc_pll0, regmap, &cam_cc_pll0_config);
  1685		clk_fabia_pll_configure(&cam_cc_pll1, regmap, &cam_cc_pll1_config);
  1686		clk_agera_pll_configure(&cam_cc_pll2, regmap, &cam_cc_pll2_config);
  1687		clk_fabia_pll_configure(&cam_cc_pll3, regmap, &cam_cc_pll3_config);
  1688	
  1689		ret = qcom_cc_really_probe(pdev, &cam_cc_sc7180_desc, regmap);
  1690		if (ret) {
  1691			dev_err(&pdev->dev, "Failed to register CAM CC clocks\n");
  1692			goto suspend_pm_runtime;
  1693		}
  1694	
  1695	suspend_pm_runtime:
> 1696		ret = pm_clk_runtime_suspend(&pdev->dev);

1697 if (ret)
1698 dev_err(&pdev->dev, "pm runtime suspend failed\n");
1699
1700 return 0;
1701
1702 destroy_pm_clk:
1703 pm_clk_destroy(&pdev->dev);
1704
1705 disable_pm_runtime:
1706 pm_runtime_disable(&pdev->dev);
1707
1708 return ret;
1709 }
1710

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#5 lore raw

Re: [PATCH v1 0/3] Add Camera clock controller driver for SC7180

In reply to a message not in the archive

Quoting Taniya Das (2020-09-08 10:07:25)

Quoted 6 lines

[v1]
* Add support for Agera PLL which is used in the camera clock controller.

* Add driver support for camera clock controller for SC7180 and also update device tree bindings for the various clocks supported in the clock controller.

I got duplicate patches in my inbox. Is something broken on the codeaurora server?

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#7 lore raw

Quoting Taniya Das (2020-09-08 10:07:26)

Quoted 30 lines
drivers/clk/qcom/clk-alpha-pll.c +22 -0
index 26139ef..fb27fcf 100644
@@ -1561,3 +1571,75 @@ const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = {
        .set_rate = clk_alpha_pll_postdiv_fabia_set_rate,
 };
 EXPORT_SYMBOL_GPL(clk_alpha_pll_postdiv_lucid_ops);
+
+void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
+                       const struct alpha_pll_config *config)
+{
+       if (config->l)
+               regmap_write(regmap, PLL_L_VAL(pll), config->l);
+
+       if (config->alpha)
+               regmap_write(regmap, PLL_ALPHA_VAL(pll), config->alpha);
+
+       if (config->user_ctl_val)
+               regmap_write(regmap, PLL_USER_CTL(pll), config->user_ctl_val);
+
+       if (config->config_ctl_val)
+               regmap_write(regmap, PLL_CONFIG_CTL(pll),
+                                               config->config_ctl_val);
+
+       if (config->config_ctl_hi_val)
+               regmap_write(regmap, PLL_CONFIG_CTL_U(pll),
+                                               config->config_ctl_hi_val);
+
+       if (config->test_ctl_val)

drivers/clk/qcom/clk-alpha-pll.c const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = { · line 1605

Quoted 10 lines
drivers/clk/qcom/clk-alpha-pll.c +10 -0
+               regmap_write(regmap, PLL_TEST_CTL(pll),
+                                               config->test_ctl_val);
+
+       if (config->test_ctl_hi_val)
+               regmap_write(regmap,  PLL_TEST_CTL_U(pll),
+                                               config->test_ctl_hi_val);
+}
+EXPORT_SYMBOL_GPL(clk_agera_pll_configure);
+
+static int alpha_pll_agera_set_rate(struct clk_hw *hw, unsigned long rate,

Why not clk_alpha_pll prefix? We should prefix the other PLL functions in here with clk_alpha_ like trion and fabia

Quoted 7 lines
drivers/clk/qcom/clk-alpha-pll.c +7 -0
+                                                       unsigned long prate)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+       u32 l, alpha_width = pll_alpha_width(pll);
+       unsigned long rrate;
+       u64 a;
+

drivers/clk/qcom/clk-alpha-pll.c const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = { · line 1622

Quoted 10 lines
drivers/clk/qcom/clk-alpha-pll.c +10 -0
+       rrate = alpha_pll_round_rate(rate, prate, &l, &a, alpha_width);
+
+       /*
+        * Due to limited number of bits for fractional rate programming, the
+        * rounded up rate could be marginally higher than the requested rate.
+        */
+       if (rrate > (rate + PLL_RATE_MARGIN) || rrate < rate) {
+               pr_err("Call set rate on the PLL with rounded rates!\n");
+               return -EINVAL;
+       }

See commit f78f29079327 ("clk: qcom: alpha-pll: Make error prints more informative") where I tried to make this better. Can you extract this check into a function that helps us understand the error better?

drivers/clk/qcom/clk-alpha-pll.c const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = { · line 1629

Quoted 7 lines
drivers/clk/qcom/clk-alpha-pll.c +7 -0
+
+       /* change L_VAL without having to go through the power on sequence */
+       regmap_write(pll->clkr.regmap, PLL_L_VAL(pll), l);
+       regmap_write(pll->clkr.regmap, PLL_ALPHA_VAL(pll), a);
+
+       /* Ensure that the write above goes through before proceeding. */
+       mb();

regmap has an mb() in it. Remove this?

Quoted 16 lines
drivers/clk/qcom/clk-alpha-pll.c +16 -0
+
+       if (clk_hw_is_enabled(hw))
+               return wait_for_pll_enable_lock(pll);
+
+       return 0;
+}
+
+const struct clk_ops clk_alpha_pll_agera_ops = {
+       .enable = clk_alpha_pll_enable,
+       .disable = clk_alpha_pll_disable,
+       .is_enabled = clk_alpha_pll_is_enabled,
+       .recalc_rate = alpha_pll_fabia_recalc_rate,
+       .round_rate = clk_alpha_pll_round_rate,
+       .set_rate = alpha_pll_agera_set_rate,
+};
+EXPORT_SYMBOL_GPL(clk_alpha_pll_agera_ops);
author
#8 lore raw

Thanks for the review Stephen.

Quoted 36 lines · Stephen Boyd

Quoting Taniya Das (2020-09-08 10:07:26)

Quoted 35 lines
drivers/clk/qcom/clk-alpha-pll.c +27 -0
index 26139ef..fb27fcf 100644
@@ -1561,3 +1571,75 @@ const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = {
         .set_rate = clk_alpha_pll_postdiv_fabia_set_rate,
  };
  EXPORT_SYMBOL_GPL(clk_alpha_pll_postdiv_lucid_ops);
+
+void clk_agera_pll_configure(struct clk_alpha_pll *pll, struct regmap *regmap,
+                       const struct alpha_pll_config *config)
+{
+       if (config->l)
+               regmap_write(regmap, PLL_L_VAL(pll), config->l);
+
+       if (config->alpha)
+               regmap_write(regmap, PLL_ALPHA_VAL(pll), config->alpha);
+
+       if (config->user_ctl_val)
+               regmap_write(regmap, PLL_USER_CTL(pll), config->user_ctl_val);
+
+       if (config->config_ctl_val)
+               regmap_write(regmap, PLL_CONFIG_CTL(pll),
+                                               config->config_ctl_val);
+
+       if (config->config_ctl_hi_val)
+               regmap_write(regmap, PLL_CONFIG_CTL_U(pll),
+                                               config->config_ctl_hi_val);
+
+       if (config->test_ctl_val)
+               regmap_write(regmap, PLL_TEST_CTL(pll),
+                                               config->test_ctl_val);
+
+       if (config->test_ctl_hi_val)
+               regmap_write(regmap,  PLL_TEST_CTL_U(pll),
Quoted 9 lines

drivers/clk/qcom/clk-alpha-pll.c const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = { · line 1605

Quoted 5 lines
drivers/clk/qcom/clk-alpha-pll.c +5 -0
+                                               config->test_ctl_hi_val);
+}
+EXPORT_SYMBOL_GPL(clk_agera_pll_configure);
+
+static int alpha_pll_agera_set_rate(struct clk_hw *hw, unsigned long rate,

Why not clk_alpha_pll prefix? We should prefix the other PLL functions in here with clk_alpha_ like trion and fabia

Yes, I will update this in the next patch.

Quoted 13 lines
Quoted 13 lines
drivers/clk/qcom/clk-alpha-pll.c +13 -0
+                                                       unsigned long prate)
+{
+       struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
+       u32 l, alpha_width = pll_alpha_width(pll);
+       unsigned long rrate;
+       u64 a;
+
+       rrate = alpha_pll_round_rate(rate, prate, &l, &a, alpha_width);
+
+       /*
+        * Due to limited number of bits for fractional rate programming, the
+        * rounded up rate could be marginally higher than the requested rate.
+        */
Quoted 9 lines

drivers/clk/qcom/clk-alpha-pll.c const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = { · line 1622

Quoted 4 lines
drivers/clk/qcom/clk-alpha-pll.c +4 -0
+       if (rrate > (rate + PLL_RATE_MARGIN) || rrate < rate) {
+               pr_err("Call set rate on the PLL with rounded rates!\n");
+               return -EINVAL;
+       }

See commit f78f29079327 ("clk: qcom: alpha-pll: Make error prints more informative") where I tried to make this better. Can you extract this check into a function that helps us understand the error better?

Updated to follow the same.

Quoted 10 lines

drivers/clk/qcom/clk-alpha-pll.c const struct clk_ops clk_alpha_pll_postdiv_lucid_ops = { · line 1629

Quoted 7 lines
drivers/clk/qcom/clk-alpha-pll.c +7 -0
+
+       /* change L_VAL without having to go through the power on sequence */
+       regmap_write(pll->clkr.regmap, PLL_L_VAL(pll), l);
+       regmap_write(pll->clkr.regmap, PLL_ALPHA_VAL(pll), a);
+
+       /* Ensure that the write above goes through before proceeding. */
+       mb();

regmap has an mb() in it. Remove this?

Yes, will remove it.

Quoted 16 lines
Quoted 16 lines
drivers/clk/qcom/clk-alpha-pll.c +16 -0
+
+       if (clk_hw_is_enabled(hw))
+               return wait_for_pll_enable_lock(pll);
+
+       return 0;
+}
+
+const struct clk_ops clk_alpha_pll_agera_ops = {
+       .enable = clk_alpha_pll_enable,
+       .disable = clk_alpha_pll_disable,
+       .is_enabled = clk_alpha_pll_is_enabled,
+       .recalc_rate = alpha_pll_fabia_recalc_rate,
+       .round_rate = clk_alpha_pll_round_rate,
+       .set_rate = alpha_pll_agera_set_rate,
+};
+EXPORT_SYMBOL_GPL(clk_alpha_pll_agera_ops);
Signature · 4 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#10 lore raw

Re: [PATCH v1 2/3] dt-bindings: clock: Add YAML schemas for the QCOM Camera clock bindings.

Quoting Taniya Das (2020-09-08 10:07:27)

Quoted 4 lines

The Camera Subsystem clock provider have a bunch of generic properties that are needed in a device tree. Add a YAML schemas for those.

Add clock ids for Camera clocks which are required to bring the camera

Why capitalize camera?

Quoted 31 lines

subsystem out of reset.

---
 .../bindings/clock/qcom,sc7180-camcc.yaml          |  73 +++++++++++++
 include/dt-bindings/clock/qcom,camcc-sc7180.h      | 121 +++++++++++++++++++++
 2 files changed, 194 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml
 create mode 100644 include/dt-bindings/clock/qcom,camcc-sc7180.h
Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml new file +15 -0
new file mode 100644
index 0000000..07bd38e
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/qcom,sc7180-camcc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Camera Clock & Reset Controller Binding for SC7180
+
+maintainers:
+  - Taniya Das <[email protected]>
+
+description: |
+  Qualcomm camera clock control module which supports the clocks, resets and
+  power domains on SC7180.
+

Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml line 25

Quoted 10 lines
Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml new file +10 -0
+  See also:
+  - dt-bindings/clock/qcom,camcc-sc7180.h.
+
+properties:
+  compatible:
+    const: qcom,sc7180-camcc
+
+  clocks:
+    items:
+      - description: Board XO source

Why do we need board XO

Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml line 28

Quoted 3 lines
Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml new file +3 -0
+      - description: Camera_ahb clock from GCC
+      - description: Camera XO clock from GCC
+

And also the gate on XO in GCC? Presumably only the one in GCC should be going to the camera clock controller?

Quoted 45 lines
Documentation/devicetree/bindings/clock/qcom,sc7180-camcc.yaml new file +45 -0
+  clock-names:
+    items:
+      - const: bi_tcxo
+      - const: iface
+      - const: xo
+
+  '#clock-cells':
+    const: 1
+
+  '#reset-cells':
+    const: 1
+
+  '#power-domain-cells':
+    const: 1
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+  - '#reset-cells'
+  - '#power-domain-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/qcom,gcc-sc7180.h>
+    #include <dt-bindings/clock/qcom,rpmh.h>
+    clock-controller@ad00000 {
+      compatible = "qcom,sc7180-camcc";
+      reg = <0x0ad00000 0x10000>;
+      clocks = <&rpmhcc RPMH_CXO_CLK>,
+               <&gcc GCC_CAMERA_AHB_CLK>,
+               <&gcc GCC_CAMERA_XO_CLK>;
+      clock-names = "bi_tcxo", "iface", "xo";
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+      #power-domain-cells = <1>;
+    };
+...