--- zzzz-none-000/linux-3.10.107/arch/mips/ath79/prom.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/mips/ath79/prom.c 2021-11-10 11:53:53.000000000 +0000 @@ -14,44 +14,141 @@ #include #include +#include +#include +#include + +#include + #include #include +#include +#include +#include #include "common.h" -static inline int is_valid_ram_addr(void *addr) -{ - if (((u32) addr > KSEG0) && - ((u32) addr < (KSEG0 + ATH79_MEM_SIZE_MAX))) - return 1; - - if (((u32) addr > KSEG1) && - ((u32) addr < (KSEG1 + ATH79_MEM_SIZE_MAX))) - return 1; - - return 0; +#ifdef CONFIG_EARLY_PRINTK +extern void serial_print(char *fmt, ...) ; +#else +#define serial_print(fmt, ...) +#endif + +static unsigned int fw3_save[8]; + +/*--- #define DEBUG_ATH_PROM ---*/ + +#if defined(DEBUG_ATH_PROM) +#define ath_prom_print(arg...) serial_print(arg) +#else +#define ath_prom_print(arg...) +#endif + +void prom_printf (const char *fmt, ...) { + va_list args; + + va_start (args, fmt); + ath_prom_print (fmt, args); + va_end (args); } -static __init void ath79_prom_init_cmdline(int argc, char **argv) -{ +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +static __init void ath79_prom_init_cmdline(int argc, char **argv) { + int i; + serial_print("\n"); /*--- damit es schön aussieht ---*/ + ath_prom_print("[%s]:\n", __func__); + ath_prom_print("[%s]: argv[0] = '%s'\n", __func__, argv[0]); + ath_prom_print("[%s]: argv[1] = '%s'\n", __func__, argv[1]); + ath_prom_print("[%s]: argv[2] = '%s'\n", __func__, argv[2]); + +#if 0 if (!is_valid_ram_addr(argv)) return; +#endif - for (i = 0; i < argc; i++) + for (i = 0; i < argc; i++) { +#if 0 if (is_valid_ram_addr(argv[i])) { +#endif strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline)); strlcat(arcs_cmdline, argv[i], sizeof(arcs_cmdline)); +#if 0 } +#endif + } + + ath_prom_print("[%s]:commandline = '%s'\n", __FUNCTION__, arcs_cmdline); +} + +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +static void __init mips_nmi_setup(void) { + + void *base; + extern char except_vec_nmi; + + base = cpu_has_veic ? + (void *)(CAC_BASE + 0xa80) : + (void *)(CAC_BASE + 0x380); + memcpy(base, &except_vec_nmi, 0x80); + printk(KERN_ERR "[%s] setup NMI vector to base 0x%p\n", __FUNCTION__, base); + flush_icache_range((unsigned long)base, (unsigned long)base + 0x80); } -void __init prom_init(void) +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +void __init device_tree_init(void) { + unsigned long base, size; + + if (!initial_boot_params) + return; + + base = virt_to_phys((void *)initial_boot_params); + size = be32_to_cpu(initial_boot_params->totalsize); + + /* Before we do anything, lets reserve the dt blob */ + reserve_bootmem(base, size, BOOTMEM_DEFAULT); + + unflatten_device_tree(); +} + +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +void __init prom_init(void) { + + ath_prom_print("[%s]:\n", __func__); ath79_prom_init_cmdline(fw_arg0, (char **)fw_arg1); + ath_prom_print("[%s]: call env_init\n", __func__); + env_init((int *)fw_arg2, ENV_LOCATION_FLASH); + + memcpy(fw3_save, (const void *)fw_arg3, sizeof(fw3_save)); + mips_machtype = MACH_GROUP_ATHEROS; + + board_nmi_handler_setup = mips_nmi_setup; + + ath_prom_print("[%s]: done\n", __func__); } void __init prom_free_prom_memory(void) { /* We do not have to prom memory to free */ } + +static int __init prom_init_config(void) +{ + unsigned int *config = (unsigned int*)fw3_save; + int i; + + for (i = 0; i < 8; i++) { + unsigned int c = config[i] & ((128 << 10) - 1); + + avm_prom_load_config_entry(c); + } + + return 0; +} +late_initcall(prom_init_config);