sh: SuperH Mobile suspend support
Subsystems (3)
PATCH 1/1 sh: SuperH Mobile suspend support
From: Magnus Damm <[email protected]>
This patch adds CONFIG_SUSPEND support to the SuperH architecture. If enabled, SuperH Mobile processors will register their suspend callbacks during boot.
To suspend, use "echo mem > /sys/power/state". To allow wakeup, make sure "/sys/device/platform/../power/wakeup" contains "enabled". Additional per-device driver patches are most likely needed.
---
arch/sh/Kconfig | 1 arch/sh/include/asm/suspend.h | 12 ++ arch/sh/kernel/cpu/sh4a/Makefile | 7 + arch/sh/kernel/cpu/sh4a/pm-sh_mobile.c | 76 +++++++++++++++++ arch/sh/kernel/cpu/sh4a/sleep-sh_mobile.S | 125 +++++++++++++++++++++++++++++ 5 files changed, 221 insertions(+)
arch/sh/Kconfig +1 -0
@@ -159,6 +159,7 @@ config CPU_SH4 select CPU_HAS_SR_RB select CPU_HAS_PTEA if !CPU_SH4A || CPU_SHX2 select CPU_HAS_FPU if !CPU_SH4AL_DSP + select ARCH_SUSPEND_POSSIBLE config CPU_SH4A bool
arch/sh/include/asm/suspend.h +12 -0
@@ -1,6 +1,7 @@#ifndef _ASM_SH_SUSPEND_H#define _ASM_SH_SUSPEND_H +#ifndef __ASSEMBLY__static inline int arch_prepare_suspend (void ) {return 0 ; }#include <asm/ptrace.h>
@@ -9,5 +10,16 @@ struct swsusp_arch_regs {struct pt_regs user_regs;unsigned long bank1_regs[8 ]; }; +#endif + +#define SUSP_SH_SLEEP (1 << 0)/* Regular sleep mode */ +#define SUSP_SH_STANDBY (1 << 1)/* Software standby mode */ +#define SUSP_SH_RSTANDBY (1 << 2)/* R-standby mode */ +#define SUSP_SH_USTANDBY (1 << 3)/* U-standby mode */ +#define SUSP_SH_SF (1 << 4)/* Enable self-refresh */ + +#define SUSP_MODE_SLEEP (SUSP_SH_SLEEP) +#define SUSP_MODE_SLEEP_SF (SUSP_SH_SLEEP | SUSP_SH_SF) +#define SUSP_MODE_STANDBY_SF (SUSP_SH_STANDBY | SUSP_SH_SF)#endif /* _ASM_SH_SUSPEND_H */
arch/sh/kernel/cpu/sh4a/Makefile +7 -0
@@ -35,6 +35,13 @@ pinmux-$(CONFIG_CPU_SUBTYPE_SH7723) := p pinmux-$(CONFIG_CPU_SUBTYPE_SH7785) := pinmux-sh7785.o pinmux-$(CONFIG_CPU_SUBTYPE_SH7786) := pinmux-sh7786.o +# Power Mangement & Sleep mode +pm-$(CONFIG_CPU_SUBTYPE_SH7343) := pm-sh_mobile.o sleep-sh_mobile.o +pm-$(CONFIG_CPU_SUBTYPE_SH7366) := pm-sh_mobile.o sleep-sh_mobile.o +pm-$(CONFIG_CPU_SUBTYPE_SH7722) := pm-sh_mobile.o sleep-sh_mobile.o +pm-$(CONFIG_CPU_SUBTYPE_SH7723) := pm-sh_mobile.o sleep-sh_mobile.o + obj-y += $(clock-y) obj-$(CONFIG_SMP) += $(smp-y) obj-$(CONFIG_GENERIC_GPIO) += $(pinmux-y) +obj-$(CONFIG_PM) += $(pm-y)
arch/sh/kernel/cpu/sh4a/pm-sh_mobile.c new file +76 -0
76 lines not on this page · raw message
arch/sh/kernel/cpu/sh4a/sleep-sh_mobile.S new file +125 -0
125 lines not on this page · raw message
arch/sh/Kconfig config CPU_SH4 · line 165
Quoted 10 lines · Magnus Damm
arch/sh/Kconfig +1
-0@@ -159,6 +159,7 @@ config CPU_SH4 select CPU_HAS_SR_RB select CPU_HAS_PTEA if !CPU_SH4A || CPU_SHX2 select CPU_HAS_FPU if !CPU_SH4AL_DSP + select ARCH_SUSPEND_POSSIBLE config CPU_SH4A bool
This is bogus, as this is all SH-Mobile specific. The easiest option is probably to define a CPU_SHMOBILE that all of these CPUs can select, and then moving all of this in to arch/sh/kernel/cpu/shmobile/. We've done similar things on the ARM side for code-sharing between SH-Mobile G3 and G4 for example.
Quoted 12 lines
arch/sh/include/asm/suspend.h +1
-0@@ -1,6 +1,7 @@#ifndef _ASM_SH_SUSPEND_H#define _ASM_SH_SUSPEND_H +#ifndef __ASSEMBLY__static inline int arch_prepare_suspend (void ) {return 0 ; }#include <asm/ptrace.h> @@ -9,5 +10,16 @@ struct swsusp_arch_regs {struct pt_regs user_regs;
arch/sh/include/asm/suspend.h struct swsusp_arch_regs { · line 20
Quoted 10 lines
arch/sh/include/asm/suspend.h +8
-0unsigned long bank1_regs[8]; }; +#endif + +#define SUSP_SH_SLEEP (1 << 0)/* Regular sleep mode */ +#define SUSP_SH_STANDBY (1 << 1)/* Software standby mode */ +#define SUSP_SH_RSTANDBY (1 << 2)/* R-standby mode */ +#define SUSP_SH_USTANDBY (1 << 3)/* U-standby mode */ +#define SUSP_SH_SF (1 << 4)/* Enable self-refresh */ +
This probably wants a bit more explanation, as it's not entirely obvious for folks not familiar with SH-Mobile internals what standby modes are generic SH vs SH-Mobile specific.
arch/sh/include/asm/suspend.h struct swsusp_arch_regs { · line 23
Quoted 3 lines
arch/sh/include/asm/suspend.h +3
-0+extern const unsigned char do_standby[]; +extern const unsigned int do_standby_size; +
These are pretty uninspired globals, please use something more definitive. (ie, shmobile_enter_standby/shmobile_standby_size or something similar).
arch/sh/include/asm/suspend.h struct swsusp_arch_regs {
Quoted 8 lines
arch/sh/include/asm/suspend.h +8
-0+static void set_vbr (void *base) +{ + asmvolatile ("ldc %0, vbr" + :/* no output */ + :"r" (base) + :"memory" ); +} +
Just toss this in an asm/ header somewhere, it's not worth reimplementing all over the place. Although for a single instruction it doesn't really add much, you may as well just open-code it.
PATCH 1/1 sh: SuperH Mobile suspend support V2
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
This patch contains CONFIG_SUSPEND support to the SuperH architecture V2. If enabled, SuperH Mobile processors will register their suspend callbacks during boot.
To suspend, use "echo mem > /sys/power/state". To allow wakeup, make sure "/sys/device/platform/../power/wakeup" contains "enabled". Additional per-device driver patches are most likely needed.
---
Changes since V1:
- fixed up issues pointed out by Paul
- added more comments
arch/sh/Kconfig | 1 arch/sh/include/asm/suspend.h | 9 ++ arch/sh/kernel/cpu/sh4a/Makefile | 7 + arch/sh/kernel/cpu/sh4a/pm-sh_mobile.c | 92 +++++++++++++++++++++ arch/sh/kernel/cpu/sh4a/sleep-sh_mobile.S | 125 +++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+)
arch/sh/Kconfig +1 -0
@@ -181,6 +181,7 @@ config CPU_SHX3 config ARCH_SHMOBILE bool + select ARCH_SUSPEND_POSSIBLE choice prompt "Processor sub-type selection"
arch/sh/include/asm/suspend.h +9 -0
@@ -1,6 +1,7 @@#ifndef _ASM_SH_SUSPEND_H#define _ASM_SH_SUSPEND_H +#ifndef __ASSEMBLY__static inline int arch_prepare_suspend (void ) {return 0 ; }#include <asm/ptrace.h>
@@ -9,5 +10,13 @@ struct swsusp_arch_regs {struct pt_regs user_regs;unsigned long bank1_regs[8 ]; }; +#endif + +/* flags passed to assembly suspend code */ +#define SUSP_SH_SLEEP (1 << 0)/* Regular sleep mode */ +#define SUSP_SH_STANDBY (1 << 1)/* SH-Mobile Software standby mode */ +#define SUSP_SH_RSTANDBY (1 << 2)/* SH-Mobile R-standby mode */ +#define SUSP_SH_USTANDBY (1 << 3)/* SH-Mobile U-standby mode */ +#define SUSP_SH_SF (1 << 4)/* Enable self-refresh */ #endif /* _ASM_SH_SUSPEND_H */
arch/sh/kernel/cpu/sh4a/Makefile +7 -0
@@ -35,6 +35,13 @@ pinmux-$(CONFIG_CPU_SUBTYPE_SH7723) := p pinmux-$(CONFIG_CPU_SUBTYPE_SH7785) := pinmux-sh7785.o pinmux-$(CONFIG_CPU_SUBTYPE_SH7786) := pinmux-sh7786.o +# Power Mangement & Sleep mode +pm-$(CONFIG_CPU_SUBTYPE_SH7343) := pm-sh_mobile.o sleep-sh_mobile.o +pm-$(CONFIG_CPU_SUBTYPE_SH7366) := pm-sh_mobile.o sleep-sh_mobile.o +pm-$(CONFIG_CPU_SUBTYPE_SH7722) := pm-sh_mobile.o sleep-sh_mobile.o +pm-$(CONFIG_CPU_SUBTYPE_SH7723) := pm-sh_mobile.o sleep-sh_mobile.o + obj-y += $(clock-y) obj-$(CONFIG_SMP) += $(smp-y) obj-$(CONFIG_GENERIC_GPIO) += $(pinmux-y) +obj-$(CONFIG_PM) += $(pm-y)
arch/sh/kernel/cpu/sh4a/pm-sh_mobile.c new file +92 -0
92 lines not on this page · raw message
arch/sh/kernel/cpu/sh4a/sleep-sh_mobile.S new file +125 -0
125 lines not on this page · raw message
PATCH 1/1 sh: SuperH Mobile suspend support V3
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
This patch contains CONFIG_SUSPEND support to the SuperH architecture V3. If enabled, SuperH Mobile processors will register their suspend callbacks during boot.
To suspend, use "echo mem > /sys/power/state". To allow wakeup, make sure "/sys/device/platform/../power/wakeup" contains "enabled". Additional per-device driver patches are most likely needed.
---
Changes since V2:
- fixed ILRAM typo
- use CONFIG_ARCH_SHMOBILE in Makefile
Changes since V1:
- fixed up issues pointed out by Paul
- added more comments
arch/sh/Kconfig | 1 arch/sh/include/asm/suspend.h | 9 ++ arch/sh/kernel/cpu/sh4a/Makefile | 4 arch/sh/kernel/cpu/sh4a/pm-sh_mobile.c | 92 +++++++++++++++++++++ arch/sh/kernel/cpu/sh4a/sleep-sh_mobile.S | 125 +++++++++++++++++++++++++++++ 5 files changed, 231 insertions(+)
arch/sh/Kconfig +1 -0
@@ -181,6 +181,7 @@ config CPU_SHX3 config ARCH_SHMOBILE bool + select ARCH_SUSPEND_POSSIBLE choice prompt "Processor sub-type selection"
arch/sh/include/asm/suspend.h +9 -0
@@ -1,6 +1,7 @@#ifndef _ASM_SH_SUSPEND_H#define _ASM_SH_SUSPEND_H +#ifndef __ASSEMBLY__static inline int arch_prepare_suspend (void ) {return 0 ; }#include <asm/ptrace.h>
@@ -9,5 +10,13 @@ struct swsusp_arch_regs {struct pt_regs user_regs;unsigned long bank1_regs[8 ]; }; +#endif + +/* flags passed to assembly suspend code */ +#define SUSP_SH_SLEEP (1 << 0)/* Regular sleep mode */ +#define SUSP_SH_STANDBY (1 << 1)/* SH-Mobile Software standby mode */ +#define SUSP_SH_RSTANDBY (1 << 2)/* SH-Mobile R-standby mode */ +#define SUSP_SH_USTANDBY (1 << 3)/* SH-Mobile U-standby mode */ +#define SUSP_SH_SF (1 << 4)/* Enable self-refresh */ #endif /* _ASM_SH_SUSPEND_H */
arch/sh/kernel/cpu/sh4a/Makefile +4 -0
@@ -35,6 +35,10 @@ pinmux-$(CONFIG_CPU_SUBTYPE_SH7723) := p pinmux-$(CONFIG_CPU_SUBTYPE_SH7785) := pinmux-sh7785.o pinmux-$(CONFIG_CPU_SUBTYPE_SH7786) := pinmux-sh7786.o +# Power Mangement & Sleep mode +pm-$(CONFIG_ARCH_SHMOBILE) := pm-sh_mobile.o sleep-sh_mobile.o + obj-y += $(clock-y) obj-$(CONFIG_SMP) += $(smp-y) obj-$(CONFIG_GENERIC_GPIO) += $(pinmux-y) +obj-$(CONFIG_PM) += $(pm-y)
arch/sh/kernel/cpu/sh4a/pm-sh_mobile.c new file +92 -0
92 lines not on this page · raw message
arch/sh/kernel/cpu/sh4a/sleep-sh_mobile.S new file +125 -0
125 lines not on this page · raw message
PATCH 1/1 sh: add ap325 lcd power off support
From: Magnus Damm <[email protected]>
Improve the ap325 board code to allow the lcd panel and backlight to be powered off.
---
arch/sh/boards/board-ap325rxa.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/sh/boards/board-ap325rxa.c +11 -0
@@ -166,6 +166,16 @@ static void ap320_wvga_power_on(void *boctrl_outw (0x100 ,FPGA_BKLREG ); } +static void ap320_wvga_power_off (void *board_data) +{ +/* backlight */ +ctrl_outw (0 ,FPGA_BKLREG ); +gpio_set_value (GPIO_PTS3 ,1 ); + +/* ASD AP-320/325 LCD OFF */ +ctrl_outw (0 ,FPGA_LCDREG ); +} +static struct sh_mobile_lcdc_info lcdc_info = { .clock_source =LCDC_CLK_EXTERNAL , .ch[0 ] = {
@@ -191,6 +201,7 @@ static struct sh_mobile_lcdc_info lcdc_i }, .board_cfg = { .display_on = ap320_wvga_power_on, + .display_off = ap320_wvga_power_off, }, } };
PATCH 1/1 video: sh_mobile_lcdcfb suspend/resume support
From: Magnus Damm <[email protected]>
This patch adds suspend/resume support to the LCDC driver for SuperH Mobile - sh_mobile_lcdcfb.
We simply stop hardware on suspend and start it again on resume. For RGB panels this is trivial, but for SYS panels in deferred io mode this becomes a bit more difficult - we need to wait for a frame end interrupt to make sure the clocks are balanced before stopping the actual hardware.
---
Tested on ap325 and Migo-R.
drivers/video/sh_mobile_lcdcfb.c | 66 +++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 7 deletions(-)
drivers/video/sh_mobile_lcdcfb.c +59 -7
@@ -33,6 +33,8 @@ struct sh_mobile_lcdc_chan {struct fb_info info;dma_addr_t dma_handle;struct fb_deferred_io defio; +unsigned long frame_end; +wait_queue_head_t frame_end_wait; };struct sh_mobile_lcdc_priv {
@@ -226,7 +228,10 @@ static void sh_mobile_lcdc_deferred_io_tstatic irqreturn_t sh_mobile_lcdc_irq (int irq,void *data) {struct sh_mobile_lcdc_priv *priv = data; +struct sh_mobile_lcdc_chan *ch;unsigned long tmp; +int is_sub; +int k;/* acknowledge interrupt */ tmp =lcdc_read (priv, _LDINTR);
@@ -234,8 +239,24 @@ static irqreturn_t sh_mobile_lcdc_irq(in tmp |=0x000000ff ^LDINTR_FS ;/* status in low 8 */ lcdc_write (priv, _LDINTR, tmp); -/* disable clocks */ -sh_mobile_lcdc_clk_off (priv); +/* figure out if this interrupt is for main or sub lcd */ + is_sub = (lcdc_read (priv, _LDSR) & (1 <<10 )) ?1 :0 ; + +/* wake up channel and disable clocks*/ +for (k =0 ; k <ARRAY_SIZE (priv->ch); k++) { + ch = &priv->ch[k]; + +if (!ch->enabled) +continue ; + +if (is_sub ==lcdc_chan_is_sublcd (ch)) { + ch->frame_end =1 ; +wake_up (&ch->frame_end_wait); + +sh_mobile_lcdc_clk_off (priv); + } + } +return IRQ_HANDLED ; }
@@ -448,18 +469,27 @@ static void sh_mobile_lcdc_stop(struct sstruct sh_mobile_lcdc_board_cfg *board_cfg;int k; -/* tell the board code to disable the panel */ +/* clean up deferred io and ask board code to disable panel */ for (k =0 ; k <ARRAY_SIZE (priv->ch); k++) { ch = &priv->ch[k]; - board_cfg = &ch->cfg.board_cfg; -if (board_cfg->display_off) - board_cfg->display_off (board_cfg->board_data); -/* cleanup deferred io if enabled */ +/* deferred io mode: +* flush frame, and wait for frame end interrupt +* clean up deferred io and enable clock +*/ if (ch->info.fbdefio) { + ch->frame_end =0 ; +schedule_delayed_work (&ch->info.deferred_work,0 ); +wait_event (ch->frame_end_wait, ch->frame_end);fb_deferred_io_cleanup (&ch->info); ch->info.fbdefio =NULL ; +sh_mobile_lcdc_clk_on (priv); } + + board_cfg = &ch->cfg.board_cfg; +if (board_cfg->display_off) + board_cfg->display_off (board_cfg->board_data); + }/* stop the lcdc */
@@ -652,6 +682,26 @@ static int sh_mobile_lcdc_set_bpp(structreturn 0 ; } +static int sh_mobile_lcdc_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); + +sh_mobile_lcdc_stop (platform_get_drvdata (pdev)); +return 0 ; +} + +static int sh_mobile_lcdc_resume (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); + +return sh_mobile_lcdc_start (platform_get_drvdata (pdev)); +} + +static struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = { + .suspend = sh_mobile_lcdc_suspend, + .resume = sh_mobile_lcdc_resume, +}; +static int sh_mobile_lcdc_remove (struct platform_device *pdev);static int __init sh_mobile_lcdc_probe (struct platform_device *pdev)
@@ -707,6 +757,7 @@ static int __init sh_mobile_lcdc_probe(sdev_err (&pdev->dev,"unsupported interface type\n" ); goto err1; } +init_waitqueue_head (&priv->ch[i].frame_end_wait);switch (pdata->ch[i].chan) {case LCDC_CHAN_MAINLCD :
@@ -860,6 +911,7 @@ static struct platform_driver sh_mobile_ .driver = { .name = "sh_mobile_lcdc_fb", .owner = THIS_MODULE, + .pm = &sh_mobile_lcdc_dev_pm_ops, }, .probe = sh_mobile_lcdc_probe, .remove = sh_mobile_lcdc_remove,
Re: [PATCH] sh: SuperH Mobile suspend support V3
Quoted 10 lines · Magnus Damm
This patch contains
CONFIG_SUSPENDsupport to the SuperH architecture V3. If enabled, SuperH Mobile processors will register their suspend callbacks during boot.To suspend, use "echo mem >
/sys/power/state". To allow wakeup, make sure "/sys/device/platform/../power/wakeup" contains "enabled". Additional per-device driver patches are most likely needed.Signed-off-by Magnus Damm <[email protected]>
Quoted 4 lines · Magnus Damm
Improve the ap325 board code to allow the lcd panel and backlight to be powered off.
Signed-off-by Magnus Damm <[email protected]>
Quoted 11 lines · Magnus Damm
This patch adds suspend/resume support to the LCDC driver for SuperH Mobile -
sh_mobile_lcdcfb.We simply stop hardware on suspend and start it again on resume. For RGB panels this is trivial, but for SYS panels in deferred io mode this becomes a bit more difficult - we need to wait for a frame end interrupt to make sure the clocks are balanced before stopping the actual hardware.
Signed-off-by Magnus Damm <[email protected]>
All applied, thanks.