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