xref: /freebsd/sys/dev/ata/ata-isa.c (revision 6ddce903)
1331c488dSSøren Schmidt /*-
26ddce903SSøren Schmidt  * Copyright (c) 1998,1999,2000,2001,2002 S�ren Schmidt <sos@FreeBSD.org>
3331c488dSSøren Schmidt  * All rights reserved.
4331c488dSSøren Schmidt  *
5331c488dSSøren Schmidt  * Redistribution and use in source and binary forms, with or without
6331c488dSSøren Schmidt  * modification, are permitted provided that the following conditions
7331c488dSSøren Schmidt  * are met:
8331c488dSSøren Schmidt  * 1. Redistributions of source code must retain the above copyright
9331c488dSSøren Schmidt  *    notice, this list of conditions and the following disclaimer,
10331c488dSSøren Schmidt  *    without modification, immediately at the beginning of the file.
11331c488dSSøren Schmidt  * 2. Redistributions in binary form must reproduce the above copyright
12331c488dSSøren Schmidt  *    notice, this list of conditions and the following disclaimer in the
13331c488dSSøren Schmidt  *    documentation and/or other materials provided with the distribution.
14331c488dSSøren Schmidt  * 3. The name of the author may not be used to endorse or promote products
15331c488dSSøren Schmidt  *    derived from this software without specific prior written permission.
16331c488dSSøren Schmidt  *
17331c488dSSøren Schmidt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18331c488dSSøren Schmidt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19331c488dSSøren Schmidt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20331c488dSSøren Schmidt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21331c488dSSøren Schmidt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22331c488dSSøren Schmidt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23331c488dSSøren Schmidt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24331c488dSSøren Schmidt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25331c488dSSøren Schmidt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26331c488dSSøren Schmidt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27331c488dSSøren Schmidt  *
28331c488dSSøren Schmidt  * $FreeBSD$
29331c488dSSøren Schmidt  */
30331c488dSSøren Schmidt 
31331c488dSSøren Schmidt #include <sys/param.h>
32331c488dSSøren Schmidt #include <sys/systm.h>
33331c488dSSøren Schmidt #include <sys/kernel.h>
34331c488dSSøren Schmidt #include <sys/disk.h>
35331c488dSSøren Schmidt #include <sys/module.h>
36331c488dSSøren Schmidt #include <sys/bus.h>
37331c488dSSøren Schmidt #include <sys/bio.h>
38331c488dSSøren Schmidt #include <sys/malloc.h>
39331c488dSSøren Schmidt #include <sys/devicestat.h>
40331c488dSSøren Schmidt #include <sys/sysctl.h>
41331c488dSSøren Schmidt #include <machine/stdarg.h>
42331c488dSSøren Schmidt #include <machine/resource.h>
43331c488dSSøren Schmidt #include <machine/bus.h>
44331c488dSSøren Schmidt #include <sys/rman.h>
45331c488dSSøren Schmidt #include <isa/isavar.h>
46331c488dSSøren Schmidt #include <dev/ata/ata-all.h>
47331c488dSSøren Schmidt 
48331c488dSSøren Schmidt /* local vars */
49331c488dSSøren Schmidt static struct isa_pnp_id ata_ids[] = {
50331c488dSSøren Schmidt     {0x0006d041,	"Generic ESDI/IDE/ATA controller"},	/* PNP0600 */
51331c488dSSøren Schmidt     {0x0106d041,	"Plus Hardcard II"},			/* PNP0601 */
52331c488dSSøren Schmidt     {0x0206d041,	"Plus Hardcard IIXL/EZ"},		/* PNP0602 */
53331c488dSSøren Schmidt     {0x0306d041,	"Generic ATA"},				/* PNP0603 */
54331c488dSSøren Schmidt     {0}
55331c488dSSøren Schmidt };
56331c488dSSøren Schmidt 
57331c488dSSøren Schmidt static int
58331c488dSSøren Schmidt ata_isa_probe(device_t dev)
59331c488dSSøren Schmidt {
606ddce903SSøren Schmidt     struct ata_channel *ch = device_get_softc(dev);
61331c488dSSøren Schmidt     struct resource *io;
62331c488dSSøren Schmidt     u_long tmp;
636ddce903SSøren Schmidt     int rid;
64331c488dSSøren Schmidt 
65331c488dSSøren Schmidt     /* check isapnp ids */
66331c488dSSøren Schmidt     if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO)
67331c488dSSøren Schmidt 	return ENXIO;
68331c488dSSøren Schmidt 
69331c488dSSøren Schmidt     /* allocate the io port range to get the start address */
70331c488dSSøren Schmidt     rid = ATA_IOADDR_RID;
71331c488dSSøren Schmidt     io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
72331c488dSSøren Schmidt 			    ATA_IOSIZE, RF_ACTIVE);
73331c488dSSøren Schmidt     if (!io)
74331c488dSSøren Schmidt 	return ENOMEM;
75331c488dSSøren Schmidt 
76331c488dSSøren Schmidt     /* set the altport range */
77331c488dSSøren Schmidt     if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, &tmp, &tmp)) {
78331c488dSSøren Schmidt 	bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID,
79331c488dSSøren Schmidt 			 rman_get_start(io) + ATA_ALTOFFSET, ATA_ALTIOSIZE);
80331c488dSSøren Schmidt     }
81331c488dSSøren Schmidt 
82331c488dSSøren Schmidt     bus_release_resource(dev, SYS_RES_IOPORT, rid, io);
836ddce903SSøren Schmidt     ch->unit = 0;
846ddce903SSøren Schmidt     ch->flags |= ATA_USE_16BIT;
85331c488dSSøren Schmidt     return ata_probe(dev);
86331c488dSSøren Schmidt }
87331c488dSSøren Schmidt 
88331c488dSSøren Schmidt static device_method_t ata_isa_methods[] = {
89331c488dSSøren Schmidt     /* device interface */
90331c488dSSøren Schmidt     DEVMETHOD(device_probe,	ata_isa_probe),
91331c488dSSøren Schmidt     DEVMETHOD(device_attach,	ata_attach),
92331c488dSSøren Schmidt     DEVMETHOD(device_resume,	ata_resume),
93331c488dSSøren Schmidt     { 0, 0 }
94331c488dSSøren Schmidt };
95331c488dSSøren Schmidt 
96331c488dSSøren Schmidt static driver_t ata_isa_driver = {
97331c488dSSøren Schmidt     "ata",
98331c488dSSøren Schmidt     ata_isa_methods,
996ddce903SSøren Schmidt     sizeof(struct ata_channel),
100331c488dSSøren Schmidt };
101331c488dSSøren Schmidt 
102331c488dSSøren Schmidt DRIVER_MODULE(ata, isa, ata_isa_driver, ata_devclass, 0, 0);
103312ec441SSøren Schmidt 
104312ec441SSøren Schmidt /*
105312ec441SSøren Schmidt  * the following is a bandaid to get ISA only setups to link,
106312ec441SSøren Schmidt  * since these are getting rare the ugliness is kept here
107312ec441SSøren Schmidt  */
108312ec441SSøren Schmidt #include "pci.h"
109312ec441SSøren Schmidt #if NPCI == 0
110312ec441SSøren Schmidt void *
1116ddce903SSøren Schmidt ata_dmaalloc(struct ata_channel *ch, int device)
112312ec441SSøren Schmidt {
113312ec441SSøren Schmidt     return 0;
114312ec441SSøren Schmidt }
115312ec441SSøren Schmidt 
116312ec441SSøren Schmidt void
1176ddce903SSøren Schmidt ata_dmainit(struct ata_channel *ch, int device,
118312ec441SSøren Schmidt 	    int piomode, int wdmamode, int udmamode)
119312ec441SSøren Schmidt {
120312ec441SSøren Schmidt }
121312ec441SSøren Schmidt 
122312ec441SSøren Schmidt int
1236ddce903SSøren Schmidt ata_dmasetup(struct ata_channel *ch, int device, struct ata_dmaentry *dmatab,
124312ec441SSøren Schmidt 	     caddr_t data, int32_t count)
125312ec441SSøren Schmidt {
126312ec441SSøren Schmidt     return -1;
127312ec441SSøren Schmidt }
128312ec441SSøren Schmidt 
129312ec441SSøren Schmidt void
1306ddce903SSøren Schmidt ata_dmastart(struct ata_channel *ch, int device,
131312ec441SSøren Schmidt 	     struct ata_dmaentry *dmatab, int dir)
132312ec441SSøren Schmidt {
133312ec441SSøren Schmidt }
134312ec441SSøren Schmidt 
135312ec441SSøren Schmidt int
1366ddce903SSøren Schmidt ata_dmadone(struct ata_channel *ch)
137312ec441SSøren Schmidt {
138312ec441SSøren Schmidt     return -1;
139312ec441SSøren Schmidt }
140312ec441SSøren Schmidt 
141312ec441SSøren Schmidt int
1426ddce903SSøren Schmidt ata_dmastatus(struct ata_channel *ch)
143312ec441SSøren Schmidt {
144312ec441SSøren Schmidt     return -1;
145312ec441SSøren Schmidt }
146312ec441SSøren Schmidt #endif
147