Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / atari / vme / vme.c
blob1160e05b334655407fe01c1b12e02b7d139d94f1
1 /* $NetBSD: vme.c,v 1.15 2009/03/14 15:36:04 dsl Exp $ */
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: vme.c,v 1.15 2009/03/14 15:36:04 dsl Exp $");
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/kernel.h>
35 #include <sys/conf.h>
36 #include <sys/malloc.h>
37 #include <sys/device.h>
39 #include <machine/intr.h>
41 #include <atari/vme/vmevar.h>
43 int vmematch(struct device *, struct cfdata *, void *);
44 void vmeattach(struct device *, struct device *, void *);
45 int vmeprint(void *, const char *);
47 CFATTACH_DECL(vme, sizeof(struct vme_softc),
48 vmematch, vmeattach, NULL, NULL);
50 int vmesearch(struct device *, struct cfdata *,
51 const int *, void *);
53 int
54 vmematch(struct device *parent, struct cfdata *cf, void *aux)
56 struct vmebus_attach_args *vba = aux;
58 if (strcmp(vba->vba_busname, cf->cf_name))
59 return (0);
61 return (1);
64 void
65 vmeattach(struct device *parent, struct device *self, void *aux)
67 struct vme_softc *sc = (struct vme_softc *)self;
68 struct vmebus_attach_args *vba = aux;
70 printf("\n");
72 sc->sc_iot = vba->vba_iot;
73 sc->sc_memt = vba->vba_memt;
74 sc->sc_vc = vba->vba_vc;
76 config_search_ia(vmesearch, self, "vme", NULL);
79 int
80 vmeprint(void *aux, const char *vme)
82 struct vme_attach_args *va = aux;
84 if (va->va_iosize)
85 aprint_normal(" port 0x%x", va->va_iobase);
86 if (va->va_iosize > 1)
87 aprint_normal("-0x%x", va->va_iobase + va->va_iosize - 1);
88 if (va->va_msize)
89 aprint_normal(" iomem 0x%x", va->va_maddr);
90 if (va->va_msize > 1)
91 aprint_normal("-0x%x", va->va_maddr + va->va_msize - 1);
92 if (va->va_irq != IRQUNK)
93 aprint_normal(" irq %d", va->va_irq);
94 return (UNCONF);
97 int
98 vmesearch(struct device *parent, struct cfdata *cf, const int *ldesc, void *aux)
100 struct vme_softc *sc = (struct vme_softc *)parent;
101 struct vme_attach_args va;
103 va.va_iot = sc->sc_iot;
104 va.va_memt = sc->sc_memt;
105 va.va_vc = sc->sc_vc;
106 va.va_iobase = cf->cf_iobase;
107 va.va_iosize = cf->cf_iosize;
108 va.va_maddr = cf->cf_maddr;
109 va.va_msize = cf->cf_msize;
110 va.va_irq = cf->cf_irq;
112 if (config_match(parent, cf, &va) > 0)
113 config_attach(parent, cf, &va, vmeprint);
114 return (0);