Skip to contentSkip to conversation

34XX: PM: Support for retention on suspend and idle

PATCH In review Högander Jouni 2 participants 16 messages May 16, 2008 – May 20, 2008

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover 34XX: PM: Support for retention on suspend and idle

This patch set adds suspend and pm idle support for omap3. There are still lots of missing stuff so omap doesn't enter full retention without workaround patches. Workaround patches are sent in separate set.

You can try these by applying this set and workaround set. Then boot the device and do "echo mem > /sys/power/state". Dynamic retention can be tried by "echo 1 > /sys/power/sleep_while_idle". There is one pending patch by Felipe Balbi (ARCH: OMAP: MUSB: Do not block sleep) addition to this and workaround set which is needed dynamic idle to work. Enabling dynamic idle has nasty side effect that serial console stops to work. This happens only if you enable it by "echo 1 > /sys/power/sleep_while_idle"

I have tested these patches on TI 3430 SDP ES2.0 board.

Signature · 6 lines
Jouni Högander

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 1/9 24XX: PM: Move pm.c to pm24xx.c and sleep.S to sleep24xx.S

Rename filenames to prepare 34XX additions. Compile omap2 code only if CONFIG_ARCH_OMAP2 is defined.

---
 arch/arm/mach-omap2/Makefile    |    4 +-
 arch/arm/mach-omap2/pm.c        |  845 ---------------------------------------
 arch/arm/mach-omap2/pm24xx.c    |  845 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/sleep.S     |  133 ------
 arch/arm/mach-omap2/sleep24xx.S |  133 ++++++
 5 files changed, 981 insertions(+), 979 deletions(-)
 delete mode 100644 arch/arm/mach-omap2/pm.c
 create mode 100644 arch/arm/mach-omap2/pm24xx.c
 delete mode 100644 arch/arm/mach-omap2/sleep.S
 create mode 100644 arch/arm/mach-omap2/sleep24xx.S
arch/arm/mach-omap2/Makefile +3 -1
index ea0cf43..462f685 100644
@@ -12,7 +12,9 @@ obj-$(CONFIG_ARCH_OMAP2)		+= sram24xx.o
 obj-$(CONFIG_ARCH_OMAP3)		+= sram34xx.o
 
 # Power Management
-obj-$(CONFIG_PM) += pm.o sleep.o
+ifeq ($(CONFIG_ARCH_OMAP2),y)
+obj-$(CONFIG_PM) += pm24xx.o sleep24xx.o
+endif
 
 # Clock framework
 obj-$(CONFIG_ARCH_OMAP2)		+= clock24xx.o
arch/arm/mach-omap2/pm.c deleted +0 -845

845 lines not on this page · raw message

arch/arm/mach-omap2/pm24xx.c new file +845 -0

845 lines not on this page · raw message

arch/arm/mach-omap2/sleep.S deleted +0 -133

133 lines not on this page · raw message

arch/arm/mach-omap2/sleep24xx.S new file +133 -0

133 lines not on this page · raw message

Signature · 1 line
1.5.5
#4 lore raw

PATCH 4/9 OMAP: Add new function to check wether there is irq pending

In reply to Högander Jouni

Add common omap2/3 function to check wether there is irq pending. Switch to use it in omap2 pm code instead of its own.

---
 arch/arm/mach-omap2/irq.c        |   29 +++++++++++++++++++++++------
 arch/arm/mach-omap2/pm24xx.c     |   19 +++----------------
 include/asm-arm/arch-omap/irqs.h |    1 +
 3 files changed, 27 insertions(+), 22 deletions(-)
arch/arm/mach-omap2/irq.c +23 -6
index ac062ee..f1e1e2e 100644
@@ -20,12 +20,13 @@
 
 /* selected INTC register offsets */
 
-#define INTC_REVISION	0x0000
-#define INTC_SYSCONFIG	0x0010
-#define INTC_SYSSTATUS	0x0014
-#define INTC_CONTROL	0x0048
-#define INTC_MIR_CLEAR0	0x0088
-#define INTC_MIR_SET0	0x008c
+#define INTC_REVISION		0x0000
+#define INTC_SYSCONFIG		0x0010
+#define INTC_SYSSTATUS		0x0014
+#define INTC_CONTROL		0x0048
+#define INTC_MIR_CLEAR0		0x0088
+#define INTC_MIR_SET0		0x008c
+#define INTC_PENDING_IRQ0	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,22 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
+		struct omap_irq_bank *bank = irq_banks + i;
+		int irq;
+
+		for (irq = 0; irq < bank->nr_irqs; irq += 32)
+			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
+					       ((irq >> 5) << 5)))
+				return 1;
+	}
+	return 0;
+}
+
 void __init omap_init_irq(void)
 {
 	unsigned long nr_irqs = 0;
arch/arm/mach-omap2/pm24xx.c +3 -16
index 7bb654f..8636f1c 100644
@@ -74,19 +74,6 @@ static int omap2_fclks_active(void)
 	return 0;
 }
 
-static int omap2_irq_pending(void)
-{
-	u32 pending_reg = 0x480fe098;
-	int i;
-
-	for (i = 0; i < 4; i++) {
-		if (omap_readl(pending_reg))
-			return 1;
-		pending_reg += 0x20;
-	}
-	return 0;
-}
-
 static void omap2_enter_full_retention(void)
 {
 	u32 l, sleep_time = 0;
@@ -121,7 +108,7 @@ static void omap2_enter_full_retention(void)
 
 	/* One last check for pending IRQs to avoid extra latency due
 	 * to sleeping unnecessarily. */
-	if (omap2_irq_pending())
+	if (omap_irq_pending())
 		goto no_sleep;
 
 	serial_console_sleep(1);
@@ -272,7 +259,7 @@ static void omap2_pm_idle(void)
 		 */
 		if (atomic_read(&sleep_block) == 0) {
 			timer_dyn_reprogram();
-			if (omap2_irq_pending())
+			if (omap_irq_pending())
 				goto out;
 		}
 		omap2_enter_mpu_retention();
@@ -286,7 +273,7 @@ static void omap2_pm_idle(void)
 	 */
 	timer_dyn_reprogram();
 
-	if (omap2_irq_pending())
+	if (omap_irq_pending())
 		goto out;
 
 	omap2_enter_full_retention();
include/asm-arm/arch-omap/irqs.h +1 -0
index c80e160..343e93e 100644
@@ -368,6 +368,7 @@
 
 #ifndef __ASSEMBLY__
 extern void omap_init_irq(void);
+extern int omap_irq_pending(void);
 #endif
 
 #include <asm/hardware.h>
Signature · 1 line
1.5.5
#2 lore raw

PATCH 2/9 24XX: PM: Move debugging related code to pm-debug.c

In reply to Högander Jouni

Move debugging and serial console handling to pm-debug.c.

---
 arch/arm/mach-omap2/Makefile   |    2 +
 arch/arm/mach-omap2/pm-debug.c |  275 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/pm.h       |   31 +++++
 arch/arm/mach-omap2/pm24xx.c   |  258 +-------------------------------------
 4 files changed, 309 insertions(+), 257 deletions(-)
 create mode 100644 arch/arm/mach-omap2/pm-debug.c
 create mode 100644 arch/arm/mach-omap2/pm.h
arch/arm/mach-omap2/Makefile +2 -0
index 462f685..8f80382 100644
@@ -16,6 +16,8 @@ ifeq ($(CONFIG_ARCH_OMAP2),y)
 obj-$(CONFIG_PM) += pm24xx.o sleep24xx.o
 endif
 
+obj-$(CONFIG_PM_DEBUG) += pm-debug.o
+
 # Clock framework
 obj-$(CONFIG_ARCH_OMAP2)		+= clock24xx.o
 obj-$(CONFIG_ARCH_OMAP3)		+= clock34xx.o
arch/arm/mach-omap2/pm-debug.c new file +275 -0

275 lines not on this page · raw message

arch/arm/mach-omap2/pm.h new file +31 -0
new file mode 100644
index 0000000..541bf90
@@ -0,0 +1,31 @@
+#ifndef __ARCH_ARM_MACH_OMAP2_PM_H
+#define __ARCH_ARM_MACH_OMAP2_PM_H
+/*
+ * linux/arch/arm/mach-omap2/pm.h
+ *
+ * OMAP Power Management Routines
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Jouni Hogander
+ *
+ * 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.
+ */
+
+#ifdef CONFIG_PM_DEBUG
+extern u32 omap2_read_32k_sync_counter(void);
+extern void omap2_pm_dump(int mode, int resume, unsigned int us);
+extern void serial_console_fclk_mask(u32 *f1, u32 *f2);
+extern void pm_init_serial_console(void);
+extern void serial_console_sleep(int enable);
+extern int omap2_pm_debug;
+#else
+#define omap2_read_32k_sync_counter() 0;
+#define serial_console_sleep(enable) do; while(0)
+#define pm_init_serial_console() do; while(0)
+#define omap2_pm_dump(mode,resume,us) do; while(0)
+#define serial_console_fclk_mask(f1,f2)  do; while(0)
+#define omap2_pm_debug 0
+#endif /* CONFIG_PM_DEBUG */
+#endif
arch/arm/mach-omap2/pm24xx.c +1 -257

270 lines not on this page · raw message

Signature · 1 line
1.5.5
#11 lore raw

PATCH 6/9 34XX: Suspend: Use same naming convention in sleep34xx.S as in sleep24XX.S

In reply to Högander Jouni

Change omap34xx_suspend to omap34xx_cpu_suspend and omap34xx_suspend_sz to omap34xx_cpu_suspend_sz.

Do not use PRM_BASE in sleep34xx.S because it is not defined in linux-omap tree.

Use OMAP343X_SDRC_BASE in sleep34xx.S instead of SDRC_BASE.

Convert all IO_ADDRESS style definitions to OMAP34XX_PRM_REGADDR style definitions.

Add omap34xx_cpu_suspend and omap34xx_cpu_suspend_sz to include/asm-arm/arch-omap/pm.h

Do necessary modifications to be able to use arch/arm/mach-omap2/prm.h and include/asm-arm/arch-omap/control.h ins asm files.

---
 arch/arm/mach-omap2/prm.h           |    7 ++-----
 arch/arm/mach-omap2/sleep34xx.S     |   28 +++++++++++++++++++---------
 include/asm-arm/arch-omap/control.h |    6 ++++++
 include/asm-arm/arch-omap/pm.h      |    3 +++
 4 files changed, 30 insertions(+), 14 deletions(-)
arch/arm/mach-omap2/prm.h +2 -5
index e1ce33e..f816165 100644
@@ -14,9 +14,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/io.h>
-#include <linux/bitops.h>
-
 #include "prcm-common.h"
 
 #ifndef __ASSEMBLER__
@@ -156,6 +153,8 @@ static __inline__ u32 __attribute__((unused)) prm_rmw_reg_bits(u32 mask,
 #define OMAP3430_PRM_IRQSTATUS_IVA2			0x00f8
 #define OMAP3430_PRM_IRQENABLE_IVA2			0x00fc
 
+#ifndef __ASSEMBLER__
+
 /* Read-modify-write bits in a PRM register (by domain) */
 static u32 __attribute__((unused)) prm_rmw_mod_reg_bits(u32 mask, u32 bits,
 							s16 module, s16 idx)
@@ -183,8 +182,6 @@ static u32 __attribute__((unused)) prm_clear_mod_reg_bits(u32 bits, s16 module,
 #define OMAP24XX_PRCM_IRQSTATUS_IVA			0x00f8
 #define OMAP24XX_PRCM_IRQENABLE_IVA			0x00fc
 
-#ifndef __ASSEMBLER__
-
 /* Power/reset management domain register get/set */
 
 static __inline__ void __attribute__((unused)) prm_write_mod_reg(u32 val,
arch/arm/mach-omap2/sleep34xx.S +19 -9
index c9db507..ebc7eb3 100644
@@ -28,12 +28,22 @@
 #include <asm/assembler.h>
 #include <asm/arch/io.h>
 #include <asm/arch/pm.h>
-
-#define PM_PREPWSTST_CORE_V	IO_ADDRESS(PRM_BASE + 0xAE8)
-#define PM_PREPWSTST_MPU_V	IO_ADDRESS(PRM_BASE + 0x9E8)
-#define PM_PWSTCTRL_MPU_P	(PRM_BASE + 0x9E0)
-#define SCRATCHPAD_BASE_P	0x48002910
-#define SDRC_POWER_V		IO_ADDRESS(SDRC_BASE + 0x070)
+#include <asm/arch/control.h>
+
+#include "prm.h"
+#include "sdrc.h"
+
+#define PM_PREPWSTST_CORE_V	OMAP34XX_PRM_REGADDR(CORE_MOD, \
+				OMAP3430_PM_PREPWSTST)
+#define PM_PREPWSTST_MPU_V	OMAP34XX_PRM_REGADDR(MPU_MOD, \
+				OMAP3430_PM_PREPWSTST)
+#define PM_PWSTCTRL_MPU_P	OMAP34XX_PRM_REGADDR(MPU_MOD, PM_PWSTCTRL)
+#define SCRATCHPAD_MEM_OFFS	0x310 /* Move this as correct place is
+				       * available */
+#define SCRATCHPAD_BASE_P	OMAP343X_CTRL_REGADDR(\
+				OMAP343X_CONTROL_MEM_WKUP +\
+				SCRATCHPAD_MEM_OFFS)
+#define SDRC_POWER_V		OMAP34XX_SDRC_REGADDR(SDRC_POWER)
 
 	.text
 /* Function call to get the restore pointer for resume from OFF */
@@ -52,7 +62,7 @@ ENTRY(get_restore_pointer_sz)
  * Note: This code get's copied to internal SRAM at boot. When the OMAP
  *	 wakes up it continues execution at the point it went to sleep.
  */
-ENTRY(omap34xx_suspend)
+ENTRY(omap34xx_cpu_suspend)
 	stmfd	sp!, {r0-r12, lr}		@ save registers on stack
 loop:
 	/*b	loop*/	@Enable to debug by stepping through code
@@ -530,5 +540,5 @@ table_entry:
 	.word	0x00000C02
 cache_pred_disable_mask:
 	.word	0xFFFFE7FB
-ENTRY(omap34xx_suspend_sz)
-	.word	. - omap34xx_suspend
+ENTRY(omap34xx_cpu_suspend_sz)
+	.word	. - omap34xx_cpu_suspend
include/asm-arm/arch-omap/control.h +6 -0
index 0832348..1d95cc2 100644
@@ -18,12 +18,18 @@
 
 #include <asm/arch/io.h>
 
+#ifndef __ASSEMBLY__
 #define OMAP242X_CTRL_REGADDR(reg)					\
 	(__force void __iomem *)IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
 #define OMAP243X_CTRL_REGADDR(reg)					\
 	(__force void __iomem *)IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
 #define OMAP343X_CTRL_REGADDR(reg)					\
 	(__force void __iomem *)IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
+#else
+#define OMAP242X_CTRL_REGADDR(reg)	IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
+#define OMAP243X_CTRL_REGADDR(reg)	IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
+#define OMAP343X_CTRL_REGADDR(reg)	IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
+#endif /* __ASSEMBLY__ */
 
 /*
  * As elsewhere, the "OMAP2_" prefix indicates that the macro is valid for
include/asm-arm/arch-omap/pm.h +3 -0
index 0ce03fd..d0c7d4d 100644
@@ -146,6 +146,7 @@ extern void omap730_cpu_suspend(unsigned short, unsigned short);
 extern void omap1510_cpu_suspend(unsigned short, unsigned short);
 extern void omap1610_cpu_suspend(unsigned short, unsigned short);
 extern void omap24xx_cpu_suspend(u32 dll_ctrl, u32 cpu_revision);
+extern void omap34xx_cpu_suspend(u32 *addr, int save_state);
 extern void omap730_idle_loop_suspend(void);
 extern void omap1510_idle_loop_suspend(void);
 extern void omap1610_idle_loop_suspend(void);
@@ -155,10 +156,12 @@ extern unsigned int omap730_cpu_suspend_sz;
 extern unsigned int omap1510_cpu_suspend_sz;
 extern unsigned int omap1610_cpu_suspend_sz;
 extern unsigned int omap24xx_cpu_suspend_sz;
+extern unsigned int omap34xx_cpu_suspend_sz;
 extern unsigned int omap730_idle_loop_suspend_sz;
 extern unsigned int omap1510_idle_loop_suspend_sz;
 extern unsigned int omap1610_idle_loop_suspend_sz;
 extern unsigned int omap24xx_idle_loop_suspend_sz;
+extern unsigned int omap34xx_suspend_sz;
 
 #ifdef CONFIG_OMAP_SERIAL_WAKE
 extern void omap_serial_wake_trigger(int enable);
Signature · 1 line
1.5.5
#3 lore raw

PATCH 3/9 PM: Add pm.c file for omap2 and omap3 common code

In reply to Högander Jouni

Add pm.c file for common code and move handling of sleep_while_idle attribute and sleep_block to it.

---
 arch/arm/mach-omap2/Makefile |    2 +
 arch/arm/mach-omap2/pm.c     |   91 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/pm.h     |    4 ++
 arch/arm/mach-omap2/pm24xx.c |   49 +----------------------
 4 files changed, 98 insertions(+), 48 deletions(-)
 create mode 100644 arch/arm/mach-omap2/pm.c
arch/arm/mach-omap2/Makefile +2 -0
index 8f80382..12f6a6f 100644
@@ -12,6 +12,8 @@ obj-$(CONFIG_ARCH_OMAP2)		+= sram24xx.o
 obj-$(CONFIG_ARCH_OMAP3)		+= sram34xx.o
 
 # Power Management
+obj-$(CONFIG_PM) += pm.o
+
 ifeq ($(CONFIG_ARCH_OMAP2),y)
 obj-$(CONFIG_PM) += pm24xx.o sleep24xx.o
 endif
arch/arm/mach-omap2/pm.c new file +91 -0

91 lines not on this page · raw message

arch/arm/mach-omap2/pm.h +4 -0
index 541bf90..15482ba 100644
@@ -13,6 +13,10 @@
  * published by the Free Software Foundation.
  */
 
+extern int omap2_pm_init(void);
+extern unsigned short enable_dyn_sleep;
+extern atomic_t sleep_block;
+
 #ifdef CONFIG_PM_DEBUG
 extern u32 omap2_read_32k_sync_counter(void);
 extern void omap2_pm_dump(int mode, int resume, unsigned int us);
arch/arm/mach-omap2/pm24xx.c +1 -48

80 lines not on this page · raw message

Signature · 1 line
1.5.5
#10 lore raw

PATCH 5/9 34XX: Suspend: Take suspend sram code from ti cdp kernel

In reply to Högander Jouni

From: Karthik Dasu <[email protected]>

Take sram code from ti cdp kernel for 34XX suspend.

---
 arch/arm/mach-omap2/sleep34xx.S |  534 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 534 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/sleep34xx.S
arch/arm/mach-omap2/sleep34xx.S new file +534 -0
new file mode 100644
index 0000000..c9db507
@@ -0,0 +1,534 @@
+/*
+ * linux/arch/arm/mach-omap2/sleep.S
+ *
+ * (C) Copyright 2007
+ * Texas Instruments
+ * Karthik Dasu <[email protected]>
+ *
+ * (C) Copyright 2004
+ * Texas Instruments, <www.ti.com>
+ * Richard Woodruff <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/arch/io.h>
+#include <asm/arch/pm.h>
+
+#define PM_PREPWSTST_CORE_V	IO_ADDRESS(PRM_BASE + 0xAE8)
+#define PM_PREPWSTST_MPU_V	IO_ADDRESS(PRM_BASE + 0x9E8)
+#define PM_PWSTCTRL_MPU_P	(PRM_BASE + 0x9E0)
+#define SCRATCHPAD_BASE_P	0x48002910
+#define SDRC_POWER_V		IO_ADDRESS(SDRC_BASE + 0x070)
+
+	.text
+/* Function call to get the restore pointer for resume from OFF */
+ENTRY(get_restore_pointer)
+        stmfd   sp!, {lr}     @ save registers on stack
+	adr	r0, restore
+        ldmfd   sp!, {pc}     @ restore regs and return
+ENTRY(get_restore_pointer_sz)
+        .word   . - get_restore_pointer_sz
+/*
+ * Forces OMAP into idle state
+ *
+ * omap34xx_suspend() - This bit of code just executes the WFI
+ * for normal idles.
+ *
+ * Note: This code get's copied to internal SRAM at boot. When the OMAP
+ *	 wakes up it continues execution at the point it went to sleep.
+ */
+ENTRY(omap34xx_suspend)
+	stmfd	sp!, {r0-r12, lr}		@ save registers on stack
+loop:
+	/*b	loop*/	@Enable to debug by stepping through code
+	/* r0 contains restore pointer in sdram */
+	/* r1 contains information about saving context */
+	ldr     r4, sdrc_power          @ read the SDRC_POWER register
+	ldr     r5, [r4]                @ read the contents of SDRC_POWER
+	orr     r5, r5, #0x40           @ enable self refresh on idle req
+	str     r5, [r4]                @ write back to SDRC_POWER register
+
+	cmp	r1, #0x0
+	/* If context save is required, do that and execute wfi */
+	bne	save_context_wfi
+	/* Data memory barrier and Data sync barrier */
+	mov	r1, #0
+	mcr	p15, 0, r1, c7, c10, 4
+	mcr	p15, 0, r1, c7, c10, 5
+
+	wfi				@ wait for interrupt
+
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	bl i_dll_wait
+
+	ldmfd	sp!, {r0-r12, pc}		@ restore regs and return
+restore:
+	/* b restore*/ 	@ Enable to debug restore code
+        /* Check what was the reason for mpu reset and store the reason in r9*/
+        /* 1 - Only L1 and logic lost */
+        /* 2 - Only L2 lost - In this case, we wont be here */
+        /* 3 - Both L1 and L2 lost */
+	ldr     r1, pm_pwstctrl_mpu
+	ldr	r2, [r1]
+	and     r2, r2, #0x3
+	cmp     r2, #0x0	@ Check if target power state was OFF or RET
+        moveq   r9, #0x3        @ MPU OFF => L1 and L2 lost
+	movne	r9, #0x1	@ Only L1 and L2 lost => avoid L2 invalidation
+	bne	logic_l1_restore
+	/* Execute smi to invalidate L2 cache */
+	mov r12, #0x1                         @ set up to invalide L2
+smi:    .word 0xE1600070                @ Call SMI monitor (smieq)
+logic_l1_restore:
+	mov	r1, #0
+	/* Invalidate all instruction caches to PoU
+	 * and flush branch target cache */
+	mcr	p15, 0, r1, c7, c5, 0
+
+	ldr	r4, scratchpad_base
+	ldr	r3, [r4,#0xBC]
+	ldmia	r3!, {r4-r6}
+	mov	sp, r4
+	msr	spsr_cxsf, r5
+	mov	lr, r6
+
+	ldmia	r3!, {r4-r9}
+	/* Coprocessor access Control Register */
+	mcr p15, 0, r4, c1, c0, 2
+
+	/* TTBR0 */
+	MCR p15, 0, r5, c2, c0, 0
+	/* TTBR1 */
+	MCR p15, 0, r6, c2, c0, 1
+	/* Translation table base control register */
+	MCR p15, 0, r7, c2, c0, 2
+	/*domain access Control Register */
+	MCR p15, 0, r8, c3, c0, 0
+	/* data fault status Register */
+	MCR p15, 0, r9, c5, c0, 0
+
+	ldmia  r3!,{r4-r8}
+	/* instruction fault status Register */
+	MCR p15, 0, r4, c5, c0, 1
+	/*Data Auxiliary Fault Status Register */
+	MCR p15, 0, r5, c5, c1, 0
+	/*Instruction Auxiliary Fault Status Register*/
+	MCR p15, 0, r6, c5, c1, 1
+	/*Data Fault Address Register */
+	MCR p15, 0, r7, c6, c0, 0
+	/*Instruction Fault Address Register*/
+	MCR p15, 0, r8, c6, c0, 2
+	ldmia  r3!,{r4-r7}
+
+	/* user r/w thread and process ID */
+	MCR p15, 0, r4, c13, c0, 2
+	/* user ro thread and process ID */
+	MCR p15, 0, r5, c13, c0, 3
+	/*Privileged only thread and process ID */
+	MCR p15, 0, r6, c13, c0, 4
+	/* cache size selection */
+	MCR p15, 2, r7, c0, c0, 0
+	ldmia  r3!,{r4-r8}
+	/* Data TLB lockdown registers */
+	MCR p15, 0, r4, c10, c0, 0
+	/* Instruction TLB lockdown registers */
+	MCR p15, 0, r5, c10, c0, 1
+	/* Secure or Nonsecure Vector Base Address */
+	MCR p15, 0, r6, c12, c0, 0
+	/* FCSE PID */
+	MCR p15, 0, r7, c13, c0, 0
+	/* Context PID */
+	MCR p15, 0, r8, c13, c0, 1
+
+	ldmia  r3!,{r4-r5}
+	/* primary memory remap register */
+	MCR p15, 0, r4, c10, c2, 0
+	/*normal memory remap register */
+	MCR p15, 0, r5, c10, c2, 1
+
+	/* Restore registers for other modes from SDRAM */
+	/* Save current mode */
+	mrs	r7, cpsr
+
+	/* FIQ mode */
+	bic	r0, r7, #0x1F
+	orr	r0, r0, #0x11
+	msr	cpsr, r0
+	ldmia	r3!, {r8-r12}
+	/* load the SP and LR from SDRAM */
+	ldmia  r3!,{r4-r6}
+	mov    sp, r4	/*update the SP */
+	mov    lr, r5	/*update the LR */
+	msr    spsr, r6	/*update the SPSR*/
+
+	/* IRQ mode */
+	bic    r0, r7, #0x1F
+	orr    r0, r0, #0x12
+	msr    cpsr, r0	/*go into IRQ mode*/
+	ldmia  r3!,{r4-r6}	/*load the SP and LR from SDRAM*/
+	mov    sp, r4	/*update the SP */
+	mov    lr, r5	/*update the LR */
+	msr    spsr, r6	/*update the SPSR */
+
+	/* ABORT mode */
+	bic    r0, r7, #0x1F
+	orr    r0, r0, #0x17
+	msr    cpsr, r0	/* go into ABORT mode */
+	ldmia  r3!,{r4-r6}	/*load the SP and LR from SDRAM */
+	mov    sp, r4		/*update the SP */
+	mov    lr, r5		/*update the LR */
+	msr    spsr, r6		/*update the SPSR */
+
+	/* UNDEEF mode */
+	bic    r0, r7, #0x1F
+	orr    r0, r0, #0x1B
+	msr    cpsr, r0		/*go into UNDEF mode */
+	ldmia  r3!,{r4-r6}	/*load the SP and LR from SDRAM */
+	mov    sp, r4		/*update the SP*/
+	mov    lr, r5		/*update the LR*/
+	msr    spsr, r6		/*update the SPSR*/
+
+	/* SYSTEM (USER) mode */
+	bic    r0, r7, #0x1F
+	orr    r0, r0, #0x1F
+	msr    cpsr, r0		/*go into USR mode */
+	ldmia  r3!,{r4-r6}	/*load the SP and LR from SDRAM*/
+	mov    sp, r4		/*update the SP */
+	mov    lr, r5		/*update the LR */
+	msr    spsr, r6		/*update the SPSR */
+	msr    cpsr, r7		/*back to original mode*/
+
+	/* Restore cpsr */
+	ldmia	r3!,{r4}	/*load CPSR from SDRAM*/
+	msr	cpsr, r4	/*store cpsr */
+
+	/* Enabling MMU here */
+	mrc	p15, 0, r7, c2, c0, 2 /* Read TTBRControl */
+	/* Extract N (0:2) bits and decide whether to use TTBR0 or TTBR1*/
+	and	r7, #0x7
+	cmp	r7, #0x0
+	beq	usettbr0
+ttbr_error:
+	/* More work needs to be done to support N[0:2] value other than 0
+	* So looping here so that the error can be detected
+	*/
+	b	ttbr_error
+usettbr0:
+	mrc	p15, 0, r2, c2, c0, 0
+	ldr	r5, ttbrbit_mask
+	and	r2, r5
+	mov	r4, pc
+	ldr	r5, table_index_mask
+	and	r4, r5 /* r4 = 31 to 20 bits of pc */
+	/* Extract the value to be written to table entry */
+	ldr	r1, table_entry
+	add	r1, r1, r4 /* r1 has value to be written to table entry*/
+	/* Getting the address of table entry to modify */
+	lsr	r4, #18
+	add	r2, r4 /* r2 has the location which needs to be modified */
+	/* Storing previous entry of location being modified */
+	ldr	r5, scratchpad_base
+	ldr	r4, [r2]
+	str	r4, [r5, #0xC0]
+	/* Modify the table entry */
+	str	r1, [r2]
+	/* Storing address of entry being modified
+	 * - will be restored after enabling MMU */
+	ldr	r5, scratchpad_base
+	str	r2, [r5, #0xC4]
+
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 4	@ Flush prefetch buffer
+	mcr	p15, 0, r0, c7, c5, 6	@ Invalidate branch predictor array
+	mcr	p15, 0, r0, c8, c5, 0	@ Invalidate instruction TLB
+	mcr	p15, 0, r0, c8, c6, 0	@ Invalidate data TLB
+	/* Restore control register  but dont enable caches here*/
+	/* Caches will be enabled after restoring MMU table entry */
+	ldmia	r3!, {r4}
+	/* Store previous value of control register in scratchpad */
+	str	r4, [r5, #0xC8]
+	ldr	r2, cache_pred_disable_mask
+	and	r4, r2
+	mcr	p15, 0, r4, c1, c0, 0
+
+	ldmfd	sp!, {r0-r12, pc}		@ restore regs and return
+save_context_wfi:
+	/*b	save_context_wfi*/	@ enable to debug save code
+	mov	r8, r0 /* Store SDRAM address in r8 */
+        /* Check what that target sleep state is:stored in r1*/
+        /* 1 - Only L1 and logic lost */
+        /* 2 - Only L2 lost */
+        /* 3 - Both L1 and L2 lost */
+	cmp	r1, #0x2 /* Only L2 lost */
+	beq	clean_l2
+	cmp	r1, #0x1 /* L2 retained */
+	/* r9 stores whether to clean L2 or not*/
+	moveq	r9, #0x0 /* Dont Clean L2 */
+	movne	r9, #0x1 /* Clean L2 */
+l1_logic_lost:
+	/* Store sp and spsr to SDRAM */
+	mov	r4, sp
+	mrs	r5, spsr
+	mov	r6, lr
+	stmia	r8!, {r4-r6}
+	/* Save all ARM registers */
+	/* Coprocessor access control register */
+	mrc	p15, 0, r6, c1, c0, 2
+	stmia	r8!, {r6}
+	/* TTBR0, TTBR1 and Translation table base control */
+	mrc	p15, 0, r4, c2, c0, 0
+	mrc	p15, 0, r5, c2, c0, 1
+	mrc	p15, 0, r6, c2, c0, 2
+	stmia	r8!, {r4-r6}
+	/* Domain access control register, data fault status register,
+	and instruction fault status register */
+	mrc	p15, 0, r4, c3, c0, 0
+	mrc	p15, 0, r5, c5, c0, 0
+	mrc	p15, 0, r6, c5, c0, 1
+	stmia	r8!, {r4-r6}
+	/* Data aux fault status register, instruction aux fault status,
+	datat fault address register and instruction fault address register*/
+	mrc	p15, 0, r4, c5, c1, 0
+	mrc	p15, 0, r5, c5, c1, 1
+	mrc	p15, 0, r6, c6, c0, 0
+	mrc	p15, 0, r7, c6, c0, 2
+	stmia	r8!, {r4-r7}
+	/* user r/w thread and process ID, user r/o thread and process ID,
+	priv only thread and process ID, cache size selection */
+	mrc	p15, 0, r4, c13, c0, 2
+	mrc	p15, 0, r5, c13, c0, 3
+	mrc	p15, 0, r6, c13, c0, 4
+	mrc	p15, 2, r7, c0, c0, 0
+	stmia	r8!, {r4-r7}
+	/* Data TLB lockdown, instruction TLB lockdown registers */
+	mrc	p15, 0, r5, c10, c0, 0
+	mrc	p15, 0, r6, c10, c0, 1
+	stmia	r8!, {r5-r6}
+	/* Secure or non secure vector base address, FCSE PID, Context PID*/
+	mrc	p15, 0, r4, c12, c0, 0
+	mrc	p15, 0, r5, c13, c0, 0
+	mrc	p15, 0, r6, c13, c0, 1
+	stmia	r8!, {r4-r6}
+	/* Primary remap, normal remap registers */
+	mrc	p15, 0, r4, c10, c2, 0
+	mrc	p15, 0, r5, c10, c2, 1
+	stmia	r8!,{r4-r5}
+	/* Store SP, LR, SPSR registers for SUP, FIQ, IRQ, ABORT and USER
+	modes into SDRAM */
+
+	/* move SDRAM address to r7 as r8 is banked in FIQ*/
+	mov	r7, r8
+
+	/* Save current mode */
+	mrs	r2, cpsr
+	/* FIQ mode */
+	bic	r0, r2, #0x1F
+	orr	r0, r0, #0x11
+	msr	cpsr, r0 /* go to FIQ mode */
+	stmia	r7!, {r8-r12}
+	mov	r4, r13 /* move SP into r4*/
+	mov	r5, r14
+	mrs	r6, spsr
+	stmia	r7!, {r4-r6}
+
+	/* IRQ mode */
+	bic	r0, r2, #0x1F
+	orr	r0, r0, #0x12
+	msr	cpsr, r0
+	mov	r4, r13
+	mov	r5, r14
+	mrs	r6, spsr
+	stmia	r7!, {r4-r6}
+
+	/* Abort mode */
+	bic	r0, r2, #0x1F
+	orr	r0, r0, #0x17
+	msr	cpsr, r0
+	mov	r4, r13
+	mov	r5, r14
+	mrs	r6, spsr
+	stmia	r7!, {r4-r6}
+
+	/* UNDEF mode */
+	bic	r0, r2, #0x1F
+	orr	r0, r0, #0x1B
+	msr	cpsr, r0
+	mov	r4, r13
+	mov	r5, r14
+	mrs	r6, spsr
+	stmia	r7!, {r4-r6}
+
+	/* System (USER mode) */
+	bic	r0, r2, #0x1F
+	orr	r0, r0, #0x1F
+	msr	cpsr, r0
+	mov	r4, r13
+	mov	r5, r14
+	mrs	r6, spsr
+	stmia	r7!, {r4-r6}
+
+	/* Back to original mode */
+	msr	cpsr, r2
+
+	/* Store current cpsr*/
+	stmia	r7!, {r2}
+
+	mrc	p15, 0, r4, c1, c0, 0
+	/* save control register */
+	stmia	r7!, {r4}
+clean_caches:
+	/* Clean Data or unified cache to POU*/
+	/* How to invalidate only L1 cache???? - #FIX_ME# */
+	/* mcr	p15, 0, r11, c7, c11, 1 */
+	cmp	r9, #1 /* Check whether L2 inval is required or not*/
+	bne	skip_l2_inval
+clean_l2:
+	/* read clidr */
+	mrc     p15, 1, r0, c0, c0, 1
+	/* extract loc from clidr */
+	ands    r3, r0, #0x7000000
+	/* left align loc bit field */
+	mov     r3, r3, lsr #23
+	/* if loc is 0, then no need to clean */
+	beq     finished
+	/* start clean at cache level 0 */
+	mov     r10, #0
+loop1:
+	/* work out 3x current cache level */
+	add     r2, r10, r10, lsr #1
+	/* extract cache type bits from clidr*/
+	mov     r1, r0, lsr r2
+	/* mask of the bits for current cache only */
+	and     r1, r1, #7
+	/* see what cache we have at this level */
+	cmp     r1, #2
+	/* skip if no cache, or just i-cache */
+	blt     skip
+	/* select current cache level in cssr */
+	mcr     p15, 2, r10, c0, c0, 0
+	/* isb to sych the new cssr&csidr */
+	isb
+	/* read the new csidr */
+	mrc     p15, 1, r1, c0, c0, 0
+	/* extract the length of the cache lines */
+	and     r2, r1, #7
+	/* add 4 (line length offset) */
+	add     r2, r2, #4
+	ldr     r4, assoc_mask
+	/* find maximum number on the way size */
+	ands    r4, r4, r1, lsr #3
+	/* find bit position of way size increment */
+	clz     r5, r4
+	ldr     r7, numset_mask
+	/* extract max number of the index size*/
+	ands    r7, r7, r1, lsr #13
+loop2:
+	mov     r9, r4
+	/* create working copy of max way size*/
+loop3:
+	/* factor way and cache number into r11 */
+	orr     r11, r10, r9, lsl r5
+	/* factor index number into r11 */
+	orr     r11, r11, r7, lsl r2
+	/*clean & invalidate by set/way */
+	mcr     p15, 0, r11, c7, c10, 2
+	/* decrement the way*/
+	subs    r9, r9, #1
+	bge     loop3
+	/*decrement the index */
+	subs    r7, r7, #1
+	bge     loop2
+skip:
+	add     r10, r10, #2
+	/* increment cache number */
+	cmp     r3, r10
+	bgt     loop1
+finished:
+	/*swith back to cache level 0 */
+	mov     r10, #0
+	/* select current cache level in cssr */
+	mcr     p15, 2, r10, c0, c0, 0
+	isb
+skip_l2_inval:
+	/* Data memory barrier and Data sync barrier */
+	mov     r1, #0
+	mcr     p15, 0, r1, c7, c10, 4
+	mcr     p15, 0, r1, c7, c10, 5
+
+	wfi                             @ wait for interrupt
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	bl i_dll_wait
+	/* restore regs and return */
+	ldmfd   sp!, {r0-r12, pc}
+
+i_dll_wait:
+	ldr     r4, clk_stabilize_delay
+
+i_dll_delay:
+	subs    r4, r4, #0x1
+	bne     i_dll_delay
+	ldr     r4, sdrc_power
+	ldr     r5, [r4]
+	bic     r5, r5, #0x40
+	str     r5, [r4]
+	bx	lr
+pm_prepwstst_core:
+	.word	PM_PREPWSTST_CORE_V
+pm_prepwstst_mpu:
+	.word	PM_PREPWSTST_MPU_V
+pm_pwstctrl_mpu:
+	.word	PM_PWSTCTRL_MPU_P
+scratchpad_base:
+	.word	SCRATCHPAD_BASE_P
+sdrc_power:
+	.word SDRC_POWER_V
+context_mem:
+	.word	0x803E3E14
+clk_stabilize_delay:
+	.word 0x000001FF
+assoc_mask:
+	.word	0x3ff
+numset_mask:
+	.word	0x7fff
+ttbrbit_mask:
+	.word	0xFFFFC000
+table_index_mask:
+	.word	0xFFF00000
+table_entry:
+	.word	0x00000C02
+cache_pred_disable_mask:
+	.word	0xFFFFE7FB
+ENTRY(omap34xx_suspend_sz)
+	.word	. - omap34xx_suspend
Signature · 1 line
1.5.5
#12 lore raw

PATCH 7/9 34XX: Add miscellaneous definitions related to 34xx

In reply to Högander Jouni
---
 arch/arm/mach-omap2/cm-regbits-34xx.h  |    7 +++++++
 arch/arm/mach-omap2/prm-regbits-34xx.h |    9 +++++++++
 arch/arm/mach-omap2/prm.h              |   24 +++++++++++++-----------
 include/asm-arm/arch-omap/irqs.h       |    1 +
 4 files changed, 30 insertions(+), 11 deletions(-)
arch/arm/mach-omap2/cm-regbits-34xx.h +7 -0
index 219f5c8..6ec66f4 100644
@@ -208,6 +208,10 @@
 #define OMAP3430ES2_ST_USBTLL_MASK			(1 << 2)
 
 /* CM_AUTOIDLE1_CORE */
+#define OMAP3430ES2_AUTO_MMC3				(1 << 30)
+#define OMAP3430ES2_AUTO_MMC3_SHIFT			30
+#define OMAP3430ES2_AUTO_ICR				(1 << 29)
+#define OMAP3430ES2_AUTO_ICR_SHIFT			29
 #define OMAP3430_AUTO_AES2				(1 << 28)
 #define OMAP3430_AUTO_AES2_SHIFT			28
 #define OMAP3430_AUTO_SHA12				(1 << 27)
@@ -276,6 +280,9 @@
 #define OMAP3430_AUTO_DES1_SHIFT			0
 
 /* CM_AUTOIDLE3_CORE */
+#define	OMAP3430ES2_AUTO_USBHOST			(1 << 0)
+#define	OMAP3430ES2_AUTO_USBHOST_SHIFT			0
+#define	OMAP3430ES2_AUTO_USBTLL				(1 << 2)
 #define OMAP3430ES2_AUTO_USBTLL_SHIFT			2
 #define OMAP3430ES2_AUTO_USBTLL_MASK			(1 << 2)
 
arch/arm/mach-omap2/prm-regbits-34xx.h +9 -0
index 5b5ecfe..c6a7940 100644
@@ -366,6 +366,7 @@
 
 /* PM_WKEN_WKUP specific bits */
 #define OMAP3430_EN_IO					(1 << 8)
+#define OMAP3430_EN_GPIO1				(1 << 3)
 
 /* PM_MPUGRPSEL_WKUP specific bits */
 
@@ -452,6 +453,14 @@
 #define OMAP3430_CMDRA0_MASK				(0xff << 0)
 
 /* PRM_VC_CMD_VAL_0 specific bits */
+#define OMAP3430_VC_CMD_ON_SHIFT			24
+#define OMAP3430_VC_CMD_ON_MASK				(0xFF << 24)
+#define OMAP3430_VC_CMD_ONLP_SHIFT			16
+#define OMAP3430_VC_CMD_ONLP_MASK			(0xFF << 16)
+#define OMAP3430_VC_CMD_RET_SHIFT			8
+#define OMAP3430_VC_CMD_RET_MASK			(0xFF << 8)
+#define OMAP3430_VC_CMD_OFF_SHIFT			0
+#define OMAP3430_VC_CMD_OFF_MASK			(0xFF << 0)
 
 /* PRM_VC_CMD_VAL_1 specific bits */
 
arch/arm/mach-omap2/prm.h +13 -11
index f816165..27d44e2 100644
@@ -142,6 +142,19 @@ static __inline__ u32 __attribute__((unused)) prm_rmw_reg_bits(u32 mask,
 #define PM_PWSTCTRL					0x00e0
 #define PM_PWSTST					0x00e4
 
+/* Omap2 specific registers */
+#define OMAP24XX_PM_WKEN2				0x00a4
+#define OMAP24XX_PM_WKST2				0x00b4
+
+#define OMAP24XX_PRCM_IRQSTATUS_DSP			0x00f0	/* IVA mod */
+#define OMAP24XX_PRCM_IRQENABLE_DSP			0x00f4	/* IVA mod */
+#define OMAP24XX_PRCM_IRQSTATUS_IVA			0x00f8
+#define OMAP24XX_PRCM_IRQENABLE_IVA			0x00fc
+
+/* Omap3 specific registers */
+#define OMAP3430ES2_PM_WKEN3				0x00f0
+#define OMAP3430ES2_PM_WKST3				0x00b8
+
 #define OMAP3430_PM_MPUGRPSEL				0x00a4
 #define OMAP3430_PM_MPUGRPSEL1				OMAP3430_PM_MPUGRPSEL
 
@@ -172,16 +185,6 @@ static u32 __attribute__((unused)) prm_clear_mod_reg_bits(u32 bits, s16 module,
 	return prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
 }
 
-/* Architecture-specific registers */
-
-#define OMAP24XX_PM_WKEN2				0x00a4
-#define OMAP24XX_PM_WKST2				0x00b4
-
-#define OMAP24XX_PRCM_IRQSTATUS_DSP			0x00f0	/* IVA mod */
-#define OMAP24XX_PRCM_IRQENABLE_DSP			0x00f4	/* IVA mod */
-#define OMAP24XX_PRCM_IRQSTATUS_IVA			0x00f8
-#define OMAP24XX_PRCM_IRQENABLE_IVA			0x00fc
-
 /* Power/reset management domain register get/set */
 
 static __inline__ void __attribute__((unused)) prm_write_mod_reg(u32 val,
@@ -243,7 +246,6 @@ static __inline__ u32 __attribute__((unused)) prm_read_mod_reg(s16 module,
 #define OMAP_RSTTIME1_SHIFT				0
 #define OMAP_RSTTIME1_MASK				(0xff << 0)
 
-
 /* PRM_RSTCTRL */
 /* Named RM_RSTCTRL_WKUP on the 24xx */
 /* 2420 calls RST_DPLL3 'RST_DPLL' */
include/asm-arm/arch-omap/irqs.h +1 -0
index 343e93e..f901e8b 100644
@@ -300,6 +300,7 @@
 #define INT_34XX_ST_MCBSP2_IRQ	4
 #define INT_34XX_ST_MCBSP3_IRQ	5
 #define INT_34XX_SYS_NIRQ	7
+#define INT_34XX_PRCM_MPU_IRQ	11
 #define INT_34XX_MCBSP1_IRQ	16
 #define INT_34XX_MCBSP2_IRQ	17
 #define INT_34XX_MCBSP3_IRQ	22
Signature · 1 line
1.5.5
#14 lore raw

PATCH 9/9 OMAP3430SDP: Enable config options CONFIG_OMAP_RESET_CLOCKS and CONFIG_SUSPEND

In reply to Högander Jouni
---
 arch/arm/configs/omap_3430sdp_defconfig |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/configs/omap_3430sdp_defconfig +2 -2
index 0fef29d..9e4af26 100644
@@ -168,7 +168,7 @@ CONFIG_ARCH_OMAP3=y
 # OMAP Feature Selections
 #
 CONFIG_OMAP_DEBUG_SRAM_PATCH=y
-# CONFIG_OMAP_RESET_CLOCKS is not set
+CONFIG_OMAP_RESET_CLOCKS=y
 CONFIG_OMAP_BOOT_TAG=y
 CONFIG_OMAP_BOOT_REASON=y
 # CONFIG_OMAP_COMPONENT_VERSION is not set
@@ -308,7 +308,7 @@ CONFIG_BINFMT_MISC=y
 CONFIG_PM=y
 # CONFIG_PM_LEGACY is not set
 # CONFIG_PM_DEBUG is not set
-# CONFIG_SUSPEND is not set
+CONFIG_SUSPEND=y
 # CONFIG_APM_EMULATION is not set
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
Signature · 1 line
1.5.5
#13 lore raw

PATCH 8/9 34XX: PM: Initial version of suspend and dynamic retention

In reply to Högander Jouni

This is initial version of suspend and dynamic retention for 34xx. Omap is tried to put to full retention on suspend and pm_idle.

---
 arch/arm/mach-omap2/Makefile |    3 +
 arch/arm/mach-omap2/pm.c     |    4 +-
 arch/arm/mach-omap2/pm.h     |    2 +
 arch/arm/mach-omap2/pm34xx.c |  386 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 394 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/pm34xx.c
arch/arm/mach-omap2/Makefile +3 -0
index 12f6a6f..6168aa4 100644
@@ -18,6 +18,9 @@ ifeq ($(CONFIG_ARCH_OMAP2),y)
 obj-$(CONFIG_PM) += pm24xx.o sleep24xx.o
 endif
 
+ifeq ($(CONFIG_ARCH_OMAP3),y)
+obj-$(CONFIG_PM) += pm34xx.o sleep34xx.o
+endif
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 
 # Clock framework
arch/arm/mach-omap2/pm.c +3 -1
index 55ed75b..bef58d7 100644
@@ -74,8 +74,10 @@ int __init omap_pm_init(void)
 
 	if (cpu_is_omap24xx())
 		error = omap2_pm_init();
+	if (cpu_is_omap34xx())
+		error = omap3_pm_init();
 	if (error) {
-		printk(KERN_ERR "omap2_pm_init failed: %d\n", error);
+		printk(KERN_ERR "omap2|3_pm_init failed: %d\n", error);
 		return error;
 	}
 
arch/arm/mach-omap2/pm.h +2 -0
index 15482ba..351456e 100644
@@ -14,6 +14,8 @@
  */
 
 extern int omap2_pm_init(void);
+extern int omap3_pm_init(void);
+
 extern unsigned short enable_dyn_sleep;
 extern atomic_t sleep_block;
 
arch/arm/mach-omap2/pm34xx.c new file +386 -0

386 lines not on this page · raw message

Signature · 1 line
1.5.5
maintainer
#5 lore raw

Re: [PATCH 4/9] OMAP: Add new function to check wether there is irq pending

In reply to Jouni Hogander

Hi,

Quoted 44 lines · Jouni Hogander

Add common omap2/3 function to check wether there is irq pending. Switch to use it in omap2 pm code instead of its own.

---
 arch/arm/mach-omap2/irq.c        |   29 +++++++++++++++++++++++------
 arch/arm/mach-omap2/pm24xx.c     |   19 +++----------------
 include/asm-arm/arch-omap/irqs.h |    1 +
 3 files changed, 27 insertions(+), 22 deletions(-)
arch/arm/mach-omap2/irq.c +13 -6
index ac062ee..f1e1e2e 100644
@@ -20,12 +20,13 @@
 
 /* selected INTC register offsets */
 
-#define INTC_REVISION	0x0000
-#define INTC_SYSCONFIG	0x0010
-#define INTC_SYSSTATUS	0x0014
-#define INTC_CONTROL	0x0048
-#define INTC_MIR_CLEAR0	0x0088
-#define INTC_MIR_SET0	0x008c
+#define INTC_REVISION		0x0000
+#define INTC_SYSCONFIG		0x0010
+#define INTC_SYSSTATUS		0x0014
+#define INTC_CONTROL		0x0048
+#define INTC_MIR_CLEAR0		0x0088
+#define INTC_MIR_SET0		0x008c
+#define INTC_PENDING_IRQ0	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,22 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
+		struct omap_irq_bank *bank = irq_banks + i;

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 141

Quoted 10 lines
arch/arm/mach-omap2/irq.c +10 -0
+		int irq;
+
+		for (irq = 0; irq < bank->nr_irqs; irq += 32)
+			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
+					       ((irq >> 5) << 5)))
+				return 1;
+	}
+	return 0;
+}
+

In this case it should be enough to know if anything is set in the bank registers, so you should be able to leave out the second for loop. At most you need to read only the four bank registers. No need to check for individual interrupts.

Quoted 73 lines
arch/arm/mach-omap2/irq.c +0 -0
 void __init omap_init_irq(void)
 {
 	unsigned long nr_irqs = 0;
arch/arm/mach-omap2/pm24xx.c +3 -16
index 7bb654f..8636f1c 100644
@@ -74,19 +74,6 @@ static int omap2_fclks_active(void)
 	return 0;
 }
 
-static int omap2_irq_pending(void)
-{
-	u32 pending_reg = 0x480fe098;
-	int i;
-
-	for (i = 0; i < 4; i++) {
-		if (omap_readl(pending_reg))
-			return 1;
-		pending_reg += 0x20;
-	}
-	return 0;
-}
-
 static void omap2_enter_full_retention(void)
 {
 	u32 l, sleep_time = 0;
@@ -121,7 +108,7 @@ static void omap2_enter_full_retention(void)
 
 	/* One last check for pending IRQs to avoid extra latency due
 	 * to sleeping unnecessarily. */
-	if (omap2_irq_pending())
+	if (omap_irq_pending())
 		goto no_sleep;
 
 	serial_console_sleep(1);
@@ -272,7 +259,7 @@ static void omap2_pm_idle(void)
 		 */
 		if (atomic_read(&sleep_block) == 0) {
 			timer_dyn_reprogram();
-			if (omap2_irq_pending())
+			if (omap_irq_pending())
 				goto out;
 		}
 		omap2_enter_mpu_retention();
@@ -286,7 +273,7 @@ static void omap2_pm_idle(void)
 	 */
 	timer_dyn_reprogram();
 
-	if (omap2_irq_pending())
+	if (omap_irq_pending())
 		goto out;
 
 	omap2_enter_full_retention();
include/asm-arm/arch-omap/irqs.h +1 -0
index c80e160..343e93e 100644
@@ -368,6 +368,7 @@
 
 #ifndef __ASSEMBLY__
 extern void omap_init_irq(void);
+extern int omap_irq_pending(void);
 #endif
 
 #include <asm/hardware.h>
Signature · 6 lines
1.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: [PATCH 4/9] OMAP: Add new function to check wether there is irq pending

Quoted 54 lines · ext Tony Lindgren

Hi,

Quoted 51 lines · Jouni Hogander

Add common omap2/3 function to check wether there is irq pending. Switch to use it in omap2 pm code instead of its own.

---
 arch/arm/mach-omap2/irq.c        |   29 +++++++++++++++++++++++------
 arch/arm/mach-omap2/pm24xx.c     |   19 +++----------------
 include/asm-arm/arch-omap/irqs.h |    1 +
 3 files changed, 27 insertions(+), 22 deletions(-)
arch/arm/mach-omap2/irq.c +20 -6
index ac062ee..f1e1e2e 100644
@@ -20,12 +20,13 @@
 
 /* selected INTC register offsets */
 
-#define INTC_REVISION	0x0000
-#define INTC_SYSCONFIG	0x0010
-#define INTC_SYSSTATUS	0x0014
-#define INTC_CONTROL	0x0048
-#define INTC_MIR_CLEAR0	0x0088
-#define INTC_MIR_SET0	0x008c
+#define INTC_REVISION		0x0000
+#define INTC_SYSCONFIG		0x0010
+#define INTC_SYSSTATUS		0x0014
+#define INTC_CONTROL		0x0048
+#define INTC_MIR_CLEAR0		0x0088
+#define INTC_MIR_SET0		0x008c
+#define INTC_PENDING_IRQ0	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,22 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
+		struct omap_irq_bank *bank = irq_banks + i;
+		int irq;
+
+		for (irq = 0; irq < bank->nr_irqs; irq += 32)
+			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
+					       ((irq >> 5) << 5)))
+				return 1;
+	}
Quoted 8 lines

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 141

Quoted 3 lines
arch/arm/mach-omap2/irq.c +3 -0
+	return 0;
+}
+

In this case it should be enough to know if anything is set in the bank registers, so you should be able to leave out the second for loop. At most you need to read only the four bank registers. No need to check for individual interrupts.

Current code is presenting each interrupt controller as a bank. I think in TRM they are talking about banks in each controller. So there is three banks in mpu intc 0..2. This is in arch/arm/mach-omap2/irq.c:

* OMAP2 has a number of different interrupt controllers, each interrupt
* controller is identified as its own "bank". Register definitions are
* fairly consistent for each bank, but not all registers are implemented
* for each bank.. when in doubt, consult the TRM.
*/

So the first loop is going through controllers which is only mpu intc. Second loop is going through bank registers. I'm using irq only for finding out right offset for bank register. This is another implementation. Which does exactly same thing:

int omap_irq_pending(void)

{
	int i, j;

	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
		struct omap_irq_bank *bank = irq_banks + i;

		for (j = 0; j < 3; j++)
			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
					       0x20 * j))
				return 1;
	}
	return 0;
}

