| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: iomdkbc.c,v 1.6 2019/11/10 21:16:23 chs Exp $ */ | | 1 | /* $NetBSD: iomdkbc.c,v 1.7 2020/11/20 18:18:51 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2004 Ben Harris | | 4 | * Copyright (c) 2004 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. |
| @@ -18,31 +18,31 @@ | | | @@ -18,31 +18,31 @@ |
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
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 | #include <sys/cdefs.h> | | 30 | #include <sys/cdefs.h> |
31 | __KERNEL_RCSID(0, "$NetBSD: iomdkbc.c,v 1.6 2019/11/10 21:16:23 chs Exp $"); | | 31 | __KERNEL_RCSID(0, "$NetBSD: iomdkbc.c,v 1.7 2020/11/20 18:18:51 thorpej Exp $"); |
32 | | | 32 | |
33 | #include <sys/param.h> | | 33 | #include <sys/param.h> |
34 | #include <sys/device.h> | | 34 | #include <sys/device.h> |
35 | #include <sys/malloc.h> | | 35 | #include <sys/kmem.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | | | 37 | |
38 | #include <dev/pckbport/pckbportvar.h> | | 38 | #include <dev/pckbport/pckbportvar.h> |
39 | | | 39 | |
40 | #include <sys/bus.h> | | 40 | #include <sys/bus.h> |
41 | #include <machine/intr.h> | | 41 | #include <machine/intr.h> |
42 | | | 42 | |
43 | #include <arch/arm/iomd/iomdreg.h> | | 43 | #include <arch/arm/iomd/iomdreg.h> |
44 | #include <arch/arm/iomd/iomdvar.h> | | 44 | #include <arch/arm/iomd/iomdvar.h> |
45 | #include <arch/arm/iomd/iomdkbcvar.h> | | 45 | #include <arch/arm/iomd/iomdkbcvar.h> |
46 | | | 46 | |
47 | /* XXX belongs in iomdreg.h */ | | 47 | /* XXX belongs in iomdreg.h */ |
48 | #define IOMDKBC_TXE 0x80 | | 48 | #define IOMDKBC_TXE 0x80 |
| @@ -123,46 +123,46 @@ iomdkbc_attach(device_t parent, device_t | | | @@ -123,46 +123,46 @@ iomdkbc_attach(device_t parent, device_t |
123 | struct iomdkbc_softc *sc = device_private(self); | | 123 | struct iomdkbc_softc *sc = device_private(self); |
124 | struct iomdkbc_internal *t; | | 124 | struct iomdkbc_internal *t; |
125 | | | 125 | |
126 | sc->sc_dev = self; | | 126 | sc->sc_dev = self; |
127 | aprint_normal("\n"); | | 127 | aprint_normal("\n"); |
128 | | | 128 | |
129 | t = NULL; | | 129 | t = NULL; |
130 | if (strcmp(ka->ka_name, "kbd") == 0) { | | 130 | if (strcmp(ka->ka_name, "kbd") == 0) { |
131 | /* XXX not really right, but good enough. */ | | 131 | /* XXX not really right, but good enough. */ |
132 | if (iomdkbc_cntag.t_haveport[PCKBPORT_KBD_SLOT]) { | | 132 | if (iomdkbc_cntag.t_haveport[PCKBPORT_KBD_SLOT]) { |
133 | /* Have an iomdkbc as console. Assume it's this one.*/ | | 133 | /* Have an iomdkbc as console. Assume it's this one.*/ |
134 | t = &iomdkbc_cntag; | | 134 | t = &iomdkbc_cntag; |
135 | } else { | | 135 | } else { |
136 | t = malloc(sizeof(struct iomdkbc_internal), M_DEVBUF, | | 136 | t = kmem_zalloc(sizeof(struct iomdkbc_internal), |
137 | M_WAITOK | M_ZERO); | | 137 | KM_SLEEP); |
138 | t->t_haveport[PCKBPORT_KBD_SLOT] = 1; | | 138 | t->t_haveport[PCKBPORT_KBD_SLOT] = 1; |
139 | t->t_iot = ka->ka_iot; | | 139 | t->t_iot = ka->ka_iot; |
140 | t->t_ioh[PCKBPORT_KBD_SLOT] = ka->ka_ioh; | | 140 | t->t_ioh[PCKBPORT_KBD_SLOT] = ka->ka_ioh; |
141 | } | | 141 | } |
142 | t->t_rxih[PCKBPORT_KBD_SLOT] = intr_claim(ka->ka_rxirq, | | 142 | t->t_rxih[PCKBPORT_KBD_SLOT] = intr_claim(ka->ka_rxirq, |
143 | IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t); | | 143 | IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t); |
144 | t->t_rxirq[PCKBPORT_KBD_SLOT] = ka->ka_rxirq; | | 144 | t->t_rxirq[PCKBPORT_KBD_SLOT] = ka->ka_rxirq; |
145 | disable_irq(t->t_rxirq[PCKBPORT_KBD_SLOT]); | | 145 | disable_irq(t->t_rxirq[PCKBPORT_KBD_SLOT]); |
146 | sc->sc_id = t; | | 146 | sc->sc_id = t; |
147 | t->t_sc = sc; | | 147 | t->t_sc = sc; |
148 | t->t_pt = pckbport_attach(t, &iomdkbc_ops); | | 148 | t->t_pt = pckbport_attach(t, &iomdkbc_ops); |
149 | pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_KBD_SLOT); | | 149 | pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_KBD_SLOT); |
150 | } | | 150 | } |
151 | | | 151 | |
152 | if (strcmp(pa->pa_name, "opms") == 0) { | | 152 | if (strcmp(pa->pa_name, "opms") == 0) { |
153 | if (t == NULL) { | | 153 | if (t == NULL) { |
154 | t = malloc(sizeof(struct iomdkbc_internal), M_DEVBUF, | | 154 | t = kmem_zalloc(sizeof(struct iomdkbc_internal), |
155 | M_WAITOK | M_ZERO); | | 155 | KM_SLEEP); |
156 | } | | 156 | } |
157 | t->t_haveport[PCKBPORT_AUX_SLOT] = 1; | | 157 | t->t_haveport[PCKBPORT_AUX_SLOT] = 1; |
158 | t->t_iot = pa->pa_iot; | | 158 | t->t_iot = pa->pa_iot; |
159 | t->t_ioh[PCKBPORT_AUX_SLOT] = pa->pa_ioh; | | 159 | t->t_ioh[PCKBPORT_AUX_SLOT] = pa->pa_ioh; |
160 | t->t_rxih[PCKBPORT_AUX_SLOT] = intr_claim(pa->pa_irq, | | 160 | t->t_rxih[PCKBPORT_AUX_SLOT] = intr_claim(pa->pa_irq, |
161 | IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t); | | 161 | IPL_TTY, device_xname(sc->sc_dev), iomdkbc_intr, t); |
162 | t->t_rxirq[PCKBPORT_AUX_SLOT] = pa->pa_irq; | | 162 | t->t_rxirq[PCKBPORT_AUX_SLOT] = pa->pa_irq; |
163 | disable_irq(t->t_rxirq[PCKBPORT_AUX_SLOT]); | | 163 | disable_irq(t->t_rxirq[PCKBPORT_AUX_SLOT]); |
164 | sc->sc_id = t; | | 164 | sc->sc_id = t; |
165 | t->t_sc = sc; | | 165 | t->t_sc = sc; |
166 | if (t->t_pt == NULL) | | 166 | if (t->t_pt == NULL) |
167 | t->t_pt = pckbport_attach(t, &iomdkbc_ops); | | 167 | t->t_pt = pckbport_attach(t, &iomdkbc_ops); |
168 | pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_AUX_SLOT); | | 168 | pckbport_attach_slot(sc->sc_dev, t->t_pt, PCKBPORT_AUX_SLOT); |