blob: 42a8d0c400e5917262f709fffe128095568e50a7 [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 Simek7f581f02010-08-02 14:42:09 +020014#include <netdev.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
20#ifdef CONFIG_XILINX_GPIO
21static int reset_pin = -1;
22#endif
Michal Simek952d5142007-03-11 13:42:58 +010023
Mike Frysinger6d1f6982010-10-20 03:41:17 -040024int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Michal Simek952d5142007-03-11 13:42:58 +010025{
Michal Simek23ccda02013-04-24 10:01:20 +020026#ifdef CONFIG_XILINX_GPIO
27 if (reset_pin != -1)
28 gpio_direction_output(reset_pin, 1);
Michal Simek952d5142007-03-11 13:42:58 +010029#endif
Michal Simek25d20af2012-11-02 09:33:05 +010030
Michal Simek80e045f2013-04-22 11:23:16 +020031#ifdef CONFIG_XILINX_TB_WATCHDOG
32 hw_watchdog_disable();
33#endif
34
Michal Simek952d5142007-03-11 13:42:58 +010035 puts ("Reseting board\n");
Michal Simekc9446872012-11-07 15:27:39 +010036 __asm__ __volatile__ (" mts rmsr, r0;" \
37 "bra r0");
Michal Simek25d20af2012-11-02 09:33:05 +010038
Mike Frysinger6d1f6982010-10-20 03:41:17 -040039 return 0;
Michal Simek952d5142007-03-11 13:42:58 +010040}
41
42int gpio_init (void)
43{
Michal Simek23ccda02013-04-24 10:01:20 +020044#ifdef CONFIG_XILINX_GPIO
45 reset_pin = gpio_alloc(CONFIG_SYS_GPIO_0_ADDR, "reset", 1);
46 if (reset_pin != -1)
47 gpio_request(reset_pin, "reset_pin");
Michal Simek952d5142007-03-11 13:42:58 +010048#endif
49 return 0;
50}
Michal Simek9c817f82007-05-07 19:33:51 +020051
Michal Simek9cabb362012-07-04 13:12:37 +020052void board_init(void)
53{
54 gpio_init();
Michal Simek9cabb362012-07-04 13:12:37 +020055}
56
Michal Simek7f581f02010-08-02 14:42:09 +020057int board_eth_init(bd_t *bis)
58{
Michal Simeka6745b82011-10-12 23:23:22 +000059 int ret = 0;
Michal Simek7a88e3a2011-08-31 11:51:50 +020060
61#ifdef CONFIG_XILINX_AXIEMAC
62 ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR,
63 XILINX_AXIDMA_BASEADDR);
64#endif
65
Michal Simek7f581f02010-08-02 14:42:09 +020066#ifdef CONFIG_XILINX_EMACLITE
Michal Simeka6745b82011-10-12 23:23:22 +000067 u32 txpp = 0;
68 u32 rxpp = 0;
69# ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
70 txpp = 1;
71# endif
72# ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
73 rxpp = 1;
74# endif
75 ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR,
76 txpp, rxpp);
Michal Simek7f581f02010-08-02 14:42:09 +020077#endif
Stephan Linzda949bc2012-02-25 00:48:34 +000078
79#ifdef CONFIG_XILINX_LL_TEMAC
80# ifdef XILINX_LLTEMAC_BASEADDR
81# ifdef XILINX_LLTEMAC_FIFO_BASEADDR
82 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR,
83 XILINX_LL_TEMAC_M_FIFO, XILINX_LLTEMAC_FIFO_BASEADDR);
84# elif XILINX_LLTEMAC_SDMA_CTRL_BASEADDR
85# if XILINX_LLTEMAC_SDMA_USE_DCR == 1
86 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR,
87 XILINX_LL_TEMAC_M_SDMA_DCR,
88 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR);
89# else
90 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR,
91 XILINX_LL_TEMAC_M_SDMA_PLB,
92 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR);
93# endif
94# endif
95# endif
96# ifdef XILINX_LLTEMAC_BASEADDR1
97# ifdef XILINX_LLTEMAC_FIFO_BASEADDR1
98 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR1,
99 XILINX_LL_TEMAC_M_FIFO, XILINX_LLTEMAC_FIFO_BASEADDR1);
100# elif XILINX_LLTEMAC_SDMA_CTRL_BASEADDR1
101# if XILINX_LLTEMAC_SDMA_USE_DCR == 1
102 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR1,
103 XILINX_LL_TEMAC_M_SDMA_DCR,
104 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR1);
105# else
106 ret |= xilinx_ll_temac_eth_init(bis, XILINX_LLTEMAC_BASEADDR1,
107 XILINX_LL_TEMAC_M_SDMA_PLB,
108 XILINX_LLTEMAC_SDMA_CTRL_BASEADDR1);
109# endif
110# endif
111# endif
112#endif
113
Michal Simeka6745b82011-10-12 23:23:22 +0000114 return ret;
Michal Simek7f581f02010-08-02 14:42:09 +0200115}