Skip to contentSkip to conversation

ARM: clps711x: Add cpuidle driver

PATCH New Alexander Shiyan 2 participants 8 messages Mar 22, 2014 – Mar 26, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: clps711x: Add cpuidle driver

Add cpuidle support for ARM Cirrus Logic CLPS711X CPUs. This CPU has an unique internal register and write to this location will put the system into the Idle State by halting the clock to the processor until an interrupt is generated.

---
 drivers/cpuidle/Kconfig.arm        |  6 ++++
 drivers/cpuidle/Makefile           |  1 +
 drivers/cpuidle/cpuidle-clps711x.c | 64 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 drivers/cpuidle/cpuidle-clps711x.c
drivers/cpuidle/Kconfig.arm +6 -0
index 97ccc31..371e75d 100644
@@ -13,6 +13,12 @@ config ARM_BIG_LITTLE_CPUIDLE
 	  define different C-states for little and big cores through the
 	  multiple CPU idle drivers infrastructure.
 
+config ARM_CLPS711X_CPUIDLE
+	bool "CPU Idle Driver for CLPS711X processors"
+	depends on ARCH_CLPS711X || COMPILE_TEST
+	help
+	  Select this to enable cpuidle on Cirrus Logic CLPS711X SOCs.
+
 config ARM_HIGHBANK_CPUIDLE
 	bool "CPU Idle Driver for Calxeda processors"
 	depends on ARM_PSCI
drivers/cpuidle/Makefile +1 -0
index f71ae1b..534fff5 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
 ##################################################################################
 # ARM SoC drivers
 obj-$(CONFIG_ARM_BIG_LITTLE_CPUIDLE)	+= cpuidle-big_little.o
+obj-$(CONFIG_ARM_CLPS711X_CPUIDLE)	+= cpuidle-clps711x.o
 obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE)	+= cpuidle-calxeda.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE)	+= cpuidle-kirkwood.o
 obj-$(CONFIG_ARM_ZYNQ_CPUIDLE)		+= cpuidle-zynq.o
drivers/cpuidle/cpuidle-clps711x.c new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 2/2 ARM: clps711x: Switch CLPS711X subarch to use cpuidle driver

This patch removes old support for cpuidle and switches all current users to use new cpuidle driver.

---
 arch/arm/mach-clps711x/board-autcpu12.c |  1 -
 arch/arm/mach-clps711x/board-cdb89712.c |  1 -
 arch/arm/mach-clps711x/board-clep7312.c |  1 -
 arch/arm/mach-clps711x/board-edb7211.c  |  1 -
 arch/arm/mach-clps711x/board-p720t.c    |  1 -
 arch/arm/mach-clps711x/common.c         | 12 ------------
 arch/arm/mach-clps711x/common.h         |  1 -
 arch/arm/mach-clps711x/devices.c        | 10 ++++++++++
 8 files changed, 10 insertions(+), 18 deletions(-)
arch/arm/mach-clps711x/board-autcpu12.c +0 -1
index d62ca16..45abf6b 100644
@@ -266,7 +266,6 @@ MACHINE_START(AUTCPU12, "autronix autcpu12")
 	/* Maintainer: Thomas Gleixner */
 	.atag_offset	= 0x20000,
 	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
 	.init_irq	= clps711x_init_irq,
 	.init_time	= clps711x_timer_init,
 	.init_machine	= autcpu12_init,
arch/arm/mach-clps711x/board-cdb89712.c +0 -1
index e261a47..1ec378c 100644
@@ -140,7 +140,6 @@ MACHINE_START(CDB89712, "Cirrus-CDB89712")
 	/* Maintainer: Ray Lehtiniemi */
 	.atag_offset	= 0x100,
 	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
 	.init_irq	= clps711x_init_irq,
 	.init_time	= clps711x_timer_init,
 	.init_machine	= cdb89712_init,
arch/arm/mach-clps711x/board-clep7312.c +0 -1
index 221b9de..1f3b403 100644
@@ -38,7 +38,6 @@ MACHINE_START(CLEP7212, "Cirrus Logic 7212/7312")
 	.atag_offset	= 0x0100,
 	.fixup		= fixup_clep7312,
 	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
 	.init_irq	= clps711x_init_irq,
 	.init_time	= clps711x_timer_init,
 	.restart	= clps711x_restart,
