blob: 4c20450b6359ee8d9a7cde888508ad659c9e1370 [file] [log] [blame]
Michal Simekf22651c2012-09-28 09:56:37 +00001/*
2 * (C) Copyright 2012 Michal Simek <monstr@monstr.eu>
3 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02004 * SPDX-License-Identifier: GPL-2.0+
Michal Simekf22651c2012-09-28 09:56:37 +00005 */
6
7#include <common.h>
Michal Simek9e0e37a2014-02-24 11:16:32 +01008#include <fdtdec.h>
Michal Simek5b73caf2014-04-25 13:51:17 +02009#include <fpga.h>
10#include <mmc.h>
Michal Simekd5dae852013-04-22 15:43:02 +020011#include <zynqpl.h>
Michal Simek71936532013-04-12 16:33:08 +020012#include <asm/arch/hardware.h>
13#include <asm/arch/sys_proto.h>
Michal Simekf22651c2012-09-28 09:56:37 +000014
15DECLARE_GLOBAL_DATA_PTR;
16
Michal Simek0b680202014-03-04 12:41:05 +010017#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
18 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek5b73caf2014-04-25 13:51:17 +020019static xilinx_desc fpga;
Michal Simekd5dae852013-04-22 15:43:02 +020020
21/* It can be done differently */
Michal Simek5b73caf2014-04-25 13:51:17 +020022static xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10);
23static xilinx_desc fpga015 = XILINX_XC7Z015_DESC(0x15);
24static xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20);
25static xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30);
Siva Durga Prasad Paladugub9103802014-11-25 15:29:54 +053026static xilinx_desc fpga035 = XILINX_XC7Z035_DESC(0x35);
Michal Simek5b73caf2014-04-25 13:51:17 +020027static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
28static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
Michal Simekd5dae852013-04-22 15:43:02 +020029#endif
30
Michal Simekf22651c2012-09-28 09:56:37 +000031int board_init(void)
32{
Michal Simek0b680202014-03-04 12:41:05 +010033#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
34 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simekd5dae852013-04-22 15:43:02 +020035 u32 idcode;
36
37 idcode = zynq_slcr_get_idcode();
38
39 switch (idcode) {
40 case XILINX_ZYNQ_7010:
41 fpga = fpga010;
42 break;
Michal Simek31993d62013-09-26 16:39:03 +020043 case XILINX_ZYNQ_7015:
44 fpga = fpga015;
45 break;
Michal Simekd5dae852013-04-22 15:43:02 +020046 case XILINX_ZYNQ_7020:
47 fpga = fpga020;
48 break;
49 case XILINX_ZYNQ_7030:
50 fpga = fpga030;
51 break;
Siva Durga Prasad Paladugub9103802014-11-25 15:29:54 +053052 case XILINX_ZYNQ_7035:
53 fpga = fpga035;
54 break;
Michal Simekd5dae852013-04-22 15:43:02 +020055 case XILINX_ZYNQ_7045:
56 fpga = fpga045;
57 break;
Michal Simekfd2b10b2013-06-17 13:54:07 +020058 case XILINX_ZYNQ_7100:
59 fpga = fpga100;
60 break;
Michal Simekd5dae852013-04-22 15:43:02 +020061 }
62#endif
63
Michal Simek0b680202014-03-04 12:41:05 +010064#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
65 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simekd5dae852013-04-22 15:43:02 +020066 fpga_init();
67 fpga_add(fpga_xilinx, &fpga);
68#endif
69
Michal Simekf22651c2012-09-28 09:56:37 +000070 return 0;
71}
72
Jagannadha Sutradharudu Tekib3de9242014-01-09 01:48:21 +053073int 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 Simekf22651c2012-09-28 09:56:37 +000092
Michal Simek5a82d532014-08-28 13:31:02 +020093#ifdef CONFIG_DISPLAY_BOARDINFO
94int checkboard(void)
95{
Michal Simek5af08552016-01-25 11:04:21 +010096 puts("Board: Xilinx Zynq\n");
Michal Simek5a82d532014-08-28 13:31:02 +020097 return 0;
98}
99#endif
100
Joe Hershbergera509a1d2016-01-26 11:57:03 -0600101int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
102{
103#if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
104 defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET)
105 if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR,
106 CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET,
107 ethaddr, 6))
108 printf("I2C EEPROM MAC address read failed\n");
109#endif
110
111 return 0;
112}
113
Michal Simekf22651c2012-09-28 09:56:37 +0000114int dram_init(void)
115{
Michal Simek9e0e37a2014-02-24 11:16:32 +0100116 int node;
117 fdt_addr_t addr;
118 fdt_size_t size;
119 const void *blob = gd->fdt_blob;
Michal Simekf22651c2012-09-28 09:56:37 +0000120
Michal Simek9e0e37a2014-02-24 11:16:32 +0100121 node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
122 "memory", 7);
123 if (node == -FDT_ERR_NOTFOUND) {
124 debug("ZYNQ DRAM: Can't get memory node\n");
125 return -1;
126 }
127 addr = fdtdec_get_addr_size(blob, node, "reg", &size);
128 if (addr == FDT_ADDR_T_NONE || size == 0) {
129 debug("ZYNQ DRAM: Can't get base address or size\n");
130 return -1;
131 }
132 gd->ram_size = size;
Michal Simek148ba552013-06-17 14:37:01 +0200133 zynq_ddrc_init();
134
Michal Simekf22651c2012-09-28 09:56:37 +0000135 return 0;
136}