mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/10] i.MX reset reason detection support
@ 2018-04-14 17:50 Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 01/10] common: reset_source: Add the notion of "reset source instance" Andrey Smirnov
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Everyone:

This patchset is the result of my work on adding support for detecting
and reporting reset reason as can be obtained from System Reset
Controller (to be more precise via SRSR register) on i.MX family of
SoC.

Currently list of supported SoC is as follows:

	  - i.MX6 (tested on i.MX6Q)
	  - i.MX7 (tested on i.MX7D)
	  - VFxxx (tested on VF610)

Feedback is wellcome!

Thanks,
Andrey Smirnov

Andrey Smirnov (10):
  common: reset_source: Add the notion of "reset source instance"
  ARM: i.MX: Add infrastructure to record SoC reset reason
  ARM: i.MX6: Record reset reason as a part of startup
  ARM: i.MX7: Record reset reason as a part of startup
  common: reset_source: Introduce reset_source_name()
  ARM: i.MX: Log detected reset reason
  ARM: i.MX: Print "revision unknown" if that is the case
  ARM: VFxxx: Add code to detect reset reason
  ARM: VFxxx: Add code to detect cpu variant
  ARM: VFxxx: Detect cpu variant and reset source on start

 arch/arm/mach-imx/Makefile                    |  1 +
 arch/arm/mach-imx/imx.c                       | 83 ++++++++++++++++++++++++++-
 arch/arm/mach-imx/imx6.c                      |  4 +-
 arch/arm/mach-imx/imx7.c                      |  3 +
 arch/arm/mach-imx/include/mach/generic.h      |  1 +
 arch/arm/mach-imx/include/mach/reset-reason.h | 31 ++++++++++
 arch/arm/mach-imx/include/mach/vf610-regs.h   |  3 +
 arch/arm/mach-imx/include/mach/vf610.h        | 51 ++++++++++++++++
 arch/arm/mach-imx/vf610.c                     | 50 ++++++++++++++++
 common/reset_source.c                         | 23 ++++++++
 include/reset_source.h                        | 17 ++++++
 11 files changed, 264 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-imx/include/mach/reset-reason.h
 create mode 100644 arch/arm/mach-imx/include/mach/vf610.h
 create mode 100644 arch/arm/mach-imx/vf610.c

-- 
2.14.3


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

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

* [PATCH 01/10] common: reset_source: Add the notion of "reset source instance"
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 02/10] ARM: i.MX: Add infrastructure to record SoC reset reason Andrey Smirnov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

In order to accomodate SoCs that come with multiple watchdogs (or any
other reset sources of the same kind) add a notion of "reset source
instance", similar to what we already have for bootsource API.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/reset_source.c  | 17 +++++++++++++++++
 include/reset_source.h | 11 +++++++++++
 2 files changed, 28 insertions(+)

diff --git a/common/reset_source.c b/common/reset_source.c
index 06e2ca85f..6a6c4f5da 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -32,6 +32,7 @@ static const char * const reset_src_names[] = {
 
 static enum reset_src_type reset_source;
 static unsigned int reset_source_priority;
+static int reset_source_instance;
 
 enum reset_src_type reset_source_get(void)
 {
@@ -39,6 +40,12 @@ enum reset_src_type reset_source_get(void)
 }
 EXPORT_SYMBOL(reset_source_get);
 
+int reset_source_get_instance(void)
+{
+	return reset_source_instance;
+}
+EXPORT_SYMBOL(reset_source_get_instance);
+
 void reset_source_set_priority(enum reset_src_type st, unsigned int priority)
 {
 	if (priority <= reset_source_priority)
@@ -46,17 +53,27 @@ void reset_source_set_priority(enum reset_src_type st, unsigned int priority)
 
 	reset_source = st;
 	reset_source_priority = priority;
+	reset_source_instance = 0;
 
 	pr_debug("Setting reset source to %s with priority %d\n",
 			reset_src_names[reset_source], priority);
 }
 EXPORT_SYMBOL(reset_source_set_priority);
 
+void reset_source_set_instance(enum reset_src_type type, int instance)
+{
+	if (reset_source == type)
+		reset_source_instance = instance;
+}
+EXPORT_SYMBOL(reset_source_set_instance);
+
 static int reset_source_init(void)
 {
 	globalvar_add_simple_enum("system.reset", (unsigned int *)&reset_source,
 			reset_src_names, ARRAY_SIZE(reset_src_names));
 
+	globalvar_add_simple_int("system.reset_instance", &reset_source_instance,
+				 "%d");
 	return 0;
 }
 
diff --git a/include/reset_source.h b/include/reset_source.h
index 3ff06b70a..c9911c008 100644
--- a/include/reset_source.h
+++ b/include/reset_source.h
@@ -27,6 +27,8 @@ enum reset_src_type {
 #ifdef CONFIG_RESET_SOURCE
 void reset_source_set_priority(enum reset_src_type, unsigned int priority);
 enum reset_src_type reset_source_get(void);
+void reset_source_set_instance(enum reset_src_type type, int instance);
+int reset_source_get_instance(void);
 unsigned int of_get_reset_source_priority(struct device_node *node);
 #else
 static inline void reset_source_set_priority(enum reset_src_type type,
@@ -34,11 +36,20 @@ static inline void reset_source_set_priority(enum reset_src_type type,
 {
 }
 
+static inline void reset_source_set_instance(enum reset_src_type type, int instance)
+{
+}
+
 static inline enum reset_src_type reset_source_get(void)
 {
 	return RESET_UKWN;
 }
 
+static inline int reset_source_get_instance(void)
+{
+	return 0;
+}
+
 static inline unsigned int of_get_reset_source_priority(struct device_node *node)
 {
 	return 0;
-- 
2.14.3


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

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

* [PATCH 02/10] ARM: i.MX: Add infrastructure to record SoC reset reason
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 01/10] common: reset_source: Add the notion of "reset source instance" Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-18 15:23   ` Philipp Zabel
  2018-04-14 17:50 ` [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup Andrey Smirnov
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx.c                       | 49 +++++++++++++++++++++++++++
 arch/arm/mach-imx/include/mach/reset-reason.h | 17 ++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 arch/arm/mach-imx/include/mach/reset-reason.h

diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
index 9400105c6..e860e298a 100644
--- a/arch/arm/mach-imx/imx.c
+++ b/arch/arm/mach-imx/imx.c
@@ -14,8 +14,11 @@
 #include <common.h>
 #include <of.h>
 #include <init.h>
+#include <io.h>
 #include <mach/revision.h>
+#include <mach/reset-reason.h>
 #include <mach/generic.h>
+#include <reset_source.h>
 
 static int __imx_silicon_revision = IMX_CHIP_REV_UNKNOWN;
 
@@ -147,3 +150,49 @@ static int imx_init(void)
 	return ret;
 }
 postcore_initcall(imx_init);
+
+void imx_set_reset_reason(void __iomem *srsr)
+{
+	enum reset_src_type type = RESET_UKWN;
+	const u32 reg = readl(srsr);
+
+	/*
+	 * SRSR register captures ALL reset event that occured since
+	 * POR, so we need to clear it to make sure we only caputre
+	 * the latest one.
+	 */
+	writel(reg, srsr);
+
+	switch (reg) {
+	case IMX_SRC_SRSR_IPP_RESET: /* FALLTHROUGH */
+	case IMX_SRC_SRSR_IPP_RESET | IMX_SRC_SRSR_WDOG1_RESET:
+		type = RESET_POR;
+		break;
+	case IMX_SRC_SRSR_WDOG3_RESET: /* FALLTHROUGH */
+	case IMX_SRC_SRSR_WDOG4_RESET: /* FALLTHROUGH */
+	case IMX_SRC_SRSR_WDOG1_RESET:
+		type = RESET_WDG;
+		break;
+	case IMX_SRC_SRSR_JTAG_RESET: /* FALLTHROUGH */
+	case IMX_SRC_SRSR_JTAG_SW_RESET:
+		type = RESET_JTAG;
+		break;
+	case IMX_SRC_SRSR_TEMPSENSE_RESET:
+		type = RESET_THERM;
+		break;
+	case IMX_SRC_SRSR_WARM_BOOT:
+		type = RESET_RST;
+		break;
+	}
+
+	reset_source_set(type);
+
+	switch (reg) {
+	case IMX_SRC_SRSR_WDOG3_RESET:
+		reset_source_set_instance(type, 1);
+		break;
+	case IMX_SRC_SRSR_WDOG4_RESET:
+		reset_source_set_instance(type, 2);
+		break;
+	}
+}
diff --git a/arch/arm/mach-imx/include/mach/reset-reason.h b/arch/arm/mach-imx/include/mach/reset-reason.h
new file mode 100644
index 000000000..96b905303
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/reset-reason.h
@@ -0,0 +1,17 @@
+#ifndef __MACH_RESET_REASON_H__
+#define __MACH_RESET_REASON_H__
+
+#define IMX_SRC_SRSR_IPP_RESET		BIT(0)
+#define IMX_SRC_SRSR_CSU_RESET		BIT(1)
+#define IMX_SRC_SRSR_IPP_USER_RESET	BIT(3)
+#define IMX_SRC_SRSR_WDOG1_RESET	BIT(4)
+#define IMX_SRC_SRSR_JTAG_RESET		BIT(5)
+#define IMX_SRC_SRSR_JTAG_SW_RESET	BIT(6)
+#define IMX_SRC_SRSR_WDOG3_RESET	BIT(7)
+#define IMX_SRC_SRSR_WDOG4_RESET	BIT(8)
+#define IMX_SRC_SRSR_TEMPSENSE_RESET	BIT(9)
+#define IMX_SRC_SRSR_WARM_BOOT		BIT(16)
+
+void imx_set_reset_reason(void __iomem *srsr);
+
+#endif /* __MACH_RESET_REASON_H__ */
-- 
2.14.3


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

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

* [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 01/10] common: reset_source: Add the notion of "reset source instance" Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 02/10] ARM: i.MX: Add infrastructure to record SoC reset reason Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-16  7:13   ` Sascha Hauer
  2018-04-14 17:50 ` [PATCH 04/10] ARM: i.MX7: " Andrey Smirnov
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx6.c                      | 4 +++-
 arch/arm/mach-imx/include/mach/reset-reason.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index 14a1cba5a..3d81c2785 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -19,6 +19,7 @@
 #include <mach/imx6.h>
 #include <mach/generic.h>
 #include <mach/revision.h>
+#include <mach/reset-reason.h>
 #include <mach/imx6-anadig.h>
 #include <mach/imx6-regs.h>
 #include <mach/generic.h>
@@ -151,6 +152,7 @@ int imx6_init(void)
 {
 	const char *cputypestr;
 	u32 mx6_silicon_revision;
+	void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
 
 	imx6_init_lowlevel();
 
@@ -195,7 +197,7 @@ int imx6_init(void)
 	}
 
 	imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
-
+	imx_set_reset_reason(src + IMX6_SRC_SRSR);
 	imx6_setup_ipu_qos();
 	imx6ul_enet_clk_init();
 
diff --git a/arch/arm/mach-imx/include/mach/reset-reason.h b/arch/arm/mach-imx/include/mach/reset-reason.h
index 96b905303..f65224a55 100644
--- a/arch/arm/mach-imx/include/mach/reset-reason.h
+++ b/arch/arm/mach-imx/include/mach/reset-reason.h
@@ -12,6 +12,8 @@
 #define IMX_SRC_SRSR_TEMPSENSE_RESET	BIT(9)
 #define IMX_SRC_SRSR_WARM_BOOT		BIT(16)
 
+#define IMX6_SRC_SRSR	0x008
+
 void imx_set_reset_reason(void __iomem *srsr);
 
 #endif /* __MACH_RESET_REASON_H__ */
-- 
2.14.3


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

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

* [PATCH 04/10] ARM: i.MX7: Record reset reason as a part of startup
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
                   ` (2 preceding siblings ...)
  2018-04-14 17:50 ` [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-16  7:13   ` Sascha Hauer
  2018-04-14 17:50 ` [PATCH 05/10] common: reset_source: Introduce reset_source_name() Andrey Smirnov
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx7.c                      | 3 +++
 arch/arm/mach-imx/include/mach/reset-reason.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-imx/imx7.c b/arch/arm/mach-imx/imx7.c
index 4eef99c87..a5debd06c 100644
--- a/arch/arm/mach-imx/imx7.c
+++ b/arch/arm/mach-imx/imx7.c
@@ -19,6 +19,7 @@
 #include <mach/imx7.h>
 #include <mach/generic.h>
 #include <mach/revision.h>
+#include <mach/reset-reason.h>
 #include <mach/imx7-regs.h>
 
 void imx7_init_lowlevel(void)
@@ -171,6 +172,7 @@ int imx7_init(void)
 {
 	const char *cputypestr;
 	u32 imx7_silicon_revision;
+	void __iomem *src = IOMEM(MX7_SRC_BASE_ADDR);
 
 	imx7_init_lowlevel();
 
@@ -197,6 +199,7 @@ int imx7_init(void)
 	}
 
 	imx_set_silicon_revision(cputypestr, imx7_silicon_revision);
+	imx_set_reset_reason(src + IMX7_SRC_SRSR);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/include/mach/reset-reason.h b/arch/arm/mach-imx/include/mach/reset-reason.h
index f65224a55..a8a9dc682 100644
--- a/arch/arm/mach-imx/include/mach/reset-reason.h
+++ b/arch/arm/mach-imx/include/mach/reset-reason.h
@@ -13,6 +13,7 @@
 #define IMX_SRC_SRSR_WARM_BOOT		BIT(16)
 
 #define IMX6_SRC_SRSR	0x008
+#define IMX7_SRC_SRSR	0x05c
 
 void imx_set_reset_reason(void __iomem *srsr);
 
-- 
2.14.3


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

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

* [PATCH 05/10] common: reset_source: Introduce reset_source_name()
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
                   ` (3 preceding siblings ...)
  2018-04-14 17:50 ` [PATCH 04/10] ARM: i.MX7: " Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 06/10] ARM: i.MX: Log detected reset reason Andrey Smirnov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Introduce reset_source_name() to get string representation of current
reset source.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 common/reset_source.c  | 6 ++++++
 include/reset_source.h | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/common/reset_source.c b/common/reset_source.c
index 6a6c4f5da..b2985ee85 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -60,6 +60,12 @@ void reset_source_set_priority(enum reset_src_type st, unsigned int priority)
 }
 EXPORT_SYMBOL(reset_source_set_priority);
 
+const char *reset_source_name(void)
+{
+	return reset_src_names[reset_source];
+}
+EXPORT_SYMBOL(reset_source_name)
+
 void reset_source_set_instance(enum reset_src_type type, int instance)
 {
 	if (reset_source == type)
diff --git a/include/reset_source.h b/include/reset_source.h
index c9911c008..f9aed6a7a 100644
--- a/include/reset_source.h
+++ b/include/reset_source.h
@@ -30,6 +30,7 @@ enum reset_src_type reset_source_get(void);
 void reset_source_set_instance(enum reset_src_type type, int instance);
 int reset_source_get_instance(void);
 unsigned int of_get_reset_source_priority(struct device_node *node);
+const char *reset_source_name(void);
 #else
 static inline void reset_source_set_priority(enum reset_src_type type,
 		unsigned int priority)
@@ -54,6 +55,11 @@ static inline unsigned int of_get_reset_source_priority(struct device_node *node
 {
 	return 0;
 }
+
+const char *reset_source_name(void)
+{
+	return "unknown";
+}
 #endif
 
 #define RESET_SOURCE_DEFAULT_PRIORITY 100
-- 
2.14.3


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

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

* [PATCH 06/10] ARM: i.MX: Log detected reset reason
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
                   ` (4 preceding siblings ...)
  2018-04-14 17:50 ` [PATCH 05/10] common: reset_source: Introduce reset_source_name() Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 07/10] ARM: i.MX: Print "revision unknown" if that is the case Andrey Smirnov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Log detected reset reason as well as raw value of SRSR for better
clarity.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
index e860e298a..b7465875e 100644
--- a/arch/arm/mach-imx/imx.c
+++ b/arch/arm/mach-imx/imx.c
@@ -195,4 +195,7 @@ void imx_set_reset_reason(void __iomem *srsr)
 		reset_source_set_instance(type, 2);
 		break;
 	}
+
+	pr_info("i.MX reset reason %s (SRSR: 0x%08x)\n",
+		reset_source_name(), reg);
 }
-- 
2.14.3


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

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

* [PATCH 07/10] ARM: i.MX: Print "revision unknown" if that is the case
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
                   ` (5 preceding siblings ...)
  2018-04-14 17:50 ` [PATCH 06/10] ARM: i.MX: Log detected reset reason Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 08/10] ARM: VFxxx: Add code to detect reset reason Andrey Smirnov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Printing "revision 16.16" if i.MX SoC's revision is unknown is a bit
confusing so modify the code to actually say "revision unknown" in
such a case.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
index b7465875e..fb1160de9 100644
--- a/arch/arm/mach-imx/imx.c
+++ b/arch/arm/mach-imx/imx.c
@@ -31,7 +31,10 @@ void imx_set_silicon_revision(const char *soc, int revision)
 {
 	__imx_silicon_revision = revision;
 
-	pr_info("detected %s revision %d.%d\n", soc,
+	if (revision == IMX_CHIP_REV_UNKNOWN)
+		pr_info("detected %s revision unknown\n", soc);
+	else
+		pr_info("detected %s revision %d.%d\n", soc,
 			(revision >> 4) & 0xf,
 			revision & 0xf);
 }
-- 
2.14.3


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

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

* [PATCH 08/10] ARM: VFxxx: Add code to detect reset reason
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
                   ` (6 preceding siblings ...)
  2018-04-14 17:50 ` [PATCH 07/10] ARM: i.MX: Print "revision unknown" if that is the case Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-16  7:19   ` Sascha Hauer
  2018-04-14 17:50 ` [PATCH 09/10] ARM: VFxxx: Add code to detect cpu variant Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 10/10] ARM: VFxxx: Detect cpu variant and reset source on start Andrey Smirnov
  9 siblings, 1 reply; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/imx.c                       | 78 +++++++++++++++++----------
 arch/arm/mach-imx/include/mach/reset-reason.h | 11 ++++
 2 files changed, 62 insertions(+), 27 deletions(-)

diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
index fb1160de9..e84713766 100644
--- a/arch/arm/mach-imx/imx.c
+++ b/arch/arm/mach-imx/imx.c
@@ -158,6 +158,7 @@ void imx_set_reset_reason(void __iomem *srsr)
 {
 	enum reset_src_type type = RESET_UKWN;
 	const u32 reg = readl(srsr);
+	const bool is_vf610 = cpu_is_vf610();
 
 	/*
 	 * SRSR register captures ALL reset event that occured since
@@ -166,37 +167,60 @@ void imx_set_reset_reason(void __iomem *srsr)
 	 */
 	writel(reg, srsr);
 
-	switch (reg) {
-	case IMX_SRC_SRSR_IPP_RESET: /* FALLTHROUGH */
-	case IMX_SRC_SRSR_IPP_RESET | IMX_SRC_SRSR_WDOG1_RESET:
-		type = RESET_POR;
-		break;
-	case IMX_SRC_SRSR_WDOG3_RESET: /* FALLTHROUGH */
-	case IMX_SRC_SRSR_WDOG4_RESET: /* FALLTHROUGH */
-	case IMX_SRC_SRSR_WDOG1_RESET:
-		type = RESET_WDG;
-		break;
-	case IMX_SRC_SRSR_JTAG_RESET: /* FALLTHROUGH */
-	case IMX_SRC_SRSR_JTAG_SW_RESET:
-		type = RESET_JTAG;
-		break;
-	case IMX_SRC_SRSR_TEMPSENSE_RESET:
-		type = RESET_THERM;
-		break;
-	case IMX_SRC_SRSR_WARM_BOOT:
-		type = RESET_RST;
-		break;
+	if (is_vf610) {
+		/*
+		 * Layout of SRSR on Vybrid is quite different so we
+		 * handle it separately.
+		 */
+		if (reg & VF610_SRC_SRSR_POR_RST) {
+			type = RESET_POR;
+		} else if (reg & VF610_SRC_SRSR_WDOG_xx) {
+			type = RESET_WDG;
+		} else if (reg & VF610_SRC_SRSR_JTAG_RST) {
+			type = RESET_JTAG;
+		} else if (reg & VF610_SRC_SRSR_SW_RST) {
+			type = RESET_RST;
+		} else if (reg & VF610_SRC_SRSR_RESETB) {
+			type = RESET_EXT;
+		}
+	} else {
+		switch (reg) {
+		case IMX_SRC_SRSR_IPP_RESET: /* FALLTHROUGH */
+		case IMX_SRC_SRSR_IPP_RESET | IMX_SRC_SRSR_WDOG1_RESET:
+			type = RESET_POR;
+			break;
+		case IMX_SRC_SRSR_WDOG3_RESET: /* FALLTHROUGH */
+		case IMX_SRC_SRSR_WDOG4_RESET: /* FALLTHROUGH */
+		case IMX_SRC_SRSR_WDOG1_RESET:
+			type = RESET_WDG;
+			break;
+		case IMX_SRC_SRSR_JTAG_RESET: /* FALLTHROUGH */
+		case IMX_SRC_SRSR_JTAG_SW_RESET:
+			type = RESET_JTAG;
+			break;
+		case IMX_SRC_SRSR_TEMPSENSE_RESET:
+			type = RESET_THERM;
+			break;
+		case IMX_SRC_SRSR_WARM_BOOT:
+			type = RESET_RST;
+			break;
+		}
 	}
 
 	reset_source_set(type);
 
-	switch (reg) {
-	case IMX_SRC_SRSR_WDOG3_RESET:
-		reset_source_set_instance(type, 1);
-		break;
-	case IMX_SRC_SRSR_WDOG4_RESET:
-		reset_source_set_instance(type, 2);
-		break;
+	if (is_vf610) {
+		if (reg & VF610_SRC_SRSR_WDOG_M4)
+			reset_source_set_instance(type, 1);
+	} else {
+		switch (reg) {
+		case IMX_SRC_SRSR_WDOG3_RESET:
+			reset_source_set_instance(type, 1);
+			break;
+		case IMX_SRC_SRSR_WDOG4_RESET:
+			reset_source_set_instance(type, 2);
+			break;
+		}
 	}
 
 	pr_info("i.MX reset reason %s (SRSR: 0x%08x)\n",
diff --git a/arch/arm/mach-imx/include/mach/reset-reason.h b/arch/arm/mach-imx/include/mach/reset-reason.h
index a8a9dc682..543fec4a1 100644
--- a/arch/arm/mach-imx/include/mach/reset-reason.h
+++ b/arch/arm/mach-imx/include/mach/reset-reason.h
@@ -14,6 +14,17 @@
 
 #define IMX6_SRC_SRSR	0x008
 #define IMX7_SRC_SRSR	0x05c
+#define VF610_SRC_SRSR	0x008
+
+
+#define VF610_SRC_SRSR_SW_RST		BIT(18)
+#define VF610_SRC_SRSR_RESETB		BIT(7)
+#define VF610_SRC_SRSR_JTAG_RST		BIT(5)
+#define VF610_SRC_SRSR_WDOG_M4		BIT(4)
+#define VF610_SRC_SRSR_WDOG_A5		BIT(3)
+#define VF610_SRC_SRSR_WDOG_xx		(VF610_SRC_SRSR_WDOG_A5 | \
+					 VF610_SRC_SRSR_WDOG_M4)
+#define VF610_SRC_SRSR_POR_RST		BIT(0)
 
 void imx_set_reset_reason(void __iomem *srsr);
 
-- 
2.14.3


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

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

* [PATCH 09/10] ARM: VFxxx: Add code to detect cpu variant
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
                   ` (7 preceding siblings ...)
  2018-04-14 17:50 ` [PATCH 08/10] ARM: VFxxx: Add code to detect reset reason Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  2018-04-14 17:50 ` [PATCH 10/10] ARM: VFxxx: Detect cpu variant and reset source on start Andrey Smirnov
  9 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/include/mach/vf610-regs.h |  3 ++
 arch/arm/mach-imx/include/mach/vf610.h      | 51 +++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 arch/arm/mach-imx/include/mach/vf610.h

diff --git a/arch/arm/mach-imx/include/mach/vf610-regs.h b/arch/arm/mach-imx/include/mach/vf610-regs.h
index 8be220b68..2afdf7edc 100644
--- a/arch/arm/mach-imx/include/mach/vf610-regs.h
+++ b/arch/arm/mach-imx/include/mach/vf610-regs.h
@@ -107,4 +107,7 @@
 #define VF610_MSCM_IRSPRC_CP0_EN	1
 #define VF610_MSCM_IRSPRC_NUM		112
 
+#define VF610_MSCM_CPxCOUNT		0x00c
+#define VF610_MSCM_CPxCFG1		0x014
+
 #endif
diff --git a/arch/arm/mach-imx/include/mach/vf610.h b/arch/arm/mach-imx/include/mach/vf610.h
new file mode 100644
index 000000000..6d00d2e45
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/vf610.h
@@ -0,0 +1,51 @@
+#ifndef __MACH_VF610_H
+#define __MACH_VF610_H
+
+#include <io.h>
+#include <mach/generic.h>
+#include <mach/vf610-regs.h>
+#include <mach/revision.h>
+
+#define VF610_CPUTYPE_VFx10	0x010
+
+#define VF610_CPUTYPE_VF610	0x610
+#define VF610_CPUTYPE_VF600	0x600
+#define VF610_CPUTYPE_VF510	0x510
+#define VF610_CPUTYPE_VF500	0x500
+
+#define VF610_ROM_VERSION_OFFSET	0x80
+
+static inline int __vf610_cpu_type(void)
+{
+	void __iomem *mscm = IOMEM(VF610_MSCM_BASE_ADDR);
+	const u32 cpxcount = readl(mscm + VF610_MSCM_CPxCOUNT);
+	const u32 cpxcfg1  = readl(mscm + VF610_MSCM_CPxCFG1);
+	int cpu_type;
+
+	cpu_type = cpxcount ? VF610_CPUTYPE_VF600 : VF610_CPUTYPE_VF500;
+
+	return cpxcfg1 ? cpu_type | VF610_CPUTYPE_VFx10 : cpu_type;
+}
+
+static inline int vf610_cpu_type(void)
+{
+	if (!cpu_is_vf610())
+		return 0;
+
+	return __vf610_cpu_type();
+}
+
+static inline int vf610_cpu_revision(void)
+{
+	if (!cpu_is_vf610())
+		return IMX_CHIP_REV_UNKNOWN;
+
+	/*
+	 * There doesn't seem to be a documented way of retreiving
+	 * silicon revision on VFxxx cpus, so we just report Mask ROM
+	 * version instead
+	 */
+	return readl(VF610_ROM_VERSION_OFFSET) & 0xff;
+}
+
+#endif
-- 
2.14.3


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

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

* [PATCH 10/10] ARM: VFxxx: Detect cpu variant and reset source on start
  2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
                   ` (8 preceding siblings ...)
  2018-04-14 17:50 ` [PATCH 09/10] ARM: VFxxx: Add code to detect cpu variant Andrey Smirnov
@ 2018-04-14 17:50 ` Andrey Smirnov
  9 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-14 17:50 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-imx/Makefile               |  1 +
 arch/arm/mach-imx/imx.c                  |  2 +-
 arch/arm/mach-imx/include/mach/generic.h |  1 +
 arch/arm/mach-imx/vf610.c                | 50 ++++++++++++++++++++++++++++++++
 4 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-imx/vf610.c

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 8ec846cce..160ed4b08 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_ARCH_IMX6) += imx6.o usb-imx6.o
 CFLAGS_imx6.o := -march=armv7-a
 lwl-$(CONFIG_ARCH_IMX6) += imx6-mmdc.o
 obj-$(CONFIG_ARCH_IMX7) += imx7.o
+obj-$(CONFIG_ARCH_VF610) += vf610.o
 obj-$(CONFIG_ARCH_IMX_XLOAD) += xload.o
 obj-$(CONFIG_IMX_IIM)	+= iim.o
 obj-$(CONFIG_IMX_OCOTP)	+= ocotp.o
diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
index e84713766..174eff037 100644
--- a/arch/arm/mach-imx/imx.c
+++ b/arch/arm/mach-imx/imx.c
@@ -120,7 +120,7 @@ static int imx_init(void)
 	else if (cpu_is_mx7())
 		ret = imx7_init();
 	else if (cpu_is_vf610())
-		ret = 0;
+		ret = vf610_init();
 	else
 		return -EINVAL;
 
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index f68dc875b..cb5675185 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -34,6 +34,7 @@ int imx51_init(void);
 int imx53_init(void);
 int imx6_init(void);
 int imx7_init(void);
+int vf610_init(void);
 
 int imx1_devices_init(void);
 int imx21_devices_init(void);
diff --git a/arch/arm/mach-imx/vf610.c b/arch/arm/mach-imx/vf610.c
new file mode 100644
index 000000000..0ef3e43af
--- /dev/null
+++ b/arch/arm/mach-imx/vf610.c
@@ -0,0 +1,50 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <init.h>
+#include <common.h>
+#include <io.h>
+#include <linux/sizes.h>
+#include <mach/generic.h>
+#include <mach/revision.h>
+#include <mach/reset-reason.h>
+#include <mach/vf610.h>
+
+int vf610_init(void)
+{
+	const char *cputypestr;
+	void __iomem *src = IOMEM(VF610_SRC_BASE_ADDR);
+
+	switch (vf610_cpu_type()) {
+	case VF610_CPUTYPE_VF610:
+		cputypestr = "VF610";
+		break;
+	case VF610_CPUTYPE_VF600:
+		cputypestr = "VF600";
+		break;
+	case VF610_CPUTYPE_VF510:
+		cputypestr = "VF510";
+		break;
+	case VF610_CPUTYPE_VF500:
+		cputypestr = "VF500";
+		break;
+	default:
+		cputypestr = "unknown VFxxx";
+		break;
+	}
+
+	imx_set_silicon_revision(cputypestr, vf610_cpu_revision());
+	imx_set_reset_reason(src + VF610_SRC_SRSR);
+
+	return 0;
+}
-- 
2.14.3


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

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

* Re: [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup
  2018-04-14 17:50 ` [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup Andrey Smirnov
@ 2018-04-16  7:13   ` Sascha Hauer
  2018-04-16 13:28     ` Andrey Smirnov
  0 siblings, 1 reply; 21+ messages in thread
From: Sascha Hauer @ 2018-04-16  7:13 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

Hi Andrey,

On Sat, Apr 14, 2018 at 10:50:17AM -0700, Andrey Smirnov wrote:
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/mach-imx/imx6.c                      | 4 +++-
>  arch/arm/mach-imx/include/mach/reset-reason.h | 2 ++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
> index 14a1cba5a..3d81c2785 100644
> --- a/arch/arm/mach-imx/imx6.c
> +++ b/arch/arm/mach-imx/imx6.c
> @@ -19,6 +19,7 @@
>  #include <mach/imx6.h>
>  #include <mach/generic.h>
>  #include <mach/revision.h>
> +#include <mach/reset-reason.h>
>  #include <mach/imx6-anadig.h>
>  #include <mach/imx6-regs.h>
>  #include <mach/generic.h>
> @@ -151,6 +152,7 @@ int imx6_init(void)
>  {
>  	const char *cputypestr;
>  	u32 mx6_silicon_revision;
> +	void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
>  
>  	imx6_init_lowlevel();
>  
> @@ -195,7 +197,7 @@ int imx6_init(void)
>  	}
>  
>  	imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
> -
> +	imx_set_reset_reason(src + IMX6_SRC_SRSR);

This will get overwritten by the watchdog driver if enabled.

Sascha

-- 
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] 21+ messages in thread

* Re: [PATCH 04/10] ARM: i.MX7: Record reset reason as a part of startup
  2018-04-14 17:50 ` [PATCH 04/10] ARM: i.MX7: " Andrey Smirnov
@ 2018-04-16  7:13   ` Sascha Hauer
  0 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2018-04-16  7:13 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Sat, Apr 14, 2018 at 10:50:18AM -0700, Andrey Smirnov wrote:
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/mach-imx/imx7.c                      | 3 +++
>  arch/arm/mach-imx/include/mach/reset-reason.h | 1 +
>  2 files changed, 4 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/imx7.c b/arch/arm/mach-imx/imx7.c
> index 4eef99c87..a5debd06c 100644
> --- a/arch/arm/mach-imx/imx7.c
> +++ b/arch/arm/mach-imx/imx7.c
> @@ -19,6 +19,7 @@
>  #include <mach/imx7.h>
>  #include <mach/generic.h>
>  #include <mach/revision.h>
> +#include <mach/reset-reason.h>
>  #include <mach/imx7-regs.h>
>  
>  void imx7_init_lowlevel(void)
> @@ -171,6 +172,7 @@ int imx7_init(void)
>  {
>  	const char *cputypestr;
>  	u32 imx7_silicon_revision;
> +	void __iomem *src = IOMEM(MX7_SRC_BASE_ADDR);
>  
>  	imx7_init_lowlevel();
>  
> @@ -197,6 +199,7 @@ int imx7_init(void)
>  	}
>  
>  	imx_set_silicon_revision(cputypestr, imx7_silicon_revision);
> +	imx_set_reset_reason(src + IMX7_SRC_SRSR);

Same here.

Sascha


-- 
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] 21+ messages in thread

* Re: [PATCH 08/10] ARM: VFxxx: Add code to detect reset reason
  2018-04-14 17:50 ` [PATCH 08/10] ARM: VFxxx: Add code to detect reset reason Andrey Smirnov
@ 2018-04-16  7:19   ` Sascha Hauer
  2018-04-16 13:12     ` Andrey Smirnov
  0 siblings, 1 reply; 21+ messages in thread
From: Sascha Hauer @ 2018-04-16  7:19 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Sat, Apr 14, 2018 at 10:50:22AM -0700, Andrey Smirnov wrote:
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/mach-imx/imx.c                       | 78 +++++++++++++++++----------
>  arch/arm/mach-imx/include/mach/reset-reason.h | 11 ++++
>  2 files changed, 62 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
> index fb1160de9..e84713766 100644
> --- a/arch/arm/mach-imx/imx.c
> +++ b/arch/arm/mach-imx/imx.c
> @@ -158,6 +158,7 @@ void imx_set_reset_reason(void __iomem *srsr)
>  {
>  	enum reset_src_type type = RESET_UKWN;
>  	const u32 reg = readl(srsr);
> +	const bool is_vf610 = cpu_is_vf610();
>  
>  	/*
>  	 * SRSR register captures ALL reset event that occured since
> @@ -166,37 +167,60 @@ void imx_set_reset_reason(void __iomem *srsr)
>  	 */
>  	writel(reg, srsr);
>  
> -	switch (reg) {
> -	case IMX_SRC_SRSR_IPP_RESET: /* FALLTHROUGH */
> -	case IMX_SRC_SRSR_IPP_RESET | IMX_SRC_SRSR_WDOG1_RESET:
> -		type = RESET_POR;
> -		break;
> -	case IMX_SRC_SRSR_WDOG3_RESET: /* FALLTHROUGH */
> -	case IMX_SRC_SRSR_WDOG4_RESET: /* FALLTHROUGH */
> -	case IMX_SRC_SRSR_WDOG1_RESET:
> -		type = RESET_WDG;
> -		break;
> -	case IMX_SRC_SRSR_JTAG_RESET: /* FALLTHROUGH */
> -	case IMX_SRC_SRSR_JTAG_SW_RESET:
> -		type = RESET_JTAG;
> -		break;
> -	case IMX_SRC_SRSR_TEMPSENSE_RESET:
> -		type = RESET_THERM;
> -		break;
> -	case IMX_SRC_SRSR_WARM_BOOT:
> -		type = RESET_RST;
> -		break;
> +	if (is_vf610) {

The caller already knows this is a vf610 and the code path for vf610 is
completely different. Please add a vf610_set_reset_reason() instead of
clobbering the i.MX function with this.

Sascha


-- 
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] 21+ messages in thread

* Re: [PATCH 08/10] ARM: VFxxx: Add code to detect reset reason
  2018-04-16  7:19   ` Sascha Hauer
@ 2018-04-16 13:12     ` Andrey Smirnov
  0 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-16 13:12 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On Mon, Apr 16, 2018 at 12:19 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Sat, Apr 14, 2018 at 10:50:22AM -0700, Andrey Smirnov wrote:
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>>  arch/arm/mach-imx/imx.c                       | 78 +++++++++++++++++----------
>>  arch/arm/mach-imx/include/mach/reset-reason.h | 11 ++++
>>  2 files changed, 62 insertions(+), 27 deletions(-)
>>
>> diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
>> index fb1160de9..e84713766 100644
>> --- a/arch/arm/mach-imx/imx.c
>> +++ b/arch/arm/mach-imx/imx.c
>> @@ -158,6 +158,7 @@ void imx_set_reset_reason(void __iomem *srsr)
>>  {
>>       enum reset_src_type type = RESET_UKWN;
>>       const u32 reg = readl(srsr);
>> +     const bool is_vf610 = cpu_is_vf610();
>>
>>       /*
>>        * SRSR register captures ALL reset event that occured since
>> @@ -166,37 +167,60 @@ void imx_set_reset_reason(void __iomem *srsr)
>>        */
>>       writel(reg, srsr);
>>
>> -     switch (reg) {
>> -     case IMX_SRC_SRSR_IPP_RESET: /* FALLTHROUGH */
>> -     case IMX_SRC_SRSR_IPP_RESET | IMX_SRC_SRSR_WDOG1_RESET:
>> -             type = RESET_POR;
>> -             break;
>> -     case IMX_SRC_SRSR_WDOG3_RESET: /* FALLTHROUGH */
>> -     case IMX_SRC_SRSR_WDOG4_RESET: /* FALLTHROUGH */
>> -     case IMX_SRC_SRSR_WDOG1_RESET:
>> -             type = RESET_WDG;
>> -             break;
>> -     case IMX_SRC_SRSR_JTAG_RESET: /* FALLTHROUGH */
>> -     case IMX_SRC_SRSR_JTAG_SW_RESET:
>> -             type = RESET_JTAG;
>> -             break;
>> -     case IMX_SRC_SRSR_TEMPSENSE_RESET:
>> -             type = RESET_THERM;
>> -             break;
>> -     case IMX_SRC_SRSR_WARM_BOOT:
>> -             type = RESET_RST;
>> -             break;
>> +     if (is_vf610) {
>
> The caller already knows this is a vf610 and the code path for vf610 is
> completely different. Please add a vf610_set_reset_reason() instead of
> clobbering the i.MX function with this.
>

They do share code fore clearing RSRS register, but sure, will do in v2.

Thanks,
Andrey Smirnov

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

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

* Re: [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup
  2018-04-16  7:13   ` Sascha Hauer
@ 2018-04-16 13:28     ` Andrey Smirnov
  2018-04-17  6:49       ` Sascha Hauer
  0 siblings, 1 reply; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-16 13:28 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On Mon, Apr 16, 2018 at 12:13 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> Hi Andrey,
>
> On Sat, Apr 14, 2018 at 10:50:17AM -0700, Andrey Smirnov wrote:
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>>  arch/arm/mach-imx/imx6.c                      | 4 +++-
>>  arch/arm/mach-imx/include/mach/reset-reason.h | 2 ++
>>  2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
>> index 14a1cba5a..3d81c2785 100644
>> --- a/arch/arm/mach-imx/imx6.c
>> +++ b/arch/arm/mach-imx/imx6.c
>> @@ -19,6 +19,7 @@
>>  #include <mach/imx6.h>
>>  #include <mach/generic.h>
>>  #include <mach/revision.h>
>> +#include <mach/reset-reason.h>
>>  #include <mach/imx6-anadig.h>
>>  #include <mach/imx6-regs.h>
>>  #include <mach/generic.h>
>> @@ -151,6 +152,7 @@ int imx6_init(void)
>>  {
>>       const char *cputypestr;
>>       u32 mx6_silicon_revision;
>> +     void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
>>
>>       imx6_init_lowlevel();
>>
>> @@ -195,7 +197,7 @@ int imx6_init(void)
>>       }
>>
>>       imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
>> -
>> +     imx_set_reset_reason(src + IMX6_SRC_SRSR);
>
> This will get overwritten by the watchdog driver if enabled.
>

I am not sure I see how. Imx_watchdog_detect_reset_source() reports
reset sources with the same priority as this code, so
reset_source_set_priority() should bail out early without changing
anything in that case.

Regardless, even if it were true, I think that behavior is perfectly
OK. First of all, startup log will still be present, which is IMHO
pretty useful. Second, the platforms that doen't use/rely on built-in
watchdog would benefit from this.

Another thing we can do is add code to respect "reset-source-priority"
to imxwd.c, so that people could ajdust what reset source info they
want to see via DT.

Let me know what you think.

Thanks,
Andrey Smirnov

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

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

* Re: [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup
  2018-04-16 13:28     ` Andrey Smirnov
@ 2018-04-17  6:49       ` Sascha Hauer
  2018-04-17 15:35         ` Andrey Smirnov
  0 siblings, 1 reply; 21+ messages in thread
From: Sascha Hauer @ 2018-04-17  6:49 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

On Mon, Apr 16, 2018 at 06:28:11AM -0700, Andrey Smirnov wrote:
> On Mon, Apr 16, 2018 at 12:13 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > Hi Andrey,
> >
> > On Sat, Apr 14, 2018 at 10:50:17AM -0700, Andrey Smirnov wrote:
> >> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> >> ---
> >>  arch/arm/mach-imx/imx6.c                      | 4 +++-
> >>  arch/arm/mach-imx/include/mach/reset-reason.h | 2 ++
> >>  2 files changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
> >> index 14a1cba5a..3d81c2785 100644
> >> --- a/arch/arm/mach-imx/imx6.c
> >> +++ b/arch/arm/mach-imx/imx6.c
> >> @@ -19,6 +19,7 @@
> >>  #include <mach/imx6.h>
> >>  #include <mach/generic.h>
> >>  #include <mach/revision.h>
> >> +#include <mach/reset-reason.h>
> >>  #include <mach/imx6-anadig.h>
> >>  #include <mach/imx6-regs.h>
> >>  #include <mach/generic.h>
> >> @@ -151,6 +152,7 @@ int imx6_init(void)
> >>  {
> >>       const char *cputypestr;
> >>       u32 mx6_silicon_revision;
> >> +     void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
> >>
> >>       imx6_init_lowlevel();
> >>
> >> @@ -195,7 +197,7 @@ int imx6_init(void)
> >>       }
> >>
> >>       imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
> >> -
> >> +     imx_set_reset_reason(src + IMX6_SRC_SRSR);
> >
> > This will get overwritten by the watchdog driver if enabled.
> >
> 
> I am not sure I see how. Imx_watchdog_detect_reset_source() reports
> reset sources with the same priority as this code, so
> reset_source_set_priority() should bail out early without changing
> anything in that case.

I wasn't aware there is a priority mechanism involved. Indeed the
behaviour seems to be correct. Maybe we should even higher the priority
of imx_set_reset_reason()? This information seems the more accurate one,
so it should be used, and we shouldn't depend on the order of execution.

Sascha

-- 
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] 21+ messages in thread

* Re: [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup
  2018-04-17  6:49       ` Sascha Hauer
@ 2018-04-17 15:35         ` Andrey Smirnov
  2018-04-18  8:23           ` Sascha Hauer
  0 siblings, 1 reply; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-17 15:35 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On Mon, Apr 16, 2018 at 11:49 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Apr 16, 2018 at 06:28:11AM -0700, Andrey Smirnov wrote:
>> On Mon, Apr 16, 2018 at 12:13 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> > Hi Andrey,
>> >
>> > On Sat, Apr 14, 2018 at 10:50:17AM -0700, Andrey Smirnov wrote:
>> >> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> >> ---
>> >>  arch/arm/mach-imx/imx6.c                      | 4 +++-
>> >>  arch/arm/mach-imx/include/mach/reset-reason.h | 2 ++
>> >>  2 files changed, 5 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
>> >> index 14a1cba5a..3d81c2785 100644
>> >> --- a/arch/arm/mach-imx/imx6.c
>> >> +++ b/arch/arm/mach-imx/imx6.c
>> >> @@ -19,6 +19,7 @@
>> >>  #include <mach/imx6.h>
>> >>  #include <mach/generic.h>
>> >>  #include <mach/revision.h>
>> >> +#include <mach/reset-reason.h>
>> >>  #include <mach/imx6-anadig.h>
>> >>  #include <mach/imx6-regs.h>
>> >>  #include <mach/generic.h>
>> >> @@ -151,6 +152,7 @@ int imx6_init(void)
>> >>  {
>> >>       const char *cputypestr;
>> >>       u32 mx6_silicon_revision;
>> >> +     void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
>> >>
>> >>       imx6_init_lowlevel();
>> >>
>> >> @@ -195,7 +197,7 @@ int imx6_init(void)
>> >>       }
>> >>
>> >>       imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
>> >> -
>> >> +     imx_set_reset_reason(src + IMX6_SRC_SRSR);
>> >
>> > This will get overwritten by the watchdog driver if enabled.
>> >
>>
>> I am not sure I see how. Imx_watchdog_detect_reset_source() reports
>> reset sources with the same priority as this code, so
>> reset_source_set_priority() should bail out early without changing
>> anything in that case.
>
> I wasn't aware there is a priority mechanism involved. Indeed the
> behaviour seems to be correct. Maybe we should even higher the priority
> of imx_set_reset_reason()? This information seems the more accurate one,
> so it should be used, and we shouldn't depend on the order of execution.
>

I think if I add support for "reset-source-priority" to imxwd.c and
set it up to use the value less then RESET_SOURCE_DEFAULT_PRIORITY by
default we can get both what you describe and allow users to override
the behavior and prioritize reset source provided by watchdog driver.

Let me know if this sounds like a bad idea.

Thanks,
Andrey Smirnov

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

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

* Re: [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup
  2018-04-17 15:35         ` Andrey Smirnov
@ 2018-04-18  8:23           ` Sascha Hauer
  0 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2018-04-18  8:23 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

On Tue, Apr 17, 2018 at 08:35:12AM -0700, Andrey Smirnov wrote:
> On Mon, Apr 16, 2018 at 11:49 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > On Mon, Apr 16, 2018 at 06:28:11AM -0700, Andrey Smirnov wrote:
> >> On Mon, Apr 16, 2018 at 12:13 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >> >> @@ -151,6 +152,7 @@ int imx6_init(void)
> >> >>  {
> >> >>       const char *cputypestr;
> >> >>       u32 mx6_silicon_revision;
> >> >> +     void __iomem *src = IOMEM(MX6_SRC_BASE_ADDR);
> >> >>
> >> >>       imx6_init_lowlevel();
> >> >>
> >> >> @@ -195,7 +197,7 @@ int imx6_init(void)
> >> >>       }
> >> >>
> >> >>       imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
> >> >> -
> >> >> +     imx_set_reset_reason(src + IMX6_SRC_SRSR);
> >> >
> >> > This will get overwritten by the watchdog driver if enabled.
> >> >
> >>
> >> I am not sure I see how. Imx_watchdog_detect_reset_source() reports
> >> reset sources with the same priority as this code, so
> >> reset_source_set_priority() should bail out early without changing
> >> anything in that case.
> >
> > I wasn't aware there is a priority mechanism involved. Indeed the
> > behaviour seems to be correct. Maybe we should even higher the priority
> > of imx_set_reset_reason()? This information seems the more accurate one,
> > so it should be used, and we shouldn't depend on the order of execution.
> >
> 
> I think if I add support for "reset-source-priority" to imxwd.c and
> set it up to use the value less then RESET_SOURCE_DEFAULT_PRIORITY by
> default we can get both what you describe and allow users to override
> the behavior and prioritize reset source provided by watchdog driver.
> 
> Let me know if this sounds like a bad idea.

It doesn't sound like a bad idea, I'm just not convinced it's a good
idea ;)

Reading the SRC registers seems to give us more accurate informations
than reading the watchdog. Provided this is true I don't see a reason to
make the priority configurable. If it was only for i.MX6/7 I would say,
we could remove the reset source detection from the watchdog driver
entirely, but we need the informations from the driver on older SoCs.

Anyway, before making this configurable I think it's better to wait
until somebody to show up who really needs this (and thus can explain
the reasons), rather than to just add it in case it might be useful.

Sascha

-- 
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] 21+ messages in thread

* Re: [PATCH 02/10] ARM: i.MX: Add infrastructure to record SoC reset reason
  2018-04-14 17:50 ` [PATCH 02/10] ARM: i.MX: Add infrastructure to record SoC reset reason Andrey Smirnov
@ 2018-04-18 15:23   ` Philipp Zabel
  2018-04-19 22:19     ` Andrey Smirnov
  0 siblings, 1 reply; 21+ messages in thread
From: Philipp Zabel @ 2018-04-18 15:23 UTC (permalink / raw)
  To: Andrey Smirnov, barebox

On Sat, 2018-04-14 at 10:50 -0700, Andrey Smirnov wrote:
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/mach-imx/imx.c                       | 49 +++++++++++++++++++++++++++
>  arch/arm/mach-imx/include/mach/reset-reason.h | 17 ++++++++++
>  2 files changed, 66 insertions(+)
>  create mode 100644 arch/arm/mach-imx/include/mach/reset-reason.h
> 
> diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
> index 9400105c6..e860e298a 100644
> --- a/arch/arm/mach-imx/imx.c
> +++ b/arch/arm/mach-imx/imx.c
> @@ -14,8 +14,11 @@
>  #include <common.h>
>  #include <of.h>
>  #include <init.h>
> +#include <io.h>
>  #include <mach/revision.h>
> +#include <mach/reset-reason.h>
>  #include <mach/generic.h>
> +#include <reset_source.h>
>  
>  static int __imx_silicon_revision = IMX_CHIP_REV_UNKNOWN;
>  
> @@ -147,3 +150,49 @@ static int imx_init(void)
>  	return ret;
>  }
>  postcore_initcall(imx_init);
> +
> +void imx_set_reset_reason(void __iomem *srsr)
> +{
> +	enum reset_src_type type = RESET_UKWN;
> +	const u32 reg = readl(srsr);
> +
> +	/*
> +	 * SRSR register captures ALL reset event that occured since
> +	 * POR, so we need to clear it to make sure we only caputre
> +	 * the latest one.
> +	 */
> +	writel(reg, srsr);

What if, say, both a watchdog and the tempsense reset have triggered
since last POR (or since last clearing of SRSR)?
In that case we'll report RESET_UKWN *and* throw away the SRSR
information here.

regards
Philipp

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

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

* Re: [PATCH 02/10] ARM: i.MX: Add infrastructure to record SoC reset reason
  2018-04-18 15:23   ` Philipp Zabel
@ 2018-04-19 22:19     ` Andrey Smirnov
  0 siblings, 0 replies; 21+ messages in thread
From: Andrey Smirnov @ 2018-04-19 22:19 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: Barebox List

On Wed, Apr 18, 2018 at 8:23 AM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> On Sat, 2018-04-14 at 10:50 -0700, Andrey Smirnov wrote:
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>>  arch/arm/mach-imx/imx.c                       | 49 +++++++++++++++++++++++++++
>>  arch/arm/mach-imx/include/mach/reset-reason.h | 17 ++++++++++
>>  2 files changed, 66 insertions(+)
>>  create mode 100644 arch/arm/mach-imx/include/mach/reset-reason.h
>>
>> diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
>> index 9400105c6..e860e298a 100644
>> --- a/arch/arm/mach-imx/imx.c
>> +++ b/arch/arm/mach-imx/imx.c
>> @@ -14,8 +14,11 @@
>>  #include <common.h>
>>  #include <of.h>
>>  #include <init.h>
>> +#include <io.h>
>>  #include <mach/revision.h>
>> +#include <mach/reset-reason.h>
>>  #include <mach/generic.h>
>> +#include <reset_source.h>
>>
>>  static int __imx_silicon_revision = IMX_CHIP_REV_UNKNOWN;
>>
>> @@ -147,3 +150,49 @@ static int imx_init(void)
>>       return ret;
>>  }
>>  postcore_initcall(imx_init);
>> +
>> +void imx_set_reset_reason(void __iomem *srsr)
>> +{
>> +     enum reset_src_type type = RESET_UKWN;
>> +     const u32 reg = readl(srsr);
>> +
>> +     /*
>> +      * SRSR register captures ALL reset event that occured since
>> +      * POR, so we need to clear it to make sure we only caputre
>> +      * the latest one.
>> +      */
>> +     writel(reg, srsr);
>
> What if, say, both a watchdog and the tempsense reset have triggered
> since last POR (or since last clearing of SRSR)?
> In that case we'll report RESET_UKWN *and* throw away the SRSR
> information here.
>

I am assuming we are talking about the fact that "reg" is decoded
using switch statement, as opposed to doing bitmaksing (like VFxxx
code does). I got the code form U-Boot and that is how it's doing the
decoding, but you are right it is going to be problematic for use-case
you describe.

I'll switch the code to do bitmaksing instead.

Thanks,
Andrey Smrinov

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

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

end of thread, other threads:[~2018-04-19 22:19 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-14 17:50 [PATCH 00/10] i.MX reset reason detection support Andrey Smirnov
2018-04-14 17:50 ` [PATCH 01/10] common: reset_source: Add the notion of "reset source instance" Andrey Smirnov
2018-04-14 17:50 ` [PATCH 02/10] ARM: i.MX: Add infrastructure to record SoC reset reason Andrey Smirnov
2018-04-18 15:23   ` Philipp Zabel
2018-04-19 22:19     ` Andrey Smirnov
2018-04-14 17:50 ` [PATCH 03/10] ARM: i.MX6: Record reset reason as a part of startup Andrey Smirnov
2018-04-16  7:13   ` Sascha Hauer
2018-04-16 13:28     ` Andrey Smirnov
2018-04-17  6:49       ` Sascha Hauer
2018-04-17 15:35         ` Andrey Smirnov
2018-04-18  8:23           ` Sascha Hauer
2018-04-14 17:50 ` [PATCH 04/10] ARM: i.MX7: " Andrey Smirnov
2018-04-16  7:13   ` Sascha Hauer
2018-04-14 17:50 ` [PATCH 05/10] common: reset_source: Introduce reset_source_name() Andrey Smirnov
2018-04-14 17:50 ` [PATCH 06/10] ARM: i.MX: Log detected reset reason Andrey Smirnov
2018-04-14 17:50 ` [PATCH 07/10] ARM: i.MX: Print "revision unknown" if that is the case Andrey Smirnov
2018-04-14 17:50 ` [PATCH 08/10] ARM: VFxxx: Add code to detect reset reason Andrey Smirnov
2018-04-16  7:19   ` Sascha Hauer
2018-04-16 13:12     ` Andrey Smirnov
2018-04-14 17:50 ` [PATCH 09/10] ARM: VFxxx: Add code to detect cpu variant Andrey Smirnov
2018-04-14 17:50 ` [PATCH 10/10] ARM: VFxxx: Detect cpu variant and reset source on start Andrey Smirnov

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