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