Skip to content

Commit

Permalink
ide: add struct ide_port_info instances to legacy host drivers
Browse files Browse the repository at this point in the history
* 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.

Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Feb 2, 2008
1 parent 1ebf749 commit c413b9b
Show file tree
Hide file tree
Showing 29 changed files with 258 additions and 270 deletions.
25 changes: 13 additions & 12 deletions drivers/ide/arm/icside.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@ static void icside_dma_lost_irq(ide_drive_t *drive)

static 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;
Expand Down Expand Up @@ -459,11 +456,19 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)

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)
{
Expand All @@ -472,6 +477,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
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) {
Expand Down Expand Up @@ -521,30 +527,25 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
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;

Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/arm/ide_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/arm/rapide.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)

idx[0] = hwif->index;

ide_device_add(idx);
ide_device_add(idx, NULL);

ecard_set_drvdata(ec, hwif);
goto out;
Expand Down
18 changes: 10 additions & 8 deletions drivers/ide/cris/ide-cris.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,15 @@ static void cris_set_dma_mode(ide_drive_t *drive, const u8 speed)
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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/h8300/ide-h8300.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-pnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id
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;
}
Expand Down
82 changes: 78 additions & 4 deletions drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,11 +1289,85 @@ static void hwif_register_devices(ide_hwif_t *hwif)
}
}

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;

if (d->chipset)
hwif->chipset = d->chipset;

if (d->init_iops)
d->init_iops(hwif);

if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0)
ide_hwif_setup_dma(hwif, d);

if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) ||
(d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
hwif->irq = port ? 15 : 14;

hwif->host_flags = d->host_flags;
hwif->pio_mask = d->pio_mask;

if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate)
hwif->mate->serialized = hwif->serialized = 1;

if (d->host_flags & IDE_HFLAG_IO_32BIT) {
hwif->drives[0].io_32bit = 1;
hwif->drives[1].io_32bit = 1;
}

if (d->host_flags & IDE_HFLAG_UNMASK_IRQS) {
hwif->drives[0].unmask = 1;
hwif->drives[1].unmask = 1;
}

hwif->swdma_mask = d->swdma_mask;
hwif->mwdma_mask = d->mwdma_mask;
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)
hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0;

if ((d->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0) {
hwif->drives[0].autotune = 1;
hwif->drives[1].autotune = 1;
}

if (d->host_flags & IDE_HFLAG_RQSIZE_256)
hwif->rqsize = 256;

/* call chipset specific routine for each enabled port */
if (d->init_hwif)
d->init_hwif(hwif);
}

int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
{
ide_hwif_t *hwif, *mate = NULL;
int i, rc = 0;

for (i = 0; i < MAX_HWIFS; i++) {
if (d == NULL || idx[i] == 0xff) {
mate = NULL;
continue;
}

hwif = &ide_hwifs[idx[i]];

if (d->chipset != ide_etrax100 && (i & 1) && mate) {
hwif->mate = mate;
mate->mate = hwif;
}

mate = (i & 1) ? NULL : hwif;

ide_init_port(hwif, i & 1, d);
}

for (i = 0; i < MAX_HWIFS; i++) {
if (idx[i] == 0xff)
continue;
Expand Down Expand Up @@ -1362,14 +1436,14 @@ int ide_device_add_all(u8 *idx)
}
EXPORT_SYMBOL_GPL(ide_device_add_all);

int ide_device_add(u8 idx[4])
int ide_device_add(u8 idx[4], const struct ide_port_info *d)
{
u8 idx_all[MAX_HWIFS];
int i;

for (i = 0; i < MAX_HWIFS; i++)
idx_all[i] = (i < 4) ? idx[i] : 0xff;

return ide_device_add_all(idx_all);
return ide_device_add_all(idx_all, d);
}
EXPORT_SYMBOL_GPL(ide_device_add);
2 changes: 1 addition & 1 deletion drivers/ide/ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),

idx[0] = index;

ide_device_add(idx);
ide_device_add(idx, NULL);

if (hwifp)
*hwifp = hwif;
Expand Down
24 changes: 9 additions & 15 deletions drivers/ide/legacy/ali14xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/legacy/buddha.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static int __init buddha_init(void)
}
}

ide_device_add(idx);
ide_device_add(idx, NULL);
}

return 0;
Expand Down
24 changes: 10 additions & 14 deletions drivers/ide/legacy/dtc2278.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio)
}
}

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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/legacy/falconide.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/legacy/gayle.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static int __init gayle_init(void)
release_mem_region(res_start, res_n);
}

ide_device_add(idx);
ide_device_add(idx, NULL);

return 0;
}
Expand Down
Loading

0 comments on commit c413b9b

Please sign in to comment.