2006-08-29 18:12:40 -04:00
|
|
|
/*
|
|
|
|
* pata_amd.c - AMD PATA for new ATA layer
|
|
|
|
* (C) 2005-2006 Red Hat Inc
|
|
|
|
* Alan Cox <alan@redhat.com>
|
|
|
|
*
|
|
|
|
* Based on pata-sil680. Errata information is taken from data sheets
|
|
|
|
* and the amd74xx.c driver by Vojtech Pavlik. Nvidia SATA devices are
|
|
|
|
* claimed by sata-nv.c.
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* Variable system clock when/if it makes sense
|
|
|
|
* Power management on ports
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Documentation publically available.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <linux/libata.h>
|
|
|
|
|
|
|
|
#define DRV_NAME "pata_amd"
|
2007-12-01 21:47:01 -05:00
|
|
|
#define DRV_VERSION "0.3.10"
|
2006-08-29 18:12:40 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* timing_setup - shared timing computation and load
|
|
|
|
* @ap: ATA port being set up
|
|
|
|
* @adev: drive being configured
|
|
|
|
* @offset: port offset
|
|
|
|
* @speed: target speed
|
|
|
|
* @clock: clock multiplier (number of times 33MHz for this part)
|
|
|
|
*
|
|
|
|
* Perform the actual timing set up for Nvidia or AMD PATA devices.
|
|
|
|
* The actual devices vary so they all call into this helper function
|
|
|
|
* providing the clock multipler and offset (because AMD and Nvidia put
|
|
|
|
* the ports at different locations).
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offset, int speed, int clock)
|
|
|
|
{
|
|
|
|
static const unsigned char amd_cyc2udma[] = {
|
|
|
|
6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
|
|
|
struct ata_device *peer = ata_dev_pair(adev);
|
|
|
|
int dn = ap->port_no * 2 + adev->devno;
|
|
|
|
struct ata_timing at, apeer;
|
|
|
|
int T, UT;
|
|
|
|
const int amd_clock = 33333; /* KHz. */
|
|
|
|
u8 t;
|
|
|
|
|
|
|
|
T = 1000000000 / amd_clock;
|
2008-03-28 17:33:56 -04:00
|
|
|
UT = T;
|
|
|
|
if (clock >= 2)
|
|
|
|
UT = T / 2;
|
2006-08-29 18:12:40 -04:00
|
|
|
|
|
|
|
if (ata_timing_compute(adev, speed, &at, T, UT) < 0) {
|
|
|
|
dev_printk(KERN_ERR, &pdev->dev, "unknown mode %d.\n", speed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (peer) {
|
|
|
|
/* This may be over conservative */
|
|
|
|
if (peer->dma_mode) {
|
|
|
|
ata_timing_compute(peer, peer->dma_mode, &apeer, T, UT);
|
|
|
|
ata_timing_merge(&apeer, &at, &at, ATA_TIMING_8BIT);
|
|
|
|
}
|
|
|
|
ata_timing_compute(peer, peer->pio_mode, &apeer, T, UT);
|
|
|
|
ata_timing_merge(&apeer, &at, &at, ATA_TIMING_8BIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (speed == XFER_UDMA_5 && amd_clock <= 33333) at.udma = 1;
|
|
|
|
if (speed == XFER_UDMA_6 && amd_clock <= 33333) at.udma = 15;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now do the setup work
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Configure the address set up timing */
|
|
|
|
pci_read_config_byte(pdev, offset + 0x0C, &t);
|
2008-05-14 19:17:00 -04:00
|
|
|
t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(at.setup, 1, 4) - 1) << ((3 - dn) << 1));
|
2006-08-29 18:12:40 -04:00
|
|
|
pci_write_config_byte(pdev, offset + 0x0C , t);
|
|
|
|
|
|
|
|
/* Configure the 8bit I/O timing */
|
|
|
|
pci_write_config_byte(pdev, offset + 0x0E + (1 - (dn >> 1)),
|
2008-05-14 19:17:00 -04:00
|
|
|
((clamp_val(at.act8b, 1, 16) - 1) << 4) | (clamp_val(at.rec8b, 1, 16) - 1));
|
2006-08-29 18:12:40 -04:00
|
|
|
|
|
|
|
/* Drive timing */
|
|
|
|
pci_write_config_byte(pdev, offset + 0x08 + (3 - dn),
|
2008-05-14 19:17:00 -04:00
|
|
|
((clamp_val(at.active, 1, 16) - 1) << 4) | (clamp_val(at.recover, 1, 16) - 1));
|
2006-08-29 18:12:40 -04:00
|
|
|
|
|
|
|
switch (clock) {
|
|
|
|
case 1:
|
2008-05-14 19:17:00 -04:00
|
|
|
t = at.udma ? (0xc0 | (clamp_val(at.udma, 2, 5) - 2)) : 0x03;
|
2006-08-29 18:12:40 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2008-05-14 19:17:00 -04:00
|
|
|
t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val(at.udma, 2, 10)]) : 0x03;
|
2006-08-29 18:12:40 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2008-05-14 19:17:00 -04:00
|
|
|
t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val(at.udma, 1, 10)]) : 0x03;
|
2006-08-29 18:12:40 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2008-05-14 19:17:00 -04:00
|
|
|
t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val(at.udma, 1, 15)]) : 0x03;
|
2006-08-29 18:12:40 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UDMA timing */
|
2007-12-01 21:47:01 -05:00
|
|
|
if (at.udma)
|
|
|
|
pci_write_config_byte(pdev, offset + 0x10 + (3 - dn), t);
|
2006-08-29 18:12:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-08-06 05:36:23 -04:00
|
|
|
* amd_pre_reset - perform reset handling
|
|
|
|
* @link: ATA link
|
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it.
ata_wait_ready() which directly takes @deadline is implemented to be
used as the wait function. This patch is in preparation for EH timing
improvements.
* ata_wait_ready() never does busy sleep. It's only used from EH and
no wait in EH is that urgent. This function also prints 'be
patient' message automatically after 5 secs of waiting if more than
3 secs is remaining till deadline.
* ata_bus_post_reset() now fails with error code if any of its wait
fails. This is important because earlier reset tries will have
shorter timeout than the spec requires. If a device fails to
respond before the short timeout, reset should be retried with
longer timeout rather than silently ignoring the device.
There are three behavior differences.
1. Timeout is applied to both devices at once, not separately. This
is more consistent with what the spec says.
2. When a device passes devchk but fails to become ready before
deadline. Previouly, post_reset would just succeed and let
device classification remove the device. New code fails the
reset thus causing reset retry. After a few times, EH will give
up disabling the port.
3. When slave device passes devchk but fails to become accessible
(TF-wise) after reset. Original code disables dev1 after 30s
timeout and continues as if the device doesn't exist, while the
patched code fails reset. When this happens, new code fails
reset on whole port rather than proceeding with only the primary
device.
If the failing device is suffering transient problems, new code
retries reset which is a better behavior. If the failing device is
actually broken, the net effect is identical to it, but not to the
other device sharing the channel. In the previous code, reset would
have succeeded after 30s thus detecting the working one. In the new
code, reset fails and whole port gets disabled. IMO, it's a
pathological case anyway (broken device sharing bus with working
one) and doesn't really matter.
* ata_bus_softreset() is changed to return error code from
ata_bus_post_reset(). It used to return 0 unconditionally.
* Spin up waiting is to be removed and not converted to honor
deadline.
* To be on the safe side, deadline is set to 40s for the time being.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-02 02:50:52 -05:00
|
|
|
* @deadline: deadline jiffies for the operation
|
2006-08-29 18:12:40 -04:00
|
|
|
*
|
2007-04-10 19:04:20 -04:00
|
|
|
* Reset sequence checking enable bits to see which ports are
|
|
|
|
* active.
|
2006-08-29 18:12:40 -04:00
|
|
|
*/
|
|
|
|
|
2007-08-06 05:36:23 -04:00
|
|
|
static int amd_pre_reset(struct ata_link *link, unsigned long deadline)
|
2006-08-29 18:12:40 -04:00
|
|
|
{
|
|
|
|
static const struct pci_bits amd_enable_bits[] = {
|
|
|
|
{ 0x40, 1, 0x02, 0x02 },
|
|
|
|
{ 0x40, 1, 0x01, 0x01 }
|
|
|
|
};
|
|
|
|
|
2007-08-06 05:36:23 -04:00
|
|
|
struct ata_port *ap = link->ap;
|
2006-08-29 18:12:40 -04:00
|
|
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
2006-08-31 00:03:49 -04:00
|
|
|
|
2006-09-26 12:53:38 -04:00
|
|
|
if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
|
|
|
|
return -ENOENT;
|
2006-08-29 18:12:40 -04:00
|
|
|
|
2008-04-07 09:47:16 -04:00
|
|
|
return ata_sff_prereset(link, deadline);
|
2006-08-29 18:12:40 -04:00
|
|
|
}
|
|
|
|
|
2007-04-10 19:04:20 -04:00
|
|
|
static int amd_cable_detect(struct ata_port *ap)
|
2006-08-29 18:12:40 -04:00
|
|
|
{
|
2007-04-10 19:04:20 -04:00
|
|
|
static const u32 bitmask[2] = {0x03, 0x0C};
|
2006-08-29 18:12:40 -04:00
|
|
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
2007-04-10 19:04:20 -04:00
|
|
|
u8 ata66;
|
2006-08-29 18:12:40 -04:00
|
|
|
|
2007-04-10 19:04:20 -04:00
|
|
|
pci_read_config_byte(pdev, 0x42, &ata66);
|
|
|
|
if (ata66 & bitmask[ap->port_no])
|
|
|
|
return ATA_CBL_PATA80;
|
|
|
|
return ATA_CBL_PATA40;
|
2006-08-29 18:12:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* amd33_set_piomode - set initial PIO mode data
|
|
|
|
* @ap: ATA interface
|
|
|
|
* @adev: ATA device
|
|
|
|
*
|
|
|
|
* Program the AMD registers for PIO mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void amd33_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->pio_mode, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void amd66_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->pio_mode, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void amd100_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->pio_mode, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void amd133_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->pio_mode, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* amd33_set_dmamode - set initial DMA mode data
|
|
|
|
* @ap: ATA interface
|
|
|
|
* @adev: ATA device
|
|
|
|
*
|
|
|
|
* Program the MWDMA/UDMA modes for the AMD and Nvidia
|
|
|
|
* chipset.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void amd33_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->dma_mode, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void amd66_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->dma_mode, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void amd100_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->dma_mode, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x40, adev->dma_mode, 4);
|
|
|
|
}
|
|
|
|
|
2007-12-18 02:33:07 -05:00
|
|
|
/* Both host-side and drive-side detection results are worthless on NV
|
|
|
|
* PATAs. Ignore them and just follow what BIOS configured. Both the
|
|
|
|
* current configuration in PCI config reg and ACPI GTM result are
|
|
|
|
* cached during driver attach and are consulted to select transfer
|
|
|
|
* mode.
|
|
|
|
*/
|
|
|
|
static unsigned long nv_mode_filter(struct ata_device *dev,
|
|
|
|
unsigned long xfer_mask)
|
|
|
|
{
|
|
|
|
static const unsigned int udma_mask_map[] =
|
|
|
|
{ ATA_UDMA2, ATA_UDMA1, ATA_UDMA0, 0,
|
|
|
|
ATA_UDMA3, ATA_UDMA4, ATA_UDMA5, ATA_UDMA6 };
|
|
|
|
struct ata_port *ap = dev->link->ap;
|
|
|
|
char acpi_str[32] = "";
|
|
|
|
u32 saved_udma, udma;
|
|
|
|
const struct ata_acpi_gtm *gtm;
|
|
|
|
unsigned long bios_limit = 0, acpi_limit = 0, limit;
|
|
|
|
|
|
|
|
/* find out what BIOS configured */
|
|
|
|
udma = saved_udma = (unsigned long)ap->host->private_data;
|
|
|
|
|
|
|
|
if (ap->port_no == 0)
|
|
|
|
udma >>= 16;
|
|
|
|
if (dev->devno == 0)
|
|
|
|
udma >>= 8;
|
|
|
|
|
|
|
|
if ((udma & 0xc0) == 0xc0)
|
|
|
|
bios_limit = ata_pack_xfermask(0, 0, udma_mask_map[udma & 0x7]);
|
|
|
|
|
|
|
|
/* consult ACPI GTM too */
|
|
|
|
gtm = ata_acpi_init_gtm(ap);
|
|
|
|
if (gtm) {
|
|
|
|
acpi_limit = ata_acpi_gtm_xfermask(dev, gtm);
|
|
|
|
|
|
|
|
snprintf(acpi_str, sizeof(acpi_str), " (%u:%u:0x%x)",
|
|
|
|
gtm->drive[0].dma, gtm->drive[1].dma, gtm->flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* be optimistic, EH can take care of things if something goes wrong */
|
|
|
|
limit = bios_limit | acpi_limit;
|
|
|
|
|
|
|
|
/* If PIO or DMA isn't configured at all, don't limit. Let EH
|
|
|
|
* handle it.
|
|
|
|
*/
|
|
|
|
if (!(limit & ATA_MASK_PIO))
|
|
|
|
limit |= ATA_MASK_PIO;
|
|
|
|
if (!(limit & (ATA_MASK_MWDMA | ATA_MASK_UDMA)))
|
|
|
|
limit |= ATA_MASK_MWDMA | ATA_MASK_UDMA;
|
|
|
|
|
|
|
|
ata_port_printk(ap, KERN_DEBUG, "nv_mode_filter: 0x%lx&0x%lx->0x%lx, "
|
|
|
|
"BIOS=0x%lx (0x%x) ACPI=0x%lx%s\n",
|
|
|
|
xfer_mask, limit, xfer_mask & limit, bios_limit,
|
|
|
|
saved_udma, acpi_limit, acpi_str);
|
|
|
|
|
|
|
|
return xfer_mask & limit;
|
|
|
|
}
|
2006-08-29 18:12:40 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* nv_probe_init - cable detection
|
2007-08-06 05:36:23 -04:00
|
|
|
* @lin: ATA link
|
2006-08-29 18:12:40 -04:00
|
|
|
*
|
|
|
|
* Perform cable detection. The BIOS stores this in PCI config
|
|
|
|
* space for us.
|
|
|
|
*/
|
|
|
|
|
2007-08-06 05:36:23 -04:00
|
|
|
static int nv_pre_reset(struct ata_link *link, unsigned long deadline)
|
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it.
ata_wait_ready() which directly takes @deadline is implemented to be
used as the wait function. This patch is in preparation for EH timing
improvements.
* ata_wait_ready() never does busy sleep. It's only used from EH and
no wait in EH is that urgent. This function also prints 'be
patient' message automatically after 5 secs of waiting if more than
3 secs is remaining till deadline.
* ata_bus_post_reset() now fails with error code if any of its wait
fails. This is important because earlier reset tries will have
shorter timeout than the spec requires. If a device fails to
respond before the short timeout, reset should be retried with
longer timeout rather than silently ignoring the device.
There are three behavior differences.
1. Timeout is applied to both devices at once, not separately. This
is more consistent with what the spec says.
2. When a device passes devchk but fails to become ready before
deadline. Previouly, post_reset would just succeed and let
device classification remove the device. New code fails the
reset thus causing reset retry. After a few times, EH will give
up disabling the port.
3. When slave device passes devchk but fails to become accessible
(TF-wise) after reset. Original code disables dev1 after 30s
timeout and continues as if the device doesn't exist, while the
patched code fails reset. When this happens, new code fails
reset on whole port rather than proceeding with only the primary
device.
If the failing device is suffering transient problems, new code
retries reset which is a better behavior. If the failing device is
actually broken, the net effect is identical to it, but not to the
other device sharing the channel. In the previous code, reset would
have succeeded after 30s thus detecting the working one. In the new
code, reset fails and whole port gets disabled. IMO, it's a
pathological case anyway (broken device sharing bus with working
one) and doesn't really matter.
* ata_bus_softreset() is changed to return error code from
ata_bus_post_reset(). It used to return 0 unconditionally.
* Spin up waiting is to be removed and not converted to honor
deadline.
* To be on the safe side, deadline is set to 40s for the time being.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
2007-02-02 02:50:52 -05:00
|
|
|
{
|
2006-09-12 12:14:03 -04:00
|
|
|
static const struct pci_bits nv_enable_bits[] = {
|
|
|
|
{ 0x50, 1, 0x02, 0x02 },
|
|
|
|
{ 0x50, 1, 0x01, 0x01 }
|
|
|
|
};
|
2006-08-29 18:12:40 -04:00
|
|
|
|
2007-08-06 05:36:23 -04:00
|
|
|
struct ata_port *ap = link->ap;
|
2006-08-29 18:12:40 -04:00
|
|
|
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
|
|
|
|
|
2006-09-26 12:53:38 -04:00
|
|
|
if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no]))
|
|
|
|
return -ENOENT;
|
2006-09-12 12:14:03 -04:00
|
|
|
|
2008-04-07 09:47:16 -04:00
|
|
|
return ata_sff_prereset(link, deadline);
|
2006-08-29 18:12:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nv100_set_piomode - set initial PIO mode data
|
|
|
|
* @ap: ATA interface
|
|
|
|
* @adev: ATA device
|
|
|
|
*
|
|
|
|
* Program the AMD registers for PIO mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void nv100_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x50, adev->pio_mode, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv133_set_piomode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x50, adev->pio_mode, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nv100_set_dmamode - set initial DMA mode data
|
|
|
|
* @ap: ATA interface
|
|
|
|
* @adev: ATA device
|
|
|
|
*
|
|
|
|
* Program the MWDMA/UDMA modes for the AMD and Nvidia
|
|
|
|
* chipset.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void nv100_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x50, adev->dma_mode, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv133_set_dmamode(struct ata_port *ap, struct ata_device *adev)
|
|
|
|
{
|
|
|
|
timing_setup(ap, adev, 0x50, adev->dma_mode, 4);
|
|
|
|
}
|
|
|
|
|
2007-12-18 02:33:07 -05:00
|
|
|
static void nv_host_stop(struct ata_host *host)
|
|
|
|
{
|
|
|
|
u32 udma = (unsigned long)host->private_data;
|
|
|
|
|
|
|
|
/* restore PCI config register 0x60 */
|
|
|
|
pci_write_config_dword(to_pci_dev(host->dev), 0x60, udma);
|
|
|
|
}
|
|
|
|
|
2006-08-29 18:12:40 -04:00
|
|
|
static struct scsi_host_template amd_sht = {
|
2008-03-24 23:22:49 -04:00
|
|
|
ATA_BMDMA_SHT(DRV_NAME),
|
2006-08-29 18:12:40 -04:00
|
|
|
};
|
|
|
|
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
static const struct ata_port_operations amd_base_port_ops = {
|
|
|
|
.inherits = &ata_bmdma_port_ops,
|
2008-03-24 23:22:49 -04:00
|
|
|
.prereset = amd_pre_reset,
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
};
|
|
|
|
|
2006-08-29 18:12:40 -04:00
|
|
|
static struct ata_port_operations amd33_port_ops = {
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
.inherits = &amd_base_port_ops,
|
|
|
|
.cable_detect = ata_cable_40wire,
|
2006-08-29 18:12:40 -04:00
|
|
|
.set_piomode = amd33_set_piomode,
|
|
|
|
.set_dmamode = amd33_set_dmamode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations amd66_port_ops = {
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
.inherits = &amd_base_port_ops,
|
|
|
|
.cable_detect = ata_cable_unknown,
|
2006-08-29 18:12:40 -04:00
|
|
|
.set_piomode = amd66_set_piomode,
|
|
|
|
.set_dmamode = amd66_set_dmamode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations amd100_port_ops = {
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
.inherits = &amd_base_port_ops,
|
|
|
|
.cable_detect = ata_cable_unknown,
|
2006-08-29 18:12:40 -04:00
|
|
|
.set_piomode = amd100_set_piomode,
|
|
|
|
.set_dmamode = amd100_set_dmamode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations amd133_port_ops = {
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
.inherits = &amd_base_port_ops,
|
|
|
|
.cable_detect = amd_cable_detect,
|
2006-08-29 18:12:40 -04:00
|
|
|
.set_piomode = amd133_set_piomode,
|
|
|
|
.set_dmamode = amd133_set_dmamode,
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
};
|
2006-08-29 18:12:40 -04:00
|
|
|
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
static const struct ata_port_operations nv_base_port_ops = {
|
|
|
|
.inherits = &ata_bmdma_port_ops,
|
|
|
|
.cable_detect = ata_cable_ignore,
|
|
|
|
.mode_filter = nv_mode_filter,
|
2008-03-24 23:22:49 -04:00
|
|
|
.prereset = nv_pre_reset,
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
.host_stop = nv_host_stop,
|
2006-08-29 18:12:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations nv100_port_ops = {
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
.inherits = &nv_base_port_ops,
|
2006-08-29 18:12:40 -04:00
|
|
|
.set_piomode = nv100_set_piomode,
|
|
|
|
.set_dmamode = nv100_set_dmamode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ata_port_operations nv133_port_ops = {
|
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and
register it with libata core layer. This allows low level drivers
high level of flexibility but also burdens them with lots of
boilerplate entries.
This becomes worse for drivers which support related similar
controllers which differ slightly. They share most of the operations
except for a few. However, the driver still needs to list all
operations for each variant. This results in large number of
duplicate entries, which is not only inefficient but also error-prone
as it becomes very difficult to tell what the actual differences are.
This duplicate boilerplates all over the low level drivers also make
updating the core layer exteremely difficult and error-prone. When
compounded with multi-branched development model, it ends up
accumulating inconsistencies over time. Some of those inconsistencies
cause immediate problems and fixed. Others just remain there dormant
making maintenance increasingly difficult.
To rectify the problem, this patch implements ata_port_operations
inheritance. To allow LLDs to easily re-use their own ops tables
overriding only specific methods, this patch implements poor man's
class inheritance. An ops table has ->inherits field which can be set
to any ops table as long as it doesn't create a loop. When the host
is started, the inheritance chain is followed and any operation which
isn't specified is taken from the nearest ancestor which has it
specified. This operation is called finalization and done only once
per an ops table and the LLD doesn't have to do anything special about
it other than making the ops table non-const such that libata can
update it.
libata provides four base ops tables lower drivers can inherit from -
base, sata, pmp, sff and bmdma. To avoid overriding these ops
accidentaly, these ops are declared const and LLDs should always
inherit these instead of using them directly.
After finalization, all the ops table are identical before and after
the patch except for setting .irq_handler to ata_interrupt in drivers
which didn't use to. The .irq_handler doesn't have any actual effect
and the field will soon be removed by later patch.
* sata_sx4 is still using old style EH and currently doesn't take
advantage of ops inheritance.
Signed-off-by: Tejun Heo <htejun@gmail.com>
2008-03-24 23:22:49 -04:00
|
|
|
.inherits = &nv_base_port_ops,
|
2006-08-29 18:12:40 -04:00
|
|
|
.set_piomode = nv133_set_piomode,
|
|
|
|
.set_dmamode = nv133_set_dmamode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
|
|
|
|
{
|
2007-05-04 06:43:58 -04:00
|
|
|
static const struct ata_port_info info[10] = {
|
2006-08-29 18:12:40 -04:00
|
|
|
{ /* 0: AMD 7401 */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07, /* No SWDMA */
|
|
|
|
.udma_mask = 0x07, /* UDMA 33 */
|
|
|
|
.port_ops = &amd33_port_ops
|
|
|
|
},
|
|
|
|
{ /* 1: Early AMD7409 - no swdma */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA4, /* UDMA 66 */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &amd66_port_ops
|
|
|
|
},
|
|
|
|
{ /* 2: AMD 7409, no swdma errata */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA4, /* UDMA 66 */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &amd66_port_ops
|
|
|
|
},
|
|
|
|
{ /* 3: AMD 7411 */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA5, /* UDMA 100 */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &amd100_port_ops
|
|
|
|
},
|
|
|
|
{ /* 4: AMD 7441 */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA5, /* UDMA 100 */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &amd100_port_ops
|
|
|
|
},
|
|
|
|
{ /* 5: AMD 8111*/
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA6, /* UDMA 133, no swdma */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &amd133_port_ops
|
|
|
|
},
|
|
|
|
{ /* 6: AMD 8111 UDMA 100 (Serenade) */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA5, /* UDMA 100, no swdma */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &amd133_port_ops
|
|
|
|
},
|
|
|
|
{ /* 7: Nvidia Nforce */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA5, /* UDMA 100 */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &nv100_port_ops
|
|
|
|
},
|
|
|
|
{ /* 8: Nvidia Nforce2 and later */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA6, /* UDMA 133, no swdma */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &nv133_port_ops
|
|
|
|
},
|
|
|
|
{ /* 9: AMD CS5536 (Geode companion) */
|
2007-05-28 06:59:48 -04:00
|
|
|
.flags = ATA_FLAG_SLAVE_POSS,
|
2006-08-29 18:12:40 -04:00
|
|
|
.pio_mask = 0x1f,
|
|
|
|
.mwdma_mask = 0x07,
|
2007-07-09 12:16:50 -04:00
|
|
|
.udma_mask = ATA_UDMA5, /* UDMA 100 */
|
2006-08-29 18:12:40 -04:00
|
|
|
.port_ops = &amd100_port_ops
|
|
|
|
}
|
|
|
|
};
|
2008-03-24 23:22:49 -04:00
|
|
|
const struct ata_port_info *ppi[] = { NULL, NULL };
|
2006-08-29 18:12:40 -04:00
|
|
|
static int printed_version;
|
|
|
|
int type = id->driver_data;
|
2008-03-24 23:22:49 -04:00
|
|
|
void *hpriv = NULL;
|
2006-08-29 18:12:40 -04:00
|
|
|
u8 fifo;
|
2008-03-24 23:22:47 -04:00
|
|
|
int rc;
|
2006-08-29 18:12:40 -04:00
|
|
|
|
|
|
|
if (!printed_version++)
|
|
|
|
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
|
|
|
|
|
2008-03-24 23:22:47 -04:00
|
|
|
rc = pcim_enable_device(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2006-08-29 18:12:40 -04:00
|
|
|
pci_read_config_byte(pdev, 0x41, &fifo);
|
|
|
|
|
|
|
|
/* Check for AMD7409 without swdma errata and if found adjust type */
|
2007-06-08 18:46:36 -04:00
|
|
|
if (type == 1 && pdev->revision > 0x7)
|
2006-08-29 18:12:40 -04:00
|
|
|
type = 2;
|
|
|
|
|
2007-12-18 02:33:07 -05:00
|
|
|
/* Serenade ? */
|
|
|
|
if (type == 5 && pdev->subsystem_vendor == PCI_VENDOR_ID_AMD &&
|
|
|
|
pdev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE)
|
|
|
|
type = 6; /* UDMA 100 only */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Okay, type is determined now. Apply type-specific workarounds.
|
|
|
|
*/
|
2008-03-24 23:22:49 -04:00
|
|
|
ppi[0] = &info[type];
|
2007-12-18 02:33:07 -05:00
|
|
|
|
|
|
|
if (type < 3)
|
2008-04-07 09:47:16 -04:00
|
|
|
ata_pci_bmdma_clear_simplex(pdev);
|
2007-12-18 02:33:07 -05:00
|
|
|
|
2006-08-29 18:12:40 -04:00
|
|
|
/* Check for AMD7411 */
|
|
|
|
if (type == 3)
|
|
|
|
/* FIFO is broken */
|
|
|
|
pci_write_config_byte(pdev, 0x41, fifo & 0x0F);
|
|
|
|
else
|
|
|
|
pci_write_config_byte(pdev, 0x41, fifo | 0xF0);
|
|
|
|
|
2007-12-18 02:33:07 -05:00
|
|
|
/* Cable detection on Nvidia chips doesn't work too well,
|
|
|
|
* cache BIOS programmed UDMA mode.
|
|
|
|
*/
|
|
|
|
if (type == 7 || type == 8) {
|
|
|
|
u32 udma;
|
2006-08-29 18:12:40 -04:00
|
|
|
|
2007-12-18 02:33:07 -05:00
|
|
|
pci_read_config_dword(pdev, 0x60, &udma);
|
2008-03-24 23:22:49 -04:00
|
|
|
hpriv = (void *)(unsigned long)udma;
|
2007-12-18 02:33:07 -05:00
|
|
|
}
|
2006-08-29 18:12:40 -04:00
|
|
|
|
|
|
|
/* And fire it up */
|
2008-04-07 09:47:16 -04:00
|
|
|
return ata_pci_sff_init_one(pdev, ppi, &amd_sht, hpriv);
|
2006-08-29 18:12:40 -04:00
|
|
|
}
|
|
|
|
|
2007-03-02 03:31:26 -05:00
|
|
|
#ifdef CONFIG_PM
|
2006-11-27 11:21:24 -05:00
|
|
|
static int amd_reinit_one(struct pci_dev *pdev)
|
|
|
|
{
|
2008-03-24 23:22:47 -04:00
|
|
|
struct ata_host *host = dev_get_drvdata(&pdev->dev);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = ata_pci_device_do_resume(pdev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2006-11-27 11:21:24 -05:00
|
|
|
if (pdev->vendor == PCI_VENDOR_ID_AMD) {
|
|
|
|
u8 fifo;
|
|
|
|
pci_read_config_byte(pdev, 0x41, &fifo);
|
|
|
|
if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7411)
|
|
|
|
/* FIFO is broken */
|
|
|
|
pci_write_config_byte(pdev, 0x41, fifo & 0x0F);
|
|
|
|
else
|
|
|
|
pci_write_config_byte(pdev, 0x41, fifo | 0xF0);
|
|
|
|
if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7409 ||
|
|
|
|
pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401)
|
2008-04-07 09:47:16 -04:00
|
|
|
ata_pci_bmdma_clear_simplex(pdev);
|
2006-11-27 11:21:24 -05:00
|
|
|
}
|
2008-03-24 23:22:47 -04:00
|
|
|
|
|
|
|
ata_host_resume(host);
|
|
|
|
return 0;
|
2006-11-27 11:21:24 -05:00
|
|
|
}
|
2007-03-02 03:31:26 -05:00
|
|
|
#endif
|
2006-11-27 11:21:24 -05:00
|
|
|
|
2006-08-29 18:12:40 -04:00
|
|
|
static const struct pci_device_id amd[] = {
|
2006-09-28 20:21:59 -04:00
|
|
|
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 },
|
|
|
|
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 },
|
|
|
|
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 3 },
|
|
|
|
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 4 },
|
|
|
|
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 5 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 7 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 8 },
|
2006-11-02 17:58:21 -05:00
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 8 },
|
2007-06-07 06:23:12 -04:00
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 8 },
|
|
|
|
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 8 },
|
2006-09-28 20:21:59 -04:00
|
|
|
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 },
|
|
|
|
|
|
|
|
{ },
|
2006-08-29 18:12:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct pci_driver amd_pci_driver = {
|
2006-09-28 20:21:59 -04:00
|
|
|
.name = DRV_NAME,
|
2006-08-29 18:12:40 -04:00
|
|
|
.id_table = amd,
|
|
|
|
.probe = amd_init_one,
|
2006-11-27 11:21:24 -05:00
|
|
|
.remove = ata_pci_remove_one,
|
2007-03-02 03:31:26 -05:00
|
|
|
#ifdef CONFIG_PM
|
2006-11-27 11:21:24 -05:00
|
|
|
.suspend = ata_pci_device_suspend,
|
|
|
|
.resume = amd_reinit_one,
|
2007-03-02 03:31:26 -05:00
|
|
|
#endif
|
2006-08-29 18:12:40 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init amd_init(void)
|
|
|
|
{
|
|
|
|
return pci_register_driver(&amd_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit amd_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&amd_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Alan Cox");
|
2008-02-08 10:22:39 -05:00
|
|
|
MODULE_DESCRIPTION("low-level driver for AMD and Nvidia PATA IDE");
|
2006-08-29 18:12:40 -04:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(pci, amd);
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
|
|
|
|
module_init(amd_init);
|
|
|
|
module_exit(amd_exit);
|