If you think this is better I can change it. In first version I was just trying to follow practices used in irq.c for finding out offsets.

Signature · 6 lines
Jouni Högander

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#7 lore raw

Re: [PATCH 4/9] OMAP: Add new function to check wether there is irq pending

Quoted 95 lines · Högander Jouni
Quoted 54 lines · ext Tony Lindgren

Hi,

Quoted 51 lines · Jouni Hogander

Add common omap2/3 function to check wether there is irq pending. Switch to use it in omap2 pm code instead of its own.

---
 arch/arm/mach-omap2/irq.c        |   29 +++++++++++++++++++++++------
 arch/arm/mach-omap2/pm24xx.c     |   19 +++----------------
 include/asm-arm/arch-omap/irqs.h |    1 +
 3 files changed, 27 insertions(+), 22 deletions(-)
arch/arm/mach-omap2/irq.c +20 -6
index ac062ee..f1e1e2e 100644
@@ -20,12 +20,13 @@
 
 /* selected INTC register offsets */
 
-#define INTC_REVISION	0x0000
-#define INTC_SYSCONFIG	0x0010
-#define INTC_SYSSTATUS	0x0014
-#define INTC_CONTROL	0x0048
-#define INTC_MIR_CLEAR0	0x0088
-#define INTC_MIR_SET0	0x008c
+#define INTC_REVISION		0x0000
+#define INTC_SYSCONFIG		0x0010
+#define INTC_SYSSTATUS		0x0014
+#define INTC_CONTROL		0x0048
+#define INTC_MIR_CLEAR0		0x0088
+#define INTC_MIR_SET0		0x008c
+#define INTC_PENDING_IRQ0	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,22 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
+		struct omap_irq_bank *bank = irq_banks + i;
+		int irq;
+
+		for (irq = 0; irq < bank->nr_irqs; irq += 32)
+			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
+					       ((irq >> 5) << 5)))
+				return 1;
+	}
Quoted 8 lines

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 141

