Skip to contentSkip to conversation

cpufreq: exynos5440: support for cpufreq driver

PATCH Superseded Amit Daniel Kachhap 3 participants 7 messages Mar 12, 2013 – Mar 18, 2013

Subsystems (5)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover cpufreq: exynos5440: support for cpufreq driver

Submitting the V4 version of exynos5440 cpufreq driver. This patchset addresses all the coding and design concerns raised especially by Viresh.

Changes in V4:
* Added dev_err logs instead of pr_err.
* Used the devm_ioremap_resource API.
* Implemented several coding guidelines and minor error comments from Sylwester, Russell and Viresh.

Changes in V3:
* Converted the driver to probe based as suggested by Viresh. This is also beneficial for multiplatform kernel.
* Other coding guidelines related changes.
* Moved the DT node outside cpu0 node as the driver is now a platform driver.

Changes in V2:
* Added OPP library support to parse DT parameters.
* Removed a hack to handle interrupts in bootup.
* Implemented other review comments from Viresh and Inder.

All these patches are dependent on Thomas Abraham common clock patches.
(http://www.mail-archive.com/[email protected]/msg15860.html)
This whole patch series is based on 3.9-rc2.

Amit Daniel Kachhap (4):
cpufreq: exynos: Adding cpufreq driver for exynos5440
cpufreq: exynos: Remove error return even if no soc is found
arm: exynos: Enable OPP library support for exynos5440
dts: Add cpufreq controller node for Exynos5440 SoC

 .../bindings/cpufreq/cpufreq-exynos5440.txt        |   29 ++
 arch/arm/boot/dts/exynos5440.dtsi                  |   12 +
 arch/arm/mach-exynos/Kconfig                       |    2 +
 arch/arm/mach-exynos/mach-exynos5-dt.c             |    2 +
 drivers/cpufreq/Kconfig.arm                        |    9 +
 drivers/cpufreq/Makefile                           |    1 +
 drivers/cpufreq/exynos-cpufreq.c                   |    2 +-
 drivers/cpufreq/exynos5440-cpufreq.c               |  466 ++++++++++++++++++++
 8 files changed, 522 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
 create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
#1 lore raw

PATCH v4 1/4 cpufreq: exynos: Adding cpufreq driver for exynos5440

This patch adds dvfs support for exynos5440 SOC. This soc has 4 cores and they scale at same frequency. The nature of exynos5440 clock controller is different from previous exynos controllers so not using the common exynos cpufreq framework. The major difference being interrupt notfication for frequency change. Also, OPP library is used for device tree parsing to get different parameters like frequency, voltage etc. Since the opp library sorts the frequency table in ascending order so they are again re-arranged in descending order. This will have one-to-one mapping with the clock controller state management logic.

---
 .../bindings/cpufreq/cpufreq-exynos5440.txt        |   29 ++
 drivers/cpufreq/Kconfig.arm                        |    9 +
 drivers/cpufreq/Makefile                           |    1 +
 drivers/cpufreq/exynos5440-cpufreq.c               |  466 ++++++++++++++++++++
 4 files changed, 505 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
 create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +29 -0
new file mode 100644
index 0000000..a0dbe0b
@@ -0,0 +1,29 @@
+
+Exynos5440 cpufreq driver
+-------------------
+
+Exynos5440 SoC cpufreq driver for CPU frequency scaling.
+
+Required properties:
+- interrupts: Interrupt to know the completion of cpu frequency change.
+- operating-points: Table of frequencies and voltage CPU could be transitioned into,
+	in the decreasing order. Frequency should be in KHZ units and voltage
+	should be in microvolts.
+
+Optional properties:
+- clock-latency: Clock monitor latency in microsecond.
+
+All the required listed above must be defined under node cpufreq.
+
+Example:
+--------
+	cpufreq@160000 {
+		compatible = "samsung,exynos5440-cpufreq";
+		reg = <0x160000 0x1000>;
+		interrupts = <0 57 0>;
+		operating-points = <
+				1000000 975000
+				800000  925000>;
+		clock-latency = <100000>;
+	};
+
drivers/cpufreq/Kconfig.arm +9 -0
index 030ddf6..7ed9c4a 100644
@@ -77,6 +77,15 @@ config ARM_EXYNOS5250_CPUFREQ
 	  This adds the CPUFreq driver for Samsung EXYNOS5250
 	  SoC.
 
+config ARM_EXYNOS5440_CPUFREQ
+	def_bool SOC_EXYNOS5440
+	depends on HAVE_CLK && PM_OPP && OF
+	help
+	  This adds the CPUFreq driver for Samsung EXYNOS5440
+	  SoC. The nature of exynos5440 clock controller is
+	  different than previous exynos controllers so not using
+	  the common exynos framework.
+
 config ARM_KIRKWOOD_CPUFREQ
 	def_bool ARCH_KIRKWOOD && OF
 	help
drivers/cpufreq/Makefile +1 -0
index 863fd18..c841438 100644
@@ -52,6 +52,7 @@ obj-$(CONFIG_ARM_EXYNOS_CPUFREQ)	+= exynos-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ)	+= exynos4210-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ)	+= exynos4x12-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ)	+= exynos5250-cpufreq.o
+obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)	+= exynos5440-cpufreq.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)	+= kirkwood-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)	+= omap-cpufreq.o
 obj-$(CONFIG_ARM_SPEAR_CPUFREQ)		+= spear-cpufreq.o
drivers/cpufreq/exynos5440-cpufreq.c new file +466 -0

466 lines not on this page · raw message

Signature · 1 line
1.7.1
maintainer
#2 lore raw

Re: [PATCH V4 1/4] cpufreq: exynos: Adding cpufreq driver for exynos5440

This is what Russell told me a long time back:
"Don't use Adding, Fixing, etc words as this work is not something, which is already done."

So your subject should have been: "cpufreq: exynos: Add cpufreq driver for exynos5440"

Fix it if you need another version, which i believe you do :)

Quoted 4 lines · Amit Daniel Kachhap

This patch adds dvfs support for exynos5440 SOC. This soc has 4 cores and they scale at same frequency. The nature of exynos5440 clock controller is different from previous exynos controllers so not using the common exynos cpufreq framework. The major difference being interrupt notfication for

s/notfication/notification

Quoted 22 lines

frequency change. Also, OPP library is used for device tree parsing to get different parameters like frequency, voltage etc. Since the opp library sorts the frequency table in ascending order so they are again re-arranged in descending order. This will have one-to-one mapping with the clock controller state management logic.

---
 .../bindings/cpufreq/cpufreq-exynos5440.txt        |   29 ++
 drivers/cpufreq/Kconfig.arm                        |    9 +
 drivers/cpufreq/Makefile                           |    1 +
 drivers/cpufreq/exynos5440-cpufreq.c               |  466 ++++++++++++++++++++
 4 files changed, 505 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
 create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +0 -0
new file mode 100644
index 0000000..a0dbe0b

Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +10 -0
@@ -0,0 +1,29 @@
+
+Exynos5440 cpufreq driver
+-------------------
+
+Exynos5440 SoC cpufreq driver for CPU frequency scaling.
+
+Required properties:
+- interrupts: Interrupt to know the completion of cpu frequency change.
+- operating-points: Table of frequencies and voltage CPU could be transitioned into,
+       in the decreasing order. Frequency should be in KHZ units and voltage

s/KHZ/KHz

Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt line 11

Quoted 1 line
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +1 -0
+       should be in microvolts.

probably s/microvolts/micro-volts ??

