Linux PARISC architecture development
 help / color / mirror / Atom feed
* [parisc-linux] ns87415 (superio) support for 2.6.x
@ 2004-03-10 22:48 Randolph Chung
  2004-03-11 12:59 ` Joel Soete
  0 siblings, 1 reply; 3+ messages in thread
From: Randolph Chung @ 2004-03-10 22:48 UTC (permalink / raw)
  To: parisc-linux

This patch fixes ns87415 to work on suckyio-based boxes. the devic
e reports that dma is enabled, but from the performance we get it 
looks like something is still not quite right (we only see ~3MB/s)

Patch is against 2.6.4-rc3-pa5....  tested on c3000 and c3750. 
(Thanks Max.)

Any comments on the hooks that are needed in the generic ns87415 
driver to make this work?

Also, should we enable native mode for all ide devices discovered 
and not just ns87415?

randolph
-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/

Index: arch/parisc/kernel/pci.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/parisc/kernel/pci.c,v
retrieving revision 1.13
diff -u -p -r1.13 pci.c
--- a/arch/parisc/kernel/pci.c	4 Feb 2004 16:31:15 -0000	1.13
+++ b/arch/parisc/kernel/pci.c	10 Mar 2004 22:42:05 -0000
@@ -21,6 +21,7 @@
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/cache.h>		/* for L1_CACHE_BYTES */
+#include <asm/superio.h>
 
 #define DEBUG_RESOURCES 0
 #define DEBUG_CONFIG 0
@@ -145,9 +146,13 @@ char *pcibios_setup(char *str)
 	return str;
 }
 
-
 /* Used in drivers/pci/quirks.c */
-struct pci_fixup pcibios_fixups[] = { {0} };
+struct pci_fixup pcibios_fixups[] = { 
+#ifdef CONFIG_SUPERIO
+	{ PCI_FIXUP_HEADER,	PCI_VENDOR_ID_NS,	PCI_DEVICE_ID_NS_87415,	superio_fixup_pci },
+#endif
+	{ 0 }
+};
 
 
 /*
Index: drivers/ide/pci/ns87415.c
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/ide/pci/ns87415.c,v
retrieving revision 1.13
diff -u -p -r1.13 ns87415.c
--- a/drivers/ide/pci/ns87415.c	28 Feb 2004 01:50:36 -0000	1.13
+++ b/drivers/ide/pci/ns87415.c	10 Mar 2004 22:42:07 -0000
@@ -24,6 +24,9 @@
 #include <linux/init.h>
 
 #include <asm/io.h>
+#ifdef CONFIG_SUPERIO
+#include <asm/superio.h>
+#endif
 
 #include "ns87415.h"
 
@@ -130,6 +133,13 @@ static int ns87415_ide_dma_check (ide_dr
 	if (drive->media != ide_disk)
 		return HWIF(drive)->ide_dma_off_quietly(drive);
 	return __ide_dma_check(drive);
+}
+
+static void __init init_iops_ns87415(ide_hwif_t *hwif)
+{
+#ifdef CONFIG_SUPERIO
+	superio_ide_init_iops(hwif);
+#endif
 }
 
 static void __init init_hwif_ns87415 (ide_hwif_t *hwif)
Index: drivers/ide/pci/ns87415.h
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/ide/pci/ns87415.h,v
retrieving revision 1.2
diff -u -p -r1.2 ns87415.h
--- a/drivers/ide/pci/ns87415.h	8 Oct 2003 20:52:23 -0000	1.2
+++ b/drivers/ide/pci/ns87415.h	10 Mar 2004 22:42:07 -0000
@@ -5,6 +5,7 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
+static void init_iops_ns87415(ide_hwif_t *);
 static void init_hwif_ns87415(ide_hwif_t *);
 
 static ide_pci_device_t ns87415_chipsets[] __devinitdata = {
@@ -13,7 +14,7 @@ static ide_pci_device_t ns87415_chipsets
 		.device		= PCI_DEVICE_ID_NS_87415,
 		.name		= "NS87415",
 		.init_chipset	= NULL,
-		.init_iops	= NULL,
+		.init_iops	= init_iops_ns87415,
 		.init_hwif	= init_hwif_ns87415,
 		.channels	= 2,
 		.autodma	= AUTODMA,
Index: drivers/parisc/superio.c
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/parisc/superio.c,v
retrieving revision 1.5
diff -u -p -r1.5 superio.c
--- a/drivers/parisc/superio.c	21 Dec 2003 13:13:11 -0000	1.5
+++ b/drivers/parisc/superio.c	10 Mar 2004 22:42:07 -0000
@@ -69,11 +69,15 @@
 #include <linux/termios.h>
 #include <linux/tty.h>
 #include <linux/serial_core.h>
+#include <linux/delay.h>
+#include <linux/ide.h>
 #include <asm/io.h>
 #include <asm/hardware.h>
 #include <asm/irq.h>
 #include <asm/superio.h>
 
+#define SUPERIO_IDE_MAX_RETRIES 25
+
 static struct superio_device sio_dev;
 
 
@@ -161,7 +165,6 @@ superio_init(struct superio_device *sio)
 	printk (KERN_INFO "SuperIO: Found NS87560 Legacy I/O device at %s (IRQ %i) \n",
 		pci_name(pdev),pdev->irq);
 
-	/* Find our I/O devices */
 	pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
 	sio->sp1_base &= ~1;
 	printk (KERN_INFO "SuperIO: Serial port 1 at 0x%x\n", sio->sp1_base);
@@ -472,6 +475,78 @@ superio_get_ide_irq(void)
 }
 
 EXPORT_SYMBOL(superio_get_ide_irq);
+
+static u8 superio_ide_inb (unsigned long port);
+static unsigned long superio_ide_status[2];
+static unsigned long superio_ide_select[2];
+static unsigned long superio_ide_dma_status[2];
+
+void superio_fixup_pci(struct pci_dev *pdev)
+{
+	u8 prog;
+	u16 cmd;
+
+	pci_read_config_word(pdev, PCI_COMMAND, &cmd);
+	cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MASTER);
+	pci_write_config_word(pdev, PCI_COMMAND, cmd);
+
+	pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog);
+	pci_write_config_byte(pdev, PCI_CLASS_PROG, prog | 0x5);
+	pdev->class |= 0x5;
+
+	pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog);
+
+	printk("PCI: Enabled native mode for NS87415 (pif=0x%x)\n", prog);
+}
+
+/* Because of a defect in Super I/O, all reads of the PCI DMA status 
+ * registers, IDE status register and the IDE select register need to be 
+ * retried
+ */
+static u8 superio_ide_inb (unsigned long port)
+{
+	if (port == superio_ide_status[0] ||
+	    port == superio_ide_status[1] ||
+	    port == superio_ide_select[0] ||
+	    port == superio_ide_select[1] ||
+	    port == superio_ide_dma_status[0] ||
+	    port == superio_ide_dma_status[1]) {
+		u8 tmp;
+		int retries = SUPERIO_IDE_MAX_RETRIES;
+
+		/* printk(" [ reading port 0x%x with retry ] ", port); */
+
+		do {
+			tmp = inb(port);
+		} while (tmp == 0 && retries-- > 0);
+
+		return tmp;
+	}
+
+	return inb(port);
+}
+
+void __init superio_ide_init_iops (struct hwif_s *hwif)
+{
+	u32 base, dmabase;
+	u8 tmp;
+	struct pci_dev *pdev = hwif->pci_dev;
+	u8 port = hwif->channel;
+
+	base = pci_resource_start(pdev, port * 2) & ~3;
+	dmabase = pci_resource_start(pdev, 4) & ~3;
+
+	superio_ide_status[port] = base + IDE_STATUS_OFFSET;
+	superio_ide_select[port] = base + IDE_SELECT_OFFSET;
+	superio_ide_dma_status[port] = dmabase + (!port ? 2 : 0xa);
+	
+	/* Clear error/interrupt, enable dma */
+	tmp = superio_ide_inb(superio_ide_dma_status[port]);
+	outb(tmp | 0x66, superio_ide_dma_status[port]);
+
+	/* We need to override inb to workaround a SuperIO errata */
+	hwif->INB = superio_ide_inb;
+}
 
 static int __devinit superio_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
Index: include/asm-parisc/superio.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-parisc/superio.h,v
retrieving revision 1.2
diff -u -p -r1.2 superio.h
--- a/include/asm-parisc/superio.h	21 Dec 2003 13:13:10 -0000	1.2
+++ b/include/asm-parisc/superio.h	10 Mar 2004 22:42:11 -0000
@@ -81,9 +81,13 @@ struct superio_device {
 	|| ((x)->device == PCI_DEVICE_ID_NS_87560_LIO) \
 	|| ((x)->device == PCI_DEVICE_ID_NS_87560_USB) ) )
 
+struct hwif_s;
+
 extern void superio_inform_irq(int irq);
 extern void superio_serial_init(void);		/* called by rs_init() */
 extern int superio_fixup_irq(struct pci_dev *pcidev); /* called by iosapic */
 extern int superio_get_ide_irq(void);
+extern void superio_fixup_pci(struct pci_dev *pdev);
+extern void superio_ide_init_iops (struct hwif_s *hwif);
 
 #endif /* _PARISC_SUPERIO_H */

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

* RE: [parisc-linux] ns87415 (superio) support for 2.6.x
  2004-03-10 22:48 [parisc-linux] ns87415 (superio) support for 2.6.x Randolph Chung
@ 2004-03-11 12:59 ` Joel Soete
  2004-03-11 14:02   ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Soete @ 2004-03-11 12:59 UTC (permalink / raw)
  To: Randolph Chung, parisc-linux

Hi Randolph,

> This patch fixes ns87415 to work on suckyio-based boxes. the device
> reports that dma is enabled, but from the performance we get it 
>looks like something is still not quite right (we only see ~3MB/s)
>
>Patch is against 2.6.4-rc3-pa5....  tested on c3000 and c3750. 
>(Thanks Max.)

I just build the new 2.6.4-rc-pa6 (in which this patch is included also if
i didn't miss anything?) and boot it successfully on my b2k. Any way I noticed
a 'kernel bug()' in dmesg:

Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
kernel BUG at include/asm/ide.h:30!
Kernel addresses on the stack:
 [<10124bf8>] printk+0x188/0x1c8
 [<101036b8>] dump_stack+0x18/0x24
 [<1023e6dc>] init_hwif_data+0xd0/0x2e8
 [<101eaac4>] create_dir+0x4c/0x64
 [<104385bc>] init_ide_data+0x44/0x58
 [<10438fb0>] ide_init+0x44/0x80
 [<1042c780>] do_initcalls+0x58/0xf8
 [<101001d0>] init+0x28/0xd4
 [<10109c5c>] ret_from_kernel_thread+0x1c/0x24

kernel BUG at include/asm/ide.h:30!
Kernel addresses on the stack:
 [<10124bf8>] printk+0x188/0x1c8
 [<101036b8>] dump_stack+0x18/0x24
 [<1023e6dc>] init_hwif_data+0xd0/0x2e8
 [<101eaac4>] create_dir+0x4c/0x64
 [<104385c4>] init_ide_data+0x4c/0x58
 [<10438fb0>] ide_init+0x44/0x80
 [<1042c780>] do_initcalls+0x58/0xf8
 [<101001d0>] init+0x28/0xd4
 [<10109c5c>] ret_from_kernel_thread+0x1c/0x24

NS87415: IDE controller at PCI slot 0000:00:0e.0
NS87415: chipset revision 3
NS87415: 100% native mode on irq 103
    ide0: BM-DMA at 0x0900-0x0907, BIOS settings: hda:DMA, hdb:DMA
    ide1: BM-DMA at 0x0908-0x090f, BIOS settings: hdc:DMA, hdd:DMA
hda: LTN485S, ATAPI CD/DVD-ROM drive
Using anticipatory io scheduler
ide0 at 0xe00-0xe07,0xd02 on irq 103
hda: ATAPI 48X CD-ROM drive, 120kB Cache
Uniform CD-ROM driver Revision: 3.20


Thanks for your help,
    Joel

PS: this b2k is only equiped with a simple (readonly :O ) ide cdrom drive


----------------------------------------------------------------------------------------
Tiscali ADSL: 19,50 €/mois, pendant 3 mois! L'Internet rapide, c'est pour
tout le monde.
http://reg.tiscali.be/default.asp?lg=fr

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

* Re: [parisc-linux] ns87415 (superio) support for 2.6.x
  2004-03-11 12:59 ` Joel Soete
@ 2004-03-11 14:02   ` Matthew Wilcox
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2004-03-11 14:02 UTC (permalink / raw)
  To: Joel Soete; +Cc: Randolph Chung, parisc-linux

On Thu, Mar 11, 2004 at 01:59:49PM +0100, Joel Soete wrote:
> I just build the new 2.6.4-rc-pa6 (in which this patch is included also if
> i didn't miss anything?) and boot it successfully on my b2k. Any way I noticed
> a 'kernel bug()' in dmesg:
> 
> Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
> ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
> kernel BUG at include/asm/ide.h:30!

ide_default_io_base()

Looks like we should just take out this BUG().  Randolph?

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

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

end of thread, other threads:[~2004-03-11 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-10 22:48 [parisc-linux] ns87415 (superio) support for 2.6.x Randolph Chung
2004-03-11 12:59 ` Joel Soete
2004-03-11 14:02   ` Matthew Wilcox

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