Quoted 3 lines
arch/arm/mach-omap2/irq.c +3 -0
+	return 0;
+}
+

In this case it should be enough to know if anything is set in the bank registers, so you should be able to leave out the second for loop. At most you need to read only the four bank registers. No need to check for individual interrupts.

Current code is presenting each interrupt controller as a bank. I think in TRM they are talking about banks in each controller. So there is three banks in mpu intc 0..2. This is in arch/arm/mach-omap2/irq.c:

* OMAP2 has a number of different interrupt controllers, each interrupt
* controller is identified as its own "bank". Register definitions are
* fairly consistent for each bank, but not all registers are implemented
* for each bank.. when in doubt, consult the TRM.
*/

So the first loop is going through controllers which is only mpu intc. Second loop is going through bank registers. I'm using irq only for finding out right offset for bank register. This is another implementation. Which does exactly same thing:

int omap_irq_pending(void)

{
	int i, j;

	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
		struct omap_irq_bank *bank = irq_banks + i;

		for (j = 0; j < 3; j++)
			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
					       0x20 * j))
				return 1;
	}
	return 0;
}
Quoted 2 lines

If you think this is better I can change it. In first version I was just trying to follow practices used in irq.c for finding out offsets.

Hmm, AFAIK, something like below should be enough to see if any interrupts are pending (patch untested). See also include/asm-arm/arch-omap/entry-macro.S and what pm.c was doing.

Regards,

Tony

arch/arm/mach-omap2/irq.c +15 -0
index ac062ee..aef28ab 100644
@@ -26,6 +26,7 @@
 #define INTC_CONTROL	0x0048
 #define INTC_MIR_CLEAR0	0x0088
 #define INTC_MIR_SET0	0x008c
+#define INTC_PENDING	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,20 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
+		struct omap_irq_bank *bank = irq_banks + i;
+
+		if (intc_bank_read_reg(bank, INTC_PENDING))
+			return 1;
+	}
+
+	return 0;
+}
+
 void __init omap_init_irq(void)
 {
 	unsigned long nr_irqs = 0;
#8 lore raw

Re: [PATCH 4/9] OMAP: Add new function to check wether there is irq pending

Quoted 96 lines · ext Tony Lindgren
Quoted 95 lines · Högander Jouni
Quoted 54 lines · ext Tony Lindgren

Hi,

Quoted 51 lines · Jouni Hogander

Add common omap2/3 function to check wether there is irq pending. Switch to use it in omap2 pm code instead of its own.

---
 arch/arm/mach-omap2/irq.c        |   29 +++++++++++++++++++++++------
 arch/arm/mach-omap2/pm24xx.c     |   19 +++----------------
 include/asm-arm/arch-omap/irqs.h |    1 +
 3 files changed, 27 insertions(+), 22 deletions(-)
arch/arm/mach-omap2/irq.c +20 -6
index ac062ee..f1e1e2e 100644
@@ -20,12 +20,13 @@
 
 /* selected INTC register offsets */
 
-#define INTC_REVISION	0x0000
-#define INTC_SYSCONFIG	0x0010
-#define INTC_SYSSTATUS	0x0014
-#define INTC_CONTROL	0x0048
-#define INTC_MIR_CLEAR0	0x0088
-#define INTC_MIR_SET0	0x008c
+#define INTC_REVISION		0x0000
+#define INTC_SYSCONFIG		0x0010
+#define INTC_SYSSTATUS		0x0014
+#define INTC_CONTROL		0x0048
+#define INTC_MIR_CLEAR0		0x0088
+#define INTC_MIR_SET0		0x008c
+#define INTC_PENDING_IRQ0	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,22 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
+		struct omap_irq_bank *bank = irq_banks + i;
+		int irq;
+
+		for (irq = 0; irq < bank->nr_irqs; irq += 32)
+			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
+					       ((irq >> 5) << 5)))
+				return 1;
+	}
Quoted 8 lines

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 139

Quoted 3 lines
arch/arm/mach-omap2/irq.c +3 -0
+	return 0;
+}
+

In this case it should be enough to know if anything is set in the bank registers, so you should be able to leave out the second for loop. At most you need to read only the four bank registers. No need to check for individual interrupts.

Current code is presenting each interrupt controller as a bank. I think in TRM they are talking about banks in each controller. So there is three banks in mpu intc 0..2. This is in arch/arm/mach-omap2/irq.c:

* OMAP2 has a number of different interrupt controllers, each interrupt
* controller is identified as its own "bank". Register definitions are
* fairly consistent for each bank, but not all registers are implemented
* for each bank.. when in doubt, consult the TRM.
*/

So the first loop is going through controllers which is only mpu intc. Second loop is going through bank registers. I'm using irq only for finding out right offset for bank register. This is another implementation. Which does exactly same thing:

int omap_irq_pending(void)

{
	int i, j;

	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
		struct omap_irq_bank *bank = irq_banks + i;

		for (j = 0; j < 3; j++)
			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
					       0x20 * j))
				return 1;
	}
	return 0;
}
Quoted 6 lines
Quoted 2 lines

If you think this is better I can change it. In first version I was just trying to follow practices used in irq.c for finding out offsets.

Hmm, AFAIK, something like below should be enough to see if any interrupts are pending (patch untested). See also include/asm-arm/arch-omap/entry-macro.S> and what pm.c was doing.

No it doesn't work. It would work if irq_banks were presenting banks instead of controllers. See my comments below.

Quoted 20 lines

Regards,

Tony

arch/arm/mach-omap2/irq.c +1 -0
index ac062ee..aef28ab 100644
@@ -26,6 +26,7 @@
 #define INTC_CONTROL	0x0048
 #define INTC_MIR_CLEAR0	0x0088
 #define INTC_MIR_SET0	0x008c
+#define INTC_PENDING	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 130

Quoted 8 lines
arch/arm/mach-omap2/irq.c +5 -0
@@ -122,6 +123,20 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {

ARRAY_SIZE(irq_banks) == 1, because there is only mpu intc in irq_banks. irq_banks contains interrupt controllers, so we need to loop through them and loop each pending (bank) register inside these controllers.

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 138

Quoted 8 lines
arch/arm/mach-omap2/irq.c +8 -0
+		struct omap_irq_bank *bank = irq_banks + i;
+
+		if (intc_bank_read_reg(bank, INTC_PENDING))
+			return 1;
+	}
+
+	return 0;
+}

Your function reads only first INTC_PENDING register. There are three of them in mpu intc.

Quoted 5 lines
arch/arm/mach-omap2/irq.c +1 -0
+
 void __init omap_init_irq(void)
 {
 	unsigned long nr_irqs = 0;
Signature · 6 lines
Jouni Högander

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#9 lore raw

Re: [PATCH 4/9] OMAP: Add new function to check wether there is irq pending

Quoted 131 lines · Högander Jouni
Quoted 96 lines · ext Tony Lindgren
Quoted 95 lines · Högander Jouni
Quoted 54 lines · ext Tony Lindgren

Hi,

Quoted 51 lines · Jouni Hogander

Add common omap2/3 function to check wether there is irq pending. Switch to use it in omap2 pm code instead of its own.

---
 arch/arm/mach-omap2/irq.c        |   29 +++++++++++++++++++++++------
 arch/arm/mach-omap2/pm24xx.c     |   19 +++----------------
 include/asm-arm/arch-omap/irqs.h |    1 +
 3 files changed, 27 insertions(+), 22 deletions(-)
arch/arm/mach-omap2/irq.c +20 -6
index ac062ee..f1e1e2e 100644
@@ -20,12 +20,13 @@
 
 /* selected INTC register offsets */
 
-#define INTC_REVISION	0x0000
-#define INTC_SYSCONFIG	0x0010
-#define INTC_SYSSTATUS	0x0014
-#define INTC_CONTROL	0x0048
-#define INTC_MIR_CLEAR0	0x0088
-#define INTC_MIR_SET0	0x008c
+#define INTC_REVISION		0x0000
+#define INTC_SYSCONFIG		0x0010
+#define INTC_SYSSTATUS		0x0014
+#define INTC_CONTROL		0x0048
+#define INTC_MIR_CLEAR0		0x0088
+#define INTC_MIR_SET0		0x008c
+#define INTC_PENDING_IRQ0	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,22 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
+		struct omap_irq_bank *bank = irq_banks + i;
+		int irq;
+
+		for (irq = 0; irq < bank->nr_irqs; irq += 32)
+			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
+					       ((irq >> 5) << 5)))
+				return 1;
+	}
Quoted 8 lines

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 139

