[parisc-linux-cvs] ioremap()-changes, initial PCI graphic support

Helge Deller deller@gmx.de
Mon, 25 Jun 2001 19:23:18 +0200


--------------Boundary-00=_UMXHM5TS3NUV8WJS5M5W
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Subject: 

- EXTRAVERSION -pa41
- gsc.c: moved initialization call to busdevices_init() after initialization 
of the PCI bus
(else PCI graphic cards won't be detected)
- serial.c, lasi7xx.c:
added calls to ioremap(), so that serial and lasi scsi work with 
USE_HPPA_IOREMAP==1
Patch contributed by Thomas Bogendoerfer <tsbogend@alpha.franken.de>. Thanks!
- sticore.[ch]: initial commit to support PCI STI graphic cards

Note: 
PCI graphic card support is not finished yet and the driver will just report 
the detection of a PCI card.

Note 2:
PCI graphic cards are only detected currently if USE_HPPA_IOREMAP is #defined 
to "1" in include/asm/io.h.


--------------Boundary-00=_UMXHM5TS3NUV8WJS5M5W
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="diff"

Index: Makefile
===================================================================
RCS file: /home/cvs/parisc/linux/Makefile,v
retrieving revision 1.72
diff -u -r1.72 Makefile
--- Makefile	2001/06/25 14:18:47	1.72
+++ Makefile	2001/06/25 17:03:01
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 0
-EXTRAVERSION = -pa40
+EXTRAVERSION = -pa41
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
Index: drivers/gsc/gsc.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/gsc/gsc.c,v
retrieving revision 1.21
diff -u -r1.21 gsc.c
--- gsc.c	2001/06/07 17:44:43	1.21
+++ gsc.c	2001/06/25 17:03:06
@@ -245,10 +245,6 @@
 	}
 
 
-#ifdef CONFIG_GSC_LASI
-	busdevices_init();
-#endif
-
 #if defined(CONFIG_PCI)
 #if defined(CONFIG_GSC_DINO)
 	dino_init();
@@ -262,6 +258,10 @@
 #if defined(CONFIG_IOMMU_SBA)
 	sba_init();
 #endif
+#endif
+
+#ifdef CONFIG_GSC_LASI
+	busdevices_init();
 #endif
 
 #if defined(CONFIG_IOMMU_CCIO)
Index: drivers/gsc/serial.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/gsc/serial.c,v
retrieving revision 1.11
diff -u -r1.11 serial.c
--- serial.c	2001/06/14 09:50:22	1.11
+++ serial.c	2001/06/25 17:03:06
@@ -66,7 +66,7 @@
 	serial->type = PORT_16550A;
 
 	serial->line = serial_line_nr;
-	serial->iomem_base = (void*) (((unsigned long) d->hpa) + 0x800);
+	serial->iomem_base = ioremap(((unsigned long) d->hpa) + 0x800, 0x80);
 
 	serial->irq = irq; 
 	serial->io_type = SERIAL_IO_MEM;	/* define access method */
Index: drivers/scsi/lasi7xx.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/scsi/lasi7xx.c,v
retrieving revision 1.14
diff -u -r1.14 lasi7xx.c
--- lasi7xx.c	2001/03/03 05:07:36	1.14
+++ lasi7xx.c	2001/06/25 17:03:09
@@ -35,12 +35,13 @@
 #include "sim700.h"	/* for OPT_NCR_LE */
 #include "lasi7xx.h"
 
+#define NCR_IO_SIZE 64	/* IO region size */
 
 /* hosts_* are kluges to pass info between the lasi7xx_detected()
 ** and the register_driver() callbacks.
 */
 static Scsi_Host_Template *hosts_tptr;
-static int hosts_used=0;
+static int hosts_used;
 
 static int lasi_scsi_callback_700(struct hp_device *d, struct pa_iodc_driver *dri);
 static int lasi_scsi_callback_710(struct hp_device *d, struct pa_iodc_driver *dri);
@@ -63,7 +64,7 @@
 		DRIVER_CHECK_HWTYPE | DRIVER_CHECK_SVERSION,
 		"Lasi SCSI", "53c710",
 		(void *) lasi_scsi_callback_710}, 
-	{0,0,0,0,0,0, 0, (char *) NULL,(char *) NULL,(void *) NULL}
+	{0, }
 };
 
 
