console.c 2.1 KB

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