All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 13/22] x86: fsp: Save stack address to CMOS for next S3 boot
Date: Thu, 13 Apr 2017 07:34:33 -0600	[thread overview]
Message-ID: <CAPnjgZ015CMenAN+c5UKKJX9H22Goca5EF0ZOhs0GHY_0Ege1w@mail.gmail.com> (raw)
In-Reply-To: <CAEUhbmU2Ln6bVMQ-D6diFWXS5po4RYgjk5jV7Wx5moT9xujbPQ@mail.gmail.com>

Hi Bin,

On 13 April 2017 at 03:25, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Mar 22, 2017 at 4:06 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Bin,
>>
>> On 16 March 2017 at 08:26, Bin Meng <bmeng.cn@gmail.com> wrote:
>>> At the end of pre-relocation phase, save the new stack address
>>> to CMOS and use it as the stack on next S3 boot for fsp_init()
>>> continuation function.
>>>
>>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>> ---
>>>
>>>  arch/x86/cpu/cpu.c                 |  8 ++++++++
>>>  arch/x86/include/asm/cmos_layout.h | 31 +++++++++++++++++++++++++++++++
>>>  arch/x86/include/asm/u-boot-x86.h  |  1 +
>>>  arch/x86/lib/fsp/fsp_common.c      | 30 +++++++++++++++++++++++++++++-
>>>  4 files changed, 69 insertions(+), 1 deletion(-)
>>>  create mode 100644 arch/x86/include/asm/cmos_layout.h
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> nits below
>>
>>>
>>> diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
>>> index afc8645..9e2aee2 100644
>>> --- a/arch/x86/cpu/cpu.c
>>> +++ b/arch/x86/cpu/cpu.c
>>> @@ -278,6 +278,14 @@ int reserve_arch(void)
>>>         high_table_reserve();
>>>  #endif
>>>
>>> +#if defined(CONFIG_HAVE_ACPI_RESUME) && defined(CONFIG_HAVE_FSP)
>>> +       /*
>>> +        * Save stack address to CMOS so that at next S3 boot,
>>> +        * we can use it as the stack address for fsp_contiue()
>>> +        */
>>> +       fsp_save_s3_stack();
>>> +#endif
>>> +
>>>         return 0;
>>>  }
>>>  #endif
>>> diff --git a/arch/x86/include/asm/cmos_layout.h b/arch/x86/include/asm/cmos_layout.h
>>> new file mode 100644
>>> index 0000000..0a0a51e
>>> --- /dev/null
>>> +++ b/arch/x86/include/asm/cmos_layout.h
>>> @@ -0,0 +1,31 @@
>>> +/*
>>> + * Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
>>> + *
>>> + * SPDX-License-Identifier:    GPL-2.0+
>>> + */
>>> +
>>> +#ifndef __CMOS_LAYOUT_H
>>> +#define __CMOS_LAYOUT_H
>>> +
>>> +/*
>>> + * The RTC internal registers and RAM is organized as two banks of 128 bytes
>>> + * each, called the standard and extended banks. The first 14 bytes of the
>>> + * standard bank contain the RTC time and date information along with four
>>> + * registers, A - D, that are used for configuration of the RTC. The extended
>>> + * bank contains a full 128 bytes of battery backed SRAM.
>>> + *
>>> + * For simplicity in U-Boot we only support CMOS in the standard bank, and
>>> + * its base address starts from offset 0x10, which leaves us 112 bytes space.
>>> + */
>>> +#define CMOS_BASE              0x10
>>> +
>>> +/*
>>> + * The file records all offsets off CMOS_BASE that is currently used by
>>> + * U-Boot for various reasons. It is put in such a unified place in order
>>> + * to be consistent across platforms.
>>> + */
>>> +
>>> +/* stack address for S3 boot in a FSP configuration, 4 bytes */
>>> +#define CMOS_FSP_STACK_ADDR    CMOS_BASE
>>> +
>>> +#endif /* __CMOS_LAYOUT_H */
>>> diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h
>>> index 4f901f9..024aaf4 100644
>>> --- a/arch/x86/include/asm/u-boot-x86.h
>>> +++ b/arch/x86/include/asm/u-boot-x86.h
>>> @@ -56,6 +56,7 @@ u32 isa_map_rom(u32 bus_addr, int size);
>>>  int video_bios_init(void);
>>>
>>>  /* arch/x86/lib/fsp/... */
>>> +int fsp_save_s3_stack(void);
>>>  int x86_fsp_init(void);
>>
>> Function comment?
>>
>>>
>>>  void   board_init_f_r_trampoline(ulong) __attribute__ ((noreturn));
>>> diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c
>>> index 2b33fba..df73a2a 100644
>>> --- a/arch/x86/lib/fsp/fsp_common.c
>>> +++ b/arch/x86/lib/fsp/fsp_common.c
>>> @@ -5,8 +5,12 @@
>>>   */
>>>
>>>  #include <common.h>
>>> +#include <dm.h>
>>>  #include <errno.h>
>>> +#include <rtc.h>
>>>  #include <asm/acpi_s3.h>
>>> +#include <asm/cmos_layout.h>
>>> +#include <asm/early_cmos.h>
>>>  #include <asm/io.h>
>>>  #include <asm/mrccache.h>
>>>  #include <asm/post.h>
>>> @@ -71,9 +75,32 @@ static __maybe_unused void *fsp_prepare_mrc_cache(void)
>>>         return cache->data;
>>>  }
>>>
>>> +#ifdef CONFIG_HAVE_ACPI_RESUME
>>> +int fsp_save_s3_stack(void)
>>> +{
>>> +       struct udevice *dev;
>>> +       int ret;
>>> +
>>> +       if (gd->arch.prev_sleep_state == ACPI_S3)
>>> +               return 0;
>>> +
>>> +       ret = uclass_get_device(UCLASS_RTC, 0, &dev);
>>
>> You need to use uclass_get_device_err() to get an error I think.
>
> There is no such API in current mainline.

Sorry, I mean uclass_first_device_err(). It may not be suitable if you
need to use device 0, but if you just want the first device it should
be OK. Anyway I will leave this up to you.

Regards,
Simon

  reply	other threads:[~2017-04-13 13:34 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 14:26 [U-Boot] [PATCH 00/22] x86: Add ACPI S3 resume support Bin Meng
2017-03-16 14:26 ` [U-Boot] [PATCH 01/22] dm: rtc: Add 16-bit read/write support Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-04-01  2:26     ` Bin Meng
2017-03-16 14:26 ` [U-Boot] [PATCH 02/22] x86: acpi: Add Kconfig option and header file for ACPI resume Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 03/22] x86: baytrail: acpi: Add APIs for determining/clearing sleep state Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 04/22] x86: Add post codes for OS resume Bin Meng
2017-03-17  3:26   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 05/22] x86: fsp: acpi: Pass different boot mode to FSP init Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 06/22] x86: Store and display previous sleep state Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 07/22] x86: baytrail: Conditionally report S3 in the ACPI table Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 08/22] x86: fsp: Mark memory used by U-Boot as reserved in the E820 table for S3 Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-12  8:14     ` Bin Meng
2017-03-16 14:26 ` [U-Boot] [PATCH 09/22] x86: acpi: Add wake up assembly stub Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 10/22] x86: acpi: Add one API to find OS wakeup vector Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 11/22] x86: acpi: Resume OS if resume vector is found Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-12  8:14     ` Bin Meng
2017-04-13 21:15       ` Simon Glass
2017-04-17  9:37       ` Stefan Roese
2017-04-24  3:38         ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 12/22] x86: Add an early CMOS access library Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-18  9:46     ` Bin Meng
2017-04-19  0:12       ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 13/22] x86: fsp: Save stack address to CMOS for next S3 boot Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-04-13  9:25     ` Bin Meng
2017-04-13 13:34       ` Simon Glass [this message]
2017-03-16 14:26 ` [U-Boot] [PATCH 14/22] x86: fsp: Mark the first 64K low memory as reserved Bin Meng
2017-03-21 20:06   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 15/22] x86: Adjust board_final_cleanup() order Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 16/22] x86: apci: Change PM1_CNT register access to RMW Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 17/22] x86: acpi: Make enter_acpi_mode() public Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 18/22] x86: acpi: Refactor acpi_resume() Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 19/22] x86: acpi: Turn on ACPI mode for S3 Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 20/22] x86: pci: Allow conditionally run VGA rom in S3 Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-04-13 10:00     ` Bin Meng
2017-04-13 13:32       ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 21/22] x86: minnowmax: Enable ACPI S3 resume Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-16 14:26 ` [U-Boot] [PATCH 22/22] x86: Document ACPI S3 support Bin Meng
2017-03-21 20:07   ` Simon Glass
2017-03-17  3:26 ` [U-Boot] [PATCH 00/22] x86: Add ACPI S3 resume support Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPnjgZ015CMenAN+c5UKKJX9H22Goca5EF0ZOhs0GHY_0Ege1w@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.