linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.4.28-pre4-bk6] delkin_cb:  new driver for Cardbus IDE CF adaptor
@ 2004-10-21 18:44 Mark Lord
  2004-10-21 19:13 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 20+ messages in thread
From: Mark Lord @ 2004-10-21 18:44 UTC (permalink / raw)
  To: Linux Kernel, Marcelo Tosatti

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

This is the first release of a PCI-IDE module to support
the Delkin/ASKA/Workbit Cardbus CompactFlash<-->IDE adaptor.
It may (or not) also work for other versions of this hardware (eg. SD).

This module is based on the existing ide-cs module,
and works fine for me.

Patch is against 2.4.28-pre5-bk6, and it would be good if possible
to include this in the next issue of 2.4.xx (Marcelo?).

An equivalent patch for 2.6.xx is being worked on.

Signed-off-by: Mark Lord <lkml@rtr.ca>
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

[-- Attachment #2: delkin_cb.patch --]
[-- Type: text/plain, Size: 6969 bytes --]

diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/Config.in linux/drivers/ide/Config.in
--- linux-2.4.28-pre4-bk6/drivers/ide/Config.in	2004-10-21 11:02:18.000000000 -0400
+++ linux/drivers/ide/Config.in	2004-10-21 11:46:05.000000000 -0400
@@ -18,6 +18,7 @@
    dep_mbool '    Auto-Geometry Resizing support' CONFIG_IDEDISK_STROKE $CONFIG_BLK_DEV_IDEDISK
 
    dep_tristate '  PCMCIA IDE support' CONFIG_BLK_DEV_IDECS $CONFIG_BLK_DEV_IDE $CONFIG_PCMCIA
+   dep_tristate '  Cardbus IDE support (Delkin/ASKA/Workbit)' CONFIG_BLK_DEV_DELKIN $CONFIG_BLK_DEV_IDE $CONFIG_PCMCIA $CONFIG_PCI
    dep_tristate '  Include IDE/ATAPI CDROM support' CONFIG_BLK_DEV_IDECD $CONFIG_BLK_DEV_IDE
    dep_tristate '  Include IDE/ATAPI TAPE support' CONFIG_BLK_DEV_IDETAPE $CONFIG_BLK_DEV_IDE
    dep_tristate '  Include IDE/ATAPI FLOPPY support' CONFIG_BLK_DEV_IDEFLOPPY $CONFIG_BLK_DEV_IDE
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/pci/delkin_cb.c linux/drivers/ide/pci/delkin_cb.c
--- linux-2.4.28-pre4-bk6/drivers/ide/pci/delkin_cb.c	1969-12-31 19:00:00.000000000 -0500
+++ linux/drivers/ide/pci/delkin_cb.c	2004-10-21 14:24:18.000000000 -0400
@@ -0,0 +1,147 @@
+/*
+ *  linux/drivers/ide/pci/delkin_cb.c
+ *
+ *  Created 20 Oct 2004 by Mark Lord
+ *
+ *  Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adaptor
+ *
+ *  Modeled after the 16-bit PCMCIA driver: ide-cs.c
+ *
+ *  This is slightly peculiar, in that it is a PCI driver,
+ *  but is NOT an IDE PCI driver -- the IDE layer does not directly
+ *  support hot insertion/removal of PCI interfaces, so this driver
+ *  is unable to use the IDE PCI interfaces.  Instead, it uses the
+ *  same interfaces as the ide-cs (PCMCIA) driver uses.
+ *  On the plus side, the driver is also smaller/simpler this way.
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+
+/*
+ * No chip documentation has yet been found,
+ * so these configuration values were pulled from
+ * a running Win98 system using "debug".
+ * This gives around 3MByte/second read performance,
+ * which is about 2/3 of what the chip is capable of.
+ *
+ * There is also a 4KByte mmio region on the card,
+ * but its purpose has yet to be reverse-engineered.
+ */
+static const u8 setup[] = {
+	0x00, 0x05, 0xbe, 0x01, 0x20, 0x8f, 0x00, 0x00,
+	0xa4, 0x1f, 0xb3, 0x1b, 0x00, 0x00, 0x00, 0x80,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
+};
+
+static int __devinit
+delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
+{
+	unsigned long base;
+	hw_regs_t hw;
+	int i, rc;
+
+	MOD_INC_USE_COUNT;
+	rc = pci_enable_device(dev);
+	if (rc) {
+		printk(KERN_ERR "delkin_cb: pci_enable_device failed (%d)\n", rc);
+		return rc;
+	}
+	rc = pci_request_regions(dev, "delkin_cb");
+	if (rc) {
+		printk(KERN_ERR "delkin_cb: pci_request_regions failed (%d)\n", rc);
+		pci_disable_device(dev);
+		return rc;
+	}
+	base = pci_resource_start(dev, 0);
+	outb(0x02, base + 0x1e);	/* set nIEN to block interrupts */
+	inb(base + 0x17);		/* read status to clear interrupts */
+	for (i = 0; i < sizeof(setup); ++i) {
+		if (setup[i])
+			outb(setup[i], base + i);
+	}
+	ide_init_hwif_ports(&hw, (ide_ioreg_t)(base + 0x10),
+				 (ide_ioreg_t)(base + 0x1e), NULL);
+	hw.irq = dev->irq;
+	hw.chipset = ide_pci;		/* this enables IRQ sharing */
+	pci_release_regions(dev);	/* IDE layer handles regions itself */
+
+	rc = ide_register_hw(&hw, NULL);
+	if (rc < 0)	/* ide_register_hw likes to be invoked twice (buggy) */
+		rc = ide_register_hw(&hw, NULL);
+	if (rc < 0) {
+		printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
+		MOD_DEC_USE_COUNT;
+		return -ENODEV;
+	} else {
+		ide_hwif_t  *hwif  = &ide_hwifs[rc];
+		ide_drive_t *drive = &hwif->drives[0];
+		pci_set_drvdata(dev, hwif);
+		hwif->pci_dev = dev;
+		if (drive->present) {
+			drive->id->csfo = 0; /* workaround for idedisk_open bug */
+			drive->io_32bit = 1;
+			drive->unmask   = 1;
+		}
+		return 0;
+	}
+}
+
+static void
+delkin_cb_remove (struct pci_dev *dev)
+{
+	ide_hwif_t *hwif = pci_get_drvdata(dev);
+
+	if (hwif) {
+		ide_unregister(hwif->index);
+		MOD_DEC_USE_COUNT;
+	}
+	pci_disable_device(dev);
+}
+
+static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_WORKBIT, PCI_DEVICE_ID_WORKBIT_CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ 0, },
+};
+MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);
+
+static struct pci_driver driver = {
+	.name		= "Delkin/ASKA/Workbit Cardbus IDE",
+	.id_table	= delkin_cb_pci_tbl,
+	.probe		= delkin_cb_probe,
+	.remove		= delkin_cb_remove,
+};
+
+static int
+delkin_cb_init (void)
+{
+	return pci_module_init(&driver);
+}
+
+static void
+delkin_cb_exit (void)
+{
+	pci_unregister_driver(&driver);
+}
+
+module_init(delkin_cb_init);
+module_exit(delkin_cb_exit);
+
+MODULE_AUTHOR("Mark Lord");
+MODULE_DESCRIPTION("Basic support for Delkin/ASKA/Workbit Cardbus IDE");
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
+
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/pci/Makefile linux/drivers/ide/pci/Makefile
--- linux-2.4.28-pre4-bk6/drivers/ide/pci/Makefile	2004-04-14 09:05:29.000000000 -0400
+++ linux/drivers/ide/pci/Makefile	2004-10-21 11:46:20.000000000 -0400
@@ -34,6 +34,7 @@
 obj-$(CONFIG_BLK_DEV_TRM290)		+= trm290.o
 obj-$(CONFIG_BLK_DEV_VIA82CXXX)		+= via82cxxx.o
 obj-$(CONFIG_BLK_DEV_TRIFLEX)		+= triflex.o
