2 * Copyright (C) 2007, 2008, 2010
3 * Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 * SPDX-License-Identifier: GPL-2.0+
12 #include <stdio_dev.h>
17 #include <environment.h>
19 #ifdef CONFIG_BITBANGMII
23 DECLARE_GLOBAL_DATA_PTR;
25 extern int cpu_init(void);
26 extern int board_init(void);
27 extern int dram_init(void);
28 extern int timer_init(void);
30 unsigned long monitor_flash_len = CONFIG_SYS_MONITOR_LEN;
32 #ifndef CONFIG_SYS_NO_FLASH
33 static int sh_flash_init(void)
35 gd->bd->bi_flashsize = flash_init();
37 if (gd->bd->bi_flashsize >= (1024 * 1024))
38 printf("Flash: %ldMB\n", gd->bd->bi_flashsize / (1024*1024));
40 printf("Flash: %ldKB\n", gd->bd->bi_flashsize / 1024);
44 #endif /* CONFIG_SYS_NO_FLASH */
46 #if defined(CONFIG_CMD_NAND)
48 # define INIT_FUNC_NAND_INIT nand_init,
50 # define INIT_FUNC_NAND_INIT
51 #endif /* CONFIG_CMD_NAND */
53 #if defined(CONFIG_WATCHDOG)
54 extern int watchdog_init(void);
55 extern int watchdog_disable(void);
56 # undef INIT_FUNC_WATCHDOG_INIT
57 # define INIT_FUNC_WATCHDOG_INIT watchdog_init,
58 # define WATCHDOG_DISABLE watchdog_disable
60 # define INIT_FUNC_WATCHDOG_INIT
61 # define WATCHDOG_DISABLE
62 #endif /* CONFIG_WATCHDOG */
64 #if defined(CONFIG_CMD_IDE)
66 # define INIT_FUNC_IDE_INIT ide_init,
68 # define INIT_FUNC_IDE_INIT
69 #endif /* CONFIG_CMD_IDE */
71 #if defined(CONFIG_PCI)
73 static int sh_pci_init(void)
78 # define INIT_FUNC_PCI_INIT sh_pci_init,
80 # define INIT_FUNC_PCI_INIT
81 #endif /* CONFIG_PCI */
83 static int sh_mem_env_init(void)
85 mem_malloc_init(CONFIG_SYS_TEXT_BASE - GENERATED_GBL_DATA_SIZE -
86 CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN - 16);
92 #if defined(CONFIG_CMD_MMC)
93 static int sh_mmc_init(void)
96 mmc_initialize(gd->bd);
101 typedef int (init_fnc_t) (void);
103 init_fnc_t *init_sequence[] =
105 cpu_init, /* basic cpu dependent setup */
106 board_init, /* basic board dependent setup */
107 interrupt_init, /* set up exceptions */
108 env_init, /* event init */
109 serial_init, /* SCIF init */
110 INIT_FUNC_WATCHDOG_INIT /* watchdog init */
114 checkboard, /* Check support board */
115 dram_init, /* SDRAM init */
116 timer_init, /* SuperH Timer (TCNT0 only) init */
118 #ifndef CONFIG_SYS_NO_FLASH
119 sh_flash_init, /* Flash memory init*/
121 INIT_FUNC_NAND_INIT/* Flash memory (NAND) init */
122 INIT_FUNC_PCI_INIT /* PCI init */
126 #ifdef CONFIG_BOARD_LATE_INIT
129 #if defined(CONFIG_CMD_MMC)
132 NULL /* Terminate this list */
135 void sh_generic_init(void)
138 init_fnc_t **init_fnc_ptr;
140 memset(gd, 0, GENERATED_GBL_DATA_SIZE);
142 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
144 gd->bd = (bd_t *)(gd + 1); /* At end of global data */
145 gd->baudrate = CONFIG_BAUDRATE;
147 gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
150 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
151 bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
152 #ifndef CONFIG_SYS_NO_FLASH
153 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
155 #if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE)
156 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;
157 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE;
160 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
162 if ((*init_fnc_ptr) () != 0)
166 #ifdef CONFIG_WATCHDOG
167 /* disable watchdog if environment is set */
169 char *s = getenv("watchdog");
171 if (strncmp(s, "off", 3) == 0)
174 #endif /* CONFIG_WATCHDOG*/
177 #ifdef CONFIG_BITBANGMII
180 #if defined(CONFIG_CMD_NET)
183 #endif /* CONFIG_CMD_NET */