uba_cmi.c revision 1.14
11.14Smatt/*	$NetBSD: uba_cmi.c,v 1.14 2008/03/11 05:34:02 matt Exp $	   */
21.12Sagc/*
31.12Sagc * Copyright (c) 1982, 1986 The Regents of the University of California.
41.12Sagc * All rights reserved.
51.12Sagc *
61.12Sagc * Redistribution and use in source and binary forms, with or without
71.12Sagc * modification, are permitted provided that the following conditions
81.12Sagc * are met:
91.12Sagc * 1. Redistributions of source code must retain the above copyright
101.12Sagc *    notice, this list of conditions and the following disclaimer.
111.12Sagc * 2. Redistributions in binary form must reproduce the above copyright
121.12Sagc *    notice, this list of conditions and the following disclaimer in the
131.12Sagc *    documentation and/or other materials provided with the distribution.
141.12Sagc * 3. Neither the name of the University nor the names of its contributors
151.12Sagc *    may be used to endorse or promote products derived from this software
161.12Sagc *    without specific prior written permission.
171.12Sagc *
181.12Sagc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
191.12Sagc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201.12Sagc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211.12Sagc * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
221.12Sagc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231.12Sagc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241.12Sagc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251.12Sagc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261.12Sagc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271.12Sagc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281.12Sagc * SUCH DAMAGE.
291.12Sagc *
301.12Sagc *	@(#)uba.c	7.10 (Berkeley) 12/16/90
311.12Sagc *	@(#)autoconf.c	7.20 (Berkeley) 5/9/91
321.12Sagc */
331.12Sagc
341.1Sragge/*
351.1Sragge * Copyright (c) 1996 Jonathan Stone.
361.1Sragge * Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden.
371.1Sragge *
381.1Sragge * Redistribution and use in source and binary forms, with or without
391.1Sragge * modification, are permitted provided that the following conditions
401.1Sragge * are met:
411.1Sragge * 1. Redistributions of source code must retain the above copyright
421.1Sragge *    notice, this list of conditions and the following disclaimer.
431.1Sragge * 2. Redistributions in binary form must reproduce the above copyright
441.1Sragge *    notice, this list of conditions and the following disclaimer in the
451.1Sragge *    documentation and/or other materials provided with the distribution.
461.1Sragge * 3. All advertising materials mentioning features or use of this software
471.1Sragge *    must display the following acknowledgement:
481.1Sragge *	This product includes software developed by the University of
491.1Sragge *	California, Berkeley and its contributors.
501.1Sragge * 4. Neither the name of the University nor the names of its contributors
511.1Sragge *    may be used to endorse or promote products derived from this software
521.1Sragge *    without specific prior written permission.
531.1Sragge *
541.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
551.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
561.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
571.1Sragge * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
581.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
591.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
601.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
611.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
621.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
631.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
641.1Sragge * SUCH DAMAGE.
651.1Sragge *
661.1Sragge *	@(#)uba.c	7.10 (Berkeley) 12/16/90
671.1Sragge *	@(#)autoconf.c	7.20 (Berkeley) 5/9/91
681.1Sragge */
691.11Slukem
701.11Slukem#include <sys/cdefs.h>
711.14Smatt__KERNEL_RCSID(0, "$NetBSD: uba_cmi.c,v 1.14 2008/03/11 05:34:02 matt Exp $");
721.1Sragge
731.1Sragge#include <sys/param.h>
741.1Sragge#include <sys/device.h>
751.1Sragge#include <sys/systm.h>
761.1Sragge
771.1Sragge#define	_VAX_BUS_DMA_PRIVATE
781.1Sragge#include <machine/bus.h>
791.1Sragge#include <machine/mtpr.h>
801.1Sragge#include <machine/nexus.h>
811.1Sragge#include <machine/cpu.h>
821.1Sragge#include <machine/sgmap.h>
831.1Sragge
841.1Sragge#include <dev/qbus/ubavar.h>
851.1Sragge
861.4Smatt#include <vax/uba/uba_common.h>
871.1Sragge
881.5Sragge#include "locators.h"
891.5Sragge
901.1Sragge/* Some CMI-specific defines */
911.2Sragge#define	UBASIZE		((UBAPAGES + UBAIOPAGES) * VAX_NBPG)
921.2Sragge#define UMEM750(i)     	(0xfc0000 - (i) * UBASIZE)
931.2Sragge#define	UIOPAGE(x)	(UMEM750(x) + (UBAPAGES * VAX_NBPG))
941.1Sragge
951.1Sragge/*
961.1Sragge * The DW780 and DW750 are quite similar to their function from
971.1Sragge * a programmers point of view. Differencies are number of BDP's
981.1Sragge * and bus status/command registers, the latter are (partly) IPR's
991.1Sragge * on 750.
1001.1Sragge */
1011.14Smattstatic	int	dw750_match(device_t, cfdata_t, void *);
1021.14Smattstatic	void	dw750_attach(device_t, device_t, void *);
1031.14Smattstatic	void	dw750_init(struct uba_softc *);
1041.1Sragge#ifdef notyet
1051.5Sraggestatic	void	dw750_purge(struct uba_softc *, int);
1061.1Sragge#endif
1071.1Sragge
1081.14SmattCFATTACH_DECL_NEW(uba_cmi, sizeof(struct uba_vsoftc),
1091.10Sthorpej    dw750_match, dw750_attach, NULL, NULL);
1101.1Sragge
1111.1Sraggeint
1121.14Smattdw750_match(device_t parent, cfdata_t cf, void *aux)
1131.1Sragge{
1141.14Smatt	struct sbi_attach_args * const sa = aux;
1151.1Sragge
1161.5Sragge	if (cf->cf_loc[CMICF_TR] != sa->sa_nexnum &&
1171.5Sragge	    cf->cf_loc[CMICF_TR] != CMICF_TR_DEFAULT)
1181.1Sragge		return 0;
1191.1Sragge	/*
1201.1Sragge	 * The uba type is actually only telling where the uba
1211.1Sragge	 * space is in nexus space.
1221.1Sragge	 */
1231.5Sragge	if ((sa->sa_type & ~3) != NEX_UBA0)
1241.1Sragge		return 0;
1251.1Sragge
1261.1Sragge	return 1;
1271.1Sragge}
1281.1Sragge
1291.1Sraggevoid
1301.14Smattdw750_attach(device_t parent, device_t self, void *aux)
1311.1Sragge{
1321.14Smatt	struct uba_vsoftc * const sc = device_private(self);
1331.14Smatt	struct sbi_attach_args * const sa = aux;
1341.14Smatt
1351.14Smatt	aprint_normal(": DW750\n");
1361.14Smatt
1371.14Smatt	sc->uv_sc.uh_dev = self;
1381.1Sragge
1391.1Sragge	/*
1401.1Sragge	 * Fill in bus specific data.
1411.1Sragge	 */
1421.1Sragge	sc->uv_sc.uh_ubainit = dw750_init;
1431.1Sragge#ifdef notyet
1441.1Sragge	sc->uv_sc.uh_ubapurge = dw750_purge;
1451.1Sragge#endif
1461.14Smatt	sc->uv_sc.uh_iot = sa->sa_iot;
1471.1Sragge	sc->uv_sc.uh_dmat = &sc->uv_dmat;
1481.6Sragge	sc->uv_sc.uh_type = UBA_UBA;
1491.7Sragge	sc->uv_sc.uh_nr = sa->sa_type == NEX_UBA1;
1501.1Sragge
1511.1Sragge	/*
1521.1Sragge	 * Fill in variables used by the sgmap system.
1531.1Sragge	 */
1541.3Sragge	sc->uv_size = UBAPAGES * VAX_NBPG;
1551.5Sragge	sc->uv_uba = (void *)sa->sa_ioh; /* Map registers is in adaptor */
1561.1Sragge
1571.1Sragge	uba_dma_init(sc);
1581.5Sragge	uba_attach(&sc->uv_sc, UIOPAGE(sa->sa_type == NEX_UBA1));
1591.1Sragge}
1601.1Sragge
1611.1Sraggevoid
1621.5Sraggedw750_init(struct uba_softc *sc)
1631.1Sragge{
1641.1Sragge	mtpr(0, PR_IUR);
1651.1Sragge	DELAY(500000);
1661.1Sragge}
1671.1Sragge
1681.1Sragge#ifdef notyet
1691.1Sraggevoid
1701.5Sraggedw750_purge(struct uba_softc sc, int bdp)
1711.1Sragge{
1721.1Sragge	sc->uh_uba->uba_dpr[bdp] |= UBADPR_PURGE | UBADPR_NXM | UBADPR_UCE;
1731.1Sragge}
1741.1Sragge#endif
175