+obj-$(CONFIG_BLK_DEV_DELKIN)		+= delkin_cb.o
 
 # Must appear at the end of the block
 obj-$(CONFIG_BLK_DEV_GENERIC)		+= generic.o
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/scsi/nsp32.h linux/drivers/scsi/nsp32.h
--- linux-2.4.28-pre4-bk6/drivers/scsi/nsp32.h	2003-11-28 13:26:20.000000000 -0500
+++ linux/drivers/scsi/nsp32.h	2004-10-21 11:31:03.000000000 -0400
@@ -22,7 +22,6 @@
  * VENDOR/DEVICE ID
  */
 #define PCI_VENDOR_ID_IODATA  0x10fc
-#define PCI_VENDOR_ID_WORKBIT 0x1145
 
 #define PCI_DEVICE_ID_NINJASCSI_32BI_CBSC_II   0x0005
 #define PCI_DEVICE_ID_NINJASCSI_32BI_KME       0xf007
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/include/linux/pci_ids.h linux/include/linux/pci_ids.h
--- linux-2.4.28-pre4-bk6/include/linux/pci_ids.h	2004-10-21 11:02:21.000000000 -0400
+++ linux/include/linux/pci_ids.h	2004-10-21 11:16:32.000000000 -0400
@@ -2057,3 +2057,6 @@
 #define PCI_DEVICE_ID_MICROGATE_USC	0x0010
 #define PCI_DEVICE_ID_MICROGATE_SCC	0x0020
 #define PCI_DEVICE_ID_MICROGATE_SCA	0x0030
