From: Simon Horman <hidden> Date: 2015-07-10 06:37:12
Hi Olof, Hi Kevin, Hi Arnd,
Please consider these Renesas ARM based SoC PM domain updates for v4.3.
The following changes since commit d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754:
Linux 4.2-rc1 (2015-07-05 11:01:52 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git tags/renesas-pm-domain-for-v4.3
for you to fetch changes up to bd82aff9192dad2bfd3cb3fc19fdf741c2f6028e:
ARM: shmobile: r8a7790: Make struct rcar_sysc_ch const (2015-07-06 09:35:24 +0900)
----------------------------------------------------------------
Renesas ARM Based SoC PM Domain Updates for v4.3
* Make rcar_sysc_ch const for r8a779[09] SoCs
* Get rid of on_off_fn() function pointer
* Use BIT() macro instead of open coding
* Make struct rcar_sysc_ch * parameters const
* Break infinite loop
* Shrink rcar_sysc_ch size
* Improve documentation
----------------------------------------------------------------
Geert Uytterhoeven (8):
ARM: shmobile: R-Car: Improve documentation
ARM: shmobile: R-Car: Shrink rcar_sysc_ch size
ARM: shmobile: R-Car: Break infinite loop
ARM: shmobile: R-Car: Make struct rcar_sysc_ch * parameters const
ARM: shmobile: R-Car: Use BIT() macro instead of open coding
ARM: shmobile: R-Car: Get rid of on_off_fn() function pointer
ARM: shmobile: r8a7779: Make struct rcar_sysc_ch const
ARM: shmobile: r8a7790: Make struct rcar_sysc_ch const
arch/arm/mach-shmobile/pm-r8a7779.c | 3 +-
arch/arm/mach-shmobile/pm-rcar.c | 105 ++++++++++++++++++++++-------------
arch/arm/mach-shmobile/pm-rcar.h | 12 ++--
arch/arm/mach-shmobile/smp-r8a7779.c | 12 ++--
arch/arm/mach-shmobile/smp-r8a7790.c | 4 +-
5 files changed, 82 insertions(+), 54 deletions(-)
@@ -15,21 +15,35 @@#include<asm/io.h>#include"pm-rcar.h"-/* SYSC */-#define SYSCSR 0x00-#define SYSCISR 0x04-#define SYSCISCR 0x08+/* SYSC Common */+#define SYSCSR 0x00 /* SYSC Status Register */+#define SYSCISR 0x04 /* Interrupt Status Register */+#define SYSCISCR 0x08 /* Interrupt Status Clear Register */+#define SYSCIER 0x0c /* Interrupt Enable Register */+#define SYSCIMR 0x10 /* Interrupt Mask Register */-#define PWRSR_OFFS 0x00-#define PWROFFCR_OFFS 0x04-#define PWRONCR_OFFS 0x0c-#define PWRER_OFFS 0x14+/* SYSC Status Register */+#define SYSCSR_PONENB 1 /* Ready for power resume requests */+#define SYSCSR_POFFENB 0 /* Ready for power shutoff requests */-#define SYSCSR_RETRIES 100-#define SYSCSR_DELAY_US 1+/*+*PowerControlRegisterOffsetsinsidetheregisterblockforeachdomain+*Note:The"CR"registersforARMcoresexistonH1only+*UseWFItopoweroff,CPG/APMUtoresumeARMcoresonR-CarGen2+*/+#define PWRSR_OFFS 0x00 /* Power Status Register */+#define PWROFFCR_OFFS 0x04 /* Power Shutoff Control Register */+#define PWROFFSR_OFFS 0x08 /* Power Shutoff Status Register */+#define PWRONCR_OFFS 0x0c /* Power Resume Control Register */+#define PWRONSR_OFFS 0x10 /* Power Resume Status Register */+#define PWRER_OFFS 0x14 /* Power Shutoff/Resume Error */+++#define SYSCSR_RETRIES 100+#define SYSCSR_DELAY_US 1-#define SYSCISR_RETRIES 1000-#define SYSCISR_DELAY_US 1+#define SYSCISR_RETRIES 1000+#define SYSCISR_DELAY_US 1staticvoid__iomem*rcar_sysc_base;staticDEFINE_SPINLOCK(rcar_sysc_lock);/* SMP CPUs + I/O devices */
@@ -39,6 +53,7 @@ static int rcar_sysc_pwr_on_off(struct rcar_sysc_ch *sysc_ch,{intk;+/* Wait until SYSC is ready to accept a power request */for(k=0;k<SYSCSR_RETRIES;k++){if(ioread32(rcar_sysc_base+SYSCSR)&(1<<sr_bit))break;
@@ -48,6 +63,7 @@ static int rcar_sysc_pwr_on_off(struct rcar_sysc_ch *sysc_ch,if(k==SYSCSR_RETRIES)return-EAGAIN;+/* Submit power shutoff or power resume request */iowrite32(1<<sysc_ch->chan_bit,rcar_sysc_base+sysc_ch->chan_offs+reg_offs);
@@ -56,12 +72,12 @@ static int rcar_sysc_pwr_on_off(struct rcar_sysc_ch *sysc_ch,staticintrcar_sysc_pwr_off(structrcar_sysc_ch*sysc_ch){-returnrcar_sysc_pwr_on_off(sysc_ch,0,PWROFFCR_OFFS);+returnrcar_sysc_pwr_on_off(sysc_ch,SYSCSR_POFFENB,PWROFFCR_OFFS);}staticintrcar_sysc_pwr_on(structrcar_sysc_ch*sysc_ch){-returnrcar_sysc_pwr_on_off(sysc_ch,1,PWRONCR_OFFS);+returnrcar_sysc_pwr_on_off(sysc_ch,SYSCSR_PONENB,PWRONCR_OFFS);}staticintrcar_sysc_update(structrcar_sysc_ch*sysc_ch,
@@ -78,6 +94,7 @@ static int rcar_sysc_update(struct rcar_sysc_ch *sysc_ch,iowrite32(isr_mask,rcar_sysc_base+SYSCISCR);+/* Submit power shutoff or resume request until it was accepted */do{ret=on_off_fn(sysc_ch);if(ret)
@@ -87,6 +104,7 @@ static int rcar_sysc_update(struct rcar_sysc_ch *sysc_ch,sysc_ch->chan_offs+PWRER_OFFS);}while(status&chan_mask);+/* Wait until the power shutoff or resume request has completed * */for(k=0;k<SYSCISR_RETRIES;k++){if(ioread32(rcar_sysc_base+SYSCISR)&isr_mask)break;
From: Simon Horman <hidden> Date: 2015-07-10 06:37:07
From: Geert Uytterhoeven <geert+renesas@glider.be>
Shrink the individual fields in struct rcar_sysc_ch, as unsigned long or
int is overkill:
- chan_offs contains a register offset relative to a base value
(< 512),
- chan_bit and isr_bit contain bit indices (0-31).
This reduces the size of each instance from 3 (4 on 64-bit) 32-bit words
to 1 32-bit word.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <redacted>
---
arch/arm/mach-shmobile/pm-rcar.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: Simon Horman <hidden> Date: 2015-07-10 06:37:08
From: Geert Uytterhoeven <geert+renesas@glider.be>
rcar_sysc_update() loops (with interrupts disabled and while holding a
spinlock) until submitting a power shutoff or resume request fails, or
until the submitted request was accepted.
If none of these conditions becomes true, this forms an infinite loop.
Put a limit on the maximum number of loop iterations, and add a small
delay to each iteration, to fix this.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <redacted>
---
arch/arm/mach-shmobile/pm-rcar.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
@@ -95,14 +98,23 @@ static int rcar_sysc_update(struct rcar_sysc_ch *sysc_ch,iowrite32(isr_mask,rcar_sysc_base+SYSCISCR);/* Submit power shutoff or resume request until it was accepted */-do{+for(k=0;k<PWRER_RETRIES;k++){ret=on_off_fn(sysc_ch);if(ret)gotoout;status=ioread32(rcar_sysc_base+sysc_ch->chan_offs+PWRER_OFFS);-}while(status&chan_mask);+if(!(status&chan_mask))+break;++udelay(PWRER_DELAY_US);+}++if(k==PWRER_RETRIES){+ret=-EIO;+gotoout;+}/* Wait until the power shutoff or resume request has completed * */for(k=0;k<SYSCISR_RETRIES;k++){
From: Simon Horman <hidden> Date: 2015-07-10 06:37:09
From: Geert Uytterhoeven <geert+renesas@glider.be>
The passed struct rcar_sysc_ch is never modified, so it can be const.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <redacted>
---
arch/arm/mach-shmobile/pm-rcar.c | 16 ++++++++--------
arch/arm/mach-shmobile/pm-rcar.h | 6 +++---
2 files changed, 11 insertions(+), 11 deletions(-)
@@ -58,7 +58,7 @@ static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch,/* Wait until SYSC is ready to accept a power request */for(k=0;k<SYSCSR_RETRIES;k++){-if(ioread32(rcar_sysc_base+SYSCSR)&(1<<sr_bit))+if(ioread32(rcar_sysc_base+SYSCSR)&BIT(sr_bit))break;udelay(SYSCSR_DELAY_US);}
@@ -67,7 +67,7 @@ static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch,return-EAGAIN;/* Submit power shutoff or power resume request */-iowrite32(1<<sysc_ch->chan_bit,+iowrite32(BIT(sysc_ch->chan_bit),rcar_sysc_base+sysc_ch->chan_offs+reg_offs);return0;
@@ -86,8 +86,8 @@ static int rcar_sysc_pwr_on(const struct rcar_sysc_ch *sysc_ch)staticintrcar_sysc_update(conststructrcar_sysc_ch*sysc_ch,int(*on_off_fn)(conststructrcar_sysc_ch*)){-unsignedintisr_mask=1<<sysc_ch->isr_bit;-unsignedintchan_mask=1<<sysc_ch->chan_bit;+unsignedintisr_mask=BIT(sysc_ch->isr_bit);+unsignedintchan_mask=BIT(sysc_ch->chan_bit);unsignedintstatus;unsignedlongflags;intret=0;
From: Simon Horman <hidden> Date: 2015-07-10 06:37:11
From: Geert Uytterhoeven <geert+renesas@glider.be>
Simplify the power request code by passing an "on" flag, and picking the
right status bit and register offset in the innermost function, based on
this flag.
This allows to remove the rcar_sysc_pwr_{off,on}() helper functions, and
the function pointer through which they were called.
Make sr_bit and reg_offs unsigned while we're at it.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <redacted>
---
arch/arm/mach-shmobile/pm-rcar.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
@@ -51,11 +51,19 @@staticvoid__iomem*rcar_sysc_base;staticDEFINE_SPINLOCK(rcar_sysc_lock);/* SMP CPUs + I/O devices */-staticintrcar_sysc_pwr_on_off(conststructrcar_sysc_ch*sysc_ch,-intsr_bit,intreg_offs)+staticintrcar_sysc_pwr_on_off(conststructrcar_sysc_ch*sysc_ch,boolon){+unsignedintsr_bit,reg_offs;intk;+if(on){+sr_bit=SYSCSR_PONENB;+reg_offs=PWRONCR_OFFS;+}else{+sr_bit=SYSCSR_POFFENB;+reg_offs=PWROFFCR_OFFS;+}+/* Wait until SYSC is ready to accept a power request */for(k=0;k<SYSCSR_RETRIES;k++){if(ioread32(rcar_sysc_base+SYSCSR)&BIT(sr_bit))
@@ -73,18 +81,7 @@ static int rcar_sysc_pwr_on_off(const struct rcar_sysc_ch *sysc_ch,return0;}-staticintrcar_sysc_pwr_off(conststructrcar_sysc_ch*sysc_ch)-{-returnrcar_sysc_pwr_on_off(sysc_ch,SYSCSR_POFFENB,PWROFFCR_OFFS);-}--staticintrcar_sysc_pwr_on(conststructrcar_sysc_ch*sysc_ch)-{-returnrcar_sysc_pwr_on_off(sysc_ch,SYSCSR_PONENB,PWRONCR_OFFS);-}--staticintrcar_sysc_update(conststructrcar_sysc_ch*sysc_ch,-int(*on_off_fn)(conststructrcar_sysc_ch*))+staticintrcar_sysc_power(conststructrcar_sysc_ch*sysc_ch,boolon){unsignedintisr_mask=BIT(sysc_ch->isr_bit);unsignedintchan_mask=BIT(sysc_ch->chan_bit);
@@ -99,7 +96,7 @@ static int rcar_sysc_update(const struct rcar_sysc_ch *sysc_ch,/* Submit power shutoff or resume request until it was accepted */for(k=0;k<PWRER_RETRIES;k++){-ret=on_off_fn(sysc_ch);+ret=rcar_sysc_pwr_on_off(sysc_ch,on);if(ret)gotoout;
@@ -138,12 +135,12 @@ static int rcar_sysc_update(const struct rcar_sysc_ch *sysc_ch,intrcar_sysc_power_down(conststructrcar_sysc_ch*sysc_ch){-returnrcar_sysc_update(sysc_ch,rcar_sysc_pwr_off);+returnrcar_sysc_power(sysc_ch,false);}intrcar_sysc_power_up(conststructrcar_sysc_ch*sysc_ch){-returnrcar_sysc_update(sysc_ch,rcar_sysc_pwr_on);+returnrcar_sysc_power(sysc_ch,true);}boolrcar_sysc_power_is_off(conststructrcar_sysc_ch*sysc_ch)
@@ -82,7 +82,7 @@ static int r8a7779_platform_cpu_kill(unsigned int cpu)staticintr8a7779_boot_secondary(unsignedintcpu,structtask_struct*idle){-structrcar_sysc_ch*ch=NULL;+conststructrcar_sysc_ch*ch=NULL;unsignedintlcpu=cpu_logical_map(cpu);intret;
From: Olof Johansson <hidden> Date: 2015-07-14 09:50:49
On Fri, Jul 10, 2015 at 03:37:12PM +0900, Simon Horman wrote:
Hi Olof, Hi Kevin, Hi Arnd,
Please consider these Renesas ARM based SoC PM domain updates for v4.3.
The following changes since commit d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754:
Linux 4.2-rc1 (2015-07-05 11:01:52 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git tags/renesas-pm-domain-for-v4.3
for you to fetch changes up to bd82aff9192dad2bfd3cb3fc19fdf741c2f6028e:
ARM: shmobile: r8a7790: Make struct rcar_sysc_ch const (2015-07-06 09:35:24 +0900)
These looked mostly like cleanups and small fixes, so I merged them into next/cleanup.
-Olof