Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * init.c: PROM library initialisation code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1998 Harald Koerfgen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2002, 2004  Maciej W. Rozycki
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/cpu-type.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/dec/prom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) int (*__rex_bootinit)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) int (*__rex_bootread)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) int (*__rex_getbitmap)(memmap *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) unsigned long *(*__rex_slot_address)(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) void *(*__rex_gettcinfo)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) int (*__rex_getsysid)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) void (*__rex_clear_cache)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) int (*__prom_getchar)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) char *(*__prom_getenv)(char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) int (*__prom_printf)(char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) int (*__pmax_open)(char*, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) int (*__pmax_lseek)(int, long, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) int (*__pmax_read)(int, void *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) int (*__pmax_close)(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * Detect which PROM the DECSTATION has, and set the callback vectors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) void __init which_prom(s32 magic, s32 *prom_vec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 * No sign of the REX PROM's magic number means we assume a non-REX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	 * machine (i.e. we're on a DS2100/3100, DS5100 or DS5000/2xx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	if (prom_is_rex(magic)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		 * Set up prom abstraction structure with REX entry points.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		__rex_bootinit =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 			(void *)(long)*(prom_vec + REX_PROM_BOOTINIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		__rex_bootread =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			(void *)(long)*(prom_vec + REX_PROM_BOOTREAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		__rex_getbitmap =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			(void *)(long)*(prom_vec + REX_PROM_GETBITMAP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		__prom_getchar =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			(void *)(long)*(prom_vec + REX_PROM_GETCHAR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		__prom_getenv =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			(void *)(long)*(prom_vec + REX_PROM_GETENV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		__rex_getsysid =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			(void *)(long)*(prom_vec + REX_PROM_GETSYSID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		__rex_gettcinfo =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			(void *)(long)*(prom_vec + REX_PROM_GETTCINFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		__prom_printf =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			(void *)(long)*(prom_vec + REX_PROM_PRINTF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		__rex_slot_address =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			(void *)(long)*(prom_vec + REX_PROM_SLOTADDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		__rex_clear_cache =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			(void *)(long)*(prom_vec + REX_PROM_CLEARCACHE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		 * Set up prom abstraction structure with non-REX entry points.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		__prom_getchar = (void *)PMAX_PROM_GETCHAR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		__prom_getenv = (void *)PMAX_PROM_GETENV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		__prom_printf = (void *)PMAX_PROM_PRINTF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		__pmax_open = (void *)PMAX_PROM_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		__pmax_lseek = (void *)PMAX_PROM_LSEEK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		__pmax_read = (void *)PMAX_PROM_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		__pmax_close = (void *)PMAX_PROM_CLOSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) void __init prom_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	extern void dec_machine_halt(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	static const char cpu_msg[] __initconst =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		"Sorry, this kernel is compiled for a wrong CPU type!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	s32 argc = fw_arg0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	s32 *argv = (void *)fw_arg1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	u32 magic = fw_arg2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	s32 *prom_vec = (void *)fw_arg3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 * Determine which PROM we have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	 * (and therefore which machine we're on!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	which_prom(magic, prom_vec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (prom_is_rex(magic))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		rex_clear_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	/* Register the early console.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	register_prom_console();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	/* Were we compiled with the right CPU option? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #if defined(CONFIG_CPU_R3000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if ((current_cpu_type() == CPU_R4000SC) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	    (current_cpu_type() == CPU_R4400SC)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		static const char r4k_msg[] __initconst =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			"Please recompile with \"CONFIG_CPU_R4x00 = y\".\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		printk(cpu_msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		printk(r4k_msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		dec_machine_halt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #if defined(CONFIG_CPU_R4X00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	if ((current_cpu_type() == CPU_R3000) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	    (current_cpu_type() == CPU_R3000A)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		static const char r3k_msg[] __initconst =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			"Please recompile with \"CONFIG_CPU_R3000 = y\".\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		printk(cpu_msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		printk(r3k_msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		dec_machine_halt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	prom_meminit(magic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	prom_identify_arch(magic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	prom_init_cmdline(argc, argv, magic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }