ixp425_sip.c revision 1.13 1 /* $NetBSD: ixp425_sip.c,v 1.13 2012/10/14 14:20:58 msaitoh Exp $ */
2
3 /*
4 * Copyright (c) 2003
5 * Ichiro FUKUHARA <ichiro (at) ichiro.org>.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: ixp425_sip.c,v 1.13 2012/10/14 14:20:58 msaitoh Exp $");
32
33 /*
34 * Slow peripheral bus of IXP425 Processor
35 */
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
40
41 #include <machine/autoconf.h>
42 #include <sys/bus.h>
43
44 #include <arm/xscale/ixp425var.h>
45 #include <arm/xscale/ixp425_sipvar.h>
46
47 #include "locators.h"
48
49 static int ixpsip_match(device_t, cfdata_t, void *);
50 static void ixpsip_attach(device_t, device_t, void *);
51 static int ixpsip_search(device_t, cfdata_t, const int *, void *);
52 static int ixpsip_print(void *, const char *);
53
54 CFATTACH_DECL_NEW(ixpsip, sizeof(struct ixpsip_softc),
55 ixpsip_match, ixpsip_attach, NULL, NULL);
56
57 struct ixpsip_softc *ixpsip_softc;
58
59 int
60 ixpsip_match(device_t parent, cfdata_t cf, void *aux)
61 {
62 return (1);
63 }
64
65 void
66 ixpsip_attach(device_t parent, device_t self, void *aux)
67 {
68 struct ixpsip_softc *sc = device_private(self);
69 sc->sc_iot = &ixp425_bs_tag;
70
71 ixpsip_softc = sc;
72
73 printf("\n");
74
75 if (bus_space_map(sc->sc_iot, IXP425_EXP_HWBASE, IXP425_EXP_SIZE,
76 0, &sc->sc_ioh)) {
77 printf("%s: Can't map expansion bus control registers!\n",
78 device_xname(self));
79 return;
80 }
81
82 /*
83 * Attach each devices
84 */
85 config_search_ia(ixpsip_search, self, "ixpsip", NULL);
86 }
87
88 int
89 ixpsip_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
90 {
91 struct ixpsip_softc *sc = device_private(parent);
92 struct ixpsip_attach_args sa;
93
94 sa.sa_iot = sc->sc_iot;
95 sa.sa_addr = cf->cf_loc[IXPSIPCF_ADDR];
96 sa.sa_size = cf->cf_loc[IXPSIPCF_SIZE];
97 sa.sa_index = cf->cf_loc[IXPSIPCF_INDEX];
98 sa.sa_intr = cf->cf_loc[IXPSIPCF_INTR];
99
100 if (config_match(parent, cf, &sa) > 0)
101 config_attach(parent, cf, &sa, ixpsip_print);
102
103 return (0);
104 }
105
106 static int
107 ixpsip_print(void *aux, const char *name)
108 {
109 struct ixpsip_attach_args *sa = aux;
110
111 if (sa->sa_size)
112 aprint_normal(" addr 0x%lx", sa->sa_addr);
113 if (sa->sa_size > 1)
114 aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
115 if (sa->sa_index > 1)
116 aprint_normal(" index %d", sa->sa_index);
117 if (sa->sa_intr > 1)
118 aprint_normal(" intr %d", sa->sa_intr);
119
120 return (UNCONF);
121 }
122