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-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Based on Ocelot Linux port, which is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright 2001 MontaVista Software Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Author: jsun@mvista.com or jsun@junsun.net
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright 2003 ICT CAS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Author: Michael Guo <guoyi@ict.ac.cn>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  * Author: Fuxin Zhang, zhangfx@lemote.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * Copyright (C) 2009 Lemote Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * Author: Wu Zhangjin, wuzhangjin@gmail.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/fw/fw.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <loongson.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) u32 cpu_clock_freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) EXPORT_SYMBOL(cpu_clock_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) void __init prom_init_env(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	/* pmon passes arguments in 32bit pointers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	unsigned int processor_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	cpu_clock_freq = fw_getenvl("cpuclock");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	memsize = fw_getenvl("memsize");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	highmemsize = fw_getenvl("highmemsize");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (memsize == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		memsize = 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	pr_info("memsize=%u, highmemsize=%u\n", memsize, highmemsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	if (cpu_clock_freq == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		processor_id = (&current_cpu_data)->processor_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		switch (processor_id & PRID_REV_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		case PRID_REV_LOONGSON2E:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 			cpu_clock_freq = 533080000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		case PRID_REV_LOONGSON2F:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 			cpu_clock_freq = 797000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 			cpu_clock_freq = 100000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	pr_info("CpuClock = %u\n", cpu_clock_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }