Skip to contentSkip to conversation

Read default speed and mode values from DT

PATCH Superseded Patrick Delaunay 2 participants 5 messages Nov 8, 2018 – Nov 12, 2018

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Read default speed and mode values from DT

This serie generalize the commit 96907c0fe50a ("dm: spi: Read default speed and mode values from DT")

In case of DT boot, don't read default speed and mode for SPI from CONFIG_*, instead read from DT node. This will make sure that boards with multiple SPI/QSPI controllers can be probed at different bus frequencies and SPI modes.

Today it is only done in the command sf; this patch do the same for the other user of the spi_flash_probe(): spl and splash to avoid probe issue.

Patrick Delaunay (2):
spl_spi: Read default speed and mode values from DT
splash: sf: Read default speed and mode values from DT

 common/spl/spl_spi.c   | 9 ++++++++-
 common/splash_source.c | 8 ++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 spl_spi: Read default speed and mode values from DT

In case of DT boot, don't read default speed and mode for SPI from CONFIG_*, instead read from DT node.

---

 common/spl/spl_spi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
common/spl/spl_spi.c +8 -1
index 8cd4830..3cefc9a 100644
@@ -78,11 +78,18 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 	/*
 	 * Load U-Boot image from SPI flash into RAM
 	 */
-
+#ifdef CONFIG_DM_SPI_FLASH
+	/* In DM mode defaults will be taken from DT */
+	flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
+				CONFIG_SF_DEFAULT_CS,
+				0,
+				0);
+#else
 	flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
 				CONFIG_SF_DEFAULT_CS,
 				CONFIG_SF_DEFAULT_SPEED,
 				CONFIG_SF_DEFAULT_MODE);
+#endif
 	if (!flash) {
 		puts("SPI probe failed.\n");
 		return -ENODEV;
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 spl_spi: Read default speed and mode values from DT

Quoted 16 lines · Patrick Delaunay

In case of DT boot, don't read default speed and mode for SPI from CONFIG_*, instead read from DT node.

---

 common/spl/spl_spi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
common/spl/spl_spi.c +0 -0
index 8cd4830..3cefc9a 100644

common/spl/spl_spi.c static int spl_spi_load_image(struct spl_image_info *spl_image, · line 86

Quoted 10 lines
common/spl/spl_spi.c +6 -1
@@ -78,11 +78,18 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
        /*
         * Load U-Boot image from SPI flash into RAM
         */
-
+#ifdef CONFIG_DM_SPI_FLASH
+       /* In DM mode defaults will be taken from DT */
+       flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
+                               CONFIG_SF_DEFAULT_CS,
+                               0,
+                               0);

Code duplication is never good. Wouldn't it be nicer to only have an #if for the two differing parameters (e.g. via local variables) instead of duplicating the function call?

Simon

Quoted 12 lines
common/spl/spl_spi.c +2 -1
+#else
        flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
                                CONFIG_SF_DEFAULT_CS,
                                CONFIG_SF_DEFAULT_SPEED,
                                CONFIG_SF_DEFAULT_MODE);
+#endif
        if (!flash) {
                puts("SPI probe failed.\n");
                return -ENODEV;
--

2.7.4

#3 lore raw

PATCH 1/2 spl_spi: Read default speed and mode values from DT

Hi Simon,

Quoted 24 lines

From: Simon Goldschmidt <[email protected]>
Sent: vendredi 9 novembre 2018 07:45
Subject: Re: [PATCH 1/2] spl_spi: Read default speed and mode values from DT
Importance: High

common/spl/spl_spi.c static int spl_spi_load_image(struct spl_image_info

Quoted 16 lines · Patrick Delaunay

In case of DT boot, don't read default speed and mode for SPI from CONFIG_*, instead read from DT node.

---

 common/spl/spl_spi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
common/spl/spl_spi.c index renamed from common/spl/spl_spi.c +0 -0

8cd4830..3cefc9a 100644

common/spl/spl_spi.c +0 -0
@@ -78,11 +78,18 @@ static int spl_spi_load_image(struct spl_image_info

*spl_image,

Quoted 14 lines

common/spl/spl_spi.c static int spl_spi_load_image(struct spl_image_info *spl_image, · line 86

Quoted 10 lines
common/spl/spl_spi.c +6 -1
        /*
         * Load U-Boot image from SPI flash into RAM
         */
-
+#ifdef CONFIG_DM_SPI_FLASH
+       /* In DM mode defaults will be taken from DT */
+       flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
+                               CONFIG_SF_DEFAULT_CS,
+                               0,
+                               0);

Code duplication is never good. Wouldn't it be nicer to only have an #if for the two differing parameters (e.g. via local variables) instead of duplicating the function call?

Ok. I take the point and I will update the patchset with local variable in v2. I just wait few day to be sure it is the only remark.

Quoted 14 lines

Simon

Quoted 10 lines
common/spl/spl_spi.c +2 -1
+#else
        flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
                                CONFIG_SF_DEFAULT_CS,
                                CONFIG_SF_DEFAULT_SPEED,
                                CONFIG_SF_DEFAULT_MODE);
+#endif
        if (!flash) {
                puts("SPI probe failed.\n");
                return -ENODEV;
--
Quoted 2 lines

2.7.4

Regards
Patrick

#4 lore raw

PATCH 2/2 splash: sf: Read default speed and mode values from DT

In reply to Patrick Delaunay

In case of DT boot, don't read default speed and mode for SPI from CONFIG_*, instead read from DT node.

---

 common/splash_source.c | 8 ++++++++
 1 file changed, 8 insertions(+)
common/splash_source.c +8 -0
index 62763b9..f0b3407 100644
@@ -25,10 +25,18 @@ static struct spi_flash *sf;
 static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
 {
 	if (!sf) {
+#ifdef CONFIG_DM_SPI_FLASH
+		/* In DM mode defaults will be taken from DT */
+		sf = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
+				     CONFIG_SF_DEFAULT_CS,
+				     0,
+				     0);
+#else
 		sf = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
 				     CONFIG_SF_DEFAULT_CS,
 				     CONFIG_SF_DEFAULT_SPEED,
 				     CONFIG_SF_DEFAULT_MODE);
+#endif
 		if (!sf)
 			return -ENODEV;
 	}
Signature · 1 line
2.7.4