/*
* Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* On-board device autoconfiguration support for RMI {XLP, XLR, XLS} chips
*/
#ifdef OBIO_DEBUG
int obio_rmixl_debug = OBIO_DEBUG;
# define DPRINTF(x) do { if (obio_rmixl_debug) printf x ; } while (0)
#else
# define DPRINTF(x)
#endif
static int obio_match(device_t, cfdata_t, void *);
static void obio_attach(device_t, device_t, void *);
static int obio_print(void *, const char *);
static int obio_search(device_t, cfdata_t, const int *, void *);
static void obio_bus_init(struct obio_softc *);
static void obio_dma_init_64(bus_dma_tag_t);
static int rmixl_addr_error_intr(void *);
if (config_probe(parent, cf, &obio))
config_attach(parent, cf, &obio, obio_print, CFARGS_NONE);
return 0;
}
static void
obio_bus_init(struct obio_softc *sc)
{
struct rmixl_config *rcp = &rmixl_configuration;
static int done = 0;
int error;
if (done)
return;
done = 1;
/* obio (devio) space, Big Endian */
if (rcp->rc_obio_eb_memt.bs_cookie == 0)
rmixl_obio_eb_bus_mem_init(&rcp->rc_obio_eb_memt, rcp);
/* obio (devio) space, Little Endian */
if (rcp->rc_obio_el_memt.bs_cookie == 0)
rmixl_obio_el_bus_mem_init(&rcp->rc_obio_el_memt, rcp);
/* dma space for all memory, including >= 4GB */
if (rcp->rc_dma_tag._cookie == 0)
obio_dma_init_64(&rcp->rc_dma_tag);
rcp->rc_64bit_dmat = &rcp->rc_dma_tag;
/* dma space for addr < 4GB */
if (rcp->rc_32bit_dmat == NULL) {
error = bus_dmatag_subregion(rcp->rc_64bit_dmat,
0, __MASK(32), &rcp->rc_32bit_dmat, 0);
if (error)
panic("%s: failed to create 32bit dma tag: %d",
__func__, error);
}
/* dma space for addr < 512MB */
if (rcp->rc_29bit_dmat == NULL) {
error = bus_dmatag_subregion(rcp->rc_32bit_dmat,
0, __MASK(29), &rcp->rc_29bit_dmat, 0);
if (error)
panic("%s: failed to create 29bit dma tag: %d",
__func__, error);
}
/*
* activate error addr detection on all (configurable) devices
* preserve reserved bit fields
* note some of these bits are read-only (writes are ignored)
*/
r = RMIXL_IOREG_READ(RMIXL_ADDR_ERR_DEVICE_MASK);
r |= ~(__BITS(19,16) | __BITS(10,9) | __BITS(7,5));
RMIXL_IOREG_WRITE(RMIXL_ADDR_ERR_DEVICE_MASK, r);
/*
* enable the address error interrupts
* "upgrade" cache and CPU errors to A1
*/
#define _ADDR_ERR_DEVSTAT_A1 (__BIT(8) | __BIT(1) | __BIT(0))
#define _ADDR_ERR_RESV \
(__BITS(31,21) | __BITS(15,14) | __BITS(10,9) | __BITS(7,2))
#define _BITERR_INT_EN_RESV (__BITS(31,8) | __BIT(4))
r = RMIXL_IOREG_READ(RMIXL_ADDR_ERR_AERR0_EN);
r &= _ADDR_ERR_RESV;
r |= ~_ADDR_ERR_RESV;
RMIXL_IOREG_WRITE(RMIXL_ADDR_ERR_AERR0_EN, r);
r = RMIXL_IOREG_READ(RMIXL_ADDR_ERR_AERR0_UPG);
r &= _ADDR_ERR_RESV;
r |= _ADDR_ERR_DEVSTAT_A1;
RMIXL_IOREG_WRITE(RMIXL_ADDR_ERR_AERR0_UPG, r);
/*
* clear the log regs and the dev stat (interrupt status) regs
* "Write any value to bit[0] to clear"
*/
r = RMIXL_IOREG_READ(RMIXL_ADDR_ERR_AERR1_CLEAR);
RMIXL_IOREG_WRITE(RMIXL_ADDR_ERR_AERR1_CLEAR, r);
/*
* enable the double bit error interrupts
* (assume reserved bits, which are read-only, are ignored)
*/
r = RMIXL_IOREG_READ(RMIXL_ADDR_ERR_BITERR_INT_EN);
r &= _BITERR_INT_EN_RESV;
r |= __BITS(7,5);
RMIXL_IOREG_WRITE(RMIXL_ADDR_ERR_BITERR_INT_EN, r);
/*
* establish address error ISR
* XXX assuming "int 16 (bridge_tb)" is our irq
* XXX is true for XLS family only
*/
if (cpu_rmixls(mips_options.mips_cpu))
rmixl_intr_establish(16, 1, IPL_HIGH,
RMIXL_TRIG_LEVEL, RMIXL_POLR_HIGH,
rmixl_addr_error_intr, NULL, false);
}