ata-via.c (188765) | ata-via.c (188769) |
---|---|
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-via.c 188765 2009-02-18 22:17:48Z mav $"); | 28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-via.c 188769 2009-02-19 00:32:55Z mav $"); |
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> --- 12 unchanged lines hidden (view full) --- 49#include <dev/pci/pcireg.h> 50#include <dev/ata/ata-all.h> 51#include <dev/ata/ata-pci.h> 52#include <ata_if.h> 53 54/* local prototypes */ 55static int ata_via_chipinit(device_t dev); 56static int ata_via_ch_attach(device_t dev); | 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> --- 12 unchanged lines hidden (view full) --- 49#include <dev/pci/pcireg.h> 50#include <dev/ata/ata-all.h> 51#include <dev/ata/ata-pci.h> 52#include <ata_if.h> 53 54/* local prototypes */ 55static int ata_via_chipinit(device_t dev); 56static int ata_via_ch_attach(device_t dev); |
57static int ata_via_ch_detach(device_t dev); |
|
57static void ata_via_reset(device_t dev); 58static void ata_via_old_setmode(device_t dev, int mode); 59static void ata_via_southbridge_fixup(device_t dev); 60static void ata_via_new_setmode(device_t dev, int mode); 61 62/* misc defines */ 63#define VIA33 0 64#define VIA66 1 --- 70 unchanged lines hidden (view full) --- 135 if ((ctlr->chip->cfg2 == VIAAHCI) && ata_ahci_chipinit(dev) != ENXIO) 136 return 0; 137 138 ctlr->r_type2 = SYS_RES_IOPORT; 139 ctlr->r_rid2 = PCIR_BAR(5); 140 if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2, 141 &ctlr->r_rid2, RF_ACTIVE))) { 142 ctlr->ch_attach = ata_via_ch_attach; | 58static void ata_via_reset(device_t dev); 59static void ata_via_old_setmode(device_t dev, int mode); 60static void ata_via_southbridge_fixup(device_t dev); 61static void ata_via_new_setmode(device_t dev, int mode); 62 63/* misc defines */ 64#define VIA33 0 65#define VIA66 1 --- 70 unchanged lines hidden (view full) --- 136 if ((ctlr->chip->cfg2 == VIAAHCI) && ata_ahci_chipinit(dev) != ENXIO) 137 return 0; 138 139 ctlr->r_type2 = SYS_RES_IOPORT; 140 ctlr->r_rid2 = PCIR_BAR(5); 141 if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2, 142 &ctlr->r_rid2, RF_ACTIVE))) { 143 ctlr->ch_attach = ata_via_ch_attach; |
144 ctlr->ch_detach = ata_via_ch_detach; |
|
143 ctlr->reset = ata_via_reset; 144 145 /* enable PCI interrupt */ 146 pci_write_config(dev, PCIR_COMMAND, 147 pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); 148 } 149 150 if (ctlr->chip->cfg2 & VIABAR) { --- 38 unchanged lines hidden (view full) --- 189 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); 190 struct ata_channel *ch = device_get_softc(dev); 191 192 /* newer SATA chips has resources in one BAR for each channel */ 193 if (ctlr->chip->cfg2 & VIABAR) { 194 struct resource *r_io; 195 int i, rid; 196 | 145 ctlr->reset = ata_via_reset; 146 147 /* enable PCI interrupt */ 148 pci_write_config(dev, PCIR_COMMAND, 149 pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); 150 } 151 152 if (ctlr->chip->cfg2 & VIABAR) { --- 38 unchanged lines hidden (view full) --- 191 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); 192 struct ata_channel *ch = device_get_softc(dev); 193 194 /* newer SATA chips has resources in one BAR for each channel */ 195 if (ctlr->chip->cfg2 & VIABAR) { 196 struct resource *r_io; 197 int i, rid; 198 |
199 ata_pci_dmainit(dev); 200 |
|
197 rid = PCIR_BAR(ch->unit); 198 if (!(r_io = bus_alloc_resource_any(device_get_parent(dev), 199 SYS_RES_IOPORT, 200 &rid, RF_ACTIVE))) 201 return ENXIO; 202 203 for (i = ATA_DATA; i <= ATA_COMMAND; i ++) { 204 ch->r_io[i].res = r_io; --- 25 unchanged lines hidden (view full) --- 230 ch->r_io[ATA_SCONTROL].offset = 0x08 + (ch->unit << ctlr->chip->cfg1); 231 ch->flags |= ATA_NO_SLAVE; 232 233 /* XXX SOS PHY hotplug handling missing in VIA chip ?? */ 234 /* XXX SOS unknown how to enable PHY state change interrupt */ 235 return 0; 236} 237 | 201 rid = PCIR_BAR(ch->unit); 202 if (!(r_io = bus_alloc_resource_any(device_get_parent(dev), 203 SYS_RES_IOPORT, 204 &rid, RF_ACTIVE))) 205 return ENXIO; 206 207 for (i = ATA_DATA; i <= ATA_COMMAND; i ++) { 208 ch->r_io[i].res = r_io; --- 25 unchanged lines hidden (view full) --- 234 ch->r_io[ATA_SCONTROL].offset = 0x08 + (ch->unit << ctlr->chip->cfg1); 235 ch->flags |= ATA_NO_SLAVE; 236 237 /* XXX SOS PHY hotplug handling missing in VIA chip ?? */ 238 /* XXX SOS unknown how to enable PHY state change interrupt */ 239 return 0; 240} 241 |
242static int 243ata_via_ch_detach(device_t dev) 244{ 245 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); 246 struct ata_channel *ch = device_get_softc(dev); 247 248 /* newer SATA chips has resources in one BAR for each channel */ 249 if (ctlr->chip->cfg2 & VIABAR) { 250 int rid; 251 252 rid = PCIR_BAR(ch->unit); 253 bus_release_resource(device_get_parent(dev), 254 SYS_RES_IOPORT, rid, ch->r_io[ATA_CONTROL].res); 255 256 ata_pci_dmafini(dev); 257 } 258 else { 259 /* setup the usual register normal pci style */ 260 if (ata_pci_ch_detach(dev)) 261 return ENXIO; 262 } 263 264 return 0; 265} 266 |
|
238static void 239ata_via_reset(device_t dev) 240{ 241 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); 242 struct ata_channel *ch = device_get_softc(dev); 243 244 if ((ctlr->chip->cfg2 & VIABAR) && (ch->unit > 1)) 245 ata_generic_reset(dev); --- 106 unchanged lines hidden --- | 267static void 268ata_via_reset(device_t dev) 269{ 270 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); 271 struct ata_channel *ch = device_get_softc(dev); 272 273 if ((ctlr->chip->cfg2 & VIABAR) && (ch->unit > 1)) 274 ata_generic_reset(dev); --- 106 unchanged lines hidden --- |