blob: 0c8bd7d1511eb6213e96fac6dcb91201b81d49a6 [file] [log] [blame]
Michal Simek76316a32007-03-11 13:42:58 +01001/*
2 * (C) Copyright 2007 Michal Simek
3 *
4 * Michal SIMEK <monstr@monstr.eu>
5 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02006 * SPDX-License-Identifier: GPL-2.0+
Michal Simek76316a32007-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 Simek342cd092007-03-30 22:52:09 +020013#include <config.h>
Michal Simeke945f6d2014-05-08 16:08:44 +020014#include <fdtdec.h>
Michal Simekd69f8f42010-08-02 14:42:09 +020015#include <netdev.h>
Michal Simek2380b8f2012-07-04 13:12:37 +020016#include <asm/processor.h>
Michal Simek19bf1fb2007-05-07 19:33:51 +020017#include <asm/microblaze_intc.h>
18#include <asm/asm.h>
Michal Simek4e779ad2013-04-24 10:01:20 +020019#include <asm/gpio.h>
20
Michal Simeke945f6d2014-05-08 16:08:44 +020021DECLARE_GLOBAL_DATA_PTR;
22
Michal Simek4e779ad2013-04-24 10:01:20 +020023#ifdef CONFIG_XILINX_GPIO
24static int reset_pin = -1;
25#endif
Michal Simek76316a32007-03-11 13:42:58 +010026
Masahiro Yamada0f925822015-08-12 07:31:55 +090027#if CONFIG_IS_ENABLED(OF_CONTROL)
Michal Simeke945f6d2014-05-08 16:08:44 +020028ulong ram_base;
29
30void dram_init_banksize(void)
31{
32 gd->bd->bi_dram[0].start = ram_base;
33 gd->bd->bi_dram[0].size = get_effective_memsize();
34}
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};
61#else
62int dram_init(void)
63{
64 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
65
66 return 0;
67}
68#endif
69
Mike Frysinger882b7d72010-10-20 03:41:17 -040070int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Michal Simek76316a32007-03-11 13:42:58 +010071{
Michal Simek4e779ad2013-04-24 10:01:20 +020072#ifdef CONFIG_XILINX_GPIO
73 if (reset_pin != -1)
74 gpio_direction_output(reset_pin, 1);
Michal Simek76316a32007-03-11 13:42:58 +010075#endif
Michal Simekb3647272012-11-02 09:33:05 +010076
Michal Simek0f21f982013-04-22 11:23:16 +020077#ifdef CONFIG_XILINX_TB_WATCHDOG
78 hw_watchdog_disable();
79#endif
80
Michal Simek76316a32007-03-11 13:42:58 +010081 puts ("Reseting board\n");
Michal Simek88486682012-11-07 15:27:39 +010082 __asm__ __volatile__ (" mts rmsr, r0;" \
83 "bra r0");
Michal Simekb3647272012-11-02 09:33:05 +010084
Mike Frysinger882b7d72010-10-20 03:41:17 -040085 return 0;
Michal Simek76316a32007-03-11 13:42:58 +010086}
87
88int gpio_init (void)
89{
Michal Simek4e779ad2013-04-24 10:01:20 +020090#ifdef CONFIG_XILINX_GPIO
91 reset_pin = gpio_alloc(CONFIG_SYS_GPIO_0_ADDR, "reset", 1);
92 if (reset_pin != -1)
93 gpio_request(reset_pin, "reset_pin");
Michal Simek76316a32007-03-11 13:42:58 +010094#endif
95 return 0;
96}
Michal Simek19bf1fb2007-05-07 19:33:51 +020097
Michal Simek2380b8f2012-07-04 13:12:37 +020098void board_init(void)
99{
100 gpio_init();
Michal Simek2380b8f2012-07-04 13:12:37 +0200101}
102
Michal Simekd69f8f42010-08-02 14:42:09 +0200103int board_eth_init(bd_t *bis)
104{
Michal Simekc1044a12011-10-12 23:23:22 +0000105 int ret = 0;
Michal Simeke6341382011-08-31 11:51:50 +0200106
107#ifdef CONFIG_XILINX_AXIEMAC
108 ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR,
109 XILINX_AXIDMA_BASEADDR);
110#endif
111
Nathan Rossi127e8a52015-04-14 16:16:39 +1000112#if defined(CONFIG_XILINX_EMACLITE) && defined(XILINX_EMACLITE_BASEADDR)
Michal Simekc1044a12011-10-12 23:23:22 +0000113 u32 txpp = 0;
114 u32 rxpp = 0;
115# ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
116 txpp = 1;
117# endif
118# ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
119 rxpp = 1;
120# endif
121 ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR,
122 txpp, rxpp);
Michal Simekd69f8f42010-08-02 14:42:09 +0200123#endif
Stephan Linz3ceecef2012-02-25 00:48:34 +0000124
125#ifdef CONFIG_XILINX_LL_TEMAC
126# ifdef XILINX_LLTEMAC_BASEADDR
127# ifdef XILINX_LLTEMAC_FIFO_BASEADDR
128 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR,
129 XILINX_LL_TEMAC_M_FIFO, XILINX_LLTEMAC_FIFO_BASEADDR);
130# elif XILINX_LLTEMAC_SDMA_CTRL_BASEADDR
131# if XILINX_LLTEMAC_SDMA_USE_DCR == 1
132 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR,
133 XILINX_LL_TEMAC_M_SDMA_DCR,
134 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR);
135# else
136 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR,
137 XILINX_LL_TEMAC_M_SDMA_PLB,
138 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR);
139# endif
140# endif
141# endif
142# ifdef XILINX_LLTEMAC_BASEADDR1
143# ifdef XILINX_LLTEMAC_FIFO_BASEADDR1
144 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR1,
145 XILINX_LL_TEMAC_M_FIFO, XILINX_LLTEMAC_FIFO_BASEADDR1);
146# elif XILINX_LLTEMAC_SDMA_CTRL_BASEADDR1
147# if XILINX_LLTEMAC_SDMA_USE_DCR == 1
148 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR1,
149 XILINX_LL_TEMAC_M_SDMA_DCR,
150 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR1);
151# else
152 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR1,
153 XILINX_LL_TEMAC_M_SDMA_PLB,
154 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR1);
155# endif
156# endif
157# endif
158#endif
159
Michal Simekc1044a12011-10-12 23:23:22 +0000160 return ret;
Michal Simekd69f8f42010-08-02 14:42:09 +0200161}