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)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (C) 2012 Thomas Langer <thomas.langer@lantiq.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2012 John Crispin <john@phrozen.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^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/io.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) #include <asm/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <lantiq_soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * Dummy implementation.  Used to allow platform code to find out what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * source was booted from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned char ltq_boot_select(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	return BS_SPI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define BOOT_REG_BASE	(KSEG1 | 0x1F200000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define BOOT_PW1_REG	(BOOT_REG_BASE | 0x20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define BOOT_PW2_REG	(BOOT_REG_BASE | 0x24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define BOOT_PW1	0x4C545100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define BOOT_PW2	0x0051544C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define WDT_REG_BASE	(KSEG1 | 0x1F8803F0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define WDT_PW1		0x00BE0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define WDT_PW2		0x00DC0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static void machine_restart(char *command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	/* reboot magic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	ltq_w32(BOOT_PW1, (void *)BOOT_PW1_REG); /* 'LTQ\0' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	ltq_w32(BOOT_PW2, (void *)BOOT_PW2_REG); /* '\0QTL' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	ltq_w32(0, (void *)BOOT_REG_BASE); /* reset Bootreg RVEC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	/* watchdog magic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	ltq_w32(WDT_PW1, (void *)WDT_REG_BASE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	ltq_w32(WDT_PW2 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		(0x3 << 26) | /* PWL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		(0x2 << 24) | /* CLKDIV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		(0x1 << 31) | /* enable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		(1), /* reload */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		(void *)WDT_REG_BASE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	unreachable();
^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 machine_halt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	unreachable();
^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) static void machine_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	unreachable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static int __init mips_reboot_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	_machine_restart = machine_restart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	_machine_halt = machine_halt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	pm_power_off = machine_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) arch_initcall(mips_reboot_setup);