diff mbox

ARM: shmobile: Break out R-Car SYSC PM code

Message ID 20140115074308.8471.64824.sendpatchset@w520 (mailing list archive)
State New, archived
Headers show

Commit Message

Magnus Damm Jan. 15, 2014, 7:43 a.m. UTC
From: Magnus Damm <damm@opensource.se>

Break out the R-Car SYSC power management code from
the r8a7779 SoC code. With this new shared R-Car SYSC
code base it is possible to hook in Generation 2 SoCs
as well.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

Developed on top of renesas-devel-v3.13-rc8-20140115

 arch/arm/mach-shmobile/Makefile               |    2 
 arch/arm/mach-shmobile/include/mach/pm-rcar.h |   15 ++
 arch/arm/mach-shmobile/include/mach/r8a7779.h |   13 --
 arch/arm/mach-shmobile/pm-r8a7779.c           |  131 +----------------------
 arch/arm/mach-shmobile/pm-rcar.c              |  142 +++++++++++++++++++++++++
 arch/arm/mach-shmobile/smp-r8a7779.c          |   17 +-
 6 files changed, 177 insertions(+), 143 deletions(-)

Comments

Simon Horman Jan. 15, 2014, 8:30 a.m. UTC | #1
On Wed, Jan 15, 2014 at 04:43:08PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
> 
> Break out the R-Car SYSC power management code from
> the r8a7779 SoC code. With this new shared R-Car SYSC
> code base it is possible to hook in Generation 2 SoCs
> as well.

Is this also useful for the r8a7778 (the other Gen 1 SoC in mainline) ?
Magnus Damm Jan. 15, 2014, 11:16 p.m. UTC | #2
Hi Simon and Morimoto-san,

On Wed, Jan 15, 2014 at 5:30 PM, Simon Horman <horms@verge.net.au> wrote:
> On Wed, Jan 15, 2014 at 04:43:08PM +0900, Magnus Damm wrote:
>> From: Magnus Damm <damm@opensource.se>
>>
>> Break out the R-Car SYSC power management code from
>> the r8a7779 SoC code. With this new shared R-Car SYSC
>> code base it is possible to hook in Generation 2 SoCs
>> as well.
>
> Is this also useful for the r8a7778 (the other Gen 1 SoC in mainline) ?

I don't know actually. =) What does Morimoto-san say about this?

Cheers,

/ magnus
Kuninori Morimoto Jan. 16, 2014, 12:37 a.m. UTC | #3
Hi Magnus, Simon

> >> Break out the R-Car SYSC power management code from
> >> the r8a7779 SoC code. With this new shared R-Car SYSC
> >> code base it is possible to hook in Generation 2 SoCs
> >> as well.
> >
> > Is this also useful for the r8a7778 (the other Gen 1 SoC in mainline) ?
> 
> I don't know actually. =) What does Morimoto-san say about this?

Thank you for this patch.
it is useful, but, unfortunately r8a7778 (= M1) doesn't have SYSC


Best regards
---
Kuninori Morimoto
Simon Horman Jan. 16, 2014, 12:50 a.m. UTC | #4
On Wed, Jan 15, 2014 at 04:37:58PM -0800, Kuninori Morimoto wrote:
> 
> Hi Magnus, Simon
> 
> > >> Break out the R-Car SYSC power management code from
> > >> the r8a7779 SoC code. With this new shared R-Car SYSC
> > >> code base it is possible to hook in Generation 2 SoCs
> > >> as well.
> > >
> > > Is this also useful for the r8a7778 (the other Gen 1 SoC in mainline) ?
> > 
> > I don't know actually. =) What does Morimoto-san say about this?
> 
> Thank you for this patch.
> it is useful, but, unfortunately r8a7778 (= M1) doesn't have SYSC

Thanks, one less thing to worry about :)
Simon Horman Feb. 6, 2014, 7:05 a.m. UTC | #5
On Wed, Jan 15, 2014 at 04:43:08PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
> 
> Break out the R-Car SYSC power management code from
> the r8a7779 SoC code. With this new shared R-Car SYSC
> code base it is possible to hook in Generation 2 SoCs
> as well.
> 
> Signed-off-by: Magnus Damm <damm@opensource.se>

Thanks, I have queued this up.
Olof Johansson Feb. 20, 2014, 9:36 a.m. UTC | #6
Hi,

I spotted this patch since it adds new include/mach contents, comment below:

On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:

> --- /dev/null
> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
> @@ -0,0 +1,15 @@
> +#ifndef PM_RCAR_H
> +#define PM_RCAR_H
> +
> +struct rcar_sysc_ch {
> +       unsigned long chan_offs;
> +       unsigned int chan_bit;
> +       unsigned int isr_bit;
> +};
> +
> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
> +void __iomem *rcar_sysc_init(phys_addr_t base);
> +
> +#endif /* PM_RCAR_H */


These prototypes are only ever used by code in arch/arm/mach-shmobile,
right? There's no reason to expose it to the global include namespace,
and you'll just have to remove it when the platform is converted to
multiplatform.

So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).


-Olof
Magnus Damm Feb. 20, 2014, 9:45 a.m. UTC | #7
Hi Olof,

On Thu, Feb 20, 2014 at 6:36 PM, Olof Johansson <olof@lixom.net> wrote:
> Hi,
>
> I spotted this patch since it adds new include/mach contents, comment below:
>
> On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>
>> --- /dev/null
>> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
>> @@ -0,0 +1,15 @@
>> +#ifndef PM_RCAR_H
>> +#define PM_RCAR_H
>> +
>> +struct rcar_sysc_ch {
>> +       unsigned long chan_offs;
>> +       unsigned int chan_bit;
>> +       unsigned int isr_bit;
>> +};
>> +
>> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
>> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
>> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
>> +void __iomem *rcar_sysc_init(phys_addr_t base);
>> +
>> +#endif /* PM_RCAR_H */
>
>
> These prototypes are only ever used by code in arch/arm/mach-shmobile,
> right? There's no reason to expose it to the global include namespace,
> and you'll just have to remove it when the platform is converted to
> multiplatform.
>
> So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
> instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).

Thanks for your help with the patches! You are right that these are
never used outside mach-shmobile, and moving headers out of "mach"
certainly makes sense.

For multiplatform we do currently work around the issue by the
following line in the Makefile:

ccflags-$(CONFIG_ARCH_MULTIPLATFORM) :=
-I$(srctree)/arch/arm/mach-shmobile/include

Thanks,

/ magnus
Magnus Damm Feb. 25, 2014, 2:09 a.m. UTC | #8
Hi Olof,

On Thu, Feb 20, 2014 at 6:45 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> On Thu, Feb 20, 2014 at 6:36 PM, Olof Johansson <olof@lixom.net> wrote:
>> I spotted this patch since it adds new include/mach contents, comment below:
>>
>> On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>>
>>> --- /dev/null
>>> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
>>> @@ -0,0 +1,15 @@
>>> +#ifndef PM_RCAR_H
>>> +#define PM_RCAR_H
>>> +
>>> +struct rcar_sysc_ch {
>>> +       unsigned long chan_offs;
>>> +       unsigned int chan_bit;
>>> +       unsigned int isr_bit;
>>> +};
>>> +
>>> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
>>> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
>>> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
>>> +void __iomem *rcar_sysc_init(phys_addr_t base);
>>> +
>>> +#endif /* PM_RCAR_H */
>>
>>
>> These prototypes are only ever used by code in arch/arm/mach-shmobile,
>> right? There's no reason to expose it to the global include namespace,
>> and you'll just have to remove it when the platform is converted to
>> multiplatform.
>>
>> So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
>> instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).
>
> Thanks for your help with the patches! You are right that these are
> never used outside mach-shmobile, and moving headers out of "mach"
> certainly makes sense.

FYI, the following series includes my attempt to address this issue:

[PATCH 00/12] ARM: shmobile: Rework include path for SoC files
[PATCH 01/12] ARM: shmobile: Add temporary include workaround
[PATCH 02/12] ARM: shmobile: Rework include path for sh7372
[PATCH 03/12] ARM: shmobile: Rework include path for sh73a0
[PATCH 04/12] ARM: shmobile: Rework include path for EMEV2
[PATCH 05/12] ARM: shmobile: Rework include path for r8a7740
[PATCH 06/12] ARM: shmobile: Rework include path for r8a7778
[PATCH 07/12] ARM: shmobile: Rework include path for r8a7779
[PATCH 08/12] ARM: shmobile: Rework include path for r8a7790
[PATCH 09/12] ARM: shmobile: Rework include path for r8a7791
[PATCH 10/12] ARM: shmobile: Rework include path for r8a73a4
[PATCH 11/12] ARM: shmobile: Rework include path for r7s72100
[PATCH 12/12] ARM: shmobile: Rework include path for common bits

If you would like me to rework the code somehow then please let me
know. I also intend to ask a different developer to convert the actual
boards once these changes have been merged by Simon, hope this is a
good way forward for you.

Cheers,

/ magnus
Olof Johansson March 9, 2014, 5:22 a.m. UTC | #9
On Tue, Feb 25, 2014 at 11:09:52AM +0900, Magnus Damm wrote:
> Hi Olof,
> 
> On Thu, Feb 20, 2014 at 6:45 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> > On Thu, Feb 20, 2014 at 6:36 PM, Olof Johansson <olof@lixom.net> wrote:
> >> I spotted this patch since it adds new include/mach contents, comment below:
> >>
> >> On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> >>
> >>> --- /dev/null
> >>> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
> >>> @@ -0,0 +1,15 @@
> >>> +#ifndef PM_RCAR_H
> >>> +#define PM_RCAR_H
> >>> +
> >>> +struct rcar_sysc_ch {
> >>> +       unsigned long chan_offs;
> >>> +       unsigned int chan_bit;
> >>> +       unsigned int isr_bit;
> >>> +};
> >>> +
> >>> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
> >>> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
> >>> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
> >>> +void __iomem *rcar_sysc_init(phys_addr_t base);
> >>> +
> >>> +#endif /* PM_RCAR_H */
> >>
> >>
> >> These prototypes are only ever used by code in arch/arm/mach-shmobile,
> >> right? There's no reason to expose it to the global include namespace,
> >> and you'll just have to remove it when the platform is converted to
> >> multiplatform.
> >>
> >> So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
> >> instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).
> >
> > Thanks for your help with the patches! You are right that these are
> > never used outside mach-shmobile, and moving headers out of "mach"
> > certainly makes sense.
> 
> FYI, the following series includes my attempt to address this issue:
> 
> [PATCH 00/12] ARM: shmobile: Rework include path for SoC files
> [PATCH 01/12] ARM: shmobile: Add temporary include workaround
> [PATCH 02/12] ARM: shmobile: Rework include path for sh7372
> [PATCH 03/12] ARM: shmobile: Rework include path for sh73a0
> [PATCH 04/12] ARM: shmobile: Rework include path for EMEV2
> [PATCH 05/12] ARM: shmobile: Rework include path for r8a7740
> [PATCH 06/12] ARM: shmobile: Rework include path for r8a7778
> [PATCH 07/12] ARM: shmobile: Rework include path for r8a7779
> [PATCH 08/12] ARM: shmobile: Rework include path for r8a7790
> [PATCH 09/12] ARM: shmobile: Rework include path for r8a7791
> [PATCH 10/12] ARM: shmobile: Rework include path for r8a73a4
> [PATCH 11/12] ARM: shmobile: Rework include path for r7s72100
> [PATCH 12/12] ARM: shmobile: Rework include path for common bits
> 
> If you would like me to rework the code somehow then please let me
> know. I also intend to ask a different developer to convert the actual
> boards once these changes have been merged by Simon, hope this is a
> good way forward for you.

It certainly looks like a good way forward, thanks for doing this.

