Michal Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 Michal Simek |
| 3 | * |
| 4 | * Michal SIMEK <monstr@monstr.eu> |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | /* This is a board specific file. It's OK to include board specific |
| 10 | * header files */ |
| 11 | |
| 12 | #include <common.h> |
Michal Simek | 342cd09 | 2007-03-30 22:52:09 +0200 | [diff] [blame] | 13 | #include <config.h> |
Michal Simek | d69f8f4 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 14 | #include <netdev.h> |
Michal Simek | 2380b8f | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 15 | #include <asm/processor.h> |
Michal Simek | 19bf1fb | 2007-05-07 19:33:51 +0200 | [diff] [blame] | 16 | #include <asm/microblaze_intc.h> |
| 17 | #include <asm/asm.h> |
Michal Simek | 4e779ad | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 18 | #include <asm/gpio.h> |
| 19 | |
| 20 | #ifdef CONFIG_XILINX_GPIO |
| 21 | static int reset_pin = -1; |
| 22 | #endif |
Michal Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 23 | |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 24 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Michal Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 25 | { |
Michal Simek | 4e779ad | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 26 | #ifdef CONFIG_XILINX_GPIO |
| 27 | if (reset_pin != -1) |
| 28 | gpio_direction_output(reset_pin, 1); |
Michal Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 29 | #endif |
Michal Simek | b364727 | 2012-11-02 09:33:05 +0100 | [diff] [blame] | 30 | |
Michal Simek | 0f21f98 | 2013-04-22 11:23:16 +0200 | [diff] [blame] | 31 | #ifdef CONFIG_XILINX_TB_WATCHDOG |
| 32 | hw_watchdog_disable(); |
| 33 | #endif |
| 34 | |
Michal Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 35 | puts ("Reseting board\n"); |
Michal Simek | 8848668 | 2012-11-07 15:27:39 +0100 | [diff] [blame] | 36 | __asm__ __volatile__ (" mts rmsr, r0;" \ |
| 37 | "bra r0"); |
Michal Simek | b364727 | 2012-11-02 09:33:05 +0100 | [diff] [blame] | 38 | |
Mike Frysinger | 882b7d7 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 39 | return 0; |
Michal Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | int gpio_init (void) |
| 43 | { |
Michal Simek | 4e779ad | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 44 | #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 Simek | 76316a3 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 48 | #endif |
| 49 | return 0; |
| 50 | } |
Michal Simek | 19bf1fb | 2007-05-07 19:33:51 +0200 | [diff] [blame] | 51 | |
Michal Simek | 2380b8f | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 52 | void board_init(void) |
| 53 | { |
| 54 | gpio_init(); |
Michal Simek | 2380b8f | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 55 | } |
| 56 | |
Michal Simek | d69f8f4 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 57 | int board_eth_init(bd_t *bis) |
| 58 | { |
Michal Simek | c1044a1 | 2011-10-12 23:23:22 +0000 | [diff] [blame] | 59 | int ret = 0; |
Michal Simek | e634138 | 2011-08-31 11:51:50 +0200 | [diff] [blame] | 60 | |
| 61 | #ifdef CONFIG_XILINX_AXIEMAC |
| 62 | ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR, |
| 63 | XILINX_AXIDMA_BASEADDR); |
| 64 | #endif |
| 65 | |
Michal Simek | d69f8f4 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 66 | #ifdef CONFIG_XILINX_EMACLITE |
Michal Simek | c1044a1 | 2011-10-12 23:23:22 +0000 | [diff] [blame] | 67 | 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 Simek | d69f8f4 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 77 | #endif |
Stephan Linz | 3ceecef | 2012-02-25 00:48:34 +0000 | [diff] [blame] | 78 | |
| 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 Simek | c1044a1 | 2011-10-12 23:23:22 +0000 | [diff] [blame] | 114 | return ret; |
Michal Simek | d69f8f4 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 115 | } |