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/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,
|
|
|
|
};
|
|
|
|
|
2008-04-26 20:25:14 +00:00
|
|
|
static const struct ide_port_ops delkin_cb_port_ops = {
|
|
|
|
.quirkproc = ide_undecoded_slave,
|
|
|
|
};
|
|
|
|
|
2009-03-24 22:22:53 +00:00
|
|
|
static int delkin_cb_init_chipset(struct pci_dev *dev)
|
2008-10-17 16:09:16 +00:00
|
|
|
{
|
|
|
|
unsigned long base = pci_resource_start(dev, 0);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-10 18:56:37 +00:00
|
|
|
static const struct ide_port_info delkin_cb_port_info = {
|
|
|
|
.port_ops = &delkin_cb_port_ops,
|
|
|
|
.host_flags = IDE_HFLAG_IO_32BIT | IDE_HFLAG_UNMASK_IRQS |
|
|
|
|
IDE_HFLAG_NO_DMA,
|
2009-03-27 11:46:27 +00:00
|
|
|
.irq_flags = IRQF_SHARED,
|
2008-10-17 16:09:16 +00:00
|
|
|
.init_chipset = delkin_cb_init_chipset,
|
2009-05-17 17:12:22 +00:00
|
|
|
.chipset = ide_pci,
|
2008-06-10 18:56:37 +00:00
|
|
|
};
|
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static int delkin_cb_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
2007-02-07 17:19:32 +00:00
|
|
|
{
|
2008-07-23 17:55:57 +00:00
|
|
|
struct ide_host *host;
|
2007-02-07 17:19:32 +00:00
|
|
|
unsigned long base;
|
2008-10-17 16:09:16 +00:00
|
|
|
int rc;
|
2009-05-17 17:12:25 +00:00
|
|
|
struct ide_hw hw, *hws[] = { &hw };
|
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);
|
2008-10-17 16:09:16 +00:00
|
|
|
|
|
|
|
delkin_cb_init_chipset(dev);
|
2007-02-07 17:19:32 +00:00
|
|
|
|
|
|
|
memset(&hw, 0, sizeof(hw));
|
|
|
|
ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
|
|
|
|
hw.irq = dev->irq;
|
2008-06-10 18:56:37 +00:00
|
|
|
hw.dev = &dev->dev;
|
2007-02-07 17:19:32 +00:00
|
|
|
|
2009-05-17 17:12:24 +00:00
|
|
|
rc = ide_host_add(&delkin_cb_port_info, hws, 1, &host);
|
ide: add ide_host_add() helper
Add ide_host_add() helper which does ide_host_alloc()+ide_host_register(),
then convert ide_setup_pci_device[s](), ide_legacy_device_add() and some
host drivers to use it.
While at it:
* Fix ide_setup_pci_device[s](), ide_arm.c, gayle.c, ide-4drives.c,
macide.c, q40ide.c, cmd640.c and cs5520.c to return correct error value.
* -ENOENT -> -ENOMEM in rapide.c, ide-h8300.c, ide-generic.c, au1xxx-ide.c
and pmac.c
* -ENODEV -> -ENOMEM in palm_bk3710.c, ide_platform.c and delkin_cb.c
* -1 -> -ENOMEM in ide-pnp.c
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 17:55:57 +00:00
|
|
|
if (rc)
|
2008-02-02 18:56:39 +00:00
|
|
|
goto out_disable;
|
|
|
|
|
2008-07-23 17:55:57 +00:00
|
|
|
pci_set_drvdata(dev, host);
|
2008-06-10 18:56:37 +00:00
|
|
|
|
2007-02-07 17:19:32 +00:00
|
|
|
return 0;
|
2008-02-02 18:56:39 +00:00
|
|
|
|
|
|
|
out_disable:
|
2008-04-26 15:36:38 +00:00
|
|
|
pci_release_regions(dev);
|
2008-02-02 18:56:39 +00:00
|
|
|
pci_disable_device(dev);
|
ide: add ide_host_add() helper
Add ide_host_add() helper which does ide_host_alloc()+ide_host_register(),
then convert ide_setup_pci_device[s](), ide_legacy_device_add() and some
host drivers to use it.
While at it:
* Fix ide_setup_pci_device[s](), ide_arm.c, gayle.c, ide-4drives.c,
macide.c, q40ide.c, cmd640.c and cs5520.c to return correct error value.
* -ENOENT -> -ENOMEM in rapide.c, ide-h8300.c, ide-generic.c, au1xxx-ide.c
and pmac.c
* -ENODEV -> -ENOMEM in palm_bk3710.c, ide_platform.c and delkin_cb.c
* -1 -> -ENOMEM in ide-pnp.c
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 17:55:57 +00:00
|
|
|
return rc;
|
2007-02-07 17:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
delkin_cb_remove (struct pci_dev *dev)
|
|
|
|
{
|
2008-07-23 17:55:57 +00:00
|
|
|
struct ide_host *host = pci_get_drvdata(dev);
|
2007-02-07 17:19:32 +00:00
|
|
|
|
2008-07-23 17:55:57 +00:00
|
|
|
ide_host_remove(host);
|
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);
|
|
|
|
}
|
|
|
|
|
2008-10-17 16:09:16 +00:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
static int delkin_cb_suspend(struct pci_dev *dev, pm_message_t state)
|
|
|
|
{
|
|
|
|
pci_save_state(dev);
|
|
|
|
pci_disable_device(dev);
|
|
|
|
pci_set_power_state(dev, pci_choose_state(dev, state));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int delkin_cb_resume(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
struct ide_host *host = pci_get_drvdata(dev);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
pci_set_power_state(dev, PCI_D0);
|
|
|
|
|
|
|
|
rc = pci_enable_device(dev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
pci_restore_state(dev);
|
|
|
|
pci_set_master(dev);
|
|
|
|
|
|
|
|
if (host->init_chipset)
|
|
|
|
host->init_chipset(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define delkin_cb_suspend NULL
|
|
|
|
#define delkin_cb_resume NULL
|
|
|
|
#endif
|
|
|
|
|
2012-12-21 21:21:03 +00:00
|
|
|
static struct pci_device_id delkin_cb_pci_tbl[] = {
|
2007-02-07 17:19:32 +00:00
|
|
|
{ 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);
|
|
|
|
|
2008-10-13 19:39:41 +00:00
|
|
|
static struct pci_driver delkin_cb_pci_driver = {
|
2007-02-07 17:19:32 +00:00
|
|
|
.name = "Delkin-ASKA-Workbit Cardbus IDE",
|
|
|
|
.id_table = delkin_cb_pci_tbl,
|
|
|
|
.probe = delkin_cb_probe,
|
|
|
|
.remove = delkin_cb_remove,
|
2008-10-17 16:09:16 +00:00
|
|
|
.suspend = delkin_cb_suspend,
|
|
|
|
.resume = delkin_cb_resume,
|
2007-02-07 17:19:32 +00:00
|
|
|
};
|
|
|
|
|
2008-06-10 18:56:38 +00:00
|
|
|
static int __init delkin_cb_init(void)
|
2007-02-07 17:19:32 +00:00
|
|
|
{
|
2008-10-13 19:39:41 +00:00
|
|
|
return pci_register_driver(&delkin_cb_pci_driver);
|
2007-02-07 17:19:32 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 18:56:38 +00:00
|
|
|
static void __exit delkin_cb_exit(void)
|
2007-02-07 17:19:32 +00:00
|
|
|
{
|
2008-10-13 19:39:41 +00:00
|
|
|
pci_unregister_driver(&delkin_cb_pci_driver);
|
2007-02-07 17:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|