+
+#define PCI_VENDOR_ID_WORKBIT		0x1145
+#define PCI_DEVICE_ID_WORKBIT_CB	0xf021

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 18:44 [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor Mark Lord
@ 2004-10-21 19:13 ` Bartlomiej Zolnierkiewicz
  2004-10-21 20:24   ` Mark Lord
  2004-10-21 21:32   ` Alan Cox
  0 siblings, 2 replies; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-21 19:13 UTC (permalink / raw)
  To: Mark Lord; +Cc: Linux Kernel, Marcelo Tosatti

please also cc: linux-ide@vger.kernel.org

> An equivalent patch for 2.6.xx is being worked on.

generally it should be like that: 2.6.x first, 2.4.x later

> + *  This is slightly peculiar, in that it is a PCI driver,
> + *  but is NOT an IDE PCI driver -- the IDE layer does not directly
> + *  support hot insertion/removal of PCI interfaces, so this driver
> + *  is unable to use the IDE PCI interfaces.  Instead, it uses the
> + *  same interfaces as the ide-cs (PCMCIA) driver uses.
> + *  On the plus side, the driver is also smaller/simpler this way.

IDE layer doesn't support hot insertion/removal of _any_ interfaces

ide_unregister() calls are not allowed unless somebody fixes locking
(Alan fixed many issues but some more work is still needed)

Bartlomiej

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 19:13 ` Bartlomiej Zolnierkiewicz
@ 2004-10-21 20:24   ` Mark Lord
  2004-10-21 20:42     ` Bartlomiej Zolnierkiewicz
  2004-10-21 21:04     ` Chris Friesen
  2004-10-21 21:32   ` Alan Cox
  1 sibling, 2 replies; 20+ messages in thread
From: Mark Lord @ 2004-10-21 20:24 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Linux Kernel, Marcelo Tosatti

Okay, patch withdrawn.

I'll just apply it to my own kernels for my own use.

Whatever happended to the days when Linux *wanted* more
drivers and such?

Oh well..
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

Bartlomiej Zolnierkiewicz wrote:
> please also cc: linux-ide@vger.kernel.org
> 
> 
>>An equivalent patch for 2.6.xx is being worked on.
> 
> 
> generally it should be like that: 2.6.x first, 2.4.x later
> 
> 
>>+ *  This is slightly peculiar, in that it is a PCI driver,
>>+ *  but is NOT an IDE PCI driver -- the IDE layer does not directly
>>+ *  support hot insertion/removal of PCI interfaces, so this driver
>>+ *  is unable to use the IDE PCI interfaces.  Instead, it uses the
>>+ *  same interfaces as the ide-cs (PCMCIA) driver uses.
>>+ *  On the plus side, the driver is also smaller/simpler this way.
> 
> 
> IDE layer doesn't support hot insertion/removal of _any_ interfaces
> 
> ide_unregister() calls are not allowed unless somebody fixes locking
> (Alan fixed many issues but some more work is still needed)
> 
> Bartlomiej
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 20:24   ` Mark Lord
@ 2004-10-21 20:42     ` Bartlomiej Zolnierkiewicz
  2004-10-21 20:59       ` Mark Lord
  2004-10-21 23:40       ` Marcelo Tosatti
  2004-10-21 21:04     ` Chris Friesen
  1 sibling, 2 replies; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-21 20:42 UTC (permalink / raw)
  To: Mark Lord; +Cc: Linux Kernel, Marcelo Tosatti

On Thu, 21 Oct 2004 16:24:51 -0400, Mark Lord <lkml@rtr.ca> wrote:
> Okay, patch withdrawn.
> 
> I'll just apply it to my own kernels for my own use.

Just port it to 2.6.x...

> Whatever happended to the days when Linux *wanted* more
> drivers and such?

New drivers are still welcomed... but days of applying
new drivers without any complaints are long gone... ;-)

Now speaking seriously:
* 2.4.x is deprecated (sorry, Marcelo ;)
* this driver shouldn't require much work to port it to 2.6.x
* ide_unregister() is disallowed, unless IDE locking is fixed

Cheers,
Bartlomiej

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 20:42     ` Bartlomiej Zolnierkiewicz
@ 2004-10-21 20:59       ` Mark Lord
  2004-10-21 21:35         ` Alan Cox
  2004-10-21 21:51         ` Bartlomiej Zolnierkiewicz
  2004-10-21 23:40       ` Marcelo Tosatti
  1 sibling, 2 replies; 20+ messages in thread
From: Mark Lord @ 2004-10-21 20:59 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Linux Kernel

Hi Bartlomiej!

Bartlomiej Zolnierkiewicz wrote:
>
> Just port it to 2.6.x...

 From my current negative experiences with 2.6.xx, I'll pass.
That kernel breaks suspend/resume on my notebooks,
and is a dog for disk performance.  Still, I'd happily
port this new driver to it if there was a hope in hell
that the effort wouldn't be a total waste of my time.

 > ide_unregister() is disallowed, unless IDE locking is fixed

That just happens to be the existing interface used by the existing
PCMCIA layer.  The new delkin_cb driver simply does exactly the
same calls to link in/out of the kernel as ide-cs does today.

I suppose that means we should remove ide-cs as well.

Cheers
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 20:24   ` Mark Lord
  2004-10-21 20:42     ` Bartlomiej Zolnierkiewicz
@ 2004-10-21 21:04     ` Chris Friesen
  1 sibling, 0 replies; 20+ messages in thread
From: Chris Friesen @ 2004-10-21 21:04 UTC (permalink / raw)
  To: Mark Lord; +Cc: Bartlomiej Zolnierkiewicz, Linux Kernel, Marcelo Tosatti

Mark Lord wrote:

> Whatever happended to the days when Linux *wanted* more
> drivers and such?

I think Marcelo is trying to move 2.4 into maintenance mode.  At least that's 
what I've seen around a few places.

Chris

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 19:13 ` Bartlomiej Zolnierkiewicz
  2004-10-21 20:24   ` Mark Lord
@ 2004-10-21 21:32   ` Alan Cox
  2004-10-21 22:49     ` Mark Lord
  1 sibling, 1 reply; 20+ messages in thread
From: Alan Cox @ 2004-10-21 21:32 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Mark Lord, Linux Kernel Mailing List, Marcelo Tosatti

On Iau, 2004-10-21 at 20:13, Bartlomiej Zolnierkiewicz wrote:
> ide_unregister() calls are not allowed unless somebody fixes locking
> (Alan fixed many issues but some more work is still needed)

>From review I think I've got them all fixed in 2.6, but yes 2.4 is a
bit of a lost cause there (although ide-cs works generally so its no big
barrier)


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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 20:59       ` Mark Lord
@ 2004-10-21 21:35         ` Alan Cox
  2004-10-21 22:41           ` Bartlomiej Zolnierkiewicz
  2004-10-21 21:51         ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 20+ messages in thread
From: Alan Cox @ 2004-10-21 21:35 UTC (permalink / raw)
  To: Mark Lord; +Cc: Bartlomiej Zolnierkiewicz, Linux Kernel Mailing List

On Iau, 2004-10-21 at 21:59, Mark Lord wrote:
> That kernel breaks suspend/resume on my notebooks,
> and is a dog for disk performance.  Still, I'd happily
> port this new driver to it if there was a hope in hell
> that the effort wouldn't be a total waste of my time.

If you can drop it into the 2.6-ac patches that would be great and
I will merge it from review of the current code. That should have
correct IDE locking and also possibly correct PCI IDE locking (actually
I need to fix one detail).

Having a cardbus IDE adapter would be a godsend for my testing so I'll
see if I can find a source of them over here too for brutalising the
code.

The only visible difference is that we pass a hwif to the unregister
functions in the -ac tree.

Alan


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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 20:59       ` Mark Lord
  2004-10-21 21:35         ` Alan Cox
@ 2004-10-21 21:51         ` Bartlomiej Zolnierkiewicz
  2004-10-21 21:59           ` Mark Lord
  1 sibling, 1 reply; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-21 21:51 UTC (permalink / raw)
  To: Mark Lord; +Cc: Linux Kernel

On Thu, 21 Oct 2004 16:59:23 -0400, Mark Lord <lkml@rtr.ca> wrote:
> Hi Bartlomiej!
> 
> Bartlomiej Zolnierkiewicz wrote:
> >
> > Just port it to 2.6.x...
> 
>  From my current negative experiences with 2.6.xx, I'll pass.
> That kernel breaks suspend/resume on my notebooks,
> and is a dog for disk performance.  Still, I'd happily

bug reports / patches are the way to go

> port this new driver to it if there was a hope in hell
> that the effort wouldn't be a total waste of my time.

2.4.x is a total waste of my time 8)

>  > ide_unregister() is disallowed, unless IDE locking is fixed
> 
> That just happens to be the existing interface used by the existing
> PCMCIA layer.  The new delkin_cb driver simply does exactly the
> same calls to link in/out of the kernel as ide-cs does today.

"other drivers use it so it must be OK", no it is not
it was discussed few times already...

> I suppose that means we should remove ide-cs as well.

Not adding new users is sufficient for now.

Cheers,
Bartlomiej

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 21:51         ` Bartlomiej Zolnierkiewicz
@ 2004-10-21 21:59           ` Mark Lord
  2004-10-21 22:02             ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 20+ messages in thread
From: Mark Lord @ 2004-10-21 21:59 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Linux Kernel

 >Not adding new users is sufficient for now.

It's amazing just how far we've come in ten years.

Cheers
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 21:59           ` Mark Lord
@ 2004-10-21 22:02             ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-21 22:02 UTC (permalink / raw)
  To: Mark Lord; +Cc: Linux Kernel

On Thu, 21 Oct 2004 17:59:14 -0400, Mark Lord <lkml@rtr.ca> wrote:
>  >Not adding new users is sufficient for now.
> 
> It's amazing just how far we've come in ten years.

Could you explain?

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 21:35         ` Alan Cox
@ 2004-10-21 22:41           ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-21 22:41 UTC (permalink / raw)
  To: Alan Cox; +Cc: Mark Lord, Linux Kernel Mailing List

That makes a lot of sense :)

On Thu, 21 Oct 2004 22:35:54 +0100, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> On Iau, 2004-10-21 at 21:59, Mark Lord wrote:
> > That kernel breaks suspend/resume on my notebooks,
> > and is a dog for disk performance.  Still, I'd happily
> > port this new driver to it if there was a hope in hell
> > that the effort wouldn't be a total waste of my time.
> 
> If you can drop it into the 2.6-ac patches that would be great and
> I will merge it from review of the current code. That should have
> correct IDE locking and also possibly correct PCI IDE locking (actually
> I need to fix one detail).
> 
> Having a cardbus IDE adapter would be a godsend for my testing so I'll
> see if I can find a source of them over here too for brutalising the
> code.
> 
> The only visible difference is that we pass a hwif to the unregister
> functions in the -ac tree.
> 
> Alan

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 21:32   ` Alan Cox
@ 2004-10-21 22:49     ` Mark Lord
  2004-10-21 22:57       ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 20+ messages in thread
From: Mark Lord @ 2004-10-21 22:49 UTC (permalink / raw)
  To: Alan Cox
  Cc: Bartlomiej Zolnierkiewicz, Linux Kernel Mailing List,
	Marcelo Tosatti

Alan Cox wrote:
 >
>>From review I think I've got them all fixed in 2.6, but yes 2.4 is a
> bit of a lost cause there (although ide-cs works generally so its no big
> barrier)

That was my feeling on it too.  Any races that remain in 2.4 are really
a non-issue for removable PC-CARD devices -- the user is popping them
out of the socket regardless, so it cannot really be any more harmful
to tell the kernel they don't physically exist afterwards.  :)

ide-cs does seem to be reliable, as is delkin_cb.  It's not like these
devices are proliferating -- USB flash readers are pretty much taking
over on newer USB2 machines, and this unit is likely the last of the breed.

The adapter I have here is a "Delkin Devices Cardbus 32 eFilm PRO"
compact flash adapter.  They are also sold in Japan under the ASKA name,
and the chipset is by Workbit.  The only North American sources I know
of for this card are B&H Photo in New York (they have a website)
and Downtown Camera in Toronto.

These cards are popular among photographic professionals (and keen
amateurs) because of the compact size, and under Windows they are
much faster than many USB2 or Firewire readers.  Under Linux, they
just plain are not recognized -- unless delkin_cb is configured,
in which case they currently achieve about 2/3 the speed of the
MS driver.

I'll pull down your (Alan) latest tree and re-post a 2.6 patch against it.
But I would really like to see Marcelo pick up the 2.4 version as well,
since that is what people are using today.

Cheers
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 22:49     ` Mark Lord
@ 2004-10-21 22:57       ` Bartlomiej Zolnierkiewicz
  2004-10-22  0:07         ` Mark Lord
  2004-10-23 11:08         ` Mark Lord
  0 siblings, 2 replies; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-21 22:57 UTC (permalink / raw)
  To: Mark Lord; +Cc: Alan Cox, Linux Kernel Mailing List, Marcelo Tosatti

On Thu, 21 Oct 2004 18:49:03 -0400, Mark Lord <lkml@rtr.ca> wrote:

> I'll pull down your (Alan) latest tree and re-post a 2.6 patch against it.
> But I would really like to see Marcelo pick up the 2.4 version as well,
> since that is what people are using today.

Therefore 2.4 version is OK with me.

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 20:42     ` Bartlomiej Zolnierkiewicz
  2004-10-21 20:59       ` Mark Lord
@ 2004-10-21 23:40       ` Marcelo Tosatti
  1 sibling, 0 replies; 20+ messages in thread
From: Marcelo Tosatti @ 2004-10-21 23:40 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Mark Lord, Linux Kernel

On Thu, Oct 21, 2004 at 10:42:18PM +0200, Bartlomiej Zolnierkiewicz wrote:
> On Thu, 21 Oct 2004 16:24:51 -0400, Mark Lord <lkml@rtr.ca> wrote:
> > Okay, patch withdrawn.
> > 
> > I'll just apply it to my own kernels for my own use.
> 
> Just port it to 2.6.x...
> 
> > Whatever happended to the days when Linux *wanted* more
> > drivers and such?
> 
> New drivers are still welcomed... but days of applying
> new drivers without any complaints are long gone... ;-)
> 
> Now speaking seriously:
> * 2.4.x is deprecated (sorry, Marcelo ;)

Buaaaahhh...

Hehe.

People still use 2.4 because they are not prepared (for whatever reason) 
to or do not want a v2.6 upgrade, but yes, I agree it is deprecated.

> * this driver shouldn't require much work to port it to 2.6.x

As I said before in my opinion drivers in new v2.4.x releases for 
new devices are OK as long as they meet a decent coding and quality 
standard and are well tested.
And, very importantly, benefit a substantial amount of users. 

Having the driver in v2.6 first is pretty much required. 
It has the chance of being put under test, as well as 
passing Linus/Andrew "level of acceptance", plus reviewing 
from other people which is always good.

Mark, v2.4.28 is approaching -rc stage (-rc1 should be out tomorrow), 
we can include the driver during v2.4.29-pre.

In the meantime you can port it to v2.6 ?

> * ide_unregister() is disallowed, unless IDE locking is fixed





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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 22:57       ` Bartlomiej Zolnierkiewicz
@ 2004-10-22  0:07         ` Mark Lord
  2004-10-22  0:15           ` Bartlomiej Zolnierkiewicz
  2004-10-23 11:08         ` Mark Lord
  1 sibling, 1 reply; 20+ messages in thread
From: Mark Lord @ 2004-10-22  0:07 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Alan Cox, Linux Kernel Mailing List, Marcelo Tosatti

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

Bartlomiej Zolnierkiewicz wrote:
>
> Therefore 2.4 version is OK with me.

Great.

Marcelo, here is an updated 2.4 patch, which replaces the original.
The changes are a spelling correction, and I've added a precautionary
memset(0) on the hw struct before populating it (copied back from 2.6).

This is a driver for the Delkin/ASKA/Workbit cardbus CF adapter.

Signed-off-by: Mark Lord <lkml@rtr.ca>
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

[-- Attachment #2: delkin_cb-2.4.28-bk4.patch --]
[-- Type: text/plain, Size: 7798 bytes --]

diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-2.4.28-pre4-bk6/Documentation/Configure.help	2004-10-21 11:02:17.000000000 -0400
+++ linux/Documentation/Configure.help	2004-10-21 19:38:35.000000000 -0400
@@ -781,6 +781,13 @@
   <file:Documentation/modules.txt>. The module will be called
   ide-cs.o
 
+Cardbus IDE support (Delkin/ASKA/Workbit)
+CONFIG_BLK_DEV_DELKIN
+  Support for Delkin/ASKA/Workbit cardbus CompactFlash Adapters.
+  This may also work for similar SD and XD adapters.  If you want
+  to be able to use one of these, then say M here.  The module will
+  be called delkin_cb.o
+
 Include IDE/ATAPI CD-ROM support
 CONFIG_BLK_DEV_IDECD
   If you have a CD-ROM drive using the ATAPI protocol, say Y. ATAPI is
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/Config.in linux/drivers/ide/Config.in
--- linux-2.4.28-pre4-bk6/drivers/ide/Config.in	2004-10-21 11:02:18.000000000 -0400
+++ linux/drivers/ide/Config.in	2004-10-21 11:46:05.000000000 -0400
@@ -18,6 +18,7 @@
    dep_mbool '    Auto-Geometry Resizing support' CONFIG_IDEDISK_STROKE $CONFIG_BLK_DEV_IDEDISK
 
    dep_tristate '  PCMCIA IDE support' CONFIG_BLK_DEV_IDECS $CONFIG_BLK_DEV_IDE $CONFIG_PCMCIA
+   dep_tristate '  Cardbus IDE support (Delkin/ASKA/Workbit)' CONFIG_BLK_DEV_DELKIN $CONFIG_BLK_DEV_IDE $CONFIG_PCMCIA $CONFIG_PCI
    dep_tristate '  Include IDE/ATAPI CDROM support' CONFIG_BLK_DEV_IDECD $CONFIG_BLK_DEV_IDE
    dep_tristate '  Include IDE/ATAPI TAPE support' CONFIG_BLK_DEV_IDETAPE $CONFIG_BLK_DEV_IDE
    dep_tristate '  Include IDE/ATAPI FLOPPY support' CONFIG_BLK_DEV_IDEFLOPPY $CONFIG_BLK_DEV_IDE
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/pci/delkin_cb.c linux/drivers/ide/pci/delkin_cb.c
--- linux-2.4.28-pre4-bk6/drivers/ide/pci/delkin_cb.c	1969-12-31 19:00:00.000000000 -0500
+++ linux/drivers/ide/pci/delkin_cb.c	2004-10-21 17:47:33.000000000 -0400
@@ -0,0 +1,149 @@
+/*
+ *  linux/drivers/ide/pci/delkin_cb.c
+ *
+ *  Created 21 Oct 2004 by Mark Lord
+ *
+ *  Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter
+ *
+ *  Modeled after the 16-bit PCMCIA driver: ide-cs.c
+ *
+ *  This is slightly peculiar, in that it is a PCI driver,
+ *  but is NOT an IDE PCI driver -- the IDE layer does not directly
+ *  support hot insertion/removal of PCI interfaces, so this driver
+ *  is unable to use the IDE PCI interfaces.  Instead, it uses the
+ *  same interfaces as the ide-cs (PCMCIA) driver uses.
+ *  On the plus side, the driver is also smaller/simpler this way.
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+
+/*
+ * No chip documentation has yet been found,
+ * so these configuration values were pulled from
+ * a running Win98 system using "debug".
+ * This gives around 3MByte/second read performance,
+ * which is about 2/3 of what the chip is capable of.
+ *
+ * There is also a 4KByte mmio region on the card,
+ * but its purpose has yet to be reverse-engineered.
+ */
+static const u8 setup[] = {
+	0x00, 0x05, 0xbe, 0x01, 0x20, 0x8f, 0x00, 0x00,
+	0xa4, 0x1f, 0xb3, 0x1b, 0x00, 0x00, 0x00, 0x80,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
+};
+
+static int __devinit
+delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
+{
+	unsigned long base;
+	hw_regs_t hw;
+	ide_hwif_t *hwif = NULL;
+	ide_drive_t *drive;
+	int i, rc;
+
+	MOD_INC_USE_COUNT;
+	rc = pci_enable_device(dev);
+	if (rc) {
+		printk(KERN_ERR "delkin_cb: pci_enable_device failed (%d)\n", rc);
+		return rc;
+	}
+	rc = pci_request_regions(dev, "delkin_cb");
+	if (rc) {
+		printk(KERN_ERR "delkin_cb: pci_request_regions failed (%d)\n", rc);
+		pci_disable_device(dev);
+		return rc;
+	}
+	base = pci_resource_start(dev, 0);
+	outb(0x02, base + 0x1e);	/* set nIEN to block interrupts */
+	inb(base + 0x17);		/* read status to clear interrupts */
+	for (i = 0; i < sizeof(setup); ++i) {
+		if (setup[i])
+			outb(setup[i], base + i);
+	}
+	pci_release_regions(dev);	/* IDE layer handles regions itself */
+
+	memset(&hw, 0, sizeof(hw));
+	ide_init_hwif_ports(&hw, (ide_ioreg_t)(base + 0x10),
+				 (ide_ioreg_t)(base + 0x1e), NULL);
+	hw.irq = dev->irq;
+	hw.chipset = ide_pci;		/* this enables IRQ sharing */
+
+	rc = ide_register_hw(&hw, &hwif);
+	if (rc < 0)	/* ide_register_hw likes to be invoked twice (buggy) */
+		rc = ide_register_hw(&hw, &hwif);
+	if (rc < 0) {
+		printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
+		MOD_DEC_USE_COUNT;
+		return -ENODEV;
+	}
+	pci_set_drvdata(dev, hwif);
+	hwif->pci_dev = dev;
+	drive = &hwif->drives[0];
+	if (drive->present) {
+		drive->id->csfo = 0; /* workaround for idedisk_open bug */
+		drive->io_32bit = 1;
+		drive->unmask   = 1;
+	}
+	return 0;
+}
+
+static void
+delkin_cb_remove (struct pci_dev *dev)
+{
+	ide_hwif_t *hwif = pci_get_drvdata(dev);
+
+	if (hwif) {
+		ide_unregister(hwif->index);
+		MOD_DEC_USE_COUNT;
+	}
+	pci_disable_device(dev);
+}
+
+static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_WORKBIT, PCI_DEVICE_ID_WORKBIT_CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ 0, },
+};
+MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);
+
+static struct pci_driver driver = {
+	.name		= "Delkin/ASKA/Workbit Cardbus IDE",
+	.id_table	= delkin_cb_pci_tbl,
+	.probe		= delkin_cb_probe,
+	.remove		= delkin_cb_remove,
+};
+
+static int
+delkin_cb_init (void)
+{
+	return pci_module_init(&driver);
+}
+
+static void
+delkin_cb_exit (void)
+{
+	pci_unregister_driver(&driver);
+}
+
+module_init(delkin_cb_init);
+module_exit(delkin_cb_exit);
+
+MODULE_AUTHOR("Mark Lord");
+MODULE_DESCRIPTION("Basic support for Delkin/ASKA/Workbit Cardbus IDE");
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
+
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/pci/Makefile linux/drivers/ide/pci/Makefile
--- linux-2.4.28-pre4-bk6/drivers/ide/pci/Makefile	2004-04-14 09:05:29.000000000 -0400
+++ linux/drivers/ide/pci/Makefile	2004-10-21 11:46:20.000000000 -0400
@@ -34,6 +34,7 @@
 obj-$(CONFIG_BLK_DEV_TRM290)		+= trm290.o
 obj-$(CONFIG_BLK_DEV_VIA82CXXX)		+= via82cxxx.o
 obj-$(CONFIG_BLK_DEV_TRIFLEX)		+= triflex.o
+obj-$(CONFIG_BLK_DEV_DELKIN)		+= delkin_cb.o
 
 # Must appear at the end of the block
 obj-$(CONFIG_BLK_DEV_GENERIC)		+= generic.o
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/scsi/nsp32.h linux/drivers/scsi/nsp32.h
--- linux-2.4.28-pre4-bk6/drivers/scsi/nsp32.h	2003-11-28 13:26:20.000000000 -0500
+++ linux/drivers/scsi/nsp32.h	2004-10-21 11:31:03.000000000 -0400
@@ -22,7 +22,6 @@
  * VENDOR/DEVICE ID
  */
 #define PCI_VENDOR_ID_IODATA  0x10fc
-#define PCI_VENDOR_ID_WORKBIT 0x1145
 
 #define PCI_DEVICE_ID_NINJASCSI_32BI_CBSC_II   0x0005
 #define PCI_DEVICE_ID_NINJASCSI_32BI_KME       0xf007
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/include/linux/pci_ids.h linux/include/linux/pci_ids.h
--- linux-2.4.28-pre4-bk6/include/linux/pci_ids.h	2004-10-21 11:02:21.000000000 -0400
+++ linux/include/linux/pci_ids.h	2004-10-21 11:16:32.000000000 -0400
@@ -2057,3 +2057,6 @@
 #define PCI_DEVICE_ID_MICROGATE_USC	0x0010
 #define PCI_DEVICE_ID_MICROGATE_SCC	0x0020
 #define PCI_DEVICE_ID_MICROGATE_SCA	0x0030
+
+#define PCI_VENDOR_ID_WORKBIT		0x1145
+#define PCI_DEVICE_ID_WORKBIT_CB	0xf021

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-22  0:07         ` Mark Lord
@ 2004-10-22  0:15           ` Bartlomiej Zolnierkiewicz
  2004-10-22  0:20             ` Mark Lord
  0 siblings, 1 reply; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-22  0:15 UTC (permalink / raw)
  To: Mark Lord; +Cc: Alan Cox, Linux Kernel Mailing List, Marcelo Tosatti

wrt to 2.6.x version

> +       memset(&hw, 0, sizeof(hw));
> +       ide_init_hwif_ports(&hw, (ide_ioreg_t)(base + 0x10),
> +                                (ide_ioreg_t)(base + 0x1e), NULL);

please use ide_std_init_ports()

> +       rc = ide_register_hw(&hw, &hwif);
> +       if (rc < 0)     /* ide_register_hw likes to be invoked twice (buggy) */
> +               rc = ide_register_hw(&hw, &hwif);

is this needed in 2.6.x and if so why?

> +               drive->id->csfo = 0; /* workaround for idedisk_open bug */

ditto

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-22  0:15           ` Bartlomiej Zolnierkiewicz
@ 2004-10-22  0:20             ` Mark Lord
  2004-10-22  0:31               ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 20+ messages in thread
From: Mark Lord @ 2004-10-22  0:20 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Alan Cox, Linux Kernel Mailing List

Bartlomiej Zolnierkiewicz wrote:
> wrt to 2.6.x version
..
> please use ide_std_init_ports()

Okay, will do.

>>+       rc = ide_register_hw(&hw, &hwif);
>>+       if (rc < 0)     /* ide_register_hw likes to be invoked twice (buggy) */
>>+               rc = ide_register_hw(&hw, &hwif);
> 
> is this needed in 2.6.x and if so why?

Not sure yet -- still testing, though I've already done an #if 0 on it.

>>+               drive->id->csfo = 0; /* workaround for idedisk_open bug */

Not there in the 2.6.xx version.

And in 2.4.xx.. why is idedisk_open() examining vendor-specific
fields of the IDENTIFY data, anyway?  Very very unsafe.
I put the above one-liner workaround (drive->id->csfo) into delkin_cb
to bypass the problems it creates for now, until idedisk_open gets fixed.

Normally I'd just send a patch to fix idedisk_open(), but since I don't
even understand what it is trying to do, it would be safer for whoever
put that code there to have a second look.  Especially since 2.4.xx
is supposed to be stable now -- if it ain't broke, don't break it.  :)

