diff options
Diffstat (limited to 'include')
33 files changed, 836 insertions, 473 deletions
diff --git a/include/bootcount.h b/include/bootcount.h index 8fa8cf8218..cd30403984 100644 --- a/include/bootcount.h +++ b/include/bootcount.h @@ -59,6 +59,16 @@ int dm_bootcount_set(struct udevice *dev, u32 bootcount); #endif +/** bootcount_store() - store the current bootcount */ +void bootcount_store(ulong); + +/** + * bootcount_load() - load the current bootcount + * + * @return bootcount, read from the appropriate location + */ +ulong bootcount_load(void); + #if defined(CONFIG_SPL_BOOTCOUNT_LIMIT) || defined(CONFIG_BOOTCOUNT_LIMIT) #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE) @@ -127,10 +137,6 @@ static inline void bootcount_inc(void) #endif /* !CONFIG_SPL_BUILD */ } -#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT) -void bootcount_store(ulong a) {}; -ulong bootcount_load(void) { return 0; } -#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_BOOTCOUNT_LIMIT */ #else static inline int bootcount_error(void) { return 0; } static inline void bootcount_inc(void) {} diff --git a/include/command.h b/include/command.h index f6170e7151..d1063774ce 100644 --- a/include/command.h +++ b/include/command.h @@ -199,6 +199,22 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size); * @return 0 if OK, 1 for error */ int board_run_command(const char *cmdline); + +int run_command(const char *cmd, int flag); +int run_command_repeatable(const char *cmd, int flag); + +/** + * Run a list of commands separated by ; or even \0 + * + * Note that if 'len' is not -1, then the command does not need to be nul + * terminated, Memory will be allocated for the command in that case. + * + * @param cmd List of commands to run, each separated bu semicolon + * @param len Length of commands excluding terminator if known (-1 if not) + * @param flag Execution flags (CMD_FLAG_...) + * @return 0 on success, or != 0 on error. + */ +int run_command_list(const char *cmd, int len, int flag); #endif /* __ASSEMBLY__ */ /* diff --git a/include/common.h b/include/common.h index d8f302ea92..8b37b58747 100644 --- a/include/common.h +++ b/include/common.h @@ -3,8 +3,8 @@ * Common header file for U-Boot * * This file still includes quite a bit of stuff that should be in separate - * headers like command.h, cpu.h and timer.h. Please think before adding more - * things. Patches to remove things are welcome. + * headers. Please think before adding more things. + * Patches to remove things are welcome. * * (C) Copyright 2000-2009 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. @@ -46,8 +46,6 @@ typedef volatile unsigned char vu_char; #include <log.h> -typedef void (interrupt_handler_t)(void *); - #include <asm/u-boot.h> /* boot information for Linux kernel */ #include <asm/global_data.h> /* global data used for startup functions */ @@ -64,27 +62,10 @@ typedef void (interrupt_handler_t)(void *); */ void hang (void) __attribute__ ((noreturn)); -int cpu_init(void); - #include <display_options.h> /* common/main.c */ void main_loop (void); -int run_command(const char *cmd, int flag); -int run_command_repeatable(const char *cmd, int flag); - -/** - * Run a list of commands separated by ; or even \0 - * - * Note that if 'len' is not -1, then the command does not need to be nul - * terminated, Memory will be allocated for the command in that case. - * - * @param cmd List of commands to run, each separated bu semicolon - * @param len Length of commands excluding terminator if known (-1 if not) - * @param flag Execution flags (CMD_FLAG_...) - * @return 0 on success, or != 0 on error. - */ -int run_command_list(const char *cmd, int len, int flag); int checkflash(void); int checkdram(void); @@ -93,26 +74,6 @@ extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */ int mdm_init(void); /** - * Show the DRAM size in a board-specific way - * - * This is used by boards to display DRAM information in their own way. - * - * @param size Size of DRAM (which should be displayed along with other info) - */ -void board_show_dram(phys_size_t size); - -/** - * Get the uppermost pointer that is valid to access - * - * Some systems may not map all of their address space. This function allows - * boards to indicate what their highest support pointer value is for DRAM - * access. - * - * @param total_size Size of U-Boot (unused?) - */ -ulong board_get_usable_ram_top(ulong total_size); - -/** * arch_fixup_fdt() - Write arch-specific information to fdt * * Defined in arch/$(ARCH)/lib/bootm-fdt.c @@ -141,8 +102,6 @@ int do_fat_fsload(cmd_tbl_t *, int, int, char * const []); /* common/cmd_ext2.c */ int do_ext2load(cmd_tbl_t *, int, int, char * const []); -void pci_init_board(void); - /* common/exports.c */ void jumptable_init(void); @@ -157,77 +116,22 @@ phys_size_t get_effective_memsize(void); void reset_phy (void); void fdc_hw_init (void); -/* $(BOARD)/eeprom.c */ -#ifdef CONFIG_CMD_EEPROM -void eeprom_init (int bus); -int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); -int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); -#else -/* - * Some EEPROM code is depecated because it used the legacy I2C interface. Add - * some macros here so we don't have to touch every one of those uses - */ -#define eeprom_init(bus) -#define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS) -#define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS) -#endif - #if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR #endif -/* $(BOARD)/$(BOARD).c */ -int board_early_init_f (void); -int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */ -int board_late_init (void); -int board_postclk_init (void); /* after clocks/timebase, before env/serial */ -int board_early_init_r (void); - #if defined(CONFIG_SYS_DRAM_TEST) int testdram(void); #endif /* CONFIG_SYS_DRAM_TEST */ -/* $(CPU)/start.S */ -int icache_status (void); -void icache_enable (void); -void icache_disable(void); -int dcache_status (void); -void dcache_enable (void); -void dcache_disable(void); -void mmu_disable(void); #if defined(CONFIG_ARM) void relocate_code(ulong); #else void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn)); #endif -ulong get_endaddr (void); -void trap_init (ulong); - -/* $(CPU)/cpu.c */ -static inline int cpumask_next(int cpu, unsigned int mask) -{ - for (cpu++; !((1 << cpu) & mask); cpu++) - ; - - return cpu; -} - -#define for_each_cpu(iter, cpu, num_cpus, mask) \ - for (iter = 0, cpu = cpumask_next(-1, mask); \ - iter < num_cpus; \ - iter++, cpu = cpumask_next(cpu, mask)) \ - -int cpu_numcores (void); -int cpu_num_dspcores(void); -u32 cpu_mask (void); -u32 cpu_dsp_mask(void); -int is_core_valid (unsigned int); void s_init(void); -int checkcpu (void); -int checkicache (void); -int checkdcache (void); void upmconfig (unsigned int, unsigned int *, unsigned int); ulong get_tbclk (void); void reset_misc (void); @@ -235,134 +139,22 @@ void reset_cpu (ulong addr); void ft_cpu_setup(void *blob, bd_t *bd); void ft_pci_setup(void *blob, bd_t *bd); -void smp_set_core_boot_addr(unsigned long addr, int corenr); -void smp_kick_all_cpus(void); - -/* $(CPU)/serial.c */ -int serial_init (void); -void serial_setbrg (void); -void serial_putc (const char); -void serial_putc_raw(const char); -void serial_puts (const char *); -int serial_getc (void); -int serial_tstc (void); - /* $(CPU)/speed.c */ int get_clocks (void); ulong get_bus_freq (ulong); int get_serial_clock(void); -/* $(CPU)/interrupts.c */ -int interrupt_init (void); -void timer_interrupt (struct pt_regs *); -void external_interrupt (struct pt_regs *); -void irq_install_handler(int, interrupt_handler_t *, void *); -void irq_free_handler (int); -void reset_timer (void); - -/* Return value of monotonic microsecond timer */ -unsigned long timer_get_us(void); - -void enable_interrupts (void); -int disable_interrupts (void); - -/* $(CPU)/.../commproc.c */ -void bootcount_store (ulong); -ulong bootcount_load (void); - -/* $(CPU)/.../<eth> */ -void mii_init (void); - -/* arch/$(ARCH)/lib/cache.c */ -void enable_caches(void); -void flush_cache (unsigned long, unsigned long); -void flush_dcache_all(void); -void flush_dcache_range(unsigned long start, unsigned long stop); -void invalidate_dcache_range(unsigned long start, unsigned long stop); -void invalidate_dcache_all(void); -void invalidate_icache_all(void); - -enum { - /* Disable caches (else flush caches but leave them active) */ - CBL_DISABLE_CACHES = 1 << 0, - CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1, - - CBL_ALL = 3, -}; - -/** - * Clean up ready for linux - * - * @param flags Flags to control what is done - */ -int cleanup_before_linux_select(int flags); - -/* arch/$(ARCH)/lib/ticks.S */ -uint64_t get_ticks(void); -void wait_ticks (unsigned long); - -/* arch/$(ARCH)/lib/time.c */ -ulong usec2ticks (unsigned long usec); -ulong ticks2usec (unsigned long ticks); - -/* lib/lz4_wrapper.c */ -int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn); - -/* lib/qsort.c */ -void qsort(void *base, size_t nmemb, size_t size, - int(*compar)(const void *, const void *)); -int strcmp_compar(const void *, const void *); - /* lib/uuid.c */ #include <uuid.h> /* lib/vsprintf.c */ #include <vsprintf.h> -/* lib/strmhz.c */ -char * strmhz(char *buf, unsigned long hz); - -/* lib/crc32.c */ -#include <u-boot/crc.h> - -/* lib/rand.c */ -#define RAND_MAX -1U -void srand(unsigned int seed); -unsigned int rand(void); -unsigned int rand_r(unsigned int *seedp); - -/* - * STDIO based functions (can always be used) - */ -/* serial stuff */ -int serial_printf (const char *fmt, ...) - __attribute__ ((format (__printf__, 1, 2))); - /* lib/net_utils.c */ #include <net.h> -static inline struct in_addr env_get_ip(char *var) -{ - return string_to_ip(env_get(var)); -} - -#ifdef CONFIG_LED_STATUS -# include <status_led.h> -#endif #include <bootstage.h> -#ifdef CONFIG_SHOW_ACTIVITY -void show_activity(int arg); -#endif - -/* Multicore arch functions */ -#ifdef CONFIG_MP -int cpu_status(u32 nr); -int cpu_reset(u32 nr); -int cpu_disable(u32 nr); -int cpu_release(u32 nr, int argc, char * const argv[]); -#endif - #else /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */ diff --git a/include/configs/T208xRDB.h b/include/configs/T208xRDB.h index b64bafdb33..8c0b81adfd 100644 --- a/include/configs/T208xRDB.h +++ b/include/configs/T208xRDB.h @@ -502,7 +502,6 @@ unsigned long get_board_ddr_clk(void); * env is stored at 0x100000, sector size is 0x10000, ucode is stored after * env, so we got 0x110000. */ -#define CONFIG_SYS_CORTINA_FW_IN_SPIFLASH #define CONFIG_SYS_FMAN_FW_ADDR 0x110000 #define CONFIG_CORTINA_FW_ADDR 0x120000 @@ -512,12 +511,10 @@ unsigned long get_board_ddr_clk(void); * about 1MB (2048 blocks), Env is stored after the image, and the env size is * 0x2000 (16 blocks), 8 + 2048 + 16 = 2072, enlarge it to 2080. */ -#define CONFIG_SYS_CORTINA_FW_IN_MMC #define CONFIG_SYS_FMAN_FW_ADDR (512 * 0x820) #define CONFIG_CORTINA_FW_ADDR (512 * 0x8a0) #elif defined(CONFIG_NAND) -#define CONFIG_SYS_CORTINA_FW_IN_NAND #define CONFIG_SYS_FMAN_FW_ADDR (3 * CONFIG_SYS_NAND_BLOCK_SIZE) #define CONFIG_CORTINA_FW_ADDR (4 * CONFIG_SYS_NAND_BLOCK_SIZE) #elif defined(CONFIG_SRIO_PCIE_BOOT_SLAVE) @@ -528,11 +525,9 @@ unsigned long get_board_ddr_clk(void); * slave SRIO or PCIE outbound window->master inbound window-> * master LAW->the ucode address in master's memory space. */ -#define CONFIG_SYS_CORTINA_FW_IN_REMOTE #define CONFIG_SYS_FMAN_FW_ADDR 0xFFE00000 #define CONFIG_CORTINA_FW_ADDR 0xFFE10000 #else -#define CONFIG_SYS_CORTINA_FW_IN_NOR #define CONFIG_SYS_FMAN_FW_ADDR 0xEFF00000 #define CONFIG_CORTINA_FW_ADDR 0xEFE00000 #endif @@ -541,7 +536,6 @@ unsigned long get_board_ddr_clk(void); #endif /* CONFIG_NOBQFMAN */ #ifdef CONFIG_SYS_DPAA_FMAN -#define CONFIG_PHY_CORTINA #define CONFIG_PHY_REALTEK #define CONFIG_CORTINA_FW_LENGTH 0x40000 #define RGMII_PHY1_ADDR 0x01 /* RealTek RTL8211E */ diff --git a/include/configs/T4240RDB.h b/include/configs/T4240RDB.h index fc2aed3356..493da70f66 100644 --- a/include/configs/T4240RDB.h +++ b/include/configs/T4240RDB.h @@ -548,8 +548,6 @@ unsigned long get_board_ddr_clk(void); #ifdef CONFIG_SYS_DPAA_FMAN #define CONFIG_PHYLIB_10G #define CONFIG_PHY_VITESSE -#define CONFIG_PHY_CORTINA -#define CONFIG_SYS_CORTINA_FW_IN_NOR #define CONFIG_CORTINA_FW_ADDR 0xefe00000 #define CONFIG_CORTINA_FW_LENGTH 0x40000 #define CONFIG_PHY_TERANETICS diff --git a/include/configs/ls1012a2g5rdb.h b/include/configs/ls1012a2g5rdb.h index cb329385d9..5943b69716 100644 --- a/include/configs/ls1012a2g5rdb.h +++ b/include/configs/ls1012a2g5rdb.h @@ -85,7 +85,7 @@ "installer=load mmc 0:2 $load_addr " \ "/flex_installer_arm64.itb; " \ "bootm $load_addr#$board\0" \ - "qspi_bootcmd=echo Trying load from qspi..;" \ + "qspi_bootcmd=pfe stop; echo Trying load from qspi..;" \ "sf probe && sf read $load_addr " \ "$kernel_addr $kernel_size; env exists secureboot " \ "&& sf read $kernelheader_addr_r $kernelheader_addr " \ diff --git a/include/configs/ls1012afrdm.h b/include/configs/ls1012afrdm.h index 8c7d4e558d..8a3ebf06f2 100644 --- a/include/configs/ls1012afrdm.h +++ b/include/configs/ls1012afrdm.h @@ -60,7 +60,7 @@ "installer=load usb 0:2 $load_addr " \ "/flex_installer_arm64.itb; " \ "bootm $load_addr#$board\0" \ - "qspi_bootcmd=echo Trying load from qspi..;" \ + "qspi_bootcmd=pfe stop; echo Trying load from qspi..;" \ "sf probe && sf read $load_addr " \ "$kernel_addr $kernel_size && bootm $load_addr#$board\0" diff --git a/include/configs/ls1012afrwy.h b/include/configs/ls1012afrwy.h index 44b37c5475..c0519e3c11 100644 --- a/include/configs/ls1012afrwy.h +++ b/include/configs/ls1012afrwy.h @@ -101,13 +101,13 @@ "installer=load mmc 0:2 $load_addr " \ "/flex_installer_arm64.itb; " \ "bootm $load_addr#$board\0" \ - "qspi_bootcmd=echo Trying load from qspi..;" \ + "qspi_bootcmd=pfe stop; echo Trying load from qspi..;" \ "sf probe && sf read $load_addr " \ "$kernel_addr $kernel_size; env exists secureboot " \ "&& sf read $kernelheader_addr_r $kernelheader_addr " \ "$kernelheader_size && esbc_validate ${kernelheader_addr_r}; " \ "bootm $load_addr#$board\0" \ - "sd_bootcmd=echo Trying load from sd card..;" \ + "sd_bootcmd=pfe stop; echo Trying load from sd card..;" \ "mmcinfo; mmc read $load_addr " \ "$kernel_addr_sd $kernel_size_sd ;" \ "env exists secureboot && mmc read $kernelheader_addr_r "\ diff --git a/include/configs/ls1012ardb.h b/include/configs/ls1012ardb.h index 3cd7baf21d..0341495dfb 100644 --- a/include/configs/ls1012ardb.h +++ b/include/configs/ls1012ardb.h @@ -107,7 +107,7 @@ "installer=load mmc 0:2 $load_addr " \ "/flex_installer_arm64.itb; " \ "bootm $load_addr#$board\0" \ - "qspi_bootcmd=echo Trying load from qspi..;" \ + "qspi_bootcmd=pfe stop; echo Trying load from qspi..;" \ "sf probe && sf read $load_addr " \ "$kernel_addr $kernel_size; env exists secureboot " \ "&& sf read $kernelheader_addr_r $kernelheader_addr " \ diff --git a/include/configs/ls1028a_common.h b/include/configs/ls1028a_common.h index 09fc333810..4bd510d42e 100644 --- a/include/configs/ls1028a_common.h +++ b/include/configs/ls1028a_common.h @@ -69,6 +69,7 @@ #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 0) \ + func(MMC, mmc, 1) \ func(USB, usb, 0) #include <config_distro_bootcmd.h> @@ -129,25 +130,46 @@ "${scripthdraddr} ${prefix}${boot_script_hdr} " \ "&& esbc_validate ${scripthdraddr};" \ "source ${scriptaddr}\0" \ - "sd_bootcmd=echo Trying load from SD ..;" \ + "xspi_bootcmd=echo Trying load from FlexSPI flash ...;" \ + "sf probe 0:0 && sf read $load_addr " \ + "$kernel_start $kernel_size ; env exists secureboot &&" \ + "sf read $kernelheader_addr_r $kernelheader_start " \ + "$kernelheader_size && esbc_validate ${kernelheader_addr_r}; "\ + " bootm $load_addr#$board\0" \ + "xspi_hdploadcmd=echo Trying load HDP firmware from FlexSPI...;" \ + "sf probe 0:0 && sf read $load_addr 0x940000 0x30000 " \ + "&& hdp load $load_addr 0x2000\0" \ + "sd_bootcmd=echo Trying load from SD ...;" \ "mmcinfo; mmc read $load_addr " \ "$kernel_addr_sd $kernel_size_sd && " \ "env exists secureboot && mmc read $kernelheader_addr_r " \ "$kernelhdr_addr_sd $kernelhdr_size_sd " \ " && esbc_validate ${kernelheader_addr_r};" \ "bootm $load_addr#$board\0" \ + "sd_hdploadcmd=echo Trying load HDP firmware from SD..;" \ + "mmcinfo;mmc read $load_addr 0x4a00 0x200 " \ + "&& hdp load $load_addr 0x2000\0" \ "emmc_bootcmd=echo Trying load from EMMC ..;" \ "mmcinfo; mmc dev 1; mmc read $load_addr " \ "$kernel_addr_sd $kernel_size_sd && " \ "env exists secureboot && mmc read $kernelheader_addr_r " \ "$kernelhdr_addr_sd $kernelhdr_size_sd " \ " && esbc_validate ${kernelheader_addr_r};" \ - "bootm $load_addr#$board\0" + "bootm $load_addr#$board\0" \ + "emmc_hdploadcmd=echo Trying load HDP firmware from EMMC..;" \ + "mmc dev 1;mmcinfo;mmc read $load_addr 0x4a00 0x200 " \ + "&& hdp load $load_addr 0x2000\0" #undef CONFIG_BOOTCOMMAND +#define XSPI_NOR_BOOTCOMMAND \ + "run xspi_hdploadcmd; run distro_bootcmd; run xspi_bootcmd; " \ + "env exists secureboot && esbc_halt;;" #define SD_BOOTCOMMAND \ - "run distro_bootcmd;run sd_bootcmd; " \ + "run sd_hdploadcmd; run distro_bootcmd;run sd_bootcmd; " \ + "env exists secureboot && esbc_halt;" +#define SD2_BOOTCOMMAND \ + "run emmc_hdploadcmd; run distro_bootcmd;run emmc_bootcmd; " \ "env exists secureboot && esbc_halt;" /* Monitor Command Prompt */ diff --git a/include/configs/ls1043a_common.h b/include/configs/ls1043a_common.h index e237012626..bf24d4036d 100644 --- a/include/configs/ls1043a_common.h +++ b/include/configs/ls1043a_common.h @@ -275,8 +275,8 @@ "source ${scriptaddr}\0" \ "qspi_bootcmd=echo Trying load from qspi..;" \ "sf probe && sf read $load_addr " \ - "$kernel_addr $kernel_size; env exists secureboot " \ - "&& sf read $kernelheader_addr_r $kernelheader_addr " \ + "$kernel_start $kernel_size; env exists secureboot " \ + "&& sf read $kernelheader_addr_r $kernelheader_start " \ "$kernelheader_size && esbc_validate ${kernelheader_addr_r}; " \ "bootm $load_addr#$board\0" \ "nor_bootcmd=echo Trying load from nor..;" \ diff --git a/include/configs/ls2080ardb.h b/include/configs/ls2080ardb.h index c5d57cfdd4..926239a588 100644 --- a/include/configs/ls2080ardb.h +++ b/include/configs/ls2080ardb.h @@ -560,8 +560,6 @@ unsigned long get_board_sys_clk(void); /* MAC/PHY configuration */ #ifdef CONFIG_FSL_MC_ENET -#define CONFIG_PHY_CORTINA -#define CONFIG_SYS_CORTINA_FW_IN_NOR #ifdef CONFIG_QSPI_BOOT #define CONFIG_CORTINA_FW_ADDR 0x20980000 #else diff --git a/include/configs/mt8518.h b/include/configs/mt8518.h new file mode 100644 index 0000000000..a7fe83a605 --- /dev/null +++ b/include/configs/mt8518.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Configuration for MediaTek MT8518 SoC + * + * Copyright (C) 2019 MediaTek Inc. + * Author: Mingming Lee <mingming.lee@mediatek.com> + */ + +#ifndef __MT8518_H +#define __MT8518_H + +#include <linux/sizes.h> + +/* Machine ID */ +#define CONFIG_SYS_NONCACHED_MEMORY SZ_1M + +#define CONFIG_CPU_ARMV8 + +#define COUNTER_FREQUENCY 13000000 + +/* DRAM definition */ +#define CONFIG_SYS_SDRAM_BASE 0x40000000 +#define CONFIG_SYS_SDRAM_SIZE 0x20000000 + +#define CONFIG_SYS_LOAD_ADDR 0x41000000 +#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR + +#define CONFIG_SYS_MALLOC_LEN SZ_32M +#define CONFIG_SYS_BOOTM_LEN SZ_64M + +/* Uboot definition */ +#define CONFIG_SYS_UBOOT_START CONFIG_SYS_TEXT_BASE +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE + \ + SZ_2M - \ + GENERATED_GBL_DATA_SIZE) + +/* ENV Setting */ +#if defined(CONFIG_MMC_MTK) +#define CONFIG_SYS_MMC_ENV_DEV 0 +#define CONFIG_ENV_OVERWRITE + +/* MMC offset in block unit,and block size is 0x200 */ +#define ENV_BOOT_READ_IMAGE \ + "boot_rd_img=mmc dev 0" \ + ";mmc read ${loadaddr} 0x27400 0x4000" \ + ";iminfo ${loadaddr}\0" +#endif + +/* Console configuration */ +#define ENV_DEVICE_SETTINGS \ + "stdin=serial\0" \ + "stdout=serial\0" \ + "stderr=serial\0" + +#define ENV_BOOT_CMD \ + "mtk_boot=run boot_rd_img;bootm;\0" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "fdt_high=0x6c000000\0" \ + ENV_DEVICE_SETTINGS \ + ENV_BOOT_READ_IMAGE \ + ENV_BOOT_CMD \ + "bootcmd=run mtk_boot;\0" \ + +#endif diff --git a/include/configs/omapl138_lcdk.h b/include/configs/omapl138_lcdk.h index fc5c87cc9a..2c499d812b 100644 --- a/include/configs/omapl138_lcdk.h +++ b/include/configs/omapl138_lcdk.h @@ -23,7 +23,7 @@ #define CONFIG_SYS_TIMERBASE DAVINCI_TIMER0_BASE #define CONFIG_SYS_HZ_CLOCK clk_get(DAVINCI_AUXCLK_CLKID) #define CONFIG_SYS_HZ 1000 -#define CONFIG_SKIP_LOWLEVEL_INIT +#define CONFIG_SKIP_LOWLEVEL_INIT_ONLY /* * Memory Info diff --git a/include/configs/vct.h b/include/configs/vct.h deleted file mode 100644 index 284d268259..0000000000 --- a/include/configs/vct.h +++ /dev/null @@ -1,194 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2008 Stefan Roese <sr@denx.de>, DENX Software Engineering - */ - -/* - * This file contains the configuration parameters for the VCT board - * family: - * - * vct_premium - * vct_premium_small - * vct_premium_onenand - * vct_premium_onenand_small - * vct_platinum - * vct_platinum_small - * vct_platinum_onenand - * vct_platinum_onenand_small - * vct_platinumavc - * vct_platinumavc_small - * vct_platinumavc_onenand - * vct_platinumavc_onenand_small - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#define CPU_CLOCK_RATE 324000000 /* Clock for the MIPS core */ -#define CONFIG_SYS_MIPS_TIMER_FREQ (CPU_CLOCK_RATE / 2) - -#define CONFIG_SKIP_LOWLEVEL_INIT /* SDRAM is initialized by the bootstrap code */ - -#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE -#define CONFIG_SYS_MONITOR_LEN (256 << 10) -#define CONFIG_SYS_MALLOC_LEN (1 << 20) -#define CONFIG_SYS_BOOTPARAMS_LEN (128 << 10) -#define CONFIG_SYS_INIT_SP_OFFSET 0x400000 - -#if !defined(CONFIG_VCT_NAND) && !defined(CONFIG_VCT_ONENAND) -#define CONFIG_VCT_NOR -#endif - -/* - * UART - */ -#ifdef CONFIG_VCT_PLATINUMAVC -#define UART_1_BASE 0xBDC30000 -#else -#define UART_1_BASE 0xBF89C000 -#endif - -#define CONFIG_SYS_NS16550_SERIAL -#define CONFIG_SYS_NS16550_REG_SIZE -4 -#define CONFIG_SYS_NS16550_COM1 UART_1_BASE -#define CONFIG_SYS_NS16550_CLK 921600 - -/* - * SDRAM - */ -#define CONFIG_SYS_SDRAM_BASE 0x80000000 -#define CONFIG_SYS_MBYTES_SDRAM 128 -#define CONFIG_SYS_MEMTEST_START 0x80200000 -#define CONFIG_SYS_MEMTEST_END 0x80400000 -#define CONFIG_SYS_LOAD_ADDR 0x80400000 /* default load address */ - -#if defined(CONFIG_VCT_PREMIUM) || defined(CONFIG_VCT_PLATINUM) -#define CONFIG_NET_RETRY_COUNT 20 -#endif - -/* - * Commands - */ -#if defined(CONFIG_CMD_USB) - -/* - * USB/EHCI - */ -#define CONFIG_USB_EHCI_VCT /* on VCT platform */ -#define CONFIG_EHCI_MMIO_BIG_ENDIAN -#define CONFIG_EHCI_DESC_BIG_ENDIAN -#define CONFIG_EHCI_IS_TDI -#define CONFIG_EHCI_HCD_INIT_AFTER_RESET /* re-init HCD after CMD_RESET */ -#endif /* CONFIG_CMD_USB */ - -/* - * BOOTP options - */ -#define CONFIG_BOOTP_BOOTFILESIZE - -/* - * Miscellaneous configurable options - */ -#define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */ -#define CONFIG_TIMESTAMP /* Print image info with timestamp */ - -/* - * FLASH and environment organization - */ -#if defined(CONFIG_VCT_NOR) -#define CONFIG_FLASH_NOT_MEM_MAPPED - -/* - * We need special accessor functions for the CFI FLASH driver. This - * can be enabled via the CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS option. - */ -#define CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS - -/* - * For the non-memory-mapped NOR FLASH, we need to define the - * NOR FLASH area. This can't be detected via the addr2info() - * function, since we check for flash access in the very early - * U-Boot code, before the NOR FLASH is detected. - */ -#define CONFIG_FLASH_BASE 0xb0000000 -#define CONFIG_FLASH_END 0xbfffffff - -/* - * CFI driver settings - */ -#define CONFIG_SYS_FLASH_CFI_AMD_RESET 1 /* Use AMD (Spansion) reset cmd */ -#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT /* no byte writes on IXP4xx */ - -#define CONFIG_SYS_FLASH_BASE 0xb0000000 -#define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE } -#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of memory banks */ -#define CONFIG_SYS_MAX_FLASH_SECT 512 /* max number of sectors on one chip */ - -#define CONFIG_SYS_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */ -#define CONFIG_SYS_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */ - -#ifdef CONFIG_ENV_IS_IN_FLASH -/* Address and size of Redundant Environment Sector */ -#endif /* CONFIG_ENV_IS_IN_FLASH */ -#endif /* CONFIG_VCT_NOR */ - -#if defined(CONFIG_VCT_ONENAND) -#define CONFIG_USE_ONENAND_BOARD_INIT -#define CONFIG_SYS_ONENAND_BASE 0x00000000 /* this is not real address */ -#define CONFIG_SYS_FLASH_BASE 0x00000000 -#endif /* CONFIG_VCT_ONENAND */ - -/* - * I2C/EEPROM - */ -#define CONFIG_SYS_I2C -#define CONFIG_SYS_I2C_SOFT /* I2C bit-banged */ -#define CONFIG_SYS_I2C_SOFT_SPEED 83000 /* 83 kHz is supposed to work */ -#define CONFIG_SYS_I2C_SOFT_SLAVE 0x7f - -/* - * Software (bit-bang) I2C driver configuration - */ -#define CONFIG_SYS_GPIO_I2C_SCL 11 -#define CONFIG_SYS_GPIO_I2C_SDA 10 - -#ifndef __ASSEMBLY__ -int vct_gpio_dir(int pin, int dir); -void vct_gpio_set(int pin, int val); -int vct_gpio_get(int pin); -#endif - -#define I2C_INIT vct_gpio_dir(CONFIG_SYS_GPIO_I2C_SCL, 1) -#define I2C_ACTIVE vct_gpio_dir(CONFIG_SYS_GPIO_I2C_SDA, 1) -#define I2C_TRISTATE vct_gpio_dir(CONFIG_SYS_GPIO_I2C_SDA, 0) -#define I2C_READ vct_gpio_get(CONFIG_SYS_GPIO_I2C_SDA) -#define I2C_SDA(bit) vct_gpio_set(CONFIG_SYS_GPIO_I2C_SDA, bit) -#define I2C_SCL(bit) vct_gpio_set(CONFIG_SYS_GPIO_I2C_SCL, bit) -#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ - -#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 -/* CAT24WC32 */ -#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 /* Bytes of address */ -#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 5 /* The Catalyst CAT24WC32 has */ - /* 32 byte page write mode using*/ - /* last 5 bits of the address */ -#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10 /* and takes up to 10 msec */ - -#define CONFIG_BOOTCOMMAND "run test3" - -/* - * UBI configuration - */ - -/* - * We need a small, stripped down image to fit into the first 128k OneNAND - * erase block (gzipped). This image only needs basic commands for FLASH - * (NOR/OneNAND) usage and Linux kernel booting. - */ -#if defined(CONFIG_VCT_SMALL_IMAGE) -#undef CONFIG_SYS_I2C_SOFT -#undef CONFIG_SOURCE -#undef CONFIG_TIMESTAMP -#endif /* CONFIG_VCT_SMALL_IMAGE */ - -#endif /* __CONFIG_H */ diff --git a/include/cpu_func.h b/include/cpu_func.h new file mode 100644 index 0000000000..46f3d92459 --- /dev/null +++ b/include/cpu_func.h @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * Copyright 2019 Google LLC + */ + +#ifndef __CPU_LEGACY_H +#define __CPU_LEGACY_H + +#include <linux/types.h> + +/* + * Multicore arch functions + * + * These should be moved to use the CPU uclass. + */ +int cpu_status(u32 nr); +int cpu_reset(u32 nr); +int cpu_disable(u32 nr); +int cpu_release(u32 nr, int argc, char * const argv[]); + +static inline int cpumask_next(int cpu, unsigned int mask) +{ + for (cpu++; !((1 << cpu) & mask); cpu++) + ; + + return cpu; +} + +#define for_each_cpu(iter, cpu, num_cpus, mask) \ + for (iter = 0, cpu = cpumask_next(-1, mask); \ + iter < num_cpus; \ + iter++, cpu = cpumask_next(cpu, mask)) \ + +int cpu_numcores(void); +int cpu_num_dspcores(void); +u32 cpu_mask(void); +u32 cpu_dsp_mask(void); +int is_core_valid(unsigned int core); + +/** + * checkcpu() - perform an early check of the CPU + * + * This is used on PowerPC, SH and X86 machines as a CPU init mechanism. It is + * called during the pre-relocation init sequence in board_init_f(). + * + * @return 0 if oK, -ve on error + */ +int checkcpu(void); + +void smp_set_core_boot_addr(unsigned long addr, int corenr); +void smp_kick_all_cpus(void); + +int icache_status(void); +void icache_enable(void); +void icache_disable(void); +int dcache_status(void); +void dcache_enable(void); +void dcache_disable(void); +void mmu_disable(void); + +/* arch/$(ARCH)/lib/cache.c */ +void enable_caches(void); +void flush_cache(unsigned long addr, unsigned long size); +void flush_dcache_all(void); +void flush_dcache_range(unsigned long start, unsigned long stop); +void invalidate_dcache_range(unsigned long start, unsigned long stop); +void invalidate_dcache_all(void); +void invalidate_icache_all(void); + +enum { + /* Disable caches (else flush caches but leave them active) */ + CBL_DISABLE_CACHES = 1 << 0, + CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1, + + CBL_ALL = 3, +}; + +/** + * Clean up ready for linux + * + * @param flags Flags to control what is done + */ +int cleanup_before_linux_select(int flags); +; +#endif diff --git a/include/dt-bindings/clock/mt8518-clk.h b/include/dt-bindings/clock/mt8518-clk.h new file mode 100644 index 0000000000..43b7247968 --- /dev/null +++ b/include/dt-bindings/clock/mt8518-clk.h @@ -0,0 +1,249 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2019 MediaTek Inc. + */ + +#ifndef _DT_BINDINGS_CLK_MT8518_H +#define _DT_BINDINGS_CLK_MT8518_H + +/* APMIXEDSYS */ + +#define CLK_APMIXED_ARMPLL 0 +#define CLK_APMIXED_MAINPLL 1 +#define CLK_APMIXED_UNIVPLL 2 +#define CLK_APMIXED_MMPLL 3 +#define CLK_APMIXED_APLL1 4 +#define CLK_APMIXED_APLL2 5 +#define CLK_APMIXED_TVDPLL 6 +#define CLK_APMIXED_NR_CLK 7 + +/* TOPCKGEN */ + +#define CLK_TOP_CLK_NULL 0 +#define CLK_TOP_FQ_TRNG_OUT0 1 +#define CLK_TOP_FQ_TRNG_OUT1 2 +#define CLK_TOP_CLK32K 3 +#define CLK_TOP_DMPLL 4 +#define CLK_TOP_MAINPLL_D4 5 +#define CLK_TOP_MAINPLL_D8 6 +#define CLK_TOP_MAINPLL_D16 7 +#define CLK_TOP_MAINPLL_D11 8 +#define CLK_TOP_MAINPLL_D22 9 +#define CLK_TOP_MAINPLL_D3 10 +#define CLK_TOP_MAINPLL_D6 11 +#define CLK_TOP_MAINPLL_D12 12 +#define CLK_TOP_MAINPLL_D5 13 +#define CLK_TOP_MAINPLL_D10 14 +#define CLK_TOP_MAINPLL_D20 15 +#define CLK_TOP_MAINPLL_D40 16 +#define CLK_TOP_MAINPLL_D7 17 +#define CLK_TOP_MAINPLL_D14 18 +#define CLK_TOP_UNIVPLL_D2 19 +#define CLK_TOP_UNIVPLL_D4 20 +#define CLK_TOP_UNIVPLL_D8 21 +#define CLK_TOP_UNIVPLL_D16 22 +#define CLK_TOP_UNIVPLL_D3 23 +#define CLK_TOP_UNIVPLL_D6 24 +#define CLK_TOP_UNIVPLL_D12 25 +#define CLK_TOP_UNIVPLL_D24 26 +#define CLK_TOP_UNIVPLL_D5 27 +#define CLK_TOP_UNIVPLL_D20 28 +#define CLK_TOP_UNIVPLL_D10 29 +#define CLK_TOP_MMPLL_D2 30 +#define CLK_TOP_USB20_48M 31 +#define CLK_TOP_APLL1 32 +#define CLK_TOP_APLL1_D4 33 +#define CLK_TOP_APLL2 34 +#define CLK_TOP_APLL2_D2 35 +#define CLK_TOP_APLL2_D3 36 +#define CLK_TOP_APLL2_D4 37 +#define CLK_TOP_APLL2_D8 38 +#define CLK_TOP_CLK26M 39 +#define CLK_TOP_CLK26M_D2 40 +#define CLK_TOP_CLK26M_D4 41 +#define CLK_TOP_CLK26M_D8 42 +#define CLK_TOP_CLK26M_D793 43 +#define CLK_TOP_TVDPLL 44 +#define CLK_TOP_TVDPLL_D2 45 +#define CLK_TOP_TVDPLL_D4 46 +#define CLK_TOP_TVDPLL_D8 47 +#define CLK_TOP_TVDPLL_D16 48 +#define CLK_TOP_USB20_CLK480M 49 +#define CLK_TOP_RG_APLL1_D2 50 +#define CLK_TOP_RG_APLL1_D4 51 +#define CLK_TOP_RG_APLL1_D8 52 +#define CLK_TOP_RG_APLL1_D16 53 +#define CLK_TOP_RG_APLL1_D3 54 +#define CLK_TOP_RG_APLL2_D2 55 +#define CLK_TOP_RG_APLL2_D4 56 +#define CLK_TOP_RG_APLL2_D8 57 +#define CLK_TOP_RG_APLL2_D16 58 +#define CLK_TOP_RG_APLL2_D3 59 +#define CLK_TOP_NFI1X_INFRA_BCLK 60 +#define CLK_TOP_AHB_INFRA_D2 61 +#define CLK_TOP_UART0_SEL 62 +#define CLK_TOP_EMI1X_SEL 63 +#define CLK_TOP_EMI_DDRPHY_SEL 64 +#define CLK_TOP_MSDC1_SEL 65 +#define CLK_TOP_PWM_MM_SEL 66 +#define CLK_TOP_UART1_SEL 67 +#define CLK_TOP_SPM_52M_SEL 68 +#define CLK_TOP_PMICSPI_SEL 69 +#define CLK_TOP_NFI2X_SEL 70 +#define CLK_TOP_DDRPHYCFG_SEL 71 +#define CLK_TOP_SMI_SEL 72 +#define CLK_TOP_USB_SEL 73 +#define CLK_TOP_SPINOR_SEL 74 +#define CLK_TOP_ETH_SEL 75 +#define CLK_TOP_AUD1_SEL 76 +#define CLK_TOP_AUD2_SEL 77 +#define CLK_TOP_I2C_SEL 78 +#define CLK_TOP_AUD_I2S0_M_SEL 79 +#define CLK_TOP_AUD_I2S3_M_SEL 80 +#define CLK_TOP_AUD_I2S4_M_SEL 81 +#define CLK_TOP_AUD_I2S6_M_SEL 82 +#define CLK_TOP_PWM_SEL 83 +#define CLK_TOP_AUD_SPDIFIN_SEL 84 +#define CLK_TOP_UART2_SEL 85 +#define CLK_TOP_DBG_ATCLK_SEL 86 +#define CLK_TOP_PNG_SYS_SEL 87 +#define CLK_TOP_SEJ_13M_SEL 88 +#define CLK_TOP_IMGRZ_SYS_SEL 89 +#define CLK_TOP_GRAPH_ECLK_SEL 90 +#define CLK_TOP_FDBI_SEL 91 +#define CLK_TOP_FAUDIO_SEL 92 +#define CLK_TOP_FA2SYS_SEL 93 +#define CLK_TOP_FA1SYS_SEL 94 +#define CLK_TOP_FASM_M_SEL 95 +#define CLK_TOP_FASM_H_SEL 96 +#define CLK_TOP_FASM_L_SEL 97 +#define CLK_TOP_FECC_CK_SEL 98 +#define CLK_TOP_PE2_MAC_SEL 99 +#define CLK_TOP_CMSYS_SEL 100 +#define CLK_TOP_GCPU_SEL 101 +#define CLK_TOP_SPIS_CK_SEL 102 +#define CLK_TOP_APLL1_REF_SEL 103 +#define CLK_TOP_APLL2_REF_SEL 104 +#define CLK_TOP_INT_32K_SEL 105 +#define CLK_TOP_APLL1_SRC_SEL 106 +#define CLK_TOP_APLL2_SRC_SEL 107 +#define CLK_TOP_FAUD_INTBUS_SEL 108 +#define CLK_TOP_AXIBUS_SEL 109 +#define CLK_TOP_HAPLL1_SEL 110 +#define CLK_TOP_HAPLL2_SEL 111 +#define CLK_TOP_SPINFI_SEL 112 +#define CLK_TOP_MSDC0_SEL 113 +#define CLK_TOP_MSDC0_CLK50_SEL 114 +#define CLK_TOP_MSDC2_SEL 115 +#define CLK_TOP_MSDC2_CLK50_SEL 116 +#define CLK_TOP_DISP_DPI_CK_SEL 117 +#define CLK_TOP_SPI1_SEL 118 +#define CLK_TOP_SPI2_SEL 119 +#define CLK_TOP_SPI3_SEL 120 +#define CLK_TOP_APLL12_CK_DIV0 121 +#define CLK_TOP_APLL12_CK_DIV3 122 +#define CLK_TOP_APLL12_CK_DIV4 123 +#define CLK_TOP_APLL12_CK_DIV6 124 + +/* TOPCKGEN Gates */ +#define CLK_TOP_PWM_MM 0 +#define CLK_TOP_SMI 1 +#define CLK_TOP_SPI2 2 +#define CLK_TOP_SPI3 3 +#define CLK_TOP_SPINFI 4 +#define CLK_TOP_26M_DEBUG 5 +#define CLK_TOP_USB_48M_DEBUG 6 +#define CLK_TOP_52M_DEBUG 7 +#define CLK_TOP_32K_DEBUG 8 +#define CLK_TOP_THERM 9 +#define CLK_TOP_APDMA 10 +#define CLK_TOP_I2C0 11 +#define CLK_TOP_I2C1 12 +#define CLK_TOP_AUXADC1 13 +#define CLK_TOP_NFI 14 +#define CLK_TOP_NFIECC 15 +#define CLK_TOP_DEBUGSYS 16 +#define CLK_TOP_PWM 17 +#define CLK_TOP_UART0 18 +#define CLK_TOP_UART1 19 +#define CLK_TOP_USB 20 +#define CLK_TOP_FLASHIF_26M 21 +#define CLK_TOP_AUXADC2 22 +#define CLK_TOP_I2C2 23 +#define CLK_TOP_MSDC0 24 +#define CLK_TOP_MSDC1 25 +#define CLK_TOP_NFI2X 26 +#define CLK_TOP_MEMSLP_DLYER 27 +#define CLK_TOP_SPI 28 +#define CLK_TOP_APXGPT 29 +#define CLK_TOP_PMICWRAP_MD 30 +#define CLK_TOP_PMICWRAP_CONN 31 +#define CLK_TOP_PMIC_SYSCK 32 +#define CLK_TOP_AUX_ADC 33 +#define CLK_TOP_AUX_TP 34 +#define CLK_TOP_RBIST 35 +#define CLK_TOP_NFI_BUS 36 +#define CLK_TOP_GCE 37 +#define CLK_TOP_TRNG 38 +#define CLK_TOP_PWM_B 39 +#define CLK_TOP_PWM1_FB 40 +#define CLK_TOP_PWM2_FB 41 +#define CLK_TOP_PWM3_FB 42 +#define CLK_TOP_PWM4_FB 43 +#define CLK_TOP_PWM5_FB 44 +#define CLK_TOP_FLASHIF_FREERUN 45 +#define CLK_TOP_CQDMA 46 +#define CLK_TOP_66M_ETH 47 +#define CLK_TOP_133M_ETH 48 +#define CLK_TOP_FLASHIF_AXI 49 +#define CLK_TOP_USBIF 50 +#define CLK_TOP_UART2 51 +#define CLK_TOP_GCPU_B 52 +#define CLK_TOP_MSDC0_B 53 +#define CLK_TOP_MSDC1_B 54 +#define CLK_TOP_MSDC2_B 55 +#define CLK_TOP_USB_B 56 +#define CLK_TOP_SPINOR 57 +#define CLK_TOP_MSDC2 58 +#define CLK_TOP_ETH 59 +#define CLK_TOP_AUD1 60 +#define CLK_TOP_AUD2 61 +#define CLK_TOP_I2C 62 +#define CLK_TOP_PWM_INFRA 63 +#define CLK_TOP_AUD_SPDIF_IN 64 +#define CLK_TOP_RG_UART2 65 +#define CLK_TOP_DBG_AT 66 +#define CLK_TOP_APLL12_DIV0 67 +#define CLK_TOP_APLL12_DIV3 68 +#define CLK_TOP_APLL12_DIV4 69 +#define CLK_TOP_APLL12_DIV6 70 +#define CLK_TOP_IMGRZ_SYS 71 +#define CLK_TOP_PNG_SYS 72 +#define CLK_TOP_GRAPH_E 73 +#define CLK_TOP_FDBI 74 +#define CLK_TOP_FAUDIO 75 +#define CLK_TOP_FAUD_INTBUS 76 +#define CLK_TOP_HAPLL1 77 +#define CLK_TOP_HAPLL2 78 +#define CLK_TOP_FA2SYS 79 +#define CLK_TOP_FA1SYS 80 +#define CLK_TOP_FASM_L 81 +#define CLK_TOP_FASM_M 82 +#define CLK_TOP_FASM_H 83 +#define CLK_TOP_FECC 84 +#define CLK_TOP_PE2_MAC 85 +#define CLK_TOP_CMSYS 86 +#define CLK_TOP_GCPU 87 +#define CLK_TOP_SPIS 88 +#define CLK_TOP_I2C3 89 +#define CLK_TOP_SPI_SLV_B 90 +#define CLK_TOP_SPI_SLV_BUS 91 +#define CLK_TOP_PCIE_MAC_BUS 92 +#define CLK_TOP_CMSYS_BUS 93 +#define CLK_TOP_ECC_B 94 +#define CLK_TOP_PCIE_PHY_BUS 95 +#define CLK_TOP_PCIE_AUX 96 +#define CLK_TOP_DISP_DPI 97 +#define CLK_TOP_NR_CLK 98 + +#endif /* _DT_BINDINGS_CLK_MT8518_H */ diff --git a/include/eeprom.h b/include/eeprom.h new file mode 100644 index 0000000000..61eb826a73 --- /dev/null +++ b/include/eeprom.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#ifndef __EEPROM_LEGACY_H +#define __EEPROM_LEGACY_H + +#ifdef CONFIG_CMD_EEPROM +void eeprom_init(int bus); +int eeprom_read(uint dev_addr, uint offset, uchar *buffer, uint cnt); +int eeprom_write(uint dev_addr, uint offset, uchar *buffer, uint cnt); +#else +/* + * Some EEPROM code is depecated because it used the legacy I2C interface. Add + * some macros here so we don't have to touch every one of those uses + */ +#define eeprom_init(bus) +#define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS) +#define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS) +#endif + +#endif diff --git a/include/exports.h b/include/exports.h index 147a00f860..35f463287f 100644 --- a/include/exports.h +++ b/include/exports.h @@ -1,12 +1,16 @@ #ifndef __EXPORTS_H__ #define __EXPORTS_H__ +#include <irq_func.h> + #ifndef __ASSEMBLY__ #ifdef CONFIG_PHY_AQUANTIA #include <env.h> #include <phy_interface.h> #endif +#include <irq_func.h> + struct spi_slave; /* These are declarations of exported functions available in C code */ diff --git a/include/init.h b/include/init.h index afc953d51e..8b65b2afe4 100644 --- a/include/init.h +++ b/include/init.h @@ -10,6 +10,8 @@ #ifndef __INIT_H_ #define __INIT_H_ 1 +#include <linux/types.h> + #ifndef __ASSEMBLY__ /* put C only stuff in this section */ /* @@ -149,6 +151,8 @@ ulong board_init_f_alloc_reserve(ulong top); */ void board_init_f_init_reserve(ulong base); +struct global_data; + /** * arch_setup_gd() - Set up the global_data pointer * @gd_ptr: Pointer to global data @@ -160,10 +164,11 @@ void board_init_f_init_reserve(ulong base); * * gd = gd_ptr; */ -void arch_setup_gd(gd_t *gd_ptr); +void arch_setup_gd(struct global_data *gd_ptr); /* common/board_r.c */ -void board_init_r(gd_t *id, ulong dest_addr) __attribute__ ((noreturn)); +void board_init_r(struct global_data *id, ulong dest_addr) + __attribute__ ((noreturn)); int cpu_init_r(void); int last_stage_init(void); @@ -181,6 +186,30 @@ int init_func_vid(void); int checkboard(void); int show_board_info(void); +/** + * Get the uppermost pointer that is valid to access + * + * Some systems may not map all of their address space. This function allows + * boards to indicate what their highest support pointer value is for DRAM + * access. + * + * @param total_size Size of U-Boot (unused?) + */ +ulong board_get_usable_ram_top(ulong total_size); + +int board_early_init_f(void); + +/* manipulate the U-Boot fdt before its relocation */ +int board_fix_fdt(void *rw_fdt_blob); +int board_late_init(void); +int board_postclk_init(void); /* after clocks/timebase, before env/serial */ +int board_early_init_r(void); + +/* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */ +void pci_init_board(void); + +void trap_init(unsigned long reloc_addr); + #endif /* __ASSEMBLY__ */ /* Put only stuff here that the assembler can digest */ diff --git a/include/irq_func.h b/include/irq_func.h new file mode 100644 index 0000000000..c7c4babbfc --- /dev/null +++ b/include/irq_func.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Header file for interrupt functions + * + * (C) Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#ifndef __IRQ_FUNC_H +#define __IRQ_FUNC_H + +struct pt_regs; + +typedef void (interrupt_handler_t)(void *arg); + +int interrupt_init(void); +void timer_interrupt(struct pt_regs *regs); +void external_interrupt(struct pt_regs *regs); +void irq_install_handler(int vec, interrupt_handler_t *handler, void *arg); +void irq_free_handler(int vec); +void reset_timer(void); + +void enable_interrupts(void); +int disable_interrupts(void); + +#endif diff --git a/include/linux/crc8.h b/include/linux/crc8.h deleted file mode 100644 index 0ab5b9ab21..0000000000 --- a/include/linux/crc8.h +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (c) 2013 Google, Inc - */ - - -#ifndef __linux_crc8_h -#define __linux_crc8_h - -/** - * crc8() - Calculate and return CRC-8 of the data - * - * This uses an x^8 + x^2 + x + 1 polynomial. A table-based algorithm would - * be faster, but for only a few bytes it isn't worth the code size - * - * @crc_start: CRC8 start value - * @vptr: Buffer to checksum - * @len: Length of buffer in bytes - * @return CRC8 checksum - */ -unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len); - -#endif diff --git a/include/linux/mii.h b/include/linux/mii.h index 21db032340..49e29ac314 100644 --- a/include/linux/mii.h +++ b/include/linux/mii.h @@ -225,4 +225,6 @@ static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv) return cap; } +void mii_init(void); + #endif /* __LINUX_MII_H__ */ diff --git a/include/lz4.h b/include/lz4.h new file mode 100644 index 0000000000..1276fb98a3 --- /dev/null +++ b/include/lz4.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef __LZ4_H +#define __LZ4_H + +/** + * ulz4fn() - Decompress LZ4 data + * + * @src: Source data to decompress + * @srcn: Length of source data + * @dst: Destination for uncompressed data + * @dstn: Returns length of uncompressed data + * @return 0 if OK, -EPROTONOSUPPORT if the magic number or version number are + * not recognised or independent blocks are used, -EINVAL if the reserved + * fields are non-zero, or input is overrun, -EENOBUFS if the destination + * buffer is overrun, -EEPROTO if the compressed data causes an error in + * the decompression algorithm + */ +int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn); + +#endif diff --git a/include/net.h b/include/net.h index 75a16e4c8f..11eca1bc6c 100644 --- a/include/net.h +++ b/include/net.h @@ -16,6 +16,7 @@ #include <asm/byteorder.h> /* for nton* / ntoh* stuff */ #include <env.h> #include <linux/if_ether.h> +#include <rand.h> #define DEBUG_LL_STATE 0 /* Link local state machine changes */ #define DEBUG_DEV_PKT 0 /* Packets or info directed to the device */ @@ -828,7 +829,13 @@ static inline void net_random_ethaddr(uchar *addr) /* Convert an IP address to a string */ void ip_to_string(struct in_addr x, char *s); -/* Convert a string to ip address */ +/** + * string_to_ip() - Convert a string to ip address + * + * @s: String to conver, in the format format a.b.c.d, where each value is a + * decimal number from 0 to 255 + * @return IP address, or 0 if invalid + */ struct in_addr string_to_ip(const char *s); /* Convert a VLAN id to a string */ @@ -886,4 +893,17 @@ int update_tftp(ulong addr, char *interface, char *devstring); */ void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr); +/** + * env_get_ip() - Convert an environment value to to an ip address + * + * @var: Environment variable to convert. The value of this variable must be + * in the format format a.b.c.d, where each value is a decimal number from + * 0 to 255 + * @return IP address, or 0 if invalid + */ +static inline struct in_addr env_get_ip(char *var) +{ + return string_to_ip(env_get(var)); +} + #endif /* __NET_H__ */ diff --git a/include/rand.h b/include/rand.h new file mode 100644 index 0000000000..c9d15f50a1 --- /dev/null +++ b/include/rand.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#ifndef __RAND_H +#define __RAND_H + +#define RAND_MAX -1U + +/** + * srand() - Set the random-number seed value + * + * This can be used to restart the pseudo-random-number sequence from a known + * point. This affects future calls to rand() to start from that point + * + * @seed: New seed + */ +void srand(unsigned int seed); + +/** + * rand() - Get a 32-bit pseudo-random number + * + * @returns next random number in the sequence + */ +unsigned int rand(void); + +/** + * rand_r() - Get a 32-bit pseudo-random number + * + * This version of the function allows multiple sequences to be used at the + * same time, since it requires the caller to store the seed value. + * + * @seed value to use, updated on exit + * @returns next random number in the sequence + */ +unsigned int rand_r(unsigned int *seedp); + +#endif diff --git a/include/serial.h b/include/serial.h index c1368c68b6..104f34ff91 100644 --- a/include/serial.h +++ b/include/serial.h @@ -50,18 +50,20 @@ extern void serial_reinit_all(void); /* For usbtty */ #ifdef CONFIG_USB_TTY -extern int usbtty_getc(void); -extern void usbtty_putc(const char c); -extern void usbtty_puts(const char *str); -extern int usbtty_tstc(void); +struct stdio_dev; + +int usbtty_getc(struct stdio_dev *dev); +void usbtty_putc(struct stdio_dev *dev, const char c); +void usbtty_puts(struct stdio_dev *dev, const char *str); +int usbtty_tstc(struct stdio_dev *dev); #else /* stubs */ -#define usbtty_getc() 0 -#define usbtty_putc(a) -#define usbtty_puts(a) -#define usbtty_tstc() 0 +#define usbtty_getc(dev) 0 +#define usbtty_putc(dev, a) +#define usbtty_puts(dev, a) +#define usbtty_tstc(dev) 0 #endif /* CONFIG_USB_TTY */ @@ -322,4 +324,23 @@ void pl01x_serial_initialize(void); void pxa_serial_initialize(void); void sh_serial_initialize(void); +/** + * serial_printf() - Write a formatted string to the serial console + * + * The total size of the output must be less than CONFIG_SYS_PBSIZE. + * + * @fmt: Printf format string, followed by format arguments + * @return number of characters written + */ +int serial_printf(const char *fmt, ...) + __attribute__ ((format (__printf__, 1, 2))); + +int serial_init(void); +void serial_setbrg(void); +void serial_putc(const char ch); +void serial_putc_raw(const char ch); +void serial_puts(const char *str); +int serial_getc(void); +int serial_tstc(void); + #endif diff --git a/include/sort.h b/include/sort.h new file mode 100644 index 0000000000..0c6b588fcb --- /dev/null +++ b/include/sort.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef __SORT_H +#define __SORT_H + +/** + * qsort() - Use the quicksort algorithm to sort some values + * + * @base: Base address of array to sort + * @nmemb: Number of members to sort + * @size: Size of each member in bytes + * @compar: Comparison function which should return: + * < 0 if element at s1 < element at s2, + * 0 if element at s1 == element at s2, + * > 0 if element at s1 > element at s2, + */ +void qsort(void *base, size_t nmemb, size_t size, + int (*compar)(const void *s1, const void *s2)); + +/** + * strcmp_compar() - compar function for string arrays + * + * This can be passed to qsort when a string array is being sorted + * + * @s1: First string to compare + * @s2: Second string to compare + * @return comparison value (less than, equal to, or greater than 0) + */ +int strcmp_compar(const void *s1, const void *s2); + +#endif diff --git a/include/status_led.h b/include/status_led.h index 5b3570166d..6707ab1d29 100644 --- a/include/status_led.h +++ b/include/status_led.h @@ -36,8 +36,8 @@ #endif /* CONFIG_LED_STATUS5 */ void status_led_init(void); -void status_led_tick (unsigned long timestamp); -void status_led_set (int led, int state); +void status_led_tick(unsigned long timestamp); +void status_led_set(int led, int state); /***** MVS v1 **********************************************************/ #if (defined(CONFIG_MVS) && CONFIG_MVS < 2) diff --git a/include/time.h b/include/time.h index a1149522ed..71446c3171 100644 --- a/include/time.h +++ b/include/time.h @@ -70,4 +70,47 @@ uint64_t usec_to_tick(unsigned long usec); (time_after_eq(a,b) && \ time_before(a,c)) +/** + * usec2ticks() - Convert microseconds to internal ticks + * + * @usec: Value of microseconds to convert + * @return Corresponding internal ticks value, calculated using get_tbclk() + */ +ulong usec2ticks(unsigned long usec); + +/** + * ticks2usec() - Convert internal ticks to microseconds + * + * @ticks: Value of ticks to convert + * @return Corresponding microseconds value, calculated using get_tbclk() + */ +ulong ticks2usec(unsigned long ticks); + +/** + * wait_ticks() - waits a given number of ticks + * + * This is an internal function typically used to implement udelay() and + * similar. Normally you should use udelay() or mdelay() instead. + * + * @ticks: Number of ticks to wait + */ +void wait_ticks(unsigned long ticks); + +/** + * timer_get_us() - Get monotonic microsecond timer + * + * @return value of monotonic microsecond timer + */ +unsigned long timer_get_us(void); + +/** + * get_ticks() - Get the current tick value + * + * This is an internal value used by the timer on the system. Ticks increase + * monotonically at the rate given by get_tbclk(). + * + * @return current tick value + */ +uint64_t get_ticks(void); + #endif /* _TIME_H */ diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h index 788ef29a17..1086d2168c 100644 --- a/include/u-boot/crc.h +++ b/include/u-boot/crc.h @@ -8,7 +8,19 @@ #ifndef _UBOOT_CRC_H #define _UBOOT_CRC_H -/* lib/crc8.c */ +/** + * crc8() - Calculate and return CRC-8 of the data + * + * This uses an x^8 + x^2 + x + 1 polynomial. A table-based algorithm would + * be faster, but for only a few bytes it isn't worth the code size + * + * lib/crc8.c + * + * @crc_start: CRC8 start value + * @vptr: Buffer to checksum + * @len: Length of buffer in bytes + * @return CRC8 checksum + */ unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len); /* lib/crc16.c - 16 bit CRC with polynomial x^16+x^12+x^5+1 (CRC-CCITT) */ @@ -26,9 +38,47 @@ void crc16_ccitt_wd_buf(const uint8_t *in, uint len, uint8_t *out, uint chunk_sz); /* lib/crc32.c */ -uint32_t crc32 (uint32_t, const unsigned char *, uint); -uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint); -uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint); + +/** + * crc32 - Calculate the CRC32 for a block of data + * + * @crc: Input crc to chain from a previous calculution (use 0 to start a new + * calculation) + * @buf: Bytes to checksum + * @len: Number of bytes to checksum + * @return checksum value + */ +uint32_t crc32(uint32_t crc, const unsigned char *buf, uint len); + +/** + * crc32_wd - Calculate the CRC32 for a block of data (watchdog version) + * + * This checksums the data @chunk_sz bytes at a time, calling WATCHDOG_RESET() + * after each chunk, to prevent the watchdog from firing. + * + * @crc: Input crc to chain from a previous calculution (use 0 to start a new + * calculation) + * @buf: Bytes to checksum + * @len: Number of bytes to checksum + * @chunk_sz: Chunk size to use between watchdog resets + * @return checksum + */ +uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uint len, + uint chunk_sz); + +/** + * crc32_no_comp - Calculate the CRC32 for a block of data (no one's compliment) + * + * This version uses a different algorithm which doesn't use one's compliment. + * JFFS2 (and other things?) use this. + * + * @crc: Input crc to chain from a previous calculution (use 0 to start a new + * calculation) + * @buf: Bytes to checksum + * @len: Number of bytes to checksum + * @return checksum value + */ +uint32_t crc32_no_comp(uint32_t crc, const unsigned char *buf, uint len); /** * crc32_wd_buf - Perform CRC32 on a buffer and return result in buffer @@ -38,11 +88,34 @@ uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint); * @output: Place to put checksum result (4 bytes) * @chunk_sz: Trigger watchdog after processing this many bytes */ -void crc32_wd_buf(const unsigned char *input, uint ilen, - unsigned char *output, uint chunk_sz); +void crc32_wd_buf(const uint8_t *input, uint ilen, uint8_t *output, + uint chunk_sz); /* lib/crc32c.c */ -void crc32c_init(uint32_t *, uint32_t); -uint32_t crc32c_cal(uint32_t, const char *, int, uint32_t *); + +/** + * crc32c_init() - Set up a the CRC32 table + * + * This sets up 256-item table to aid in CRC32 calculation + * + * @crc32c_table: Place to put table + * @pol: polynomial to use + */ +void crc32c_init(uint32_t *crc32c_table, uint32_t pol); + +/** + * crc32c_cal() - Perform CRC32 on a buffer given a table + * + * This algorithm uses the table (set up by crc32c_init() to speed up + * processing. + * + * @crc: Previous crc (use 0 at start) + * @data: Data bytes to checksum + * @length: Number of bytes to process + * @crc32c_table:: CRC table + * @return checksum value + */ +uint32_t crc32c_cal(uint32_t crc, const char *data, int length, + uint32_t *crc32c_table); #endif /* _UBOOT_CRC_H */ diff --git a/include/vsprintf.h b/include/vsprintf.h index d1740a378e..56844dd2de 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -212,4 +212,14 @@ void print_grouped_ull(unsigned long long int_val, int digits); bool str2off(const char *p, loff_t *num); bool str2long(const char *p, ulong *num); + +/** + * strmhz() - Convert a value to a Hz string + * + * This creates a string indicating the number of MHz of a value. For example, + * 2700000 produces "2.7". + * @buf: Buffer to hold output string, which must be large enough + * @hz: Value to convert + */ +char *strmhz(char *buf, unsigned long hz); #endif diff --git a/include/vxworks.h b/include/vxworks.h index 1a29509460..d90d862fb7 100644 --- a/include/vxworks.h +++ b/include/vxworks.h @@ -9,6 +9,9 @@ #include <efi_api.h> +/* Use Linux compatible standard DTB */ +#define VXWORKS_SYSFLG_STD_DTB 0x1 + /* * Physical address of memory base for VxWorks x86 * This is LOCAL_MEM_LOCAL_ADRS in the VxWorks kernel configuration. |