Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IA64-SGI] pcdp: add PCDP pci interface support

Resend 2 with changes per Bjorn Helgaas comments. Changes from original:

+ Change globals to vga_console_iobase/vga_console_membase and make them
unconditional.
+ Address style-related comments.

Patch to extend the PCDP vga setup code to support PCI io/mem translations
for the legacy vga ioport and ram spaces on architectures (e.g. altix) which
need them.

Summary of the changes:

drivers/firmware/pcdp.c
drivers/firmware/pcdp.h
-----------------------
+ add declaration for the spec-defined PCI interface struct (pcdp_if_pci)
as well as support macros.

+ extend setup_vga_console() to know about pcdp_if_pci and add a couple of
globals to hold the io and mem translation offsets if present.

arch/ia64/kernel/setup.c
------------------------
+ tweek early_console_setup() to allow multiple early console setup routines
to be called.

include/asm-ia64/vga.h
----------------------
+ make VGA_MAP_MEM vga_console_membase aware

Signed-off-by: Mark Maule <maule@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by

Mark Maule and committed by
Tony Luck
66b7f8a3 54522b66

+62 -12
+8 -4
arch/ia64/kernel/setup.c
··· 72 72 unsigned long ia64_cycles_per_usec; 73 73 struct ia64_boot_param *ia64_boot_param; 74 74 struct screen_info screen_info; 75 + unsigned long vga_console_iobase; 76 + unsigned long vga_console_membase; 75 77 76 78 unsigned long ia64_max_cacheline_size; 77 79 unsigned long ia64_iobase; /* virtual address for I/O accesses */ ··· 275 273 static inline int __init 276 274 early_console_setup (char *cmdline) 277 275 { 276 + int earlycons = 0; 277 + 278 278 #ifdef CONFIG_SERIAL_SGI_L1_CONSOLE 279 279 { 280 280 extern int sn_serial_console_early_setup(void); 281 281 if (!sn_serial_console_early_setup()) 282 - return 0; 282 + earlycons++; 283 283 } 284 284 #endif 285 285 #ifdef CONFIG_EFI_PCDP 286 286 if (!efi_setup_pcdp_console(cmdline)) 287 - return 0; 287 + earlycons++; 288 288 #endif 289 289 #ifdef CONFIG_SERIAL_8250_CONSOLE 290 290 if (!early_serial_console_init(cmdline)) 291 - return 0; 291 + earlycons++; 292 292 #endif 293 293 294 - return -1; 294 + return (earlycons) ? 0 : -1; 295 295 } 296 296 297 297 static inline void
+21 -3
drivers/firmware/pcdp.c
··· 16 16 #include <linux/console.h> 17 17 #include <linux/efi.h> 18 18 #include <linux/serial.h> 19 + #include <asm/vga.h> 19 20 #include "pcdp.h" 20 21 21 22 static int __init ··· 41 40 } 42 41 43 42 static int __init 44 - setup_vga_console(struct pcdp_vga *vga) 43 + setup_vga_console(struct pcdp_device *dev) 45 44 { 46 45 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) 47 - if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) { 46 + u8 *if_ptr; 47 + 48 + if_ptr = ((u8 *)dev + sizeof(struct pcdp_device)); 49 + if (if_ptr[0] == PCDP_IF_PCI) { 50 + struct pcdp_if_pci if_pci; 51 + 52 + /* struct copy since ifptr might not be correctly aligned */ 53 + 54 + memcpy(&if_pci, if_ptr, sizeof(if_pci)); 55 + 56 + if (if_pci.trans & PCDP_PCI_TRANS_IOPORT) 57 + vga_console_iobase = if_pci.ioport_tra; 58 + 59 + if (if_pci.trans & PCDP_PCI_TRANS_MMIO) 60 + vga_console_membase = if_pci.mmio_tra; 61 + } 62 + 63 + if (efi_mem_type(vga_console_membase + 0xA0000) == EFI_CONVENTIONAL_MEMORY) { 48 64 printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n"); 49 65 return -ENODEV; 50 66 } ··· 113 95 dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) { 114 96 if (dev->flags & PCDP_PRIMARY_CONSOLE) { 115 97 if (dev->type == PCDP_CONSOLE_VGA) { 116 - return setup_vga_console((struct pcdp_vga *) dev); 98 + return setup_vga_console(dev); 117 99 } 118 100 } 119 101 }
+29 -4
drivers/firmware/pcdp.h
··· 52 52 u32 clock_rate; 53 53 u8 pci_prog_intfc; 54 54 u8 flags; 55 - }; 55 + } __attribute__((packed)); 56 + 57 + #define PCDP_IF_PCI 1 58 + 59 + /* pcdp_if_pci.trans */ 60 + #define PCDP_PCI_TRANS_IOPORT 0x02 61 + #define PCDP_PCI_TRANS_MMIO 0x01 62 + 63 + struct pcdp_if_pci { 64 + u8 interconnect; 65 + u8 reserved; 66 + u16 length; 67 + u8 segment; 68 + u8 bus; 69 + u8 dev; 70 + u8 fun; 71 + u16 dev_id; 72 + u16 vendor_id; 73 + u32 acpi_interrupt; 74 + u64 mmio_tra; 75 + u64 ioport_tra; 76 + u8 flags; 77 + u8 trans; 78 + } __attribute__((packed)); 56 79 57 80 struct pcdp_vga { 58 81 u8 count; /* address space descriptors */ 59 - }; 82 + } __attribute__((packed)); 60 83 61 84 /* pcdp_device.flags */ 62 85 #define PCDP_PRIMARY_CONSOLE 1 ··· 89 66 u8 flags; 90 67 u16 length; 91 68 u16 efi_index; 92 - }; 69 + /* next data is pcdp_if_pci or pcdp_if_acpi (not yet supported) */ 70 + /* next data is device specific type (currently only pcdp_vga) */ 71 + } __attribute__((packed)); 93 72 94 73 struct pcdp { 95 74 u8 signature[4]; ··· 106 81 u32 num_uarts; 107 82 struct pcdp_uart uart[0]; /* actual size is num_uarts */ 108 83 /* remainder of table is pcdp_device structures */ 109 - }; 84 + } __attribute__((packed));
+4 -1
include/asm-ia64/vga.h
··· 14 14 * videoram directly without any black magic. 15 15 */ 16 16 17 - #define VGA_MAP_MEM(x) ((unsigned long) ioremap((x), 0)) 17 + extern unsigned long vga_console_iobase; 18 + extern unsigned long vga_console_membase; 19 + 20 + #define VGA_MAP_MEM(x) ((unsigned long) ioremap(vga_console_membase + (x), 0)) 18 21 19 22 #define vga_readb(x) (*(x)) 20 23 #define vga_writeb(x,y) (*(y) = (x))