4 * Copyright (c) 2009 Stephen M. Rumble
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * IOC1/IOC2 chips on IP4 and IP6/IP10 machines. This interfaces the SCSI
29 * and Ethernet controllers, performs DMA for the former, and does address
30 * space translation for the latter (maps the lance memory space to physical
33 * 'I/O Controller' is a sufficiently generic name that SGI created another
34 * one for IP24, which basically stuffed a bunch of miscellany on an ASIC.
35 * So, we'll call ourselves 'Old IOC' and hope that there wasn't an even older
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD$");
42 #include <sys/param.h>
43 #include <sys/device.h>
45 #define _SGIMIPS_BUS_DMA_PRIVATE
46 #include <machine/cpu.h>
47 #include <machine/locore.h>
48 #include <machine/autoconf.h>
49 #include <machine/bus.h>
50 #include <machine/machtype.h>
51 #include <machine/sysconf.h>
53 #include <sgimips/ioc/oiocreg.h>
54 #include <sgimips/ioc/oiocvar.h>
63 bus_space_tag_t sc_iot
;
64 bus_space_handle_t sc_ioh
;
67 static int oioc_match(struct device
*, struct cfdata
*, void *);
68 static void oioc_attach(struct device
*, struct device
*, void *);
69 static int oioc_print(void *, const char *);
71 CFATTACH_DECL(oioc
, sizeof(struct oioc_softc
),
72 oioc_match
, oioc_attach
, NULL
, NULL
);
84 oioc_match(struct device
* parent
, struct cfdata
* match
, void *aux
)
89 case MACH_SGI_IP6
| MACH_SGI_IP10
:
97 oioc_attach(struct device
* parent
, struct device
* self
, void *aux
)
99 struct oioc_softc
*sc
= (struct oioc_softc
*)self
;
100 struct mainbus_attach_args
*ma
= aux
;
104 sc
->sc_iot
= SGIMIPS_BUS_SPACE_NORMAL
;
105 if (bus_space_map(sc
->sc_iot
, ma
->ma_addr
, 0,
106 BUS_SPACE_MAP_LINEAR
, &sc
->sc_ioh
))
107 panic("oioc_attach: could not allocate memory\n");
109 if (platform
.badaddr((void *)MIPS_PHYS_TO_KSEG1(ma
->ma_addr
+
115 printf("\noioc0: Old SGI IOC%d\n", oiocrev
);
120 /* Try to enable burst mode. If we can't, we can't... */
121 reg1
= 12 << OIOC2_CONFIG_HIWAT_SHFT
;
122 reg1
|= OIOC2_CONFIG_BURST_MASK
;
123 bus_space_write_4(sc
->sc_iot
, sc
->sc_ioh
, OIOC2_CONFIG
, reg1
);
125 reg2
= bus_space_read_4(sc
->sc_iot
, sc
->sc_ioh
, OIOC2_CONFIG
);
126 if ((reg2
& (reg1
| OIOC2_CONFIG_NOSYNC_MASK
)) == reg1
)
127 sc
->sc_burst_dma
= 1;
129 snprintb(buf
, sizeof(buf
),
138 (u_quad_t
)reg2
& 0xffffffff);
139 printf("oioc0: %s\n", buf
);
142 printf("oioc0: Burst DMA %ssupported\n",
143 (sc
->sc_burst_dma
) ? "" : "not ");
145 for (i
= 0; oioc_devices
[i
].od_name
!= NULL
; i
++) {
146 struct oioc_attach_args oa
;
148 oa
.oa_name
= oioc_devices
[i
].od_name
;
149 oa
.oa_irq
= oioc_devices
[i
].od_irq
;
150 oa
.oa_burst_dma
= sc
->sc_burst_dma
;
151 oa
.oa_st
= SGIMIPS_BUS_SPACE_NORMAL
;
152 oa
.oa_sh
= sc
->sc_ioh
;
153 oa
.oa_dmat
= &sgimips_default_bus_dma_tag
;
154 config_found_ia(self
, "oioc", &oa
, oioc_print
);
159 oioc_print(void *aux
, const char *pnp
)
161 struct oioc_attach_args
*oa
= aux
;
164 printf("%s at %s", oa
->oa_name
, pnp
);