(Apologies for the delay in response, I've been ignoring my upstream email for
a while and I'm dealing with the backlog now)


-Olof
Magnus Damm March 12, 2014, 10:26 p.m. UTC | #10
On Sun, Mar 9, 2014 at 2:22 PM, Olof Johansson <olof@lixom.net> wrote:
> On Tue, Feb 25, 2014 at 11:09:52AM +0900, Magnus Damm wrote:
>> Hi Olof,
>>
>> On Thu, Feb 20, 2014 at 6:45 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>> > On Thu, Feb 20, 2014 at 6:36 PM, Olof Johansson <olof@lixom.net> wrote:
>> >> I spotted this patch since it adds new include/mach contents, comment below:
>> >>
>> >> On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>> >>
>> >>> --- /dev/null
>> >>> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
>> >>> @@ -0,0 +1,15 @@
>> >>> +#ifndef PM_RCAR_H
>> >>> +#define PM_RCAR_H
>> >>> +
>> >>> +struct rcar_sysc_ch {
>> >>> +       unsigned long chan_offs;
>> >>> +       unsigned int chan_bit;
>> >>> +       unsigned int isr_bit;
>> >>> +};
>> >>> +
>> >>> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
>> >>> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
>> >>> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
>> >>> +void __iomem *rcar_sysc_init(phys_addr_t base);
>> >>> +
>> >>> +#endif /* PM_RCAR_H */
>> >>
>> >>
>> >> These prototypes are only ever used by code in arch/arm/mach-shmobile,
>> >> right? There's no reason to expose it to the global include namespace,
>> >> and you'll just have to remove it when the platform is converted to
>> >> multiplatform.
>> >>
>> >> So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
>> >> instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).
>> >
>> > Thanks for your help with the patches! You are right that these are
>> > never used outside mach-shmobile, and moving headers out of "mach"
>> > certainly makes sense.
>>
>> FYI, the following series includes my attempt to address this issue:
>>
>> [PATCH 00/12] ARM: shmobile: Rework include path for SoC files
>> [PATCH 01/12] ARM: shmobile: Add temporary include workaround
>> [PATCH 02/12] ARM: shmobile: Rework include path for sh7372
>> [PATCH 03/12] ARM: shmobile: Rework include path for sh73a0
>> [PATCH 04/12] ARM: shmobile: Rework include path for EMEV2
>> [PATCH 05/12] ARM: shmobile: Rework include path for r8a7740
>> [PATCH 06/12] ARM: shmobile: Rework include path for r8a7778
>> [PATCH 07/12] ARM: shmobile: Rework include path for r8a7779
>> [PATCH 08/12] ARM: shmobile: Rework include path for r8a7790
>> [PATCH 09/12] ARM: shmobile: Rework include path for r8a7791
>> [PATCH 10/12] ARM: shmobile: Rework include path for r8a73a4
>> [PATCH 11/12] ARM: shmobile: Rework include path for r7s72100
>> [PATCH 12/12] ARM: shmobile: Rework include path for common bits
>>
>> If you would like me to rework the code somehow then please let me
>> know. I also intend to ask a different developer to convert the actual
>> boards once these changes have been merged by Simon, hope this is a
>> good way forward for you.
>
> It certainly looks like a good way forward, thanks for doing this.

Ok, thanks. The list of patches above is the first step forward from my side.

I'm afraid that I'm a bit confused by your comments in thread:
"Re: [PATCH v2] ARM: shmobile: Add temporary include workaround"

The single v2 patch on the line above is just a bug fixed version of [01/12].

Can you please clarify if you're ok with the series or if you want me
to rework it somehow?

> (Apologies for the delay in response, I've been ignoring my upstream email for
> a while and I'm dealing with the backlog now)

No problem!

Thanks,

/ magnus
Olof Johansson March 13, 2014, 12:04 a.m. UTC | #11
On Wed, Mar 12, 2014 at 3:26 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> On Sun, Mar 9, 2014 at 2:22 PM, Olof Johansson <olof@lixom.net> wrote:
>> On Tue, Feb 25, 2014 at 11:09:52AM +0900, Magnus Damm wrote:
>>> Hi Olof,
>>>
>>> On Thu, Feb 20, 2014 at 6:45 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>>> > On Thu, Feb 20, 2014 at 6:36 PM, Olof Johansson <olof@lixom.net> wrote:
>>> >> I spotted this patch since it adds new include/mach contents, comment below:
>>> >>
>>> >> On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>>> >>
>>> >>> --- /dev/null
>>> >>> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
>>> >>> @@ -0,0 +1,15 @@
>>> >>> +#ifndef PM_RCAR_H
>>> >>> +#define PM_RCAR_H
>>> >>> +
>>> >>> +struct rcar_sysc_ch {
>>> >>> +       unsigned long chan_offs;
>>> >>> +       unsigned int chan_bit;
>>> >>> +       unsigned int isr_bit;
>>> >>> +};
>>> >>> +
>>> >>> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
>>> >>> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
>>> >>> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
>>> >>> +void __iomem *rcar_sysc_init(phys_addr_t base);
>>> >>> +
>>> >>> +#endif /* PM_RCAR_H */
>>> >>
>>> >>
>>> >> These prototypes are only ever used by code in arch/arm/mach-shmobile,
>>> >> right? There's no reason to expose it to the global include namespace,
>>> >> and you'll just have to remove it when the platform is converted to
>>> >> multiplatform.
>>> >>
>>> >> So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
>>> >> instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).
>>> >
>>> > Thanks for your help with the patches! You are right that these are
>>> > never used outside mach-shmobile, and moving headers out of "mach"
>>> > certainly makes sense.
>>>
>>> FYI, the following series includes my attempt to address this issue:
>>>
>>> [PATCH 00/12] ARM: shmobile: Rework include path for SoC files
>>> [PATCH 01/12] ARM: shmobile: Add temporary include workaround
>>> [PATCH 02/12] ARM: shmobile: Rework include path for sh7372
>>> [PATCH 03/12] ARM: shmobile: Rework include path for sh73a0
>>> [PATCH 04/12] ARM: shmobile: Rework include path for EMEV2
>>> [PATCH 05/12] ARM: shmobile: Rework include path for r8a7740
>>> [PATCH 06/12] ARM: shmobile: Rework include path for r8a7778
>>> [PATCH 07/12] ARM: shmobile: Rework include path for r8a7779
>>> [PATCH 08/12] ARM: shmobile: Rework include path for r8a7790
>>> [PATCH 09/12] ARM: shmobile: Rework include path for r8a7791
>>> [PATCH 10/12] ARM: shmobile: Rework include path for r8a73a4
>>> [PATCH 11/12] ARM: shmobile: Rework include path for r7s72100
>>> [PATCH 12/12] ARM: shmobile: Rework include path for common bits
>>>
>>> If you would like me to rework the code somehow then please let me
>>> know. I also intend to ask a different developer to convert the actual
>>> boards once these changes have been merged by Simon, hope this is a
>>> good way forward for you.
>>
>> It certainly looks like a good way forward, thanks for doing this.
>
> Ok, thanks. The list of patches above is the first step forward from my side.
>
> I'm afraid that I'm a bit confused by your comments in thread:
> "Re: [PATCH v2] ARM: shmobile: Add temporary include workaround"
>
> The single v2 patch on the line above is just a bug fixed version of [01/12].
>
> Can you please clarify if you're ok with the series or if you want me
> to rework it somehow?

