blob: e1310565451433fa73ce8ec5fee52bdbe4f20d63 [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 Simekf22651c2012-09-28 09:56:37 +000011#include <netdev.h>
Michal Simekd5dae852013-04-22 15:43:02 +020012#include <zynqpl.h>
Michal Simek71936532013-04-12 16:33:08 +020013#include <asm/arch/hardware.h>
14#include <asm/arch/sys_proto.h>
Michal Simekf22651c2012-09-28 09:56:37 +000015
16DECLARE_GLOBAL_DATA_PTR;
17
Michal Simek0b680202014-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 Simek5b73caf2014-04-25 13:51:17 +020020static xilinx_desc fpga;
Michal Simekd5dae852013-04-22 15:43:02 +020021
22/* It can be done differently */
Michal Simek5b73caf2014-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);
27static 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;
52 case XILINX_ZYNQ_7045:
53 fpga = fpga045;
54 break;
Michal Simekfd2b10b2013-06-17 13:54:07 +020055 case XILINX_ZYNQ_7100:
56 fpga = fpga100;
57 break;
Michal Simekd5dae852013-04-22 15:43:02 +020058 }
59#endif
60
Michal Simek0b680202014-03-04 12:41:05 +010061#if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
62 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
Michal Simekd5dae852013-04-22 15:43:02 +020063 fpga_init();
64 fpga_add(fpga_xilinx, &fpga);
65#endif
66
Michal Simekf22651c2012-09-28 09:56:37 +000067 return 0;
68}
69
Jagannadha Sutradharudu Tekib3de9242014-01-09 01:48:21 +053070int board_late_init(void)
71{
72 switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
73 case ZYNQ_BM_NOR:
74 setenv("modeboot", "norboot");
75 break;
76 case ZYNQ_BM_SD:
77 setenv("modeboot", "sdboot");
78 break;
79 case ZYNQ_BM_JTAG:
80 setenv("modeboot", "jtagboot");
81 break;
82 default:
83 setenv("modeboot", "");
84 break;
85 }
86
87 return 0;
88}
Michal Simekf22651c2012-09-28 09:56:37 +000089
Michal Simek5a82d532014-08-28 13:31:02 +020090#ifdef CONFIG_DISPLAY_BOARDINFO
91int checkboard(void)
92{
93 puts("Board:\tXilinx Zynq\n");
94 return 0;
95}
96#endif
97
Michal Simekf22651c2012-09-28 09:56:37 +000098int board_eth_init(bd_t *bis)
99{
100 u32 ret = 0;
101
Michal Simek2d83d332013-07-25 15:47:16 +0200102#ifdef CONFIG_XILINX_AXIEMAC
103 ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR,
104 XILINX_AXIDMA_BASEADDR);
105#endif
106#ifdef CONFIG_XILINX_EMACLITE
107 u32 txpp = 0;
108 u32 rxpp = 0;
109# ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
110 txpp = 1;
111# endif
112# ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
113 rxpp = 1;
114# endif
115 ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR,
116 txpp, rxpp);
117#endif
118
Michal Simek71936532013-04-12 16:33:08 +0200119#if defined(CONFIG_ZYNQ_GEM)
120# if defined(CONFIG_ZYNQ_GEM0)
David Andrey117cd4c2013-04-04 19:13:07 +0200121 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0,
David Andrey01fbf312013-04-05 17:24:24 +0200122 CONFIG_ZYNQ_GEM_PHY_ADDR0, 0);
Michal Simek71936532013-04-12 16:33:08 +0200123# endif
124# if defined(CONFIG_ZYNQ_GEM1)
David Andrey117cd4c2013-04-04 19:13:07 +0200125 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1,
David Andrey01fbf312013-04-05 17:24:24 +0200126 CONFIG_ZYNQ_GEM_PHY_ADDR1, 0);
Michal Simek71936532013-04-12 16:33:08 +0200127# endif
Michal Simekf22651c2012-09-28 09:56:37 +0000128#endif
Michal Simekf22651c2012-09-28 09:56:37 +0000129 return ret;
130}
Michal Simekf22651c2012-09-28 09:56:37 +0000131
Michal Simek293eb332013-04-22 14:56:49 +0200132#ifdef CONFIG_CMD_MMC
133int board_mmc_init(bd_t *bd)
134{
135 int ret = 0;
136
137#if defined(CONFIG_ZYNQ_SDHCI)
138# if defined(CONFIG_ZYNQ_SDHCI0)
139 ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0);
140# endif
141# if defined(CONFIG_ZYNQ_SDHCI1)
142 ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1);
143# endif
144#endif
145 return ret;
146}
147#endif
148
Michal Simekf22651c2012-09-28 09:56:37 +0000149int dram_init(void)
150{
Michal Simek9e0e37a2014-02-24 11:16:32 +0100151#ifdef CONFIG_OF_CONTROL
152 int node;
153 fdt_addr_t addr;
154 fdt_size_t size;
155 const void *blob = gd->fdt_blob;
Michal Simekf22651c2012-09-28 09:56:37 +0000156
Michal Simek9e0e37a2014-02-24 11:16:32 +0100157 node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
158 "memory", 7);
159 if (node == -FDT_ERR_NOTFOUND) {
160 debug("ZYNQ DRAM: Can't get memory node\n");
161 return -1;
162 }
163 addr = fdtdec_get_addr_size(blob, node, "reg", &size);
164 if (addr == FDT_ADDR_T_NONE || size == 0) {
165 debug("ZYNQ DRAM: Can't get base address or size\n");
166 return -1;
167 }
168 gd->ram_size = size;
169#else
170 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
171#endif
Michal Simek148ba552013-06-17 14:37:01 +0200172 zynq_ddrc_init();
173
Michal Simekf22651c2012-09-28 09:56:37 +0000174 return 0;
175}