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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * misc.c:  Miscellaneous prom functions that don't belong
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *          anywhere else.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/sun3-head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/idprom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/openprom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/oplib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/movs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* Reset and reboot the machine with the command 'bcommand'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) prom_reboot(char *bcommand)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	(*(romvec->pv_reboot))(bcommand);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /* Drop into the prom, with the chance to continue with the 'go'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)  * prom command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) prom_cmdline(void)
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* Drop into the prom, but completely terminate the program.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  * No chance of continuing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) prom_halt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	(*(romvec->pv_halt))();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	goto again; /* PROM is out to get me -DaveM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) typedef void (*sfunc_t)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* Get the idprom and stuff it into buffer 'idbuf'.  Returns the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)  * format type.  'num_bytes' is the number of bytes that your idbuf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)  * has space for.  Returns 0xff on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) prom_get_idprom(char *idbuf, int num_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	int i, oldsfc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	GET_SFC(oldsfc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	SET_SFC(FC_CONTROL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	for(i=0;i<num_bytes; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		/* There is a problem with the GET_CONTROL_BYTE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		macro; defining the extra variable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		gets around it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 		int c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		GET_CONTROL_BYTE(SUN3_IDPROM_BASE + i, c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		idbuf[i] = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	SET_SFC(oldsfc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	return idbuf[0];
^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) /* Get the major prom version number. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) prom_version(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	return romvec->pv_romvers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* Get the prom plugin-revision. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) prom_getrev(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 	return prom_rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* Get the prom firmware print revision. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) prom_getprev(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 	return prom_prev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }