powerpc/83xx: Sleep and deep sleep support for MPC8315E-RDB
v2 cover powerpc/83xx: Sleep and deep sleep support for MPC8315E-RDB
Hi all,
This is quite late resend, sorry.
Only the third patch has changed, i.e. I got rid of sleep-nexus stuff per Scott and Benjamin suggestions.
Thanks,
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
PATCH v2 1/3 powerpc/83xx/suspend: Clear deep_sleeping after devices resume
Currently 83xx PMC driver clears deep_sleeping variable very early, before devices are resumed. This makes fsl_deep_sleep() unusable in drivers' resume() callback.
Sure, drivers can store fsl_deep_sleep() value on suspend and use the stored value on resume. But a better solution is to postpone clearing the deep_sleeping variable, i.e. move it into finish() callback.
--- arch/powerpc/platforms/83xx/suspend.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/83xx/suspend.c +2 -2
@@ -194,7 +194,7 @@ out:return ret; } -static void mpc83xx_suspend_finish (void ) +static void mpc83xx_suspend_end (void ) { deep_sleeping =0 ; }
@@ -278,7 +278,7 @@ static struct platform_suspend_ops mpc83xx_suspend_ops = { .valid = mpc83xx_suspend_valid, .begin = mpc83xx_suspend_begin, .enter = mpc83xx_suspend_enter, - .finish = mpc83xx_suspend_finish, + .end = mpc83xx_suspend_end, }; static int pmc_probe(struct of_device *ofdev,
Signature · 1 line
1.6.3.3
Kumar Gala
AppliedRe: [PATCH 1/3] powerpc/83xx/suspend: Clear deep_sleeping after devices resume
Quoted 9 lines · Anton Vorontsov
Currently 83xx PMC driver clears
deep_sleepingvariable very early, before devices are resumed. This makesfsl_deep_sleep()unusable in drivers'resume()callback.Sure, drivers can store
fsl_deep_sleep()value on suspend and use the stored value on resume. But a better solution is to postpone clearing thedeep_sleepingvariable, i.e. move it intofinish()callback.
Quoted 5 lines
Signed-off-by Anton Vorontsov <[email protected]>Acked-by Scott Wood <[email protected]>---
arch/powerpc/platforms/83xx/suspend.c| 4 ++--1 files changed, 2 insertions(+), 2 deletions(-)
applied to next
- k
PATCH v2 2/3 powerpc/83xx/suspend: Save and restore SICRL, SICRH and SCCR
In reply to Anton VorontsovWe need to save SICRL, SICRH and SCCR registers on suspend, and restore them on resume. Otherwise, we lose IO and clocks setup on MPC8315E-RDB boards when ULPI USB PHY is used (non-POR setup).
--- arch/powerpc/platforms/83xx/suspend.c | 48 +++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-)
arch/powerpc/platforms/83xx/suspend.c +48 -0
@@ -32,6 +32,7 @@#define PMCCR1_NEXT_STATE 0x0C/* Next state for power management */ #define PMCCR1_NEXT_STATE_SHIFT 2#define PMCCR1_CURR_STATE 0x03/* Current state for power management*/ +#define IMMR_SYSCR_OFFSET 0x100#define IMMR_RCW_OFFSET 0x900#define RCW_PCI_HOST 0x80000000
@@ -78,6 +79,22 @@ struct mpc83xx_clock {u32 sccr; }; +struct mpc83xx_syscr { +__be32 sgprl; +__be32 sgprh; +__be32 spridr; + __be32 :32; +__be32 spcr; +__be32 sicrl; +__be32 sicrh; +}; + +struct mpc83xx_saved { +u32 sicrl; +u32 sicrh; +u32 sccr; +}; +struct pmc_type {int has_deep_sleep; };
@@ -87,6 +104,8 @@ static int has_deep_sleep, deep_sleeping;static int pmc_irq;static struct mpc83xx_pmc __iomem *pmc_regs;static struct mpc83xx_clock __iomem *clock_regs; +static struct mpc83xx_syscr __iomem *syscr_regs; +static struct mpc83xx_saved saved_regs;static int is_pci_agent, wake_from_pci;static phys_addr_t immrbase;static int pci_pm_state;
@@ -137,6 +156,20 @@ static irqreturn_t pmc_irq_handler(int irq, void *dev_id)return ret; } +static void mpc83xx_suspend_restore_regs (void ) +{ +out_be32 (&syscr_regs->sicrl, saved_regs.sicrl); +out_be32 (&syscr_regs->sicrh, saved_regs.sicrh); +out_be32 (&clock_regs->sccr, saved_regs.sccr); +} + +static void mpc83xx_suspend_save_regs (void ) +{ + saved_regs.sicrl =in_be32 (&syscr_regs->sicrl); + saved_regs.sicrh =in_be32 (&syscr_regs->sicrh); + saved_regs.sccr =in_be32 (&clock_regs->sccr); +} +static int mpc83xx_suspend_enter (suspend_state_t state) {int ret = -EAGAIN ;
@@ -166,6 +199,8 @@ static int mpc83xx_suspend_enter(suspend_state_t state)*/ if (deep_sleeping) { +mpc83xx_suspend_save_regs (); +out_be32 (&pmc_regs->mask,PMCER_ALL ); out_be32(&pmc_regs->config1,
@@ -179,6 +214,8 @@ static int mpc83xx_suspend_enter(suspend_state_t state) in_be32(&pmc_regs->config1) & ~PMCCR1_POWER_OFF);out_be32 (&pmc_regs->mask,PMCER_PMCI ); + +mpc83xx_suspend_restore_regs (); }else {out_be32 (&pmc_regs->mask,PMCER_PMCI );
@@ -333,12 +370,23 @@ static int pmc_probe(struct of_device *ofdev, goto out_pmc; } +if (has_deep_sleep) { + syscr_regs =ioremap (immrbase +IMMR_SYSCR_OFFSET , +sizeof (*syscr_regs)); +if (!syscr_regs) { + ret = -ENOMEM ; + goto out_syscr; + } + } +if (is_pci_agent)mpc83xx_set_agent ();suspend_set_ops (&mpc83xx_suspend_ops);return 0 ; +out_syscr: +iounmap (clock_regs); out_pmc:iounmap (pmc_regs); out:
Signature · 1 line
1.6.3.3
Kumar Gala
AppliedRe: [PATCH 2/3] powerpc/83xx/suspend: Save and restore SICRL, SICRH and SCCR
Quoted 1 line · Anton Vorontsov
We need to save SICRL, SICRH and SCCR registers on suspend, and =
restore
Quoted 6 lines
them on resume. Otherwise, we lose IO and clocks setup on MPC8315E-RDB boards when ULPI USB PHY is used (non-POR setup).
=20Signed-off-by Anton Vorontsov <[email protected]>---
arch/powerpc/platforms/83xx/suspend.c| 48 =
+++++++++++++++++++++++++++++++++
Quoted 1 line
1 files changed, 48 insertions(+), 0 deletions(-)
applied to next
- k=
PATCH v2 3/3 powerpc/83xx: Add power management support for MPC8315E-RDB boards
In reply to Anton Vorontsov- Add nodes for PMC and GTM controllers. GTM4 can be used as a wakeup source;
- Add fsl,magic-packet properties to eTSEC nodes, i.e. wake-on-lan support. Unlike MPC8313 processors, MPC8315 can resume from deep sleep upon magic packet reception.
--- arch/powerpc/boot/dts/mpc8315erdb.dts | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
arch/powerpc/boot/dts/mpc8315erdb.dts +27 -0
@@ -204,6 +204,7 @@ interrupt-parent = <&ipic>; tbi-handle = <&tbi0>; phy-handle = < &phy0 >; + fsl,magic-packet; mdio@520 { #address-cells = <1>;
@@ -246,6 +247,7 @@ interrupt-parent = <&ipic>; tbi-handle = <&tbi1>; phy-handle = < &phy1 >; + fsl,magic-packet; mdio@520 { #address-cells = <1>;
@@ -309,6 +311,22 @@ interrupt-parent = <&ipic>; }; + gtm1: timer@500 { + compatible = "fsl,mpc8315-gtm", "fsl,gtm"; + reg = <0x500 0x100>; + interrupts = <90 8 78 8 84 8 72 8>; + interrupt-parent = <&ipic>; + clock-frequency = <133333333>; + }; + + timer@600 { + compatible = "fsl,mpc8315-gtm", "fsl,gtm"; + reg = <0x600 0x100>; + interrupts = <91 8 79 8 85 8 73 8>; + interrupt-parent = <&ipic>; + clock-frequency = <133333333>; + }; + /* IPIC * interrupts cell = <intr #, sense> * sense values match linux IORESOURCE_IRQ_* defines:
@@ -337,6 +355,15 @@ 0x59 0x8>; interrupt-parent = < &ipic >; }; + + pmc: power@b00 { + compatible = "fsl,mpc8315-pmc", "fsl,mpc8313-pmc", + "fsl,mpc8349-pmc"; + reg = <0xb00 0x100 0xa00 0x100>; + interrupts = <80 8>; + interrupt-parent = <&ipic>; + fsl,mpc8313-wakeup-timer = <>m1>; + }; }; pci0: pci@e0008500 {
Signature · 1 line
1.6.3.3
Kumar Gala
AppliedRe: [PATCH 3/3] powerpc/83xx: Add power management support for MPC8315E-RDB boards
Quoted 11 lines · Anton Vorontsov
- Add nodes for PMC and GTM controllers. GTM4 can be used as a wakeup source;
- Add fsl,magic-packet properties to eTSEC nodes, i.e. wake-on-lan support. Unlike MPC8313 processors, MPC8315 can resume from deep sleep upon magic packet reception.
Signed-off-by Anton Vorontsov <[email protected]>---
arch/powerpc/boot/dts/mpc8315erdb.dts| 27 +++++++++++++++++++++++++++1 files changed, 27 insertions(+), 0 deletions(-)
applied to next
- k
Quoted 6 lines · Anton Vorontsov
Hi all,
This is quite late resend, sorry.
Only the third patch has changed, i.e. I got rid of sleep-nexus stuff per Scott and Benjamin suggestions.
-Scott