blob: e59038106aa6409a76b5e330292def7fe7671805 [file] [log] [blame]
Michal Simekaf482d52012-09-28 09:56:37 +00001/*
2 * (C) Copyright 2012 Michal Simek <monstr@monstr.eu>
3 *
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +02004 * SPDX-License-Identifier: GPL-2.0+
Michal Simekaf482d52012-09-28 09:56:37 +00005 */
6
7#include <common.h>
Michal Simek65ef52f2014-02-24 11:16:32 +01008#include <fdtdec.h>
Michal Simek0f796702014-04-25 13:51:17 +02009#include <fpga.h>
10#include <mmc.h>
Michal Simek15d654c2013-04-22 15:43:02 +020011#include <zynqpl.h>
Michal Simek242192b2013-04-12 16:33:08 +020012#include <asm/arch/hardware.h>
13#include <asm/arch/sys_proto.h>
Michal Simekb8262d02017-11-10 13:01:10 +010014#include <asm/arch/ps7_init_gpl.h>
Michal Simekaf482d52012-09-28 09:56:37 +000015
16DECLARE_GLOBAL_DATA_PTR;
17
Michal Simekda713862014-03-04 12:41:05 +010018#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
19 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek0f796702014-04-25 13:51:17 +020020static xilinx_desc fpga;
Michal Simek15d654c2013-04-22 15:43:02 +020021
22/* It can be done differently */
Michal Simek82c97022016-10-18 16:10:25 +020023static xilinx_desc fpga007s = XILINX_XC7Z007S_DESC(0x7);
Michal Simek0f796702014-04-25 13:51:17 +020024static xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10);
Michal Simek82c97022016-10-18 16:10:25 +020025static xilinx_desc fpga012s = XILINX_XC7Z012S_DESC(0x12);
26static xilinx_desc fpga014s = XILINX_XC7Z014S_DESC(0x14);
Michal Simek0f796702014-04-25 13:51:17 +020027static xilinx_desc fpga015 = XILINX_XC7Z015_DESC(0x15);
28static xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20);
29static xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30);
Siva Durga Prasad Paladugu77fc12c2014-11-25 15:29:54 +053030static xilinx_desc fpga035 = XILINX_XC7Z035_DESC(0x35);
Michal Simek0f796702014-04-25 13:51:17 +020031static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
32static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
Michal Simek15d654c2013-04-22 15:43:02 +020033#endif
34
Michal Simekaf482d52012-09-28 09:56:37 +000035int board_init(void)
36{
Michal Simekda713862014-03-04 12:41:05 +010037#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
38 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek15d654c2013-04-22 15:43:02 +020039 u32 idcode;
40
41 idcode = zynq_slcr_get_idcode();
42
43 switch (idcode) {
Michal Simek82c97022016-10-18 16:10:25 +020044 case XILINX_ZYNQ_7007S:
45 fpga = fpga007s;
46 break;
Michal Simek15d654c2013-04-22 15:43:02 +020047 case XILINX_ZYNQ_7010:
48 fpga = fpga010;
49 break;
Michal Simek82c97022016-10-18 16:10:25 +020050 case XILINX_ZYNQ_7012S:
51 fpga = fpga012s;
52 break;
53 case XILINX_ZYNQ_7014S:
54 fpga = fpga014s;
55 break;
Michal Simek0e91d3a2013-09-26 16:39:03 +020056 case XILINX_ZYNQ_7015:
57 fpga = fpga015;
58 break;
Michal Simek15d654c2013-04-22 15:43:02 +020059 case XILINX_ZYNQ_7020:
60 fpga = fpga020;
61 break;
62 case XILINX_ZYNQ_7030:
63 fpga = fpga030;
64 break;
Siva Durga Prasad Paladugu77fc12c2014-11-25 15:29:54 +053065 case XILINX_ZYNQ_7035:
66 fpga = fpga035;
67 break;
Michal Simek15d654c2013-04-22 15:43:02 +020068 case XILINX_ZYNQ_7045:
69 fpga = fpga045;
70 break;
Michal Simek52f91b52013-06-17 13:54:07 +020071 case XILINX_ZYNQ_7100:
72 fpga = fpga100;
73 break;
Michal Simek15d654c2013-04-22 15:43:02 +020074 }
75#endif
76
Michal Simekda713862014-03-04 12:41:05 +010077#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
78 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek15d654c2013-04-22 15:43:02 +020079 fpga_init();
80 fpga_add(fpga_xilinx, &fpga);
81#endif
82
Michal Simekaf482d52012-09-28 09:56:37 +000083 return 0;
84}
85
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053086int board_late_init(void)
87{
88 switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
Michal Simek19356712016-12-16 13:16:14 +010089 case ZYNQ_BM_QSPI:
Simon Glass6a38e412017-08-03 12:22:09 -060090 env_set("modeboot", "qspiboot");
Michal Simek19356712016-12-16 13:16:14 +010091 break;
92 case ZYNQ_BM_NAND:
Simon Glass6a38e412017-08-03 12:22:09 -060093 env_set("modeboot", "nandboot");
Michal Simek19356712016-12-16 13:16:14 +010094 break;
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053095 case ZYNQ_BM_NOR:
Simon Glass6a38e412017-08-03 12:22:09 -060096 env_set("modeboot", "norboot");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053097 break;
98 case ZYNQ_BM_SD:
Simon Glass6a38e412017-08-03 12:22:09 -060099 env_set("modeboot", "sdboot");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +0530100 break;
101 case ZYNQ_BM_JTAG:
Simon Glass6a38e412017-08-03 12:22:09 -0600102 env_set("modeboot", "jtagboot");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +0530103 break;
104 default:
Simon Glass6a38e412017-08-03 12:22:09 -0600105 env_set("modeboot", "");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +0530106 break;
107 }
108
109 return 0;
110}
Michal Simekaf482d52012-09-28 09:56:37 +0000111
Michal Simek3fa64452014-08-28 13:31:02 +0200112#ifdef CONFIG_DISPLAY_BOARDINFO
113int checkboard(void)
114{
Michal Simekb8262d02017-11-10 13:01:10 +0100115 u32 version = zynq_get_silicon_version();
116
117 version <<= 1;
118 if (version > (PCW_SILICON_VERSION_3 << 1))
119 version += 1;
120
Michal Simek47ce9362016-01-25 11:04:21 +0100121 puts("Board: Xilinx Zynq\n");
Michal Simekb8262d02017-11-10 13:01:10 +0100122 printf("Silicon: v%d.%d\n", version >> 1, version & 1);
123
Michal Simek3fa64452014-08-28 13:31:02 +0200124 return 0;
125}
126#endif
127
Joe Hershberger7f4e5552016-01-26 11:57:03 -0600128int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
129{
130#if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
131 defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET)
132 if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR,
133 CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET,
134 ethaddr, 6))
135 printf("I2C EEPROM MAC address read failed\n");
136#endif
137
138 return 0;
139}
140
Michal Simekf4780a72016-04-01 15:56:33 +0200141#if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE)
Simon Glass2f949c32017-03-31 08:40:32 -0600142int dram_init_banksize(void)
Nathan Rossic12892b2016-12-04 19:33:22 +1000143{
Michal Simekd5b7de62017-11-03 15:25:51 +0100144 return fdtdec_setup_memory_banksize();
Tom Riniedcfdbd2016-12-09 07:56:54 -0500145}
Michal Simekf4780a72016-04-01 15:56:33 +0200146
Tom Riniedcfdbd2016-12-09 07:56:54 -0500147int dram_init(void)
148{
Nathan Rossi58ea0d82016-12-19 00:03:34 +1000149 if (fdtdec_setup_memory_size() != 0)
150 return -EINVAL;
Tom Riniedcfdbd2016-12-09 07:56:54 -0500151
152 zynq_ddrc_init();
153
154 return 0;
Michal Simekf4780a72016-04-01 15:56:33 +0200155}
Michal Simekf4780a72016-04-01 15:56:33 +0200156#else
157int dram_init(void)
158{
159 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
160
Michal Simekf5ff7bc2013-06-17 14:37:01 +0200161 zynq_ddrc_init();
162
Michal Simekaf482d52012-09-28 09:56:37 +0000163 return 0;
164}
Michal Simekf4780a72016-04-01 15:56:33 +0200165#endif