blob: fb8eab07d76820dbc5fcc77756205b919d538a7e [file] [log] [blame]
Michal Simekaf482d52012-09-28 09:56:37 +00001/*
2 * (C) Copyright 2012 Michal Simek <monstr@monstr.eu>
Michal Simek98d0f1f2018-01-17 07:37:47 +01003 * (C) Copyright 2013 - 2018 Xilinx, Inc.
Michal Simekaf482d52012-09-28 09:56:37 +00004 *
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +02005 * SPDX-License-Identifier: GPL-2.0+
Michal Simekaf482d52012-09-28 09:56:37 +00006 */
7
8#include <common.h>
Michal Simek65ef52f2014-02-24 11:16:32 +01009#include <fdtdec.h>
Michal Simek0f796702014-04-25 13:51:17 +020010#include <fpga.h>
11#include <mmc.h>
Michal Simek15d654c2013-04-22 15:43:02 +020012#include <zynqpl.h>
Michal Simek242192b2013-04-12 16:33:08 +020013#include <asm/arch/hardware.h>
14#include <asm/arch/sys_proto.h>
Michal Simekb8262d02017-11-10 13:01:10 +010015#include <asm/arch/ps7_init_gpl.h>
Michal Simekaf482d52012-09-28 09:56:37 +000016
17DECLARE_GLOBAL_DATA_PTR;
18
Michal Simekda713862014-03-04 12:41:05 +010019#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
20 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek0f796702014-04-25 13:51:17 +020021static xilinx_desc fpga;
Michal Simek15d654c2013-04-22 15:43:02 +020022
23/* It can be done differently */
Michal Simek82c97022016-10-18 16:10:25 +020024static xilinx_desc fpga007s = XILINX_XC7Z007S_DESC(0x7);
Michal Simek0f796702014-04-25 13:51:17 +020025static xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10);
Michal Simek82c97022016-10-18 16:10:25 +020026static xilinx_desc fpga012s = XILINX_XC7Z012S_DESC(0x12);
27static xilinx_desc fpga014s = XILINX_XC7Z014S_DESC(0x14);
Michal Simek0f796702014-04-25 13:51:17 +020028static xilinx_desc fpga015 = XILINX_XC7Z015_DESC(0x15);
29static xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20);
30static xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30);
Siva Durga Prasad Paladugu77fc12c2014-11-25 15:29:54 +053031static xilinx_desc fpga035 = XILINX_XC7Z035_DESC(0x35);
Michal Simek0f796702014-04-25 13:51:17 +020032static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
33static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
Michal Simek15d654c2013-04-22 15:43:02 +020034#endif
35
Michal Simekaf482d52012-09-28 09:56:37 +000036int board_init(void)
37{
Michal Simekda713862014-03-04 12:41:05 +010038#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
39 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek15d654c2013-04-22 15:43:02 +020040 u32 idcode;
41
42 idcode = zynq_slcr_get_idcode();
43
44 switch (idcode) {
Michal Simek82c97022016-10-18 16:10:25 +020045 case XILINX_ZYNQ_7007S:
46 fpga = fpga007s;
47 break;
Michal Simek15d654c2013-04-22 15:43:02 +020048 case XILINX_ZYNQ_7010:
49 fpga = fpga010;
50 break;
Michal Simek82c97022016-10-18 16:10:25 +020051 case XILINX_ZYNQ_7012S:
52 fpga = fpga012s;
53 break;
54 case XILINX_ZYNQ_7014S:
55 fpga = fpga014s;
56 break;
Michal Simek0e91d3a2013-09-26 16:39:03 +020057 case XILINX_ZYNQ_7015:
58 fpga = fpga015;
59 break;
Michal Simek15d654c2013-04-22 15:43:02 +020060 case XILINX_ZYNQ_7020:
61 fpga = fpga020;
62 break;
63 case XILINX_ZYNQ_7030:
64 fpga = fpga030;
65 break;
Siva Durga Prasad Paladugu77fc12c2014-11-25 15:29:54 +053066 case XILINX_ZYNQ_7035:
67 fpga = fpga035;
68 break;
Michal Simek15d654c2013-04-22 15:43:02 +020069 case XILINX_ZYNQ_7045:
70 fpga = fpga045;
71 break;
Michal Simek52f91b52013-06-17 13:54:07 +020072 case XILINX_ZYNQ_7100:
73 fpga = fpga100;
74 break;
Michal Simek15d654c2013-04-22 15:43:02 +020075 }
76#endif
77
Michal Simekda713862014-03-04 12:41:05 +010078#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
79 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek15d654c2013-04-22 15:43:02 +020080 fpga_init();
81 fpga_add(fpga_xilinx, &fpga);
82#endif
83
Michal Simekaf482d52012-09-28 09:56:37 +000084 return 0;
85}
86
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053087int board_late_init(void)
88{
89 switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
Michal Simek19356712016-12-16 13:16:14 +010090 case ZYNQ_BM_QSPI:
Simon Glass6a38e412017-08-03 12:22:09 -060091 env_set("modeboot", "qspiboot");
Michal Simek19356712016-12-16 13:16:14 +010092 break;
93 case ZYNQ_BM_NAND:
Simon Glass6a38e412017-08-03 12:22:09 -060094 env_set("modeboot", "nandboot");
Michal Simek19356712016-12-16 13:16:14 +010095 break;
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053096 case ZYNQ_BM_NOR:
Simon Glass6a38e412017-08-03 12:22:09 -060097 env_set("modeboot", "norboot");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053098 break;
99 case ZYNQ_BM_SD:
Simon Glass6a38e412017-08-03 12:22:09 -0600100 env_set("modeboot", "sdboot");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +0530101 break;
102 case ZYNQ_BM_JTAG:
Simon Glass6a38e412017-08-03 12:22:09 -0600103 env_set("modeboot", "jtagboot");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +0530104 break;
105 default:
Simon Glass6a38e412017-08-03 12:22:09 -0600106 env_set("modeboot", "");
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +0530107 break;
108 }
109
110 return 0;
111}
Michal Simekaf482d52012-09-28 09:56:37 +0000112
Michal Simek3fa64452014-08-28 13:31:02 +0200113#ifdef CONFIG_DISPLAY_BOARDINFO
114int checkboard(void)
115{
Michal Simekb8262d02017-11-10 13:01:10 +0100116 u32 version = zynq_get_silicon_version();
117
118 version <<= 1;
119 if (version > (PCW_SILICON_VERSION_3 << 1))
120 version += 1;
121
Michal Simek47ce9362016-01-25 11:04:21 +0100122 puts("Board: Xilinx Zynq\n");
Michal Simekb8262d02017-11-10 13:01:10 +0100123 printf("Silicon: v%d.%d\n", version >> 1, version & 1);
124
Michal Simek3fa64452014-08-28 13:31:02 +0200125 return 0;
126}
127#endif
128
Joe Hershberger7f4e5552016-01-26 11:57:03 -0600129int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
130{
131#if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
132 defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET)
133 if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR,
134 CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET,
135 ethaddr, 6))
136 printf("I2C EEPROM MAC address read failed\n");
137#endif
138
139 return 0;
140}
141
Michal Simekf4780a72016-04-01 15:56:33 +0200142#if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE)
Simon Glass2f949c32017-03-31 08:40:32 -0600143int dram_init_banksize(void)
Nathan Rossic12892b2016-12-04 19:33:22 +1000144{
Michal Simekd5b7de62017-11-03 15:25:51 +0100145 return fdtdec_setup_memory_banksize();
Tom Riniedcfdbd2016-12-09 07:56:54 -0500146}
Michal Simekf4780a72016-04-01 15:56:33 +0200147
Tom Riniedcfdbd2016-12-09 07:56:54 -0500148int dram_init(void)
149{
Nathan Rossi58ea0d82016-12-19 00:03:34 +1000150 if (fdtdec_setup_memory_size() != 0)
151 return -EINVAL;
Tom Riniedcfdbd2016-12-09 07:56:54 -0500152
153 zynq_ddrc_init();
154
155 return 0;
Michal Simekf4780a72016-04-01 15:56:33 +0200156}
Michal Simekf4780a72016-04-01 15:56:33 +0200157#else
158int dram_init(void)
159{
160 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
161
Michal Simekf5ff7bc2013-06-17 14:37:01 +0200162 zynq_ddrc_init();
163
Michal Simekaf482d52012-09-28 09:56:37 +0000164 return 0;
165}
Michal Simekf4780a72016-04-01 15:56:33 +0200166#endif