2 * Copyright (C) 2007, 2008, 2010
3 * Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <stdio_dev.h>
16 #include <environment.h>
18 #ifdef CONFIG_BITBANGMII
22 DECLARE_GLOBAL_DATA_PTR;
24 extern int cpu_init(void);
25 extern int board_init(void);
26 extern int dram_init(void);
27 extern int timer_init(void);
29 unsigned long monitor_flash_len = CONFIG_SYS_MONITOR_LEN;
31 #ifndef CONFIG_SYS_NO_FLASH
32 static int sh_flash_init(void)
34 gd->bd->bi_flashsize = flash_init();
36 if (gd->bd->bi_flashsize >= (1024 * 1024))
37 printf("Flash: %ldMB\n", gd->bd->bi_flashsize / (1024*1024));
39 printf("Flash: %ldKB\n", gd->bd->bi_flashsize / 1024);
43 #endif /* CONFIG_SYS_NO_FLASH */
45 #if defined(CONFIG_CMD_NAND)
47 # define INIT_FUNC_NAND_INIT nand_init,
49 # define INIT_FUNC_NAND_INIT
50 #endif /* CONFIG_CMD_NAND */
52 #if defined(CONFIG_WATCHDOG)
53 extern int watchdog_init(void);
54 extern int watchdog_disable(void);
55 # undef INIT_FUNC_WATCHDOG_INIT
56 # define INIT_FUNC_WATCHDOG_INIT watchdog_init,
57 # define WATCHDOG_DISABLE watchdog_disable
59 # define INIT_FUNC_WATCHDOG_INIT
60 # define WATCHDOG_DISABLE
61 #endif /* CONFIG_WATCHDOG */
63 #if defined(CONFIG_CMD_IDE)
65 # define INIT_FUNC_IDE_INIT ide_init,
67 # define INIT_FUNC_IDE_INIT
68 #endif /* CONFIG_CMD_IDE */
70 #if defined(CONFIG_PCI)
72 static int sh_pci_init(void)
77 # define INIT_FUNC_PCI_INIT sh_pci_init,
79 # define INIT_FUNC_PCI_INIT
80 #endif /* CONFIG_PCI */
82 static int sh_mem_env_init(void)
84 mem_malloc_init(CONFIG_SYS_TEXT_BASE - GENERATED_GBL_DATA_SIZE -
85 CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN - 16);
91 #if defined(CONFIG_CMD_MMC)
92 static int sh_mmc_init(void)
95 mmc_initialize(gd->bd);
100 typedef int (init_fnc_t) (void);
102 init_fnc_t *init_sequence[] =
104 cpu_init, /* basic cpu dependent setup */
105 board_init, /* basic board dependent setup */
106 interrupt_init, /* set up exceptions */
107 env_init, /* event init */
108 serial_init, /* SCIF init */
109 INIT_FUNC_WATCHDOG_INIT /* watchdog init */
113 checkboard, /* Check support board */
114 dram_init, /* SDRAM init */
115 timer_init, /* SuperH Timer (TCNT0 only) init */
117 #ifndef CONFIG_SYS_NO_FLASH
118 sh_flash_init, /* Flash memory init*/
120 INIT_FUNC_NAND_INIT/* Flash memory (NAND) init */
121 INIT_FUNC_PCI_INIT /* PCI init */
125 #ifdef CONFIG_BOARD_LATE_INIT
128 #if defined(CONFIG_CMD_MMC)
131 NULL /* Terminate this list */
134 void sh_generic_init(void)
137 init_fnc_t **init_fnc_ptr;
139 memset(gd, 0, GENERATED_GBL_DATA_SIZE);
141 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
143 gd->bd = (bd_t *)(gd + 1); /* At end of global data */
144 gd->baudrate = CONFIG_BAUDRATE;
146 gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
149 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
150 bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
151 #ifndef CONFIG_SYS_NO_FLASH
152 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
154 #if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE)
155 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;
156 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE;
159 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
161 if ((*init_fnc_ptr) () != 0)
165 #ifdef CONFIG_WATCHDOG
166 /* disable watchdog if environment is set */
168 char *s = getenv("watchdog");
170 if (strncmp(s, "off", 3) == 0)
173 #endif /* CONFIG_WATCHDOG*/
176 #ifdef CONFIG_BITBANGMII
179 #if defined(CONFIG_CMD_NET)
182 #endif /* CONFIG_CMD_NET */