Skip to contentSkip to conversation

first pass at core PM sync-up

PATCH New Kevin Hilman 1 participant 4 messages Feb 4, 2009

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

cover first pass at core PM sync-up

The linux-omap tree has long carried some core PM code that has never gone upstream. This is a first pass to get a base PM core upstream, so that the PM branch can be pushed next.

This code has been touched by many folks, and it's impossible to give credit to everyone, but I tried to mention significant contributions in the patch headers. Please let me know if I missed anyone.

This series currently applies on top of the large clock update series sent by Paul Walmsley. I will rebase onto RMKs clock merge when it is ready and available.

Paul's series is in the 'staging/paul-clock1' branch of my linux-omap-pm git repo. This series is pushed on top of that in the 'staging/pm-upstream' branch.

Kevin

Jouni Hogander (1):
OMAP: Add new function to check wether there is irq pending

Kalle Jokiniemi (1):
OMAP3: PM: SmartReflex driver integration

Kevin Hilman (1):
OMAP2/3: PM: push core PM code from linux-omap

 arch/arm/mach-omap2/Makefile               |    4 +
 arch/arm/mach-omap2/irq.c                  |   17 +-
 arch/arm/mach-omap2/pm-debug.c             |  157 ++++++
 arch/arm/mach-omap2/pm.c                   |  154 +++---
 arch/arm/mach-omap2/pm.h                   |   32 ++
 arch/arm/mach-omap2/pm24xx.c               |  545 ++++++++++++++++++++
 arch/arm/mach-omap2/pm34xx.c               |  695 +++++++++++++++++++++++++
 arch/arm/mach-omap2/prm-regbits-34xx.h     |   20 +-
 arch/arm/mach-omap2/sleep34xx.S            |  544 ++++++++++++++++++++
 arch/arm/mach-omap2/smartreflex.c          |  762 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/smartreflex.h          |  259 ++++++++++
 arch/arm/plat-omap/Kconfig                 |   31 ++
 arch/arm/plat-omap/include/mach/control.h  |   18 +
 arch/arm/plat-omap/include/mach/irqs.h     |    1 +
 arch/arm/plat-omap/include/mach/omap34xx.h |    3 +-
 arch/arm/plat-omap/include/mach/pm.h       |   77 +---
 16 files changed, 3169 insertions(+), 150 deletions(-)
 create mode 100644 arch/arm/mach-omap2/pm-debug.c
 create mode 100644 arch/arm/mach-omap2/pm.h
 create mode 100644 arch/arm/mach-omap2/pm24xx.c
 create mode 100644 arch/arm/mach-omap2/pm34xx.c
 create mode 100644 arch/arm/mach-omap2/sleep34xx.S
 create mode 100644 arch/arm/mach-omap2/smartreflex.c
 create mode 100644 arch/arm/mach-omap2/smartreflex.h
#1 lore raw

PATCH 1/3 OMAP2/3: PM: push core PM code from linux-omap

This patch is to sync the core linux-omap PM code with mainline. This code has evolved in the linux-omap tree, but the attempt here is to start by adding the reworked PM core code from linux-omap to mainline. Following this will be a series of patches from the 'PM branch' of the linux-omap tree to add full PM hardware support from the linux-omap tree.

Much of this PM core code was written by Jouni Hogander with significant contributions from Paul Walmsley as well as many others in the linux-omap community.

Cc Jouni Hogander <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/Makefile         |    3 +
 arch/arm/mach-omap2/pm-debug.c       |  157 +++++++++
 arch/arm/mach-omap2/pm.c             |  154 +++++----
 arch/arm/mach-omap2/pm.h             |   32 ++
 arch/arm/mach-omap2/pm24xx.c         |  558 +++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/pm34xx.c         |  608 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/sleep34xx.S      |  544 ++++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/mach/pm.h |   77 +----
 8 files changed, 1996 insertions(+), 137 deletions(-)
 create mode 100644 arch/arm/mach-omap2/pm-debug.c
 create mode 100644 arch/arm/mach-omap2/pm.h
 create mode 100644 arch/arm/mach-omap2/pm24xx.c
 create mode 100644 arch/arm/mach-omap2/pm34xx.c
 create mode 100644 arch/arm/mach-omap2/sleep34xx.S
arch/arm/mach-omap2/Makefile +3 -0
index 9717afc..a98057a 100644
@@ -21,7 +21,10 @@ obj-$(CONFIG_ARCH_OMAP2)		+= sdrc2xxx.o
 # Power Management
 ifeq ($(CONFIG_PM),y)
 obj-y					+= pm.o
+obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
 obj-$(CONFIG_ARCH_OMAP24XX)		+= sleep24xx.o
+obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o
+obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
 endif
 
 # Clock framework
