[RFC PATCH v5 1/1] drivers: mfd: vexpress: add Serial Power Controller (SPC) support

2013-07-16 Thread Lorenzo Pieralisi
The TC2 versatile express core tile integrates a logic block that provides the
interface between the dual cluster test-chip and the M3 microcontroller that
carries out power management. The logic block, called Serial Power Controller
(SPC), contains several memory mapped registers to control among other things
low-power states, wake-up irqs and per-CPU jump addresses registers.

This patch provides a driver that enables run-time control of features
implemented by the SPC power management control logic.

The SPC control logic is required to be programmed very early in the boot
process to reset secondary CPUs on the TC2 testchip, set-up jump addresses and
wake-up IRQs for power management. Hence, waiting for core changes to be
made in the device core code to enable early registration of platform
devices, the driver puts in place an early init scheme that allows kernel
drivers to initialize the SPC driver directly from the components requiring
it, if their initialization routine is called before the driver init
function by the boot process.

Device tree bindings documentation for the SPC component is provided with
the patchset.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Olof Johansson o...@lixom.net
Cc: Pawel Moll pawel.m...@arm.com
Cc: Amit Kucheria amit.kuche...@linaro.org
Cc: Jon Medhurst t...@linaro.org
Signed-off-by: Achin Gupta achin.gu...@arm.com
Signed-off-by: Lorenzo Pieralisi lorenzo.pieral...@arm.com
Signed-off-by: Sudeep KarkadaNagesha sudeep.karkadanage...@arm.com
---
 Documentation/devicetree/bindings/mfd/vexpress-spc.txt |  36 ++
 drivers/mfd/Kconfig|  10 +
 drivers/mfd/Makefile   |   1 +
 drivers/mfd/vexpress-spc.c | 253 ++
 include/linux/vexpress.h   |  17 +
 5 files changed, 317 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/vexpress-spc.txt 
b/Documentation/devicetree/bindings/mfd/vexpress-spc.txt
new file mode 100644
index 000..1614725
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/vexpress-spc.txt
@@ -0,0 +1,36 @@
+* ARM Versatile Express Serial Power Controller device tree bindings
+
+Latest ARM development boards implement a power management interface (serial
+power controller - SPC) that is capable of managing power states transitions,
+wake-up IRQs and resume addresses for ARM multiprocessor testchips.
+The serial controller can be programmed through a memory mapped interface
+that enables communication between firmware running on the microcontroller
+managing power states and the application processors.
+
+The SPC DT bindings are defined as follows:
+
+- spc node
+
+   - compatible:
+   Usage: required
+   Value type: stringlist
+   Definition: must be
+   arm,vexpress-spc,v2p-ca15_a7, arm,vexpress-spc
+   - reg:
+   Usage: required
+   Value type: prop-encode-array
+   Definition: A standard property that specifies the base address
+   and the size of the SPC address space
+   - interrupts:
+   Usage: required
+   Value type: prop-encoded-array
+   Definition:  SPC interrupt configuration. A standard property
+that follows ePAPR interrupts specifications
+
+Example:
+
+spc: spc@7fff {
+   compatible = arm,vexpress-spc,v2p-ca15_a7, arm,vexpress-spc;
+   reg = 0x7fff 0x1000;
+   interrupts = 0 95 4;
+};
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6959b8d..ebd23f4 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1149,3 +1149,13 @@ config VEXPRESS_CONFIG
help
  Platform configuration infrastructure for the ARM Ltd.
  Versatile Express.
+
+config VEXPRESS_SPC
+   bool Versatile Express SPC driver support
+   depends on ARM
+   help
+ The Serial Power Controller (SPC) for ARM Ltd. test chips, is
+ an IP that provides a memory mapped interface to power controller
+ HW. The driver provides an API abstraction allowing to program
+ registers controlling low-level power management features like power
+ down flags, global and per-cpu wake-up IRQs.
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 718e94a..3a01203 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -153,5 +153,6 @@ obj-$(CONFIG_MFD_SEC_CORE)  += sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_SYSCON)   += syscon.o
 obj-$(CONFIG_MFD_LM3533)   += lm3533-core.o lm3533-ctrlbank.o
 obj-$(CONFIG_VEXPRESS_CONFIG)  += vexpress-config.o vexpress-sysreg.o
+obj-$(CONFIG_VEXPRESS_SPC) += vexpress-spc.o
 obj-$(CONFIG_MFD_RETU) += retu-mfd.o
 obj-$(CONFIG_MFD_AS3711)   += as3711.o
diff --git a/drivers/mfd/vexpress-spc.c b/drivers/mfd/vexpress-spc.c
new file mode 100644
index 000..aa8c2a4
--- /dev/null
+++ 

Re: [RFC PATCH v5 1/1] drivers: mfd: vexpress: add Serial Power Controller (SPC) support

2013-07-16 Thread Rob Herring
On 07/16/2013 11:05 AM, Lorenzo Pieralisi wrote:
 The TC2 versatile express core tile integrates a logic block that provides the
 interface between the dual cluster test-chip and the M3 microcontroller that
 carries out power management. The logic block, called Serial Power Controller
 (SPC), contains several memory mapped registers to control among other things
 low-power states, wake-up irqs and per-CPU jump addresses registers.
 
 This patch provides a driver that enables run-time control of features
 implemented by the SPC power management control logic.
 
 The SPC control logic is required to be programmed very early in the boot
 process to reset secondary CPUs on the TC2 testchip, set-up jump addresses and
 wake-up IRQs for power management. Hence, waiting for core changes to be
 made in the device core code to enable early registration of platform
 devices, the driver puts in place an early init scheme that allows kernel
 drivers to initialize the SPC driver directly from the components requiring
 it, if their initialization routine is called before the driver init
 function by the boot process.
 
 Device tree bindings documentation for the SPC component is provided with
 the patchset.

Just curious, wouldn't a TC2 PSCI implementation eliminate the need for
most/all of this code?

Rob

 
 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Olof Johansson o...@lixom.net
 Cc: Pawel Moll pawel.m...@arm.com
 Cc: Amit Kucheria amit.kuche...@linaro.org
 Cc: Jon Medhurst t...@linaro.org
 Signed-off-by: Achin Gupta achin.gu...@arm.com
 Signed-off-by: Lorenzo Pieralisi lorenzo.pieral...@arm.com
 Signed-off-by: Sudeep KarkadaNagesha sudeep.karkadanage...@arm.com
 ---
  Documentation/devicetree/bindings/mfd/vexpress-spc.txt |  36 ++
  drivers/mfd/Kconfig|  10 +
  drivers/mfd/Makefile   |   1 +
  drivers/mfd/vexpress-spc.c | 253 ++
  include/linux/vexpress.h   |  17 +
  5 files changed, 317 insertions(+)
 
 diff --git a/Documentation/devicetree/bindings/mfd/vexpress-spc.txt 
 b/Documentation/devicetree/bindings/mfd/vexpress-spc.txt
 new file mode 100644
 index 000..1614725
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/vexpress-spc.txt
 @@ -0,0 +1,36 @@
 +* ARM Versatile Express Serial Power Controller device tree bindings
 +
 +Latest ARM development boards implement a power management interface (serial
 +power controller - SPC) that is capable of managing power states transitions,
 +wake-up IRQs and resume addresses for ARM multiprocessor testchips.
 +The serial controller can be programmed through a memory mapped interface
 +that enables communication between firmware running on the microcontroller
 +managing power states and the application processors.
 +
 +The SPC DT bindings are defined as follows:
 +
 +- spc node
 +
 + - compatible:
 + Usage: required
 + Value type: stringlist
 + Definition: must be
 + arm,vexpress-spc,v2p-ca15_a7, arm,vexpress-spc
 + - reg:
 + Usage: required
 + Value type: prop-encode-array
 + Definition: A standard property that specifies the base address
 + and the size of the SPC address space
 + - interrupts:
 + Usage: required
 + Value type: prop-encoded-array
 + Definition:  SPC interrupt configuration. A standard property
 +  that follows ePAPR interrupts specifications
 +
 +Example:
 +
 +spc: spc@7fff {
 + compatible = arm,vexpress-spc,v2p-ca15_a7, arm,vexpress-spc;
 + reg = 0x7fff 0x1000;
 + interrupts = 0 95 4;
 +};
 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 6959b8d..ebd23f4 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -1149,3 +1149,13 @@ config VEXPRESS_CONFIG
   help
 Platform configuration infrastructure for the ARM Ltd.
 Versatile Express.
 +
 +config VEXPRESS_SPC
 + bool Versatile Express SPC driver support
 + depends on ARM
 + help
 +   The Serial Power Controller (SPC) for ARM Ltd. test chips, is
 +   an IP that provides a memory mapped interface to power controller
 +   HW. The driver provides an API abstraction allowing to program
 +   registers controlling low-level power management features like power
 +   down flags, global and per-cpu wake-up IRQs.
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 718e94a..3a01203 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -153,5 +153,6 @@ obj-$(CONFIG_MFD_SEC_CORE)+= sec-core.o sec-irq.o
  obj-$(CONFIG_MFD_SYSCON) += syscon.o
  obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o
  obj-$(CONFIG_VEXPRESS_CONFIG)+= vexpress-config.o vexpress-sysreg.o
 +obj-$(CONFIG_VEXPRESS_SPC)   += vexpress-spc.o
  obj-$(CONFIG_MFD_RETU)

Re: [RFC PATCH v5 1/1] drivers: mfd: vexpress: add Serial Power Controller (SPC) support

2013-07-16 Thread Nicolas Pitre
On Tue, 16 Jul 2013, Rob Herring wrote:

 On 07/16/2013 11:05 AM, Lorenzo Pieralisi wrote:
  The TC2 versatile express core tile integrates a logic block that provides 
  the
  interface between the dual cluster test-chip and the M3 microcontroller that
  carries out power management. The logic block, called Serial Power 
  Controller
  (SPC), contains several memory mapped registers to control among other 
  things
  low-power states, wake-up irqs and per-CPU jump addresses registers.
  
  This patch provides a driver that enables run-time control of features
  implemented by the SPC power management control logic.
  
  The SPC control logic is required to be programmed very early in the boot
  process to reset secondary CPUs on the TC2 testchip, set-up jump addresses 
  and
  wake-up IRQs for power management. Hence, waiting for core changes to be
  made in the device core code to enable early registration of platform
  devices, the driver puts in place an early init scheme that allows kernel
  drivers to initialize the SPC driver directly from the components requiring
  it, if their initialization routine is called before the driver init
  function by the boot process.
  
  Device tree bindings documentation for the SPC component is provided with
  the patchset.
 
 Just curious, wouldn't a TC2 PSCI implementation eliminate the need for
 most/all of this code?

There is a PSCI equivalent for the above already, in the sense that 
there is a simple MCPM backend that bypass most of the MCPM race 
avoidance code paths and simply calls into PSCI instead.  But not all 
the world is going to be PSCI, and therefore we need to ensure good 
support for non-PSCI platforms as well.

This is why TC2 supports both, and this also ensure that the PSCI 
implementation, which won't be part of the kernel and therefore unlikely 
to get the same level of scrutiny, is properly implemented and doesn't 
introduce any regression when compared to the non PSCI case.

Remember that TC2 is multi-cluster which means that the PSCI 
implementation has to carry the same amount of complexity as the whole 
in-kernel MCPM layer and that doesn't make me overly confident it is 
going to always be right.

All this to say that we do need this code despite PSCI availability.


Nicolas
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss