svn commit: r188765 - in head/sys/dev/ata: . chipsets

Alexander Motin mav at FreeBSD.org
Wed Feb 18 14:17:50 PST 2009


Author: mav
Date: Wed Feb 18 22:17:48 2009
New Revision: 188765
URL: http://svn.freebsd.org/changeset/base/188765

Log:
  As soon as they called in only same one place (ata_pcichannel_attach()),
  join allocate() and dmainit() atapci subdriver's channel initialization
  methods into single ch_attach() method.
  
  As opposite to ch_attach() add new ch_detach() method to deallocate/disable
  channel.

Modified:
  head/sys/dev/ata/ata-pci.c
  head/sys/dev/ata/ata-pci.h
  head/sys/dev/ata/chipsets/ata-acard.c
  head/sys/dev/ata/chipsets/ata-acerlabs.c
  head/sys/dev/ata/chipsets/ata-ahci.c
  head/sys/dev/ata/chipsets/ata-highpoint.c
  head/sys/dev/ata/chipsets/ata-intel.c
  head/sys/dev/ata/chipsets/ata-jmicron.c
  head/sys/dev/ata/chipsets/ata-marvell.c
  head/sys/dev/ata/chipsets/ata-netcell.c
  head/sys/dev/ata/chipsets/ata-nvidia.c
  head/sys/dev/ata/chipsets/ata-promise.c
  head/sys/dev/ata/chipsets/ata-serverworks.c
  head/sys/dev/ata/chipsets/ata-siliconimage.c
  head/sys/dev/ata/chipsets/ata-sis.c
  head/sys/dev/ata/chipsets/ata-via.c

Modified: head/sys/dev/ata/ata-pci.c
==============================================================================
--- head/sys/dev/ata/ata-pci.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/ata-pci.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -99,8 +99,7 @@ ata_pci_attach(device_t dev)
     else
 	ctlr->channels = 1;
     ctlr->ichannels = -1;
-    ctlr->allocate = ata_pci_allocate;
-    ctlr->dmainit = ata_pci_dmainit;
+    ctlr->ch_attach = ata_pci_ch_attach;
     ctlr->dev = dev;
 
     /* if needed try to enable busmastering */
@@ -344,7 +343,7 @@ ata_generic_chipinit(device_t dev)
 }
 
 int
-ata_pci_allocate(device_t dev)
+ata_pci_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
@@ -361,6 +360,8 @@ ata_pci_allocate(device_t dev)
 	return ENXIO;
     }
 
+    ata_pci_dmainit(dev);
+
     for (i = ATA_DATA; i <= ATA_COMMAND; i ++) {
 	ch->r_io[i].res = io;
 	ch->r_io[i].offset = i;
@@ -532,10 +533,7 @@ ata_pcichannel_attach(device_t dev)
 
     ch->unit = (intptr_t)device_get_ivars(dev);
 
-    if (ctlr->dmainit)
-	ctlr->dmainit(dev);
-
-    if ((error = ctlr->allocate(dev)))
+    if ((error = ctlr->ch_attach(dev)))
 	return error;
 
     return ata_attach(dev);
@@ -544,14 +542,16 @@ ata_pcichannel_attach(device_t dev)
 static int
 ata_pcichannel_detach(device_t dev)
 {
+    struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     int error;
 
     if ((error = ata_detach(dev)))
 	return error;
 
-    /* XXX SOS free resources for io and ctlio ?? */
+    if (ctlr->ch_detach)
+	return (ctlr->ch_detach(dev));
 
-    return 0;
+    return (0);
 }
 
 static int

Modified: head/sys/dev/ata/ata-pci.h
==============================================================================
--- head/sys/dev/ata/ata-pci.h	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/ata-pci.h	Wed Feb 18 22:17:48 2009	(r188765)
@@ -55,10 +55,10 @@ struct ata_pci_controller {
     int                 (*chipinit)(device_t);
     int                 (*suspend)(device_t);
     int                 (*resume)(device_t);
-    int                 (*allocate)(device_t);
+    int                 (*ch_attach)(device_t);
+    int                 (*ch_detach)(device_t);
     int                 (*locking)(device_t, int);
     void                (*reset)(device_t);
-    void                (*dmainit)(device_t);
     void                (*setmode)(device_t, int);
     struct {
     void                (*function)(void *);
@@ -409,7 +409,7 @@ struct resource * ata_pci_alloc_resource
 int ata_pci_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r);
 int ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *function, void *argument, void **cookiep);
  int ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie);
