blob: 5119c09037e5bfe2bca7151bd8fb87a7a327cd08 [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>
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);
Michal Simek52f91b52013-06-17 13:54:07 +020023Xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
Michal Simek15d654c2013-04-22 15:43:02 +020024#endif
25
Michal Simekaf482d52012-09-28 09:56:37 +000026int board_init(void)
27{
Michal Simek15d654c2013-04-22 15:43:02 +020028#ifdef CONFIG_FPGA
29 u32 idcode;
30
31 idcode = zynq_slcr_get_idcode();
32
33 switch (idcode) {
34 case XILINX_ZYNQ_7010:
35 fpga = fpga010;
36 break;
37 case XILINX_ZYNQ_7020:
38 fpga = fpga020;
39 break;
40 case XILINX_ZYNQ_7030:
41 fpga = fpga030;
42 break;
43 case XILINX_ZYNQ_7045:
44 fpga = fpga045;
45 break;
Michal Simek52f91b52013-06-17 13:54:07 +020046 case XILINX_ZYNQ_7100:
47 fpga = fpga100;
48 break;
Michal Simek15d654c2013-04-22 15:43:02 +020049 }
50#endif
51
Michal Simekaf482d52012-09-28 09:56:37 +000052 icache_enable();
53
Michal Simek15d654c2013-04-22 15:43:02 +020054#ifdef CONFIG_FPGA
55 fpga_init();
56 fpga_add(fpga_xilinx, &fpga);
57#endif
58
Michal Simekaf482d52012-09-28 09:56:37 +000059 return 0;
60}
61
62
63#ifdef CONFIG_CMD_NET
64int board_eth_init(bd_t *bis)
65{
66 u32 ret = 0;
67
Michal Simek47edb142013-07-25 15:47:16 +020068#ifdef CONFIG_XILINX_AXIEMAC
69 ret |= xilinx_axiemac_initialize(bis, XILINX_AXIEMAC_BASEADDR,
70 XILINX_AXIDMA_BASEADDR);
71#endif
72#ifdef CONFIG_XILINX_EMACLITE
73 u32 txpp = 0;
74 u32 rxpp = 0;
75# ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG
76 txpp = 1;
77# endif
78# ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG
79 rxpp = 1;
80# endif
81 ret |= xilinx_emaclite_initialize(bis, XILINX_EMACLITE_BASEADDR,
82 txpp, rxpp);
83#endif
84
Michal Simek242192b2013-04-12 16:33:08 +020085#if defined(CONFIG_ZYNQ_GEM)
86# if defined(CONFIG_ZYNQ_GEM0)
David Andrey1b0dd5e2013-04-04 19:13:07 +020087 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0,
David Andrey73875dc2013-04-05 17:24:24 +020088 CONFIG_ZYNQ_GEM_PHY_ADDR0, 0);
Michal Simek242192b2013-04-12 16:33:08 +020089# endif
90# if defined(CONFIG_ZYNQ_GEM1)
David Andrey1b0dd5e2013-04-04 19:13:07 +020091 ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1,
David Andrey73875dc2013-04-05 17:24:24 +020092 CONFIG_ZYNQ_GEM_PHY_ADDR1, 0);
Michal Simek242192b2013-04-12 16:33:08 +020093# endif
Michal Simekaf482d52012-09-28 09:56:37 +000094#endif
Michal Simekaf482d52012-09-28 09:56:37 +000095 return ret;
96}
97#endif
98
Michal Simek0dd222b2013-04-22 14:56:49 +020099#ifdef CONFIG_CMD_MMC
100int board_mmc_init(bd_t *bd)
101{
102 int ret = 0;
103
104#if defined(CONFIG_ZYNQ_SDHCI)
105# if defined(CONFIG_ZYNQ_SDHCI0)
106 ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0);
107# endif
108# if defined(CONFIG_ZYNQ_SDHCI1)
109 ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1);
110# endif
111#endif
112 return ret;
113}
114#endif
115
Michal Simekaf482d52012-09-28 09:56:37 +0000116int dram_init(void)
117{
118 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
119
Michal Simekf5ff7bc2013-06-17 14:37:01 +0200120 zynq_ddrc_init();
121
Michal Simekaf482d52012-09-28 09:56:37 +0000122 return 0;
123}