Re: [PATCH 5/6] OMAP: powerdomain: Arch specific funcs for mem control

2010-11-28 Thread Paul Walmsley
Hi Rajendra,

On Tue, 16 Nov 2010, Rajendra Nayak wrote:

 Define the following architecture specific funtions for omap2/3/4
 .pwrdm_set_mem_onst
 .pwrdm_set_mem_retst
 .pwrdm_read_mem_pwrst
 .pwrdm_read_prev_mem_pwrst
 .pwrdm_read_mem_retst
 .pwrdm_clear_all_prev_pwrst
 .pwrdm_enable_hdwr_sar
 .pwrdm_disable_hdwr_sar
 .pwrdm_wait_transition
 
 Convert the platform-independent framework to call these functions.
 
 Signed-off-by: Rajendra Nayak rna...@ti.com
 Cc: Paul Walmsley p...@pwsan.com
 Cc: Benoit Cousson b-cous...@ti.com
 Cc: Kevin Hilman khil...@deeprootsystems.com
 ---
  arch/arm/mach-omap2/Makefile   |2 +-
  arch/arm/mach-omap2/powerdomains.c |  114 
  arch/arm/mach-omap2/powerdomains.h |5 +
  arch/arm/mach-omap2/powerdomains2xxx.c |  129 ++
  arch/arm/mach-omap2/powerdomains44xx.c |   87 +
  arch/arm/plat-omap/powerdomain.c   |  306 
 ++--
  6 files changed, 391 insertions(+), 252 deletions(-)
  create mode 100644 arch/arm/mach-omap2/powerdomains.c
 
 diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
 index 5f843fc..87a73b7 100644
 --- a/arch/arm/mach-omap2/Makefile
 +++ b/arch/arm/mach-omap2/Makefile
 @@ -4,7 +4,7 @@
  
  # Common support
  obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o 
 \
 -  common.o
 +  common.o powerdomains.o

Please move this down to the newly-created Powerdomains section of the 
Makefile.

  
  omap-2-3-common  = irq.o sdrc.o prm2xxx_3xxx.o
  hwmod-common = omap_hwmod.o \
 diff --git a/arch/arm/mach-omap2/powerdomains.c 
 b/arch/arm/mach-omap2/powerdomains.c
 new file mode 100644
 index 000..876bebe
 --- /dev/null
 +++ b/arch/arm/mach-omap2/powerdomains.c

Maybe call this file 'powerdomain-common.c' to be similar to file names 
like prcm-common.c ?

 @@ -0,0 +1,114 @@
 +/*
 + *  linux/arch/arm/mach-omap2/powerdomains.c
 + *  Contains common powerdomain framework functions
 + *
 + *  Copyright (C) 2010 Texas Instruments, Inc.
 + *  Copyright (C) 2010 Nokia Corporation
 + *
 + * Derived from mach-omap2/powerdomain.c written by Paul Walmsley
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/errno.h
 +#include linux/kernel.h
 +#include pm.h
 +#include cm.h
 +#include cm-regbits-34xx.h
 +#include cm-regbits-44xx.h
 +#include prm-regbits-34xx.h
 +#include prm-regbits-44xx.h
 +
 +/*
 + * OMAP3 and OMAP4 specific register bit initialisations
 + * Notice that the names here are not according to each power
 + * domain but the bit mapping used applies to all of them
 + */
 +/* OMAP3 and OMAP4 Memory Onstate Masks (common across all power domains) */
 +#define OMAP_MEM0_ONSTATE_MASK OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK
 +#define OMAP_MEM1_ONSTATE_MASK OMAP3430_L1FLATMEMONSTATE_MASK
 +#define OMAP_MEM2_ONSTATE_MASK OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK
 +#define OMAP_MEM3_ONSTATE_MASK OMAP3430_L2FLATMEMONSTATE_MASK
 +#define OMAP_MEM4_ONSTATE_MASK OMAP4430_OCP_NRET_BANK_ONSTATE_MASK
 +
 +/* OMAP3 and OMAP4 Memory Retstate Masks (common across all power domains) */
 +#define OMAP_MEM0_RETSTATE_MASK OMAP3430_SHAREDL1CACHEFLATRETSTATE_MASK
 +#define OMAP_MEM1_RETSTATE_MASK OMAP3430_L1FLATMEMRETSTATE_MASK
 +#define OMAP_MEM2_RETSTATE_MASK OMAP3430_SHAREDL2CACHEFLATRETSTATE_MASK
 +#define OMAP_MEM3_RETSTATE_MASK OMAP3430_L2FLATMEMRETSTATE_MASK
 +#define OMAP_MEM4_RETSTATE_MASK OMAP4430_OCP_NRET_BANK_RETSTATE_MASK
 +
 +/* OMAP3 and OMAP4 Memory Status bits */
 +#define OMAP_MEM0_STATEST_MASK OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK
 +#define OMAP_MEM1_STATEST_MASK OMAP3430_L1FLATMEMSTATEST_MASK
 +#define OMAP_MEM2_STATEST_MASK OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK
 +#define OMAP_MEM3_STATEST_MASK OMAP3430_L2FLATMEMSTATEST_MASK
 +#define OMAP_MEM4_STATEST_MASK OMAP4430_OCP_NRET_BANK_STATEST_MASK
 +
 +int _get_mem_bank_onstate_mask(u8 bank);
 +int _get_mem_bank_retst_mask(u8 bank);
 +int _get_mem_bank_stst_mask(u8 bank);
 +
 +/* Common Internal functions used across OMAP rev's*/
 +int _get_mem_bank_onstate_mask(u8 bank)
 +{
 + switch (bank) {
 + case 0:
 + return OMAP_MEM0_ONSTATE_MASK;
 + case 1:
 + return OMAP_MEM1_ONSTATE_MASK;
 + case 2:
 + return OMAP_MEM2_ONSTATE_MASK;
 + case 3:
 + return OMAP_MEM3_ONSTATE_MASK;
 + case 4:
 + return OMAP_MEM4_ONSTATE_MASK;
 + default:
 + WARN_ON(1); /* should never happen */
 + return -EEXIST;
 + }
 + return 0;
 +}
 +
 +int _get_mem_bank_retst_mask(u8 bank)
 +{
 + switch (bank) {
 + case 0:
 + return OMAP_MEM0_RETSTATE_MASK;
 + case 1:
 + return OMAP_MEM1_RETSTATE_MASK;
 + case 2:
 + return 

[PATCH 5/6] OMAP: powerdomain: Arch specific funcs for mem control

2010-11-16 Thread Rajendra Nayak
Define the following architecture specific funtions for omap2/3/4
.pwrdm_set_mem_onst
.pwrdm_set_mem_retst
.pwrdm_read_mem_pwrst
.pwrdm_read_prev_mem_pwrst
.pwrdm_read_mem_retst
.pwrdm_clear_all_prev_pwrst
.pwrdm_enable_hdwr_sar
.pwrdm_disable_hdwr_sar
.pwrdm_wait_transition

Convert the platform-independent framework to call these functions.

Signed-off-by: Rajendra Nayak rna...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Benoit Cousson b-cous...@ti.com
Cc: Kevin Hilman khil...@deeprootsystems.com
---
 arch/arm/mach-omap2/Makefile   |2 +-
 arch/arm/mach-omap2/powerdomains.c |  114 
 arch/arm/mach-omap2/powerdomains.h |5 +
 arch/arm/mach-omap2/powerdomains2xxx.c |  129 ++
 arch/arm/mach-omap2/powerdomains44xx.c |   87 +
 arch/arm/plat-omap/powerdomain.c   |  306 ++--
 6 files changed, 391 insertions(+), 252 deletions(-)
 create mode 100644 arch/arm/mach-omap2/powerdomains.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 5f843fc..87a73b7 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -4,7 +4,7 @@
 
 # Common support
 obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o \
-common.o
+common.o powerdomains.o
 
 omap-2-3-common= irq.o sdrc.o prm2xxx_3xxx.o
 hwmod-common   = omap_hwmod.o \
diff --git a/arch/arm/mach-omap2/powerdomains.c 
b/arch/arm/mach-omap2/powerdomains.c
new file mode 100644
index 000..876bebe
--- /dev/null
+++ b/arch/arm/mach-omap2/powerdomains.c
@@ -0,0 +1,114 @@
+/*
+ *  linux/arch/arm/mach-omap2/powerdomains.c
+ *  Contains common powerdomain framework functions
+ *
+ *  Copyright (C) 2010 Texas Instruments, Inc.
+ *  Copyright (C) 2010 Nokia Corporation
+ *
+ * Derived from mach-omap2/powerdomain.c written by Paul Walmsley
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/errno.h
+#include linux/kernel.h
+#include pm.h
+#include cm.h
+#include cm-regbits-34xx.h
+#include cm-regbits-44xx.h
+#include prm-regbits-34xx.h
+#include prm-regbits-44xx.h
+
+/*
+ * OMAP3 and OMAP4 specific register bit initialisations
+ * Notice that the names here are not according to each power
+ * domain but the bit mapping used applies to all of them
+ */
+/* OMAP3 and OMAP4 Memory Onstate Masks (common across all power domains) */
+#define OMAP_MEM0_ONSTATE_MASK OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK
+#define OMAP_MEM1_ONSTATE_MASK OMAP3430_L1FLATMEMONSTATE_MASK
+#define OMAP_MEM2_ONSTATE_MASK OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK
+#define OMAP_MEM3_ONSTATE_MASK OMAP3430_L2FLATMEMONSTATE_MASK
+#define OMAP_MEM4_ONSTATE_MASK OMAP4430_OCP_NRET_BANK_ONSTATE_MASK
+
+/* OMAP3 and OMAP4 Memory Retstate Masks (common across all power domains) */
+#define OMAP_MEM0_RETSTATE_MASK OMAP3430_SHAREDL1CACHEFLATRETSTATE_MASK
+#define OMAP_MEM1_RETSTATE_MASK OMAP3430_L1FLATMEMRETSTATE_MASK
+#define OMAP_MEM2_RETSTATE_MASK OMAP3430_SHAREDL2CACHEFLATRETSTATE_MASK
+#define OMAP_MEM3_RETSTATE_MASK OMAP3430_L2FLATMEMRETSTATE_MASK
+#define OMAP_MEM4_RETSTATE_MASK OMAP4430_OCP_NRET_BANK_RETSTATE_MASK
+
+/* OMAP3 and OMAP4 Memory Status bits */
+#define OMAP_MEM0_STATEST_MASK OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK
+#define OMAP_MEM1_STATEST_MASK OMAP3430_L1FLATMEMSTATEST_MASK
+#define OMAP_MEM2_STATEST_MASK OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK
+#define OMAP_MEM3_STATEST_MASK OMAP3430_L2FLATMEMSTATEST_MASK
+#define OMAP_MEM4_STATEST_MASK OMAP4430_OCP_NRET_BANK_STATEST_MASK
+
+int _get_mem_bank_onstate_mask(u8 bank);
+int _get_mem_bank_retst_mask(u8 bank);
+int _get_mem_bank_stst_mask(u8 bank);
+
+/* Common Internal functions used across OMAP rev's*/
+int _get_mem_bank_onstate_mask(u8 bank)
+{
+   switch (bank) {
+   case 0:
+   return OMAP_MEM0_ONSTATE_MASK;
+   case 1:
+   return OMAP_MEM1_ONSTATE_MASK;
+   case 2:
+   return OMAP_MEM2_ONSTATE_MASK;
+   case 3:
+   return OMAP_MEM3_ONSTATE_MASK;
+   case 4:
+   return OMAP_MEM4_ONSTATE_MASK;
+   default:
+   WARN_ON(1); /* should never happen */
+   return -EEXIST;
+   }
+   return 0;
+}
+
+int _get_mem_bank_retst_mask(u8 bank)
+{
+   switch (bank) {
+   case 0:
+   return OMAP_MEM0_RETSTATE_MASK;
+   case 1:
+   return OMAP_MEM1_RETSTATE_MASK;
+   case 2:
+   return OMAP_MEM2_RETSTATE_MASK;
+   case 3:
+   return OMAP_MEM3_RETSTATE_MASK;
+   case 4:
+   return OMAP_MEM4_RETSTATE_MASK;
+   default:
+   WARN_ON(1); /* should never happen */
+   return -EEXIST;
+   }
+   return 0;
+}
+
+int _get_mem_bank_stst_mask(u8 bank)
+{
+  

Re: [PATCH 5/6] OMAP: powerdomain: Arch specific funcs for mem control

2010-11-16 Thread Thomas Petazzoni
Hello,

On Tue, 16 Nov 2010 21:08:05 +0530
Rajendra Nayak rna...@ti.com wrote:

 Define the following architecture specific funtions for omap2/3/4

funtions - functions.

 +/* Common Internal functions used across OMAP rev's*/
 +int _get_mem_bank_onstate_mask(u8 bank)
 +{
 + switch (bank) {
 + case 0:
 + return OMAP_MEM0_ONSTATE_MASK;
 + case 1:
 + return OMAP_MEM1_ONSTATE_MASK;
 + case 2:
 + return OMAP_MEM2_ONSTATE_MASK;
 + case 3:
 + return OMAP_MEM3_ONSTATE_MASK;
 + case 4:
 + return OMAP_MEM4_ONSTATE_MASK;
 + default:
 + WARN_ON(1); /* should never happen */
 + return -EEXIST;

EEXIST is the error code for File exists, so here I would rather
expect something like ENOENT. But I understand that it was already
-EEXIST in the existing code.

Thanks,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html