-int ata_pci_allocate(device_t dev);
+int ata_pci_ch_attach(device_t dev);
 int ata_pci_status(device_t dev);
 void ata_pci_hw(device_t dev);
 void ata_pci_dmainit(device_t dev);
@@ -434,7 +434,7 @@ void ata_pm_identify(device_t dev);
 
 /* global prototypes from chipsets/ata-*.c */
 int ata_ahci_chipinit(device_t);
-int ata_ahci_allocate(device_t dev);
+int ata_ahci_ch_attach(device_t dev);
 void ata_ahci_reset(device_t dev);
 void ata_ahci_dmainit(device_t dev);
 int ata_marvell_edma_chipinit(device_t);

Modified: head/sys/dev/ata/chipsets/ata-acard.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-acard.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-acard.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_acard_chipinit(device_t dev);
-static int ata_acard_allocate(device_t dev);
+static int ata_acard_ch_attach(device_t dev);
 static int ata_acard_status(device_t dev);
 static void ata_acard_850_setmode(device_t dev, int mode);
 static void ata_acard_86X_setmode(device_t dev, int mode);
@@ -97,7 +97,7 @@ ata_acard_chipinit(device_t dev)
     if (ata_setup_interrupt(dev, ata_generic_intr))
 	return ENXIO;
 
-    ctlr->allocate = ata_acard_allocate;
+    ctlr->ch_attach = ata_acard_ch_attach;
     if (ctlr->chip->cfg1 == ATP_OLD) {
 	ctlr->setmode = ata_acard_850_setmode;
 	ctlr->locking = ata_serialize;
@@ -108,12 +108,12 @@ ata_acard_chipinit(device_t dev)
 }
 
 static int
-ata_acard_allocate(device_t dev)
+ata_acard_ch_attach(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(dev);
 
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     ch->hw.status = ata_acard_status;

Modified: head/sys/dev/ata/chipsets/ata-acerlabs.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-acerlabs.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-acerlabs.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,8 +53,8 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_ali_chipinit(device_t dev);
-static int ata_ali_allocate(device_t dev);
-static int ata_ali_sata_allocate(device_t dev);
+static int ata_ali_ch_attach(device_t dev);
+static int ata_ali_sata_ch_attach(device_t dev);
 static void ata_ali_reset(device_t dev);
 static void ata_ali_setmode(device_t dev, int mode);
 
@@ -105,7 +105,7 @@ ata_ali_chipinit(device_t dev)
     switch (ctlr->chip->cfg2) {
     case ALI_SATA:
 	ctlr->channels = ctlr->chip->cfg1;
-	ctlr->allocate = ata_ali_sata_allocate;
+	ctlr->ch_attach = ata_ali_sata_ch_attach;
 	ctlr->setmode = ata_sata_setmode;
 
 	/* AHCI mode is correctly supported only on the ALi 5288. */
@@ -133,7 +133,7 @@ ata_ali_chipinit(device_t dev)
 	    device_printf(dev,
 			  "using PIO transfers above 137GB as workaround for "
 			  "48bit DMA access bug, expect reduced performance\n");
-	ctlr->allocate = ata_ali_allocate;
+	ctlr->ch_attach = ata_ali_ch_attach;
 	ctlr->reset = ata_ali_reset;
 	ctlr->setmode = ata_ali_setmode;
 	break;
@@ -148,13 +148,13 @@ ata_ali_chipinit(device_t dev)
 }
 
 static int
-ata_ali_allocate(device_t dev)
+ata_ali_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
 
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     /* older chips can't do 48bit DMA transfers */
@@ -165,7 +165,7 @@ ata_ali_allocate(device_t dev)
 }
 
 static int
-ata_ali_sata_allocate(device_t dev)
+ata_ali_sata_ch_attach(device_t dev)
 {
     device_t parent = device_get_parent(dev);
     struct ata_pci_controller *ctlr = device_get_softc(parent);

Modified: head/sys/dev/ata/chipsets/ata-ahci.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-ahci.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-ahci.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -128,8 +128,7 @@ ata_ahci_chipinit(device_t dev)
 	    (ATA_INL(ctlr->r_res2, ATA_AHCI_CAP) & ATA_AHCI_NPMASK) + 1);
 
     ctlr->reset = ata_ahci_reset;
-    ctlr->dmainit = ata_ahci_dmainit;
-    ctlr->allocate = ata_ahci_allocate;
+    ctlr->ch_attach = ata_ahci_ch_attach;
     ctlr->setmode = ata_sata_setmode;
     ctlr->suspend = ata_ahci_suspend;
     ctlr->resume = ata_ahci_ctlr_reset;
@@ -197,12 +196,14 @@ ata_ahci_suspend(device_t dev)
 
 
 int
-ata_ahci_allocate(device_t dev)
+ata_ahci_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
     int offset = ch->unit << 7;
 
+    ata_ahci_dmainit(dev);
+
     /* set the SATA resources */
     ch->r_io[ATA_SSTATUS].res = ctlr->r_res2;
     ch->r_io[ATA_SSTATUS].offset = ATA_AHCI_P_SSTS + offset;

Modified: head/sys/dev/ata/chipsets/ata-highpoint.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-highpoint.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-highpoint.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_highpoint_chipinit(device_t dev);
-static int ata_highpoint_allocate(device_t dev);
+static int ata_highpoint_ch_attach(device_t dev);
 static void ata_highpoint_setmode(device_t dev, int mode);
 static int ata_highpoint_check_80pin(device_t dev, int mode);
 
@@ -134,18 +134,18 @@ ata_highpoint_chipinit(device_t dev)
 	    pci_write_config(dev, 0x5b,
 			     (pci_read_config(dev, 0x5b, 1) & 0x01) | 0x20, 1);
     }
-    ctlr->allocate = ata_highpoint_allocate;
+    ctlr->ch_attach = ata_highpoint_ch_attach;
     ctlr->setmode = ata_highpoint_setmode;
     return 0;
 }
 
 static int
-ata_highpoint_allocate(device_t dev)
+ata_highpoint_ch_attach(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(dev);
 
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     ch->flags |= ATA_ALWAYS_DMASTAT;

Modified: head/sys/dev/ata/chipsets/ata-intel.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-intel.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-intel.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,12 +53,12 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_intel_chipinit(device_t dev);
-static int ata_intel_allocate(device_t dev);
+static int ata_intel_ch_attach(device_t dev);
 static void ata_intel_reset(device_t dev);
 static void ata_intel_old_setmode(device_t dev, int mode);
 static void ata_intel_new_setmode(device_t dev, int mode);
 static void ata_intel_sata_setmode(device_t dev, int mode);
-static int ata_intel_31244_allocate(device_t dev);
+static int ata_intel_31244_ch_attach(device_t dev);
 static int ata_intel_31244_status(device_t dev);
 static void ata_intel_31244_tf_write(struct ata_request *request);
 static void ata_intel_31244_reset(device_t dev);
@@ -171,7 +171,7 @@ ata_intel_chipinit(device_t dev)
 							RF_ACTIVE)))
 		return ENXIO;
 	    ctlr->channels = 4;
-	    ctlr->allocate = ata_intel_31244_allocate;
+	    ctlr->ch_attach = ata_intel_31244_ch_attach;
 	    ctlr->reset = ata_intel_31244_reset;
 	}
 	ctlr->setmode = ata_sata_setmode;
@@ -180,7 +180,7 @@ ata_intel_chipinit(device_t dev)
     /* non SATA intel chips goes here */
     else if (ctlr->chip->max_dma < ATA_SA150) {
 	ctlr->channels = ctlr->chip->cfg2;
-	ctlr->allocate = ata_intel_allocate;
+	ctlr->ch_attach = ata_intel_ch_attach;
 	ctlr->setmode = ata_intel_new_setmode;
     }
 
