oosiop_jazzio.c revision 1.1 1 /* $NetBSD: oosiop_jazzio.c,v 1.1 2003/04/06 09:55:51 tsutsui Exp $ */
2
3 /*
4 * Copyright (c) 2001 Shuichiro URATA. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/device.h>
32 #include <sys/buf.h>
33 #include <sys/malloc.h>
34
35 #include <dev/scsipi/scsi_all.h>
36 #include <dev/scsipi/scsipi_all.h>
37 #include <dev/scsipi/scsiconf.h>
38 #include <dev/scsipi/scsi_message.h>
39
40 #include <machine/cpu.h>
41 #include <machine/autoconf.h>
42 #include <machine/bus.h>
43
44 #include <dev/ic/oosiopreg.h>
45 #include <dev/ic/oosiopvar.h>
46 #include <arc/jazz/jazziovar.h>
47
48 int oosiop_jazzio_match(struct device *, struct cfdata *, void *);
49 void oosiop_jazzio_attach(struct device *, struct device *, void *);
50
51 CFATTACH_DECL(oosiop_jazzio, sizeof(struct oosiop_softc),
52 oosiop_jazzio_match, oosiop_jazzio_attach, NULL, NULL);
53 extern struct cfdriver oosiop_cd;
54
55 /*
56 * Match driver based on name
57 */
58 int
59 oosiop_jazzio_match(parent, match, aux)
60 struct device *parent;
61 struct cfdata *match;
62 void *aux;
63 {
64 struct jazzio_attach_args *ja = aux;
65
66 if (strcmp(ja->ja_name, "NCRC700") != 0)
67 return (0);
68
69 return (1);
70 }
71
72 void
73 oosiop_jazzio_attach(parent, self, aux)
74 struct device *parent;
75 struct device *self;
76 void *aux;
77 {
78 struct jazzio_attach_args *ja = aux;
79 struct oosiop_softc *sc = (void *)self;
80 int i, scid;
81
82 sc->sc_bst = ja->ja_bust;
83 sc->sc_dmat = ja->ja_dmat;
84
85 if (bus_space_map(sc->sc_bst, ja->ja_addr,
86 OOSIOP_NREGS, 0, &sc->sc_bsh) != 0) {
87 printf(": failed to map regsters\n");
88 return;
89 }
90
91 sc->sc_chip = OOSIOP_700_66;
92 sc->sc_freq = 50000000;
93
94 /* Preserve host id */
95 scid = oosiop_read_1(sc, OOSIOP_SCID);
96 for (i = 0; i < OOSIOP_NTGT; i++)
97 if (scid & (1 << i))
98 break;
99 if (i == OOSIOP_NTGT)
100 i = OOSIOP_NTGT - 1;
101
102 sc->sc_id = i;
103
104 jazzio_intr_establish(ja->ja_intr, (intr_handler_t)oosiop_intr, sc);
105
106 oosiop_attach(sc);
107 }
108