Quoted 23 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +18 -0
+
+Optional properties:
+- clock-latency: Clock monitor latency in microsecond.
+
+All the required listed above must be defined under node cpufreq.
+
+Example:
+--------
+       cpufreq@160000 {
+               compatible = "samsung,exynos5440-cpufreq";
+               reg = <0x160000 0x1000>;
+               interrupts = <0 57 0>;
+               operating-points = <
+                               1000000 975000
+                               800000  925000>;
+               clock-latency = <100000>;
+       };
+
drivers/cpufreq/exynos5440-cpufreq.c +2 -0
+static void exynos_enable_dvfs(void)
+{
 

drivers/cpufreq/exynos5440-cpufreq.c line 191

Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c +10 -0
+       /* Set initial performance index */
+       for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
+               if (freq_table[i].frequency == dvfs_info->cur_frequency)
+                       break;
+
+       if (freq_table[i].frequency == CPUFREQ_TABLE_END) {
+               dev_crit(dvfs_info->dev, "Boot up frequency not supported\n");
+               /* Assign the highest frequency */
+               i = 0;
+               dvfs_info->cur_frequency = freq_table[i].frequency;

What about:

dvfs_info->cur_frequency = freq_table[0].frequency;

as i don't see i being used again?

drivers/cpufreq/exynos5440-cpufreq.c line 233

Quoted 12 lines
drivers/cpufreq/exynos5440-cpufreq.c +9 -0
+       }
 
+}
 
+static int exynos_target(struct cpufreq_policy *policy,
+                         unsigned int target_freq,
+                         unsigned int relation)
+{
 
+       if (cpufreq_frequency_table_target(policy, freq_table,
+                                          target_freq, relation, &index)) {
+               ret = -EINVAL;

Use the error value returned by called functions, probably i gave this comment last time too?

Quoted 4 lines
drivers/cpufreq/exynos5440-cpufreq.c +3 -0
+               goto out;
+       }
 
+}

drivers/cpufreq/exynos5440-cpufreq.c line 311

Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c +9 -0
 
+static void exynos_sort_descend_freq_table(void)
+{
+       struct cpufreq_frequency_table *freq_tbl = dvfs_info->freq_table;
+       int i = 0, index;
+       unsigned int tmp_freq;
+
+       /*
+        * Freq table is already in ascending order as it is created from
+        * OPP library, so just swap the elements to make it descending.

why??

Quoted 31 lines
drivers/cpufreq/exynos5440-cpufreq.c +30 -0
+        */
+       for (i = 0; i < dvfs_info->freq_count / 2; i++) {
+               index = dvfs_info->freq_count - i - 1;
+               tmp_freq = freq_tbl[i].frequency;
+               freq_tbl[i].frequency = freq_tbl[index].frequency;
+               freq_tbl[index].frequency = tmp_freq;
+       }
+}
+
 
