Skip to content

Commit d17799f

Browse files
zch-repoScott Wood
authored andcommitted
powerpc/rcpm: add RCPM driver
There is a RCPM (Run Control/Power Management) in Freescale QorIQ series processors. The device performs tasks associated with device run control and power management. The driver implements some features: mask/unmask irq, enter/exit low power states, freeze time base, etc. Signed-off-by: Chenhui Zhao <chenhui.zhao@freescale.com> Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com> [scottwood: remove __KERNEL__ ifdef] Signed-off-by: Scott Wood <oss@buserror.net>
1 parent e7affb1 commit d17799f

9 files changed

Lines changed: 571 additions & 0 deletions

File tree

‎arch/powerpc/include/asm/cputhreads.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static inline u32 get_tensr(void)
103103
return 1;
104104
}
105105

106+
void book3e_stop_thread(int thread);
106107

107108
#endif /* _ASM_POWERPC_CPUTHREADS_H */
108109

‎arch/powerpc/include/asm/fsl_pm.h‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Support Power Management
3+
*
4+
* Copyright 2014-2015 Freescale Semiconductor Inc.
5+
*
6+
* This program is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License as published by the
8+
* Free Software Foundation; either version 2 of the License, or (at your
9+
* option) any later version.
10+
*/
11+
#ifndef __PPC_FSL_PM_H
12+
#define __PPC_FSL_PM_H
13+
14+
#define E500_PM_PH10 1
15+
#define E500_PM_PH15 2
16+
#define E500_PM_PH20 3
17+
#define E500_PM_PH30 4
18+
#define E500_PM_DOZE E500_PM_PH10
19+
#define E500_PM_NAP E500_PM_PH15
20+
21+
#define PLAT_PM_SLEEP 20
22+
#define PLAT_PM_LPM20 30
23+
24+
#define FSL_PM_SLEEP (1 << 0)
25+
#define FSL_PM_DEEP_SLEEP (1 << 1)
26+
27+
struct fsl_pm_ops {
28+
/* mask pending interrupts to the RCPM from MPIC */
29+
void (*irq_mask)(int cpu);
30+
31+
/* unmask pending interrupts to the RCPM from MPIC */
32+
void (*irq_unmask)(int cpu);
33+
void (*cpu_enter_state)(int cpu, int state);
34+
void (*cpu_exit_state)(int cpu, int state);
35+
void (*cpu_up_prepare)(int cpu);
36+
void (*cpu_die)(int cpu);
37+
int (*plat_enter_sleep)(void);
38+
void (*freeze_time_base)(bool freeze);
39+
40+
/* keep the power of IP blocks during sleep/deep sleep */
41+
void (*set_ip_power)(bool enable, u32 mask);
42+
43+
/* get platform supported power management modes */
44+
unsigned int (*get_pm_modes)(void);
45+
};
46+
47+
extern const struct fsl_pm_ops *qoriq_pm_ops;
48+
49+
int __init fsl_rcpm_init(void);
50+
51+
#endif /* __PPC_FSL_PM_H */

‎arch/powerpc/kernel/head_64.S‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,25 @@ exception_marker:
181181
#endif
182182

183183
#ifdef CONFIG_PPC_BOOK3E
184+
/*
185+
* stop a thread in the same core
186+
* input parameter:
187+
* r3 = the thread physical id
188+
*/
189+
_GLOBAL(book3e_stop_thread)
190+
cmpi 0, r3, 0
191+
beq 10f
192+
cmpi 0, r3, 1
193+
beq 10f
194+
/* If the thread id is invalid, just exit. */
195+
b 13f
196+
10:
197+
li r4, 1
198+
sld r4, r4, r3
199+
mtspr SPRN_TENC, r4
200+
13:
201+
blr
202+
184203
_GLOBAL(fsl_secondary_thread_init)
185204
mfspr r4,SPRN_BUCSR
186205

‎arch/powerpc/platforms/85xx/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ menuconfig FSL_SOC_BOOKE
88
select FSL_PCI if PCI
99
select SERIAL_8250_EXTENDED if SERIAL_8250
1010
select SERIAL_8250_SHARE_IRQ if SERIAL_8250
11+
select FSL_CORENET_RCPM if PPC_E500MC
1112
default y
1213

1314
if FSL_SOC_BOOKE

‎arch/powerpc/platforms/85xx/common.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
#include <linux/of_irq.h>
1010
#include <linux/of_platform.h>
1111

12+
#include <asm/fsl_pm.h>
1213
#include <soc/fsl/qe/qe.h>
1314
#include <sysdev/cpm2_pic.h>
1415

1516
#include "mpc85xx.h"
1617

18+
const struct fsl_pm_ops *qoriq_pm_ops;
19+
1720
static const struct of_device_id mpc85xx_common_ids[] __initconst = {
1821
{ .type = "soc", },
1922
{ .compatible = "soc", },

‎arch/powerpc/sysdev/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ config SCOM_DEBUGFS
4040
config GE_FPGA
4141
bool
4242
default n
43+
44+
config FSL_CORENET_RCPM
45+
bool
46+
help
47+
This option enables support for RCPM (Run Control/Power Management).

‎arch/powerpc/sysdev/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
2020
obj-$(CONFIG_FSL_SOC) += fsl_soc.o fsl_mpic_err.o
2121
obj-$(CONFIG_FSL_PCI) += fsl_pci.o $(fsl-msi-obj-y)
2222
obj-$(CONFIG_FSL_PMC) += fsl_pmc.o
23+
obj-$(CONFIG_FSL_CORENET_RCPM) += fsl_rcpm.o
2324
obj-$(CONFIG_FSL_LBC) += fsl_lbc.o
2425
obj-$(CONFIG_FSL_GTM) += fsl_gtm.o
2526
obj-$(CONFIG_FSL_85XX_CACHE_SRAM) += fsl_85xx_l2ctlr.o fsl_85xx_cache_sram.o

0 commit comments

Comments
 (0)