1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * (C) Copyright 2007-2018 Michal Simek 4 * 5 * Michal SIMEK <monstr@monstr.eu> 6 */ 7 8 /* 9 * This is a board specific file. It's OK to include board specific 10 * header files 11 */ 12 13 #include <common.h> 14 #include <config.h> 15 #include <dm.h> 16 #include <dm/lists.h> 17 #include <fdtdec.h> 18 #include <asm/processor.h> 19 #include <asm/microblaze_intc.h> 20 #include <asm/asm.h> 21 #include <asm/gpio.h> 22 #include <dm/uclass.h> 23 #include <wdt.h> 24 25 DECLARE_GLOBAL_DATA_PTR; 26 27 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT) 28 static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL; 29 #endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ 30 31 ulong ram_base; 32 33 int dram_init_banksize(void) 34 { 35 return fdtdec_setup_memory_banksize(); 36 } 37 38 int dram_init(void) 39 { 40 if (fdtdec_setup_mem_size_base() != 0) 41 return -EINVAL; 42 43 return 0; 44 }; 45 46 #ifdef CONFIG_WDT 47 /* Called by macro WATCHDOG_RESET */ 48 void watchdog_reset(void) 49 { 50 #if !defined(CONFIG_SPL_BUILD) 51 ulong now; 52 static ulong next_reset; 53 54 if (!watchdog_dev) 55 return; 56 57 now = timer_get_us(); 58 59 /* Do not reset the watchdog too often */ 60 if (now > next_reset) { 61 wdt_reset(watchdog_dev); 62 next_reset = now + 1000; 63 } 64 #endif /* !CONFIG_SPL_BUILD */ 65 } 66 #endif /* CONFIG_WDT */ 67 68 int board_late_init(void) 69 { 70 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT) 71 watchdog_dev = NULL; 72 73 if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev)) { 74 debug("Watchdog: Not found by seq!\n"); 75 if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { 76 puts("Watchdog: Not found!\n"); 77 return 0; 78 } 79 } 80 81 wdt_start(watchdog_dev, 0, 0); 82 puts("Watchdog: Started\n"); 83 #endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ 84 #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE) 85 int ret; 86 87 ret = device_bind_driver(gd->dm_root, "mb_soft_reset", 88 "reset_soft", NULL); 89 if (ret) 90 printf("Warning: No reset driver: ret=%d\n", ret); 91 #endif 92 return 0; 93 } 94