+static int exynos_cpufreq_probe(struct platform_device *pdev)
+{
+       int ret = -EINVAL;
+       struct device_node *np;
+       struct resource res;
+
+       np =  of_find_compatible_node(NULL, NULL, "samsung,exynos5440-cpufreq");
+       if (!np)
+               return -ENODEV;
+
+       dvfs_info = devm_kzalloc(&pdev->dev, sizeof(*dvfs_info), GFP_KERNEL);
+       if (!dvfs_info) {
+               ret = -ENOMEM;
+               goto err_put_node;
+       }
+
+       dvfs_info->dev = &pdev->dev;
+       dvfs_info->dev->of_node = np;
+
+       ret = of_address_to_resource(np, 0, &res);
+       if (ret)

drivers/cpufreq/exynos5440-cpufreq.c line 373

Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c +10 -0
+               goto err_put_node;
+
+       dvfs_info->base = devm_ioremap_resource(dvfs_info->dev, &res);
+       if (IS_ERR(dvfs_info->base)) {
+               ret = PTR_ERR(dvfs_info->base);
+               goto err_put_node;
+       }
+
+       dvfs_info->irq = irq_of_parse_and_map(np, 0);
+       if (dvfs_info->irq == 0) {

maybe, if (!dvfs_info->irq) {

Quoted 72 lines
drivers/cpufreq/exynos5440-cpufreq.c +72 -0
+               dev_err(dvfs_info->dev, "No cpufreq irq found\n");
+               ret = -ENODEV;
+               goto err_put_node;
+       }
+
+       ret = of_init_opp_table(dvfs_info->dev);
+       if (ret) {
+               dev_err(dvfs_info->dev, "failed to init OPP table: %d\n", ret);
+               goto err_put_node;
+       }
+
+       ret = opp_init_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
+       if (ret) {
+               dev_err(dvfs_info->dev,
+                       "failed to init cpufreq table: %d\n", ret);
+               goto err_put_node;
+       }
+       dvfs_info->freq_count = opp_get_opp_count(dvfs_info->dev);
+       exynos_sort_descend_freq_table();
+
+       if (of_property_read_u32(np, "clock-latency", &dvfs_info->latency))
+               dvfs_info->latency = DEF_TRANS_LATENCY;
+
+       dvfs_info->cpu_clk = devm_clk_get(dvfs_info->dev, "armclk");
+       if (IS_ERR(dvfs_info->cpu_clk)) {
+               dev_err(dvfs_info->dev, "Failed to get cpu clock\n");
+               ret = PTR_ERR(dvfs_info->cpu_clk);
+               goto err_free_table;
+       }
+
+       dvfs_info->cur_frequency = clk_get_rate(dvfs_info->cpu_clk);
+       if (!dvfs_info->cur_frequency) {
+               dev_err(dvfs_info->dev, "Failed to get clock rate\n");
+               ret = -EINVAL;
+               goto err_free_table;
+       }
+       dvfs_info->cur_frequency /= 1000;
+
+       INIT_WORK(&dvfs_info->irq_work, exynos_cpufreq_work);
+       ret = devm_request_irq(dvfs_info->dev, dvfs_info->irq,
+                               exynos_cpufreq_irq, IRQF_TRIGGER_NONE,
+                               CPUFREQ_NAME, dvfs_info);
+       if (ret) {
+               dev_err(dvfs_info->dev, "Failed to register IRQ\n");
+               goto err_free_table;
+       }
+
+       ret = init_div_table();
+       if (ret) {
+               dev_err(dvfs_info->dev, "Failed to initialise div table\n");
+               goto err_free_table;
+       }
+
+       exynos_enable_dvfs();
+       ret = cpufreq_register_driver(&exynos_driver);
+       if (ret) {
+               dev_err(dvfs_info->dev,
+                       "%s: failed to register cpufreq driver\n", __func__);
+               goto err_free_table;
+       }
+
+       of_node_put(np);
+       dvfs_info->dvfs_enabled = true;
+       return 0;
+
+err_free_table:
+       opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
+err_put_node:
+       of_node_put(np);
+       dev_err(dvfs_info->dev, "%s: failed initialization\n", __func__);
+       return ret;
+}
#3 lore raw

Re: [PATCH V4 1/4] cpufreq: exynos: Adding cpufreq driver for exynos5440

Hi Viresh,

Quoted 6 lines · Viresh Kumar

This is what Russell told me a long time back:
"Don't use Adding, Fixing, etc words as this work is not something, which is already done."

So your subject should have been: "cpufreq: exynos: Add cpufreq driver for exynos5440"

ok right.

Quoted 2 lines

Fix it if you need another version, which i believe you do :)

yes no escape now :)

Quoted 9 lines
Quoted 4 lines · Amit Daniel Kachhap

This patch adds dvfs support for exynos5440 SOC. This soc has 4 cores and they scale at same frequency. The nature of exynos5440 clock controller is different from previous exynos controllers so not using the common exynos cpufreq framework. The major difference being interrupt notfication for

s/notfication/notification

ok

Quoted 27 lines
Quoted 27 lines

frequency change. Also, OPP library is used for device tree parsing to get different parameters like frequency, voltage etc. Since the opp library sorts the frequency table in ascending order so they are again re-arranged in descending order. This will have one-to-one mapping with the clock controller state management logic.

---
 .../bindings/cpufreq/cpufreq-exynos5440.txt        |   29 ++
 drivers/cpufreq/Kconfig.arm                        |    9 +
 drivers/cpufreq/Makefile                           |    1 +
 drivers/cpufreq/exynos5440-cpufreq.c               |  466 ++++++++++++++++++++
 4 files changed, 505 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
 create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +4 -0
