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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * RedBoot firmware support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Author: Scott Wood <scottwood@freescale.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright (c) 2007 Freescale Semiconductor, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Copyright (c) 2008 Codehermit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "ops.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "stdio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "redboot.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "fsl-soc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "io.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) static bd_t bd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) BSS_STACK(4096);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define MHZ(x)	((x + 500000) / 1000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static void platform_fixups(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	void *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	dt_fixup_mac_addresses(bd.bi_enetaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 16, bd.bi_busfreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	node = finddevice("/soc/cpm/brg");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	if (node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		printf("BRG clock-frequency <- 0x%x (%dMHz)\r\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		       bd.bi_busfreq, MHZ(bd.bi_busfreq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		setprop(node, "clock-frequency",  &bd.bi_busfreq, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		   unsigned long r6, unsigned long r7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	memcpy(&bd, (char *)r3, sizeof(bd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	if (bd.bi_tag != 0x42444944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	simple_alloc_init(_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 			  bd.bi_memstart + bd.bi_memsize - (unsigned long)_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 			  32, 64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	fdt_init(_dtb_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	serial_console_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	platform_ops.fixups = platform_fixups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	loader_info.cmdline = (char *)bd.bi_cmdline;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	loader_info.cmdline_len = strlen((char *)bd.bi_cmdline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }