Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 2 | /* |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 3 | * (C) Copyright 2007-2018 Michal Simek |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 4 | * |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 5 | * Michal SIMEK <monstr@monstr.eu> |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
Shreenidhi Shedi | ffced40 | 2018-07-15 02:34:35 +0530 | [diff] [blame] | 8 | /* |
| 9 | * This is a board specific file. It's OK to include board specific |
| 10 | * header files |
| 11 | */ |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 12 | |
| 13 | #include <common.h> |
Michal Simek | dda9bd8 | 2007-03-30 22:52:09 +0200 | [diff] [blame] | 14 | #include <config.h> |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 15 | #include <dm.h> |
| 16 | #include <dm/lists.h> |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 17 | #include <fdtdec.h> |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 18 | #include <asm/processor.h> |
Michal Simek | 9c817f8 | 2007-05-07 19:33:51 +0200 | [diff] [blame] | 19 | #include <asm/microblaze_intc.h> |
| 20 | #include <asm/asm.h> |
Michal Simek | 23ccda0 | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 21 | #include <asm/gpio.h> |
Shreenidhi Shedi | 1f8fcbb | 2018-07-15 02:05:40 +0530 | [diff] [blame] | 22 | #include <dm/uclass.h> |
| 23 | #include <wdt.h> |
Michal Simek | 23ccda0 | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 24 | |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
Shreenidhi Shedi | 1f8fcbb | 2018-07-15 02:05:40 +0530 | [diff] [blame] | 27 | #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT) |
Stefan Roese | f3170d1 | 2019-04-03 09:12:48 +0200 | [diff] [blame] | 28 | static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL; |
Shreenidhi Shedi | 1f8fcbb | 2018-07-15 02:05:40 +0530 | [diff] [blame] | 29 | #endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ |
| 30 | |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 31 | ulong ram_base; |
| 32 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 33 | int dram_init_banksize(void) |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 34 | { |
Michal Simek | fdf3d80 | 2018-11-22 12:39:18 +0100 | [diff] [blame] | 35 | return fdtdec_setup_memory_banksize(); |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | int dram_init(void) |
| 39 | { |
Michal Simek | fdf3d80 | 2018-11-22 12:39:18 +0100 | [diff] [blame] | 40 | if (fdtdec_setup_mem_size_base() != 0) |
| 41 | return -EINVAL; |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 42 | |
| 43 | return 0; |
| 44 | }; |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 45 | |
Shreenidhi Shedi | 1f8fcbb | 2018-07-15 02:05:40 +0530 | [diff] [blame] | 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 */ |
Michal Simek | 9c817f8 | 2007-05-07 19:33:51 +0200 | [diff] [blame] | 67 | |
Michal Simek | 0152524 | 2015-12-11 15:01:28 +0100 | [diff] [blame] | 68 | int board_late_init(void) |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 69 | { |
Shreenidhi Shedi | 1f8fcbb | 2018-07-15 02:05:40 +0530 | [diff] [blame] | 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 */ |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 84 | #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SYSRESET_MICROBLAZE) |
| 85 | int ret; |
Shreenidhi Shedi | 1f8fcbb | 2018-07-15 02:05:40 +0530 | [diff] [blame] | 86 | |
Michal Simek | 4e39ea8 | 2018-07-13 08:26:28 +0200 | [diff] [blame] | 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 |
Michal Simek | 0152524 | 2015-12-11 15:01:28 +0100 | [diff] [blame] | 92 | return 0; |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 93 | } |