6e31be35052328fe8861679d9bc44639795b99c5
[platform/kernel/u-boot.git] / board / AndesTech / nx25-ae250 / nx25-ae250.c
1 /*
2  * Copyright (C) 2017 Andes Technology Corporation
3  * Rick Chen, Andes Technology Corporation <rick@andestech.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <asm/mach-types.h>
9 #include <common.h>
10 #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
11 #include <netdev.h>
12 #endif
13 #include <linux/io.h>
14
15 DECLARE_GLOBAL_DATA_PTR;
16
17 /*
18  * Miscellaneous platform dependent initializations
19  */
20
21 int board_init(void)
22 {
23         gd->bd->bi_arch_number = MACH_TYPE_AE250;
24         gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
25
26         return 0;
27 }
28
29 int dram_init(void)
30 {
31         unsigned long sdram_base = PHYS_SDRAM_0;
32         unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
33         unsigned long actual_size;
34
35         actual_size = get_ram_size((void *)sdram_base, expected_size);
36         gd->ram_size = actual_size;
37
38         if (expected_size != actual_size) {
39                 printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
40                         actual_size >> 20, expected_size >> 20);
41         }
42
43         return 0;
44 }
45
46 int dram_init_banksize(void)
47 {
48         gd->bd->bi_dram[0].start = PHYS_SDRAM_0;
49         gd->bd->bi_dram[0].size =  PHYS_SDRAM_0_SIZE;
50         gd->bd->bi_dram[1].start = PHYS_SDRAM_1;
51         gd->bd->bi_dram[1].size =  PHYS_SDRAM_1_SIZE;
52
53         return 0;
54 }
55
56 #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
57 int board_eth_init(bd_t *bd)
58 {
59         return ftmac100_initialize(bd);
60 }
61 #endif
62
63 ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
64 {
65         return 0;
66 }
67
68 void *board_fdt_blob_setup(void)
69 {
70         void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
71         if (fdt_magic(*ptr) == FDT_MAGIC)
72                         return (void *)*ptr;
73
74         return (void *)CONFIG_SYS_FDT_BASE;
75 }