xref: /netbsd-src/sys/arch/arm/ixp12x0/ixpsip.c (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1 /*	$NetBSD: ixpsip.c,v 1.13 2011/07/01 20:27:50 dyoung Exp $ */
2 
3 /*
4  * Copyright (c) 2002
5  *	Ichiro FUKUHARA <ichiro@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: ixpsip.c,v 1.13 2011/07/01 20:27:50 dyoung Exp $");
32 
33 /*
34  * Slow peripheral bus of ixp12x0 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/ixp12x0/ixp12x0var.h>
45 #include <arm/ixp12x0/ixpsipvar.h>
46 
47 #include "locators.h"
48 
49 static int	ixpsip_match(struct device *, struct cfdata *, void *);
50 static void	ixpsip_attach(struct device *, struct device *, void *);
51 static int	ixpsip_search(struct device *, struct cfdata *,
52 			      const int *, void *);
53 static int	ixpsip_print(void *, const char *);
54 
55 CFATTACH_DECL(ixpsip, sizeof(struct ixpsip_softc),
56     ixpsip_match, ixpsip_attach, NULL, NULL);
57 
58 int
59 ixpsip_match(struct device *parent, struct cfdata *cf, void *aux)
60 {
61 	return (1);
62 }
63 
64 void
65 ixpsip_attach(struct device *parent, struct device *self, void *aux)
66 {
67 	struct ixpsip_softc *sc = (void *) self;
68 	sc->sc_iot = &ixp12x0_bs_tag;
69 
70 	printf("\n");
71 
72 	/*
73 	 *  Attach each devices
74 	 */
75 	config_search_ia(ixpsip_search, self, "ixpsip", NULL);
76 }
77 
78 int
79 ixpsip_search(struct device *parent, struct cfdata *cf, const int *ldesc, void *aux)
80 {
81 	struct ixpsip_softc *sc = (struct ixpsip_softc *)parent;
82 	struct ixpsip_attach_args sa;
83 
84 	sa.sa_iot = sc->sc_iot;
85 	sa.sa_addr = cf->cf_loc[IXPSIPCF_ADDR];
86 	sa.sa_size = cf->cf_loc[IXPSIPCF_SIZE];
87 	sa.sa_intr = cf->cf_loc[IXPSIPCF_INTR];
88 
89 	if (config_match(parent, cf, &sa) > 0)
90 		config_attach(parent, cf, &sa, ixpsip_print);
91 
92 	return (0);
93 }
94 
95 static int
96 ixpsip_print(void *aux, const char *name)
97 {
98         struct ixpsip_attach_args *sa = (struct ixpsip_attach_args*)aux;
99 
100 	if (sa->sa_size)
101 		aprint_normal(" addr 0x%lx", sa->sa_addr);
102 	if (sa->sa_size > 1)
103 		aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
104 	if (sa->sa_intr > 1)
105 		aprint_normal(" intr %d", sa->sa_intr);
106 
107 	return (UNCONF);
108 }
109