Skip to contentSkip to conversation

mpc83xx: Power Management support

PATCH In review Scott Wood 3 participants 11 messages Jun 25, 2008 – Jul 2, 2008

Subsystems (2)
lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH 1/3 mpc83xx: Power Management support

Basic PM support for 83xx. Standby is implemented as sleep. Suspend-to-RAM is implemented as "deep sleep" (with the processor turned off) on 831x. PCI agent power management is supported.

Device power management of SOC peripherals is not yet supported.

---
 arch/powerpc/Kconfig                      |    2 +-
 arch/powerpc/platforms/83xx/Makefile      |    1 +
 arch/powerpc/platforms/83xx/suspend-asm.S |  539 +++++++++++++++++++++++++++++
 arch/powerpc/platforms/83xx/suspend.c     |  390 +++++++++++++++++++++
 arch/powerpc/sysdev/fsl_soc.h             |    1 +
 arch/powerpc/sysdev/ipic.c                |   71 ++++
 include/asm-powerpc/reg.h                 |    4 +
 include/linux/fsl_devices.h               |    6 +
 8 files changed, 1013 insertions(+), 1 deletions(-)
 create mode 100644 arch/powerpc/platforms/83xx/suspend-asm.S
 create mode 100644 arch/powerpc/platforms/83xx/suspend.c
arch/powerpc/Kconfig +1 -1
index 2cde4e3..8280b33 100644
@@ -192,7 +192,7 @@ config ARCH_HIBERNATION_POSSIBLE
 
 config ARCH_SUSPEND_POSSIBLE
 	def_bool y
-	depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200
+	depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200 || PPC_83xx
 
 config PPC_DCR_NATIVE
 	bool
arch/powerpc/platforms/83xx/Makefile +1 -0
index f331fd7..32c7ad1 100644
@@ -3,6 +3,7 @@
 #
 obj-y				:= misc.o usb.o
 obj-$(CONFIG_PCI)		+= pci.o
+obj-$(CONFIG_SUSPEND)		+= suspend.o suspend-asm.o
 obj-$(CONFIG_MPC831x_RDB)	+= mpc831x_rdb.o
 obj-$(CONFIG_MPC832x_RDB)	+= mpc832x_rdb.o
 obj-$(CONFIG_MPC834x_MDS)	+= mpc834x_mds.o
arch/powerpc/platforms/83xx/suspend-asm.S new file +539 -0

539 lines not on this page · raw message

arch/powerpc/platforms/83xx/suspend.c new file +390 -0

390 lines not on this page · raw message

arch/powerpc/sysdev/fsl_soc.h +1 -0
index 52c831f..0242998 100644
@@ -10,6 +10,7 @@ extern u32 get_baudrate(void);
 extern u32 fsl_get_sys_freq(void);
 
 struct spi_board_info;
+struct device_node;
 
 extern int fsl_spi_init(struct spi_board_info *board_infos,
 			unsigned int num_board_infos,
arch/powerpc/sysdev/ipic.c +71 -0

85 lines not on this page · raw message

include/asm-powerpc/reg.h +4 -0
index edc0cfd..b60287d 100644
@@ -153,10 +153,12 @@
 #define   CTRL_RUNLATCH	0x1
 #define SPRN_DABR	0x3F5	/* Data Address Breakpoint Register */
 #define   DABR_TRANSLATION	(1UL << 2)
+#define SPRN_DABR2	0x13D	/* e300 */
 #define SPRN_DABRX	0x3F7	/* Data Address Breakpoint Register Extension */
 #define   DABRX_USER	(1UL << 0)
 #define   DABRX_KERNEL	(1UL << 1)
 #define SPRN_DAR	0x013	/* Data Address Register */
+#define SPRN_DBCR	0x136	/* e300 Data Breakpoint Control Reg */
 #define SPRN_DSISR	0x012	/* Data Storage Interrupt Status Register */
 #define   DSISR_NOHPTE		0x40000000	/* no translation found */
 #define   DSISR_PROTFAULT	0x08000000	/* protection fault */
@@ -262,6 +264,8 @@
 #define HID1_PS		(1<<16)		/* 750FX PLL selection */
 #define SPRN_HID2	0x3F8		/* Hardware Implementation Register 2 */
 #define SPRN_IABR	0x3F2	/* Instruction Address Breakpoint Register */
+#define SPRN_IABR2	0x3FA		/* 83xx */
+#define SPRN_IBCR	0x135		/* 83xx Insn Breakpoint Control Reg */
 #define SPRN_HID4	0x3F4		/* 970 HID4 */
 #define SPRN_HID5	0x3F6		/* 970 HID5 */
 #define SPRN_HID6	0x3F9	/* BE HID 6 */
include/linux/fsl_devices.h +6 -0
index c415a49..0472877 100644
@@ -125,4 +125,10 @@ struct mpc8xx_pcmcia_ops {
 	int(*voltage_set)(int slot, int vcc, int vpp);
 };
 
+/* Returns non-zero if the current suspend operation would
+ * lead to a deep sleep (i.e. power removed from the core,
+ * instead of just the clock).
+ */
+int fsl_deep_sleep(void);
+
 #endif /* _FSL_DEVICE_H_ */
Signature · 1 line
1.5.5.4
#1 lore raw
Quoted 5 lines · Scott Wood

Basic PM support for 83xx. Standby is implemented as sleep. Suspend-to-RAM is implemented as "deep sleep" (with the processor turned off) on 831x. PCI agent power management is supported.

Device power management of SOC peripherals is not yet supported.

(Not comments on this patch, but related)

Do you know if anyone is looking at making sure DOZE/NAP work on 83xx? We clearly don't flush the L1 cache today in the 6xx code.

- k

author
#2 lore raw
Quoted 7 lines · Kumar Gala
Quoted 4 lines · Scott Wood

Basic PM support for 83xx. Standby is implemented as sleep. Suspend-to-RAM is implemented as "deep sleep" (with the processor turned off) on 831x. PCI agent power management is supported.

Quoted 5 lines
Quoted 1 line

Device power management of SOC peripherals is not yet supported.

(Not comments on this patch, but related)

Do you know if anyone is looking at making sure DOZE/NAP work on 83xx? We clearly don't flush the L1 cache today in the 6xx code.

Doze should work (a long time ago when I did power measurements I saw a drop in consumption once Linux started, and the system was idle)... Nap is not supported, and should probably be removed from the e300 cputable entry. I don't think it's worthwhile to flush the cache every time the cpu is idle just to nap instead of doze.

-Scott

#3 lore raw
In reply to Kumar Gala
Quoted 10 lines
Quoted 5 lines

Basic PM support for 83xx. Standby is implemented as sleep. Suspend-to-RAM is implemented as "deep sleep" (with the processor turned off) on 831x. PCI agent power management is supported.

Device power management of SOC peripherals is not yet supported.

=20
(Not comments on this patch, but related)
=20
Do you know if anyone is looking at making sure DOZE/NAP work on =20 83xx? We clearly don't flush the L1 cache today in the 6xx code.

I did the test on 837x, the NAP did *not* work, due to the cache coherence issue.
You are right, currently no flush L1 in the 6xx code, maybe it depend on the
platform hardware capability.

Dave

#4 lore raw
Quoted 8 lines · Liu Dave
Quoted 8 lines
Quoted 5 lines

Basic PM support for 83xx. Standby is implemented as sleep. Suspend-to-RAM is implemented as "deep sleep" (with the processor turned off) on 831x. PCI agent power management is supported.

Device power management of SOC peripherals is not yet supported.

(Not comments on this patch, but related)

Quoted 8 lines
Quoted 2 lines

Do you know if anyone is looking at making sure DOZE/NAP work on 83xx? We clearly don't flush the L1 cache today in the 6xx code.

I did the test on 837x, the NAP did *not* work, due to the cache coherence issue.
You are right, currently no flush L1 in the 6xx code, maybe it depend on the
platform hardware capability.

Ben told me the pmac HW/chipsets did something here to ensure that the core never actually went into NAP (or something like that) so they didn't have to flush the caches.

- k

#5 lore raw
In reply to Scott Wood
Quoted 42 lines
arch/powerpc/platforms/83xx/suspend-asm.S new file +8 -0
new file mode 100644
index 0000000..03e29a2
@@ -0,0 +1,539 @@
+/*
+ * Enter and leave sleep state on MPC83xx
+ *
+ * Author: Scott Wood <[email protected]>
+ *
+ * Copyright (c) 2006 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */

arch/powerpc/platforms/83xx/suspend-asm.S new file +23 -0
+
+#include <asm/page.h>
+#include <asm/ppc_asm.h>
+#include <asm/reg.h>
+#include <asm/asm-offsets.h>
+
+#define SS_MEMSAVE	0x00
+#define SS_HID		0x08 /* 3 HIDs */
+#define SS_IABR		0x14 /* 2 IABRs */
+#define SS_IBCR		0x1c
+#define SS_DABR		0x20 /* 2 DABRs */
+#define SS_DBCR		0x28
+#define SS_SP		0x2c
+#define SS_SR		0x30 /* 16 segment registers */
+#define SS_CURRENT	0x70
+#define SS_MSR		0x74
+#define SS_SDR1		0x78
+#define SS_LR		0x7c
+#define SS_SPRG		0x80 /* 4 SPRGs */
+#define SS_DBAT		0x90 /* 8 DBATs */
+#define SS_IBAT		0xd0 /* 8 IBATs */
+#define SS_TB		0x110
+#define SS_CR		0x118

arch/powerpc/platforms/83xx/suspend-asm.S line 44

Quoted 10 lines
arch/powerpc/platforms/83xx/suspend-asm.S new file +10 -0
+#define SS_GPREG	0x11c /* r12-r31 */
+#define STATE_SAVE_SIZE 0x16c
+
+	.section .data
+	.align	5
+
+mpc83xx_sleep_save_area:
+	.space	STATE_SAVE_SIZE
+immrbase:
+	.long	0

If we are going to allocate space for save area like this, can't we do this in C code. Its less error prone and easier to extend over time. I know the powermac code does something similar but it places the save area on the stack.

It also seems like the core register save/restore should be shared between 83xx and 5{1,2}xx but that would be a longer term goal.

- k

author
#6 lore raw
Quoted 1 line · Kumar Gala

If we are going to allocate space for save area like this, can't we do this in C code. Its less error prone and easier to extend over time. I know the powermac code does something similar but it places the save area on the stack.

Then we'd have to split it between things that can be saved from C versus things that can't (gpregs, cr, lr, etc), or mess around with exposing struct offsets to asm code. I think it's just easier to do it this way.

-Scott

#7 lore raw
In reply to Scott Wood
Quoted 19 lines
arch/powerpc/platforms/83xx/suspend-asm.S new file +8 -0
new file mode 100644
index 0000000..03e29a2
@@ -0,0 +1,539 @@
+/*
+ * Enter and leave sleep state on MPC83xx
+ *
+ * Author: Scott Wood <[email protected]>
+ *
+ * Copyright (c) 2006 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */

arch/powerpc/platforms/83xx/suspend-asm.S line 18

Quoted 7 lines
arch/powerpc/platforms/83xx/suspend-asm.S new file +7 -0
+
+#include <asm/page.h>
+#include <asm/ppc_asm.h>
+#include <asm/reg.h>
+#include <asm/asm-offsets.h>
+
+#define SS_MEMSAVE	0x00

What is this? add a comment?

arch/powerpc/platforms/83xx/suspend-asm.S line 26

Quoted 8 lines
arch/powerpc/platforms/83xx/suspend-asm.S new file +8 -0
+#define SS_HID		0x08 /* 3 HIDs */
+#define SS_IABR		0x14 /* 2 IABRs */
+#define SS_IBCR		0x1c
+#define SS_DABR		0x20 /* 2 DABRs */
+#define SS_DBCR		0x28
+#define SS_SP		0x2c
+#define SS_SR		0x30 /* 16 segment registers */
+#define SS_CURRENT	0x70

How about SS_R2 to match the pmac sleep.S code. It will make refactoring all this easier in the future.

arch/powerpc/platforms/83xx/suspend-asm.S line 36

Quoted 10 lines
arch/powerpc/platforms/83xx/suspend-asm.S new file +10 -0
+#define SS_MSR		0x74
+#define SS_SDR1		0x78
+#define SS_LR		0x7c
+#define SS_SPRG		0x80 /* 4 SPRGs */
+#define SS_DBAT		0x90 /* 8 DBATs */
+#define SS_IBAT		0xd0 /* 8 IBATs */
+#define SS_TB		0x110
+#define SS_CR		0x118
+#define SS_GPREG	0x11c /* r12-r31 */
+#define STATE_SAVE_SIZE 0x16c

- k

author
#8 lore raw
Quoted 3 lines · Kumar Gala
Quoted 1 line

+#define SS_MEMSAVE 0x00

What is this? add a comment?

There's a comment where MEMSAVE is used:

/* The first 2 words of memory are used to communicate with the
* bootloader, to tell it how to resume.
*
* The first word is the magic number 0xf5153ae5, and the second
* is the pointer to mpc83xx_deep_resume.
*
* The original content of these two words is saved in the state
* save area.
*/

We could stick a /* First 8 bytes of RAM */ after the #define if you want.

Quoted 10 lines

arch/powerpc/platforms/83xx/suspend-asm.S line 26

Quoted 8 lines
arch/powerpc/platforms/83xx/suspend-asm.S new file +8 -0
+#define SS_HID        0x08 /* 3 HIDs */
+#define SS_IABR        0x14 /* 2 IABRs */
+#define SS_IBCR        0x1c
+#define SS_DABR        0x20 /* 2 DABRs */
+#define SS_DBCR        0x28
+#define SS_SP        0x2c
+#define SS_SR        0x30 /* 16 segment registers */
+#define SS_CURRENT    0x70

How about SS_R2 to match the pmac sleep.S code. It will make refactoring all this easier in the future.

OK.

-Scott

#9 lore raw
Quoted 7 lines · Scott Wood
Quoted 2 lines · Kumar Gala
Quoted 1 line

+#define SS_MEMSAVE 0x00

What is this? add a comment?

There's a comment where MEMSAVE is used:

       /* The first 2 words of memory are used to communicate with the

I read this as the memory address 0, 0x4. do you mean the first two words of the save area?

Quoted 12 lines

* bootloader, to tell it how to resume.
*
* The first word is the magic number 0xf5153ae5, and the
second
* is the pointer to mpc83xx_deep_resume.
*
* The original content of these two words is saved in the
state
* save area.
*/

Quoted 1 line

We could stick a /* First 8 bytes of RAM */ after the #define if you want.

ahh, might be useful to add SS_MEMSAVE into the comment.

- k

author
#10 lore raw
Quoted 4 lines · Kumar Gala
Quoted 1 line · Scott Wood

Kumar Gala wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

+#define SS_MEMSAVE 0x00

What is this? add a comment?

There's a comment where MEMSAVE is used:

       /* The first 2 words of memory are used to communicate with the

I read this as the memory address 0, 0x4. do you mean the first two words of the save area?

Both. Memory addresses 0 and 4 are saved in the first two words of the save area, so that we can overwrite the former with the magic number and resume address.

Quoted 10 lines
Quoted 10 lines

* bootloader, to tell it how to resume.
*
* The first word is the magic number 0xf5153ae5, and the second
* is the pointer to mpc83xx_deep_resume.
*
* The original content of these two words is saved in the state
* save area.
*/

Quoted 3 lines
Quoted 1 line

We could stick a /* First 8 bytes of RAM */ after the #define if you want.

ahh, might be useful to add SS_MEMSAVE into the comment.

OK.

-Scott