All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] spl_spi: Read default speed and mode values from DT
Date: Mon, 10 Dec 2018 16:48:02 -0600	[thread overview]
Message-ID: <CAHCN7xKsgi__4-6H5=19jei3Xdky4vtHdpXkWJzCHtt5b5DRbw@mail.gmail.com> (raw)
In-Reply-To: <1542648790-21362-2-git-send-email-patrick.delaunay@st.com>

On Mon, Nov 19, 2018 at 11:55 AM Patrick Delaunay
<patrick.delaunay@st.com> wrote:
>
> In case of DT boot, don't read default speed and mode for SPI from
> CONFIG_*, instead read from DT node.
>
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> Changes in v2:
> - use variables to avoid duplicated code
>
>  common/spl/spl_spi.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
> index 8cd4830..b348b45 100644
> --- a/common/spl/spl_spi.c
> +++ b/common/spl/spl_spi.c
> @@ -74,15 +74,21 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
>         unsigned payload_offs = CONFIG_SYS_SPI_U_BOOT_OFFS;
>         struct spi_flash *flash;
>         struct image_header *header;
> +       unsigned int max_hz = CONFIG_SF_DEFAULT_SPEED;
> +       unsigned int spi_mode = CONFIG_SF_DEFAULT_MODE;
>

Instead of
> +#ifdef CONFIG_DM_SPI_FLASH

What about using:

#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)

> +       /* In DM mode defaults will be taken from DT */
> +       max_hz = 0, spi_mode = 0;
> +#endif

This one-line change 'should' give you what you want, the settings of
0 for boards using the device tree.  If board that uses OF_PLATDATA
cannot load the device tree, it'll default back to the configs set
above.  You could probably combine all if statements into one, and I'd
be fine with that too.

This one-line change made my board boot with this series.  I haven't
applied the follow-up series yet but if a v3 was posted with this
change, I'd mark it as 'tested-by.

adam

>         /*
>          * Load U-Boot image from SPI flash into RAM
>          */
>
>         flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
>                                 CONFIG_SF_DEFAULT_CS,
> -                               CONFIG_SF_DEFAULT_SPEED,
> -                               CONFIG_SF_DEFAULT_MODE);
> +                               max_hz,
> +                               spi_mode);
>         if (!flash) {
>                 puts("SPI probe failed.\n");
>                 return -ENODEV;
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

  parent reply	other threads:[~2018-12-10 22:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19 17:33 [U-Boot] [PATCH v2 0/2] Read default speed and mode values from DT Patrick Delaunay
2018-11-19 17:33 ` [U-Boot] [PATCH v2 1/2] spl_spi: " Patrick Delaunay
2018-11-19 19:08   ` Simon Goldschmidt
2018-11-27  8:06     ` Patrick DELAUNAY
2018-11-27  8:11       ` Simon Goldschmidt
2018-11-27 12:33         ` Patrick DELAUNAY
2018-11-27 12:54           ` Simon Goldschmidt
2018-12-10 11:01             ` Patrick DELAUNAY
2018-12-10 22:48   ` Adam Ford [this message]
2018-12-13 16:04     ` Patrick DELAUNAY
2018-11-19 17:33 ` [U-Boot] [PATCH v2 2/2] splash: sf: " Patrick Delaunay
2018-12-10 15:50 ` [U-Boot] [PATCH v2 0/2] " Adam Ford
2018-12-13 16:17   ` Patrick DELAUNAY

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='CAHCN7xKsgi__4-6H5=19jei3Xdky4vtHdpXkWJzCHtt5b5DRbw@mail.gmail.com' \
    --to=aford173@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.