1 /* $NetBSD: attimer_isa.c,v 1.12 2009/05/12 08:44:19 cegger Exp $ */
4 * Copyright (c) 2005 The NetBSD Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
30 * Copyright (c) 1996 Carnegie-Mellon University.
31 * All rights reserved.
33 * Author: Chris G. Demetriou
35 * Permission to use, copy, modify and distribute this software and
36 * its documentation is hereby granted, provided that both the copyright
37 * notice and this permission notice appear in all copies of the
38 * software, derivative works or modified versions, and any portions
39 * thereof, and that both notices appear in supporting documentation.
41 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
42 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
43 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 * Carnegie Mellon requests users of this software to return to
47 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
48 * School of Computer Science
49 * Carnegie Mellon University
50 * Pittsburgh PA 15213-3890
52 * any improvements or extensions that they make and grant Carnegie the
53 * rights to redistribute these changes.
57 * ISA attachment for attimer(4)
60 #include <sys/cdefs.h>
61 __KERNEL_RCSID(0, "$NetBSD: attimer_isa.c,v 1.12 2009/05/12 08:44:19 cegger Exp $");
63 #include <sys/param.h>
64 #include <sys/systm.h>
65 #include <sys/errno.h>
66 #include <sys/ioctl.h>
67 #include <sys/device.h>
72 #include <dev/ic/attimervar.h>
74 #include <dev/isa/isareg.h>
75 #include <dev/isa/isavar.h>
77 static int attimer_isa_match(device_t
, cfdata_t
, void *);
78 static void attimer_isa_attach(device_t
, device_t
, void *);
80 CFATTACH_DECL_NEW(attimer_isa
, sizeof(struct attimer_softc
),
81 attimer_isa_match
, attimer_isa_attach
, attimer_detach
, NULL
);
84 attimer_isa_match(device_t parent
, cfdata_t match
, void *aux
)
86 struct isa_attach_args
*ia
= aux
;
87 bus_space_handle_t att_ioh
;
89 if (ISA_DIRECT_CONFIG(ia
))
92 /* If values are hardwired to something that they can't be, punt. */
94 (ia
->ia_io
[0].ir_addr
!= ISA_UNKNOWN_PORT
&&
95 ia
->ia_io
[0].ir_addr
!= IO_TIMER1
))
98 if (ia
->ia_niomem
> 0 &&
99 (ia
->ia_iomem
[0].ir_addr
!= ISA_UNKNOWN_IOMEM
))
102 if (ia
->ia_nirq
> 0 &&
103 (ia
->ia_irq
[0].ir_irq
!= ISA_UNKNOWN_IRQ
))
106 if (ia
->ia_ndrq
> 0 &&
107 (ia
->ia_drq
[0].ir_drq
!= ISA_UNKNOWN_DRQ
))
110 if (bus_space_map(ia
->ia_iot
, IO_TIMER1
, 4, 0, &att_ioh
))
112 bus_space_unmap(ia
->ia_iot
, att_ioh
, 4);
114 ia
->ia_io
[0].ir_addr
= IO_TIMER1
;
115 ia
->ia_io
[0].ir_size
= 4;
126 attimer_isa_attach(device_t parent
, device_t self
, void *aux
)
128 struct attimer_softc
*sc
= device_private(self
);
129 struct isa_attach_args
*ia
= aux
;
132 sc
->sc_iot
= ia
->ia_iot
;
138 if (bus_space_map(sc
->sc_iot
, IO_TIMER1
, sc
->sc_size
, 0,
140 aprint_error_dev(self
, "could not map registers\n");