- Apply host chip driver cleanups by Bartomiej Zonierkiewicz.
- Take the draft device type driver implementation from Adam Richter and make
it actually work with some of the drivers we have at hand. Quite a lot
of it was fixed by me as well to have the desired effects.
We have added a attach method for the sub device type drivers to make it
possible dor sub device type drivers to attach devices to the overall
infrastructure. UNIX has something like this SCSI code is implementing
something like this, just for some unknown reasons Linux block device
operations don't have it...
- ide_drive_t is finally gone. Please use struct ata_device instead.
Hint the ide.h specific byte type should go over time as well, sine there
is no need to invent something already handled by the kernel. Please use
the unambigious u8 type instead where possible.
- Add a bit of documentation about cabling issues. ide.txt needs a lot of
improvement at some time still.
***
*** Use of the "serialize" option is no longer necessary.
-This is the multiple IDE interface driver, as evolved from hd.c. It supports
-up to 9 IDE interfaces per default, on one or more IRQs (usually 14 & 15).
-There can be up to two drives per interface, as per the ATA-6 spec.
+================================================================================
+Common pitfalls:
+
+- 40-conductor IDE cables are capable of transfering data in DMA modes up to
+ udma2, but no faster.
+
+- If possible devices should be attached to separate channels if they are
+ available. Typically the disk on the first and CD-ROM on the second.
+
+- If you mix devices on the same cable, please consider using similar devices
+ in respect of the data transfer mode they support.
+
+- Even better tru to stick to the same vendor and device type on the same
+ cable.
+
+================================================================================
+
+This is the multiple IDE interface driver, as evolved from hd.c.
+
+It supports up to 9 IDE interfaces per default, on one or more IRQs (usually
+14 & 15). There can be up to two drives per interface, as per the ATA-6 spec.
Primary: ide0, port 0x1f0; major=3; hda is minor=0; hdb is minor=64
Secondary: ide1, port 0x170; major=22; hdc is minor=0; hdd is minor=64
#define ATA_PIO0_HOLD 4
static int e100_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq);
-static void e100_ideproc (ide_ide_action_t func, ide_drive_t *drive,
+static void e100_ideproc (ide_ide_action_t func, struct ata_device *drive,
void *buffer, unsigned int length);
/*
"CONNER CTT8000-A",
NULL};
-static void tune_e100_ide(ide_drive_t *drive, byte pio)
+static void tune_e100_ide(struct ata_device *drive, byte pio)
{
unsigned long flags;
* extra byte allocated for the buffer.
*/
static void
-e100_atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount)
+e100_atapi_read(struct ata_device *drive, void *buffer, unsigned int bytecount)
{
ide_ioreg_t data_reg = IDE_DATA_REG;
}
static void
-e100_atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount)
+e100_atapi_write(struct ata_device *drive, void *buffer, unsigned int bytecount)
{
ide_ioreg_t data_reg = IDE_DATA_REG;
* This is used for most PIO data transfers *from* the IDE interface
*/
static void
-e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+e100_ide_input_data (struct ata_device *drive, void *buffer, unsigned int wcount)
{
e100_atapi_read(drive, buffer, wcount << 2);
}
* This is used for most PIO data transfers *to* the IDE interface
*/
static void
-e100_ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
+e100_ide_output_data (struct ata_device *drive, void *buffer, unsigned int wcount)
{
e100_atapi_write(drive, buffer, wcount << 2);
}
return 1; /* let the PIO routines handle this weirdness */
}
-static int config_drive_for_dma (ide_drive_t *drive)
+static int config_drive_for_dma (struct ata_device *drive)
{
const char **list;
struct hd_driveid *id = drive->id;
bool ' IGNORE word93 Validation BITS' CONFIG_IDEDMA_IVB
fi
- if [ "$CONFIG_BLK_DEV_IDECD" != "n" -o \
- "$CONFIG_BLK_DEV_IDETAPE" != "n" -o \
- "$CONFIG_BLK_DEV_IDEFLOPPY" != "n" -o \
- "$CONFIG_BLK_DEV_IDESCSI" != "n" ]; then
- define_bool CONFIG_ATAPI y
- fi
+ define_bool CONFIG_ATAPI y
else
bool 'Old hard disk (MFM/RLL/IDE) driver' CONFIG_BLK_DEV_HD_ONLY
define_bool CONFIG_BLK_DEV_HD $CONFIG_BLK_DEV_HD_ONLY
obj-$(CONFIG_BLK_DEV_IDE) += ide-mod.o
obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o
obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o
-obj-$(CONFIG_ATAPI) += atapi.o
+# obj-$(CONFIG_ATAPI) += atapi.o
obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o
obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o
obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o
obj-$(CONFIG_BLK_DEV_ATARAID_PDC) += pdcraid.o
obj-$(CONFIG_BLK_DEV_ATARAID_HPT) += hptraid.o
-ide-mod-objs := ide-taskfile.o ide.o ide-probe.o ide-geometry.o ide-features.o ata-timing.o $(ide-obj-y)
+ide-mod-objs := ide-taskfile.o ide.o ide-probe.o ide-geometry.o ide-features.o ata-timing.o atapi.o $(ide-obj-y)
include $(TOPDIR)/Rules.make
enablebits: { {0x00,0x00,0x00}, {0x00,0x00,0x00} },
bootable: OFF_BOARD,
flags: ATA_F_IRQ | ATA_F_DMA
- },
- {
- vendor: PCI_VENDOR_ID_ARTOP,
- device: PCI_DEVICE_ID_ARTOP_ATP865,
- init_chipset: aec62xx_init_chipset,
- ata66_check: aec62xx_ata66_check,
- init_channel: aec62xx_init_channel,
- enablebits: { {0x00,0x00,0x00}, {0x00,0x00,0x00} },
- bootable: NEVER_BOARD,
- flags: ATA_F_IRQ | ATA_F_NOADMA | ATA_F_DMA
- },
- {
- vendor: PCI_VENDOR_ID_ARTOP,
- device: PCI_DEVICE_ID_ARTOP_ATP865R,
- init_chipset: aec62xx_init_chipset,
- ata66_check: aec62xx_ata66_check,
- init_channel: aec62xx_init_channel,
- enablebits: { {0x4a,0x02,0x02}, {0x4a,0x04,0x04} },
- bootable: OFF_BOARD,
- flags: ATA_F_IRQ | ATA_F_DMA
- },
+ }
};
int __init init_aec62xx(void)
* by upper layers.
*/
-static int amd_set_drive(ide_drive_t *drive, unsigned char speed)
+static int amd_set_drive(struct ata_device *drive, unsigned char speed)
{
- ide_drive_t *peer = drive->channel->drives + (~drive->dn & 1);
+ struct ata_device *peer = drive->channel->drives + (~drive->dn & 1);
struct ata_timing t, p;
int T, UT;
* PIO-only tuning.
*/
-static void amd74xx_tune_drive(ide_drive_t *drive, unsigned char pio)
+static void amd74xx_tune_drive(struct ata_device *drive, u8 pio)
{
if (!((amd_enabled >> drive->channel->unit) & 1))
return;
/*
* Set a new transfer mode at the drive
*/
-int cs5530_set_xfer_mode (ide_drive_t *drive, byte mode)
+int cs5530_set_xfer_mode(struct ata_device *drive, byte mode)
{
int error = 0;
* The ide_init_cs5530() routine guarantees that all drives
* will have valid default PIO timings set up before we get here.
*/
-static void cs5530_tuneproc (ide_drive_t *drive, byte pio) /* pio=255 means "autotune" */
+static void cs5530_tuneproc(struct ata_device *drive, byte pio) /* pio=255 means "autotune" */
{
struct ata_channel *hwif = drive->channel;
unsigned int format, basereg = CS5530_BASEREG(hwif);
* cs5530_config_dma() handles selection/setting of DMA/UDMA modes
* for both the chipset and drive.
*/
-static int cs5530_config_dma (ide_drive_t *drive)
+static int cs5530_config_dma(struct ata_device *drive)
{
int udma_ok = 1, mode = 0;
struct ata_channel *hwif = drive->channel;
int unit = drive->select.b.unit;
- ide_drive_t *mate = &hwif->drives[unit^1];
+ struct ata_device *mate = &hwif->drives[unit^1];
struct hd_driveid *id = drive->id;
unsigned int basereg, reg, timings;
/*
* set DMA mode a specific channel for CY82C693
*/
-static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
+static void cy82c693_dma_enable(struct ata_device *drive, int mode, int single)
{
byte index;
byte data;
/*
* tune ide drive - set PIO mode
*/
-static void cy82c693_tune_drive (ide_drive_t *drive, byte pio)
+static void cy82c693_tune_drive(struct ata_device *drive, byte pio)
{
struct ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev;
}
}
-static void tune_dtc2278 (ide_drive_t *drive, byte pio)
+static void tune_dtc2278(struct ata_device *drive, byte pio)
{
unsigned long flags;
byte hpt34x_proc = 0;
-extern char *ide_xfer_verbose (byte xfer_rate);
+extern char *ide_xfer_verbose(byte xfer_rate);
-static void hpt34x_clear_chipset (ide_drive_t *drive)
+static void hpt34x_clear_chipset(struct ata_device *drive)
{
unsigned int reg1 = 0, tmp1 = 0;
unsigned int reg2 = 0, tmp2 = 0;
pci_write_config_dword(drive->channel->pci_dev, 0x48, tmp2);
}
-static int hpt34x_tune_chipset (ide_drive_t *drive, byte speed)
+static int hpt34x_tune_chipset(struct ata_device *drive, byte speed)
{
byte hi_speed, lo_speed;
unsigned int reg1 = 0, tmp1 = 0;
return ide_config_drive_speed(drive, speed);
}
-static void config_chipset_for_pio(ide_drive_t *drive)
+static void config_chipset_for_pio(struct ata_device *drive)
{
unsigned short eide_pio_timing[6] = {960, 480, 240, 180, 120, 90};
unsigned short xfer_pio = drive->id->eide_pio_modes;
(void) hpt34x_tune_chipset(drive, speed);
}
-static void hpt34x_tune_drive (ide_drive_t *drive, byte pio)
+static void hpt34x_tune_drive(struct ata_device *drive, byte pio)
{
byte speed;
#endif
#define HPT366_DEBUG_DRIVE_INFO 0
+#define HPT374_ALLOW_ATA133_6 0
+#define HPT372_ALLOW_ATA133_6 1
#define HPT370_ALLOW_ATA100_5 1
#define HPT366_ALLOW_ATA66_4 1
#define HPT366_ALLOW_ATA66_3 1
static struct pci_dev *hpt_devs[HPT366_MAX_DEVS];
static int n_hpt_devs;
-static unsigned int pci_rev_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev2_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev3_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev5_check_hpt3xx(struct pci_dev *dev);
-static unsigned int pci_rev7_check_hpt3xx(struct pci_dev *dev);
-
static u8 hpt366_proc = 0;
-extern char *ide_xfer_verbose(u8 xfer_rate);
+
+static unsigned int hpt_min_rev(struct pci_dev *dev, int rev);
#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
static int hpt366_get_info(char *, char **, off_t, int);
(c0 & 0x80) ? "no" : "yes",
(c1 & 0x80) ? "no" : "yes");
- if (pci_rev3_check_hpt3xx(dev)) {
+ if (hpt_min_rev(dev, 3)) {
u8 cbl;
cbl = inb_p(iobase + 0x7b);
outb_p(cbl | 1, iobase + 0x7b);
}
#endif /* defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) */
-/*
- * fixme: it really needs to be a switch.
- */
-
-static unsigned int pci_rev_check_hpt3xx (struct pci_dev *dev)
-{
- unsigned int class_rev;
- pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
- class_rev &= 0xff;
- return ((int) (class_rev > 0x02) ? 1 : 0);
-}
-
-static unsigned int pci_rev2_check_hpt3xx (struct pci_dev *dev)
-{
- unsigned int class_rev;
- pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
- class_rev &= 0xff;
- return ((int) (class_rev > 0x01) ? 1 : 0);
-}
-
-static unsigned int pci_rev3_check_hpt3xx (struct pci_dev *dev)
-{
- unsigned int class_rev;
- pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
- class_rev &= 0xff;
- return ((int) (class_rev > 0x02) ? 1 : 0);
-}
-
-static unsigned int pci_rev5_check_hpt3xx (struct pci_dev *dev)
-{
- unsigned int class_rev;
- pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
- class_rev &= 0xff;
- return ((int) (class_rev > 0x04) ? 1 : 0);
-}
-
-static unsigned int pci_rev7_check_hpt3xx (struct pci_dev *dev)
-{
- unsigned int class_rev;
- pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
- class_rev &= 0xff;
- return ((int) (class_rev > 0x06) ? 1 : 0);
-}
-
static int check_in_drive_lists(struct ata_device *drive, const char **list)
{
struct hd_driveid *id = drive->id;
return 0;
}
+static unsigned int hpt_revision(struct pci_dev *dev)
+{
+ unsigned int class_rev;
+ pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
+ class_rev &= 0xff;
+
+ switch(dev->device) {
+ case PCI_DEVICE_ID_TTI_HPT374:
+ class_rev = PCI_DEVICE_ID_TTI_HPT374; break;
+ case PCI_DEVICE_ID_TTI_HPT372:
+ class_rev = PCI_DEVICE_ID_TTI_HPT372; break;
+ default:
+ break;
+ }
+ return class_rev;
+}
+
+static unsigned int hpt_min_rev(struct pci_dev *dev, int rev)
+{
+ return (hpt_revision(dev) >= rev) ? 1 : 0;
+}
+
+static int hpt3xx_ratemask(struct ata_device *drive)
+{
+ struct pci_dev *dev = drive->channel->pci_dev;
+ int map = XFER_UDMA;
+
+ if (hpt_min_rev(dev, 8)) { /* HPT374 */
+ if (HPT374_ALLOW_ATA133_6)
+ map |= XFER_UDMA_133;
+ map |= (XFER_UDMA_100 | XFER_UDMA_66);
+ } else if (hpt_min_rev(dev, 5)) { /* HPT372 */
+ if (HPT372_ALLOW_ATA133_6)
+ map |= XFER_UDMA_133;
+ map |= (XFER_UDMA_100 | XFER_UDMA_66);
+ } else if (hpt_min_rev(dev, 4)) { /* HPT370A */
+ if (HPT370_ALLOW_ATA100_5)
+ map |= XFER_UDMA_100;
+ map |= XFER_UDMA_66;
+ } else if (hpt_min_rev(dev, 3)) { /* HPT370 */
+ if (HPT370_ALLOW_ATA100_5)
+ map |= XFER_UDMA_100;
+ map |= XFER_UDMA_66;
+ if (check_in_drive_lists(drive, bad_ata33))
+ return 0;
+ } else { /* HPT366 and HPT368 */
+ map |= XFER_UDMA_66;
+ if (check_in_drive_lists(drive, bad_ata33))
+ return 0;
+ }
+
+ if (!eighty_ninty_three(drive))
+ return XFER_UDMA;
+
+ return map;
+}
+
+
static unsigned int pci_bus_clock_list(byte speed, struct chipset_bus_clock_list_entry * chipset_table)
{
for ( ; chipset_table->xfer_speed ; chipset_table++)
static int hpt3xx_tune_chipset(struct ata_device *drive, byte speed)
{
+ struct pci_dev *dev = drive->channel->pci_dev;
+
if ((drive->type != ATA_DISK) && (speed < XFER_SW_DMA_0))
return -1;
if (!drive->init_speed)
drive->init_speed = speed;
- if (pci_rev7_check_hpt3xx(drive->channel->pci_dev)) {
+ if (hpt_min_rev(dev, 7)) {
hpt374_tune_chipset(drive, speed);
- } else if (pci_rev5_check_hpt3xx(drive->channel->pci_dev)) {
+ } else if (hpt_min_rev(dev, 5)) {
hpt372_tune_chipset(drive, speed);
- } else if (pci_rev3_check_hpt3xx(drive->channel->pci_dev)) {
+ } else if (hpt_min_rev(dev, 3)) {
hpt370_tune_chipset(drive, speed);
- } else if (pci_rev2_check_hpt3xx(drive->channel->pci_dev)) {
+ } else if (hpt_min_rev(dev, 2)) {
hpt368_tune_chipset(drive, speed);
} else {
hpt366_tune_chipset(drive, speed);
}
#ifdef CONFIG_BLK_DEV_IDEDMA
-/*
- * This allows the configuration of ide_pci chipset registers
- * for cards that learn about the drive's UDMA, DMA, PIO capabilities
- * after the drive is reported by the OS. Initally for designed for
- * HPT366 UDMA chipset by HighPoint|Triones Technologies, Inc.
- *
- * check_in_drive_lists(drive, bad_ata66_4)
- * check_in_drive_lists(drive, bad_ata66_3)
- * check_in_drive_lists(drive, bad_ata33)
- *
- */
static int config_chipset_for_dma(struct ata_device *drive)
{
- struct hd_driveid *id = drive->id;
- byte speed = 0x00;
- byte ultra66 = eighty_ninty_three(drive);
- int rval;
+ struct pci_dev *dev = drive->channel->pci_dev;
+ int map;
+ byte mode;
+ /* FIXME: remove this --bkz */
config_chipset_for_pio(drive);
- drive->init_speed = 0;
- if ((drive->type != ATA_DISK) && (speed < XFER_SW_DMA_0))
+ if (drive->type != ATA_DISK)
return 0;
- if ((id->dma_ultra & 0x0040) &&
- (pci_rev5_check_hpt3xx(drive->channel->pci_dev)) &&
- (ultra66)) {
- speed = XFER_UDMA_6;
- } else if ((id->dma_ultra & 0x0020) &&
- (!check_in_drive_lists(drive, bad_ata100_5)) &&
- (HPT370_ALLOW_ATA100_5) &&
- (pci_rev_check_hpt3xx(drive->channel->pci_dev)) &&
- (pci_rev3_check_hpt3xx(drive->channel->pci_dev)) &&
- (ultra66)) {
- speed = XFER_UDMA_5;
- } else if ((id->dma_ultra & 0x0010) &&
- (!check_in_drive_lists(drive, bad_ata66_4)) &&
- (HPT366_ALLOW_ATA66_4) &&
- (ultra66)) {
- speed = XFER_UDMA_4;
- } else if ((id->dma_ultra & 0x0008) &&
- (!check_in_drive_lists(drive, bad_ata66_3)) &&
- (HPT366_ALLOW_ATA66_3) &&
- (ultra66)) {
- speed = XFER_UDMA_3;
- } else if (id->dma_ultra && (!check_in_drive_lists(drive, bad_ata33))) {
- if (id->dma_ultra & 0x0004) {
- speed = XFER_UDMA_2;
- } else if (id->dma_ultra & 0x0002) {
- speed = XFER_UDMA_1;
- } else if (id->dma_ultra & 0x0001) {
- speed = XFER_UDMA_0;
+ /* FIXME: check SWDMA modes --bkz */
+ map = hpt3xx_ratemask(drive) | XFER_MWDMA;
+ mode = ata_timing_mode(drive, map);
+
+ /* FIXME: badlists need futher investigation --bkz
+ bad_ata100_5 is for HPT370/370A,
+ bad_ata66_4, bad_ata66_3 and bad_ata33 are for HPT366/368
+ */
+ if (mode == XFER_UDMA_5 && hpt_min_rev(dev, 5)) {
+ if (check_in_drive_lists(drive, bad_ata100_5)) {
+ /* FIXME: make XFER_UDMA_66/100/133
+ independent of XFER_UDMA --bkz */
+ map &= ~XFER_UDMA_100;
+ map |= XFER_UDMA;
+ mode = ata_timing_mode(drive, map);
}
- } else if (id->dma_mword & 0x0004) {
- speed = XFER_MW_DMA_2;
- } else if (id->dma_mword & 0x0002) {
- speed = XFER_MW_DMA_1;
- } else if (id->dma_mword & 0x0001) {
- speed = XFER_MW_DMA_0;
- } else {
- return 0;
}
+ if (mode == XFER_UDMA_4 && hpt_min_rev(dev, 3)) {
+ if (check_in_drive_lists(drive, bad_ata66_4)) {
+ if (drive->id->dma_ultra & 0x0008) {
+ mode = XFER_UDMA_3;
+ } else {
+ map &= ~XFER_UDMA_66;
+ map |= XFER_UDMA;
+ mode = ata_timing_mode(drive, map);
+ }
+ }
+ }
+ if (mode == XFER_UDMA_3 && hpt_min_rev(dev, 3)) {
+ if (check_in_drive_lists(drive, bad_ata66_3)) {
+ map &= ~XFER_UDMA_66;
+ map |= XFER_UDMA;
+ mode = ata_timing_mode(drive, map);
+ }
+ }
+ if (check_in_drive_lists(drive, bad_ata33) && hpt_min_rev(dev, 3))
+ mode = ata_timing_mode(drive, XFER_MWDMA);
- (void) hpt3xx_tune_chipset(drive, speed);
-
- rval = (int)( ((id->dma_ultra >> 14) & 3) ? 1 :
- ((id->dma_ultra >> 11) & 7) ? 1 :
- ((id->dma_ultra >> 8) & 7) ? 1 :
- ((id->dma_mword >> 8) & 7) ? 1 :
- 0);
- return rval;
+ return !hpt3xx_tune_chipset(drive, mode);
}
static int hpt3xx_quirkproc(struct ata_device *drive)
struct pci_dev *dev = drive->channel->pci_dev;
if (drive->quirk_list) {
- if (pci_rev3_check_hpt3xx(dev)) {
+ if (hpt_min_rev(dev, 3)) {
byte reg5a = 0;
pci_read_config_byte(dev, 0x5a, ®5a);
if (((reg5a & 0x10) >> 4) != mask)
freq &= 0x1FF;
if (freq < 0x9c) {
pll = F_LOW_PCI_33;
- if (pci_rev7_check_hpt3xx(dev)) {
+ if (hpt_min_rev(dev, 7)) {
dev->sysdata = (void *) thirty_three_base_hpt374;
- } else if (pci_rev5_check_hpt3xx(dev)) {
- dev->sysdata = (void *) thirty_three_base_hpt372;
- } else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+ } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) thirty_three_base_hpt372;
} else {
dev->sysdata = (void *) thirty_three_base_hpt370;
pll = F_LOW_PCI_40;
} else if (freq < 0xc8) {
pll = F_LOW_PCI_50;
- if (pci_rev7_check_hpt3xx(dev)) {
+ if (hpt_min_rev(dev, 7)) {
// dev->sysdata = (void *) fifty_base_hpt374;
BUG();
- } else if (pci_rev5_check_hpt3xx(dev)) {
- dev->sysdata = (void *) fifty_base_hpt372;
- } else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+ } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) fifty_base_hpt372;
} else {
dev->sysdata = (void *) fifty_base_hpt370;
printk("HPT37X: using 50MHz PCI clock\n");
} else {
pll = F_LOW_PCI_66;
- if (pci_rev7_check_hpt3xx(dev)) {
+ if (hpt_min_rev(dev, 7)) {
// dev->sysdata = (void *) sixty_six_base_hpt374;
BUG();
- } else if (pci_rev5_check_hpt3xx(dev)) {
- dev->sysdata = (void *) sixty_six_base_hpt372;
- } else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+ } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) sixty_six_base_hpt372;
} else {
dev->sysdata = (void *) sixty_six_base_hpt370;
pci_write_config_dword(dev, 0x5c,
pll & ~0x100);
pci_write_config_byte(dev, 0x5b, 0x21);
- if (pci_rev7_check_hpt3xx(dev)) {
+ if (hpt_min_rev(dev, 7)) {
// dev->sysdata = (void *) fifty_base_hpt374;
BUG();
- } else if (pci_rev5_check_hpt3xx(dev)) {
- dev->sysdata = (void *) fifty_base_hpt372;
- } else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+ } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) fifty_base_hpt372;
} else {
dev->sysdata = (void *) fifty_base_hpt370;
if (test != 0x08)
pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
- if (pci_rev3_check_hpt3xx(dev))
+ if (hpt_min_rev(dev, 3))
hpt37x_init(dev);
else
hpt366_init(dev);
static void __init hpt366_init_channel(struct ata_channel *ch)
{
+ struct pci_dev *dev = ch->pci_dev;
+
ch->tuneproc = hpt3xx_tune_drive;
ch->speedproc = hpt3xx_tune_chipset;
ch->quirkproc = hpt3xx_quirkproc;
#ifdef CONFIG_BLK_DEV_IDEDMA
if (ch->dma_base) {
- if (pci_rev3_check_hpt3xx(ch->pci_dev)) {
+ if (hpt_min_rev(dev, 3)) {
byte reg5ah = 0;
- pci_read_config_byte(ch->pci_dev, 0x5a, ®5ah);
+ pci_read_config_byte(dev, 0x5a, ®5ah);
if (reg5ah & 0x10) /* interrupt force enable */
- pci_write_config_byte(ch->pci_dev, 0x5a, reg5ah & ~0x10);
+ pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10);
/*
* set up ioctl for power status.
* note: power affects both
ch->resetproc = hpt3xx_reset;
ch->busproc = hpt370_busproc;
- if (pci_rev7_check_hpt3xx(ch->pci_dev)) {
- ch->udma_stop = hpt374_udma_stop;
- ch->XXX_udma = hpt374_dmaproc;
- } else if (pci_rev5_check_hpt3xx(ch->pci_dev)) {
+ if (hpt_min_rev(dev, 7)) {
ch->udma_stop = hpt374_udma_stop;
ch->XXX_udma = hpt374_dmaproc;
- } else if (ch->pci_dev->device == PCI_DEVICE_ID_TTI_HPT372) {
+ } else if (hpt_min_rev(dev, 5)) {
ch->udma_stop = hpt374_udma_stop;
ch->XXX_udma = hpt374_dmaproc;
- } else if (pci_rev3_check_hpt3xx(ch->pci_dev)) {
+ } else if (hpt_min_rev(dev, 3)) {
ch->udma_start = hpt370_udma_start;
ch->udma_stop = hpt370_udma_stop;
ch->udma_timeout = hpt370_udma_timeout;
ch->udma_irq_lost = hpt370_udma_irq_lost;
ch->XXX_udma = hpt370_dmaproc;
}
- } else if (pci_rev2_check_hpt3xx(ch->pci_dev)) {
+ } else if (hpt_min_rev(dev, 2)) {
ch->udma_irq_lost = hpt366_udma_irq_lost;
// ch->resetproc = hpt3xx_reset;
// ch->busproc = hpt3xx_tristate;
{
unsigned long lba = 0;
kdev_t dev;
- ide_drive_t *ideinfo;
-
+ struct ata_device *ideinfo;
+
dev = mk_kdev(major,minor);
ideinfo = get_info_ptr (dev);
if (ideinfo==NULL)
return 0;
-
-
+
+
/* first sector of the last cluster */
if (ideinfo->head==0)
return 0;
/*
* This routine is invoked from ide.c to prepare for access to a given drive.
*/
-static void ht6560b_selectproc (ide_drive_t *drive)
+static void ht6560b_selectproc(struct ata_device *drive)
{
unsigned long flags;
static byte current_select = 0;
return 1;
}
-static byte ht_pio2timings(ide_drive_t *drive, byte pio)
+static byte ht_pio2timings(struct ata_device *drive, byte pio)
{
int active_time, recovery_time;
int active_cycles, recovery_cycles;
/*
* Enable/Disable so called prefetch mode
*/
-static void ht_set_prefetch(ide_drive_t *drive, byte state)
+static void ht_set_prefetch(struct ata_device *drive, byte state)
{
unsigned long flags;
int t = HT_PREFETCH_MODE << 8;
#endif
}
-static void tune_ht6560b (ide_drive_t *drive, byte pio)
+static void tune_ht6560b(struct ata_device *drive, byte pio)
{
unsigned long flags;
byte timing;
return 0;
}
+static void ide_cdrom_attach(struct ata_device *drive);
+
static struct ata_operations ide_cdrom_driver = {
owner: THIS_MODULE,
+ attach: ide_cdrom_attach,
cleanup: ide_cdrom_cleanup,
standby: NULL,
do_request: ide_cdrom_do_request,
/* options */
static char *ignore = NULL;
+static void ide_cdrom_attach(struct ata_device *drive)
+{
+ struct cdrom_info *info;
+ char *req;
+ struct ata_channel *channel;
+ int unit;
+
+ if (drive->type != ATA_ROM)
+ return;
+
+ req = drive->driver_req;
+ if (req[0] != '\0' && strcmp(req, "ide-cdrom"))
+ return;
+
+ /* skip drives that we were told to ignore */
+ if (ignore && !strcmp(ignore, drive->name)) {
+ printk(KERN_INFO "%s: ignored\n", drive->name);
+ return;
+ }
+ info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
+ if (!info) {
+ printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
+ return;
+ }
+ if (ide_register_subdriver (drive, &ide_cdrom_driver)) {
+ printk(KERN_ERR "%s: Failed to register the driver with ide.c\n", drive->name);
+ kfree (info);
+ return;
+ }
+
+
+ memset(info, 0, sizeof (struct cdrom_info));
+ drive->driver_data = info;
+
+ if (ide_cdrom_setup (drive)) {
+ if (ide_cdrom_cleanup (drive))
+ printk (KERN_ERR "%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
+ return;
+ }
+
+ channel = drive->channel;
+ unit = drive - channel->drives;
+
+ ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
+}
+
MODULE_PARM(ignore, "s");
MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static void __exit ide_cdrom_exit(void)
{
- struct ata_device *drive;
- int failed = 0;
-
- while ((drive = ide_scan_devices(ATA_ROM, "ide-cdrom", &ide_cdrom_driver, failed)) != NULL)
- if (ide_cdrom_cleanup (drive)) {
- printk ("%s: cleanup_module() called while still busy\n", drive->name);
- failed++;
- }
+ unregister_ata_driver(&ide_cdrom_driver);
}
int ide_cdrom_init(void)
{
- struct ata_device *drive;
- struct cdrom_info *info;
- int failed = 0;
-
- MOD_INC_USE_COUNT;
- while ((drive = ide_scan_devices (ATA_ROM, "ide-cdrom", NULL, failed++)) != NULL) {
- /* skip drives that we were told to ignore */
- if (ignore != NULL) {
- if (strstr(ignore, drive->name)) {
- printk("ide-cd: ignoring drive %s\n", drive->name);
- continue;
- }
- }
- if (drive->scsi) {
- printk("ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
- continue;
- }
- info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
- if (info == NULL) {
- printk ("%s: Can't allocate a cdrom structure\n", drive->name);
- continue;
- }
- if (ide_register_subdriver (drive, &ide_cdrom_driver)) {
- printk ("%s: Failed to register the driver with ide.c\n", drive->name);
- kfree (info);
- continue;
- }
- memset(info, 0, sizeof (struct cdrom_info));
- drive->driver_data = info;
-
- MOD_INC_USE_COUNT;
- if (ide_cdrom_setup (drive)) {
- MOD_DEC_USE_COUNT;
- if (ide_cdrom_cleanup (drive))
- printk ("%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
- continue;
- }
- MOD_DEC_USE_COUNT;
-
- failed--;
- }
- revalidate_drives();
- MOD_DEC_USE_COUNT;
- return 0;
+ return ata_driver_module(&ide_cdrom_driver);
}
module_init(ide_cdrom_init);
if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) &&
(!drive->forced_geom) && drive->bios_sect && drive->bios_head)
drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head;
- printk(KERN_INFO "%s: %ld sectors", drive->name, capacity);
+ printk(KERN_INFO " %s: %ld sectors", drive->name, capacity);
#if 0
}
}
+static void idedisk_attach(struct ata_device *drive);
/*
* Subdriver functions.
*/
static struct ata_operations idedisk_driver = {
owner: THIS_MODULE,
+ attach: idedisk_attach,
cleanup: idedisk_cleanup,
standby: idedisk_standby,
do_request: idedisk_do_request,
capacity: idedisk_capacity,
};
-MODULE_DESCRIPTION("ATA DISK Driver");
-
-static void __exit idedisk_exit (void)
+static void idedisk_attach(struct ata_device *drive)
{
- struct ata_device *drive;
- int failed = 0;
+ char *req;
+ struct ata_channel *channel;
+ int unit;
- while ((drive = ide_scan_devices(ATA_DISK, "ide-disk", &idedisk_driver, failed)) != NULL) {
- if (idedisk_cleanup (drive)) {
- printk(KERN_ERR "%s: cleanup_module() called while still busy\n", drive->name);
- ++failed;
- }
+ if (drive->type != ATA_DISK)
+ return;
+
+ req = drive->driver_req;
+ if (req[0] != '\0' && strcmp(req, "ide-disk"))
+ return;
+
+ if (ide_register_subdriver(drive, &idedisk_driver)) {
+ printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
+ return;
+ }
+
+ idedisk_setup(drive);
+ if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
+ printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", drive->name, drive->head);
+ idedisk_cleanup(drive);
+ return;
}
+
+ channel = drive->channel;
+ unit = drive - channel->drives;
+
+ ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
}
-int idedisk_init(void)
+static void __exit idedisk_exit(void)
{
- struct ata_device *drive;
- int failed = 0;
-
- MOD_INC_USE_COUNT;
- while ((drive = ide_scan_devices(ATA_DISK, "ide-disk", NULL, failed++)) != NULL) {
- if (ide_register_subdriver (drive, &idedisk_driver)) {
- printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
- continue;
- }
- idedisk_setup(drive);
- if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
- printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", drive->name, drive->head);
- idedisk_cleanup(drive);
- continue;
- }
- --failed;
- }
- revalidate_drives();
- MOD_DEC_USE_COUNT;
+ unregister_ata_driver(&idedisk_driver);
+}
- return 0;
+int __init idedisk_init(void)
+{
+ return ata_driver_module(&idedisk_driver);
}
module_init(idedisk_init);
module_exit(idedisk_exit);
+
+MODULE_DESCRIPTION("ATA DISK Driver");
MODULE_LICENSE("GPL");
/*
- * linux/drivers/ide/ide-floppy.c Version 0.99 Feb 24 2002
- *
* Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il>
* Copyright (C) 2000 - 2002 Paul Bristow <paul@paulbristow.net>
*/
return 0;
}
+static void idefloppy_attach(struct ata_device *drive);
+
/*
* IDE subdriver functions, registered with ide.c
*/
static struct ata_operations idefloppy_driver = {
owner: THIS_MODULE,
+ attach: idefloppy_attach,
cleanup: idefloppy_cleanup,
standby: NULL,
do_request: idefloppy_do_request,
capacity: idefloppy_capacity,
};
-MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
-
-static void __exit idefloppy_exit(void)
+static void idefloppy_attach(struct ata_device *drive)
{
- struct ata_device *drive;
- int failed = 0;
+ idefloppy_floppy_t *floppy;
+ char *req;
+ struct ata_channel *channel;
+ int unit;
- while ((drive = ide_scan_devices(ATA_FLOPPY, "ide-floppy", &idefloppy_driver, failed)) != NULL) {
- if (idefloppy_cleanup(drive)) {
- printk ("%s: cleanup_module() called while still busy\n", drive->name);
- failed++;
- }
+ if (drive->type != ATA_FLOPPY)
+ return;
+
+ req = drive->driver_req;
+ if (req[0] != '\0' && strcmp(req, "ide-floppy"))
+ return;
+
+ if (!idefloppy_identify_device (drive, drive->id)) {
+ printk (KERN_ERR "ide-floppy: %s: not supported by this version of driver\n",
+ drive->name);
+ return;
+ }
+
+ if (drive->scsi) {
+ printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi emulation.\n",
+ drive->name);
+ return;
+ }
+ if (!(floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL))) {
+ printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n",
+ drive->name);
+ return;
+ }
+ if (ide_register_subdriver(drive, &idefloppy_driver)) {
+ printk(KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
+ kfree (floppy);
+ return;
}
+
+ idefloppy_setup(drive, floppy);
+
+ channel = drive->channel;
+ unit = drive - channel->drives;
+
+ ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
}
-/*
- * idefloppy_init will register the driver for each floppy.
- */
-int idefloppy_init(void)
-{
- struct ata_device *drive;
- idefloppy_floppy_t *floppy;
- int failed = 0;
+MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
- printk("ide-floppy driver " IDEFLOPPY_VERSION "\n");
- MOD_INC_USE_COUNT;
- while ((drive = ide_scan_devices (ATA_FLOPPY, "ide-floppy", NULL, failed++)) != NULL) {
- if (!idefloppy_identify_device (drive, drive->id)) {
- printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name);
- continue;
- }
- if (drive->scsi) {
- printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
- continue;
- }
- if ((floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
- printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
- continue;
- }
- if (ide_register_subdriver (drive, &idefloppy_driver)) {
- printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
- kfree (floppy);
- continue;
- }
- MOD_INC_USE_COUNT;
- idefloppy_setup (drive, floppy);
- MOD_DEC_USE_COUNT;
+static void __exit idefloppy_exit(void)
+{
+ unregister_ata_driver(&idefloppy_driver);
+}
- failed--;
- }
- revalidate_drives();
- MOD_DEC_USE_COUNT;
- return 0;
+int __init idefloppy_init(void)
+{
+ return ata_driver_module(&idefloppy_driver);
}
module_init(idefloppy_init);
static int check_ide_device (unsigned long base);
static void ide_interrupt_ack (void *dev);
-static void m8xx_ide_tuneproc(ide_drive_t *drive, byte pio);
+static void m8xx_ide_tuneproc(struct ata_device *drive, byte pio);
typedef struct ide_ioport_desc {
unsigned long base_off; /* Offset to PCMCIA memory */
/* Calculate PIO timings */
static void
-m8xx_ide_tuneproc(ide_drive_t *drive, byte pio)
+m8xx_ide_tuneproc(struct ata_device *drive, byte pio)
{
#if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
volatile pcmconf8xx_t *pcmp;
if ((dev->vendor == PCI_VENDOR_ID_AL && dev->device == PCI_DEVICE_ID_AL_M5219) ||
(dev->vendor == PCI_VENDOR_ID_AMD && dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) ||
- (dev->vendor == PCI_VENDOR_ID_CMD && dev->device == PCI_DEVICE_ID_CMD_643)) {
+ (dev->vendor == PCI_VENDOR_ID_CMD && dev->device == PCI_DEVICE_ID_CMD_643) ||
+ (dev->vendor == PCI_VENDOR_ID_SERVERWORKS && dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)) {
outb(inb(dma_base + 2) & 0x60, dma_base+2);
if (inb(dma_base + 2) & 0x80)
printk(KERN_INFO "%s: simplex device: DMA forced\n", name);
}
}
}
- printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
- dev->name, dev->slot_name, dev->devfn);
+ printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+ dev->name, dev->slot_name);
setup_pci_device(dev, d);
if (!dev2)
return;
d2 = d;
- printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
- dev2->name, dev2->slot_name, dev2->devfn);
+ printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+ dev2->name, dev2->slot_name);
setup_pci_device(dev2, d2);
}
}
}
- printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
- dev->name, dev->slot_name, dev->devfn);
+ printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+ dev->name, dev->slot_name);
setup_pci_device(dev, d);
if (!dev2) {
return;
}
}
d2 = d;
- printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n",
- dev2->name, dev2->slot_name, dev2->devfn);
+ printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+ dev2->name, dev2->slot_name);
setup_pci_device(dev2, d2);
}
switch(class_rev) {
case 5:
case 4:
- case 3: printk(KERN_INFO "ATA: %s: controller on PCI slot %s\n", dev->name, dev->slot_name);
+ case 3: printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+ dev->name, dev->slot_name);
setup_pci_device(dev, d);
return;
default: break;
break;
}
}
- printk(KERN_INFO "ATA: %s: controller on PCI slot %s\n", dev->name, dev->slot_name);
+ printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+ dev->name, dev->slot_name);
setup_pci_device(dev, d);
if (!dev2)
return;
d2 = d;
- printk(KERN_INFO "ATA: %s: controller on PCI slot %s\n", dev2->name, dev2->slot_name);
+ printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
+ dev2->name, dev2->slot_name);
setup_pci_device(dev2, d2);
}
* beeing grabbed by generic drivers.
*/
if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
- printk(KERN_INFO "ATA: unknown interface: %s, on PCI slot %s\n",
+ printk(KERN_INFO "ATA: unknown interface: %s, PCI slot %s\n",
dev->name, dev->slot_name);
}
return;
} else if (d->vendor == PCI_VENDOR_ID_PROMISE && d->device == PCI_DEVICE_ID_PROMISE_20268R)
pdc20270_device_order_fixup(dev, d);
else {
- printk(KERN_INFO "ATA: %s (%04x:%04x) on PCI slot %s\n",
- dev->name, vendor, device, dev->slot_name);
+ printk(KERN_INFO "ATA: %s, PCI slot %s\n",
+ dev->name, dev->slot_name);
setup_pci_device(dev, d);
}
}
/*
- * linux/drivers/ide/ide-tape.c Version 1.17a Jan, 2001
- *
* Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il>
*
- * $Header$
- *
* This driver was constructed as a student project in the software laboratory
* of the faculty of electrical engineering in the Technion - Israel's
* Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David.
printk (KERN_INFO "ide-tape: Medium Type - %d\n",header->medium_type);
printk (KERN_INFO "ide-tape: Device Specific Parameter - %d\n",header->dsp);
printk (KERN_INFO "ide-tape: Block Descriptor Length - %d\n",header->bdl);
-
+
printk (KERN_INFO "ide-tape: Capabilities and Mechanical Status Page:\n");
printk (KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code);
printk (KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length);
set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags);
tape->min_pipeline = tape->max_pipeline = tape->max_stages = 10;
-
+
idetape_get_inquiry_results(drive);
idetape_get_mode_sense_results(drive);
idetape_get_blocksize_from_block_descriptor(drive);
*/
}
-/*
- * IDE subdriver functions, registered with ide.c
- */
+static void idetape_attach(struct ata_device *);
+
static struct ata_operations idetape_driver = {
owner: THIS_MODULE,
+ attach: idetape_attach,
cleanup: idetape_cleanup,
standby: NULL,
do_request: idetape_do_request,
revalidate: idetape_revalidate,
};
+
+
/*
* Our character device supporting functions, passed to register_chrdev.
*/
release: idetape_chrdev_release,
};
-MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
-MODULE_LICENSE("GPL");
-
-static void __exit idetape_exit(void)
+static void idetape_attach(struct ata_device *drive)
{
- struct ata_device *drive;
- int minor;
+ idetape_tape_t *tape;
+ int minor, supported = 0;
+ char *req;
+ struct ata_channel *channel;
+ int unit;
- for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++) {
- drive = idetape_chrdevs[minor].drive;
- if (drive != NULL && idetape_cleanup (drive))
- printk (KERN_ERR "ide-tape: %s: cleanup_module() called while still busy\n", drive->name);
- }
-}
+ if (drive->type != ATA_TAPE)
+ return;
+
+ req = drive->driver_req;
+ if (req[0] != '\0' && strcmp(req, "ide-tape"))
+ return;
-/*
- * idetape_init will register the driver for each tape.
- */
-int idetape_init(void)
-{
- struct ata_device *drive;
- idetape_tape_t *tape;
- int minor, failed = 0, supported = 0;
-/* DRIVER(drive)->busy++; */
- MOD_INC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_INC_USE_COUNT in idetape_init\n");
-#endif
if (!idetape_chrdev_present)
for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++ )
idetape_chrdevs[minor].drive = NULL;
- if ((drive = ide_scan_devices(ATA_TAPE, "ide-tape", NULL, failed++)) == NULL) {
- revalidate_drives();
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
- return 0;
- }
if (!idetape_chrdev_present &&
devfs_register_chrdev (IDETAPE_MAJOR, "ht", &idetape_fops)) {
- printk (KERN_ERR "ide-tape: Failed to register character device interface\n");
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
- return -EBUSY;
+ printk(KERN_ERR "ide-tape: Failed to register character device interface\n");
+ return;
}
- do {
- if (!idetape_identify_device (drive, drive->id)) {
- printk (KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name);
- continue;
- }
- if (drive->scsi) {
- if (strstr(drive->id->model, "OnStream DI-")) {
- printk("ide-tape: ide-scsi emulation is not supported for %s.\n", drive->id->model);
- } else {
- printk("ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
- continue;
- }
- }
- tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
- if (tape == NULL) {
- printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
- continue;
- }
- if (ide_register_subdriver (drive, &idetape_driver)) {
- printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
- kfree (tape);
- continue;
+
+ if (!idetape_identify_device (drive, drive->id)) {
+ printk(KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name);
+ return;
+ }
+ if (drive->scsi) {
+ if (strstr(drive->id->model, "OnStream DI-")) {
+ printk(KERN_INFO "ide-tape: ide-scsi emulation is not supported for %s.\n", drive->id->model);
+ } else {
+ printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
+ return;
}
- for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
- idetape_setup (drive, tape, minor);
- idetape_chrdevs[minor].drive = drive;
- tape->de_r =
- devfs_register (drive->de, "mt", DEVFS_FL_DEFAULT,
- drive->channel->major, minor,
- S_IFCHR | S_IRUGO | S_IWUGO,
- &idetape_fops, NULL);
- tape->de_n =
- devfs_register (drive->de, "mtn", DEVFS_FL_DEFAULT,
- drive->channel->major, minor + 128,
- S_IFCHR | S_IRUGO | S_IWUGO,
- &idetape_fops, NULL);
- devfs_register_tape (tape->de_r);
- supported++; failed--;
- } while ((drive = ide_scan_devices(ATA_TAPE, "ide-tape", NULL, failed++)) != NULL);
+ }
+ tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
+ if (!tape) {
+ printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
+ return;
+ }
+ if (ide_register_subdriver (drive, &idetape_driver)) {
+ printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
+ kfree (tape);
+ return;
+ }
+ for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
+ idetape_setup (drive, tape, minor);
+ idetape_chrdevs[minor].drive = drive;
+ tape->de_r =
+ devfs_register (drive->de, "mt", DEVFS_FL_DEFAULT,
+ drive->channel->major, minor,
+ S_IFCHR | S_IRUGO | S_IWUGO,
+ &idetape_fops, NULL);
+ tape->de_n =
+ devfs_register (drive->de, "mtn", DEVFS_FL_DEFAULT,
+ drive->channel->major, minor + 128,
+ S_IFCHR | S_IRUGO | S_IWUGO,
+ &idetape_fops, NULL);
+ devfs_register_tape (tape->de_r);
+ supported++;
+
if (!idetape_chrdev_present && !supported) {
devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
} else
idetape_chrdev_present = 1;
- revalidate_drives();
- MOD_DEC_USE_COUNT;
-#if ONSTREAM_DEBUG
- printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
-#endif
- return 0;
+
+ /* Feel free to use partitions even on tapes... */
+
+ channel = drive->channel;
+ unit = drive - channel->drives;
+
+ ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
+}
+
+MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
+MODULE_LICENSE("GPL");
+
+static void __exit idetape_exit(void)
+{
+ unregister_ata_driver(&idetape_driver);
+}
+
+int __init idetape_init(void)
+{
+ return ata_driver_module(&idetape_driver);
}
module_init(idetape_init);
#include "ata-timing.h"
#include "pcihost.h"
+
+MODULE_DESCRIPTION("ATA/ATAPI driver infrastructure");
+MODULE_PARM(options,"s");
+MODULE_LICENSE("GPL");
+
/*
* Those will be moved into separate header files eventually.
*/
int noautodma = 0;
+/* Single linked list of sub device type drivers */
+static struct ata_operations *ata_drivers; /* = NULL */
+static spinlock_t ata_drivers_lock = SPIN_LOCK_UNLOCKED;
+
/*
* This is declared extern in ide.h, for access by other IDE modules:
*/
u8 ide_dump_status(struct ata_device *drive, struct request * rq, const char *msg, u8 stat)
{
unsigned long flags;
- byte err = 0;
- int i;
+ u8 err = 0;
__save_flags (flags); /* local CPU only */
ide__sti(); /* local CPU only */
}
/*
+ * FIXME: rename to ata_wipe_partitions.
+ *
* This routine is called to flush all partitions and partition tables
* for a changed disk, and then re-read the new partition table.
* If we are revalidating a disk because of a media change, then we
}
/*
- * Look again for all drives in the system on all interfaces. This is used
- * after a new driver category has been loaded as module.
+ * Look again for all drives in the system on all interfaces.
*/
-void revalidate_drives(void)
+static void revalidate_drives(void)
{
int i;
}
}
-static void ide_driver_module (void)
+static void ide_driver_module(void)
{
int i;
* may set up the hw structure yourself OR use this routine to
* do it for you.
*/
-void ide_setup_ports ( hw_regs_t *hw,
- ide_ioreg_t base, int *offsets,
- ide_ioreg_t ctrl, ide_ioreg_t intr,
- ide_ack_intr_t *ack_intr, int irq)
+void ide_setup_ports(hw_regs_t *hw,
+ ide_ioreg_t base, int *offsets,
+ ide_ioreg_t ctrl, ide_ioreg_t intr,
+ ide_ack_intr_t *ack_intr, int irq)
{
int i;
hw->ack_intr = ack_intr;
}
+static int subdriver_match(struct ata_channel *channel, struct ata_operations *ops)
+{
+ int count, unit;
+
+ if (!channel->present)
+ return 0;
+
+ count = 0;
+ for (unit = 0; unit < MAX_DRIVES; ++unit) {
+ struct ata_device *drive = &channel->drives[unit];
+ if (drive->present && !drive->driver) {
+ (*ops->attach)(drive);
+ if (drive->driver != NULL)
+ count++;
+ }
+ }
+ return count;
+}
+
+static struct ata_operations * subdriver_interator(struct ata_operations *prev)
+{
+ struct ata_operations *tmp;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ata_drivers_lock, flags);
+
+ /* Restart from beginning if current ata_operations was deallocated,
+ or if prev is NULL. */
+ for(tmp = ata_drivers; tmp != prev && tmp; tmp = tmp->next);
+ if (!tmp)
+ tmp = ata_drivers;
+ else
+ tmp = tmp->next;
+
+ spin_unlock_irqrestore(&ata_drivers_lock, flags);
+
+ return tmp;
+
+}
+
/*
* Register an IDE interface, specifing exactly the registers etc
* Set init=1 iff calling before probes have taken place.
{
int h;
int retry = 1;
- struct ata_channel *hwif;
+ struct ata_channel *ch;
+ struct ata_operations *subdriver;
do {
for (h = 0; h < MAX_HWIFS; ++h) {
- hwif = &ide_hwifs[h];
- if (hwif->hw.io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET])
+ ch = &ide_hwifs[h];
+ if (ch->hw.io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET])
goto found;
}
for (h = 0; h < MAX_HWIFS; ++h) {
- hwif = &ide_hwifs[h];
- if ((!hwif->present && (hwif->unit == ATA_PRIMARY) && !initializing) ||
- (!hwif->hw.io_ports[IDE_DATA_OFFSET] && initializing))
+ ch = &ide_hwifs[h];
+ if ((!ch->present && (ch->unit == ATA_PRIMARY) && !initializing) ||
+ (!ch->hw.io_ports[IDE_DATA_OFFSET] && initializing))
goto found;
}
for (h = 0; h < MAX_HWIFS; ++h)
return -1;
found:
- ide_unregister(hwif);
- if (hwif->present)
+ ide_unregister(ch);
+ if (ch->present)
return -1;
- memcpy(&hwif->hw, hw, sizeof(*hw));
- memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
- hwif->irq = hw->irq;
- hwif->noprobe = 0;
- hwif->chipset = hw->chipset;
+ memcpy(&ch->hw, hw, sizeof(*hw));
+ memcpy(ch->io_ports, ch->hw.io_ports, sizeof(ch->hw.io_ports));
+ ch->irq = hw->irq;
+ ch->noprobe = 0;
+ ch->chipset = hw->chipset;
if (!initializing) {
ideprobe_init();
ide_driver_module();
}
+ /* Look up whatever there is a subdriver, which will serve this
+ * device.
+ */
+ subdriver = NULL;
+ while ((subdriver = subdriver_interator(subdriver))) {
+ if (subdriver_match(ch, subdriver) > 0)
+ break;
+ }
+
if (hwifp)
- *hwifp = hwif;
+ *hwifp = ch;
- return (initializing || hwif->present) ? h : -1;
+ return (initializing || ch->present) ? h : -1;
}
/*
#else
__set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(HZ/20);
-#endif /* CONFIG_BLK_DEV_IDECS */
+#endif
}
/*
}
/*
- * Lookup ATA devices, which requested a particular driver.
- */
-struct ata_device *ide_scan_devices(byte type, const char *name, struct ata_operations *driver, int n)
-{
- unsigned int unit, index, i;
-
- for (index = 0, i = 0; index < MAX_HWIFS; ++index) {
- struct ata_channel *ch = &ide_hwifs[index];
-
- if (!ch->present)
- continue;
-
- for (unit = 0; unit < MAX_DRIVES; ++unit) {
- struct ata_device *drive = &ch->drives[unit];
- char *req = drive->driver_req;
-
- if (*req && !strstr(name, req))
- continue;
- if (drive->present && drive->type == type && drive->driver == driver && ++i > n)
- return drive;
- }
- }
-
- return NULL;
-}
-
-/*
- * This is in fact registering a drive not a driver.
+ * This is in fact registering a device not a driver.
*/
int ide_register_subdriver(struct ata_device *drive, struct ata_operations *driver)
{
pnpide_init(0);
#endif
drive->driver = NULL;
- drive->present = 0;
restore_flags(flags); /* all CPUs */
/*
- * Register an ATA driver for a particular device type.
+ * Register an ATA subdriver for a particular device type.
*/
-int register_ata_driver(unsigned int type, struct ata_operations *driver)
+int register_ata_driver(struct ata_operations *driver)
{
- return 0;
+ unsigned long flags;
+ int index;
+ int count = 0;
+
+ spin_lock_irqsave(&ata_drivers_lock, flags);
+ driver->next = ata_drivers;
+ ata_drivers = driver;
+ spin_unlock_irqrestore(&ata_drivers_lock, flags);
+
+ for (index = 0; index < MAX_HWIFS; ++index)
+ count += subdriver_match(&ide_hwifs[index], driver);
+
+ return count;
}
EXPORT_SYMBOL(register_ata_driver);
/*
- * Unregister an ATA driver for a particular device type.
+ * Unregister an ATA subdriver for a particular device type.
*/
-
-int unregister_ata_driver(unsigned int type, struct ata_operations *driver)
+void unregister_ata_driver(struct ata_operations *driver)
{
- return 0;
+ struct ata_operations **tmp;
+ unsigned long flags;
+ int index;
+ int unit;
+
+ spin_lock_irqsave(&ata_drivers_lock, flags);
+ for (tmp = &ata_drivers; *tmp != NULL; tmp = &(*tmp)->next) {
+ if (*tmp == driver) {
+ *tmp = driver->next;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&ata_drivers_lock, flags);
+
+ for (index = 0; index < MAX_HWIFS; ++index) {
+ struct ata_channel *ch = &ide_hwifs[index];
+ for (unit = 0; unit < MAX_DRIVES; ++unit) {
+ struct ata_device *drive = &ch->drives[unit];
+
+ if (drive->driver == driver)
+ (*ata_ops(drive)->cleanup)(drive);
+ }
+ }
}
EXPORT_SYMBOL(unregister_ata_driver);
EXPORT_SYMBOL(ide_fops);
EXPORT_SYMBOL(ide_hwifs);
EXPORT_SYMBOL(ide_spin_wait_hwgroup);
-EXPORT_SYMBOL(revalidate_drives);
-/*
- * Probe module
- */
devfs_handle_t ide_devfs_handle;
EXPORT_SYMBOL(ide_lock);
EXPORT_SYMBOL(drive_is_flashcard);
EXPORT_SYMBOL(ide_timer_expiry);
EXPORT_SYMBOL(do_ide_request);
-/*
- * Driver module
- */
-EXPORT_SYMBOL(ide_scan_devices);
+
EXPORT_SYMBOL(ide_register_subdriver);
EXPORT_SYMBOL(ide_unregister_subdriver);
EXPORT_SYMBOL(ide_set_handler);
EXPORT_SYMBOL(ide_setup_ports);
EXPORT_SYMBOL(get_info_ptr);
-static int ide_notify_reboot (struct notifier_block *this, unsigned long event, void *x)
+/*
+ * Handle power handling related events ths system informs us about.
+ */
+static int ata_sys_notify(struct notifier_block *this, unsigned long event, void *x)
{
int i;
return NOTIFY_DONE;
}
-static struct notifier_block ide_notifier = {
- ide_notify_reboot,
+static struct notifier_block ata_notifier = {
+ ata_sys_notify,
NULL,
5
};
{
int h;
- printk(KERN_INFO "ATA/ATAPI driver v" VERSION "\n");
+ printk(KERN_INFO "ATA/ATAPI device driver v" VERSION "\n");
ide_devfs_handle = devfs_mk_dir (NULL, "ide", NULL);
-/*
- * Because most of the ATA adapters represent the timings in unit of bus
- * clocks, and there is no known reliable way to detect the bus clock
- * frequency, we assume 50 MHz for non-PCI (VLB, EISA) and 33 MHz for PCI based
- * systems. Since assuming only hurts performance and not stability, this is
- * OK. The user can change this on the command line by using the "idebus=XX"
- * parameter. While the system_bus_speed variable is in kHz units, we accept
- * both MHz and kHz entry on the command line for backward compatibility.
- */
+ /*
+ * Because most of the ATA adapters represent the timings in unit of
+ * bus clocks, and there is no known reliable way to detect the bus
+ * clock frequency, we assume 50 MHz for non-PCI (VLB, EISA) and 33 MHz
+ * for PCI based systems. Since assuming only hurts performance and not
+ * stability, this is OK. The user can change this on the command line
+ * by using the "idebus=XX" parameter. While the system_bus_speed
+ * variable is in kHz units, we accept both MHz and kHz entry on the
+ * command line for backward compatibility.
+ */
system_bus_speed = 50000;
if (idebus_parameter >= 20000 && idebus_parameter <= 80000)
system_bus_speed = idebus_parameter;
-
+
printk(KERN_INFO "ATA: %s bus speed %d.%dMHz\n",
pci_present() ? "PCI" : "System", system_bus_speed / 1000, system_bus_speed / 100 % 10);
# ifdef CONFIG_SCSI
idescsi_init();
# else
- #warning ATA SCSI emulation selected but no SCSI-subsystem in kernel
+ #error ATA SCSI emulation selected but no SCSI-subsystem in kernel
# endif
#endif
ide_geninit(channel);
}
- register_reboot_notifier(&ide_notifier);
+ register_reboot_notifier(&ata_notifier);
return 0;
}
static char *options = NULL;
-MODULE_PARM(options,"s");
-MODULE_LICENSE("GPL");
static int __init init_ata(void)
{
{
int h;
- unregister_reboot_notifier(&ide_notifier);
+ unregister_reboot_notifier(&ata_notifier);
for (h = 0; h < MAX_HWIFS; ++h) {
ide_unregister(&ide_hwifs[h]);
}
/*
* Prototypes
*/
-static void it8172_tune_drive (ide_drive_t *drive, byte pio);
+static void it8172_tune_drive (struct ata_device *drive, byte pio);
#if defined(CONFIG_BLK_DEV_IDEDMA) && defined(CONFIG_IT8172_TUNING)
static byte it8172_dma_2_pio (byte xfer_rate);
-static int it8172_tune_chipset (ide_drive_t *drive, byte speed);
-static int it8172_config_chipset_for_dma (ide_drive_t *drive);
-static int it8172_dmaproc(ide_dma_action_t func, ide_drive_t *drive);
+static int it8172_tune_chipset (struct ata_device *drive, byte speed);
+static int it8172_config_chipset_for_dma (struct ata_device *drive);
+static int it8172_dmaproc(ide_dma_action_t func, struct ata_device *drive);
#endif
void __init ide_init_it8172(struct ata_channel *channel);
-static void it8172_tune_drive (ide_drive_t *drive, byte pio)
+static void it8172_tune_drive (struct ata_device *drive, byte pio)
{
unsigned long flags;
u16 drive_enables;
}
}
-static int it8172_tune_chipset (ide_drive_t *drive, byte speed)
+static int it8172_tune_chipset (struct ata_device *drive, byte speed)
{
struct ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev;
return err;
}
-static int it8172_config_chipset_for_dma(ide_drive_t *drive)
+static int it8172_config_chipset_for_dma(struct ata_device *drive)
{
struct hd_driveid *id = drive->id;
byte speed;
ide_dma_off_quietly);
}
-static int it8172_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
+static int it8172_dmaproc(ide_dma_action_t func, struct ata_device *drive)
{
switch (func) {
case ide_dma_check:
/* hardware ID, and we cna't get that without */
/* probing the drive which freezes a 190. */
- ide_drive_t *drive = &ide_hwifs[index].drives[0];
+ struct ata_device *drive = &ide_hwifs[index].drives[0];
drive->capacity = drive->cyl*drive->head*drive->sect;
#ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
* the IRQ associated with the port (drive->channel),
* and selects either PIO or DMA handshaking for the next I/O operation.
*/
-static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
+static void ns87415_prepare_drive(struct ata_device *drive, unsigned int use_dma)
{
struct ata_channel *hwif = drive->channel;
unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data;
__restore_flags(flags); /* local CPU only */
}
-static void ns87415_selectproc (ide_drive_t *drive)
+static void ns87415_selectproc(struct ata_device *drive)
{
ns87415_prepare_drive (drive, drive->using_dma);
}
/* there are stored pio numbers from other calls of opti621_tune_drive */
-static void compute_pios(ide_drive_t *drive, byte pio)
+static void compute_pios(struct ata_device *drive, byte pio)
/* Store values into drive->drive_data
* second_contr - 0 for primary controller, 1 for secondary
* slave_drive - 0 -> pio is for master, 1 -> pio is for slave
}
/* Main tune procedure, called from tuneproc. */
-static void opti621_tune_drive (ide_drive_t *drive, byte pio)
+static void opti621_tune_drive(struct ata_device *drive, byte pio)
{
/* primary and secondary drives share some registers,
* so we have to program both drives
return 0;
}
+static int pdc202xx_ratemask(struct ata_device *drive)
+{
+ struct pci_dev *dev = drive->channel->pci_dev;
+ int map = 0;
+
+ if (!eighty_ninty_three(drive))
+ return XFER_UDMA;
+
+ switch(dev->device) {
+ case PCI_DEVICE_ID_PROMISE_20276:
+ case PCI_DEVICE_ID_PROMISE_20275:
+ case PCI_DEVICE_ID_PROMISE_20269:
+ map |= XFER_UDMA_133;
+ case PCI_DEVICE_ID_PROMISE_20268R:
+ case PCI_DEVICE_ID_PROMISE_20268:
+ case PCI_DEVICE_ID_PROMISE_20267:
+ case PCI_DEVICE_ID_PROMISE_20265:
+ map |= XFER_UDMA_100;
+ case PCI_DEVICE_ID_PROMISE_20262:
+ map |= XFER_UDMA_66;
+ case PCI_DEVICE_ID_PROMISE_20246:
+ map |= XFER_UDMA;
+ }
+ return map;
+}
+
static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed)
{
struct ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev;
unsigned int drive_conf;
- int err;
byte drive_pci, AP, BP, CP, DP;
byte TA = 0, TB = 0, TC = 0;
if (!drive->init_speed)
drive->init_speed = speed;
- err = ide_config_drive_speed(drive, speed);
drive->current_speed = speed;
#if PDC202XX_DEBUG_DRIVE_INFO
pci_read_config_dword(dev, drive_pci, &drive_conf);
printk("0x%08x\n", drive_conf);
#endif /* PDC202XX_DEBUG_DRIVE_INFO */
- return err;
+
+ return ide_config_drive_speed(drive, speed);
}
#define set_2regs(a, b) \
byte thold = 0x10;
byte adj = (drive->dn%2) ? 0x08 : 0x00;
- int err;
-
#ifdef CONFIG_BLK_DEV_IDEDMA
if (speed == XFER_UDMA_2) {
OUT_BYTE((thold + adj), indexreg);
if (!drive->init_speed)
drive->init_speed = speed;
- err = ide_config_drive_speed(drive, speed);
drive->current_speed = speed;
- return err;
+ return ide_config_drive_speed(drive, speed);
}
/* 0 1 2 3 4 5 6 7 8
}
#ifdef CONFIG_BLK_DEV_IDEDMA
-static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
+static int config_chipset_for_dma(struct ata_device *drive, byte udma)
{
struct hd_driveid *id = drive->id;
struct ata_channel *hwif = drive->channel;
+ struct hd_driveid *mate_id = hwif->drives[!(drive->dn%2)].id;
struct pci_dev *dev = hwif->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4);
unsigned long dma_base = hwif->dma_base;
byte adj = (drive->dn%2) ? 0x08 : 0x00;
byte cable = 0;
byte jumpbit = 0;
- byte unit = (drive->select.b.unit & 0x01);
unsigned int drive_conf;
- byte drive_pci = 0;
- byte test1, test2, speed = -1;
+ byte drive_pci = 0, mate_pci = 0;
+ byte test1, test2, mode = -1;
byte AP;
unsigned short EP;
byte CLKSPD = 0;
- byte udma_33 = ultra;
-// byte udma_33 = ultra ? (IN_BYTE(high_16 + 0x001f) & 1) : 0;
- byte udma_66 = ((eighty_ninty_three(drive)) && udma_33) ? 1 : 0;
- byte udma_100 = 0;
- byte udma_133 = 0;
+ /* primary - second bit, secondary - fourth bit */
byte mask = hwif->unit ? 0x08 : 0x02;
unsigned short c_mask = hwif->unit ? (1<<11) : (1<<10);
+ int map;
- byte ultra_66 = ((id->dma_ultra & 0x0010) ||
- (id->dma_ultra & 0x0008)) ? 1 : 0;
- byte ultra_100 = ((id->dma_ultra & 0x0020) ||
- (ultra_66)) ? 1 : 0;
- byte ultra_133 = ((id->dma_ultra & 0x0040) ||
- (ultra_100)) ? 1 : 0;
+ byte needs_80w = ((id->dma_ultra & 0x0008) ||
+ (id->dma_ultra & 0x0010) ||
+ (id->dma_ultra & 0x0020) ||
+ (id->dma_ultra & 0x0040));
switch(dev->device) {
case PCI_DEVICE_ID_PROMISE_20275:
case PCI_DEVICE_ID_PROMISE_20276:
case PCI_DEVICE_ID_PROMISE_20269:
- udma_133 = (udma_66) ? 1 : 0;
- udma_100 = (udma_66) ? 1 : 0;
- OUT_BYTE(0x0b, (hwif->dma_base + 1));
- cable = ((IN_BYTE((hwif->dma_base + 3)) & 0x04));
- jumpbit = 1;
- break;
case PCI_DEVICE_ID_PROMISE_20268R:
- udma_100 = 1;
- udma_66 = 1;
- OUT_BYTE(0x0b, (hwif->dma_base + 1));
- cable = ((IN_BYTE((hwif->dma_base + 3)) & 0x04));
- jumpbit = 1;
- break;
case PCI_DEVICE_ID_PROMISE_20268:
- udma_100 = (udma_66) ? 1 : 0;
- OUT_BYTE(0x0b, (hwif->dma_base + 1));
- cable = ((IN_BYTE((hwif->dma_base + 3)) & 0x04));
+ OUT_BYTE(0x0b, indexreg);
+ cable = ((IN_BYTE(datareg) & 0x04));
jumpbit = 1;
break;
case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265:
- udma_100 = (udma_66) ? 1 : 0;
- pci_read_config_word(dev, 0x50, &EP);
- cable = (EP & c_mask);
- jumpbit = 0;
- break;
case PCI_DEVICE_ID_PROMISE_20262:
pci_read_config_word(dev, 0x50, &EP);
cable = (EP & c_mask);
jumpbit = 0;
break;
default:
- udma_100 = 0; udma_133 = 0; cable = 1; jumpbit = 0;
+ cable = 1; jumpbit = 0;
break;
}
* leave the 66Mhz clock on and readjust the timing
* parameters.
*/
-
- if (((ultra_66) || (ultra_100) || (ultra_133)) && (cable)) {
-#ifdef DEBUG
- printk("ULTRA66: %s channel of Ultra 66 requires an 80-pin cable for Ultra66 operation.\n", hwif->unit ? "Secondary" : "Primary");
- printk(" Switching to Ultra33 mode.\n");
-#endif /* DEBUG */
- /* Primary : zero out second bit */
- /* Secondary : zero out fourth bit */
- if (!jumpbit)
- OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
- printk("Warning: %s channel requires an 80-pin cable for operation.\n", hwif->unit ? "Secondary":"Primary");
- printk("%s reduced to Ultra33 mode.\n", drive->name);
- udma_66 = 0; udma_100 = 0; udma_133 = 0;
- } else {
- if ((ultra_66) || (ultra_100) || (ultra_133)) {
- /*
- * check to make sure drive on same channel
- * is u66 capable
- */
- if (hwif->drives[!(drive->dn%2)].id) {
- if ((hwif->drives[!(drive->dn%2)].id->dma_ultra & 0x0040) ||
- (hwif->drives[!(drive->dn%2)].id->dma_ultra
-& 0x0020) ||
- (hwif->drives[!(drive->dn%2)].id->dma_ultra & 0x0010) ||
- (hwif->drives[!(drive->dn%2)].id->dma_ultra & 0x0008)) {
- if (!jumpbit)
- OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
+ if (needs_80w) {
+ /* FIXME: this check is wrong for 20246 --bkz */
+ if (cable) {
+ printk(KERN_WARNING "%s: channel requires an 80-pin cable.\n", hwif->name);
+ printk(KERN_WARNING "%s: reduced to UDMA(33) mode.\n", drive->name);
+ if (!jumpbit)
+ OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
+ }
+ if (!jumpbit) {
+ if (mate_id) { /* check if mate is at least udma3 */
+ if ((mate_id->dma_ultra & 0x0040) ||
+ (mate_id->dma_ultra & 0x0020) ||
+ (mate_id->dma_ultra & 0x0010) ||
+ (mate_id->dma_ultra & 0x0008)) {
+ OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
} else {
- if (!jumpbit)
- OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
+ OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
}
- } else { /* udma4 drive by itself */
- if (!jumpbit)
- OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
+ } else { /* single drive */
+ OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
}
}
}
switch(drive->dn) {
case 0: drive_pci = 0x60;
- pci_read_config_dword(dev, drive_pci, &drive_conf);
- if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
- goto chipset_is_set;
- pci_read_config_byte(dev, (drive_pci), &test1);
- if (!(test1 & SYNC_ERRDY_EN))
- pci_write_config_byte(dev, (drive_pci), test1|SYNC_ERRDY_EN);
- break;
- case 1: drive_pci = 0x64;
- pci_read_config_dword(dev, drive_pci, &drive_conf);
- if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
- goto chipset_is_set;
- pci_read_config_byte(dev, 0x60, &test1);
- pci_read_config_byte(dev, (drive_pci), &test2);
- if ((test1 & SYNC_ERRDY_EN) && !(test2 & SYNC_ERRDY_EN))
- pci_write_config_byte(dev, (drive_pci), test2|SYNC_ERRDY_EN);
- break;
case 2: drive_pci = 0x68;
pci_read_config_dword(dev, drive_pci, &drive_conf);
if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
goto chipset_is_set;
- pci_read_config_byte(dev, (drive_pci), &test1);
+ pci_read_config_byte(dev, drive_pci, &test1);
if (!(test1 & SYNC_ERRDY_EN))
- pci_write_config_byte(dev, (drive_pci), test1|SYNC_ERRDY_EN);
+ pci_write_config_byte(dev, drive_pci, test1|SYNC_ERRDY_EN);
break;
- case 3: drive_pci = 0x6c;
+ case 1: drive_pci = 0x64; mate_pci = 0x60;
+ case 3: drive_pci = 0x6c; mate_pci = 0x68;
pci_read_config_dword(dev, drive_pci, &drive_conf);
if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
goto chipset_is_set;
- pci_read_config_byte(dev, 0x68, &test1);
- pci_read_config_byte(dev, (drive_pci), &test2);
+ pci_read_config_byte(dev, mate_pci, &test1);
+ pci_read_config_byte(dev, drive_pci, &test2);
if ((test1 & SYNC_ERRDY_EN) && !(test2 & SYNC_ERRDY_EN))
- pci_write_config_byte(dev, (drive_pci), test2|SYNC_ERRDY_EN);
+ pci_write_config_byte(dev, drive_pci, test2|SYNC_ERRDY_EN);
break;
default:
return 0;
jumpbit_is_set:
- if ((id->dma_ultra & 0x0040)&&(udma_133)) speed = XFER_UDMA_6;
- else if ((id->dma_ultra & 0x0020)&&(udma_100)) speed = XFER_UDMA_5;
- else if ((id->dma_ultra & 0x0010)&&(udma_66)) speed = XFER_UDMA_4;
- else if ((id->dma_ultra & 0x0008)&&(udma_66)) speed = XFER_UDMA_3;
- else if ((id->dma_ultra & 0x0004)&&(udma_33)) speed = XFER_UDMA_2;
- else if ((id->dma_ultra & 0x0002)&&(udma_33)) speed = XFER_UDMA_1;
- else if ((id->dma_ultra & 0x0001)&&(udma_33)) speed = XFER_UDMA_0;
- else if (id->dma_mword & 0x0004) speed = XFER_MW_DMA_2;
- else if (id->dma_mword & 0x0002) speed = XFER_MW_DMA_1;
- else if (id->dma_mword & 0x0001) speed = XFER_MW_DMA_0;
- else if ((id->dma_1word & 0x0004)&&(!jumpbit)) speed = XFER_SW_DMA_2;
- else if ((id->dma_1word & 0x0002)&&(!jumpbit)) speed = XFER_SW_DMA_1;
- else if ((id->dma_1word & 0x0001)&&(!jumpbit)) speed = XFER_SW_DMA_0;
- else {
+ if (udma) {
+ map = pdc202xx_ratemask(drive);
+ } else {
+ if (!jumpbit)
+ map = XFER_SWDMA | XFER_MWDMA;
+ else
+ map = XFER_MWDMA;
+ }
+
+ mode = ata_timing_mode(drive, map);
+ if (mode < XFER_SW_DMA_0) {
/* restore original pci-config space */
if (!jumpbit)
pci_write_config_dword(dev, drive_pci, drive_conf);
return 0;
}
- outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
- (void) hwif->speedproc(drive, speed);
-
- return ((int) ((id->dma_ultra >> 14) & 3) ? 1 :
- ((id->dma_ultra >> 11) & 7) ? 1 :
- ((id->dma_ultra >> 8) & 7) ? 1 :
- ((id->dma_mword >> 8) & 7) ? 1 :
- ((id->dma_1word >> 8) & 7) ? 1 :
- 0);
+ return !(hwif->speedproc(drive, mode));
}
static int config_drive_xfer_rate(struct ata_device *drive)
static int pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
{
- u8 clock = 0;
- u8 hardware48hack = 0;
+ u8 lba48hack = 0, clock = 0;
struct ata_channel *ch = drive->channel;
struct pci_dev *dev = ch->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4);
unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00);
-
switch (dev->device) {
- case PCI_DEVICE_ID_PROMISE_20275:
- case PCI_DEVICE_ID_PROMISE_20276:
- case PCI_DEVICE_ID_PROMISE_20269:
- case PCI_DEVICE_ID_PROMISE_20268R:
- case PCI_DEVICE_ID_PROMISE_20268:
- break;
case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262:
- hardware48hack = 1;
+ lba48hack = 1;
clock = IN_BYTE(high_16 + 0x11);
default:
break;
}
- if ((drive->addressing) && (hardware48hack)) {
+ if (drive->addressing && lba48hack) {
unsigned long word_count = 0;
outb(clock|(ch->unit ? 0x08 : 0x02), high_16 + 0x11);
int pdc202xx_udma_stop(struct ata_device *drive)
{
- u8 newchip = 0;
- u8 clock = 0;
- u8 hardware48hack = 0;
+ u8 lba48hack = 0, clock = 0;
struct ata_channel *ch = drive->channel;
struct pci_dev *dev = ch->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4);
u8 dma_stat;
switch (dev->device) {
- case PCI_DEVICE_ID_PROMISE_20275:
- case PCI_DEVICE_ID_PROMISE_20276:
- case PCI_DEVICE_ID_PROMISE_20269:
- case PCI_DEVICE_ID_PROMISE_20268R:
- case PCI_DEVICE_ID_PROMISE_20268:
- newchip = 1;
- break;
case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262:
- hardware48hack = 1;
+ lba48hack = 1;
+ /* FIXME: why do we need this here --bkz */
clock = IN_BYTE(high_16 + 0x11);
default:
break;
}
- if ((drive->addressing) && (hardware48hack)) {
+
+ if (drive->addressing && lba48hack) {
outl(0, atapi_reg); /* zero out extra */
clock = IN_BYTE(high_16 + 0x11);
OUT_BYTE(clock & ~(ch->unit ? 0x08:0x02), high_16 + 0x11);
u8 sc1d = 0;
u8 newchip = 0;
u8 clock = 0;
- u8 hardware48hack = 0;
struct pci_dev *dev = ch->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4);
unsigned long dma_base = ch->dma_base;
case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262:
- hardware48hack = 1;
+ /* FIXME: why do we need this here --bkz */
clock = IN_BYTE(high_16 + 0x11);
default:
break;
break;
case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265:
- set_reg_and_wait(udma_speed_flag | 0x10, high_16 + 0x001f, 100);
- set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000); /* 2 seconds ?! */
- break;
case PCI_DEVICE_ID_PROMISE_20262:
/*
- * software reset - this is required because the bios
- * will set UDMA timing on if the hdd supports it. The
- * user may want to turn udma off. A bug in the pdc20262
- * is that it cannot handle a downgrade in timing from
+ * software reset - this is required because the BIOS
+ * will set UDMA timing on if the drive supports it.
+ * The user may want to turn udma off. A bug is that
+ * that device cannot handle a downgrade in timing from
* UDMA to DMA. Disk accesses after issuing a set
- * feature command will result in errors. A software
- * reset leaves the timing registers intact,
+ * feature command will result in errors.
+ *
+ * A software reset leaves the timing registers intact,
* but resets the drives.
*/
set_reg_and_wait(udma_speed_flag | 0x10, high_16 + 0x001f, 100);
- set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000); /* 2 seconds ?! */
+ set_reg_and_wait(udma_speed_flag & ~0x10, high_16 + 0x001f, 2000); /* 2 seconds ?! */
+ break;
default:
if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
byte irq = 0, irq2 = 0;
/* module data table */
static struct ata_pci_device chipsets[] __initdata = {
-#ifdef CONFIG_PDC202XX_FORCE
- {
- vendor: PCI_VENDOR_ID_PROMISE,
- device: PCI_DEVICE_ID_PROMISE_20246,
- init_chipset: pdc202xx_init_chipset,
- ata66_check: NULL,
- init_channel: ide_init_pdc202xx,
- bootable: OFF_BOARD,
- extra: 16,
- flags: ATA_F_IRQ | ATA_F_DMA
- },
- {
- vendor: PCI_VENDOR_ID_PROMISE,
- device: PCI_DEVICE_ID_PROMISE_20262,
- init_chipset: pdc202xx_init_chipset,
- ata66_check: ata66_pdc202xx,
- init_channel: ide_init_pdc202xx,
- bootable: OFF_BOARD,
- extra: 48,
- flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
- },
- {
- vendor: PCI_VENDOR_ID_PROMISE,
- device: PCI_DEVICE_ID_PROMISE_20265,
- init_chipset: pdc202xx_init_chipset,
- ata66_check: ata66_pdc202xx,
- init_channel: ide_init_pdc202xx,
- bootable: ON_BOARD,
- extra: 48,
- flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
- },
- {
- vendor: PCI_VENDOR_ID_PROMISE,
- device: PCI_DEVICE_ID_PROMISE_20267,
- init_chipset: pdc202xx_init_chipset,
- ata66_check: ata66_pdc202xx,
- init_channel: ide_init_pdc202xx,
- bootable: OFF_BOARD,
- extra: 48,
- flags: ATA_F_IRQ | ATA_F_DMA
- },
-#else
{
vendor: PCI_VENDOR_ID_PROMISE,
device: PCI_DEVICE_ID_PROMISE_20246,
init_chipset: pdc202xx_init_chipset,
ata66_check: NULL,
init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
+#endif
bootable: OFF_BOARD,
extra: 16,
flags: ATA_F_IRQ | ATA_F_DMA
init_chipset: pdc202xx_init_chipset,
ata66_check: ata66_pdc202xx,
init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
+#endif
bootable: OFF_BOARD,
extra: 48,
flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
init_chipset: pdc202xx_init_chipset,
ata66_check: ata66_pdc202xx,
init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
bootable: OFF_BOARD,
+#else
+ bootable: ON_BOARD,
+#endif
extra: 48,
flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
},
init_chipset: pdc202xx_init_chipset,
ata66_check: ata66_pdc202xx,
init_channel: ide_init_pdc202xx,
+#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
+#endif
bootable: OFF_BOARD,
extra: 48,
flags: ATA_F_IRQ | ATA_F_DMA
},
-#endif
{
vendor: PCI_VENDOR_ID_PROMISE,
device: PCI_DEVICE_ID_PROMISE_20268,
static unsigned long calc_pdcblock_offset(struct block_device *bdev)
{
unsigned long lba = 0;
- ide_drive_t *ideinfo = get_info_ptr(to_kdev_t(bdev->bd_dev));
+ struct ata_device *ideinfo = get_info_ptr(to_kdev_t(bdev->bd_dev));
if (ideinfo==NULL)
return 0;
* This routine is invoked from ide.c to prepare for access to a given drive.
*/
-static void qd_select (ide_drive_t *drive)
+static void qd_select(struct ata_device *drive)
{
byte index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) |
(QD_TIMREG(drive) & 0x02);
* tries to find timing from dos driver's table
*/
-static int qd_find_disk_type (ide_drive_t *drive,
+static int qd_find_disk_type(struct ata_device *drive,
int *active_time, int *recovery_time)
{
struct qd65xx_timing_s *p;
* check whether timings don't conflict
*/
-static int qd_timing_ok (ide_drive_t drives[])
+static int qd_timing_ok(struct ata_device drives[])
{
return (IDE_IMPLY(drives[0].present && drives[1].present,
IDE_IMPLY(QD_TIMREG(drives) == QD_TIMREG(drives+1),
* records the timing, and enables selectproc as needed
*/
-static void qd_set_timing (ide_drive_t *drive, byte timing)
+static void qd_set_timing(struct ata_device *drive, byte timing)
{
struct ata_channel *hwif = drive->channel;
* qd6500_tune_drive
*/
-static void qd6500_tune_drive (ide_drive_t *drive, byte pio)
+static void qd6500_tune_drive(struct ata_device *drive, byte pio)
{
int active_time = 175;
int recovery_time = 415; /* worst case values from the dos driver */
* qd6580_tune_drive
*/
-static void qd6580_tune_drive (ide_drive_t *drive, byte pio)
+static void qd6580_tune_drive(struct ata_device *drive, byte pio)
{
struct ata_timing *t;
int base = drive->channel->select_data;
static struct pci_dev *isa_dev;
+static int svwks_ratemask(struct ata_device *drive)
+{
+ struct pci_dev *dev = drive->channel->pci_dev;
+ int map = 0;
+
+ if (!eighty_ninty_three(drive))
+ return XFER_UDMA;
+
+ switch(dev->device) {
+ case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
+ if (svwks_revision >= SVWKS_CSB5_REVISION_NEW)
+ map |= XFER_UDMA_100;
+ map |= XFER_UDMA_66;
+ case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
+ map |= XFER_UDMA;
+ break;
+ }
+ return map;
+}
+
static int svwks_tune_chipset(struct ata_device *drive, byte speed)
{
static u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
byte unit = (drive->select.b.unit & 0x01);
byte csb5 = (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ? 1 : 0;
-#ifdef CONFIG_BLK_DEV_IDEDMA
- unsigned long dma_base = hwif->dma_base;
-#endif
- int err;
-
byte drive_pci = 0x00;
byte drive_pci2 = 0x00;
byte drive_pci3 = hwif->unit ? 0x57 : 0x56;
printk("%s: %s drive%d\n", drive->name, ide_xfer_verbose(speed), drive->dn);
#endif /* SVWKS_DEBUG_DRIVE_INFO */
- if (!drive->init_speed)
- drive->init_speed = speed;
-
pci_write_config_byte(dev, drive_pci, pio_timing);
if (csb5)
pci_write_config_word(dev, 0x4A, csb5_pio);
pci_write_config_byte(dev, drive_pci2, dma_timing);
pci_write_config_byte(dev, drive_pci3, ultra_timing);
pci_write_config_byte(dev, 0x54, ultra_enable);
-
- if (speed > XFER_PIO_4)
- outb(inb(dma_base+2)|(1<<(5+unit)), dma_base+2);
- else
- outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
-#endif /* CONFIG_BLK_DEV_IDEDMA */
-
- err = ide_config_drive_speed(drive, speed);
+#endif
+ if (!drive->init_speed)
+ drive->init_speed = speed;
drive->current_speed = speed;
- return err;
+
+ return ide_config_drive_speed(drive, speed);
}
static void config_chipset_for_pio(struct ata_device *drive)
#ifdef CONFIG_BLK_DEV_IDEDMA
static int config_chipset_for_dma(struct ata_device *drive)
{
- struct hd_driveid *id = drive->id;
- struct pci_dev *dev = drive->channel->pci_dev;
- byte udma_66 = eighty_ninty_three(drive);
- int ultra66 = (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ? 1 : 0;
- int ultra100 = (ultra66 && svwks_revision >= SVWKS_CSB5_REVISION_NEW) ? 1 : 0;
-
- byte speed = ata_timing_mode(drive, XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | XFER_UDMA
- | ((udma_66 && ultra66) ? XFER_UDMA_66 : 0)
- | ((udma_66 && ultra100) ? XFER_UDMA_100 : 0));
+ int map;
+ byte mode;
- (void) svwks_tune_chipset(drive, speed);
+ /* FIXME: check SWDMA modes --bkz */
+ map = XFER_MWDMA | svwks_ratemask(drive);
+ mode = ata_timing_mode(drive, map);
- return ((int) ((id->dma_ultra >> 11) & 7) ? 1 :
- ((id->dma_ultra >> 8) & 7) ? 1 :
- ((id->dma_mword >> 8) & 7) ? 1 :
- ((id->dma_1word >> 8) & 7) ? 1 :
- 0);
+ return !svwks_tune_chipset(drive, mode);
}
static int config_drive_xfer_rate(struct ata_device *drive)
/*
* Configure the drive and chipset for PIO
*/
-static void config_for_pio(ide_drive_t *drive, int pio, int report)
+static void config_for_pio(struct ata_device *drive, int pio, int report)
{
struct ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev;
/*
* Configure the drive and the chipset for DMA
*/
-static int config_for_dma(ide_drive_t *drive)
+static int config_for_dma(struct ata_device *drive)
{
struct ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev;
* Check to see if the drive and
* chipset is capable of DMA mode
*/
-static int sl82c105_check_drive(ide_drive_t *drive)
+static int sl82c105_check_drive(struct ata_device *drive)
{
int on = 0;
* This function is called when the IDE timer expires, the drive
* indicates that it is READY, and we were waiting for DMA to complete.
*/
-static void sl82c105_lostirq(ide_drive_t *drive)
+static void sl82c105_lostirq(struct ata_device *drive)
{
struct ata_channel *ch = drive->channel;
struct pci_dev *dev = ch->pci_dev;
* We only deal with PIO mode here - DMA mode 'using_dma' is not
* initialised at the point that this function is called.
*/
-static void tune_sl82c105(ide_drive_t *drive, byte pio)
+static void tune_sl82c105(struct ata_device *drive, byte pio)
{
config_for_pio(drive, pio, 1);
*/
}
+static void idescsi_attach(struct ata_device *drive);
+
/*
* IDE subdriver functions, registered with ide.c
*/
static struct ata_operations idescsi_driver = {
owner: THIS_MODULE,
+ attach: idescsi_attach,
cleanup: idescsi_cleanup,
standby: NULL,
do_request: idescsi_do_request,
capacity: NULL,
};
-/*
- * idescsi_init will register the driver for each scsi.
- */
-int idescsi_init(void)
+static void idescsi_attach(struct ata_device *drive)
{
- struct ata_device *drive;
idescsi_scsi_t *scsi;
- /* FIXME: The following is just plain wrong, since those are definitely *not* the
- * media types supported by the ATA layer */
- byte media[] = {TYPE_DISK, TYPE_TAPE, TYPE_PROCESSOR, TYPE_WORM, TYPE_ROM, TYPE_SCANNER, TYPE_MOD, 255};
- int i, failed, id;
+ int i, id;
+ char *req;
+ struct ata_channel *channel;
+ int unit;
if (idescsi_initialized)
- return 0;
+ return;
idescsi_initialized = 1;
for (i = 0; i < MAX_HWIFS * MAX_DRIVES; i++)
idescsi_drives[i] = NULL;
- MOD_INC_USE_COUNT;
- for (i = 0; media[i] != 255; i++) {
- failed = 0;
- while ((drive = ide_scan_devices (media[i], "ide-scsi", NULL, failed++)) != NULL) {
- if ((scsi = (idescsi_scsi_t *) kmalloc (sizeof (idescsi_scsi_t), GFP_KERNEL)) == NULL) {
- printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
- continue;
- }
- if (ide_register_subdriver (drive, &idescsi_driver)) {
- printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
- kfree (scsi);
- continue;
- }
- for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++);
- idescsi_setup (drive, scsi, id);
- failed--;
- }
+ req = drive->driver_req;
+ if (req[0] != '\0' && strcmp(req, "ide-scsi"))
+ return;
+
+ if ((scsi = (idescsi_scsi_t *) kmalloc (sizeof (idescsi_scsi_t), GFP_KERNEL)) == NULL) {
+ printk(KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
+ return;
}
- revalidate_drives();
- MOD_DEC_USE_COUNT;
- return 0;
+ if (ide_register_subdriver (drive, &idescsi_driver)) {
+ printk(KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
+ kfree (scsi);
+ return;
+ }
+ for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++);
+ idescsi_setup (drive, scsi, id);
+
+ channel = drive->channel;
+ unit = drive - channel->drives;
+
+ ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
}
int idescsi_detect (Scsi_Host_Template *host_template)
emulated: 1,
};
-static int __init init_idescsi_module(void)
+
+static int __init idescsi_init(void)
{
- idescsi_init();
+ int ret;
+ ret = ata_driver_module(&idescsi_driver);
scsi_register_host(&idescsi_template);
return 0;
}
static void __exit exit_idescsi_module(void)
{
- struct ata_device *drive;
- byte media[] = {TYPE_DISK, TYPE_TAPE, TYPE_PROCESSOR, TYPE_WORM, TYPE_ROM, TYPE_SCANNER, TYPE_MOD, 255};
- int i, failed;
-
scsi_unregister_host(&idescsi_template);
- /* FIXME: The media types scanned here have literally nothing to do
- * with the media types used by the overall ATA code!
- *
- * This is basically showing us, that there is something wrong with the
- * ide_scan_devices function.
- */
+#if 0
+ /* FIXME: what about this cleanup stuff here? This all should be done
+ * on close time perhaps? */
- for (i = 0; media[i] != 255; i++) {
- failed = 0;
- while ((drive = ide_scan_devices (media[i], "ide-scsi", &idescsi_driver, failed)) != NULL)
- if (idescsi_cleanup (drive)) {
- printk ("%s: exit_idescsi_module() called while still busy\n", drive->name);
- failed++;
- }
+ if (idescsi_cleanup (drive)) {
+ printk ("%s: exit_idescsi_module() called while still busy\n", drive->name);
}
+#endif
+
+ unregister_ata_driver(&idescsi_driver);
}
-module_init(init_idescsi_module);
+module_init(idescsi_init);
module_exit(exit_idescsi_module);
MODULE_LICENSE("GPL");
/*
* ATA/ATAPI device structure :
*/
-typedef
struct ata_device {
struct ata_channel * channel;
char name[6]; /* device name */
unsigned long immed_comp;
int max_last_depth;
int max_depth;
-} ide_drive_t;
+};
/*
* Status returned by various functions.
struct ata_operations {
struct module *owner;
+ void (*attach) (struct ata_device *);
int (*cleanup)(struct ata_device *);
int (*standby)(struct ata_device *);
ide_startstop_t (*do_request)(struct ata_device *, struct request *, sector_t);
void (*revalidate)(struct ata_device *);
sector_t (*capacity)(struct ata_device *);
+
+ /* linked list of rgistered device type drivers */
+ struct ata_operations *next;
};
/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
extern sector_t ata_capacity(struct ata_device *drive);
-/* FIXME: Actually implement and use them as soon as possible! to make the
- * ide_scan_devices() go away! */
-
-extern int unregister_ata_driver(unsigned int type, struct ata_operations *driver);
-extern int register_ata_driver(unsigned int type, struct ata_operations *driver);
+extern void unregister_ata_driver(struct ata_operations *driver);
+extern int register_ata_driver(struct ata_operations *driver);
+static inline int ata_driver_module(struct ata_operations *driver)
+{
+#ifdef MODULE
+ if (register_ata_driver(driver) <= 0) {
+ unregister_ata_driver(driver);
+ return -ENODEV;
+ }
+#else
+ register_ata_driver(driver);
+#endif
+ return 0;
+}
#define ata_ops(drive) ((drive)->driver)
extern int idescsi_init (void);
#endif
-extern struct ata_device *ide_scan_devices(byte, const char *, struct ata_operations *, int);
extern int ide_register_subdriver(struct ata_device *, struct ata_operations *);
extern int ide_unregister_subdriver(struct ata_device *drive);
+extern int ide_revalidate_disk(kdev_t i_rdev);
#ifdef CONFIG_PCI
# define ON_BOARD 0
#define DRIVE_LOCK(drive) ((drive)->queue.queue_lock)
extern int drive_is_ready(struct ata_device *drive);
-extern void revalidate_drives(void);
#endif