Quoted 3 lines
arch/arm/mach-omap2/irq.c +3 -0
+	return 0;
+}
+

In this case it should be enough to know if anything is set in the bank registers, so you should be able to leave out the second for loop. At most you need to read only the four bank registers. No need to check for individual interrupts.

Current code is presenting each interrupt controller as a bank. I think in TRM they are talking about banks in each controller. So there is three banks in mpu intc 0..2. This is in arch/arm/mach-omap2/irq.c:

* OMAP2 has a number of different interrupt controllers, each interrupt
* controller is identified as its own "bank". Register definitions are
* fairly consistent for each bank, but not all registers are implemented
* for each bank.. when in doubt, consult the TRM.
*/

So the first loop is going through controllers which is only mpu intc. Second loop is going through bank registers. I'm using irq only for finding out right offset for bank register. This is another implementation. Which does exactly same thing:

int omap_irq_pending(void)

{
	int i, j;

	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
		struct omap_irq_bank *bank = irq_banks + i;

		for (j = 0; j < 3; j++)
			if (intc_bank_read_reg(bank, INTC_PENDING_IRQ0 +
					       0x20 * j))
				return 1;
	}
	return 0;
}
Quoted 6 lines
Quoted 2 lines

If you think this is better I can change it. In first version I was just trying to follow practices used in irq.c for finding out offsets.

Hmm, AFAIK, something like below should be enough to see if any interrupts are pending (patch untested). See also include/asm-arm/arch-omap/entry-macro.S> and what pm.c was doing.

No it doesn't work. It would work if irq_banks were presenting banks instead of controllers. See my comments below.

Quoted 23 lines

Regards,

Tony

arch/arm/mach-omap2/irq.c +1 -0
index ac062ee..aef28ab 100644
@@ -26,6 +26,7 @@
 #define INTC_CONTROL	0x0048
 #define INTC_MIR_CLEAR0	0x0088
 #define INTC_MIR_SET0	0x008c
+#define INTC_PENDING	0x0098
 
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
@@ -122,6 +123,20 @@ static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
 	intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
 }
 
Quoted 10 lines

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 130

Quoted 5 lines
arch/arm/mach-omap2/irq.c +5 -0
+int omap_irq_pending(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {

ARRAY_SIZE(irq_banks) == 1, because there is only mpu intc in irq_banks. irq_banks contains interrupt controllers, so we need to loop through them and loop each pending (bank) register inside these controllers.

Ah, OK. Yes you're right there is only one bank in irq_banks. And that's why you still need to calculate the register offset with (i >> 5) << 5. And you're increasing the for loop by 32, not by 1, I guess that's where I originally misread your patch and got confused.

Let's just use your original patch then.

Tony

Quoted 13 lines

arch/arm/mach-omap2/irq.c static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) · line 138

Quoted 9 lines
arch/arm/mach-omap2/irq.c +8 -0
+		struct omap_irq_bank *bank = irq_banks + i;
+
+		if (intc_bank_read_reg(bank, INTC_PENDING))
+			return 1;
+	}
+
+	return 0;
+}

Your function reads only first INTC_PENDING register. There are three of them in mpu intc.

Quoted 9 lines
Quoted 5 lines
arch/arm/mach-omap2/irq.c +1 -0
+
 void __init omap_init_irq(void)
 {
 	unsigned long nr_irqs = 0;
Signature · 1 line
Jouni Högander

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#15 lore raw
In reply to Högander Jouni
Quoted 14 lines · Högander Jouni

This patch set adds suspend and pm idle support for omap3. There are still lots of missing stuff so omap doesn't enter full retention without workaround patches. Workaround patches are sent in separate set.

You can try these by applying this set and workaround set. Then boot the device and do "echo mem > /sys/power/state". Dynamic retention can be tried by "echo 1 > /sys/power/sleep_while_idle". There is one pending patch by Felipe Balbi (ARCH: OMAP: MUSB: Do not block sleep) addition to this and workaround set which is needed dynamic idle to work. Enabling dynamic idle has nasty side effect that serial console stops to work. This happens only if you enable it by "echo 1 > /sys/power/sleep_while_idle"

Quoted 1 line

I have tested these patches on TI 3430 SDP ES2.0 board.

Pushing this series today.

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html