arch/arm/mach-clps711x/board-edb7211.c +0 -1
index 0776098..fa4580f 100644
@@ -180,7 +180,6 @@ MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
 	.fixup		= fixup_edb7211,
 	.reserve	= edb7211_reserve,
 	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
 	.init_irq	= clps711x_init_irq,
 	.init_time	= clps711x_timer_init,
 	.init_machine	= edb7211_init,
arch/arm/mach-clps711x/board-p720t.c +0 -1
index 67b7337..4a2ec28 100644
@@ -365,7 +365,6 @@ MACHINE_START(P720T, "ARM-Prospector720T")
 	.atag_offset	= 0x100,
 	.fixup		= fixup_p720t,
 	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
 	.init_irq	= clps711x_init_irq,
 	.init_time	= clps711x_timer_init,
 	.init_machine	= p720t_init,
arch/arm/mach-clps711x/common.c +0 -12
index aee81fa..2a6323b 100644
@@ -193,15 +193,3 @@ void clps711x_restart(enum reboot_mode mode, const char *cmd)
 {
 	soft_restart(0);
 }
-
-static void clps711x_idle(void)
-{
-	clps_writel(1, HALT);
-	asm("mov r0, r0");
-	asm("mov r0, r0");
-}
-
-void __init clps711x_init_early(void)
-{
-	arm_pm_idle = clps711x_idle;
-}
arch/arm/mach-clps711x/common.h +0 -1
index 7489139..f881899 100644
@@ -13,7 +13,6 @@ extern void clps711x_map_io(void);
 extern void clps711x_init_irq(void);
 extern void clps711x_timer_init(void);
 extern void clps711x_restart(enum reboot_mode mode, const char *cmd);
-extern void clps711x_init_early(void);
 
 /* drivers/irqchip/irq-clps711x.c */
 void clps711x_intc_init(phys_addr_t, resource_size_t);
arch/arm/mach-clps711x/devices.c +10 -0
index 2001488..0c689d3 100644
@@ -14,6 +14,15 @@
 
 #include <mach/hardware.h>
 
