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)  *	linux/arch/alpha/kernel/console.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Architecture-specific specific support for VGA device on 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * non-0 I/O hose
^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/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/tty.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/console.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/vt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/vga.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/machvec.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "pci_impl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifdef CONFIG_VGA_HOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct pci_controller *pci_vga_hose;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static struct resource alpha_vga = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	.name	= "alpha-vga+",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	.flags	= IORESOURCE_IO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	.start	= 0x3C0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	.end	= 0x3DF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static struct pci_controller * __init 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) default_vga_hose_select(struct pci_controller *h1, struct pci_controller *h2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	if (h2->index < h1->index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		return h2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	return h1;
^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) void __init 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) locate_and_init_vga(void *(*sel_func)(void *, void *))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	struct pci_controller *hose = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	struct pci_dev *dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	/* Default the select function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	if (!sel_func) sel_func = (void *)default_vga_hose_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	/* Find the console VGA device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	for(dev=NULL; (dev=pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, dev));) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		if (!hose)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 			hose = dev->sysdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			hose = sel_func(hose, dev->sysdata);
^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) 	/* Did we already initialize the correct one? Is there one? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	if (!hose || (conswitchp == &vga_con && pci_vga_hose == hose))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	/* Create a new VGA ioport resource WRT the hose it is on. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	alpha_vga.start += hose->io_space->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	alpha_vga.end += hose->io_space->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	request_resource(hose->io_space, &alpha_vga);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	/* Set the VGA hose and init the new console. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	pci_vga_hose = hose;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	console_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	do_take_over_console(&vga_con, 0, MAX_NR_CONSOLES-1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	console_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) find_console_vga_hose(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	if (pu64[7] == 3) {	/* TERM_TYPE == graphics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 		struct pci_controller *hose;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 		int h = (pu64[30] >> 24) & 0xff;	/* console hose # */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 		 * Our hose numbering DOES match the console's, so find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 		 * the right one...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 		for (hose = hose_head; hose; hose = hose->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 			if (hose->index == h) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 		if (hose) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 			printk("Console graphics on hose %d\n", h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 			pci_vga_hose = hose;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #endif