mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] state: do not complain about missing backend-storage-type
@ 2017-05-23  7:46 Sascha Hauer
  2017-05-23  7:46 ` [PATCH 2/2] state: Add working example dtsi file Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2017-05-23  7:46 UTC (permalink / raw)
  To: Barebox List

backend-storage-type is irrelevant for mtd devices, so do not
complain about this option missing. The mtd backend will print
messages if necessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/state/state.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/common/state/state.c b/common/state/state.c
index 878fd1b0fb..121ba0c6d3 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -571,7 +571,7 @@ struct state *state_new_from_node(struct device_node *node, char *path,
 	struct state *state;
 	int ret = 0;
 	const char *backend_type;
-	const char *storage_type;
+	const char *storage_type = NULL;
 	const char *alias;
 	uint32_t stridesize;
 
@@ -616,12 +616,7 @@ struct state *state_new_from_node(struct device_node *node, char *path,
 		stridesize = 0;
 	}
 
-	ret = of_property_read_string(node, "backend-storage-type",
-				      &storage_type);
-	if (ret) {
-		storage_type = NULL;
-		dev_info(&state->dev, "No backend-storage-type found, using default.\n");
-	}
+	of_property_read_string(node, "backend-storage-type", &storage_type);
 
 	ret = state_format_init(state, backend_type, node, alias);
 	if (ret)
-- 
2.11.0


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

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

* [PATCH 2/2] state: Add working example dtsi file
  2017-05-23  7:46 [PATCH 1/2] state: do not complain about missing backend-storage-type Sascha Hauer
@ 2017-05-23  7:46 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2017-05-23  7:46 UTC (permalink / raw)
  To: Barebox List

This adds a working example dtsi file for the state framework. It can
be directly included by the Phytec phyFLEX i.MX6 board. The board has
been chosen because it has a wide range of different storage devices
suitable for state: SD, NAND, SPI NOR and i2c EEPROM.

This example can be used for testing and also as a template for others
to copy.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/dts/imx6qdl-phytec-pbab01.dtsi |   4 +
 arch/arm/dts/state-example.dtsi         | 128 ++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+)
 create mode 100644 arch/arm/dts/state-example.dtsi

diff --git a/arch/arm/dts/imx6qdl-phytec-pbab01.dtsi b/arch/arm/dts/imx6qdl-phytec-pbab01.dtsi
index 86ab991c91..991c7e4fab 100644
--- a/arch/arm/dts/imx6qdl-phytec-pbab01.dtsi
+++ b/arch/arm/dts/imx6qdl-phytec-pbab01.dtsi
@@ -14,3 +14,7 @@
 &uart1 {
 	status = "okay";
 };
+
+#ifdef USE_STATE_EXAMPLE
+#include "state-example.dtsi"
+#endif
diff --git a/arch/arm/dts/state-example.dtsi b/arch/arm/dts/state-example.dtsi
new file mode 100644
index 0000000000..490ee7840b
--- /dev/null
+++ b/arch/arm/dts/state-example.dtsi
@@ -0,0 +1,128 @@
+/*
+ * This code is released using a dual license strategy: BSD/GPL
+ * You can choose the licence that better fits your requirements.
+ *
+ * Released under the terms of 3-clause BSD License
+ * Released under the terms of GNU General Public License Version 2.0
+ *
+ */
+
+/*
+ * This contains an example how to use the state framework. This file
+ * can be directly included by imx6qdl-phytec-pbab01.dtsi, other boards
+ * need adjustments. Note that this example may use the partitions in
+ * other ways than intended by phytec, so before using this see below
+ * if it will overwrite some precious data.
+ */
+
+#define STATE_VARS \
+	#address-cells = <1>;				\
+	#size-cells = <1>;				\
+	mac {						\
+		reg = <0x0 0x6>;			\
+		type = "mac";				\
+	};						\
+							\
+	number {					\
+		reg = <0x8 0x4>;			\
+		type = "uint32";			\
+	};						\
+							\
+	name {						\
+		reg = <0xc 0x10>;			\
+		type = "string";			\
+	};						\
+							\
+	fruit {						\
+		reg = <0x1c 0x4>;			\
+		type = "enum32";			\
+		names = "apple", "pear", "banana";	\
+	}
+
+/ {
+	aliases {
+		state_nor = &state_nor;
+		state_nand = &state_nand;
+		state_sd = &state_sd;
+		state_eeprom = &state_eeprom;
+	};
+
+	state_nor: state_nor {
+		magic = <0x512890a0>;
+		compatible = "barebox,state";
+		backend-type = "raw";
+		backend = <&backend_state_nor>;
+		backend-storage-type = "circular";
+
+		STATE_VARS;
+	};
+
+	state_nand: state_nand {
+		magic = <0xab67421f>;
+		compatible = "barebox,state";
+		backend-type = "raw";
+		backend = <&backend_state_nand>;
+		backend-storage-type = "circular";
+
+		STATE_VARS;
+	};
+
+	state_sd: state_sd {
+		magic = <0xef784236>;
+		compatible = "barebox,state";
+		backend-type = "raw";
+		backend = <&backend_state_usdhc>;
+		backend-stridesize = <1024>;
+
+		STATE_VARS;
+	};
+
+	state_eeprom: state_eeprom {
+		magic = <0x344682db>;
+		compatible = "barebox,state";
+		backend-type = "raw";
+		backend = <&backend_state_eeprom>;
+		backend-stridesize = <64>;
+
+		STATE_VARS;
+	};
+
+};
+
+&ecspi3 {
+	flash@0 {
+		backend_state_nor: partition@120000 {
+		};
+	};
+};
+
+&gpmi {
+	backend_state_nand: partition@500000 {
+	};
+};
+
+&i2c1 {
+	eeprom@50 {
+		partitions {
+			compatible = "fixed-partitions";
+			#size-cells = <1>;
+			#address-cells = <1>;
+			backend_state_eeprom: state@400 {
+				reg = <0x400 0x400>;
+				label = "state-eeprom";
+			};
+		};
+	};
+};
+
+&usdhc2 {
+	partitions {
+		compatible = "fixed-partitions";
+		#size-cells = <1>;
+		#address-cells = <1>;
+		backend_state_usdhc: state@0x80000 {
+			reg = <0x80000 0x80000>;
+			label = "state-sd";
+		};
+	};
+};
\ No newline at end of file
-- 
2.11.0


_______________________________________________
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:[~2017-05-23  7:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23  7:46 [PATCH 1/2] state: do not complain about missing backend-storage-type Sascha Hauer
2017-05-23  7:46 ` [PATCH 2/2] state: Add working example dtsi file Sascha Hauer

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