Skip to contentSkip to conversation

dt-bindings: interconnect: Add Qualcomm CCI dt-bindings

PATCH In review Jun Nie 6 participants 26 messages Feb 1, 2023 – Feb 3, 2023

Subsystems (4)
lore
Share & tools
lore

Jun Nie

author
#0 lore raw

PATCH 1/2 dt-bindings: interconnect: Add Qualcomm CCI dt-bindings

Add devicetree binding of Qualcomm CCI on MSM8939.

---
 .../bindings/interconnect/qcom,cci.yaml       | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interconnect/qcom,cci.yaml
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +81 -0
new file mode 100644
index 000000000000..100c440ba220
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interconnect/mediatek,cci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Cache Coherent Interconnect (CCI) frequency and voltage scaling
+
+maintainers:
+  - Jun Nie <[email protected]>
+
+description: |
+  Qualcomm Cache Coherent Interconnect (CCI) is a hardware engine used by
+  MSM8939. The driver is to scale its frequency and adjust the voltage in
+  hardware accordingly. The voltage provider is modeled as power domain on
+  MSM8939, so power domain dts node is required.
+
+properties:
+  compatible:
+    enum:
+      - qcom,msm8939-cci
+
+  clocks:
+    maxItems: 1
+
+  operating-points-v2: true
+  opp-table:
+    type: object
+
+required:
+  - compatible
+  - clocks
+  - operating-points-v2
+  - nvmem-cells
+  - power-domains
+
+additionalProperties: false
+
+examples:
+  - |
+    cci: cci {
+        compatible = "qcom,msm8939-cci";
+	clocks = <&apcs2>;
+	operating-points-v2 = <&cci_opp_table>;
+	power-domains = <&cpr>;
+	nvmem-cells = <&cpr_efuse_speedbin_pvs>;
+    };
+
+    cci_opp_table: cci-opp-table {
+	compatible = "operating-points-v2";
+
+	cci_opp1: opp-200000000 {
+	       opp-hz = /bits/ 64 <200000000>;
+	       opp-supported-hw = <0x3f>;
+	       required-opps = <&cpr_opp3>;
+	};
+
+	cci_opp2: opp-297600000 {
+	       opp-hz = /bits/ 64 <297600000>;
+	       opp-supported-hw = <0x3f>;
+	       required-opps = <&cpr_opp12>;
+	};
+
+	cci_opp3: opp-400000000 {
+	       opp-hz = /bits/ 64 <400000000>;
+	       opp-supported-hw = <0x1>;
+	       required-opps = <&cpr_opp14>;
+	};
+
+	cci_opp4: opp-400000000 {
+	       opp-hz = /bits/ 64 <400000000>;
+	       opp-supported-hw = <0x3e>;
+	       required-opps = <&cpr_opp15>;
+	};
+
+	cci_opp5: opp-595200000 {
+	       opp-hz = /bits/ 64 <595200000>;
+	       opp-supported-hw = <0x3f>;
+	       required-opps = <&cpr_opp17>;
+	};
+    };
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/2 PM / devfreq: qcom: Introduce CCI devfreq driver

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

---
 drivers/devfreq/Kconfig    |   9 +++
 drivers/devfreq/Makefile   |   1 +
 drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/devfreq/qcom-cci.c
drivers/devfreq/Kconfig +9 -0
index 9754d8b31621..6f3f1872f3fb 100644
@@ -130,6 +130,15 @@ config ARM_MEDIATEK_CCI_DEVFREQ
 	  buck voltages and update a proper CCI frequency. Use the notification
 	  to get the regulator status.
 
+config ARM_QCOM_CCI_DEVFREQ
+	tristate "QUALCOMM CCI DEVFREQ Driver"
+	depends on ARCH_QCOM || COMPILE_TEST
+	select DEVFREQ_GOV_PASSIVE
+	help
+	  This adds a devfreq driver for Qualcomm Cache Coherent Interconnect which
+	  shares the same regulator with the cpu cluster. This driver can track a
+	  proper regulator state while CCI frequency is updated.
+
 config ARM_RK3399_DMC_DEVFREQ
 	tristate "ARM RK3399 DMC DEVFREQ Driver"
 	depends on (ARCH_ROCKCHIP && HAVE_ARM_SMCCC) || \
drivers/devfreq/Makefile +1 -0
index bf40d04928d0..f2526d8c168d 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ)	+= exynos-bus.o
 obj-$(CONFIG_ARM_IMX_BUS_DEVFREQ)	+= imx-bus.o
 obj-$(CONFIG_ARM_IMX8M_DDRC_DEVFREQ)	+= imx8m-ddrc.o
 obj-$(CONFIG_ARM_MEDIATEK_CCI_DEVFREQ)	+= mtk-cci-devfreq.o
+obj-$(CONFIG_ARM_QCOM_CCI_DEVFREQ)	+= qcom-cci.o
 obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ)	+= rk3399_dmc.o
 obj-$(CONFIG_ARM_SUN8I_A33_MBUS_DEVFREQ)	+= sun8i-a33-mbus.o
 obj-$(CONFIG_ARM_TEGRA_DEVFREQ)		+= tegra30-devfreq.o
drivers/devfreq/qcom-cci.c new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 4 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.

You need to Cc Qualcomm subarch maintainers.

Quoted 6 lines
---
 drivers/devfreq/Kconfig    |   9 +++
 drivers/devfreq/Makefile   |   1 +
 drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++

Who is going to maintain this file/driver?

Quoted 3 lines
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/devfreq/qcom-cci.c

(...)

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+
+static int qcom_cci_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct qcom_cci *priv;
+	const char *gov = DEVFREQ_GOV_USERSPACE;
+	struct device_node *np = dev->of_node;
+	struct nvmem_cell *speedbin_nvmem;
+	int ret;
+	u32 version;

drivers/devfreq/qcom-cci.c line 100

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(priv->clk)) {
+		ret = PTR_ERR(priv->clk);
+		dev_err(dev, "failed to fetch clk: %d\n", ret);
+		return ret;

All these are just return dev_err_probe

drivers/devfreq/qcom-cci.c line 110

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+	}
+	platform_set_drvdata(pdev, priv);
+
+	/* Check whether we have profiled speed version per chip */
+	speedbin_nvmem = of_nvmem_cell_get(np, NULL);
+	if (IS_ERR(speedbin_nvmem))
+		return PTR_ERR(speedbin_nvmem);
+
+	version = qcom_get_dev_version(speedbin_nvmem);
+	dev_info(dev, "%s: set opp table version 0x%x\n", __func__, version);

Drop __func__.

drivers/devfreq/qcom-cci.c line 115

Quoted 5 lines
drivers/devfreq/qcom-cci.c new file +5 -0
+
+	nvmem_cell_put(speedbin_nvmem);
+	ret = dev_pm_opp_set_supported_hw(dev, &version, 1);
+	if (ret) {
+		dev_err(dev, "Failed to set supported hardware\n");

return dev_err_probe

drivers/devfreq/qcom-cci.c line 122

Quoted 7 lines
drivers/devfreq/qcom-cci.c new file +7 -0
+		return ret;
+	}
+
+	ret = dev_pm_opp_of_add_table(dev);
+	if (ret < 0) {
+		dev_err(dev, "failed to get OPP table\n");
+		return ret;

return dev_err_probe

drivers/devfreq/qcom-cci.c line 134

Quoted 12 lines
drivers/devfreq/qcom-cci.c new file +12 -0
+	}
+
+	priv->profile.target = qcom_cci_target;
+	priv->profile.exit = qcom_cci_exit;
+	priv->profile.get_cur_freq = qcom_cci_get_cur_freq;
+	priv->profile.initial_freq = clk_get_rate(priv->clk);
+
+	priv->devfreq = devm_devfreq_add_device(dev, &priv->profile,
+						gov, NULL);
+	if (IS_ERR(priv->devfreq)) {
+		ret = PTR_ERR(priv->devfreq);
+		dev_err(dev, "failed to add devfreq device: %d\n", ret);

ret = dev_err_probe

Quoted 18 lines
drivers/devfreq/qcom-cci.c new file +18 -0
+		goto err;
+	}
+
+	return 0;
+
+err:
+	dev_pm_opp_of_remove_table(dev);
+	return ret;
+}
+
+static const struct of_device_id qcom_cci_of_match[] = {
+	{ .compatible = "qcom,msm8939-cci"},
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, qcom_cci_of_match);
+
+static struct platform_driver qcom_cci_platdrv = {
+	.probe		= qcom_cci_probe,

drivers/devfreq/qcom-cci.c line 162

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+	.driver = {
+		.name	= "qcom-cci-devfreq",
+		.of_match_table = qcom_cci_of_match,
+	},
+};
+module_platform_driver(qcom_cci_platdrv);
+
+MODULE_DESCRIPTION("QCOM cci frequency scaling driver");
+MODULE_AUTHOR("Jun Nie <[email protected]>");
+MODULE_LICENSE("GPL");

Best regards,
Krzysztof

author
#3 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 8 lines
Quoted 5 lines
---
 drivers/devfreq/Kconfig    |   9 +++
 drivers/devfreq/Makefile   |   1 +
 drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++

Who is going to maintain this file/driver?

I will add myself as maintainer of this file.
All other comments will be addressed in next version. Thanks!

- Jun

Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

In reply to Jun Nie
Quoted 6 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

Nice work.

Thanks for taking the time to follow up on this. I had a look at the 4.19 out-of-tree version of this we have and this code looks just about right.

With Krzysztof's comments addressed please add my

#5 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

In reply to Jun Nie

Hi,

Quoted 19 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

---
 drivers/devfreq/Kconfig    |   9 +++
 drivers/devfreq/Makefile   |   1 +
 drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/devfreq/qcom-cci.c
drivers/devfreq/Kconfig +0 -0
index 9754d8b31621..6f3f1872f3fb 100644
@@ -130,6 +130,15 @@ config ARM_MEDIATEK_CCI_DEVFREQ
 	  buck voltages and update a proper CCI frequency. Use the notification

drivers/devfreq/Kconfig config ARM_MEDIATEK_CCI_DEVFREQ · line 140

Quoted 10 lines
drivers/devfreq/Kconfig +8 -0
 	  to get the regulator status.
 
+config ARM_QCOM_CCI_DEVFREQ
+	tristate "QUALCOMM CCI DEVFREQ Driver"
+	depends on ARCH_QCOM || COMPILE_TEST
+	select DEVFREQ_GOV_PASSIVE
+	help
+	  This adds a devfreq driver for Qualcomm Cache Coherent Interconnect which
+	  shares the same regulator with the cpu cluster. This driver can track a
+	  proper regulator state while CCI frequency is updated.

Maybe, this driver use the passive governor because as this description, the regulator is shared with cpu cluster. But, as I commented below, you use the 'userspace' governor in probe. is it right?

Quoted 28 lines
drivers/devfreq/Kconfig +1 -0
+
 config ARM_RK3399_DMC_DEVFREQ
 	tristate "ARM RK3399 DMC DEVFREQ Driver"
 	depends on (ARCH_ROCKCHIP && HAVE_ARM_SMCCC) || \
drivers/devfreq/Makefile +1 -0
index bf40d04928d0..f2526d8c168d 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ)	+= exynos-bus.o
 obj-$(CONFIG_ARM_IMX_BUS_DEVFREQ)	+= imx-bus.o
 obj-$(CONFIG_ARM_IMX8M_DDRC_DEVFREQ)	+= imx8m-ddrc.o
 obj-$(CONFIG_ARM_MEDIATEK_CCI_DEVFREQ)	+= mtk-cci-devfreq.o
+obj-$(CONFIG_ARM_QCOM_CCI_DEVFREQ)	+= qcom-cci.o
 obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ)	+= rk3399_dmc.o
 obj-$(CONFIG_ARM_SUN8I_A33_MBUS_DEVFREQ)	+= sun8i-a33-mbus.o
 obj-$(CONFIG_ARM_TEGRA_DEVFREQ)		+= tegra30-devfreq.o
drivers/devfreq/qcom-cci.c new file +6 -0
new file mode 100644
index 000000000000..21b5f133cddc
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 Linaro Ltd.
+ */
+
+#include <linux/clk.h>

drivers/devfreq/qcom-cci.c line 16

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+#include <linux/devfreq.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/of_device.h>
+#include <linux/pm_opp.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define SPEED_PVS(s, p) ((s << 16) | p)

What it meaning of PVS? Could you add the comment for 'PVS' and 's', 'p'?

drivers/devfreq/qcom-cci.c line 25

Quoted 9 lines
drivers/devfreq/qcom-cci.c new file +9 -0
+
+struct qcom_cci {
+	struct devfreq_dev_profile profile;
+	struct devfreq *devfreq;
+	struct clk *clk;
+};
+
+static int qcom_cci_target(struct device *dev,
+		unsigned long *freq, u32 flags)

Actually, this line is not long. You can type it on one line as following:

static int qcom_cci_target(struct device *dev, unsigned long *freq, u32 flags)

drivers/devfreq/qcom-cci.c line 28

Quoted 3 lines
drivers/devfreq/qcom-cci.c new file +3 -0
+{
+	struct dev_pm_opp *new_opp;
+	int ret;

As I mentioned belwo, this local variable is not needed if just return PTR_ERR(new_opp).

drivers/devfreq/qcom-cci.c line 34

Quoted 6 lines
drivers/devfreq/qcom-cci.c new file +6 -0
+
+	new_opp = devfreq_recommended_opp(dev, freq, flags);
+	if (IS_ERR(new_opp)) {
+		ret = PTR_ERR(new_opp);
+		dev_err(dev, "failed to get recommended opp: %d\n", ret);
+		return ret;

Better to add 'return PTR_ERR(new_opp)' without 'ret' local variable.

Quoted 17 lines
drivers/devfreq/qcom-cci.c new file +17 -0
+	}
+	dev_pm_opp_put(new_opp);
+
+	return dev_pm_opp_set_rate(dev, *freq);
+}
+
+static int qcom_cci_get_cur_freq(struct device *dev, unsigned long *freq)
+{
+	struct qcom_cci *priv = dev_get_drvdata(dev);
+
+	*freq = clk_get_rate(priv->clk);
+
+	return 0;
+}
+
+static int qcom_get_dev_version(struct nvmem_cell *speedbin_nvmem)
+{

drivers/devfreq/qcom-cci.c line 61

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+	int speed = 0, pvs = 0;
+	u8 *speedbin;
+	size_t len;
+
+	speedbin = nvmem_cell_read(speedbin_nvmem, &len);
+	if (IS_ERR(speedbin))
+		return PTR_ERR(speedbin);
+
+	speed = (speedbin[0xc] >> 2) & 0x7;
+	pvs = (speedbin[0x3] >> 5 & 0x1) | ((speedbin[0x6] >> 2 & 0x3) << 1);

Actually, 0xc, 0x3, 0x7, 0x1 and so on. It is impossible to understand the meaning of this hex value. Plesae add the constant defintion for the readability.

Quoted 14 lines
drivers/devfreq/qcom-cci.c new file +14 -0
+	kfree(speedbin);
+
+	/* Convert speedbin and PVS into version bit map */
+	switch (SPEED_PVS(speed, pvs)) {
+	case SPEED_PVS(0, 0): return 0x1;
+	case SPEED_PVS(2, 0): return 0x2;
+	case SPEED_PVS(2, 2): return 0x4;
+	case SPEED_PVS(4, 0): return 0x8;
+	case SPEED_PVS(5, 0): return 0x10;
+	case SPEED_PVS(5, 6): return 0x20;
+	default:
+		return 0x1;> +	}
+}
+

drivers/devfreq/qcom-cci.c line 86

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+static void qcom_cci_exit(struct device *dev)
+{
+	dev_pm_opp_of_remove_table(dev);
+}
+
+static int qcom_cci_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct qcom_cci *priv;
+	const char *gov = DEVFREQ_GOV_USERSPACE;

Even if you select 'DEVFREQ_GOV_PASSIVE' on Kconfig, Is it right that this driver use the userspace governor?

Quoted 4 lines
drivers/devfreq/qcom-cci.c new file +4 -0
+	struct device_node *np = dev->of_node;
+	struct nvmem_cell *speedbin_nvmem;
+	int ret;
+	u32 version;

drivers/devfreq/qcom-cci.c line 100

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(priv->clk)) {
+		ret = PTR_ERR(priv->clk);
+		dev_err(dev, "failed to fetch clk: %d\n", ret);
+		return ret;

You can use dev_err_probe as following:

	return dev_err_probe(dev, ret, "failed to fetch clk: %d\n", ret);

drivers/devfreq/qcom-cci.c line 107

Quoted 7 lines
drivers/devfreq/qcom-cci.c new file +7 -0
+	}
+	platform_set_drvdata(pdev, priv);
+
+	/* Check whether we have profiled speed version per chip */
+	speedbin_nvmem = of_nvmem_cell_get(np, NULL);
+	if (IS_ERR(speedbin_nvmem))
+		return PTR_ERR(speedbin_nvmem);

I recommend that you need to add the fail log with dev_err.

drivers/devfreq/qcom-cci.c line 110

Quoted 3 lines
drivers/devfreq/qcom-cci.c new file +3 -0
+
+	version = qcom_get_dev_version(speedbin_nvmem);
+	dev_info(dev, "%s: set opp table version 0x%x\n", __func__, version);

Don't need to use '__func__' because dev_info will print the module name. It is enough.

Quoted 15 lines
drivers/devfreq/qcom-cci.c new file +15 -0
+
+	nvmem_cell_put(speedbin_nvmem);
+	ret = dev_pm_opp_set_supported_hw(dev, &version, 1);
+	if (ret) {
+		dev_err(dev, "Failed to set supported hardware\n");
+		return ret;
+	}
+
+	ret = dev_pm_opp_of_add_table(dev);
+	if (ret < 0) {
+		dev_err(dev, "failed to get OPP table\n");
+		return ret;
+	}
+
+	priv->profile.target = qcom_cci_target;

drivers/devfreq/qcom-cci.c line 135

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+	priv->profile.exit = qcom_cci_exit;
+	priv->profile.get_cur_freq = qcom_cci_get_cur_freq;
+	priv->profile.initial_freq = clk_get_rate(priv->clk);
+
+	priv->devfreq = devm_devfreq_add_device(dev, &priv->profile,
+						gov, NULL);
+	if (IS_ERR(priv->devfreq)) {
+		ret = PTR_ERR(priv->devfreq);
+		dev_err(dev, "failed to add devfreq device: %d\n", ret);
+		goto err;

Need to goto 'err_remove_opp_table' instead of 'err'.

drivers/devfreq/qcom-cci.c line 142

Quoted 7 lines
drivers/devfreq/qcom-cci.c new file +7 -0
+	}
+
+	return 0;
+
+err:
+	dev_pm_opp_of_remove_table(dev);
+	return ret;

For more correct exception handling, need to change it as following:

err_remove_opp_table:

	dev_pm_opp_of_remove_table(dev);
err:
	return ret;
Quoted 8 lines
drivers/devfreq/qcom-cci.c new file +8 -0
+}
+
+static const struct of_device_id qcom_cci_of_match[] = {
+	{ .compatible = "qcom,msm8939-cci"},
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, qcom_cci_of_match);
+

drivers/devfreq/qcom-cci.c line 160

Quoted 10 lines
drivers/devfreq/qcom-cci.c new file +10 -0
+static struct platform_driver qcom_cci_platdrv = {
+	.probe		= qcom_cci_probe,
+	.driver = {
+		.name	= "qcom-cci-devfreq",
+		.of_match_table = qcom_cci_of_match,
+	},
+};
+module_platform_driver(qcom_cci_platdrv);
+
+MODULE_DESCRIPTION("QCOM cci frequency scaling driver");

cci is the abbreviation. You need to use the captical letter as following:

MODULE_DESCRIPTION("QCOM CCI frequency scaling driver");

Quoted 2 lines
drivers/devfreq/qcom-cci.c new file +2 -0
+MODULE_AUTHOR("Jun Nie <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 3 lines
Best Regards,
Samsung Electronics
Chanwoo Choi
author
#6 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 70 lines · Chanwoo Choi <[email protected]> 于2023年2月1日周三 19:02写道:

Hi,

Quoted 19 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

---
 drivers/devfreq/Kconfig    |   9 +++
 drivers/devfreq/Makefile   |   1 +
 drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/devfreq/qcom-cci.c
drivers/devfreq/Kconfig +0 -0
index 9754d8b31621..6f3f1872f3fb 100644
@@ -130,6 +130,15 @@ config ARM_MEDIATEK_CCI_DEVFREQ
        buck voltages and update a proper CCI frequency. Use the notification

drivers/devfreq/Kconfig config ARM_MEDIATEK_CCI_DEVFREQ · line 140

Quoted 10 lines
drivers/devfreq/Kconfig +8 -0
        to get the regulator status.
 
+config ARM_QCOM_CCI_DEVFREQ
+     tristate "QUALCOMM CCI DEVFREQ Driver"
+     depends on ARCH_QCOM || COMPILE_TEST
+     select DEVFREQ_GOV_PASSIVE
+     help
+       This adds a devfreq driver for Qualcomm Cache Coherent Interconnect which
+       shares the same regulator with the cpu cluster. This driver can track a
+       proper regulator state while CCI frequency is updated.

Maybe, this driver use the passive governor because as this description, the regulator is shared with cpu cluster. But, as I commented below, you use the 'userspace' governor in probe. is it right?

Quoted 32 lines
drivers/devfreq/Kconfig +1 -0
+
 config ARM_RK3399_DMC_DEVFREQ
      tristate "ARM RK3399 DMC DEVFREQ Driver"
      depends on (ARCH_ROCKCHIP && HAVE_ARM_SMCCC) || \
drivers/devfreq/Makefile +1 -0
index bf40d04928d0..f2526d8c168d 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ)        += exynos-bus.o
 obj-$(CONFIG_ARM_IMX_BUS_DEVFREQ)    += imx-bus.o
 obj-$(CONFIG_ARM_IMX8M_DDRC_DEVFREQ) += imx8m-ddrc.o
 obj-$(CONFIG_ARM_MEDIATEK_CCI_DEVFREQ)       += mtk-cci-devfreq.o
+obj-$(CONFIG_ARM_QCOM_CCI_DEVFREQ)   += qcom-cci.o
 obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ) += rk3399_dmc.o
 obj-$(CONFIG_ARM_SUN8I_A33_MBUS_DEVFREQ)     += sun8i-a33-mbus.o
 obj-$(CONFIG_ARM_TEGRA_DEVFREQ)              += tegra30-devfreq.o
drivers/devfreq/qcom-cci.c new file +10 -0
new file mode 100644
index 000000000000..21b5f133cddc
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 Linaro Ltd.
+ */
+
+#include <linux/clk.h>
+#include <linux/devfreq.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
Quoted 9 lines

drivers/devfreq/qcom-cci.c line 16

Quoted 6 lines
drivers/devfreq/qcom-cci.c new file +6 -0
+#include <linux/of_device.h>
+#include <linux/pm_opp.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define SPEED_PVS(s, p) ((s << 16) | p)

What it meaning of PVS? Could you add the comment for 'PVS' and 's', 'p'?

This is what I have from Qualcomm code. Maybe others have more info about it. Process Voltage Scaling(PVS) Tables defines the voltage and frequency value based on the msm-id in SMEM and speedbin blown in the efuse combination.

Quoted 53 lines

drivers/devfreq/qcom-cci.c line 25

Quoted 9 lines
drivers/devfreq/qcom-cci.c new file +9 -0
+
+struct qcom_cci {
+     struct devfreq_dev_profile profile;
+     struct devfreq *devfreq;
+     struct clk *clk;
+};
+
+static int qcom_cci_target(struct device *dev,
+             unsigned long *freq, u32 flags)

Actually, this line is not long. You can type it on one line as following:

static int qcom_cci_target(struct device *dev, unsigned long *freq, u32 flags)

drivers/devfreq/qcom-cci.c line 28

