xref: /freebsd/sys/dev/ata/ata-isa.c (revision bb5bdd38)
1331c488dSSøren Schmidt /*-
2bb5bdd38SSøren Schmidt  * Copyright (c) 1998 - 2003 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 
31b5d0be89SPeter Wemm #include "opt_ata.h"
32b5d0be89SPeter Wemm 
33331c488dSSøren Schmidt #include <sys/param.h>
34331c488dSSøren Schmidt #include <sys/systm.h>
35331c488dSSøren Schmidt #include <sys/kernel.h>
36331c488dSSøren Schmidt #include <sys/module.h>
37331c488dSSøren Schmidt #include <sys/bus.h>
38331c488dSSøren Schmidt #include <sys/malloc.h>
39331c488dSSøren Schmidt #include <machine/stdarg.h>
40331c488dSSøren Schmidt #include <machine/resource.h>
41331c488dSSøren Schmidt #include <machine/bus.h>
42331c488dSSøren Schmidt #include <sys/rman.h>
43331c488dSSøren Schmidt #include <isa/isavar.h>
44331c488dSSøren Schmidt #include <dev/ata/ata-all.h>
45331c488dSSøren Schmidt 
46331c488dSSøren Schmidt /* local vars */
47331c488dSSøren Schmidt static struct isa_pnp_id ata_ids[] = {
48331c488dSSøren Schmidt     {0x0006d041,	"Generic ESDI/IDE/ATA controller"},	/* PNP0600 */
49331c488dSSøren Schmidt     {0x0106d041,	"Plus Hardcard II"},			/* PNP0601 */
50331c488dSSøren Schmidt     {0x0206d041,	"Plus Hardcard IIXL/EZ"},		/* PNP0602 */
51331c488dSSøren Schmidt     {0x0306d041,	"Generic ATA"},				/* PNP0603 */
52bb5bdd38SSøren Schmidt 								/* PNP0680 */
53bb5bdd38SSøren Schmidt     {0x8006d041,	"Standard bus mastering IDE hard disk controller"},
54331c488dSSøren Schmidt     {0}
55331c488dSSøren Schmidt };
56331c488dSSøren Schmidt 
578ba4488cSSøren Schmidt static void
588ba4488cSSøren Schmidt ata_isa_lock(struct ata_channel *ch, int type)
598ba4488cSSøren Schmidt {
608ba4488cSSøren Schmidt }
618ba4488cSSøren Schmidt 
628ba4488cSSøren Schmidt static int
63331c488dSSøren Schmidt ata_isa_probe(device_t dev)
64331c488dSSøren Schmidt {
656ddce903SSøren Schmidt     struct ata_channel *ch = device_get_softc(dev);
66331c488dSSøren Schmidt     struct resource *io;
67331c488dSSøren Schmidt     u_long tmp;
686ddce903SSøren Schmidt     int rid;
69331c488dSSøren Schmidt 
70331c488dSSøren Schmidt     /* check isapnp ids */
71331c488dSSøren Schmidt     if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO)
72331c488dSSøren Schmidt 	return ENXIO;
73331c488dSSøren Schmidt 
748ba4488cSSøren Schmidt     /* allocate the io port range */
75331c488dSSøren Schmidt     rid = ATA_IOADDR_RID;
76331c488dSSøren Schmidt     io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
77331c488dSSøren Schmidt 			    ATA_IOSIZE, RF_ACTIVE);
78331c488dSSøren Schmidt     if (!io)
79331c488dSSøren Schmidt 	return ENOMEM;
80331c488dSSøren Schmidt 
81331c488dSSøren Schmidt     /* set the altport range */
82331c488dSSøren Schmidt     if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, &tmp, &tmp)) {
83331c488dSSøren Schmidt 	bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID,
84331c488dSSøren Schmidt 			 rman_get_start(io) + ATA_ALTOFFSET, ATA_ALTIOSIZE);
85331c488dSSøren Schmidt     }
86331c488dSSøren Schmidt 
87331c488dSSøren Schmidt     bus_release_resource(dev, SYS_RES_IOPORT, rid, io);
886ddce903SSøren Schmidt     ch->unit = 0;
896ddce903SSøren Schmidt     ch->flags |= ATA_USE_16BIT;
90bb5bdd38SSøren Schmidt     ch->locking = ata_isa_lock;
91331c488dSSøren Schmidt     return ata_probe(dev);
92331c488dSSøren Schmidt }
93331c488dSSøren Schmidt 
94331c488dSSøren Schmidt static device_method_t ata_isa_methods[] = {
95331c488dSSøren Schmidt     /* device interface */
96331c488dSSøren Schmidt     DEVMETHOD(device_probe,	ata_isa_probe),
97331c488dSSøren Schmidt     DEVMETHOD(device_attach,	ata_attach),
98331c488dSSøren Schmidt     DEVMETHOD(device_resume,	ata_resume),
99331c488dSSøren Schmidt     { 0, 0 }
100331c488dSSøren Schmidt };
101331c488dSSøren Schmidt 
102331c488dSSøren Schmidt static driver_t ata_isa_driver = {
103331c488dSSøren Schmidt     "ata",
104331c488dSSøren Schmidt     ata_isa_methods,
1056ddce903SSøren Schmidt     sizeof(struct ata_channel),
106331c488dSSøren Schmidt };
107331c488dSSøren Schmidt 
108331c488dSSøren Schmidt DRIVER_MODULE(ata, isa, ata_isa_driver, ata_devclass, 0, 0);
109312ec441SSøren Schmidt 
110312ec441SSøren Schmidt /*
111312ec441SSøren Schmidt  * the following is a bandaid to get ISA only setups to link,
112312ec441SSøren Schmidt  * since these are getting rare the ugliness is kept here
113312ec441SSøren Schmidt  */
114b5d0be89SPeter Wemm #ifdef ATA_NOPCI
1157800211bSSøren Schmidt int
1167800211bSSøren Schmidt ata_dmaalloc(struct ata_device *atadev)
117312ec441SSøren Schmidt {
1187800211bSSøren Schmidt     return ENXIO;
119312ec441SSøren Schmidt }
120312ec441SSøren Schmidt 
121312ec441SSøren Schmidt void
1227800211bSSøren Schmidt ata_dmafree(struct ata_device *atadev)
1237800211bSSøren Schmidt {
1247800211bSSøren Schmidt }
1257800211bSSøren Schmidt 
1267800211bSSøren Schmidt void
1277800211bSSøren Schmidt ata_dmafreetags(struct ata_channel *ch)
1287800211bSSøren Schmidt {
1297800211bSSøren Schmidt }
1307800211bSSøren Schmidt 
1317800211bSSøren Schmidt void
1327800211bSSøren Schmidt ata_dmainit(struct ata_device *atadev, int piomode, int wdmamode, int udmamode)
133312ec441SSøren Schmidt {
134312ec441SSøren Schmidt }
135312ec441SSøren Schmidt 
136312ec441SSøren Schmidt int
1377800211bSSøren Schmidt ata_dmasetup(struct ata_device *atadev, caddr_t data, int32_t count)
138312ec441SSøren Schmidt {
139312ec441SSøren Schmidt     return -1;
140312ec441SSøren Schmidt }
141312ec441SSøren Schmidt 
142b5d0be89SPeter Wemm int
143091a610aSSøren Schmidt ata_dmastart(struct ata_device *atadev, caddr_t data, int32_t count, int dir)
144312ec441SSøren Schmidt {
145b5d0be89SPeter Wemm     return -1;
146312ec441SSøren Schmidt }
147312ec441SSøren Schmidt 
148312ec441SSøren Schmidt int
1497800211bSSøren Schmidt ata_dmadone(struct ata_device *atadev)
150312ec441SSøren Schmidt {
151312ec441SSøren Schmidt     return -1;
152312ec441SSøren Schmidt }
153312ec441SSøren Schmidt 
154312ec441SSøren Schmidt int
1556ddce903SSøren Schmidt ata_dmastatus(struct ata_channel *ch)
156312ec441SSøren Schmidt {
157312ec441SSøren Schmidt     return -1;
158312ec441SSøren Schmidt }
159312ec441SSøren Schmidt #endif
160