2007-02-07 17:19:32 +00:00
|
|
|
/*
|
|
|
|
* Created 20 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.
|
|
|
|
*/
|
2008-02-02 18:56:33 +00:00
|
|
|
|
2007-02-07 17:19:32 +00:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/hdreg.h>
|
|
|
|
#include <linux/ide.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
2008-02-02 18:56:33 +00:00
|
|
|
|
2007-02-07 17:19:32 +00:00
|
|
|
#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;
|
2008-02-02 18:56:39 +00:00
|
|
|
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
|
2007-02-07 17:19:32 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&hw, 0, sizeof(hw));
|
|
|
|
ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
|
|
|
|
hw.irq = dev->irq;
|
|
|
|
hw.chipset = ide_pci; /* this enables IRQ sharing */
|
|
|
|
|
2008-04-26 15:36:32 +00:00
|
|
|
hwif = ide_find_port();
|
2008-02-02 18:56:39 +00:00
|
|
|
if (hwif == NULL)
|
|
|
|
goto out_disable;
|
|
|
|
|
|
|
|
i = hwif->index;
|
|
|
|
|
|
|
|
if (hwif->present)
|
ide: remove broken/dangerous HDIO_[UNREGISTER,SCAN]_HWIF ioctls (take 3)
hdparm explicitely marks HDIO_[UNREGISTER,SCAN]_HWIF ioctls as DANGEROUS
and given the number of bugs we can assume that there are no real users:
* DMA has no chance of working because DMA resources are released by
ide_unregister() and they are never allocated again.
* Since ide_init_hwif_ports() is used for ->io_ports[] setup the ioctls
don't work for almost all hosts with "non-standard" (== non ISA-like)
layout of IDE taskfile registers (there is a lot of such host drivers).
* ide_port_init_devices() is not called when probing IDE devices so:
- drive->autotune is never set and IDE host/devices are not programmed
for the correct PIO/DMA transfer modes (=> possible data corruption)
- host specific I/O 32-bit and IRQ unmasking settings are not applied
(=> possible data corruption)
- host specific ->port_init_devs method is not called (=> no luck with
ht6560b, qd65xx and opti621 host drivers)
* ->rw_disk method is not preserved (=> no HPT3xxN chipsets support).
* ->serialized flag is not preserved (=> possible data corruption when
using icside, aec62xx (ATP850UF chipset), cmd640, cs5530, hpt366
(HPT3xxN chipsets), rz1000, sc1200, dtc2278 and ht6560b host drivers).
* ->ack_intr method is not preserved (=> needed by ide-cris, buddha,
gayle and macide host drivers).
* ->sata_scr[] and sata_misc[] is cleared by ide_unregister() and it
isn't initialized again (SiI3112 support needs them).
* To issue an ioctl() there need to be at least one IDE device present
in the system.
* ->cable_detect method is not preserved + it is not called when probing
IDE devices so cable detection is broken (however since DMA support is
also broken it doesn't really matter ;-).
* Some objects which may have already been freed in ide_unregister()
are restored by ide_hwif_restore() (i.e. ->hwgroup).
* ide_register_hw() may unregister unrelated IDE ports if free ide_hwifs[]
slot cannot be found.
* When IDE host drivers are modular unregistered port may be re-used by
different host driver that owned it first causing subtle bugs.
Since we now have a proper warm-plug support remove these ioctls,
then remove no longer needed:
- ide_register_hw() and ide_hwif_restore() functions
- 'init_default' and 'restore' arguments of ide_unregister()
- zeroeing of hwif->{dma,extra}_* fields in ide_unregister()
As an added bonus IDE core code size shrinks by ~3kB (x86-32).
v2:
* fix ide_unregister() arguments in cleanup_module() (Andrew Morton).
v3:
* fix ide_unregister() arguments in palm_bk3710.c.
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-17 22:46:24 +00:00
|
|
|
ide_unregister(i);
|
2008-04-17 22:46:24 +00:00
|
|
|
else
|
2008-02-02 18:56:39 +00:00
|
|
|
ide_init_port_data(hwif, i);
|
|
|
|
|
|
|
|
ide_init_port_hw(hwif, &hw);
|
2008-04-26 15:36:38 +00:00
|
|
|
hwif->mmio = 1;
|
2008-02-02 18:56:39 +00:00
|
|
|
hwif->quirkproc = &ide_undecoded_slave;
|
|
|
|
|
|
|
|
idx[0] = i;
|
|
|
|
|
|
|
|
ide_device_add(idx, NULL);
|
|
|
|
|
|
|
|
if (!hwif->present)
|
|
|
|
goto out_disable;
|
|
|
|
|
2007-02-07 17:19:32 +00:00
|
|
|
pci_set_drvdata(dev, hwif);
|
2008-02-01 22:09:31 +00:00
|
|
|
hwif->dev = &dev->dev;
|
2007-02-07 17:19:32 +00:00
|
|
|
drive = &hwif->drives[0];
|
|
|
|
if (drive->present) {
|
|
|
|
drive->io_32bit = 1;
|
|
|
|
drive->unmask = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2008-02-02 18:56:39 +00:00
|
|
|
|
|
|
|
out_disable:
|
|
|
|
printk(KERN_ERR "delkin_cb: no IDE devices found\n");
|
2008-04-26 15:36:38 +00:00
|
|
|
pci_release_regions(dev);
|
2008-02-02 18:56:39 +00:00
|
|
|
pci_disable_device(dev);
|
|
|
|
return -ENODEV;
|
2007-02-07 17:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
delkin_cb_remove (struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
ide_hwif_t *hwif = pci_get_drvdata(dev);
|
|
|
|
|
|
|
|
if (hwif)
|
ide: remove broken/dangerous HDIO_[UNREGISTER,SCAN]_HWIF ioctls (take 3)
hdparm explicitely marks HDIO_[UNREGISTER,SCAN]_HWIF ioctls as DANGEROUS
and given the number of bugs we can assume that there are no real users:
* DMA has no chance of working because DMA resources are released by
ide_unregister() and they are never allocated again.
* Since ide_init_hwif_ports() is used for ->io_ports[] setup the ioctls
don't work for almost all hosts with "non-standard" (== non ISA-like)
layout of IDE taskfile registers (there is a lot of such host drivers).
* ide_port_init_devices() is not called when probing IDE devices so:
- drive->autotune is never set and IDE host/devices are not programmed
for the correct PIO/DMA transfer modes (=> possible data corruption)
- host specific I/O 32-bit and IRQ unmasking settings are not applied
(=> possible data corruption)
- host specific ->port_init_devs method is not called (=> no luck with
ht6560b, qd65xx and opti621 host drivers)
* ->rw_disk method is not preserved (=> no HPT3xxN chipsets support).
* ->serialized flag is not preserved (=> possible data corruption when
using icside, aec62xx (ATP850UF chipset), cmd640, cs5530, hpt366
(HPT3xxN chipsets), rz1000, sc1200, dtc2278 and ht6560b host drivers).
* ->ack_intr method is not preserved (=> needed by ide-cris, buddha,
gayle and macide host drivers).
* ->sata_scr[] and sata_misc[] is cleared by ide_unregister() and it
isn't initialized again (SiI3112 support needs them).
* To issue an ioctl() there need to be at least one IDE device present
in the system.
* ->cable_detect method is not preserved + it is not called when probing
IDE devices so cable detection is broken (however since DMA support is
also broken it doesn't really matter ;-).
* Some objects which may have already been freed in ide_unregister()
are restored by ide_hwif_restore() (i.e. ->hwgroup).
* ide_register_hw() may unregister unrelated IDE ports if free ide_hwifs[]
slot cannot be found.
* When IDE host drivers are modular unregistered port may be re-used by
different host driver that owned it first causing subtle bugs.
Since we now have a proper warm-plug support remove these ioctls,
then remove no longer needed:
- ide_register_hw() and ide_hwif_restore() functions
- 'init_default' and 'restore' arguments of ide_unregister()
- zeroeing of hwif->{dma,extra}_* fields in ide_unregister()
As an added bonus IDE core code size shrinks by ~3kB (x86-32).
v2:
* fix ide_unregister() arguments in cleanup_module() (Andrew Morton).
v3:
* fix ide_unregister() arguments in palm_bk3710.c.
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-17 22:46:24 +00:00
|
|
|
ide_unregister(hwif->index);
|
2008-02-02 18:56:39 +00:00
|
|
|
|
2008-04-26 15:36:38 +00:00
|
|
|
pci_release_regions(dev);
|
2007-02-07 17:19:32 +00:00
|
|
|
pci_disable_device(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
|
|
|
|
{ 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
|
2007-04-20 20:16:58 +00:00
|
|
|
{ 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
|
2007-02-07 17:19:32 +00:00
|
|
|
{ 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)
|
|
|
|
{
|
2007-03-03 16:48:55 +00:00
|
|
|
return pci_register_driver(&driver);
|
2007-02-07 17:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|