ixp425_ixme.c revision 1.1 1 /* $NetBSD: ixp425_ixme.c,v 1.1 2006/12/10 10:01:49 scw Exp $ */
2
3 /*-
4 * Copyright (c) 2006 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Steve C. Woodford.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: ixp425_ixme.c,v 1.1 2006/12/10 10:01:49 scw Exp $");
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/kernel.h>
45 #include <sys/device.h>
46
47 #define _ARM32_BUS_DMA_PRIVATE
48 #include <machine/bus.h>
49
50 #include <arm/xscale/ixp425var.h>
51 #include <arm/xscale/ixp425_qmgr.h>
52 #include <arm/xscale/ixp425_ixmevar.h>
53
54 #include "locators.h"
55
56 static int ixme_match(struct device *, struct cfdata *, void *);
57 static void ixme_attach(struct device *, struct device *, void *);
58 static int ixme_search(struct device *, struct cfdata *, const int *,
59 void *);
60 static int ixme_print(void *, const char *);
61
62 struct ixme_softc {
63 struct device sc_dev;
64 struct arm32_dma_range sc_dr;
65 struct arm32_bus_dma_tag sc_dt;
66 void *sc_qmgr;
67 };
68
69 CFATTACH_DECL(ixme, sizeof(struct ixme_softc),
70 ixme_match, ixme_attach, NULL, NULL);
71
72 static int
73 ixme_match(struct device *parent, struct cfdata *self, void *arg)
74 {
75
76 return (1);
77 }
78
79 static void
80 ixme_attach(struct device *parent, struct device *self, void *arg)
81 {
82 struct ixme_softc *sc = (void *)self;
83 extern paddr_t physical_start, physical_end;
84
85 aprint_naive("\n");
86 aprint_normal(": IXP4xx MicroEngine Support\n");
87
88 sc->sc_qmgr = ixpqmgr_init(&ixp425_bs_tag);
89 if (sc->sc_qmgr == NULL) {
90 panic("%s: ixme_attach: Failed to init Queue Manager",
91 sc->sc_dev.dv_xname);
92 }
93
94 sc->sc_dr.dr_sysbase = physical_start;
95 sc->sc_dr.dr_busbase = 0;
96 sc->sc_dr.dr_len = physical_end - physical_start;
97 sc->sc_dt._ranges = &sc->sc_dr;
98 sc->sc_dt._nranges = 1;
99
100 sc->sc_dt._dmamap_create = _bus_dmamap_create;
101 sc->sc_dt._dmamap_destroy = _bus_dmamap_destroy;
102 sc->sc_dt._dmamap_load = _bus_dmamap_load;
103 sc->sc_dt._dmamap_load_mbuf = _bus_dmamap_load_mbuf;
104 sc->sc_dt._dmamap_load_uio = _bus_dmamap_load_uio;
105 sc->sc_dt._dmamap_load_raw = _bus_dmamap_load_raw;
106 sc->sc_dt._dmamap_unload = _bus_dmamap_unload;
107 sc->sc_dt._dmamap_sync_pre = _bus_dmamap_sync;
108 sc->sc_dt._dmamap_sync_post = NULL;
109 sc->sc_dt._dmamem_alloc = _bus_dmamem_alloc;
110 sc->sc_dt._dmamem_free = _bus_dmamem_free;
111 sc->sc_dt._dmamem_map = _bus_dmamem_map;
112 sc->sc_dt._dmamem_unmap = _bus_dmamem_unmap;
113 sc->sc_dt._dmamem_mmap = _bus_dmamem_mmap;
114
115 config_search_ia(ixme_search, self, "ixme", NULL);
116 }
117
118 static int
119 ixme_search(struct device *parent, struct cfdata *cf, const int *ldesc,
120 void *arg)
121 {
122 struct ixme_softc *sc = (void *)parent;
123 struct ixme_attach_args ixa;
124
125 if (cf->cf_loc[IXMECF_NPE] < 0 || cf->cf_loc[IXMECF_NPE] > 2)
126 return (0);
127
128 ixa.ixa_iot = &ixp425_bs_tag;
129 ixa.ixa_dt = &sc->sc_dt;
130 ixa.ixa_npe = cf->cf_loc[IXMECF_NPE];
131
132 if (config_match(parent, cf, &ixa) > 0) {
133 config_attach(parent, cf, &ixa, ixme_print);
134 return (1);
135 }
136
137 return (0);
138 }
139
140 static int
141 ixme_print(void *arg, const char *name)
142 {
143 struct ixme_attach_args *ixa = arg;
144
145 aprint_normal(" NPE-%c", 'A' + ixa->ixa_npe);
146
147 return (UNCONF);
148 }
149