common: Drop flash.h from common header
[platform/kernel/u-boot.git] / board / AndesTech / ax25-ae350 / ax25-ae350.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2017 Andes Technology Corporation
4  * Rick Chen, Andes Technology Corporation <rick@andestech.com>
5  */
6
7 #include <common.h>
8 #include <flash.h>
9 #include <init.h>
10 #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
11 #include <netdev.h>
12 #endif
13 #include <linux/io.h>
14 #include <faraday/ftsmc020.h>
15 #include <fdtdec.h>
16 #include <dm.h>
17 #include <spl.h>
18
19 DECLARE_GLOBAL_DATA_PTR;
20
21 extern phys_addr_t prior_stage_fdt_address;
22 /*
23  * Miscellaneous platform dependent initializations
24  */
25
26 int board_init(void)
27 {
28         gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
29
30         return 0;
31 }
32
33 int dram_init(void)
34 {
35         return fdtdec_setup_mem_size_base();
36 }
37
38 int dram_init_banksize(void)
39 {
40         return fdtdec_setup_memory_banksize();
41 }
42
43 #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
44 int board_eth_init(bd_t *bd)
45 {
46         return ftmac100_initialize(bd);
47 }
48 #endif
49
50 ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
51 {
52         return 0;
53 }
54
55 void *board_fdt_blob_setup(void)
56 {
57         return (void *)CONFIG_SYS_FDT_BASE;
58 }
59
60 int smc_init(void)
61 {
62         int node = -1;
63         const char *compat = "andestech,atfsmc020";
64         void *blob = (void *)gd->fdt_blob;
65         fdt_addr_t addr;
66         struct ftsmc020_bank *regs;
67
68         node = fdt_node_offset_by_compatible(blob, -1, compat);
69         if (node < 0)
70                 return -FDT_ERR_NOTFOUND;
71
72         addr = fdtdec_get_addr(blob, node, "reg");
73
74         if (addr == FDT_ADDR_T_NONE)
75                 return -EINVAL;
76
77         regs = (struct ftsmc020_bank *)addr;
78         regs->cr &= ~FTSMC020_BANK_WPROT;
79
80         return 0;
81 }
82
83 static void v5l2_init(void)
84 {
85         struct udevice *dev;
86
87         uclass_get_device(UCLASS_CACHE, 0, &dev);
88 }
89
90 #ifdef CONFIG_BOARD_EARLY_INIT_F
91 int board_early_init_f(void)
92 {
93         smc_init();
94         v5l2_init();
95
96         return 0;
97 }
98 #endif
99
100 #ifdef CONFIG_SPL
101 void board_boot_order(u32 *spl_boot_list)
102 {
103         u8 i;
104         u32 boot_devices[] = {
105 #ifdef CONFIG_SPL_RAM_SUPPORT
106                 BOOT_DEVICE_RAM,
107 #endif
108 #ifdef CONFIG_SPL_MMC_SUPPORT
109                 BOOT_DEVICE_MMC1,
110 #endif
111         };
112
113         for (i = 0; i < ARRAY_SIZE(boot_devices); i++)
114                 spl_boot_list[i] = boot_devices[i];
115 }
116 #endif
117
118 #ifdef CONFIG_SPL_LOAD_FIT
119 int board_fit_config_name_match(const char *name)
120 {
121         /* boot using first FIT config */
122         return 0;
123 }
124 #endif