+static const struct resource clps711x_cpuidle_res __initconst =
+	DEFINE_RES_MEM(CLPS711X_PHYS_BASE + HALT, SZ_128);
+
+static void __init clps711x_add_cpuidle(void)
+{
+	platform_device_register_simple("clps711x-cpuidle", PLATFORM_DEVID_NONE,
+					&clps711x_cpuidle_res, 1);
+}
+
 static const phys_addr_t clps711x_gpios[][2] __initconst = {
 	{ PADR, PADDR },
 	{ PBDR, PBDDR },
@@ -83,6 +92,7 @@ static void __init clps711x_add_uart(void)
 
 void __init clps711x_devices_init(void)
 {
+	clps711x_add_cpuidle();
 	clps711x_add_gpio();
 	clps711x_add_syscon();
 	clps711x_add_uart();
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 2/2 ARM: clps711x: Switch CLPS711X subarch to use cpuidle driver

Quoted 4 lines · Alexander Shiyan

This patch removes old support for cpuidle and switches all current users to use new cpuidle driver.

Hi Alexander,

this patch does not apply. Could you respin it against 3.14-rc8.

Thanks
-- Daniel

Quoted 132 lines
---
  arch/arm/mach-clps711x/board-autcpu12.c |  1 -
  arch/arm/mach-clps711x/board-cdb89712.c |  1 -
  arch/arm/mach-clps711x/board-clep7312.c |  1 -
  arch/arm/mach-clps711x/board-edb7211.c  |  1 -
  arch/arm/mach-clps711x/board-p720t.c    |  1 -
  arch/arm/mach-clps711x/common.c         | 12 ------------
  arch/arm/mach-clps711x/common.h         |  1 -
  arch/arm/mach-clps711x/devices.c        | 10 ++++++++++
  8 files changed, 10 insertions(+), 18 deletions(-)
arch/arm/mach-clps711x/board-autcpu12.c +0 -1
index d62ca16..45abf6b 100644
@@ -266,7 +266,6 @@ MACHINE_START(AUTCPU12, "autronix autcpu12")
  	/* Maintainer: Thomas Gleixner */
  	.atag_offset	= 0x20000,
  	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
  	.init_irq	= clps711x_init_irq,
  	.init_time	= clps711x_timer_init,
  	.init_machine	= autcpu12_init,
arch/arm/mach-clps711x/board-cdb89712.c +0 -1
index e261a47..1ec378c 100644
@@ -140,7 +140,6 @@ MACHINE_START(CDB89712, "Cirrus-CDB89712")
  	/* Maintainer: Ray Lehtiniemi */
  	.atag_offset	= 0x100,
  	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
  	.init_irq	= clps711x_init_irq,
  	.init_time	= clps711x_timer_init,
  	.init_machine	= cdb89712_init,
arch/arm/mach-clps711x/board-clep7312.c +0 -1
index 221b9de..1f3b403 100644
@@ -38,7 +38,6 @@ MACHINE_START(CLEP7212, "Cirrus Logic 7212/7312")
  	.atag_offset	= 0x0100,
  	.fixup		= fixup_clep7312,
  	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
  	.init_irq	= clps711x_init_irq,
  	.init_time	= clps711x_timer_init,
  	.restart	= clps711x_restart,
arch/arm/mach-clps711x/board-edb7211.c +0 -1
index 0776098..fa4580f 100644
@@ -180,7 +180,6 @@ MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
  	.fixup		= fixup_edb7211,
  	.reserve	= edb7211_reserve,
  	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
  	.init_irq	= clps711x_init_irq,
  	.init_time	= clps711x_timer_init,
  	.init_machine	= edb7211_init,
arch/arm/mach-clps711x/board-p720t.c +0 -1
index 67b7337..4a2ec28 100644
@@ -365,7 +365,6 @@ MACHINE_START(P720T, "ARM-Prospector720T")
  	.atag_offset	= 0x100,
  	.fixup		= fixup_p720t,
  	.map_io		= clps711x_map_io,
-	.init_early	= clps711x_init_early,
  	.init_irq	= clps711x_init_irq,
  	.init_time	= clps711x_timer_init,
  	.init_machine	= p720t_init,
arch/arm/mach-clps711x/common.c +0 -12
index aee81fa..2a6323b 100644
@@ -193,15 +193,3 @@ void clps711x_restart(enum reboot_mode mode, const char *cmd)
  {
  	soft_restart(0);
  }
-
-static void clps711x_idle(void)
-{
-	clps_writel(1, HALT);
-	asm("mov r0, r0");
-	asm("mov r0, r0");
-}
-
-void __init clps711x_init_early(void)
-{
-	arm_pm_idle = clps711x_idle;
-}
arch/arm/mach-clps711x/common.h +0 -1
index 7489139..f881899 100644
@@ -13,7 +13,6 @@ extern void clps711x_map_io(void);
  extern void clps711x_init_irq(void);
  extern void clps711x_timer_init(void);
  extern void clps711x_restart(enum reboot_mode mode, const char *cmd);
-extern void clps711x_init_early(void);
 
  /* drivers/irqchip/irq-clps711x.c */
  void clps711x_intc_init(phys_addr_t, resource_size_t);
arch/arm/mach-clps711x/devices.c +10 -0
index 2001488..0c689d3 100644
@@ -14,6 +14,15 @@
 
  #include <mach/hardware.h>
 
+static const struct resource clps711x_cpuidle_res __initconst =
+	DEFINE_RES_MEM(CLPS711X_PHYS_BASE + HALT, SZ_128);
+
+static void __init clps711x_add_cpuidle(void)
+{
+	platform_device_register_simple("clps711x-cpuidle", PLATFORM_DEVID_NONE,
+					&clps711x_cpuidle_res, 1);
+}
+
  static const phys_addr_t clps711x_gpios[][2] __initconst = {
  	{ PADR, PADDR },
  	{ PBDR, PBDDR },
@@ -83,6 +92,7 @@ static void __init clps711x_add_uart(void)
 
  void __init clps711x_devices_init(void)
  {
+	clps711x_add_cpuidle();
  	clps711x_add_gpio();
  	clps711x_add_syscon();
  	clps711x_add_uart();
Signature · 5 lines
  <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#3 lore raw

Re: [PATCH 2/2] ARM: clps711x: Switch CLPS711X subarch to use cpuidle driver

Wed, 26 Mar 2014 12:03:16 +0100 ?? Daniel Lezcano <[email protected]>:

Quoted 9 lines · Alexander Shiyan
Quoted 4 lines

This patch removes old support for cpuidle and switches all current users to use new cpuidle driver.

Hi Alexander,

this patch does not apply. Could you respin it against 3.14-rc8.

This part (2/2) can be applied later, I can resend this one part through arm-soc tree.

---

#4 lore raw

PATCH 2/2 ARM: clps711x: Switch CLPS711X subarch to use cpuidle driver

Quoted 5 lines · Alexander Shiyan

Wed, 26 Mar 2014 12:03:16 +0100 от Daniel Lezcano <[email protected]>:

Quoted 4 lines · Alexander Shiyan
Quoted 3 lines

This patch removes old support for cpuidle and switches all current users to use new cpuidle driver.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Hi Alexander,

this patch does not apply. Could you respin it against 3.14-rc8.

This part (2/2) can be applied later, I can resend this one part through arm-soc tree.

Ok, I applied the patch 1/2 for 3.16 on my tree.

Thanks

-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#5 lore raw

PATCH 1/2 ARM: clps711x: Add cpuidle driver

In reply to Alexander Shiyan
Quoted 75 lines · Alexander Shiyan

Add cpuidle support for ARM Cirrus Logic CLPS711X CPUs. This CPU has an unique internal register and write to this location will put the system into the Idle State by halting the clock to the processor until an interrupt is generated.

---
  drivers/cpuidle/Kconfig.arm        |  6 ++++
  drivers/cpuidle/Makefile           |  1 +
  drivers/cpuidle/cpuidle-clps711x.c | 64 ++++++++++++++++++++++++++++++++++++++
  3 files changed, 71 insertions(+)

create mode 100644 drivers/cpuidle/cpuidle-clps711x.c

drivers/cpuidle/Kconfig.arm +6 -0
index 97ccc31..371e75d 100644
@@ -13,6 +13,12 @@ config ARM_BIG_LITTLE_CPUIDLE
  	  define different C-states for little and big cores through the
  	  multiple CPU idle drivers infrastructure.
 
+config ARM_CLPS711X_CPUIDLE
+	bool "CPU Idle Driver for CLPS711X processors"
+	depends on ARCH_CLPS711X || COMPILE_TEST
+	help
+	  Select this to enable cpuidle on Cirrus Logic CLPS711X SOCs.
+
  config ARM_HIGHBANK_CPUIDLE
  	bool "CPU Idle Driver for Calxeda processors"
  	depends on ARM_PSCI
drivers/cpuidle/Makefile +1 -0
index f71ae1b..534fff5 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
  ##################################################################################
  # ARM SoC drivers
  obj-$(CONFIG_ARM_BIG_LITTLE_CPUIDLE)	+= cpuidle-big_little.o
+obj-$(CONFIG_ARM_CLPS711X_CPUIDLE)	+= cpuidle-clps711x.o
  obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE)	+= cpuidle-calxeda.o
  obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE)	+= cpuidle-kirkwood.o
  obj-$(CONFIG_ARM_ZYNQ_CPUIDLE)		+= cpuidle-zynq.o
drivers/cpuidle/cpuidle-clps711x.c new file +27 -0
new file mode 100644
index 0000000..5243811
@@ -0,0 +1,64 @@
+/*
+ *  CLPS711X CPU idle driver
+ *
+ *  Copyright (C) 2014 Alexander Shiyan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/cpuidle.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#define CLPS711X_CPUIDLE_NAME	"clps711x-cpuidle"
+
+static void __iomem *clps711x_halt;
+
+static int clps711x_cpuidle_halt(struct cpuidle_device *dev,
+				 struct cpuidle_driver *drv, int index)
+{
+	writel(0xaa, clps711x_halt);
+
+	return index;

drivers/cpuidle/cpuidle-clps711x.c line 37

Quoted 10 lines
drivers/cpuidle/cpuidle-clps711x.c new file +10 -0
+}
+
+static struct cpuidle_driver clps711x_idle_driver = {
+	.name		= CLPS711X_CPUIDLE_NAME,
+	.owner		= THIS_MODULE,
+	.states[0]	= {
+		.name		= "HALT",
+		.desc		= "CLPS711X HALT",
+		.enter		= clps711x_cpuidle_halt,
+		.exit_latency	= 1,

Did you forget target_residency ? Or just not defined it as it is 0 ?

Quoted 28 lines
drivers/cpuidle/cpuidle-clps711x.c new file +27 -0
+	},
+	.state_count	= 1,
+};
+
+static int __init clps711x_cpuidle_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	clps711x_halt = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(clps711x_halt))
+		return PTR_ERR(clps711x_halt);
+
+	return cpuidle_register(&clps711x_idle_driver, NULL);
+}
+
+static struct platform_driver clps711x_cpuidle_driver = {
+	.driver	= {
+		.name	= CLPS711X_CPUIDLE_NAME,
+		.owner	= THIS_MODULE,
+	},
+};
+module_platform_driver_probe(clps711x_cpuidle_driver, clps711x_cpuidle_probe);
+
+MODULE_AUTHOR("Alexander Shiyan <[email protected]>");
+MODULE_DESCRIPTION("CLPS711X CPU idle driver");
+MODULE_LICENSE("GPL");
Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#6 lore raw

Mon, 24 Mar 2014 16:34:44 +0100 ?? Daniel Lezcano <[email protected]>:

Quoted 8 lines · Alexander Shiyan
Quoted 7 lines

Add cpuidle support for ARM Cirrus Logic CLPS711X CPUs. This CPU has an unique internal register and write to this location will put the system into the Idle State by halting the clock to the processor until an interrupt is generated.

---

...

Quoted 10 lines

drivers/cpuidle/cpuidle-clps711x.c line 37

Quoted 8 lines
drivers/cpuidle/cpuidle-clps711x.c new file +8 -0
+static struct cpuidle_driver clps711x_idle_driver = {
+	.name		= CLPS711X_CPUIDLE_NAME,
+	.owner		= THIS_MODULE,
+	.states[0]	= {
+		.name		= "HALT",
+		.desc		= "CLPS711X HALT",
+		.enter		= clps711x_cpuidle_halt,
+		.exit_latency	= 1,

Did you forget target_residency ? Or just not defined it as it is 0 ?

Yes, zero value.

---

#7 lore raw

PATCH 1/2 ARM: clps711x: Add cpuidle driver

Quoted 21 lines · Alexander Shiyan

Mon, 24 Mar 2014 16:34:44 +0100 от Daniel Lezcano <[email protected]>:

Quoted 8 lines · Alexander Shiyan
Quoted 7 lines

Add cpuidle support for ARM Cirrus Logic CLPS711X CPUs. This CPU has an unique internal register and write to this location will put the system into the Idle State by halting the clock to the processor until an interrupt is generated.

---

...

Quoted 10 lines

drivers/cpuidle/cpuidle-clps711x.c line 37

Quoted 8 lines
drivers/cpuidle/cpuidle-clps711x.c new file +8 -0
+static struct cpuidle_driver clps711x_idle_driver = {
+	.name		= CLPS711X_CPUIDLE_NAME,
+	.owner		= THIS_MODULE,
+	.states[0]	= {
+		.name		= "HALT",
+		.desc		= "CLPS711X HALT",
+		.enter		= clps711x_cpuidle_halt,
+		.exit_latency	= 1,

Did you forget target_residency ? Or just not defined it as it is 0 ?

Quoted 1 line

Yes, zero value.

Ok, thanks. The driver looks good. I will pick it for 3.16.

Thanks
-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog