OMAP3: control/PM: move padconf save code to mach-omap2/control.c
authorPaul Walmsley <paul@pwsan.com>
Wed, 22 Dec 2010 04:05:16 +0000 (21:05 -0700)
committerPaul Walmsley <paul@pwsan.com>
Wed, 22 Dec 2010 04:05:16 +0000 (21:05 -0700)
Move the padconf save code from pm34xx.c to the System Control Module
code in mach-omap2/control.c.  This is part of the general push to
move direct register access from middle-layer core code to low-level
core code, so the middle-layer code can be abstracted to work on
multiple platforms and cleaned up.

In the medium-to-long term, this code should be called by the mux
layer code, not the PM idle code.  This is because, according to the
TRM, saving the padconf only needs to be done when the padconf
changes[1].

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: Tony Lindgren <tony@atomide.com>
Tested-by: Rajendra Nayak <rnayak@ti.com>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
1. OMAP34xx Multimedia Device Silicon Revision 3.1.x [Rev. ZH] [SWPU222H]
   Section 4.11.4 "Device Off-Mode Sequences"

arch/arm/mach-omap2/control.c
arch/arm/mach-omap2/control.h
arch/arm/mach-omap2/pm34xx.c
arch/arm/plat-omap/include/plat/prcm.h

index 61101e807df108b586f67b823ddc3acdc51d9e30..695279419020372cf16d2be18465734308d2c5c4 100644 (file)
 #include "pm.h"
 #include "control.h"
 
+/* Used by omap3_ctrl_save_padconf() */
+#define START_PADCONF_SAVE             0x2
+#define PADCONF_SAVE_DONE              0x1
+
 static void __iomem *omap2_ctrl_base;
 static void __iomem *omap4_ctrl_pad_base;
 
@@ -530,4 +534,31 @@ void omap3630_ctrl_disable_rta(void)
        omap_ctrl_writel(OMAP36XX_RTA_DISABLE, OMAP36XX_CONTROL_MEM_RTA_CTRL);
 }
 
+/**
+ * omap3_ctrl_save_padconf - save padconf registers to scratchpad RAM
+ *
+ * Tell the SCM to start saving the padconf registers, then wait for
+ * the process to complete.  Returns 0 unconditionally, although it
+ * should also eventually be able to return -ETIMEDOUT, if the save
+ * does not complete.
+ *
+ * XXX This function is missing a timeout.  What should it be?
+ */
+int omap3_ctrl_save_padconf(void)
+{
+       u32 cpo;
+
+       /* Save the padconf registers */
+       cpo = omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_OFF);
+       cpo |= START_PADCONF_SAVE;
+       omap_ctrl_writel(cpo, OMAP343X_CONTROL_PADCONF_OFF);
+
+       /* wait for the save to complete */
+       while (!(omap_ctrl_readl(OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS)
+                & PADCONF_SAVE_DONE))
+               udelay(1);
+
+       return 0;
+}
+
 #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
index 4bfc1f0d974c43f1a30dcf423707ae436a4aa85e..1ddc83bc2f841329e87c77b3423b545eed4bc4d0 100644 (file)
@@ -359,6 +359,7 @@ extern void omap3_control_save_context(void);
 extern void omap3_control_restore_context(void);
 extern void omap3_ctrl_write_boot_mode(u8 bootmode);
 extern void omap3630_ctrl_disable_rta(void);
+extern int omap3_ctrl_save_padconf(void);
 #else
 #define omap_ctrl_base_get()           0
 #define omap_ctrl_readb(x)             0
index 5efd1fb8c6402a47896ba0a03c545f1f696409ab..5b323f28da2dce177c49da1729ed884a0d741e96 100644 (file)
@@ -133,16 +133,7 @@ static void omap3_disable_io_chain(void)
 
 static void omap3_core_save_context(void)
 {
-       u32 control_padconf_off;
-
-       /* Save the padconf registers */
-       control_padconf_off = omap_ctrl_readl(OMAP343X_CONTROL_PADCONF_OFF);
-       control_padconf_off |= START_PADCONF_SAVE;
-       omap_ctrl_writel(control_padconf_off, OMAP343X_CONTROL_PADCONF_OFF);
-       /* wait for the save to complete */
-       while (!(omap_ctrl_readl(OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS)
-                       & PADCONF_SAVE_DONE))
-               udelay(1);
+       omap3_ctrl_save_padconf();
 
        /*
         * Force write last pad into memory, as this can fail in some
index 078906d86b6c5e8ce33269ef92440efb411f42bf..2fdf8c80d390b2b7b191677d82e996b292921660 100644 (file)
@@ -32,9 +32,6 @@ void omap_prcm_arch_reset(char mode, const char *cmd);
 int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest,
                         const char *name);
 
-#define START_PADCONF_SAVE 0x2
-#define PADCONF_SAVE_DONE  0x1
-
 #endif