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