Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 1 | diff --git a/arch/arm/dts/armada-388-clearfog.dts b/arch/arm/dts/armada-388-clearfog.dts |
| 2 | index 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 = <ð1>; |
| 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át | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 95 | diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 96 | index ede303d4eb..e5abda6f76 100644 |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 97 | --- a/board/solidrun/clearfog/clearfog.c |
| 98 | +++ b/board/solidrun/clearfog/clearfog.c |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 99 | @@ -10,10 +10,15 @@ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 100 | #include <asm/io.h> |
| 101 | #include <asm/arch/cpu.h> |
| 102 | #include <asm/arch/soc.h> |
| 103 | +#include <dm/uclass.h> |
| 104 | |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 105 | #include "../drivers/ddr/marvell/a38x/ddr3_init.h" |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 106 | #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át | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 115 | @@ -124,6 +129,10 @@ int board_early_init_f(void) |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 116 | 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át | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 126 | @@ -131,6 +140,18 @@ int board_init(void) |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 127 | /* 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át | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 145 | @@ -149,6 +170,28 @@ int board_init(void) |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 146 | 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"); |
| 174 | diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 175 | index 5e1733e11b..4af2d1e902 100644 |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 176 | --- a/configs/clearfog_defconfig |
| 177 | +++ b/configs/clearfog_defconfig |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 178 | @@ -53,3 +53,5 @@ CONFIG_USB=y |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 179 | CONFIG_DM_USB=y |
Jan Kundrát | 6fa8750 | 2018-01-12 15:09:58 +0100 | [diff] [blame] | 180 | CONFIG_USB_XHCI_HCD=y |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 181 | CONFIG_USB_STORAGE=y |
| 182 | +CONFIG_WDT=y |
| 183 | +CONFIG_WDT_ORION=y |
| 184 | diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 185 | index f57f9b21ab..9d14c320a9 100644 |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 186 | --- a/include/configs/clearfog.h |
| 187 | +++ b/include/configs/clearfog.h |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 188 | @@ -28,6 +28,11 @@ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 189 | #define CONFIG_SYS_I2C_SLAVE 0x0 |
| 190 | #define CONFIG_SYS_I2C_SPEED 100000 |
| 191 | |
| 192 | +/* Watchdog */ |
| 193 | +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION) |
| 194 | +# define CONFIG_WATCHDOG |
| 195 | +#endif |
| 196 | + |
| 197 | /* SPI NOR flash default params, used by sf commands */ |
Jan Kundrát | 6fa8750 | 2018-01-12 15:09:58 +0100 | [diff] [blame] | 198 | #define CONFIG_SF_DEFAULT_BUS 1 |
| 199 | |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 200 | @@ -54,6 +59,9 @@ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 201 | #define CONFIG_ENV_OFFSET 0xf0000 |
| 202 | #define CONFIG_ENV_ADDR CONFIG_ENV_OFFSET |
| 203 | |
| 204 | +#define CONFIG_ENV_OFFSET_REDUND 0xe0000 |
| 205 | +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT |
| 206 | + |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 207 | #define PHY_ANEG_TIMEOUT 8000 /* PHY needs a longer aneg time */ |
| 208 | |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 209 | /* PCIe support */ |
| 210 | @@ -149,14 +157,45 @@ |
| 211 | "scriptaddr=" SCRIPT_ADDR_R "\0" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 212 | "pxefile_addr_r=" PXEFILE_ADDR_R "\0" |
| 213 | |
| 214 | -#include <config_distro_bootcmd.h> |
| 215 | - |
| 216 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
| 217 | RELOCATION_LIMITS_ENV_SETTINGS \ |
| 218 | LOAD_ADDRESS_ENV_SETTINGS \ |
| 219 | - "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \ |
| 220 | "console=ttyS0,115200\0" \ |
| 221 | - BOOTENV |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 222 | + "usbboot=usb start; fatload usb 0:1 ${scriptaddr} boot.scr; source ${scriptaddr}\0" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 223 | + "bootcmd=test -n \"${BOOT_A_LEFT}\" || setenv BOOT_A_LEFT 3;" \ |
| 224 | + "test -n \"${BOOT_B_LEFT}\" || setenv BOOT_B_LEFT 3;" \ |
Jan Kundrát | a98768a | 2017-10-20 17:08:23 +0200 | [diff] [blame] | 225 | + "test -n \"${BOOT_ORDER}\" || setenv BOOT_ORDER \"A B\";" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 226 | + "setenv rauc_part;" \ |
Jan Kundrát | a98768a | 2017-10-20 17:08:23 +0200 | [diff] [blame] | 227 | + "for BOOT_SLOT in \"${BOOT_ORDER}\"; do" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 228 | + " if test \"x${rauc_part}\" != \"x\"; then" \ |
| 229 | + " ;" \ |
| 230 | + " elif test \"x${BOOT_SLOT}\" = \"xA\"; then" \ |
| 231 | + " if test ${BOOT_A_LEFT} -gt 0; then" \ |
| 232 | + " setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1;" \ |
| 233 | + " echo \"Found valid slot A, ${BOOT_A_LEFT} attempts remaining\";" \ |
| 234 | + " setenv rauc_part 1;" \ |
| 235 | + " setenv rauc_slot A;" \ |
| 236 | + " fi;" \ |
| 237 | + " elif test \"x${BOOT_SLOT}\" = \"xB\"; then" \ |
| 238 | + " if test ${BOOT_B_LEFT} -gt 0; then" \ |
| 239 | + " setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1;" \ |
| 240 | + " echo \"Found valid slot B, ${BOOT_B_LEFT} attempts remaining\";" \ |
Jan Kundrát | b425ea8 | 2017-10-19 17:56:36 +0200 | [diff] [blame] | 241 | + " setenv rauc_part 3;" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 242 | + " setenv rauc_slot B;" \ |
| 243 | + " fi;" \ |
| 244 | + " fi;" \ |
| 245 | + "done;" \ |
| 246 | + "if test -n \"${rauc_part}\"; then" \ |
| 247 | + " saveenv ;" \ |
| 248 | + "else" \ |
| 249 | + " echo \"No valid slot found, resetting tries to 3\";" \ |
| 250 | + " setenv BOOT_A_LEFT 3;" \ |
| 251 | + " setenv BOOT_B_LEFT 3;" \ |
| 252 | + " saveenv;" \ |
| 253 | + " reset;" \ |
| 254 | + "fi;" \ |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 255 | + "load mmc 0:${rauc_part} ${scriptaddr} /boot/boot.scr || reset;" \ |
| 256 | + "source ${scriptaddr} || reset\0" |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 257 | |
| 258 | #endif /* CONFIG_SPL_BUILD */ |
| 259 | |