| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: unixbp.c,v 1.5 2002/10/02 03:25:47 thorpej Exp $ */ | | 1 | /* $NetBSD: unixbp.c,v 1.6 2009/01/04 00:36:00 bjh21 Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2000 Ben Harris | | 4 | * Copyright (c) 2000 Ben Harris |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -22,86 +22,87 @@ | | | @@ -22,86 +22,87 @@ |
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | /* | | 29 | /* |
30 | * unixbp.c - driver for the Unix Backplane, found in the R140 etc | | 30 | * unixbp.c - driver for the Unix Backplane, found in the R140 etc |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/param.h> | | 33 | #include <sys/param.h> |
34 | | | 34 | |
35 | __KERNEL_RCSID(0, "$NetBSD: unixbp.c,v 1.5 2002/10/02 03:25:47 thorpej Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: unixbp.c,v 1.6 2009/01/04 00:36:00 bjh21 Exp $"); |
36 | | | 36 | |
37 | #include <sys/device.h> | | 37 | #include <sys/device.h> |
38 | #include <sys/systm.h> | | 38 | #include <sys/systm.h> |
39 | #include <machine/bus.h> | | 39 | #include <machine/bus.h> |
40 | #include <arch/acorn26/iobus/iocvar.h> | | 40 | #include <arch/acorn26/iobus/iocvar.h> |
41 | #include <arch/acorn26/podulebus/unixbpreg.h> | | 41 | #include <arch/acorn26/podulebus/unixbpreg.h> |
42 | #include <arch/acorn26/podulebus/unixbpvar.h> | | 42 | #include <arch/acorn26/podulebus/unixbpvar.h> |
43 | | | 43 | |
44 | struct unixbp_softc { | | 44 | struct unixbp_softc { |
45 | struct device sc_dev; | | 45 | device_t sc_dev; |
46 | bus_space_tag_t sc_iot; | | 46 | bus_space_tag_t sc_iot; |
47 | bus_space_handle_t sc_ioh; | | 47 | bus_space_handle_t sc_ioh; |
48 | }; | | 48 | }; |
49 | | | 49 | |
50 | static int unixbp_match(struct device *, struct cfdata *, void *); | | 50 | static int unixbp_match(device_t, cfdata_t, void *); |
51 | static void unixbp_attach(struct device *, struct device *, void *); | | 51 | static void unixbp_attach(device_t, device_t, void *); |
52 | | | 52 | |
53 | CFATTACH_DECL(unixbp, sizeof(struct unixbp_softc), | | 53 | CFATTACH_DECL_NEW(unixbp, sizeof(struct unixbp_softc), |
54 | unixbp_match, unixbp_attach, NULL, NULL); | | 54 | unixbp_match, unixbp_attach, NULL, NULL); |
55 | | | 55 | |
56 | struct device *the_unixbp; | | 56 | device_t the_unixbp; |
57 | | | 57 | |
58 | static int | | 58 | static int |
59 | unixbp_match(struct device *parent, struct cfdata *cf, void *aux) | | 59 | unixbp_match(device_t parent, cfdata_t cf, void *aux) |
60 | { | | 60 | { |
61 | struct ioc_attach_args *ioc = aux; | | 61 | struct ioc_attach_args *ioc = aux; |
62 | bus_space_tag_t bst = ioc->ioc_fast_t; | | 62 | bus_space_tag_t bst = ioc->ioc_fast_t; |
63 | bus_space_handle_t bsh = ioc->ioc_fast_h; | | 63 | bus_space_handle_t bsh = ioc->ioc_fast_h; |
64 | | | 64 | |
65 | /* Ask to disable all interrupts and check the request lines go low. */ | | 65 | /* Ask to disable all interrupts and check the request lines go low. */ |
66 | bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0); | | 66 | bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0); |
67 | if ((bus_space_read_1(bst, bsh, UNIXBP_REG_REQUEST) & 0xf) != 0) | | 67 | if ((bus_space_read_1(bst, bsh, UNIXBP_REG_REQUEST) & 0xf) != 0) |
68 | return 0; | | 68 | return 0; |
69 | /* Re-enable interrupts. */ | | 69 | /* Re-enable interrupts. */ |
70 | bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0xf); | | 70 | bus_space_write_1(bst, bsh, UNIXBP_REG_MASK, 0xf); |
71 | return 1; | | 71 | return 1; |
72 | } | | 72 | } |
73 | | | 73 | |
74 | static void | | 74 | static void |
75 | unixbp_attach(struct device *parent, struct device *self, void *aux) | | 75 | unixbp_attach(device_t parent, device_t self, void *aux) |
76 | { | | 76 | { |
77 | struct ioc_attach_args *ioc = aux; | | 77 | struct ioc_attach_args *ioc = aux; |
78 | struct unixbp_softc *sc = (void *)self; | | 78 | struct unixbp_softc *sc = device_private(self); |
79 | | | 79 | |
| | | 80 | sc->sc_dev = self; |
80 | if (the_unixbp == NULL) | | 81 | if (the_unixbp == NULL) |
81 | the_unixbp = self; | | 82 | the_unixbp = self; |
82 | sc->sc_iot = ioc->ioc_fast_t; | | 83 | sc->sc_iot = ioc->ioc_fast_t; |
83 | sc->sc_ioh = ioc->ioc_fast_h; | | 84 | sc->sc_ioh = ioc->ioc_fast_h; |
84 | | | 85 | |
85 | printf("\n"); | | 86 | aprint_normal("\n"); |
86 | } | | 87 | } |
87 | | | 88 | |
88 | int | | 89 | int |
89 | unixbp_irq_status_full() | | 90 | unixbp_irq_status_full() |
90 | { | | 91 | { |
91 | struct unixbp_softc *sc = (void *)the_unixbp; | | 92 | struct unixbp_softc *sc = device_private(the_unixbp); |
92 | | | 93 | |
93 | if (sc == NULL) | | 94 | if (sc == NULL) |
94 | return 0; | | 95 | return 0; |
95 | return bus_space_read_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_REQUEST) | | 96 | return bus_space_read_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_REQUEST) |
96 | & 0xf; | | 97 | & 0xf; |
97 | } | | 98 | } |
98 | | | 99 | |
99 | void | | 100 | void |
100 | unixbp_irq_setmask(int mask) | | 101 | unixbp_irq_setmask(int mask) |
101 | { | | 102 | { |
102 | struct unixbp_softc *sc = (void *)the_unixbp; | | 103 | struct unixbp_softc *sc = device_private(the_unixbp); |
103 | | | 104 | |
104 | if (sc == NULL) | | 105 | if (sc == NULL) |
105 | return; | | 106 | return; |
106 | bus_space_write_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_MASK, mask & 0xf); | | 107 | bus_space_write_1(sc->sc_iot, sc->sc_ioh, UNIXBP_REG_MASK, mask & 0xf); |
107 | } | | 108 | } |