@@ -189,7 +189,7 @@ ata_intel_chipinit(device_t dev)
 	/* force all ports active "the legacy way" */
 	pci_write_config(dev, 0x92, pci_read_config(dev, 0x92, 2) | 0x0f, 2);
 
-	ctlr->allocate = ata_intel_allocate;
+	ctlr->ch_attach = ata_intel_ch_attach;
 	ctlr->reset = ata_intel_reset;
 
 	/* 
@@ -218,13 +218,13 @@ ata_intel_chipinit(device_t dev)
 }
 
 static int
-ata_intel_allocate(device_t dev)
+ata_intel_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
 
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     /* if r_res2 is valid it points to SATA interface registers */
@@ -257,7 +257,7 @@ ata_intel_reset(device_t dev)
 	    mask = 0x0003;
 	else {
 	    mask = (0x0001 << ch->unit);
-	    /* XXX SOS should be in intel_allocate if we grow it */
+	    /* XXX SOS should be in intel_ch_attach if we grow it */
 	    ch->flags |= ATA_NO_SLAVE;
 	}
     }
@@ -396,7 +396,7 @@ ata_intel_sata_setmode(device_t dev, int
 }
 
 static int
-ata_intel_31244_allocate(device_t dev)
+ata_intel_31244_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);

Modified: head/sys/dev/ata/chipsets/ata-jmicron.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-jmicron.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-jmicron.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_jmicron_chipinit(device_t dev);
-static int ata_jmicron_allocate(device_t dev);
+static int ata_jmicron_ch_attach(device_t dev);
 static void ata_jmicron_reset(device_t dev);
 static void ata_jmicron_dmainit(device_t dev);
 static void ata_jmicron_setmode(device_t dev, int mode);
@@ -112,9 +112,8 @@ ata_jmicron_chipinit(device_t dev)
 	    return 0;
 
 	/* otherwise we are on the PATA part */
-	ctlr->allocate = ata_pci_allocate;
+	ctlr->ch_attach = ata_pci_ch_attach;
 	ctlr->reset = ata_generic_reset;
-	ctlr->dmainit = ata_pci_dmainit;
 	ctlr->setmode = ata_jmicron_setmode;
 	ctlr->channels = ctlr->chip->cfg2;
     }
@@ -126,9 +125,8 @@ ata_jmicron_chipinit(device_t dev)
 	if (ctlr->chip->cfg1 && (error = ata_ahci_chipinit(dev)))
 	    return error;
 
-	ctlr->allocate = ata_jmicron_allocate;
+	ctlr->ch_attach = ata_jmicron_ch_attach;
 	ctlr->reset = ata_jmicron_reset;
-	ctlr->dmainit = ata_jmicron_dmainit;
 	ctlr->setmode = ata_jmicron_setmode;
 
 	/* set the number of HW channels */ 
@@ -138,19 +136,21 @@ ata_jmicron_chipinit(device_t dev)
 }
 
 static int
-ata_jmicron_allocate(device_t dev)
+ata_jmicron_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
     int error;
 
+    ata_jmicron_dmainit(dev);
+
     if (ch->unit >= ctlr->chip->cfg1) {
 	ch->unit -= ctlr->chip->cfg1;
-	error = ata_pci_allocate(dev);
+	error = ata_pci_ch_attach(dev);
 	ch->unit += ctlr->chip->cfg1;
     }
     else
-	error = ata_ahci_allocate(dev);
+	error = ata_ahci_ch_attach(dev);
     return error;
 }
 

Modified: head/sys/dev/ata/chipsets/ata-marvell.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-marvell.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-marvell.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,9 +53,9 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_marvell_pata_chipinit(device_t dev);
-static int ata_marvell_pata_allocate(device_t dev);
+static int ata_marvell_pata_ch_attach(device_t dev);
 static void ata_marvell_pata_setmode(device_t dev, int mode);