Oh, yeah, that's confusing -- my "looks good, please go ahead" was for
patch 2-12, I don't think you actually need 1/12 at this time since
you move the include file over and change the include statements in
the same time in the other 11 patches?


-Olof
Magnus Damm March 13, 2014, 1:02 a.m. UTC | #12
On Thu, Mar 13, 2014 at 9:04 AM, Olof Johansson <olof@lixom.net> wrote:
> On Wed, Mar 12, 2014 at 3:26 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>> On Sun, Mar 9, 2014 at 2:22 PM, Olof Johansson <olof@lixom.net> wrote:
>>> On Tue, Feb 25, 2014 at 11:09:52AM +0900, Magnus Damm wrote:
>>>> Hi Olof,
>>>>
>>>> On Thu, Feb 20, 2014 at 6:45 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>>>> > On Thu, Feb 20, 2014 at 6:36 PM, Olof Johansson <olof@lixom.net> wrote:
>>>> >> I spotted this patch since it adds new include/mach contents, comment below:
>>>> >>
>>>> >> On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
>>>> >>
>>>> >>> --- /dev/null
>>>> >>> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
>>>> >>> @@ -0,0 +1,15 @@
>>>> >>> +#ifndef PM_RCAR_H
>>>> >>> +#define PM_RCAR_H
>>>> >>> +
>>>> >>> +struct rcar_sysc_ch {
>>>> >>> +       unsigned long chan_offs;
>>>> >>> +       unsigned int chan_bit;
>>>> >>> +       unsigned int isr_bit;
>>>> >>> +};
>>>> >>> +
>>>> >>> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
>>>> >>> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
>>>> >>> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
>>>> >>> +void __iomem *rcar_sysc_init(phys_addr_t base);
>>>> >>> +
>>>> >>> +#endif /* PM_RCAR_H */
>>>> >>
>>>> >>
>>>> >> These prototypes are only ever used by code in arch/arm/mach-shmobile,
>>>> >> right? There's no reason to expose it to the global include namespace,
>>>> >> and you'll just have to remove it when the platform is converted to
>>>> >> multiplatform.
>>>> >>
>>>> >> So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
>>>> >> instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).
>>>> >
>>>> > Thanks for your help with the patches! You are right that these are
>>>> > never used outside mach-shmobile, and moving headers out of "mach"
>>>> > certainly makes sense.
>>>>
>>>> FYI, the following series includes my attempt to address this issue:
>>>>
>>>> [PATCH 00/12] ARM: shmobile: Rework include path for SoC files
>>>> [PATCH 01/12] ARM: shmobile: Add temporary include workaround
>>>> [PATCH 02/12] ARM: shmobile: Rework include path for sh7372
>>>> [PATCH 03/12] ARM: shmobile: Rework include path for sh73a0
>>>> [PATCH 04/12] ARM: shmobile: Rework include path for EMEV2
>>>> [PATCH 05/12] ARM: shmobile: Rework include path for r8a7740
>>>> [PATCH 06/12] ARM: shmobile: Rework include path for r8a7778
>>>> [PATCH 07/12] ARM: shmobile: Rework include path for r8a7779
>>>> [PATCH 08/12] ARM: shmobile: Rework include path for r8a7790
>>>> [PATCH 09/12] ARM: shmobile: Rework include path for r8a7791
>>>> [PATCH 10/12] ARM: shmobile: Rework include path for r8a73a4
>>>> [PATCH 11/12] ARM: shmobile: Rework include path for r7s72100
>>>> [PATCH 12/12] ARM: shmobile: Rework include path for common bits
>>>>
>>>> If you would like me to rework the code somehow then please let me
>>>> know. I also intend to ask a different developer to convert the actual
>>>> boards once these changes have been merged by Simon, hope this is a
>>>> good way forward for you.
>>>
>>> It certainly looks like a good way forward, thanks for doing this.
>>
>> Ok, thanks. The list of patches above is the first step forward from my side.
>>
>> I'm afraid that I'm a bit confused by your comments in thread:
>> "Re: [PATCH v2] ARM: shmobile: Add temporary include workaround"
>>
>> The single v2 patch on the line above is just a bug fixed version of [01/12].
>>
>> Can you please clarify if you're ok with the series or if you want me
>> to rework it somehow?
>
> Oh, yeah, that's confusing -- my "looks good, please go ahead" was for
> patch 2-12, I don't think you actually need 1/12 at this time since
> you move the include file over and change the include statements in
> the same time in the other 11 patches?

