blob: 104e986f944a8be5912f6b6078ed3398cffbf827 [file] [log] [blame]
Jan Kundrátbe552612018-05-21 22:45:32 +02001diff --git a/arch/arm/dts/armada-388-clearfog.dts b/arch/arm/dts/armada-388-clearfog.dts
2index bc52bc0167..177cb4cd25 100644
3--- a/arch/arm/dts/armada-388-clearfog.dts
4+++ b/arch/arm/dts/armada-388-clearfog.dts
5@@ -90,13 +90,10 @@
6 internal-regs {
7 ethernet@30000 {
8 mac-address = [00 50 43 02 02 02];
9+ managed = "in-band-status";
10+ phy = <&phy1>;
11 phy-mode = "sgmii";
12 status = "okay";
13-
14- fixed-link {
15- speed = <1000>;
16- full-duplex;
17- };
18 };
19
20 ethernet@34000 {
21@@ -228,6 +225,10 @@
22 pinctrl-0 = <&mdio_pins>;
23 pinctrl-names = "default";
24
25+ phy1: ethernet-phy@1 { /* Marvell 88E1512 */
26+ reg = <1>;
27+ };
28+
29 phy_dedicated: ethernet-phy@0 {
30 /*
31 * Annoyingly, the marvell phy driver
32@@ -384,62 +385,6 @@
33 tx-fault-gpio = <&expander0 13 GPIO_ACTIVE_HIGH>;
34 };
35
36- dsa@0 {
37- compatible = "marvell,dsa";
38- dsa,ethernet = <&eth1>;
39- dsa,mii-bus = <&mdio>;
40- pinctrl-0 = <&clearfog_dsa0_clk_pins &clearfog_dsa0_pins>;
41- pinctrl-names = "default";
42- #address-cells = <2>;
43- #size-cells = <0>;
44-
45- switch@0 {
46- #address-cells = <1>;
47- #size-cells = <0>;
48- reg = <4 0>;
49-
50- port@0 {
51- reg = <0>;
52- label = "lan1";
53- };
54-
55- port@1 {
56- reg = <1>;
57- label = "lan2";
58- };
59-
60- port@2 {
61- reg = <2>;
62- label = "lan3";
63- };
64-
65- port@3 {
66- reg = <3>;
67- label = "lan4";
68- };
69-
70- port@4 {
71- reg = <4>;
72- label = "lan5";
73- };
74-
75- port@5 {
76- reg = <5>;
77- label = "cpu";
78- };
79-
80- port@6 {
81- /* 88E1512 external phy */
82- reg = <6>;
83- label = "lan6";
84- fixed-link {
85- speed = <1000>;
86- full-duplex;
87- };
88- };
89- };
90- };
91-
92 gpio-keys {
93 compatible = "gpio-keys";
94 pinctrl-0 = <&rear_button_pins>;
Jan Kundrát04d102b2017-10-19 12:04:06 +020095diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
Jan Kundrátbe552612018-05-21 22:45:32 +020096index ede303d4eb..e5abda6f76 100644
Jan Kundrát04d102b2017-10-19 12:04:06 +020097--- a/board/solidrun/clearfog/clearfog.c
98+++ b/board/solidrun/clearfog/clearfog.c
Jan Kundrátbe552612018-05-21 22:45:32 +020099@@ -10,10 +10,15 @@
Jan Kundrát04d102b2017-10-19 12:04:06 +0200100 #include <asm/io.h>
101 #include <asm/arch/cpu.h>
102 #include <asm/arch/soc.h>
103+#include <dm/uclass.h>
104
Jan Kundrátbe552612018-05-21 22:45:32 +0200105 #include "../drivers/ddr/marvell/a38x/ddr3_init.h"
Jan Kundrát04d102b2017-10-19 12:04:06 +0200106 #include <../serdes/a38x/high_speed_env_spec.h>
107
108+#ifdef CONFIG_WDT_ORION
109+# include <wdt.h>
110+#endif
111+
112 DECLARE_GLOBAL_DATA_PTR;
113
114 #define ETH_PHY_CTRL_REG 0
Jan Kundrátbe552612018-05-21 22:45:32 +0200115@@ -124,6 +129,10 @@ int board_early_init_f(void)
Jan Kundrát04d102b2017-10-19 12:04:06 +0200116 return 0;
117 }
118
119+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION)
120+static struct udevice *watchdog_dev = NULL;
121+#endif
122+
123 int board_init(void)
124 {
125 int i;
Jan Kundrátbe552612018-05-21 22:45:32 +0200126@@ -131,6 +140,18 @@ int board_init(void)
Jan Kundrát04d102b2017-10-19 12:04:06 +0200127 /* Address of boot parameters */
128 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
129
130+#ifndef CONFIG_SPL_BUILD
131+# ifdef CONFIG_WDT_ORION
132+ if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
133+ puts("Cannot find Armada 385 watchdog!\n");
134+ } else {
135+ puts("Enabling Armada 385 watchdog.\n");
136+ /* one minute */
137+ wdt_start(watchdog_dev, (u32) 25000000 * 60, 0);
138+ }
139+# endif
140+#endif
141+
142 /* Toggle GPIO41 to reset onboard switch and phy */
143 clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
144 clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9));
Jan Kundrátbe552612018-05-21 22:45:32 +0200145@@ -149,6 +170,28 @@ int board_init(void)
Jan Kundrát04d102b2017-10-19 12:04:06 +0200146 return 0;
147 }
148
149+#ifdef CONFIG_WATCHDOG
150+/* Called by macro WATCHDOG_RESET */
151+void watchdog_reset(void)
152+{
153+# if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION)
154+ static ulong next_reset = 0;
155+ ulong now;
156+
157+ if (!watchdog_dev)
158+ return;
159+
160+ now = timer_get_us();
161+
162+ /* Do not reset the watchdog too often */
163+ if (now > next_reset) {
164+ wdt_reset(watchdog_dev);
165+ next_reset = now + 1000;
166+ }
167+# endif
168+}
169+#endif
170+
171 int checkboard(void)
172 {
173 puts("Board: SolidRun ClearFog\n");
174diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig
Jan Kundrátbe552612018-05-21 22:45:32 +0200175index 5e1733e11b..4af2d1e902 100644
Jan Kundrát04d102b2017-10-19 12:04:06 +0200176--- a/configs/clearfog_defconfig
177+++ b/configs/clearfog_defconfig
Jan Kundrátbe552612018-05-21 22:45:32 +0200178@@ -53,3 +53,5 @@ CONFIG_USB=y
Jan Kundrát04d102b2017-10-19 12:04:06 +0200179 CONFIG_DM_USB=y
Jan Kundrát6fa87502018-01-12 15:09:58 +0100180 CONFIG_USB_XHCI_HCD=y
Jan Kundrát04d102b2017-10-19 12:04:06 +0200181 CONFIG_USB_STORAGE=y
182+CONFIG_WDT=y
183+CONFIG_WDT_ORION=y
184diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h
Jan Kundrátbc1236c2018-06-05 12:30:58 +0200185index f57f9b21ab..870bac78f4 100644
Jan Kundrát04d102b2017-10-19 12:04:06 +0200186--- a/include/configs/clearfog.h
187+++ b/include/configs/clearfog.h
Jan Kundrátbc1236c2018-06-05 12:30:58 +0200188@@ -25,9 +25,15 @@
189 #define CONFIG_SYS_I2C
190 #define CONFIG_SYS_I2C_MVTWSI
191 #define CONFIG_I2C_MVTWSI_BASE0 MVEBU_TWSI_BASE
192+#define CONFIG_I2C_MVTWSI_BASE1 MVEBU_TWSI1_BASE
Jan Kundrát04d102b2017-10-19 12:04:06 +0200193 #define CONFIG_SYS_I2C_SLAVE 0x0
194 #define CONFIG_SYS_I2C_SPEED 100000
195
196+/* Watchdog */
197+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION)
198+# define CONFIG_WATCHDOG
199+#endif
200+
201 /* SPI NOR flash default params, used by sf commands */
Jan Kundrát6fa87502018-01-12 15:09:58 +0100202 #define CONFIG_SF_DEFAULT_BUS 1
203
Jan Kundrátbc1236c2018-06-05 12:30:58 +0200204@@ -54,6 +60,9 @@
Jan Kundrát04d102b2017-10-19 12:04:06 +0200205 #define CONFIG_ENV_OFFSET 0xf0000
206 #define CONFIG_ENV_ADDR CONFIG_ENV_OFFSET
207
208+#define CONFIG_ENV_OFFSET_REDUND 0xe0000
209+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
210+
Jan Kundrát04d102b2017-10-19 12:04:06 +0200211 #define PHY_ANEG_TIMEOUT 8000 /* PHY needs a longer aneg time */
212
Jan Kundrátbe552612018-05-21 22:45:32 +0200213 /* PCIe support */
Jan Kundrátbc1236c2018-06-05 12:30:58 +0200214@@ -149,14 +158,45 @@
Jan Kundrátbe552612018-05-21 22:45:32 +0200215 "scriptaddr=" SCRIPT_ADDR_R "\0" \
Jan Kundrát04d102b2017-10-19 12:04:06 +0200216 "pxefile_addr_r=" PXEFILE_ADDR_R "\0"
217
218-#include <config_distro_bootcmd.h>
219-
220 #define CONFIG_EXTRA_ENV_SETTINGS \
221 RELOCATION_LIMITS_ENV_SETTINGS \
222 LOAD_ADDRESS_ENV_SETTINGS \
223- "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
224 "console=ttyS0,115200\0" \
225- BOOTENV
Jan Kundrátbe552612018-05-21 22:45:32 +0200226+ "usbboot=usb start; fatload usb 0:1 ${scriptaddr} boot.scr; source ${scriptaddr}\0" \
Jan Kundrát04d102b2017-10-19 12:04:06 +0200227+ "bootcmd=test -n \"${BOOT_A_LEFT}\" || setenv BOOT_A_LEFT 3;" \
228+ "test -n \"${BOOT_B_LEFT}\" || setenv BOOT_B_LEFT 3;" \
Jan Kundráta98768a2017-10-20 17:08:23 +0200229+ "test -n \"${BOOT_ORDER}\" || setenv BOOT_ORDER \"A B\";" \
Jan Kundrát04d102b2017-10-19 12:04:06 +0200230+ "setenv rauc_part;" \
Jan Kundráta98768a2017-10-20 17:08:23 +0200231+ "for BOOT_SLOT in \"${BOOT_ORDER}\"; do" \
Jan Kundrát04d102b2017-10-19 12:04:06 +0200232+ " if test \"x${rauc_part}\" != \"x\"; then" \
233+ " ;" \
234+ " elif test \"x${BOOT_SLOT}\" = \"xA\"; then" \
235+ " if test ${BOOT_A_LEFT} -gt 0; then" \
236+ " setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1;" \
237+ " echo \"Found valid slot A, ${BOOT_A_LEFT} attempts remaining\";" \
238+ " setenv rauc_part 1;" \
239+ " setenv rauc_slot A;" \
240+ " fi;" \
241+ " elif test \"x${BOOT_SLOT}\" = \"xB\"; then" \
242+ " if test ${BOOT_B_LEFT} -gt 0; then" \
243+ " setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1;" \
244+ " echo \"Found valid slot B, ${BOOT_B_LEFT} attempts remaining\";" \
Jan Kundrátb425ea82017-10-19 17:56:36 +0200245+ " setenv rauc_part 3;" \
Jan Kundrát04d102b2017-10-19 12:04:06 +0200246+ " setenv rauc_slot B;" \
247+ " fi;" \
248+ " fi;" \
249+ "done;" \
250+ "if test -n \"${rauc_part}\"; then" \
251+ " saveenv ;" \
252+ "else" \
253+ " echo \"No valid slot found, resetting tries to 3\";" \
254+ " setenv BOOT_A_LEFT 3;" \
255+ " setenv BOOT_B_LEFT 3;" \
256+ " saveenv;" \
257+ " reset;" \
258+ "fi;" \
Jan Kundrátbe552612018-05-21 22:45:32 +0200259+ "load mmc 0:${rauc_part} ${scriptaddr} /boot/boot.scr || reset;" \
260+ "source ${scriptaddr} || reset\0"
Jan Kundrát04d102b2017-10-19 12:04:06 +0200261
262 #endif /* CONFIG_SPL_BUILD */
263