Quoted 3 lines
drivers/devfreq/qcom-cci.c new file +3 -0
+{
+     struct dev_pm_opp *new_opp;
+     int ret;

As I mentioned belwo, this local variable is not needed if just return PTR_ERR(new_opp).

drivers/devfreq/qcom-cci.c line 34

Quoted 6 lines
drivers/devfreq/qcom-cci.c new file +6 -0
+
+     new_opp = devfreq_recommended_opp(dev, freq, flags);
+     if (IS_ERR(new_opp)) {
+             ret = PTR_ERR(new_opp);
+             dev_err(dev, "failed to get recommended opp: %d\n", ret);
+             return ret;

Better to add 'return PTR_ERR(new_opp)' without 'ret' local variable.

Quoted 23 lines
drivers/devfreq/qcom-cci.c new file +23 -0
+     }
+     dev_pm_opp_put(new_opp);
+
+     return dev_pm_opp_set_rate(dev, *freq);
+}
+
+static int qcom_cci_get_cur_freq(struct device *dev, unsigned long *freq)
+{
+     struct qcom_cci *priv = dev_get_drvdata(dev);
+
+     *freq = clk_get_rate(priv->clk);
+
+     return 0;
+}
+
+static int qcom_get_dev_version(struct nvmem_cell *speedbin_nvmem)
+{
+     int speed = 0, pvs = 0;
+     u8 *speedbin;
+     size_t len;
+
+     speedbin = nvmem_cell_read(speedbin_nvmem, &len);
+     if (IS_ERR(speedbin))
Quoted 9 lines

drivers/devfreq/qcom-cci.c line 61

Quoted 4 lines
drivers/devfreq/qcom-cci.c new file +4 -0
+             return PTR_ERR(speedbin);
+
+     speed = (speedbin[0xc] >> 2) & 0x7;
+     pvs = (speedbin[0x3] >> 5 & 0x1) | ((speedbin[0x6] >> 2 & 0x3) << 1);

Actually, 0xc, 0x3, 0x7, 0x1 and so on. It is impossible to understand the meaning of this hex value. Plesae add the constant defintion for the readability.

Thanks for pointing it. The bit wise manipulation will be converted into nvmem offset and
bit position in next version. So driver will read out value directly without bit shift/mask.
Other comments will be adopted in next version. Thanks!

- Jun

#7 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 147 lines · Jun Nie
Quoted 70 lines · Chanwoo Choi <[email protected]> 于2023年2月1日周三 19:02写道:

Hi,

Quoted 19 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

---
  drivers/devfreq/Kconfig    |   9 +++
  drivers/devfreq/Makefile   |   1 +
  drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
  3 files changed, 172 insertions(+)

create mode 100644 drivers/devfreq/qcom-cci.c

drivers/devfreq/Kconfig +0 -0
index 9754d8b31621..6f3f1872f3fb 100644
@@ -130,6 +130,15 @@ config ARM_MEDIATEK_CCI_DEVFREQ
         buck voltages and update a proper CCI frequency. Use the notification

drivers/devfreq/Kconfig config ARM_MEDIATEK_CCI_DEVFREQ · line 140

Quoted 10 lines
drivers/devfreq/Kconfig +8 -0
         to get the regulator status.
 
+config ARM_QCOM_CCI_DEVFREQ
+     tristate "QUALCOMM CCI DEVFREQ Driver"
+     depends on ARCH_QCOM || COMPILE_TEST
+     select DEVFREQ_GOV_PASSIVE
+     help
+       This adds a devfreq driver for Qualcomm Cache Coherent Interconnect which
+       shares the same regulator with the cpu cluster. This driver can track a
+       proper regulator state while CCI frequency is updated.

Maybe, this driver use the passive governor because as this description, the regulator is shared with cpu cluster. But, as I commented below, you use the 'userspace' governor in probe. is it right?

Quoted 32 lines
drivers/devfreq/Kconfig +1 -0
+
  config ARM_RK3399_DMC_DEVFREQ
       tristate "ARM RK3399 DMC DEVFREQ Driver"
       depends on (ARCH_ROCKCHIP && HAVE_ARM_SMCCC) || \
drivers/devfreq/Makefile +1 -0
index bf40d04928d0..f2526d8c168d 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ)        += exynos-bus.o
  obj-$(CONFIG_ARM_IMX_BUS_DEVFREQ)    += imx-bus.o
  obj-$(CONFIG_ARM_IMX8M_DDRC_DEVFREQ) += imx8m-ddrc.o
  obj-$(CONFIG_ARM_MEDIATEK_CCI_DEVFREQ)       += mtk-cci-devfreq.o
+obj-$(CONFIG_ARM_QCOM_CCI_DEVFREQ)   += qcom-cci.o
  obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ) += rk3399_dmc.o
  obj-$(CONFIG_ARM_SUN8I_A33_MBUS_DEVFREQ)     += sun8i-a33-mbus.o
  obj-$(CONFIG_ARM_TEGRA_DEVFREQ)              += tegra30-devfreq.o
drivers/devfreq/qcom-cci.c new file +10 -0
new file mode 100644
index 000000000000..21b5f133cddc
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 Linaro Ltd.
+ */
+
+#include <linux/clk.h>
+#include <linux/devfreq.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
Quoted 9 lines

drivers/devfreq/qcom-cci.c line 16

Quoted 6 lines
drivers/devfreq/qcom-cci.c new file +6 -0
+#include <linux/of_device.h>
+#include <linux/pm_opp.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define SPEED_PVS(s, p) ((s << 16) | p)

What it meaning of PVS? Could you add the comment for 'PVS' and 's', 'p'?

This is what I have from Qualcomm code. Maybe others have more info about it. Process Voltage Scaling(PVS) Tables defines the voltage and frequency value based on the msm-id in SMEM and speedbin blown in the efuse combination.

Quoted 53 lines

drivers/devfreq/qcom-cci.c line 25

Quoted 9 lines
drivers/devfreq/qcom-cci.c new file +9 -0
+
+struct qcom_cci {
+     struct devfreq_dev_profile profile;
+     struct devfreq *devfreq;
+     struct clk *clk;
+};
+
+static int qcom_cci_target(struct device *dev,
+             unsigned long *freq, u32 flags)

Actually, this line is not long. You can type it on one line as following:

static int qcom_cci_target(struct device *dev, unsigned long *freq, u32 flags)

drivers/devfreq/qcom-cci.c line 28

