public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] PowerOP take 3, PowerOP core 1/5
@ 2006-07-20 19:50 Eugeny S. Mints
  2006-07-20 22:01 ` David Brownell
  0 siblings, 1 reply; 4+ messages in thread
From: Eugeny S. Mints @ 2006-07-20 19:50 UTC (permalink / raw)
  To: linux-pm; +Cc: patrick.mochel, Matthew Locke, linux, sampsa.fabritius

[-- Attachment #1: Type: text/plain, Size: 183 bytes --]

The PowerOP arch independent core provides routines for
calling the platform-specific backend to read and set operating
points and for registering a single machine-dependent backend.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: powerop.core.patch --]
[-- Type: text/x-patch; name="powerop.core.patch", Size: 4144 bytes --]

diff --git a/drivers/Makefile b/drivers/Makefile
index fc2d744..f8eaf31 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_ISDN)		+= isdn/
 obj-$(CONFIG_EDAC)		+= edac/
 obj-$(CONFIG_MCA)		+= mca/
 obj-$(CONFIG_EISA)		+= eisa/
+obj-$(CONFIG_POWEROP)		+= powerop/
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_MMC)		+= mmc/
 obj-$(CONFIG_NEW_LEDS)		+= leds/
diff --git a/drivers/powerop/Kconfig b/drivers/powerop/Kconfig
new file mode 100644
index 0000000..0ae74ab
--- /dev/null
+++ b/drivers/powerop/Kconfig
@@ -0,0 +1,12 @@
+#
+# powerop
+#
+
+menu "PowerOP (Power Management)"
+
+config POWEROP
+	bool "PowerOP Core"
+	help
+
+endmenu
+
diff --git a/drivers/powerop/Makefile b/drivers/powerop/Makefile
new file mode 100644
index 0000000..1d430ce
--- /dev/null
+++ b/drivers/powerop/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_POWEROP)		+= powerop.o
+
diff --git a/drivers/powerop/powerop.c b/drivers/powerop/powerop.c
new file mode 100644
index 0000000..a023726
--- /dev/null
+++ b/drivers/powerop/powerop.c
@@ -0,0 +1,95 @@
+/*
+ * PowerOP generic core functions
+ *
+ * Author: Todd Poynor <tpoynor@mvista.com>
+ * Interface update by Eugeny S. Mints <eugeny.mints@gmail.com>
+ *
+ * 2005 (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/powerop.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+
+static struct powerop_driver *powerop_driver;
+
+/* serialize access to get/set_point routines */
+static DECLARE_MUTEX(powerop_mutex);
+
+int
+powerop_set_point(struct powerop_point *point)
+{
+	int rc;
+
+	down(&powerop_mutex);
+	rc = powerop_driver && powerop_driver->set_point ? 
+		powerop_driver->set_point(point) : -EINVAL;
+	up(&powerop_mutex);
+	
+	return rc;
+}
+
+int
+powerop_get_point(struct powerop_point *point)
+{
+	int rc;
+
+	down(&powerop_mutex);
+	rc = powerop_driver && powerop_driver->get_point ? 
+		powerop_driver->get_point(point) : -EINVAL;
+	up(&powerop_mutex);
+
+	return rc;
+}
+
+
+EXPORT_SYMBOL_GPL(powerop_set_point);
+EXPORT_SYMBOL_GPL(powerop_get_point);
+
+int 
+powerop_driver_register(struct powerop_driver *p)
+{
+	int error = 0;
+
+	if (! powerop_driver) {
+		printk(KERN_INFO "PowerOP registering driver %s.\n", p->name);
+		powerop_driver = p;
+
+	} else
+		error = -EBUSY;
+
+	return error;
+}
+
+void 
+powerop_driver_unregister(struct powerop_driver *p)
+{
+	if (powerop_driver == p) {
+		printk(KERN_INFO "PowerOP unregistering driver %s.\n", p->name);
+		powerop_driver = NULL;
+	}
+}
+
+EXPORT_SYMBOL_GPL(powerop_driver_register);
+EXPORT_SYMBOL_GPL(powerop_driver_unregister);
+
+static int __init powerop_init(void)
+{
+	return 0;
+}
+
+static void __exit powerop_exit(void)
+{
+}
+
+module_init(powerop_init);
+module_exit(powerop_exit);
+
+MODULE_DESCRIPTION("PowerOP Power Management");
+MODULE_LICENSE("GPL");
+
diff --git a/include/linux/powerop.h b/include/linux/powerop.h
new file mode 100644
index 0000000..befdbf5
--- /dev/null
+++ b/include/linux/powerop.h
@@ -0,0 +1,31 @@
+/*
+ * PowerOP core definitions
+ *
+ * Author: Todd Poynor <tpoynor@mvista.com>
+ * Interface update by Eugeny S. Mints <eugeny.mints@gmail.com>
+ *
+ * 2005 (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+#ifndef __POWEROP_H__
+#define __POWEROP_H__
+
+#include <asm/powerop.h>
+
+struct powerop_driver {
+	char *name;
+	int (*set_point)(struct powerop_point *opt);
+	int (*get_point)(struct powerop_point *opt);
+};
+/* Interface to upper PMF layers */
+int powerop_set_point(struct powerop_point *opt);
+int powerop_get_point(struct powerop_point *opt);
+
+/* Interface to an arch PM core */
+int powerop_driver_register(struct powerop_driver *p);
+void powerop_driver_unregister(struct powerop_driver *p);
+
+#endif /* __POWEROP_H__ */
+

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



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

* Re: [RFC] PowerOP take 3, PowerOP core 1/5
  2006-07-20 19:50 [RFC] PowerOP take 3, PowerOP core 1/5 Eugeny S. Mints
@ 2006-07-20 22:01 ` David Brownell
  2006-07-26 20:44   ` Eugeny S. Mints
  0 siblings, 1 reply; 4+ messages in thread
From: David Brownell @ 2006-07-20 22:01 UTC (permalink / raw)
  To: linux-pm; +Cc: Matthew Locke, patrick.mochel, sampsa.fabritius, linux

On Thursday 20 July 2006 12:50 pm, Eugeny S. Mints wrote:
> +static int __init powerop_init(void)
> +{
> +       return 0;
> +}
> +
> +static void __exit powerop_exit(void)
> +{
> +}
> +
> +module_init(powerop_init);
> +module_exit(powerop_exit);

Best to delete useless code like that.  :)

And you should be grabbing that mutex to register/unregister the arch
methods table, otherwise there's little point in having it ...

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

* Re: [RFC] PowerOP take 3, PowerOP core 1/5
  2006-07-20 22:01 ` David Brownell
@ 2006-07-26 20:44   ` Eugeny S. Mints
  2006-07-27  0:18     ` David Brownell
  0 siblings, 1 reply; 4+ messages in thread
From: Eugeny S. Mints @ 2006-07-26 20:44 UTC (permalink / raw)
  To: David Brownell
  Cc: Matthew Locke, patrick.mochel, linux-pm, sampsa.fabritius, linux

David Brownell wrote:
> On Thursday 20 July 2006 12:50 pm, Eugeny S. Mints wrote:
>   
>> +static int __init powerop_init(void)
>> +{
>> +       return 0;
>> +}
>> +
>> +static void __exit powerop_exit(void)
>> +{
>> +}
>> +
>> +module_init(powerop_init);
>> +module_exit(powerop_exit);
>>     
>
> Best to delete useless code like that.  :)
>
> And you should be grabbing that mutex to register/unregister the arch
> methods table, otherwise there's little point in having it ...
>   
basically agree. The reference code is handling only one arch layer
(essentially PM core) underneath PowerOP for the time being though.
At the same time PM Core is expected to be "aware" of all PM related
parameters and details so I actually would like to see an use case  showing
when an extra layer below PowerOP  may be useful to continue moving
towards multi arch layer approach.

Thanks,
Eugeny

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

* Re: [RFC] PowerOP take 3, PowerOP core 1/5
  2006-07-26 20:44   ` Eugeny S. Mints
@ 2006-07-27  0:18     ` David Brownell
  0 siblings, 0 replies; 4+ messages in thread
From: David Brownell @ 2006-07-27  0:18 UTC (permalink / raw)
  To: Eugeny S. Mints
  Cc: Matthew Locke, patrick.mochel, linux-pm, sampsa.fabritius, linux

On Wednesday 26 July 2006 1:44 pm, Eugeny S. Mints wrote:

> basically agree. The reference code is handling only one arch layer
> (essentially PM core) underneath PowerOP for the time being though.

I'm not sure it's practical to standardize more than one such layer yet.
Boards based on one SOC could share much code ... ditto ones using the
same external PM chip(s).  But "layer" isn't necessarily the right model
for integration (except in slideware, of course).  The value of such
PM componentry will show with whole/real systems though.

- Dave

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

end of thread, other threads:[~2006-07-27  0:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-20 19:50 [RFC] PowerOP take 3, PowerOP core 1/5 Eugeny S. Mints
2006-07-20 22:01 ` David Brownell
2006-07-26 20:44   ` Eugeny S. Mints
2006-07-27  0:18     ` David Brownell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox