diff mbox

[5/6] powerpc/fsl-pci: Add pci inbound/outbound PM support

Message ID 1343125210-16720-5-git-send-email-B38951@freescale.com (mailing list archive)
State Superseded
Delegated to: Kumar Gala
Headers show

Commit Message

Hongtao Jia July 24, 2012, 10:20 a.m. UTC
Power supply for PCI inbound/outbound window registers is off when system
go to deep-sleep state. We save the values of registers before suspend
and restore to registers after resume.

Signed-off-by: Jiang Yutang <b14898@freescale.com>
Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/include/asm/pci-bridge.h |    2 +-
 arch/powerpc/sysdev/fsl_pci.c         |  121 +++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+), 1 deletions(-)

Comments

Kumar Gala July 27, 2012, 1:24 p.m. UTC | #1
On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:

> Power supply for PCI inbound/outbound window registers is off when system
> go to deep-sleep state. We save the values of registers before suspend
> and restore to registers after resume.
> 
> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> Signed-off-by: Li Yang <leoli@freescale.com>
> ---
> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> arch/powerpc/sysdev/fsl_pci.c         |  121 +++++++++++++++++++++++++++++++++
> 2 files changed, 122 insertions(+), 1 deletions(-)

Remind me why we need to save/restore PCI ATMUs, why not just re-parse the device tree to restore?

- k
Hongtao Jia July 30, 2012, 6:09 a.m. UTC | #2
> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Friday, July 27, 2012 9:24 PM
> To: Jia Hongtao-B38951
> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> 
> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> 
> > Power supply for PCI inbound/outbound window registers is off when
> system
> > go to deep-sleep state. We save the values of registers before suspend
> > and restore to registers after resume.
> >
> > Signed-off-by: Jiang Yutang <b14898@freescale.com>
> > Signed-off-by: Jia Hongtao <B38951@freescale.com>
> > Signed-off-by: Li Yang <leoli@freescale.com>
> > ---
> > arch/powerpc/include/asm/pci-bridge.h |    2 +-
> > arch/powerpc/sysdev/fsl_pci.c         |  121
> +++++++++++++++++++++++++++++++++
> > 2 files changed, 122 insertions(+), 1 deletions(-)
> 
> Remind me why we need to save/restore PCI ATMUs, why not just re-parse
> the device tree to restore?
> 
> - k

Save/restore is the more efficient way. Latency of sleep/wakeup is one of
most important features in power management.

-Hongtao.
Kumar Gala July 31, 2012, 1:37 p.m. UTC | #3
On Jul 30, 2012, at 1:09 AM, Jia Hongtao-B38951 wrote:

>> -----Original Message-----
>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
>> Sent: Friday, July 27, 2012 9:24 PM
>> To: Jia Hongtao-B38951
>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
>> support
>> 
>> 
>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
>> 
>>> Power supply for PCI inbound/outbound window registers is off when
>> system
>>> go to deep-sleep state. We save the values of registers before suspend
>>> and restore to registers after resume.
>>> 
>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
>>> Signed-off-by: Li Yang <leoli@freescale.com>
>>> ---
>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
>>> arch/powerpc/sysdev/fsl_pci.c         |  121
>> +++++++++++++++++++++++++++++++++
>>> 2 files changed, 122 insertions(+), 1 deletions(-)
>> 
>> Remind me why we need to save/restore PCI ATMUs, why not just re-parse
>> the device tree to restore?
>> 
>> - k
> 
> Save/restore is the more efficient way. Latency of sleep/wakeup is one of
> most important features in power management.
> 
> -Hongtao.

I don't think the time it takes to run through setup_pci_atmu() is that long compared to fsl_pci_resume().

Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on resume?

- k
Hongtao Jia Aug. 2, 2012, 11:35 a.m. UTC | #4
> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Tuesday, July 31, 2012 9:37 PM
> To: Jia Hongtao-B38951
> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> 
> On Jul 30, 2012, at 1:09 AM, Jia Hongtao-B38951 wrote:
> 
> >> -----Original Message-----
> >> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> >> Sent: Friday, July 27, 2012 9:24 PM
> >> To: Jia Hongtao-B38951
> >> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
> >> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> >> support
> >>
> >>
> >> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> >>
> >>> Power supply for PCI inbound/outbound window registers is off when
> >> system
> >>> go to deep-sleep state. We save the values of registers before
> suspend
> >>> and restore to registers after resume.
> >>>
> >>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> >>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> >>> Signed-off-by: Li Yang <leoli@freescale.com>
> >>> ---
> >>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> >>> arch/powerpc/sysdev/fsl_pci.c         |  121
> >> +++++++++++++++++++++++++++++++++
> >>> 2 files changed, 122 insertions(+), 1 deletions(-)
> >>
> >> Remind me why we need to save/restore PCI ATMUs, why not just re-parse
> >> the device tree to restore?
> >>
> >> - k
> >
> > Save/restore is the more efficient way. Latency of sleep/wakeup is one
> of
> > most important features in power management.
> >
> > -Hongtao.
> 
> I don't think the time it takes to run through setup_pci_atmu() is that
> long compared to fsl_pci_resume().
> 
> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on resume?
> 
> - k

I will investigate on this and send the patch later.

-Hongtao.
Hongtao Jia Aug. 7, 2012, 10:11 a.m. UTC | #5
> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Tuesday, July 31, 2012 9:37 PM
> To: Jia Hongtao-B38951
> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> 
> On Jul 30, 2012, at 1:09 AM, Jia Hongtao-B38951 wrote:
> 
> >> -----Original Message-----
> >> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> >> Sent: Friday, July 27, 2012 9:24 PM
> >> To: Jia Hongtao-B38951
> >> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
> >> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> >> support
> >>
> >>
> >> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> >>
> >>> Power supply for PCI inbound/outbound window registers is off when
> >> system
> >>> go to deep-sleep state. We save the values of registers before
> >>> suspend and restore to registers after resume.
> >>>
> >>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> >>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> >>> Signed-off-by: Li Yang <leoli@freescale.com>
> >>> ---
> >>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> >>> arch/powerpc/sysdev/fsl_pci.c         |  121
> >> +++++++++++++++++++++++++++++++++
> >>> 2 files changed, 122 insertions(+), 1 deletions(-)
> >>
> >> Remind me why we need to save/restore PCI ATMUs, why not just
> >> re-parse the device tree to restore?
> >>
> >> - k
> >
> > Save/restore is the more efficient way. Latency of sleep/wakeup is one
> > of most important features in power management.
> >
> > -Hongtao.
> 
> I don't think the time it takes to run through setup_pci_atmu() is that
> long compared to fsl_pci_resume().
> 
> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on resume?
> 
> - k

Hi Kumar,
I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR is not
lost when system in deep sleep. We don't need to save it.

I will send PM patch after PCI initialization patch set being accepted. 

-Hongtao.
Scott Wood Aug. 7, 2012, 3:34 p.m. UTC | #6
On 08/07/2012 05:11 AM, Jia Hongtao-B38951 wrote:
> 
> 
>> -----Original Message-----
>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
>> Sent: Tuesday, July 31, 2012 9:37 PM
>> To: Jia Hongtao-B38951
>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
>> support
>>
>>
>> On Jul 30, 2012, at 1:09 AM, Jia Hongtao-B38951 wrote:
>>
>>>> -----Original Message-----
>>>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
>>>> Sent: Friday, July 27, 2012 9:24 PM
>>>> To: Jia Hongtao-B38951
>>>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
>>>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
>>>> support
>>>>
>>>>
>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
>>>>
>>>>> Power supply for PCI inbound/outbound window registers is off when
>>>> system
>>>>> go to deep-sleep state. We save the values of registers before
>>>>> suspend and restore to registers after resume.
>>>>>
>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
>>>>> ---
>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
>>>> +++++++++++++++++++++++++++++++++
>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
>>>>
>>>> Remind me why we need to save/restore PCI ATMUs, why not just
>>>> re-parse the device tree to restore?
>>>>
>>>> - k
>>>
>>> Save/restore is the more efficient way. Latency of sleep/wakeup is one
>>> of most important features in power management.
>>>
>>> -Hongtao.
>>
>> I don't think the time it takes to run through setup_pci_atmu() is that
>> long compared to fsl_pci_resume().
>>
>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on resume?
>>
>> - k
> 
> Hi Kumar,
> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR is not
> lost when system in deep sleep. We don't need to save it.

How does the PCI code know you're entering deep sleep and not hibernation?

-Scott
Kumar Gala Aug. 7, 2012, 5:34 p.m. UTC | #7
On Aug 7, 2012, at 10:34 AM, Scott Wood wrote:

> On 08/07/2012 05:11 AM, Jia Hongtao-B38951 wrote:
>> 
>> 
>>> -----Original Message-----
>>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
>>> Sent: Tuesday, July 31, 2012 9:37 PM
>>> To: Jia Hongtao-B38951
>>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
>>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
>>> support
>>> 
>>> 
>>> On Jul 30, 2012, at 1:09 AM, Jia Hongtao-B38951 wrote:
>>> 
>>>>> -----Original Message-----
>>>>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
>>>>> Sent: Friday, July 27, 2012 9:24 PM
>>>>> To: Jia Hongtao-B38951
>>>>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
>>>>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
>>>>> support
>>>>> 
>>>>> 
>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
>>>>> 
>>>>>> Power supply for PCI inbound/outbound window registers is off when
>>>>> system
>>>>>> go to deep-sleep state. We save the values of registers before
>>>>>> suspend and restore to registers after resume.
>>>>>> 
>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
>>>>>> ---
>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
>>>>> +++++++++++++++++++++++++++++++++
>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
>>>>> 
>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
>>>>> re-parse the device tree to restore?
>>>>> 
>>>>> - k
>>>> 
>>>> Save/restore is the more efficient way. Latency of sleep/wakeup is one
>>>> of most important features in power management.
>>>> 
>>>> -Hongtao.
>>> 
>>> I don't think the time it takes to run through setup_pci_atmu() is that
>>> long compared to fsl_pci_resume().
>>> 
>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on resume?
>>> 
>>> - k
>> 
>> Hi Kumar,
>> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR is not
>> lost when system in deep sleep. We don't need to save it.
> 
> How does the PCI code know you're entering deep sleep and not hibernation?
> 
> -Scott
> 