My current set of patches do not move the location of the include file
just yet. The reason for this is that this series targets SoC code
only, but both board files and SoC files use the same header files. So
until all files are converted the workaround is needed.

I'd be happy to adjust the patches to fit your recommendation and move
the header file in the same patch. But then I need to touch both SoC
code and board code in the same patch - which is fine - but I would
like to know what branch to target if so.

So how would you like to consume this cleanup? And when? =)

Thanks,

/ magnus
Olof Johansson March 14, 2014, 5:39 a.m. UTC | #13
On Thu, Mar 13, 2014 at 10:02:03AM +0900, Magnus Damm wrote:
> On Thu, Mar 13, 2014 at 9:04 AM, Olof Johansson <olof@lixom.net> wrote:
> > On Wed, Mar 12, 2014 at 3:26 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> >> On Sun, Mar 9, 2014 at 2:22 PM, Olof Johansson <olof@lixom.net> wrote:
> >>> On Tue, Feb 25, 2014 at 11:09:52AM +0900, Magnus Damm wrote:
> >>>> Hi Olof,
> >>>>
> >>>> On Thu, Feb 20, 2014 at 6:45 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> >>>> > On Thu, Feb 20, 2014 at 6:36 PM, Olof Johansson <olof@lixom.net> wrote:
> >>>> >> I spotted this patch since it adds new include/mach contents, comment below:
> >>>> >>
> >>>> >> On Tue, Jan 14, 2014 at 11:43 PM, Magnus Damm <magnus.damm@gmail.com> wrote:
> >>>> >>
> >>>> >>> --- /dev/null
> >>>> >>> +++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h  2014-01-15 13:30:38.000000000 +0900
> >>>> >>> @@ -0,0 +1,15 @@
> >>>> >>> +#ifndef PM_RCAR_H
> >>>> >>> +#define PM_RCAR_H
> >>>> >>> +
> >>>> >>> +struct rcar_sysc_ch {
> >>>> >>> +       unsigned long chan_offs;
> >>>> >>> +       unsigned int chan_bit;
> >>>> >>> +       unsigned int isr_bit;
> >>>> >>> +};
> >>>> >>> +
> >>>> >>> +int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
> >>>> >>> +int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
> >>>> >>> +bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
> >>>> >>> +void __iomem *rcar_sysc_init(phys_addr_t base);
> >>>> >>> +
> >>>> >>> +#endif /* PM_RCAR_H */
> >>>> >>
> >>>> >>
> >>>> >> These prototypes are only ever used by code in arch/arm/mach-shmobile,
> >>>> >> right? There's no reason to expose it to the global include namespace,
> >>>> >> and you'll just have to remove it when the platform is converted to
> >>>> >> multiplatform.
> >>>> >>
> >>>> >> So, I suggest moving this to be at arch/arm/mach-shmobile/pm-rcar.h
> >>>> >> instead (and included as "pm-rcar.h" instead of <mach/pm-rcar.h>).
> >>>> >
> >>>> > Thanks for your help with the patches! You are right that these are
> >>>> > never used outside mach-shmobile, and moving headers out of "mach"
> >>>> > certainly makes sense.
> >>>>
> >>>> FYI, the following series includes my attempt to address this issue:
> >>>>
> >>>> [PATCH 00/12] ARM: shmobile: Rework include path for SoC files
> >>>> [PATCH 01/12] ARM: shmobile: Add temporary include workaround
> >>>> [PATCH 02/12] ARM: shmobile: Rework include path for sh7372
> >>>> [PATCH 03/12] ARM: shmobile: Rework include path for sh73a0
> >>>> [PATCH 04/12] ARM: shmobile: Rework include path for EMEV2
> >>>> [PATCH 05/12] ARM: shmobile: Rework include path for r8a7740
> >>>> [PATCH 06/12] ARM: shmobile: Rework include path for r8a7778
> >>>> [PATCH 07/12] ARM: shmobile: Rework include path for r8a7779
> >>>> [PATCH 08/12] ARM: shmobile: Rework include path for r8a7790
> >>>> [PATCH 09/12] ARM: shmobile: Rework include path for r8a7791
> >>>> [PATCH 10/12] ARM: shmobile: Rework include path for r8a73a4
> >>>> [PATCH 11/12] ARM: shmobile: Rework include path for r7s72100
> >>>> [PATCH 12/12] ARM: shmobile: Rework include path for common bits
> >>>>
> >>>> If you would like me to rework the code somehow then please let me
> >>>> know. I also intend to ask a different developer to convert the actual
> >>>> boards once these changes have been merged by Simon, hope this is a
> >>>> good way forward for you.
> >>>
> >>> It certainly looks like a good way forward, thanks for doing this.
> >>
> >> Ok, thanks. The list of patches above is the first step forward from my side.
> >>
> >> I'm afraid that I'm a bit confused by your comments in thread:
> >> "Re: [PATCH v2] ARM: shmobile: Add temporary include workaround"
> >>
> >> The single v2 patch on the line above is just a bug fixed version of [01/12].
> >>
> >> Can you please clarify if you're ok with the series or if you want me
> >> to rework it somehow?
> >
> > Oh, yeah, that's confusing -- my "looks good, please go ahead" was for
> > patch 2-12, I don't think you actually need 1/12 at this time since
> > you move the include file over and change the include statements in
> > the same time in the other 11 patches?
> 
> My current set of patches do not move the location of the include file
> just yet. The reason for this is that this series targets SoC code
> only, but both board files and SoC files use the same header files. So
> until all files are converted the workaround is needed.

Oh, my bad. When I saw the change from <mach/file.h> to "file.h", I missed that
there was no diff move that accompanied it.

> I'd be happy to adjust the patches to fit your recommendation and move
> the header file in the same patch. But then I need to touch both SoC
> code and board code in the same patch - which is fine - but I would
> like to know what branch to target if so.

We're still talking mostly about code under mach-shmobile though, right?
I think most of these header files are only actually used underneath of there.

