public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
@ 2006-11-02  8:37 Steve Langasek
  2006-11-02 21:14 ` Andrew Morton
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Langasek @ 2006-11-02  8:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eki, Richard Henderson, Ivan Kokshaysky, linux-kernel,
	thias.lelourd, jharrison

From: Jay Estabrook <jay.estabrook@hp.com>

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 <asm/vga.h>
 #include <asm/machvec.h>
 
+#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 <video/vga.h>
 #include <asm/io.h>
 
+/* wait until after includes to test for this, to allow arch-specific mod. */
+#ifndef vga_request_resource
+# define vga_request_resource request_resource
+#endif
+
 static DEFINE_SPINLOCK(vga_lock);
 static int cursor_size_lastfrom;
 static int cursor_size_lastto;
@@ -393,7 +398,7 @@
 			vga_video_type = VIDEO_TYPE_EGAM;
 			vga_vram_size = 0x8000;
 			display_desc = "EGA+";
-			request_resource(&ioport_resource,
+			vga_request_resource(&ioport_resource,
 					 &ega_console_resource);
 		} else {
 			static struct resource mda1_console_resource =
@@ -403,9 +408,9 @@
 			vga_video_type = VIDEO_TYPE_MDA;
 			vga_vram_size = 0x2000;
 			display_desc = "*MDA";
-			request_resource(&ioport_resource,
+			vga_request_resource(&ioport_resource,
 					 &mda1_console_resource);
-			request_resource(&ioport_resource,
+			vga_request_resource(&ioport_resource,
 					 &mda2_console_resource);
 			vga_video_font_height = 14;
 		}
@@ -425,14 +430,14 @@
 				    = { .name = "ega", .start = 0x3C0, .end = 0x3DF };
 				vga_video_type = VIDEO_TYPE_EGAC;
 				display_desc = "EGA";
-				request_resource(&ioport_resource,
+				vga_request_resource(&ioport_resource,
 						 &ega_console_resource);
 			} else {
 				static struct resource vga_console_resource
 				    = { .name = "vga+", .start = 0x3C0, .end = 0x3DF };
 				vga_video_type = VIDEO_TYPE_VGAC;
 				display_desc = "VGA+";
-				request_resource(&ioport_resource,
+				vga_request_resource(&ioport_resource,
 						 &vga_console_resource);
 
 #ifdef VGA_CAN_DO_64KB
@@ -477,7 +482,7 @@
 			vga_video_type = VIDEO_TYPE_CGA;
 			vga_vram_size = 0x2000;
 			display_desc = "*CGA";
-			request_resource(&ioport_resource,
+			vga_request_resource(&ioport_resource,
 					 &cga_console_resource);
 			vga_video_font_height = 8;
 		}
diff -uNr source/include/asm-alpha/core_titan.h source-es45/include/asm-alpha/core_titan.h
--- source/include/asm-alpha/core_titan.h	2006-09-19 20:42:06.000000000 -0700
+++ source-es45/include/asm-alpha/core_titan.h	2006-09-30 03:14:44.000000000 -0700
@@ -3,6 +3,7 @@
 
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <asm/pci.h>
 #include <asm/compiler.h>
 
 /*
@@ -383,6 +384,7 @@
 
 __EXTERN_INLINE void __iomem *titan_ioportmap(unsigned long addr)
 {
+	FIXUP_IOADDR_VGA(addr);
 	return (void __iomem *)(addr + TITAN_IO_BIAS);
 }
 
diff -uNr source/include/asm-alpha/core_tsunami.h source-es45/include/asm-alpha/core_tsunami.h
--- source/include/asm-alpha/core_tsunami.h	2006-09-19 20:42:06.000000000 -0700
+++ source-es45/include/asm-alpha/core_tsunami.h	2006-09-30 03:14:44.000000000 -0700
@@ -2,6 +2,8 @@
 #define __ALPHA_TSUNAMI__H__
 
 #include <linux/types.h>
+#include <linux/pci.h>
+#include <asm/pci.h>
 #include <asm/compiler.h>
 
 /*
@@ -305,12 +307,14 @@
 
 __EXTERN_INLINE void __iomem *tsunami_ioportmap(unsigned long addr)
 {
+	FIXUP_IOADDR_VGA(addr);
 	return (void __iomem *)(addr + TSUNAMI_IO_BIAS);
 }
 
 __EXTERN_INLINE void __iomem *tsunami_ioremap(unsigned long addr, 
 					      unsigned long size)
 {
+	FIXUP_MEMADDR_VGA(addr);
 	return (void __iomem *)(addr + TSUNAMI_MEM_BIAS);
 }
 
diff -uNr source/include/asm-alpha/io.h source-es45/include/asm-alpha/io.h
--- source/include/asm-alpha/io.h	2006-09-19 20:42:06.000000000 -0700
+++ source-es45/include/asm-alpha/io.h	2006-09-30 03:14:44.000000000 -0700
@@ -126,6 +126,30 @@
 	return (long)address <= 0 ? NULL : virt;
 }
 
+#ifdef CONFIG_VGA_HOSE
+extern struct pci_controller *pci_vga_hose;
+
+# define __is_port_vga(a)       \
+	(((a) >= 0x3b0) && ((a) < 0x3e0) && \
+	 ((a) != 0x3b3) && ((a) != 0x3d3))
+
+# define __is_mem_vga(a) \
+	(((a) >= 0xa0000) && ((a) <= 0xc0000))
+
+# define FIXUP_IOADDR_VGA(a) do {                       \
+	if (pci_vga_hose && __is_port_vga(a))     \
+		a += pci_vga_hose->io_space->start;     \
+ } while(0)
+
+# define FIXUP_MEMADDR_VGA(a) do {                       \
+	if (pci_vga_hose && __is_mem_vga(a))     \
+		a += pci_vga_hose->io_space->start;     \
+ } while(0)
+
+#else /* CONFIG_VGA_HOSE */
+# define FIXUP_IOADDR_VGA(a)
+#endif /* CONFIG_VGA_HOSE */
+
 /*
  * There are different chipsets to interface the Alpha CPUs to the world.
  */
diff -uNr source/include/asm-alpha/vga.h source-es45/include/asm-alpha/vga.h
--- source/include/asm-alpha/vga.h	2006-09-19 20:42:06.000000000 -0700
+++ source-es45/include/asm-alpha/vga.h	2006-09-30 03:14:44.000000000 -0700
@@ -48,4 +48,26 @@
 
 #define VGA_MAP_MEM(x,s)	((unsigned long) ioremap(x, s))
 
+#ifdef CONFIG_VGA_HOSE
+#include <linux/ioport.h>
+#include <linux/pci.h>
+
+extern struct pci_controller *pci_vga_hose;
+ 
+#define vga_request_resource alpha_vga_request_resource
+
+static int __inline__
+alpha_vga_request_resource(struct resource *root, struct resource *new)
+{
+	/* First, fixup the VGA resource bounds WRT the hose it is on. */
+	if (pci_vga_hose) {
+		new->start += pci_vga_hose->io_space->start;
+		new->end += pci_vga_hose->io_space->start;
+	}
+
+	/* Finally, do a normal request_resource(). */
+	return request_resource(root, new);
+}
+#endif /* CONFIG_VGA_HOSE */
+
 #endif

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
vorlon@debian.org                                   http://www.debian.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
  2006-11-02  8:37 [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25) Steve Langasek
@ 2006-11-02 21:14 ` Andrew Morton
  2006-11-02 22:28   ` Ivan Kokshaysky
  2006-11-04  6:35   ` Steve Langasek
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2006-11-02 21:14 UTC (permalink / raw)
  To: Steve Langasek
  Cc: Eki, Richard Henderson, Ivan Kokshaysky, linux-kernel,
	thias.lelourd, jharrison

