linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] i.MX53 cpufreq support
@ 2014-09-19 16:16 Lucas Stach
  2014-09-19 16:16 ` [PATCH 1/5] cpufreq: cpu0: disable unsupported OPPs Lucas Stach
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Lucas Stach @ 2014-09-19 16:16 UTC (permalink / raw)
  To: Shawn Guo, Viresh Kumar
  Cc: Rafael J. Wysocki, linux-arm-kernel, linux-pm, kernel

This series implements cpufreq support for the i.MX53 SoC
using the generic cpufreq-cpu0 driver. The design is based
on feedback I got on the last round of patches.

Basically this implements a CPU clock type that abstracts away
all the clock handling required for reprogramming the PLL
feeding the CPU, so we don't have to worry about this in the
cpufreq driver. For now this is only used on MX53, but looking
forward the same approach (and code) could be used on MX6.

The first patch allows cpufreq-cpu0 to deactivate OPPs where
the regulator isn't able to provide the required voltage. This
has been tested on custom a MX53 board.

Lucas Stach (5):
  cpufreq: cpu0: disable unsupported OPPs
  clk: imx5: add step clock, used when reprogramming PLL1
  clk: imx: add CPU clock type
  arm: imx53: clk: add ARM clock
  ARM: imx53: add cpufreq support

 arch/arm/boot/dts/imx53.dtsi           |  13 ++++-
 arch/arm/mach-imx/Makefile             |   2 +-
 arch/arm/mach-imx/clk-cpu.c            | 104 +++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/clk-imx51-imx53.c    |  14 ++++-
 arch/arm/mach-imx/clk.h                |   4 ++
 arch/arm/mach-imx/mach-imx53.c         |   4 ++
 drivers/cpufreq/cpufreq-cpu0.c         |  60 +++++++++++--------
 include/dt-bindings/clock/imx5-clock.h |   5 +-
 8 files changed, 179 insertions(+), 27 deletions(-)
 create mode 100644 arch/arm/mach-imx/clk-cpu.c

-- 
2.1.0


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

* [PATCH 1/5] cpufreq: cpu0: disable unsupported OPPs
  2014-09-19 16:16 [PATCH 0/5] i.MX53 cpufreq support Lucas Stach
@ 2014-09-19 16:16 ` Lucas Stach
  2014-09-19 16:49   ` Viresh Kumar
  2014-09-19 16:16 ` [PATCH 2/5] clk: imx5: add step clock, used when reprogramming PLL1 Lucas Stach
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Lucas Stach @ 2014-09-19 16:16 UTC (permalink / raw)
  To: Shawn Guo, Viresh Kumar
  Cc: Rafael J. Wysocki, linux-arm-kernel, linux-pm, kernel

If the regulator connected to the CPU voltage plane doesn't
support an OPP specified voltage with the acceptable tolerance
it's better to just disable the OPP instead of constantly
failing the voltage scaling later on.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/cpufreq/cpufreq-cpu0.c | 60 ++++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 23 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 0d2172b07765..83296bd2089e 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -117,6 +117,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
 {
 	struct device_node *np;
 	int ret;
+	unsigned long opp_freq = 0, min_uV = ~0, max_uV = 0, tol;
 
 	cpu_dev = get_cpu_device(0);
 	if (!cpu_dev) {
@@ -155,42 +156,55 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
 	/* OPPs might be populated at runtime, don't check for error here */
 	of_init_opp_table(cpu_dev);
 
-	ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
-	if (ret) {
-		pr_err("failed to init cpufreq table: %d\n", ret);
-		goto out_put_clk;
-	}
-
 	of_property_read_u32(np, "voltage-tolerance", &voltage_tolerance);
 
 	if (of_property_read_u32(np, "clock-latency", &transition_latency))
 		transition_latency = CPUFREQ_ETERNAL;
 
 	if (!IS_ERR(cpu_reg)) {
-		struct dev_pm_opp *opp;
-		unsigned long min_uV, max_uV;
-		int i;
-
 		/*
-		 * OPP is maintained in order of increasing frequency, and
-		 * freq_table initialised from OPP is therefore sorted in the
-		 * same order.
+		 * Disable any OPPs where the connected regulator isn't able to
+		 * provide the specified voltage and record minimum and maximum
+		 * voltage levels.
 		 */
-		for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
-			;
-		rcu_read_lock();
-		opp = dev_pm_opp_find_freq_exact(cpu_dev,
-				freq_table[0].frequency * 1000, true);
-		min_uV = dev_pm_opp_get_voltage(opp);
-		opp = dev_pm_opp_find_freq_exact(cpu_dev,
-				freq_table[i-1].frequency * 1000, true);
-		max_uV = dev_pm_opp_get_voltage(opp);
-		rcu_read_unlock();
+		while (1) {
+			struct dev_pm_opp *opp;
+			unsigned long opp_uV;
+
+			rcu_read_lock();
+			opp = dev_pm_opp_find_freq_ceil(cpu_dev, &opp_freq);
+			if (IS_ERR(opp)) {
+				rcu_read_unlock();
+				break;
+			}
+			opp_uV = dev_pm_opp_get_voltage(opp);
+			rcu_read_unlock();
+
+			tol = opp_uV * voltage_tolerance / 100;
+			if (regulator_is_supported_voltage(cpu_reg, opp_uV,
+							   opp_uV + tol)) {
+				if (opp_uV < min_uV)
+					min_uV = opp_uV;
+				if (opp_uV > max_uV)
+					max_uV = opp_uV;
+			} else {
+				dev_pm_opp_disable(cpu_dev, opp_freq);
+			}
+
+			opp_freq++;
+		}
+
 		ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV);
 		if (ret > 0)
 			transition_latency += ret * 1000;
 	}
 
+	ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
+	if (ret) {
+		pr_err("failed to init cpufreq table: %d\n", ret);
+		goto out_put_clk;
+	}
+
 	ret = cpufreq_register_driver(&cpu0_cpufreq_driver);
 	if (ret) {
 		pr_err("failed register driver: %d\n", ret);
-- 
2.1.0


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

* [PATCH 2/5] clk: imx5: add step clock, used when reprogramming PLL1
  2014-09-19 16:16 [PATCH 0/5] i.MX53 cpufreq support Lucas Stach
  2014-09-19 16:16 ` [PATCH 1/5] cpufreq: cpu0: disable unsupported OPPs Lucas Stach
@ 2014-09-19 16:16 ` Lucas Stach
  2014-09-19 16:16 ` [PATCH 3/5] clk: imx: add CPU clock type Lucas Stach
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Lucas Stach @ 2014-09-19 16:16 UTC (permalink / raw)
  To: Shawn Guo, Viresh Kumar
  Cc: Rafael J. Wysocki, linux-arm-kernel, linux-pm, kernel

This is the bypass clock used to feed the ARM partition
while we reprogram PLL1 to another clock.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 arch/arm/mach-imx/clk-imx51-imx53.c    | 9 ++++++++-
 include/dt-bindings/clock/imx5-clock.h | 4 +++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index 72d65214223e..aafccf4b47c2 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -125,6 +125,8 @@ static const char *mx53_spdif_xtal_sel[] = { "osc", "ckih", "ckih2", "pll4_sw",
 static const char *spdif_sel[] = { "pll1_sw", "pll2_sw", "pll3_sw", "spdif_xtal_sel", };
 static const char *spdif0_com_sel[] = { "spdif0_podf", "ssi1_root_gate", };
 static const char *mx51_spdif1_com_sel[] = { "spdif1_podf", "ssi2_root_gate", };
+static const char *step_sels[] = { "lp_apm", };
+static const char *cpu_podf_sels[] = { "pll1_sw", "step_sel" };
 
 static struct clk *clk[IMX5_CLK_END];
 static struct clk_onecell_data clk_data;
@@ -193,7 +195,9 @@ static void __init mx5_clocks_common_init(void __iomem *ccm_base)
 	clk[IMX5_CLK_USB_PHY_PODF]	= imx_clk_divider("usb_phy_podf", "usb_phy_pred", MXC_CCM_CDCDR, 0, 3);
 	clk[IMX5_CLK_USB_PHY_SEL]	= imx_clk_mux("usb_phy_sel", MXC_CCM_CSCMR1, 26, 1,
 						usb_phy_sel_str, ARRAY_SIZE(usb_phy_sel_str));
-	clk[IMX5_CLK_CPU_PODF]		= imx_clk_divider("cpu_podf", "pll1_sw", MXC_CCM_CACRR, 0, 3);
+	clk[IMX5_CLK_STEP_SEL]		= imx_clk_mux("step_sel", MXC_CCM_CCSR, 7, 2, step_sels, ARRAY_SIZE(step_sels));
+	clk[IMX5_CLK_CPU_PODF_SEL]	= imx_clk_mux("cpu_podf_sel", MXC_CCM_CCSR, 2, 1, cpu_podf_sels, ARRAY_SIZE(cpu_podf_sels));
+	clk[IMX5_CLK_CPU_PODF]		= imx_clk_divider("cpu_podf", "cpu_podf_sel", MXC_CCM_CACRR, 0, 3);
 	clk[IMX5_CLK_DI_PRED]		= imx_clk_divider("di_pred", "pll3_sw", MXC_CCM_CDCDR, 6, 3);
 	clk[IMX5_CLK_IIM_GATE]		= imx_clk_gate2("iim_gate", "ipg", MXC_CCM_CCGR0, 30);
 	clk[IMX5_CLK_UART1_IPG_GATE]	= imx_clk_gate2("uart1_ipg_gate", "ipg", MXC_CCM_CCGR1, 6);
@@ -551,6 +555,9 @@ static void __init mx53_clocks_init(struct device_node *np)
 	/* move can bus clk to 24MHz */
 	clk_set_parent(clk[IMX5_CLK_CAN_SEL], clk[IMX5_CLK_LP_APM]);
 
+	/* make sure step clock is running from 24MHz */
+	clk_set_parent(clk[IMX5_CLK_STEP_SEL], clk[IMX5_CLK_LP_APM]);
+
 	clk_prepare_enable(clk[IMX5_CLK_IIM_GATE]);
 	imx_print_silicon_rev("i.MX53", mx53_revision());
 	clk_disable_unprepare(clk[IMX5_CLK_IIM_GATE]);
diff --git a/include/dt-bindings/clock/imx5-clock.h b/include/dt-bindings/clock/imx5-clock.h
index 5f2667ecd98e..1a36ff4ace1e 100644
--- a/include/dt-bindings/clock/imx5-clock.h
+++ b/include/dt-bindings/clock/imx5-clock.h
@@ -198,6 +198,8 @@
 #define IMX5_CLK_OCRAM			186
 #define IMX5_CLK_SAHARA_IPG_GATE	187
 #define IMX5_CLK_SATA_REF		188
-#define IMX5_CLK_END			189
+#define IMX5_CLK_STEP_SEL		189
+#define IMX5_CLK_CPU_PODF_SEL		190
+#define IMX5_CLK_END			191
 
 #endif /* __DT_BINDINGS_CLOCK_IMX5_H */
-- 
2.1.0


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

* [PATCH 3/5] clk: imx: add CPU clock type
  2014-09-19 16:16 [PATCH 0/5] i.MX53 cpufreq support Lucas Stach
  2014-09-19 16:16 ` [PATCH 1/5] cpufreq: cpu0: disable unsupported OPPs Lucas Stach
  2014-09-19 16:16 ` [PATCH 2/5] clk: imx5: add step clock, used when reprogramming PLL1 Lucas Stach
@ 2014-09-19 16:16 ` Lucas Stach
  2014-09-26  2:59   ` Shawn Guo
  2014-09-19 16:16 ` [PATCH 4/5] arm: imx53: clk: add ARM clock Lucas Stach
  2014-09-19 16:16 ` [PATCH 5/5] ARM: imx53: add cpufreq support Lucas Stach
  4 siblings, 1 reply; 10+ messages in thread
From: Lucas Stach @ 2014-09-19 16:16 UTC (permalink / raw)
  To: Shawn Guo, Viresh Kumar
  Cc: Rafael J. Wysocki, linux-arm-kernel, linux-pm, kernel

From: Lucas Stach <dev@lynxeye.de>

This implements a virtual clock used to abstract away
all the steps needed in order to change the ARM clock,
so we don't have to push all this clock handling into
the cpufreq driver.

While it will be used for i.MX53 at first it is generic
enough to be used on i.MX6 later on.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/mach-imx/Makefile  |   2 +-
 arch/arm/mach-imx/clk-cpu.c | 104 ++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/clk.h     |   4 ++
 3 files changed, 109 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-imx/clk-cpu.c

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index ac88599ca080..4d6071351f4f 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -12,7 +12,7 @@ obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-
 obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o
 
 imx5-pm-$(CONFIG_PM) += pm-imx5.o
-obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o $(imx5-pm-y)
+obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o clk-cpu.o $(imx5-pm-y)
 
 obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \
 			    clk-pfd.o clk-busy.o clk.o \
diff --git a/arch/arm/mach-imx/clk-cpu.c b/arch/arm/mach-imx/clk-cpu.c
new file mode 100644
index 000000000000..ffba96228d3b
--- /dev/null
+++ b/arch/arm/mach-imx/clk-cpu.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2014 Lucas Stach <l.stach@pengutronix.de>, Pengutronix
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/slab.h>
+
+struct clk_cpu {
+	struct clk_hw	hw;
+	struct clk	*div, *mux, *pll, *step;
+};
+
+static inline struct clk_cpu *to_clk_cpu(struct clk_hw *hw)
+{
+	return container_of(hw, struct clk_cpu, hw);
+}
+
+static unsigned long clk_cpu_recalc_rate(struct clk_hw *hw,
+					 unsigned long parent_rate)
+{
+	struct clk_cpu *cpu = to_clk_cpu(hw);
+
+	return clk_get_rate(cpu->div);
+}
+
+static long clk_cpu_round_rate(struct clk_hw *hw, unsigned long rate,
+			       unsigned long *prate)
+{
+	struct clk_cpu *cpu = to_clk_cpu(hw);
+
+	return clk_round_rate(cpu->pll, rate);
+}
+
+static int clk_cpu_set_rate(struct clk_hw *hw, unsigned long rate,
+			    unsigned long parent_rate)
+{
+	struct clk_cpu *cpu = to_clk_cpu(hw);
+	int ret;
+
+	/* switch to PLL bypass clock */
+	ret = clk_set_parent(cpu->mux, cpu->step);
+	if (ret)
+		return ret;
+
+	/* reprogram PLL */
+	ret = clk_set_rate(cpu->pll, rate);
+	if (ret) {
+		clk_set_parent(cpu->mux, cpu->pll);
+		return ret;
+	}
+	/* switch back to PLL clock */
+	clk_set_parent(cpu->mux, cpu->pll);
+
+	/* Ensure the divider is what we expect */
+	clk_set_rate(cpu->div, rate);
+
+	return 0;
+}
+
+static const struct clk_ops clk_cpu_ops = {
+	.recalc_rate	= clk_cpu_recalc_rate,
+	.round_rate	= clk_cpu_round_rate,
+	.set_rate	= clk_cpu_set_rate,
+};
+
+struct clk *imx_clk_cpu(const char *name, const char *parent_name,
+		struct clk *div, struct clk *mux, struct clk *pll,
+		struct clk *step)
+{
+	struct clk_cpu *cpu;
+	struct clk *clk;
+	struct clk_init_data init;
+
+	cpu = kzalloc(sizeof(*cpu), GFP_KERNEL);
+	if (!cpu)
+		return ERR_PTR(-ENOMEM);
+
+	cpu->div = div;
+	cpu->mux = mux;
+	cpu->pll = pll;
+	cpu->step = step;
+
+	init.name = name;
+	init.ops = &clk_cpu_ops;
+	init.flags = 0;
+	init.parent_names = &parent_name;
+	init.num_parents = 1;
+
+	cpu->hw.init = &init;
+
+	clk = clk_register(NULL, &cpu->hw);
+	if (IS_ERR(clk))
+		kfree(cpu);
+
+	return clk;
+}
diff --git a/arch/arm/mach-imx/clk.h b/arch/arm/mach-imx/clk.h
index d5ba76fee115..5de8b53ec208 100644
--- a/arch/arm/mach-imx/clk.h
+++ b/arch/arm/mach-imx/clk.h
@@ -128,4 +128,8 @@ static inline struct clk *imx_clk_fixed_factor(const char *name,
 			CLK_SET_RATE_PARENT, mult, div);
 }
 
+struct clk *imx_clk_cpu(const char *name, const char *parent_name,
+		struct clk *div, struct clk *mux, struct clk *pll,
+		struct clk *step);
+
 #endif
-- 
2.1.0


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

* [PATCH 4/5] arm: imx53: clk: add ARM clock
  2014-09-19 16:16 [PATCH 0/5] i.MX53 cpufreq support Lucas Stach
                   ` (2 preceding siblings ...)
  2014-09-19 16:16 ` [PATCH 3/5] clk: imx: add CPU clock type Lucas Stach
@ 2014-09-19 16:16 ` Lucas Stach
  2014-09-19 16:16 ` [PATCH 5/5] ARM: imx53: add cpufreq support Lucas Stach
  4 siblings, 0 replies; 10+ messages in thread
From: Lucas Stach @ 2014-09-19 16:16 UTC (permalink / raw)
  To: Shawn Guo, Viresh Kumar
  Cc: Rafael J. Wysocki, linux-arm-kernel, linux-pm, kernel

The ARM clock is a virtual clock feeding the ARM partition of
the SoC. It controls multiple other clocks to ensure the right
sequencing when cpufreq changes the CPU clock rate.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/mach-imx/clk-imx51-imx53.c    | 5 +++++
 include/dt-bindings/clock/imx5-clock.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index aafccf4b47c2..0f7e536147cb 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -541,6 +541,11 @@ static void __init mx53_clocks_init(struct device_node *np)
 	clk[IMX5_CLK_CKO2]		= imx_clk_gate2("cko2", "cko2_podf", MXC_CCM_CCOSR, 24);
 	clk[IMX5_CLK_SPDIF_XTAL_SEL]	= imx_clk_mux("spdif_xtal_sel", MXC_CCM_CSCMR1, 2, 2,
 						mx53_spdif_xtal_sel, ARRAY_SIZE(mx53_spdif_xtal_sel));
+	clk[IMX5_CLK_ARM]		= imx_clk_cpu("arm", "cpu_podf",
+						clk[IMX5_CLK_CPU_PODF],
+						clk[IMX5_CLK_CPU_PODF_SEL],
+						clk[IMX5_CLK_PLL1_SW],
+						clk[IMX5_CLK_STEP_SEL]);
 
 	imx_check_clocks(clk, ARRAY_SIZE(clk));
 
diff --git a/include/dt-bindings/clock/imx5-clock.h b/include/dt-bindings/clock/imx5-clock.h
index 1a36ff4ace1e..f4b7478e23c8 100644
--- a/include/dt-bindings/clock/imx5-clock.h
+++ b/include/dt-bindings/clock/imx5-clock.h
@@ -200,6 +200,7 @@
 #define IMX5_CLK_SATA_REF		188
 #define IMX5_CLK_STEP_SEL		189
 #define IMX5_CLK_CPU_PODF_SEL		190
-#define IMX5_CLK_END			191
+#define IMX5_CLK_ARM			191
+#define IMX5_CLK_END			192
 
 #endif /* __DT_BINDINGS_CLOCK_IMX5_H */
-- 
2.1.0


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

* [PATCH 5/5] ARM: imx53: add cpufreq support
  2014-09-19 16:16 [PATCH 0/5] i.MX53 cpufreq support Lucas Stach
                   ` (3 preceding siblings ...)
  2014-09-19 16:16 ` [PATCH 4/5] arm: imx53: clk: add ARM clock Lucas Stach
@ 2014-09-19 16:16 ` Lucas Stach
  2014-09-26  3:02   ` Shawn Guo
  4 siblings, 1 reply; 10+ messages in thread
From: Lucas Stach @ 2014-09-19 16:16 UTC (permalink / raw)
  To: Shawn Guo, Viresh Kumar
  Cc: Rafael J. Wysocki, linux-arm-kernel, linux-pm, kernel

Instanciate the platform device for the generic cpufreq-cpu0
driver and add all required properties to the DT.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/boot/dts/imx53.dtsi   | 13 ++++++++++++-
 arch/arm/mach-imx/mach-imx53.c |  4 ++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 64fa27b36be0..bd5226a7ea20 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -46,10 +46,21 @@
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a8";
 			reg = <0x0>;
+			clocks = <&clks IMX5_CLK_ARM>;
+			clock-latency = <61036>;
+			voltage-tolerance = <5>;
+			operating-points = <
+				/* kHz */
+				 166666  850000
+				 400000  900000
+				 800000 1050000
+				1000000 1200000
+				1200000 1300000
+			>;
 		};
 	};
 
diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c
index 03dd6ea13acc..4eb6849c52d2 100644
--- a/arch/arm/mach-imx/mach-imx53.c
+++ b/arch/arm/mach-imx/mach-imx53.c
@@ -38,9 +38,13 @@ static void __init imx53_dt_init(void)
 	imx_aips_allow_unprivileged_access("fsl,imx53-aipstz");
 }
 
+static struct platform_device imx53_cpufreq_pdev = { .name = "cpufreq-cpu0", };
+
 static void __init imx53_init_late(void)
 {
 	imx53_pm_init();
+
+	platform_device_register(&imx53_cpufreq_pdev);
 }
 
 static const char * const imx53_dt_board_compat[] __initconst = {
-- 
2.1.0


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

* Re: [PATCH 1/5] cpufreq: cpu0: disable unsupported OPPs
  2014-09-19 16:16 ` [PATCH 1/5] cpufreq: cpu0: disable unsupported OPPs Lucas Stach
@ 2014-09-19 16:49   ` Viresh Kumar
  0 siblings, 0 replies; 10+ messages in thread
From: Viresh Kumar @ 2014-09-19 16:49 UTC (permalink / raw)
  To: Lucas Stach, Mark Brown
  Cc: Shawn Guo, Rafael J. Wysocki,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	Sascha Hauer

Cc'ing Mark Brown to get his views on the idea.

On 19 September 2014 09:16, Lucas Stach <l.stach@pengutronix.de> wrote:
> If the regulator connected to the CPU voltage plane doesn't
> support an OPP specified voltage with the acceptable tolerance
> it's better to just disable the OPP instead of constantly
> failing the voltage scaling later on.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/cpufreq/cpufreq-cpu0.c | 60 ++++++++++++++++++++++++++----------------
>  1 file changed, 37 insertions(+), 23 deletions(-)

And this file doesn't exist anymore (its renamed). Rebase over
Rafael's linux-next branch for that.

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

* Re: [PATCH 3/5] clk: imx: add CPU clock type
  2014-09-19 16:16 ` [PATCH 3/5] clk: imx: add CPU clock type Lucas Stach
@ 2014-09-26  2:59   ` Shawn Guo
  2014-09-26 10:10     ` Lucas Stach
  0 siblings, 1 reply; 10+ messages in thread
From: Shawn Guo @ 2014-09-26  2:59 UTC (permalink / raw)
  To: Lucas Stach
  Cc: Viresh Kumar, Rafael J. Wysocki, linux-arm-kernel, linux-pm,
	kernel

On Fri, Sep 19, 2014 at 06:16:19PM +0200, Lucas Stach wrote:
> From: Lucas Stach <dev@lynxeye.de>
> 
> This implements a virtual clock used to abstract away
> all the steps needed in order to change the ARM clock,
> so we don't have to push all this clock handling into
> the cpufreq driver.
> 
> While it will be used for i.MX53 at first it is generic
> enough to be used on i.MX6 later on.
> 
> Signed-off-by: Lucas Stach <dev@lynxeye.de>

Is this intentional to use a different email address than your usual
one?

> ---
>  arch/arm/mach-imx/Makefile  |   2 +-
>  arch/arm/mach-imx/clk-cpu.c | 104 ++++++++++++++++++++++++++++++++++++++++++++
>  arch/arm/mach-imx/clk.h     |   4 ++
>  3 files changed, 109 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/mach-imx/clk-cpu.c
> 
> diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> index ac88599ca080..4d6071351f4f 100644
> --- a/arch/arm/mach-imx/Makefile
> +++ b/arch/arm/mach-imx/Makefile
> @@ -12,7 +12,7 @@ obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-
>  obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o
>  
>  imx5-pm-$(CONFIG_PM) += pm-imx5.o
> -obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o $(imx5-pm-y)
> +obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o clk-cpu.o $(imx5-pm-y)
>  
>  obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \
>  			    clk-pfd.o clk-busy.o clk.o \
> diff --git a/arch/arm/mach-imx/clk-cpu.c b/arch/arm/mach-imx/clk-cpu.c
> new file mode 100644
> index 000000000000..ffba96228d3b
> --- /dev/null
> +++ b/arch/arm/mach-imx/clk-cpu.c
> @@ -0,0 +1,104 @@
> +/*
> + * Copyright (c) 2014 Lucas Stach <l.stach@pengutronix.de>, Pengutronix
> + *
> + * The code contained herein is licensed under the GNU General Public
> + * License. You may obtain a copy of the GNU General Public License
> + * Version 2 or later at the following locations:
> + *
> + * http://www.opensource.org/licenses/gpl-license.html
> + * http://www.gnu.org/copyleft/gpl.html
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clk-provider.h>
> +#include <linux/slab.h>
> +
> +struct clk_cpu {
> +	struct clk_hw	hw;
> +	struct clk	*div, *mux, *pll, *step;

This is personal taste, so I'm not strong on this.  But I feel having
them on multiple lines makes the later addition/removal of struct clk
pointers a bit easier.

Other than these trivial comments, the patch looks good to me.

Shawn

> +};

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

* Re: [PATCH 5/5] ARM: imx53: add cpufreq support
  2014-09-19 16:16 ` [PATCH 5/5] ARM: imx53: add cpufreq support Lucas Stach
@ 2014-09-26  3:02   ` Shawn Guo
  0 siblings, 0 replies; 10+ messages in thread
From: Shawn Guo @ 2014-09-26  3:02 UTC (permalink / raw)
  To: Lucas Stach
  Cc: Viresh Kumar, Rafael J. Wysocki, kernel, linux-arm-kernel,
	linux-pm

On Fri, Sep 19, 2014 at 06:16:21PM +0200, Lucas Stach wrote:
> Instanciate the platform device for the generic cpufreq-cpu0
> driver and add all required properties to the DT.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  arch/arm/boot/dts/imx53.dtsi   | 13 ++++++++++++-
>  arch/arm/mach-imx/mach-imx53.c |  4 ++++

Please split dts and kernel changes.

>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
> index 64fa27b36be0..bd5226a7ea20 100644
> --- a/arch/arm/boot/dts/imx53.dtsi
> +++ b/arch/arm/boot/dts/imx53.dtsi
> @@ -46,10 +46,21 @@
>  	cpus {
>  		#address-cells = <1>;
>  		#size-cells = <0>;
> -		cpu@0 {
> +		cpu0: cpu@0 {
>  			device_type = "cpu";
>  			compatible = "arm,cortex-a8";
>  			reg = <0x0>;
> +			clocks = <&clks IMX5_CLK_ARM>;
> +			clock-latency = <61036>;
> +			voltage-tolerance = <5>;
> +			operating-points = <
> +				/* kHz */
> +				 166666  850000
> +				 400000  900000
> +				 800000 1050000
> +				1000000 1200000
> +				1200000 1300000
> +			>;
>  		};
>  	};
>  
> diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c
> index 03dd6ea13acc..4eb6849c52d2 100644
> --- a/arch/arm/mach-imx/mach-imx53.c
> +++ b/arch/arm/mach-imx/mach-imx53.c
> @@ -38,9 +38,13 @@ static void __init imx53_dt_init(void)
>  	imx_aips_allow_unprivileged_access("fsl,imx53-aipstz");
>  }
>  
> +static struct platform_device imx53_cpufreq_pdev = { .name = "cpufreq-cpu0", };
> +
>  static void __init imx53_init_late(void)
>  {
>  	imx53_pm_init();
> +
> +	platform_device_register(&imx53_cpufreq_pdev);

It should be a bit easier to call the following.

	platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);