new file mode 100644
index 0000000..a0dbe0b
@@ -0,0 +1,29 @@
+
+Exynos5440 cpufreq driver
+-------------------
+
Quoted 8 lines

Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt line 10

Quoted 6 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +6 -0
+Exynos5440 SoC cpufreq driver for CPU frequency scaling.
+
+Required properties:
+- interrupts: Interrupt to know the completion of cpu frequency change.
+- operating-points: Table of frequencies and voltage CPU could be transitioned into,
+       in the decreasing order. Frequency should be in KHZ units and voltage

s/KHZ/KHz

ok

Quoted 39 lines

Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt line 11

Quoted 2 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +1 -0
+       should be in microvolts.

probably s/microvolts/micro-volts ??

Quoted 23 lines
Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file +18 -0
+
+Optional properties:
+- clock-latency: Clock monitor latency in microsecond.
+
+All the required listed above must be defined under node cpufreq.
+
+Example:
+--------
+       cpufreq@160000 {
+               compatible = "samsung,exynos5440-cpufreq";
+               reg = <0x160000 0x1000>;
+               interrupts = <0 57 0>;
+               operating-points = <
+                               1000000 975000
+                               800000  925000>;
+               clock-latency = <100000>;
+       };
+
drivers/cpufreq/exynos5440-cpufreq.c +2 -0
+static void exynos_enable_dvfs(void)
+{
 

drivers/cpufreq/exynos5440-cpufreq.c line 191

Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c +10 -0
+       /* Set initial performance index */
+       for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
+               if (freq_table[i].frequency == dvfs_info->cur_frequency)
+                       break;
+
+       if (freq_table[i].frequency == CPUFREQ_TABLE_END) {
+               dev_crit(dvfs_info->dev, "Boot up frequency not supported\n");
+               /* Assign the highest frequency */
+               i = 0;
+               dvfs_info->cur_frequency = freq_table[i].frequency;
Quoted 5 lines

What about:

dvfs_info->cur_frequency = freq_table[0].frequency;

as i don't see i being used again?

No It is used below for frequency setting.

Quoted 10 lines
Quoted 9 lines
drivers/cpufreq/exynos5440-cpufreq.c +6 -0
+       }
 
+}
 
+static int exynos_target(struct cpufreq_policy *policy,
+                         unsigned int target_freq,
+                         unsigned int relation)
+{
Quoted 6 lines

drivers/cpufreq/exynos5440-cpufreq.c line 233

Quoted 3 lines
drivers/cpufreq/exynos5440-cpufreq.c +3 -0
+       if (cpufreq_frequency_table_target(policy, freq_table,
+                                          target_freq, relation, &index)) {
+               ret = -EINVAL;

Use the error value returned by called functions, probably i gave this comment last time too?

yes my mistake.

Quoted 6 lines
Quoted 5 lines
drivers/cpufreq/exynos5440-cpufreq.c +3 -0
+               goto out;
+       }
 
+}
Quoted 11 lines

drivers/cpufreq/exynos5440-cpufreq.c line 311

Quoted 9 lines
drivers/cpufreq/exynos5440-cpufreq.c +9 -0
+static void exynos_sort_descend_freq_table(void)
+{
+       struct cpufreq_frequency_table *freq_tbl = dvfs_info->freq_table;
+       int i = 0, index;
+       unsigned int tmp_freq;
+
+       /*
+        * Freq table is already in ascending order as it is created from
+        * OPP library, so just swap the elements to make it descending.

why??

I explained this requirement in the patch commit. Will explain it here again.

Quoted 36 lines
Quoted 36 lines
drivers/cpufreq/exynos5440-cpufreq.c +34 -0
+        */
+       for (i = 0; i < dvfs_info->freq_count / 2; i++) {
+               index = dvfs_info->freq_count - i - 1;
+               tmp_freq = freq_tbl[i].frequency;
+               freq_tbl[i].frequency = freq_tbl[index].frequency;
+               freq_tbl[index].frequency = tmp_freq;
+       }
+}
+
 