arch/arm/mach-omap2/pm-debug.c new file +157 -0

157 lines not on this page · raw message

arch/arm/mach-omap2/pm.c +80 -74

188 lines not on this page · raw message

arch/arm/mach-omap2/pm.h new file +32 -0
new file mode 100644
index 0000000..625a905
@@ -0,0 +1,32 @@
+/*
+ * OMAP2/3 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.
+ */
+#ifndef __ARCH_ARM_MACH_OMAP2_PM_H
+#define __ARCH_ARM_MACH_OMAP2_PM_H
+
+extern int omap2_pm_init(void);
+extern int omap3_pm_init(void);
+
+extern unsigned short enable_dyn_sleep;
+extern unsigned short clocks_off_while_idle;
+extern atomic_t sleep_block;
+
+extern void omap2_block_sleep(void);
+extern void omap2_allow_sleep(void);
+
+#ifdef CONFIG_PM_DEBUG
+extern void omap2_pm_dump(int mode, int resume, unsigned int us);
+extern int omap2_pm_debug;
+#else
+#define omap2_pm_dump(mode, resume, us)		do {} while (0);
+#define omap2_pm_debug				0
+#endif /* CONFIG_PM_DEBUG */
+
+#endif
arch/arm/mach-omap2/pm24xx.c new file +558 -0

558 lines not on this page · raw message

arch/arm/mach-omap2/pm34xx.c new file +608 -0

608 lines not on this page · raw message

arch/arm/mach-omap2/sleep34xx.S new file +544 -0

544 lines not on this page · raw message

arch/arm/plat-omap/include/mach/pm.h +14 -63

121 lines not on this page · raw message

Signature · 1 line
1.6.1
#2 lore raw

PATCH 2/3 OMAP: Add new function to check wether there is irq pending

From: Jouni Hogander <[email protected]>

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              |   17 ++++++++++++++++-
 arch/arm/mach-omap2/pm24xx.c           |   19 +++----------------
 arch/arm/plat-omap/include/mach/irqs.h |    1 +
 3 files changed, 20 insertions(+), 17 deletions(-)
arch/arm/mach-omap2/irq.c +16 -1
index 636e282..6d5b8c1 100644
@@ -28,7 +28,6 @@
 #define INTC_MIR_CLEAR0		0x0088
 #define INTC_MIR_SET0		0x008c
 #define INTC_PENDING_IRQ0	0x0098
-
 /* Number of IRQ state bits in each MIR register */
 #define IRQ_BITS_PER_REG	32
 
@@ -156,6 +155,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_of_irqs = 0;
arch/arm/mach-omap2/pm24xx.c +3 -16
index b3268c5..3e9ed3f 100644
@@ -78,19 +78,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;
@@ -129,7 +116,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;
 
 	/* Jump to SRAM suspend code */
@@ -275,13 +262,13 @@ static void omap2_pm_idle(void)
 	local_fiq_disable();
 
 	if (!omap2_can_sleep()) {
-		if (!atomic_read(&sleep_block) && omap2_irq_pending())
+		if (!atomic_read(&sleep_block) && omap_irq_pending())
 			goto out;
 		omap2_enter_mpu_retention();
 		goto out;
 	}
 
-	if (omap2_irq_pending())
+	if (omap_irq_pending())
 		goto out;
 
 	omap2_enter_full_retention();
arch/arm/plat-omap/include/mach/irqs.h +1 -0
index bed5274..990573f 100644
@@ -386,6 +386,7 @@
 
 #ifndef __ASSEMBLY__
 extern void omap_init_irq(void);
+extern int omap_irq_pending(void);
 #endif
 
 #include <mach/hardware.h>
Signature · 1 line
1.6.1
#3 lore raw

PATCH 3/3 OMAP3: PM: SmartReflex driver integration

From: Kalle Jokiniemi <[email protected]>

Originally from linux-omap tree, and original commit message follows. This also includes various updates, cleanups and fixes by the folks CC'd below.

Quoted 1 line

From : Kalle Jokiniemi <[email protected]>

This patch integrates TI's SmartReflex driver into linux-omap. SmartReflex is a module that adjusts OMAP3 VDD1 and VDD2 operating voltages around the nominal values of current operating point depending on silicon characteristics and operating conditions.

The patch adds Kconfig options "SmartReflex support" and a sub-option "SmartReflex testing support" under "System type"->"TI OMAP implementations" menu. The testing support can be used to test SmartReflex functionality, if the E-fuse values have not been set for the device. It however uses software hard coded sensor parameters, which may not work on all devices. Beware.

The driver creates two sysfs entries into /sys/power/ named "sr_vdd1_autocomp" and "sr_vdd2_autocomp" which can be used to activate voltage autocompensation feature of SmartReflex modules 1 and 2.

Use the following commands to enable autocompensation:

echo -n 1 > /sys/power/sr_vdd1_autocomp
echo -n 1 > /sys/power/sr_vdd2_autocomp

To disable:

echo -n 0 > /sys/power/sr_vdd1_autocomp
echo -n 0 > /sys/power/sr_vdd2_autocomp

---
 arch/arm/mach-omap2/Makefile               |    1 +
 arch/arm/mach-omap2/pm34xx.c               |   87 ++++
 arch/arm/mach-omap2/prm-regbits-34xx.h     |   20 +-
 arch/arm/mach-omap2/smartreflex.c          |  762 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/smartreflex.h          |  259 ++++++++++
 arch/arm/plat-omap/Kconfig                 |   31 ++
 arch/arm/plat-omap/include/mach/control.h  |   18 +
 arch/arm/plat-omap/include/mach/omap34xx.h |    3 +-
 8 files changed, 1169 insertions(+), 12 deletions(-)
 create mode 100644 arch/arm/mach-omap2/smartreflex.c
 create mode 100644 arch/arm/mach-omap2/smartreflex.h
arch/arm/mach-omap2/Makefile +1 -0
index a98057a..c69221c 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
 obj-$(CONFIG_ARCH_OMAP24XX)		+= sleep24xx.o
 obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
+obj-$(CONFIG_OMAP_SMARTREFLEX)		+= smartreflex.o
 endif
 
 # Clock framework
arch/arm/mach-omap2/pm34xx.c +87 -0

107 lines not on this page · raw message

arch/arm/mach-omap2/prm-regbits-34xx.h +9 -11
index c6a7940..da1897b 100644
@@ -435,10 +435,10 @@
 /* PM_PWSTST_EMU specific bits */
 
 /* PRM_VC_SMPS_SA */
-#define OMAP3430_PRM_VC_SMPS_SA_SA1_SHIFT		16
-#define OMAP3430_PRM_VC_SMPS_SA_SA1_MASK		(0x7f << 16)
-#define OMAP3430_PRM_VC_SMPS_SA_SA0_SHIFT		0
-#define OMAP3430_PRM_VC_SMPS_SA_SA0_MASK		(0x7f << 0)
+#define OMAP3430_SMPS_SA1_SHIFT				16
+#define OMAP3430_SMPS_SA1_MASK				(0x7f << 16)
+#define OMAP3430_SMPS_SA0_SHIFT				0
+#define OMAP3430_SMPS_SA0_MASK				(0x7f << 0)
 
 /* PRM_VC_SMPS_VOL_RA */
 #define OMAP3430_VOLRA1_SHIFT				16
@@ -452,17 +452,15 @@
 #define OMAP3430_CMDRA0_SHIFT				0
 #define OMAP3430_CMDRA0_MASK				(0xff << 0)
 
-/* PRM_VC_CMD_VAL_0 specific bits */
+/* PRM_VC_CMD_VAL specific bits */
 #define OMAP3430_VC_CMD_ON_SHIFT			24
-#define OMAP3430_VC_CMD_ON_MASK				(0xFF << 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_ONLP_MASK			(0xff << 16)
 #define OMAP3430_VC_CMD_RET_SHIFT			8
-#define OMAP3430_VC_CMD_RET_MASK			(0xFF << 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 */
+#define OMAP3430_VC_CMD_OFF_MASK			(0xff << 0)
 
 /* PRM_VC_CH_CONF */
 #define OMAP3430_CMD1					(1 << 20)
arch/arm/mach-omap2/smartreflex.c new file +762 -0

762 lines not on this page · raw message

arch/arm/mach-omap2/smartreflex.h new file +259 -0

259 lines not on this page · raw message

arch/arm/plat-omap/Kconfig +31 -0
index 46d3b0b..91f8b8b 100644
@@ -58,6 +58,37 @@ config OMAP_DEBUG_CLOCKDOMAIN
 	  for every clockdomain register write.  However, the
 	  extra detail costs some memory.
 
+config OMAP_SMARTREFLEX
+	bool "SmartReflex support"
+	depends on ARCH_OMAP34XX && TWL4030_CORE && PM
+	help
+	  Say Y if you want to enable SmartReflex.
+
+	  SmartReflex can perform continuous dynamic voltage
+	  scaling around the nominal operating point voltage
+	  according to silicon characteristics and operating
+	  conditions. Enabling SmartReflex reduces power
+	  consumption.
+
+	  Please note, that by default SmartReflex is only
+	  initialized. To enable the automatic voltage
+	  compensation for VDD1 and VDD2, user must write 1 to
+	  /sys/power/sr_vddX_autocomp, where X is 1 or 2.
+
+config OMAP_SMARTREFLEX_TESTING
+	bool "Smartreflex testing support"
+	depends on OMAP_SMARTREFLEX
+	default n
+	help
+	  Say Y if you want to enable SmartReflex testing with SW hardcoded
+	  NVALUES intead of E-fuse NVALUES set in factory silicon testing.
+
+	  In some devices the E-fuse values have not been set, even though
+	  SmartReflex modules are included. Using these hardcoded values set
+	  in software, one can test the SmartReflex features without E-fuse.
+
+	  WARNING: Enabling this option may cause your device to hang!
+
 config OMAP_RESET_CLOCKS
 	bool "Reset unused clocks during boot"
 	depends on ARCH_OMAP
arch/arm/plat-omap/include/mach/control.h +18 -0
index 269147f..8a65bd2 100644
@@ -139,6 +139,15 @@
 #define OMAP343X_CONTROL_TEST_KEY_11	(OMAP2_CONTROL_GENERAL + 0x00f4)
 #define OMAP343X_CONTROL_TEST_KEY_12	(OMAP2_CONTROL_GENERAL + 0x00f8)
 #define OMAP343X_CONTROL_TEST_KEY_13	(OMAP2_CONTROL_GENERAL + 0x00fc)
+#define OMAP343X_CONTROL_FUSE_OPP1_VDD1	(OMAP2_CONTROL_GENERAL + 0x0110)
+#define OMAP343X_CONTROL_FUSE_OPP2_VDD1	(OMAP2_CONTROL_GENERAL + 0x0114)
+#define OMAP343X_CONTROL_FUSE_OPP3_VDD1	(OMAP2_CONTROL_GENERAL + 0x0118)
+#define OMAP343X_CONTROL_FUSE_OPP4_VDD1	(OMAP2_CONTROL_GENERAL + 0x011c)
+#define OMAP343X_CONTROL_FUSE_OPP5_VDD1	(OMAP2_CONTROL_GENERAL + 0x0120)
+#define OMAP343X_CONTROL_FUSE_OPP1_VDD2	(OMAP2_CONTROL_GENERAL + 0x0124)
+#define OMAP343X_CONTROL_FUSE_OPP2_VDD2	(OMAP2_CONTROL_GENERAL + 0x0128)
+#define OMAP343X_CONTROL_FUSE_OPP3_VDD2	(OMAP2_CONTROL_GENERAL + 0x012c)
+#define OMAP343X_CONTROL_FUSE_SR	(OMAP2_CONTROL_GENERAL + 0x0130)
 #define OMAP343X_CONTROL_IVA2_BOOTADDR	(OMAP2_CONTROL_GENERAL + 0x0190)
 #define OMAP343X_CONTROL_IVA2_BOOTMOD	(OMAP2_CONTROL_GENERAL + 0x0194)
 #define OMAP343X_CONTROL_PBIAS_LITE	(OMAP2_CONTROL_GENERAL + 0x02b0)
@@ -176,6 +185,15 @@
 #define OMAP2_SYSBOOT_2_MASK		(1 << 2)
 #define OMAP2_SYSBOOT_1_MASK		(1 << 1)
 #define OMAP2_SYSBOOT_0_MASK		(1 << 0)
+/* CONTROL_FUSE_SR bits */
+#define OMAP343X_SR2_SENNENABLE_MASK	(0x3 << 10)
+#define OMAP343X_SR2_SENNENABLE_SHIFT	10
+#define OMAP343X_SR2_SENPENABLE_MASK	(0x3 << 8)
+#define OMAP343X_SR2_SENPENABLE_SHIFT	8
+#define OMAP343X_SR1_SENNENABLE_MASK	(0x3 << 2)
+#define OMAP343X_SR1_SENNENABLE_SHIFT	2
+#define OMAP343X_SR1_SENPENABLE_MASK	(0x3 << 0)
+#define OMAP343X_SR1_SENPENABLE_SHIFT	0
 
 /* CONTROL_PBIAS_LITE bits */
 #define OMAP343X_PBIASLITESUPPLY_HIGH1	(1 << 15)
arch/arm/plat-omap/include/mach/omap34xx.h +2 -1
index 8e0479f..3eb075d 100644
@@ -53,7 +53,8 @@
 #define OMAP34XX_HSUSB_OTG_BASE	(L4_34XX_BASE + 0xAB000)
 #define OMAP34XX_HSUSB_HOST_BASE	(L4_34XX_BASE + 0x64000)
 #define OMAP34XX_USBTLL_BASE	(L4_34XX_BASE + 0x62000)
-
+#define OMAP34XX_SR1_BASE	0x480C9000
+#define OMAP34XX_SR2_BASE	0x480CB000
 
 #if defined(CONFIG_ARCH_OMAP3430)
 
Signature · 1 line
1.6.1