-static int ata_marvell_edma_allocate(device_t dev);
+static int ata_marvell_edma_ch_attach(device_t dev);
 static int ata_marvell_edma_status(device_t dev);
 static int ata_marvell_edma_begin_transaction(struct ata_request *request);
 static int ata_marvell_edma_end_transaction(struct ata_request *request);
@@ -135,19 +135,19 @@ ata_marvell_pata_chipinit(device_t dev)
     if (ata_setup_interrupt(dev, ata_generic_intr))
 	return ENXIO;
 
-    ctlr->allocate = ata_marvell_pata_allocate;
+    ctlr->ch_attach = ata_marvell_pata_ch_attach;
     ctlr->setmode = ata_marvell_pata_setmode;
     ctlr->channels = ctlr->chip->cfg1;
     return 0;
 }
 
 static int
-ata_marvell_pata_allocate(device_t dev)
+ata_marvell_pata_ch_attach(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(dev);
  
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
  
     /* dont use 32 bit PIO transfers */
@@ -189,9 +189,8 @@ ata_marvell_edma_chipinit(device_t dev)
     /* mask all PCI interrupts */
     ATA_OUTL(ctlr->r_res1, 0x01d5c, 0x00000000);
 
-    ctlr->allocate = ata_marvell_edma_allocate;
+    ctlr->ch_attach = ata_marvell_edma_ch_attach;
     ctlr->reset = ata_marvell_edma_reset;
-    ctlr->dmainit = ata_marvell_edma_dmainit;
     ctlr->setmode = ata_sata_setmode;
     ctlr->channels = ctlr->chip->cfg1;
 
@@ -217,13 +216,15 @@ ata_marvell_edma_chipinit(device_t dev)
 }
 
 static int
-ata_marvell_edma_allocate(device_t dev)
+ata_marvell_edma_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
     u_int64_t work = ch->dma.work_bus;
     int i;
 
+    ata_marvell_edma_dmainit(dev);
+
     /* clear work area */
     bzero(ch->dma.work, 1024+256);
 

Modified: head/sys/dev/ata/chipsets/ata-netcell.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-netcell.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-netcell.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_netcell_chipinit(device_t dev);
-static int ata_netcell_allocate(device_t dev);
+static int ata_netcell_ch_attach(device_t dev);
 static void ata_netcell_setmode(device_t dev, int mode);
 
 
@@ -81,18 +81,18 @@ ata_netcell_chipinit(device_t dev)
     if (ata_setup_interrupt(dev, ata_generic_intr))
         return ENXIO;
 
-    ctlr->allocate = ata_netcell_allocate;
+    ctlr->ch_attach = ata_netcell_ch_attach;
     ctlr->setmode = ata_netcell_setmode;
     return 0;
 }
 
 static int
-ata_netcell_allocate(device_t dev)
+ata_netcell_ch_attach(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(dev);
  
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
  
     /* the NetCell only supports 16 bit PIO transfers */

Modified: head/sys/dev/ata/chipsets/ata-nvidia.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-nvidia.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-nvidia.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_nvidia_chipinit(device_t dev);
-static int ata_nvidia_allocate(device_t dev);
+static int ata_nvidia_ch_attach(device_t dev);
 static int ata_nvidia_status(device_t dev);
 static void ata_nvidia_reset(device_t dev);
 static void ata_nvidia_setmode(device_t dev, int mode);
@@ -130,7 +130,7 @@ ata_nvidia_chipinit(device_t dev)
 						   &ctlr->r_rid2, RF_ACTIVE))) {
 	    int offset = ctlr->chip->cfg1 & NV4 ? 0x0440 : 0x0010;
 
-	    ctlr->allocate = ata_nvidia_allocate;
+	    ctlr->ch_attach = ata_nvidia_ch_attach;
 	    ctlr->reset = ata_nvidia_reset;
 
 	    /* enable control access */
@@ -171,13 +171,13 @@ ata_nvidia_chipinit(device_t dev)
 }
 
 static int
-ata_nvidia_allocate(device_t dev)
+ata_nvidia_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
 
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     ch->r_io[ATA_SSTATUS].res = ctlr->r_res2;

Modified: head/sys/dev/ata/chipsets/ata-promise.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-promise.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-promise.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,16 +53,16 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_promise_chipinit(device_t dev);
-static int ata_promise_allocate(device_t dev);
+static int ata_promise_ch_attach(device_t dev);
 static int ata_promise_status(device_t dev);
 static int ata_promise_dmastart(struct ata_request *request);
 static int ata_promise_dmastop(struct ata_request *request);
 static void ata_promise_dmareset(device_t dev);
 static void ata_promise_dmainit(device_t dev);
 static void ata_promise_setmode(device_t dev, int mode);
-static int ata_promise_tx2_allocate(device_t dev);
+static int ata_promise_tx2_ch_attach(device_t dev);
 static int ata_promise_tx2_status(device_t dev);
-static int ata_promise_mio_allocate(device_t dev);
+static int ata_promise_mio_ch_attach(device_t dev);
 static void ata_promise_mio_intr(void *data);
 static int ata_promise_mio_status(device_t dev);
 static int ata_promise_mio_command(struct ata_request *request);
@@ -226,19 +226,17 @@ ata_promise_chipinit(device_t dev)
     case PR_NEW:
 	/* setup clocks */
 	ATA_OUTB(ctlr->r_res1, 0x11, ATA_INB(ctlr->r_res1, 0x11) | 0x0a);
-
-	ctlr->dmainit = ata_promise_dmainit;
 	/* FALLTHROUGH */
 
     case PR_OLD:
 	/* enable burst mode */
 	ATA_OUTB(ctlr->r_res1, 0x1f, ATA_INB(ctlr->r_res1, 0x1f) | 0x01);
-	ctlr->allocate = ata_promise_allocate;
+	ctlr->ch_attach = ata_promise_ch_attach;
 	ctlr->setmode = ata_promise_setmode;
 	return 0;
 
     case PR_TX:
-	ctlr->allocate = ata_promise_tx2_allocate;
+	ctlr->ch_attach = ata_promise_tx2_ch_attach;
 	ctlr->setmode = ata_promise_setmode;
 	return 0;
 
@@ -284,9 +282,8 @@ ata_promise_chipinit(device_t dev)
 	    TAILQ_INIT(&hpkt->queue);
 	    hpkt->busy = 0;
 	    device_set_ivars(dev, hpkt);
-	    ctlr->allocate = ata_promise_mio_allocate;
+	    ctlr->ch_attach = ata_promise_mio_ch_attach;
 	    ctlr->reset = ata_promise_mio_reset;
-	    ctlr->dmainit = ata_promise_mio_dmainit;
 	    ctlr->setmode = ata_promise_setmode;
 	    ctlr->channels = 4;
 	    return 0;
@@ -337,9 +334,8 @@ sataii:
 	if ((ctlr->chip->cfg2 == PR_SATA2) || (ctlr->chip->cfg2 == PR_CMBO2))
 	    ATA_OUTL(ctlr->r_res2, 0x44, ATA_INL(ctlr->r_res2, 0x44) | 0x2000);
 
-	ctlr->allocate = ata_promise_mio_allocate;
+	ctlr->ch_attach = ata_promise_mio_ch_attach;
 	ctlr->reset = ata_promise_mio_reset;
-	ctlr->dmainit = ata_promise_mio_dmainit;
 	ctlr->setmode = ata_promise_mio_setmode;
 
 	return 0;
@@ -354,11 +350,15 @@ failnfree:
 }
 
 static int