+static int exynos_cpufreq_probe(struct platform_device *pdev)
+{
+       int ret = -EINVAL;
+       struct device_node *np;
+       struct resource res;
+
+       np =  of_find_compatible_node(NULL, NULL, "samsung,exynos5440-cpufreq");
+       if (!np)
+               return -ENODEV;
+
+       dvfs_info = devm_kzalloc(&pdev->dev, sizeof(*dvfs_info), GFP_KERNEL);
+       if (!dvfs_info) {
+               ret = -ENOMEM;
+               goto err_put_node;
+       }
+
+       dvfs_info->dev = &pdev->dev;
+       dvfs_info->dev->of_node = np;
+
+       ret = of_address_to_resource(np, 0, &res);
+       if (ret)
+               goto err_put_node;
+
+       dvfs_info->base = devm_ioremap_resource(dvfs_info->dev, &res);
+       if (IS_ERR(dvfs_info->base)) {
Quoted 8 lines

drivers/cpufreq/exynos5440-cpufreq.c line 373

Quoted 6 lines
drivers/cpufreq/exynos5440-cpufreq.c +6 -0
+               ret = PTR_ERR(dvfs_info->base);
+               goto err_put_node;
+       }
+
+       dvfs_info->irq = irq_of_parse_and_map(np, 0);
+       if (dvfs_info->irq == 0) {

maybe, if (!dvfs_info->irq) {

ok

Thanks,
Amit Daniel

Quoted 78 lines
Quoted 64 lines
drivers/cpufreq/exynos5440-cpufreq.c +62 -0
+               dev_err(dvfs_info->dev, "No cpufreq irq found\n");
+               ret = -ENODEV;
+               goto err_put_node;
+       }
+
+       ret = of_init_opp_table(dvfs_info->dev);
+       if (ret) {
+               dev_err(dvfs_info->dev, "failed to init OPP table: %d\n", ret);
+               goto err_put_node;
+       }
+
+       ret = opp_init_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
+       if (ret) {
+               dev_err(dvfs_info->dev,
+                       "failed to init cpufreq table: %d\n", ret);
+               goto err_put_node;
+       }
+       dvfs_info->freq_count = opp_get_opp_count(dvfs_info->dev);
+       exynos_sort_descend_freq_table();
+
+       if (of_property_read_u32(np, "clock-latency", &dvfs_info->latency))
+               dvfs_info->latency = DEF_TRANS_LATENCY;
+
+       dvfs_info->cpu_clk = devm_clk_get(dvfs_info->dev, "armclk");
+       if (IS_ERR(dvfs_info->cpu_clk)) {
+               dev_err(dvfs_info->dev, "Failed to get cpu clock\n");
+               ret = PTR_ERR(dvfs_info->cpu_clk);
+               goto err_free_table;
+       }
+
+       dvfs_info->cur_frequency = clk_get_rate(dvfs_info->cpu_clk);
+       if (!dvfs_info->cur_frequency) {
+               dev_err(dvfs_info->dev, "Failed to get clock rate\n");
+               ret = -EINVAL;
+               goto err_free_table;
+       }
+       dvfs_info->cur_frequency /= 1000;
+
+       INIT_WORK(&dvfs_info->irq_work, exynos_cpufreq_work);
+       ret = devm_request_irq(dvfs_info->dev, dvfs_info->irq,
+                               exynos_cpufreq_irq, IRQF_TRIGGER_NONE,
+                               CPUFREQ_NAME, dvfs_info);
+       if (ret) {
+               dev_err(dvfs_info->dev, "Failed to register IRQ\n");
+               goto err_free_table;
+       }
+
+       ret = init_div_table();
+       if (ret) {
+               dev_err(dvfs_info->dev, "Failed to initialise div table\n");
+               goto err_free_table;
+       }
+
+       exynos_enable_dvfs();
+       ret = cpufreq_register_driver(&exynos_driver);
+       if (ret) {
+               dev_err(dvfs_info->dev,
+                       "%s: failed to register cpufreq driver\n", __func__);
+               goto err_free_table;
+       }
+
+       of_node_put(np);

drivers/cpufreq/exynos5440-cpufreq.c line 445

Quoted 10 lines
drivers/cpufreq/exynos5440-cpufreq.c +10 -0
+       dvfs_info->dvfs_enabled = true;
+       return 0;
+
+err_free_table:
+       opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
+err_put_node:
+       of_node_put(np);
+       dev_err(dvfs_info->dev, "%s: failed initialization\n", __func__);
+       return ret;
+}

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

PATCH v4 2/4 cpufreq: exynos: Remove error return even if no soc is found

In reply to Amit Daniel Kachhap

This patch helps to have single binary for exynos5440 and previous exynos soc's. This change is needed for adding exynos5440 cpufreq driver which does not uses exynos-cpufreq common file and adds it own driver.

---
 drivers/cpufreq/exynos-cpufreq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/cpufreq/exynos-cpufreq.c +1 -1
index 78057a3..ee75997 100644
@@ -297,7 +297,7 @@ static int __init exynos_cpufreq_init(void)
 	else if (soc_is_exynos5250())
 		ret = exynos5250_cpufreq_init(exynos_info);
 	else
-		pr_err("%s: CPU type not found\n", __func__);
+		return 0;
 
 	if (ret)
 		goto err_vdd_arm;
Signature · 1 line
1.7.1
#5 lore raw

PATCH v4 3/4 arm: exynos: Enable OPP library support for exynos5440

In reply to Amit Daniel Kachhap

The OPP library support is needed for exynos5440 cpu frequency dynamic scaling driver.

---
 arch/arm/mach-exynos/Kconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-exynos/Kconfig +2 -0
index 70f94c8..d5dde07 100644
@@ -72,10 +72,12 @@ config SOC_EXYNOS5440
 	bool "SAMSUNG EXYNOS5440"
 	default y
 	depends on ARCH_EXYNOS5
+	select ARCH_HAS_OPP
 	select ARM_ARCH_TIMER
 	select AUTO_ZRELADDR
 	select PINCTRL
 	select PINCTRL_EXYNOS5440
+	select PM_OPP
 	help
 	  Enable EXYNOS5440 SoC support
 
Signature · 1 line
1.7.1
#6 lore raw

PATCH v4 4/4 dts: Add cpufreq controller node for Exynos5440 SoC

In reply to Amit Daniel Kachhap

Add cpufreq controller device node for Exynos5440 SoC for passing parameters like controller base address, interrupt and cpufreq table. This node is added outside cpu0 as this driver is now a platform driver and a new device structure is needed.

---
 arch/arm/boot/dts/exynos5440.dtsi      |   12 ++++++++++++
 arch/arm/mach-exynos/mach-exynos5-dt.c |    2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)
arch/arm/boot/dts/exynos5440.dtsi +12 -0
index 5f3562a..4b29a5a 100644
@@ -63,6 +63,18 @@
 
 	};
 
+	cpufreq@160000 {
+		compatible = "samsung,exynos5440-cpufreq";
+		reg = <0x160000 0x1000>;
+		interrupts = <0 57 0>;
+		operating-points = <
+				/* KHZ	  uV */
+				1200000 1025000
+				1000000 975000
+				800000  925000
+		>;
+	};
+
 	serial@B0000 {
 		compatible = "samsung,exynos4210-uart";
 		reg = <0xB0000 0x1000>;
arch/arm/mach-exynos/mach-exynos5-dt.c +2 -0
index acaeb14..0a446c4 100644
@@ -145,6 +145,8 @@ static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = {
 static const struct of_dev_auxdata exynos5440_auxdata_lookup[] __initconst = {
 	OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5440_PA_UART0,
 				"exynos4210-uart.0", NULL),
+	OF_DEV_AUXDATA("samsung,exynos5440-cpufreq", 0x160000,
+				"exynos5440-cpufreq", NULL),
 	{},
 };
 
Signature · 1 line
1.7.1