common/board_f.c
void board_init_f(ulong boot_flags)
if (initcall_run_list(init_sequence_f))
hang();
------------------------------------------------------
839 static init_fnc_t init_sequence_f[] = {
840 #ifdef CONFIG_SANDBOX
841 setup_ram_buf,
842 #endif
843 setup_mon_len,
844 setup_fdt,
845 #ifdef CONFIG_TRACE
846 trace_early_init,
847 #endif
848 initf_malloc,
849 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
850 /* TODO: can this go into arch_cpu_init()? */
851 probecpu,
852 #endif
853 arch_cpu_init, /* basic arch cpu dependent setup */
854 #ifdef CONFIG_X86
855 cpu_init_f, /* TODO(sjg@chromium.org): remove */
856 # ifdef CONFIG_OF_CONTROL
857 find_fdt, /* TODO(sjg@chromium.org): remove */
858 # endif
859 #endif
860 mark_bootstage, //bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
861 #ifdef CONFIG_OF_CONTROL
862 fdtdec_check_fdt,
863 #endif
864 initf_dm, //进行u-boot的driver model的初始化,在这里回去解析fdt的设备并注册与之匹配的驱动
865 #if defined(CONFIG_BOARD_EARLY_INIT_F) // rk no define
866 board_early_init_f, 平台的開發者可以根據需要,實現board_early_init_f接口,以完成特定的功能。原文網址:https://kknews.cc/news/r5yby2x.html
867 #endif
868 /* TODO: can any of this go into arch_cpu_init()? */
869 #if defined(CONFIG_PPC) && !defined(CONFIG_8xx_CPUCLK_DEFAULT)
870 get_clocks, /* get CPU and bus clocks (etc.) */
871 #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
872 && !defined(CONFIG_TQM885D)
873 adjust_sdram_tbs_8xx,
874 #endif
875 /* TODO: can we rename this to timer_init()? */
876 init_timebase, 进行u-boot的driver model的初始化,在这里回去解析fdt的设备并注册与之匹配的驱动
877 #endif
878 #if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_BLACKFIN)
879 timer_init, /* initialize timer */ arch/arm/cpu/armv8/rk33xx/timer.c:int
880 #endif
881 #ifdef CONFIG_SYS_ALLOC_DPRAM
882 #if !defined(CONFIG_CPM2)
883 dpram_init,
884 #endif
885 #endif
886 #if defined(CONFIG_BOARD_POSTCLK_INIT)
887 board_postclk_init,
888 #endif
889 #ifdef CONFIG_FSL_ESDHC
890 get_clocks,
891 #endif
892 env_init, /* initialize environment */
893 #if defined(CONFIG_8xx_CPUCLK_DEFAULT)
894 /* get CPU and bus clocks according to the environment variable */
895 get_clocks_866,
896 /* adjust sdram refresh rate according to the new clock */
897 sdram_adjust_866,
898 init_timebase,
899 #endif
900 init_baud_rate, /* initialze baudrate settings */
getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
901 serial_init, /* serial communications setup */
902 console_init_f, /* stage 1 init of console */
903 #ifdef CONFIG_SANDBOX
904 sandbox_early_getopt_check,
905 #endif
906 #ifdef CONFIG_OF_CONTROL
907 fdtdec_prepare_fdt,
908 #endif
909 display_options, /* say that we are here */ lib/display_options.c: printf ("\n\n%s\n\n", version_string);
910 display_text_info, /* show debugging info if required */
911 #if defined(CONFIG_MPC8260)
912 prt_8260_rsr,
913 prt_8260_clks,
914 #endif /* CONFIG_MPC8260 */
915 #if defined(CONFIG_MPC83xx)
916 prt_83xx_rsr,
917 #endif
918 #ifdef CONFIG_PPC
919 checkcpu,
920 #endif
921 print_cpuinfo, /* display cpu info (and speed) */
922 #if defined(CONFIG_MPC5xxx)
923 prt_mpc5xxx_clks,
924 #endif /* CONFIG_MPC5xxx */
925 #if defined(CONFIG_DISPLAY_BOARDINFO)
926 show_board_info,
927 #endif
928 INIT_FUNC_WATCHDOG_INIT common/board_f.c:static int
i nit_func_watchdog_init(void)
929 #if defined(CONFIG_MISC_INIT_F) //NO
930 misc_init_f,
931 #endif
932 INIT_FUNC_WATCHDOG_RESET common/board_f.c:int init_func_watchdog_reset(void) WATCHDOG_RESET();
933 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
934 init_func_i2c,
935 #endif
936 #if defined(CONFIG_HARD_SPI)
937 init_func_spi,
938 #endif
939 #ifdef CONFIG_X86
940 dram_init_f, /* configure available RAM banks */
941 calculate_relocation_address,
942 #endif
943 announce_dram_init, // puts("DRAM: ");
944 /* TODO: unify all these dram functions? */
945 #ifdef CONFIG_ARM
946 dram_init, /* configure available RAM banks */
947 #endif
948 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
949 init_func_ram,
950 #endif
951 #ifdef CONFIG_POST
952 post_init_f,
953 #endif
954 INIT_FUNC_WATCHDOG_RESET
955 #if defined(CONFIG_SYS_DRAM_TEST)
956 testdram,
957 #endif /* CONFIG_SYS_DRAM_TEST */
958 INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset(void)
959 WATCHDOG_RESET();
960 #ifdef CONFIG_POST
961 init_post,
962 #endif
963 INIT_FUNC_WATCHDOG_RESET
964 /*
965 * Now that we have DRAM mapped and working, we can
966 * relocate the code and continue running from DRAM.
967 *
968 * Reserve memory at end of RAM for (top down in that order):
969 * - area that won't get touched by U-Boot and Linux (optional)
970 * - kernel log buffer
971 * - protected RAM
972 * - LCD framebuffer
973 * - monitor code
974 * - board info struct
975 */
976 setup_dest_addr,
977 #if defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2)
978 /* Blackfin u-boot monitor should be on top of the ram */
979 reserve_uboot,
980 #endif
981 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
982 reserve_logbuffer,
983 #endif
984 #ifdef CONFIG_PRAM
985 reserve_pram,
986 #endif
987 reserve_round_4k,
988 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) &&
989 defined(CONFIG_ARM)
990 reserve_mmu,
991 #endif
992 #if defined(CONFIG_LCD) || defined(CONFIG_ROCKCHIP_DISPLAY)
993 reserve_lcd, //common/board_f.c
994 #endif
995 #ifdef CONFIG_ROCKCHIP
996 reserve_global_buffers,
997 #endif
998 reserve_trace,
999 /* TODO: Why the dependency on CONFIG_8xx? */
1000 #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
1001 !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
1002 !defined(CONFIG_BLACKFIN)
1003 reserve_video,
1004 #endif
1005 #if !defined(CONFIG_BLACKFIN) && !defined(CONFIG_NIOS2)
1006 reserve_uboot,
1007 #endif
1008 #ifndef CONFIG_SPL_BUILD
1009 reserve_malloc,
1010 reserve_board,
1011 #endif
1012 setup_machine,
1013 reserve_global_data,
1014 reserve_fdt,
1015 reserve_stacks,
1016 setup_dram_config,
1017 show_dram_config,
1018 #ifdef CONFIG_PPC
1019 setup_board_part1,
1020 INIT_FUNC_WATCHDOG_RESET
1021 setup_board_part2,
1022 #endif
1023 display_new_sp,
1024 #ifdef CONFIG_SYS_EXTBDINFO
1025 setup_board_extra,
1026 #endif
1027 INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset(void)
1028 reloc_fdt,
1029 setup_reloc,
1030 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
1031 jump_to_copy,
1032 #endif
1033 NULL,
1034 };
------說明------------------------------------------------------------------------------------------------------
140 static int init_baud_rate(void)
141 {
142 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
143 return 0; //configs/rk3399_defconfig 115200
144 }
drivers/serial/serial.c
/**
* serial_init() - Initialize currently selected serial port
*
* This function initializes the currently selected serial port. This
* usually involves setting up the registers of that particular port,
* enabling clock and such. This function uses the get_current() call
* to determine which port is selected.
*
* Returns 0 on success, negative on error.
*/
int serial_init(void)
{
gd->flags |= GD_FLG_SERIAL_READY;
return get_current()->start();
}
/**
* get_current() - Return pointer to currently selected serial port
*
* This function returns a pointer to currently selected serial port.
* The currently selected serial port is altered by serial_assign()
* function.
*
* In case this function is called before relocation or before any serial
* port is configured, this function calls default_serial_console() to
* determine the serial port. Otherwise, the configured serial port is
* returned.
*
* Returns pointer to the currently selected serial port on success,
* NULL on error.
*/
static struct serial_device *get_current(void)
{
struct serial_device *dev;
if (!(gd->flags & GD_FLG_RELOC))
dev = default_serial_console();
else if (!serial_current)
dev = default_serial_console();
else
dev = serial_current;
/* We must have a console device */
if (!dev) {
#ifdef CONFIG_SPL_BUILD
puts("Cannot find console\n");
hang();
#else
panic("Cannot find console\n");
#endif
}
return dev;
}
https://www.twblogs.net/a/5b8b21d72b717718832d8815
common/console.c:int console_init_f(void)
console_init_f,设置 gd->have_console 为 1,表示有个控制台,此函数也将前面暂存在缓冲区中的数据通过控制台打印出来
/u-boot/configs/rk3399_defconfig