ata-ati.c (230132) | ata-ati.c (233282) |
---|---|
1/*- 2 * Copyright (c) 1998 - 2008 S��ren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 - 2008 S��ren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-ati.c 230132 2012-01-15 13:23:18Z uqs $"); | 28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-ati.c 233282 2012-03-21 16:59:39Z marius $"); |
29 30#include "opt_ata.h" 31#include <sys/param.h> 32#include <sys/module.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/ata.h> 36#include <sys/bus.h> --- 16 unchanged lines hidden (view full) --- 53 54/* local prototypes */ 55static int ata_ati_chipinit(device_t dev); 56static int ata_ati_dumb_ch_attach(device_t dev); 57static int ata_ati_ixp700_ch_attach(device_t dev); 58static int ata_ati_setmode(device_t dev, int target, int mode); 59 60/* misc defines */ | 29 30#include "opt_ata.h" 31#include <sys/param.h> 32#include <sys/module.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/ata.h> 36#include <sys/bus.h> --- 16 unchanged lines hidden (view full) --- 53 54/* local prototypes */ 55static int ata_ati_chipinit(device_t dev); 56static int ata_ati_dumb_ch_attach(device_t dev); 57static int ata_ati_ixp700_ch_attach(device_t dev); 58static int ata_ati_setmode(device_t dev, int target, int mode); 59 60/* misc defines */ |
61#define ATI_PATA 0x01 62#define ATI_SATA 0x02 | 61#define SII_MEMIO 1 /* must match ata_siliconimage.c's definition */ 62#define SII_BUG 0x04 /* must match ata_siliconimage.c's definition */ 63 64#define ATI_SATA SII_MEMIO 65#define ATI_PATA 0x02 |
63#define ATI_AHCI 0x04 | 66#define ATI_AHCI 0x04 |
64#define SII_MEMIO 1 65#define SII_BUG 0x04 | |
66 67static int force_ahci = 1; 68TUNABLE_INT("hw.ahci.force", &force_ahci); 69 70/* 71 * ATI chipset support functions 72 */ 73static int 74ata_ati_probe(device_t dev) 75{ 76 struct ata_pci_controller *ctlr = device_get_softc(dev); | 67 68static int force_ahci = 1; 69TUNABLE_INT("hw.ahci.force", &force_ahci); 70 71/* 72 * ATI chipset support functions 73 */ 74static int 75ata_ati_probe(device_t dev) 76{ 77 struct ata_pci_controller *ctlr = device_get_softc(dev); |
77 static struct ata_chip_id ids[] = | 78 static const struct ata_chip_id const ids[] = |
78 {{ ATA_ATI_IXP200, 0x00, ATI_PATA, 0, ATA_UDMA5, "IXP200" }, 79 { ATA_ATI_IXP300, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP300" }, | 79 {{ ATA_ATI_IXP200, 0x00, ATI_PATA, 0, ATA_UDMA5, "IXP200" }, 80 { ATA_ATI_IXP300, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP300" }, |
80 { ATA_ATI_IXP300_S1, 0x00, ATI_SATA, 0, ATA_SA150, "IXP300" }, | 81 { ATA_ATI_IXP300_S1, 0x00, ATI_SATA, SII_BUG, ATA_SA150, "IXP300" }, |
81 { ATA_ATI_IXP400, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP400" }, | 82 { ATA_ATI_IXP400, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP400" }, |
82 { ATA_ATI_IXP400_S1, 0x00, ATI_SATA, 0, ATA_SA150, "IXP400" }, 83 { ATA_ATI_IXP400_S2, 0x00, ATI_SATA, 0, ATA_SA150, "IXP400" }, | 83 { ATA_ATI_IXP400_S1, 0x00, ATI_SATA, SII_BUG, ATA_SA150, "IXP400" }, 84 { ATA_ATI_IXP400_S2, 0x00, ATI_SATA, SII_BUG, ATA_SA150, "IXP400" }, |
84 { ATA_ATI_IXP600, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP600" }, 85 { ATA_ATI_IXP600_S1, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP600" }, 86 { ATA_ATI_IXP700, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP700/800" }, 87 { ATA_ATI_IXP700_S1, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 88 { ATA_ATI_IXP700_S2, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 89 { ATA_ATI_IXP700_S3, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 90 { ATA_ATI_IXP700_S4, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 91 { ATA_ATI_IXP800_S1, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP800" }, --- 10 unchanged lines hidden (view full) --- 102 103 switch (ctlr->chip->cfg1) { 104 case ATI_PATA: 105 ctlr->chipinit = ata_ati_chipinit; 106 break; 107 case ATI_SATA: 108 /* 109 * the ATI SATA controller is actually a SiI 3112 controller | 85 { ATA_ATI_IXP600, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP600" }, 86 { ATA_ATI_IXP600_S1, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP600" }, 87 { ATA_ATI_IXP700, 0x00, ATI_PATA, 0, ATA_UDMA6, "IXP700/800" }, 88 { ATA_ATI_IXP700_S1, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 89 { ATA_ATI_IXP700_S2, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 90 { ATA_ATI_IXP700_S3, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 91 { ATA_ATI_IXP700_S4, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP700/800" }, 92 { ATA_ATI_IXP800_S1, 0x00, ATI_AHCI, 0, ATA_SA300, "IXP800" }, --- 10 unchanged lines hidden (view full) --- 103 104 switch (ctlr->chip->cfg1) { 105 case ATI_PATA: 106 ctlr->chipinit = ata_ati_chipinit; 107 break; 108 case ATI_SATA: 109 /* 110 * the ATI SATA controller is actually a SiI 3112 controller |
110 * cfg values below much match those in ata-siliconimage.c | |
111 */ | 111 */ |
112 ctlr->chip->cfg1 = SII_MEMIO; 113 ctlr->chip->cfg2 = SII_BUG; | |
114 ctlr->chipinit = ata_sii_chipinit; 115 break; 116 case ATI_AHCI: 117 if (force_ahci == 1 || pci_get_subclass(dev) != PCIS_STORAGE_IDE) 118 ctlr->chipinit = ata_ahci_chipinit; 119 else 120 ctlr->chipinit = ata_ati_chipinit; 121 break; --- 85 unchanged lines hidden (view full) --- 207ata_ati_setmode(device_t dev, int target, int mode) 208{ 209 device_t parent = device_get_parent(dev); 210 struct ata_pci_controller *ctlr = device_get_softc(parent); 211 struct ata_channel *ch = device_get_softc(dev); 212 int devno = (ch->unit << 1) + target; 213 int offset = (devno ^ 0x01) << 3; 214 int piomode; | 112 ctlr->chipinit = ata_sii_chipinit; 113 break; 114 case ATI_AHCI: 115 if (force_ahci == 1 || pci_get_subclass(dev) != PCIS_STORAGE_IDE) 116 ctlr->chipinit = ata_ahci_chipinit; 117 else 118 ctlr->chipinit = ata_ati_chipinit; 119 break; --- 85 unchanged lines hidden (view full) --- 205ata_ati_setmode(device_t dev, int target, int mode) 206{ 207 device_t parent = device_get_parent(dev); 208 struct ata_pci_controller *ctlr = device_get_softc(parent); 209 struct ata_channel *ch = device_get_softc(dev); 210 int devno = (ch->unit << 1) + target; 211 int offset = (devno ^ 0x01) << 3; 212 int piomode; |
215 u_int8_t piotimings[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; 216 u_int8_t dmatimings[] = { 0x77, 0x21, 0x20 }; | 213 static const uint8_t piotimings[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; 214 static const uint8_t dmatimings[] = { 0x77, 0x21, 0x20 }; |
217 218 mode = min(mode, ctlr->chip->max_dma); 219 if (mode >= ATA_UDMA0) { 220 /* Set UDMA mode, enable UDMA, set WDMA2/PIO4 */ 221 pci_write_config(parent, 0x56, 222 (pci_read_config(parent, 0x56, 2) & 223 ~(0xf << (devno << 2))) | 224 ((mode & ATA_MODE_MASK) << (devno << 2)), 2); --- 41 unchanged lines hidden --- | 215 216 mode = min(mode, ctlr->chip->max_dma); 217 if (mode >= ATA_UDMA0) { 218 /* Set UDMA mode, enable UDMA, set WDMA2/PIO4 */ 219 pci_write_config(parent, 0x56, 220 (pci_read_config(parent, 0x56, 2) & 221 ~(0xf << (devno << 2))) | 222 ((mode & ATA_MODE_MASK) << (devno << 2)), 2); --- 41 unchanged lines hidden --- |