pccons_isa.c revision 1.2 1 /* $NetBSD: pccons_isa.c,v 1.2 2002/01/07 21:46:57 thorpej Exp $ */
2 /* NetBSD: vga_isa.c,v 1.4 2000/08/14 20:14:51 thorpej Exp */
3
4 /*
5 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
6 * All rights reserved.
7 *
8 * Author: Chris G. Demetriou
9 *
10 * Permission to use, copy, modify and distribute this software and
11 * its documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
29 */
30
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/device.h>
34
35 #include <machine/bus.h>
36
37 #include <dev/isa/isavar.h>
38
39 #include <arc/dev/pcconsvar.h>
40 #include <arc/isa/pccons_isavar.h>
41
42 int pccons_isa_match __P((struct device *, struct cfdata *, void *));
43 void pccons_isa_attach __P((struct device *, struct device *, void *));
44
45 struct cfattach pc_isa_ca = {
46 sizeof(struct pc_softc), pccons_isa_match, pccons_isa_attach,
47 };
48
49 struct pccons_config *pccons_isa_conf;
50
51 int
52 pccons_isa_match(parent, match, aux)
53 struct device *parent;
54 struct cfdata *match;
55 void *aux;
56 {
57 struct isa_attach_args *ia = aux;
58 bus_addr_t iobase = 0x3b0; /* XXX mono 0x3b0 color 0x3c0 */
59 bus_size_t iosize = 0x30; /* XXX 0x20 */
60 bus_addr_t maddr = 0xa0000;
61 bus_size_t msize = 0x20000;
62 int irq = 1;
63
64 if (ia->ia_nio < 1)
65 return (0);
66 if (ia->ia_io[0].ir_addr != ISACF_PORT_DEFAULT)
67 iobase = ia->ia_io[0].ir_addr;
68 #if 0 /* XXX isa.c */
69 if (ia->ia_iosize != 0)
70 iosize = ia->ia_iosize;
71 #endif
72 if (ia->ia_niomem < 1)
73 return (0);
74 if (ia->ia_iomem[0].ir_addr != ISACF_IOMEM_DEFAULT)
75 maddr = ia->ia_iomem[0].ir_addr;
76 if (ia->ia_iomem[0].ir_size != ISACF_IOSIZ_DEFAULT)
77 msize = ia->ia_iomem[0].ir_size;
78
79 if (ia->ia_nirq < 1)
80 return (0);
81 if (ia->ia_irq[0].ir_irq != ISACF_IRQ_DEFAULT)
82 irq = ia->ia_irq[0].ir_irq;
83
84 #if 0
85 /* If values are hardwired to something that they can't be, punt. */
86 if (iobase != 0x3b0 || iosize != 0x30 ||
87 maddr != 0xa0000 || msize != 0x20000 ||
88 ia->ia_irq != 1 || ia->ia_drq != DRQUNK)
89 return (0);
90 #endif
91
92 if (pccons_isa_conf == NULL)
93 return (0);
94
95 if (!pccons_common_match(ia->ia_iot, ia->ia_memt, ia->ia_iot,
96 pccons_isa_conf))
97 return (0);
98
99 ia->ia_nio = 1;
100 ia->ia_io[0].ir_addr = iobase;
101 ia->ia_io[0].ir_size = iosize;
102
103 ia->ia_niomem = 1;
104 ia->ia_iomem[0].ir_addr = maddr;
105 ia->ia_iomem[0].ir_size = msize;
106
107 ia->ia_nirq = 1;
108 ia->ia_irq[0].ir_irq = irq;
109
110 ia->ia_ndrq = 0;
111
112 return (1);
113 }
114
115 void
116 pccons_isa_attach(parent, self, aux)
117 struct device *parent, *self;
118 void *aux;
119 {
120 struct pc_softc *sc = (struct pc_softc *)self;
121 struct isa_attach_args *ia = aux;
122
123 isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_TTY,
124 pcintr, self);
125 pccons_common_attach(sc, ia->ia_iot, ia->ia_memt, ia->ia_iot,
126 pccons_isa_conf);
127 }
128
129 int
130 pccons_isa_cnattach(iot, memt)
131 bus_space_tag_t iot, memt;
132 {
133 if (pccons_isa_conf == NULL)
134 return (ENXIO);
135
136 pccons_common_cnattach(iot, memt, iot, pccons_isa_conf);
137 return (0);
138 }
139