blob: 45a2c47aa281964f3321723dd4186cc0afc7325d [file] [log] [blame]
Vikas Manochae66c49f2016-02-11 15:47:20 -08001/*
2 * (C) Copyright 2016
3 * Vikas Manocha, <vikas.manocha@st.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
Vikas Manocha2d9c33c2017-04-10 15:02:54 -07009#include <dm.h>
10#include <ram.h>
Vikas Manochae66c49f2016-02-11 15:47:20 -080011#include <asm/io.h>
12#include <asm/armv7m.h>
13#include <asm/arch/stm32.h>
14#include <asm/arch/gpio.h>
15#include <dm/platdata.h>
16#include <dm/platform_data/serial_stm32x7.h>
17#include <asm/arch/stm32_periph.h>
18#include <asm/arch/stm32_defs.h>
Michael Kurzb20b70f2017-01-22 16:04:27 +010019#include <asm/arch/syscfg.h>
Vikas Manochae66c49f2016-02-11 15:47:20 -080020
21DECLARE_GLOBAL_DATA_PTR;
22
Toshifumi NISHINAGA25c1b132016-07-08 01:02:25 +090023int dram_init(void)
24{
Vikas Manocha2d9c33c2017-04-10 15:02:54 -070025 struct udevice *dev;
26 struct ram_info ram;
Toshifumi NISHINAGA25c1b132016-07-08 01:02:25 +090027 int rv;
28
Vikas Manocha2d9c33c2017-04-10 15:02:54 -070029 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
30 if (rv) {
31 debug("DRAM init failed: %d\n", rv);
32 return rv;
33 }
34 rv = ram_get_info(dev, &ram);
35 if (rv) {
36 debug("Cannot get DRAM size: %d\n", rv);
37 return rv;
38 }
39 debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
40 gd->ram_size = ram.size;
Toshifumi NISHINAGA25c1b132016-07-08 01:02:25 +090041
42 /*
43 * Fill in global info with description of SRAM configuration
44 */
45 gd->bd->bi_dram[0].start = CONFIG_SYS_RAM_BASE;
Vikas Manocha2d9c33c2017-04-10 15:02:54 -070046 gd->bd->bi_dram[0].size = ram.size;
Toshifumi NISHINAGA25c1b132016-07-08 01:02:25 +090047
Toshifumi NISHINAGA25c1b132016-07-08 01:02:25 +090048 return rv;
49}
50
Michael Kurzb20b70f2017-01-22 16:04:27 +010051#ifdef CONFIG_ETH_DESIGNWARE
Michael Kurzb20b70f2017-01-22 16:04:27 +010052static int stmmac_setup(void)
53{
Michael Kurzb20b70f2017-01-22 16:04:27 +010054 clock_setup(SYSCFG_CLOCK_CFG);
Michael Kurzb20b70f2017-01-22 16:04:27 +010055 /* Set >RMII mode */
56 STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
Michael Kurzb20b70f2017-01-22 16:04:27 +010057 clock_setup(STMMAC_CLOCK_CFG);
58
59 return 0;
60}
Michael Kurzb20b70f2017-01-22 16:04:27 +010061
Vikas Manocha280057b2017-04-10 15:02:59 -070062int board_early_init_f(void)
Michael Kurzd4363ba2017-01-22 16:04:30 +010063{
Vikas Manocha280057b2017-04-10 15:02:59 -070064 stmmac_setup();
65
Michael Kurzd4363ba2017-01-22 16:04:30 +010066 return 0;
67}
68#endif
69
Vikas Manochae66c49f2016-02-11 15:47:20 -080070u32 get_board_rev(void)
71{
72 return 0;
73}
74
Vikas Manochae66c49f2016-02-11 15:47:20 -080075int board_init(void)
76{
77 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
78
79 return 0;
80}