blob: be7154ea147cfa13407a64802d33c84d713d9be3 [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 Denk1a459662013-07-08 09:37:19 +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 Simekd69f8f42010-08-02 14:42:09 +020014#include <netdev.h>
Michal Simek2380b8f2012-07-04 13:12:37 +020015#include <asm/processor.h>
Michal Simek19bf1fb2007-05-07 19:33:51 +020016#include <asm/microblaze_intc.h>
17#include <asm/asm.h>
Michal Simek4e779ad2013-04-24 10:01:20 +020018#include <asm/gpio.h>
19
20#ifdef CONFIG_XILINX_GPIO
21static int reset_pin = -1;
22#endif
Michal Simek76316a32007-03-11 13:42:58 +010023
Mike Frysinger882b7d72010-10-20 03:41:17 -040024int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Michal Simek76316a32007-03-11 13:42:58 +010025{
Michal Simek4e779ad2013-04-24 10:01:20 +020026#ifdef CONFIG_XILINX_GPIO
27 if (reset_pin != -1)
28 gpio_direction_output(reset_pin, 1);
Michal Simek76316a32007-03-11 13:42:58 +010029#endif
Michal Simekb3647272012-11-02 09:33:05 +010030
Michal Simek0f21f982013-04-22 11:23:16 +020031#ifdef CONFIG_XILINX_TB_WATCHDOG
32 hw_watchdog_disable();
33#endif
34
Michal Simek76316a32007-03-11 13:42:58 +010035 puts ("Reseting board\n");
Michal Simek88486682012-11-07 15:27:39 +010036 __asm__ __volatile__ (" mts rmsr, r0;" \
37 "bra r0");
Michal Simekb3647272012-11-02 09:33:05 +010038
Mike Frysinger882b7d72010-10-20 03:41:17 -040039 return 0;
Michal Simek76316a32007-03-11 13:42:58 +010040}
41
42int gpio_init (void)
43{
Michal Simek4e779ad2013-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 Simek76316a32007-03-11 13:42:58 +010048#endif
49 return 0;
50}
Michal Simek19bf1fb2007-05-07 19:33:51 +020051
Michal Simek2380b8f2012-07-04 13:12:37 +020052void board_init(void)
53{
54 gpio_init();
Michal Simek2380b8f2012-07-04 13:12:37 +020055}
56
Michal Simekd69f8f42010-08-02 14:42:09 +020057int board_eth_init(bd_t *bis)
58{
Michal Simekc1044a12011-10-12 23:23:22 +000059 int ret = 0;
Michal Simeke6341382011-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 Simekd69f8f42010-08-02 14:42:09 +020066#ifdef CONFIG_XILINX_EMACLITE
Michal Simekc1044a12011-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 Simekd69f8f42010-08-02 14:42:09 +020077#endif
Stephan Linz3ceecef2012-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 Simekc1044a12011-10-12 23:23:22 +0000114 return ret;
Michal Simekd69f8f42010-08-02 14:42:09 +0200115}