xref: /netbsd/sys/arch/hpcarm/dev/ipaq_saip.c (revision c4a72b64)
1 /*	$NetBSD: ipaq_saip.c,v 1.13 2002/10/02 05:18:52 thorpej Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001, The NetBSD Foundation, Inc.  All rights reserved.
5  *
6  * This code is derived from software contributed to The NetBSD Foundation
7  * by Ichiro FUKUHARA (ichiro@ichiro.org).
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by the NetBSD
20  *      Foundation, Inc. and its contributors.
21  * 4. Neither the name of The NetBSD Foundation nor the names of its
22  *    contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  */
25 #include <sys/param.h>
26 #include <sys/systm.h>
27 #include <sys/types.h>
28 #include <sys/conf.h>
29 #include <sys/device.h>
30 #include <sys/kernel.h>
31 #include <sys/malloc.h>
32 #include <sys/uio.h>
33 
34 #include <machine/cpu.h>
35 #include <machine/bus.h>
36 
37 #include <arm/sa11x0/sa11x0_var.h>
38 #include <arm/sa11x0/sa11x0_reg.h>
39 #include <arm/sa11x0/sa11x0_dmacreg.h>
40 #include <arm/sa11x0/sa11x0_ppcreg.h>
41 #include <arm/sa11x0/sa11x0_gpioreg.h>
42 #include <arm/sa11x0/sa11x0_sspreg.h>
43 
44 #include <hpcarm/dev/ipaq_saipvar.h>
45 #include <hpcarm/dev/ipaq_gpioreg.h>
46 
47 /* prototypes */
48 static int	ipaq_match(struct device *, struct cfdata *, void *);
49 static void	ipaq_attach(struct device *, struct device *, void *);
50 static int 	ipaq_search(struct device *, struct cfdata *, void *);
51 static int	ipaq_print(void *, const char *);
52 
53 /* attach structures */
54 CFATTACH_DECL(ipaqbus, sizeof(struct ipaq_softc),
55     ipaq_match, ipaq_attach, NULL, NULL);
56 
57 static int
58 ipaq_print(aux, name)
59 	void *aux;
60 	const char *name;
61 {
62         return (UNCONF);
63 }
64 
65 int
66 ipaq_match(parent, match, aux)
67 	struct device *parent;
68 	struct cfdata *match;
69 	void *aux;
70 {
71 	return (1);
72 }
73 
74 void
75 ipaq_attach(parent, self, aux)
76 	struct device *parent;
77 	struct device *self;
78 	void *aux;
79 {
80 	struct ipaq_softc *sc = (struct ipaq_softc*)self;
81 	struct sa11x0_softc *psc = (struct sa11x0_softc *)parent;
82 
83 	printf("\n");
84 
85 	sc->sc_iot = psc->sc_iot;
86 	sc->sc_ioh = psc->sc_ioh;
87 	sc->sc_gpioh = psc->sc_gpioh;
88 
89 	/* Map the Extended GPIO registers */
90 	if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh))
91 		panic("%s: unable to map Extended GPIO registers",
92 			self->dv_xname);
93 
94 	sc->ipaq_egpio = EGPIO_INIT;
95         bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio);
96 
97 	/* Map the SSP registers */
98 	if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph))
99 		panic("%s: unable to map SSP registers",
100 			self->dv_xname);
101 
102 	sc->sc_ppch = psc->sc_ppch;
103 	sc->sc_dmach = psc->sc_dmach;
104 
105 	/*
106 	 *  Attach each devices
107 	 */
108 	config_search(ipaq_search, self, NULL);
109 }
110 
111 int
112 ipaq_search(parent, cf, aux)
113 	struct device *parent;
114 	struct cfdata *cf;
115 	void *aux;
116 {
117 	if (config_match(parent, cf, NULL) > 0)
118 		config_attach(parent, cf, NULL, ipaq_print);
119 
120         return 0;
121 }
122