-ata_promise_allocate(device_t dev)
+ata_promise_ch_attach(device_t dev)
 {
+    struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
 
-    if (ata_pci_allocate(dev))
+    if (ctlr->chip->cfg1 == PR_NEW)
+	ata_promise_dmainit(dev);
+
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     ch->hw.status = ata_promise_status;
@@ -521,11 +521,11 @@ ata_promise_setmode(device_t dev, int mo
 }
 
 static int
-ata_promise_tx2_allocate(device_t dev)
+ata_promise_tx2_ch_attach(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(dev);
 
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     ch->hw.status = ata_promise_tx2_status;
@@ -545,13 +545,15 @@ ata_promise_tx2_status(device_t dev)
 }
 
 static int
-ata_promise_mio_allocate(device_t dev)
+ata_promise_mio_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
     int offset = (ctlr->chip->cfg2 & PR_SX4X) ? 0x000c0000 : 0;
     int i;
- 
+
+    ata_promise_mio_dmainit(dev);
+
     for (i = ATA_DATA; i <= ATA_COMMAND; i++) {
 	ch->r_io[i].res = ctlr->r_res2;
 	ch->r_io[i].offset = offset + 0x0200 + (i << 2) + (ch->unit << 7); 

Modified: head/sys/dev/ata/chipsets/ata-serverworks.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-serverworks.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-serverworks.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_serverworks_chipinit(device_t dev);
-static int ata_serverworks_allocate(device_t dev);
+static int ata_serverworks_ch_attach(device_t dev);
 static void ata_serverworks_tf_read(struct ata_request *request);
 static void ata_serverworks_tf_write(struct ata_request *request);
 static void ata_serverworks_setmode(device_t dev, int mode);
@@ -113,7 +113,7 @@ ata_serverworks_chipinit(device_t dev)
 	    return ENXIO;
 
 	ctlr->channels = ctlr->chip->cfg2;
-	ctlr->allocate = ata_serverworks_allocate;
+	ctlr->ch_attach = ata_serverworks_ch_attach;
 	ctlr->setmode = ata_sata_setmode;
 	return 0;
     }
@@ -144,7 +144,7 @@ ata_serverworks_chipinit(device_t dev)
 }
 
 static int
-ata_serverworks_allocate(device_t dev)
+ata_serverworks_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);

Modified: head/sys/dev/ata/chipsets/ata-siliconimage.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-siliconimage.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-siliconimage.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -52,14 +52,14 @@ __FBSDID("$FreeBSD$");
 #include <ata_if.h>
 
 /* local prototypes */
-static int ata_cmd_allocate(device_t dev);
+static int ata_cmd_ch_attach(device_t dev);
 static int ata_cmd_status(device_t dev);
 static void ata_cmd_setmode(device_t dev, int mode);
-static int ata_sii_allocate(device_t dev);
+static int ata_sii_ch_attach(device_t dev);
 static int ata_sii_status(device_t dev);
 static void ata_sii_reset(device_t dev);
 static void ata_sii_setmode(device_t dev, int mode);
-static int ata_siiprb_allocate(device_t dev);
+static int ata_siiprb_ch_attach(device_t dev);
 static int ata_siiprb_status(device_t dev);
 static int ata_siiprb_begin_transaction(struct ata_request *request);
 static int ata_siiprb_end_transaction(struct ata_request *request);
@@ -138,9 +138,8 @@ ata_sii_chipinit(device_t dev)
 	    bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1,ctlr->r_res1);
 	    return ENXIO;
 	}
-	ctlr->allocate = ata_siiprb_allocate;
+	ctlr->ch_attach = ata_siiprb_ch_attach;
 	ctlr->reset = ata_siiprb_reset;
-	ctlr->dmainit = ata_siiprb_dmainit;
 	ctlr->setmode = ata_sata_setmode;
 	ctlr->channels = (ctlr->chip->cfg2 == SII_4CH) ? 4 : 2;
 
@@ -187,7 +186,7 @@ ata_sii_chipinit(device_t dev)
 	pci_write_config(dev, 0x8a, (pci_read_config(dev, 0x8a, 1) & 0x3f), 1);
 
 	if (ctlr->r_res2)
-	    ctlr->allocate = ata_sii_allocate;
+	    ctlr->ch_attach = ata_sii_ch_attach;
 
 	if (ctlr->chip->max_dma >= ATA_SA150) {
 	    ctlr->reset = ata_sii_reset;
@@ -206,7 +205,7 @@ ata_sii_chipinit(device_t dev)
 	/* enable interrupt as BIOS might not */
 	pci_write_config(dev, 0x71, 0x01, 1);
 
-	ctlr->allocate = ata_cmd_allocate;
+	ctlr->ch_attach = ata_cmd_ch_attach;
 	ctlr->setmode = ata_cmd_setmode;
 	break;
     }
