Commit 13413379 authored by Linus Torvalds's avatar Linus Torvalds

Merge

parents 6177c8bb ac5bdbb7
...@@ -37,9 +37,27 @@ ...@@ -37,9 +37,27 @@
*** ***
*** Use of the "serialize" option is no longer necessary. *** 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). Common pitfalls:
There can be up to two drives per interface, as per the ATA-6 spec.
- 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 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 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) { ...@@ -192,7 +192,7 @@ unsigned char IN_BYTE(ide_ioreg_t reg) {
#define ATA_PIO0_HOLD 4 #define ATA_PIO0_HOLD 4
static int e100_dmaproc(ide_dma_action_t func, struct ata_device *drive, struct request *rq); 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); void *buffer, unsigned int length);
/* /*
...@@ -206,7 +206,7 @@ const char *good_dma_drives[] = {"Micropolis 2112A", ...@@ -206,7 +206,7 @@ const char *good_dma_drives[] = {"Micropolis 2112A",
"CONNER CTT8000-A", "CONNER CTT8000-A",
NULL}; 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; unsigned long flags;
...@@ -380,7 +380,7 @@ static etrax_dma_descr mydescr; ...@@ -380,7 +380,7 @@ static etrax_dma_descr mydescr;
* extra byte allocated for the buffer. * extra byte allocated for the buffer.
*/ */
static void 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; ide_ioreg_t data_reg = IDE_DATA_REG;
...@@ -459,7 +459,7 @@ e100_atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount) ...@@ -459,7 +459,7 @@ e100_atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount)
} }
static void 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; ide_ioreg_t data_reg = IDE_DATA_REG;
...@@ -546,7 +546,7 @@ e100_atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount) ...@@ -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 * This is used for most PIO data transfers *from* the IDE interface
*/ */
static void 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); e100_atapi_read(drive, buffer, wcount << 2);
} }
...@@ -555,7 +555,7 @@ e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount) ...@@ -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 * This is used for most PIO data transfers *to* the IDE interface
*/ */
static void 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); e100_atapi_write(drive, buffer, wcount << 2);
} }
...@@ -661,7 +661,7 @@ static int e100_udma_new_table(struct ata_channel *ch, struct request *rq) ...@@ -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 */ 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; const char **list;
struct hd_driveid *id = drive->id; struct hd_driveid *id = drive->id;
......
...@@ -131,12 +131,7 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then ...@@ -131,12 +131,7 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
bool ' IGNORE word93 Validation BITS' CONFIG_IDEDMA_IVB bool ' IGNORE word93 Validation BITS' CONFIG_IDEDMA_IVB
fi fi
if [ "$CONFIG_BLK_DEV_IDECD" != "n" -o \ define_bool CONFIG_ATAPI y
"$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 else
bool 'Old hard disk (MFM/RLL/IDE) driver' CONFIG_BLK_DEV_HD_ONLY bool 'Old hard disk (MFM/RLL/IDE) driver' CONFIG_BLK_DEV_HD_ONLY
define_bool CONFIG_BLK_DEV_HD $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 ...@@ -21,7 +21,7 @@ obj-$(CONFIG_BLK_DEV_HD) += hd.o
obj-$(CONFIG_BLK_DEV_IDE) += ide-mod.o obj-$(CONFIG_BLK_DEV_IDE) += ide-mod.o
obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o
obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.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_IDECD) += ide-cd.o
obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o
obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o
...@@ -74,6 +74,6 @@ obj-$(CONFIG_BLK_DEV_ATARAID) += ataraid.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_PDC) += pdcraid.o
obj-$(CONFIG_BLK_DEV_ATARAID_HPT) += hptraid.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 include $(TOPDIR)/Rules.make
...@@ -607,27 +607,7 @@ static struct ata_pci_device chipsets[] __initdata = { ...@@ -607,27 +607,7 @@ static struct ata_pci_device chipsets[] __initdata = {
enablebits: { {0x00,0x00,0x00}, {0x00,0x00,0x00} }, enablebits: { {0x00,0x00,0x00}, {0x00,0x00,0x00} },
bootable: OFF_BOARD, bootable: OFF_BOARD,
flags: ATA_F_IRQ | ATA_F_DMA 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) int __init init_aec62xx(void)
......
...@@ -226,9 +226,9 @@ static void amd_set_speed(struct pci_dev *dev, unsigned char dn, struct ata_timi ...@@ -226,9 +226,9 @@ static void amd_set_speed(struct pci_dev *dev, unsigned char dn, struct ata_timi
* by upper layers. * 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; struct ata_timing t, p;
int T, UT; int T, UT;
...@@ -263,7 +263,7 @@ static int amd_set_drive(ide_drive_t *drive, unsigned char speed) ...@@ -263,7 +263,7 @@ static int amd_set_drive(ide_drive_t *drive, unsigned char speed)
* PIO-only tuning. * 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)) if (!((amd_enabled >> drive->channel->unit) & 1))
return; return;
......
...@@ -81,7 +81,7 @@ extern char *ide_xfer_verbose (byte xfer_rate); ...@@ -81,7 +81,7 @@ extern char *ide_xfer_verbose (byte xfer_rate);
/* /*
* Set a new transfer mode at the drive * 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; int error = 0;
...@@ -113,7 +113,7 @@ static unsigned int cs5530_pio_timings[2][5] = ...@@ -113,7 +113,7 @@ static unsigned int cs5530_pio_timings[2][5] =
* The ide_init_cs5530() routine guarantees that all drives * The ide_init_cs5530() routine guarantees that all drives
* will have valid default PIO timings set up before we get here. * 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; struct ata_channel *hwif = drive->channel;
unsigned int format, basereg = CS5530_BASEREG(hwif); 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 ...@@ -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 * cs5530_config_dma() handles selection/setting of DMA/UDMA modes
* for both the chipset and drive. * 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; int udma_ok = 1, mode = 0;
struct ata_channel *hwif = drive->channel; struct ata_channel *hwif = drive->channel;
int unit = drive->select.b.unit; 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; struct hd_driveid *id = drive->id;
unsigned int basereg, reg, timings; unsigned int basereg, reg, timings;
......
...@@ -183,7 +183,7 @@ static void compute_clocks (byte pio, pio_clocks_t *p_pclk) ...@@ -183,7 +183,7 @@ static void compute_clocks (byte pio, pio_clocks_t *p_pclk)
/* /*
* set DMA mode a specific channel for CY82C693 * 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 index;
byte data; byte data;
...@@ -270,7 +270,7 @@ static int cy82c693_dmaproc(struct ata_device *drive) ...@@ -270,7 +270,7 @@ static int cy82c693_dmaproc(struct ata_device *drive)
/* /*
* tune ide drive - set PIO mode * 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 ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
......
...@@ -66,7 +66,7 @@ static void sub22 (char b, char c) ...@@ -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; unsigned long flags;
......
...@@ -94,9 +94,9 @@ static int hpt34x_get_info (char *buffer, char **addr, off_t offset, int count) ...@@ -94,9 +94,9 @@ static int hpt34x_get_info (char *buffer, char **addr, off_t offset, int count)
byte hpt34x_proc = 0; 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 reg1 = 0, tmp1 = 0;
unsigned int reg2 = 0, tmp2 = 0; unsigned int reg2 = 0, tmp2 = 0;
...@@ -109,7 +109,7 @@ static void hpt34x_clear_chipset (ide_drive_t *drive) ...@@ -109,7 +109,7 @@ static void hpt34x_clear_chipset (ide_drive_t *drive)
pci_write_config_dword(drive->channel->pci_dev, 0x48, tmp2); 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; byte hi_speed, lo_speed;
unsigned int reg1 = 0, tmp1 = 0; unsigned int reg1 = 0, tmp1 = 0;
...@@ -145,7 +145,7 @@ static int hpt34x_tune_chipset (ide_drive_t *drive, byte speed) ...@@ -145,7 +145,7 @@ static int hpt34x_tune_chipset (ide_drive_t *drive, byte speed)
return ide_config_drive_speed(drive, 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 eide_pio_timing[6] = {960, 480, 240, 180, 120, 90};
unsigned short xfer_pio = drive->id->eide_pio_modes; unsigned short xfer_pio = drive->id->eide_pio_modes;
...@@ -182,7 +182,7 @@ static void config_chipset_for_pio(ide_drive_t *drive) ...@@ -182,7 +182,7 @@ static void config_chipset_for_pio(ide_drive_t *drive)
(void) hpt34x_tune_chipset(drive, speed); (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; byte speed;
......
...@@ -471,6 +471,8 @@ static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = { ...@@ -471,6 +471,8 @@ static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = {
#endif #endif
#define HPT366_DEBUG_DRIVE_INFO 0 #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 HPT370_ALLOW_ATA100_5 1
#define HPT366_ALLOW_ATA66_4 1 #define HPT366_ALLOW_ATA66_4 1
#define HPT366_ALLOW_ATA66_3 1 #define HPT366_ALLOW_ATA66_3 1
...@@ -484,14 +486,9 @@ static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = { ...@@ -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 struct pci_dev *hpt_devs[HPT366_MAX_DEVS];
static int n_hpt_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; 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) #if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
static int hpt366_get_info(char *, char **, off_t, int); 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) ...@@ -531,7 +528,7 @@ static int hpt366_get_info (char *buffer, char **addr, off_t offset, int count)
(c0 & 0x80) ? "no" : "yes", (c0 & 0x80) ? "no" : "yes",
(c1 & 0x80) ? "no" : "yes"); (c1 & 0x80) ? "no" : "yes");
if (pci_rev3_check_hpt3xx(dev)) { if (hpt_min_rev(dev, 3)) {
u8 cbl; u8 cbl;
cbl = inb_p(iobase + 0x7b); cbl = inb_p(iobase + 0x7b);
outb_p(cbl | 1, 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) ...@@ -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) */ #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) static int check_in_drive_lists(struct ata_device *drive, const char **list)
{ {
struct hd_driveid *id = drive->id; struct hd_driveid *id = drive->id;
...@@ -644,6 +597,64 @@ static int check_in_drive_lists(struct ata_device *drive, const char **list) ...@@ -644,6 +597,64 @@ static int check_in_drive_lists(struct ata_device *drive, const char **list)
return 0; 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) static unsigned int pci_bus_clock_list(byte speed, struct chipset_bus_clock_list_entry * chipset_table)
{ {
for ( ; chipset_table->xfer_speed ; chipset_table++) for ( ; chipset_table->xfer_speed ; chipset_table++)
...@@ -772,19 +783,21 @@ static void hpt374_tune_chipset(struct ata_device *drive, byte speed) ...@@ -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) 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)) if ((drive->type != ATA_DISK) && (speed < XFER_SW_DMA_0))
return -1; return -1;
if (!drive->init_speed) if (!drive->init_speed)
drive->init_speed = 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); 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); 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); 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); hpt368_tune_chipset(drive, speed);
} else { } else {
hpt366_tune_chipset(drive, speed); hpt366_tune_chipset(drive, speed);
...@@ -845,77 +858,57 @@ static void hpt3xx_tune_drive(struct ata_device *drive, byte pio) ...@@ -845,77 +858,57 @@ static void hpt3xx_tune_drive(struct ata_device *drive, byte pio)
} }
#ifdef CONFIG_BLK_DEV_IDEDMA #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) 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 speed = 0x00; int map;
byte ultra66 = eighty_ninty_three(drive); byte mode;
int rval;
/* FIXME: remove this --bkz */
config_chipset_for_pio(drive); 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; return 0;
if ((id->dma_ultra & 0x0040) && /* FIXME: check SWDMA modes --bkz */
(pci_rev5_check_hpt3xx(drive->channel->pci_dev)) && map = hpt3xx_ratemask(drive) | XFER_MWDMA;
(ultra66)) { mode = ata_timing_mode(drive, map);
speed = XFER_UDMA_6;
} else if ((id->dma_ultra & 0x0020) && /* FIXME: badlists need futher investigation --bkz
(!check_in_drive_lists(drive, bad_ata100_5)) && bad_ata100_5 is for HPT370/370A,
(HPT370_ALLOW_ATA100_5) && bad_ata66_4, bad_ata66_3 and bad_ata33 are for HPT366/368
(pci_rev_check_hpt3xx(drive->channel->pci_dev)) && */
(pci_rev3_check_hpt3xx(drive->channel->pci_dev)) && if (mode == XFER_UDMA_5 && hpt_min_rev(dev, 5)) {
(ultra66)) { if (check_in_drive_lists(drive, bad_ata100_5)) {
speed = XFER_UDMA_5; /* FIXME: make XFER_UDMA_66/100/133
} else if ((id->dma_ultra & 0x0010) && independent of XFER_UDMA --bkz */
(!check_in_drive_lists(drive, bad_ata66_4)) && map &= ~XFER_UDMA_100;
(HPT366_ALLOW_ATA66_4) && map |= XFER_UDMA;
(ultra66)) { mode = ata_timing_mode(drive, map);
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;
} }
} 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); return !hpt3xx_tune_chipset(drive, mode);
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;
} }
static int hpt3xx_quirkproc(struct ata_device *drive) static int hpt3xx_quirkproc(struct ata_device *drive)
...@@ -937,7 +930,7 @@ static void hpt3xx_maskproc(struct ata_device *drive, int mask) ...@@ -937,7 +930,7 @@ static void hpt3xx_maskproc(struct ata_device *drive, int mask)
struct pci_dev *dev = drive->channel->pci_dev; struct pci_dev *dev = drive->channel->pci_dev;
if (drive->quirk_list) { if (drive->quirk_list) {
if (pci_rev3_check_hpt3xx(dev)) { if (hpt_min_rev(dev, 3)) {
byte reg5a = 0; byte reg5a = 0;
pci_read_config_byte(dev, 0x5a, &reg5a); pci_read_config_byte(dev, 0x5a, &reg5a);
if (((reg5a & 0x10) >> 4) != mask) if (((reg5a & 0x10) >> 4) != mask)
...@@ -1283,11 +1276,9 @@ static void __init hpt37x_init(struct pci_dev *dev) ...@@ -1283,11 +1276,9 @@ static void __init hpt37x_init(struct pci_dev *dev)
freq &= 0x1FF; freq &= 0x1FF;
if (freq < 0x9c) { if (freq < 0x9c) {
pll = F_LOW_PCI_33; pll = F_LOW_PCI_33;
if (pci_rev7_check_hpt3xx(dev)) { if (hpt_min_rev(dev, 7)) {
dev->sysdata = (void *) thirty_three_base_hpt374; dev->sysdata = (void *) thirty_three_base_hpt374;
} else if (pci_rev5_check_hpt3xx(dev)) { } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) thirty_three_base_hpt372;
} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
dev->sysdata = (void *) thirty_three_base_hpt372; dev->sysdata = (void *) thirty_three_base_hpt372;
} else { } else {
dev->sysdata = (void *) thirty_three_base_hpt370; dev->sysdata = (void *) thirty_three_base_hpt370;
...@@ -1297,12 +1288,10 @@ static void __init hpt37x_init(struct pci_dev *dev) ...@@ -1297,12 +1288,10 @@ static void __init hpt37x_init(struct pci_dev *dev)
pll = F_LOW_PCI_40; pll = F_LOW_PCI_40;
} else if (freq < 0xc8) { } else if (freq < 0xc8) {
pll = F_LOW_PCI_50; pll = F_LOW_PCI_50;
if (pci_rev7_check_hpt3xx(dev)) { if (hpt_min_rev(dev, 7)) {
// dev->sysdata = (void *) fifty_base_hpt374; // dev->sysdata = (void *) fifty_base_hpt374;
BUG(); BUG();
} else if (pci_rev5_check_hpt3xx(dev)) { } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) fifty_base_hpt372;
} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
dev->sysdata = (void *) fifty_base_hpt372; dev->sysdata = (void *) fifty_base_hpt372;
} else { } else {
dev->sysdata = (void *) fifty_base_hpt370; dev->sysdata = (void *) fifty_base_hpt370;
...@@ -1310,12 +1299,10 @@ static void __init hpt37x_init(struct pci_dev *dev) ...@@ -1310,12 +1299,10 @@ static void __init hpt37x_init(struct pci_dev *dev)
printk("HPT37X: using 50MHz PCI clock\n"); printk("HPT37X: using 50MHz PCI clock\n");
} else { } else {
pll = F_LOW_PCI_66; pll = F_LOW_PCI_66;
if (pci_rev7_check_hpt3xx(dev)) { if (hpt_min_rev(dev, 7)) {
// dev->sysdata = (void *) sixty_six_base_hpt374; // dev->sysdata = (void *) sixty_six_base_hpt374;
BUG(); BUG();
} else if (pci_rev5_check_hpt3xx(dev)) { } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) sixty_six_base_hpt372;
} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
dev->sysdata = (void *) sixty_six_base_hpt372; dev->sysdata = (void *) sixty_six_base_hpt372;
} else { } else {
dev->sysdata = (void *) sixty_six_base_hpt370; dev->sysdata = (void *) sixty_six_base_hpt370;
...@@ -1358,12 +1345,10 @@ static void __init hpt37x_init(struct pci_dev *dev) ...@@ -1358,12 +1345,10 @@ static void __init hpt37x_init(struct pci_dev *dev)
pci_write_config_dword(dev, 0x5c, pci_write_config_dword(dev, 0x5c,
pll & ~0x100); pll & ~0x100);
pci_write_config_byte(dev, 0x5b, 0x21); 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; // dev->sysdata = (void *) fifty_base_hpt374;
BUG(); BUG();
} else if (pci_rev5_check_hpt3xx(dev)) { } else if (hpt_min_rev(dev, 5)) {
dev->sysdata = (void *) fifty_base_hpt372;
} else if (dev->device == PCI_DEVICE_ID_TTI_HPT372) {
dev->sysdata = (void *) fifty_base_hpt372; dev->sysdata = (void *) fifty_base_hpt372;
} else { } else {
dev->sysdata = (void *) fifty_base_hpt370; dev->sysdata = (void *) fifty_base_hpt370;
...@@ -1437,7 +1422,7 @@ static unsigned int __init hpt366_init_chipset(struct pci_dev *dev) ...@@ -1437,7 +1422,7 @@ static unsigned int __init hpt366_init_chipset(struct pci_dev *dev)
if (test != 0x08) if (test != 0x08)
pci_write_config_byte(dev, PCI_MAX_LAT, 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); hpt37x_init(dev);
else else
hpt366_init(dev); hpt366_init(dev);
...@@ -1471,6 +1456,8 @@ static unsigned int __init hpt366_ata66_check(struct ata_channel *ch) ...@@ -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) static void __init hpt366_init_channel(struct ata_channel *ch)
{ {
struct pci_dev *dev = ch->pci_dev;
ch->tuneproc = hpt3xx_tune_drive; ch->tuneproc = hpt3xx_tune_drive;
ch->speedproc = hpt3xx_tune_chipset; ch->speedproc = hpt3xx_tune_chipset;
ch->quirkproc = hpt3xx_quirkproc; ch->quirkproc = hpt3xx_quirkproc;
...@@ -1485,11 +1472,11 @@ static void __init hpt366_init_channel(struct ata_channel *ch) ...@@ -1485,11 +1472,11 @@ static void __init hpt366_init_channel(struct ata_channel *ch)
#ifdef CONFIG_BLK_DEV_IDEDMA #ifdef CONFIG_BLK_DEV_IDEDMA
if (ch->dma_base) { if (ch->dma_base) {
if (pci_rev3_check_hpt3xx(ch->pci_dev)) { if (hpt_min_rev(dev, 3)) {
byte reg5ah = 0; 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 */ 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. * set up ioctl for power status.
* note: power affects both * note: power affects both
...@@ -1498,23 +1485,20 @@ static void __init hpt366_init_channel(struct ata_channel *ch) ...@@ -1498,23 +1485,20 @@ static void __init hpt366_init_channel(struct ata_channel *ch)
ch->resetproc = hpt3xx_reset; ch->resetproc = hpt3xx_reset;
ch->busproc = hpt370_busproc; ch->busproc = hpt370_busproc;
if (pci_rev7_check_hpt3xx(ch->pci_dev)) { if (hpt_min_rev(dev, 7)) {
ch->udma_stop = hpt374_udma_stop;
ch->XXX_udma = hpt374_dmaproc;
} else if (pci_rev5_check_hpt3xx(ch->pci_dev)) {
ch->udma_stop = hpt374_udma_stop; ch->udma_stop = hpt374_udma_stop;
ch->XXX_udma = hpt374_dmaproc; 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->udma_stop = hpt374_udma_stop;
ch->XXX_udma = hpt374_dmaproc; 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_start = hpt370_udma_start;
ch->udma_stop = hpt370_udma_stop; ch->udma_stop = hpt370_udma_stop;
ch->udma_timeout = hpt370_udma_timeout; ch->udma_timeout = hpt370_udma_timeout;
ch->udma_irq_lost = hpt370_udma_irq_lost; ch->udma_irq_lost = hpt370_udma_irq_lost;
ch->XXX_udma = hpt370_dmaproc; 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->udma_irq_lost = hpt366_udma_irq_lost;
// ch->resetproc = hpt3xx_reset; // ch->resetproc = hpt3xx_reset;
// ch->busproc = hpt3xx_tristate; // ch->busproc = hpt3xx_tristate;
......
...@@ -230,14 +230,14 @@ static unsigned long maxsectors (int major,int minor) ...@@ -230,14 +230,14 @@ static unsigned long maxsectors (int major,int minor)
{ {
unsigned long lba = 0; unsigned long lba = 0;
kdev_t dev; kdev_t dev;
ide_drive_t *ideinfo; struct ata_device *ideinfo;
dev = mk_kdev(major,minor); dev = mk_kdev(major,minor);
ideinfo = get_info_ptr (dev); ideinfo = get_info_ptr (dev);
if (ideinfo==NULL) if (ideinfo==NULL)
return 0; return 0;
/* first sector of the last cluster */ /* first sector of the last cluster */
if (ideinfo->head==0) if (ideinfo->head==0)
return 0; return 0;
......
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
/* /*
* This routine is invoked from ide.c to prepare for access to a given drive. * 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; unsigned long flags;
static byte current_select = 0; static byte current_select = 0;
...@@ -195,7 +195,7 @@ static int __init try_to_init_ht6560b(void) ...@@ -195,7 +195,7 @@ static int __init try_to_init_ht6560b(void)
return 1; 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_time, recovery_time;
int active_cycles, recovery_cycles; int active_cycles, recovery_cycles;
...@@ -248,7 +248,7 @@ static byte ht_pio2timings(ide_drive_t *drive, byte pio) ...@@ -248,7 +248,7 @@ static byte ht_pio2timings(ide_drive_t *drive, byte pio)
/* /*
* Enable/Disable so called prefetch mode * 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; unsigned long flags;
int t = HT_PREFETCH_MODE << 8; int t = HT_PREFETCH_MODE << 8;
...@@ -275,7 +275,7 @@ static void ht_set_prefetch(ide_drive_t *drive, byte state) ...@@ -275,7 +275,7 @@ static void ht_set_prefetch(ide_drive_t *drive, byte state)
#endif #endif
} }
static void tune_ht6560b (ide_drive_t *drive, byte pio) static void tune_ht6560b(struct ata_device *drive, byte pio)
{ {
unsigned long flags; unsigned long flags;
byte timing; byte timing;
......
...@@ -2925,8 +2925,11 @@ int ide_cdrom_cleanup(struct ata_device *drive) ...@@ -2925,8 +2925,11 @@ int ide_cdrom_cleanup(struct ata_device *drive)
return 0; return 0;
} }
static void ide_cdrom_attach(struct ata_device *drive);
static struct ata_operations ide_cdrom_driver = { static struct ata_operations ide_cdrom_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
attach: ide_cdrom_attach,
cleanup: ide_cdrom_cleanup, cleanup: ide_cdrom_cleanup,
standby: NULL, standby: NULL,
do_request: ide_cdrom_do_request, do_request: ide_cdrom_do_request,
...@@ -2942,67 +2945,63 @@ static struct ata_operations ide_cdrom_driver = { ...@@ -2942,67 +2945,63 @@ static struct ata_operations ide_cdrom_driver = {
/* options */ /* options */
static char *ignore = NULL; 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_PARM(ignore, "s");
MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static void __exit ide_cdrom_exit(void) static void __exit ide_cdrom_exit(void)
{ {
struct ata_device *drive; unregister_ata_driver(&ide_cdrom_driver);
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++;
}
} }
int ide_cdrom_init(void) int ide_cdrom_init(void)
{ {
struct ata_device *drive; return ata_driver_module(&ide_cdrom_driver);
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;
} }
module_init(ide_cdrom_init); module_init(ide_cdrom_init);
......
...@@ -913,7 +913,7 @@ static void idedisk_setup(struct ata_device *drive) ...@@ -913,7 +913,7 @@ static void idedisk_setup(struct ata_device *drive)
if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) && if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) &&
(!drive->forced_geom) && 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; 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 #if 0
...@@ -1149,12 +1149,14 @@ static int idedisk_ioctl(struct ata_device *drive, struct inode *inode, struct f ...@@ -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. * Subdriver functions.
*/ */
static struct ata_operations idedisk_driver = { static struct ata_operations idedisk_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
attach: idedisk_attach,
cleanup: idedisk_cleanup, cleanup: idedisk_cleanup,
standby: idedisk_standby, standby: idedisk_standby,
do_request: idedisk_do_request, do_request: idedisk_do_request,
...@@ -1167,46 +1169,49 @@ static struct ata_operations idedisk_driver = { ...@@ -1167,46 +1169,49 @@ static struct ata_operations idedisk_driver = {
capacity: idedisk_capacity, capacity: idedisk_capacity,
}; };
MODULE_DESCRIPTION("ATA DISK Driver"); static void idedisk_attach(struct ata_device *drive)
static void __exit idedisk_exit (void)
{ {
struct ata_device *drive; char *req;
int failed = 0; struct ata_channel *channel;
int unit;
while ((drive = ide_scan_devices(ATA_DISK, "ide-disk", &idedisk_driver, failed)) != NULL) { if (drive->type != ATA_DISK)
if (idedisk_cleanup (drive)) { return;
printk(KERN_ERR "%s: cleanup_module() called while still busy\n", drive->name);
++failed; 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; unregister_ata_driver(&idedisk_driver);
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;
return 0; int __init idedisk_init(void)
{
return ata_driver_module(&idedisk_driver);
} }
module_init(idedisk_init); module_init(idedisk_init);
module_exit(idedisk_exit); module_exit(idedisk_exit);
MODULE_DESCRIPTION("ATA DISK Driver");
MODULE_LICENSE("GPL"); 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) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il>
* Copyright (C) 2000 - 2002 Paul Bristow <paul@paulbristow.net> * Copyright (C) 2000 - 2002 Paul Bristow <paul@paulbristow.net>
*/ */
...@@ -1977,11 +1975,14 @@ static int idefloppy_cleanup(struct ata_device *drive) ...@@ -1977,11 +1975,14 @@ static int idefloppy_cleanup(struct ata_device *drive)
return 0; return 0;
} }
static void idefloppy_attach(struct ata_device *drive);
/* /*
* IDE subdriver functions, registered with ide.c * IDE subdriver functions, registered with ide.c
*/ */
static struct ata_operations idefloppy_driver = { static struct ata_operations idefloppy_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
attach: idefloppy_attach,
cleanup: idefloppy_cleanup, cleanup: idefloppy_cleanup,
standby: NULL, standby: NULL,
do_request: idefloppy_do_request, do_request: idefloppy_do_request,
...@@ -1994,59 +1995,60 @@ static struct ata_operations idefloppy_driver = { ...@@ -1994,59 +1995,60 @@ static struct ata_operations idefloppy_driver = {
capacity: idefloppy_capacity, capacity: idefloppy_capacity,
}; };
MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); static void idefloppy_attach(struct ata_device *drive)
static void __exit idefloppy_exit(void)
{ {
struct ata_device *drive; idefloppy_floppy_t *floppy;
int failed = 0; char *req;
struct ata_channel *channel;
int unit;
while ((drive = ide_scan_devices(ATA_FLOPPY, "ide-floppy", &idefloppy_driver, failed)) != NULL) { if (drive->type != ATA_FLOPPY)
if (idefloppy_cleanup(drive)) { return;
printk ("%s: cleanup_module() called while still busy\n", drive->name);
failed++; 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));
} }
/* MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
* idefloppy_init will register the driver for each floppy.
*/
int idefloppy_init(void)
{
struct ata_device *drive;
idefloppy_floppy_t *floppy;
int failed = 0;
printk("ide-floppy driver " IDEFLOPPY_VERSION "\n"); static void __exit idefloppy_exit(void)
MOD_INC_USE_COUNT; {
while ((drive = ide_scan_devices (ATA_FLOPPY, "ide-floppy", NULL, failed++)) != NULL) { unregister_ata_driver(&idefloppy_driver);
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;
failed--; int __init idefloppy_init(void)
} {
revalidate_drives(); return ata_driver_module(&idefloppy_driver);
MOD_DEC_USE_COUNT;
return 0;
} }
module_init(idefloppy_init); module_init(idefloppy_init);
......
...@@ -51,7 +51,7 @@ static void print_funcid (int func); ...@@ -51,7 +51,7 @@ static void print_funcid (int func);
static int check_ide_device (unsigned long base); static int check_ide_device (unsigned long base);
static void ide_interrupt_ack (void *dev); 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 { typedef struct ide_ioport_desc {
unsigned long base_off; /* Offset to PCMCIA memory */ unsigned long base_off; /* Offset to PCMCIA memory */
...@@ -437,7 +437,7 @@ void m8xx_ide_init_hwif_ports (hw_regs_t *hw, ...@@ -437,7 +437,7 @@ void m8xx_ide_init_hwif_ports (hw_regs_t *hw,
/* Calculate PIO timings */ /* Calculate PIO timings */
static void 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) #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
volatile pcmconf8xx_t *pcmp; volatile pcmconf8xx_t *pcmp;
......
...@@ -207,7 +207,8 @@ static unsigned long __init get_dma_base(struct ata_channel *hwif, int extra, co ...@@ -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) || 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_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); outb(inb(dma_base + 2) & 0x60, dma_base+2);
if (inb(dma_base + 2) & 0x80) if (inb(dma_base + 2) & 0x80)
printk(KERN_INFO "%s: simplex device: DMA forced\n", name); 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_ ...@@ -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", printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
dev->name, dev->slot_name, dev->devfn); dev->name, dev->slot_name);
setup_pci_device(dev, d); setup_pci_device(dev, d);
if (!dev2) if (!dev2)
return; return;
d2 = d; d2 = d;
printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n", printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
dev2->name, dev2->slot_name, dev2->devfn); dev2->name, dev2->slot_name);
setup_pci_device(dev2, d2); setup_pci_device(dev2, d2);
} }
...@@ -583,8 +584,8 @@ static void __init hpt374_device_order_fixup (struct pci_dev *dev, struct ata_pc ...@@ -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", printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
dev->name, dev->slot_name, dev->devfn); dev->name, dev->slot_name);
setup_pci_device(dev, d); setup_pci_device(dev, d);
if (!dev2) { if (!dev2) {
return; return;
...@@ -600,8 +601,8 @@ static void __init hpt374_device_order_fixup (struct pci_dev *dev, struct ata_pc ...@@ -600,8 +601,8 @@ static void __init hpt374_device_order_fixup (struct pci_dev *dev, struct ata_pc
} }
} }
d2 = d; d2 = d;
printk(KERN_INFO "ATA: %s: controller on PCI slot %s dev %02x\n", printk(KERN_INFO "ATA: %s: controller, PCI slot %s\n",
dev2->name, dev2->slot_name, dev2->devfn); dev2->name, dev2->slot_name);
setup_pci_device(dev2, d2); setup_pci_device(dev2, d2);
} }
...@@ -622,7 +623,8 @@ static void __init hpt366_device_order_fixup (struct pci_dev *dev, struct ata_pc ...@@ -622,7 +623,8 @@ static void __init hpt366_device_order_fixup (struct pci_dev *dev, struct ata_pc
switch(class_rev) { switch(class_rev) {
case 5: case 5:
case 4: 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); setup_pci_device(dev, d);
return; return;
default: break; default: break;
...@@ -643,12 +645,14 @@ static void __init hpt366_device_order_fixup (struct pci_dev *dev, struct ata_pc ...@@ -643,12 +645,14 @@ static void __init hpt366_device_order_fixup (struct pci_dev *dev, struct ata_pc
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); setup_pci_device(dev, d);
if (!dev2) if (!dev2)
return; return;
d2 = d; 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); setup_pci_device(dev2, d2);
} }
...@@ -683,7 +687,7 @@ static void __init scan_pcidev(struct pci_dev *dev) ...@@ -683,7 +687,7 @@ static void __init scan_pcidev(struct pci_dev *dev)
* beeing grabbed by generic drivers. * beeing grabbed by generic drivers.
*/ */
if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) { 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); dev->name, dev->slot_name);
} }
return; return;
...@@ -707,8 +711,8 @@ static void __init scan_pcidev(struct pci_dev *dev) ...@@ -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) } else if (d->vendor == PCI_VENDOR_ID_PROMISE && d->device == PCI_DEVICE_ID_PROMISE_20268R)
pdc20270_device_order_fixup(dev, d); pdc20270_device_order_fixup(dev, d);
else { else {
printk(KERN_INFO "ATA: %s (%04x:%04x) on PCI slot %s\n", printk(KERN_INFO "ATA: %s, PCI slot %s\n",
dev->name, vendor, device, dev->slot_name); dev->name, dev->slot_name);
setup_pci_device(dev, d); 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> * Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il>
* *
* $Header$
*
* This driver was constructed as a student project in the software laboratory * This driver was constructed as a student project in the software laboratory
* of the faculty of electrical engineering in the Technion - Israel's * of the faculty of electrical engineering in the Technion - Israel's
* Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David. * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David.
...@@ -5849,7 +5845,7 @@ static void idetape_get_mode_sense_results(struct ata_device *drive) ...@@ -5849,7 +5845,7 @@ static void idetape_get_mode_sense_results(struct ata_device *drive)
printk (KERN_INFO "ide-tape: Medium Type - %d\n",header->medium_type); 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: Device Specific Parameter - %d\n",header->dsp);
printk (KERN_INFO "ide-tape: Block Descriptor Length - %d\n",header->bdl); 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: Capabilities and Mechanical Status Page:\n");
printk (KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code); printk (KERN_INFO "ide-tape: Page code - %d\n",capabilities->page_code);
printk (KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length); printk (KERN_INFO "ide-tape: Page length - %d\n",capabilities->page_length);
...@@ -5955,7 +5951,7 @@ static void idetape_setup(struct ata_device *drive, idetape_tape_t *tape, int mi ...@@ -5955,7 +5951,7 @@ static void idetape_setup(struct ata_device *drive, idetape_tape_t *tape, int mi
set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags); set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags);
tape->min_pipeline = tape->max_pipeline = tape->max_stages = 10; tape->min_pipeline = tape->max_pipeline = tape->max_stages = 10;
idetape_get_inquiry_results(drive); idetape_get_inquiry_results(drive);
idetape_get_mode_sense_results(drive); idetape_get_mode_sense_results(drive);
idetape_get_blocksize_from_block_descriptor(drive); idetape_get_blocksize_from_block_descriptor(drive);
...@@ -6054,11 +6050,11 @@ static void idetape_revalidate(struct ata_device *_dummy) ...@@ -6054,11 +6050,11 @@ static void idetape_revalidate(struct ata_device *_dummy)
*/ */
} }
/* static void idetape_attach(struct ata_device *);
* IDE subdriver functions, registered with ide.c
*/
static struct ata_operations idetape_driver = { static struct ata_operations idetape_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
attach: idetape_attach,
cleanup: idetape_cleanup, cleanup: idetape_cleanup,
standby: NULL, standby: NULL,
do_request: idetape_do_request, do_request: idetape_do_request,
...@@ -6070,6 +6066,8 @@ static struct ata_operations idetape_driver = { ...@@ -6070,6 +6066,8 @@ static struct ata_operations idetape_driver = {
revalidate: idetape_revalidate, revalidate: idetape_revalidate,
}; };
/* /*
* Our character device supporting functions, passed to register_chrdev. * Our character device supporting functions, passed to register_chrdev.
*/ */
...@@ -6082,104 +6080,93 @@ static struct file_operations idetape_fops = { ...@@ -6082,104 +6080,93 @@ static struct file_operations idetape_fops = {
release: idetape_chrdev_release, release: idetape_chrdev_release,
}; };
MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver"); static void idetape_attach(struct ata_device *drive)
MODULE_LICENSE("GPL");
static void __exit idetape_exit(void)
{ {
struct ata_device *drive; idetape_tape_t *tape;
int minor; int minor, supported = 0;
char *req;
struct ata_channel *channel;
int unit;
for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++) { if (drive->type != ATA_TAPE)
drive = idetape_chrdevs[minor].drive; return;
if (drive != NULL && idetape_cleanup (drive))
printk (KERN_ERR "ide-tape: %s: cleanup_module() called while still busy\n", drive->name); 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) if (!idetape_chrdev_present)
for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++ ) for (minor = 0; minor < MAX_HWIFS * MAX_DRIVES; minor++ )
idetape_chrdevs[minor].drive = NULL; 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 && if (!idetape_chrdev_present &&
devfs_register_chrdev (IDETAPE_MAJOR, "ht", &idetape_fops)) { devfs_register_chrdev (IDETAPE_MAJOR, "ht", &idetape_fops)) {
printk (KERN_ERR "ide-tape: Failed to register character device interface\n"); printk(KERN_ERR "ide-tape: Failed to register character device interface\n");
MOD_DEC_USE_COUNT; return;
#if ONSTREAM_DEBUG
printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
#endif
return -EBUSY;
} }
do {
if (!idetape_identify_device (drive, drive->id)) { if (!idetape_identify_device (drive, drive->id)) {
printk (KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name); printk(KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name);
continue; return;
} }
if (drive->scsi) { if (drive->scsi) {
if (strstr(drive->id->model, "OnStream DI-")) { 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 { } else {
printk("ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name); printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name);
continue; return;
}
}
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;
} }
for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++); }
idetape_setup (drive, tape, minor); tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
idetape_chrdevs[minor].drive = drive; if (!tape) {
tape->de_r = printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
devfs_register (drive->de, "mt", DEVFS_FL_DEFAULT, return;
drive->channel->major, minor, }
S_IFCHR | S_IRUGO | S_IWUGO, if (ide_register_subdriver (drive, &idetape_driver)) {
&idetape_fops, NULL); printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
tape->de_n = kfree (tape);
devfs_register (drive->de, "mtn", DEVFS_FL_DEFAULT, return;
drive->channel->major, minor + 128, }
S_IFCHR | S_IRUGO | S_IWUGO, for (minor = 0; idetape_chrdevs[minor].drive != NULL; minor++);
&idetape_fops, NULL); idetape_setup (drive, tape, minor);
devfs_register_tape (tape->de_r); idetape_chrdevs[minor].drive = drive;
supported++; failed--; tape->de_r =
} while ((drive = ide_scan_devices(ATA_TAPE, "ide-tape", NULL, failed++)) != NULL); 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) { if (!idetape_chrdev_present && !supported) {
devfs_unregister_chrdev (IDETAPE_MAJOR, "ht"); devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
} else } else
idetape_chrdev_present = 1; idetape_chrdev_present = 1;
revalidate_drives();
MOD_DEC_USE_COUNT; /* Feel free to use partitions even on tapes... */
#if ONSTREAM_DEBUG
printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n"); channel = drive->channel;
#endif unit = drive - channel->drives;
return 0;
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); module_init(idetape_init);
......
...@@ -68,6 +68,11 @@ ...@@ -68,6 +68,11 @@
#include "ata-timing.h" #include "ata-timing.h"
#include "pcihost.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. * Those will be moved into separate header files eventually.
*/ */
...@@ -134,6 +139,10 @@ static int irq_lock; ...@@ -134,6 +139,10 @@ static int irq_lock;
int noautodma = 0; 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: * 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) ...@@ -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) u8 ide_dump_status(struct ata_device *drive, struct request * rq, const char *msg, u8 stat)
{ {
unsigned long flags; unsigned long flags;
byte err = 0; u8 err = 0;
__save_flags (flags); /* local CPU only */ __save_flags (flags); /* local CPU only */
ide__sti(); /* local CPU only */ ide__sti(); /* local CPU only */
...@@ -1633,6 +1642,8 @@ struct ata_device *get_info_ptr(kdev_t i_rdev) ...@@ -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 * This routine is called to flush all partitions and partition tables
* for a changed disk, and then re-read the new partition table. * 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 * 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) ...@@ -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 * Look again for all drives in the system on all interfaces.
* after a new driver category has been loaded as module.
*/ */
void revalidate_drives(void) static void revalidate_drives(void)
{ {
int i; int i;
...@@ -1706,7 +1716,7 @@ void revalidate_drives(void) ...@@ -1706,7 +1716,7 @@ void revalidate_drives(void)
} }
} }
static void ide_driver_module (void) static void ide_driver_module(void)
{ {
int i; int i;
...@@ -2016,10 +2026,10 @@ void ide_unregister(struct ata_channel *ch) ...@@ -2016,10 +2026,10 @@ void ide_unregister(struct ata_channel *ch)
* may set up the hw structure yourself OR use this routine to * may set up the hw structure yourself OR use this routine to
* do it for you. * 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 base, int *offsets,
ide_ioreg_t ctrl, ide_ioreg_t intr, ide_ioreg_t ctrl, ide_ioreg_t intr,
ide_ack_intr_t *ack_intr, int irq) ide_ack_intr_t *ack_intr, int irq)
{ {
int i; int i;
...@@ -2041,6 +2051,46 @@ void ide_setup_ports ( hw_regs_t *hw, ...@@ -2041,6 +2051,46 @@ void ide_setup_ports ( hw_regs_t *hw,
hw->ack_intr = ack_intr; 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 * Register an IDE interface, specifing exactly the registers etc
* Set init=1 iff calling before probes have taken place. * 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) ...@@ -2049,18 +2099,19 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp)
{ {
int h; int h;
int retry = 1; int retry = 1;
struct ata_channel *hwif; struct ata_channel *ch;
struct ata_operations *subdriver;
do { do {
for (h = 0; h < MAX_HWIFS; ++h) { for (h = 0; h < MAX_HWIFS; ++h) {
hwif = &ide_hwifs[h]; ch = &ide_hwifs[h];
if (hwif->hw.io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET]) if (ch->hw.io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET])
goto found; goto found;
} }
for (h = 0; h < MAX_HWIFS; ++h) { for (h = 0; h < MAX_HWIFS; ++h) {
hwif = &ide_hwifs[h]; ch = &ide_hwifs[h];
if ((!hwif->present && (hwif->unit == ATA_PRIMARY) && !initializing) || if ((!ch->present && (ch->unit == ATA_PRIMARY) && !initializing) ||
(!hwif->hw.io_ports[IDE_DATA_OFFSET] && initializing)) (!ch->hw.io_ports[IDE_DATA_OFFSET] && initializing))
goto found; goto found;
} }
for (h = 0; h < MAX_HWIFS; ++h) for (h = 0; h < MAX_HWIFS; ++h)
...@@ -2070,14 +2121,14 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp) ...@@ -2070,14 +2121,14 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp)
return -1; return -1;
found: found:
ide_unregister(hwif); ide_unregister(ch);
if (hwif->present) if (ch->present)
return -1; return -1;
memcpy(&hwif->hw, hw, sizeof(*hw)); memcpy(&ch->hw, hw, sizeof(*hw));
memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports)); memcpy(ch->io_ports, ch->hw.io_ports, sizeof(ch->hw.io_ports));
hwif->irq = hw->irq; ch->irq = hw->irq;
hwif->noprobe = 0; ch->noprobe = 0;
hwif->chipset = hw->chipset; ch->chipset = hw->chipset;
if (!initializing) { if (!initializing) {
ideprobe_init(); ideprobe_init();
...@@ -2086,10 +2137,19 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp) ...@@ -2086,10 +2137,19 @@ int ide_register_hw(hw_regs_t *hw, struct ata_channel **hwifp)
ide_driver_module(); 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) 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) ...@@ -2178,7 +2238,7 @@ void ide_delay_50ms (void)
#else #else
__set_current_state(TASK_UNINTERRUPTIBLE); __set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(HZ/20); 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) ...@@ -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. * This is in fact registering a device not a 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.
*/ */
int ide_register_subdriver(struct ata_device *drive, struct ata_operations *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) ...@@ -3056,7 +3089,6 @@ int ide_unregister_subdriver(struct ata_device *drive)
pnpide_init(0); pnpide_init(0);
#endif #endif
drive->driver = NULL; drive->driver = NULL;
drive->present = 0;
restore_flags(flags); /* all CPUs */ restore_flags(flags); /* all CPUs */
...@@ -3065,23 +3097,56 @@ int ide_unregister_subdriver(struct ata_device *drive) ...@@ -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); EXPORT_SYMBOL(register_ata_driver);
/* /*
* Unregister an ATA driver for a particular device type. * Unregister an ATA subdriver for a particular device type.
*/ */
void unregister_ata_driver(struct ata_operations *driver)
int unregister_ata_driver(unsigned int type, 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(unregister_ata_driver);
...@@ -3098,21 +3163,14 @@ struct block_device_operations ide_fops[] = {{ ...@@ -3098,21 +3163,14 @@ struct block_device_operations ide_fops[] = {{
EXPORT_SYMBOL(ide_fops); EXPORT_SYMBOL(ide_fops);
EXPORT_SYMBOL(ide_hwifs); EXPORT_SYMBOL(ide_hwifs);
EXPORT_SYMBOL(ide_spin_wait_hwgroup); EXPORT_SYMBOL(ide_spin_wait_hwgroup);
EXPORT_SYMBOL(revalidate_drives);
/*
* Probe module
*/
devfs_handle_t ide_devfs_handle; devfs_handle_t ide_devfs_handle;
EXPORT_SYMBOL(ide_lock); EXPORT_SYMBOL(ide_lock);
EXPORT_SYMBOL(drive_is_flashcard); EXPORT_SYMBOL(drive_is_flashcard);
EXPORT_SYMBOL(ide_timer_expiry); EXPORT_SYMBOL(ide_timer_expiry);
EXPORT_SYMBOL(do_ide_request); EXPORT_SYMBOL(do_ide_request);
/*
* Driver module
*/
EXPORT_SYMBOL(ide_scan_devices);
EXPORT_SYMBOL(ide_register_subdriver); EXPORT_SYMBOL(ide_register_subdriver);
EXPORT_SYMBOL(ide_unregister_subdriver); EXPORT_SYMBOL(ide_unregister_subdriver);
EXPORT_SYMBOL(ide_set_handler); EXPORT_SYMBOL(ide_set_handler);
...@@ -3134,7 +3192,10 @@ EXPORT_SYMBOL(ide_unregister); ...@@ -3134,7 +3192,10 @@ EXPORT_SYMBOL(ide_unregister);
EXPORT_SYMBOL(ide_setup_ports); EXPORT_SYMBOL(ide_setup_ports);
EXPORT_SYMBOL(get_info_ptr); 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; int i;
...@@ -3178,8 +3239,8 @@ static int ide_notify_reboot (struct notifier_block *this, unsigned long event, ...@@ -3178,8 +3239,8 @@ static int ide_notify_reboot (struct notifier_block *this, unsigned long event,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static struct notifier_block ide_notifier = { static struct notifier_block ata_notifier = {
ide_notify_reboot, ata_sys_notify,
NULL, NULL,
5 5
}; };
...@@ -3191,19 +3252,20 @@ static int __init ata_module_init(void) ...@@ -3191,19 +3252,20 @@ static int __init ata_module_init(void)
{ {
int h; 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); ide_devfs_handle = devfs_mk_dir (NULL, "ide", NULL);
/* /*
* Because most of the ATA adapters represent the timings in unit of bus * Because most of the ATA adapters represent the timings in unit of
* clocks, and there is no known reliable way to detect the bus clock * bus clocks, and there is no known reliable way to detect the bus
* frequency, we assume 50 MHz for non-PCI (VLB, EISA) and 33 MHz for PCI based * clock frequency, we assume 50 MHz for non-PCI (VLB, EISA) and 33 MHz
* systems. Since assuming only hurts performance and not stability, this is * for PCI based systems. Since assuming only hurts performance and not
* OK. The user can change this on the command line by using the "idebus=XX" * stability, this is OK. The user can change this on the command line
* parameter. While the system_bus_speed variable is in kHz units, we accept * by using the "idebus=XX" parameter. While the system_bus_speed
* both MHz and kHz entry on the command line for backward compatibility. * variable is in kHz units, we accept both MHz and kHz entry on the
*/ * command line for backward compatibility.
*/
system_bus_speed = 50000; system_bus_speed = 50000;
...@@ -3224,7 +3286,7 @@ static int __init ata_module_init(void) ...@@ -3224,7 +3286,7 @@ static int __init ata_module_init(void)
if (idebus_parameter >= 20000 && idebus_parameter <= 80000) if (idebus_parameter >= 20000 && idebus_parameter <= 80000)
system_bus_speed = idebus_parameter; system_bus_speed = idebus_parameter;
printk(KERN_INFO "ATA: %s bus speed %d.%dMHz\n", printk(KERN_INFO "ATA: %s bus speed %d.%dMHz\n",
pci_present() ? "PCI" : "System", system_bus_speed / 1000, system_bus_speed / 100 % 10); pci_present() ? "PCI" : "System", system_bus_speed / 1000, system_bus_speed / 100 % 10);
...@@ -3385,7 +3447,7 @@ static int __init ata_module_init(void) ...@@ -3385,7 +3447,7 @@ static int __init ata_module_init(void)
# ifdef CONFIG_SCSI # ifdef CONFIG_SCSI
idescsi_init(); idescsi_init();
# else # 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
#endif #endif
...@@ -3397,14 +3459,12 @@ static int __init ata_module_init(void) ...@@ -3397,14 +3459,12 @@ static int __init ata_module_init(void)
ide_geninit(channel); ide_geninit(channel);
} }
register_reboot_notifier(&ide_notifier); register_reboot_notifier(&ata_notifier);
return 0; return 0;
} }
static char *options = NULL; static char *options = NULL;
MODULE_PARM(options,"s");
MODULE_LICENSE("GPL");
static int __init init_ata(void) static int __init init_ata(void)
{ {
...@@ -3426,7 +3486,7 @@ static void __exit cleanup_ata(void) ...@@ -3426,7 +3486,7 @@ static void __exit cleanup_ata(void)
{ {
int h; int h;
unregister_reboot_notifier(&ide_notifier); unregister_reboot_notifier(&ata_notifier);
for (h = 0; h < MAX_HWIFS; ++h) { for (h = 0; h < MAX_HWIFS; ++h) {
ide_unregister(&ide_hwifs[h]); ide_unregister(&ide_hwifs[h]);
} }
......
...@@ -48,17 +48,17 @@ ...@@ -48,17 +48,17 @@
/* /*
* Prototypes * 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) #if defined(CONFIG_BLK_DEV_IDEDMA) && defined(CONFIG_IT8172_TUNING)
static byte it8172_dma_2_pio (byte xfer_rate); 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);
static int it8172_config_chipset_for_dma (ide_drive_t *drive); static int it8172_config_chipset_for_dma (struct ata_device *drive);
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);
#endif #endif
void __init ide_init_it8172(struct ata_channel *channel); 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; unsigned long flags;
u16 drive_enables; u16 drive_enables;
...@@ -139,7 +139,7 @@ static byte it8172_dma_2_pio (byte xfer_rate) ...@@ -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 ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
...@@ -194,7 +194,7 @@ static int it8172_tune_chipset (ide_drive_t *drive, byte speed) ...@@ -194,7 +194,7 @@ static int it8172_tune_chipset (ide_drive_t *drive, byte speed)
return err; 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; struct hd_driveid *id = drive->id;
byte speed; byte speed;
...@@ -210,7 +210,7 @@ static int it8172_config_chipset_for_dma(ide_drive_t *drive) ...@@ -210,7 +210,7 @@ static int it8172_config_chipset_for_dma(ide_drive_t *drive)
ide_dma_off_quietly); 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) { switch (func) {
case ide_dma_check: case ide_dma_check:
......
...@@ -119,7 +119,7 @@ void macide_init(void) ...@@ -119,7 +119,7 @@ void macide_init(void)
/* hardware ID, and we cna't get that without */ /* hardware ID, and we cna't get that without */
/* probing the drive which freezes a 190. */ /* 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; drive->capacity = drive->cyl*drive->head*drive->sect;
#ifdef CONFIG_BLK_DEV_MAC_MEDIABAY #ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
......
...@@ -33,7 +33,7 @@ static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 }; ...@@ -33,7 +33,7 @@ static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 };
* the IRQ associated with the port (drive->channel), * the IRQ associated with the port (drive->channel),
* and selects either PIO or DMA handshaking for the next I/O operation. * 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; struct ata_channel *hwif = drive->channel;
unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data; 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) ...@@ -78,7 +78,7 @@ static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
__restore_flags(flags); /* local CPU only */ __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); ns87415_prepare_drive (drive, drive->using_dma);
} }
......
...@@ -137,7 +137,7 @@ int reg_base; ...@@ -137,7 +137,7 @@ int reg_base;
/* there are stored pio numbers from other calls of opti621_tune_drive */ /* 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 /* Store values into drive->drive_data
* second_contr - 0 for primary controller, 1 for secondary * second_contr - 0 for primary controller, 1 for secondary
* slave_drive - 0 -> pio is for master, 1 -> pio is for slave * 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) ...@@ -245,7 +245,7 @@ static void compute_clocks(int pio, pio_clocks_t *clks)
} }
/* Main tune procedure, called from tuneproc. */ /* 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, /* primary and secondary drives share some registers,
* so we have to program both drives * so we have to program both drives
......
...@@ -187,13 +187,38 @@ int check_in_drive_lists(struct ata_device *drive) ...@@ -187,13 +187,38 @@ int check_in_drive_lists(struct ata_device *drive)
return 0; 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) static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed)
{ {
struct ata_channel *hwif = drive->channel; struct ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
unsigned int drive_conf; unsigned int drive_conf;
int err;
byte drive_pci, AP, BP, CP, DP; byte drive_pci, AP, BP, CP, DP;
byte TA = 0, TB = 0, TC = 0; byte TA = 0, TB = 0, TC = 0;
...@@ -298,7 +323,6 @@ static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed) ...@@ -298,7 +323,6 @@ static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed)
if (!drive->init_speed) if (!drive->init_speed)
drive->init_speed = speed; drive->init_speed = speed;
err = ide_config_drive_speed(drive, speed);
drive->current_speed = speed; drive->current_speed = speed;
#if PDC202XX_DEBUG_DRIVE_INFO #if PDC202XX_DEBUG_DRIVE_INFO
...@@ -308,7 +332,8 @@ static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed) ...@@ -308,7 +332,8 @@ static int pdc202xx_tune_chipset(struct ata_device *drive, byte speed)
pci_read_config_dword(dev, drive_pci, &drive_conf); pci_read_config_dword(dev, drive_pci, &drive_conf);
printk("0x%08x\n", drive_conf); printk("0x%08x\n", drive_conf);
#endif /* PDC202XX_DEBUG_DRIVE_INFO */ #endif /* PDC202XX_DEBUG_DRIVE_INFO */
return err;
return ide_config_drive_speed(drive, speed);
} }
#define set_2regs(a, b) \ #define set_2regs(a, b) \
...@@ -335,8 +360,6 @@ static int pdc202xx_new_tune_chipset(struct ata_device *drive, byte speed) ...@@ -335,8 +360,6 @@ static int pdc202xx_new_tune_chipset(struct ata_device *drive, byte speed)
byte thold = 0x10; byte thold = 0x10;
byte adj = (drive->dn%2) ? 0x08 : 0x00; byte adj = (drive->dn%2) ? 0x08 : 0x00;
int err;
#ifdef CONFIG_BLK_DEV_IDEDMA #ifdef CONFIG_BLK_DEV_IDEDMA
if (speed == XFER_UDMA_2) { if (speed == XFER_UDMA_2) {
OUT_BYTE((thold + adj), indexreg); OUT_BYTE((thold + adj), indexreg);
...@@ -426,10 +449,9 @@ static int pdc202xx_new_tune_chipset(struct ata_device *drive, byte speed) ...@@ -426,10 +449,9 @@ static int pdc202xx_new_tune_chipset(struct ata_device *drive, byte speed)
if (!drive->init_speed) if (!drive->init_speed)
drive->init_speed = speed; drive->init_speed = speed;
err = ide_config_drive_speed(drive, speed);
drive->current_speed = speed; drive->current_speed = speed;
return err; return ide_config_drive_speed(drive, speed);
} }
/* 0 1 2 3 4 5 6 7 8 /* 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) ...@@ -451,10 +473,11 @@ static void config_chipset_for_pio(struct ata_device *drive, byte pio)
} }
#ifdef CONFIG_BLK_DEV_IDEDMA #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 hd_driveid *id = drive->id;
struct ata_channel *hwif = drive->channel; struct ata_channel *hwif = drive->channel;
struct hd_driveid *mate_id = hwif->drives[!(drive->dn%2)].id;
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4); unsigned long high_16 = pci_resource_start(dev, 4);
unsigned long dma_base = hwif->dma_base; unsigned long dma_base = hwif->dma_base;
...@@ -464,65 +487,41 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra) ...@@ -464,65 +487,41 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
byte adj = (drive->dn%2) ? 0x08 : 0x00; byte adj = (drive->dn%2) ? 0x08 : 0x00;
byte cable = 0; byte cable = 0;
byte jumpbit = 0; byte jumpbit = 0;
byte unit = (drive->select.b.unit & 0x01);
unsigned int drive_conf; unsigned int drive_conf;
byte drive_pci = 0; byte drive_pci = 0, mate_pci = 0;
byte test1, test2, speed = -1; byte test1, test2, mode = -1;
byte AP; byte AP;
unsigned short EP; unsigned short EP;
byte CLKSPD = 0; byte CLKSPD = 0;
byte udma_33 = ultra; /* primary - second bit, secondary - fourth bit */
// 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;
byte mask = hwif->unit ? 0x08 : 0x02; byte mask = hwif->unit ? 0x08 : 0x02;
unsigned short c_mask = hwif->unit ? (1<<11) : (1<<10); unsigned short c_mask = hwif->unit ? (1<<11) : (1<<10);
int map;
byte ultra_66 = ((id->dma_ultra & 0x0010) || byte needs_80w = ((id->dma_ultra & 0x0008) ||
(id->dma_ultra & 0x0008)) ? 1 : 0; (id->dma_ultra & 0x0010) ||
byte ultra_100 = ((id->dma_ultra & 0x0020) || (id->dma_ultra & 0x0020) ||
(ultra_66)) ? 1 : 0; (id->dma_ultra & 0x0040));
byte ultra_133 = ((id->dma_ultra & 0x0040) ||
(ultra_100)) ? 1 : 0;
switch(dev->device) { switch(dev->device) {
case PCI_DEVICE_ID_PROMISE_20275: case PCI_DEVICE_ID_PROMISE_20275:
case PCI_DEVICE_ID_PROMISE_20276: case PCI_DEVICE_ID_PROMISE_20276:
case PCI_DEVICE_ID_PROMISE_20269: 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: 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: case PCI_DEVICE_ID_PROMISE_20268:
udma_100 = (udma_66) ? 1 : 0; OUT_BYTE(0x0b, indexreg);
OUT_BYTE(0x0b, (hwif->dma_base + 1)); cable = ((IN_BYTE(datareg) & 0x04));
cable = ((IN_BYTE((hwif->dma_base + 3)) & 0x04));
jumpbit = 1; jumpbit = 1;
break; break;
case PCI_DEVICE_ID_PROMISE_20267: case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265: 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: case PCI_DEVICE_ID_PROMISE_20262:
pci_read_config_word(dev, 0x50, &EP); pci_read_config_word(dev, 0x50, &EP);
cable = (EP & c_mask); cable = (EP & c_mask);
jumpbit = 0; jumpbit = 0;
break; break;
default: default:
udma_100 = 0; udma_133 = 0; cable = 1; jumpbit = 0; cable = 1; jumpbit = 0;
break; break;
} }
...@@ -540,40 +539,26 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra) ...@@ -540,40 +539,26 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
* leave the 66Mhz clock on and readjust the timing * leave the 66Mhz clock on and readjust the timing
* parameters. * parameters.
*/ */
if (needs_80w) {
if (((ultra_66) || (ultra_100) || (ultra_133)) && (cable)) { /* FIXME: this check is wrong for 20246 --bkz */
#ifdef DEBUG if (cable) {
printk("ULTRA66: %s channel of Ultra 66 requires an 80-pin cable for Ultra66 operation.\n", hwif->unit ? "Secondary" : "Primary"); printk(KERN_WARNING "%s: channel requires an 80-pin cable.\n", hwif->name);
printk(" Switching to Ultra33 mode.\n"); printk(KERN_WARNING "%s: reduced to UDMA(33) mode.\n", drive->name);
#endif /* DEBUG */ if (!jumpbit)
/* Primary : zero out second bit */ OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
/* Secondary : zero out fourth bit */ }
if (!jumpbit) if (!jumpbit) {
OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11)); if (mate_id) { /* check if mate is at least udma3 */
printk("Warning: %s channel requires an 80-pin cable for operation.\n", hwif->unit ? "Secondary":"Primary"); if ((mate_id->dma_ultra & 0x0040) ||
printk("%s reduced to Ultra33 mode.\n", drive->name); (mate_id->dma_ultra & 0x0020) ||
udma_66 = 0; udma_100 = 0; udma_133 = 0; (mate_id->dma_ultra & 0x0010) ||
} else { (mate_id->dma_ultra & 0x0008)) {
if ((ultra_66) || (ultra_100) || (ultra_133)) { OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
/*
* 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));
} else { } else {
if (!jumpbit) OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
OUT_BYTE(CLKSPD & ~mask, (high_16 + 0x11));
} }
} else { /* udma4 drive by itself */ } else { /* single drive */
if (!jumpbit) OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
OUT_BYTE(CLKSPD | mask, (high_16 + 0x11));
} }
} }
} }
...@@ -589,38 +574,23 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra) ...@@ -589,38 +574,23 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
switch(drive->dn) { switch(drive->dn) {
case 0: drive_pci = 0x60; 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; case 2: drive_pci = 0x68;
pci_read_config_dword(dev, drive_pci, &drive_conf); pci_read_config_dword(dev, drive_pci, &drive_conf);
if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4)) if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
goto chipset_is_set; 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)) 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; 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); pci_read_config_dword(dev, drive_pci, &drive_conf);
if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4)) if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
goto chipset_is_set; goto chipset_is_set;
pci_read_config_byte(dev, 0x68, &test1); pci_read_config_byte(dev, mate_pci, &test1);
pci_read_config_byte(dev, (drive_pci), &test2); pci_read_config_byte(dev, drive_pci, &test2);
if ((test1 & SYNC_ERRDY_EN) && !(test2 & SYNC_ERRDY_EN)) 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; break;
default: default:
return 0; return 0;
...@@ -640,35 +610,24 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra) ...@@ -640,35 +610,24 @@ static int config_chipset_for_dma(struct ata_device *drive, byte ultra)
jumpbit_is_set: jumpbit_is_set:
if ((id->dma_ultra & 0x0040)&&(udma_133)) speed = XFER_UDMA_6; if (udma) {
else if ((id->dma_ultra & 0x0020)&&(udma_100)) speed = XFER_UDMA_5; map = pdc202xx_ratemask(drive);
else if ((id->dma_ultra & 0x0010)&&(udma_66)) speed = XFER_UDMA_4; } else {
else if ((id->dma_ultra & 0x0008)&&(udma_66)) speed = XFER_UDMA_3; if (!jumpbit)
else if ((id->dma_ultra & 0x0004)&&(udma_33)) speed = XFER_UDMA_2; map = XFER_SWDMA | XFER_MWDMA;
else if ((id->dma_ultra & 0x0002)&&(udma_33)) speed = XFER_UDMA_1; else
else if ((id->dma_ultra & 0x0001)&&(udma_33)) speed = XFER_UDMA_0; map = XFER_MWDMA;
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; mode = ata_timing_mode(drive, map);
else if ((id->dma_1word & 0x0004)&&(!jumpbit)) speed = XFER_SW_DMA_2; if (mode < XFER_SW_DMA_0) {
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 {
/* restore original pci-config space */ /* restore original pci-config space */
if (!jumpbit) if (!jumpbit)
pci_write_config_dword(dev, drive_pci, drive_conf); pci_write_config_dword(dev, drive_pci, drive_conf);
return 0; return 0;
} }
outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2); return !(hwif->speedproc(drive, mode));
(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);
} }
static int config_drive_xfer_rate(struct ata_device *drive) static int config_drive_xfer_rate(struct ata_device *drive)
...@@ -729,31 +688,23 @@ 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) static int pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
{ {
u8 clock = 0; u8 lba48hack = 0, clock = 0;
u8 hardware48hack = 0;
struct ata_channel *ch = drive->channel; struct ata_channel *ch = drive->channel;
struct pci_dev *dev = ch->pci_dev; struct pci_dev *dev = ch->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4); unsigned long high_16 = pci_resource_start(dev, 4);
unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00); unsigned long atapi_reg = high_16 + (ch->unit ? 0x24 : 0x00);
switch (dev->device) { 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_20267:
case PCI_DEVICE_ID_PROMISE_20265: case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262: case PCI_DEVICE_ID_PROMISE_20262:
hardware48hack = 1; lba48hack = 1;
clock = IN_BYTE(high_16 + 0x11); clock = IN_BYTE(high_16 + 0x11);
default: default:
break; break;
} }
if ((drive->addressing) && (hardware48hack)) { if (drive->addressing && lba48hack) {
unsigned long word_count = 0; unsigned long word_count = 0;
outb(clock|(ch->unit ? 0x08 : 0x02), high_16 + 0x11); 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) ...@@ -774,9 +725,7 @@ static int pdc202xx_udma_start(struct ata_device *drive, struct request *rq)
int pdc202xx_udma_stop(struct ata_device *drive) int pdc202xx_udma_stop(struct ata_device *drive)
{ {
u8 newchip = 0; u8 lba48hack = 0, clock = 0;
u8 clock = 0;
u8 hardware48hack = 0;
struct ata_channel *ch = drive->channel; struct ata_channel *ch = drive->channel;
struct pci_dev *dev = ch->pci_dev; struct pci_dev *dev = ch->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4); unsigned long high_16 = pci_resource_start(dev, 4);
...@@ -785,22 +734,17 @@ int pdc202xx_udma_stop(struct ata_device *drive) ...@@ -785,22 +734,17 @@ int pdc202xx_udma_stop(struct ata_device *drive)
u8 dma_stat; u8 dma_stat;
switch (dev->device) { 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_20267:
case PCI_DEVICE_ID_PROMISE_20265: case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262: case PCI_DEVICE_ID_PROMISE_20262:
hardware48hack = 1; lba48hack = 1;
/* FIXME: why do we need this here --bkz */
clock = IN_BYTE(high_16 + 0x11); clock = IN_BYTE(high_16 + 0x11);
default: default:
break; break;
} }
if ((drive->addressing) && (hardware48hack)) {
if (drive->addressing && lba48hack) {
outl(0, atapi_reg); /* zero out extra */ outl(0, atapi_reg); /* zero out extra */
clock = IN_BYTE(high_16 + 0x11); clock = IN_BYTE(high_16 + 0x11);
OUT_BYTE(clock & ~(ch->unit ? 0x08:0x02), 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) ...@@ -822,7 +766,6 @@ static int pdc202xx_udma_irq_status(struct ata_device *drive)
u8 sc1d = 0; u8 sc1d = 0;
u8 newchip = 0; u8 newchip = 0;
u8 clock = 0; u8 clock = 0;
u8 hardware48hack = 0;
struct pci_dev *dev = ch->pci_dev; struct pci_dev *dev = ch->pci_dev;
unsigned long high_16 = pci_resource_start(dev, 4); unsigned long high_16 = pci_resource_start(dev, 4);
unsigned long dma_base = ch->dma_base; unsigned long dma_base = ch->dma_base;
...@@ -838,7 +781,7 @@ static int pdc202xx_udma_irq_status(struct ata_device *drive) ...@@ -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_20267:
case PCI_DEVICE_ID_PROMISE_20265: case PCI_DEVICE_ID_PROMISE_20265:
case PCI_DEVICE_ID_PROMISE_20262: case PCI_DEVICE_ID_PROMISE_20262:
hardware48hack = 1; /* FIXME: why do we need this here --bkz */
clock = IN_BYTE(high_16 + 0x11); clock = IN_BYTE(high_16 + 0x11);
default: default:
break; break;
...@@ -918,22 +861,21 @@ static unsigned int __init pdc202xx_init_chipset(struct pci_dev *dev) ...@@ -918,22 +861,21 @@ static unsigned int __init pdc202xx_init_chipset(struct pci_dev *dev)
break; break;
case PCI_DEVICE_ID_PROMISE_20267: case PCI_DEVICE_ID_PROMISE_20267:
case PCI_DEVICE_ID_PROMISE_20265: 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: case PCI_DEVICE_ID_PROMISE_20262:
/* /*
* software reset - this is required because the bios * software reset - this is required because the BIOS
* will set UDMA timing on if the hdd supports it. The * will set UDMA timing on if the drive supports it.
* user may want to turn udma off. A bug in the pdc20262 * The user may want to turn udma off. A bug is that
* is that it cannot handle a downgrade in timing from * that device cannot handle a downgrade in timing from
* UDMA to DMA. Disk accesses after issuing a set * UDMA to DMA. Disk accesses after issuing a set
* feature command will result in errors. A software * feature command will result in errors.
* reset leaves the timing registers intact, *
* A software reset leaves the timing registers intact,
* but resets the drives. * 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, 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: default:
if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) { if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
byte irq = 0, irq2 = 0; byte irq = 0, irq2 = 0;
...@@ -1039,55 +981,15 @@ static void __init ide_init_pdc202xx(struct ata_channel *hwif) ...@@ -1039,55 +981,15 @@ static void __init ide_init_pdc202xx(struct ata_channel *hwif)
/* module data table */ /* module data table */
static struct ata_pci_device chipsets[] __initdata = { 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, vendor: PCI_VENDOR_ID_PROMISE,
device: PCI_DEVICE_ID_PROMISE_20246, device: PCI_DEVICE_ID_PROMISE_20246,
init_chipset: pdc202xx_init_chipset, init_chipset: pdc202xx_init_chipset,
ata66_check: NULL, ata66_check: NULL,
init_channel: ide_init_pdc202xx, init_channel: ide_init_pdc202xx,
#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}}, enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
#endif
bootable: OFF_BOARD, bootable: OFF_BOARD,
extra: 16, extra: 16,
flags: ATA_F_IRQ | ATA_F_DMA flags: ATA_F_IRQ | ATA_F_DMA
...@@ -1098,7 +1000,9 @@ static struct ata_pci_device chipsets[] __initdata = { ...@@ -1098,7 +1000,9 @@ static struct ata_pci_device chipsets[] __initdata = {
init_chipset: pdc202xx_init_chipset, init_chipset: pdc202xx_init_chipset,
ata66_check: ata66_pdc202xx, ata66_check: ata66_pdc202xx,
init_channel: ide_init_pdc202xx, init_channel: ide_init_pdc202xx,
#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}}, enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
#endif
bootable: OFF_BOARD, bootable: OFF_BOARD,
extra: 48, extra: 48,
flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
...@@ -1109,8 +1013,12 @@ static struct ata_pci_device chipsets[] __initdata = { ...@@ -1109,8 +1013,12 @@ static struct ata_pci_device chipsets[] __initdata = {
init_chipset: pdc202xx_init_chipset, init_chipset: pdc202xx_init_chipset,
ata66_check: ata66_pdc202xx, ata66_check: ata66_pdc202xx,
init_channel: ide_init_pdc202xx, init_channel: ide_init_pdc202xx,
#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}}, enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
bootable: OFF_BOARD, bootable: OFF_BOARD,
#else
bootable: ON_BOARD,
#endif
extra: 48, extra: 48,
flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA flags: ATA_F_IRQ | ATA_F_PHACK | ATA_F_DMA
}, },
...@@ -1120,12 +1028,13 @@ static struct ata_pci_device chipsets[] __initdata = { ...@@ -1120,12 +1028,13 @@ static struct ata_pci_device chipsets[] __initdata = {
init_chipset: pdc202xx_init_chipset, init_chipset: pdc202xx_init_chipset,
ata66_check: ata66_pdc202xx, ata66_check: ata66_pdc202xx,
init_channel: ide_init_pdc202xx, init_channel: ide_init_pdc202xx,
#ifndef CONFIG_PDC202XX_FORCE
enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}}, enablebits: {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
#endif
bootable: OFF_BOARD, bootable: OFF_BOARD,
extra: 48, extra: 48,
flags: ATA_F_IRQ | ATA_F_DMA flags: ATA_F_IRQ | ATA_F_DMA
}, },
#endif
{ {
vendor: PCI_VENDOR_ID_PROMISE, vendor: PCI_VENDOR_ID_PROMISE,
device: PCI_DEVICE_ID_PROMISE_20268, device: PCI_DEVICE_ID_PROMISE_20268,
......
...@@ -377,7 +377,7 @@ static int pdcraid1_make_request (request_queue_t *q, int rw, struct buffer_head ...@@ -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) static unsigned long calc_pdcblock_offset(struct block_device *bdev)
{ {
unsigned long lba = 0; 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) if (ideinfo==NULL)
return 0; return 0;
......
...@@ -112,7 +112,7 @@ byte __init qd_read_reg (byte reg) ...@@ -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. * 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) | byte index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) |
(QD_TIMREG(drive) & 0x02); (QD_TIMREG(drive) & 0x02);
...@@ -164,7 +164,7 @@ static byte qd6580_compute_timing (int active_time, int recovery_time) ...@@ -164,7 +164,7 @@ static byte qd6580_compute_timing (int active_time, int recovery_time)
* tries to find timing from dos driver's table * 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) int *active_time, int *recovery_time)
{ {
struct qd65xx_timing_s *p; struct qd65xx_timing_s *p;
...@@ -192,7 +192,7 @@ static int qd_find_disk_type (ide_drive_t *drive, ...@@ -192,7 +192,7 @@ static int qd_find_disk_type (ide_drive_t *drive,
* check whether timings don't conflict * 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, return (IDE_IMPLY(drives[0].present && drives[1].present,
IDE_IMPLY(QD_TIMREG(drives) == QD_TIMREG(drives+1), IDE_IMPLY(QD_TIMREG(drives) == QD_TIMREG(drives+1),
...@@ -206,7 +206,7 @@ static int qd_timing_ok (ide_drive_t drives[]) ...@@ -206,7 +206,7 @@ static int qd_timing_ok (ide_drive_t drives[])
* records the timing, and enables selectproc as needed * 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; struct ata_channel *hwif = drive->channel;
...@@ -225,7 +225,7 @@ static void qd_set_timing (ide_drive_t *drive, byte timing) ...@@ -225,7 +225,7 @@ static void qd_set_timing (ide_drive_t *drive, byte timing)
* qd6500_tune_drive * 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 active_time = 175;
int recovery_time = 415; /* worst case values from the dos driver */ 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) ...@@ -247,7 +247,7 @@ static void qd6500_tune_drive (ide_drive_t *drive, byte pio)
* qd6580_tune_drive * 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; struct ata_timing *t;
int base = drive->channel->select_data; int base = drive->channel->select_data;
......
...@@ -240,6 +240,26 @@ extern char *ide_xfer_verbose (byte xfer_rate); ...@@ -240,6 +240,26 @@ extern char *ide_xfer_verbose (byte xfer_rate);
static struct pci_dev *isa_dev; 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 int svwks_tune_chipset(struct ata_device *drive, byte speed)
{ {
static u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; 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) ...@@ -251,11 +271,6 @@ static int svwks_tune_chipset(struct ata_device *drive, byte speed)
byte unit = (drive->select.b.unit & 0x01); byte unit = (drive->select.b.unit & 0x01);
byte csb5 = (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ? 1 : 0; 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_pci = 0x00;
byte drive_pci2 = 0x00; byte drive_pci2 = 0x00;
byte drive_pci3 = hwif->unit ? 0x57 : 0x56; byte drive_pci3 = hwif->unit ? 0x57 : 0x56;
...@@ -338,9 +353,6 @@ static int svwks_tune_chipset(struct ata_device *drive, byte speed) ...@@ -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); printk("%s: %s drive%d\n", drive->name, ide_xfer_verbose(speed), drive->dn);
#endif /* SVWKS_DEBUG_DRIVE_INFO */ #endif /* SVWKS_DEBUG_DRIVE_INFO */
if (!drive->init_speed)
drive->init_speed = speed;
pci_write_config_byte(dev, drive_pci, pio_timing); pci_write_config_byte(dev, drive_pci, pio_timing);
if (csb5) if (csb5)
pci_write_config_word(dev, 0x4A, csb5_pio); pci_write_config_word(dev, 0x4A, csb5_pio);
...@@ -349,16 +361,12 @@ static int svwks_tune_chipset(struct ata_device *drive, byte speed) ...@@ -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_pci2, dma_timing);
pci_write_config_byte(dev, drive_pci3, ultra_timing); pci_write_config_byte(dev, drive_pci3, ultra_timing);
pci_write_config_byte(dev, 0x54, ultra_enable); pci_write_config_byte(dev, 0x54, ultra_enable);
#endif
if (speed > XFER_PIO_4) if (!drive->init_speed)
outb(inb(dma_base+2)|(1<<(5+unit)), dma_base+2); drive->init_speed = speed;
else
outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
#endif /* CONFIG_BLK_DEV_IDEDMA */
err = ide_config_drive_speed(drive, speed);
drive->current_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) 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) ...@@ -415,23 +423,14 @@ static void svwks_tune_drive(struct ata_device *drive, byte pio)
#ifdef CONFIG_BLK_DEV_IDEDMA #ifdef CONFIG_BLK_DEV_IDEDMA
static int config_chipset_for_dma(struct ata_device *drive) static int config_chipset_for_dma(struct ata_device *drive)
{ {
struct hd_driveid *id = drive->id; int map;
struct pci_dev *dev = drive->channel->pci_dev; byte mode;
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));
(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 : return !svwks_tune_chipset(drive, mode);
((id->dma_ultra >> 8) & 7) ? 1 :
((id->dma_mword >> 8) & 7) ? 1 :
((id->dma_1word >> 8) & 7) ? 1 :
0);
} }
static int config_drive_xfer_rate(struct ata_device *drive) static int config_drive_xfer_rate(struct ata_device *drive)
......
...@@ -71,7 +71,7 @@ static unsigned int get_timing_sl82c105(struct ata_timing *t) ...@@ -71,7 +71,7 @@ static unsigned int get_timing_sl82c105(struct ata_timing *t)
/* /*
* Configure the drive and chipset for PIO * 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 ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
...@@ -109,7 +109,7 @@ static void config_for_pio(ide_drive_t *drive, int pio, int report) ...@@ -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 * 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 ata_channel *hwif = drive->channel;
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
...@@ -131,7 +131,7 @@ static int config_for_dma(ide_drive_t *drive) ...@@ -131,7 +131,7 @@ static int config_for_dma(ide_drive_t *drive)
* Check to see if the drive and * Check to see if the drive and
* chipset is capable of DMA mode * 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; int on = 0;
...@@ -240,7 +240,7 @@ static void sl82c105_timeout(struct ata_device *drive) ...@@ -240,7 +240,7 @@ static void sl82c105_timeout(struct ata_device *drive)
* This function is called when the IDE timer expires, the 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. * 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 ata_channel *ch = drive->channel;
struct pci_dev *dev = ch->pci_dev; struct pci_dev *dev = ch->pci_dev;
...@@ -273,7 +273,7 @@ static void sl82c105_lostirq(ide_drive_t *drive) ...@@ -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 * We only deal with PIO mode here - DMA mode 'using_dma' is not
* initialised at the point that this function is called. * 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); config_for_pio(drive, pio, 1);
......
...@@ -502,11 +502,14 @@ static void idescsi_revalidate(struct ata_device *_dummy) ...@@ -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 * IDE subdriver functions, registered with ide.c
*/ */
static struct ata_operations idescsi_driver = { static struct ata_operations idescsi_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
attach: idescsi_attach,
cleanup: idescsi_cleanup, cleanup: idescsi_cleanup,
standby: NULL, standby: NULL,
do_request: idescsi_do_request, do_request: idescsi_do_request,
...@@ -519,45 +522,40 @@ static struct ata_operations idescsi_driver = { ...@@ -519,45 +522,40 @@ static struct ata_operations idescsi_driver = {
capacity: NULL, capacity: NULL,
}; };
/* static void idescsi_attach(struct ata_device *drive)
* idescsi_init will register the driver for each scsi.
*/
int idescsi_init(void)
{ {
struct ata_device *drive;
idescsi_scsi_t *scsi; idescsi_scsi_t *scsi;
/* FIXME: The following is just plain wrong, since those are definitely *not* the int i, id;
* media types supported by the ATA layer */ char *req;
byte media[] = {TYPE_DISK, TYPE_TAPE, TYPE_PROCESSOR, TYPE_WORM, TYPE_ROM, TYPE_SCANNER, TYPE_MOD, 255}; struct ata_channel *channel;
int i, failed, id; int unit;
if (idescsi_initialized) if (idescsi_initialized)
return 0; return;
idescsi_initialized = 1; idescsi_initialized = 1;
for (i = 0; i < MAX_HWIFS * MAX_DRIVES; i++) for (i = 0; i < MAX_HWIFS * MAX_DRIVES; i++)
idescsi_drives[i] = NULL; 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) { req = drive->driver_req;
printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name); if (req[0] != '\0' && strcmp(req, "ide-scsi"))
continue; return;
}
if (ide_register_subdriver (drive, &idescsi_driver)) { if ((scsi = (idescsi_scsi_t *) kmalloc (sizeof (idescsi_scsi_t), GFP_KERNEL)) == NULL) {
printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name); printk(KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
kfree (scsi); return;
continue;
}
for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++);
idescsi_setup (drive, scsi, id);
failed--;
}
} }
revalidate_drives(); if (ide_register_subdriver (drive, &idescsi_driver)) {
MOD_DEC_USE_COUNT; printk(KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
return 0; 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) int idescsi_detect (Scsi_Host_Template *host_template)
...@@ -805,38 +803,31 @@ static Scsi_Host_Template idescsi_template = { ...@@ -805,38 +803,31 @@ static Scsi_Host_Template idescsi_template = {
emulated: 1, 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); scsi_register_host(&idescsi_template);
return 0; return 0;
} }
static void __exit exit_idescsi_module(void) 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); scsi_unregister_host(&idescsi_template);
/* FIXME: The media types scanned here have literally nothing to do #if 0
* with the media types used by the overall ATA code! /* FIXME: what about this cleanup stuff here? This all should be done
* * on close time perhaps? */
* This is basically showing us, that there is something wrong with the
* ide_scan_devices function.
*/
for (i = 0; media[i] != 255; i++) { if (idescsi_cleanup (drive)) {
failed = 0; printk ("%s: exit_idescsi_module() called while still busy\n", drive->name);
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_exit(exit_idescsi_module);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -317,7 +317,6 @@ typedef union { ...@@ -317,7 +317,6 @@ typedef union {
/* /*
* ATA/ATAPI device structure : * ATA/ATAPI device structure :
*/ */
typedef
struct ata_device { struct ata_device {
struct ata_channel * channel; struct ata_channel * channel;
char name[6]; /* device name */ char name[6]; /* device name */
...@@ -409,7 +408,7 @@ struct ata_device { ...@@ -409,7 +408,7 @@ struct ata_device {
unsigned long immed_comp; unsigned long immed_comp;
int max_last_depth; int max_last_depth;
int max_depth; int max_depth;
} ide_drive_t; };
/* /*
* Status returned by various functions. * Status returned by various functions.
...@@ -590,6 +589,7 @@ static inline int ata_can_queue(struct ata_device *drive) ...@@ -590,6 +589,7 @@ static inline int ata_can_queue(struct ata_device *drive)
struct ata_operations { struct ata_operations {
struct module *owner; struct module *owner;
void (*attach) (struct ata_device *);
int (*cleanup)(struct ata_device *); int (*cleanup)(struct ata_device *);
int (*standby)(struct ata_device *); int (*standby)(struct ata_device *);
ide_startstop_t (*do_request)(struct ata_device *, struct request *, sector_t); ide_startstop_t (*do_request)(struct ata_device *, struct request *, sector_t);
...@@ -602,6 +602,9 @@ struct ata_operations { ...@@ -602,6 +602,9 @@ struct ata_operations {
void (*revalidate)(struct ata_device *); void (*revalidate)(struct ata_device *);
sector_t (*capacity)(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 */ /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
...@@ -618,11 +621,20 @@ do { \ ...@@ -618,11 +621,20 @@ do { \
extern sector_t ata_capacity(struct ata_device *drive); extern sector_t ata_capacity(struct ata_device *drive);
/* FIXME: Actually implement and use them as soon as possible! to make the extern void unregister_ata_driver(struct ata_operations *driver);
* ide_scan_devices() go away! */ extern int register_ata_driver(struct ata_operations *driver);
static inline int ata_driver_module(struct ata_operations *driver)
extern int unregister_ata_driver(unsigned int type, struct ata_operations *driver); {
extern int register_ata_driver(unsigned int type, 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) #define ata_ops(drive) ((drive)->driver)
...@@ -797,9 +809,9 @@ extern int idefloppy_init (void); ...@@ -797,9 +809,9 @@ extern int idefloppy_init (void);
extern int idescsi_init (void); extern int idescsi_init (void);
#endif #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_register_subdriver(struct ata_device *, struct ata_operations *);
extern int ide_unregister_subdriver(struct ata_device *drive); extern int ide_unregister_subdriver(struct ata_device *drive);
extern int ide_revalidate_disk(kdev_t i_rdev);
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
# define ON_BOARD 0 # define ON_BOARD 0
...@@ -890,6 +902,5 @@ extern spinlock_t ide_lock; ...@@ -890,6 +902,5 @@ extern spinlock_t ide_lock;
#define DRIVE_LOCK(drive) ((drive)->queue.queue_lock) #define DRIVE_LOCK(drive) ((drive)->queue.queue_lock)
extern int drive_is_ready(struct ata_device *drive); extern int drive_is_ready(struct ata_device *drive);
extern void revalidate_drives(void);
#endif #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