From patchwork Mon Jan 18 17:20:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 43125 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id EB061B7C63 for ; Tue, 19 Jan 2010 04:27:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755216Ab0ARR1X (ORCPT ); Mon, 18 Jan 2010 12:27:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755307Ab0ARRVM (ORCPT ); Mon, 18 Jan 2010 12:21:12 -0500 Received: from mail-ew0-f214.google.com ([209.85.219.214]:52797 "EHLO mail-ew0-f214.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755306Ab0ARRVJ (ORCPT ); Mon, 18 Jan 2010 12:21:09 -0500 Received: by mail-ew0-f214.google.com with SMTP id 6so3708367ewy.29 for ; Mon, 18 Jan 2010 09:21:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :in-reply-to:references:subject; bh=7jt4NcUExJk37YrWVz390eaAIeOJzBrx1PblHekJYZI=; b=cTbd9gumsuFQPPWb7PEIaqsgRPiNf5y3lQrnorJa9FwhS8UeeoDy6auXFEeJW6f1+L bI50XK+zAFyFD/gY3KqMb7l4F1XR9I2I7uyICgkxIpAEDI6wOlfPHbWY3shlikzUWcSA 8/yb7hw2cA3BV5fy52yX7inVw0UcS1feRv+0o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=wk6zEbJQlg91GPpmCQ/zBxLtd1jVdHOq5sgzEHizntor6peJe9lqi8w5iSvHdeCKjU 9WHdut9kTw0gC8pcfUYaQIRYNOlqUz/qgK7+yhVjXh1OPYwra27bEgURu1aV60e/1sgg qylipSGmKelv9xkGYnK8XuBM08XnEr7NnoAoM= Received: by 10.216.89.135 with SMTP id c7mr248167wef.62.1263835268827; Mon, 18 Jan 2010 09:21:08 -0800 (PST) Received: from ?127.0.0.1? (chello089079027028.chello.pl [89.79.27.28]) by mx.google.com with ESMTPS id i6sm6975625gve.16.2010.01.18.09.21.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 18 Jan 2010 09:21:08 -0800 (PST) From: Bartlomiej Zolnierkiewicz To: linux-ide@vger.kernel.org Cc: Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org Date: Mon, 18 Jan 2010 18:20:00 +0100 Message-Id: <20100118172000.14623.73749.sendpatchset@localhost> In-Reply-To: <20100118171349.14623.90030.sendpatchset@localhost> References: <20100118171349.14623.90030.sendpatchset@localhost> Subject: [PATCH 42/64] via82cxxx: workaround h/w bugs Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Bartlomiej Zolnierkiewicz Subject: [PATCH] via82cxxx: workaround h/w bugs Add custom struct ide_tp_ops instance to fix the internal bug of some VIA chipsets which will reset the device register after changing the nIEN bit in the device control register. Based on commit bfce5e0 for pata_via host driver. Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/via82cxxx.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/ide/via82cxxx.c =================================================================== --- a/drivers/ide/via82cxxx.c +++ b/drivers/ide/via82cxxx.c @@ -107,6 +107,7 @@ struct via82cxxx_dev { struct via_isa_bridge *via_config; unsigned int via_80w; + u8 cached_device[2]; }; /** @@ -382,10 +383,66 @@ static const struct ide_port_ops via_por .cable_detect = via82cxxx_cable_detect, }; +static void via_write_devctl(ide_hwif_t *hwif, u8 ctl) +{ + struct via82cxxx_dev *vdev = hwif->host->host_priv; + + outb(ctl, hwif->io_ports.ctl_addr); + outb(vdev->cached_device[hwif->channel], hwif->io_ports.device_addr); +} + +static void __via_dev_select(ide_drive_t *drive, u8 select) +{ + ide_hwif_t *hwif = drive->hwif; + struct via82cxxx_dev *vdev = hwif->host->host_priv; + + outb(select, hwif->io_ports.device_addr); + vdev->cached_device[hwif->channel] = select; +} + +static void via_dev_select(ide_drive_t *drive) +{ + __via_dev_select(drive, drive->select | ATA_DEVICE_OBS); +} + +static void via_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid) +{ + ide_hwif_t *hwif = drive->hwif; + struct ide_io_ports *io_ports = &hwif->io_ports; + + if (valid & IDE_VALID_FEATURE) + outb(tf->feature, io_ports->feature_addr); + if (valid & IDE_VALID_NSECT) + outb(tf->nsect, io_ports->nsect_addr); + if (valid & IDE_VALID_LBAL) + outb(tf->lbal, io_ports->lbal_addr); + if (valid & IDE_VALID_LBAM) + outb(tf->lbam, io_ports->lbam_addr); + if (valid & IDE_VALID_LBAH) + outb(tf->lbah, io_ports->lbah_addr); + if (valid & IDE_VALID_DEVICE) + __via_dev_select(drive, tf->device); +} + +const struct ide_tp_ops via_tp_ops = { + .exec_command = ide_exec_command, + .read_status = ide_read_status, + .read_altstatus = ide_read_altstatus, + .write_devctl = via_write_devctl, + + .dev_select = via_dev_select, + .tf_load = via_tf_load, + .tf_read = ide_tf_read, + + .input_data = ide_input_data, + .output_data = ide_output_data, +}; + static const struct ide_port_info via82cxxx_chipset __devinitdata = { .name = DRV_NAME, .init_chipset = init_chipset_via82cxxx, .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, + .tp_ops = &via_tp_ops, .port_ops = &via_port_ops, .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | IDE_HFLAG_POST_SET_MODE |