Suspend-to-RAM for A20 in sunxi-3.4

526 views
Skip to first unread message

Willi Gnilke

unread,
Mar 23, 2015, 12:37:03 PM3/23/15
to linux...@googlegroups.com

Using the linux-sunxi sunxi-3.4 branch I hoped to get suspend working because there is a lot of code in the arch/arm/mach-sun7i/pm directory which looks good.

with echo mem > /sys/power/state

the device goes into sleep but does not wakeup after pressing the power button. Instead it reboots.


I think that suspend is for battery powered devices essential and i'm very interested in getting this work.

My questions:

- Is there a kernel (3.4) in which suspend/resume runs stable

- Are there any special requirements to user space (i.e. graphics, X11 etc.) or even uboot?

- What about suspend for A20 in mainline kernel / sunxi-next?

- Where to start hacking?


My board is PcDuino3 but I think this is nothing special about it as hardware  is very similar to other boards.





Siarhei Siamashka

unread,
Mar 23, 2015, 2:54:17 PM3/23/15
to linux...@googlegroups.com, willi....@gmail.com
On Mon, 23 Mar 2015 09:21:01 -0700 (PDT)
Willi Gnilke <willi....@gmail.com> wrote:

>
>
> Using the linux-sunxi sunxi-3.4 branch I hoped to get suspend working
> because there is a lot of code in the arch/arm/mach-sun7i/pm directory
> which looks good.

The sun7i support in the sunxi-3.4 kernel is a result of a quick and
dirty forward porting from the old Allwinner's 3.3 kernel. AFAIK the
suspend support was never transplanted correctly.

> with echo mem > /sys/power/state
>
> the device goes into sleep but does not wakeup after pressing the power
> button. Instead it reboots.

The reboot is the bootloader thing.

For the suspend-to-ram implementation, the DRAM chips are put into the
self-refresh mode and the SoC is powered off. Waking up means that the
system is booting normally from the SD card or other default boot
locations. This means that the U-Boot bootloader is getting started
as part of the resume process. And right now it just discards the
data from DRAM and boots normally:

http://git.denx.de/?p=u-boot.git;a=commitdiff;h=f2577967738f923571b7156ad46ef91d9fa8d9f8

Which looks like a reboot.

Yes, for a proper suspend-to-ram support, we need to bring the DRAM back
from the self-refresh mode and resume the execution.

> I think that suspend is for battery powered devices essential and i'm very
> interested in getting this work.
>
> My questions:
>
> - Is there a kernel (3.4) in which suspend/resume runs stable
>
> - Are there any special requirements to user space (i.e. graphics, X11
> etc.) or even uboot?
>
> - What about suspend for A20 in mainline kernel / sunxi-next?
>
> - Where to start hacking?

You can have a look at super standby bits of the Allwinner's boot0
code here:

https://github.com/allwinner-zh/bootloader/tree/master/basic_loader/bsp/bsp_for_a20/init_dram

And then try to integrate the relevant parts from it into the mainline
U-Boot. Please note that the resume support is likely going to be quite
different for the mainline kernel compared to what is required for the
Allwinner's Android kernel (because of PSCI). But this all is better to
be discussed in the mainline U-Boot mailing list.

> My board is PcDuino3 but I think this is nothing special about it as
> hardware is very similar to other boards.

Yes, there should not be anything very much special. Can the PcDuino3
board in fact be powered from a battery?

--
Best regards,
Siarhei Siamashka

Willi Gnilke

unread,
Mar 24, 2015, 4:02:27 AM3/24/15
to linux...@googlegroups.com
Thank you for this quick answer,
Yes, the PcDuino has a battery connector and battery mode works very well.
I understand the procedure you described for wakeup. Provided that the Suspend code in the sunxi-3.4 is working I have to go into uboot to prevent it from cold restart/initialisation. This seems difficult.
Certainly I must start with a stripped "serial console only" version of linux.
Is there anyone in the forum, Hans de Goede has done many commits, who has some expirience in this field? 
Anybody who can say what already works and what not?



web32...@gmail.com

unread,
Mar 30, 2015, 1:31:15 PM3/30/15
to linux...@googlegroups.com
вторник, 24 марта 2015 г., 14:02:27 UTC+6 пользователь Willi Gnilke написал:
Hello.

It does not work now.
sun7i has two standby modes:
1.normal standby
It is very similar to standby on A10.It works on sdk lichee kernel even with u-boot on sdcard, because it does not power off SoC, just only enables self-refresh and wait. It is enough to make suspend work. However it does not work in sunxi-3.4 for some unknown reason. System hangs when enabling DRAM self-refresh mode, so reclocking DRAM at runtime on sunxi-3.4 is now impossible to.
2. super standby
Super standby code enables DRAM self-reforesh mode and shutting down SoC. So it requires support in bootloader and all drivers. It is very similar to suspend-to-disk and support of it in other drivers required.
I think that suspend-to-disk will be more useful on boards with external power and it easier to implement in mainline.

dwo...@gmail.com

unread,
May 22, 2015, 4:15:56 AM5/22/15
to linux...@googlegroups.com

Hi Willi,

Did you get any further with this? I am realy interested if it i posisble to suspend the A20 to RAM.

engrd...@gmail.com

unread,
Nov 12, 2015, 8:37:34 AM11/12/15
to linux-sunxi, dwo...@gmail.com
On Friday, May 22, 2015 at 12:15:56 PM UTC+4, dwo...@gmail.com wrote:
> Hi Willi,
>
> Did you get any further with this? I am realy interested if it i posisble to suspend the A20 to RAM.

Any news on this ??
Reply all
Reply to author
Forward
0 new messages