@@ -88,7 +89,7 @@
 lasi_scsi_callback_700(struct hp_device *d, struct pa_iodc_driver *dri)
 {
 	hosts_used = sim700_init_host(hosts_tptr, 700, 
-			(unsigned long)d->hpa + LASI_SCSI_CORE_OFFSET,
+			ioremap((unsigned long)d->hpa + LASI_SCSI_CORE_OFFSET, NCR_IO_SIZE),
 			busdevice_alloc_irq(d), OPT_NCR_LE);
 
 	return (hosts_used == 0);
@@ -98,7 +99,7 @@
 lasi_scsi_callback_710(struct hp_device *d, struct pa_iodc_driver *dri)
 {
 	hosts_used = sim700_init_host(hosts_tptr, 710, 
-			(unsigned long)d->hpa + LASI_SCSI_CORE_OFFSET,
+			ioremap((unsigned long)d->hpa + LASI_SCSI_CORE_OFFSET, NCR_IO_SIZE),
 			busdevice_alloc_irq(d), 0);
 
 	return (hosts_used == 0);
Index: drivers/video/sti/sticore.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticore.c,v
retrieving revision 1.16
diff -u -r1.16 sticore.c
--- sticore.c	2001/06/22 17:14:16	1.16
+++ sticore.c	2001/06/25 17:03:18
@@ -21,6 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/malloc.h>
 #include <linux/init.h>
+#include <linux/pci.h>
 #include <video/font.h>
 
 #include <asm/pgalloc.h>
@@ -221,7 +222,7 @@
 	unsigned long dest_len = count;
 	unsigned long dest_start = (unsigned long) dest;
 
-	/* this still needs to be revisited (see arch/parisc/mm/init.c:246 ! */
+	/* this still needs to be revisited (see arch/parisc/mm/init.c:246) ! */
 	while (count >= 4) {
 		count -= 4;
 		*(u32 *)dest = gsc_readl(base);
@@ -686,12 +687,12 @@
 }
 
 static struct sti_struct * __init
-sti_try_rom_generic(unsigned long address, unsigned long hpa)
+sti_try_rom_generic(unsigned long address, unsigned long hpa, struct pci_dev *pd)
 {
 	struct sti_struct *sti;
 	int ok;
 	u32 sig;
-	
+
 test_rom:
 	/* if we can't read the ROM, bail out early.  Not being able
 	 * to read the hpa is okay, for romless sti */
@@ -788,7 +789,7 @@
 	    if (rom) {
 		DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n",
 		    rom, hpa));
-		sti = sti_try_rom_generic(rom, hpa);
+		sti = sti_try_rom_generic(rom, hpa, NULL);
 		if (sti)
 		    return sti;
 	    } else {
@@ -803,6 +804,89 @@
 }
 
 
+static int __devinit sticon_init_one (struct pci_dev *pd,
+				      const struct pci_device_id *ent)
+{
+	unsigned long fb_base, rom_base;
+	unsigned int fb_len, rom_len;
+	struct sti_struct *sti;
+	int i;
+	
+	pci_enable_device(pd);
+
+	fb_base = pci_resource_start (pd, 0);
+	fb_len = pci_resource_len (pd, 0);
+	rom_base = pci_resource_start (pd, PCI_ROM_RESOURCE);
+	rom_len = pci_resource_len (pd, PCI_ROM_RESOURCE);
+	if (rom_base) {
+		/* rom_base = fb_base + fb_len; */
+		pci_write_config_dword(pd, PCI_ROM_ADDRESS, rom_base | PCI_ROM_ADDRESS_ENABLE);
+		printk("STI PCI ROM enabled at 0x%08lx\n", rom_base);
+	}
+
+	printk("PCI graphic found at %08lx (%u MB) and %08lx (%u kB)\n",
+		fb_base, fb_len/1024/1024, rom_base, rom_len/1024);
+
+	for (i=0; i<DEVICE_COUNT_RESOURCE; i++)
+		printk("PCI region %d: %08lx with %lu kB\n",
+				i,
+				pci_resource_start(pd,i),
+				pci_resource_len(pd,i)/1024);
+
+	printk("Trying PCI STI ROM at %08lx, PCI hpa at %08lx\n",
+		    rom_base, fb_base);
+#if 1
+	/* FIXME: */
+	printk("I'm not trying to set up the PCI graphic card now... It would freeze your machine\n");
+	sti = NULL;
+#else
+	sti = sti_try_rom_generic(rom_base, fb_base, pd);
+#endif
+	if (!sti) {
+		printk(KERN_WARNING 
+			"Unable to handle STI device '%s'\n",
+			pd->name);
+		return -ENODEV;
+	}
+	return 0;
+}
+
+
+static void __devexit sticon_remove_one (struct pci_dev *pd)
+{
+	BUG();
+}
+
+
+#define PCI_DEVICE_ID_VISUALIZE_EG	0x1005
+
+static struct pci_device_id sticon_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_HP, PCI_DEVICE_ID_VISUALIZE_EG, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ 0, } /* terminate list */
+};
+MODULE_DEVICE_TABLE(pci, sticon_pci_tbl);
+
+static struct pci_driver sticon_driver = {
+	name:		"sticon",
+	id_table:	sticon_pci_tbl,
+	probe:		sticon_init_one,
+	remove:		sticon_remove_one,
+};
+
+
+int __init sticon_pci_init(void)
+{
+	return pci_module_init (&sticon_driver);
+}
+
+
+static void __exit sticon_pci_exit(void)
+{
+	pci_unregister_driver (&sticon_driver);
+}
+
+
+
 struct sti_struct * __init
 sti_init_roms(void)
 {
@@ -825,6 +909,9 @@
 	search_sti(flash_rom, (unsigned long) 0xfffffffff6000000);
 	search_sti(flash_rom, (unsigned long) 0xfffffffffa000000);
 
+	/* now search for PCI graphic cards */
+	sticon_pci_init();
+	
 	/* check boot-value from "sti=<index>" */
 	if (sti_initial_index >= num_sti_roms)
 	    sti_initial_index = 0;
Index: drivers/video/sti/sticore.h
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticore.h,v
retrieving revision 1.14
diff -u -r1.14 sticore.h
--- sticore.h	2001/06/20 20:24:36	1.14
+++ sticore.h	2001/06/25 17:03:19
@@ -353,6 +353,9 @@
 
 	struct sti_conf_outptr outptr; /* configuration */
 	struct sti_conf_outptr_ext outptr_ext;
+
+	/* PCI data structures */
+	struct pci_dev *pd;
 };
 
 

--------------Boundary-00=_UMXHM5TS3NUV8WJS5M5W--