2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1998-2000 Michel Aubry
|
|
|
|
* Copyright (C) 1998-2000 Andrzej Krzysztofowicz
|
|
|
|
* Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
|
2007-05-16 06:51:42 +08:00
|
|
|
* Copyright (C) 2007 Bartlomiej Zolnierkiewicz
|
2005-04-17 06:20:36 +08:00
|
|
|
* Portions copyright (c) 2001 Sun Microsystems
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* RCC/ServerWorks IDE driver for Linux
|
|
|
|
*
|
|
|
|
* OSB4: `Open South Bridge' IDE Interface (fn 1)
|
|
|
|
* supports UDMA mode 2 (33 MB/s)
|
|
|
|
*
|
|
|
|
* CSB5: `Champion South Bridge' IDE Interface (fn 1)
|
|
|
|
* all revisions support UDMA mode 4 (66 MB/s)
|
|
|
|
* revision A2.0 and up support UDMA mode 5 (100 MB/s)
|
|
|
|
*
|
|
|
|
* *** The CSB5 does not provide ANY register ***
|
|
|
|
* *** to detect 80-conductor cable presence. ***
|
|
|
|
*
|
|
|
|
* CSB6: `Champion South Bridge' IDE Interface (optional: third channel)
|
|
|
|
*
|
2005-08-19 04:30:35 +08:00
|
|
|
* HT1000: AKA BCM5785 - Hypertransport Southbridge for Opteron systems. IDE
|
|
|
|
* controller same as the CSB6. Single channel ATA100 only.
|
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Documentation:
|
|
|
|
* Available under NDA only. Errata info very hard to get.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/ide.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
2008-07-25 04:53:32 +08:00
|
|
|
#define DRV_NAME "serverworks"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */
|
|
|
|
#define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */
|
|
|
|
|
|
|
|
/* Seagate Barracuda ATA IV Family drives in UDMA mode 5
|
|
|
|
* can overrun their FIFOs when used with the CSB5 */
|
|
|
|
static const char *svwks_bad_ata100[] = {
|
|
|
|
"ST320011A",
|
|
|
|
"ST340016A",
|
|
|
|
"ST360021A",
|
|
|
|
"ST380021A",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_dev *isa_dev;
|
|
|
|
|
|
|
|
static int check_in_drive_lists (ide_drive_t *drive, const char **list)
|
|
|
|
{
|
2008-10-11 04:39:19 +08:00
|
|
|
char *m = (char *)&drive->id[ATA_ID_PROD];
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
while (*list)
|
2008-10-11 04:39:19 +08:00
|
|
|
if (!strcmp(*list++, m))
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-10 06:01:08 +08:00
|
|
|
static u8 svwks_udma_filter(ide_drive_t *drive)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-02 06:09:31 +08:00
|
|
|
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
|
2007-05-10 06:01:08 +08:00
|
|
|
u8 mask = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-08-19 04:30:35 +08:00
|
|
|
if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE)
|
2007-05-10 06:01:08 +08:00
|
|
|
return 0x1f;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
|
|
|
|
u32 reg = 0;
|
|
|
|
if (isa_dev)
|
|
|
|
pci_read_config_dword(isa_dev, 0x64, ®);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't enable UDMA on disk devices for the moment
|
|
|
|
*/
|
|
|
|
if(drive->media == ide_disk)
|
|
|
|
return 0;
|
|
|
|
/* Check the OSB4 DMA33 enable bit */
|
2007-05-10 06:01:08 +08:00
|
|
|
return ((reg & 0x00004000) == 0x00004000) ? 0x07 : 0;
|
2007-06-09 06:46:36 +08:00
|
|
|
} else if (dev->revision < SVWKS_CSB5_REVISION_NEW) {
|
2007-05-10 06:01:08 +08:00
|
|
|
return 0x07;
|
2007-06-09 06:46:36 +08:00
|
|
|
} else if (dev->revision >= SVWKS_CSB5_REVISION_NEW) {
|
2007-05-10 06:01:08 +08:00
|
|
|
u8 btr = 0, mode;
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_read_config_byte(dev, 0x5A, &btr);
|
|
|
|
mode = btr & 0x3;
|
2007-05-10 06:01:08 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* If someone decides to do UDMA133 on CSB5 the same
|
|
|
|
issue will bite so be inclusive */
|
|
|
|
if (mode > 2 && check_in_drive_lists(drive, svwks_bad_ata100))
|
|
|
|
mode = 2;
|
2007-05-10 06:01:08 +08:00
|
|
|
|
|
|
|
switch(mode) {
|
2007-10-17 04:29:52 +08:00
|
|
|
case 3: mask = 0x3f; break;
|
2007-05-10 06:01:08 +08:00
|
|
|
case 2: mask = 0x1f; break;
|
|
|
|
case 1: mask = 0x07; break;
|
|
|
|
default: mask = 0x00; break;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
|
|
|
|
(dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) &&
|
|
|
|
(!(PCI_FUNC(dev->devfn) & 1)))
|
2007-05-10 06:01:08 +08:00
|
|
|
mask = 0x1f;
|
|
|
|
|
|
|
|
return mask;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 svwks_csb_check (struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
switch (dev->device) {
|
|
|
|
case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
|
|
|
|
case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
|
|
|
|
case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
|
2005-08-19 04:30:35 +08:00
|
|
|
case PCI_DEVICE_ID_SERVERWORKS_HT1000IDE:
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-07-20 07:11:56 +08:00
|
|
|
|
ide: move ide_config_drive_speed() calls to upper layers (take 2)
* Convert {ide_hwif_t,ide_pci_device_t}->host_flag to be u16.
* Add IDE_HFLAG_POST_SET_MODE host flag to indicate the need to program
the host for the transfer mode after programming the device. Set it
in au1xxx-ide, amd74xx, cs5530, cs5535, pdc202xx_new, sc1200, pmac
and via82cxxx host drivers.
* Add IDE_HFLAG_NO_SET_MODE host flag to indicate the need to completely
skip programming of host/device for the transfer mode ("smart" hosts).
Set it in it821x host driver and check it in ide_tune_dma().
* Add ide_set_pio_mode()/ide_set_dma_mode() helpers and convert all
direct ->set_pio_mode/->speedproc users to use these helpers.
* Move ide_config_drive_speed() calls from ->set_pio_mode/->speedproc
methods to callers.
* Rename ->speedproc method to ->set_dma_mode, make it void and update
all implementations accordingly.
* Update ide_set_xfer_rate() comments.
* Unexport ide_config_drive_speed().
v2:
* Fix issues noticed by Sergei:
- export ide_set_dma_mode() instead of moving ->set_pio_mode abuse wrt
to setting DMA modes from sc1200_set_pio_mode() to do_special()
- check IDE_HFLAG_NO_SET_MODE in ide_tune_dma()
- check for (hwif->set_pio_mode) == NULL in ide_set_pio_mode()
- check for (hwif->set_dma_mode) == NULL in ide_set_dma_mode()
- return -1 from ide_set_{pio,dma}_mode() if ->set_{pio,dma}_mode == NULL
- don't set ->set_{pio,dma}_mode on it821x in "smart" mode
- fix build problem in pmac.c
- minor fixes in au1xxx-ide.c/cs5530.c/siimage.c
- improve patch description
Changes in behavior caused by this patch:
- HDIO_SET_PIO_MODE ioctl would now return -ENOSYS for attempts to change
PIO mode if it821x controller is in "smart" mode
- removal of two debugging printk-s (from cs5530.c and sc1200.c)
- transfer modes 0x00-0x07 passed from user space may be programmed twice on
the device (not really an issue since 0x00 is not supported correctly by
any host driver ATM, 0x01 is not supported at all and 0x02-0x07 are invalid)
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2007-10-13 23:47:51 +08:00
|
|
|
static void svwks_set_pio_mode(ide_drive_t *drive, const u8 pio)
|
2007-07-20 07:11:56 +08:00
|
|
|
{
|
|
|
|
static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
|
|
|
|
static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 };
|
|
|
|
|
2008-02-02 06:09:31 +08:00
|
|
|
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
|
2007-07-20 07:11:56 +08:00
|
|
|
|
|
|
|
pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]);
|
|
|
|
|
|
|
|
if (svwks_csb_check(dev)) {
|
|
|
|
u16 csb_pio = 0;
|
|
|
|
|
|
|
|
pci_read_config_word(dev, 0x4a, &csb_pio);
|
|
|
|
|
|
|
|
csb_pio &= ~(0x0f << (4 * drive->dn));
|
|
|
|
csb_pio |= (pio << (4 * drive->dn));
|
|
|
|
|
|
|
|
pci_write_config_word(dev, 0x4a, csb_pio);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ide: move ide_config_drive_speed() calls to upper layers (take 2)
* Convert {ide_hwif_t,ide_pci_device_t}->host_flag to be u16.
* Add IDE_HFLAG_POST_SET_MODE host flag to indicate the need to program
the host for the transfer mode after programming the device. Set it
in au1xxx-ide, amd74xx, cs5530, cs5535, pdc202xx_new, sc1200, pmac
and via82cxxx host drivers.
* Add IDE_HFLAG_NO_SET_MODE host flag to indicate the need to completely
skip programming of host/device for the transfer mode ("smart" hosts).
Set it in it821x host driver and check it in ide_tune_dma().
* Add ide_set_pio_mode()/ide_set_dma_mode() helpers and convert all
direct ->set_pio_mode/->speedproc users to use these helpers.
* Move ide_config_drive_speed() calls from ->set_pio_mode/->speedproc
methods to callers.
* Rename ->speedproc method to ->set_dma_mode, make it void and update
all implementations accordingly.
* Update ide_set_xfer_rate() comments.
* Unexport ide_config_drive_speed().
v2:
* Fix issues noticed by Sergei:
- export ide_set_dma_mode() instead of moving ->set_pio_mode abuse wrt
to setting DMA modes from sc1200_set_pio_mode() to do_special()
- check IDE_HFLAG_NO_SET_MODE in ide_tune_dma()
- check for (hwif->set_pio_mode) == NULL in ide_set_pio_mode()
- check for (hwif->set_dma_mode) == NULL in ide_set_dma_mode()
- return -1 from ide_set_{pio,dma}_mode() if ->set_{pio,dma}_mode == NULL
- don't set ->set_{pio,dma}_mode on it821x in "smart" mode
- fix build problem in pmac.c
- minor fixes in au1xxx-ide.c/cs5530.c/siimage.c
- improve patch description
Changes in behavior caused by this patch:
- HDIO_SET_PIO_MODE ioctl would now return -ENOSYS for attempts to change
PIO mode if it821x controller is in "smart" mode
- removal of two debugging printk-s (from cs5530.c and sc1200.c)
- transfer modes 0x00-0x07 passed from user space may be programmed twice on
the device (not really an issue since 0x00 is not supported correctly by
any host driver ATM, 0x01 is not supported at all and 0x02-0x07 are invalid)
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2007-10-13 23:47:51 +08:00
|
|
|
static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-06-28 19:27:02 +08:00
|
|
|
static const u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
|
|
|
|
static const u8 dma_modes[] = { 0x77, 0x21, 0x20 };
|
|
|
|
static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 };
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ide_hwif_t *hwif = HWIF(drive);
|
2008-02-02 06:09:31 +08:00
|
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
2008-10-14 03:39:40 +08:00
|
|
|
u8 unit = drive->dn & 1;
|
2007-07-20 07:11:56 +08:00
|
|
|
|
|
|
|
u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_read_config_byte(dev, (0x56|hwif->channel), &ultra_timing);
|
|
|
|
pci_read_config_byte(dev, 0x54, &ultra_enable);
|
|
|
|
|
|
|
|
ultra_timing &= ~(0x0F << (4*unit));
|
|
|
|
ultra_enable &= ~(0x01 << drive->dn);
|
|
|
|
|
2008-01-27 03:12:59 +08:00
|
|
|
if (speed >= XFER_UDMA_0) {
|
|
|
|
dma_timing |= dma_modes[2];
|
|
|
|
ultra_timing |= (udma_modes[speed - XFER_UDMA_0] << (4 * unit));
|
|
|
|
ultra_enable |= (0x01 << drive->dn);
|
|
|
|
} else if (speed >= XFER_MW_DMA_0)
|
|
|
|
dma_timing |= dma_modes[speed - XFER_MW_DMA_0];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
pci_write_config_byte(dev, drive_pci2[drive->dn], dma_timing);
|
|
|
|
pci_write_config_byte(dev, (0x56|hwif->channel), ultra_timing);
|
|
|
|
pci_write_config_byte(dev, 0x54, ultra_enable);
|
|
|
|
}
|
|
|
|
|
2008-10-11 04:39:32 +08:00
|
|
|
static unsigned int init_chipset_svwks(struct pci_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned int reg;
|
|
|
|
u8 btr;
|
|
|
|
|
|
|
|
/* force Master Latency Timer value to 64 PCICLKs */
|
|
|
|
pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40);
|
|
|
|
|
|
|
|
/* OSB4 : South Bridge and IDE */
|
|
|
|
if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
|
2006-10-01 14:27:29 +08:00
|
|
|
isa_dev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
|
2005-04-17 06:20:36 +08:00
|
|
|
PCI_DEVICE_ID_SERVERWORKS_OSB4, NULL);
|
|
|
|
if (isa_dev) {
|
|
|
|
pci_read_config_dword(isa_dev, 0x64, ®);
|
|
|
|
reg &= ~0x00002000; /* disable 600ns interrupt mask */
|
|
|
|
if(!(reg & 0x00004000))
|
2008-07-25 04:53:33 +08:00
|
|
|
printk(KERN_DEBUG DRV_NAME " %s: UDMA not BIOS "
|
|
|
|
"enabled.\n", pci_name(dev));
|
2005-04-17 06:20:36 +08:00
|
|
|
reg |= 0x00004000; /* enable UDMA/33 support */
|
|
|
|
pci_write_config_dword(isa_dev, 0x64, reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup CSB5/CSB6 : South Bridge and IDE option RAID */
|
|
|
|
else if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||
|
|
|
|
(dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
|
|
|
|
(dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) {
|
|
|
|
|
|
|
|
/* Third Channel Test */
|
|
|
|
if (!(PCI_FUNC(dev->devfn) & 1)) {
|
|
|
|
struct pci_dev * findev = NULL;
|
|
|
|
u32 reg4c = 0;
|
2006-10-01 14:27:29 +08:00
|
|
|
findev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
|
2005-04-17 06:20:36 +08:00
|
|
|
PCI_DEVICE_ID_SERVERWORKS_CSB5, NULL);
|
|
|
|
if (findev) {
|
|
|
|
pci_read_config_dword(findev, 0x4C, ®4c);
|
|
|
|
reg4c &= ~0x000007FF;
|
|
|
|
reg4c |= 0x00000040;
|
|
|
|
reg4c |= 0x00000020;
|
|
|
|
pci_write_config_dword(findev, 0x4C, reg4c);
|
2006-10-01 14:27:29 +08:00
|
|
|
pci_dev_put(findev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
outb_p(0x06, 0x0c00);
|
|
|
|
dev->irq = inb_p(0x0c01);
|
|
|
|
} else {
|
|
|
|
struct pci_dev * findev = NULL;
|
|
|
|
u8 reg41 = 0;
|
|
|
|
|
2006-10-01 14:27:29 +08:00
|
|
|
findev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
|
2005-04-17 06:20:36 +08:00
|
|
|
PCI_DEVICE_ID_SERVERWORKS_CSB6, NULL);
|
|
|
|
if (findev) {
|
|
|
|
pci_read_config_byte(findev, 0x41, ®41);
|
|
|
|
reg41 &= ~0x40;
|
|
|
|
pci_write_config_byte(findev, 0x41, reg41);
|
2006-10-01 14:27:29 +08:00
|
|
|
pci_dev_put(findev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* This is a device pin issue on CSB6.
|
|
|
|
* Since there will be a future raid mode,
|
|
|
|
* early versions of the chipset require the
|
|
|
|
* interrupt pin to be set, and it is a compatibility
|
|
|
|
* mode issue.
|
|
|
|
*/
|
|
|
|
if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE)
|
|
|
|
dev->irq = 0;
|
|
|
|
}
|
|
|
|
// pci_read_config_dword(dev, 0x40, &pioreg)
|
|
|
|
// pci_write_config_dword(dev, 0x40, 0x99999999);
|
|
|
|
// pci_read_config_dword(dev, 0x44, &dmareg);
|
|
|
|
// pci_write_config_dword(dev, 0x44, 0xFFFFFFFF);
|
|
|
|
/* setup the UDMA Control register
|
|
|
|
*
|
|
|
|
* 1. clear bit 6 to enable DMA
|
|
|
|
* 2. enable DMA modes with bits 0-1
|
|
|
|
* 00 : legacy
|
|
|
|
* 01 : udma2
|
|
|
|
* 10 : udma2/udma4
|
|
|
|
* 11 : udma2/udma4/udma5
|
|
|
|
*/
|
|
|
|
pci_read_config_byte(dev, 0x5A, &btr);
|
|
|
|
btr &= ~0x40;
|
|
|
|
if (!(PCI_FUNC(dev->devfn) & 1))
|
|
|
|
btr |= 0x2;
|
|
|
|
else
|
2007-06-09 06:46:36 +08:00
|
|
|
btr |= (dev->revision >= SVWKS_CSB5_REVISION_NEW) ? 0x3 : 0x2;
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_write_config_byte(dev, 0x5A, btr);
|
|
|
|
}
|
2005-08-19 04:30:35 +08:00
|
|
|
/* Setup HT1000 SouthBridge Controller - Single Channel Only */
|
|
|
|
else if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) {
|
|
|
|
pci_read_config_byte(dev, 0x5A, &btr);
|
|
|
|
btr &= ~0x40;
|
|
|
|
btr |= 0x3;
|
|
|
|
pci_write_config_byte(dev, 0x5A, btr);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-06-28 19:27:02 +08:00
|
|
|
return dev->irq;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-08-06 00:17:04 +08:00
|
|
|
static u8 ata66_svwks_svwks(ide_hwif_t *hwif)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-10 05:17:58 +08:00
|
|
|
return ATA_CBL_PATA80;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* On Dell PowerEdge servers with a CSB5/CSB6, the top two bits
|
|
|
|
* of the subsystem device ID indicate presence of an 80-pin cable.
|
|
|
|
* Bit 15 clear = secondary IDE channel does not have 80-pin cable.
|
|
|
|
* Bit 15 set = secondary IDE channel has 80-pin cable.
|
|
|
|
* Bit 14 clear = primary IDE channel does not have 80-pin cable.
|
|
|
|
* Bit 14 set = primary IDE channel has 80-pin cable.
|
|
|
|
*/
|
2008-08-06 00:17:04 +08:00
|
|
|
static u8 ata66_svwks_dell(ide_hwif_t *hwif)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-02 06:09:31 +08:00
|
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL &&
|
|
|
|
dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
|
|
|
|
(dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ||
|
|
|
|
dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE))
|
|
|
|
return ((1 << (hwif->channel + 14)) &
|
2007-07-10 05:17:58 +08:00
|
|
|
dev->subsystem_device) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
|
|
|
|
return ATA_CBL_PATA40;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sun Cobalt Alpine hardware avoids the 80-pin cable
|
|
|
|
* detect issue by attaching the drives directly to the board.
|
|
|
|
* This check follows the Dell precedent (how scary is that?!)
|
|
|
|
*
|
|
|
|
* WARNING: this only works on Alpine hardware!
|
|
|
|
*/
|
2008-08-06 00:17:04 +08:00
|
|
|
static u8 ata66_svwks_cobalt(ide_hwif_t *hwif)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-02 06:09:31 +08:00
|
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN &&
|
|
|
|
dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
|
|
|
|
dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
|
|
|
|
return ((1 << (hwif->channel + 14)) &
|
2007-07-10 05:17:58 +08:00
|
|
|
dev->subsystem_device) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
|
|
|
|
return ATA_CBL_PATA40;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-08-06 00:17:04 +08:00
|
|
|
static u8 svwks_cable_detect(ide_hwif_t *hwif)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-02 06:09:31 +08:00
|
|
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Server Works */
|
|
|
|
if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS)
|
|
|
|
return ata66_svwks_svwks (hwif);
|
|
|
|
|
|
|
|
/* Dell PowerEdge */
|
|
|
|
if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL)
|
|
|
|
return ata66_svwks_dell (hwif);
|
|
|
|
|
|
|
|
/* Cobalt Alpine */
|
|
|
|
if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN)
|
|
|
|
return ata66_svwks_cobalt (hwif);
|
|
|
|
|
2006-06-28 19:27:02 +08:00
|
|
|
/* Per Specified Design by OEM, and ASIC Architect */
|
|
|
|
if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
|
|
|
|
(dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
|
2007-07-10 05:17:58 +08:00
|
|
|
return ATA_CBL_PATA80;
|
2006-06-28 19:27:02 +08:00
|
|
|
|
2007-07-10 05:17:58 +08:00
|
|
|
return ATA_CBL_PATA40;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-04-27 04:25:14 +08:00
|
|
|
static const struct ide_port_ops osb4_port_ops = {
|
|
|
|
.set_pio_mode = svwks_set_pio_mode,
|
|
|
|
.set_dma_mode = svwks_set_dma_mode,
|
|
|
|
.udma_filter = svwks_udma_filter,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-27 04:25:14 +08:00
|
|
|
static const struct ide_port_ops svwks_port_ops = {
|
|
|
|
.set_pio_mode = svwks_set_pio_mode,
|
|
|
|
.set_dma_mode = svwks_set_dma_mode,
|
|
|
|
.udma_filter = svwks_udma_filter,
|
|
|
|
.cable_detect = svwks_cable_detect,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-24 01:55:56 +08:00
|
|
|
#define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS
|
2008-01-26 05:17:18 +08:00
|
|
|
|
2007-10-20 06:32:34 +08:00
|
|
|
static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
|
2008-07-25 04:53:32 +08:00
|
|
|
{ /* 0: OSB4 */
|
|
|
|
.name = DRV_NAME,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init_chipset = init_chipset_svwks,
|
2008-04-27 04:25:14 +08:00
|
|
|
.port_ops = &osb4_port_ops,
|
2008-01-26 05:17:18 +08:00
|
|
|
.host_flags = IDE_HFLAGS_SVWKS,
|
2007-07-20 07:11:59 +08:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-10-19 06:30:07 +08:00
|
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
|
|
.udma_mask = 0x00, /* UDMA is problematic on OSB4 */
|
2008-07-25 04:53:32 +08:00
|
|
|
},
|
|
|
|
{ /* 1: CSB5 */
|
|
|
|
.name = DRV_NAME,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init_chipset = init_chipset_svwks,
|
2008-04-27 04:25:14 +08:00
|
|
|
.port_ops = &svwks_port_ops,
|
2008-01-26 05:17:18 +08:00
|
|
|
.host_flags = IDE_HFLAGS_SVWKS,
|
2007-07-20 07:11:59 +08:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-10-19 06:30:07 +08:00
|
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
|
|
.udma_mask = ATA_UDMA5,
|
2008-07-25 04:53:32 +08:00
|
|
|
},
|
|
|
|
{ /* 2: CSB6 */
|
|
|
|
.name = DRV_NAME,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init_chipset = init_chipset_svwks,
|
2008-04-27 04:25:14 +08:00
|
|
|
.port_ops = &svwks_port_ops,
|
2008-01-26 05:17:18 +08:00
|
|
|
.host_flags = IDE_HFLAGS_SVWKS,
|
2007-07-20 07:11:59 +08:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-10-19 06:30:07 +08:00
|
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
|
|
.udma_mask = ATA_UDMA5,
|
2008-07-25 04:53:32 +08:00
|
|
|
},
|
|
|
|
{ /* 3: CSB6-2 */
|
|
|
|
.name = DRV_NAME,
|
2005-04-17 06:20:36 +08:00
|
|
|
.init_chipset = init_chipset_svwks,
|
2008-04-27 04:25:14 +08:00
|
|
|
.port_ops = &svwks_port_ops,
|
2008-01-26 05:17:18 +08:00
|
|
|
.host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE,
|
2007-07-20 07:11:59 +08:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-10-19 06:30:07 +08:00
|
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
|
|
.udma_mask = ATA_UDMA5,
|
2008-07-25 04:53:32 +08:00
|
|
|
},
|
|
|
|
{ /* 4: HT1000 */
|
|
|
|
.name = DRV_NAME,
|
2005-08-19 04:30:35 +08:00
|
|
|
.init_chipset = init_chipset_svwks,
|
2008-04-27 04:25:14 +08:00
|
|
|
.port_ops = &svwks_port_ops,
|
2008-01-26 05:17:18 +08:00
|
|
|
.host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE,
|
2007-07-20 07:11:59 +08:00
|
|
|
.pio_mask = ATA_PIO4,
|
2007-10-19 06:30:07 +08:00
|
|
|
.mwdma_mask = ATA_MWDMA2,
|
|
|
|
.udma_mask = ATA_UDMA5,
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* svwks_init_one - called when a OSB/CSB is found
|
|
|
|
* @dev: the svwks device
|
|
|
|
* @id: the matching pci id
|
|
|
|
*
|
|
|
|
* Called when the PCI registration layer (or the IDE initialization)
|
|
|
|
* finds a device matching our IDE device tables.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
|
|
|
{
|
2007-10-20 06:32:34 +08:00
|
|
|
struct ide_port_info d;
|
2007-10-19 06:30:09 +08:00
|
|
|
u8 idx = id->driver_data;
|
|
|
|
|
|
|
|
d = serverworks_chipsets[idx];
|
|
|
|
|
2008-02-02 06:09:30 +08:00
|
|
|
if (idx == 1)
|
|
|
|
d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;
|
|
|
|
else if (idx == 2 || idx == 3) {
|
2007-10-19 06:30:09 +08:00
|
|
|
if ((PCI_FUNC(dev->devfn) & 1) == 0) {
|
|
|
|
if (pci_resource_start(dev, 0) != 0x01f1)
|
2008-04-26 23:36:35 +08:00
|
|
|
d.host_flags |= IDE_HFLAG_NON_BOOTABLE;
|
2007-10-19 06:30:09 +08:00
|
|
|
d.host_flags |= IDE_HFLAG_SINGLE;
|
|
|
|
} else
|
|
|
|
d.host_flags &= ~IDE_HFLAG_SINGLE;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-25 04:53:14 +08:00
|
|
|
return ide_pci_init_one(dev, &d, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-10-17 04:29:56 +08:00
|
|
|
static const struct pci_device_id svwks_pci_tbl[] = {
|
|
|
|
{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE), 0 },
|
|
|
|
{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE), 1 },
|
|
|
|
{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE), 2 },
|
|
|
|
{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2), 3 },
|
|
|
|
{ PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE), 4 },
|
2005-04-17 06:20:36 +08:00
|
|
|
{ 0, },
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, svwks_pci_tbl);
|
|
|
|
|
|
|
|
static struct pci_driver driver = {
|
|
|
|
.name = "Serverworks_IDE",
|
|
|
|
.id_table = svwks_pci_tbl,
|
|
|
|
.probe = svwks_init_one,
|
2008-07-25 04:53:25 +08:00
|
|
|
.remove = ide_pci_remove,
|
2008-10-11 04:39:32 +08:00
|
|
|
.suspend = ide_pci_suspend,
|
|
|
|
.resume = ide_pci_resume,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2007-01-27 20:46:56 +08:00
|
|
|
static int __init svwks_ide_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return ide_pci_register_driver(&driver);
|
|
|
|
}
|
|
|
|
|
2008-07-25 04:53:25 +08:00
|
|
|
static void __exit svwks_ide_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&driver);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
module_init(svwks_ide_init);
|
2008-07-25 04:53:25 +08:00
|
|
|
module_exit(svwks_ide_exit);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick");
|
|
|
|
MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE");
|
|
|
|
MODULE_LICENSE("GPL");
|