Commit ce43a9ec authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.6-pre1 IDE cleanup 11

1. Start of driver tree usage upon suggestion from Pavel Machek.
     This still will needs a lot of further work in the future, but
     the current code doesn't hurt anything and allowa Pavel to work
     further from the base line. In esp. natively implemented
      suspend to file requires this - which I would love to see comming
     in,since I'm quite frequently using a notebook myself.

2. Kill the _IDE_C macro, which was playing games on entierly
     unnecessary declarations inside of header files in esp ide_modes.h

3. Replace the functionally totally equal system_bus_block() and
     ide_system_bus_speed() functions with one simple global
     variable: system_bus_speed. This saves quite a significatn amount of
     code. Unfortunately this is the part, which is makeing this
     patch to appear bigger then it really is...

4. Use ide_devalidate_drive() directly instead of idedisk_revalidate().

5. Kill conditional CONFIG_KMOD as well as some other minor tweaks.

Well this isn't that much in terms of functionality,  but it took me
quite q bit of time to catch up on the patch-2.5.5.gz ;-)
parent f0a86f5a
......@@ -203,22 +203,18 @@ extern char *ide_xfer_verbose (byte xfer_rate);
static byte pci_bus_clock_list (byte speed, struct chipset_bus_clock_list_entry * chipset_table)
{
int bus_speed = system_bus_clock();
for ( ; chipset_table->xfer_speed ; chipset_table++)
if (chipset_table->xfer_speed == speed) {
return ((byte) ((bus_speed <= 33) ? chipset_table->chipset_settings_33 : chipset_table->chipset_settings_34));
return ((byte) ((system_bus_speed <= 33) ? chipset_table->chipset_settings_33 : chipset_table->chipset_settings_34));
}
return 0x00;
}
static byte pci_bus_clock_list_ultra (byte speed, struct chipset_bus_clock_list_entry * chipset_table)
{
int bus_speed = system_bus_clock();
for ( ; chipset_table->xfer_speed ; chipset_table++)
if (chipset_table->xfer_speed == speed) {
return ((byte) ((bus_speed <= 33) ? chipset_table->ultra_settings_33 : chipset_table->ultra_settings_34));
return ((byte) ((system_bus_speed <= 33) ? chipset_table->ultra_settings_33 : chipset_table->ultra_settings_34));
}
return 0x00;
}
......
......@@ -119,15 +119,14 @@ static void ali14xx_tune_drive (ide_drive_t *drive, byte pio)
byte param1, param2, param3, param4;
unsigned long flags;
ide_pio_data_t d;
int bus_speed = system_bus_clock();
pio = ide_get_best_pio_mode(drive, pio, ALI_MAX_PIO, &d);
/* calculate timing, according to PIO mode */
time1 = d.cycle_time;
time2 = ide_pio_timings[pio].active_time;
param3 = param1 = (time2 * bus_speed + 999) / 1000;
param4 = param2 = (time1 * bus_speed + 999) / 1000 - param1;
param3 = param1 = (time2 * system_bus_speed + 999) / 1000;
param4 = param2 = (time1 * system_bus_speed + 999) / 1000 - param1;
if (pio < 3) {
param3 += 8;
param4 += 8;
......
......@@ -247,7 +247,6 @@ static void ali15x3_tune_drive (ide_drive_t *drive, byte pio)
int s_time, a_time, c_time;
byte s_clc, a_clc, r_clc;
unsigned long flags;
int bus_speed = system_bus_clock();
int port = hwif->index ? 0x5c : 0x58;
int portFIFO = hwif->channel ? 0x55 : 0x54;
byte cd_dma_fifo = 0;
......@@ -255,18 +254,18 @@ static void ali15x3_tune_drive (ide_drive_t *drive, byte pio)
pio = ide_get_best_pio_mode(drive, pio, 5, &d);
s_time = ide_pio_timings[pio].setup_time;
a_time = ide_pio_timings[pio].active_time;
if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
if ((s_clc = (s_time * system_bus_speed + 999) / 1000) >= 8)
s_clc = 0;
if ((a_clc = (a_time * bus_speed + 999) / 1000) >= 8)
if ((a_clc = (a_time * system_bus_speed + 999) / 1000) >= 8)
a_clc = 0;
c_time = ide_pio_timings[pio].cycle_time;
#if 0
if ((r_clc = ((c_time - s_time - a_time) * bus_speed + 999) / 1000) >= 16)
if ((r_clc = ((c_time - s_time - a_time) * system_bus_speed + 999) / 1000) >= 16)
r_clc = 0;
#endif
if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) {
if (!(r_clc = (c_time * system_bus_speed + 999) / 1000 - a_clc - s_clc)) {
r_clc = 1;
} else {
if (r_clc >= 16)
......
......@@ -23,7 +23,7 @@
*
* A.Hartgers@stud.tue.nl, JZDQC@CUNYVM.CUNY.edu, abramov@cecmow.enet.dec.com,
* bardj@utopia.ppp.sn.no, bart@gaga.tue.nl, bbol001@cs.auckland.ac.nz,
* chrisc@dbass.demon.co.uk, dalecki@namu26.Num.Math.Uni-Goettingen.de,
* chrisc@dbass.demon.co.uk, dalecki@evision-ventures.com,
* derekn@vw.ece.cmu.edu, florian@btp2x3.phy.uni-bayreuth.de,
* flynn@dei.unipd.it, gadio@netvision.net.il, godzilla@futuris.net,
* j@pobox.com, jkemp1@mises.uni-paderborn.de, jtoppe@hiwaay.net,
......@@ -596,14 +596,13 @@ static void cmd640_set_mode (unsigned int index, byte pio_mode, unsigned int cyc
{
int setup_time, active_time, recovery_time, clock_time;
byte setup_count, active_count, recovery_count, recovery_count2, cycle_count;
int bus_speed = system_bus_clock();
if (pio_mode > 5)
pio_mode = 5;
setup_time = ide_pio_timings[pio_mode].setup_time;
active_time = ide_pio_timings[pio_mode].active_time;
recovery_time = cycle_time - (setup_time + active_time);
clock_time = 1000 / bus_speed;
clock_time = 1000 / system_bus_speed;
cycle_count = (cycle_time + clock_time - 1) / clock_time;
setup_count = (setup_time + clock_time - 1) / clock_time;
......
......@@ -283,8 +283,6 @@ static void cmd64x_tuneproc (ide_drive_t *drive, byte mode_wanted)
int setup_time, active_time, recovery_time, clock_time, pio_mode, cycle_time;
byte recovery_count2, cycle_count;
int setup_count, active_count, recovery_count;
int bus_speed = system_bus_clock();
/*byte b;*/
ide_pio_data_t d;
switch (mode_wanted) {
......@@ -309,7 +307,7 @@ static void cmd64x_tuneproc (ide_drive_t *drive, byte mode_wanted)
setup_time = ide_pio_timings[pio_mode].setup_time;
active_time = ide_pio_timings[pio_mode].active_time;
recovery_time = cycle_time - (setup_time + active_time);
clock_time = 1000 / bus_speed;
clock_time = 1000 / system_bus_speed;
cycle_count = (cycle_time + clock_time - 1) / clock_time;
setup_count = (setup_time + clock_time - 1) / clock_time;
......
......@@ -141,7 +141,6 @@ static int calc_clk (int time, int bus_speed)
static void compute_clocks (byte pio, pio_clocks_t *p_pclk)
{
int clk1, clk2;
int bus_speed = system_bus_clock(); /* get speed of PCI bus */
/* we don't check against CY82C693's min and max speed,
* so you can play with the idebus=xx parameter
......@@ -151,17 +150,17 @@ static void compute_clocks (byte pio, pio_clocks_t *p_pclk)
pio = CY82C693_MAX_PIO;
/* let's calc the address setup time clocks */
p_pclk->address_time = (byte)calc_clk(ide_pio_timings[pio].setup_time, bus_speed);
p_pclk->address_time = (byte)calc_clk(ide_pio_timings[pio].setup_time, system_bus_speed);
/* let's calc the active and recovery time clocks */
clk1 = calc_clk(ide_pio_timings[pio].active_time, bus_speed);
clk1 = calc_clk(ide_pio_timings[pio].active_time, system_bus_speed);
/* calc recovery timing */
clk2 = ide_pio_timings[pio].cycle_time -
ide_pio_timings[pio].active_time -
ide_pio_timings[pio].setup_time;
clk2 = calc_clk(clk2, bus_speed);
clk2 = calc_clk(clk2, system_bus_speed);
clk1 = (clk1<<4)|clk2; /* combine active and recovery clocks */
......
......@@ -207,7 +207,6 @@ static byte ht_pio2timings(ide_drive_t *drive, byte pio)
int active_time, recovery_time;
int active_cycles, recovery_cycles;
ide_pio_data_t d;
int bus_speed = system_bus_clock();
if (pio) {
pio = ide_get_best_pio_mode(drive, pio, 5, &d);
......@@ -224,8 +223,8 @@ static byte ht_pio2timings(ide_drive_t *drive, byte pio)
/*
* Cycle times should be Vesa bus cycles
*/
active_cycles = (active_time * bus_speed + 999) / 1000;
recovery_cycles = (recovery_time * bus_speed + 999) / 1000;
active_cycles = (active_time * system_bus_speed + 999) / 1000;
recovery_cycles = (recovery_time * system_bus_speed + 999) / 1000;
/*
* Upper and lower limits
*/
......
......@@ -378,11 +378,6 @@ static int idedisk_media_change (ide_drive_t *drive)
return drive->removable; /* if removable, always assume it was changed */
}
static void idedisk_revalidate (ide_drive_t *drive)
{
ide_revalidate_drive(drive);
}
/*
* Queries for true maximum capacity of the drive.
* Returns maximum LBA address (> 0) of the drive, 0 if failed.
......@@ -915,13 +910,22 @@ static void idedisk_add_settings(ide_drive_t *drive)
ide_add_setting(drive, "max_failures", SETTING_RW, -1, -1, TYPE_INT, 0, 65535, 1, 1, &drive->max_failures, NULL);
}
static void idedisk_setup (ide_drive_t *drive)
/* This is just a hook for the overall driver tree.
*
* FIXME: This is soon goig to replace the custom linked list games played up
* to great extend between the different components of the IDE drivers.
*/
static struct device_driver idedisk_devdrv = {};
static void idedisk_setup(ide_drive_t *drive)
{
int i;
struct hd_driveid *id = drive->id;
unsigned long capacity;
int drvid = -1;
idedisk_add_settings(drive);
if (id == NULL)
......@@ -933,7 +937,7 @@ static void idedisk_setup (ide_drive_t *drive)
*/
if (drive->removable && !drive_is_flashcard(drive)) {
/*
* Removable disks (eg. SYQUEST); ignore 'WD' drives
* Removable disks (eg. SYQUEST); ignore 'WD' drives.
*/
if (id->model[0] != 'W' || id->model[1] != 'D') {
drive->doorlocking = 1;
......@@ -942,13 +946,26 @@ static void idedisk_setup (ide_drive_t *drive)
for (i = 0; i < MAX_DRIVES; ++i) {
ide_hwif_t *hwif = HWIF(drive);
if (drive != &hwif->drives[i]) continue;
if (drive != &hwif->drives[i])
continue;
drvid = i;
hwif->gd->de_arr[i] = drive->de;
if (drive->removable)
hwif->gd->flags[i] |= GENHD_FL_REMOVABLE;
break;
}
/* Register us within the device tree.
*/
if (drvid != -1) {
sprintf(drive->device.bus_id, "%d", drvid);
sprintf(drive->device.name, "ide-disk");
drive->device.driver = &idedisk_devdrv;
drive->device.parent = &HWIF(drive)->device;
device_register(&drive->device);
}
/* Extract geometry if we did not already have one for the drive */
if (!drive->cyl || !drive->head || !drive->sect) {
drive->cyl = drive->bios_cyl = id->cyls;
......@@ -1023,6 +1040,12 @@ static void idedisk_setup (ide_drive_t *drive)
static int idedisk_cleanup (ide_drive_t *drive)
{
/* FIXME: we will have to think twice whatever this is the proper place
* to do it.
*/
put_device(&drive->device);
if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache)
if (do_idedisk_flushcache(drive))
printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n",
......@@ -1050,7 +1073,7 @@ static ide_driver_t idedisk_driver = {
open: idedisk_open,
release: idedisk_release,
media_change: idedisk_media_change,
revalidate: idedisk_revalidate,
revalidate: ide_revalidate_drive,
pre_reset: idedisk_pre_reset,
capacity: idedisk_capacity,
special: idedisk_special,
......
......@@ -57,6 +57,7 @@ struct pnp_dev_t {
static int __init pnpide_generic_init(struct pci_dev *dev, int enable)
{
hw_regs_t hw;
ide_hwif_t *hwif;
int index;
if (!enable)
......@@ -69,10 +70,11 @@ static int __init pnpide_generic_init(struct pci_dev *dev, int enable)
generic_ide_offsets, (ide_ioreg_t) DEV_IO(dev, 1),
0, NULL, DEV_IRQ(dev, 0));
index = ide_register_hw(&hw, NULL);
index = ide_register_hw(&hw, &hwif);
if (index != -1) {
printk("ide%d: %s IDE interface\n", index, DEV_NAME(dev));
hwif->pci_dev = dev;
printk("ide%d: %s IDE interface\n", index, DEV_NAME(dev));
return 0;
}
......
......@@ -46,6 +46,7 @@
#include <linux/delay.h>
#include <linux/ide.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
......@@ -465,6 +466,17 @@ static int hwif_check_regions (ide_hwif_t *hwif)
static void hwif_register (ide_hwif_t *hwif)
{
/* Register this hardware interface within the global device tree.
*/
sprintf(hwif->device.bus_id, "%04x", hwif->io_ports[IDE_DATA_OFFSET]);
sprintf(hwif->device.name, "ide");
hwif->device.driver_data = hwif;
if (hwif->pci_dev)
hwif->device.parent = &hwif->pci_dev->dev;
else
hwif->device.parent = NULL; /* Would like to do = &device_legacy */
device_register(&hwif->device);
if (((unsigned long)hwif->io_ports[IDE_DATA_OFFSET] | 7) ==
((unsigned long)hwif->io_ports[IDE_STATUS_OFFSET])) {
ide_request_region(hwif->io_ports[IDE_DATA_OFFSET], 8, hwif->name);
......
......@@ -128,8 +128,6 @@
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#define _IDE_C /* Tell ide.h it's really us */
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
......@@ -153,6 +151,8 @@
#include <linux/completion.h>
#include <linux/reboot.h>
#include <linux/cdrom.h>
#include <linux/device.h>
#include <linux/kmod.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
......@@ -162,17 +162,102 @@
#include "ide_modes.h"
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
#endif /* CONFIG_KMOD */
/* Constant tables for PIO mode programming:
*/
const ide_pio_timings_t ide_pio_timings[6] = {
{ 70, 165, 600 }, /* PIO Mode 0 */
{ 50, 125, 383 }, /* PIO Mode 1 */
{ 30, 100, 240 }, /* PIO Mode 2 */
{ 30, 80, 180 }, /* PIO Mode 3 with IORDY */
{ 25, 70, 120 }, /* PIO Mode 4 with IORDY */
{ 20, 50, 100 } /* PIO Mode 5 with IORDY (nonstandard) */
};
/*
* Black list. Some drives incorrectly report their maximal PIO mode,
* at least in respect to CMD640. Here we keep info on some known drives.
*/
static struct ide_pio_info {
const char *name;
int pio;
} ide_pio_blacklist [] = {
/* { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
{ "Conner Peripherals 540MB - CFS540A", 3 },
{ "WDC AC2700", 3 },
{ "WDC AC2540", 3 },
{ "WDC AC2420", 3 },
{ "WDC AC2340", 3 },
{ "WDC AC2250", 0 },
{ "WDC AC2200", 0 },
{ "WDC AC21200", 4 },
{ "WDC AC2120", 0 },
{ "WDC AC2850", 3 },
{ "WDC AC1270", 3 },
{ "WDC AC1170", 1 },
{ "WDC AC1210", 1 },
{ "WDC AC280", 0 },
/* { "WDC AC21000", 4 }, */
{ "WDC AC31000", 3 },
{ "WDC AC31200", 3 },
/* { "WDC AC31600", 4 }, */
{ "Maxtor 7131 AT", 1 },
{ "Maxtor 7171 AT", 1 },
{ "Maxtor 7213 AT", 1 },
{ "Maxtor 7245 AT", 1 },
{ "Maxtor 7345 AT", 1 },
{ "Maxtor 7546 AT", 3 },
{ "Maxtor 7540 AV", 3 },
{ "SAMSUNG SHD-3121A", 1 },
{ "SAMSUNG SHD-3122A", 1 },
{ "SAMSUNG SHD-3172A", 1 },
/* { "ST51080A", 4 },
* { "ST51270A", 4 },
* { "ST31220A", 4 },
* { "ST31640A", 4 },
* { "ST32140A", 4 },
* { "ST3780A", 4 },
*/
{ "ST5660A", 3 },
{ "ST3660A", 3 },
{ "ST3630A", 3 },
{ "ST3655A", 3 },
{ "ST3391A", 3 },
{ "ST3390A", 1 },
{ "ST3600A", 1 },
{ "ST3290A", 0 },
{ "ST3144A", 0 },
{ "ST3491A", 1 }, /* reports 3, should be 1 or 2 (depending on */
/* drive) according to Seagates FIND-ATA program */
{ "QUANTUM ELS127A", 0 },
{ "QUANTUM ELS170A", 0 },
{ "QUANTUM LPS240A", 0 },
{ "QUANTUM LPS210A", 3 },
{ "QUANTUM LPS270A", 3 },
{ "QUANTUM LPS365A", 3 },
{ "QUANTUM LPS540A", 3 },
{ "QUANTUM LIGHTNING 540A", 3 },
{ "QUANTUM LIGHTNING 730A", 3 },
{ "QUANTUM FIREBALL_540", 3 }, /* Older Quantum Fireballs don't work */
{ "QUANTUM FIREBALL_640", 3 },
{ "QUANTUM FIREBALL_1080", 3 },
{ "QUANTUM FIREBALL_1280", 3 },
{ NULL, 0 }
};
/* default maximum number of failures */
#define IDE_DEFAULT_MAX_FAILURES 1
#define IDE_DEFAULT_MAX_FAILURES 1
static const byte ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR, IDE4_MAJOR, IDE5_MAJOR, IDE6_MAJOR, IDE7_MAJOR, IDE8_MAJOR, IDE9_MAJOR };
static int idebus_parameter; /* holds the "idebus=" parameter */
static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */
int system_bus_speed; /* holds what we think is VESA/PCI bus speed */
static int initializing; /* set while initializing built-in drivers */
/*
......@@ -200,6 +285,106 @@ int noautodma = 0;
*/
ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */
/*
* This routine searches the ide_pio_blacklist for an entry
* matching the start/whole of the supplied model name.
*
* Returns -1 if no match found.
* Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
*/
int ide_scan_pio_blacklist (char *model)
{
struct ide_pio_info *p;
for (p = ide_pio_blacklist; p->name != NULL; p++) {
if (strncmp(p->name, model, strlen(p->name)) == 0)
return p->pio;
}
return -1;
}
/*
* This routine returns the recommended PIO settings for a given drive,
* based on the drive->id information and the ide_pio_blacklist[].
* This is used by most chipset support modules when "auto-tuning".
*/
/*
* Drive PIO mode auto selection
*/
byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d)
{
int pio_mode;
int cycle_time = 0;
int use_iordy = 0;
struct hd_driveid* id = drive->id;
int overridden = 0;
int blacklisted = 0;
if (mode_wanted != 255) {
pio_mode = mode_wanted;
} else if (!drive->id) {
pio_mode = 0;
} else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
overridden = 1;
blacklisted = 1;
use_iordy = (pio_mode > 2);
} else {
pio_mode = id->tPIO;
if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
pio_mode = 2;
overridden = 1;
}
if (id->field_valid & 2) { /* drive implements ATA2? */
if (id->capability & 8) { /* drive supports use_iordy? */
use_iordy = 1;
cycle_time = id->eide_pio_iordy;
if (id->eide_pio_modes & 7) {
overridden = 0;
if (id->eide_pio_modes & 4)
pio_mode = 5;
else if (id->eide_pio_modes & 2)
pio_mode = 4;
else
pio_mode = 3;
}
} else {
cycle_time = id->eide_pio;
}
}
#if 0
if (drive->id->major_rev_num & 0x0004) printk("ATA-2 ");
#endif
/*
* Conservative "downgrade" for all pre-ATA2 drives
*/
if (pio_mode && pio_mode < 4) {
pio_mode--;
overridden = 1;
#if 0
use_iordy = (pio_mode > 2);
#endif
if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time)
cycle_time = 0; /* use standard timing */
}
}
if (pio_mode > max_mode) {
pio_mode = max_mode;
cycle_time = 0;
}
if (d) {
d->pio_mode = pio_mode;
d->cycle_time = cycle_time ? cycle_time : ide_pio_timings[pio_mode].cycle_time;
d->use_iordy = use_iordy;
d->overridden = overridden;
d->blacklisted = blacklisted;
}
return pio_mode;
}
#if (DISK_RECOVERY_TIME > 0)
/*
* For really screwy hardware (hey, at least it *can* be used with Linux)
......@@ -308,7 +493,6 @@ static void __init init_ide_data (void)
ide_init_default_hwifs();
idebus_parameter = 0;
system_bus_speed = 0;
}
/*
......@@ -342,30 +526,6 @@ int drive_is_flashcard (ide_drive_t *drive)
return 0; /* no, it is not a flash memory card */
}
/*
* ide_system_bus_speed() returns what we think is the system VESA/PCI
* bus speed (in MHz). This is used for calculating interface PIO timings.
* The default is 40 for known PCI systems, 50 otherwise.
* The "idebus=xx" parameter can be used to override this value.
* The actual value to be used is computed/displayed the first time through.
*/
int ide_system_bus_speed (void)
{
if (!system_bus_speed) {
if (idebus_parameter)
system_bus_speed = idebus_parameter; /* user supplied value */
#ifdef CONFIG_PCI
else if (pci_present())
system_bus_speed = 33; /* safe default value for PCI */
#endif /* CONFIG_PCI */
else
system_bus_speed = 50; /* safe default value for VESA and PCI */
printk("ide: Assuming %dMHz system bus speed for PIO modes%s\n", system_bus_speed,
idebus_parameter ? "" : "; override with idebus=xx");
}
return system_bus_speed;
}
int __ide_end_request(ide_drive_t *drive, int uptodate, int nr_secs)
{
struct request *rq;
......@@ -2005,6 +2165,7 @@ void ide_unregister (unsigned int index)
hwif = &ide_hwifs[index];
if (!hwif->present)
goto abort;
put_device(&hwif->device);
for (unit = 0; unit < MAX_DRIVES; ++unit) {
drive = &hwif->drives[unit];
if (!drive->present)
......@@ -2489,11 +2650,6 @@ void ide_delay_50ms (void)
#endif /* CONFIG_BLK_DEV_IDECS */
}
int system_bus_clock (void)
{
return((int) ((!system_bus_speed) ? ide_system_bus_speed() : system_bus_speed ));
}
int ide_reinit_drive (ide_drive_t *drive)
{
switch (drive->media) {
......@@ -3676,9 +3832,6 @@ EXPORT_SYMBOL(ide_unregister);
EXPORT_SYMBOL(ide_setup_ports);
EXPORT_SYMBOL(get_info_ptr);
EXPORT_SYMBOL(current_capacity);
EXPORT_SYMBOL(system_bus_clock);
EXPORT_SYMBOL(ide_reinit_drive);
static int ide_notify_reboot (struct notifier_block *this, unsigned long event, void *x)
......@@ -3730,17 +3883,32 @@ static struct notifier_block ide_notifier = {
/*
* This is gets invoked once during initialization, to set *everything* up
*/
int __init ide_init (void)
int __init ide_init(void)
{
static char banner_printed;
int i;
if (!banner_printed) {
printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n");
ide_devfs_handle = devfs_mk_dir (NULL, "ide", NULL);
system_bus_speed = ide_system_bus_speed();
banner_printed = 1;
}
printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n");
ide_devfs_handle = devfs_mk_dir (NULL, "ide", NULL);
/* Initialize system bus speed.
*
* This can be changed by a particular chipse initialization module.
* Otherwise we assume 33MHz as a safe value for PCI bus based systems.
* 50MHz will be assumed for abolitions like VESA, since higher values
* result in more conservative timing setups.
*
* The kernel parameter idebus=XX overrides the default settings.
*/
system_bus_speed = 50;
if (idebus_parameter)
system_bus_speed = idebus_parameter;
#ifdef CONFIG_PCI
else if (pci_present())
system_bus_speed = 33;
#endif
printk("ide: system bus speed %dMHz\n", system_bus_speed);
init_ide_data ();
......
......@@ -11,9 +11,6 @@
/*
* Shared data/functions for determining best PIO mode for an IDE drive.
* Most of this stuff originally lived in cmd640.c, and changes to the
* ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
* breaking the fragile cmd640.c support.
*/
#ifdef CONFIG_BLK_DEV_IDE_MODES
......@@ -37,200 +34,9 @@ typedef struct ide_pio_data_s {
byte blacklisted;
unsigned int cycle_time;
} ide_pio_data_t;
#ifndef _IDE_C
int ide_scan_pio_blacklist (char *model);
byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d);
extern int ide_scan_pio_blacklist (char *model);
extern byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d);
extern const ide_pio_timings_t ide_pio_timings[6];
#else /* _IDE_C */
const ide_pio_timings_t ide_pio_timings[6] = {
{ 70, 165, 600 }, /* PIO Mode 0 */
{ 50, 125, 383 }, /* PIO Mode 1 */
{ 30, 100, 240 }, /* PIO Mode 2 */
{ 30, 80, 180 }, /* PIO Mode 3 with IORDY */
{ 25, 70, 120 }, /* PIO Mode 4 with IORDY */
{ 20, 50, 100 } /* PIO Mode 5 with IORDY (nonstandard) */
};
/*
* Black list. Some drives incorrectly report their maximal PIO mode,
* at least in respect to CMD640. Here we keep info on some known drives.
*/
static struct ide_pio_info {
const char *name;
int pio;
} ide_pio_blacklist [] = {
/* { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
{ "Conner Peripherals 540MB - CFS540A", 3 },
{ "WDC AC2700", 3 },
{ "WDC AC2540", 3 },
{ "WDC AC2420", 3 },
{ "WDC AC2340", 3 },
{ "WDC AC2250", 0 },
{ "WDC AC2200", 0 },
{ "WDC AC21200", 4 },
{ "WDC AC2120", 0 },
{ "WDC AC2850", 3 },
{ "WDC AC1270", 3 },
{ "WDC AC1170", 1 },
{ "WDC AC1210", 1 },
{ "WDC AC280", 0 },
/* { "WDC AC21000", 4 }, */
{ "WDC AC31000", 3 },
{ "WDC AC31200", 3 },
/* { "WDC AC31600", 4 }, */
{ "Maxtor 7131 AT", 1 },
{ "Maxtor 7171 AT", 1 },
{ "Maxtor 7213 AT", 1 },
{ "Maxtor 7245 AT", 1 },
{ "Maxtor 7345 AT", 1 },
{ "Maxtor 7546 AT", 3 },
{ "Maxtor 7540 AV", 3 },
{ "SAMSUNG SHD-3121A", 1 },
{ "SAMSUNG SHD-3122A", 1 },
{ "SAMSUNG SHD-3172A", 1 },
/* { "ST51080A", 4 },
* { "ST51270A", 4 },
* { "ST31220A", 4 },
* { "ST31640A", 4 },
* { "ST32140A", 4 },
* { "ST3780A", 4 },
*/
{ "ST5660A", 3 },
{ "ST3660A", 3 },
{ "ST3630A", 3 },
{ "ST3655A", 3 },
{ "ST3391A", 3 },
{ "ST3390A", 1 },
{ "ST3600A", 1 },
{ "ST3290A", 0 },
{ "ST3144A", 0 },
{ "ST3491A", 1 }, /* reports 3, should be 1 or 2 (depending on */
/* drive) according to Seagates FIND-ATA program */
{ "QUANTUM ELS127A", 0 },
{ "QUANTUM ELS170A", 0 },
{ "QUANTUM LPS240A", 0 },
{ "QUANTUM LPS210A", 3 },
{ "QUANTUM LPS270A", 3 },
{ "QUANTUM LPS365A", 3 },
{ "QUANTUM LPS540A", 3 },
{ "QUANTUM LIGHTNING 540A", 3 },
{ "QUANTUM LIGHTNING 730A", 3 },
{ "QUANTUM FIREBALL_540", 3 }, /* Older Quantum Fireballs don't work */
{ "QUANTUM FIREBALL_640", 3 },
{ "QUANTUM FIREBALL_1080", 3 },
{ "QUANTUM FIREBALL_1280", 3 },
{ NULL, 0 }
};
/*
* This routine searches the ide_pio_blacklist for an entry
* matching the start/whole of the supplied model name.
*
* Returns -1 if no match found.
* Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
*/
int ide_scan_pio_blacklist (char *model)
{
struct ide_pio_info *p;
for (p = ide_pio_blacklist; p->name != NULL; p++) {
if (strncmp(p->name, model, strlen(p->name)) == 0)
return p->pio;
}
return -1;
}
/*
* This routine returns the recommended PIO settings for a given drive,
* based on the drive->id information and the ide_pio_blacklist[].
* This is used by most chipset support modules when "auto-tuning".
*/
/*
* Drive PIO mode auto selection
*/
byte ide_get_best_pio_mode (ide_drive_t *drive, byte mode_wanted, byte max_mode, ide_pio_data_t *d)
{
int pio_mode;
int cycle_time = 0;
int use_iordy = 0;
struct hd_driveid* id = drive->id;
int overridden = 0;
int blacklisted = 0;
if (mode_wanted != 255) {
pio_mode = mode_wanted;
} else if (!drive->id) {
pio_mode = 0;
} else if ((pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
overridden = 1;
blacklisted = 1;
use_iordy = (pio_mode > 2);
} else {
pio_mode = id->tPIO;
if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
pio_mode = 2;
overridden = 1;
}
if (id->field_valid & 2) { /* drive implements ATA2? */
if (id->capability & 8) { /* drive supports use_iordy? */
use_iordy = 1;
cycle_time = id->eide_pio_iordy;
if (id->eide_pio_modes & 7) {
overridden = 0;
if (id->eide_pio_modes & 4)
pio_mode = 5;
else if (id->eide_pio_modes & 2)
pio_mode = 4;
else
pio_mode = 3;
}
} else {
cycle_time = id->eide_pio;
}
}
#if 0
if (drive->id->major_rev_num & 0x0004) printk("ATA-2 ");
#endif
/*
* Conservative "downgrade" for all pre-ATA2 drives
*/
if (pio_mode && pio_mode < 4) {
pio_mode--;
overridden = 1;
#if 0
use_iordy = (pio_mode > 2);
#endif
if (cycle_time && cycle_time < ide_pio_timings[pio_mode].cycle_time)
cycle_time = 0; /* use standard timing */
}
}
if (pio_mode > max_mode) {
pio_mode = max_mode;
cycle_time = 0;
}
if (d) {
d->pio_mode = pio_mode;
d->cycle_time = cycle_time ? cycle_time : ide_pio_timings[pio_mode].cycle_time;
d->use_iordy = use_iordy;
d->overridden = overridden;
d->blacklisted = blacklisted;
}
return pio_mode;
}
#endif /* _IDE_C */
#endif /* CONFIG_BLK_DEV_IDE_MODES */
#endif /* _IDE_MODES_H */
......@@ -164,7 +164,7 @@ static void compute_pios(ide_drive_t *drive, byte pio)
}
}
int cmpt_clk(int time, int bus_speed)
static int cmpt_clk(int time, int bus_speed)
/* Returns (rounded up) time in clocks for time in ns,
* with bus_speed in MHz.
* Example: bus_speed = 40 MHz, time = 80 ns
......@@ -216,14 +216,13 @@ static void compute_clocks(int pio, pio_clocks_t *clks)
{
if (pio != PIO_NOT_EXIST) {
int adr_setup, data_pls;
int bus_speed = system_bus_clock();
adr_setup = ide_pio_timings[pio].setup_time;
data_pls = ide_pio_timings[pio].active_time;
clks->address_time = cmpt_clk(adr_setup, bus_speed);
clks->data_time = cmpt_clk(data_pls, bus_speed);
clks->address_time = cmpt_clk(adr_setup, system_bus_speed);
clks->data_time = cmpt_clk(data_pls, system_bus_speed);
clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time
- adr_setup-data_pls, bus_speed);
- adr_setup-data_pls, system_bus_speed);
if (clks->address_time<1) clks->address_time = 1;
if (clks->address_time>4) clks->address_time = 4;
if (clks->data_time<1) clks->data_time = 1;
......
......@@ -139,12 +139,12 @@ static byte qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recove
{
byte active_cycle,recovery_cycle;
if (ide_system_bus_speed()<=33) {
active_cycle = 9 - IDE_IN(active_time * ide_system_bus_speed() / 1000 + 1, 2, 9);
recovery_cycle = 15 - IDE_IN(recovery_time * ide_system_bus_speed() / 1000 + 1, 0, 15);
if (system_bus_speed <= 33) {
active_cycle = 9 - IDE_IN(active_time * system_bus_speed / 1000 + 1, 2, 9);
recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_speed / 1000 + 1, 0, 15);
} else {
active_cycle = 8 - IDE_IN(active_time * ide_system_bus_speed() / 1000 + 1, 1, 8);
recovery_cycle = 18 - IDE_IN(recovery_time * ide_system_bus_speed() / 1000 + 1, 3, 18);
active_cycle = 8 - IDE_IN(active_time * system_bus_speed / 1000 + 1, 1, 8);
recovery_cycle = 18 - IDE_IN(recovery_time * system_bus_speed / 1000 + 1, 3, 18);
}
return((recovery_cycle<<4) | 0x08 | active_cycle);
......@@ -158,8 +158,8 @@ static byte qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recove
static byte qd6580_compute_timing (int active_time, int recovery_time)
{
byte active_cycle = 17-IDE_IN(active_time * ide_system_bus_speed() / 1000 + 1, 2, 17);
byte recovery_cycle = 15-IDE_IN(recovery_time * ide_system_bus_speed() / 1000 + 1, 2, 15);
byte active_cycle = 17-IDE_IN(active_time * system_bus_speed / 1000 + 1, 2, 17);
byte recovery_cycle = 15-IDE_IN(recovery_time * system_bus_speed / 1000 + 1, 2, 15);
return((recovery_cycle<<4) | active_cycle);
}
......
......@@ -484,7 +484,7 @@ unsigned int __init pci_init_via82cxxx(struct pci_dev *dev, const char *name)
* Determine system bus clock.
*/
via_clock = system_bus_clock() * 1000;
via_clock = system_bus_speed * 1000;
switch (via_clock) {
case 33000: via_clock = 33333; break;
......
......@@ -8,11 +8,6 @@
#include <linux/spinlock.h>
#include <linux/compiler.h>
/*
* get rid of this next...
*/
extern int ide_init(void);
extern void set_device_ro(kdev_t dev,int flag);
extern void add_blkdev_randomness(int major);
......
......@@ -13,6 +13,7 @@
#include <linux/hdsmart.h>
#include <linux/blkdev.h>
#include <linux/proc_fs.h>
#include <linux/device.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/hdreg.h>
......@@ -426,7 +427,7 @@ typedef struct ide_drive_s {
unsigned long capacity; /* total number of sectors */
unsigned long long capacity48; /* total number of sectors */
unsigned int drive_data; /* for use by tuneproc/selectproc as needed */
struct hwif_s *hwif; /* actually (ide_hwif_t *) */
struct hwif_s *hwif; /* parent pointer to the interface we are attached to */
wait_queue_head_t wqueue; /* used to wait for drive in open() */
struct hd_driveid *id; /* drive model identification info */
struct hd_struct *part; /* drive partition table */
......@@ -450,6 +451,7 @@ typedef struct ide_drive_s {
byte acoustic; /* acoustic management */
unsigned int failures; /* current failure count */
unsigned int max_failures; /* maximum allowed failure count */
struct device device; /* global device tree handle */
} ide_drive_t;
/*
......@@ -582,6 +584,7 @@ typedef struct hwif_s {
void *hwif_data; /* extra hwif data */
ide_busproc_t *busproc; /* driver soft-power interface */
byte bus_state; /* power state of the IDE bus */
struct device device; /* global device tree handle */
} ide_hwif_t;
/*
......@@ -735,9 +738,7 @@ typedef struct ide_driver_s {
* structure directly (the allocation/layout may change!).
*
*/
#ifndef _IDE_C
extern struct hwif_s ide_hwifs[]; /* master data repository */
#endif
extern int noautodma;
/*
......@@ -812,7 +813,7 @@ unsigned long current_capacity (ide_drive_t *drive);
/*
* Revalidate (read partition tables)
*/
void ide_revalidate_drive (ide_drive_t *drive);
extern void ide_revalidate_drive (ide_drive_t *drive);
/*
* Start a reset operation for an IDE interface.
......@@ -953,7 +954,6 @@ void do_taskfile (ide_drive_t *drive, struct hd_drive_task_hdr *taskfile, struct
/*
* Special Flagged Register Validation Caller
*/
// ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task);
ide_startstop_t set_multmode_intr (ide_drive_t *drive);
ide_startstop_t set_geometry_intr (ide_drive_t *drive);
......@@ -984,7 +984,6 @@ int pkt_taskfile_ioctl (ide_drive_t *drive, struct inode *inode, struct file *fi
#endif /* CONFIG_PKT_TASK_IOCTL */
void ide_delay_50ms (void);
int system_bus_clock(void);
byte ide_auto_reduce_xfer (ide_drive_t *drive);
int ide_driveid_update (ide_drive_t *drive);
......@@ -993,13 +992,7 @@ int ide_config_drive_speed (ide_drive_t *drive, byte speed);
byte eighty_ninty_three (ide_drive_t *drive);
int set_transfer (ide_drive_t *drive, ide_task_t *args);
/*
* ide_system_bus_speed() returns what we think is the system VESA/PCI
* bus speed (in MHz). This is used for calculating interface PIO timings.
* The default is 40 for known PCI systems, 50 otherwise.
* The "idebus=xx" parameter can be used to override this value.
*/
int ide_system_bus_speed (void);
extern int system_bus_speed;
/*
* idedisk_input_data() is a wrapper around ide_input_data() which copes
......@@ -1031,40 +1024,36 @@ void ide_intr (int irq, void *dev_id, struct pt_regs *regs);
void do_ide_request (request_queue_t * q);
void ide_init_subdrivers (void);
#ifndef _IDE_C
extern struct block_device_operations ide_fops[];
extern ide_proc_entry_t generic_subdriver_entries[];
#endif
int ide_reinit_drive (ide_drive_t *drive);
extern int ide_reinit_drive (ide_drive_t *drive);
#ifdef _IDE_C
# ifdef CONFIG_BLK_DEV_IDE
#ifdef CONFIG_BLK_DEV_IDE
/* Probe for devices attached to the systems host controllers.
*/
extern int ideprobe_init (void);
# endif
#endif
#ifdef CONFIG_BLK_DEV_IDEDISK
int idedisk_reinit (ide_drive_t *drive);
int idedisk_init (void);
extern int idedisk_reinit (ide_drive_t *drive);
extern int idedisk_init (void);
#endif /* CONFIG_BLK_DEV_IDEDISK */
#ifdef CONFIG_BLK_DEV_IDECD
int ide_cdrom_reinit (ide_drive_t *drive);
int ide_cdrom_init (void);
extern int ide_cdrom_reinit (ide_drive_t *drive);
extern int ide_cdrom_init (void);
#endif /* CONFIG_BLK_DEV_IDECD */
#ifdef CONFIG_BLK_DEV_IDETAPE
int idetape_reinit (ide_drive_t *drive);
int idetape_init (void);
extern int idetape_reinit (ide_drive_t *drive);
extern int idetape_init (void);
#endif /* CONFIG_BLK_DEV_IDETAPE */
#ifdef CONFIG_BLK_DEV_IDEFLOPPY
int idefloppy_reinit (ide_drive_t *drive);
int idefloppy_init (void);
extern int idefloppy_reinit (ide_drive_t *drive);
extern int idefloppy_init (void);
#endif /* CONFIG_BLK_DEV_IDEFLOPPY */
#ifdef CONFIG_BLK_DEV_IDESCSI
int idescsi_reinit (ide_drive_t *drive);
int idescsi_init (void);
extern int idescsi_reinit (ide_drive_t *drive);
extern int idescsi_init (void);
#endif /* CONFIG_BLK_DEV_IDESCSI */
#endif /* _IDE_C */
ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *driver, int n);
extern int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver);
......
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