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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * IP32 basic setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (C) 2000 Harald Koerfgen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Copyright (C) 2002, 2003, 2005 Ilya A. Volynets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Copyright (C) 2006 Ralf Baechle <ralf@linux-mips.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/console.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/mipsregs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/mmu_context.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <asm/sgialib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <asm/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <asm/ip32/crime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <asm/ip32/mace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <asm/ip32/ip32_ints.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) extern void ip32_be_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) extern void crime_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #ifdef CONFIG_SGI_O2MACE_ETH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * This is taken care of in here 'cause they say using Arc later on is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * problematic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) extern char o2meth_eaddr[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static inline unsigned char str2hexnum(unsigned char c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	if (c >= '0' && c <= '9')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		return c - '0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	if (c >= 'a' && c <= 'f')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		return c - 'a' + 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	return 0; /* foo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static inline void str2eaddr(unsigned char *ea, unsigned char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	for (i = 0; i < 6; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		unsigned char num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		if(*str == ':')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 			str++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		num = str2hexnum(*str++) << 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		num |= (str2hexnum(*str++));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		ea[i] = num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) /* An arbitrary time; this can be decreased if reliability looks good */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define WAIT_MS 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) void __init plat_time_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	printk(KERN_INFO "Calibrating system timer... ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	write_c0_count(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	crime->timer = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) void __init plat_mem_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	board_be_init = ip32_be_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #ifdef CONFIG_SGI_O2MACE_ETH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		char *mac = ArcGetEnvironmentVariable("eaddr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		str2eaddr(o2meth_eaddr, mac);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #if defined(CONFIG_SERIAL_CORE_CONSOLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		char* con = ArcGetEnvironmentVariable("console");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		if (con && *con == 'd') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			static char options[8] __initdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			char *baud = ArcGetEnvironmentVariable("dbaud");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			if (baud)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 				strcpy(options, baud);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 					      baud ? options : NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }