From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Goldschmidt Date: Mon, 19 Nov 2018 20:08:40 +0100 Subject: [U-Boot] [PATCH v2 1/2] spl_spi: Read default speed and mode values from DT In-Reply-To: <1542648790-21362-2-git-send-email-patrick.delaunay@st.com> References: <1542648790-21362-1-git-send-email-patrick.delaunay@st.com> <1542648790-21362-2-git-send-email-patrick.delaunay@st.com> Message-ID: <7828272b-a824-d56f-9e46-159d7d959859@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 19.11.2018 18:33, Patrick Delaunay 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 > Signed-off-by: Patrick Delaunay I was commenting about code duplication, which is better now, so: Reviewed-by: Simon Goldschmidt I do think it would be nice to invert the logic. That way, we could get completely rid of those two CONFIG_SF_DEFAULT settings for DM_SPI_FLASH boards (and eventually for all boards - when's the deadline for that?). But there are other places that still do it like you do here, so it's probably better to change them all at once... Simon > --- > > 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; > > +#ifdef CONFIG_DM_SPI_FLASH > + /* In DM mode defaults will be taken from DT */ > + max_hz = 0, spi_mode = 0; > +#endif > /* > * 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;