mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* of_state_fixup / different path in barebox and kernel
@ 2016-02-17 18:14 Harald Welte
  2016-02-18 11:57 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Harald Welte @ 2016-02-17 18:14 UTC (permalink / raw)
  To: barebox

Dear List,

I have a custom board with an AM335x on it.  We used to have an I2C
EEPROM for keeping the boot state, but moved that to SPI in a subsequent
version.

The SPI EEPROM uses gpio-based chip select, which is supported by linux
kernel spi-omap2-mcspi.c.  However, it is not supported by barebox.

My "solution" was to simply use the gpio-bitbang in barebox, which also
works fine for those few bytes that need to be read, performance doesn't
matter.

Now however I can no longer boot any kernel image, as of_state_fixup
fails in

	backend_node = of_find_node_by_path_from(root, state->backend->of_path);

due to the fact that the of-path of the EEPROM is different in the
barebox device tree (/spi_gpio/m95m02@0) than in the kernel device tree
(/ocp/spi@481a0000/m95m02@0)

Is there any designated solution for this situation?

Thanks in advance,
	Harald
-- 
- Harald Welte <laforge@gnumonks.org>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: of_state_fixup / different path in barebox and kernel
  2016-02-17 18:14 of_state_fixup / different path in barebox and kernel Harald Welte
@ 2016-02-18 11:57 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2016-02-18 11:57 UTC (permalink / raw)
  To: Harald Welte; +Cc: barebox

Hi Harald,

On Wed, Feb 17, 2016 at 07:14:56PM +0100, Harald Welte wrote:
> Dear List,
> 
> I have a custom board with an AM335x on it.  We used to have an I2C
> EEPROM for keeping the boot state, but moved that to SPI in a subsequent
> version.
> 
> The SPI EEPROM uses gpio-based chip select, which is supported by linux
> kernel spi-omap2-mcspi.c.  However, it is not supported by barebox.
> 
> My "solution" was to simply use the gpio-bitbang in barebox, which also
> works fine for those few bytes that need to be read, performance doesn't
> matter.
> 
> Now however I can no longer boot any kernel image, as of_state_fixup
> fails in
> 
> 	backend_node = of_find_node_by_path_from(root, state->backend->of_path);

In newer versions we have:

commit b62aea561142c6974b593301fbec9ed18381cf8d
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Thu Sep 10 15:11:28 2015 +0200

    of_fix_tree: do not fail when fixup fails

So at least a failed of_fixup should no longer prevent you from booting.

> 
> due to the fact that the of-path of the EEPROM is different in the
> barebox device tree (/spi_gpio/m95m02@0) than in the kernel device tree
> (/ocp/spi@481a0000/m95m02@0)
> 
> Is there any designated solution for this situation?

We could introduce a state.of_backend_path variable which holds the
path, something like attached. You would then have to change the
variable to the correct path somewhere.

Another way I could think of would be to add a possibility to blacklist
of_fixups. That would do it aswell since you could provide a correct
device tree for the kernel, right?

Sascha

-----------------------------8<-------------------------------

diff --git a/common/state.c b/common/state.c
index 3e95efd..223d00d 100644
--- a/common/state.c
+++ b/common/state.c
@@ -56,7 +56,7 @@ struct state {
 struct state_backend {
 	int (*save)(struct state_backend *backend, struct state *state);
 	const char *name;
-	const char *of_path;
+	char *of_path;
 	const char *path;
 	struct digest *digest;
 };
@@ -1642,6 +1642,7 @@ int state_backend_raw_file(struct state *state, const char *of_path,
 	struct state_backend *backend;
 	struct state_variable *sv;
 	struct mtd_info_user meminfo;
+	struct param_d *p;
 	size_t path_size = 0;
 	int ret;
 
@@ -1680,6 +1681,13 @@ int state_backend_raw_file(struct state *state, const char *of_path,
 
 	state->backend = backend;
 
+	p = dev_add_param_string(&state->dev, "of_backend_path", NULL, NULL,
+				   &state->backend->of_path, NULL);
+	if (IS_ERR(p)) {
+		ret = PTR_ERR(p);
+		goto err;
+	}
+
 	ret = mtd_get_meminfo(backend->path, &meminfo);
 	if (!ret && !(meminfo.flags & MTD_NO_ERASE)) {
 		backend_raw->need_erase = true;

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-18 11:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-17 18:14 of_state_fixup / different path in barebox and kernel Harald Welte
2016-02-18 11:57 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox