All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
Subject: [PATCH v6 3/5] spi: Add checks for OF_CONTROL
Date: Sun, 25 Jul 2021 10:13:45 -0600	[thread overview]
Message-ID: <20210725161347.457937-4-sjg@chromium.org> (raw)
In-Reply-To: <20210725161347.457937-1-sjg@chromium.org>

This uclass requires OF_CONTROL to be enabled but some boards use it in
SPL without doing that. Add a warning so that the maintainer can fix it.

Expand the check in spi_post_probe() too.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v6:
- Add new patch for SPI flash

 drivers/spi/spi-uclass.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index d867b278064..2ae3e075993 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -176,11 +176,11 @@ static int spi_child_post_bind(struct udevice *dev)
 
 static int spi_post_probe(struct udevice *bus)
 {
-#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct dm_spi_bus *spi = dev_get_uclass_priv(bus);
 
-	spi->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0);
-#endif
+	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+		spi->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0);
+
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 	struct dm_spi_ops *ops = spi_get_ops(bus);
 	static int reloc_done;
@@ -471,6 +471,16 @@ int spi_slave_of_to_plat(struct udevice *dev, struct dm_spi_slave_plat *plat)
 	int mode = 0;
 	int value;
 
+	/*
+	 * This uclass requires OF_CONTROL but this is included on some boards
+	 * that don't support it in SPL. Return an error so the board vendor
+	 * can resolve this.
+	 */
+	if (!CONFIG_IS_ENABLED(OF_CONTROL)) {
+		log_err("SPI flash requires OF_CONTROL enabled");
+		return -ENOSYS;
+	}
+
 	plat->cs = dev_read_u32_default(dev, "reg", -1);
 	plat->max_hz = dev_read_u32_default(dev, "spi-max-frequency",
 					    SPI_DEFAULT_SPEED_HZ);
-- 
2.32.0.432.gabb21c7263-goog


  parent reply	other threads:[~2021-07-25 16:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-25 16:13 [PATCH v6 0/5] of-platdata: Avoid building libfdt Simon Glass
2021-07-25 16:13 ` [PATCH v6 1/5] omap: mmc: Avoid using libfdt with of-platdata Simon Glass
2021-07-25 16:13 ` [PATCH v6 2/5] net: atheros: Add a check for OF_CONTROL Simon Glass
2021-07-27  4:23   ` Ramon Fried
2021-07-25 16:13 ` Simon Glass [this message]
2021-07-25 16:13 ` [PATCH v6 4/5] spl: Allow SPL/TPL to use of-platdata without libfdt Simon Glass
2021-07-25 16:13 ` [PATCH v6 5/5] dm: core: Don't include ofnode functions with of-platdata Simon Glass
2021-07-25 20:32 ` [PATCH v6 0/5] of-platdata: Avoid building libfdt Tom Rini
2021-07-26  3:57   ` Simon Glass
2021-07-26 12:09     ` Tom Rini
2021-07-26 13:45       ` Simon Glass
2021-07-26 14:43         ` Tom Rini
2021-07-31 23:07           ` Simon Glass
2021-07-31 23:11             ` Tom Rini

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=20210725161347.457937-4-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=jagan@amarulasolutions.com \
    --cc=jagannadh.teki@gmail.com \
    --cc=trini@konsulko.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.