Use device_private() to get struct sbus_softc from device_t parent. XXX: sbus_softc has been split from device_t on sparc, but not on sparc64!?diff -r1.28 -r1.29 src/sys/dev/sbus/if_hme_sbus.c
(tsutsui)
--- src/sys/dev/sbus/if_hme_sbus.c 2009/05/12 14:43:59 1.28
+++ src/sys/dev/sbus/if_hme_sbus.c 2009/05/17 00:28:35 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_hme_sbus.c,v 1.28 2009/05/12 14:43:59 cegger Exp $ */ | 1 | /* $NetBSD: if_hme_sbus.c,v 1.29 2009/05/17 00:28:35 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Kranenburg. | 8 | * by Paul Kranenburg. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * SBus front-end device driver for the HME ethernet device. | 33 | * SBus front-end device driver for the HME ethernet device. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: if_hme_sbus.c,v 1.28 2009/05/12 14:43:59 cegger Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: if_hme_sbus.c,v 1.29 2009/05/17 00:28:35 tsutsui Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/syslog.h> | 41 | #include <sys/syslog.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | #include <sys/malloc.h> | 43 | #include <sys/malloc.h> | |
44 | #include <sys/socket.h> | 44 | #include <sys/socket.h> | |
45 | 45 | |||
46 | #include <net/if.h> | 46 | #include <net/if.h> | |
47 | #include <net/if_dl.h> | 47 | #include <net/if_dl.h> | |
48 | #include <net/if_ether.h> | 48 | #include <net/if_ether.h> | |
49 | #include <net/if_media.h> | 49 | #include <net/if_media.h> | |
50 | 50 | |||
@@ -75,26 +75,27 @@ hmematch_sbus(device_t parent, cfdata_t | @@ -75,26 +75,27 @@ hmematch_sbus(device_t parent, cfdata_t | |||
75 | struct sbus_attach_args *sa = aux; | 75 | struct sbus_attach_args *sa = aux; | |
76 | 76 | |||
77 | return (strcmp(cf->cf_name, sa->sa_name) == 0 || | 77 | return (strcmp(cf->cf_name, sa->sa_name) == 0 || | |
78 | strcmp("SUNW,qfe", sa->sa_name) == 0 || | 78 | strcmp("SUNW,qfe", sa->sa_name) == 0 || | |
79 | strcmp("SUNW,hme", sa->sa_name) == 0); | 79 | strcmp("SUNW,hme", sa->sa_name) == 0); | |
80 | } | 80 | } | |
81 | 81 | |||
82 | void | 82 | void | |
83 | hmeattach_sbus(device_t parent, device_t self, void *aux) | 83 | hmeattach_sbus(device_t parent, device_t self, void *aux) | |
84 | { | 84 | { | |
85 | struct sbus_attach_args *sa = aux; | 85 | struct sbus_attach_args *sa = aux; | |
86 | struct hmesbus_softc *hsc = (void *)self; | 86 | struct hmesbus_softc *hsc = (void *)self; | |
87 | struct hme_softc *sc = &hsc->hsc_hme; | 87 | struct hme_softc *sc = &hsc->hsc_hme; | |
88 | struct sbus_softc *sbsc = device_private(parent); | |||
88 | struct sbusdev *sd = &hsc->hsc_sbus; | 89 | struct sbusdev *sd = &hsc->hsc_sbus; | |
89 | u_int32_t burst, sbusburst; | 90 | u_int32_t burst, sbusburst; | |
90 | int node; | 91 | int node; | |
91 | 92 | |||
92 | node = sa->sa_node; | 93 | node = sa->sa_node; | |
93 | 94 | |||
94 | /* Pass on the bus tags */ | 95 | /* Pass on the bus tags */ | |
95 | sc->sc_bustag = sa->sa_bustag; | 96 | sc->sc_bustag = sa->sa_bustag; | |
96 | sc->sc_dmatag = sa->sa_dmatag; | 97 | sc->sc_dmatag = sa->sa_dmatag; | |
97 | 98 | |||
98 | printf(": Sun Happy Meal Ethernet (%s)\n", | 99 | printf(": Sun Happy Meal Ethernet (%s)\n", | |
99 | sa->sa_name); | 100 | sa->sa_name); | |
100 | 101 | |||
@@ -154,27 +155,27 @@ hmeattach_sbus(device_t parent, device_t | @@ -154,27 +155,27 @@ hmeattach_sbus(device_t parent, device_t | |||
154 | aprint_error_dev(self, "cannot map MIF registers\n"); | 155 | aprint_error_dev(self, "cannot map MIF registers\n"); | |
155 | return; | 156 | return; | |
156 | } | 157 | } | |
157 | 158 | |||
158 | sd->sd_reset = (void *)hme_reset; | 159 | sd->sd_reset = (void *)hme_reset; | |
159 | sbus_establish(sd, self); | 160 | sbus_establish(sd, self); | |
160 | 161 | |||
161 | prom_getether(node, sc->sc_enaddr); | 162 | prom_getether(node, sc->sc_enaddr); | |
162 | 163 | |||
163 | /* | 164 | /* | |
164 | * Get transfer burst size from PROM and pass it on | 165 | * Get transfer burst size from PROM and pass it on | |
165 | * to the back-end driver. | 166 | * to the back-end driver. | |
166 | */ | 167 | */ | |
167 | sbusburst = ((struct sbus_softc *)parent)->sc_burst; | 168 | sbusburst = sbsc->sc_burst; | |
168 | if (sbusburst == 0) | 169 | if (sbusburst == 0) | |
169 | sbusburst = SBUS_BURST_32 - 1; /* 1->16 */ | 170 | sbusburst = SBUS_BURST_32 - 1; /* 1->16 */ | |
170 | 171 | |||
171 | burst = prom_getpropint(node, "burst-sizes", -1); | 172 | burst = prom_getpropint(node, "burst-sizes", -1); | |
172 | if (burst == -1) | 173 | if (burst == -1) | |
173 | /* take SBus burst sizes */ | 174 | /* take SBus burst sizes */ | |
174 | burst = sbusburst; | 175 | burst = sbusburst; | |
175 | 176 | |||
176 | /* Clamp at parent's burst sizes */ | 177 | /* Clamp at parent's burst sizes */ | |
177 | burst &= sbusburst; | 178 | burst &= sbusburst; | |
178 | 179 | |||
179 | /* Translate into plain numerical format */ | 180 | /* Translate into plain numerical format */ | |
180 | sc->sc_burst = (burst & SBUS_BURST_32) ? 32 : | 181 | sc->sc_burst = (burst & SBUS_BURST_32) ? 32 : |
--- src/sys/dev/sbus/isp_sbus.c 2009/05/12 14:43:59 1.75
+++ src/sys/dev/sbus/isp_sbus.c 2009/05/17 00:28:35 1.76
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: isp_sbus.c,v 1.75 2009/05/12 14:43:59 cegger Exp $ */ | 1 | /* $NetBSD: isp_sbus.c,v 1.76 2009/05/17 00:28:35 tsutsui Exp $ */ | |
2 | /* | 2 | /* | |
3 | * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. | 3 | * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. | |
4 | * | 4 | * | |
5 | * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration | 5 | * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Additional Copyright (C) 2000-2007 by Matthew Jacob | 8 | * Additional Copyright (C) 2000-2007 by Matthew Jacob | |
9 | * All rights reserved. | 9 | * All rights reserved. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | * | 32 | * | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __KERNEL_RCSID(0, "$NetBSD: isp_sbus.c,v 1.75 2009/05/12 14:43:59 cegger Exp $"); | 36 | __KERNEL_RCSID(0, "$NetBSD: isp_sbus.c,v 1.76 2009/05/17 00:28:35 tsutsui Exp $"); | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/device.h> | 40 | #include <sys/device.h> | |
41 | #include <sys/kernel.h> | 41 | #include <sys/kernel.h> | |
42 | #include <sys/malloc.h> | 42 | #include <sys/malloc.h> | |
43 | #include <sys/queue.h> | 43 | #include <sys/queue.h> | |
44 | #include <dev/ic/isp_netbsd.h> | 44 | #include <dev/ic/isp_netbsd.h> | |
45 | #include <sys/intr.h> | 45 | #include <sys/intr.h> | |
46 | #include <machine/autoconf.h> | 46 | #include <machine/autoconf.h> | |
47 | #include <dev/sbus/sbusvar.h> | 47 | #include <dev/sbus/sbusvar.h> | |
48 | #include <sys/reboot.h> | 48 | #include <sys/reboot.h> | |
49 | 49 | |||
@@ -112,26 +112,27 @@ isp_match(device_t parent, cfdata_t cf, | @@ -112,26 +112,27 @@ isp_match(device_t parent, cfdata_t cf, | |||
112 | strcmp("SUNW,isp", sa->sa_name) == 0 || | 112 | strcmp("SUNW,isp", sa->sa_name) == 0 || | |
113 | strcmp("QLGC,isp", sa->sa_name) == 0); | 113 | strcmp("QLGC,isp", sa->sa_name) == 0); | |
114 | 114 | |||
115 | return (rv); | 115 | return (rv); | |
116 | } | 116 | } | |
117 | 117 | |||
118 | 118 | |||
119 | static void | 119 | static void | |
120 | isp_sbus_attach(device_t parent, device_t self, void *aux) | 120 | isp_sbus_attach(device_t parent, device_t self, void *aux) | |
121 | { | 121 | { | |
122 | int freq, ispburst, sbusburst; | 122 | int freq, ispburst, sbusburst; | |
123 | struct sbus_attach_args *sa = aux; | 123 | struct sbus_attach_args *sa = aux; | |
124 | struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) self; | 124 | struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) self; | |
125 | struct sbus_softc *sbsc = device_private(parent); | |||
125 | ispsoftc_t *isp = &sbc->sbus_isp; | 126 | ispsoftc_t *isp = &sbc->sbus_isp; | |
126 | 127 | |||
127 | printf(" for %s\n", sa->sa_name); | 128 | printf(" for %s\n", sa->sa_name); | |
128 | 129 | |||
129 | isp->isp_nchan = isp->isp_osinfo.adapter.adapt_nchannels = 1; | 130 | isp->isp_nchan = isp->isp_osinfo.adapter.adapt_nchannels = 1; | |
130 | 131 | |||
131 | sbc->sbus_bustag = sa->sa_bustag; | 132 | sbc->sbus_bustag = sa->sa_bustag; | |
132 | if (sa->sa_nintr != 0) | 133 | if (sa->sa_nintr != 0) | |
133 | sbc->sbus_pri = sa->sa_pri; | 134 | sbc->sbus_pri = sa->sa_pri; | |
134 | sbc->sbus_mdvec = mdvec; | 135 | sbc->sbus_mdvec = mdvec; | |
135 | 136 | |||
136 | if (sa->sa_npromvaddrs) { | 137 | if (sa->sa_npromvaddrs) { | |
137 | sbus_promaddr_to_handle(sa->sa_bustag, | 138 | sbus_promaddr_to_handle(sa->sa_bustag, | |
@@ -150,27 +151,27 @@ isp_sbus_attach(device_t parent, device_ | @@ -150,27 +151,27 @@ isp_sbus_attach(device_t parent, device_ | |||
150 | /* | 151 | /* | |
151 | * Convert from HZ to MHz, rounding up. | 152 | * Convert from HZ to MHz, rounding up. | |
152 | */ | 153 | */ | |
153 | freq = (freq + 500000)/1000000; | 154 | freq = (freq + 500000)/1000000; | |
154 | } | 155 | } | |
155 | sbc->sbus_mdvec.dv_clock = freq; | 156 | sbc->sbus_mdvec.dv_clock = freq; | |
156 | 157 | |||
157 | /* | 158 | /* | |
158 | * Now figure out what the proper burst sizes, etc., to use. | 159 | * Now figure out what the proper burst sizes, etc., to use. | |
159 | * Unfortunately, there is no ddi_dma_burstsizes here which | 160 | * Unfortunately, there is no ddi_dma_burstsizes here which | |
160 | * walks up the tree finding the limiting burst size node (if | 161 | * walks up the tree finding the limiting burst size node (if | |
161 | * any). | 162 | * any). | |
162 | */ | 163 | */ | |
163 | sbusburst = ((struct sbus_softc *)parent)->sc_burst; | 164 | sbusburst = sbsc->sc_burst; | |
164 | if (sbusburst == 0) | 165 | if (sbusburst == 0) | |
165 | sbusburst = SBUS_BURST_32 - 1; | 166 | sbusburst = SBUS_BURST_32 - 1; | |
166 | ispburst = prom_getpropint(sa->sa_node, "burst-sizes", -1); | 167 | ispburst = prom_getpropint(sa->sa_node, "burst-sizes", -1); | |
167 | if (ispburst == -1) { | 168 | if (ispburst == -1) { | |
168 | ispburst = sbusburst; | 169 | ispburst = sbusburst; | |
169 | } | 170 | } | |
170 | ispburst &= sbusburst; | 171 | ispburst &= sbusburst; | |
171 | ispburst &= ~(1 << 7); | 172 | ispburst &= ~(1 << 7); | |
172 | ispburst &= ~(1 << 6); | 173 | ispburst &= ~(1 << 6); | |
173 | sbc->sbus_mdvec.dv_conf1 = 0; | 174 | sbc->sbus_mdvec.dv_conf1 = 0; | |
174 | if (ispburst & (1 << 5)) { | 175 | if (ispburst & (1 << 5)) { | |
175 | sbc->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_32; | 176 | sbc->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_32; | |
176 | } else if (ispburst & (1 << 4)) { | 177 | } else if (ispburst & (1 << 4)) { |
--- src/sys/dev/sbus/lebuffer.c 2009/05/12 14:43:59 1.32
+++ src/sys/dev/sbus/lebuffer.c 2009/05/17 00:28:35 1.33
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lebuffer.c,v 1.32 2009/05/12 14:43:59 cegger Exp $ */ | 1 | /* $NetBSD: lebuffer.c,v 1.33 2009/05/17 00:28:35 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Kranenburg. | 8 | * by Paul Kranenburg. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: lebuffer.c,v 1.32 2009/05/12 14:43:59 cegger Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: lebuffer.c,v 1.33 2009/05/17 00:28:35 tsutsui Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/kernel.h> | 37 | #include <sys/kernel.h> | |
38 | #include <sys/errno.h> | 38 | #include <sys/errno.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/malloc.h> | 40 | #include <sys/malloc.h> | |
41 | 41 | |||
42 | #include <sys/bus.h> | 42 | #include <sys/bus.h> | |
43 | #include <machine/autoconf.h> | 43 | #include <machine/autoconf.h> | |
44 | #include <sys/cpu.h> | 44 | #include <sys/cpu.h> | |
45 | 45 | |||
46 | #include <dev/sbus/sbusvar.h> | 46 | #include <dev/sbus/sbusvar.h> | |
@@ -67,63 +67,64 @@ lebufmatch(device_t parent, cfdata_t cf, | @@ -67,63 +67,64 @@ lebufmatch(device_t parent, cfdata_t cf, | |||
67 | struct sbus_attach_args *sa = aux; | 67 | struct sbus_attach_args *sa = aux; | |
68 | 68 | |||
69 | return (strcmp(cf->cf_name, sa->sa_name) == 0); | 69 | return (strcmp(cf->cf_name, sa->sa_name) == 0); | |
70 | } | 70 | } | |
71 | 71 | |||
72 | /* | 72 | /* | |
73 | * Attach all the sub-devices we can find | 73 | * Attach all the sub-devices we can find | |
74 | */ | 74 | */ | |
75 | void | 75 | void | |
76 | lebufattach(device_t parent, device_t self, void *aux) | 76 | lebufattach(device_t parent, device_t self, void *aux) | |
77 | { | 77 | { | |
78 | struct sbus_attach_args *sa = aux; | 78 | struct sbus_attach_args *sa = aux; | |
79 | struct lebuf_softc *sc = (void *)self; | 79 | struct lebuf_softc *sc = (void *)self; | |
80 | struct sbus_softc *sbsc = device_private(parent); | |||
80 | int node; | 81 | int node; | |
81 | int sbusburst; | 82 | int sbusburst; | |
82 | bus_space_tag_t bt = sa->sa_bustag; | 83 | bus_space_tag_t bt = sa->sa_bustag; | |
83 | bus_dma_tag_t dt = sa->sa_dmatag; | 84 | bus_dma_tag_t dt = sa->sa_dmatag; | |
84 | bus_space_handle_t bh; | 85 | bus_space_handle_t bh; | |
85 | 86 | |||
86 | if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset, sa->sa_size, | 87 | if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset, sa->sa_size, | |
87 | BUS_SPACE_MAP_LINEAR, &bh) != 0) { | 88 | BUS_SPACE_MAP_LINEAR, &bh) != 0) { | |
88 | aprint_error_dev(self, "attach: cannot map registers\n"); | 89 | aprint_error_dev(self, "attach: cannot map registers\n"); | |
89 | return; | 90 | return; | |
90 | } | 91 | } | |
91 | 92 | |||
92 | /* | 93 | /* | |
93 | * This device's "register space" is just a buffer where the | 94 | * This device's "register space" is just a buffer where the | |
94 | * Lance ring-buffers can be stored. Note the buffer's location | 95 | * Lance ring-buffers can be stored. Note the buffer's location | |
95 | * and size, so the `le' driver can pick them up. | 96 | * and size, so the `le' driver can pick them up. | |
96 | */ | 97 | */ | |
97 | sc->sc_buffer = bus_space_vaddr(bt, bh); | 98 | sc->sc_buffer = bus_space_vaddr(bt, bh); | |
98 | sc->sc_bufsiz = sa->sa_size; | 99 | sc->sc_bufsiz = sa->sa_size; | |
99 | 100 | |||
100 | node = sc->sc_node = sa->sa_node; | 101 | node = sc->sc_node = sa->sa_node; | |
101 | 102 | |||
102 | /* | 103 | /* | |
103 | * Get transfer burst size from PROM | 104 | * Get transfer burst size from PROM | |
104 | */ | 105 | */ | |
105 | sbusburst = ((struct sbus_softc *)parent)->sc_burst; | 106 | sbusburst = sbsc->sc_burst; | |
106 | if (sbusburst == 0) | 107 | if (sbusburst == 0) | |
107 | sbusburst = SBUS_BURST_32 - 1; /* 1->16 */ | 108 | sbusburst = SBUS_BURST_32 - 1; /* 1->16 */ | |
108 | 109 | |||
109 | sc->sc_burst = prom_getpropint(node, "burst-sizes", -1); | 110 | sc->sc_burst = prom_getpropint(node, "burst-sizes", -1); | |
110 | if (sc->sc_burst == -1) | 111 | if (sc->sc_burst == -1) | |
111 | /* take SBus burst sizes */ | 112 | /* take SBus burst sizes */ | |
112 | sc->sc_burst = sbusburst; | 113 | sc->sc_burst = sbusburst; | |
113 | 114 | |||
114 | /* Clamp at parent's burst sizes */ | 115 | /* Clamp at parent's burst sizes */ | |
115 | sc->sc_burst &= sbusburst; | 116 | sc->sc_burst &= sbusburst; | |
116 | 117 | |||
117 | sbus_establish(&sc->sc_sd, &sc->sc_dev); | 118 | sbus_establish(&sc->sc_sd, &sc->sc_dev); | |
118 | 119 | |||
119 | printf(": %dK memory\n", sc->sc_bufsiz / 1024); | 120 | printf(": %dK memory\n", sc->sc_bufsiz / 1024); | |
120 | 121 | |||
121 | /* search through children */ | 122 | /* search through children */ | |
122 | for (node = firstchild(node); node; node = nextsibling(node)) { | 123 | for (node = firstchild(node); node; node = nextsibling(node)) { | |
123 | struct sbus_attach_args sax; | 124 | struct sbus_attach_args sax; | |
124 | sbus_setup_attach_args((struct sbus_softc *)parent, | 125 | sbus_setup_attach_args(sbsc, | |
125 | bt, dt, node, &sax); | 126 | bt, dt, node, &sax); | |
126 | (void)config_found(&sc->sc_dev, (void *)&sax, lebufprint); | 127 | (void)config_found(&sc->sc_dev, (void *)&sax, lebufprint); | |
127 | sbus_destroy_attach_args(&sax); | 128 | sbus_destroy_attach_args(&sax); | |
128 | } | 129 | } | |
129 | } | 130 | } |
--- src/sys/dev/sbus/qec.c 2009/05/12 14:43:59 1.43
+++ src/sys/dev/sbus/qec.c 2009/05/17 00:28:35 1.44
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: qec.c,v 1.43 2009/05/12 14:43:59 cegger Exp $ */ | 1 | /* $NetBSD: qec.c,v 1.44 2009/05/17 00:28:35 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Kranenburg. | 8 | * by Paul Kranenburg. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: qec.c,v 1.43 2009/05/12 14:43:59 cegger Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: qec.c,v 1.44 2009/05/17 00:28:35 tsutsui Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/kernel.h> | 37 | #include <sys/kernel.h> | |
38 | #include <sys/errno.h> | 38 | #include <sys/errno.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/malloc.h> | 40 | #include <sys/malloc.h> | |
41 | 41 | |||
42 | #include <sys/bus.h> | 42 | #include <sys/bus.h> | |
43 | #include <sys/intr.h> | 43 | #include <sys/intr.h> | |
44 | #include <machine/autoconf.h> | 44 | #include <machine/autoconf.h> | |
45 | 45 | |||
46 | #include <dev/sbus/sbusvar.h> | 46 | #include <dev/sbus/sbusvar.h> | |
@@ -89,26 +89,27 @@ qecmatch(device_t parent, cfdata_t cf, v | @@ -89,26 +89,27 @@ qecmatch(device_t parent, cfdata_t cf, v | |||
89 | struct sbus_attach_args *sa = aux; | 89 | struct sbus_attach_args *sa = aux; | |
90 | 90 | |||
91 | return (strcmp(cf->cf_name, sa->sa_name) == 0); | 91 | return (strcmp(cf->cf_name, sa->sa_name) == 0); | |
92 | } | 92 | } | |
93 | 93 | |||
94 | /* | 94 | /* | |
95 | * Attach all the sub-devices we can find | 95 | * Attach all the sub-devices we can find | |
96 | */ | 96 | */ | |
97 | void | 97 | void | |
98 | qecattach(device_t parent, device_t self, void *aux) | 98 | qecattach(device_t parent, device_t self, void *aux) | |
99 | { | 99 | { | |
100 | struct sbus_attach_args *sa = aux; | 100 | struct sbus_attach_args *sa = aux; | |
101 | struct qec_softc *sc = (void *)self; | 101 | struct qec_softc *sc = (void *)self; | |
102 | struct sbus_softc *sbsc = device_private(parent); | |||
102 | int node; | 103 | int node; | |
103 | int sbusburst; | 104 | int sbusburst; | |
104 | bus_space_tag_t sbt; | 105 | bus_space_tag_t sbt; | |
105 | bus_space_handle_t bh; | 106 | bus_space_handle_t bh; | |
106 | int error; | 107 | int error; | |
107 | 108 | |||
108 | sc->sc_bustag = sa->sa_bustag; | 109 | sc->sc_bustag = sa->sa_bustag; | |
109 | sc->sc_dmatag = sa->sa_dmatag; | 110 | sc->sc_dmatag = sa->sa_dmatag; | |
110 | node = sa->sa_node; | 111 | node = sa->sa_node; | |
111 | 112 | |||
112 | if (sa->sa_nreg < 2) { | 113 | if (sa->sa_nreg < 2) { | |
113 | printf("%s: only %d register sets\n", | 114 | printf("%s: only %d register sets\n", | |
114 | device_xname(self), sa->sa_nreg); | 115 | device_xname(self), sa->sa_nreg); | |
@@ -140,27 +141,27 @@ qecattach(device_t parent, device_t self | @@ -140,27 +141,27 @@ qecattach(device_t parent, device_t self | |||
140 | sc->sc_buffer = (void *)bus_space_vaddr(sa->sa_bustag, bh); | 141 | sc->sc_buffer = (void *)bus_space_vaddr(sa->sa_bustag, bh); | |
141 | sc->sc_bufsiz = (bus_size_t)sa->sa_reg[1].oa_size; | 142 | sc->sc_bufsiz = (bus_size_t)sa->sa_reg[1].oa_size; | |
142 | 143 | |||
143 | /* Get number of on-board channels */ | 144 | /* Get number of on-board channels */ | |
144 | sc->sc_nchannels = prom_getpropint(node, "#channels", -1); | 145 | sc->sc_nchannels = prom_getpropint(node, "#channels", -1); | |
145 | if (sc->sc_nchannels == -1) { | 146 | if (sc->sc_nchannels == -1) { | |
146 | printf(": no channels\n"); | 147 | printf(": no channels\n"); | |
147 | return; | 148 | return; | |
148 | } | 149 | } | |
149 | 150 | |||
150 | /* | 151 | /* | |
151 | * Get transfer burst size from PROM | 152 | * Get transfer burst size from PROM | |
152 | */ | 153 | */ | |
153 | sbusburst = ((struct sbus_softc *)parent)->sc_burst; | 154 | sbusburst = sbsc->sc_burst; | |
154 | if (sbusburst == 0) | 155 | if (sbusburst == 0) | |
155 | sbusburst = SBUS_BURST_32 - 1; /* 1->16 */ | 156 | sbusburst = SBUS_BURST_32 - 1; /* 1->16 */ | |
156 | 157 | |||
157 | sc->sc_burst = prom_getpropint(node, "burst-sizes", -1); | 158 | sc->sc_burst = prom_getpropint(node, "burst-sizes", -1); | |
158 | if (sc->sc_burst == -1) | 159 | if (sc->sc_burst == -1) | |
159 | /* take SBus burst sizes */ | 160 | /* take SBus burst sizes */ | |
160 | sc->sc_burst = sbusburst; | 161 | sc->sc_burst = sbusburst; | |
161 | 162 | |||
162 | /* Clamp at parent's burst sizes */ | 163 | /* Clamp at parent's burst sizes */ | |
163 | sc->sc_burst &= sbusburst; | 164 | sc->sc_burst &= sbusburst; | |
164 | 165 | |||
165 | sbus_establish(&sc->sc_sd, &sc->sc_dev); | 166 | sbus_establish(&sc->sc_sd, &sc->sc_dev); | |
166 | 167 | |||
@@ -195,27 +196,27 @@ qecattach(device_t parent, device_t self | @@ -195,27 +196,27 @@ qecattach(device_t parent, device_t self | |||
195 | * | 196 | * | |
196 | * XXX - qe.c should call bus_intr_establish() with `level = 0'.. | 197 | * XXX - qe.c should call bus_intr_establish() with `level = 0'.. | |
197 | * XXX - maybe we should have our own attach args for all that. | 198 | * XXX - maybe we should have our own attach args for all that. | |
198 | */ | 199 | */ | |
199 | sc->sc_intr = sa->sa_intr; | 200 | sc->sc_intr = sa->sa_intr; | |
200 | 201 | |||
201 | printf(": %dK memory\n", sc->sc_bufsiz / 1024); | 202 | printf(": %dK memory\n", sc->sc_bufsiz / 1024); | |
202 | 203 | |||
203 | qec_init(sc); | 204 | qec_init(sc); | |
204 | 205 | |||
205 | /* search through children */ | 206 | /* search through children */ | |
206 | for (node = firstchild(node); node; node = nextsibling(node)) { | 207 | for (node = firstchild(node); node; node = nextsibling(node)) { | |
207 | struct sbus_attach_args sax; | 208 | struct sbus_attach_args sax; | |
208 | sbus_setup_attach_args((struct sbus_softc *)parent, | 209 | sbus_setup_attach_args(sbsc, | |
209 | sbt, sc->sc_dmatag, node, &sax); | 210 | sbt, sc->sc_dmatag, node, &sax); | |
210 | (void)config_found(&sc->sc_dev, (void *)&sax, qecprint); | 211 | (void)config_found(&sc->sc_dev, (void *)&sax, qecprint); | |
211 | sbus_destroy_attach_args(&sax); | 212 | sbus_destroy_attach_args(&sax); | |
212 | } | 213 | } | |
213 | } | 214 | } | |
214 | 215 | |||
215 | int | 216 | int | |
216 | qec_bus_map(bus_space_tag_t t, bus_addr_t ba, bus_size_t size, int flags, vaddr_t va, bus_space_handle_t *hp) | 217 | qec_bus_map(bus_space_tag_t t, bus_addr_t ba, bus_size_t size, int flags, vaddr_t va, bus_space_handle_t *hp) | |
217 | /* va: Ignored */ | 218 | /* va: Ignored */ | |
218 | { | 219 | { | |
219 | int error; | 220 | int error; | |
220 | 221 | |||
221 | if ((error = bus_space_translate_address_generic( | 222 | if ((error = bus_space_translate_address_generic( |