kauai.c revision 1.1.2.3 1 1.1.2.3 grant /* $NetBSD: kauai.c,v 1.1.2.3 2003/06/19 11:24:01 grant Exp $ */
2 1.1.2.2 grant
3 1.1.2.2 grant /*-
4 1.1.2.2 grant * Copyright (c) 2003 Tsubai Masanari. All rights reserved.
5 1.1.2.2 grant *
6 1.1.2.2 grant * Redistribution and use in source and binary forms, with or without
7 1.1.2.2 grant * modification, are permitted provided that the following conditions
8 1.1.2.2 grant * are met:
9 1.1.2.2 grant * 1. Redistributions of source code must retain the above copyright
10 1.1.2.2 grant * notice, this list of conditions and the following disclaimer.
11 1.1.2.2 grant * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.2 grant * notice, this list of conditions and the following disclaimer in the
13 1.1.2.2 grant * documentation and/or other materials provided with the distribution.
14 1.1.2.2 grant * 3. The name of the author may not be used to endorse or promote products
15 1.1.2.2 grant * derived from this software without specific prior written permission.
16 1.1.2.2 grant *
17 1.1.2.2 grant * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 1.1.2.2 grant * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 1.1.2.2 grant * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.1.2.2 grant * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 1.1.2.2 grant * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 1.1.2.2 grant * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 1.1.2.2 grant * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 1.1.2.2 grant * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 1.1.2.2 grant * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 1.1.2.2 grant * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.1.2.2 grant */
28 1.1.2.2 grant
29 1.1.2.2 grant #include <sys/param.h>
30 1.1.2.2 grant #include <sys/systm.h>
31 1.1.2.2 grant #include <sys/device.h>
32 1.1.2.2 grant #include <sys/malloc.h>
33 1.1.2.2 grant
34 1.1.2.2 grant #include <uvm/uvm_extern.h>
35 1.1.2.2 grant
36 1.1.2.2 grant #include <machine/bus.h>
37 1.1.2.2 grant
38 1.1.2.2 grant #include <dev/ata/atareg.h>
39 1.1.2.2 grant #include <dev/ata/atavar.h>
40 1.1.2.2 grant #include <dev/ic/wdcvar.h>
41 1.1.2.2 grant
42 1.1.2.2 grant #include <dev/ofw/openfirm.h>
43 1.1.2.2 grant
44 1.1.2.2 grant #include <dev/pci/pcivar.h>
45 1.1.2.2 grant #include <dev/pci/pcireg.h>
46 1.1.2.2 grant #include <dev/pci/pcidevs.h>
47 1.1.2.2 grant
48 1.1.2.2 grant #include <macppc/dev/dbdma.h>
49 1.1.2.2 grant
50 1.1.2.2 grant #define WDC_REG_NPORTS 8
51 1.1.2.2 grant #define WDC_AUXREG_OFFSET 0x16
52 1.1.2.2 grant
53 1.1.2.2 grant #define PIO_CONFIG_REG (0x200 >> 4) /* PIO and DMA access timing */
54 1.1.2.2 grant #define DMA_CONFIG_REG (0x210 >> 4) /* UDMA access timing */
55 1.1.2.2 grant
56 1.1.2.2 grant struct kauai_softc {
57 1.1.2.2 grant struct wdc_softc sc_wdcdev;
58 1.1.2.2 grant struct channel_softc *wdc_chanptr;
59 1.1.2.2 grant struct channel_softc wdc_channel;
60 1.1.2.2 grant struct channel_queue wdc_queue;
61 1.1.2.2 grant dbdma_regmap_t *sc_dmareg;
62 1.1.2.2 grant dbdma_command_t *sc_dmacmd;
63 1.1.2.2 grant u_int sc_piotiming_r[2];
64 1.1.2.2 grant u_int sc_piotiming_w[2];
65 1.1.2.2 grant u_int sc_dmatiming_r[2];
66 1.1.2.2 grant u_int sc_dmatiming_w[2];
67 1.1.2.2 grant void (*sc_calc_timing)(struct kauai_softc *, int);
68 1.1.2.2 grant };
69 1.1.2.2 grant
70 1.1.2.2 grant int kauai_match __P((struct device *, struct cfdata *, void *));
71 1.1.2.2 grant void kauai_attach __P((struct device *, struct device *, void *));
72 1.1.2.2 grant int kauai_dma_init __P((void *, int, int, void *, size_t, int));
73 1.1.2.2 grant void kauai_dma_start __P((void *, int, int));
74 1.1.2.2 grant int kauai_dma_finish __P((void *, int, int, int));
75 1.1.2.2 grant void kauai_set_modes __P((struct channel_softc *));
76 1.1.2.2 grant static void calc_timing_kauai __P((struct kauai_softc *, int));
77 1.1.2.2 grant static int getnodebypci(pci_chipset_tag_t, pcitag_t);
78 1.1.2.2 grant
79 1.1.2.3 grant struct cfattach kauai_ca = {
80 1.1.2.3 grant sizeof(struct kauai_softc), kauai_match, kauai_attach,
81 1.1.2.3 grant NULL, wdcactivate
82 1.1.2.3 grant };
83 1.1.2.2 grant
84 1.1.2.2 grant int
85 1.1.2.2 grant kauai_match(parent, match, aux)
86 1.1.2.2 grant struct device *parent;
87 1.1.2.2 grant struct cfdata *match;
88 1.1.2.2 grant void *aux;
89 1.1.2.2 grant {
90 1.1.2.2 grant struct pci_attach_args *pa = aux;
91 1.1.2.2 grant
92 1.1.2.2 grant if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE &&
93 1.1.2.2 grant PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_APPLE_KAUAI)
94 1.1.2.2 grant return 5;
95 1.1.2.2 grant
96 1.1.2.2 grant return 0;
97 1.1.2.2 grant }
98 1.1.2.2 grant
99 1.1.2.2 grant void
100 1.1.2.2 grant kauai_attach(parent, self, aux)
101 1.1.2.2 grant struct device *parent, *self;
102 1.1.2.2 grant void *aux;
103 1.1.2.2 grant {
104 1.1.2.2 grant struct kauai_softc *sc = (void *)self;
105 1.1.2.2 grant struct pci_attach_args *pa = aux;
106 1.1.2.2 grant struct channel_softc *chp = &sc->wdc_channel;
107 1.1.2.2 grant pci_intr_handle_t ih;
108 1.1.2.2 grant paddr_t regbase, dmabase;
109 1.1.2.2 grant int node, reg[5];
110 1.1.2.2 grant
111 1.1.2.2 grant #ifdef DIAGNOSTIC
112 1.1.2.2 grant if ((vaddr_t)sc->sc_dmacmd & 0x0f) {
113 1.1.2.2 grant printf(": bad dbdma alignment\n");
114 1.1.2.2 grant return;
115 1.1.2.2 grant }
116 1.1.2.2 grant #endif
117 1.1.2.2 grant
118 1.1.2.2 grant node = getnodebypci(pa->pa_pc, pa->pa_tag);
119 1.1.2.2 grant if (node == 0) {
120 1.1.2.2 grant printf(": cannot find gmac node\n");
121 1.1.2.2 grant return;
122 1.1.2.2 grant }
123 1.1.2.2 grant
124 1.1.2.2 grant if (OF_getprop(node, "assigned-addresses", reg, sizeof reg) < 12) {
125 1.1.2.2 grant printf(": cannot get address property\n");
126 1.1.2.2 grant return;
127 1.1.2.2 grant }
128 1.1.2.2 grant regbase = reg[2] + 0x2000;
129 1.1.2.2 grant dmabase = reg[2] + 0x1000;
130 1.1.2.2 grant
131 1.1.2.2 grant /*
132 1.1.2.2 grant * XXX PCI_INTERRUPT_REG seems to be wired to 0.
133 1.1.2.2 grant * XXX So use fixed intrpin and intrline values.
134 1.1.2.2 grant */
135 1.1.2.2 grant if (pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_INTERRUPT_REG) == 0) {
136 1.1.2.2 grant pa->pa_intrpin = 1;
137 1.1.2.2 grant pa->pa_intrline = 39;
138 1.1.2.2 grant }
139 1.1.2.2 grant
140 1.1.2.2 grant if (pci_intr_map(pa, &ih)) {
141 1.1.2.2 grant printf(": unable to map interrupt\n");
142 1.1.2.2 grant return;
143 1.1.2.2 grant }
144 1.1.2.2 grant printf(": interrupting at %s\n", pci_intr_string(pa->pa_pc, ih));
145 1.1.2.2 grant
146 1.1.2.2 grant chp->cmd_iot = chp->ctl_iot = macppc_make_bus_space_tag(regbase, 4);
147 1.1.2.2 grant
148 1.1.2.2 grant if (bus_space_map(chp->cmd_iot, 0, WDC_REG_NPORTS, 0, &chp->cmd_ioh) ||
149 1.1.2.2 grant bus_space_subregion(chp->cmd_iot, chp->cmd_ioh,
150 1.1.2.2 grant WDC_AUXREG_OFFSET, 1, &chp->ctl_ioh)) {
151 1.1.2.2 grant printf("%s: couldn't map registers\n", self->dv_xname);
152 1.1.2.2 grant return;
153 1.1.2.2 grant }
154 1.1.2.2 grant
155 1.1.2.2 grant if (pci_intr_establish(pa->pa_pc, ih, IPL_BIO, wdcintr, chp) == NULL) {
156 1.1.2.2 grant printf("%s: unable to establish interrupt\n", self->dv_xname);
157 1.1.2.2 grant return;
158 1.1.2.2 grant }
159 1.1.2.2 grant
160 1.1.2.2 grant
161 1.1.2.2 grant sc->sc_wdcdev.PIO_cap = 4;
162 1.1.2.2 grant sc->sc_wdcdev.DMA_cap = 2;
163 1.1.2.2 grant sc->sc_wdcdev.UDMA_cap = 5;
164 1.1.2.2 grant sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_MODE;
165 1.1.2.2 grant sc->sc_wdcdev.cap |= WDC_CAPABILITY_DMA | WDC_CAPABILITY_UDMA;
166 1.1.2.2 grant sc->wdc_chanptr = chp;
167 1.1.2.2 grant sc->sc_wdcdev.channels = &sc->wdc_chanptr;
168 1.1.2.2 grant sc->sc_wdcdev.nchannels = 1;
169 1.1.2.2 grant sc->sc_wdcdev.dma_arg = sc;
170 1.1.2.2 grant sc->sc_wdcdev.dma_init = kauai_dma_init;
171 1.1.2.2 grant sc->sc_wdcdev.dma_start = kauai_dma_start;
172 1.1.2.2 grant sc->sc_wdcdev.dma_finish = kauai_dma_finish;
173 1.1.2.2 grant sc->sc_wdcdev.set_modes = kauai_set_modes;
174 1.1.2.2 grant sc->sc_calc_timing = calc_timing_kauai;
175 1.1.2.2 grant sc->sc_dmareg = (void *)dmabase;
176 1.1.2.2 grant
177 1.1.2.2 grant chp->channel = 0;
178 1.1.2.2 grant chp->wdc = &sc->sc_wdcdev;
179 1.1.2.2 grant chp->ch_queue = &sc->wdc_queue;
180 1.1.2.2 grant
181 1.1.2.2 grant wdcattach(chp);
182 1.1.2.2 grant
183 1.1.2.2 grant /* Modify access timings. */
184 1.1.2.2 grant kauai_set_modes(chp);
185 1.1.2.2 grant }
186 1.1.2.2 grant
187 1.1.2.2 grant void
188 1.1.2.2 grant kauai_set_modes(chp)
189 1.1.2.2 grant struct channel_softc *chp;
190 1.1.2.2 grant {
191 1.1.2.2 grant struct kauai_softc *sc = (void *)chp->wdc;
192 1.1.2.2 grant struct ata_drive_datas *drvp0 = &chp->ch_drive[0];
193 1.1.2.2 grant struct ata_drive_datas *drvp1 = &chp->ch_drive[1];
194 1.1.2.2 grant struct ata_drive_datas *drvp;
195 1.1.2.2 grant int drive;
196 1.1.2.2 grant
197 1.1.2.2 grant if ((drvp0->drive_flags & DRIVE) && (drvp1->drive_flags & DRIVE)) {
198 1.1.2.2 grant drvp0->PIO_mode = drvp1->PIO_mode =
199 1.1.2.2 grant min(drvp0->PIO_mode, drvp1->PIO_mode);
200 1.1.2.2 grant }
201 1.1.2.2 grant
202 1.1.2.2 grant for (drive = 0; drive < 2; drive++) {
203 1.1.2.2 grant drvp = &chp->ch_drive[drive];
204 1.1.2.2 grant if (drvp->drive_flags & DRIVE) {
205 1.1.2.2 grant (*sc->sc_calc_timing)(sc, drive);
206 1.1.2.2 grant bus_space_write_4(chp->cmd_iot, chp->cmd_ioh,
207 1.1.2.2 grant PIO_CONFIG_REG, sc->sc_piotiming_r[drive]);
208 1.1.2.2 grant bus_space_write_4(chp->cmd_iot, chp->cmd_ioh,
209 1.1.2.2 grant DMA_CONFIG_REG, sc->sc_dmatiming_r[drive]);
210 1.1.2.2 grant }
211 1.1.2.2 grant }
212 1.1.2.2 grant
213 1.1.2.2 grant wdc_print_modes(chp);
214 1.1.2.2 grant }
215 1.1.2.2 grant
216 1.1.2.2 grant /*
217 1.1.2.2 grant * IDE transfer timings
218 1.1.2.2 grant */
219 1.1.2.2 grant static const u_int pio_timing_kauai[] = { /* 0xff000fff */
220 1.1.2.2 grant 0x08000a92, /* Mode 0 */
221 1.1.2.2 grant 0x0800060f, /* 1 */
222 1.1.2.2 grant 0x0800038b, /* 2 */
223 1.1.2.2 grant 0x05000249, /* 3 */
224 1.1.2.2 grant 0x04000148 /* 4 */
225 1.1.2.2 grant };
226 1.1.2.2 grant static const u_int dma_timing_kauai[] = { /* 0x00fff000 */
227 1.1.2.2 grant 0x00618000, /* Mode 0 */
228 1.1.2.2 grant 0x00209000, /* 1 */
229 1.1.2.2 grant 0x00148000 /* 2 */
230 1.1.2.2 grant };
231 1.1.2.2 grant static const u_int udma_timing_kauai[] = { /* 0x0000ffff */
232 1.1.2.2 grant 0x000070c0, /* Mode 0 */
233 1.1.2.2 grant 0x00005d80, /* 1 */
234 1.1.2.2 grant 0x00004a60, /* 2 */
235 1.1.2.2 grant 0x00003a50, /* 3 */
236 1.1.2.2 grant 0x00002a30, /* 4 */
237 1.1.2.2 grant 0x00002921 /* 5 */
238 1.1.2.2 grant };
239 1.1.2.2 grant
240 1.1.2.2 grant /*
241 1.1.2.2 grant * Timing calculation for Kauai.
242 1.1.2.2 grant */
243 1.1.2.2 grant void
244 1.1.2.2 grant calc_timing_kauai(sc, drive)
245 1.1.2.2 grant struct kauai_softc *sc;
246 1.1.2.2 grant int drive;
247 1.1.2.2 grant {
248 1.1.2.2 grant struct channel_softc *chp = &sc->wdc_channel;
249 1.1.2.2 grant struct ata_drive_datas *drvp = &chp->ch_drive[drive];
250 1.1.2.2 grant int piomode = drvp->PIO_mode;
251 1.1.2.2 grant int dmamode = drvp->DMA_mode;
252 1.1.2.2 grant int udmamode = drvp->UDMA_mode;
253 1.1.2.2 grant u_int pioconf, dmaconf;
254 1.1.2.2 grant
255 1.1.2.2 grant pioconf = pio_timing_kauai[piomode];
256 1.1.2.2 grant
257 1.1.2.2 grant dmaconf = 0;
258 1.1.2.2 grant if (drvp->drive_flags & DRIVE_DMA)
259 1.1.2.2 grant dmaconf |= dma_timing_kauai[dmamode];
260 1.1.2.2 grant if (drvp->drive_flags & DRIVE_UDMA)
261 1.1.2.2 grant dmaconf |= udma_timing_kauai[udmamode];
262 1.1.2.2 grant
263 1.1.2.2 grant if (drvp->drive_flags & DRIVE_UDMA)
264 1.1.2.2 grant dmaconf |= 1;
265 1.1.2.2 grant
266 1.1.2.2 grant sc->sc_piotiming_r[drive] = sc->sc_piotiming_w[drive] = pioconf;
267 1.1.2.2 grant sc->sc_dmatiming_r[drive] = sc->sc_dmatiming_w[drive] = dmaconf;
268 1.1.2.2 grant }
269 1.1.2.2 grant
270 1.1.2.2 grant int
271 1.1.2.2 grant kauai_dma_init(v, channel, drive, databuf, datalen, flags)
272 1.1.2.2 grant void *v;
273 1.1.2.2 grant void *databuf;
274 1.1.2.2 grant size_t datalen;
275 1.1.2.2 grant int flags;
276 1.1.2.2 grant {
277 1.1.2.2 grant struct kauai_softc *sc = v;
278 1.1.2.2 grant dbdma_command_t *cmdp = sc->sc_dmacmd;
279 1.1.2.2 grant struct channel_softc *chp = &sc->wdc_channel;
280 1.1.2.2 grant vaddr_t va = (vaddr_t)databuf;
281 1.1.2.2 grant int read = flags & WDC_DMA_READ;
282 1.1.2.2 grant int cmd = read ? DBDMA_CMD_IN_MORE : DBDMA_CMD_OUT_MORE;
283 1.1.2.2 grant u_int offset;
284 1.1.2.2 grant
285 1.1.2.2 grant bus_space_write_4(chp->cmd_iot, chp->cmd_ioh, DMA_CONFIG_REG,
286 1.1.2.2 grant read ? sc->sc_dmatiming_r[drive] : sc->sc_dmatiming_w[drive]);
287 1.1.2.2 grant bus_space_read_4(chp->cmd_iot, chp->cmd_ioh, DMA_CONFIG_REG);
288 1.1.2.2 grant
289 1.1.2.2 grant offset = va & PGOFSET;
290 1.1.2.2 grant
291 1.1.2.2 grant /* if va is not page-aligned, setup the first page */
292 1.1.2.2 grant if (offset != 0) {
293 1.1.2.2 grant int rest = PAGE_SIZE - offset; /* the rest of the page */
294 1.1.2.2 grant
295 1.1.2.2 grant if (datalen > rest) { /* if continues to next page */
296 1.1.2.2 grant DBDMA_BUILD(cmdp, cmd, 0, rest, vtophys(va),
297 1.1.2.2 grant DBDMA_INT_NEVER, DBDMA_WAIT_NEVER,
298 1.1.2.2 grant DBDMA_BRANCH_NEVER);
299 1.1.2.2 grant datalen -= rest;
300 1.1.2.2 grant va += rest;
301 1.1.2.2 grant cmdp++;
302 1.1.2.2 grant }
303 1.1.2.2 grant }
304 1.1.2.2 grant
305 1.1.2.2 grant /* now va is page-aligned */
306 1.1.2.2 grant while (datalen > PAGE_SIZE) {
307 1.1.2.2 grant DBDMA_BUILD(cmdp, cmd, 0, PAGE_SIZE, vtophys(va),
308 1.1.2.2 grant DBDMA_INT_NEVER, DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
309 1.1.2.2 grant datalen -= PAGE_SIZE;
310 1.1.2.2 grant va += PAGE_SIZE;
311 1.1.2.2 grant cmdp++;
312 1.1.2.2 grant }
313 1.1.2.2 grant
314 1.1.2.2 grant /* the last page (datalen <= PAGE_SIZE here) */
315 1.1.2.2 grant cmd = read ? DBDMA_CMD_IN_LAST : DBDMA_CMD_OUT_LAST;
316 1.1.2.2 grant DBDMA_BUILD(cmdp, cmd, 0, datalen, vtophys(va),
317 1.1.2.2 grant DBDMA_INT_NEVER, DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
318 1.1.2.2 grant cmdp++;
319 1.1.2.2 grant
320 1.1.2.2 grant DBDMA_BUILD(cmdp, DBDMA_CMD_STOP, 0, 0, 0,
321 1.1.2.2 grant DBDMA_INT_NEVER, DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
322 1.1.2.2 grant
323 1.1.2.2 grant return 0;
324 1.1.2.2 grant }
325 1.1.2.2 grant
326 1.1.2.2 grant void
327 1.1.2.2 grant kauai_dma_start(v, channel, drive)
328 1.1.2.2 grant void *v;
329 1.1.2.2 grant int channel, drive;
330 1.1.2.2 grant {
331 1.1.2.2 grant struct kauai_softc *sc = v;
332 1.1.2.2 grant
333 1.1.2.2 grant dbdma_start(sc->sc_dmareg, sc->sc_dmacmd);
334 1.1.2.2 grant }
335 1.1.2.2 grant
336 1.1.2.2 grant int
337 1.1.2.2 grant kauai_dma_finish(v, channel, drive, read)
338 1.1.2.2 grant void *v;
339 1.1.2.2 grant int channel, drive;
340 1.1.2.2 grant int read;
341 1.1.2.2 grant {
342 1.1.2.2 grant struct kauai_softc *sc = v;
343 1.1.2.2 grant
344 1.1.2.2 grant dbdma_stop(sc->sc_dmareg);
345 1.1.2.2 grant return 0;
346 1.1.2.2 grant }
347 1.1.2.2 grant
348 1.1.2.2 grant /*
349 1.1.2.2 grant * Find OF-device corresponding to the PCI device.
350 1.1.2.2 grant */
351 1.1.2.2 grant int
352 1.1.2.2 grant getnodebypci(pc, tag)
353 1.1.2.2 grant pci_chipset_tag_t pc;
354 1.1.2.2 grant pcitag_t tag;
355 1.1.2.2 grant {
356 1.1.2.2 grant int bus, dev, func;
357 1.1.2.2 grant u_int reg[5];
358 1.1.2.2 grant int p, q;
359 1.1.2.2 grant int l, b, d, f;
360 1.1.2.2 grant
361 1.1.2.2 grant pci_decompose_tag(pc, tag, &bus, &dev, &func);
362 1.1.2.2 grant
363 1.1.2.2 grant for (q = OF_peer(0); q; q = p) {
364 1.1.2.2 grant l = OF_getprop(q, "assigned-addresses", reg, sizeof(reg));
365 1.1.2.2 grant if (l > 4) {
366 1.1.2.2 grant b = (reg[0] >> 16) & 0xff;
367 1.1.2.2 grant d = (reg[0] >> 11) & 0x1f;
368 1.1.2.2 grant f = (reg[0] >> 8) & 0x07;
369 1.1.2.2 grant
370 1.1.2.2 grant if (b == bus && d == dev && f == func)
371 1.1.2.2 grant return q;
372 1.1.2.2 grant }
373 1.1.2.2 grant if ((p = OF_child(q)))
374 1.1.2.2 grant continue;
375 1.1.2.2 grant while (q) {
376 1.1.2.2 grant if ((p = OF_peer(q)))
377 1.1.2.2 grant break;
378 1.1.2.2 grant q = OF_parent(q);
379 1.1.2.2 grant }
380 1.1.2.2 grant }
381 1.1.2.2 grant return 0;
382 1.1.2.2 grant }
383