Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 1 | diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c |
| 2 | index 8906636f76..f94bd5e465 100644 |
| 3 | --- a/board/solidrun/clearfog/clearfog.c |
| 4 | +++ b/board/solidrun/clearfog/clearfog.c |
| 5 | @@ -11,10 +11,15 @@ |
| 6 | #include <asm/io.h> |
| 7 | #include <asm/arch/cpu.h> |
| 8 | #include <asm/arch/soc.h> |
| 9 | +#include <dm/uclass.h> |
| 10 | |
| 11 | #include "../drivers/ddr/marvell/a38x/ddr3_a38x_topology.h" |
| 12 | #include <../serdes/a38x/high_speed_env_spec.h> |
| 13 | |
| 14 | +#ifdef CONFIG_WDT_ORION |
| 15 | +# include <wdt.h> |
| 16 | +#endif |
| 17 | + |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | #define ETH_PHY_CTRL_REG 0 |
| 21 | @@ -122,6 +127,10 @@ int board_early_init_f(void) |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION) |
| 26 | +static struct udevice *watchdog_dev = NULL; |
| 27 | +#endif |
| 28 | + |
| 29 | int board_init(void) |
| 30 | { |
| 31 | int i; |
| 32 | @@ -129,6 +138,18 @@ int board_init(void) |
| 33 | /* Address of boot parameters */ |
| 34 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
| 35 | |
| 36 | +#ifndef CONFIG_SPL_BUILD |
| 37 | +# ifdef CONFIG_WDT_ORION |
| 38 | + if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { |
| 39 | + puts("Cannot find Armada 385 watchdog!\n"); |
| 40 | + } else { |
| 41 | + puts("Enabling Armada 385 watchdog.\n"); |
| 42 | + /* one minute */ |
| 43 | + wdt_start(watchdog_dev, (u32) 25000000 * 60, 0); |
| 44 | + } |
| 45 | +# endif |
| 46 | +#endif |
| 47 | + |
| 48 | /* Toggle GPIO41 to reset onboard switch and phy */ |
| 49 | clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9)); |
| 50 | clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9)); |
| 51 | @@ -147,6 +168,28 @@ int board_init(void) |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | +#ifdef CONFIG_WATCHDOG |
| 56 | +/* Called by macro WATCHDOG_RESET */ |
| 57 | +void watchdog_reset(void) |
| 58 | +{ |
| 59 | +# if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION) |
| 60 | + static ulong next_reset = 0; |
| 61 | + ulong now; |
| 62 | + |
| 63 | + if (!watchdog_dev) |
| 64 | + return; |
| 65 | + |
| 66 | + now = timer_get_us(); |
| 67 | + |
| 68 | + /* Do not reset the watchdog too often */ |
| 69 | + if (now > next_reset) { |
| 70 | + wdt_reset(watchdog_dev); |
| 71 | + next_reset = now + 1000; |
| 72 | + } |
| 73 | +# endif |
| 74 | +} |
| 75 | +#endif |
| 76 | + |
| 77 | int checkboard(void) |
| 78 | { |
| 79 | puts("Board: SolidRun ClearFog\n"); |
| 80 | diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig |
| 81 | index 5eceacf491..fd48b0db02 100644 |
| 82 | --- a/configs/clearfog_defconfig |
| 83 | +++ b/configs/clearfog_defconfig |
| 84 | @@ -46,3 +46,5 @@ CONFIG_USB=y |
| 85 | CONFIG_DM_USB=y |
| 86 | CONFIG_USB_EHCI_HCD=y |
| 87 | CONFIG_USB_STORAGE=y |
| 88 | +CONFIG_WDT=y |
| 89 | +CONFIG_WDT_ORION=y |
| 90 | diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h |
Jan Kundrát | b425ea8 | 2017-10-19 17:56:36 +0200 | [diff] [blame] | 91 | index 5061f6c6fd..592c7cc499 100644 |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 92 | --- a/include/configs/clearfog.h |
| 93 | +++ b/include/configs/clearfog.h |
| 94 | @@ -32,6 +32,11 @@ |
| 95 | #define CONFIG_SYS_I2C_SLAVE 0x0 |
| 96 | #define CONFIG_SYS_I2C_SPEED 100000 |
| 97 | |
| 98 | +/* Watchdog */ |
| 99 | +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION) |
| 100 | +# define CONFIG_WATCHDOG |
| 101 | +#endif |
| 102 | + |
| 103 | /* SPI NOR flash default params, used by sf commands */ |
| 104 | #define CONFIG_SF_DEFAULT_SPEED 1000000 |
| 105 | #define CONFIG_SF_DEFAULT_MODE SPI_MODE_3 |
| 106 | @@ -65,6 +70,9 @@ |
| 107 | #define CONFIG_ENV_OFFSET 0xf0000 |
| 108 | #define CONFIG_ENV_ADDR CONFIG_ENV_OFFSET |
| 109 | |
| 110 | +#define CONFIG_ENV_OFFSET_REDUND 0xe0000 |
| 111 | +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT |
| 112 | + |
| 113 | #define CONFIG_PHY_MARVELL /* there is a marvell phy */ |
| 114 | #define PHY_ANEG_TIMEOUT 8000 /* PHY needs a longer aneg time */ |
| 115 | |
| 116 | @@ -166,14 +174,46 @@ |
| 117 | "scriptaddr=" SCRIPT_ADDR_R "\0" \ |
| 118 | "pxefile_addr_r=" PXEFILE_ADDR_R "\0" |
| 119 | |
| 120 | -#include <config_distro_bootcmd.h> |
| 121 | - |
| 122 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
| 123 | RELOCATION_LIMITS_ENV_SETTINGS \ |
| 124 | LOAD_ADDRESS_ENV_SETTINGS \ |
| 125 | - "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \ |
| 126 | "console=ttyS0,115200\0" \ |
| 127 | - BOOTENV |
| 128 | + "extra_bootargs=panic=10 oops=panic\0" \ |
| 129 | + "bootcmd=test -n \"${BOOT_A_LEFT}\" || setenv BOOT_A_LEFT 3;" \ |
| 130 | + "test -n \"${BOOT_B_LEFT}\" || setenv BOOT_B_LEFT 3;" \ |
| 131 | + "setenv rauc_part;" \ |
| 132 | + "for BOOT_SLOT in \"A B\"; do" \ |
| 133 | + " if test \"x${rauc_part}\" != \"x\"; then" \ |
| 134 | + " ;" \ |
| 135 | + " elif test \"x${BOOT_SLOT}\" = \"xA\"; then" \ |
| 136 | + " if test ${BOOT_A_LEFT} -gt 0; then" \ |
| 137 | + " setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1;" \ |
| 138 | + " echo \"Found valid slot A, ${BOOT_A_LEFT} attempts remaining\";" \ |
| 139 | + " setenv rauc_part 1;" \ |
| 140 | + " setenv rauc_slot A;" \ |
| 141 | + " fi;" \ |
| 142 | + " elif test \"x${BOOT_SLOT}\" = \"xB\"; then" \ |
| 143 | + " if test ${BOOT_B_LEFT} -gt 0; then" \ |
| 144 | + " setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1;" \ |
| 145 | + " echo \"Found valid slot B, ${BOOT_B_LEFT} attempts remaining\";" \ |
Jan Kundrát | b425ea8 | 2017-10-19 17:56:36 +0200 | [diff] [blame] | 146 | + " setenv rauc_part 3;" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 147 | + " setenv rauc_slot B;" \ |
| 148 | + " fi;" \ |
| 149 | + " fi;" \ |
| 150 | + "done;" \ |
| 151 | + "if test -n \"${rauc_part}\"; then" \ |
| 152 | + " saveenv ;" \ |
| 153 | + "else" \ |
| 154 | + " echo \"No valid slot found, resetting tries to 3\";" \ |
| 155 | + " setenv BOOT_A_LEFT 3;" \ |
| 156 | + " setenv BOOT_B_LEFT 3;" \ |
| 157 | + " saveenv;" \ |
| 158 | + " reset;" \ |
| 159 | + "fi;" \ |
Jan Kundrát | b83fe12 | 2017-10-19 15:35:22 +0200 | [diff] [blame] | 160 | + "setenv bootargs root=/dev/mmcblk0p${rauc_part} rauc.slot=${rauc_slot} czechlight=${czechlight} systemd.machine_id=${machineid} ${extra_bootargs};" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 161 | + "load mmc 0:${rauc_part} ${fdt_addr_r} /boot/armada-388-clearfog-base.dtb || reset;" \ |
| 162 | + "load mmc 0:${rauc_part} ${kernel_addr_r} /boot/zImage || reset;" \ |
| 163 | + "bootz ${kernel_addr_r} - ${fdt_addr_r} || reset\0" |
| 164 | |
| 165 | #endif /* CONFIG_SPL_BUILD */ |
| 166 | |