ata-cyrix.c (194893) | ata-cyrix.c (200171) |
---|---|
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-cyrix.c 194893 2009-06-24 19:49:18Z mav $"); | 28__FBSDID("$FreeBSD: head/sys/dev/ata/chipsets/ata-cyrix.c 200171 2009-12-06 00:10:13Z 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> --- 11 unchanged lines hidden (view full) --- 48#include <dev/pci/pcivar.h> 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_cyrix_chipinit(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> --- 11 unchanged lines hidden (view full) --- 48#include <dev/pci/pcivar.h> 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_cyrix_chipinit(device_t dev); |
56static void ata_cyrix_setmode(device_t dev, int mode); | 56static int ata_cyrix_ch_attach(device_t dev); 57static int ata_cyrix_setmode(device_t dev, int target, int mode); |
57 58 59/* 60 * Cyrix chipset support functions 61 */ 62static int 63ata_cyrix_probe(device_t dev) 64{ --- 9 unchanged lines hidden (view full) --- 74 75static int 76ata_cyrix_chipinit(device_t dev) 77{ 78 struct ata_pci_controller *ctlr = device_get_softc(dev); 79 80 if (ata_setup_interrupt(dev, ata_generic_intr)) 81 return ENXIO; | 58 59 60/* 61 * Cyrix chipset support functions 62 */ 63static int 64ata_cyrix_probe(device_t dev) 65{ --- 9 unchanged lines hidden (view full) --- 75 76static int 77ata_cyrix_chipinit(device_t dev) 78{ 79 struct ata_pci_controller *ctlr = device_get_softc(dev); 80 81 if (ata_setup_interrupt(dev, ata_generic_intr)) 82 return ENXIO; |
82 | 83 ctlr->ch_attach = ata_cyrix_ch_attach; |
83 ctlr->setmode = ata_cyrix_setmode; 84 return 0; 85} 86 | 84 ctlr->setmode = ata_cyrix_setmode; 85 return 0; 86} 87 |
87static void 88ata_cyrix_setmode(device_t dev, int mode) | 88static int 89ata_cyrix_ch_attach(device_t dev) |
89{ | 90{ |
90 struct ata_pci_controller *ctlr = device_get_softc(GRANDPARENT(dev)); 91 struct ata_channel *ch = device_get_softc(device_get_parent(dev)); 92 struct ata_device *atadev = device_get_softc(dev); 93 int devno = (ch->unit << 1) + atadev->unit; 94 u_int32_t piotiming[] = 95 { 0x00009172, 0x00012171, 0x00020080, 0x00032010, 0x00040010 }; 96 u_int32_t dmatiming[] = { 0x00077771, 0x00012121, 0x00002020 }; 97 u_int32_t udmatiming[] = { 0x00921250, 0x00911140, 0x00911030 }; 98 int error; | 91 struct ata_channel *ch = device_get_softc(dev); 92 int error; 93 94 error = ata_pci_ch_attach(dev); 95 ch->dma.alignment = 16; 96 ch->dma.max_iosize = 64 * DEV_BSIZE; 97 return (error); 98} |
99 | 99 |
100 mode = ata_limit_mode(dev, mode, ATA_UDMA2); | |
101 | 100 |
102 error = ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode); | 101static int 102ata_cyrix_setmode(device_t dev, int target, int mode) 103{ 104 struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); 105 struct ata_channel *ch = device_get_softc(dev); 106 int devno = (ch->unit << 1) + target; 107 int piomode; 108 u_int32_t piotiming[] = 109 { 0x00009172, 0x00012171, 0x00020080, 0x00032010, 0x00040010 }; 110 u_int32_t dmatiming[] = { 0x00077771, 0x00012121, 0x00002020 }; 111 u_int32_t udmatiming[] = { 0x00921250, 0x00911140, 0x00911030 }; |
103 | 112 |
104 if (bootverbose) 105 device_printf(dev, "%ssetting %s on Cyrix chip\n", 106 (error) ? "FAILURE " : "", ata_mode2str(mode)); 107 108 if (!error) { | 113 mode = min(mode, ATA_UDMA2); |
109 /* dont try to set the mode if we dont have the resource */ 110 if (ctlr->r_res1) { | 114 /* dont try to set the mode if we dont have the resource */ 115 if (ctlr->r_res1) { |
111 ch->dma.alignment = 16; 112 ch->dma.max_iosize = 64 * DEV_BSIZE; 113 114 if (mode >= ATA_UDMA0) { | 116 if (mode >= ATA_UDMA0) { 117 /* Set UDMA timings, and PIO4. */ 118 ATA_OUTL(ch->r_io[ATA_BMCMD_PORT].res, 119 0x24 + (devno << 3), udmatiming[mode & ATA_MODE_MASK]); 120 piomode = ATA_PIO4; 121 } else if (mode >= ATA_WDMA0) { 122 /* Set WDMA timings, and respective PIO mode. */ 123 ATA_OUTL(ch->r_io[ATA_BMCMD_PORT].res, 124 0x24 + (devno << 3), dmatiming[mode & ATA_MODE_MASK]); 125 piomode = (mode == ATA_WDMA0) ? ATA_PIO0 : 126 (mode == ATA_WDMA1) ? ATA_PIO3 : ATA_PIO4; 127 } else 128 piomode = mode; 129 /* Set PIO mode calculated above. */ |
115 ATA_OUTL(ch->r_io[ATA_BMCMD_PORT].res, | 130 ATA_OUTL(ch->r_io[ATA_BMCMD_PORT].res, |
116 0x24 + (devno << 3), udmatiming[mode & ATA_MODE_MASK]); 117 } 118 else if (mode >= ATA_WDMA0) { 119 ATA_OUTL(ch->r_io[ATA_BMCMD_PORT].res, 120 0x24 + (devno << 3), dmatiming[mode & ATA_MODE_MASK]); 121 } 122 else { 123 ATA_OUTL(ch->r_io[ATA_BMCMD_PORT].res, 124 0x20 + (devno << 3), piotiming[mode & ATA_MODE_MASK]); 125 } | 131 0x20 + (devno << 3), piotiming[ata_mode2idx(piomode)]); |
126 } | 132 } |
127 atadev->mode = mode; 128 } | 133 return (mode); |
129} 130 131ATA_DECLARE_DRIVER(ata_cyrix); | 134} 135 136ATA_DECLARE_DRIVER(ata_cyrix); |