Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbWKBIhZ (ORCPT ); Thu, 2 Nov 2006 03:37:25 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752648AbWKBIhZ (ORCPT ); Thu, 2 Nov 2006 03:37:25 -0500 Received: from dsl093-039-086.pdx1.dsl.speakeasy.net ([66.93.39.86]:65478 "EHLO mauritius.dodds.net") by vger.kernel.org with ESMTP id S1752331AbWKBIhX (ORCPT ); Thu, 2 Nov 2006 03:37:23 -0500 Date: Thu, 2 Nov 2006 00:37:20 -0800 From: Steve Langasek To: Andrew Morton Cc: Eki , Richard Henderson , Ivan Kokshaysky , linux-kernel@vger.kernel.org, thias.lelourd@gmail.com, jharrison@linuxbs.org Subject: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25) Message-ID: <20061102083718.GC12267@mauritius.dodds.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 22802 Lines: 730 From: Jay Estabrook Add working support for VGA hoses on Alpha, which is required in order to use a VGA console on TITAN- and TSUNAMI-class Alpha systems. This also generalizes support for non-standard VGA offsets on Alpha to cover the Marvel class of alphas without special-casing. Includes recognizing an additional model of TITAN-class Alpha. Tested successfully on an ES45 and a DS25 with a vanilla 2.6.18 kernel, also tested on an LX164 with the Debian 2.6.18 kernel with no regressions. Included in Alpha Core distribution for some time. diff -uNr source/arch/alpha/Kconfig source-es45/arch/alpha/Kconfig --- source/arch/alpha/Kconfig 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/Kconfig 2006-09-30 03:14:44.000000000 -0700 @@ -469,6 +469,11 @@ depends on ALPHA_GENERIC || ALPHA_PC164 default y +config VGA_HOSE + bool "VGA on arbitrary hose" + depends on ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI + default y + config ALPHA_SRM bool "Use SRM as bootloader" if ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_NAUTILUS || ALPHA_NONAME default y if ALPHA_JENSEN || ALPHA_MIKASA || ALPHA_SABLE || ALPHA_LYNX || ALPHA_NORITAKE || ALPHA_DP264 || ALPHA_RAWHIDE || ALPHA_EIGER || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_MARVEL @@ -626,6 +631,13 @@ source "drivers/Kconfig" +# DUMMY_CONSOLE may be defined in drivers/video/console/Kconfig +# but we also need it if VGA_HOSE is set +config DUMMY_CONSOLE + bool + depends on VGA_HOSE + default y + source "fs/Kconfig" source "arch/alpha/oprofile/Kconfig" diff -uNr source/arch/alpha/kernel/alpha_ksyms.c source-es45/arch/alpha/kernel/alpha_ksyms.c --- source/arch/alpha/kernel/alpha_ksyms.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/alpha_ksyms.c 2006-09-30 03:14:44.000000000 -0700 @@ -206,3 +206,7 @@ EXPORT_SYMBOL(irongate_ioremap); EXPORT_SYMBOL(irongate_iounmap); #endif + +#ifdef CONFIG_VGA_HOSE +EXPORT_SYMBOL(pci_vga_hose); +#endif diff -uNr source/arch/alpha/kernel/console.c source-es45/arch/alpha/kernel/console.c --- source/arch/alpha/kernel/console.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/console.c 2006-09-30 03:14:44.000000000 -0700 @@ -12,13 +12,11 @@ #include #include +#include "pci_impl.h" + #ifdef CONFIG_VGA_HOSE -/* - * Externally-visible vga hose bases - */ -unsigned long __vga_hose_io_base = 0; /* base for default hose */ -unsigned long __vga_hose_mem_base = 0; /* base for default hose */ +struct pci_controller *pci_vga_hose = NULL; static struct pci_controller * __init default_vga_hose_select(struct pci_controller *h1, struct pci_controller *h2) @@ -32,10 +31,7 @@ void __init set_vga_hose(struct pci_controller *hose) { - if (hose) { - __vga_hose_io_base = hose->io_space->start; - __vga_hose_mem_base = hose->mem_space->start; - } + pci_vga_hose = hose; } void __init @@ -44,18 +40,17 @@ struct pci_controller *hose = NULL; struct pci_dev *dev = NULL; + /* Default the select function */ if (!sel_func) sel_func = (void *)default_vga_hose_select; + /* Find the console VGA device */ for(dev=NULL; (dev=pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, dev));) { if (!hose) hose = dev->sysdata; else hose = sel_func(hose, dev->sysdata); } - /* Did we already inititialize the correct one? */ - if (conswitchp == &vga_con && - __vga_hose_io_base == hose->io_space->start && - __vga_hose_mem_base == hose->mem_space->start) - return; + /* Did we already initialize the correct one? Is there one? */ + if (!hose || (conswitchp == &vga_con && pci_vga_hose == hose)) return; /* Set the VGA hose and init the new console */ set_vga_hose(hose); diff -uNr source/arch/alpha/kernel/core_marvel.c source-es45/arch/alpha/kernel/core_marvel.c --- source/arch/alpha/kernel/core_marvel.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/core_marvel.c 2006-09-30 03:14:44.000000000 -0700 @@ -684,9 +684,6 @@ /* * IO map support. */ - -#define __marvel_is_mem_vga(a) (((a) >= 0xa0000) && ((a) <= 0xc0000)) - void __iomem * marvel_ioremap(unsigned long addr, unsigned long size) { @@ -698,13 +695,9 @@ unsigned long pfn; /* - * Adjust the addr. + * Adjust the address. */ -#ifdef CONFIG_VGA_HOSE - if (pci_vga_hose && __marvel_is_mem_vga(addr)) { - addr += pci_vga_hose->mem_space->start; - } -#endif + FIXUP_MEMADDR_VGA(addr); /* * Find the hose. @@ -781,7 +774,7 @@ return (void __iomem *) vaddr; } - return NULL; + return (void __iomem *) NULL; } void @@ -803,8 +796,6 @@ return (addr & 0xFF000000UL) == 0; } -#define __marvel_is_port_vga(a) \ - (((a) >= 0x3b0) && ((a) < 0x3e0) && ((a) != 0x3b3) && ((a) != 0x3d3)) #define __marvel_is_port_kbd(a) (((a) == 0x60) || ((a) == 0x64)) #define __marvel_is_port_rtc(a) (((a) == 0x70) || ((a) == 0x71)) @@ -813,7 +804,7 @@ if (__marvel_is_port_rtc (addr) || __marvel_is_port_kbd(addr)) ; #ifdef CONFIG_VGA_HOSE - else if (__marvel_is_port_vga (addr) && pci_vga_hose) + else if (__is_port_vga (addr) && pci_vga_hose) addr += pci_vga_hose->io_space->start; #endif else diff -uNr source/arch/alpha/kernel/core_titan.c source-es45/arch/alpha/kernel/core_titan.c --- source/arch/alpha/kernel/core_titan.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/core_titan.c 2006-09-30 03:14:44.000000000 -0700 @@ -35,6 +35,17 @@ } saved_config[4] __attribute__((common)); /* + * Is PChip 1 present? No need to query it more than once. + */ +static int titan_pchip1_present = 0; + +/* hoseno to index mapping */ +#define H2I(h) ((((h)&2)>>1)|(((h)&1)<<1)) +/* index to hoseno mapping */ +#define I2H(i) ((((i)&2)>>1)|(((i)&1)<<1)) + + +/* * BIOS32-style PCI interface: */ @@ -196,14 +207,14 @@ titan_pci_tbi(struct pci_controller *hose, dma_addr_t start, dma_addr_t end) { titan_pachip *pachip = - (hose->index & 1) ? TITAN_pachip1 : TITAN_pachip0; + (hose->index & 2) ? TITAN_pachip1 : TITAN_pachip0; titan_pachip_port *port; volatile unsigned long *csr; unsigned long value; /* Get the right hose. */ port = &pachip->g_port; - if (hose->index & 2) + if (hose->index & 1) port = &pachip->a_port; /* We can invalidate up to 8 tlb entries in a go. The flush @@ -238,12 +249,12 @@ } static void __init -titan_init_one_pachip_port(titan_pachip_port *port, int index) +titan_init_one_pachip_port(titan_pachip_port *port, int hoseno) { struct pci_controller *hose; hose = alloc_pci_controller(); - if (index == 0) + if (hoseno == 0) pci_isa_hose = hose; hose->io_space = alloc_resource(); hose->mem_space = alloc_resource(); @@ -258,47 +269,47 @@ hose->sparse_mem_base = 0; hose->sparse_io_base = 0; hose->dense_mem_base - = (TITAN_MEM(index) & 0xffffffffffUL) | 0x80000000000UL; + = (TITAN_MEM(hoseno) & 0xffffffffffUL) | 0x80000000000UL; hose->dense_io_base - = (TITAN_IO(index) & 0xffffffffffUL) | 0x80000000000UL; + = (TITAN_IO(hoseno) & 0xffffffffffUL) | 0x80000000000UL; - hose->config_space_base = TITAN_CONF(index); - hose->index = index; + hose->config_space_base = TITAN_CONF(hoseno); + hose->index = H2I(hoseno); - hose->io_space->start = TITAN_IO(index) - TITAN_IO_BIAS; + hose->io_space->start = TITAN_IO(hoseno) - TITAN_IO_BIAS; hose->io_space->end = hose->io_space->start + TITAN_IO_SPACE - 1; - hose->io_space->name = pci_io_names[index]; + hose->io_space->name = pci_io_names[hoseno]; hose->io_space->flags = IORESOURCE_IO; - hose->mem_space->start = TITAN_MEM(index) - TITAN_MEM_BIAS; + hose->mem_space->start = TITAN_MEM(hoseno) - TITAN_MEM_BIAS; hose->mem_space->end = hose->mem_space->start + 0xffffffff; - hose->mem_space->name = pci_mem_names[index]; + hose->mem_space->name = pci_mem_names[hoseno]; hose->mem_space->flags = IORESOURCE_MEM; if (request_resource(&ioport_resource, hose->io_space) < 0) - printk(KERN_ERR "Failed to request IO on hose %d\n", index); + printk(KERN_ERR "Failed to request IO on hose %d\n", hoseno); if (request_resource(&iomem_resource, hose->mem_space) < 0) - printk(KERN_ERR "Failed to request MEM on hose %d\n", index); + printk(KERN_ERR "Failed to request MEM on hose %d\n", hoseno); /* * Save the existing PCI window translations. SRM will * need them when we go to reboot. */ - saved_config[index].wsba[0] = port->wsba[0].csr; - saved_config[index].wsm[0] = port->wsm[0].csr; - saved_config[index].tba[0] = port->tba[0].csr; - - saved_config[index].wsba[1] = port->wsba[1].csr; - saved_config[index].wsm[1] = port->wsm[1].csr; - saved_config[index].tba[1] = port->tba[1].csr; - - saved_config[index].wsba[2] = port->wsba[2].csr; - saved_config[index].wsm[2] = port->wsm[2].csr; - saved_config[index].tba[2] = port->tba[2].csr; - - saved_config[index].wsba[3] = port->wsba[3].csr; - saved_config[index].wsm[3] = port->wsm[3].csr; - saved_config[index].tba[3] = port->tba[3].csr; + saved_config[hoseno].wsba[0] = port->wsba[0].csr; + saved_config[hoseno].wsm[0] = port->wsm[0].csr; + saved_config[hoseno].tba[0] = port->tba[0].csr; + + saved_config[hoseno].wsba[1] = port->wsba[1].csr; + saved_config[hoseno].wsm[1] = port->wsm[1].csr; + saved_config[hoseno].tba[1] = port->tba[1].csr; + + saved_config[hoseno].wsba[2] = port->wsba[2].csr; + saved_config[hoseno].wsm[2] = port->wsm[2].csr; + saved_config[hoseno].tba[2] = port->tba[2].csr; + + saved_config[hoseno].wsba[3] = port->wsba[3].csr; + saved_config[hoseno].wsm[3] = port->wsm[3].csr; + saved_config[hoseno].tba[3] = port->tba[3].csr; /* * Set up the PCI to main memory translation windows. @@ -344,14 +355,14 @@ static void __init titan_init_pachips(titan_pachip *pachip0, titan_pachip *pachip1) { - int pchip1_present = TITAN_cchip->csc.csr & 1L<<14; + titan_pchip1_present = TITAN_cchip->csc.csr & 1L<<14; /* Init the ports in hose order... */ titan_init_one_pachip_port(&pachip0->g_port, 0); /* hose 0 */ - if (pchip1_present) + if (titan_pchip1_present) titan_init_one_pachip_port(&pachip1->g_port, 1);/* hose 1 */ titan_init_one_pachip_port(&pachip0->a_port, 2); /* hose 2 */ - if (pchip1_present) + if (titan_pchip1_present) titan_init_one_pachip_port(&pachip1->a_port, 3);/* hose 3 */ } @@ -366,16 +377,18 @@ int h = (pu64[30] >> 24) & 0xff; /* console hose # */ /* - * Our hose numbering matches the console's, so just find + * Our hose numbering does NOT match the console's, so find * the right one... */ for (hose = hose_head; hose; hose = hose->next) { - if (hose->index == h) break; + if (I2H(hose->index) == h) break; } if (hose) { - printk("Console graphics on hose %d\n", hose->index); + printk("Console graphics on hose %d\n", h); pci_vga_hose = hose; + } else { + printk("ERROR: Console graphics hose not found\n"); } } #endif /* CONFIG_VGA_HOSE */ @@ -406,6 +419,7 @@ /* With multiple PCI busses, we play with I/O as physical addrs. */ ioport_resource.end = ~0UL; + iomem_resource.end = ~0UL; /* PCI DMA Direct Mapping is 1GB at 2GB. */ __direct_map_base = 0x80000000; @@ -441,9 +455,7 @@ static void titan_kill_pachips(titan_pachip *pachip0, titan_pachip *pachip1) { - int pchip1_present = TITAN_cchip->csc.csr & 1L<<14; - - if (pchip1_present) { + if (titan_pchip1_present) { titan_kill_one_pachip_port(&pachip1->g_port, 1); titan_kill_one_pachip_port(&pachip1->a_port, 3); } @@ -474,12 +486,12 @@ unsigned long *ptes; unsigned long pfn; +#ifdef CONFIG_VGA_HOSE /* - * Adjust the addr. + * Adjust the address and hose, if necessary. */ -#ifdef CONFIG_VGA_HOSE - if (pci_vga_hose && __titan_is_mem_vga(addr)) { - h = pci_vga_hose->index; + if (pci_vga_hose && __is_mem_vga(addr)) { + h = I2H(pci_vga_hose->index); addr += pci_vga_hose->mem_space->start; } #endif @@ -488,7 +500,7 @@ * Find the hose. */ for (hose = hose_head; hose; hose = hose->next) - if (hose->index == h) + if (I2H(hose->index) == h) break; if (!hose) return NULL; @@ -521,8 +533,10 @@ * Map it */ area = get_vm_area(size, VM_IOREMAP); - if (!area) + if (!area) { + printk("ioremap failed... no vm_area...\n"); return NULL; + } ptes = hose->sg_pci->ptes; for (vaddr = (unsigned long)area->addr; @@ -539,7 +553,7 @@ if (__alpha_remap_area_pages(vaddr, pfn << PAGE_SHIFT, PAGE_SIZE, 0)) { - printk("FAILED to map...\n"); + printk("FAILED to remap_area_pages...\n"); vfree(area->addr); return NULL; } @@ -551,7 +565,8 @@ return (void __iomem *) vaddr; } - return NULL; + /* Assume a legacy (read: VGA) address, and return appropriately. */ + return (void __iomem *)(addr + TITAN_MEM_BIAS); } void @@ -750,6 +765,7 @@ if (titan_query_agp(port)) hosenum = 2; if (hosenum < 0 && + titan_pchip1_present && titan_query_agp(port = &TITAN_pachip1->a_port)) hosenum = 3; @@ -757,7 +773,7 @@ * Find the hose the port is on. */ for (hose = hose_head; hose; hose = hose->next) - if (hose->index == hosenum) + if (I2H(hose->index) == hosenum) break; if (!hose || !hose->sg_pci) diff -uNr source/arch/alpha/kernel/core_tsunami.c source-es45/arch/alpha/kernel/core_tsunami.c --- source/arch/alpha/kernel/core_tsunami.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/core_tsunami.c 2006-09-30 03:14:44.000000000 -0700 @@ -349,6 +349,32 @@ tsunami_pci_tbi(hose, 0, -1); } +static void __init +tsunami_init_vga_hose(void) +{ +#ifdef CONFIG_VGA_HOSE + u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset); + + if (pu64[7] == 3) { /* TERM_TYPE == graphics */ + struct pci_controller *hose; + int h = (pu64[30] >> 24) & 0xff; /* console hose # */ + + /* + * Our hose numbering does NOT match the console's, so find + * the right one... + */ + for (hose = hose_head; hose; hose = hose->next) { + if (hose->index == h) break; + } + + if (hose) { + printk("Console graphics on hose %d\n", h); + pci_vga_hose = hose; + } + } +#endif /* CONFIG_VGA_HOSE */ +} + void __init tsunami_init_arch(void) { @@ -393,6 +419,9 @@ tsunami_init_one_pchip(TSUNAMI_pchip0, 0); if (TSUNAMI_cchip->csc.csr & 1L<<14) tsunami_init_one_pchip(TSUNAMI_pchip1, 1); + + /* Check for graphic console location (if any). */ + tsunami_init_vga_hose(); } static void diff -uNr source/arch/alpha/kernel/proto.h source-es45/arch/alpha/kernel/proto.h --- source/arch/alpha/kernel/proto.h 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/proto.h 2006-09-30 03:14:44.000000000 -0700 @@ -106,6 +106,11 @@ extern unsigned long wildfire_node_mem_start(int); extern unsigned long wildfire_node_mem_size(int); +/* console.c */ +#ifdef CONFIG_VGA_HOSE + extern void locate_and_init_vga(void *(*)(void *, void *)); +#endif + /* setup.c */ extern unsigned long srm_hae; extern int boot_cpuid; diff -uNr source/arch/alpha/kernel/setup.c source-es45/arch/alpha/kernel/setup.c --- source/arch/alpha/kernel/setup.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/setup.c 2006-09-30 03:14:44.000000000 -0700 @@ -787,9 +787,9 @@ static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4}; static char titan_names[][16] = { - "DEFAULT", "Privateer", "Falcon", "Granite" + "DEFAULT", "Privateer", "Falcon", "Granite", "HyperBrick2" }; -static int titan_indices[] = {0,1,2,2,3}; +static int titan_indices[] = {0,1,2,2,3,4}; static char tsunami_names[][16] = { "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper", @@ -891,6 +891,7 @@ &privateer_mv, /* privateer */ &titan_mv, /* falcon */ &privateer_mv, /* granite */ + &titan_mv, /* hyperbrick2 */ }; static struct alpha_machine_vector *tsunami_vecs[] __initdata = diff -uNr source/arch/alpha/kernel/sys_dp264.c source-es45/arch/alpha/kernel/sys_dp264.c --- source/arch/alpha/kernel/sys_dp264.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/arch/alpha/kernel/sys_dp264.c 2006-09-30 03:14:44.000000000 -0700 @@ -543,6 +543,9 @@ { common_init_pci(); SMC669_Init(0); +#ifdef CONFIG_VGA_HOSE + locate_and_init_vga(NULL); +#endif } static void __init @@ -551,6 +554,18 @@ common_init_pci(); SMC669_Init(1); es1888_init(); +#ifdef CONFIG_VGA_HOSE + locate_and_init_vga(NULL); +#endif +} + +static void __init +clipper_init_pci(void) +{ + common_init_pci(); +#ifdef CONFIG_VGA_HOSE + locate_and_init_vga(NULL); +#endif } static void __init @@ -655,7 +670,7 @@ .init_arch = tsunami_init_arch, .init_irq = clipper_init_irq, .init_rtc = common_init_rtc, - .init_pci = common_init_pci, + .init_pci = clipper_init_pci, .kill_arch = tsunami_kill_arch, .pci_map_irq = clipper_map_irq, .pci_swizzle = common_swizzle, diff -uNr source/drivers/video/console/vgacon.c source-es45/drivers/video/console/vgacon.c --- source/drivers/video/console/vgacon.c 2006-09-19 20:42:06.000000000 -0700 +++ source-es45/drivers/video/console/vgacon.c 2006-09-30 03:14:44.000000000 -0700 @@ -52,6 +52,11 @@ #include