All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 36/38] x86: Add support for booting from Fast SPI
Date: Wed, 2 Oct 2019 22:08:03 +0800	[thread overview]
Message-ID: <CAEUhbmUCBcAnZoRFZAz8Xqb5Tp_HJQ6Sh=drkfUJtTXYx3YM5g@mail.gmail.com> (raw)
In-Reply-To: <20190925141147.191166-37-sjg@chromium.org>

On Wed, Sep 25, 2019 at 10:13 PM Simon Glass <sjg@chromium.org> wrote:
>
> Most x86 CPUs use a mechanism where the SPI flash is mapped into the very
> top of 32-bit address space, so that it can be executed in place and read
> simply by copying from memory. For an 8MB ROM the mapping starts at
> 0xff800000.
>
> However some recent Intel CPUs do not use a simple 1:1 memory map. Instead
> the map starts at a different address and not all of the SPI flash is
> accessible through the map. This 'Fast SPI' feature requires that U-Boot
> check the location of the map. It is also possible (optionally) to read
> from the SPI flash using a driver.
>
> Add support for booting from Fast SPI. The memory-mapped version is used
> by both TPL and SPL on apollolake.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Rename the fast SPI headers
>
>  arch/x86/cpu/intel_common/Makefile   |  1 +
>  arch/x86/cpu/intel_common/fast_spi.c | 48 ++++++++++++++++++++++++++++
>  arch/x86/include/asm/spl.h           |  1 +
>  3 files changed, 50 insertions(+)
>  create mode 100644 arch/x86/cpu/intel_common/fast_spi.c
>
> diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile
> index 07f27c29ec7..2de567dd9fe 100644
> --- a/arch/x86/cpu/intel_common/Makefile
> +++ b/arch/x86/cpu/intel_common/Makefile
> @@ -9,6 +9,7 @@ obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += report_platform.o
>  obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += mrc.o
>  endif
>  obj-y += cpu.o
> +obj-$(CONFIG_SPI_FLASH_INTEL_FAST) += fast_spi.o
>  obj-y += lpc.o
>  ifndef CONFIG_TARGET_EFI_APP
>  obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += microcode.o
> diff --git a/arch/x86/cpu/intel_common/fast_spi.c b/arch/x86/cpu/intel_common/fast_spi.c
> new file mode 100644
> index 00000000000..a7334ecf1a3
> --- /dev/null
> +++ b/arch/x86/cpu/intel_common/fast_spi.c
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright 2019 Google LLC
> + */
> +
> +#include <common.h>
> +#include <asm/io.h>
> +#include <asm/pci.h>
> +#include <asm/arch/fast_spi.h>
> +#include <asm/arch/iomap.h>
> +
> +/*
> + * Returns bios_start and fills in size of the BIOS region.
> + */
> +ulong fast_spi_get_bios_region(struct fast_spi_regs *regs, size_t *bios_size)

I suspect we need a public header file for these 2 APIs?

> +{
> +       ulong bios_start, bios_end;
> +
> +       /*
> +        * BIOS_BFPREG provides info about BIOS-Flash Primary Region Base and
> +        * Limit. Base and Limit fields are in units of 4K.
> +        */
> +       u32 val = readl(&regs->bfp);
> +
> +       bios_start = (val & SPIBAR_BFPREG_PRB_MASK) << 12;
> +       bios_end = (((val & SPIBAR_BFPREG_PRL_MASK) >>
> +                    SPIBAR_BFPREG_PRL_SHIFT) + 1) << 12;
> +       *bios_size = bios_end - bios_start;
> +
> +       return bios_start;
> +}
> +
> +int fast_spi_get_bios_mmap(ulong *map_basep, size_t *map_sizep, uint *offsetp)
> +{
> +       struct fast_spi_regs *regs;
> +       ulong bar, base, mmio_base;
> +
> +       /* Special case to find mapping without probing the device */
> +       pci_x86_read_config(NULL, PCH_DEV_SPI, PCI_BASE_ADDRESS_0, &bar,
> +                           PCI_SIZE_32);
> +       mmio_base = bar & PCI_BASE_ADDRESS_MEM_MASK;
> +       regs = (struct fast_spi_regs *)mmio_base;
> +       base = fast_spi_get_bios_region(regs, map_sizep);
> +       *map_basep = (u32)-*map_sizep - base;
> +       *offsetp = base;
> +
> +       return 0;
> +}
> diff --git a/arch/x86/include/asm/spl.h b/arch/x86/include/asm/spl.h
> index 1bef4877eb3..cc6cac08f23 100644
> --- a/arch/x86/include/asm/spl.h
> +++ b/arch/x86/include/asm/spl.h
> @@ -11,6 +11,7 @@
>
>  enum {
>         BOOT_DEVICE_SPI_MMAP    = 10,
> +       BOOT_DEVICE_FAST_SPI,
>         BOOT_DEVICE_CROS_VBOOT,
>  };
>
> --

Regards,
Bin

  reply	other threads:[~2019-10-02 14:08 UTC|newest]

Thread overview: 132+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25 14:11 [U-Boot] [PATCH v2 00/38] x86: Various modifications to prepare for FSP2 Simon Glass
2019-09-25 14:11 ` [U-Boot] [PATCH v2 01/38] binman: Pass the toolpath to binman from the main Makefile Simon Glass
2019-10-02 13:55   ` Bin Meng
2019-10-03  2:02     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 02/38] binman: Allow selection of logging verbosity Simon Glass
2019-10-02 13:56   ` Bin Meng
2019-10-03  2:02     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 03/38] dm: gpio: Allow control of GPIO uclass in SPL Simon Glass
2019-10-02 13:56   ` Bin Meng
2019-10-03  2:02     ` Bin Meng
2019-10-04  2:58       ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 04/38] mtd: spi: Add 'struct spi_flash {' to the code Simon Glass
2019-10-02 13:56   ` Bin Meng
2019-10-03  2:02     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 05/38] serial: ns16550: Allow serial to enabled/disabled in SPL Simon Glass
2019-10-02 13:56   ` Bin Meng
2019-10-03  2:02     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 06/38] spl: Correct priority selection for image loaders Simon Glass
2019-09-26 12:32   ` Simon Goldschmidt
2019-09-25 14:11 ` [U-Boot] [PATCH v2 07/38] spl: Avoid checking for Ctrl-C in SPL with print_buffer() Simon Glass
2019-10-02 13:58   ` Bin Meng
2019-10-03  7:38     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 08/38] spl: handoff: Correct Kconfig condition for SPL and TPL Simon Glass
2019-10-02 13:58   ` Bin Meng
2019-10-03  7:38     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 09/38] spl: Add an arch-specific hook for writing to SPL handoff Simon Glass
2019-10-02 13:58   ` Bin Meng
2019-10-03  7:38     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 10/38] spl: Set up the bloblist in board_init_r() Simon Glass
2019-10-02 13:58   ` Bin Meng
2019-10-03  7:38     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 11/38] spl: Add a function to determine the U-Boot phase Simon Glass
2019-10-02 13:58   ` Bin Meng
2019-10-03  7:50     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 12/38] x86: spi: Add a driver for the Intel Fast SPI interface Simon Glass
2019-10-09 13:10   ` Bin Meng
2019-10-19  2:43     ` Simon Glass
2019-10-21  2:34       ` Bin Meng
2019-10-21  3:16         ` Simon Glass
2019-09-25 14:11 ` [U-Boot] [PATCH v2 13/38] spi: sandbox: Add a test driver for sandbox SPI flash Simon Glass
2019-10-09 13:50   ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 14/38] spi: Add support for memory-mapped flash Simon Glass
2019-10-09 13:55   ` Bin Meng
2019-10-12  3:08     ` Simon Glass
2019-10-12  4:33       ` Bin Meng
2019-10-16 10:29         ` Vignesh Raghavendra
2019-10-16 16:40           ` Simon Glass
2019-10-18  8:51             ` Vignesh Raghavendra
2019-10-18 14:13               ` Simon Glass
2019-10-17 14:28           ` Simon Glass
2019-10-18  2:22             ` Simon Glass
2019-10-18  2:32               ` Bin Meng
2019-10-18 14:14                 ` Simon Glass
2019-10-18 15:38                   ` Bin Meng
2019-10-18 20:37                     ` Simon Glass
2019-10-21  2:29                       ` Bin Meng
2019-10-21  3:14                         ` Simon Glass
2019-10-18  9:48               ` Vignesh Raghavendra
2019-10-18 14:13                 ` Simon Glass
2019-09-25 14:11 ` [U-Boot] [PATCH v2 15/38] x86: sysreset: Allow reset driver to be included in SPL/TPL Simon Glass
2019-10-02 14:06   ` Bin Meng
2019-10-03  7:50     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 16/38] x86: Rename some FSP functions to have an fsp_ prefix Simon Glass
2019-10-02 14:06   ` Bin Meng
2019-10-03  7:57     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 17/38] x86: fsp: Create a common fsp_support.h header Simon Glass
2019-10-02 14:06   ` Bin Meng
2019-10-03  8:32     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 18/38] x86: fsp: Use if() instead of #ifdef Simon Glass
2019-10-03  8:16   ` Bin Meng
2019-10-03  8:23     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 19/38] x86: fsp: Tidy up comment style a little Simon Glass
2019-10-02 14:06   ` Bin Meng
2019-10-03  8:29     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 20/38] x86: fsp: Move common dram functions into a common file Simon Glass
2019-10-02 14:06   ` Bin Meng
2019-10-03  8:35     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 21/38] x86: Move common fsp " Simon Glass
2019-10-02 14:06   ` Bin Meng
2019-10-03  8:44     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 22/38] x86: fsp: Move common support " Simon Glass
2019-10-02 14:06   ` Bin Meng
2019-10-03  8:44     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 23/38] efi: Move inline functions to unconditional part of header Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:44     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 24/38] x86: fsp: Add a few more definitions for FSP2 Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:44     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 25/38] x86: fsp: Add access to variable MRC data Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:44     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 26/38] x86: Move common Intel CPU info code into a function Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:56     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 27/38] x86: Add binman symbols to the image Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:56     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 28/38] x86: pci: Add a function to clear and set PCI config regs Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:56     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 29/38] x86: spl: Use hang() instead of a while() loop Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:56     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 30/38] x86: spl: Reduce priority of the basic SPL image loader Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  8:57     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 31/38] x86: spl: Move broadwell-specific code out of generic x86 spl Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-03  9:09     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 32/38] x86: fsp: Save usable RAM and hob_list in the handoff area Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-04  3:06     ` Bin Meng
2019-10-04  3:28       ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 33/38] x86: fsp: Allow the HOBs to be used after relocation Simon Glass
2019-10-04  3:23   ` Bin Meng
2019-10-10 17:06     ` Simon Glass
2019-09-25 14:11 ` [U-Boot] [PATCH v2 34/38] x86: Change condition for using CAR Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-04  3:28     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 35/38] x86: Add more comments to the start-up code Simon Glass
2019-10-02 14:07   ` Bin Meng
2019-10-04  3:28     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 36/38] x86: Add support for booting from Fast SPI Simon Glass
2019-10-02 14:08   ` Bin Meng [this message]
2019-10-12  2:55     ` Simon Glass
2019-09-25 14:11 ` [U-Boot] [PATCH v2 37/38] x86: Add various MTRR indexes and values Simon Glass
2019-10-02 14:08   ` Bin Meng
2019-10-04  4:05     ` Bin Meng
2019-09-25 14:11 ` [U-Boot] [PATCH v2 38/38] x86: Rename turbo ratio MSR to MSR_TURBO_RATIO_LIMIT Simon Glass
2019-10-02 14:08   ` Bin Meng
2019-10-04  4:05     ` Bin Meng

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='CAEUhbmUCBcAnZoRFZAz8Xqb5Tp_HJQ6Sh=drkfUJtTXYx3YM5g@mail.gmail.com' \
    --to=bmeng.cn@gmail.com \
    --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.