blob: 91d16e969795e1ac193a378a0fbded550b9a8564 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2012-2015 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#include <err.h>
24#include <debug.h>
25#include <stdio.h>
26#include <string.h>
27#include <arch/arm/mmu.h>
28#include <kernel/vm.h>
29#include <dev/uart.h>
30#include <dev/interrupt/arm_gic.h>
31#include <dev/timer/arm_cortex_a9.h>
32#include <lib/console.h>
33#include <lib/watchdog.h>
34#include <platform.h>
35#include <platform/zynq.h>
36#include <platform/gem.h>
37#include <platform/timer.h>
38#include "platform_p.h"
39
40#if ZYNQ_SDRAM_INIT
41STATIC_ASSERT(SDRAM_SIZE != 0);
42#endif
43
44/* default timeout of the global hardware watchdog */
45#ifndef ZYNQ_WATCHDOG_TIMEOUT
46#define ZYNQ_WATCHDOG_TIMEOUT (1000) // 1 second
47#endif
48
49/* saved REBOOT_STATUS register */
50static uint32_t saved_reboot_status;
51
52/* target can specify this as the initial jam table to set up the soc */
53__WEAK void ps7_init(void) { }
54
55/* These should be defined in the target somewhere */
56extern const uint32_t zynq_mio_cfg[ZYNQ_MIO_CNT];
57extern const long zynq_ddr_cfg[];
58extern const uint32_t zynq_ddr_cfg_cnt;
59extern const zynq_pll_cfg_tree_t zynq_pll_cfg;
60extern const zynq_clk_cfg_t zynq_clk_cfg;
61extern const zynq_ddriob_cfg_t zynq_ddriob_cfg;
62
63static inline int reg_poll(uint32_t addr,uint32_t mask)
64{
65 uint32_t iters = UINT_MAX;
66 while (iters-- && !(*REG32(addr) & mask)) ;
67
68 if (iters) {
69 return 0;
70 }
71
72 return -1;
73}
74
75/* For each PLL we need to configure the cp / res / lock_cnt and then place the PLL in bypass
76 * before doing a reset to switch to the new values. Then bypass is removed to switch back to using
77 * the PLL once its locked.
78 */
79int zynq_pll_init(void) {
80 const zynq_pll_cfg_tree_t *cfg = &zynq_pll_cfg;
81
82 SLCR_REG(ARM_PLL_CFG) = PLL_CFG_LOCK_CNT(cfg->arm.lock_cnt) | PLL_CFG_PLL_CP(cfg->arm.cp) |
83 PLL_CFG_PLL_RES(cfg->arm.res);
84 SLCR_REG(ARM_PLL_CTRL) = PLL_FDIV(cfg->arm.fdiv) | PLL_BYPASS_FORCE | PLL_RESET;
85 SLCR_REG(ARM_PLL_CTRL) &= ~PLL_RESET;
86
87 if (reg_poll((uintptr_t)&SLCR->PLL_STATUS, PLL_STATUS_ARM_PLL_LOCK) == -1) {
88 return -1;
89 }
90
91 SLCR_REG(ARM_PLL_CTRL) &= ~PLL_BYPASS_FORCE;
92 SLCR_REG(ARM_CLK_CTRL) = zynq_clk_cfg.arm_clk;
93
94#if ZYNQ_SDRAM_INIT
95 SLCR_REG(DDR_PLL_CFG) = PLL_CFG_LOCK_CNT(cfg->ddr.lock_cnt) | PLL_CFG_PLL_CP(cfg->ddr.cp) |
96 PLL_CFG_PLL_RES(cfg->ddr.res);
97 SLCR_REG(DDR_PLL_CTRL) = PLL_FDIV(cfg->ddr.fdiv) | PLL_BYPASS_FORCE | PLL_RESET;
98 SLCR_REG(DDR_PLL_CTRL) &= ~PLL_RESET;
99
100 if (reg_poll((uintptr_t)&SLCR->PLL_STATUS, PLL_STATUS_DDR_PLL_LOCK) == -1) {
101 return -1;
102 }
103
104 SLCR_REG(DDR_PLL_CTRL) &= ~PLL_BYPASS_FORCE;
105 SLCR_REG(DDR_CLK_CTRL) = zynq_clk_cfg.ddr_clk;
106#elif SDRAM_SIZE == 0
107 /* if we're not using sdram and haven't been told to initialize sdram, stop the DDR pll */
108 SLCR_REG(DDR_CLK_CTRL) = 0;
109 SLCR_REG(DDR_PLL_CTRL) |= PLL_PWRDOWN;
110#endif
111 SLCR_REG(IO_PLL_CFG) = PLL_CFG_LOCK_CNT(cfg->io.lock_cnt) | PLL_CFG_PLL_CP(cfg->io.cp) |
112 PLL_CFG_PLL_RES(cfg->io.res);
113 SLCR_REG(IO_PLL_CTRL) = PLL_FDIV(cfg->io.fdiv) | PLL_BYPASS_FORCE | PLL_RESET;
114 SLCR_REG(IO_PLL_CTRL) &= ~PLL_RESET;
115
116 if (reg_poll((uintptr_t)&SLCR->PLL_STATUS, PLL_STATUS_IO_PLL_LOCK) == -1) {
117 return -1;
118 }
119
120 SLCR_REG(IO_PLL_CTRL) &= ~PLL_BYPASS_FORCE;
121 return 0;
122}
123
124int zynq_mio_init(void)
125{
126
127 /* This DDRIOB configuration applies to both zybo and uzed, but it's possible
128 * it may not work for all boards in the future. Just something to keep in mind
129 * with different memory configurations.
130 */
131 SLCR_REG(GPIOB_CTRL) = GPIOB_CTRL_VREF_EN;
132
133 for (size_t pin = 0; pin < countof(zynq_mio_cfg); pin++) {
134 if (zynq_mio_cfg[pin] != MIO_DEFAULT) {
135 SLCR_REG(MIO_PIN_00 + (pin * 4)) = zynq_mio_cfg[pin];
136 }
137 }
138
139 SLCR_REG(SD0_WP_CD_SEL) = SDIO0_WP_SEL(0x37) | SDIO0_CD_SEL(0x2F);
140
141 return 0;
142}
143
144void zynq_clk_init(void)
145{
146 SLCR_REG(DCI_CLK_CTRL) = zynq_clk_cfg.dci_clk;
147 SLCR_REG(GEM0_CLK_CTRL) = zynq_clk_cfg.gem0_clk;
148 SLCR_REG(GEM0_RCLK_CTRL) = zynq_clk_cfg.gem0_rclk;
149 SLCR_REG(GEM1_CLK_CTRL) = zynq_clk_cfg.gem1_clk;
150 SLCR_REG(GEM1_RCLK_CTRL) = zynq_clk_cfg.gem1_rclk;
151 SLCR_REG(SMC_CLK_CTRL) = zynq_clk_cfg.smc_clk;
152 SLCR_REG(LQSPI_CLK_CTRL) = zynq_clk_cfg.lqspi_clk;
153 SLCR_REG(SDIO_CLK_CTRL) = zynq_clk_cfg.sdio_clk;
154 SLCR_REG(UART_CLK_CTRL) = zynq_clk_cfg.uart_clk;
155 SLCR_REG(SPI_CLK_CTRL) = zynq_clk_cfg.spi_clk;
156 SLCR_REG(CAN_CLK_CTRL) = zynq_clk_cfg.can_clk;
157 SLCR_REG(CAN_MIOCLK_CTRL)= zynq_clk_cfg.can_mioclk;
158 SLCR_REG(USB0_CLK_CTRL) = zynq_clk_cfg.usb0_clk;
159 SLCR_REG(USB1_CLK_CTRL) = zynq_clk_cfg.usb1_clk;
160 SLCR_REG(PCAP_CLK_CTRL) = zynq_clk_cfg.pcap_clk;
161 SLCR_REG(FPGA0_CLK_CTRL) = zynq_clk_cfg.fpga0_clk;
162 SLCR_REG(FPGA1_CLK_CTRL) = zynq_clk_cfg.fpga1_clk;
163 SLCR_REG(FPGA2_CLK_CTRL) = zynq_clk_cfg.fpga2_clk;
164 SLCR_REG(FPGA3_CLK_CTRL) = zynq_clk_cfg.fpga3_clk;
165 SLCR_REG(APER_CLK_CTRL) = zynq_clk_cfg.aper_clk;
166 SLCR_REG(CLK_621_TRUE) = zynq_clk_cfg.clk_621_true;
167}
168
169#if ZYNQ_SDRAM_INIT
170void zynq_ddr_init(void)
171{
172 SLCR_REG(DDRIOB_ADDR0) = zynq_ddriob_cfg.addr0;
173 SLCR_REG(DDRIOB_ADDR1) = zynq_ddriob_cfg.addr1;
174 SLCR_REG(DDRIOB_DATA0) = zynq_ddriob_cfg.data0;
175 SLCR_REG(DDRIOB_DATA1) = zynq_ddriob_cfg.data1;
176 SLCR_REG(DDRIOB_DIFF0) = zynq_ddriob_cfg.diff0;
177 SLCR_REG(DDRIOB_DIFF1) = zynq_ddriob_cfg.diff1;
178 SLCR_REG(DDRIOB_CLOCK) = DDRIOB_OUTPUT_EN(0x3);
179
180 /* These register fields are not documented in the TRM. These
181 * values represent the defaults generated via the Zynq tools
182 */
183 SLCR_REG(DDRIOB_DRIVE_SLEW_ADDR) = 0x0018C61CU;
184 SLCR_REG(DDRIOB_DRIVE_SLEW_DATA) = 0x00F9861CU;
185 SLCR_REG(DDRIOB_DRIVE_SLEW_DIFF) = 0x00F9861CU;
186 SLCR_REG(DDRIOB_DRIVE_SLEW_CLOCK) = 0x00F9861CU;
187 SLCR_REG(DDRIOB_DDR_CTRL) = 0x00000E60U;
188 SLCR_REG(DDRIOB_DCI_CTRL) = 0x00000001U;
189 SLCR_REG(DDRIOB_DCI_CTRL) |= 0x00000020U;
190 SLCR_REG(DDRIOB_DCI_CTRL) |= 0x00000823U;
191
192 /* Write addresss / value pairs from target table */
193 for (size_t i = 0; i < zynq_ddr_cfg_cnt; i += 2) {
194 *REG32(zynq_ddr_cfg[i]) = zynq_ddr_cfg[i+1];
195 }
196
197 /* Wait for DCI done */
198 reg_poll((uintptr_t)&SLCR->DDRIOB_DCI_STATUS, 0x2000);
199
200 /* Bring ddr out of reset and wait until self refresh */
201 *REG32(DDRC_CTRL) |= DDRC_CTRL_OUT_OF_RESET;
202 reg_poll(DDRC_MODE_STATUS, DDRC_STS_SELF_REFRESH);
203
204 /* Switch timer to 64k */
205 *REG32(0XF8007000) = *REG32(0xF8007000) & ~0x20000000U;
206
207 if (zynq_ddriob_cfg.ibuf_disable) {
208 SLCR_REG(DDRIOB_DATA0) |= DDRIOB_IBUF_DISABLE_MODE;
209 SLCR_REG(DDRIOB_DATA1) |= DDRIOB_IBUF_DISABLE_MODE;
210 SLCR_REG(DDRIOB_DIFF0) |= DDRIOB_IBUF_DISABLE_MODE;
211 SLCR_REG(DDRIOB_DIFF1) |= DDRIOB_IBUF_DISABLE_MODE;
212 }
213
214 if (zynq_ddriob_cfg.term_disable) {
215 SLCR_REG(DDRIOB_DATA0) |= DDRIOB_TERM_DISABLE_MODE;
216 SLCR_REG(DDRIOB_DATA1) |= DDRIOB_TERM_DISABLE_MODE;
217 SLCR_REG(DDRIOB_DIFF0) |= DDRIOB_TERM_DISABLE_MODE;
218 SLCR_REG(DDRIOB_DIFF1) |= DDRIOB_TERM_DISABLE_MODE;
219 }
220}
221#endif
222
223STATIC_ASSERT(IS_ALIGNED(SDRAM_BASE, MB));
224STATIC_ASSERT(IS_ALIGNED(SDRAM_SIZE, MB));
225
226#if SDRAM_SIZE != 0
227/* if we have sdram, the first 1MB is covered by sram */
228#define RAM_SIZE (MB + (SDRAM_SIZE - MB))
229#else
230#define RAM_SIZE (MB)
231#endif
232
233/* initial memory mappings. parsed by start.S */
234struct mmu_initial_mapping mmu_initial_mappings[] = {
235 /* 1GB of sram + sdram space */
236 { .phys = SRAM_BASE,
237 .virt = KERNEL_BASE,
238 .size = RAM_SIZE,
239 .flags = 0,
240 .name = "memory" },
241
242 /* AXI fpga fabric bus 0 */
243 { .phys = 0x40000000,
244 .virt = 0x40000000,
245 .size = (128*1024*1024),
246 .flags = MMU_INITIAL_MAPPING_FLAG_DEVICE,
247 .name = "axi0" },
248
249 /* AXI fpga fabric bus 1 */
250 { .phys = 0x80000000,
251 .virt = 0x80000000,
252 .size = (16*1024*1024),
253 .flags = MMU_INITIAL_MAPPING_FLAG_DEVICE,
254 .name = "axi1" },
255 /* 0xe0000000 hardware devices */
256 { .phys = 0xe0000000,
257 .virt = 0xe0000000,
258 .size = 0x00300000,
259 .flags = MMU_INITIAL_MAPPING_FLAG_DEVICE,
260 .name = "hw-e0000000" },
261
262 /* 0xe1000000 hardware devices */
263 { .phys = 0xe1000000,
264 .virt = 0xe1000000,
265 .size = 0x05000000,
266 .flags = MMU_INITIAL_MAPPING_FLAG_DEVICE,
267 .name = "hw-e1000000" },
268
269 /* 0xf8000000 hardware devices */
270 { .phys = 0xf8000000,
271 .virt = 0xf8000000,
272 .size = 0x01000000,
273 .flags = MMU_INITIAL_MAPPING_FLAG_DEVICE,
274 .name = "hw-f8000000" },
275
276 /* 0xfc000000 hardware devices */
277 { .phys = 0xfc000000,
278 .virt = 0xfc000000,
279 .size = 0x02000000,
280 .flags = MMU_INITIAL_MAPPING_FLAG_DEVICE,
281 .name = "hw-fc000000" },
282
283 /* sram high aperture */
284 { .phys = 0xfff00000,
285 .virt = 0xfff00000,
286 .size = 0x00100000,
287 .flags = MMU_INITIAL_MAPPING_FLAG_DEVICE },
288
289 /* identity map to let the boot code run */
290 { .phys = SRAM_BASE,
291 .virt = SRAM_BASE,
292 .size = RAM_SIZE,
293 .flags = MMU_INITIAL_MAPPING_TEMPORARY },
294
295 /* null entry to terminate the list */
296 { 0 }
297};
298
299#if SDRAM_SIZE != 0
300static pmm_arena_t sdram_arena = {
301 .name = "sdram",
302 .base = SDRAM_BASE,
303 .size = SDRAM_SIZE - MB, /* first 1MB is covered by SRAM */
304 .flags = PMM_ARENA_FLAG_KMAP
305};
306#endif
307
308static pmm_arena_t sram_arena = {
309 .name = "sram",
310 .base = SRAM_BASE,
311 .size = SRAM_SIZE,
312 .priority = 1,
313 .flags = PMM_ARENA_FLAG_KMAP
314};
315
316void platform_init_mmu_mappings(void)
317{
318}
319
320void platform_early_init(void)
321{
322#if 0
323 ps7_init();
324#else
325 /* Unlock the registers and leave them that way */
326 zynq_slcr_unlock();
327 zynq_mio_init();
328 zynq_pll_init();
329 zynq_clk_init();
330#if ZYNQ_SDRAM_INIT
331 zynq_ddr_init();
332#endif
333#endif
334
335 /* Enable all level shifters */
336 SLCR_REG(LVL_SHFTR_EN) = 0xF;
337 /* FPGA SW reset (not documented, but mandatory) */
338 SLCR_REG(FPGA_RST_CTRL) = 0x0;
339
340 /* zynq manual says this is mandatory for cache init */
341 *REG32(SLCR_BASE + 0xa1c) = 0x020202;
342
343 /* save the reboot status register, clear bits we dont want to save */
344 saved_reboot_status = SLCR->REBOOT_STATUS;
345 SLCR->REBOOT_STATUS &= ~(0xff << 16);
346
347 /* early initialize the uart so we can printf */
348 uart_init_early();
349
350 /* initialize the interrupt controller */
351 arm_gic_init();
352 zynq_gpio_init();
353
354 /* initialize the timer block */
355 arm_cortex_a9_timer_init(CPUPRIV_BASE, zynq_get_arm_timer_freq());
356
357 /* initialize the hardware watchdog */
358 watchdog_hw_init(ZYNQ_WATCHDOG_TIMEOUT);
359
360 /* bump the 2nd cpu into our code space and remap the top SRAM block */
361 if (KERNEL_LOAD_OFFSET != 0) {
362 /* construct a trampoline to get the 2nd cpu up to the trap routine */
363
364 /* figure out the offset of the trampoline routine in physical space from address 0 */
365 extern void platform_reset(void);
366 addr_t tramp = (addr_t)&platform_reset;
367 tramp -= KERNEL_BASE;
368 tramp += MEMBASE;
369
370 /* stuff in a ldr pc, [nextaddrress], and a target address */
371 uint32_t *ptr = (uint32_t *)KERNEL_BASE;
372
373 ptr[0] = 0xe51ff004; // ldr pc, [pc, #-4]
374 ptr[1] = tramp;
375 arch_clean_invalidate_cache_range((addr_t)ptr, 8);
376 }
377
378 /* reset the 2nd cpu, letting it go through its reset vector (at 0x0 physical) */
379 SLCR_REG(A9_CPU_RST_CTRL) |= (1<<1); // reset cpu 1
380 spin(10);
381 SLCR_REG(A9_CPU_RST_CTRL) &= ~(1<<1); // unreset cpu 1
382
383 /* wait for the 2nd cpu to reset, go through the usual reset vector, and get trapped by our code */
384 /* see platform/zynq/reset.S */
385 extern volatile int __cpu_trapped;
386 uint count = 100000;
387 while (--count) {
388 arch_clean_invalidate_cache_range((addr_t)&__cpu_trapped, sizeof(__cpu_trapped));
389 if (__cpu_trapped != 0)
390 break;
391 }
392 if (count == 0) {
393 panic("ZYNQ: failed to trap 2nd cpu\n");
394 }
395
396 /* bounce the 4th sram region down to lower address */
397 SLCR_REG(OCM_CFG) &= ~0xf; /* all banks at low address */
398
399 /* add the main memory arena */
400#if !ZYNQ_CODE_IN_SDRAM && SDRAM_SIZE != 0
401 /* In the case of running from SRAM, and we are using SDRAM,
402 * there is a discontinuity between the end of SRAM (256K) and the start of SDRAM (1MB),
403 * so intentionally bump the boot-time allocator to start in the base of SDRAM.
404 */
405 extern uintptr_t boot_alloc_start;
406 extern uintptr_t boot_alloc_end;
407
408 boot_alloc_start = KERNEL_BASE + MB;
409 boot_alloc_end = KERNEL_BASE + MB;
410#endif
411
412#if SDRAM_SIZE != 0
413 pmm_add_arena(&sdram_arena);
414#endif
415 pmm_add_arena(&sram_arena);
416}
417
418void platform_init(void)
419{
420 uart_init();
421
422 /* enable if we want to see some hardware boot status */
423#if LK_DEBUGLEVEL > 0
424 printf("zynq boot status:\n");
425 printf("\tREBOOT_STATUS 0x%x\n", saved_reboot_status);
426 if (BIT(saved_reboot_status, 16)) printf("\t\tSWDT_RST\n");
427 if (BIT(saved_reboot_status, 17)) printf("\t\tAWDT0_RST\n");
428 if (BIT(saved_reboot_status, 18)) printf("\t\tAWDT1_RST\n");
429 if (BIT(saved_reboot_status, 19)) printf("\t\tSLC_RST\n");
430 if (BIT(saved_reboot_status, 20)) printf("\t\tDBG_RST\n");
431 if (BIT(saved_reboot_status, 21)) printf("\t\tSRST_B\n");
432 if (BIT(saved_reboot_status, 22)) printf("\t\tPOR\n");
433 printf("\tREBOOT_STATE 0x%lx\n", BITS_SHIFT(saved_reboot_status, 31, 24));
434 printf("\tboot mode 0x%x\n", zynq_get_boot_mode());
435#endif
436}
437
438void platform_quiesce(void)
439{
440#if ZYNQ_WITH_GEM_ETH
441 gem_disable();
442#endif
443
444 platform_stop_timer();
445
446 /* stop the 2nd cpu and hold in reset */
447 SLCR_REG(A9_CPU_RST_CTRL) |= (1<<1); // reset cpu 1
448}
449
450/* called from lkboot to see if we want to abort autobooting.
451 * having the BOOT_MODE pins set to JTAG should cause us to hang out in
452 * whatever binary is loaded at the time.
453 */
454bool platform_abort_autoboot(void)
455{
456 /* test BOOT_MODE pins to see if we want to skip the autoboot stuff */
457 uint32_t boot_mode = zynq_get_boot_mode();
458 if (boot_mode == ZYNQ_BOOT_MODE_JTAG) {
459 printf("ZYNQ: disabling autoboot due to JTAG/QSPI jumper being set to JTAG\n");
460 return true;
461 }
462
463 return false;
464}
465
466#if WITH_LIB_CONSOLE
467static int cmd_zynq(int argc, const cmd_args *argv)
468{
469 if (argc < 2) {
470notenoughargs:
471 printf("not enough arguments\n");
472usage:
473 printf("usage: %s <command>\n", argv[0].str);
474 printf("\tslcr lock\n");
475 printf("\tslcr unlock\n");
476 printf("\tslcr lockstatus\n");
477 printf("\tmio\n");
478 printf("\tclocks\n");
479 printf("\ttrip_watchdog\n");
480 return -1;
481 }
482
483 if (!strcmp(argv[1].str, "slcr")) {
484 if (argc < 3) goto notenoughargs;
485
486 bool print_lock_status = false;
487 if (!strcmp(argv[2].str, "lock")) {
488 zynq_slcr_lock();
489 print_lock_status = true;
490 } else if (!strcmp(argv[2].str, "unlock")) {
491 zynq_slcr_unlock();
492 print_lock_status = true;
493 } else if (print_lock_status || !strcmp(argv[2].str, "lockstatus")) {
494 printf("%s\n", (SLCR->SLCR_LOCKSTA & 0x1) ? "locked" : "unlocked");
495 } else {
496 goto usage;
497 }
498 } else if (!strcmp(argv[1].str, "mio")) {
499 printf("zynq mio:\n");
500 for (size_t i = 0; i < ZYNQ_MIO_CNT; i++) {
501 printf("\t%02u: 0x%08x", i, *REG32((uintptr_t)&SLCR->MIO_PIN_00 + (i * 4)));
502 if (i % 4 == 3 || i == 53) {
503 putchar('\n');
504 }
505 }
506 } else if (!strcmp(argv[1].str, "clocks")) {
507 zynq_dump_clocks();
508 } else if (!strcmp(argv[1].str, "trip_watchdog")) {
509 /* try to trip the watchdog by disabling interrupts for a while */
510 arch_disable_ints();
511 for (int i = 0; i < 20; i++) {
512 spin(250000);
513 printf("SWDT MODE 0x%x CONTROL 0x%x STATUS 0x%x\n", SWDT->MODE, SWDT->CONTROL, SWDT->STATUS);
514 }
515 arch_enable_ints();
516 } else {
517 goto usage;
518 }
519
520 return 0;
521}
522
523STATIC_COMMAND_START
524#if LK_DEBUGLEVEL > 1
525STATIC_COMMAND("zynq", "zynq configuration commands", &cmd_zynq)
526#endif
527STATIC_COMMAND_END(zynq);
528#endif // WITH_LIB_CONSOLE