]> Pileus Git - ~andy/linux/blobdiff - arch/arm/mach-omap2/prm2xxx_3xxx.c
Merge tag 'omap-devel-c-for-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git...
[~andy/linux] / arch / arm / mach-omap2 / prm2xxx_3xxx.c
index 21cb74003a562f27bc2a5a8538093d92503c44d0..e10fd1e9446baa395672fbffc65924bb5baed63a 100644 (file)
@@ -302,17 +302,60 @@ void omap3xxx_prm_restore_irqen(u32 *saved_mask)
                                OMAP3_PRM_IRQENABLE_MPU_OFFSET);
 }
 
-static int __init omap3xxx_prcm_init(void)
+/**
+ * omap3xxx_prm_reconfigure_io_chain - clear latches and reconfigure I/O chain
+ *
+ * Clear any previously-latched I/O wakeup events and ensure that the
+ * I/O wakeup gates are aligned with the current mux settings.  Works
+ * by asserting WUCLKIN, waiting for WUCLKOUT to be asserted, and then
+ * deasserting WUCLKIN and clearing the ST_IO_CHAIN WKST bit.  No
+ * return value.
+ */
+void omap3xxx_prm_reconfigure_io_chain(void)
+{
+       int i = 0;
+
+       omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
+                                  PM_WKEN);
+
+       omap_test_timeout(omap2_prm_read_mod_reg(WKUP_MOD, PM_WKST) &
+                         OMAP3430_ST_IO_CHAIN_MASK,
+                         MAX_IOPAD_LATCH_TIME, i);
+       if (i == MAX_IOPAD_LATCH_TIME)
+               pr_warn("PRM: I/O chain clock line assertion timed out\n");
+
+       omap2_prm_clear_mod_reg_bits(OMAP3430_EN_IO_CHAIN_MASK, WKUP_MOD,
+                                    PM_WKEN);
+
+       omap2_prm_set_mod_reg_bits(OMAP3430_ST_IO_CHAIN_MASK, WKUP_MOD,
+                                  PM_WKST);
+
+       omap2_prm_read_mod_reg(WKUP_MOD, PM_WKST);
+}
+
+/**
+ * omap3xxx_prm_enable_io_wakeup - enable wakeup events from I/O wakeup latches
+ *
+ * Activates the I/O wakeup event latches and allows events logged by
+ * those latches to signal a wakeup event to the PRCM.  For I/O
+ * wakeups to occur, WAKEUPENABLE bits must be set in the pad mux
+ * registers, and omap3xxx_prm_reconfigure_io_chain() must be called.
+ * No return value.
+ */
+static void __init omap3xxx_prm_enable_io_wakeup(void)
 {
-       int ret = 0;
+       if (omap3_has_io_wakeup())
+               omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD,
+                                          PM_WKEN);
+}
 
+static int __init omap3xxx_prcm_init(void)
+{
        if (cpu_is_omap34xx()) {
-               ret = omap_prcm_register_chain_handler(&omap3_prcm_irq_setup);
-               if (!ret)
-                       irq_set_status_flags(omap_prcm_event_to_irq("io"),
-                                            IRQ_NOAUTOEN);
+               omap3xxx_prm_enable_io_wakeup();
+               return omap_prcm_register_chain_handler(&omap3_prcm_irq_setup);
        }
 
-       return ret;
+       return 0;
 }
 subsys_initcall(omap3xxx_prcm_init);