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 | 82c9702 | 2016-10-18 16:10:25 +0200 | [diff] [blame] | 22 | static xilinx_desc fpga007s = XILINX_XC7Z007S_DESC(0x7); |
Michal Simek | 0f79670 | 2014-04-25 13:51:17 +0200 | [diff] [blame] | 23 | static xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10); |
Michal Simek | 82c9702 | 2016-10-18 16:10:25 +0200 | [diff] [blame] | 24 | static xilinx_desc fpga012s = XILINX_XC7Z012S_DESC(0x12); |
| 25 | static xilinx_desc fpga014s = XILINX_XC7Z014S_DESC(0x14); |
Michal Simek | 0f79670 | 2014-04-25 13:51:17 +0200 | [diff] [blame] | 26 | static xilinx_desc fpga015 = XILINX_XC7Z015_DESC(0x15); |
| 27 | static xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20); |
| 28 | static xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30); |
Siva Durga Prasad Paladugu | 77fc12c | 2014-11-25 15:29:54 +0530 | [diff] [blame] | 29 | static xilinx_desc fpga035 = XILINX_XC7Z035_DESC(0x35); |
Michal Simek | 0f79670 | 2014-04-25 13:51:17 +0200 | [diff] [blame] | 30 | static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45); |
| 31 | static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100); |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 32 | #endif |
| 33 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 34 | int board_init(void) |
| 35 | { |
Michal Simek | da71386 | 2014-03-04 12:41:05 +0100 | [diff] [blame] | 36 | #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \ |
| 37 | (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 38 | u32 idcode; |
| 39 | |
| 40 | idcode = zynq_slcr_get_idcode(); |
| 41 | |
| 42 | switch (idcode) { |
Michal Simek | 82c9702 | 2016-10-18 16:10:25 +0200 | [diff] [blame] | 43 | case XILINX_ZYNQ_7007S: |
| 44 | fpga = fpga007s; |
| 45 | break; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 46 | case XILINX_ZYNQ_7010: |
| 47 | fpga = fpga010; |
| 48 | break; |
Michal Simek | 82c9702 | 2016-10-18 16:10:25 +0200 | [diff] [blame] | 49 | case XILINX_ZYNQ_7012S: |
| 50 | fpga = fpga012s; |
| 51 | break; |
| 52 | case XILINX_ZYNQ_7014S: |
| 53 | fpga = fpga014s; |
| 54 | break; |
Michal Simek | 0e91d3a | 2013-09-26 16:39:03 +0200 | [diff] [blame] | 55 | case XILINX_ZYNQ_7015: |
| 56 | fpga = fpga015; |
| 57 | break; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 58 | case XILINX_ZYNQ_7020: |
| 59 | fpga = fpga020; |
| 60 | break; |
| 61 | case XILINX_ZYNQ_7030: |
| 62 | fpga = fpga030; |
| 63 | break; |
Siva Durga Prasad Paladugu | 77fc12c | 2014-11-25 15:29:54 +0530 | [diff] [blame] | 64 | case XILINX_ZYNQ_7035: |
| 65 | fpga = fpga035; |
| 66 | break; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 67 | case XILINX_ZYNQ_7045: |
| 68 | fpga = fpga045; |
| 69 | break; |
Michal Simek | 52f91b5 | 2013-06-17 13:54:07 +0200 | [diff] [blame] | 70 | case XILINX_ZYNQ_7100: |
| 71 | fpga = fpga100; |
| 72 | break; |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 73 | } |
| 74 | #endif |
| 75 | |
Michal Simek | da71386 | 2014-03-04 12:41:05 +0100 | [diff] [blame] | 76 | #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \ |
| 77 | (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
Michal Simek | 15d654c | 2013-04-22 15:43:02 +0200 | [diff] [blame] | 78 | fpga_init(); |
| 79 | fpga_add(fpga_xilinx, &fpga); |
| 80 | #endif |
| 81 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 82 | return 0; |
| 83 | } |
| 84 | |
Jagannadha Sutradharudu Teki | 11704c2 | 2014-01-09 01:48:21 +0530 | [diff] [blame] | 85 | int board_late_init(void) |
| 86 | { |
| 87 | switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) { |
Michal Simek | 1935671 | 2016-12-16 13:16:14 +0100 | [diff] [blame] | 88 | case ZYNQ_BM_QSPI: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 89 | env_set("modeboot", "qspiboot"); |
Michal Simek | 1935671 | 2016-12-16 13:16:14 +0100 | [diff] [blame] | 90 | break; |
| 91 | case ZYNQ_BM_NAND: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 92 | env_set("modeboot", "nandboot"); |
Michal Simek | 1935671 | 2016-12-16 13:16:14 +0100 | [diff] [blame] | 93 | break; |
Jagannadha Sutradharudu Teki | 11704c2 | 2014-01-09 01:48:21 +0530 | [diff] [blame] | 94 | case ZYNQ_BM_NOR: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 95 | env_set("modeboot", "norboot"); |
Jagannadha Sutradharudu Teki | 11704c2 | 2014-01-09 01:48:21 +0530 | [diff] [blame] | 96 | break; |
| 97 | case ZYNQ_BM_SD: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 98 | env_set("modeboot", "sdboot"); |
Jagannadha Sutradharudu Teki | 11704c2 | 2014-01-09 01:48:21 +0530 | [diff] [blame] | 99 | break; |
| 100 | case ZYNQ_BM_JTAG: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 101 | env_set("modeboot", "jtagboot"); |
Jagannadha Sutradharudu Teki | 11704c2 | 2014-01-09 01:48:21 +0530 | [diff] [blame] | 102 | break; |
| 103 | default: |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 104 | env_set("modeboot", ""); |
Jagannadha Sutradharudu Teki | 11704c2 | 2014-01-09 01:48:21 +0530 | [diff] [blame] | 105 | break; |
| 106 | } |
| 107 | |
| 108 | return 0; |
| 109 | } |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 110 | |
Michal Simek | 3fa6445 | 2014-08-28 13:31:02 +0200 | [diff] [blame] | 111 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 112 | int checkboard(void) |
| 113 | { |
Michal Simek | 47ce936 | 2016-01-25 11:04:21 +0100 | [diff] [blame] | 114 | puts("Board: Xilinx Zynq\n"); |
Michal Simek | 3fa6445 | 2014-08-28 13:31:02 +0200 | [diff] [blame] | 115 | return 0; |
| 116 | } |
| 117 | #endif |
| 118 | |
Joe Hershberger | 7f4e555 | 2016-01-26 11:57:03 -0600 | [diff] [blame] | 119 | int zynq_board_read_rom_ethaddr(unsigned char *ethaddr) |
| 120 | { |
| 121 | #if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \ |
| 122 | defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) |
| 123 | if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR, |
| 124 | CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, |
| 125 | ethaddr, 6)) |
| 126 | printf("I2C EEPROM MAC address read failed\n"); |
| 127 | #endif |
| 128 | |
| 129 | return 0; |
| 130 | } |
| 131 | |
Michal Simek | f4780a7 | 2016-04-01 15:56:33 +0200 | [diff] [blame] | 132 | #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE) |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 133 | int dram_init_banksize(void) |
Nathan Rossi | c12892b | 2016-12-04 19:33:22 +1000 | [diff] [blame] | 134 | { |
Nathan Rossi | 58ea0d8 | 2016-12-19 00:03:34 +1000 | [diff] [blame] | 135 | fdtdec_setup_memory_banksize(); |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 136 | |
| 137 | return 0; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 138 | } |
Michal Simek | f4780a7 | 2016-04-01 15:56:33 +0200 | [diff] [blame] | 139 | |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 140 | int dram_init(void) |
| 141 | { |
Nathan Rossi | 58ea0d8 | 2016-12-19 00:03:34 +1000 | [diff] [blame] | 142 | if (fdtdec_setup_memory_size() != 0) |
| 143 | return -EINVAL; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 144 | |
| 145 | zynq_ddrc_init(); |
| 146 | |
| 147 | return 0; |
Michal Simek | f4780a7 | 2016-04-01 15:56:33 +0200 | [diff] [blame] | 148 | } |
Michal Simek | f4780a7 | 2016-04-01 15:56:33 +0200 | [diff] [blame] | 149 | #else |
| 150 | int dram_init(void) |
| 151 | { |
| 152 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
| 153 | |
Michal Simek | f5ff7bc | 2013-06-17 14:37:01 +0200 | [diff] [blame] | 154 | zynq_ddrc_init(); |
| 155 | |
Michal Simek | af482d5 | 2012-09-28 09:56:37 +0000 | [diff] [blame] | 156 | return 0; |
| 157 | } |
Michal Simek | f4780a7 | 2016-04-01 15:56:33 +0200 | [diff] [blame] | 158 | #endif |