blob: ca159b0cd31529c27c2cb57a0f24a6929da39035 [file] [log] [blame]
Michal Simekaf482d52012-09-28 09:56:37 +00001/*
2 * (C) Copyright 2012 Michal Simek <monstr@monstr.eu>
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Michal Simekaf482d52012-09-28 09:56:37 +00005 */
6
7#include <common.h>
8#include <netdev.h>
Michal Simek15d654c2013-04-22 15:43:02 +02009#include <zynqpl.h>
Michal Simek242192b2013-04-12 16:33:08 +020010#include <asm/arch/hardware.h>
11#include <asm/arch/sys_proto.h>
Michal Simekaf482d52012-09-28 09:56:37 +000012
13DECLARE_GLOBAL_DATA_PTR;
14
Michal Simek15d654c2013-04-22 15:43:02 +020015#ifdef CONFIG_FPGA
16Xilinx_desc fpga;
17
18/* It can be done differently */
19Xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10);
20Xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20);
21Xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30);
22Xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
23#endif
24
Michal Simekaf482d52012-09-28 09:56:37 +000025int board_init(void)
26{
Michal Simek15d654c2013-04-22 15:43:02 +020027#ifdef CONFIG_FPGA
28 u32 idcode;
29
30 idcode = zynq_slcr_get_idcode();
31
32 switch (idcode) {
33 case XILINX_ZYNQ_7010:
34 fpga = fpga010;
35 break;
36 case XILINX_ZYNQ_7020:
37 fpga = fpga020;
38 break;
39 case XILINX_ZYNQ_7030:
40 fpga = fpga030;
41 break;
42 case XILINX_ZYNQ_7045:
43 fpga = fpga045;
44 break;
45 }
46#endif
47
Michal Simekaf482d52012-09-28 09:56:37 +000048 icache_enable();
49
Michal Simek15d654c2013-04-22 15:43:02 +020050#ifdef CONFIG_FPGA
51 fpga_init();
52 fpga_add(fpga_xilinx, &fpga);
53#endif
54
Michal Simekaf482d52012-09-28 09:56:37 +000055 return 0;
56}
57
58
59#ifdef CONFIG_CMD_NET
60int board_eth_init(bd_t *bis)
61{
62 u32 ret = 0;
63
Michal Simek242192b2013-04-12 16:33:08 +020064#if defined(CONFIG_ZYNQ_GEM)
65# if defined(CONFIG_ZYNQ_GEM0)
David Andrey1b0dd5e2013-04-04 19:13:07 +020066 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0,
David Andrey73875dc2013-04-05 17:24:24 +020067 CONFIG_ZYNQ_GEM_PHY_ADDR0, 0);
Michal Simek242192b2013-04-12 16:33:08 +020068# endif
69# if defined(CONFIG_ZYNQ_GEM1)
David Andrey1b0dd5e2013-04-04 19:13:07 +020070 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1,
David Andrey73875dc2013-04-05 17:24:24 +020071 CONFIG_ZYNQ_GEM_PHY_ADDR1, 0);
Michal Simek242192b2013-04-12 16:33:08 +020072# endif
Michal Simekaf482d52012-09-28 09:56:37 +000073#endif
Michal Simekaf482d52012-09-28 09:56:37 +000074 return ret;
75}
76#endif
77
Michal Simek0dd222b2013-04-22 14:56:49 +020078#ifdef CONFIG_CMD_MMC
79int board_mmc_init(bd_t *bd)
80{
81 int ret = 0;
82
83#if defined(CONFIG_ZYNQ_SDHCI)
84# if defined(CONFIG_ZYNQ_SDHCI0)
85 ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0);
86# endif
87# if defined(CONFIG_ZYNQ_SDHCI1)
88 ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1);
89# endif
90#endif
91 return ret;
92}
93#endif
94
Michal Simekaf482d52012-09-28 09:56:37 +000095int dram_init(void)
96{
97 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
98
Michal Simekf5ff7bc2013-06-17 14:37:01 +020099 zynq_ddrc_init();
100
Michal Simekaf482d52012-09-28 09:56:37 +0000101 return 0;
102}