ata-ite.c (200459) | ata-ite.c (200753) |
---|---|
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-ite.c 200459 2009-12-13 00:13:21Z marius $"); | 28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-ite.c 200753 2009-12-20 15:03:57Z 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> --- 63 unchanged lines hidden (view full) --- 100 /* set PCI mode and 66Mhz reference clock */ 101 pci_write_config(dev, 0x50, pci_read_config(dev, 0x50, 1) & ~0x83, 1); 102 103 /* set default active & recover timings */ 104 pci_write_config(dev, 0x54, 0x31, 1); 105 pci_write_config(dev, 0x56, 0x31, 1); 106 107 ctlr->setmode = ata_ite_821x_setmode; | 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> --- 63 unchanged lines hidden (view full) --- 100 /* set PCI mode and 66Mhz reference clock */ 101 pci_write_config(dev, 0x50, pci_read_config(dev, 0x50, 1) & ~0x83, 1); 102 103 /* set default active & recover timings */ 104 pci_write_config(dev, 0x54, 0x31, 1); 105 pci_write_config(dev, 0x56, 0x31, 1); 106 107 ctlr->setmode = ata_ite_821x_setmode; |
108 /* No timing restrictions initally. */ 109 ctlr->chipset_data = (void *)0; |
|
108 } 109 ctlr->ch_attach = ata_ite_ch_attach; 110 return 0; 111} 112 113static int 114ata_ite_ch_attach(device_t dev) 115{ --- 8 unchanged lines hidden (view full) --- 124static int 125ata_ite_821x_setmode(device_t dev, int target, int mode) 126{ 127 device_t parent = device_get_parent(dev); 128 struct ata_pci_controller *ctlr = device_get_softc(parent); 129 struct ata_channel *ch = device_get_softc(dev); 130 int devno = (ch->unit << 1) + target; 131 int piomode; | 110 } 111 ctlr->ch_attach = ata_ite_ch_attach; 112 return 0; 113} 114 115static int 116ata_ite_ch_attach(device_t dev) 117{ --- 8 unchanged lines hidden (view full) --- 126static int 127ata_ite_821x_setmode(device_t dev, int target, int mode) 128{ 129 device_t parent = device_get_parent(dev); 130 struct ata_pci_controller *ctlr = device_get_softc(parent); 131 struct ata_channel *ch = device_get_softc(dev); 132 int devno = (ch->unit << 1) + target; 133 int piomode; |
134 uint8_t *timings = (uint8_t*)(&ctlr->chipset_data); |
|
132 u_int8_t udmatiming[] = 133 { 0x44, 0x42, 0x31, 0x21, 0x11, 0xa2, 0x91 }; 134 u_int8_t chtiming[] = 135 { 0xaa, 0xa3, 0xa1, 0x33, 0x31, 0x88, 0x32, 0x31 }; 136 137 mode = min(mode, ctlr->chip->max_dma); 138 /* check the CBLID bits for 80 conductor cable detection */ 139 if (mode > ATA_UDMA2 && (pci_read_config(parent, 0x40, 2) & --- 13 unchanged lines hidden (view full) --- 153 piomode = ATA_PIO4; 154 } else { 155 /* disable UDMA mode */ 156 pci_write_config(parent, 0x50, 157 pci_read_config(parent, 0x50, 1) | 158 (1 << (devno + 3)), 1); 159 piomode = mode; 160 } | 135 u_int8_t udmatiming[] = 136 { 0x44, 0x42, 0x31, 0x21, 0x11, 0xa2, 0x91 }; 137 u_int8_t chtiming[] = 138 { 0xaa, 0xa3, 0xa1, 0x33, 0x31, 0x88, 0x32, 0x31 }; 139 140 mode = min(mode, ctlr->chip->max_dma); 141 /* check the CBLID bits for 80 conductor cable detection */ 142 if (mode > ATA_UDMA2 && (pci_read_config(parent, 0x40, 2) & --- 13 unchanged lines hidden (view full) --- 156 piomode = ATA_PIO4; 157 } else { 158 /* disable UDMA mode */ 159 pci_write_config(parent, 0x50, 160 pci_read_config(parent, 0x50, 1) | 161 (1 << (devno + 3)), 1); 162 piomode = mode; 163 } |
164 timings[devno] = chtiming[ata_mode2idx(piomode)]; |
|
161 /* set active and recover timing (shared between master & slave) */ | 165 /* set active and recover timing (shared between master & slave) */ |
162 if (pci_read_config(parent, 0x54 + (ch->unit << 2), 1) < 163 chtiming[ata_mode2idx(piomode)]) 164 pci_write_config(parent, 0x54 + (ch->unit << 2), 165 chtiming[ata_mode2idx(piomode)], 1); | 166 pci_write_config(parent, 0x54 + (ch->unit << 2), 167 max(timings[ch->unit << 1], timings[(ch->unit << 1) + 1]), 1); |
166 return (mode); 167} 168 169static int 170ata_ite_8213_setmode(device_t dev, int target, int mode) 171{ 172 device_t parent = device_get_parent(dev); 173 struct ata_pci_controller *ctlr = device_get_softc(parent); --- 57 unchanged lines hidden --- | 168 return (mode); 169} 170 171static int 172ata_ite_8213_setmode(device_t dev, int target, int mode) 173{ 174 device_t parent = device_get_parent(dev); 175 struct ata_pci_controller *ctlr = device_get_softc(parent); --- 57 unchanged lines hidden --- |