sbdio.c (04faabf0) sbdio.c (7b2990da)
1/* $NetBSD: sbdio.c,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
1/* $NetBSD: sbdio.c,v 1.2 2008/03/29 08:14:41 tsutsui Exp $ */
2
3/*-
4 * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
9 *

--- 22 unchanged lines hidden (view full) ---

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>
2
3/*-
4 * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
9 *

--- 22 unchanged lines hidden (view full) ---

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: sbdio.c,v 1.1 2005/12/29 15:20:09 tsutsui Exp $");
40__KERNEL_RCSID(0, "$NetBSD: sbdio.c,v 1.2 2008/03/29 08:14:41 tsutsui Exp $");
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/device.h>
45
46#include <machine/autoconf.h>
47#define _EWS4800MIPS_BUS_DMA_PRIVATE
48#include <machine/bus.h>
49#include <machine/sbdvar.h>
50#include <machine/sbdiovar.h>
51
52#include "ioconf.h"
53
54struct sbdio_softc {
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/device.h>
45
46#include <machine/autoconf.h>
47#define _EWS4800MIPS_BUS_DMA_PRIVATE
48#include <machine/bus.h>
49#include <machine/sbdvar.h>
50#include <machine/sbdiovar.h>
51
52#include "ioconf.h"
53
54struct sbdio_softc {
55 struct device sc_dev;
55 device_t sc_dev;
56 struct ews4800mips_bus_space sc_bus_tag;
57 struct ews4800mips_bus_dma_tag sc_dma_tag;
58};
59
56 struct ews4800mips_bus_space sc_bus_tag;
57 struct ews4800mips_bus_dma_tag sc_dma_tag;
58};
59
60int sbdio_match(struct device *, struct cfdata *, void *);
61void sbdio_attach(struct device *, struct device *, void *);
62int sbdio_print(void *, const char *);
60static int sbdio_match(device_t, cfdata_t, void *);
61static void sbdio_attach(device_t, device_t, void *);
62static int sbdio_print(void *, const char *);
63
63
64CFATTACH_DECL(sbdio, sizeof(struct sbdio_softc),
64CFATTACH_DECL_NEW(sbdio, sizeof(struct sbdio_softc),
65 sbdio_match, sbdio_attach, NULL, NULL);
66
67static int sbdio_found;
68
69int
65 sbdio_match, sbdio_attach, NULL, NULL);
66
67static int sbdio_found;
68
69int
70sbdio_match(struct device *parent, struct cfdata *match, void *aux)
70sbdio_match(device_t parent, cfdata_t cf, void *aux)
71{
72 struct mainbus_attach_args *ma = aux;
73
74 if (sbdio_found != 0)
75 return 0;
76
77 if (strcmp(ma->ma_name, sbdio_cd.cd_name) != 0)
78 return 0;
79
80 if (platform.sbdiodevs == NULL)
81 return 0;
82
83 return 1;
84}
85
86void
71{
72 struct mainbus_attach_args *ma = aux;
73
74 if (sbdio_found != 0)
75 return 0;
76
77 if (strcmp(ma->ma_name, sbdio_cd.cd_name) != 0)
78 return 0;
79
80 if (platform.sbdiodevs == NULL)
81 return 0;
82
83 return 1;
84}
85
86void
87sbdio_attach(struct device *parent, struct device *self, void *aux)
87sbdio_attach(device_t parent, device_t self, void *aux)
88{
88{
89 struct sbdio_softc *sc = (void *)self;
89 struct sbdio_softc *sc = device_private(self);
90 struct sbdio_attach_args sa;
91 const struct sbdiodevdesc *sd;
92
93 sbdio_found = 1;
94
90 struct sbdio_attach_args sa;
91 const struct sbdiodevdesc *sd;
92
93 sbdio_found = 1;
94
95 printf("\n");
95 sc->sc_dev = self;
96 aprint_normal("\n");
96
97 /* structure assignment */
98 sc->sc_dma_tag = ews4800mips_default_bus_dma_tag;
99
97
98 /* structure assignment */
99 sc->sc_dma_tag = ews4800mips_default_bus_dma_tag;
100
100 bus_space_create(&sc->sc_bus_tag, sc->sc_dev.dv_xname,
101 bus_space_create(&sc->sc_bus_tag, device_xname(sc->sc_dev),
101 MIPS_KSEG1_START, MIPS_KSEG2_START - MIPS_KSEG1_START); /* XXX */
102
103 for (sd = platform.sbdiodevs; sd->sd_name != NULL; sd++) {
104 sa.sa_name = sd->sd_name;
105 sa.sa_bust = &sc->sc_bus_tag;
106 sa.sa_dmat = &sc->sc_dma_tag;
107 sa.sa_addr1 = sd->sd_addr1;
108 sa.sa_addr2 = sd->sd_addr2;
109 sa.sa_irq = sd->sd_irq;
110 sa.sa_flags = sd->sd_flags;
111 config_found(self, &sa, sbdio_print);
112 }
113}
114
115int
116sbdio_print(void *aux, const char *pnp)
117{
102 MIPS_KSEG1_START, MIPS_KSEG2_START - MIPS_KSEG1_START); /* XXX */
103
104 for (sd = platform.sbdiodevs; sd->sd_name != NULL; sd++) {
105 sa.sa_name = sd->sd_name;
106 sa.sa_bust = &sc->sc_bus_tag;
107 sa.sa_dmat = &sc->sc_dma_tag;
108 sa.sa_addr1 = sd->sd_addr1;
109 sa.sa_addr2 = sd->sd_addr2;
110 sa.sa_irq = sd->sd_irq;
111 sa.sa_flags = sd->sd_flags;
112 config_found(self, &sa, sbdio_print);
113 }
114}
115
116int
117sbdio_print(void *aux, const char *pnp)
118{
119 struct sbdio_attach_args *sa = aux;
118
120
121 if (sa->sa_addr1 != (paddr_t)-1) {
122 aprint_normal(" at 0x%lx", sa->sa_addr1);
123 if (sa->sa_addr2 != (paddr_t)-1)
124 aprint_normal(", 0x%lx", sa->sa_addr2);
125 }
126 if (sa->sa_irq != -1)
127 aprint_normal(" irq %d", sa->sa_irq);
128
119 return pnp ? QUIET : UNCONF;
120}
129 return pnp ? QUIET : UNCONF;
130}