blob: aa55ebad38112c77a164225914c4ea3e06242788 [file] [log] [blame]
Michal Simek952d5142007-03-11 13:42:58 +01001/*
2 * (C) Copyright 2007 Michal Simek
3 *
4 * Michal SIMEK <monstr@monstr.eu>
5 *
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +02006 * SPDX-License-Identifier: GPL-2.0+
Michal Simek952d5142007-03-11 13:42:58 +01007 */
8
9/* This is a board specific file. It's OK to include board specific
10 * header files */
11
12#include <common.h>
Michal Simekdda9bd82007-03-30 22:52:09 +020013#include <config.h>
Michal Simek65e915c2014-05-08 16:08:44 +020014#include <fdtdec.h>
Michal Simek9cabb362012-07-04 13:12:37 +020015#include <asm/processor.h>
Michal Simek9c817f82007-05-07 19:33:51 +020016#include <asm/microblaze_intc.h>
17#include <asm/asm.h>
Michal Simek23ccda02013-04-24 10:01:20 +020018#include <asm/gpio.h>
19
Michal Simek65e915c2014-05-08 16:08:44 +020020DECLARE_GLOBAL_DATA_PTR;
21
Michal Simek23ccda02013-04-24 10:01:20 +020022#ifdef CONFIG_XILINX_GPIO
23static int reset_pin = -1;
24#endif
Michal Simek952d5142007-03-11 13:42:58 +010025
Michal Simek65e915c2014-05-08 16:08:44 +020026ulong ram_base;
27
Simon Glass2f949c32017-03-31 08:40:32 -060028int dram_init_banksize(void)
Michal Simek65e915c2014-05-08 16:08:44 +020029{
30 gd->bd->bi_dram[0].start = ram_base;
31 gd->bd->bi_dram[0].size = get_effective_memsize();
Simon Glass2f949c32017-03-31 08:40:32 -060032
33 return 0;
Michal Simek65e915c2014-05-08 16:08:44 +020034}
35
36int dram_init(void)
37{
38 int node;
39 fdt_addr_t addr;
40 fdt_size_t size;
41 const void *blob = gd->fdt_blob;
42
43 node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
44 "memory", 7);
45 if (node == -FDT_ERR_NOTFOUND) {
46 debug("DRAM: Can't get memory node\n");
47 return 1;
48 }
49 addr = fdtdec_get_addr_size(blob, node, "reg", &size);
50 if (addr == FDT_ADDR_T_NONE || size == 0) {
51 debug("DRAM: Can't get base address or size\n");
52 return 1;
53 }
54 ram_base = addr;
55
56 gd->ram_top = addr; /* In setup_dest_addr() is done +ram_size */
57 gd->ram_size = size;
58
59 return 0;
60};
Michal Simek65e915c2014-05-08 16:08:44 +020061
Mike Frysinger6d1f6982010-10-20 03:41:17 -040062int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Michal Simek952d5142007-03-11 13:42:58 +010063{
Michal Simek8cd24912015-12-09 11:53:25 +010064#ifndef CONFIG_SPL_BUILD
Michal Simek23ccda02013-04-24 10:01:20 +020065#ifdef CONFIG_XILINX_GPIO
66 if (reset_pin != -1)
67 gpio_direction_output(reset_pin, 1);
Michal Simek952d5142007-03-11 13:42:58 +010068#endif
Michal Simek25d20af2012-11-02 09:33:05 +010069
Michal Simek80e045f2013-04-22 11:23:16 +020070#ifdef CONFIG_XILINX_TB_WATCHDOG
71 hw_watchdog_disable();
72#endif
Michal Simek8cd24912015-12-09 11:53:25 +010073#endif
Michal Simek952d5142007-03-11 13:42:58 +010074 puts ("Reseting board\n");
Michal Simekc9446872012-11-07 15:27:39 +010075 __asm__ __volatile__ (" mts rmsr, r0;" \
76 "bra r0");
Michal Simek25d20af2012-11-02 09:33:05 +010077
Mike Frysinger6d1f6982010-10-20 03:41:17 -040078 return 0;
Michal Simek952d5142007-03-11 13:42:58 +010079}
80
Michal Simek01525242015-12-11 15:01:28 +010081static int gpio_init(void)
Michal Simek952d5142007-03-11 13:42:58 +010082{
Michal Simek23ccda02013-04-24 10:01:20 +020083#ifdef CONFIG_XILINX_GPIO
84 reset_pin = gpio_alloc(CONFIG_SYS_GPIO_0_ADDR, "reset", 1);
85 if (reset_pin != -1)
86 gpio_request(reset_pin, "reset_pin");
Michal Simek952d5142007-03-11 13:42:58 +010087#endif
88 return 0;
89}
Michal Simek9c817f82007-05-07 19:33:51 +020090
Michal Simek01525242015-12-11 15:01:28 +010091int board_late_init(void)
Michal Simek9cabb362012-07-04 13:12:37 +020092{
93 gpio_init();
Michal Simek01525242015-12-11 15:01:28 +010094
95 return 0;
Michal Simek9cabb362012-07-04 13:12:37 +020096}