summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/ata-pci.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2009-12-06 00:10:13 +0000
committermav <mav@FreeBSD.org>2009-12-06 00:10:13 +0000
commit6a3018e7cff16ab166672e276b4b39154ad09739 (patch)
tree8def18d183a8f2ec2847c5ef06fe2fac081d798e /sys/dev/ata/ata-pci.c
parent9bb92ae41af45cc801f28a880e08648aad72e241 (diff)
downloadFreeBSD-src-6a3018e7cff16ab166672e276b4b39154ad09739.zip
FreeBSD-src-6a3018e7cff16ab166672e276b4b39154ad09739.tar.gz
MFp4:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into cam(4) interface modules. When enabled, this options deprecates all ata(4) peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers (ada, cd, ...) and interfaces to be natively used instead. As side effect of this, ata(4) mode setting code was completely rewritten to make controller API more strict and permit above change. While doing this, SATA revision was separated from PATA mode. It allows DMA-incapable SATA devices to operate and makes hw.ata.atapi_dma tunable work again. Also allow ata(4) controller drivers (except some specific or broken ones) to handle larger data transfers. Previous constraint of 64K was artificial and is not really required by PCI ATA BM specification or hardware. Submitted by: nwitehorn (powerpc part)
Diffstat (limited to 'sys/dev/ata/ata-pci.c')
-rw-r--r--sys/dev/ata/ata-pci.c68
1 files changed, 23 insertions, 45 deletions
diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c
index ce21926..cd87728 100644
--- a/sys/dev/ata/ata-pci.c
+++ b/sys/dev/ata/ata-pci.c
@@ -55,10 +55,6 @@ static MALLOC_DEFINE(M_ATAPCI, "ata_pci", "ATA driver PCI");
/* misc defines */
#define IOMASK 0xfffffffc
-/* local prototypes */
-static int ata_generic_chipinit(device_t dev);
-static void ata_generic_setmode(device_t dev, int mode);
-
/*
* generic PCI ATA device probe
*/
@@ -374,18 +370,14 @@ ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq,
}
}
-static void
-ata_generic_setmode(device_t dev, int mode)
+int
+ata_generic_setmode(device_t dev, int target, int mode)
{
- struct ata_device *atadev = device_get_softc(dev);
- mode = ata_limit_mode(dev, mode, ATA_UDMA2);
- mode = ata_check_80pin(dev, mode);
- if (!ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode))
- atadev->mode = mode;
+ return (min(mode, ATA_UDMA2));
}
-static int
+int
ata_generic_chipinit(device_t dev)
{
struct ata_pci_controller *ctlr = device_get_softc(dev);
@@ -707,16 +699,26 @@ ata_pcichannel_reset(device_t dev)
ata_generic_reset(dev);
}
-static void
-ata_pcichannel_setmode(device_t parent, device_t dev)
+static int
+ata_pcichannel_setmode(device_t dev, int target, int mode)
+{
+ struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
+
+ if (ctlr->setmode)
+ return (ctlr->setmode(dev, target, mode));
+ else
+ return (ata_generic_setmode(dev, target, mode));
+}
+
+static int
+ata_pcichannel_getrev(device_t dev, int target)
{
- struct ata_pci_controller *ctlr = device_get_softc(GRANDPARENT(dev));
- struct ata_device *atadev = device_get_softc(dev);
- int mode = atadev->mode;
+ struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
- ctlr->setmode(dev, ATA_PIO_MAX);
- if (mode >= ATA_DMA)
- ctlr->setmode(dev, mode);
+ if (ctlr->getrev)
+ return (ctlr->getrev(dev, target));
+ else
+ return (0);
}
static device_method_t ata_pcichannel_methods[] = {
@@ -730,6 +732,7 @@ static device_method_t ata_pcichannel_methods[] = {
/* ATA methods */
DEVMETHOD(ata_setmode, ata_pcichannel_setmode),
+ DEVMETHOD(ata_getrev, ata_pcichannel_getrev),
DEVMETHOD(ata_locking, ata_pcichannel_locking),
DEVMETHOD(ata_reset, ata_pcichannel_reset),
@@ -858,31 +861,6 @@ ata_find_chip(device_t dev, struct ata_chip_id *index, int slot)
return (NULL);
}
-void
-ata_print_cable(device_t dev, u_int8_t *who)
-{
- device_printf(dev,
- "DMA limited to UDMA33, %s found non-ATA66 cable\n", who);
-}
-
-int
-ata_check_80pin(device_t dev, int mode)
-{
- struct ata_device *atadev = device_get_softc(dev);
-
- if (!ata_dma_check_80pin) {
- if (bootverbose)
- device_printf(dev, "Skipping 80pin cable check\n");
- return mode;
- }
-
- if (mode > ATA_UDMA2 && !(atadev->param.hwres & ATA_CABLE_ID)) {
- ata_print_cable(dev, "device");
- mode = ATA_UDMA2;
- }
- return mode;
-}
-
char *
ata_pcivendor2str(device_t dev)
{
OpenPOWER on IntegriCloud