示例#1
0
static int __init tx4938ide_probe(struct platform_device *pdev)
{
    struct ide_hw hw, *hws[] = { &hw };
    struct ide_host *host;
    struct resource *res;
    struct tx4938ide_platform_info *pdata = pdev->dev.platform_data;
    int irq, ret, i;
    unsigned long mapbase, mapctl;
    struct ide_port_info d = tx4938ide_port_info;

    irq = platform_get_irq(pdev, 0);
    if (irq < 0)
        return -ENODEV;
    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    if (!res)
        return -ENODEV;

    if (!devm_request_mem_region(&pdev->dev, res->start,
                                 resource_size(res), "tx4938ide"))
        return -EBUSY;
    mapbase = (unsigned long)devm_ioremap(&pdev->dev, res->start,
                                          8 << pdata->ioport_shift);
    mapctl = (unsigned long)devm_ioremap(&pdev->dev,
                                         res->start + 0x10000 +
                                         (6 << pdata->ioport_shift),
                                         1 << pdata->ioport_shift);
    if (!mapbase || !mapctl)
        return -EBUSY;

    memset(&hw, 0, sizeof(hw));
    if (pdata->ioport_shift) {
        unsigned long port = mapbase;
        unsigned long ctl = mapctl;

        hw.io_ports_array[0] = port;
#ifdef __BIG_ENDIAN
        port++;
        ctl++;
#endif
        for (i = 1; i <= 7; i++)
            hw.io_ports_array[i] =
                port + (i << pdata->ioport_shift);
        hw.io_ports.ctl_addr = ctl;
    } else
        ide_std_init_ports(&hw, mapbase, mapctl);
    hw.irq = irq;
    hw.dev = &pdev->dev;

    pr_info("TX4938 IDE interface (base %#lx, ctl %#lx, irq %d)\n",
            mapbase, mapctl, hw.irq);
    if (pdata->gbus_clock)
        tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, 0);
    else
        d.port_ops = NULL;
    ret = ide_host_add(&d, hws, 1, &host);
    if (!ret)
        platform_set_drvdata(pdev, host);
    return ret;
}
示例#2
0
static void tx4938ide_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
{
    struct tx4938ide_platform_info *pdata = hwif->dev->platform_data;
    u8 safe = drive->pio_mode - XFER_PIO_0;
    ide_drive_t *pair;

    pair = ide_get_pair_dev(drive);
    if (pair)
        safe = min(safe, pair->pio_mode - XFER_PIO_0);
    tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, safe);
}
示例#3
0
static void tx4938ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
{
	ide_hwif_t *hwif = drive->hwif;
	struct tx4938ide_platform_info *pdata = hwif->dev->platform_data;
	u8 safe = pio;
	ide_drive_t *pair;

	pair = ide_get_pair_dev(drive);
	if (pair)
		safe = min(safe, ide_get_best_pio_mode(pair, 255, 5));
	tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, safe);
}