Commit 13413379 authored by Linus Torvalds's avatar Linus Torvalds

Merge

parents 6177c8bb ac5bdbb7
......@@ -37,9 +37,27 @@
***
*** 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
......
......@@ -192,7 +192,7 @@ unsigned char IN_BYTE(ide_ioreg_t reg) {
#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);
/*
......@@ -206,7 +206,7 @@ const char *good_dma_drives[] = {"Micropolis 2112A",
"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;
......@@ -380,7 +380,7 @@ static etrax_dma_descr mydescr;
* 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;
......@@ -459,7 +459,7 @@ e100_atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount)
}
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;
......@@ -546,7 +546,7 @@ e100_atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount)
* 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);
}
......@@ -555,7 +555,7 @@ e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
* 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);
}
......@@ -661,7 +661,7 @@ static int e100_udma_new_table(struct ata_channel *ch, struct request *rq)
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;
......
......@@ -131,12 +131,7 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
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
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
......
......@@ -21,7 +21,7 @@ obj-$(CONFIG_BLK_DEV_HD) += hd.o
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
......@@ -74,6 +74,6 @@ obj-$(CONFIG_BLK_DEV_ATARAID) += ataraid.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
......@@ -607,27 +607,7 @@ static struct ata_pci_device chipsets[] __initdata = {
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)
......
......@@ -226,9 +226,9 @@ static void amd_set_speed(struct pci_dev *dev, unsigned char dn, struct ata_timi
* 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;
......@@ -263,7 +263,7 @@ static int amd_set_drive(ide_drive_t *drive, unsigned char speed)
* 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;
......
......@@ -81,7 +81,7 @@ extern char *ide_xfer_verbose (byte xfer_rate);
/*
* 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;
......@@ -113,7 +113,7 @@ static unsigned int cs5530_pio_timings[2][5] =
* 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);
......@@ -134,12 +134,12 @@ static void cs5530_tuneproc (ide_drive_t *drive, byte pio) /* pio=255 means "aut
* 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;
......
......@@ -183,7 +183,7 @@ static void compute_clocks (byte pio, pio_clocks_t *p_pclk)
/*
* 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;
......@@ -270,7 +270,7 @@ static int cy82c693_dmaproc(struct ata_device *drive)
/*
* 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;
......
......@@ -66,7 +66,7 @@ static void sub22 (char b, char c)
}
}
static void tune_dtc2278 (ide_drive_t *drive, byte pio)
static void tune_dtc2278(struct ata_device *drive, byte pio)
{
unsigned long flags;
......
......@@ -94,9 +94,9 @@ static int hpt34x_get_info (char *buffer, char **addr, off_t offset, int count)
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;
......@@ -109,7 +109,7 @@ static void hpt34x_clear_chipset (ide_drive_t *drive)
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;
......@@ -145,7 +145,7 @@ static int hpt34x_tune_chipset (ide_drive_t *drive, byte speed)
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;
......@@ -182,7 +182,7 @@ static void config_chipset_for_pio(ide_drive_t *drive)
(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;
......
......@@ -471,6 +471,8 @@ static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = {
#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
......@@ -484,14 +486,9 @@ static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = {
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);
......@@ -531,7 +528,7 @@ static int hpt366_get_info (char *buffer, char **addr, off_t offset, int count)
(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);
......@@ -580,50 +577,6 @@ static int hpt366_get_info (char *buffer, char **addr, off_t offset, int count)
}
#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;
......@@ -644,6 +597,64 @@ static int check_in_drive_lists(struct ata_device *drive, const char **list)
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++)
......@@ -772,19 +783,21 @@ static void hpt374_tune_chipset(struct ata_device *drive, byte speed)
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);
......@@ -845,77 +858,57 @@ static void hpt3xx_tune_drive(struct ata_device *drive, byte pio)
}
#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;
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 {
return 0;
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)
......@@ -937,7 +930,7 @@ static void hpt3xx_maskproc(struct ata_device *drive, int mask)
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, &reg5a);
if (((reg5a & 0x10) >> 4) != mask)
......@@ -1283,11 +1276,9 @@ static void __init hpt37x_init(struct pci_dev *dev)
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;
......@@ -1297,12 +1288,10 @@ static void __init hpt37x_init(struct pci_dev *dev)
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;
......@@ -1310,12 +1299,10 @@ static void __init hpt37x_init(struct pci_dev *dev)
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;
......@@ -1358,12 +1345,10 @@ static void __init hpt37x_init(struct pci_dev *dev)
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;
......@@ -1437,7 +1422,7 @@ static unsigned int __init hpt366_init_chipset(struct pci_dev *dev)
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);
......@@ -1471,6 +1456,8 @@ static unsigned int __init hpt366_ata66_check(struct ata_channel *ch)
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;
......@@ -1485,11 +1472,11 @@ static void __init hpt366_init_channel(struct ata_channel *ch)
#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, &reg5ah);
pci_read_config_byte(dev, 0x5a, &reg5ah);
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
......@@ -1498,23 +1485,20 @@ static void __init hpt366_init_channel(struct ata_channel *ch)
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;
......
......@@ -230,7 +230,7 @@ static unsigned long maxsectors (int major,int minor)
{
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);
......
......@@ -120,7 +120,7 @@
/*
* 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;
......@@ -195,7 +195,7 @@ static int __init try_to_init_ht6560b(void)
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;
......@@ -248,7 +248,7 @@ static byte ht_pio2timings(ide_drive_t *drive, byte pio)
/*
* 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;
......@@ -275,7 +275,7 @@ static void ht_set_prefetch(ide_drive_t *drive, byte state)
#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;
......
......@@ -2925,8 +2925,11 @@ int ide_cdrom_cleanup(struct ata_device *drive)
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,
......@@ -2942,67 +2945,63 @@ static struct ata_operations ide_cdrom_driver = {
/* options */
static char *ignore = NULL;
MODULE_PARM(ignore, "s");
MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static void __exit ide_cdrom_exit(void)
static void ide_cdrom_attach(struct ata_device *drive)
{
struct ata_device *drive;
int failed = 0;
struct cdrom_info *info;
char *req;
struct ata_channel *channel;
int unit;
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++;
}
}
if (drive->type != ATA_ROM)
return;
int ide_cdrom_init(void)
{
struct ata_device *drive;
struct cdrom_info *info;
int failed = 0;
req = drive->driver_req;
if (req[0] != '\0' && strcmp(req, "ide-cdrom"))
return;
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;
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 == NULL) {
printk ("%s: Can't allocate a cdrom structure\n", drive->name);
continue;
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 ("%s: Failed to register the driver with ide.c\n", drive->name);
printk(KERN_ERR "%s: Failed to register the driver with ide.c\n", drive->name);
kfree (info);
continue;
return;
}
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;
printk (KERN_ERR "%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
return;
}
MOD_DEC_USE_COUNT;
failed--;
}
revalidate_drives();
MOD_DEC_USE_COUNT;
return 0;
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)
{
unregister_ata_driver(&ide_cdrom_driver);
}
int ide_cdrom_init(void)
{
return ata_driver_module(&ide_cdrom_driver);
}
module_init(ide_cdrom_init);
......
......@@ -913,7 +913,7 @@ static void idedisk_setup(struct ata_device *drive)
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
......@@ -1149,12 +1149,14 @@ static int idedisk_ioctl(struct ata_device *drive, struct inode *inode, struct f
}
}
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,
......@@ -1167,46 +1169,49 @@ static struct ata_operations idedisk_driver = {
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;
int idedisk_init(void)
{
struct ata_device *drive;
int failed = 0;
req = drive->driver_req;
if (req[0] != '\0' && strcmp(req, "ide-disk"))
return;
MOD_INC_USE_COUNT;
while ((drive = ide_scan_devices(ATA_DISK, "ide-disk", NULL, failed++)) != NULL) {
if (ide_register_subdriver (drive, &idedisk_driver)) {
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;
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);
continue;
}
--failed;
return;
}
revalidate_drives();
MOD_DEC_USE_COUNT;
return 0;
channel = drive->channel;
unit = drive - channel->drives;
ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
}
static void __exit idedisk_exit(void)
{
unregister_ata_driver(&idedisk_driver);
}
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>
*/
......@@ -1977,11 +1975,14 @@ static int idefloppy_cleanup(struct ata_device *drive)
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,
......@@ -1994,59 +1995,60 @@ static struct ata_operations idefloppy_driver = {
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;
/*
* idefloppy_init will register the driver for each floppy.
*/
int idefloppy_init(void)
{
struct ata_device *drive;
idefloppy_floppy_t *floppy;
int failed = 0;
req = drive->driver_req;
if (req[0] != '\0' && strcmp(req, "ide-floppy"))
return;
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;
printk (KERN_ERR "ide-floppy: %s: not supported by this version of driver\n",
drive->name);
return;
}
if (drive->scsi) {
printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
continue;
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)) == NULL) {
printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
continue;
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);
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;
return;
}
MOD_INC_USE_COUNT;
idefloppy_setup (drive, floppy);
MOD_DEC_USE_COUNT;
failed--;
}
revalidate_drives();
MOD_DEC_USE_COUNT;
return 0;
idefloppy_setup(drive, floppy);
channel = drive->channel;
unit = drive - channel->drives;
ide_revalidate_disk(mk_kdev(channel->major, unit << PARTN_BITS));
}
MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
static void __exit idefloppy_exit(void)
{
unregister_ata_driver(&idefloppy_driver);
}
int __init idefloppy_init(void)
{
return ata_driver_module(&idefloppy_driver);
}
module_init(idefloppy_init);
......
......@@ -51,7 +51,7 @@ static void print_funcid (int func);
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 */
......@@ -437,7 +437,7 @@ void m8xx_ide_init_hwif_ports (hw_regs_t *hw,
/* 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;
......
......@@ -207,7 +207,8 @@ static unsigned long __init get_dma_base(struct ata_channel *hwif, int extra, co
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);
......@@ -553,14 +554,14 @@ static void __init pdc20270_device_order_fixup (struct pci_dev *dev, struct ata_
}
}
}
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);
}
......@@ -583,8 +584,8 @@ static void __init hpt374_device_order_fixup (struct pci_dev *dev, struct ata_pc
}
}
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;
......@@ -600,8 +601,8 @@ static void __init hpt374_device_order_fixup (struct pci_dev *dev, struct ata_pc
}
}
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);
}
......@@ -622,7 +623,8 @@ static void __init hpt366_device_order_fixup (struct pci_dev *dev, struct ata_pc
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;
......@@ -643,12 +645,14 @@ static void __init hpt366_device_order_fixup (struct pci_dev *dev, struct ata_pc
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);
}
......@@ -683,7 +687,7 @@ static void __init scan_pcidev(struct pci_dev *dev)
* 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;
......@@ -707,8 +711,8 @@ static void __init scan_pcidev(struct pci_dev *dev)
} 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.
......@@ -6054,11 +6050,11 @@ static void idetape_revalidate(struct ata_device *_dummy)
*/
}
/*
* 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,
......@@ -6070,6 +6066,8 @@ static struct ata_operations idetape_driver = {
revalidate: idetape_revalidate,
};
/*
* Our character device supporting functions, passed to register_chrdev.
*/
......@@ -6082,77 +6080,52 @@ static struct file_operations idetape_fops = {
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;
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("ide-tape: ide-scsi emulation is not supported for %s.\n", drive->id->model);
printk(KERN_INFO "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;
printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
return;
}
}
tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
if (tape == NULL) {
if (!tape) {
printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
continue;
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);
continue;
return;
}
for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
idetape_setup (drive, tape, minor);
......@@ -6168,18 +6141,32 @@ int idetape_init(void)
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);
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);
......
......@@ -68,6 +68,11 @@
#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.
*/
......@@ -134,6 +139,10 @@ static int irq_lock;
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:
*/
......@@ -687,7 +696,7 @@ static void ata_dump_bits(struct ata_bit_messages *msgs, int nr, byte bits)
u8 ide_dump_status(struct ata_device *drive, struct request * rq, const char *msg, u8 stat)
{
unsigned long flags;
byte err = 0;
u8 err = 0;
__save_flags (flags); /* local CPU only */
ide__sti(); /* local CPU only */
......@@ -1633,6 +1642,8 @@ struct ata_device *get_info_ptr(kdev_t i_rdev)
}
/*
* 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
......@@ -1683,10 +1694,9 @@ int ide_revalidate_disk(kdev_t i_rdev)
}
/*
* 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;
......@@ -1706,7 +1716,7 @@ void revalidate_drives(void)
}
}
static void ide_driver_module (void)
static void ide_driver_module(void)
{
int i;
......@@ -2016,7 +2026,7 @@ void ide_unregister(struct ata_channel *ch)
* may set up the hw structure yourself OR use this routine to
* do it for you.
*/
void ide_setup_ports ( hw_regs_t *hw,
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)
......@@ -2041,6 +2051,46 @@ void ide_setup_ports ( hw_regs_t *hw,
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.
......@@ -2049,18 +2099,19 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp)
{
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)
......@@ -2070,14 +2121,14 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp)
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();
......@@ -2086,10 +2137,19 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp)
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;
}
/*
......@@ -2178,7 +2238,7 @@ void ide_delay_50ms (void)
#else
__set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(HZ/20);
#endif /* CONFIG_BLK_DEV_IDECS */
#endif
}
/*
......@@ -2941,34 +3001,7 @@ int ide_end_request(struct ata_device *drive, struct request *rq, int uptodate)
}
/*
* 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)
{
......@@ -3056,7 +3089,6 @@ int ide_unregister_subdriver(struct ata_device *drive)
pnpide_init(0);
#endif
drive->driver = NULL;
drive->present = 0;
restore_flags(flags); /* all CPUs */
......@@ -3065,23 +3097,56 @@ int ide_unregister_subdriver(struct ata_device *drive)
/*
* 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);
......@@ -3098,21 +3163,14 @@ struct block_device_operations ide_fops[] = {{
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);
......@@ -3134,7 +3192,10 @@ EXPORT_SYMBOL(ide_unregister);
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;
......@@ -3178,8 +3239,8 @@ static int ide_notify_reboot (struct notifier_block *this, unsigned long event,
return NOTIFY_DONE;
}
static struct notifier_block ide_notifier = {
ide_notify_reboot,
static struct notifier_block ata_notifier = {
ata_sys_notify,
NULL,
5
};
......@@ -3191,18 +3252,19 @@ static int __init ata_module_init(void)
{
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;
......@@ -3385,7 +3447,7 @@ static int __init ata_module_init(void)
# 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
......@@ -3397,14 +3459,12 @@ static int __init ata_module_init(void)
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)
{
......@@ -3426,7 +3486,7 @@ static void __exit cleanup_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]);
}
......
......@@ -48,17 +48,17 @@
/*
* 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;
......@@ -139,7 +139,7 @@ static byte it8172_dma_2_pio (byte xfer_rate)
}
}
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;
......@@ -194,7 +194,7 @@ static int it8172_tune_chipset (ide_drive_t *drive, byte speed)
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;
......@@ -210,7 +210,7 @@ static int it8172_config_chipset_for_dma(ide_drive_t *drive)
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:
......
......@@ -119,7 +119,7 @@ void macide_init(void)
/* 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
......
......@@ -33,7 +33,7 @@ static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 };
* 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;
......@@ -78,7 +78,7 @@ static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
__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);
}
......
......@@ -137,7 +137,7 @@ int reg_base;
/* 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
......@@ -245,7 +245,7 @@ static void compute_clocks(int pio, pio_clocks_t *clks)
}
/* 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
......
......@@ -187,13 +187,38 @@ int check_in_drive_lists(struct ata_device *drive)
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;
......@@ -298,7 +323,6 @@ static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed)
if (!drive->init_speed)
drive->init_speed = speed;
err = ide_config_drive_speed(drive, speed);
drive->current_speed = speed;
#if PDC202XX_DEBUG_DRIVE_INFO
......@@ -308,7 +332,8 @@ static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed)
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) \
......@@ -335,8 +360,6 @@ static int pdc202xx_new_tune_chipset(struct ata_device *drive, byte speed)
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);
......@@ -426,10 +449,9 @@ static int pdc202xx_new_tune_chipset(struct ata_device *drive, byte speed)
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
......@@ -451,10 +473,11 @@ static void config_chipset_for_pio(struct ata_device *drive, byte pio)
}
#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;
......@@ -464,65 +487,41 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
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;
}
......@@ -540,39 +539,25 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
* 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 (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));
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)
}
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));
}
} else { /* udma4 drive by itself */
if (!jumpbit)
} else { /* single drive */
OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
}
}
......@@ -589,38 +574,23 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
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;
......@@ -640,35 +610,24 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
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)
......@@ -729,31 +688,23 @@ 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);
......@@ -774,9 +725,7 @@ static int pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
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);
......@@ -785,22 +734,17 @@ int pdc202xx_udma_stop(struct ata_device *drive)
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);
......@@ -822,7 +766,6 @@ static int pdc202xx_udma_irq_status(struct ata_device *drive)
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;
......@@ -838,7 +781,7 @@ static int pdc202xx_udma_irq_status(struct ata_device *drive)
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;
......@@ -918,22 +861,21 @@ static unsigned int __init pdc202xx_init_chipset(struct pci_dev *dev)
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 ?! */
break;
default:
if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
byte irq = 0, irq2 = 0;
......@@ -1039,55 +981,15 @@ static void __init ide_init_pdc202xx(struct ata_channel *hwif)
/* 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
......@@ -1098,7 +1000,9 @@ static struct ata_pci_device chipsets[] __initdata = {
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
......@@ -1109,8 +1013,12 @@ static struct ata_pci_device chipsets[] __initdata = {
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
},
......@@ -1120,12 +1028,13 @@ static struct ata_pci_device chipsets[] __initdata = {
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,
......
......@@ -377,7 +377,7 @@ static int pdcraid1_make_request (request_queue_t *q, int rw, struct buffer_head
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;
......
......@@ -112,7 +112,7 @@ byte __init qd_read_reg (byte reg)
* 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);
......@@ -164,7 +164,7 @@ static byte qd6580_compute_timing (int active_time, int recovery_time)
* 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;
......@@ -192,7 +192,7 @@ static int qd_find_disk_type (ide_drive_t *drive,
* 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),
......@@ -206,7 +206,7 @@ static int qd_timing_ok (ide_drive_t drives[])
* 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;
......@@ -225,7 +225,7 @@ static void qd_set_timing (ide_drive_t *drive, byte timing)
* 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 */
......@@ -247,7 +247,7 @@ static void qd6500_tune_drive (ide_drive_t *drive, byte pio)
* 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;
......
......@@ -240,6 +240,26 @@ extern char *ide_xfer_verbose (byte xfer_rate);
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 };
......@@ -251,11 +271,6 @@ static int svwks_tune_chipset(struct ata_device *drive, byte speed)
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;
......@@ -338,9 +353,6 @@ static int svwks_tune_chipset(struct ata_device *drive, byte speed)
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);
......@@ -349,16 +361,12 @@ static int svwks_tune_chipset(struct ata_device *drive, byte speed)
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)
......@@ -415,23 +423,14 @@ static void svwks_tune_drive(struct ata_device *drive, byte pio)
#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)
......
......@@ -71,7 +71,7 @@ static unsigned int get_timing_sl82c105(struct ata_timing *t)
/*
* 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;
......@@ -109,7 +109,7 @@ static void config_for_pio(ide_drive_t *drive, int pio, int report)
/*
* 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;
......@@ -131,7 +131,7 @@ static int config_for_dma(ide_drive_t *drive)
* 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;
......@@ -240,7 +240,7 @@ static void sl82c105_timeout(struct ata_device *drive)
* 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;
......@@ -273,7 +273,7 @@ static void sl82c105_lostirq(ide_drive_t *drive)
* 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);
......
......@@ -502,11 +502,14 @@ static void idescsi_revalidate(struct ata_device *_dummy)
*/
}
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,
......@@ -519,45 +522,40 @@ static struct ata_operations idescsi_driver = {
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) {
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);
continue;
printk(KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
return;
}
if (ide_register_subdriver (drive, &idescsi_driver)) {
printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
printk(KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (scsi);
continue;
return;
}
for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++);
idescsi_setup (drive, scsi, id);
failed--;
}
}
revalidate_drives();
MOD_DEC_USE_COUNT;
return 0;
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)
......@@ -805,38 +803,31 @@ static Scsi_Host_Template idescsi_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++;
}
}
#endif
unregister_ata_driver(&idescsi_driver);
}
module_init(init_idescsi_module);
module_init(idescsi_init);
module_exit(exit_idescsi_module);
MODULE_LICENSE("GPL");
......@@ -317,7 +317,6 @@ typedef union {
/*
* ATA/ATAPI device structure :
*/
typedef
struct ata_device {
struct ata_channel * channel;
char name[6]; /* device name */
......@@ -409,7 +408,7 @@ struct ata_device {
unsigned long immed_comp;
int max_last_depth;
int max_depth;
} ide_drive_t;
};
/*
* Status returned by various functions.
......@@ -590,6 +589,7 @@ static inline int ata_can_queue(struct ata_device *drive)
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);
......@@ -602,6 +602,9 @@ struct ata_operations {
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 */
......@@ -618,11 +621,20 @@ do { \
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)
......@@ -797,9 +809,9 @@ extern int idefloppy_init (void);
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
......@@ -890,6 +902,5 @@ extern spinlock_t ide_lock;
#define DRIVE_LOCK(drive) ((drive)->queue.queue_lock)
extern int drive_is_ready(struct ata_device *drive);
extern void revalidate_drives(void);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment