Vikas Manocha | e66c49f | 2016-02-11 15:47:20 -0800 | [diff] [blame] | 1 | /* |
| 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 Manocha | 2d9c33c | 2017-04-10 15:02:54 -0700 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <ram.h> |
Vikas Manocha | e66c49f | 2016-02-11 15:47:20 -0800 | [diff] [blame] | 11 | #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 Kurz | b20b70f | 2017-01-22 16:04:27 +0100 | [diff] [blame] | 19 | #include <asm/arch/syscfg.h> |
Vikas Manocha | e66c49f | 2016-02-11 15:47:20 -0800 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Toshifumi NISHINAGA | 25c1b13 | 2016-07-08 01:02:25 +0900 | [diff] [blame] | 23 | int dram_init(void) |
| 24 | { |
Vikas Manocha | 2d9c33c | 2017-04-10 15:02:54 -0700 | [diff] [blame] | 25 | struct udevice *dev; |
| 26 | struct ram_info ram; |
Toshifumi NISHINAGA | 25c1b13 | 2016-07-08 01:02:25 +0900 | [diff] [blame] | 27 | int rv; |
| 28 | |
Vikas Manocha | 2d9c33c | 2017-04-10 15:02:54 -0700 | [diff] [blame] | 29 | 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 NISHINAGA | 25c1b13 | 2016-07-08 01:02:25 +0900 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * Fill in global info with description of SRAM configuration |
| 44 | */ |
| 45 | gd->bd->bi_dram[0].start = CONFIG_SYS_RAM_BASE; |
Vikas Manocha | 2d9c33c | 2017-04-10 15:02:54 -0700 | [diff] [blame] | 46 | gd->bd->bi_dram[0].size = ram.size; |
Toshifumi NISHINAGA | 25c1b13 | 2016-07-08 01:02:25 +0900 | [diff] [blame] | 47 | |
Toshifumi NISHINAGA | 25c1b13 | 2016-07-08 01:02:25 +0900 | [diff] [blame] | 48 | return rv; |
| 49 | } |
| 50 | |
Michael Kurz | b20b70f | 2017-01-22 16:04:27 +0100 | [diff] [blame] | 51 | #ifdef CONFIG_ETH_DESIGNWARE |
Michael Kurz | b20b70f | 2017-01-22 16:04:27 +0100 | [diff] [blame] | 52 | static int stmmac_setup(void) |
| 53 | { |
Michael Kurz | b20b70f | 2017-01-22 16:04:27 +0100 | [diff] [blame] | 54 | clock_setup(SYSCFG_CLOCK_CFG); |
Michael Kurz | b20b70f | 2017-01-22 16:04:27 +0100 | [diff] [blame] | 55 | /* Set >RMII mode */ |
| 56 | STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL; |
Michael Kurz | b20b70f | 2017-01-22 16:04:27 +0100 | [diff] [blame] | 57 | clock_setup(STMMAC_CLOCK_CFG); |
| 58 | |
| 59 | return 0; |
| 60 | } |
Michael Kurz | b20b70f | 2017-01-22 16:04:27 +0100 | [diff] [blame] | 61 | |
Vikas Manocha | 280057b | 2017-04-10 15:02:59 -0700 | [diff] [blame^] | 62 | int board_early_init_f(void) |
Michael Kurz | d4363ba | 2017-01-22 16:04:30 +0100 | [diff] [blame] | 63 | { |
Vikas Manocha | 280057b | 2017-04-10 15:02:59 -0700 | [diff] [blame^] | 64 | stmmac_setup(); |
| 65 | |
Michael Kurz | d4363ba | 2017-01-22 16:04:30 +0100 | [diff] [blame] | 66 | return 0; |
| 67 | } |
| 68 | #endif |
| 69 | |
Vikas Manocha | e66c49f | 2016-02-11 15:47:20 -0800 | [diff] [blame] | 70 | u32 get_board_rev(void) |
| 71 | { |
| 72 | return 0; |
| 73 | } |
| 74 | |
Vikas Manocha | e66c49f | 2016-02-11 15:47:20 -0800 | [diff] [blame] | 75 | int board_init(void) |
| 76 | { |
| 77 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 78 | |
| 79 | return 0; |
| 80 | } |