blob: 5190938a3161c9405899f7b6770201f2fa753390 [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 Simek15d654c2013-04-22 15:43:02 +020018#ifdef CONFIG_FPGA
Michal Simek0f796702014-04-25 13:51:17 +020019static xilinx_desc fpga;
Michal Simek15d654c2013-04-22 15:43:02 +020020
21/* It can be done differently */
Michal Simek0f796702014-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);
26static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
27static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
Michal Simek15d654c2013-04-22 15:43:02 +020028#endif
29
Michal Simekaf482d52012-09-28 09:56:37 +000030int board_init(void)
31{
Michal Simek15d654c2013-04-22 15:43:02 +020032#ifdef CONFIG_FPGA
33 u32 idcode;
34
35 idcode = zynq_slcr_get_idcode();
36
37 switch (idcode) {
38 case XILINX_ZYNQ_7010:
39 fpga = fpga010;
40 break;
Michal Simek0e91d3a2013-09-26 16:39:03 +020041 case XILINX_ZYNQ_7015:
42 fpga = fpga015;
43 break;
Michal Simek15d654c2013-04-22 15:43:02 +020044 case XILINX_ZYNQ_7020:
45 fpga = fpga020;
46 break;
47 case XILINX_ZYNQ_7030:
48 fpga = fpga030;
49 break;
50 case XILINX_ZYNQ_7045:
51 fpga = fpga045;
52 break;
Michal Simek52f91b52013-06-17 13:54:07 +020053 case XILINX_ZYNQ_7100:
54 fpga = fpga100;
55 break;
Michal Simek15d654c2013-04-22 15:43:02 +020056 }
57#endif
58
Michal Simek15d654c2013-04-22 15:43:02 +020059#ifdef CONFIG_FPGA
60 fpga_init();
61 fpga_add(fpga_xilinx, &fpga);
62#endif
63
Michal Simekaf482d52012-09-28 09:56:37 +000064 return 0;
65}
66
Jagannadha Sutradharudu Teki11704c22014-01-09 01:48:21 +053067int board_late_init(void)
68{
69 switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
70 case ZYNQ_BM_NOR:
71 setenv("modeboot", "norboot");
72 break;
73 case ZYNQ_BM_SD:
74 setenv("modeboot", "sdboot");
75 break;
76 case ZYNQ_BM_JTAG:
77 setenv("modeboot", "jtagboot");
78 break;
79 default:
80 setenv("modeboot", "");
81 break;
82 }
83
84 return 0;
85}
Michal Simekaf482d52012-09-28 09:56:37 +000086
Michal Simekaf482d52012-09-28 09:56:37 +000087int board_eth_init(bd_t *bis)
88{
89 u32 ret = 0;
90
Michal Simek47edb142013-07-25 15:47:16 +020091#ifdef CONFIG_XILINX_AXIEMAC
92 ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR,
93 XILINX_AXIDMA_BASEADDR);
94#endif
95#ifdef CONFIG_XILINX_EMACLITE
96 u32 txpp = 0;
97 u32 rxpp = 0;
98# ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
99 txpp = 1;
100# endif
101# ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
102 rxpp = 1;
103# endif
104 ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR,
105 txpp, rxpp);
106#endif
107
Michal Simek242192b2013-04-12 16:33:08 +0200108#if defined(CONFIG_ZYNQ_GEM)
109# if defined(CONFIG_ZYNQ_GEM0)
David Andrey1b0dd5e2013-04-04 19:13:07 +0200110 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0,
David Andrey73875dc2013-04-05 17:24:24 +0200111 CONFIG_ZYNQ_GEM_PHY_ADDR0, 0);
Michal Simek242192b2013-04-12 16:33:08 +0200112# endif
113# if defined(CONFIG_ZYNQ_GEM1)
David Andrey1b0dd5e2013-04-04 19:13:07 +0200114 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1,
David Andrey73875dc2013-04-05 17:24:24 +0200115 CONFIG_ZYNQ_GEM_PHY_ADDR1, 0);
Michal Simek242192b2013-04-12 16:33:08 +0200116# endif
Michal Simekaf482d52012-09-28 09:56:37 +0000117#endif
Michal Simekaf482d52012-09-28 09:56:37 +0000118 return ret;
119}
Michal Simekaf482d52012-09-28 09:56:37 +0000120
Michal Simek0dd222b2013-04-22 14:56:49 +0200121#ifdef CONFIG_CMD_MMC
122int board_mmc_init(bd_t *bd)
123{
124 int ret = 0;
125
126#if defined(CONFIG_ZYNQ_SDHCI)
127# if defined(CONFIG_ZYNQ_SDHCI0)
128 ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0);
129# endif
130# if defined(CONFIG_ZYNQ_SDHCI1)
131 ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1);
132# endif
133#endif
134 return ret;
135}
136#endif
137
Michal Simekaf482d52012-09-28 09:56:37 +0000138int dram_init(void)
139{
Michal Simek65ef52f2014-02-24 11:16:32 +0100140#ifdef CONFIG_OF_CONTROL
141 int node;
142 fdt_addr_t addr;
143 fdt_size_t size;
144 const void *blob = gd->fdt_blob;
Michal Simekaf482d52012-09-28 09:56:37 +0000145
Michal Simek65ef52f2014-02-24 11:16:32 +0100146 node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
147 "memory", 7);
148 if (node == -FDT_ERR_NOTFOUND) {
149 debug("ZYNQ DRAM: Can't get memory node\n");
150 return -1;
151 }
152 addr = fdtdec_get_addr_size(blob, node, "reg", &size);
153 if (addr == FDT_ADDR_T_NONE || size == 0) {
154 debug("ZYNQ DRAM: Can't get base address or size\n");
155 return -1;
156 }
157 gd->ram_size = size;
158#else
159 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
160#endif
Michal Simekf5ff7bc2013-06-17 14:37:01 +0200161 zynq_ddrc_init();
162
Michal Simekaf482d52012-09-28 09:56:37 +0000163 return 0;
164}