linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] devfreq: qcom: Add L2 Krait Cache devfreq scaling driver
@ 2020-09-27 16:05 Ansuel Smith
  2020-09-27 16:05 ` [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver Ansuel Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Ansuel Smith @ 2020-09-27 16:05 UTC (permalink / raw)
  To: MyungJoo Ham
  Cc: Ansuel Smith, Kyungmin Park, Chanwoo Choi, Rob Herring, linux-pm,
	devicetree, linux-kernel

Qcom L2 Krait CPUs use the generic cpufreq-dt driver and doesn't actually
scale the Cache frequency when the CPU frequency is changed. This
devfreq driver register with the cpu notifier and scale the Cache
based on the max Freq across all core as the CPU cache is shared across
all of them. If provided this also scale the voltage of the regulator
attached to the CPU cache. The scaling logic is based on the CPU freq
and the 3 scaling interval are set by the device dts.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/devfreq/Kconfig               |  10 +
 drivers/devfreq/Makefile              |   1 +
 drivers/devfreq/krait-cache-devfreq.c | 298 ++++++++++++++++++++++++++
 3 files changed, 309 insertions(+)
 create mode 100644 drivers/devfreq/krait-cache-devfreq.c

diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index 37dc40d1fcfb..99051aaf9c5e 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -143,6 +143,16 @@ config ARM_RK3399_DMC_DEVFREQ
 	  It sets the frequency for the memory controller and reads the usage counts
 	  from hardware.
 
+config ARM_KRAIT_CACHE_DEVFREQ
+	tristate "Scaling support for Krait CPU Cache Devfreq"
+	depends on ARCH_QCOM || COMPILE_TEST
+	help
+	  This adds the DEVFREQ driver for the Krait CPU L2 Cache shared by all cores.
+
+	  The driver register with the cpufreq notifier and find the right frequency
+	  based on the max frequency across all core and the range set in the device
+	  dts. If provided this scale also the regulator attached to the l2 cache.
+
 source "drivers/devfreq/event/Kconfig"
 
 endif # PM_DEVFREQ
diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
index 3ca1ad0ecb97..bb87925a6a2d 100644
--- a/drivers/devfreq/Makefile
+++ b/drivers/devfreq/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_ARM_IMX8M_DDRC_DEVFREQ)	+= imx8m-ddrc.o
 obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ)	+= rk3399_dmc.o
 obj-$(CONFIG_ARM_TEGRA_DEVFREQ)		+= tegra30-devfreq.o
 obj-$(CONFIG_ARM_TEGRA20_DEVFREQ)	+= tegra20-devfreq.o
+obj-$(CONFIG_ARM_KRAIT_CACHE_DEVFREQ)	+= krait-cache-devfreq.o
 
 # DEVFREQ Event Drivers
 obj-$(CONFIG_PM_DEVFREQ_EVENT)		+= event/
diff --git a/drivers/devfreq/krait-cache-devfreq.c b/drivers/devfreq/krait-cache-devfreq.c
new file mode 100644
index 000000000000..4a82e45e2aac
--- /dev/null
+++ b/drivers/devfreq/krait-cache-devfreq.c
@@ -0,0 +1,298 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/cpufreq.h>
+#include <linux/devfreq.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/slab.h>
+#include <linux/regulator/consumer.h>
+#include <linux/pm_opp.h>
+
+#include "governor.h"
+
+struct krait_data {
+	struct device *dev;
+	struct devfreq *devfreq;
+
+	struct clk *l2_clk;
+
+	unsigned long *freq_table; /* L2 bus clock rate */
+	unsigned int *l2_cpufreq; /* L2 target CPU frequency */
+
+	struct notifier_block nb;
+};
+
+static int krait_cache_set_opp(struct dev_pm_set_opp_data *data)
+{
+	unsigned long old_freq = data->old_opp.rate, freq = data->new_opp.rate;
+	struct dev_pm_opp_supply *supply = &data->new_opp.supplies[0];
+	struct regulator *reg = data->regulators[0];
+	struct clk *clk = data->clk;
+	struct krait_data *kdata;
+	unsigned long idle_freq;
+	int ret;
+
+	kdata = (struct krait_data *)dev_get_drvdata(data->dev);
+
+	idle_freq = kdata->freq_table[0];
+
+	if (reg) {
+		ret = regulator_set_voltage_triplet(reg, supply->u_volt_min,
+						    supply->u_volt,
+						    supply->u_volt_max);
+		if (ret)
+			goto exit;
+	}
+
+	/*
+	 * Set to idle bin if switching from normal to high bin
+	 * or vice versa. It has been notice that a bug is triggered
+	 * in cache scaling when more than one bin is scaled, to fix
+	 * this we first need to transition to the base rate and then
+	 * to target rate
+	 */
+	if (likely(freq != idle_freq && old_freq != idle_freq)) {
+		ret = clk_set_rate(clk, idle_freq);
+		if (ret)
+			goto exit;
+	}
+
+	ret = clk_set_rate(clk, freq);
+	if (ret)
+		goto exit;
+
+exit:
+	return ret;
+};
+
+static int krait_cache_target(struct device *dev, unsigned long *freq,
+			      u32 flags)
+{
+	return dev_pm_opp_set_rate(dev, *freq);
+};
+
+static int krait_cache_get_dev_status(struct device *dev,
+				      struct devfreq_dev_status *stat)
+{
+	struct krait_data *data = dev_get_drvdata(dev);
+
+	stat->busy_time = 0;
+	stat->total_time = 0;
+	stat->current_frequency = clk_get_rate(data->l2_clk);
+
+	return 0;
+};
+
+static int krait_cache_get_cur_freq(struct device *dev, unsigned long *freq)
+{
+	struct krait_data *data = dev_get_drvdata(dev);
+
+	*freq = clk_get_rate(data->l2_clk);
+
+	return 0;
+};
+
+static struct devfreq_dev_profile tegra_devfreq_profile = {
+	.target = krait_cache_target,
+	.get_dev_status = krait_cache_get_dev_status,
+	.get_cur_freq = krait_cache_get_cur_freq
+};
+
+static int krait_cache_notifier(struct notifier_block *nb, unsigned long action,
+				void *v)
+{
+	struct cpufreq_freqs *freqs;
+	unsigned int cpu, cur_cpu;
+	struct krait_data *data;
+	struct devfreq *devfreq;
+	unsigned long freq;
+	int ret = 0;
+
+	if (action != CPUFREQ_POSTCHANGE)
+		return NOTIFY_OK;
+
+	data = container_of(nb, struct krait_data, nb);
+	devfreq = data->devfreq;
+
+	mutex_lock_nested(&devfreq->lock, SINGLE_DEPTH_NESTING);
+
+	freqs = (struct cpufreq_freqs *)v;
+	freq = freqs->new;
+	cur_cpu = freqs->policy->cpu;
+
+	/* find the max freq across all core */
+	for_each_present_cpu(cpu)
+		if (cpu != cur_cpu)
+			freq = max(freq, (unsigned long)cpufreq_quick_get(cpu));
+
+	devfreq->governor->get_target_freq(devfreq, &freq);
+
+	ret = devfreq->profile->target(data->dev, &freq, 0);
+	if (ret < 0)
+		goto out;
+
+	if (devfreq->profile->freq_table &&
+	    (devfreq_update_status(devfreq, freq)))
+		dev_err(data->dev,
+			"Couldn't update frequency transition information.\n");
+
+	devfreq->previous_freq = freq;
+
+out:
+	mutex_unlock(&devfreq->lock);
+	return notifier_from_errno(ret);
+};
+
+static int krait_cache_governor_get_target(struct devfreq *devfreq,
+					   unsigned long *freq)
+{
+	unsigned int *l2_cpufreq;
+	unsigned long *freq_table;
+	unsigned long target_freq = *freq;
+	struct krait_data *data = dev_get_drvdata(devfreq->dev.parent);
+
+	l2_cpufreq = data->l2_cpufreq;
+	freq_table = data->freq_table;
+
+	/*
+	 * Find the highest l2 freq interval based on the max cpufreq
+	 * across all core
+	 */
+	while (*(l2_cpufreq = l2_cpufreq + 1) && target_freq >= *l2_cpufreq)
+		freq_table = freq_table + 1;
+
+	*freq = *freq_table;
+
+	return 0;
+};
+
+static int krait_cache_governor_event_handler(struct devfreq *devfreq,
+					      unsigned int event, void *data)
+{
+	struct krait_data *kdata = dev_get_drvdata(devfreq->dev.parent);
+	int ret = 0;
+
+	switch (event) {
+	case DEVFREQ_GOV_START:
+		kdata->nb.notifier_call = krait_cache_notifier;
+		ret = cpufreq_register_notifier(&kdata->nb,
+						CPUFREQ_TRANSITION_NOTIFIER);
+		break;
+
+	case DEVFREQ_GOV_STOP:
+		cpufreq_unregister_notifier(&kdata->nb,
+					    CPUFREQ_TRANSITION_NOTIFIER);
+		break;
+	}
+
+	return ret;
+};
+
+static struct devfreq_governor krait_devfreq_governor = {
+	.name = "krait_governor",
+	.get_target_freq = krait_cache_governor_get_target,
+	.event_handler = krait_cache_governor_event_handler,
+	.immutable = true,
+};
+
+static int krait_cache_probe(struct platform_device *pdev)
+{
+	int ret, count;
+	struct opp_table *table;
+	struct krait_data *data;
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->of_node;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->dev = dev;
+
+	data->l2_clk = devm_clk_get(dev, "l2");
+	if (IS_ERR(data->l2_clk))
+		return PTR_ERR(data->l2_clk);
+
+	table = dev_pm_opp_set_regulators(dev, (const char *[]){ "l2" }, 1);
+	if (IS_ERR(table)) {
+		ret = PTR_ERR(table);
+		dev_err(dev, "failed to set regulators %d\n", ret);
+		return ret;
+	}
+
+	ret = PTR_ERR_OR_ZERO(
+		dev_pm_opp_register_set_opp_helper(dev, krait_cache_set_opp));
+	if (ret)
+		return ret;
+
+	ret = dev_pm_opp_of_add_table(dev);
+	if (ret) {
+		dev_err(dev, "failed to parse L2 freq thresholds\n");
+		return ret;
+	}
+
+	count = dev_pm_opp_get_opp_count(dev);
+
+	data->l2_cpufreq =
+		devm_kzalloc(dev, sizeof(unsigned int) * count, GFP_KERNEL);
+	if (!data->l2_cpufreq)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(node, "l2-cpufreq", data->l2_cpufreq,
+					 count);
+	if (ret) {
+		dev_err(dev, "failed to parse L2 cpufreq thresholds\n");
+		return ret;
+	}
+
+	ret = devfreq_add_governor(&krait_devfreq_governor);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to add governor: %d\n", ret);
+		return ret;
+	}
+
+	platform_set_drvdata(pdev, data);
+
+	data->devfreq = devfreq_add_device(&pdev->dev, &tegra_devfreq_profile,
+					   "krait_governor", NULL);
+
+	/* Cache freq_table to quickly get it when needed */
+	data->freq_table = data->devfreq->profile->freq_table;
+
+	if (IS_ERR(data->devfreq))
+		return PTR_ERR(data->devfreq);
+
+	return 0;
+};
+
+static int krait_cache_remove(struct platform_device *pdev)
+{
+	struct krait_data *data = platform_get_drvdata(pdev);
+
+	dev_pm_opp_remove_table(data->dev);
+
+	return 0;
+};
+
+static const struct of_device_id krait_cache_match_table[] = {
+	{ .compatible = "qcom,krait-cache" },
+	{}
+};
+
+static struct platform_driver krait_cache_driver = {
+	.probe		= krait_cache_probe,
+	.remove		= krait_cache_remove,
+	.driver		= {
+		.name   = "krait-cache-scaling",
+		.of_match_table = krait_cache_match_table,
+	},
+};
+module_platform_driver(krait_cache_driver);
+
+MODULE_DESCRIPTION("Krait CPU Cache Scaling driver");
+MODULE_AUTHOR("Ansuel Smith <ansuelsmth@gmail.com>");
+MODULE_LICENSE("GPL v2");
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver
  2020-09-27 16:05 [PATCH 1/2] devfreq: qcom: Add L2 Krait Cache devfreq scaling driver Ansuel Smith
@ 2020-09-27 16:05 ` Ansuel Smith
  2020-09-28 18:03   ` Rob Herring
  2020-09-28 18:08   ` Rob Herring
  0 siblings, 2 replies; 5+ messages in thread
From: Ansuel Smith @ 2020-09-27 16:05 UTC (permalink / raw)
  To: MyungJoo Ham
  Cc: Ansuel Smith, Kyungmin Park, Chanwoo Choi, Rob Herring, linux-pm,
	devicetree, linux-kernel

Document dedicated L2 Krait CPU Cache devfreq scaling driver.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 .../bindings/devfreq/krait-cache-devfreq.yaml | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml

diff --git a/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml b/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
new file mode 100644
index 000000000000..099ed978e022
--- /dev/null
+++ b/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cpufreq/krait-cache-devfreq.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DEVFREQ driver for Krait L2 Cpu Cache Frequency Scaling
+
+maintainers:
+  - Ansuel Smith <ansuelsmth@gmail.com>
+
+description: |
+  This Scale the Krait CPU L2 Cache Frequency and optionally voltage
+  when the Cpu Frequency is changed (using the cpufreq notifier).
+
+  Cache is scaled with the max frequency across all core and the cache
+  frequency will scale based on the configured threshold in the dts.
+
+  The cache thresholds can be set to 3+ frequency bin, idle, nominal and
+  high.
+
+properties:
+  compatible:
+    const: qcom,krait-cache
+
+  clocks:
+    $ref: "/schemas/types.yaml#/definitions/phandle"
+    description: Phandle to the L2 CPU clock
+
+  clock-names:
+    const: "l2"
+
+  voltage-tolerance:
+    description: Same voltage tolerance of the Krait CPU
+
+  l2-cpufreq:
+    description: |
+      Threshold used by the driver to scale the L2 cache.
+      If the max CPU Frequency is more than the set frequency,
+      the driver will transition to the next frequency bin.
+      Value is in kHz
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 3
+    items:
+      - description: idle
+      - description: nominal
+      - description: high
+
+  l2-supply:
+    $ref: "/schemas/types.yaml#/definitions/phandle"
+    description: Phandle to the L2 regulator supply.
+
+  opp-table: true
+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - voltage-tolerance
+  - l2-cpufreq
+
+examples:
+  - |
+    qcom-krait-cache {
+      compatible = "qcom,krait-cache";
+      clocks = <&kraitcc 4>;
+      clock-names = "l2";
+      l2-cpufreq = <384000 600000 1200000>;
+      l2-supply = <&smb208_s1a>;
+
+      operating-points = <
+        /* kHz    uV */
+        384000  1100000
+        1000000  1100000
+        1200000  1150000
+      >;
+    };
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver
  2020-09-27 16:05 ` [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver Ansuel Smith
@ 2020-09-28 18:03   ` Rob Herring
  2020-09-28 18:08   ` Rob Herring
  1 sibling, 0 replies; 5+ messages in thread
From: Rob Herring @ 2020-09-28 18:03 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: linux-pm, MyungJoo Ham, devicetree, Rob Herring, Kyungmin Park,
	linux-kernel, Chanwoo Choi

On Sun, 27 Sep 2020 18:05:13 +0200, Ansuel Smith wrote:
> Document dedicated L2 Krait CPU Cache devfreq scaling driver.
> 
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  .../bindings/devfreq/krait-cache-devfreq.yaml | 77 +++++++++++++++++++
>  1 file changed, 77 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
> 


My bot found errors running 'make dt_binding_check' on your patch:

./Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml: $id: relative path/filename doesn't match actual path or filename
	expected: http://devicetree.org/schemas/devfreq/krait-cache-devfreq.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.example.dt.yaml: qcom-krait-cache: clocks:0:1: missing phandle tag in 4
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.example.dt.yaml: qcom-krait-cache: clocks:0: [4294967295, 4] is too long
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.example.dt.yaml: qcom-krait-cache: 'voltage-tolerance' is a required property
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml


See https://patchwork.ozlabs.org/patch/1372099

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

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver
  2020-09-27 16:05 ` [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver Ansuel Smith
  2020-09-28 18:03   ` Rob Herring
@ 2020-09-28 18:08   ` Rob Herring
  2020-09-28 19:05     ` ansuelsmth
  1 sibling, 1 reply; 5+ messages in thread
From: Rob Herring @ 2020-09-28 18:08 UTC (permalink / raw)
  To: Ansuel Smith
  Cc: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, linux-pm, devicetree,
	linux-kernel

On Sun, Sep 27, 2020 at 06:05:13PM +0200, Ansuel Smith wrote:
> Document dedicated L2 Krait CPU Cache devfreq scaling driver.
> 
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  .../bindings/devfreq/krait-cache-devfreq.yaml | 77 +++++++++++++++++++
>  1 file changed, 77 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
> 
> diff --git a/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml b/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
> new file mode 100644
> index 000000000000..099ed978e022
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
> @@ -0,0 +1,77 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/cpufreq/krait-cache-devfreq.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: DEVFREQ driver for Krait L2 Cpu Cache Frequency Scaling

Bindings are for h/w devices, not collections of properties for some 
driver. Define a binding for L2 cache and add on to it what you need.

> +
> +maintainers:
> +  - Ansuel Smith <ansuelsmth@gmail.com>
> +
> +description: |
> +  This Scale the Krait CPU L2 Cache Frequency and optionally voltage
> +  when the Cpu Frequency is changed (using the cpufreq notifier).
> +
> +  Cache is scaled with the max frequency across all core and the cache
> +  frequency will scale based on the configured threshold in the dts.
> +
> +  The cache thresholds can be set to 3+ frequency bin, idle, nominal and
> +  high.
> +
> +properties:
> +  compatible:
> +    const: qcom,krait-cache
> +
> +  clocks:
> +    $ref: "/schemas/types.yaml#/definitions/phandle"

'clocks' already has a type defined. You just need how many and what 
each entry is.

> +    description: Phandle to the L2 CPU clock
> +
> +  clock-names:
> +    const: "l2"
> +
> +  voltage-tolerance:
> +    description: Same voltage tolerance of the Krait CPU

Needs a vendor prefix and unit suffix.

> +
> +  l2-cpufreq:
> +    description: |
> +      Threshold used by the driver to scale the L2 cache.
> +      If the max CPU Frequency is more than the set frequency,
> +      the driver will transition to the next frequency bin.
> +      Value is in kHz
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 3
> +    items:
> +      - description: idle
> +      - description: nominal
> +      - description: high
> +
> +  l2-supply:
> +    $ref: "/schemas/types.yaml#/definitions/phandle"
> +    description: Phandle to the L2 regulator supply.
> +
> +  opp-table: true
> +
> +required:
> +  - compatible
> +  - clocks
> +  - clock-names
> +  - voltage-tolerance
> +  - l2-cpufreq
> +
> +examples:
> +  - |
> +    qcom-krait-cache {
> +      compatible = "qcom,krait-cache";
> +      clocks = <&kraitcc 4>;
> +      clock-names = "l2";
> +      l2-cpufreq = <384000 600000 1200000>;
> +      l2-supply = <&smb208_s1a>;
> +
> +      operating-points = <

Not documented and generally deprecated.

> +        /* kHz    uV */
> +        384000  1100000
> +        1000000  1100000
> +        1200000  1150000
> +      >;
> +    };
> -- 
> 2.27.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver
  2020-09-28 18:08   ` Rob Herring
@ 2020-09-28 19:05     ` ansuelsmth
  0 siblings, 0 replies; 5+ messages in thread
From: ansuelsmth @ 2020-09-28 19:05 UTC (permalink / raw)
  To: 'Rob Herring'
  Cc: 'MyungJoo Ham', 'Kyungmin Park',
	'Chanwoo Choi',
	linux-pm, devicetree, linux-kernel



> -----Original Message-----
> From: Rob Herring <robh@kernel.org>
> Sent: Monday, September 28, 2020 8:09 PM
> To: Ansuel Smith <ansuelsmth@gmail.com>
> Cc: MyungJoo Ham <myungjoo.ham@samsung.com>; Kyungmin Park
> <kyungmin.park@samsung.com>; Chanwoo Choi
> <cw00.choi@samsung.com>; linux-pm@vger.kernel.org;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU
> Cache devfreq driver
> 
> On Sun, Sep 27, 2020 at 06:05:13PM +0200, Ansuel Smith wrote:
> > Document dedicated L2 Krait CPU Cache devfreq scaling driver.
> >
> > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > ---
> >  .../bindings/devfreq/krait-cache-devfreq.yaml | 77
> +++++++++++++++++++
> >  1 file changed, 77 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/devfreq/krait-
> cache-devfreq.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/devfreq/krait-cache-
> devfreq.yaml b/Documentation/devicetree/bindings/devfreq/krait-cache-
> devfreq.yaml
> > new file mode 100644
> > index 000000000000..099ed978e022
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/devfreq/krait-cache-
> devfreq.yaml
> > @@ -0,0 +1,77 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/cpufreq/krait-cache-devfreq.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: DEVFREQ driver for Krait L2 Cpu Cache Frequency Scaling
> 
> Bindings are for h/w devices, not collections of properties for some
> driver. Define a binding for L2 cache and add on to it what you need.
> 

Should I still document it in the devfreq directory or somewhere else?

> > +
> > +maintainers:
> > +  - Ansuel Smith <ansuelsmth@gmail.com>
> > +
> > +description: |
> > +  This Scale the Krait CPU L2 Cache Frequency and optionally voltage
> > +  when the Cpu Frequency is changed (using the cpufreq notifier).
> > +
> > +  Cache is scaled with the max frequency across all core and the cache
> > +  frequency will scale based on the configured threshold in the dts.
> > +
> > +  The cache thresholds can be set to 3+ frequency bin, idle, nominal
and
> > +  high.
> > +
> > +properties:
> > +  compatible:
> > +    const: qcom,krait-cache
> > +
> > +  clocks:
> > +    $ref: "/schemas/types.yaml#/definitions/phandle"
> 
> 'clocks' already has a type defined. You just need how many and what
> each entry is.
> 
> > +    description: Phandle to the L2 CPU clock
> > +
> > +  clock-names:
> > +    const: "l2"
> > +
> > +  voltage-tolerance:
> > +    description: Same voltage tolerance of the Krait CPU
> 
> Needs a vendor prefix and unit suffix.
> 
> > +
> > +  l2-cpufreq:
> > +    description: |
> > +      Threshold used by the driver to scale the L2 cache.
> > +      If the max CPU Frequency is more than the set frequency,
> > +      the driver will transition to the next frequency bin.
> > +      Value is in kHz
> > +    $ref: /schemas/types.yaml#/definitions/uint32-array
> > +    minItems: 3
> > +    items:
> > +      - description: idle
> > +      - description: nominal
> > +      - description: high
> > +
> > +  l2-supply:
> > +    $ref: "/schemas/types.yaml#/definitions/phandle"
> > +    description: Phandle to the L2 regulator supply.
> > +
> > +  opp-table: true
> > +
> > +required:
> > +  - compatible
> > +  - clocks
> > +  - clock-names
> > +  - voltage-tolerance
> > +  - l2-cpufreq
> > +
> > +examples:
> > +  - |
> > +    qcom-krait-cache {
> > +      compatible = "qcom,krait-cache";
> > +      clocks = <&kraitcc 4>;
> > +      clock-names = "l2";
> > +      l2-cpufreq = <384000 600000 1200000>;
> > +      l2-supply = <&smb208_s1a>;
> > +
> > +      operating-points = <
> 
> Not documented and generally deprecated.
> 

Ok will change to v2.

> > +        /* kHz    uV */
> > +        384000  1100000
> > +        1000000  1100000
> > +        1200000  1150000
> > +      >;
> > +    };
> > --
> > 2.27.0
> >


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-28 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-27 16:05 [PATCH 1/2] devfreq: qcom: Add L2 Krait Cache devfreq scaling driver Ansuel Smith
2020-09-27 16:05 ` [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver Ansuel Smith
2020-09-28 18:03   ` Rob Herring
2020-09-28 18:08   ` Rob Herring
2020-09-28 19:05     ` ansuelsmth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).