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)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Author: Fuxin Zhang, zhangfx@lemote.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2009 Lemote, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Author: Zhangjin Wu, wuzhangjin@gmail.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/idle.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <loongson.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) static inline void loongson_reboot(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifndef CONFIG_CPU_JUMP_WORKAROUNDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	((void (*)(void))ioremap(LOONGSON_BOOT_BASE, 4)) ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	void (*func)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	func = (void *)ioremap(LOONGSON_BOOT_BASE, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	__asm__ __volatile__(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	"	.set	noat						\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	"	jr	%[func]						\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	"	.set	at						\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	: /* No outputs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	: [func] "r" (func));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static void loongson_restart(char *command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	/* do preparation for reboot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	mach_prepare_reboot();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	/* reboot via jumping to boot base address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	loongson_reboot();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static void loongson_poweroff(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	mach_prepare_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	 * It needs a wait loop here, but mips/kernel/reset.c already calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	 * a generic delay loop, machine_hang(), so simply return.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static void loongson_halt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	pr_notice("\n\n** You can safely turn off the power now **\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		if (cpu_wait)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 			cpu_wait();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static int __init mips_reboot_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	_machine_restart = loongson_restart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	_machine_halt = loongson_halt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	pm_power_off = loongson_poweroff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) arch_initcall(mips_reboot_setup);