Re: [PATCH 1/2] OMAP PM: create a PM layer plugin for the devices wakeup latency constraints

2011-03-07 Thread Kevin Hilman
Jean Pihet jean.pi...@newoldbits.com writes:

 Created arch/arm/plat-omap/omap-pm-constraints.c file from
 arch/arm/plat-omap/omap-pm-noop.c and the associated Kconfig option
 OMAP_PM_CONSTRAINTS.

 Based on the original patch from Vishwanath,
 cf. https://patchwork.kernel.org/patch/327312/

 Cc: Vishwanath BS vishwanath...@ti.com

 Signed-off-by: Jean Pihet j-pi...@ti.com
 ---
 Based on khilman's pm-core branch

  arch/arm/plat-omap/Kconfig   |7 +
  arch/arm/plat-omap/Makefile  |1 +
  arch/arm/plat-omap/omap-pm-constraints.c |  363 
 ++
  3 files changed, 371 insertions(+), 0 deletions(-)
  create mode 100644 arch/arm/plat-omap/omap-pm-constraints.c

 diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
 index b6333ae..b8f51e3 100644
 --- a/arch/arm/plat-omap/Kconfig
 +++ b/arch/arm/plat-omap/Kconfig
 @@ -215,6 +215,13 @@ config OMAP_PM_NONE
  config OMAP_PM_NOOP
   bool No-op/debug PM layer
  
 +config OMAP_PM_CONSTRAINTS
 + depends on PM
 + bool OMAP PM layer implementation, devices wakeup latency constraints

Minor: The 'OMAP PM layer implmentatin' is redundant here as it's a sub-choice
of the OMAP PM layer menu.  How abou just per-device constraint

Kevin

 + help
 +   Select this option to enable the PM layer plugin for
 +   the devices wakeup latency constraints support
 +
  endchoice
  
  endmenu
 diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
 index a4a1285..a293367 100644
 --- a/arch/arm/plat-omap/Makefile
 +++ b/arch/arm/plat-omap/Makefile
 @@ -32,3 +32,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
  obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
  
  obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
 +obj-$(CONFIG_OMAP_PM_CONSTRAINTS) += omap-pm-constraints.o
 diff --git a/arch/arm/plat-omap/omap-pm-constraints.c 
 b/arch/arm/plat-omap/omap-pm-constraints.c
 new file mode 100644
 index 000..c8b4e4c
 --- /dev/null
 +++ b/arch/arm/plat-omap/omap-pm-constraints.c
 @@ -0,0 +1,363 @@
 +/*
 + * omap-pm.c - OMAP power management interface
 + *
 + * This code implements the OMAP power management interface to
 + * drivers, CPUIdle, CPUFreq, and DSP Bridge.
 + *
 + * Copyright (C) 2008-2009 Texas Instruments, Inc.
 + * Copyright (C) 2008-2009 Nokia Corporation
 + * Paul Walmsley
 + *
 + * Interface developed by (in alphabetical order):
 + * Karthik Dasu, Tony Lindgren, Jean Pihet, Rajendra Nayak, Sakari Poussa,
 + * Veeramanikandan Raju, Anand Sawant, Igor Stoppa, Paul Walmsley,
 + * Richard Woodruff
 + */
 +
 +#undef DEBUG
 +
 +#include linux/init.h
 +#include linux/cpufreq.h
 +#include linux/device.h
 +#include linux/platform_device.h
 +
 +/* Interface documentation is in mach/omap-pm.h */
 +#include plat/omap-pm.h
 +#include plat/omap_device.h
 +
 +static bool off_mode_enabled;
 +static u32 dummy_context_loss_counter;
 +
 +/*
 + * Device-driver-originated constraints (via board-*.c files)
 + */
 +
 +int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
 +{
 + if (!dev || t  -1) {
 + WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
 + return -EINVAL;
 + };
 +
 + if (t == -1)
 + pr_debug(OMAP PM: remove max MPU wakeup latency constraint: 
 +  dev %s\n, dev_name(dev));
 + else
 + pr_debug(OMAP PM: add max MPU wakeup latency constraint: 
 +  dev %s, t = %ld usec\n, dev_name(dev), t);
 +
 + /*
 +  * For current Linux, this needs to map the MPU to a
 +  * powerdomain, then go through the list of current max lat
 +  * constraints on the MPU and find the smallest.  If
 +  * the latency constraint has changed, the code should
 +  * recompute the state to enter for the next powerdomain
 +  * state.
 +  *
 +  * TI CDP code can call constraint_set here.
 +  */
 +
 + return 0;
 +}
 +
 +int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long 
 r)
 +{
 + if (!dev || (agent_id != OCP_INITIATOR_AGENT 
 + agent_id != OCP_TARGET_AGENT)) {
 + WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
 + return -EINVAL;
 + };
 +
 + if (r == 0)
 + pr_debug(OMAP PM: remove min bus tput constraint: 
 +  dev %s for agent_id %d\n, dev_name(dev), agent_id);
 + else
 + pr_debug(OMAP PM: add min bus tput constraint: 
 +  dev %s for agent_id %d: rate %ld KiB\n,
 +  dev_name(dev), agent_id, r);
 +
 + /*
 +  * This code should model the interconnect and compute the
 +  * required clock frequency, convert that to a VDD2 OPP ID, then
 +  * set the VDD2 OPP appropriately.
 +  *
 +  * TI CDP code can call constraint_set here on the VDD2 OPP.
 +  */
 +
 + return 0;
 +}
 +
 +int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device 
 *dev,
 +long 

[PATCH 1/2] OMAP PM: create a PM layer plugin for the devices wakeup latency constraints

2011-03-04 Thread Jean Pihet
Created arch/arm/plat-omap/omap-pm-constraints.c file from
arch/arm/plat-omap/omap-pm-noop.c and the associated Kconfig option
OMAP_PM_CONSTRAINTS.

Based on the original patch from Vishwanath,
cf. https://patchwork.kernel.org/patch/327312/

Cc: Vishwanath BS vishwanath...@ti.com

Signed-off-by: Jean Pihet j-pi...@ti.com
---
Based on khilman's pm-core branch

 arch/arm/plat-omap/Kconfig   |7 +
 arch/arm/plat-omap/Makefile  |1 +
 arch/arm/plat-omap/omap-pm-constraints.c |  363 ++
 3 files changed, 371 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/omap-pm-constraints.c

diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index b6333ae..b8f51e3 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -215,6 +215,13 @@ config OMAP_PM_NONE
 config OMAP_PM_NOOP
bool No-op/debug PM layer
 
+config OMAP_PM_CONSTRAINTS
+   depends on PM
+   bool OMAP PM layer implementation, devices wakeup latency constraints
+   help
+ Select this option to enable the PM layer plugin for
+ the devices wakeup latency constraints support
+
 endchoice
 
 endmenu
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index a4a1285..a293367 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -32,3 +32,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
 obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
 
 obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
+obj-$(CONFIG_OMAP_PM_CONSTRAINTS) += omap-pm-constraints.o
diff --git a/arch/arm/plat-omap/omap-pm-constraints.c 
b/arch/arm/plat-omap/omap-pm-constraints.c
new file mode 100644
index 000..c8b4e4c
--- /dev/null
+++ b/arch/arm/plat-omap/omap-pm-constraints.c
@@ -0,0 +1,363 @@
+/*
+ * omap-pm.c - OMAP power management interface
+ *
+ * This code implements the OMAP power management interface to
+ * drivers, CPUIdle, CPUFreq, and DSP Bridge.
+ *
+ * Copyright (C) 2008-2009 Texas Instruments, Inc.
+ * Copyright (C) 2008-2009 Nokia Corporation
+ * Paul Walmsley
+ *
+ * Interface developed by (in alphabetical order):
+ * Karthik Dasu, Tony Lindgren, Jean Pihet, Rajendra Nayak, Sakari Poussa,
+ * Veeramanikandan Raju, Anand Sawant, Igor Stoppa, Paul Walmsley,
+ * Richard Woodruff
+ */
+
+#undef DEBUG
+
+#include linux/init.h
+#include linux/cpufreq.h
+#include linux/device.h
+#include linux/platform_device.h
+
+/* Interface documentation is in mach/omap-pm.h */
+#include plat/omap-pm.h
+#include plat/omap_device.h
+
+static bool off_mode_enabled;
+static u32 dummy_context_loss_counter;
+
+/*
+ * Device-driver-originated constraints (via board-*.c files)
+ */
+
+int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
+{
+   if (!dev || t  -1) {
+   WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
+   return -EINVAL;
+   };
+
+   if (t == -1)
+   pr_debug(OMAP PM: remove max MPU wakeup latency constraint: 
+dev %s\n, dev_name(dev));
+   else
+   pr_debug(OMAP PM: add max MPU wakeup latency constraint: 
+dev %s, t = %ld usec\n, dev_name(dev), t);
+
+   /*
+* For current Linux, this needs to map the MPU to a
+* powerdomain, then go through the list of current max lat
+* constraints on the MPU and find the smallest.  If
+* the latency constraint has changed, the code should
+* recompute the state to enter for the next powerdomain
+* state.
+*
+* TI CDP code can call constraint_set here.
+*/
+
+   return 0;
+}
+
+int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
+{
+   if (!dev || (agent_id != OCP_INITIATOR_AGENT 
+   agent_id != OCP_TARGET_AGENT)) {
+   WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
+   return -EINVAL;
+   };
+
+   if (r == 0)
+   pr_debug(OMAP PM: remove min bus tput constraint: 
+dev %s for agent_id %d\n, dev_name(dev), agent_id);
+   else
+   pr_debug(OMAP PM: add min bus tput constraint: 
+dev %s for agent_id %d: rate %ld KiB\n,
+dev_name(dev), agent_id, r);
+
+   /*
+* This code should model the interconnect and compute the
+* required clock frequency, convert that to a VDD2 OPP ID, then
+* set the VDD2 OPP appropriately.
+*
+* TI CDP code can call constraint_set here on the VDD2 OPP.
+*/
+
+   return 0;
+}
+
+int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device *dev,
+  long t)
+{
+   if (!req_dev || !dev || t  -1) {
+   WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
+   return -EINVAL;
+   };
+
+   if (t == -1)
+   pr_debug(OMAP PM: remove max device latency 

[PATCH 1/2] OMAP PM: create a PM layer plugin for the devices wakeup latency constraints

2011-02-10 Thread jean . pihet
From: Jean Pihet j-pi...@ti.com

Created arch/arm/plat-omap/omap-pm-constraints.c file from
arch/arm/plat-omap/omap-pm-noop.c and the associated Kconfig option
OMAP_PM_CONSTRAINTS.

Signed-off-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/plat-omap/Kconfig   |7 +
 arch/arm/plat-omap/Makefile  |1 +
 arch/arm/plat-omap/omap-pm-constraints.c |  363 ++
 3 files changed, 371 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/omap-pm-constraints.c

diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index b6333ae..b8f51e3 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -215,6 +215,13 @@ config OMAP_PM_NONE
 config OMAP_PM_NOOP
bool No-op/debug PM layer
 
+config OMAP_PM_CONSTRAINTS
+   depends on PM
+   bool OMAP PM layer implementation, devices wakeup latency constraints
+   help
+ Select this option to enable the PM layer plugin for
+ the devices wakeup latency constraints support
+
 endchoice
 
 endmenu
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index a4a1285..a293367 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -32,3 +32,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
 obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
 
 obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
+obj-$(CONFIG_OMAP_PM_CONSTRAINTS) += omap-pm-constraints.o
diff --git a/arch/arm/plat-omap/omap-pm-constraints.c 
b/arch/arm/plat-omap/omap-pm-constraints.c
new file mode 100644
index 000..c8b4e4c
--- /dev/null
+++ b/arch/arm/plat-omap/omap-pm-constraints.c
@@ -0,0 +1,363 @@
+/*
+ * omap-pm.c - OMAP power management interface
+ *
+ * This code implements the OMAP power management interface to
+ * drivers, CPUIdle, CPUFreq, and DSP Bridge.
+ *
+ * Copyright (C) 2008-2009 Texas Instruments, Inc.
+ * Copyright (C) 2008-2009 Nokia Corporation
+ * Paul Walmsley
+ *
+ * Interface developed by (in alphabetical order):
+ * Karthik Dasu, Tony Lindgren, Jean Pihet, Rajendra Nayak, Sakari Poussa,
+ * Veeramanikandan Raju, Anand Sawant, Igor Stoppa, Paul Walmsley,
+ * Richard Woodruff
+ */
+
+#undef DEBUG
+
+#include linux/init.h
+#include linux/cpufreq.h
+#include linux/device.h
+#include linux/platform_device.h
+
+/* Interface documentation is in mach/omap-pm.h */
+#include plat/omap-pm.h
+#include plat/omap_device.h
+
+static bool off_mode_enabled;
+static u32 dummy_context_loss_counter;
+
+/*
+ * Device-driver-originated constraints (via board-*.c files)
+ */
+
+int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
+{
+   if (!dev || t  -1) {
+   WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
+   return -EINVAL;
+   };
+
+   if (t == -1)
+   pr_debug(OMAP PM: remove max MPU wakeup latency constraint: 
+dev %s\n, dev_name(dev));
+   else
+   pr_debug(OMAP PM: add max MPU wakeup latency constraint: 
+dev %s, t = %ld usec\n, dev_name(dev), t);
+
+   /*
+* For current Linux, this needs to map the MPU to a
+* powerdomain, then go through the list of current max lat
+* constraints on the MPU and find the smallest.  If
+* the latency constraint has changed, the code should
+* recompute the state to enter for the next powerdomain
+* state.
+*
+* TI CDP code can call constraint_set here.
+*/
+
+   return 0;
+}
+
+int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
+{
+   if (!dev || (agent_id != OCP_INITIATOR_AGENT 
+   agent_id != OCP_TARGET_AGENT)) {
+   WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
+   return -EINVAL;
+   };
+
+   if (r == 0)
+   pr_debug(OMAP PM: remove min bus tput constraint: 
+dev %s for agent_id %d\n, dev_name(dev), agent_id);
+   else
+   pr_debug(OMAP PM: add min bus tput constraint: 
+dev %s for agent_id %d: rate %ld KiB\n,
+dev_name(dev), agent_id, r);
+
+   /*
+* This code should model the interconnect and compute the
+* required clock frequency, convert that to a VDD2 OPP ID, then
+* set the VDD2 OPP appropriately.
+*
+* TI CDP code can call constraint_set here on the VDD2 OPP.
+*/
+
+   return 0;
+}
+
+int omap_pm_set_max_dev_wakeup_lat(struct device *req_dev, struct device *dev,
+  long t)
+{
+   if (!req_dev || !dev || t  -1) {
+   WARN(1, OMAP PM: %s: invalid parameter(s), __func__);
+   return -EINVAL;
+   };
+
+   if (t == -1)
+   pr_debug(OMAP PM: remove max device latency constraint: 
+dev %s\n, dev_name(dev));
+   else
+   pr_debug(OMAP PM: add max device latency