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 | bd8ec7e | 2013-10-07 13:07:26 +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> |
Michal Simek | 65ef52f | 2014-02-24 11:16:32 +0100 | [diff] [blame] | 8 | #include <fdtdec.h> |
Michal Simek | 0f79670 | 2014-04-25 13:51:17 +0200 | [diff] [blame] | 9 | #include <fpga.h> |
| 10 | #include <mmc.h> |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 11 | #include <zynqpl.h> |
Michal Simek | 242192b | 2013-04-12 16:33:08 +0200 | [diff] [blame] | 12 | #include <asm/arch/hardware.h> |
| 13 | #include <asm/arch/sys_proto.h> |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
Michal Simek | da71386 | 2014-03-04 12:41:05 +0100 | [diff] [blame] | 17 | #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \ |
| 18 | (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
Michal Simek | 0f79670 | 2014-04-25 13:51:17 +0200 | [diff] [blame] | 19 | static xilinx_desc fpga; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 20 | |
| 21 | /* It can be done differently */ |
Michal Simek | 0f79670 | 2014-04-25 13:51:17 +0200 | [diff] [blame] | 22 | static xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10); |
| 23 | static xilinx_desc fpga015 = XILINX_XC7Z015_DESC(0x15); |
| 24 | static xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20); |
| 25 | static xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30); |
Siva Durga Prasad Paladugu | 77fc12c | 2014-11-25 15:29:54 +0530 | [diff] [blame] | 26 | static xilinx_desc fpga035 = XILINX_XC7Z035_DESC(0x35); |
Michal Simek | 0f79670 | 2014-04-25 13:51:17 +0200 | [diff] [blame] | 27 | static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45); |
| 28 | static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100); |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 29 | #endif |
| 30 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 31 | int board_init(void) |
| 32 | { |
Michal Simek | da71386 | 2014-03-04 12:41:05 +0100 | [diff] [blame] | 33 | #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \ |
| 34 | (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 35 | u32 idcode; |
| 36 | |
| 37 | idcode = zynq_slcr_get_idcode(); |
| 38 | |
| 39 | switch (idcode) { |
| 40 | case XILINX_ZYNQ_7010: |
| 41 | fpga = fpga010; |
| 42 | break; |
Michal Simek | 0e91d3a | 2013-09-26 16:39:03 +0200 | [diff] [blame] | 43 | case XILINX_ZYNQ_7015: |
| 44 | fpga = fpga015; |
| 45 | break; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 46 | case XILINX_ZYNQ_7020: |
| 47 | fpga = fpga020; |
| 48 | break; |
| 49 | case XILINX_ZYNQ_7030: |
| 50 | fpga = fpga030; |
| 51 | break; |
Siva Durga Prasad Paladugu | 77fc12c | 2014-11-25 15:29:54 +0530 | [diff] [blame] | 52 | case XILINX_ZYNQ_7035: |
| 53 | fpga = fpga035; |
| 54 | break; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 55 | case XILINX_ZYNQ_7045: |
| 56 | fpga = fpga045; |
| 57 | break; |
Michal Simek | 52f91b5 | 2013-06-17 13:54:07 +0200 | [diff] [blame] | 58 | case XILINX_ZYNQ_7100: |
| 59 | fpga = fpga100; |
| 60 | break; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 61 | } |
| 62 | #endif |
| 63 | |
Michal Simek | da71386 | 2014-03-04 12:41:05 +0100 | [diff] [blame] | 64 | #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \ |
| 65 | (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 66 | fpga_init(); |
| 67 | fpga_add(fpga_xilinx, &fpga); |
| 68 | #endif |
| 69 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
Jagannadha Sutradharudu Teki | 11704c2 | 2014-01-09 01:48:21 +0530 | [diff] [blame] | 73 | int board_late_init(void) |
| 74 | { |
| 75 | switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) { |
| 76 | case ZYNQ_BM_NOR: |
| 77 | setenv("modeboot", "norboot"); |
| 78 | break; |
| 79 | case ZYNQ_BM_SD: |
| 80 | setenv("modeboot", "sdboot"); |
| 81 | break; |
| 82 | case ZYNQ_BM_JTAG: |
| 83 | setenv("modeboot", "jtagboot"); |
| 84 | break; |
| 85 | default: |
| 86 | setenv("modeboot", ""); |
| 87 | break; |
| 88 | } |
| 89 | |
| 90 | return 0; |
| 91 | } |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 92 | |
Michal Simek | 3fa6445 | 2014-08-28 13:31:02 +0200 | [diff] [blame] | 93 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 94 | int checkboard(void) |
| 95 | { |
Michal Simek | 47ce936 | 2016-01-25 11:04:21 +0100 | [diff] [blame^] | 96 | puts("Board: Xilinx Zynq\n"); |
Michal Simek | 3fa6445 | 2014-08-28 13:31:02 +0200 | [diff] [blame] | 97 | return 0; |
| 98 | } |
| 99 | #endif |
| 100 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 101 | int dram_init(void) |
| 102 | { |
Masahiro Yamada | 366b24f | 2015-08-12 07:31:55 +0900 | [diff] [blame] | 103 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Michal Simek | 65ef52f | 2014-02-24 11:16:32 +0100 | [diff] [blame] | 104 | int node; |
| 105 | fdt_addr_t addr; |
| 106 | fdt_size_t size; |
| 107 | const void *blob = gd->fdt_blob; |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 108 | |
Michal Simek | 65ef52f | 2014-02-24 11:16:32 +0100 | [diff] [blame] | 109 | node = fdt_node_offset_by_prop_value(blob, -1, "device_type", |
| 110 | "memory", 7); |
| 111 | if (node == -FDT_ERR_NOTFOUND) { |
| 112 | debug("ZYNQ DRAM: Can't get memory node\n"); |
| 113 | return -1; |
| 114 | } |
| 115 | addr = fdtdec_get_addr_size(blob, node, "reg", &size); |
| 116 | if (addr == FDT_ADDR_T_NONE || size == 0) { |
| 117 | debug("ZYNQ DRAM: Can't get base address or size\n"); |
| 118 | return -1; |
| 119 | } |
| 120 | gd->ram_size = size; |
| 121 | #else |
| 122 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
| 123 | #endif |
Michal Simek | f5ff7bc | 2013-06-17 14:37:01 +0200 | [diff] [blame] | 124 | zynq_ddrc_init(); |
| 125 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 126 | return 0; |
| 127 | } |