1 /* $NetBSD: pccons_isa.c,v 1.9 2008/07/05 08:46:25 tsutsui Exp $ */
2 /* NetBSD: vga_isa.c,v 1.4 2000/08/14 20:14:51 thorpej Exp */
5 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
8 * Author: Chris G. Demetriou
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.
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.
20 * Carnegie Mellon requests users of this software to return to
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: pccons_isa.c,v 1.9 2008/07/05 08:46:25 tsutsui Exp $");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
38 #include <machine/bus.h>
40 #include <dev/isa/isavar.h>
42 #include <arc/dev/pcconsvar.h>
43 #include <arc/isa/pccons_isavar.h>
45 static int pccons_isa_match(device_t
, cfdata_t
, void *);
46 static void pccons_isa_attach(device_t
, device_t
, void *);
48 CFATTACH_DECL_NEW(pc_isa
, sizeof(struct pc_softc
),
49 pccons_isa_match
, pccons_isa_attach
, NULL
, NULL
);
51 struct pccons_config
*pccons_isa_conf
;
54 pccons_isa_match(device_t parent
, cfdata_t cf
, void *aux
)
56 struct isa_attach_args
*ia
= aux
;
57 bus_addr_t iobase
= 0x3b0; /* XXX mono 0x3b0 color 0x3c0 */
58 bus_size_t iosize
= 0x30; /* XXX 0x20 */
59 bus_addr_t maddr
= 0xa0000;
60 bus_size_t msize
= 0x20000;
65 if (ia
->ia_io
[0].ir_addr
!= ISA_UNKNOWN_PORT
)
66 iobase
= ia
->ia_io
[0].ir_addr
;
68 if (ia
->ia_iosize
!= 0)
69 iosize
= ia
->ia_iosize
;
71 if (ia
->ia_niomem
< 1)
73 if (ia
->ia_iomem
[0].ir_addr
!= ISA_UNKNOWN_IOMEM
)
74 maddr
= ia
->ia_iomem
[0].ir_addr
;
75 if (ia
->ia_iomem
[0].ir_size
!= ISA_UNKNOWN_IOSIZ
)
76 msize
= ia
->ia_iomem
[0].ir_size
;
80 if (ia
->ia_irq
[0].ir_irq
!= ISA_UNKNOWN_IRQ
)
81 irq
= ia
->ia_irq
[0].ir_irq
;
84 /* If values are hardwired to something that they can't be, punt. */
85 if (iobase
!= 0x3b0 || iosize
!= 0x30 ||
86 maddr
!= 0xa0000 || msize
!= 0x20000 ||
87 ia
->ia_irq
!= 1 || ia
->ia_drq
!= DRQUNK
)
91 if (pccons_isa_conf
== NULL
)
94 if (!pccons_common_match(ia
->ia_iot
, ia
->ia_memt
, ia
->ia_iot
,
99 ia
->ia_io
[0].ir_addr
= iobase
;
100 ia
->ia_io
[0].ir_size
= iosize
;
103 ia
->ia_iomem
[0].ir_addr
= maddr
;
104 ia
->ia_iomem
[0].ir_size
= msize
;
107 ia
->ia_irq
[0].ir_irq
= irq
;
115 pccons_isa_attach(device_t parent
, device_t self
, void *aux
)
117 struct pc_softc
*sc
= device_private(self
);
118 struct isa_attach_args
*ia
= aux
;
122 isa_intr_establish(ia
->ia_ic
, ia
->ia_irq
[0].ir_irq
, IST_EDGE
, IPL_TTY
,
124 pccons_common_attach(sc
, ia
->ia_iot
, ia
->ia_memt
, ia
->ia_iot
,
129 pccons_isa_cnattach(bus_space_tag_t iot
, bus_space_tag_t memt
)
132 if (pccons_isa_conf
== NULL
)
135 pccons_common_cnattach(iot
, memt
, iot
, pccons_isa_conf
);