Quoted 3 lines
drivers/devfreq/qcom-cci.c new file +3 -0
+{
+     struct dev_pm_opp *new_opp;
+     int ret;

As I mentioned belwo, this local variable is not needed if just return PTR_ERR(new_opp).

drivers/devfreq/qcom-cci.c line 34

Quoted 6 lines
drivers/devfreq/qcom-cci.c new file +6 -0
+
+     new_opp = devfreq_recommended_opp(dev, freq, flags);
+     if (IS_ERR(new_opp)) {
+             ret = PTR_ERR(new_opp);
+             dev_err(dev, "failed to get recommended opp: %d\n", ret);
+             return ret;

Better to add 'return PTR_ERR(new_opp)' without 'ret' local variable.

Quoted 23 lines
drivers/devfreq/qcom-cci.c new file +23 -0
+     }
+     dev_pm_opp_put(new_opp);
+
+     return dev_pm_opp_set_rate(dev, *freq);
+}
+
+static int qcom_cci_get_cur_freq(struct device *dev, unsigned long *freq)
+{
+     struct qcom_cci *priv = dev_get_drvdata(dev);
+
+     *freq = clk_get_rate(priv->clk);
+
+     return 0;
+}
+
+static int qcom_get_dev_version(struct nvmem_cell *speedbin_nvmem)
+{
+     int speed = 0, pvs = 0;
+     u8 *speedbin;
+     size_t len;
+
+     speedbin = nvmem_cell_read(speedbin_nvmem, &len);
+     if (IS_ERR(speedbin))
Quoted 9 lines

drivers/devfreq/qcom-cci.c line 61

Quoted 4 lines
drivers/devfreq/qcom-cci.c new file +4 -0
+             return PTR_ERR(speedbin);
+
+     speed = (speedbin[0xc] >> 2) & 0x7;
+     pvs = (speedbin[0x3] >> 5 & 0x1) | ((speedbin[0x6] >> 2 & 0x3) << 1);

Actually, 0xc, 0x3, 0x7, 0x1 and so on. It is impossible to understand the meaning of this hex value. Plesae add the constant defintion for the readability.

Quoted 5 lines

Thanks for pointing it. The bit wise manipulation will be converted into nvmem offset and
bit position in next version. So driver will read out value directly without bit shift/mask.
Other comments will be adopted in next version. Thanks!

Please consider handling everything using the nvmem API. If PVS is split into two regions it might be better to parse them separately and then combine them in the driver(*), rather than performing such parsing in the driver.

(*) while doing the rework of the tsens driver I also faced a similar issue. It might be nice to have 'combined' nvmem cells.

Signature · 2 lines
With best wishes
Dmitry
#8 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

In reply to Jun Nie
Quoted 5 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

Quoted 7 lines
---
  drivers/devfreq/Kconfig    |   9 +++
  drivers/devfreq/Makefile   |   1 +
  drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
  3 files changed, 172 insertions(+)

create mode 100644 drivers/devfreq/qcom-cci.c

Could you please describe in some additional details what are you trying to achieve? Should the CCI frequency be scaled manually or does it follow the cluster frequency? Do clusters vote on the CCI frequency?

I'm inclined to ask if it is possible to shift this to the cpufreq OPP tables?

Signature · 2 lines
With best wishes
Dmitry
#9 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 14 lines · Dmitry Baryshkov
Quoted 5 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

Quoted 7 lines

---
  drivers/devfreq/Kconfig    |   9 +++ drivers/devfreq/Makefile   |   1 + drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++

  3 files changed, 172 insertions(+)

  create mode 100644 drivers/devfreq/qcom-cci.c

Quoted 4 lines

Could you please describe in some additional details what are you trying to achieve? Should the CCI frequency be scaled manually or does it follow the cluster frequency? Do clusters vote on the CCI frequency?

I'm inclined to ask if it is possible to shift this to the cpufreq OPP tables?

Might not be so easy to just append CCI opps to the cluster frequency opps

                cci_cache: qcom,cci {
                        compatible = "qcom,msm8939-cci";
                        clock-names = "devfreq_clk";
                        clocks = <&apcs2>;
                        governor = "cpufreq";
                        operating-points-v2 = <&cci_opp_table>;
                        power-domains = <&cpr>;
                        power-domain-names = "cpr";
                        nvmem-cells = <&cpr_efuse_speedbin_pvs>;
                        nvmem-cell-names = "cpr_efuse_speedbin_pvs";
                };

                devfreq-cpufreq {
                        cci-cpufreq {
                                target-dev = <&cci_cache>;
                                cpu-to-dev-map-0 =
                                        <  200000  200000000 >,
                                        <  345600  200000000 >,
                                        <  400000  200000000 >,
                                        <  533330  297600000 >,
                                        <  800000  297600000 >,
                                        <  960000  297600000 >,
                                        < 1113600  297000000 >,
                                        < 1344000  595200000 >,
                                        < 1459200  595200000 >,
                                        < 1497600  595200000 >,
                                        < 1651200  595200000 >;
                                cpu-to-dev-map-4 =
                                        <  200000 200000000 >,
                                        <  249600 200000000 >,
                                        <  499200 297600000 >,
                                        <  800000 297600000 >,
                                        <  998400 595200000 >,
                                        < 1113600 595200000 >;
                        };
                };

        cci_opp_table: cci-opp-table {
                compatible = "operating-points-v2";

                opp-200000000 {
                        opp-hz = /bits/ 64 <200000000>;
                        opp-supported-hw = <0x3f>;
                        required-opps = <&cpr_opp3>;
                };

                opp-297600000 {
                        opp-hz = /bits/ 64 <297600000>;
                        opp-supported-hw = <0x3f>;
                        required-opps = <&cpr_opp12>;
                };

                opp-400000000-cpr14 {
                        opp-hz = /bits/ 64 <400000000>;
                        opp-supported-hw = <0x1>;
                        required-opps = <&cpr_opp14>;
                };

                opp-400000000-cpr15 {
                        opp-hz = /bits/ 64 <400000000>;
                        opp-supported-hw = <0x3e>;
                        required-opps = <&cpr_opp15>;
                };

                opp-595200000 {
                        opp-hz = /bits/ 64 <595200000>;
                        opp-supported-hw = <0x3f>;
                        required-opps = <&cpr_opp17>;
                };
        };


        cpr_opp_table: cpr-opp-table {
                compatible = "operating-points-v2-qcom-level";

                cpr_opp1: opp1 {
                        opp-hz = /bits/ 64 <200000000>;
                        opp-level = <1>;
                        qcom,opp-fuse-level = <1>;
                };
                cpr_opp2: opp2 {
                        opp-hz = /bits/ 64 <345600000>;
                        opp-level = <2>;
                        qcom,opp-fuse-level = <1>;
                };
                cpr_opp3: opp3 {
                        opp-hz = /bits/ 64 <400000000>;
                        opp-level = <3>;
                        qcom,opp-fuse-level = <1>;
                };
                cpr_opp4: opp4 {
                        opp-hz = /bits/ 64 <422400000>;
                        opp-level = <4>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp5: opp5 {
                        opp-hz = /bits/ 64 <499200000>;
                        opp-level = <5>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp6: opp6 {
                        opp-hz = /bits/ 64 <533330000>;
                        opp-level = <6>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp7: opp7 {
                        opp-hz = /bits/ 64 <652800000>;
                        opp-level = <7>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp8: opp8 {
                        opp-hz = /bits/ 64 <729600000>;
                        opp-level = <8>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp9: opp9 {
                        opp-hz = /bits/ 64 <800000000>;
                        opp-level = <9>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp10: opp10 {
                        opp-hz = /bits/ 64 <806400000>;
                        opp-level = <10>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp11: opp11 {
                        opp-hz = /bits/ 64 <883200000>;
                        opp-level = <11>;
                        qcom,opp-fuse-level = <2>;
                };
                cpr_opp12: opp12 {
                        opp-hz = /bits/ 64 <960000000>;
                        opp-level = <12>;
                        qcom,opp-fuse-level = <2>;
                };
        };

---
bod

#10 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 52 lines · Bryan O'Donoghue
Quoted 14 lines · Dmitry Baryshkov
Quoted 5 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

Quoted 7 lines
---
  drivers/devfreq/Kconfig    |   9 +++
  drivers/devfreq/Makefile   |   1 +
  drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
  3 files changed, 172 insertions(+)

create mode 100644 drivers/devfreq/qcom-cci.c

Quoted 7 lines

Could you please describe in some additional details what are you trying to achieve? Should the CCI frequency be scaled manually or does it follow the cluster frequency? Do clusters vote on the CCI frequency?

I'm inclined to ask if it is possible to shift this to the cpufreq OPP tables?

Might not be so easy to just append CCI opps to the cluster frequency opps

                 cci_cache: qcom,cci {
                         compatible = "qcom,msm8939-cci";
                         clock-names = "devfreq_clk";
                         clocks = <&apcs2>;
                         governor = "cpufreq";
                         operating-points-v2 = <&cci_opp_table>;
                         power-domains = <&cpr>;
                         power-domain-names = "cpr";
                         nvmem-cells = <&cpr_efuse_speedbin_pvs>;
                         nvmem-cell-names = "cpr_efuse_speedbin_pvs";
                 };

                 devfreq-cpufreq {
                         cci-cpufreq {
                                 target-dev = <&cci_cache>;
                                 cpu-to-dev-map-0 =
                                         <  200000  200000000 >,
                                         <  345600  200000000 >,
                                         <  400000  200000000 >,
                                         <  533330  297600000 >,
                                         <  800000  297600000 >,
                                         <  960000  297600000 >,
                                         < 1113600  297000000 >,
                                         < 1344000  595200000 >,
                                         < 1459200  595200000 >,
                                         < 1497600  595200000 >,
Quoted 8 lines
                                         < 1651200  595200000 >;
                                 cpu-to-dev-map-4 =
                                         <  200000 200000000 >,
                                         <  249600 200000000 >,
                                         <  499200 297600000 >,
                                         <  800000 297600000 >,
                                         <  998400 595200000 >,
                                         < 1113600 595200000 >;

These should map to existing opp entries.

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Quoted 10 lines
                         };
                 };

         cci_opp_table: cci-opp-table {
                 compatible = "operating-points-v2";

                 opp-200000000 {
                         opp-hz = /bits/ 64 <200000000>;
                         opp-supported-hw = <0x3f>;
                         required-opps = <&cpr_opp3>;

And these should probably map to max(cpu's CPR opp, CCI's CPR opp).

Quoted 95 lines
                 };

                 opp-297600000 {
                         opp-hz = /bits/ 64 <297600000>;
                         opp-supported-hw = <0x3f>;
                         required-opps = <&cpr_opp12>;
                 };

                 opp-400000000-cpr14 {
                         opp-hz = /bits/ 64 <400000000>;
                         opp-supported-hw = <0x1>;
                         required-opps = <&cpr_opp14>;
                 };

                 opp-400000000-cpr15 {
                         opp-hz = /bits/ 64 <400000000>;
                         opp-supported-hw = <0x3e>;
                         required-opps = <&cpr_opp15>;
                 };

                 opp-595200000 {
                         opp-hz = /bits/ 64 <595200000>;
                         opp-supported-hw = <0x3f>;
                         required-opps = <&cpr_opp17>;
                 };
         };


         cpr_opp_table: cpr-opp-table {
                 compatible = "operating-points-v2-qcom-level";

                 cpr_opp1: opp1 {
                         opp-hz = /bits/ 64 <200000000>;
                         opp-level = <1>;
                         qcom,opp-fuse-level = <1>;
                 };
                 cpr_opp2: opp2 {
                         opp-hz = /bits/ 64 <345600000>;
                         opp-level = <2>;
                         qcom,opp-fuse-level = <1>;
                 };
                 cpr_opp3: opp3 {
                         opp-hz = /bits/ 64 <400000000>;
                         opp-level = <3>;
                         qcom,opp-fuse-level = <1>;
                 };
                 cpr_opp4: opp4 {
                         opp-hz = /bits/ 64 <422400000>;
                         opp-level = <4>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp5: opp5 {
                         opp-hz = /bits/ 64 <499200000>;
                         opp-level = <5>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp6: opp6 {
                         opp-hz = /bits/ 64 <533330000>;
                         opp-level = <6>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp7: opp7 {
                         opp-hz = /bits/ 64 <652800000>;
                         opp-level = <7>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp8: opp8 {
                         opp-hz = /bits/ 64 <729600000>;
                         opp-level = <8>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp9: opp9 {
                         opp-hz = /bits/ 64 <800000000>;
                         opp-level = <9>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp10: opp10 {
                         opp-hz = /bits/ 64 <806400000>;
                         opp-level = <10>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp11: opp11 {
                         opp-hz = /bits/ 64 <883200000>;
                         opp-level = <11>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp12: opp12 {
                         opp-hz = /bits/ 64 <960000000>;
                         opp-level = <12>;
                         qcom,opp-fuse-level = <2>;
                 };
         };

---
bod

Signature · 2 lines
With best wishes
Dmitry
#11 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 21 lines · Dmitry Baryshkov
Quoted 13 lines
                          cci-cpufreq {
                                  target-dev = <&cci_cache>;
                                  cpu-to-dev-map-0 =
                                          <  200000  200000000 >,
                                          <  345600  200000000 >,
                                          <  400000  200000000 >,
                                          <  533330  297600000 >,
                                          <  800000  297600000 >,
                                          <  960000  297600000 >,
                                          < 1113600  297000000 >,
                                          < 1344000  595200000 >,
                                          < 1459200  595200000 >,
                                          < 1497600  595200000 >,
Quoted 8 lines
                                          < 1651200  595200000 >;
                                  cpu-to-dev-map-4 =
                                          <  200000 200000000 >,
                                          <  249600 200000000 >,
                                          <  499200 297600000 >,
                                          <  800000 297600000 >,
                                          <  998400 595200000 >,
                                          < 1113600 595200000 >;
Quoted 5 lines

These should map to existing opp entries.

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Can you point us at what it is you are proposing ?

---
bod

#12 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 22 lines · Bryan O'Donoghue
Quoted 21 lines · Dmitry Baryshkov
Quoted 21 lines

                          cci-cpufreq {
                                  target-dev = <&cci_cache>; cpu-to-dev-map-0 =
                                          <  200000  200000000 >, <  345600  200000000 >, <  400000  200000000 >, <  533330  297600000 >, <  800000  297600000 >, <  960000  297600000 >, < 1113600  297000000 >, < 1344000  595200000 >, < 1459200  595200000 >, < 1497600  595200000 >, < 1651200  595200000 >; cpu-to-dev-map-4 =
                                          <  200000 200000000 >, <  249600 200000000 >, <  499200 297600000 >, <  800000 297600000 >, <  998400 595200000 >, < 1113600 595200000 >;

Quoted 7 lines
Quoted 5 lines

These should map to existing opp entries.

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Can you point us at what it is you are proposing ?

https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/

Quoted 3 lines

---
bod

Signature · 2 lines
With best wishes
Dmitry
#13 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 25 lines · Dmitry Baryshkov
Quoted 24 lines · Bryan O'Donoghue
Quoted 23 lines · Dmitry Baryshkov
Quoted 13 lines

                          cci-cpufreq {
                                  target-dev = <&cci_cache>; cpu-to-dev-map-0 =
                                          <  200000  200000000 >, <  345600  200000000 >, <  400000  200000000 >, <  533330  297600000 >, <  800000  297600000 >, <  960000  297600000 >, < 1113600  297000000 >, < 1344000  595200000 >, < 1459200  595200000 >, < 1497600  595200000 >,

Quoted 8 lines

                                          < 1651200  595200000 >; cpu-to-dev-map-4 =
                                          <  200000 200000000 >, <  249600 200000000 >, <  499200 297600000 >, <  800000 297600000 >, <  998400 595200000 >, < 1113600 595200000 >;

These should map to existing opp entries.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Can you point us at what it is you are proposing ?

https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/

Is there no driver code too ?

#14 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 30 lines · Bryan O'Donoghue
Quoted 29 lines · Dmitry Baryshkov
Quoted 28 lines · Bryan O'Donoghue
Quoted 26 lines · Dmitry Baryshkov
Quoted 13 lines

                          cci-cpufreq {
                                  target-dev = <&cci_cache>; cpu-to-dev-map-0 =
                                          <  200000  200000000 >, <  345600  200000000 >, <  400000  200000000 >, <  533330  297600000 >, <  800000  297600000 >, <  960000  297600000 >, < 1113600  297000000 >, < 1344000  595200000 >, < 1459200  595200000 >, < 1497600  595200000 >,

Quoted 8 lines

                                          < 1651200  595200000 >; cpu-to-dev-map-4 =
                                          <  200000 200000000 >, <  249600 200000000 >, <  499200 297600000 >, <  800000 297600000 >, <  998400 595200000 >, < 1113600 595200000 >;

These should map to existing opp entries.

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Can you point us at what it is you are proposing ?

https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/

Is there no driver code too ?

There are two parts, one is the 'CBF clock' driver, which just provides a clock, another part actually connects the clock and interconnect. Initially I implemented it as a part of the CBF driver (see https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/), next revision will move the interconnect part to drivers/interconnect.

Signature · 2 lines
With best wishes
Dmitry
#15 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 31 lines · Dmitry Baryshkov
Quoted 30 lines · Bryan O'Donoghue
Quoted 29 lines · Dmitry Baryshkov
Quoted 28 lines · Bryan O'Donoghue
Quoted 26 lines · Dmitry Baryshkov
Quoted 13 lines

                          cci-cpufreq {
                                  target-dev = <&cci_cache>; cpu-to-dev-map-0 =
                                          <  200000  200000000 >, <  345600  200000000 >, <  400000  200000000 >, <  533330  297600000 >, <  800000  297600000 >, <  960000  297600000 >, < 1113600  297000000 >, < 1344000  595200000 >, < 1459200  595200000 >, < 1497600  595200000 >,

Quoted 8 lines

                                          < 1651200  595200000 >; cpu-to-dev-map-4 =
                                          <  200000 200000000 >, <  249600 200000000 >, <  499200 297600000 >, <  800000 297600000 >, <  998400 595200000 >, < 1113600 595200000 >;

These should map to existing opp entries.

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Can you point us at what it is you are proposing ?

https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/

Is there no driver code too ?

There are two parts, one is the 'CBF clock' driver, which just provides a clock, another part actually connects the clock and interconnect. Initially I implemented it as a part of the CBF driver (see https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/), next revision will move the interconnect part to drivers/interconnect.

Ah so just to be clear - discussing with Dmitry - CCI has its own set of fuses.

We have fusebin settings for clusterX and CCI.

So, I think we agree this means a separate driver for cci is warranted.

---
bod

#16 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

Quoted 38 lines · Bryan O'Donoghue
Quoted 37 lines · Dmitry Baryshkov
Quoted 35 lines · Bryan O'Donoghue
Quoted 25 lines · Dmitry Baryshkov
Quoted 24 lines · Bryan O'Donoghue
Quoted 23 lines · Dmitry Baryshkov
Quoted 13 lines

                          cci-cpufreq {
                                  target-dev = <&cci_cache>; cpu-to-dev-map-0 =
                                          <  200000  200000000 >, <  345600  200000000 >, <  400000  200000000 >, <  533330  297600000 >, <  800000  297600000 >, <  960000  297600000 >, < 1113600  297000000 >, < 1344000  595200000 >, < 1459200  595200000 >, < 1497600  595200000 >,

Quoted 8 lines

                                          < 1651200  595200000 >; cpu-to-dev-map-4 =
                                          <  200000 200000000 >, <  249600 200000000 >, <  499200 297600000 >, <  800000 297600000 >, <  998400 595200000 >, < 1113600 595200000 >;

These should map to existing opp entries.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Can you point us at what it is you are proposing ?

https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/

Is there no driver code too ?

Quoted 8 lines
Quoted 2 lines

There are two parts, one is the 'CBF clock' driver, which just provides a clock, another part actually connects the clock and interconnect. Initially I implemented it as a part of the CBF driver (see https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]/), next revision will move the interconnect part to drivers/interconnect.

Ah so just to be clear - discussing with Dmitry - CCI has its own set of fuses.

We have fusebin settings for clusterX and CCI.

So, I think we agree this means a separate driver for cci is warranted.

Yes.

Signature · 2 lines
With best wishes
Dmitry
author
#17 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

In reply to Dmitry Baryshkov
Quoted 75 lines · Dmitry Baryshkov <[email protected]> 于2023年2月1日周三 21:41写道:
Quoted 52 lines · Bryan O'Donoghue
Quoted 14 lines · Dmitry Baryshkov
Quoted 5 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

Quoted 7 lines
---
  drivers/devfreq/Kconfig    |   9 +++
  drivers/devfreq/Makefile   |   1 +
  drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
  3 files changed, 172 insertions(+)

create mode 100644 drivers/devfreq/qcom-cci.c

Quoted 7 lines

Could you please describe in some additional details what are you trying to achieve? Should the CCI frequency be scaled manually or does it follow the cluster frequency? Do clusters vote on the CCI frequency?

I'm inclined to ask if it is possible to shift this to the cpufreq OPP tables?

Might not be so easy to just append CCI opps to the cluster frequency opps

                 cci_cache: qcom,cci {
                         compatible = "qcom,msm8939-cci";
                         clock-names = "devfreq_clk";
                         clocks = <&apcs2>;
                         governor = "cpufreq";
                         operating-points-v2 = <&cci_opp_table>;
                         power-domains = <&cpr>;
                         power-domain-names = "cpr";
                         nvmem-cells = <&cpr_efuse_speedbin_pvs>;
                         nvmem-cell-names = "cpr_efuse_speedbin_pvs";
                 };

                 devfreq-cpufreq {
                         cci-cpufreq {
                                 target-dev = <&cci_cache>;
                                 cpu-to-dev-map-0 =
                                         <  200000  200000000 >,
                                         <  345600  200000000 >,
                                         <  400000  200000000 >,
                                         <  533330  297600000 >,
                                         <  800000  297600000 >,
                                         <  960000  297600000 >,
                                         < 1113600  297000000 >,
                                         < 1344000  595200000 >,
                                         < 1459200  595200000 >,
                                         < 1497600  595200000 >,
Quoted 8 lines
                                         < 1651200  595200000 >;
                                 cpu-to-dev-map-4 =
                                         <  200000 200000000 >,
                                         <  249600 200000000 >,
                                         <  499200 297600000 >,
                                         <  800000 297600000 >,
                                         <  998400 595200000 >,
                                         < 1113600 595200000 >;

These should map to existing opp entries.

I ended up doing the interconnect driver that maps a clock to the interconnect. Then I can use it in the cpu opp tables.

Quoted 6 lines
                         };
                 };

         cci_opp_table: cci-opp-table {
                 compatible = "operating-points-v2";
Quoted 6 lines
Quoted 4 lines
                 opp-200000000 {
                         opp-hz = /bits/ 64 <200000000>;
                         opp-supported-hw = <0x3f>;
                         required-opps = <&cpr_opp3>;

And these should probably map to max(cpu's CPR opp, CCI's CPR opp).

The plan is opp framework to handle it when CPU opp requires both cpr power domain
opp and CCI opp. While CCI opp will also requires specific cpr opp. Because CPU have a opp match table per pvs/speed, while CCI has another match table, it seems
impossible to write the cpr opp requirements in the code statically.

Quoted 102 lines
Quoted 94 lines
                 };

                 opp-297600000 {
                         opp-hz = /bits/ 64 <297600000>;
                         opp-supported-hw = <0x3f>;
                         required-opps = <&cpr_opp12>;
                 };

                 opp-400000000-cpr14 {
                         opp-hz = /bits/ 64 <400000000>;
                         opp-supported-hw = <0x1>;
                         required-opps = <&cpr_opp14>;
                 };

                 opp-400000000-cpr15 {
                         opp-hz = /bits/ 64 <400000000>;
                         opp-supported-hw = <0x3e>;
                         required-opps = <&cpr_opp15>;
                 };

                 opp-595200000 {
                         opp-hz = /bits/ 64 <595200000>;
                         opp-supported-hw = <0x3f>;
                         required-opps = <&cpr_opp17>;
                 };
         };


         cpr_opp_table: cpr-opp-table {
                 compatible = "operating-points-v2-qcom-level";

                 cpr_opp1: opp1 {
                         opp-hz = /bits/ 64 <200000000>;
                         opp-level = <1>;
                         qcom,opp-fuse-level = <1>;
                 };
                 cpr_opp2: opp2 {
                         opp-hz = /bits/ 64 <345600000>;
                         opp-level = <2>;
                         qcom,opp-fuse-level = <1>;
                 };
                 cpr_opp3: opp3 {
                         opp-hz = /bits/ 64 <400000000>;
                         opp-level = <3>;
                         qcom,opp-fuse-level = <1>;
                 };
                 cpr_opp4: opp4 {
                         opp-hz = /bits/ 64 <422400000>;
                         opp-level = <4>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp5: opp5 {
                         opp-hz = /bits/ 64 <499200000>;
                         opp-level = <5>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp6: opp6 {
                         opp-hz = /bits/ 64 <533330000>;
                         opp-level = <6>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp7: opp7 {
                         opp-hz = /bits/ 64 <652800000>;
                         opp-level = <7>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp8: opp8 {
                         opp-hz = /bits/ 64 <729600000>;
                         opp-level = <8>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp9: opp9 {
                         opp-hz = /bits/ 64 <800000000>;
                         opp-level = <9>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp10: opp10 {
                         opp-hz = /bits/ 64 <806400000>;
                         opp-level = <10>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp11: opp11 {
                         opp-hz = /bits/ 64 <883200000>;
                         opp-level = <11>;
                         qcom,opp-fuse-level = <2>;
                 };
                 cpr_opp12: opp12 {
                         opp-hz = /bits/ 64 <960000000>;
                         opp-level = <12>;
                         qcom,opp-fuse-level = <2>;
                 };
         };
Quoted 2 lines

---
bod

--
With best wishes
Dmitry

author
#18 lore raw

Re: [PATCH 2/2] PM / devfreq: qcom: Introduce CCI devfreq driver

In reply to Dmitry Baryshkov
Quoted 19 lines · Dmitry Baryshkov <[email protected]> 于2023年2月1日周三 19:32写道:
Quoted 5 lines · Jun Nie

Cache Coherent Interconnect (CCI) is used by some Qualcomm SoCs. This driver is introduced so that its freqency can be adjusted. And regulator associated with opp table can be also adjusted accordingly which is shared with cpu cluster.

Quoted 7 lines
---
  drivers/devfreq/Kconfig    |   9 +++
  drivers/devfreq/Makefile   |   1 +
  drivers/devfreq/qcom-cci.c | 162 +++++++++++++++++++++++++++++++++++++
  3 files changed, 172 insertions(+)

create mode 100644 drivers/devfreq/qcom-cci.c

Could you please describe in some additional details what are you trying to achieve? Should the CCI frequency be scaled manually or does it follow the cluster frequency? Do clusters vote on the CCI frequency?

Quoted 7 lines

I'm inclined to ask if it is possible to shift this to the cpufreq OPP tables?

--
With best wishes
Dmitry

The plan is to add CCI opp node as required-opp property in CPU opp, so that CPU will vote CCI frequency when scaling CPU frequency.
The interconnect bandwidth side is not addressed yet. This patch only address CCI frequency and power voltage requirement with help of device tree.

- Jun

#19 lore raw
In reply to Jun Nie
Quoted 1 line · Jun Nie

Add devicetree binding of Qualcomm CCI on MSM8939.

Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.

Subject: drop second/last, redundant "dt-bindings". The "dt-bindings" prefix is already stating that these are bindings.

Quoted 13 lines
---
 .../bindings/interconnect/qcom,cci.yaml       | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interconnect/qcom,cci.yaml
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +0 -0
new file mode 100644
index 000000000000..100c440ba220

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 4

Quoted 4 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +4 -0
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interconnect/mediatek,cci.yaml#

Does not look like you tested the bindings. Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions).

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 16

Quoted 12 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +12 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Cache Coherent Interconnect (CCI) frequency and voltage scaling
+
+maintainers:
+  - Jun Nie <[email protected]>
+
+description: |
+  Qualcomm Cache Coherent Interconnect (CCI) is a hardware engine used by
+  MSM8939. The driver is to scale its frequency and adjust the voltage in
+  hardware accordingly. The voltage provider is modeled as power domain on
+  MSM8939, so power domain dts node is required.

Don't describe other bindings, but the hardware. Last sentence is not really related. What's more - it does not fit what you wrote below.

Quoted 8 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - qcom,msm8939-cci
+
+  clocks:
+    maxItems: 1

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +10 -0
+
+  operating-points-v2: true
+  opp-table:
+    type: object
+
+required:
+  - compatible
+  - clocks
+  - operating-points-v2
+  - nvmem-cells

?? You cannot require properties which are not present.

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 35

Quoted 1 line
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +1 -0
+  - power-domains

Same here.

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 43

Quoted 8 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +8 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    cci: cci {
+        compatible = "qcom,msm8939-cci";
+	clocks = <&apcs2>;

Messed indentation.

Use 4 spaces for example indentation.

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 46

Quoted 3 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +3 -0
+	operating-points-v2 = <&cci_opp_table>;
+	power-domains = <&cpr>;
+	nvmem-cells = <&cpr_efuse_speedbin_pvs>;

How does it pass testing?

Best regards,
Krzysztof

author
#20 lore raw
Quoted 21 lines
Quoted 8 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - qcom,msm8939-cci
+
+  clocks:
+    maxItems: 1

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +10 -0
+
+  operating-points-v2: true
+  opp-table:
+    type: object
+
+required:
+  - compatible
+  - clocks
+  - operating-points-v2
+  - nvmem-cells

?? You cannot require properties which are not present.

Quoted 4 lines
Quoted 1 line

+ - power-domains

Same here.

So the properties should be added later, after cpr and fuse nodes are available in mainline, right?

- Jun

#21 lore raw
Quoted 21 lines · Jun Nie
Quoted 21 lines
Quoted 8 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - qcom,msm8939-cci
+
+  clocks:
+    maxItems: 1

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +10 -0
+
+  operating-points-v2: true
+  opp-table:
+    type: object
+
+required:
+  - compatible
+  - clocks
+  - operating-points-v2
+  - nvmem-cells

?? You cannot require properties which are not present.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ - power-domains

Same here.

So the properties should be added later, after cpr and fuse nodes are available in mainline, right?

No, binding should be complete, so why would you skip some properties? I don't see here dependency on other bindings. Unless I missed here something and there is a dependency? But then what kind? Do you reference other schema?

Best regards,
Krzysztof

author
#22 lore raw
Quoted 31 lines · Krzysztof Kozlowski <[email protected]> 于2023年2月2日周四 17:42写道:
Quoted 21 lines · Jun Nie
Quoted 21 lines
Quoted 8 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - qcom,msm8939-cci
+
+  clocks:
+    maxItems: 1

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +10 -0
+
+  operating-points-v2: true
+  opp-table:
+    type: object
+
+required:
+  - compatible
+  - clocks
+  - operating-points-v2
+  - nvmem-cells

?? You cannot require properties which are not present.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ - power-domains

Same here.

So the properties should be added later, after cpr and fuse nodes are available in mainline, right?

Quoted 8 lines

No, binding should be complete, so why would you skip some properties? I don't see here dependency on other bindings. Unless I missed here something and there is a dependency? But then what kind? Do you reference other schema?

Best regards,
Krzysztof

Sorry, it is a copy/modified error with overlooking some added properties.

+ cci_opp3: opp-cpr14-400000000 {

+            opp-hz = /bits/ 64 <400000000>;
+            opp-supported-hw = <0x1>;
+            required-opps = <&cpr_opp14>;

+ };
+
+ cci_opp4: opp-cpr15-400000000 {

Documentation/devicetree/bindings/interconnect/qcom,cci.example.dtb:
opp-table-cci: Unevaluated properties are not allowed ('opp-cpr14-400000000', 'opp-cpr15-400000000' were unexpected)

Do you know how to fix this dts check warning?
The cci_opp3 and cci_opp4 have the same frequency but with different requirements to
power domain. So the name of the 2 opp should be identical or with a different tag, but there
are warnings for both cases for the 2 lines. Thanks!

+            opp-hz = /bits/ 64 <400000000>;
+            opp-supported-hw = <0x3e>;
+            required-opps = <&cpr_opp15>;

+ };

#23 lore raw
Quoted 42 lines · Jun Nie
Quoted 31 lines · Krzysztof Kozlowski <[email protected]> 于2023年2月2日周四 17:42写道:
Quoted 21 lines · Jun Nie
Quoted 21 lines
Quoted 8 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - qcom,msm8939-cci
+
+  clocks:
+    maxItems: 1

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml line 34

Quoted 10 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +10 -0
+
+  operating-points-v2: true
+  opp-table:
+    type: object
+
+required:
+  - compatible
+  - clocks
+  - operating-points-v2
+  - nvmem-cells

?? You cannot require properties which are not present.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ - power-domains

Same here.

So the properties should be added later, after cpr and fuse nodes are available in mainline, right?

Quoted 8 lines

No, binding should be complete, so why would you skip some properties? I don't see here dependency on other bindings. Unless I missed here something and there is a dependency? But then what kind? Do you reference other schema?

Best regards,
Krzysztof

Sorry, it is a copy/modified error with overlooking some added properties.

Documentation/devicetree/bindings/interconnect/qcom,cci.yaml

Quoted 7 lines
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +7 -0
+        cci_opp3: opp-cpr14-400000000 {
+            opp-hz = /bits/ 64 <400000000>;
+            opp-supported-hw = <0x1>;
+            required-opps = <&cpr_opp14>;
+        };
+
+        cci_opp4: opp-cpr15-400000000 {

This does not answer my concerns at all. Please include all relevant properties in your bindings.

Quoted 5 lines

Documentation/devicetree/bindings/interconnect/qcom,cci.example.dtb:
opp-table-cci: Unevaluated properties are not allowed ('opp-cpr14-400000000', 'opp-cpr15-400000000' were unexpected)

Do you know how to fix this dts check warning?

Don't add properties which are not allowed or do not name properties in a way it is not allowed.

Quoted 2 lines

The cci_opp3 and cci_opp4 have the same frequency but with different requirements to

So you used the same node names... how do you expect such code to compile? In current form bindings do not allow such setup. If you think that OS should allow and support it, then change the bindings.

Best regards,
Krzysztof

#24 lore raw
In reply to Jun Nie

Hi,

In order to track the changes of dt-binding,
please add the info as following:

MAINTAINERS +1 -0
index 7f86d02cb427..e13e61218987 100644
@@ -6047,6 +6047,7 @@ S:        Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git
 F:     Documentation/devicetree/bindings/devfreq/
 F:     Documentation/devicetree/bindings/interconnect/mediatek,cci.yaml
+F:     Documentation/devicetree/bindings/interconnect/qcom,cci.yam
 F:     drivers/devfreq/
 F:     include/linux/devfreq.h
 F:     include/trace/events/devfreq.h
Quoted 95 lines · Jun Nie

Add devicetree binding of Qualcomm CCI on MSM8939.

---
 .../bindings/interconnect/qcom,cci.yaml       | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interconnect/qcom,cci.yaml
Documentation/devicetree/bindings/interconnect/qcom,cci.yaml new file +81 -0
new file mode 100644
index 000000000000..100c440ba220
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interconnect/mediatek,cci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Cache Coherent Interconnect (CCI) frequency and voltage scaling
+
+maintainers:
+  - Jun Nie <[email protected]>
+
+description: |
+  Qualcomm Cache Coherent Interconnect (CCI) is a hardware engine used by
+  MSM8939. The driver is to scale its frequency and adjust the voltage in
+  hardware accordingly. The voltage provider is modeled as power domain on
+  MSM8939, so power domain dts node is required.
+
+properties:
+  compatible:
+    enum:
+      - qcom,msm8939-cci
+
+  clocks:
+    maxItems: 1
+
+  operating-points-v2: true
+  opp-table:
+    type: object
+
+required:
+  - compatible
+  - clocks
+  - operating-points-v2
+  - nvmem-cells
+  - power-domains
+
+additionalProperties: false
+
+examples:
+  - |
+    cci: cci {
+        compatible = "qcom,msm8939-cci";
+	clocks = <&apcs2>;
+	operating-points-v2 = <&cci_opp_table>;
+	power-domains = <&cpr>;
+	nvmem-cells = <&cpr_efuse_speedbin_pvs>;
+    };
+
+    cci_opp_table: cci-opp-table {
+	compatible = "operating-points-v2";
+
+	cci_opp1: opp-200000000 {
+	       opp-hz = /bits/ 64 <200000000>;
+	       opp-supported-hw = <0x3f>;
+	       required-opps = <&cpr_opp3>;
+	};
+
+	cci_opp2: opp-297600000 {
+	       opp-hz = /bits/ 64 <297600000>;
+	       opp-supported-hw = <0x3f>;
+	       required-opps = <&cpr_opp12>;
+	};
+
+	cci_opp3: opp-400000000 {
+	       opp-hz = /bits/ 64 <400000000>;
+	       opp-supported-hw = <0x1>;
+	       required-opps = <&cpr_opp14>;
+	};
+
+	cci_opp4: opp-400000000 {
+	       opp-hz = /bits/ 64 <400000000>;
+	       opp-supported-hw = <0x3e>;
+	       required-opps = <&cpr_opp15>;
+	};
+
+	cci_opp5: opp-595200000 {
+	       opp-hz = /bits/ 64 <595200000>;
+	       opp-supported-hw = <0x3f>;
+	       required-opps = <&cpr_opp17>;
+	};
+    };
Signature · 3 lines
Best Regards,
Samsung Electronics
Chanwoo Choi
maintainer
#25 lore raw
In reply to Jun Nie
Quoted 8 lines · Jun Nie

Add devicetree binding of Qualcomm CCI on MSM8939.

---
 .../bindings/interconnect/qcom,cci.yaml       | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interconnect/qcom,cci.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:
./Documentation/devicetree/bindings/interconnect/qcom,cci.yaml:43:1: [error] syntax error: found character '\t' that cannot start any token (syntax)

dtschema/dtc warnings/errors:
make[1]: *** Deleting file 'Documentation/devicetree/bindings/interconnect/qcom,cci.example.dts' Documentation/devicetree/bindings/interconnect/qcom,cci.yaml:43:1: found character '\t' that cannot start any token make[1]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/interconnect/qcom,cci.example.dts] Error 1 make[1]: *** Waiting for unfinished jobs....
./Documentation/devicetree/bindings/interconnect/qcom,cci.yaml:43:1: found character '\t' that cannot start any token /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/interconnect/qcom,cci.yaml: ignoring, error parsing file
make: *** [Makefile:1508: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.