@@ -214,13 +213,13 @@ ata_sii_chipinit(device_t dev)
 }
 
 static int
-ata_cmd_allocate(device_t dev)
+ata_cmd_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
 
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     if (ctlr->chip->cfg2 & SII_INTR)
@@ -300,7 +299,7 @@ ata_cmd_setmode(device_t dev, int mode)
 }
 
 static int
-ata_sii_allocate(device_t dev)
+ata_sii_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
@@ -467,12 +466,14 @@ struct ata_siiprb_command {
 } __packed;
 
 static int
-ata_siiprb_allocate(device_t dev)
+ata_siiprb_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
     int offset = ch->unit * 0x2000;
 
+    ata_siiprb_dmainit(dev);
+
     /* set the SATA resources */
     ch->r_io[ATA_SSTATUS].res = ctlr->r_res2;
     ch->r_io[ATA_SSTATUS].offset = 0x1f04 + offset;

Modified: head/sys/dev/ata/chipsets/ata-sis.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-sis.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-sis.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_sis_chipinit(device_t dev);
-static int ata_sis_allocate(device_t dev);
+static int ata_sis_ch_attach(device_t dev);
 static void ata_sis_reset(device_t dev);
 static void ata_sis_setmode(device_t dev, int mode);
 
@@ -186,7 +186,7 @@ ata_sis_chipinit(device_t dev)
 	ctlr->r_rid2 = PCIR_BAR(5);
 	if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
 						   &ctlr->r_rid2, RF_ACTIVE))) {
-	    ctlr->allocate = ata_sis_allocate;
+	    ctlr->ch_attach = ata_sis_ch_attach;
 	    ctlr->reset = ata_sis_reset;
 
 	    /* enable PCI interrupt */
@@ -203,14 +203,14 @@ ata_sis_chipinit(device_t dev)
 }
 
 static int
-ata_sis_allocate(device_t dev)
+ata_sis_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
     int offset = ch->unit << ((ctlr->chip->chipid == ATA_SIS182) ? 5 : 6);
 
     /* setup the usual register normal pci style */
-    if (ata_pci_allocate(dev))
+    if (ata_pci_ch_attach(dev))
 	return ENXIO;
 
     ch->r_io[ATA_SSTATUS].res = ctlr->r_res2;

Modified: head/sys/dev/ata/chipsets/ata-via.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-via.c	Wed Feb 18 21:52:13 2009	(r188764)
+++ head/sys/dev/ata/chipsets/ata-via.c	Wed Feb 18 22:17:48 2009	(r188765)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 
 /* local prototypes */
 static int ata_via_chipinit(device_t dev);
-static int ata_via_allocate(device_t dev);
+static int ata_via_ch_attach(device_t dev);
 static void ata_via_reset(device_t dev);
 static void ata_via_old_setmode(device_t dev, int mode);
 static void ata_via_southbridge_fixup(device_t dev);
@@ -139,7 +139,7 @@ ata_via_chipinit(device_t dev)
 	ctlr->r_rid2 = PCIR_BAR(5);
 	if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
 						   &ctlr->r_rid2, RF_ACTIVE))) {
-	    ctlr->allocate = ata_via_allocate;
+	    ctlr->ch_attach = ata_via_ch_attach;
 	    ctlr->reset = ata_via_reset;
 
 	    /* enable PCI interrupt */
@@ -184,7 +184,7 @@ ata_via_chipinit(device_t dev)
 }
 
 static int
-ata_via_allocate(device_t dev)
+ata_via_ch_attach(device_t dev)
 {
     struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
     struct ata_channel *ch = device_get_softc(dev);
@@ -218,7 +218,7 @@ ata_via_allocate(device_t dev)
     }
     else {
 	/* setup the usual register normal pci style */
-	if (ata_pci_allocate(dev))
+	if (ata_pci_ch_attach(dev))
 	    return ENXIO;
     }
 


More information about the svn-src-head mailing list