Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2012 Michal Simek <monstr@monstr.eu> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <netdev.h> |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 9 | #include <zynqpl.h> |
Michal Simek | 242192b | 2013-04-12 16:33:08 +0200 | [diff] [blame] | 10 | #include <asm/arch/hardware.h> |
| 11 | #include <asm/arch/sys_proto.h> |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 15 | #ifdef CONFIG_FPGA |
| 16 | Xilinx_desc fpga; |
| 17 | |
| 18 | /* It can be done differently */ |
| 19 | Xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10); |
| 20 | Xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20); |
| 21 | Xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30); |
| 22 | Xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45); |
| 23 | #endif |
| 24 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 25 | int board_init(void) |
| 26 | { |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 27 | #ifdef CONFIG_FPGA |
| 28 | u32 idcode; |
| 29 | |
| 30 | idcode = zynq_slcr_get_idcode(); |
| 31 | |
| 32 | switch (idcode) { |
| 33 | case XILINX_ZYNQ_7010: |
| 34 | fpga = fpga010; |
| 35 | break; |
| 36 | case XILINX_ZYNQ_7020: |
| 37 | fpga = fpga020; |
| 38 | break; |
| 39 | case XILINX_ZYNQ_7030: |
| 40 | fpga = fpga030; |
| 41 | break; |
| 42 | case XILINX_ZYNQ_7045: |
| 43 | fpga = fpga045; |
| 44 | break; |
| 45 | } |
| 46 | #endif |
| 47 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 48 | icache_enable(); |
| 49 | |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 50 | #ifdef CONFIG_FPGA |
| 51 | fpga_init(); |
| 52 | fpga_add(fpga_xilinx, &fpga); |
| 53 | #endif |
| 54 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | #ifdef CONFIG_CMD_NET |
| 60 | int board_eth_init(bd_t *bis) |
| 61 | { |
| 62 | u32 ret = 0; |
| 63 | |
Michal Simek | 242192b | 2013-04-12 16:33:08 +0200 | [diff] [blame] | 64 | #if defined(CONFIG_ZYNQ_GEM) |
| 65 | # if defined(CONFIG_ZYNQ_GEM0) |
David Andrey | 1b0dd5e | 2013-04-04 19:13:07 +0200 | [diff] [blame] | 66 | ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0, |
David Andrey | 73875dc | 2013-04-05 17:24:24 +0200 | [diff] [blame] | 67 | CONFIG_ZYNQ_GEM_PHY_ADDR0, 0); |
Michal Simek | 242192b | 2013-04-12 16:33:08 +0200 | [diff] [blame] | 68 | # endif |
| 69 | # if defined(CONFIG_ZYNQ_GEM1) |
David Andrey | 1b0dd5e | 2013-04-04 19:13:07 +0200 | [diff] [blame] | 70 | ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1, |
David Andrey | 73875dc | 2013-04-05 17:24:24 +0200 | [diff] [blame] | 71 | CONFIG_ZYNQ_GEM_PHY_ADDR1, 0); |
Michal Simek | 242192b | 2013-04-12 16:33:08 +0200 | [diff] [blame] | 72 | # endif |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 73 | #endif |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 74 | return ret; |
| 75 | } |
| 76 | #endif |
| 77 | |
Michal Simek | 0dd222b | 2013-04-22 14:56:49 +0200 | [diff] [blame] | 78 | #ifdef CONFIG_CMD_MMC |
| 79 | int board_mmc_init(bd_t *bd) |
| 80 | { |
| 81 | int ret = 0; |
| 82 | |
| 83 | #if defined(CONFIG_ZYNQ_SDHCI) |
| 84 | # if defined(CONFIG_ZYNQ_SDHCI0) |
| 85 | ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0); |
| 86 | # endif |
| 87 | # if defined(CONFIG_ZYNQ_SDHCI1) |
| 88 | ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1); |
| 89 | # endif |
| 90 | #endif |
| 91 | return ret; |
| 92 | } |
| 93 | #endif |
| 94 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 95 | int dram_init(void) |
| 96 | { |
| 97 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
| 98 | |
Michal Simek | f5ff7bc | 2013-06-17 14:37:01 +0200 | [diff] [blame^] | 99 | zynq_ddrc_init(); |
| 100 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 101 | return 0; |
| 102 | } |