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 | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 96 | index ede303d4eb..17bf27f875 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 | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 115 | @@ -124,6 +129,54 @@ 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 | + |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 123 | +#define TLC59XXX_REG_MODE1 0x00 |
| 124 | +#define TLC59XXX_REG_MODE2 0x01 |
| 125 | +#define TLC59XXX_REG_PWM(LED) (LED + 0x02) |
| 126 | +#define TLC59XXX_REG_GRPPWM 0x12 |
| 127 | +#define TLC59XXX_REG_GRPFREQ 0x13 |
| 128 | +#define TLC59XXX_REG_LEDOUT0 0x14 |
| 129 | +#define TLC59XXX_REG_LEDOUT1 0x15 |
| 130 | +#define TLC59XXX_REG_LEDOUT2 0x16 |
| 131 | +#define TLC59XXX_REG_LEDOUT3 0x17 |
| 132 | +#define TLC59XXX_CHIP_RESET_ADDR 0x6b |
| 133 | +#define TLC59XXX_RESET_BYTE_0 0xa5 |
| 134 | +#define TLC59XXX_RESET_BYTE_1 0x5a |
| 135 | +#define CLA_LED_CHIP_ADDR 0x60 |
| 136 | +#define CLA_LED_STATUS_RED 8 |
| 137 | +#define CLA_LED_STATUS_GREEN 9 |
| 138 | +#define CLA_LED_STATUS_BLUE 10 |
| 139 | + |
| 140 | +static struct marvell_io_exp led_config[] = { |
| 141 | + { TLC59XXX_CHIP_RESET_ADDR, TLC59XXX_RESET_BYTE_0, TLC59XXX_RESET_BYTE_1 }, |
| 142 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_MODE1, 0x01 }, /* enable oscillator */ |
| 143 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_MODE2, 0x20 }, /* DMBLINK */ |
| 144 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_GRPPWM, 0x40 }, /* 25% duty cycle */ |
| 145 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_GRPFREQ, 0x03 }, /* very fast blinking */ |
| 146 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_PWM(CLA_LED_STATUS_RED), 0x80 }, /* 50% brightness */ |
| 147 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_PWM(CLA_LED_STATUS_GREEN), 0x80 }, /* 50% brightness */ |
| 148 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_PWM(CLA_LED_STATUS_BLUE), 0x80 }, /* 50% brightness */ |
| 149 | + { CLA_LED_CHIP_ADDR, TLC59XXX_REG_LEDOUT2, 0x3f }, /* LEDs #8, 9, 10: mode 0b11 -> group blinking */ |
| 150 | +}; |
| 151 | + |
| 152 | +int cla_setup_leds(void) |
| 153 | +{ |
| 154 | + if (i2c_set_bus_num(1)) { |
| 155 | + puts("Cannot select I2C bus 1"); |
| 156 | + return 1; |
| 157 | + } |
| 158 | + for (int i = 0; i < ARRAY_SIZE(led_config); i++) { |
| 159 | + if (i2c_write(led_config[i].chip, led_config[i].addr, 1, &led_config[i].val, 1)) { |
| 160 | + printf("LED config operation %d failed\n", i); |
| 161 | + return 1; |
| 162 | + } |
| 163 | + } |
| 164 | + return 0; |
| 165 | +} |
| 166 | + |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 167 | int board_init(void) |
| 168 | { |
| 169 | int i; |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 170 | @@ -131,6 +184,18 @@ int board_init(void) |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 171 | /* Address of boot parameters */ |
| 172 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
| 173 | |
| 174 | +#ifndef CONFIG_SPL_BUILD |
| 175 | +# ifdef CONFIG_WDT_ORION |
| 176 | + if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { |
| 177 | + puts("Cannot find Armada 385 watchdog!\n"); |
| 178 | + } else { |
| 179 | + puts("Enabling Armada 385 watchdog.\n"); |
| 180 | + /* one minute */ |
| 181 | + wdt_start(watchdog_dev, (u32) 25000000 * 60, 0); |
| 182 | + } |
| 183 | +# endif |
| 184 | +#endif |
| 185 | + |
| 186 | /* Toggle GPIO41 to reset onboard switch and phy */ |
| 187 | clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9)); |
| 188 | clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9)); |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 189 | @@ -146,9 +211,33 @@ int board_init(void) |
| 190 | for (i = 0; i < ARRAY_SIZE(io_exp); i++) |
| 191 | i2c_write(io_exp[i].chip, io_exp[i].addr, 1, &io_exp[i].val, 1); |
| 192 | |
| 193 | + cla_setup_leds(); |
| 194 | + |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | +#ifdef CONFIG_WATCHDOG |
| 199 | +/* Called by macro WATCHDOG_RESET */ |
| 200 | +void watchdog_reset(void) |
| 201 | +{ |
| 202 | +# if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION) |
| 203 | + static ulong next_reset = 0; |
| 204 | + ulong now; |
| 205 | + |
| 206 | + if (!watchdog_dev) |
| 207 | + return; |
| 208 | + |
| 209 | + now = timer_get_us(); |
| 210 | + |
| 211 | + /* Do not reset the watchdog too often */ |
| 212 | + if (now > next_reset) { |
| 213 | + wdt_reset(watchdog_dev); |
| 214 | + next_reset = now + 1000; |
| 215 | + } |
| 216 | +# endif |
| 217 | +} |
| 218 | +#endif |
| 219 | + |
| 220 | int checkboard(void) |
| 221 | { |
| 222 | puts("Board: SolidRun ClearFog\n"); |
| 223 | diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 224 | index 5e1733e11b..4af2d1e902 100644 |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 225 | --- a/configs/clearfog_defconfig |
| 226 | +++ b/configs/clearfog_defconfig |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 227 | @@ -53,3 +53,5 @@ CONFIG_USB=y |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 228 | CONFIG_DM_USB=y |
Jan Kundrát | 6fa8750 | 2018-01-12 15:09:58 +0100 | [diff] [blame] | 229 | CONFIG_USB_XHCI_HCD=y |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 230 | CONFIG_USB_STORAGE=y |
| 231 | +CONFIG_WDT=y |
| 232 | +CONFIG_WDT_ORION=y |
| 233 | diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 234 | index f57f9b21ab..b2ed0d5594 100644 |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 235 | --- a/include/configs/clearfog.h |
| 236 | +++ b/include/configs/clearfog.h |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 237 | @@ -25,8 +25,15 @@ |
Jan Kundrát | bc1236c | 2018-06-05 12:30:58 +0200 | [diff] [blame] | 238 | #define CONFIG_SYS_I2C |
| 239 | #define CONFIG_SYS_I2C_MVTWSI |
| 240 | #define CONFIG_I2C_MVTWSI_BASE0 MVEBU_TWSI_BASE |
| 241 | +#define CONFIG_I2C_MVTWSI_BASE1 MVEBU_TWSI1_BASE |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 242 | #define CONFIG_SYS_I2C_SLAVE 0x0 |
| 243 | #define CONFIG_SYS_I2C_SPEED 100000 |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 244 | +#define CONFIG_SYS_EEPROM_SIZE (128 * 1024) |
| 245 | + |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 246 | +/* Watchdog */ |
| 247 | +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT_ORION) |
| 248 | +# define CONFIG_WATCHDOG |
| 249 | +#endif |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 250 | |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 251 | /* SPI NOR flash default params, used by sf commands */ |
Jan Kundrát | 6fa8750 | 2018-01-12 15:09:58 +0100 | [diff] [blame] | 252 | #define CONFIG_SF_DEFAULT_BUS 1 |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 253 | @@ -54,6 +61,9 @@ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 254 | #define CONFIG_ENV_OFFSET 0xf0000 |
| 255 | #define CONFIG_ENV_ADDR CONFIG_ENV_OFFSET |
| 256 | |
| 257 | +#define CONFIG_ENV_OFFSET_REDUND 0xe0000 |
| 258 | +#define CONFIG_SYS_REDUNDAND_ENVIRONMENT |
| 259 | + |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 260 | #define PHY_ANEG_TIMEOUT 8000 /* PHY needs a longer aneg time */ |
| 261 | |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 262 | /* PCIe support */ |
Jan Kundrát | cdc2ece | 2018-08-20 14:52:17 +0200 | [diff] [blame^] | 263 | @@ -149,14 +159,45 @@ |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 264 | "scriptaddr=" SCRIPT_ADDR_R "\0" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 265 | "pxefile_addr_r=" PXEFILE_ADDR_R "\0" |
| 266 | |
| 267 | -#include <config_distro_bootcmd.h> |
| 268 | - |
| 269 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
| 270 | RELOCATION_LIMITS_ENV_SETTINGS \ |
| 271 | LOAD_ADDRESS_ENV_SETTINGS \ |
| 272 | - "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \ |
| 273 | "console=ttyS0,115200\0" \ |
| 274 | - BOOTENV |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 275 | + "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] | 276 | + "bootcmd=test -n \"${BOOT_A_LEFT}\" || setenv BOOT_A_LEFT 3;" \ |
| 277 | + "test -n \"${BOOT_B_LEFT}\" || setenv BOOT_B_LEFT 3;" \ |
Jan Kundrát | a98768a | 2017-10-20 17:08:23 +0200 | [diff] [blame] | 278 | + "test -n \"${BOOT_ORDER}\" || setenv BOOT_ORDER \"A B\";" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 279 | + "setenv rauc_part;" \ |
Jan Kundrát | a98768a | 2017-10-20 17:08:23 +0200 | [diff] [blame] | 280 | + "for BOOT_SLOT in \"${BOOT_ORDER}\"; do" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 281 | + " if test \"x${rauc_part}\" != \"x\"; then" \ |
| 282 | + " ;" \ |
| 283 | + " elif test \"x${BOOT_SLOT}\" = \"xA\"; then" \ |
| 284 | + " if test ${BOOT_A_LEFT} -gt 0; then" \ |
| 285 | + " setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1;" \ |
| 286 | + " echo \"Found valid slot A, ${BOOT_A_LEFT} attempts remaining\";" \ |
| 287 | + " setenv rauc_part 1;" \ |
| 288 | + " setenv rauc_slot A;" \ |
| 289 | + " fi;" \ |
| 290 | + " elif test \"x${BOOT_SLOT}\" = \"xB\"; then" \ |
| 291 | + " if test ${BOOT_B_LEFT} -gt 0; then" \ |
| 292 | + " setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1;" \ |
| 293 | + " echo \"Found valid slot B, ${BOOT_B_LEFT} attempts remaining\";" \ |
Jan Kundrát | b425ea8 | 2017-10-19 17:56:36 +0200 | [diff] [blame] | 294 | + " setenv rauc_part 3;" \ |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 295 | + " setenv rauc_slot B;" \ |
| 296 | + " fi;" \ |
| 297 | + " fi;" \ |
| 298 | + "done;" \ |
| 299 | + "if test -n \"${rauc_part}\"; then" \ |
| 300 | + " saveenv ;" \ |
| 301 | + "else" \ |
| 302 | + " echo \"No valid slot found, resetting tries to 3\";" \ |
| 303 | + " setenv BOOT_A_LEFT 3;" \ |
| 304 | + " setenv BOOT_B_LEFT 3;" \ |
| 305 | + " saveenv;" \ |
| 306 | + " reset;" \ |
| 307 | + "fi;" \ |
Jan Kundrát | be55261 | 2018-05-21 22:45:32 +0200 | [diff] [blame] | 308 | + "load mmc 0:${rauc_part} ${scriptaddr} /boot/boot.scr || reset;" \ |
| 309 | + "source ${scriptaddr} || reset\0" |
Jan Kundrát | 04d102b | 2017-10-19 12:04:06 +0200 | [diff] [blame] | 310 | |
| 311 | #endif /* CONFIG_SPL_BUILD */ |
| 312 | |