Shawn

>  }
>  
>  static const char * const imx53_dt_board_compat[] __initconst = {
> -- 
> 2.1.0
> 

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

* Re: [PATCH 3/5] clk: imx: add CPU clock type
  2014-09-26  2:59   ` Shawn Guo
@ 2014-09-26 10:10     ` Lucas Stach
  0 siblings, 0 replies; 10+ messages in thread
From: Lucas Stach @ 2014-09-26 10:10 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Viresh Kumar, Rafael J. Wysocki, kernel, linux-arm-kernel,
	linux-pm

Am Freitag, den 26.09.2014, 10:59 +0800 schrieb Shawn Guo:
> On Fri, Sep 19, 2014 at 06:16:19PM +0200, Lucas Stach wrote:
> > From: Lucas Stach <dev@lynxeye.de>
> > 
> > This implements a virtual clock used to abstract away
> > all the steps needed in order to change the ARM clock,
> > so we don't have to push all this clock handling into
> > the cpufreq driver.
> > 
> > While it will be used for i.MX53 at first it is generic
> > enough to be used on i.MX6 later on.
> > 
> > Signed-off-by: Lucas Stach <dev@lynxeye.de>
> 
> Is this intentional to use a different email address than your usual
> one?

Urgh no. That's a remnant from starting this code at home without
setting the proper git environment. Thanks for the hint.

> 
> > ---
> >  arch/arm/mach-imx/Makefile  |   2 +-
> >  arch/arm/mach-imx/clk-cpu.c | 104 ++++++++++++++++++++++++++++++++++++++++++++
> >  arch/arm/mach-imx/clk.h     |   4 ++
> >  3 files changed, 109 insertions(+), 1 deletion(-)
> >  create mode 100644 arch/arm/mach-imx/clk-cpu.c
> > 
> > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> > index ac88599ca080..4d6071351f4f 100644
> > --- a/arch/arm/mach-imx/Makefile
> > +++ b/arch/arm/mach-imx/Makefile
> > @@ -12,7 +12,7 @@ obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-
> >  obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o
> >  
> >  imx5-pm-$(CONFIG_PM) += pm-imx5.o
> > -obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o $(imx5-pm-y)
> > +obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o clk-cpu.o $(imx5-pm-y)
> >  
> >  obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \
> >  			    clk-pfd.o clk-busy.o clk.o \
> > diff --git a/arch/arm/mach-imx/clk-cpu.c b/arch/arm/mach-imx/clk-cpu.c
> > new file mode 100644
> > index 000000000000..ffba96228d3b
> > --- /dev/null
> > +++ b/arch/arm/mach-imx/clk-cpu.c
> > @@ -0,0 +1,104 @@
> > +/*
> > + * Copyright (c) 2014 Lucas Stach <l.stach@pengutronix.de>, Pengutronix
> > + *
> > + * The code contained herein is licensed under the GNU General Public
> > + * License. You may obtain a copy of the GNU General Public License
> > + * Version 2 or later at the following locations:
> > + *
> > + * http://www.opensource.org/licenses/gpl-license.html
> > + * http://www.gnu.org/copyleft/gpl.html
> > + */
> > +
> > +#include <linux/clk.h>
> > +#include <linux/clk-provider.h>
> > +#include <linux/slab.h>
> > +
> > +struct clk_cpu {
> > +	struct clk_hw	hw;
> > +	struct clk	*div, *mux, *pll, *step;
> 
> This is personal taste, so I'm not strong on this.  But I feel having
> them on multiple lines makes the later addition/removal of struct clk
> pointers a bit easier.
> 
> Other than these trivial comments, the patch looks good to me.
> 
> Shawn
> 
> > +};
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2014-09-26 10:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-19 16:16 [PATCH 0/5] i.MX53 cpufreq support Lucas Stach
2014-09-19 16:16 ` [PATCH 1/5] cpufreq: cpu0: disable unsupported OPPs Lucas Stach
2014-09-19 16:49   ` Viresh Kumar
2014-09-19 16:16 ` [PATCH 2/5] clk: imx5: add step clock, used when reprogramming PLL1 Lucas Stach
2014-09-19 16:16 ` [PATCH 3/5] clk: imx: add CPU clock type Lucas Stach
2014-09-26  2:59   ` Shawn Guo
2014-09-26 10:10     ` Lucas Stach
2014-09-19 16:16 ` [PATCH 4/5] arm: imx53: clk: add ARM clock Lucas Stach
2014-09-19 16:16 ` [PATCH 5/5] ARM: imx53: add cpufreq support Lucas Stach
2014-09-26  3:02   ` Shawn Guo

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).