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