blob: 738c31c6ee1f568cc95a6dd47ce34579f2853b64 [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 Simekaf482d52012-09-28 09:56:37 +000011#include <netdev.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 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 Simek0f796702014-04-25 13:51:17 +020023static xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10);
24static xilinx_desc fpga015 = XILINX_XC7Z015_DESC(0x15);
25static xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20);
26static xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30);
Siva Durga Prasad Paladugu77fc12c2014-11-25 15:29:54 +053027static xilinx_desc fpga035 = XILINX_XC7Z035_DESC(0x35);
Michal Simek0f796702014-04-25 13:51:17 +020028static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
29static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
Michal Simek15d654c2013-04-22 15:43:02 +020030#endif
31
Michal Simekaf482d52012-09-28 09:56:37 +000032int board_init(void)
33{
Michal Simekda713862014-03-04 12:41:05 +010034#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
35 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek15d654c2013-04-22 15:43:02 +020036 u32 idcode;
37
38 idcode = zynq_slcr_get_idcode();
39
40 switch (idcode) {
41 case XILINX_ZYNQ_7010:
42 fpga = fpga010;
43 break;
Michal Simek0e91d3a2013-09-26 16:39:03 +020044 case XILINX_ZYNQ_7015:
45 fpga = fpga015;
46 break;
Michal Simek15d654c2013-04-22 15:43:02 +020047 case XILINX_ZYNQ_7020:
48 fpga = fpga020;
49 break;
50 case XILINX_ZYNQ_7030:
51 fpga = fpga030;
52 break;
Siva Durga Prasad Paladugu77fc12c2014-11-25 15:29:54 +053053 case XILINX_ZYNQ_7035:
54 fpga = fpga035;
55 break;
Michal Simek15d654c2013-04-22 15:43:02 +020056 case XILINX_ZYNQ_7045:
57 fpga = fpga045;
58 break;
Michal Simek52f91b52013-06-17 13:54:07 +020059 case XILINX_ZYNQ_7100:
60 fpga = fpga100;
61 break;
Michal Simek15d654c2013-04-22 15:43:02 +020062 }
63#endif
64
Michal Simekda713862014-03-04 12:41:05 +010065#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
66 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simek15d654c2013-04-22 15:43:02 +020067 fpga_init();
68 fpga_add(fpga_xilinx, &fpga);
69#endif
70
Michal Simekaf482d52012-09-28 09:56:37 +000071 return 0;
72}
73
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053074int board_late_init(void)
75{
76 switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
77 case ZYNQ_BM_NOR:
78 setenv("modeboot", "norboot");
79 break;
80 case ZYNQ_BM_SD:
81 setenv("modeboot", "sdboot");
82 break;
83 case ZYNQ_BM_JTAG:
84 setenv("modeboot", "jtagboot");
85 break;
86 default:
87 setenv("modeboot", "");
88 break;
89 }
90
91 return 0;
92}
Michal Simekaf482d52012-09-28 09:56:37 +000093
Michal Simek3fa64452014-08-28 13:31:02 +020094#ifdef CONFIG_DISPLAY_BOARDINFO
95int checkboard(void)
96{
97 puts("Board:\tXilinx Zynq\n");
98 return 0;
99}
100#endif
101
Michal Simekaf482d52012-09-28 09:56:37 +0000102int board_eth_init(bd_t *bis)
103{
104 u32 ret = 0;
105
Michal Simek47edb142013-07-25 15:47:16 +0200106#ifdef CONFIG_XILINX_AXIEMAC
107 ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR,
108 XILINX_AXIDMA_BASEADDR);
109#endif
110#ifdef CONFIG_XILINX_EMACLITE
111 u32 txpp = 0;
112 u32 rxpp = 0;
113# ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
114 txpp = 1;
115# endif
116# ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
117 rxpp = 1;
118# endif
119 ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR,
120 txpp, rxpp);
121#endif
122
Michal Simek242192b2013-04-12 16:33:08 +0200123#if defined(CONFIG_ZYNQ_GEM)
124# if defined(CONFIG_ZYNQ_GEM0)
David Andrey1b0dd5e2013-04-04 19:13:07 +0200125 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0,
Siva Durga Prasad Paladugu4aac2962014-10-28 16:59:32 +0530126 CONFIG_ZYNQ_GEM_PHY_ADDR0,
127 CONFIG_ZYNQ_GEM_EMIO0);
Michal Simek242192b2013-04-12 16:33:08 +0200128# endif
129# if defined(CONFIG_ZYNQ_GEM1)
David Andrey1b0dd5e2013-04-04 19:13:07 +0200130 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1,
Siva Durga Prasad Paladugu4aac2962014-10-28 16:59:32 +0530131 CONFIG_ZYNQ_GEM_PHY_ADDR1,
132 CONFIG_ZYNQ_GEM_EMIO1);
Michal Simek242192b2013-04-12 16:33:08 +0200133# endif
Michal Simekaf482d52012-09-28 09:56:37 +0000134#endif
Michal Simekaf482d52012-09-28 09:56:37 +0000135 return ret;
136}
Michal Simekaf482d52012-09-28 09:56:37 +0000137
Michal Simek0dd222b2013-04-22 14:56:49 +0200138#ifdef CONFIG_CMD_MMC
139int board_mmc_init(bd_t *bd)
140{
141 int ret = 0;
142
143#if defined(CONFIG_ZYNQ_SDHCI)
144# if defined(CONFIG_ZYNQ_SDHCI0)
145 ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0);
146# endif
147# if defined(CONFIG_ZYNQ_SDHCI1)
148 ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1);
149# endif
150#endif
151 return ret;
152}
153#endif
154
Michal Simekaf482d52012-09-28 09:56:37 +0000155int dram_init(void)
156{
Michal Simek65ef52f2014-02-24 11:16:32 +0100157#ifdef CONFIG_OF_CONTROL
158 int node;
159 fdt_addr_t addr;
160 fdt_size_t size;
161 const void *blob = gd->fdt_blob;
Michal Simekaf482d52012-09-28 09:56:37 +0000162
Michal Simek65ef52f2014-02-24 11:16:32 +0100163 node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
164 "memory", 7);
165 if (node == -FDT_ERR_NOTFOUND) {
166 debug("ZYNQ DRAM: Can't get memory node\n");
167 return -1;
168 }
169 addr = fdtdec_get_addr_size(blob, node, "reg", &size);
170 if (addr == FDT_ADDR_T_NONE || size == 0) {
171 debug("ZYNQ DRAM: Can't get base address or size\n");
172 return -1;
173 }
174 gd->ram_size = size;
175#else
176 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
177#endif
Michal Simekf5ff7bc2013-06-17 14:37:01 +0200178 zynq_ddrc_init();
179
Michal Simekaf482d52012-09-28 09:56:37 +0000180 return 0;
181}