Also, are you sure PCICSRBAR does not need restoring?  I'd be surprised if PCICSRBAR was ok, but the ATMUs where not.

- k
Hongtao Jia Aug. 8, 2012, 3:07 a.m. UTC | #8
> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Wednesday, August 08, 2012 1:34 AM
> To: Wood Scott-B07421
> Cc: Jia Hongtao-B38951; linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421;
> Li Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> 
> On Aug 7, 2012, at 10:34 AM, Scott Wood wrote:
> 
> > On 08/07/2012 05:11 AM, Jia Hongtao-B38951 wrote:
> >>
> >>
> >>> -----Original Message-----
> >>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> >>> Sent: Tuesday, July 31, 2012 9:37 PM
> >>> To: Jia Hongtao-B38951
> >>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
> >>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound
> >>> PM support
> >>>
> >>>
> >>> On Jul 30, 2012, at 1:09 AM, Jia Hongtao-B38951 wrote:
> >>>
> >>>>> -----Original Message-----
> >>>>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> >>>>> Sent: Friday, July 27, 2012 9:24 PM
> >>>>> To: Jia Hongtao-B38951
> >>>>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li
> >>>>> Yang-R58472
> >>>>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound
> >>>>> PM support
> >>>>>
> >>>>>
> >>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> >>>>>
> >>>>>> Power supply for PCI inbound/outbound window registers is off
> >>>>>> when
> >>>>> system
> >>>>>> go to deep-sleep state. We save the values of registers before
> >>>>>> suspend and restore to registers after resume.
> >>>>>>
> >>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> >>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> >>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
> >>>>>> ---
> >>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> >>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
> >>>>> +++++++++++++++++++++++++++++++++
> >>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
> >>>>>
> >>>>> Remind me why we need to save/restore PCI ATMUs, why not just
> >>>>> re-parse the device tree to restore?
> >>>>>
> >>>>> - k
> >>>>
> >>>> Save/restore is the more efficient way. Latency of sleep/wakeup is
> >>>> one of most important features in power management.
> >>>>
> >>>> -Hongtao.
> >>>
> >>> I don't think the time it takes to run through setup_pci_atmu() is
> >>> that long compared to fsl_pci_resume().
> >>>
> >>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
> resume?
> >>>
> >>> - k
> >>
> >> Hi Kumar,
> >> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR
> >> is not lost when system in deep sleep. We don't need to save it.
> >
> > How does the PCI code know you're entering deep sleep and not
> hibernation?
> >
> > -Scott
> >
> 
> Also, are you sure PCICSRBAR does not need restoring?  I'd be surprised
> if PCICSRBAR was ok, but the ATMUs where not.
> 
> - k
> 

PEXCSRBAR is in configuration space and ATMUs are memory map registers.
I guess there are different power supplies.

-Hongtao.
Hongtao Jia Aug. 8, 2012, 9:54 a.m. UTC | #9
> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Tuesday, August 07, 2012 11:35 PM
> To: Jia Hongtao-B38951
> Cc: Kumar Gala; linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li
> Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> On 08/07/2012 05:11 AM, Jia Hongtao-B38951 wrote:
> >
> >
> >> -----Original Message-----
> >> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> >> Sent: Tuesday, July 31, 2012 9:37 PM
> >> To: Jia Hongtao-B38951
> >> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li Yang-R58472
> >> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> >> support
> >>
> >>
> >> On Jul 30, 2012, at 1:09 AM, Jia Hongtao-B38951 wrote:
> >>
> >>>> -----Original Message-----
> >>>> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> >>>> Sent: Friday, July 27, 2012 9:24 PM
> >>>> To: Jia Hongtao-B38951
> >>>> Cc: linuxppc-dev@lists.ozlabs.org; Wood Scott-B07421; Li
> >>>> Yang-R58472
> >>>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound
> >>>> PM support
> >>>>
> >>>>
> >>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> >>>>
> >>>>> Power supply for PCI inbound/outbound window registers is off when
> >>>> system
> >>>>> go to deep-sleep state. We save the values of registers before
> >>>>> suspend and restore to registers after resume.
> >>>>>
> >>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> >>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> >>>>> Signed-off-by: Li Yang <leoli@freescale.com>
> >>>>> ---
> >>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> >>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
> >>>> +++++++++++++++++++++++++++++++++
> >>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
> >>>>
> >>>> Remind me why we need to save/restore PCI ATMUs, why not just
> >>>> re-parse the device tree to restore?
> >>>>
> >>>> - k
> >>>
> >>> Save/restore is the more efficient way. Latency of sleep/wakeup is
> >>> one of most important features in power management.
> >>>
> >>> -Hongtao.
> >>
> >> I don't think the time it takes to run through setup_pci_atmu() is
> >> that long compared to fsl_pci_resume().
> >>
> >> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
> resume?
> >>
> >> - k
> >
> > Hi Kumar,
> > I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR
> > is not lost when system in deep sleep. We don't need to save it.
> 
> How does the PCI code know you're entering deep sleep and not hibernation?
> 
> -Scott

When system come back from hibernation PCI will be initialized again.
So no need to save PCI_CMD and PEXCSRBAR.

-Hongtao.
Kumar Gala Aug. 8, 2012, 12:46 p.m. UTC | #10
>>>>>> 
>>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
>>>>>> 
>>>>>>> Power supply for PCI inbound/outbound window registers is off when
>>>>>> system
>>>>>>> go to deep-sleep state. We save the values of registers before
>>>>>>> suspend and restore to registers after resume.
>>>>>>> 
>>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
>>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
>>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
>>>>>>> ---
>>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
>>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
>>>>>> +++++++++++++++++++++++++++++++++
>>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
>>>>>> 
>>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
>>>>>> re-parse the device tree to restore?
>>>>>> 
>>>>>> - k
>>>>> 
>>>>> Save/restore is the more efficient way. Latency of sleep/wakeup is
>>>>> one of most important features in power management.
>>>>> 
>>>>> -Hongtao.
>>>> 
>>>> I don't think the time it takes to run through setup_pci_atmu() is
>>>> that long compared to fsl_pci_resume().
>>>> 
>>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
>> resume?
>>>> 
>>>> - k
>>> 
>>> Hi Kumar,
>>> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR
>>> is not lost when system in deep sleep. We don't need to save it.
>> 
>> How does the PCI code know you're entering deep sleep and not hibernation?
>> 
>> -Scott
> 
> When system come back from hibernation PCI will be initialized again.
> So no need to save PCI_CMD and PEXCSRBAR.
> 
> -Hongtao. 
> 

What do you mean PCI will be initialized again?  What code path are you talking about that would set PCI_CMD & PEXCSRBAR?

- k
Scott Wood Aug. 8, 2012, 9:04 p.m. UTC | #11
On 08/08/2012 07:46 AM, Kumar Gala wrote:
>>>>>>>
>>>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
>>>>>>>
>>>>>>>> Power supply for PCI inbound/outbound window registers is off when
>>>>>>> system
>>>>>>>> go to deep-sleep state. We save the values of registers before
>>>>>>>> suspend and restore to registers after resume.
>>>>>>>>
>>>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
>>>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
>>>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
>>>>>>>> ---
>>>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
>>>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
>>>>>>> +++++++++++++++++++++++++++++++++
>>>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
>>>>>>>
>>>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
>>>>>>> re-parse the device tree to restore?
>>>>>>>
>>>>>>> - k
>>>>>>
>>>>>> Save/restore is the more efficient way. Latency of sleep/wakeup is
>>>>>> one of most important features in power management.
>>>>>>
>>>>>> -Hongtao.
>>>>>
>>>>> I don't think the time it takes to run through setup_pci_atmu() is
>>>>> that long compared to fsl_pci_resume().
>>>>>
>>>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
>>> resume?
>>>>>
>>>>> - k
>>>>
>>>> Hi Kumar,
>>>> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR
>>>> is not lost when system in deep sleep. We don't need to save it.

How do you know you're not just getting lucky?  Maybe it only survives
deep sleep up to a certain duration, or under other specific circumstances.

Can you find anywhere that documents what state will be retained during
deep sleep, or ask an appropriate hardware designer?

-Scott
Hongtao Jia Aug. 9, 2012, 2:52 a.m. UTC | #12
> -----Original Message-----
> From: Linuxppc-dev [mailto:linuxppc-dev-
> bounces+b38951=freescale.com@lists.ozlabs.org] On Behalf Of Kumar Gala
> Sent: Wednesday, August 08, 2012 8:47 PM
> To: Jia Hongtao-B38951
> Cc: Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org; Li Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> >>>>>>
> >>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> >>>>>>
> >>>>>>> Power supply for PCI inbound/outbound window registers is off
> >>>>>>> when
> >>>>>> system
> >>>>>>> go to deep-sleep state. We save the values of registers before
> >>>>>>> suspend and restore to registers after resume.
> >>>>>>>
> >>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> >>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> >>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
> >>>>>>> ---
> >>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> >>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
> >>>>>> +++++++++++++++++++++++++++++++++
> >>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
> >>>>>>
> >>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
> >>>>>> re-parse the device tree to restore?
> >>>>>>
> >>>>>> - k
> >>>>>
> >>>>> Save/restore is the more efficient way. Latency of sleep/wakeup is
> >>>>> one of most important features in power management.
> >>>>>
> >>>>> -Hongtao.
> >>>>
> >>>> I don't think the time it takes to run through setup_pci_atmu() is
> >>>> that long compared to fsl_pci_resume().
> >>>>
> >>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
> >> resume?
> >>>>
> >>>> - k
> >>>
> >>> Hi Kumar,
> >>> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR
> >>> is not lost when system in deep sleep. We don't need to save it.
> >>
> >> How does the PCI code know you're entering deep sleep and not
> hibernation?
> >>
> >> -Scott
> >
> > When system come back from hibernation PCI will be initialized again.
> > So no need to save PCI_CMD and PEXCSRBAR.
> >
> > -Hongtao.
> >
> 
> What do you mean PCI will be initialized again?  What code path are you
> talking about that would set PCI_CMD & PEXCSRBAR?
> 
> - k


In hibernation mode:

When system come back from hibernation kernel will start up again.
Before loading hibernation image PCI initialization has already done.
Some other hardware also re-init again.

-Hongtao.
Yang Li Aug. 9, 2012, 5:05 a.m. UTC | #13
On Thu, Aug 9, 2012 at 10:52 AM, Jia Hongtao-B38951
<B38951@freescale.com> wrote:
>
>
>> -----Original Message-----
>> From: Linuxppc-dev [mailto:linuxppc-dev-
>> bounces+b38951=freescale.com@lists.ozlabs.org] On Behalf Of Kumar Gala
>> Sent: Wednesday, August 08, 2012 8:47 PM
>> To: Jia Hongtao-B38951
>> Cc: Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org; Li Yang-R58472
>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
>> support
>>
>> >>>>>>
>> >>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
>> >>>>>>
>> >>>>>>> Power supply for PCI inbound/outbound window registers is off
>> >>>>>>> when
>> >>>>>> system
>> >>>>>>> go to deep-sleep state. We save the values of registers before
>> >>>>>>> suspend and restore to registers after resume.
>> >>>>>>>
>> >>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
>> >>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
>> >>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
>> >>>>>>> ---
>> >>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
>> >>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
>> >>>>>> +++++++++++++++++++++++++++++++++
>> >>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
>> >>>>>>
>> >>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
>> >>>>>> re-parse the device tree to restore?
>> >>>>>>
>> >>>>>> - k
>> >>>>>
>> >>>>> Save/restore is the more efficient way. Latency of sleep/wakeup is
>> >>>>> one of most important features in power management.
>> >>>>>
>> >>>>> -Hongtao.
>> >>>>
>> >>>> I don't think the time it takes to run through setup_pci_atmu() is
>> >>>> that long compared to fsl_pci_resume().
>> >>>>
>> >>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
>> >> resume?
>> >>>>
>> >>>> - k
>> >>>
>> >>> Hi Kumar,
>> >>> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR
>> >>> is not lost when system in deep sleep. We don't need to save it.
>> >>
>> >> How does the PCI code know you're entering deep sleep and not
>> hibernation?
>> >>
>> >> -Scott
>> >
>> > When system come back from hibernation PCI will be initialized again.
>> > So no need to save PCI_CMD and PEXCSRBAR.
>> >
>> > -Hongtao.
>> >
>>
>> What do you mean PCI will be initialized again?  What code path are you
>> talking about that would set PCI_CMD & PEXCSRBAR?
>>
>> - k
>
>
> In hibernation mode:
>
> When system come back from hibernation kernel will start up again.
> Before loading hibernation image PCI initialization has already done.
> Some other hardware also re-init again.

In current Linux implementation, restoring from hibernation image is
using late initcall.  By that time, all the platform devices are
already initialized like a fresh boot.

- Leo
Hongtao Jia Aug. 9, 2012, 10:32 a.m. UTC | #14
> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Thursday, August 09, 2012 5:04 AM
> To: Kumar Gala
> Cc: Jia Hongtao-B38951; Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org;
> Li Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> On 08/08/2012 07:46 AM, Kumar Gala wrote:
> >>>>>>>
> >>>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> >>>>>>>
> >>>>>>>> Power supply for PCI inbound/outbound window registers is off
> >>>>>>>> when
> >>>>>>> system
> >>>>>>>> go to deep-sleep state. We save the values of registers before
> >>>>>>>> suspend and restore to registers after resume.
> >>>>>>>>
> >>>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> >>>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> >>>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
> >>>>>>>> ---
> >>>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> >>>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
> >>>>>>> +++++++++++++++++++++++++++++++++
> >>>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
> >>>>>>>
> >>>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
> >>>>>>> re-parse the device tree to restore?
> >>>>>>>
> >>>>>>> - k
> >>>>>>
> >>>>>> Save/restore is the more efficient way. Latency of sleep/wakeup
> >>>>>> is one of most important features in power management.
> >>>>>>
> >>>>>> -Hongtao.
> >>>>>
> >>>>> I don't think the time it takes to run through setup_pci_atmu() is
> >>>>> that long compared to fsl_pci_resume().
> >>>>>
> >>>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
> >>> resume?
> >>>>>
> >>>>> - k
> >>>>
> >>>> Hi Kumar,
> >>>> I did some tests on P1022DS and found out that PCI_CMD and
> >>>> PCICSRBAR is not lost when system in deep sleep. We don't need to
> save it.
> 
> How do you know you're not just getting lucky?  Maybe it only survives
> deep sleep up to a certain duration, or under other specific
> circumstances.

I tested for more than 10 mins in deep sleep and the result is the same.

> 
> Can you find anywhere that documents what state will be retained during
> deep sleep, or ask an appropriate hardware designer?
> 
> -Scott

I agree with you that we should find out what state will be retained during
deep sleep. But P1022 RM doc has limited information for this. If I can get
more information from hardware designer that will be good.
Kumar Gala Aug. 9, 2012, 1:08 p.m. UTC | #15
On Aug 9, 2012, at 12:05 AM, Li Yang wrote:

> On Thu, Aug 9, 2012 at 10:52 AM, Jia Hongtao-B38951
> <B38951@freescale.com> wrote:
>> 
>> 
>>> -----Original Message-----
>>> From: Linuxppc-dev [mailto:linuxppc-dev-
>>> bounces+b38951=freescale.com@lists.ozlabs.org] On Behalf Of Kumar Gala
>>> Sent: Wednesday, August 08, 2012 8:47 PM
>>> To: Jia Hongtao-B38951
>>> Cc: Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org; Li Yang-R58472
>>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
>>> support
>>> 
>>>>>>>>> 
>>>>>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
>>>>>>>>> 
>>>>>>>>>> Power supply for PCI inbound/outbound window registers is off
>>>>>>>>>> when
>>>>>>>>> system
>>>>>>>>>> go to deep-sleep state. We save the values of registers before
>>>>>>>>>> suspend and restore to registers after resume.
>>>>>>>>>> 
>>>>>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
>>>>>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
>>>>>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
>>>>>>>>>> ---
>>>>>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
>>>>>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
>>>>>>>>> +++++++++++++++++++++++++++++++++
>>>>>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
>>>>>>>>> 
>>>>>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
>>>>>>>>> re-parse the device tree to restore?
>>>>>>>>> 
>>>>>>>>> - k
>>>>>>>> 
>>>>>>>> Save/restore is the more efficient way. Latency of sleep/wakeup is
>>>>>>>> one of most important features in power management.
>>>>>>>> 
>>>>>>>> -Hongtao.
>>>>>>> 
>>>>>>> I don't think the time it takes to run through setup_pci_atmu() is
>>>>>>> that long compared to fsl_pci_resume().
>>>>>>> 
>>>>>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd() on
>>>>> resume?
>>>>>>> 
>>>>>>> - k
>>>>>> 
>>>>>> Hi Kumar,
>>>>>> I did some tests on P1022DS and found out that PCI_CMD and PCICSRBAR
>>>>>> is not lost when system in deep sleep. We don't need to save it.
>>>>> 
>>>>> How does the PCI code know you're entering deep sleep and not
>>> hibernation?
>>>>> 
>>>>> -Scott
>>>> 
>>>> When system come back from hibernation PCI will be initialized again.
>>>> So no need to save PCI_CMD and PEXCSRBAR.
>>>> 
>>>> -Hongtao.
>>>> 
>>> 
>>> What do you mean PCI will be initialized again?  What code path are you
>>> talking about that would set PCI_CMD & PEXCSRBAR?
>>> 
>>> - k
>> 
>> 
>> In hibernation mode:
>> 
>> When system come back from hibernation kernel will start up again.
>> Before loading hibernation image PCI initialization has already done.
>> Some other hardware also re-init again.
> 
> In current Linux implementation, restoring from hibernation image is
> using late initcall.  By that time, all the platform devices are
> already initialized like a fresh boot.
> 
> - Leo

I ask against, what specific code path (I'd like a call trace) would cause PCI_CMD and PEXCSRBAR to be set in the wakeup case?

- k
Hongtao Jia Aug. 10, 2012, 2:17 a.m. UTC | #16
> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org]
> Sent: Thursday, August 09, 2012 9:08 PM
> To: Li Yang-R58472
> Cc: Jia Hongtao-B38951; Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org;
> Li Yang-R58472
> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound PM
> support
> 
> 
> On Aug 9, 2012, at 12:05 AM, Li Yang wrote:
> 
> > On Thu, Aug 9, 2012 at 10:52 AM, Jia Hongtao-B38951
> > <B38951@freescale.com> wrote:
> >>
> >>
> >>> -----Original Message-----
> >>> From: Linuxppc-dev [mailto:linuxppc-dev-
> >>> bounces+b38951=freescale.com@lists.ozlabs.org] On Behalf Of Kumar
> >>> bounces+Gala
> >>> Sent: Wednesday, August 08, 2012 8:47 PM
> >>> To: Jia Hongtao-B38951
> >>> Cc: Wood Scott-B07421; linuxppc-dev@lists.ozlabs.org; Li Yang-R58472
> >>> Subject: Re: [PATCH 5/6] powerpc/fsl-pci: Add pci inbound/outbound
> >>> PM support
> >>>
> >>>>>>>>>
> >>>>>>>>> On Jul 24, 2012, at 5:20 AM, Jia Hongtao wrote:
> >>>>>>>>>
> >>>>>>>>>> Power supply for PCI inbound/outbound window registers is off
> >>>>>>>>>> when
> >>>>>>>>> system
> >>>>>>>>>> go to deep-sleep state. We save the values of registers
> >>>>>>>>>> before suspend and restore to registers after resume.
> >>>>>>>>>>
> >>>>>>>>>> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> >>>>>>>>>> Signed-off-by: Jia Hongtao <B38951@freescale.com>
> >>>>>>>>>> Signed-off-by: Li Yang <leoli@freescale.com>
> >>>>>>>>>> ---
> >>>>>>>>>> arch/powerpc/include/asm/pci-bridge.h |    2 +-
> >>>>>>>>>> arch/powerpc/sysdev/fsl_pci.c         |  121
> >>>>>>>>> +++++++++++++++++++++++++++++++++
> >>>>>>>>>> 2 files changed, 122 insertions(+), 1 deletions(-)
> >>>>>>>>>
> >>>>>>>>> Remind me why we need to save/restore PCI ATMUs, why not just
> >>>>>>>>> re-parse the device tree to restore?
> >>>>>>>>>
> >>>>>>>>> - k
> >>>>>>>>
> >>>>>>>> Save/restore is the more efficient way. Latency of sleep/wakeup
> >>>>>>>> is one of most important features in power management.
> >>>>>>>>
> >>>>>>>> -Hongtao.
> >>>>>>>
> >>>>>>> I don't think the time it takes to run through setup_pci_atmu()
> >>>>>>> is that long compared to fsl_pci_resume().
> >>>>>>>
> >>>>>>> Also, don't you need to setup PCICCSRBAR and do setup_pci_cmd()
> >>>>>>> on
> >>>>> resume?
> >>>>>>>
> >>>>>>> - k
> >>>>>>
> >>>>>> Hi Kumar,
> >>>>>> I did some tests on P1022DS and found out that PCI_CMD and
> >>>>>> PCICSRBAR is not lost when system in deep sleep. We don't need to
> save it.
> >>>>>
> >>>>> How does the PCI code know you're entering deep sleep and not
> >>> hibernation?
> >>>>>
> >>>>> -Scott
> >>>>
> >>>> When system come back from hibernation PCI will be initialized again.
> >>>> So no need to save PCI_CMD and PEXCSRBAR.
> >>>>
> >>>> -Hongtao.
> >>>>
> >>>
> >>> What do you mean PCI will be initialized again?  What code path are
> >>> you talking about that would set PCI_CMD & PEXCSRBAR?
> >>>
> >>> - k
> >>
> >>
> >> In hibernation mode:
> >>
> >> When system come back from hibernation kernel will start up again.
> >> Before loading hibernation image PCI initialization has already done.
> >> Some other hardware also re-init again.
> >
> > In current Linux implementation, restoring from hibernation image is
> > using late initcall.  By that time, all the platform devices are
> > already initialized like a fresh boot.
> >
> > - Leo
> 
> I ask against, what specific code path (I'd like a call trace) would
> cause PCI_CMD and PEXCSRBAR to be set in the wakeup case?
> 
> - k

The code path is the same as a fresh boot:
fsl_add_bridge()
	-> setup_pci_cmd() [PCI_CMD is set]
	-> setup_pci_atmu() [PEXCSRBAR is set]

- Hongtao.
diff mbox

Patch

diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index b48fa7f..f0f00a7 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -90,9 +90,9 @@  struct pci_controller {
 
 #ifdef CONFIG_PPC64
 	unsigned long buid;
+#endif	/* CONFIG_PPC64 */
 
 	void *private_data;
-#endif	/* CONFIG_PPC64 */
 };
 
 /* These are used for config access before all the PCI probing
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 2a369be..a14ee6f 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -965,12 +965,133 @@  static int __devinit fsl_pci_probe(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_SUSPEND
+
+#define PCI_POW_PIW_OFFSET	0xc00
+#define PCI_POW_PIW_SIZE	0x200
+#define PCI_POW_NUMBER		5
+
+static int fsl_pci_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct pci_controller *hose;
+	struct pci_outbound_window_regs *pci_saved_pow;
+	struct pci_inbound_window_regs *pci_saved_piw, *temp_piw;
+	struct resource pci_rsrc;
+	unsigned int i;
+	struct fsl_pci_private_data *sus_info;
+
+	hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
+	of_address_to_resource(pdev->dev.of_node, 0, &pci_rsrc);
+
+	sus_info = kmalloc(
+			sizeof(struct fsl_pci_private_data), GFP_KERNEL);
+	if (!sus_info)
+		return -ENOMEM;
+
+	hose->private_data = sus_info;
+
+	sus_info->pci_pow = ioremap(pci_rsrc.start + PCI_POW_PIW_OFFSET,
+			PCI_POW_PIW_SIZE);
+	if (!sus_info->pci_pow) {
+		dev_err(&pdev->dev, "pci outbound/inbound windows ioremap error!\n");
+		goto err1;
+	}
+
+	sus_info->pci_piw = (struct pci_inbound_window_regs *)
+		((void *)sus_info->pci_pow + PCI_POW_PIW_SIZE) - 1;
+
+	if (of_device_is_compatible(pdev->dev.of_node, "fsl,qoriq-pcie-v2.2"))
+		sus_info->inbound_num = 4;
+	else
+		sus_info->inbound_num = 3;
+
+	sus_info->saved_regs = kmalloc(
+		sizeof(struct pci_outbound_window_regs) * PCI_POW_NUMBER +
+		sizeof(struct pci_inbound_window_regs) * sus_info->inbound_num,
+		GFP_KERNEL);
+	if (!sus_info->saved_regs)
+		goto err2;
+
+	pci_saved_pow = sus_info->saved_regs;
+	for (i = 0; i < PCI_POW_NUMBER; i++) {
+		pci_saved_pow[i].potar = in_be32(&sus_info->pci_pow[i].potar);
+		pci_saved_pow[i].potear = in_be32(&sus_info->pci_pow[i].potear);
+		pci_saved_pow[i].powbar = in_be32(&sus_info->pci_pow[i].powbar);
+		pci_saved_pow[i].powar = in_be32(&sus_info->pci_pow[i].powar);
+	}
+
+	pci_saved_piw = (struct pci_inbound_window_regs *)
+		(pci_saved_pow + PCI_POW_NUMBER);
+	temp_piw = sus_info->pci_piw;
+	for (i = 0; i < sus_info->inbound_num; i++, temp_piw--) {
+		pci_saved_piw[i].pitar = in_be32(&temp_piw->pitar);
+		pci_saved_piw[i].piwbar = in_be32(&temp_piw->piwbar);
+		pci_saved_piw[i].piwbear = in_be32(&temp_piw->piwbear);
+		pci_saved_piw[i].piwar = in_be32(&temp_piw->piwar);
+	}
+
+	return 0;
+
+err2:
+	iounmap(sus_info->pci_pow);
+
+err1:
+	kfree(sus_info);
+	return -ENOMEM;
+}
+
+static int fsl_pci_resume(struct platform_device *pdev)
+{
+	struct pci_controller *hose;
+	struct pci_outbound_window_regs *pci_saved_pow;
+	struct pci_inbound_window_regs *pci_saved_piw, *temp_piw;
+	unsigned int i;
+	struct fsl_pci_private_data *sus_info;
+
+	hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
+	sus_info = (struct fsl_pci_private_data *)hose->private_data;
+
+	if (!sus_info->pci_pow || !sus_info->pci_piw || !sus_info->saved_regs)
+		return 0;
+
+	pci_saved_pow = sus_info->saved_regs;
+	for (i = 0; i < PCI_POW_NUMBER; i++) {
+		out_be32(&sus_info->pci_pow[i].potar, pci_saved_pow[i].potar);
+		out_be32(&sus_info->pci_pow[i].potear, pci_saved_pow[i].potear);
+		out_be32(&sus_info->pci_pow[i].powbar, pci_saved_pow[i].powbar);
+		out_be32(&sus_info->pci_pow[i].powar, pci_saved_pow[i].powar);
+	}
+
+	pci_saved_piw = (struct pci_inbound_window_regs *)
+		(pci_saved_pow + PCI_POW_NUMBER);
+	temp_piw = sus_info->pci_piw;
+	for (i = 0; i < sus_info->inbound_num; i++, temp_piw--) {
+		out_be32(&temp_piw->pitar, pci_saved_piw[i].pitar);
+		out_be32(&temp_piw->piwbar, pci_saved_piw[i].piwbar);
+		out_be32(&temp_piw->piwbear, pci_saved_piw[i].piwbear);
+		out_be32(&temp_piw->piwar, pci_saved_piw[i].piwar);
+	}
+	iounmap(sus_info->pci_pow);
+	kfree(sus_info->saved_regs);
+	sus_info->saved_regs = NULL;
+	kfree(sus_info);
+	sus_info = NULL;
+	hose->private_data = NULL;
+
+	return 0;
+}
+#endif
+
 static struct platform_driver fsl_pci_driver = {
 	.driver = {
 		.name = "fsl-pci",
 		.of_match_table = pci_ids,
 	},
 	.probe = fsl_pci_probe,
+#ifdef CONFIG_SUSPEND
+	.suspend	= fsl_pci_suspend,
+	.resume		= fsl_pci_resume,
+#endif
 };
 
 static int __init fsl_pci_init(void)