ide: more IDE probing code rework
cover ide: more IDE probing code rework
* Convert legacy host drivers to use struct ide_port_info + ide_device_add() instead of open-coding initialization of IDE port data structures.
* Add ->cable_detect method for cable detection + use it in PCI host drivers.
* Fix some bugs in the process (handling of "idex=ata66" in atiixp, cs5535 and scc_pata and handling I/O 32-bit setting in dtc2278 and au1xxx-ide).
diffstat:
drivers/ide/arm/icside.c | 25 ++++--- drivers/ide/arm/ide_arm.c | 2 drivers/ide/arm/rapide.c | 2 drivers/ide/cris/ide-cris.c | 18 +++-- drivers/ide/h8300/ide-h8300.c | 2 drivers/ide/ide-generic.c | 2 drivers/ide/ide-pnp.c | 2 drivers/ide/ide-probe.c | 87 +++++++++++++++++++++++++- drivers/ide/ide.c | 6 - drivers/ide/legacy/ali14xx.c | 24 ++----- drivers/ide/legacy/buddha.c | 2 drivers/ide/legacy/dtc2278.c | 36 ++++------- drivers/ide/legacy/falconide.c | 2 drivers/ide/legacy/gayle.c | 2 drivers/ide/legacy/ht6560b.c | 22 +++--- drivers/ide/legacy/ide_platform.c | 2 drivers/ide/legacy/macide.c | 12 --- drivers/ide/legacy/q40ide.c | 2 drivers/ide/legacy/qd65xx.c | 23 ++++--- drivers/ide/legacy/umc8672.c | 24 ++----- drivers/ide/mips/au1xxx-ide.c | 34 +++------- drivers/ide/mips/swarm.c | 2 drivers/ide/pci/aec62xx.c | 25 +++---- drivers/ide/pci/alim15x3.c | 5 - drivers/ide/pci/amd74xx.c | 18 ++--- drivers/ide/pci/atiixp.c | 30 ++++----- drivers/ide/pci/cmd640.c | 31 ++++----- drivers/ide/pci/cmd64x.c | 5 - drivers/ide/pci/cs5520.c | 2 drivers/ide/pci/cs5535.c | 14 +--- drivers/ide/pci/hpt366.c | 84 ++++++++++++++----------- drivers/ide/pci/it8213.c | 21 +++--- drivers/ide/pci/it821x.c | 5 - drivers/ide/pci/jmicron.c | 6 - drivers/ide/pci/pdc202xx_new.c | 8 -- drivers/ide/pci/pdc202xx_old.c | 10 +-- drivers/ide/pci/piix.c | 7 -- drivers/ide/pci/scc_pata.c | 12 ++- drivers/ide/pci/serverworks.c | 9 -- drivers/ide/pci/sgiioc4.c | 18 +++-- drivers/ide/pci/siimage.c | 5 - drivers/ide/pci/sis5513.c | 5 - drivers/ide/pci/slc90e66.c | 19 +++-- drivers/ide/pci/tc86c001.c | 24 ++++--- drivers/ide/pci/via82cxxx.c | 6 - drivers/ide/ppc/mpc8xx.c | 2 drivers/ide/ppc/pmac.c | 84 ++++++++++--------------- drivers/ide/setup-pci.c | 123 +++++++++++--------------------------- include/linux/ide.h | 15 ++++ 49 files changed, 459 insertions(+), 467 deletions(-)
PATCH 1/8 dtc2278: fix ->io_32bit handling
On DTC2278 32-bit I/O has to be enabled for both devices on the port so always enable it during init time and disallow further changes.
--- drivers/ide/ide.c | 4 ---- drivers/ide/legacy/dtc2278.c | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/ide/ide.c +0 -4
@@ -791,10 +791,6 @@ int set_io_32bit(ide_drive_t *drive, intreturn -EBUSY ; drive->io_32bit = arg; -#ifdef CONFIG_BLK_DEV_DTC2278 -if (HWIF (drive)->chipset == ide_dtc2278) -HWIF (drive)->drives[!drive->select.b.unit].io_32bit = arg; -#endif /* CONFIG_BLK_DEV_DTC2278 */ spin_unlock_irq (&ide_lock);
drivers/ide/legacy/dtc2278.c +6 -6
@@ -84,12 +84,6 @@ static void dtc2278_set_pio_mode(ide_dri/* Actually we do - there is a data sheet available for the Winbond but does anyone actually care */ } - -/* -* 32bit I/O has to be enabled for *both* drives at the same time. -*/ - drive->io_32bit =1 ; -HWIF (drive)->drives[!drive->select.b.unit].io_32bit =1 ; }static int __init dtc2278_probe (void )
@@ -123,18 +117,24 @@ static int __init dtc2278_probe(void)local_irq_restore (flags); hwif->serialized =1 ; + hwif->no_io_32bit =1 ;/* disallow ->io_32bit changes */ hwif->chipset = ide_dtc2278; hwif->pio_mask =ATA_PIO4 ; hwif->set_pio_mode = &dtc2278_set_pio_mode; hwif->drives[0 ].no_unmask =1 ; hwif->drives[1 ].no_unmask =1 ; + hwif->drives[0 ].io_32bit =1 ; + hwif->drives[1 ].io_32bit =1 ; hwif->mate = mate; mate->serialized =1 ; + mate->no_io_32bit =1 ; mate->chipset = ide_dtc2278; mate->pio_mask =ATA_PIO4 ; mate->drives[0 ].no_unmask =1 ; mate->drives[1 ].no_unmask =1 ; + mate->drives[0 ].io_32bit =1 ; + mate->drives[1 ].io_32bit =1 ; mate->mate = hwif; mate->channel =1 ;
PATCH 2/8 au1xxx-ide: fix ->io_32bit handling
In reply to Bartlomiej ZolnierkiewiczThe host driver must set hwif's ->no_io_32bit setting not drive's one (ide_port_tune_devices() overrides drive's setting).
--- drivers/ide/mips/au1xxx-ide.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/ide/mips/au1xxx-ide.c +1 -2
@@ -658,8 +658,7 @@ static int au_ide_probe(struct device *d hwif->drives[0 ].autotune =1 ;/* 1=autotune, 2=noautotune, 0=default */ hwif->drives[1 ].autotune =1 ; - hwif->drives[0 ].no_io_32bit =1 ; - hwif->drives[1 ].no_io_32bit =1 ; + hwif->no_io_32bit =1 ; auide_hwif.hwif = hwif; hwif->hwif_data = &auide_hwif;
PATCH 3/8 atiixp/cs5535/scc_pata: fix "idex=ata66" parameter handling
In reply to Bartlomiej ZolnierkiewiczDon't override the cable type if the "idex=ata66" parameter was used.
While at it:
* atiixp.c: factor out cable detection to atiixp_cable_detect() from init_hwif_atiixp().
* cs5535.c: pass 'ide_hwif_t *hwif' instead of 'struct pci_dev *dev' to cs5535_cable_detect().
* scc_pata.c: factor out cable detection to scc_cable_detect() from init_hwif_scc() and remove incorrect comment.
---
+16 bytes
drivers/ide/pci/atiixp.c | 24 +++++++++++++++--------- drivers/ide/pci/cs5535.c | 8 ++++---- drivers/ide/pci/scc_pata.c | 9 +++++++-- 3 files changed, 26 insertions(+), 15 deletions(-)
drivers/ide/pci/atiixp.c +15 -9
@@ -121,6 +121,19 @@ static void atiixp_set_dma_mode(ide_drivspin_unlock_irqrestore (&atiixp_lock, flags); } +static u8 __devinit atiixp_cable_detect (ide_hwif_t *hwif) +{ +struct pci_dev *pdev =to_pci_dev (hwif->dev); +u8 udma_mode =0 , ch = hwif->channel; + +pci_read_config_byte (pdev,ATIIXP_IDE_UDMA_MODE + ch, &udma_mode); + +if ((udma_mode &0x07 ) >=0x04 || (udma_mode &0x70 ) >=0x40 ) +return ATA_CBL_PATA80 ; +else +return ATA_CBL_PATA40 ; +} +/** * init_hwif_atiixp - fill in the hwif for the ATIIXP * @hwif: IDE interface
@@ -131,21 +144,14 @@ static void atiixp_set_dma_mode(ide_drivstatic void __devinit init_hwif_atiixp (ide_hwif_t *hwif) { -struct pci_dev *pdev =to_pci_dev (hwif->dev); -u8 udma_mode =0 , ch = hwif->channel; - hwif->set_pio_mode = &atiixp_set_pio_mode; hwif->set_dma_mode = &atiixp_set_dma_mode;if (!hwif->dma_base)return ; -pci_read_config_byte (pdev,ATIIXP_IDE_UDMA_MODE + ch, &udma_mode); - -if ((udma_mode &0x07 ) >=0x04 || (udma_mode &0x70 ) >=0x40 ) - hwif->cbl =ATA_CBL_PATA80 ; -else - hwif->cbl =ATA_CBL_PATA40 ; +if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) + hwif->cbl =atiixp_cable_detect (hwif); }static const struct ide_port_info atiixp_pci_info[]__devinitdata = {
drivers/ide/pci/cs5535.c +4 -4
@@ -155,8 +155,9 @@ static void cs5535_set_pio_mode(ide_drivcs5535_set_speed (drive,XFER_PIO_0 + pio); } -static u8 __devinit cs5535_cable_detect (struct pci_dev *dev) +static u8 __devinit cs5535_cable_detect (ide_hwif_t *hwif) { +struct pci_dev *dev =to_pci_dev (hwif->dev);u8 bit;/* if a 80 wire cable was detected */
@@ -175,15 +176,14 @@ static u8 __devinit cs5535_cable_detect(*/ static void __devinit init_hwif_cs5535 (ide_hwif_t *hwif) { -struct pci_dev *dev =to_pci_dev (hwif->dev); - hwif->set_pio_mode = &cs5535_set_pio_mode; hwif->set_dma_mode = &cs5535_set_dma_mode;if (hwif->dma_base ==0 )return ; - hwif->cbl =cs5535_cable_detect (dev); +if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) + hwif->cbl =cs5535_cable_detect (hwif); }static const struct ide_port_info cs5535_chipset__devinitdata = {
drivers/ide/pci/scc_pata.c +7 -2
@@ -644,6 +644,11 @@ static void __devinit init_iops_scc(ide_init_mmio_iops_scc (hwif); } +static u8 __devinit scc_cable_detect (ide_hwif_t *hwif) +{ +return ATA_CBL_PATA80 ; +} +/** * init_hwif_scc - set up hwif * @hwif: interface to set up
@@ -678,8 +683,8 @@ static void __devinit init_hwif_scc(ide_else hwif->ultra_mask =ATA_UDMA5 ;/* 100MHz */ -/* we support 80c cable only. */ - hwif->cbl =ATA_CBL_PATA80 ; +if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) + hwif->cbl =scc_cable_detect (hwif); }#define DECLARE_SCC_DEV (name_str) \
PATCH 4/8 macide: remove drive->capacity64 quirk
In reply to Bartlomiej ZolnierkiewiczNowadays IDE core always provides drive ID and ide-disk always setups drive->capacity64 so this quirk is no longer needed.
--- drivers/ide/legacy/macide.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/ide/legacy/macide.c +0 -10
@@ -123,16 +123,6 @@ static int __init macide_init(void)ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw); -if (macintosh_config->ide_type ==MAC_IDE_BABOON && - macintosh_config->ident ==MAC_MODEL_PB190 ) { -/* Fix breakage in ide-disk.c: drive capacity */ -/* is not initialized for drives without a */ -/* hardware ID, and we can't get that without */ -/* probing the drive which freezes a 190. */ -ide_drive_t *drive = &hwif->drives[0 ]; - drive->capacity64 = drive->cyl*drive->head*drive->sect; - } - hwif->mmio =1 ;ide_device_add (idx);
PATCH 5/8 ide: always set DMA masks in ide_pci_setup_ports()
In reply to Bartlomiej ZolnierkiewiczAlways set DMA masks in ide_pci_setup_ports() to make sure that the valid masks for a host are set.
---
+34 bytes
drivers/ide/setup-pci.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/ide/setup-pci.c +9 -4
@@ -556,10 +556,15 @@ void ide_pci_setup_ports(struct pci_dev hwif->drives[1 ].unmask =1 ; } -if (hwif->dma_base) { - hwif->swdma_mask = d->swdma_mask; - hwif->mwdma_mask = d->mwdma_mask; - hwif->ultra_mask = d->udma_mask; + hwif->swdma_mask = d->swdma_mask; + hwif->mwdma_mask = d->mwdma_mask; + hwif->ultra_mask = d->udma_mask; + +if ((d->host_flags &&IDE_HFLAG_NO_DMA ) ==0 && + hwif->dma_base ==0 ) { + hwif->swdma_mask =0 ; + hwif->mwdma_mask =0 ; + hwif->ultra_mask =0 ; } hwif->drives[0 ].autotune =1 ;
Re: [PATCH 5/8] ide: always set DMA masks in ide_pci_setup_ports()
Hello.
Quoted 4 lines · Bartlomiej Zolnierkiewicz
Always set DMA masks in
ide_pci_setup_ports()to make sure that the valid masks for a host are set.Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
MBR, Sergei
PATCH 6/8 ide: separate PCI specific init from generic init in ide_pci_setup_ports()
In reply to Bartlomiej Zolnierkiewicz* Setup ->mate and ->channel in ide_pci_setup_ports() instead of in ide_hwif_configure().
* Make 'port' parameter for ide_hwif_configure() 'unsigned int'.
* Separate PCI specific init from generic init in ide_pci_setup_ports().
---
+28 bytes
drivers/ide/setup-pci.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
drivers/ide/setup-pci.c +21 -8
@@ -337,7 +337,8 @@ static int ide_pci_check_iomem(struct pc* ide_hwif_configure - configure an IDE interface * @dev: PCI device holding interface * @d: IDE port info -* @mate: Paired interface if any +* @port: port number +* @irq: PCI IRQ * * Perform the initial set up for the hardware interface structure. This * is done per interface port rather than per PCI device. There may be
@@ -346,7 +347,9 @@ static int ide_pci_check_iomem(struct pc* Returns the new hardware interface structure, or NULL on a failure */ -static ide_hwif_t *ide_hwif_configure (struct pci_dev *dev,const struct ide_port_info *d,ide_hwif_t *mate,int port,int irq) +static ide_hwif_t *ide_hwif_configure (struct pci_dev *dev, +const struct ide_port_info *d, +unsigned int port,int irq) {unsigned long ctl =0 , base =0 ;ide_hwif_t *hwif;
@@ -392,12 +395,7 @@ static ide_hwif_t *ide_hwif_configure(st hwif->dev = &dev->dev; hwif->cds = d; - hwif->channel = port; -if (mate) { - hwif->mate = mate; - mate->mate = hwif; - }return hwif; }
@@ -525,10 +523,25 @@ void ide_pci_setup_ports(struct pci_devcontinue ;/* port not enabled */ } -if ((hwif =ide_hwif_configure (dev, d, mate, port, pciirq)) ==NULL ) + hwif =ide_hwif_configure (dev, d, port, pciirq); +if (hwif ==NULL )continue ; *(idx + port) = hwif->index; + } + +for (port =0 ; port < channels; ++port) { +if (*(idx + port) ==0xff ) +continue ; + + hwif = &ide_hwifs[*(idx + port)]; + +if (mate) { + hwif->mate = mate; + mate->mate = hwif; + } + + hwif->channel = port;if (d->init_iops) d->init_iops (hwif);
PATCH 7/8 ide: add struct ide_port_info instances to legacy host drivers
In reply to Bartlomiej Zolnierkiewicz* Remove 'struct pci_dev *dev' argument from ide_hwif_setup_dma().
* Un-static ide_hwif_setup_dma() and add CONFIG_BLK_DEV_IDEDMA_PCI=n version.
* Add 'const struct ide_port_info *d' argument to ide_device_add[_all]().
* Factor out generic ports init from ide_pci_setup_ports() to ide_init_port(), move it to ide-probe.c and call it in in ide_device_add_all() instead of ide_pci_setup_ports().
* Move ->mate setup to ide_device_add_all() from ide_port_init().
* Add IDE_HFLAG_NO_AUTOTUNE host flag for host drivers that don't enable ->autotune currently.
* Setup hwif->chipset in ide_init_port() but iff pi->chipset is set (to not override setup done by ide_hwif_configure()).
* Add ETRAX host handling to ide_device_add_all().
* cmd640.c: set IDE_HFLAG_ABUSE_* also for CONFIG_BLK_DEV_CMD640_ENHANCED=n.
* pmac.c: make pmac_ide_setup_dma() return an error value and move DMA masks setup to pmac_ide_setup_device().
* Add 'struct ide_port_info' instances to legacy host drivers, pass them to ide_device_add() calls and then remove open-coded ports initialization.
--- drivers/ide/arm/icside.c | 25 +++++------ drivers/ide/arm/ide_arm.c | 2 drivers/ide/arm/rapide.c | 2 drivers/ide/cris/ide-cris.c | 18 ++++---- drivers/ide/h8300/ide-h8300.c | 2 drivers/ide/ide-generic.c | 2 drivers/ide/ide-pnp.c | 2 drivers/ide/ide-probe.c | 82 +++++++++++++++++++++++++++++++++++-- drivers/ide/ide.c | 2 drivers/ide/legacy/ali14xx.c | 24 ++++------ drivers/ide/legacy/buddha.c | 2 drivers/ide/legacy/dtc2278.c | 24 ++++------ drivers/ide/legacy/falconide.c | 2 drivers/ide/legacy/gayle.c | 2 drivers/ide/legacy/ht6560b.c | 22 ++++----- drivers/ide/legacy/ide_platform.c | 2 drivers/ide/legacy/macide.c | 2 drivers/ide/legacy/q40ide.c | 2 drivers/ide/legacy/qd65xx.c | 23 +++++----- drivers/ide/legacy/umc8672.c | 24 ++++------ drivers/ide/mips/au1xxx-ide.c | 31 ++++---------- drivers/ide/mips/swarm.c | 2 drivers/ide/pci/cmd640.c | 31 ++++++-------- drivers/ide/pci/cs5520.c | 2 drivers/ide/pci/sgiioc4.c | 18 +++++--- drivers/ide/ppc/mpc8xx.c | 2 drivers/ide/ppc/pmac.c | 84 +++++++++++++++----------------------- drivers/ide/setup-pci.c | 81 +++--------------------------------- include/linux/ide.h | 13 ++++- 29 files changed, 259 insertions(+), 271 deletions(-)
drivers/ide/arm/icside.c +13 -12
@@ -377,9 +377,6 @@ static void icside_dma_lost_irq(ide_drivstatic void icside_dma_init (ide_hwif_t *hwif) { - hwif->mwdma_mask =7 ;/* MW0..2 */ - hwif->swdma_mask =7 ;/* SW0..2 */ - hwif->dmatable_cpu =NULL ; hwif->dmatable_dma =0 ; hwif->set_dma_mode = icside_set_dma_mode;
@@ -459,11 +456,19 @@ icside_register_v5(struct icside_state * idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ; } +static const struct ide_port_info icside_v6_port_info__initdata = { + .host_flags =IDE_HFLAG_SERIALIZE | +IDE_HFLAG_NO_DMA |/* no SFF-style DMA */ +IDE_HFLAG_NO_AUTOTUNE , + .mwdma_mask =ATA_MWDMA2 , + .swdma_mask =ATA_SWDMA2 , +}; +static int __init icside_register_v6 (struct icside_state *state,struct expansion_card *ec) {
@@ -472,6 +477,7 @@ icside_register_v6(struct icside_state *unsigned int sel =0 ;int ret;u8 idx[4 ] = {0xff ,0xff ,0xff ,0xff }; +struct ide_port_info d = icside_v6_port_info; ioc_base =ecardm_iomap (ec,ECARD_RES_IOCFAST ,0 ,0 );if (!ioc_base) {
@@ -521,30 +527,25 @@ icside_register_v6(struct icside_state * state->hwif[1 ] = mate; hwif->maskproc = icside_maskproc; - hwif->channel =0 ; hwif->hwif_data = state; - hwif->mate = mate; - hwif->serialized =1 ; hwif->config_data = (unsigned long )ioc_base; hwif->select_data = sel; mate->maskproc = icside_maskproc; - mate->channel =1 ; mate->hwif_data = state; - mate->mate = hwif; - mate->serialized =1 ; mate->config_data = (unsigned long )ioc_base; mate->select_data = sel |1 ;if (ec->dma !=NO_DMA && !request_dma (ec->dma, hwif->name)) {icside_dma_init (hwif);icside_dma_init (mate); - } + }else + d.mwdma_mask = d.swdma_mask =0 ; idx[0 ] = hwif->index; idx[1 ] = mate->index; -ide_device_add (idx); +ide_device_add (idx, &d);return 0 ;
drivers/ide/arm/ide_arm.c +1 -1
@@ -39,7 +39,7 @@ static int __init ide_arm_init(void)ide_init_port_hw (hwif, &hw); idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL ); }return 0 ;
drivers/ide/arm/rapide.c +1 -1
@@ -58,7 +58,7 @@ rapide_probe(struct expansion_card *ec, idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL );ecard_set_drvdata (ec, hwif); goto out;
drivers/ide/cris/ide-cris.c +10 -8
@@ -753,6 +753,15 @@ static void cris_set_dma_mode(ide_drive_cris_ide_set_speed (TYPE_DMA ,0 , strobe, hold); } +static const struct ide_port_info cris_port_info__initdata = { + .chipset = ide_etrax100, + .host_flags =IDE_HFLAG_NO_ATAPI_DMA | +IDE_HFLAG_NO_DMA ,/* no SFF-style DMA */ + .pio_mask =ATA_PIO4 , + .udma_mask = cris_ultra_mask, + .mwdma_mask =ATA_MWDMA2 , +}; +static int __init init_e100_ide (void ) {hw_regs_t hw;
@@ -780,7 +789,6 @@ static int __init init_e100_ide(void)ide_init_port_data (hwif, hwif->index);ide_init_port_hw (hwif, &hw); hwif->mmio =1 ; - hwif->chipset = ide_etrax100; hwif->set_pio_mode = &cris_set_pio_mode; hwif->set_dma_mode = &cris_set_dma_mode; hwif->ata_input_data = &cris_ide_input_data;
@@ -799,12 +807,6 @@ static int __init init_e100_ide(void) hwif->INB = &cris_ide_inb; hwif->INW = &cris_ide_inw; hwif->cbl =ATA_CBL_PATA40 ; - hwif->host_flags |=IDE_HFLAG_NO_ATAPI_DMA ; - hwif->pio_mask =ATA_PIO4 , - hwif->drives[0 ].autotune =1 ; - hwif->drives[1 ].autotune =1 ; - hwif->ultra_mask = cris_ultra_mask; - hwif->mwdma_mask =0x07 ;/* Multiword DMA 0-2 */ idx[h] = hwif->index; }
@@ -820,7 +822,7 @@ static int __init init_e100_ide(void)cris_ide_set_speed (TYPE_DMA ,0 ,ATA_DMA2_STROBE ,ATA_DMA2_HOLD );cris_ide_set_speed (TYPE_UDMA ,ATA_UDMA2_CYC ,ATA_UDMA2_DVS ,0 ); -ide_device_add (idx); +ide_device_add (idx, &cris_port_info);return 0 ; }
drivers/ide/h8300/ide-h8300.c +1 -1
@@ -114,7 +114,7 @@ static int __init h8300_ide_init(void) idx[0 ] = index; -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ;
drivers/ide/ide-generic.c +1 -1
@@ -23,7 +23,7 @@ static int __init ide_generic_init(void)for (i =0 ; i <MAX_HWIFS ; i++) idx[i] = ide_hwifs[i].present ?0xff : i; -ide_device_add_all (idx); +ide_device_add_all (idx,NULL );if (ide_hwifs[0 ].io_ports[IDE_DATA_OFFSET ])ide_release_lock ();/* for atari only */
drivers/ide/ide-pnp.c +1 -1
@@ -49,7 +49,7 @@ static int idepnp_probe(struct pnp_dev *printk (KERN_INFO "ide%d: generic PnP IDE interface\n" , index);pnp_set_drvdata (dev,hwif); -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ; }
drivers/ide/ide-probe.c +78 -4
103 lines not on this page · raw message
drivers/ide/ide.c +1 -1
@@ -728,7 +728,7 @@ found: idx[0 ] = index; -ide_device_add (idx); +ide_device_add (idx,NULL );if (hwifp) *hwifp = hwif;
drivers/ide/legacy/ali14xx.c +9 -15
@@ -191,9 +191,14 @@ static int __init initRegisters (void) {return t; } +static const struct ide_port_info ali14xx_port_info = { + .chipset = ide_ali14xx, + .host_flags =IDE_HFLAG_NO_DMA |IDE_HFLAG_NO_AUTOTUNE , + .pio_mask =ATA_PIO4 , +}; +static int __init ali14xx_probe (void ) { -ide_hwif_t *hwif, *mate;static u8 idx[4 ] = {0 ,1 ,0xff ,0xff }; printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
@@ -205,21 +210,10 @@ static int __init ali14xx_probe(void)return 1 ; } - hwif = &ide_hwifs[0 ]; - mate = &ide_hwifs[1 ]; - - hwif->chipset = ide_ali14xx; - hwif->pio_mask =ATA_PIO4 ; - hwif->set_pio_mode = &ali14xx_set_pio_mode; - hwif->mate = mate; - - mate->chipset = ide_ali14xx; - mate->pio_mask =ATA_PIO4 ; - mate->set_pio_mode = &ali14xx_set_pio_mode; - mate->mate = hwif; - mate->channel =1 ; + ide_hwifs[0 ].set_pio_mode = &ali14xx_set_pio_mode; + ide_hwifs[1 ].set_pio_mode = &ali14xx_set_pio_mode; -ide_device_add (idx); +ide_device_add (idx, &ali14xx_port_info);return 0 ; }
drivers/ide/legacy/buddha.c +1 -1
@@ -232,7 +232,7 @@ fail_base2: } } -ide_device_add (idx); +ide_device_add (idx,NULL ); }return 0 ;
drivers/ide/legacy/dtc2278.c +10 -14
@@ -86,6 +86,15 @@ static void dtc2278_set_pio_mode(ide_dri } } +static const struct ide_port_info dtc2278_port_info__initdata = { + .chipset = ide_dtc2278, + .host_flags =IDE_HFLAG_SERIALIZE | +IDE_HFLAG_IO_32BIT | +IDE_HFLAG_NO_DMA | +IDE_HFLAG_NO_AUTOTUNE , + .pio_mask =ATA_PIO4 , +}; +static int __init dtc2278_probe (void ) {unsigned long flags;
@@ -116,29 +125,16 @@ static int __init dtc2278_probe(void)#endif local_irq_restore (flags); - hwif->serialized =1 ; hwif->no_io_32bit =1 ;/* disallow ->io_32bit changes */ - hwif->chipset = ide_dtc2278; - hwif->pio_mask =ATA_PIO4 ; hwif->set_pio_mode = &dtc2278_set_pio_mode; hwif->drives[0 ].no_unmask =1 ; hwif->drives[1 ].no_unmask =1 ; - hwif->drives[0 ].io_32bit =1 ; - hwif->drives[1 ].io_32bit =1 ; - hwif->mate = mate; - mate->serialized =1 ; mate->no_io_32bit =1 ; - mate->chipset = ide_dtc2278; - mate->pio_mask =ATA_PIO4 ; mate->drives[0 ].no_unmask =1 ; mate->drives[1 ].no_unmask =1 ; - mate->drives[0 ].io_32bit =1 ; - mate->drives[1 ].io_32bit =1 ; - mate->mate = hwif; - mate->channel =1 ; -ide_device_add (idx); +ide_device_add (idx, &dtc2278_port_info);return 0 ; }
drivers/ide/legacy/falconide.c +1 -1
@@ -82,7 +82,7 @@ static int __init falconide_init(void)ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw); -ide_device_add (idx); +ide_device_add (idx,NULL ); } }
drivers/ide/legacy/gayle.c +1 -1
@@ -186,7 +186,7 @@ found:release_mem_region (res_start, res_n); } -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ; }
drivers/ide/legacy/ht6560b.c +10 -12
@@ -305,6 +305,15 @@ int probe_ht6560b = 0;module_param_named (probe, probe_ht6560b, bool,0 );MODULE_PARM_DESC (probe,"probe for HT6560B chipset" ); +static const struct ide_port_info ht6560b_port_info__initdata = { + .chipset = ide_ht6560b, + .host_flags =IDE_HFLAG_SERIALIZE |/* is this needed? */ +IDE_HFLAG_NO_DMA | +IDE_HFLAG_NO_AUTOTUNE | +IDE_HFLAG_ABUSE_PREFETCH , + .pio_mask =ATA_PIO5 , +}; +static int __init ht6560b_init (void ) {ide_hwif_t *hwif, *mate;
@@ -328,22 +337,11 @@ static int __init ht6560b_init(void) goto release_region; } - hwif->chipset = ide_ht6560b; hwif->selectproc = &ht6560b_selectproc; - hwif->host_flags =IDE_HFLAG_ABUSE_PREFETCH ; - hwif->pio_mask =ATA_PIO5 ; hwif->set_pio_mode = &ht6560b_set_pio_mode; - hwif->serialized =1 ;/* is this needed? */ - hwif->mate = mate; - mate->chipset = ide_ht6560b; mate->selectproc = &ht6560b_selectproc; - mate->host_flags =IDE_HFLAG_ABUSE_PREFETCH ; - mate->pio_mask =ATA_PIO5 ; mate->set_pio_mode = &ht6560b_set_pio_mode; - mate->serialized =1 ;/* is this needed? */ - mate->mate = hwif; - mate->channel =1 ;/* * Setting default configurations for drives
@@ -357,7 +355,7 @@ static int __init ht6560b_init(void) mate->drives[0 ].drive_data = t; mate->drives[1 ].drive_data = t; -ide_device_add (idx); +ide_device_add (idx, &ht6560b_port_info);return 0 ;
drivers/ide/legacy/ide_platform.c +1 -1
@@ -108,7 +108,7 @@ static int __devinit plat_ide_probe(stru idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL );platform_set_drvdata (pdev, hwif);
drivers/ide/legacy/macide.c +1 -1
@@ -125,7 +125,7 @@ static int __init macide_init(void) hwif->mmio =1 ; -ide_device_add (idx); +ide_device_add (idx,NULL ); }return 0 ;
drivers/ide/legacy/q40ide.c +1 -1
@@ -154,7 +154,7 @@ static int __init q40ide_init(void) } } -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ; }
drivers/ide/legacy/qd65xx.c +13 -10
@@ -308,15 +308,10 @@ static int __init qd_testreg(int port)static void __init qd_setup (ide_hwif_t *hwif,int base,int config,unsigned int data0,unsigned int data1) { - hwif->chipset = ide_qd65xx; - hwif->channel = hwif->index; hwif->select_data = base; hwif->config_data = config; hwif->drives[0 ].drive_data = data0; hwif->drives[1 ].drive_data = data1; - hwif->drives[0 ].io_32bit = - hwif->drives[1 ].io_32bit =1 ; - hwif->pio_mask =ATA_PIO4 ; }/*
@@ -356,6 +351,14 @@ static void __exit qd_unsetup(ide_hwif_t} */ +static const struct ide_port_info qd65xx_port_info__initdata = { + .chipset = ide_qd65xx, + .host_flags =IDE_HFLAG_IO_32BIT | +IDE_HFLAG_NO_DMA | +IDE_HFLAG_NO_AUTOTUNE , + .pio_mask =ATA_PIO4 , +}; +/* * qd_probe: *
@@ -397,9 +400,9 @@ static int __init qd_probe(int base) hwif->set_pio_mode = &qd6500_set_pio_mode; - idx[0 ] = unit; + idx[unit] = unit; -ide_device_add (idx); +ide_device_add (idx, &qd65xx_port_info);return 1 ; }
@@ -431,9 +434,9 @@ static int __init qd_probe(int base) hwif->set_pio_mode = &qd6580_set_pio_mode; - idx[0 ] = unit; + idx[unit] = unit; -ide_device_add (idx); +ide_device_add (idx, &qd65xx_port_info);outb (QD_DEF_CONTR ,QD_CONTROL_PORT );
@@ -460,7 +463,7 @@ static int __init qd_probe(int base) idx[0 ] =0 ; idx[1 ] =1 ; -ide_device_add (idx); +ide_device_add (idx, &qd65xx_port_info);outb (QD_DEF_CONTR ,QD_CONTROL_PORT );
drivers/ide/legacy/umc8672.c +9 -15
@@ -120,9 +120,14 @@ static void umc_set_pio_mode(ide_drive_tspin_unlock_irqrestore (&ide_lock, flags); } +static const struct ide_port_info umc8672_port_info__initdata = { + .chipset = ide_umc8672, + .host_flags =IDE_HFLAG_NO_DMA |IDE_HFLAG_NO_AUTOTUNE , + .pio_mask =ATA_PIO4 , +}; +static int __init umc8672_probe (void ) { -ide_hwif_t *hwif, *mate;unsigned long flags;static u8 idx[4 ] = {0 ,1 ,0xff ,0xff };
@@ -143,21 +148,10 @@ static int __init umc8672_probe(void)umc_set_speeds (current_speeds);local_irq_restore (flags); - hwif = &ide_hwifs[0 ]; - mate = &ide_hwifs[1 ]; - - hwif->chipset = ide_umc8672; - hwif->pio_mask =ATA_PIO4 ; - hwif->set_pio_mode = &umc_set_pio_mode; - hwif->mate = mate; - - mate->chipset = ide_umc8672; - mate->pio_mask =ATA_PIO4 ; - mate->set_pio_mode = &umc_set_pio_mode; - mate->mate = hwif; - mate->channel =1 ; + ide_hwifs[0 ].set_pio_mode = &umc_set_pio_mode; + ide_hwifs[1 ].set_pio_mode = &umc_set_pio_mode; -ide_device_add (idx); +ide_device_add (idx, &umc8672_port_info);return 0 ; }
drivers/ide/mips/au1xxx-ide.c +11 -20
@@ -548,6 +548,16 @@ static void auide_setup_ports(hw_regs_t *ata_regs = ahwif->regbase + (14 <<AU1XXX_ATA_REG_OFFSET ); } +static const struct ide_port_info au1xxx_port_info = { + .host_flags =IDE_HFLAG_POST_SET_MODE | +IDE_HFLAG_NO_DMA |/* no SFF-style DMA */ +IDE_HFLAG_UNMASK_IRQS , + .pio_mask =ATA_PIO4 , +#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA + .mwdma_mask =ATA_MWDMA2 , +#endif +}; +static int au_ide_probe (struct device *dev) {struct platform_device *pdev =to_platform_device (dev);
@@ -606,21 +616,6 @@ static int au_ide_probe(struct device *d hwif->dev = dev; - hwif->ultra_mask =0x0 ;/* Disable Ultra DMA */ -#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA - hwif->mwdma_mask =0x07 ;/* Multimode-2 DMA */ - hwif->swdma_mask =0x00 ; -#else - hwif->mwdma_mask =0x0 ; - hwif->swdma_mask =0x0 ; -#endif - - hwif->pio_mask =ATA_PIO4 ; - hwif->host_flags =IDE_HFLAG_POST_SET_MODE ; - - hwif->drives[0 ].unmask =1 ; - hwif->drives[1 ].unmask =1 ; -/* hold should be on in all cases */ hwif->hold =1 ;
@@ -651,13 +646,9 @@ static int au_ide_probe(struct device *d hwif->ide_dma_test_irq = &auide_dma_test_irq; hwif->dma_lost_irq = &auide_dma_lost_irq;#endif - hwif->channel =0 ; hwif->select_data =0 ;/* no chipset-specific code */ hwif->config_data =0 ;/* no chipset-specific code */ - hwif->drives[0 ].autotune =1 ;/* 1=autotune, 2=noautotune, 0=default */ - hwif->drives[1 ].autotune =1 ; - hwif->no_io_32bit =1 ; auide_hwif.hwif = hwif;
@@ -670,7 +661,7 @@ static int au_ide_probe(struct device *d idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx, &au1xxx_port_info);dev_set_drvdata (dev, hwif);
drivers/ide/mips/swarm.c +1 -1
@@ -129,7 +129,7 @@ static int __devinit swarm_ide_probe(str idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL );dev_set_drvdata (dev, hwif);
drivers/ide/pci/cmd640.c +15 -16
@@ -703,6 +703,18 @@ static int pci_conf2(void)return 0 ; } +static const struct ide_port_info cmd640_port_info__initdata = { + .chipset = ide_cmd640, + .host_flags =IDE_HFLAG_SERIALIZE | +IDE_HFLAG_NO_DMA | +IDE_HFLAG_NO_AUTOTUNE | +IDE_HFLAG_ABUSE_PREFETCH | +IDE_HFLAG_ABUSE_FAST_DEVSEL , +#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED + .pio_mask =ATA_PIO5 , +#endif +}; +/* * Probe for a cmd640 chipset, and initialize it if found. */
@@ -760,11 +772,7 @@ static int __init cmd640x_init(void)setup_device_ptrs ();printk ("%s: buggy cmd640%c interface on %s, config=0x%02x\n" , cmd_hwif0->name,'a' + cmd640_chip_version -1 , bus_type, cfr); - cmd_hwif0->chipset = ide_cmd640;#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED - cmd_hwif0->host_flags =IDE_HFLAG_ABUSE_PREFETCH | -IDE_HFLAG_ABUSE_FAST_DEVSEL ; - cmd_hwif0->pio_mask =ATA_PIO5 ; cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode;#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
@@ -815,23 +823,14 @@ static int __init cmd640x_init(void)* Initialize data for secondary cmd640 port, if enabled */ if (second_port_cmd640) { - cmd_hwif0->serialized =1 ; - cmd_hwif1->serialized =1 ; - cmd_hwif1->chipset = ide_cmd640; - cmd_hwif0->mate = cmd_hwif1; - cmd_hwif1->mate = cmd_hwif0; - cmd_hwif1->channel =1 ; -#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED - cmd_hwif1->host_flags =IDE_HFLAG_ABUSE_PREFETCH | -IDE_HFLAG_ABUSE_FAST_DEVSEL ; - cmd_hwif1->pio_mask =ATA_PIO5 ; +#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode;#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ idx[1 ] = cmd_hwif1->index; }printk (KERN_INFO "%s: %sserialized, secondary interface %s\n" , cmd_hwif1->name, - cmd_hwif0->serialized ?"" :"not " , port2); + second_port_cmd640 ?"" :"not " , port2);/* * Establish initial timings/prefetch for all drives.
@@ -876,7 +875,7 @@ static int __init cmd640x_init(void)cmd640_dump_regs ();#endif -ide_device_add (idx); +ide_device_add (idx, &cmd640_port_info);return 1 ; }
drivers/ide/pci/cs5520.c +1 -1
@@ -174,7 +174,7 @@ static int __devinit cs5520_init_one(stride_pci_setup_ports (dev, d,14 , &idx[0 ]); -ide_device_add (idx); +ide_device_add (idx, d);return 0 ; }
drivers/ide/pci/sgiioc4.c +12 -6
@@ -555,7 +555,6 @@ static void __devinit ide_init_sgiioc4(ide_hwif_t * hwif) { hwif->mmio =1 ; - hwif->pio_mask =0x00 ; hwif->set_pio_mode =NULL ;/* Sets timing for PIO mode */ hwif->set_dma_mode = &sgiioc4_set_dma_mode; hwif->selectproc =NULL ;/* Use the default routine to select drive */
@@ -572,8 +571,6 @@ ide_init_sgiioc4(ide_hwif_t * hwif)if (hwif->dma_base ==0 )return ; - hwif->mwdma_mask =ATA_MWDMA2_ONLY ; - hwif->dma_host_set = &sgiioc4_dma_host_set; hwif->dma_setup = &sgiioc4_ide_dma_setup; hwif->dma_start = &sgiioc4_ide_dma_start;
@@ -583,6 +580,13 @@ ide_init_sgiioc4(ide_hwif_t * hwif) hwif->dma_timeout = &ide_dma_timeout; } +static const struct ide_port_info sgiioc4_port_info__devinitdata = { + .chipset = ide_pci, + .host_flags =IDE_HFLAG_NO_DMA |/* no SFF-style DMA */ +IDE_HFLAG_NO_AUTOTUNE , + .mwdma_mask =ATA_MWDMA2_ONLY , +}; +static int __devinit sgiioc4_ide_setup_pci_device (struct pci_dev *dev) {
@@ -593,6 +597,7 @@ sgiioc4_ide_setup_pci_device(struct pci_int h;u8 idx[4 ] = {0xff ,0xff ,0xff ,0xff };hw_regs_t hw; +struct ide_port_info d = sgiioc4_port_info;/* * Find an empty HWIF; if none available, return -ENOMEM.
@@ -641,7 +646,6 @@ sgiioc4_ide_setup_pci_device(struct pci_ide_init_port_hw (hwif, &hw); hwif->dev = &dev->dev; - hwif->channel =0 ;/* Single Channel chip */ /* The IOC4 uses MMIO rather than Port IO. */ default_hwif_mmiops (hwif);
@@ -649,15 +653,17 @@ sgiioc4_ide_setup_pci_device(struct pci_/* Initializing chipset IRQ Registers */ writel (0x03 , (void __iomem *)(irqport +IOC4_INTR_SET *4 )); -if (dma_base ==0 ||ide_dma_sgiioc4 (hwif, dma_base)) +if (dma_base ==0 ||ide_dma_sgiioc4 (hwif, dma_base)) {printk (KERN_INFO "%s: %s Bus-Master DMA disabled\n" , hwif->name,DRV_NAME ); + d.mwdma_mask =0 ; + }ide_init_sgiioc4 (hwif); idx[0 ] = hwif->index; -if (ide_device_add (idx)) +if (ide_device_add (idx, &d))return -EIO ;return 0 ;
drivers/ide/ppc/mpc8xx.c +1 -1
@@ -848,7 +848,7 @@ static int __init mpc8xx_ide_probe(void)#endif #endif -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ; }
drivers/ide/ppc/pmac.c +35 -49
155 lines not on this page · raw message
drivers/ide/setup-pci.c +8 -73
128 lines not on this page · raw message
include/linux/ide.h +11 -2
@@ -1019,6 +1019,13 @@ extern int __ide_pci_register_driver(strvoid ide_pci_setup_ports (struct pci_dev *,const struct ide_port_info *,int ,u8 *);void ide_setup_pci_noise (struct pci_dev *,const struct ide_port_info *); +#ifdef CONFIG_BLK_DEV_IDEDMA_PCI +void ide_hwif_setup_dma (ide_hwif_t *,const struct ide_port_info *); +#else +static inline void ide_hwif_setup_dma (ide_hwif_t *hwif, +const struct ide_port_info *d) { } +#endif +extern void default_hwif_iops (ide_hwif_t *);extern void default_hwif_mmiops (ide_hwif_t *);extern void default_hwif_transport (ide_hwif_t *);
@@ -1092,6 +1099,8 @@ enum {IDE_HFLAG_CLEAR_SIMPLEX = (1 <<28 ),/* DSC overlap is unsupported */ IDE_HFLAG_NO_DSC = (1 <<29 ), +/* don't autotune PIO */ + IDE_HFLAG_NO_AUTOTUNE = (1 << 30), };#ifdef CONFIG_BLK_DEV_OFFBOARD
@@ -1204,8 +1213,8 @@ void ide_unregister_region(struct gendisvoid ide_undecoded_slave (ide_drive_t *); -int ide_device_add_all (u8 *idx); -int ide_device_add (u8 idx[4 ]); +int ide_device_add_all (u8 *idx,const struct ide_port_info *); +int ide_device_add (u8 idx[4 ],const struct ide_port_info *);static inline void *ide_get_hwifdata (ide_hwif_t * hwif) {
Re: [PATCH 7/8] ide: add struct ide_port_info instances to legacy host drivers
Hello.
Quoted 42 lines · Bartlomiej Zolnierkiewicz
* Remove 'struct
pci_dev*dev' argument fromide_hwif_setup_dma().* Un-static
ide_hwif_setup_dma()and addCONFIG_BLK_DEV_IDEDMA_PCI=nversion.* Add 'const struct
ide_port_info*d' argument to ide_device_add[_all]().* Factor out generic ports init from
ide_pci_setup_ports()toide_init_port(), move it toide-probe.cand call it in inide_device_add_all()instead ofide_pci_setup_ports().* Move ->mate setup to
ide_device_add_all()fromide_port_init().* Add
IDE_HFLAG_NO_AUTOTUNEhost flag for host drivers that don't enable ->autotune currently.* Setup
hwif->chipsetinide_init_port()but iffpi->chipsetis set (to not override setup done byide_hwif_configure()).* Add ETRAX host handling to
ide_device_add_all().*
cmd640.c: set IDE_HFLAG_ABUSE_* also forCONFIG_BLK_DEV_CMD640_ENHANCED=n.*
pmac.c: makepmac_ide_setup_dma()return an error value and move DMA masks setup topmac_ide_setup_device().* Add 'struct
ide_port_info' instances to legacy host drivers, pass them toide_device_add()calls and then remove open-coded ports initialization.Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Index:
b/drivers/ide/arm/icside.c
===================================================================drivers/ide/arm/icside.c +1
-1@@ -459,11 +456,19 @@ icside_register_v5(struct icside_state * idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ;
drivers/ide/arm/icside.c icside_register_v5(struct icside_state * · line 471
Quoted 10 lines
drivers/ide/arm/icside.c +8
-0} +static const struct ide_port_info icside_v6_port_info__initdata = { + .host_flags =IDE_HFLAG_SERIALIZE | +IDE_HFLAG_NO_DMA |/* no SFF-style DMA */ +IDE_HFLAG_NO_AUTOTUNE , + .mwdma_mask =ATA_MWDMA2 , + .swdma_mask =ATA_SWDMA2 , +}; +
Interesting... this driver's support for SWDMA0 is broken since the cycle
should be 960 ns long, not 480, and SWDMA2 is underclocked using the same cycle as SWDMA1, 480 ns...
Quoted 5 lines
Index:
b/drivers/ide/cris/ide-cris.c
===================================================================
drivers/ide/cris/ide-cris.c static void cris_set_dma_mode(ide_drive_ · line 761
Quoted 9 lines
drivers/ide/cris/ide-cris.c +6
-0@@ -753,6 +753,15 @@ static void cris_set_dma_mode(ide_drive_cris_ide_set_speed (TYPE_DMA ,0 , strobe, hold); } +static const struct ide_port_info cris_port_info__initdata = { + .chipset = ide_etrax100, + .host_flags =IDE_HFLAG_NO_ATAPI_DMA | +IDE_HFLAG_NO_DMA ,/* no SFF-style DMA */ + .pio_mask =ATA_PIO4 , + .udma_mask = cris_ultra_mask,
Hm, I wonder which value it will assume, 0x07 or 0? Not sure even after
looking at the source... :-)
Quoted 11 lines
drivers/ide/cris/ide-cris.c +3
-0+ .mwdma_mask = ATA_MWDMA2, +}; +static int __init init_e100_ide (void ) {hw_regs_t hw;Index:
b/drivers/ide/ide-probe.c
===================================================================
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1296
Quoted 10 lines
drivers/ide/ide-probe.c +4
-2@@ -1289,12 +1289,86 @@ static void hwif_register_devices(ide_hw } } -int ide_device_add_all (u8 *idx) +static void ide_init_port (ide_hwif_t *hwif,unsigned int port, +const struct ide_port_info *d) { -ide_hwif_t *hwif; +if (d->chipset != ide_etrax100) + hwif->channel = port;
Hm, what's so special about ide_etrax100?
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1348
Quoted 1 line
drivers/ide/ide-probe.c +1
-0+int ide_device_add_all (u8 idx[MAX_HWIFS ],const struct ide_port_info *d)
Function prototype doesn't match with one from <linux/ide.h> which has the
first argument as a pointer...
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1354
Quoted 6 lines
drivers/ide/ide-probe.c +3
-0+{ +ide_hwif_t *hwif, *mate =NULL ;int i, rc =0 ;for (i =0 ; i <MAX_HWIFS ; i++) { +if (d ==NULL || idx[i] ==0xff ) {
Why check for (d == NULL) every time and not do it once and break from the
loop or even do it before the loop?
Quoted 9 lines
drivers/ide/ide-probe.c +9
-0+ mate =NULL ; +continue ; + } + + hwif = &ide_hwifs[idx[i]]; + +if (d->chipset != ide_etrax100 && (i &1 ) && mate) { + hwif->mate = mate; + mate->mate = hwif;
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1373
Quoted 10 lines
drivers/ide/ide-probe.c +8
-0+ } + + mate = (i &1 ) ?NULL : hwif; + +ide_init_port (hwif, i &1 , d); + } + +for (i =0 ; i <MAX_HWIFS ; i++) {if (idx[i] ==0xff )continue ;
MBR, Sergei
Re: [PATCH 7/8] ide: add struct ide_port_info instances to legacy host drivers
Hi,
Quoted 48 lines · Sergei Shtylyov
Hello.
Quoted 44 lines · Bartlomiej Zolnierkiewicz
* Remove 'struct
pci_dev*dev' argument fromide_hwif_setup_dma().* Un-static
ide_hwif_setup_dma()and addCONFIG_BLK_DEV_IDEDMA_PCI=nversion.* Add 'const struct
ide_port_info*d' argument to ide_device_add[_all]().* Factor out generic ports init from
ide_pci_setup_ports()toide_init_port(), move it toide-probe.cand call it in inide_device_add_all()instead ofide_pci_setup_ports().* Move ->mate setup to
ide_device_add_all()fromide_port_init().* Add
IDE_HFLAG_NO_AUTOTUNEhost flag for host drivers that don't enable ->autotune currently.* Setup
hwif->chipsetinide_init_port()but iffpi->chipsetis set (to not override setup done byide_hwif_configure()).* Add ETRAX host handling to
ide_device_add_all().*
cmd640.c: set IDE_HFLAG_ABUSE_* also forCONFIG_BLK_DEV_CMD640_ENHANCED=n.*
pmac.c: makepmac_ide_setup_dma()return an error value and move DMA masks setup topmac_ide_setup_device().* Add 'struct
ide_port_info' instances to legacy host drivers, pass them toide_device_add()calls and then remove open-coded ports initialization.Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Index:
b/drivers/ide/arm/icside.c
===================================================================drivers/ide/arm/icside.c +1
-1@@ -459,11 +456,19 @@ icside_register_v5(struct icside_state * idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ; }
Quoted 12 lines
drivers/ide/arm/icside.c icside_register_v5(struct icside_state * · line 471
Quoted 8 lines
drivers/ide/arm/icside.c +8
-0+static const struct ide_port_info icside_v6_port_info__initdata = { + .host_flags =IDE_HFLAG_SERIALIZE | +IDE_HFLAG_NO_DMA |/* no SFF-style DMA */ +IDE_HFLAG_NO_AUTOTUNE , + .mwdma_mask =ATA_MWDMA2 , + .swdma_mask =ATA_SWDMA2 , +}; +Interesting... this driver's support for SWDMA0 is broken since the cycle
should be 960 ns long, not 480, and SWDMA2 is underclocked using the same cycle as SWDMA1, 480 ns...
Added Russell to Cc:.
Quoted 16 lines
Quoted 5 lines
Index:
b/drivers/ide/cris/ide-cris.c
===================================================================drivers/ide/cris/ide-cris.c static void cris_set_dma_mode(ide_drive_ · line 761
Quoted 9 lines
drivers/ide/cris/ide-cris.c +6
-0@@ -753,6 +753,15 @@ static void cris_set_dma_mode(ide_drive_cris_ide_set_speed (TYPE_DMA ,0 , strobe, hold); } +static const struct ide_port_info cris_port_info__initdata = { + .chipset = ide_etrax100, + .host_flags =IDE_HFLAG_NO_ATAPI_DMA | +IDE_HFLAG_NO_DMA ,/* no SFF-style DMA */ + .pio_mask =ATA_PIO4 , + .udma_mask = cris_ultra_mask,Hm, I wonder which value it will assume, 0x07 or 0? Not sure even after
Quoted 1 line
looking at the source... :-)
This is tricky since it depends on the CRIS version (0x07 on CRIS V32 and 0x00 on CRIS V10).
Quoted 14 lines
Quoted 14 lines
drivers/ide/cris/ide-cris.c +3
-0+ .mwdma_mask = ATA_MWDMA2, +}; +static int __init init_e100_ide (void ) {hw_regs_t hw;Index:
b/drivers/ide/ide-probe.c
===================================================================drivers/ide/ide-probe.c +0
-0@@ -1289,12 +1289,86 @@ static void hwif_register_devices(ide_hw } }
Quoted 9 lines
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1296
Quoted 7 lines
drivers/ide/ide-probe.c +4
-2-int ide_device_add_all (u8 *idx) +static void ide_init_port (ide_hwif_t *hwif,unsigned int port, +const struct ide_port_info *d) { -ide_hwif_t *hwif; +if (d->chipset != ide_etrax100) + hwif->channel = port;Hm, what's so special about
ide_etrax100?
The driver supports *4* channels and it didn't set ->channel at all.
Since in the meantime ide-cris got marked as BROKEN I guess that a patch removing above code would be OK.
Quoted 4 lines
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1348
Quoted 1 line
drivers/ide/ide-probe.c +1
-0+int ide_device_add_all (u8 idx[MAX_HWIFS ],const struct ide_port_info *d)Function prototype doesn't match with one from <
linux/ide.h> which has the
first argument as a pointer...
I fixed it locally, thanks.
Quoted 9 lines
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1354
Quoted 6 lines
drivers/ide/ide-probe.c +3
-0+{ +ide_hwif_t *hwif, *mate =NULL ;int i, rc =0 ;for (i =0 ; i <MAX_HWIFS ; i++) { +if (d ==NULL || idx[i] ==0xff ) {Why check for (d == NULL) every time and not do it once and break from theloop or even do it before the loop?
To save on some code lines and resulting code size (ide_device_add_all is not performance critical).
Bart
Re: [PATCH 7/8] ide: add struct ide_port_info instances to legacy host drivers
Quoted 27 lines · Bartlomiej Zolnierkiewicz
Quoted 14 lines
Quoted 14 lines
Index:
b/drivers/ide/arm/icside.c
===================================================================drivers/ide/arm/icside.c +1
-1@@ -459,11 +456,19 @@ icside_register_v5(struct icside_state * idx[0 ] = hwif->index; -ide_device_add (idx); +ide_device_add (idx,NULL );return 0 ; }Quoted 12 lines
drivers/ide/arm/icside.c icside_register_v5(struct icside_state * · line 471
Quoted 8 lines
drivers/ide/arm/icside.c +8
-0+static const struct ide_port_info icside_v6_port_info__initdata = { + .host_flags =IDE_HFLAG_SERIALIZE | +IDE_HFLAG_NO_DMA |/* no SFF-style DMA */ +IDE_HFLAG_NO_AUTOTUNE , + .mwdma_mask =ATA_MWDMA2 , + .swdma_mask =ATA_SWDMA2 , +}; +Interesting... this driver's support for SWDMA0 is broken since the cycle
should be 960 ns long, not 480, and SWDMA2 is underclocked using the same cycle as SWDMA1, 480 ns...
Quoted 1 line
Added Russell to Cc:.
Underclocking the DMA is not a problem - if you look at the timing diagrams and associated tables in the ATA specifications, you'll find that they specify the *minimum* cycle timings.
However, you're correct that SWDMA0 is not able to be supported.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Re: [PATCH 7/8] ide: add struct ide_port_info instances to legacy host drivers
In reply to Bartlomiej Zolnierkiewiczdrivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1333
Quoted 3 lines · Bartlomiej Zolnierkiewicz
drivers/ide/ide-probe.c +3
-0+/* reset DMA masks only for SFF-style DMA controllers */ +if ((d->host_flags &&IDE_HFLAG_NO_DMA ) ==0 && hwif->dma_base ==0 ) + hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask =0 ;
It might be too late, but "host_flags && IDE_HFLAGS_NO_DMA" seems wrong for me.
---
Atsushi Nemoto
Re: [PATCH 7/8] ide: add struct ide_port_info instances to legacy host drivers
Quoted 7 lines · Atsushi Nemoto
drivers/ide/ide-probe.c static void hwif_register_devices(ide_hw · line 1333
Quoted 3 lines · Bartlomiej Zolnierkiewicz
drivers/ide/ide-probe.c +3
-0+/* reset DMA masks only for SFF-style DMA controllers */ +if ((d->host_flags &&IDE_HFLAG_NO_DMA ) ==0 && hwif->dma_base ==0 ) + hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask =0 ;It might be too late, but "
host_flags&&IDE_HFLAGS_NO_DMA" seems wrong for me.
It is too late for -git but not too late for 2.6.25-rc1. ;-)
Could you make a patch please?
Thanks,
Bart
Re: [PATCH 7/8] ide: add struct ide_port_info instances to legacy host drivers
Quoted 9 lines · Bartlomiej Zolnierkiewicz
Quoted 7 lines · Atsushi Nemoto
Review
Quoted 3 lines · Bartlomiej Zolnierkiewicz
(quoted diff) +3
-0+ /* reset DMA masks only for SFF-style DMA controllers */ + if ((d->host_flags && IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0) + hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0;It might be too late, but "
host_flags&&IDE_HFLAGS_NO_DMA" seems wrong for me.
Quoted 3 lines
It is too late for -git but not too late for 2.6.25-rc1. ;-)
Could you make a patch please?
I went ahead and made a patch (sorry, I needed it for git pull request :).
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: ide_init_port() bugfix
Quoted 7 lines · Atsushi Nemoto
Review
Quoted 3 lines · Bartlomiej Zolnierkiewicz
(quoted diff) +3
-0+ /* reset DMA masks only for SFF-style DMA controllers */ + if ((d->host_flags && IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0) + hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0;It might be too late, but "
host_flags&&IDE_HFLAGS_NO_DMA" seems wrong for me.
Fix regression caused by commmit c413b9b94d9a8e7548cc4b2e04b7df0439ce76fd ("ide: add struct ide_port_info instances to legacy host drivers").
--- drivers/ide/ide-probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ide/ide-probe.c +1 -1
@@ -1355,7 +1355,7 @@ static void ide_init_port(ide_hwif_t *hw hwif->ultra_mask = d->udma_mask;/* reset DMA masks only for SFF-style DMA controllers */ -if ((d->host_flags &&IDE_HFLAG_NO_DMA ) ==0 && hwif->dma_base ==0 ) +if ((d->host_flags &IDE_HFLAG_NO_DMA ) ==0 && hwif->dma_base ==0 ) hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask =0 ;if (d->host_flags &IDE_HFLAG_RQSIZE_256 )
Re: [PATCH 7/8] ide: add struct ide_port_info instances to legacy host drivers
Quoted 8 lines · Bartlomiej Zolnierkiewicz
Quoted 3 lines
It is too late for -git but not too late for 2.6.25-rc1. ;-)
Could you make a patch please?
I went ahead and made a patch (sorry, I needed it for git pull request :).
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide:ide_init_port()bugfix
Thanks! Looks sane for me :)
---
Atsushi Nemoto
PATCH 8/8 ide: add ->cable_detect method to ide_hwif_t
In reply to Bartlomiej Zolnierkiewicz* Add ->cable_detect method to ide_hwif_t.
* Call the new method in ide_init_port() if:
- the host supports UDMA modes > UDMA2 ('hwif->ultra_mask & 78')
- DMA initialization was successful (if hwif->dma_base is not set
ide_init_port() sets hwif->ultra_mask to zero)
- "idex=ata66" is not used ('hwif->cbl != ATA_CBL_PATA40_SHORT')
* Convert PCI host drivers to use ->cable_detect method.
While at it:
* Factor out cable detection to separate functions (if not already done).
* hpt366.c/it8213.c/slc90e66.c:
- don't check cable type if "idex=ata66" is used
* pdc202xx_new.c:
- add __devinit tag to pdcnew_cable_detect()
* pdc202xx_old.c:
- rename pdc202xx_old_cable_detect() to pdc2026x_old_cable_detect()
- add __devinit tag to pdc2026x_old_cable_detect()
---
-105 bytes
drivers/ide/ide-probe.c | 5 ++ drivers/ide/pci/aec62xx.c | 25 +++++------- drivers/ide/pci/alim15x3.c | 5 -- drivers/ide/pci/amd74xx.c | 18 ++++---- drivers/ide/pci/atiixp.c | 6 -- drivers/ide/pci/cmd64x.c | 5 -- drivers/ide/pci/cs5535.c | 6 -- drivers/ide/pci/hpt366.c | 84 ++++++++++++++++++++++------------------- drivers/ide/pci/it8213.c | 21 +++++----- drivers/ide/pci/it821x.c | 5 -- drivers/ide/pci/jmicron.c | 6 -- drivers/ide/pci/pdc202xx_new.c | 8 --- drivers/ide/pci/pdc202xx_old.c | 10 ++-- drivers/ide/pci/piix.c | 7 --- drivers/ide/pci/scc_pata.c | 3 - drivers/ide/pci/serverworks.c | 9 ---- drivers/ide/pci/siimage.c | 5 -- drivers/ide/pci/sis5513.c | 5 -- drivers/ide/pci/slc90e66.c | 19 +++++---- drivers/ide/pci/tc86c001.c | 24 +++++++---- drivers/ide/pci/via82cxxx.c | 6 -- include/linux/ide.h | 2 22 files changed, 137 insertions(+), 147 deletions(-)
drivers/ide/ide-probe.c +5 -0
@@ -1343,6 +1343,11 @@ static void ide_init_port(ide_hwif_t *hw/* call chipset specific routine for each enabled port */ if (d->init_hwif) d->init_hwif (hwif); + +if (hwif->cable_detect && (hwif->ultra_mask &0x78 )) { +if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) + hwif->cbl = hwif->cable_detect (hwif); + } }int ide_device_add_all (u8 idx[MAX_HWIFS ],const struct ide_port_info *d)
drivers/ide/pci/aec62xx.c +12 -13
@@ -166,6 +166,16 @@ static unsigned int __devinit init_chipsreturn dev->irq; } +static u8 __devinit atp86x_cable_detect (ide_hwif_t *hwif) +{ +struct pci_dev *dev =to_pci_dev (hwif->dev); +u8 ata66 =0 , mask = hwif->channel ?0x02 :0x01 ; + +pci_read_config_byte (dev,0x49 , &ata66); + +return (ata66 & mask) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; +} +static void __devinit init_hwif_aec62xx (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);
@@ -174,21 +184,10 @@ static void __devinit init_hwif_aec62xx(if (dev->device ==PCI_DEVICE_ID_ARTOP_ATP850UF ) hwif->set_dma_mode = &aec6210_set_mode; -else +else { hwif->set_dma_mode = &aec6260_set_mode; -if (hwif->dma_base ==0 ) -return ; - -if (dev->device ==PCI_DEVICE_ID_ARTOP_ATP850UF ) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) { -u8 ata66 =0 , mask = hwif->channel ?0x02 :0x01 ; - -pci_read_config_byte (dev,0x49 , &ata66); - - hwif->cbl = (ata66 & mask) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; + hwif->cable_detect = atp86x_cable_detect; } }
drivers/ide/pci/alim15x3.c +2 -3
@@ -666,13 +666,12 @@ static void __devinit init_hwif_common_a hwif->set_dma_mode = &ali_set_dma_mode; hwif->udma_filter = &ali_udma_filter; + hwif->cable_detect = ata66_ali15x3; +if (hwif->dma_base ==0 )return ; hwif->dma_setup = &ali15x3_dma_setup; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_ali15x3 (hwif); }/**
drivers/ide/pci/amd74xx.c +9 -9
@@ -199,6 +199,14 @@ static unsigned int __devinit init_chipsreturn dev->irq; } +static u8 __devinit amd_cable_detect (ide_hwif_t *hwif) +{ +if ((amd_80w >> hwif->channel) &1 ) +return ATA_CBL_PATA80 ; +else +return ATA_CBL_PATA40 ; +} +static void __devinit init_hwif_amd74xx (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);
@@ -209,15 +217,7 @@ static void __devinit init_hwif_amd74xx( hwif->set_pio_mode = &amd_set_pio_mode; hwif->set_dma_mode = &amd_set_drive; -if (!hwif->dma_base) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) { -if ((amd_80w >> hwif->channel) &1 ) - hwif->cbl =ATA_CBL_PATA80 ; -else - hwif->cbl =ATA_CBL_PATA40 ; - } + hwif->cable_detect = amd_cable_detect; }#define IDE_HFLAGS_AMD \
drivers/ide/pci/atiixp.c +1 -5
@@ -147,11 +147,7 @@ static void __devinit init_hwif_atiixp(i hwif->set_pio_mode = &atiixp_set_pio_mode; hwif->set_dma_mode = &atiixp_set_dma_mode; -if (!hwif->dma_base) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =atiixp_cable_detect (hwif); + hwif->cable_detect = atiixp_cable_detect; }static const struct ide_port_info atiixp_pci_info[]__devinitdata = {
drivers/ide/pci/cmd64x.c +2 -3
@@ -393,6 +393,8 @@ static void __devinit init_hwif_cmd64x(i hwif->set_pio_mode = &cmd64x_set_pio_mode; hwif->set_dma_mode = &cmd64x_set_dma_mode; + hwif->cable_detect = ata66_cmd64x; +if (!hwif->dma_base)return ;
@@ -411,9 +413,6 @@ static void __devinit init_hwif_cmd64x(iif (dev->device ==PCI_DEVICE_ID_CMD_646 && dev->revision <5 ) hwif->ultra_mask =0x00 ; -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_cmd64x (hwif); -switch (dev->device) {case PCI_DEVICE_ID_CMD_648 :case PCI_DEVICE_ID_CMD_649 :
drivers/ide/pci/cs5535.c +1 -5
@@ -179,11 +179,7 @@ static void __devinit init_hwif_cs5535(i hwif->set_pio_mode = &cs5535_set_pio_mode; hwif->set_dma_mode = &cs5535_set_dma_mode; -if (hwif->dma_base ==0 ) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =cs5535_cable_detect (hwif); + hwif->cable_detect = cs5535_cable_detect; }static const struct ide_port_info cs5535_chipset__devinitdata = {
drivers/ide/pci/hpt366.c +46 -38
107 lines not on this page · raw message
drivers/ide/pci/it8213.c +11 -10
@@ -143,6 +143,16 @@ static void it8213_set_dma_mode(ide_driv } } +static u8 __devinit it8213_cable_detect (ide_hwif_t *hwif) +{ +struct pci_dev *dev =to_pci_dev (hwif->dev); +u8 reg42h =0 ; + +pci_read_config_byte (dev,0x42 , ®42h); + +return (reg42h &0x02 ) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; +} +/** * init_hwif_it8213 - set up hwif structs * @hwif: interface to set up
@@ -152,19 +162,10 @@ static void it8213_set_dma_mode(ide_drivstatic void __devinit init_hwif_it8213 (ide_hwif_t *hwif) { -struct pci_dev *dev =to_pci_dev (hwif->dev); -u8 reg42h =0 ; - hwif->set_dma_mode = &it8213_set_dma_mode; hwif->set_pio_mode = &it8213_set_pio_mode; -if (!hwif->dma_base) -return ; - -pci_read_config_byte (dev,0x42 , ®42h); - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl = (reg42h &0x02 ) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; + hwif->cable_detect = it8213_cable_detect; }
drivers/ide/pci/it821x.c +2 -3
@@ -579,14 +579,13 @@ static void __devinit init_hwif_it821x(i }else hwif->host_flags |=IDE_HFLAG_NO_SET_MODE ; + hwif->cable_detect = ata66_it821x; +if (hwif->dma_base ==0 )return ; hwif->ultra_mask =ATA_UDMA6 ; hwif->mwdma_mask =ATA_MWDMA2 ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_it821x (hwif); }static void __devinit it8212_disable_raid (struct pci_dev *dev)
drivers/ide/pci/jmicron.c +1 -5
@@ -111,11 +111,7 @@ static void __devinit init_hwif_jmicron( hwif->set_pio_mode = &jmicron_set_pio_mode; hwif->set_dma_mode = &jmicron_set_dma_mode; -if (hwif->dma_base ==0 ) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_jmicron (hwif); + hwif->cable_detect = ata66_jmicron; }static const struct ide_port_info jmicron_chipset__devinitdata = {
drivers/ide/pci/pdc202xx_new.c +2 -6
@@ -197,7 +197,7 @@ static void pdcnew_set_pio_mode(ide_driv } } -static u8 pdcnew_cable_detect (ide_hwif_t *hwif) +static u8 __devinit pdcnew_cable_detect (ide_hwif_t *hwif) {if (get_indexed_reg (hwif,0x0b ) &0x04 )return ATA_CBL_PATA40 ;
@@ -456,11 +456,7 @@ static void __devinit init_hwif_pdc202ne hwif->quirkproc = &pdcnew_quirkproc; hwif->resetproc = &pdcnew_reset; -if (hwif->dma_base ==0 ) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =pdcnew_cable_detect (hwif); + hwif->cable_detect = pdcnew_cable_detect; }static struct pci_dev *__devinit pdc20270_get_dev2 (struct pci_dev *dev)
drivers/ide/pci/pdc202xx_old.c +5 -5
@@ -140,7 +140,7 @@ static void pdc202xx_set_pio_mode(ide_drpdc202xx_set_mode (drive,XFER_PIO_0 + pio); } -static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) +static u8 __devinit pdc2026x_old_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);u16 CIS =0 , mask = (hwif->channel) ? (1 <<11 ) : (1 <<10 );
@@ -311,9 +311,12 @@ static void __devinit init_hwif_pdc202xx hwif->quirkproc = &pdc202xx_quirkproc; -if (dev->device !=PCI_DEVICE_ID_PROMISE_20246 ) +if (dev->device !=PCI_DEVICE_ID_PROMISE_20246 ) { hwif->resetproc = &pdc202xx_reset; + hwif->cable_detect = pdc2026x_old_cable_detect; + } +if (hwif->dma_base ==0 )return ;
@@ -321,9 +324,6 @@ static void __devinit init_hwif_pdc202xx hwif->dma_timeout = &pdc202xx_dma_timeout;if (dev->device !=PCI_DEVICE_ID_PROMISE_20246 ) { -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =pdc202xx_old_cable_detect (hwif); - hwif->dma_start = &pdc202xx_old_ide_dma_start; hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; }
drivers/ide/pci/piix.c +2 -5
@@ -290,14 +290,11 @@ static void __devinit init_hwif_piix(ide hwif->set_pio_mode = &piix_set_pio_mode; hwif->set_dma_mode = &piix_set_dma_mode; + hwif->cable_detect = piix_cable_detect; +if (!hwif->dma_base)return ; -if (hwif->ultra_mask &0x78 ) { -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =piix_cable_detect (hwif); - } -if (no_piix_dma) hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask =0 ; }
drivers/ide/pci/scc_pata.c +1 -2
@@ -683,8 +683,7 @@ static void __devinit init_hwif_scc(ide_else hwif->ultra_mask =ATA_UDMA5 ;/* 100MHz */ -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =scc_cable_detect (hwif); + hwif->cable_detect = scc_cable_detect; }#define DECLARE_SCC_DEV (name_str) \
drivers/ide/pci/serverworks.c +2 -7
@@ -346,13 +346,8 @@ static void __devinit init_hwif_svwks (i hwif->set_dma_mode = &svwks_set_dma_mode; hwif->udma_filter = &svwks_udma_filter; -if (!hwif->dma_base) -return ; - -if (dev->device !=PCI_DEVICE_ID_SERVERWORKS_OSB4IDE ) { -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_svwks (hwif); - } +if (dev->device !=PCI_DEVICE_ID_SERVERWORKS_OSB4IDE ) + hwif->cable_detect = ata66_svwks; }#define IDE_HFLAGS_SVWKS \
drivers/ide/pci/siimage.c +2 -3
@@ -827,15 +827,14 @@ static void __devinit init_hwif_siimage( }else hwif->udma_filter = &sil_pata_udma_filter; + hwif->cable_detect = ata66_siimage; +if (hwif->dma_base ==0 )return ;if (sata) hwif->host_flags |=IDE_HFLAG_NO_ATAPI_DMA ; -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_siimage (hwif); -if (hwif->mmio) { hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq; }else {
drivers/ide/pci/sis5513.c +2 -3
@@ -565,13 +565,12 @@ static void __devinit init_hwif_sis5513if (chipset_family >=ATA_133 ) hwif->udma_filter = sis5513_ata133_udma_filter; + hwif->cable_detect = ata66_sis5513; +if (hwif->dma_base ==0 )return ; hwif->ultra_mask = udma_rates[chipset_family]; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_sis5513 (hwif); }static const struct ide_port_info sis5513_chipset__devinitdata = {
drivers/ide/pci/slc90e66.c +11 -8
@@ -118,23 +118,26 @@ static void slc90e66_set_dma_mode(ide_dr } } -static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) +static u8 __devinit slc90e66_cable_detect (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev); -u8 reg47 =0 ; -u8 mask = hwif->channel ?0x01 :0x02 ;/* bit0:Primary */ +u8 reg47 =0 , mask = hwif->channel ?0x01 :0x02 ; +pci_read_config_byte (dev,0x47 , ®47); + +/* bit[0(1)]: 0:80, 1:40 */ +return (reg47 & mask) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; +} + +static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) +{ hwif->set_pio_mode = &slc90e66_set_pio_mode; hwif->set_dma_mode = &slc90e66_set_dma_mode; -pci_read_config_byte (dev,0x47 , ®47); -if (hwif->dma_base ==0 )return ; -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) -/* bit[0(1)]: 0:80, 1:40 */ - hwif->cbl = (reg47 & mask) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; + hwif->cable_detect = slc90e66_cable_detect; }static const struct ide_port_info slc90e66_chipset__devinitdata = {
drivers/ide/pci/tc86c001.c +15 -9
@@ -160,6 +160,19 @@ static int tc86c001_busproc(ide_drive_treturn 0 ; } +static u8 __devinit tc86c001_cable_detect (ide_hwif_t *hwif) +{ +struct pci_dev *dev =to_pci_dev (hwif->dev); +unsigned long sc_base =pci_resource_start (dev,5 ); +u16 scr1 =inw (sc_base +0x00 ); + +/* +* System Control 1 Register bit 13 (PDIAGN): +* 0=80-pin cable, 1=40-pin cable +*/ +return (scr1 &0x2000 ) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; +} +static void __devinit init_hwif_tc86c001 (ide_hwif_t *hwif) {struct pci_dev *dev =to_pci_dev (hwif->dev);
@@ -183,6 +196,8 @@ static void __devinit init_hwif_tc86c001 hwif->busproc = &tc86c001_busproc; + hwif->cable_detect = tc86c001_cable_detect; +if (!hwif->dma_base)return ;
@@ -196,15 +211,6 @@ static void __devinit init_hwif_tc86c001 hwif->rqsize =0xffff ; hwif->dma_start = &tc86c001_dma_start; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) { -/* -* System Control 1 Register bit 13 (PDIAGN): -* 0=80-pin cable, 1=40-pin cable -*/ - scr1 =inw (sc_base +0x00 ); - hwif->cbl = (scr1 &0x2000 ) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; - } } static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev,
drivers/ide/pci/via82cxxx.c +1 -5
@@ -424,11 +424,7 @@ static void __devinit init_hwif_via82cxx hwif->set_pio_mode = &via_set_pio_mode; hwif->set_dma_mode = &via_set_drive; -if (!hwif->dma_base) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =via82cxxx_cable_detect (hwif); + hwif->cable_detect = via82cxxx_cable_detect; }static const struct ide_port_info via82cxxx_chipset__devinitdata = {
include/linux/ide.h +2 -0
@@ -535,6 +535,8 @@ typedef struct hwif_s {u8 (*mdma_filter)(ide_drive_t *);u8 (*udma_filter)(ide_drive_t *); +u8 (*cable_detect)(struct hwif_s *); +void (*ata_input_data)(ide_drive_t *,void *,u32 );void (*ata_output_data)(ide_drive_t *,void *,u32 );
Re: [PATCH 8/8] ide: add ->cable_detect method to ide_hwif_t
Hello.
Quoted 31 lines · Bartlomiej Zolnierkiewicz
* Add ->cable_detect method to
ide_hwif_t.* Call the new method in
ide_init_port()if:
- the host supports UDMA modes > UDMA2 ('hwif->ultra_mask& 78')
- DMA initialization was successful (ifhwif->dma_baseis not setide_init_port() sets hwif->ultra_mask to zero)- "idex=ata66" is not used ('
hwif->cbl!=ATA_CBL_PATA40_SHORT')* Convert PCI host drivers to use ->cable_detect method.
While at it:
* Factor out cable detection to separate functions (if not already done).
*
hpt366.c/it8213.c/slc90e66.c:
- don't check cable type if "idex=ata66" is used*
pdc202xx_new.c:
- add__devinittag topdcnew_cable_detect()*
pdc202xx_old.c:
- renamepdc202xx_old_cable_detect()topdc2026x_old_cable_detect()
- add__devinittag topdc2026x_old_cable_detect()Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Index:
b/drivers/ide/ide-probe.c
===================================================================
drivers/ide/ide-probe.c static void ide_init_port(ide_hwif_t *hw · line 1350
Quoted 8 lines
drivers/ide/ide-probe.c +5
-0@@ -1343,6 +1343,11 @@ static void ide_init_port(ide_hwif_t *hw/* call chipset specific routine for each enabled port */ if (d->init_hwif) d->init_hwif (hwif); + +if (hwif->cable_detect && (hwif->ultra_mask &0x78 )) { +if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) + hwif->cbl = hwif->cable_detect (hwif); + }
Could be collapsed to a single *if* statement...
drivers/ide/pci/alim15x3.c static void __devinit init_hwif_common_a · line 669
Quoted 9 lines
Index:
b/drivers/ide/pci/alim15x3.c
===================================================================drivers/ide/pci/alim15x3.c +1
-0@@ -666,13 +666,12 @@ static void __devinit init_hwif_common_a hwif->set_dma_mode = &ali_set_dma_mode; hwif->udma_filter = &ali_udma_filter; + hwif->cable_detect = ata66_ali15x3;
Why not give that function a "standard" name while at it?
drivers/ide/pci/cmd64x.c static void __devinit init_hwif_cmd64x(i · line 397
Quoted 11 lines
drivers/ide/pci/alim15x3.c +0
-0static const struct ide_port_info atiixp_pci_info[]__devinitdata = {Index:
b/drivers/ide/pci/cmd64x.c
===================================================================drivers/ide/pci/cmd64x.c +2
-0@@ -393,6 +393,8 @@ static void __devinit init_hwif_cmd64x(i hwif->set_pio_mode = &cmd64x_set_pio_mode; hwif->set_dma_mode = &cmd64x_set_dma_mode; + hwif->cable_detect = ata66_cmd64x; +
Same question...
Quoted 5 lines
Index:
b/drivers/ide/pci/hpt366.c
===================================================================
drivers/ide/pci/hpt366.c static unsigned int __devinit init_chips · line 1287
Quoted 9 lines
drivers/ide/pci/hpt366.c +6
-0@@ -1279,12 +1279,55 @@ static unsigned int __devinit init_chipsreturn dev->irq; } +static u8 __devinit hpt3xx_cable_detect (ide_hwif_t *hwif) +{ +struct pci_dev *dev =to_pci_dev (hwif->dev); +struct hpt_info *info =pci_get_drvdata (dev); +u8 chip_type = info->chip_type; +u8 scr1 =0 , ata66 = hwif->channel ?0x01 :0x02 ;
The 'ata66' is pretty bad name for this variable (reversed sense), let's
go with 'mask'...
Quoted 22 lines
drivers/ide/pci/hpt366.c +22
-0+ +/* +* The HPT37x uses the CBLID pins as outputs for MA15/MA16 +* address lines to access an external EEPROM. To read valid +* cable detect state the pins must be enabled as inputs. +*/ +if (chip_type ==HPT374 && (PCI_FUNC (dev->devfn) &1 )) { +/* +* HPT374 PCI function 1 +* - set bit 15 of reg 0x52 to enable TCBLID as input +* - set bit 15 of reg 0x56 to enable FCBLID as input +*/ +u8 mcr_addr = hwif->select_data +2 ; +u16 mcr; + +pci_read_config_word (dev, mcr_addr, &mcr); +pci_write_config_word (dev, mcr_addr, (mcr |0x8000 )); +/* now read cable id register */ +pci_read_config_byte (dev,0x5a , &scr1); +pci_write_config_word (dev, mcr_addr, mcr); + }else if (chip_type >=HPT370 ) { +/*
drivers/ide/pci/hpt366.c static unsigned int __devinit init_chips · line 1319
Quoted 10 lines
drivers/ide/pci/hpt366.c +10
-0+* HPT370/372 and 374 pcifn 0 +* - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs +*/ +u8 scr2 =0 ; + +pci_read_config_byte (dev,0x5b , &scr2); +pci_write_config_byte (dev,0x5b , (scr2 & ~1 )); +/* now read cable id register */ +pci_read_config_byte (dev,0x5a , &scr1); +pci_write_config_byte (dev,0x5b , scr2);
Sigh, my pretty formatting is gone... at least don't leave double spaces
and needless parens. :-)
Quoted 6 lines
drivers/ide/pci/hpt366.c +6
-0+ }else +pci_read_config_byte (dev,0x5a , &scr1); + +return (scr1 & ata66) ?ATA_CBL_PATA40 :ATA_CBL_PATA80 ; +} +
[...]
drivers/ide/pci/it821x.c static void __devinit init_hwif_it821x(i · line 583
Quoted 12 lines
drivers/ide/pci/it8213.c +0
-0Index:
b/drivers/ide/pci/it821x.c
===================================================================drivers/ide/pci/it821x.c +2
-0@@ -579,14 +579,13 @@ static void __devinit init_hwif_it821x(i }else hwif->host_flags |=IDE_HFLAG_NO_SET_MODE ; + hwif->cable_detect = ata66_it821x; +
I think the function is really worth renaming...
Quoted 6 lines
drivers/ide/pci/it821x.c +0
-0static void __devinit it8212_disable_raid (struct pci_dev *dev)Index:
b/drivers/ide/pci/jmicron.c
===================================================================
drivers/ide/pci/jmicron.c static void __devinit init_hwif_jmicron( · line 114
Quoted 9 lines
drivers/ide/pci/jmicron.c +1
-5@@ -111,11 +111,7 @@ static void __devinit init_hwif_jmicron( hwif->set_pio_mode = &jmicron_set_pio_mode; hwif->set_dma_mode = &jmicron_set_dma_mode; -if (hwif->dma_base ==0 ) -return ; - -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_jmicron (hwif); + hwif->cable_detect = ata66_jmicron;
And this one too...
drivers/ide/pci/pdc202xx_old.c static void pdc202xx_set_pio_mode(ide_dr · line 143
Quoted 10 lines
Index:
b/drivers/ide/pci/pdc202xx_old.c
===================================================================drivers/ide/pci/pdc202xx_old.c +1
-1@@ -140,7 +140,7 @@ static void pdc202xx_set_pio_mode(ide_drpdc202xx_set_mode (drive,XFER_PIO_0 + pio); } -static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) +static u8 __devinit pdc2026x_old_cable_detect (ide_hwif_t *hwif)
I suggest just pdc2026x_ without old_.
Quoted 8 lines
drivers/ide/pci/pdc202xx_old.c +0
-0#define DECLARE_SCC_DEV (name_str) \Index:
b/drivers/ide/pci/serverworks.c
===================================================================drivers/ide/pci/serverworks.c +0
-0@@ -346,13 +346,8 @@ static void __devinit init_hwif_svwks (i hwif->set_dma_mode = &svwks_set_dma_mode; hwif->udma_filter = &svwks_udma_filter;
drivers/ide/pci/serverworks.c static void __devinit init_hwif_svwks (i · line 350
Quoted 10 lines
drivers/ide/pci/serverworks.c +2
-7-if (!hwif->dma_base) -return ; - -if (dev->device !=PCI_DEVICE_ID_SERVERWORKS_OSB4IDE ) { -if (hwif->cbl !=ATA_CBL_PATA40_SHORT ) - hwif->cbl =ata66_svwks (hwif); - } +if (dev->device !=PCI_DEVICE_ID_SERVERWORKS_OSB4IDE ) + hwif->cable_detect = ata66_svwks;
Worth renaming...
drivers/ide/pci/siimage.c static void __devinit init_hwif_siimage( · line 831
Quoted 10 lines
Index:
b/drivers/ide/pci/siimage.c
===================================================================drivers/ide/pci/siimage.c +2
-0@@ -827,15 +827,14 @@ static void __devinit init_hwif_siimage( }else hwif->udma_filter = &sil_pata_udma_filter; + hwif->cable_detect = ata66_siimage; +
That one too...
drivers/ide/pci/sis5513.c static void __devinit init_hwif_sis5513 · line 569
Quoted 10 lines
Index:
b/drivers/ide/pci/sis5513.c
===================================================================drivers/ide/pci/sis5513.c +2
-0@@ -565,13 +565,12 @@ static void __devinit init_hwif_sis5513if (chipset_family >=ATA_133 ) hwif->udma_filter = sis5513_ata133_udma_filter; + hwif->cable_detect = ata66_sis5513; +
Another one...
MBR, Sergei