Cheers
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-22  0:20             ` Mark Lord
@ 2004-10-22  0:31               ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 20+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-10-22  0:31 UTC (permalink / raw)
  To: Mark Lord; +Cc: Alan Cox, Linux Kernel Mailing List

On Thu, 21 Oct 2004 20:20:40 -0400, Mark Lord <lkml@rtr.ca> wrote:
> >>+               drive->id->csfo = 0; /* workaround for idedisk_open bug */
> 
> Not there in the 2.6.xx version.
> 
> And in 2.4.xx.. why is idedisk_open() examining vendor-specific
> fields of the IDENTIFY data, anyway?  Very very unsafe.
> I put the above one-liner workaround (drive->id->csfo) into delkin_cb
> to bypass the problems it creates for now, until idedisk_open gets fixed.

id->csfo is still checked in 2.6.x but in idedisk_setup()

> Normally I'd just send a patch to fix idedisk_open(), but since I don't
> even understand what it is trying to do, it would be safer for whoever
> put that code there to have a second look.  Especially since 2.4.xx
> is supposed to be stable now -- if it ain't broke, don't break it.  :)

I guess that Alan knows more about id->csfo.

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

* Re: [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor
  2004-10-21 22:57       ` Bartlomiej Zolnierkiewicz
  2004-10-22  0:07         ` Mark Lord
@ 2004-10-23 11:08         ` Mark Lord
  1 sibling, 0 replies; 20+ messages in thread
From: Mark Lord @ 2004-10-23 11:08 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Alan Cox, Linux Kernel Mailing List, Marcelo Tosatti

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

Bartlomiej Zolnierkiewicz wrote:
>
> Therefore 2.4 version is OK with me.

Great.

Marcelo, here is an updated 2.4 patch, which replaces the original.
The changes are a spelling correction, and I've added a precautionary
memset(0) on the hw struct before populating it (copied back from 2.6).

This is a driver for the Delkin/ASKA/Workbit cardbus CF adapter.

Signed-off-by: Mark Lord <lkml@rtr.ca>
-- 
Mark Lord
(hdparm keeper & the original "Linux IDE Guy")

[-- Attachment #2: delkin_cb-2.4.28-bk4.patch --]
[-- Type: text/plain, Size: 7798 bytes --]

diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-2.4.28-pre4-bk6/Documentation/Configure.help	2004-10-21 11:02:17.000000000 -0400
+++ linux/Documentation/Configure.help	2004-10-21 19:38:35.000000000 -0400
@@ -781,6 +781,13 @@
   <file:Documentation/modules.txt>. The module will be called
   ide-cs.o
 
+Cardbus IDE support (Delkin/ASKA/Workbit)
+CONFIG_BLK_DEV_DELKIN
+  Support for Delkin/ASKA/Workbit cardbus CompactFlash Adapters.
+  This may also work for similar SD and XD adapters.  If you want
+  to be able to use one of these, then say M here.  The module will
+  be called delkin_cb.o
+
 Include IDE/ATAPI CD-ROM support
 CONFIG_BLK_DEV_IDECD
   If you have a CD-ROM drive using the ATAPI protocol, say Y. ATAPI is
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/Config.in linux/drivers/ide/Config.in
--- linux-2.4.28-pre4-bk6/drivers/ide/Config.in	2004-10-21 11:02:18.000000000 -0400
+++ linux/drivers/ide/Config.in	2004-10-21 11:46:05.000000000 -0400
@@ -18,6 +18,7 @@
    dep_mbool '    Auto-Geometry Resizing support' CONFIG_IDEDISK_STROKE $CONFIG_BLK_DEV_IDEDISK
 
    dep_tristate '  PCMCIA IDE support' CONFIG_BLK_DEV_IDECS $CONFIG_BLK_DEV_IDE $CONFIG_PCMCIA
+   dep_tristate '  Cardbus IDE support (Delkin/ASKA/Workbit)' CONFIG_BLK_DEV_DELKIN $CONFIG_BLK_DEV_IDE $CONFIG_PCMCIA $CONFIG_PCI
    dep_tristate '  Include IDE/ATAPI CDROM support' CONFIG_BLK_DEV_IDECD $CONFIG_BLK_DEV_IDE
    dep_tristate '  Include IDE/ATAPI TAPE support' CONFIG_BLK_DEV_IDETAPE $CONFIG_BLK_DEV_IDE
    dep_tristate '  Include IDE/ATAPI FLOPPY support' CONFIG_BLK_DEV_IDEFLOPPY $CONFIG_BLK_DEV_IDE
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/pci/delkin_cb.c linux/drivers/ide/pci/delkin_cb.c
--- linux-2.4.28-pre4-bk6/drivers/ide/pci/delkin_cb.c	1969-12-31 19:00:00.000000000 -0500
+++ linux/drivers/ide/pci/delkin_cb.c	2004-10-21 17:47:33.000000000 -0400
@@ -0,0 +1,149 @@
+/*
+ *  linux/drivers/ide/pci/delkin_cb.c
+ *
+ *  Created 21 Oct 2004 by Mark Lord
+ *
+ *  Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter
+ *
+ *  Modeled after the 16-bit PCMCIA driver: ide-cs.c
+ *
+ *  This is slightly peculiar, in that it is a PCI driver,
+ *  but is NOT an IDE PCI driver -- the IDE layer does not directly
+ *  support hot insertion/removal of PCI interfaces, so this driver
+ *  is unable to use the IDE PCI interfaces.  Instead, it uses the
+ *  same interfaces as the ide-cs (PCMCIA) driver uses.
+ *  On the plus side, the driver is also smaller/simpler this way.
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+
+/*
+ * No chip documentation has yet been found,
+ * so these configuration values were pulled from
+ * a running Win98 system using "debug".
+ * This gives around 3MByte/second read performance,
+ * which is about 2/3 of what the chip is capable of.
+ *
+ * There is also a 4KByte mmio region on the card,
+ * but its purpose has yet to be reverse-engineered.
+ */
+static const u8 setup[] = {
+	0x00, 0x05, 0xbe, 0x01, 0x20, 0x8f, 0x00, 0x00,
+	0xa4, 0x1f, 0xb3, 0x1b, 0x00, 0x00, 0x00, 0x80,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
+};
+
+static int __devinit
+delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
+{
+	unsigned long base;
+	hw_regs_t hw;
+	ide_hwif_t *hwif = NULL;
+	ide_drive_t *drive;
+	int i, rc;
+
+	MOD_INC_USE_COUNT;
+	rc = pci_enable_device(dev);
+	if (rc) {
+		printk(KERN_ERR "delkin_cb: pci_enable_device failed (%d)\n", rc);
+		return rc;
+	}
+	rc = pci_request_regions(dev, "delkin_cb");
+	if (rc) {
+		printk(KERN_ERR "delkin_cb: pci_request_regions failed (%d)\n", rc);
+		pci_disable_device(dev);
+		return rc;
+	}
+	base = pci_resource_start(dev, 0);
+	outb(0x02, base + 0x1e);	/* set nIEN to block interrupts */
+	inb(base + 0x17);		/* read status to clear interrupts */
+	for (i = 0; i < sizeof(setup); ++i) {
+		if (setup[i])
+			outb(setup[i], base + i);
+	}
+	pci_release_regions(dev);	/* IDE layer handles regions itself */
+
+	memset(&hw, 0, sizeof(hw));
+	ide_init_hwif_ports(&hw, (ide_ioreg_t)(base + 0x10),
+				 (ide_ioreg_t)(base + 0x1e), NULL);
+	hw.irq = dev->irq;
+	hw.chipset = ide_pci;		/* this enables IRQ sharing */
+
+	rc = ide_register_hw(&hw, &hwif);
+	if (rc < 0)	/* ide_register_hw likes to be invoked twice (buggy) */
+		rc = ide_register_hw(&hw, &hwif);
+	if (rc < 0) {
+		printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
+		MOD_DEC_USE_COUNT;
+		return -ENODEV;
+	}
+	pci_set_drvdata(dev, hwif);
+	hwif->pci_dev = dev;
+	drive = &hwif->drives[0];
+	if (drive->present) {
+		drive->id->csfo = 0; /* workaround for idedisk_open bug */
+		drive->io_32bit = 1;
+		drive->unmask   = 1;
+	}
+	return 0;
+}
+
+static void
+delkin_cb_remove (struct pci_dev *dev)
+{
+	ide_hwif_t *hwif = pci_get_drvdata(dev);
+
+	if (hwif) {
+		ide_unregister(hwif->index);
+		MOD_DEC_USE_COUNT;
+	}
+	pci_disable_device(dev);
+}
+
+static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_WORKBIT, PCI_DEVICE_ID_WORKBIT_CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ 0, },
+};
+MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);
+
+static struct pci_driver driver = {
+	.name		= "Delkin/ASKA/Workbit Cardbus IDE",
+	.id_table	= delkin_cb_pci_tbl,
+	.probe		= delkin_cb_probe,
+	.remove		= delkin_cb_remove,
+};
+
+static int
+delkin_cb_init (void)
+{
+	return pci_module_init(&driver);
+}
+
+static void
+delkin_cb_exit (void)
+{
+	pci_unregister_driver(&driver);
+}
+
+module_init(delkin_cb_init);
+module_exit(delkin_cb_exit);
+
+MODULE_AUTHOR("Mark Lord");
+MODULE_DESCRIPTION("Basic support for Delkin/ASKA/Workbit Cardbus IDE");
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
+
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/ide/pci/Makefile linux/drivers/ide/pci/Makefile
--- linux-2.4.28-pre4-bk6/drivers/ide/pci/Makefile	2004-04-14 09:05:29.000000000 -0400
+++ linux/drivers/ide/pci/Makefile	2004-10-21 11:46:20.000000000 -0400
@@ -34,6 +34,7 @@
 obj-$(CONFIG_BLK_DEV_TRM290)		+= trm290.o
 obj-$(CONFIG_BLK_DEV_VIA82CXXX)		+= via82cxxx.o
 obj-$(CONFIG_BLK_DEV_TRIFLEX)		+= triflex.o
+obj-$(CONFIG_BLK_DEV_DELKIN)		+= delkin_cb.o
 
 # Must appear at the end of the block
 obj-$(CONFIG_BLK_DEV_GENERIC)		+= generic.o
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/drivers/scsi/nsp32.h linux/drivers/scsi/nsp32.h
--- linux-2.4.28-pre4-bk6/drivers/scsi/nsp32.h	2003-11-28 13:26:20.000000000 -0500
+++ linux/drivers/scsi/nsp32.h	2004-10-21 11:31:03.000000000 -0400
@@ -22,7 +22,6 @@
  * VENDOR/DEVICE ID
  */
 #define PCI_VENDOR_ID_IODATA  0x10fc
-#define PCI_VENDOR_ID_WORKBIT 0x1145
 
 #define PCI_DEVICE_ID_NINJASCSI_32BI_CBSC_II   0x0005
 #define PCI_DEVICE_ID_NINJASCSI_32BI_KME       0xf007
diff -u --recursive --new-file --exclude='.*' linux-2.4.28-pre4-bk6/include/linux/pci_ids.h linux/include/linux/pci_ids.h
--- linux-2.4.28-pre4-bk6/include/linux/pci_ids.h	2004-10-21 11:02:21.000000000 -0400
+++ linux/include/linux/pci_ids.h	2004-10-21 11:16:32.000000000 -0400
@@ -2057,3 +2057,6 @@
 #define PCI_DEVICE_ID_MICROGATE_USC	0x0010
 #define PCI_DEVICE_ID_MICROGATE_SCC	0x0020
 #define PCI_DEVICE_ID_MICROGATE_SCA	0x0030
+
+#define PCI_VENDOR_ID_WORKBIT		0x1145
+#define PCI_DEVICE_ID_WORKBIT_CB	0xf021

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

end of thread, other threads:[~2004-10-23 13:36 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-21 18:44 [PATCH 2.4.28-pre4-bk6] delkin_cb: new driver for Cardbus IDE CF adaptor Mark Lord
2004-10-21 19:13 ` Bartlomiej Zolnierkiewicz
2004-10-21 20:24   ` Mark Lord
2004-10-21 20:42     ` Bartlomiej Zolnierkiewicz
2004-10-21 20:59       ` Mark Lord
2004-10-21 21:35         ` Alan Cox
2004-10-21 22:41           ` Bartlomiej Zolnierkiewicz
2004-10-21 21:51         ` Bartlomiej Zolnierkiewicz
2004-10-21 21:59           ` Mark Lord
2004-10-21 22:02             ` Bartlomiej Zolnierkiewicz
2004-10-21 23:40       ` Marcelo Tosatti
2004-10-21 21:04     ` Chris Friesen
2004-10-21 21:32   ` Alan Cox
2004-10-21 22:49     ` Mark Lord
2004-10-21 22:57       ` Bartlomiej Zolnierkiewicz
2004-10-22  0:07         ` Mark Lord
2004-10-22  0:15           ` Bartlomiej Zolnierkiewicz
2004-10-22  0:20             ` Mark Lord
2004-10-22  0:31               ` Bartlomiej Zolnierkiewicz
2004-10-23 11:08         ` Mark Lord

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).