If so, then it's fine to just do it in one branch. The rules for how we sort
our branches are guidelines, and where it doesn't make sense to follow them, we
don't. :)

> So how would you like to consume this cleanup? And when? =)

For something like this, that has a build-time possibility to check for
introduced breakage (i.e. no likelihood for some strange random regression at
runtime), I'm OK with the patches coming in late. I.e. there's time for 3.15 if
you want to try getting it in. If not, we can queue it up as a base branch for
any other changes for 3.16.

As far as how to consume it: send a branch with these patches on there, we'll
merge it in. If it's relatively conflict-free we'll do it under next/clenaup
for early merge, otherwise we'll save it for the end of our branches, etc. It'd
be a great cleanup to get merged so we'll make it work somehow!


-Olof
diff mbox

Patch

--- 0001/arch/arm/mach-shmobile/Makefile
+++ work/arch/arm/mach-shmobile/Makefile	2014-01-15 13:30:37.000000000 +0900
@@ -52,7 +52,7 @@  obj-$(CONFIG_CPU_IDLE)		+= cpuidle.o
 obj-$(CONFIG_ARCH_SH7372)	+= pm-sh7372.o sleep-sh7372.o pm-rmobile.o
 obj-$(CONFIG_ARCH_SH73A0)	+= pm-sh73a0.o
 obj-$(CONFIG_ARCH_R8A7740)	+= pm-r8a7740.o pm-rmobile.o
-obj-$(CONFIG_ARCH_R8A7779)	+= pm-r8a7779.o
+obj-$(CONFIG_ARCH_R8A7779)	+= pm-r8a7779.o pm-rcar.o
 
 # Board objects
 ifdef CONFIG_ARCH_SHMOBILE_MULTI
--- /dev/null
+++ work/arch/arm/mach-shmobile/include/mach/pm-rcar.h	2014-01-15 13:30:38.000000000 +0900
@@ -0,0 +1,15 @@ 
+#ifndef PM_RCAR_H
+#define PM_RCAR_H
+
+struct rcar_sysc_ch {
+	unsigned long chan_offs;
+	unsigned int chan_bit;
+	unsigned int isr_bit;
+};
+
+int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
+int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
+bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
+void __iomem *rcar_sysc_init(phys_addr_t base);
+
+#endif /* PM_RCAR_H */
--- 0001/arch/arm/mach-shmobile/include/mach/r8a7779.h
+++ work/arch/arm/mach-shmobile/include/mach/r8a7779.h	2014-01-15 13:30:37.000000000 +0900
@@ -3,6 +3,7 @@ 
 
 #include <linux/sh_clk.h>
 #include <linux/pm_domain.h>
+#include <mach/pm-rcar.h>
 
 /* HPB-DMA slave IDs */
 enum {
@@ -11,18 +12,12 @@  enum {
 	HPBDMA_SLAVE_SDHI0_RX,
 };
 
-struct r8a7779_pm_ch {
-	unsigned long chan_offs;
-	unsigned int chan_bit;
-	unsigned int isr_bit;
-};
-
 struct r8a7779_pm_domain {
 	struct generic_pm_domain genpd;
-	struct r8a7779_pm_ch ch;
+	struct rcar_sysc_ch ch;
 };
 
-static inline struct r8a7779_pm_ch *to_r8a7779_ch(struct generic_pm_domain *d)
+static inline struct rcar_sysc_ch *to_r8a7779_ch(struct generic_pm_domain *d)
 {
 	return &container_of(d, struct r8a7779_pm_domain, genpd)->ch;
 }
@@ -41,8 +36,6 @@  extern void r8a7779_clock_init(void);
 extern void r8a7779_pinmux_init(void);
 extern void r8a7779_pm_init(void);
 extern void r8a7779_register_twd(void);
-extern int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch);
-extern int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch);
 
 #ifdef CONFIG_PM
 extern void __init r8a7779_init_pm_domains(void);
--- 0001/arch/arm/mach-shmobile/pm-r8a7779.c
+++ work/arch/arm/mach-shmobile/pm-r8a7779.c	2014-01-15 13:30:37.000000000 +0900
@@ -20,132 +20,22 @@ 
 #include <linux/console.h>
 #include <asm/io.h>
 #include <mach/common.h>
+#include <mach/pm-rcar.h>
 #include <mach/r8a7779.h>
 
-static void __iomem *r8a7779_sysc_base;
-
 /* SYSC */
-#define SYSCSR 0x00
-#define SYSCISR 0x04
-#define SYSCISCR 0x08
 #define SYSCIER 0x0c
 #define SYSCIMR 0x10
-#define PWRSR0 0x40
-#define PWRSR1 0x80
-#define PWRSR2 0xc0
-#define PWRSR3 0x100
-#define PWRSR4 0x140
-
-#define PWRSR_OFFS 0x00
-#define PWROFFCR_OFFS 0x04
-#define PWRONCR_OFFS 0x0c
-#define PWRER_OFFS 0x14
-
-#define SYSCSR_RETRIES 100
-#define SYSCSR_DELAY_US 1
-
-#define SYSCISR_RETRIES 1000
-#define SYSCISR_DELAY_US 1
 
 #if defined(CONFIG_PM) || defined(CONFIG_SMP)
 
-static DEFINE_SPINLOCK(r8a7779_sysc_lock); /* SMP CPUs + I/O devices */
-
-static int r8a7779_sysc_pwr_on_off(struct r8a7779_pm_ch *r8a7779_ch,
-				   int sr_bit, int reg_offs)
-{
-	int k;
-
-	for (k = 0; k < SYSCSR_RETRIES; k++) {
-		if (ioread32(r8a7779_sysc_base + SYSCSR) & (1 << sr_bit))
-			break;
-		udelay(SYSCSR_DELAY_US);
-	}
-
-	if (k == SYSCSR_RETRIES)
-		return -EAGAIN;
-
-	iowrite32(1 << r8a7779_ch->chan_bit,
-		  r8a7779_sysc_base + r8a7779_ch->chan_offs + reg_offs);
-
-	return 0;
-}
-
-static int r8a7779_sysc_pwr_off(struct r8a7779_pm_ch *r8a7779_ch)
-{
-	return r8a7779_sysc_pwr_on_off(r8a7779_ch, 0, PWROFFCR_OFFS);
-}
-
-static int r8a7779_sysc_pwr_on(struct r8a7779_pm_ch *r8a7779_ch)
-{
-	return r8a7779_sysc_pwr_on_off(r8a7779_ch, 1, PWRONCR_OFFS);
-}
-
-static int r8a7779_sysc_update(struct r8a7779_pm_ch *r8a7779_ch,
-			       int (*on_off_fn)(struct r8a7779_pm_ch *))
-{
-	unsigned int isr_mask = 1 << r8a7779_ch->isr_bit;
-	unsigned int chan_mask = 1 << r8a7779_ch->chan_bit;
-	unsigned int status;
-	unsigned long flags;
-	int ret = 0;
-	int k;
-
-	spin_lock_irqsave(&r8a7779_sysc_lock, flags);
-
-	iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR);
-
-	do {
-		ret = on_off_fn(r8a7779_ch);
-		if (ret)
-			goto out;
-
-		status = ioread32(r8a7779_sysc_base +
-				  r8a7779_ch->chan_offs + PWRER_OFFS);
-	} while (status & chan_mask);
-
-	for (k = 0; k < SYSCISR_RETRIES; k++) {
-		if (ioread32(r8a7779_sysc_base + SYSCISR) & isr_mask)
-			break;
-		udelay(SYSCISR_DELAY_US);
-	}
-
-	if (k == SYSCISR_RETRIES)
-		ret = -EIO;
-
-	iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR);
-
- out:
-	spin_unlock_irqrestore(&r8a7779_sysc_lock, flags);
-
-	pr_debug("r8a7779 power domain %d: %02x %02x %02x %02x %02x -> %d\n",
-		 r8a7779_ch->isr_bit, ioread32(r8a7779_sysc_base + PWRSR0),
-		 ioread32(r8a7779_sysc_base + PWRSR1),
-		 ioread32(r8a7779_sysc_base + PWRSR2),
-		 ioread32(r8a7779_sysc_base + PWRSR3),
-		 ioread32(r8a7779_sysc_base + PWRSR4), ret);
-	return ret;
-}
-
-int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch)
-{
-	return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_off);
-}
-
-int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch)
-{
-	return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_on);
-}
-
 static void __init r8a7779_sysc_init(void)
 {
-	r8a7779_sysc_base = ioremap_nocache(0xffd85000, PAGE_SIZE);
-	if (!r8a7779_sysc_base)
-		panic("unable to ioremap r8a7779 SYSC hardware block\n");
+	void __iomem *base = rcar_sysc_init(0xffd85000);
 
 	/* enable all interrupt sources, but do not use interrupt handler */
-	iowrite32(0x0131000e, r8a7779_sysc_base + SYSCIER);
-	iowrite32(0, r8a7779_sysc_base + SYSCIMR);
+	iowrite32(0x0131000e, base + SYSCIER);
+	iowrite32(0, base + SYSCIMR);
 }
 
 #else /* CONFIG_PM || CONFIG_SMP */
@@ -158,24 +48,17 @@  static inline void r8a7779_sysc_init(voi
 
 static int pd_power_down(struct generic_pm_domain *genpd)
 {
-	return r8a7779_sysc_power_down(to_r8a7779_ch(genpd));
+	return rcar_sysc_power_down(to_r8a7779_ch(genpd));
 }
 
 static int pd_power_up(struct generic_pm_domain *genpd)
 {
-	return r8a7779_sysc_power_up(to_r8a7779_ch(genpd));
+	return rcar_sysc_power_up(to_r8a7779_ch(genpd));
 }
 
 static bool pd_is_off(struct generic_pm_domain *genpd)
 {
-	struct r8a7779_pm_ch *r8a7779_ch = to_r8a7779_ch(genpd);
-	unsigned int st;
-
-	st = ioread32(r8a7779_sysc_base + r8a7779_ch->chan_offs + PWRSR_OFFS);
-	if (st & (1 << r8a7779_ch->chan_bit))
-		return true;
-
-	return false;
+	return rcar_sysc_power_is_off(to_r8a7779_ch(genpd));
 }
 
 static bool pd_active_wakeup(struct device *dev)
--- /dev/null
+++ work/arch/arm/mach-shmobile/pm-rcar.c	2014-01-15 13:30:38.000000000 +0900
@@ -0,0 +1,142 @@ 
+/*
+ * R-Car SYSC Power management support
+ *
+ * Copyright (C) 2014  Magnus Damm
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/mm.h>
+#include <linux/spinlock.h>
+#include <asm/io.h>
+#include <mach/pm-rcar.h>
+
+static void __iomem *rcar_sysc_base;
+
+/* SYSC */
+#define SYSCSR 0x00
+#define SYSCISR 0x04
+#define SYSCISCR 0x08
+
+#define PWRSR_OFFS 0x00
+#define PWROFFCR_OFFS 0x04
+#define PWRONCR_OFFS 0x0c
+#define PWRER_OFFS 0x14
+
+#define SYSCSR_RETRIES 100
+#define SYSCSR_DELAY_US 1
+
+#define SYSCISR_RETRIES 1000
+#define SYSCISR_DELAY_US 1
+
+#if defined(CONFIG_PM) || defined(CONFIG_SMP)
+
+static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */
+
+static int rcar_sysc_pwr_on_off(struct rcar_sysc_ch *sysc_ch,
+				int sr_bit, int reg_offs)
+{
+	int k;
+
+	for (k = 0; k < SYSCSR_RETRIES; k++) {
+		if (ioread32(rcar_sysc_base + SYSCSR) & (1 << sr_bit))
+			break;
+		udelay(SYSCSR_DELAY_US);
+	}
+
+	if (k == SYSCSR_RETRIES)
+		return -EAGAIN;
+
+	iowrite32(1 << sysc_ch->chan_bit,
+		  rcar_sysc_base + sysc_ch->chan_offs + reg_offs);
+
+	return 0;
+}
+
+static int rcar_sysc_pwr_off(struct rcar_sysc_ch *sysc_ch)
+{
+	return rcar_sysc_pwr_on_off(sysc_ch, 0, PWROFFCR_OFFS);
+}
+
+static int rcar_sysc_pwr_on(struct rcar_sysc_ch *sysc_ch)
+{
+	return rcar_sysc_pwr_on_off(sysc_ch, 1, PWRONCR_OFFS);
+}
+
+static int rcar_sysc_update(struct rcar_sysc_ch *sysc_ch,
+			    int (*on_off_fn)(struct rcar_sysc_ch *))
+{
+	unsigned int isr_mask = 1 << sysc_ch->isr_bit;
+	unsigned int chan_mask = 1 << sysc_ch->chan_bit;
+	unsigned int status;
+	unsigned long flags;
+	int ret = 0;
+	int k;
+
+	spin_lock_irqsave(&rcar_sysc_lock, flags);
+
+	iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
+
+	do {
+		ret = on_off_fn(sysc_ch);
+		if (ret)
+			goto out;
+
+		status = ioread32(rcar_sysc_base +
+				  sysc_ch->chan_offs + PWRER_OFFS);
+	} while (status & chan_mask);
+
+	for (k = 0; k < SYSCISR_RETRIES; k++) {
+		if (ioread32(rcar_sysc_base + SYSCISR) & isr_mask)
+			break;
+		udelay(SYSCISR_DELAY_US);
+	}
+
+	if (k == SYSCISR_RETRIES)
+		ret = -EIO;
+
+	iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
+
+ out:
+	spin_unlock_irqrestore(&rcar_sysc_lock, flags);
+
+	pr_debug("sysc power domain %d: %08x -> %d\n",
+		 sysc_ch->isr_bit, ioread32(rcar_sysc_base + SYSCISR), ret);
+	return ret;
+}
+
+int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch)
+{
+	return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_off);
+}
+
+int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch)
+{
+	return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_on);
+}
+
+bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch)
+{
+	unsigned int st;
+
+	st = ioread32(rcar_sysc_base + sysc_ch->chan_offs + PWRSR_OFFS);
+	if (st & (1 << sysc_ch->chan_bit))
+		return true;
+
+	return false;
+}
+
+void __iomem *rcar_sysc_init(phys_addr_t base)
+{
+	rcar_sysc_base = ioremap_nocache(base, PAGE_SIZE);
+	if (!rcar_sysc_base)
+		panic("unable to ioremap R-Car SYSC hardware block\n");
+
+	return rcar_sysc_base;
+}
+
+#endif /* CONFIG_PM || CONFIG_SMP */
--- 0001/arch/arm/mach-shmobile/smp-r8a7779.c
+++ work/arch/arm/mach-shmobile/smp-r8a7779.c	2014-01-15 15:10:30.000000000 +0900
@@ -24,6 +24,7 @@ 
 #include <linux/io.h>
 #include <linux/delay.h>
 #include <mach/common.h>
+#include <mach/pm-rcar.h>
 #include <mach/r8a7779.h>
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
@@ -33,25 +34,25 @@ 
 #define AVECR IOMEM(0xfe700040)
 #define R8A7779_SCU_BASE 0xf0000000
 
-static struct r8a7779_pm_ch r8a7779_ch_cpu1 = {
+static struct rcar_sysc_ch r8a7779_ch_cpu1 = {
 	.chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
 	.chan_bit = 1, /* ARM1 */
 	.isr_bit = 1, /* ARM1 */
 };
 
-static struct r8a7779_pm_ch r8a7779_ch_cpu2 = {
+static struct rcar_sysc_ch r8a7779_ch_cpu2 = {
 	.chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
 	.chan_bit = 2, /* ARM2 */
 	.isr_bit = 2, /* ARM2 */
 };
 
-static struct r8a7779_pm_ch r8a7779_ch_cpu3 = {
+static struct rcar_sysc_ch r8a7779_ch_cpu3 = {
 	.chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
 	.chan_bit = 3, /* ARM3 */
 	.isr_bit = 3, /* ARM3 */
 };
 
-static struct r8a7779_pm_ch *r8a7779_ch_cpu[4] = {
+static struct rcar_sysc_ch *r8a7779_ch_cpu[4] = {
 	[1] = &r8a7779_ch_cpu1,
 	[2] = &r8a7779_ch_cpu2,
 	[3] = &r8a7779_ch_cpu3,
@@ -67,7 +68,7 @@  void __init r8a7779_register_twd(void)
 
 static int r8a7779_platform_cpu_kill(unsigned int cpu)
 {
-	struct r8a7779_pm_ch *ch = NULL;
+	struct rcar_sysc_ch *ch = NULL;
 	int ret = -EIO;
 
 	cpu = cpu_logical_map(cpu);
@@ -76,14 +77,14 @@  static int r8a7779_platform_cpu_kill(uns
 		ch = r8a7779_ch_cpu[cpu];
 
 	if (ch)
-		ret = r8a7779_sysc_power_down(ch);
+		ret = rcar_sysc_power_down(ch);
 
 	return ret ? ret : 1;
 }
 
 static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
-	struct r8a7779_pm_ch *ch = NULL;
+	struct rcar_sysc_ch *ch = NULL;
 	unsigned int lcpu = cpu_logical_map(cpu);
 	int ret;
 
@@ -91,7 +92,7 @@  static int r8a7779_boot_secondary(unsign
 		ch = r8a7779_ch_cpu[lcpu];
 
 	if (ch)
-		ret = r8a7779_sysc_power_up(ch);
+		ret = rcar_sysc_power_up(ch);
 	else
 		ret = -EIO;