On Thu, 2 Nov 2006 00:37:20 -0800
Steve Langasek <vorlon@debian.org> wrote:

> From: Jay Estabrook <jay.estabrook@hp.com>
> 
> 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.
> 

It would be appropriate for both yourself and Jay to provide signoffs for
this work, as per section 11 of Documentation/SubmittingPatches, please.

What is a "hose"?


Some trivia:


> +	if (!hose || (conswitchp == &vga_con && pci_vga_hose == hose)) return;

This is missing a newline.

> +static int titan_pchip1_present = 0;

Unneeded (and undesirable) initialisation.

> +++ 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

The ifdef isn't really needed - we usually leave it out.

> 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
>  }

We normally do:

#ifdef CONFIG_VGA_HOSE
extern void locate_and_init_vga(void *(*handler)(void *, void *));
#else
static inline void locate_and_init_vga(void *(*handler)(void *, void *))
{
}
#endif

so that all those ifdefs go away and so that the new code gets
compile-checked regardless of config settings.

>  
> +/* wait until after includes to test for this, to allow arch-specific mod. */
> +#ifndef vga_request_resource
> +# define vga_request_resource request_resource
> +#endif
> +

erk.

> +#define vga_request_resource alpha_vga_request_resource
> +
> +static int __inline__
> +alpha_vga_request_resource(struct resource *root, struct resource *new)
> +{
> +	/* First, fixup the VGA resource bounds WRT the hose it is on. */
> +	if (pci_vga_hose) {
> +		new->start += pci_vga_hose->io_space->start;
> +		new->end += pci_vga_hose->io_space->start;
> +	}
> +
> +	/* Finally, do a normal request_resource(). */
> +	return request_resource(root, new);
> +}
> 

So if the resource is being requested by vga we adjust the caller's
resource before actually requesting it.

Isn't this a bit hacky?  How come vgacon ended up requesting the wrong
addresses in the first place?

(And please don't use __inline__ or __inline - plain old `inline' works fine)

>  static DEFINE_SPINLOCK(vga_lock);
>  static int cursor_size_lastfrom;
>  static int cursor_size_lastto;
> @@ -393,7 +398,7 @@
>  			vga_video_type = VIDEO_TYPE_EGAM;
>  			vga_vram_size = 0x8000;
>  			display_desc = "EGA+";
> -			request_resource(&ioport_resource,
> +			vga_request_resource(&ioport_resource,
>  					 &ega_console_resource);
>
> ..
>
> diff -uNr source/include/asm-alpha/core_titan.h source-es45/include/asm-alpha/core_titan.h
> --- source/include/asm-alpha/core_titan.h	2006-09-19 20:42:06.000000000 -0700
> +++ source-es45/include/asm-alpha/core_titan.h	2006-09-30 03:14:44.000000000 -0700
> @@ -3,6 +3,7 @@
>  
>  #include <linux/types.h>
>  #include <linux/pci.h>
> +#include <asm/pci.h>
>  #include <asm/compiler.h>
>  
> ...
>
> diff -uNr source/include/asm-alpha/core_tsunami.h source-es45/include/asm-alpha/core_tsunami.h
> --- source/include/asm-alpha/core_tsunami.h	2006-09-19 20:42:06.000000000 -0700
> +++ source-es45/include/asm-alpha/core_tsunami.h	2006-09-30 03:14:44.000000000 -0700
> @@ -2,6 +2,8 @@
>  #define __ALPHA_TSUNAMI__H__
>  
>  #include <linux/types.h>
> +#include <linux/pci.h>
> +#include <asm/pci.h>
>  #include <asm/compiler.h>

So we actually need to include asm/pci.h in these files?  linux/pci.h
already did that?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
  2006-11-02 21:14 ` Andrew Morton
@ 2006-11-02 22:28   ` Ivan Kokshaysky
  2006-11-04  6:35   ` Steve Langasek
  1 sibling, 0 replies; 8+ messages in thread
From: Ivan Kokshaysky @ 2006-11-02 22:28 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Steve Langasek, Eki, Richard Henderson, linux-kernel,
	thias.lelourd, jharrison

On Thu, Nov 02, 2006 at 01:14:43PM -0800, Andrew Morton wrote:
> What is a "hose"?

A real name of "pci domain". ;-)

> > +	/* First, fixup the VGA resource bounds WRT the hose it is on. */
> > +	if (pci_vga_hose) {
> > +		new->start += pci_vga_hose->io_space->start;
> > +		new->end += pci_vga_hose->io_space->start;
> > +	}
> > +
> > +	/* Finally, do a normal request_resource(). */
> > +	return request_resource(root, new);

This will always fail. Should be

	return request_resource(pci_vga_hose->io_space, new);

> > +}
> > 
> 
> So if the resource is being requested by vga we adjust the caller's
> resource before actually requesting it.
> 
> Isn't this a bit hacky?  How come vgacon ended up requesting the wrong
> addresses in the first place?

vgacon requests the correct _bus_ address, but it doesn't work with
multiple buses. So a fixup similar to pcibios_fixup_resource() or
pcibios_bus_to_resource() is needed.

Ivan.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
  2006-11-02 21:14 ` Andrew Morton
  2006-11-02 22:28   ` Ivan Kokshaysky
@ 2006-11-04  6:35   ` Steve Langasek
  2006-11-09  2:04     ` Jason Harrison
  1 sibling, 1 reply; 8+ messages in thread
From: Steve Langasek @ 2006-11-04  6:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eki, Richard Henderson, Ivan Kokshaysky, linux-kernel,
	thias.lelourd, jharrison

Hi Andrew,

Thanks for the feedback.  I'll incorporate your comments and Ivan's into an
updated patch and re-test.  What's the procedure afterwards -- should I
re-submit as a follow-up to this thread or start a new thread?

On Thu, Nov 02, 2006 at 01:14:43PM -0800, Andrew Morton wrote:

> > From: Jay Estabrook <jay.estabrook@hp.com>

> > 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.

> It would be appropriate for both yourself and Jay to provide signoffs for
> this work, as per section 11 of Documentation/SubmittingPatches, please.

Ok, will ask Jay for this.

> What is a "hose"?

Ivan's comment, that this is effectively a PCI domain, is consistent with my
(limited) understanding.

> > +/* wait until after includes to test for this, to allow arch-specific mod. */
> > +#ifndef vga_request_resource
> > +# define vga_request_resource request_resource
> > +#endif
> > +

> erk.

Yeah. :/  Suggestions welcome.

> So we actually need to include asm/pci.h in these files?

Uhm, appears not.  Thanks for noticing.

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
vorlon@debian.org                                   http://www.debian.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
  2006-11-04  6:35   ` Steve Langasek
@ 2006-11-09  2:04     ` Jason Harrison
  2006-11-09  5:55       ` Steve Langasek
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Harrison @ 2006-11-09  2:04 UTC (permalink / raw)
  To: Steve Langasek
  Cc: Eki, Richard Henderson, Ivan Kokshaysky, linux-kernel,
	thias.lelourd

Greetings,

Just wanted to let you know I tested this patch 
http://people.debian.org/~vorlon/alpha-titan-video.patch on 2.6.18.2 sources 
and got the following errors during the compile.  The same 2.6.18.2 sources 
compile ok so I think this has something to do with the alpha-titan-video 
patch.  I hope this information is useful.  I do not know too much about 
debugging yet or I would have tried to provide more.

In file included from include/asm/io.h:250,
                 from include/linux/dmapool.h:14,
                 from include/linux/pci.h:564,
                 from arch/alpha/kernel/alpha_ksyms.c:16:
include/asm/core_titan.h: In function 'titan_ioportmap':
include/asm/core_titan.h:386: error: dereferencing pointer to incomplete type
make[1]: *** [arch/alpha/kernel/alpha_ksyms.o] Error 1
make: *** [arch/alpha/kernel] Error 2

Regards,
Jason Harrison

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
  2006-11-09  2:04     ` Jason Harrison
@ 2006-11-09  5:55       ` Steve Langasek
  2006-11-11 22:24         ` Jason Harrison
  2006-11-11 22:40         ` Jason Harrison
  0 siblings, 2 replies; 8+ messages in thread
From: Steve Langasek @ 2006-11-09  5:55 UTC (permalink / raw)
  To: Jason Harrison
  Cc: Eki, Richard Henderson, Ivan Kokshaysky, linux-kernel,
	thias.lelourd

Hi Jason,

On Wed, Nov 08, 2006 at 09:04:37PM -0500, Jason Harrison wrote:

> Just wanted to let you know I tested this patch 
> http://people.debian.org/~vorlon/alpha-titan-video.patch on 2.6.18.2 sources 
> and got the following errors during the compile.  The same 2.6.18.2 sources 
> compile ok so I think this has something to do with the alpha-titan-video 
> patch.  I hope this information is useful.  I do not know too much about 
> debugging yet or I would have tried to provide more.

> In file included from include/asm/io.h:250,
>                  from include/linux/dmapool.h:14,
>                  from include/linux/pci.h:564,
>                  from arch/alpha/kernel/alpha_ksyms.c:16:
> include/asm/core_titan.h: In function 'titan_ioportmap':
> include/asm/core_titan.h:386: error: dereferencing pointer to incomplete type
> make[1]: *** [arch/alpha/kernel/alpha_ksyms.o] Error 1
> make: *** [arch/alpha/kernel] Error 2

Ok; evidently, the reference to asm/pci.h really *was* required, because
otherwise the definition of FIXUP_IOADDR_VGA() is used well before struct
pci_controller is defined when building with CONFIG_ALPHA_TITAN.  I've
re-added this to the test patch, please feel free to re-download and test.

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
vorlon@debian.org                                   http://www.debian.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
  2006-11-09  5:55       ` Steve Langasek
@ 2006-11-11 22:24         ` Jason Harrison
  2006-11-11 22:40         ` Jason Harrison
  1 sibling, 0 replies; 8+ messages in thread
From: Jason Harrison @ 2006-11-11 22:24 UTC (permalink / raw)
  To: Steve Langasek
  Cc: Eki, Richard Henderson, Ivan Kokshaysky, linux-kernel,
	thias.lelourd

Greetings,

I re-downloaded the patch and attempted to build patched 2.6.18.2 kernel 
sources.  The compile failed with some errors however.  The errors are below.

cc1: warnings being treated as errors
In file included from include/asm/core_titan.h:6,
                 from include/asm/io.h:250,
                 from include/linux/dmapool.h:14,
                 from include/linux/pci.h:564,
                 from arch/alpha/kernel/alpha_ksyms.c:16:
include/asm/pci.h:229: warning: 'enum pci_dma_burst_strategy' declared inside 
parameter list
include/asm/pci.h:229: warning: its scope is only this definition or 
declaration, which is probably not what you want
include/asm/pci.h: In function 'pci_dma_burst_advice':
include/asm/pci.h:240: error: dereferencing pointer to incomplete type
include/asm/pci.h:240: error: 'PCI_DMA_BURST_BOUNDARY' undeclared (first use 
in this function)
include/asm/pci.h:240: error: (Each undeclared identifier is reported only 
once
include/asm/pci.h:240: error: for each function it appears in.)
make[1]: *** [arch/alpha/kernel/alpha_ksyms.o] Error 1
make: *** [arch/alpha/kernel] Error 2

Hope this helps.

Regards,
Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25)
  2006-11-09  5:55       ` Steve Langasek
  2006-11-11 22:24         ` Jason Harrison
@ 2006-11-11 22:40         ` Jason Harrison
  1 sibling, 0 replies; 8+ messages in thread
From: Jason Harrison @ 2006-11-11 22:40 UTC (permalink / raw)
  To: Steve Langasek
  Cc: Eki, Richard Henderson, Ivan Kokshaysky, linux-kernel,
	thias.lelourd

Greetings,

I patched the kernel with the extra systype patch located at this link.

http://www.vipu.org/~eki/alpha-titan-systype.patch

Now the kernel seems to compile fine.  By the way I am compiling a kernel 
specifically for titan type systems.  Not a generic alpha kernel.  I know eki 
had given me links to 2 patches before.  For some reason I thought they were 
both incorporated into the alpha-titan-video.patch you were working on.  I 
hope this information helps.  Not sure why the second patch is needed.  Good 
to know though.

Regards,
Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-11-11 22:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-02  8:37 [patch] video: support for VGA hoses on alpha TITAN, TSUNAMI systems (ES45, DS25) Steve Langasek
2006-11-02 21:14 ` Andrew Morton
2006-11-02 22:28   ` Ivan Kokshaysky
2006-11-04  6:35   ` Steve Langasek
2006-11-09  2:04     ` Jason Harrison
2006-11-09  5:55       ` Steve Langasek
2006-11-11 22:24         ` Jason Harrison
2006-11-11 22:40         ` Jason Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox