Michal Simek | 952d514 | 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 | bd8ec7e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 952d514 | 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 | dda9bd8 | 2007-03-30 22:52:09 +0200 | [diff] [blame] | 13 | #include <config.h> |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 14 | #include <fdtdec.h> |
Michal Simek | 7f581f0 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 15 | #include <netdev.h> |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 16 | #include <asm/processor.h> |
Michal Simek | 9c817f8 | 2007-05-07 19:33:51 +0200 | [diff] [blame] | 17 | #include <asm/microblaze_intc.h> |
| 18 | #include <asm/asm.h> |
Michal Simek | 23ccda0 | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 19 | #include <asm/gpio.h> |
| 20 | |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Michal Simek | 23ccda0 | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 23 | #ifdef CONFIG_XILINX_GPIO |
| 24 | static int reset_pin = -1; |
| 25 | #endif |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 26 | |
Masahiro Yamada | 366b24f | 2015-08-12 07:31:55 +0900 | [diff] [blame] | 27 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Michal Simek | 65e915c | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 28 | ulong ram_base; |
| 29 | |
| 30 | void 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 | |
| 36 | int 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 |
| 62 | int dram_init(void) |
| 63 | { |
| 64 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | #endif |
| 69 | |
Mike Frysinger | 6d1f698 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 70 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 71 | { |
Michal Simek | 8cd2491 | 2015-12-09 11:53:25 +0100 | [diff] [blame] | 72 | #ifndef CONFIG_SPL_BUILD |
Michal Simek | 23ccda0 | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 73 | #ifdef CONFIG_XILINX_GPIO |
| 74 | if (reset_pin != -1) |
| 75 | gpio_direction_output(reset_pin, 1); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 76 | #endif |
Michal Simek | 25d20af | 2012-11-02 09:33:05 +0100 | [diff] [blame] | 77 | |
Michal Simek | 80e045f | 2013-04-22 11:23:16 +0200 | [diff] [blame] | 78 | #ifdef CONFIG_XILINX_TB_WATCHDOG |
| 79 | hw_watchdog_disable(); |
| 80 | #endif |
Michal Simek | 8cd2491 | 2015-12-09 11:53:25 +0100 | [diff] [blame] | 81 | #endif |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 82 | puts ("Reseting board\n"); |
Michal Simek | c944687 | 2012-11-07 15:27:39 +0100 | [diff] [blame] | 83 | __asm__ __volatile__ (" mts rmsr, r0;" \ |
| 84 | "bra r0"); |
Michal Simek | 25d20af | 2012-11-02 09:33:05 +0100 | [diff] [blame] | 85 | |
Mike Frysinger | 6d1f698 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 86 | return 0; |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | int gpio_init (void) |
| 90 | { |
Michal Simek | 23ccda0 | 2013-04-24 10:01:20 +0200 | [diff] [blame] | 91 | #ifdef CONFIG_XILINX_GPIO |
| 92 | reset_pin = gpio_alloc(CONFIG_SYS_GPIO_0_ADDR, "reset", 1); |
| 93 | if (reset_pin != -1) |
| 94 | gpio_request(reset_pin, "reset_pin"); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 95 | #endif |
| 96 | return 0; |
| 97 | } |
Michal Simek | 9c817f8 | 2007-05-07 19:33:51 +0200 | [diff] [blame] | 98 | |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 99 | void board_init(void) |
| 100 | { |
| 101 | gpio_init(); |
Michal Simek | 9cabb36 | 2012-07-04 13:12:37 +0200 | [diff] [blame] | 102 | } |
| 103 | |
Michal Simek | 7f581f0 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 104 | int board_eth_init(bd_t *bis) |
| 105 | { |
Michal Simek | a6745b8 | 2011-10-12 23:23:22 +0000 | [diff] [blame] | 106 | int ret = 0; |
Michal Simek | 7a88e3a | 2011-08-31 11:51:50 +0200 | [diff] [blame] | 107 | |
| 108 | #ifdef CONFIG_XILINX_AXIEMAC |
| 109 | ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR, |
| 110 | XILINX_AXIDMA_BASEADDR); |
| 111 | #endif |
| 112 | |
Nathan Rossi | e856709 | 2015-04-14 16:16:39 +1000 | [diff] [blame] | 113 | #if defined(CONFIG_XILINX_EMACLITE) && defined(XILINX_EMACLITE_BASEADDR) |
Michal Simek | a6745b8 | 2011-10-12 23:23:22 +0000 | [diff] [blame] | 114 | u32 txpp = 0; |
| 115 | u32 rxpp = 0; |
| 116 | # ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG |
| 117 | txpp = 1; |
| 118 | # endif |
| 119 | # ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG |
| 120 | rxpp = 1; |
| 121 | # endif |
| 122 | ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR, |
| 123 | txpp, rxpp); |
Michal Simek | 7f581f0 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 124 | #endif |
Stephan Linz | da949bc | 2012-02-25 00:48:34 +0000 | [diff] [blame] | 125 | |
Michal Simek | a6745b8 | 2011-10-12 23:23:22 +0000 | [diff] [blame] | 126 | return ret; |
Michal Simek | 7f581f0 | 2010-08-02 14:42:09 +0200 | [diff] [blame] | 127 | } |