2011-07-11 03:13:22 +04:00
|
|
|
/* $NetBSD: aubus.c,v 1.23 2011/07/10 23:13:23 matt Exp $ */
|
2006-02-07 02:23:53 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2006 Itronix Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Portions written by Garrett D'Amore for Itronix 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. The name of Itronix Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific
|
|
|
|
* prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY ITRONIX 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 ITRONIX 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.
|
|
|
|
*/
|
2002-07-29 19:39:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2001 Wasabi Systems, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Simon Burge 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 by Christopher G. Demetriou
|
|
|
|
* for the NetBSD Project.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
|
|
|
|
*/
|
|
|
|
|
2003-07-15 06:43:09 +04:00
|
|
|
#include <sys/cdefs.h>
|
2011-07-11 03:13:22 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: aubus.c,v 1.23 2011/07/10 23:13:23 matt Exp $");
|
2003-07-15 06:43:09 +04:00
|
|
|
|
2002-07-29 19:39:11 +04:00
|
|
|
#include "locators.h"
|
2011-07-11 03:13:22 +04:00
|
|
|
#define _MIPS_BUS_DMA_PRIVATE
|
2002-07-29 19:39:11 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
2011-07-11 03:13:22 +04:00
|
|
|
#include <sys/bus.h>
|
2002-07-29 19:39:11 +04:00
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/extent.h>
|
|
|
|
#include <sys/malloc.h>
|
2011-07-11 03:13:22 +04:00
|
|
|
#include <sys/systm.h>
|
2002-07-29 19:39:11 +04:00
|
|
|
|
2011-07-11 03:13:22 +04:00
|
|
|
#include <mips/locore.h>
|
2002-07-29 19:39:11 +04:00
|
|
|
#include <mips/alchemy/include/aureg.h>
|
2006-02-07 02:23:53 +03:00
|
|
|
#include <mips/alchemy/include/auvar.h>
|
2002-07-29 19:39:11 +04:00
|
|
|
#include <mips/alchemy/include/aubusvar.h>
|
|
|
|
|
2011-07-11 03:13:22 +04:00
|
|
|
static int aubus_match(device_t, cfdata_t, void *);
|
2011-02-20 10:48:33 +03:00
|
|
|
static void aubus_attach(device_t, device_t, void *);
|
2002-07-29 19:39:11 +04:00
|
|
|
static int aubus_print(void *, const char *);
|
|
|
|
|
2011-02-20 10:48:33 +03:00
|
|
|
CFATTACH_DECL_NEW(aubus, 0,
|
2002-10-02 08:55:47 +04:00
|
|
|
aubus_match, aubus_attach, NULL, NULL);
|
2002-07-29 19:39:11 +04:00
|
|
|
|
|
|
|
bus_space_tag_t aubus_st; /* XXX */
|
2011-02-20 10:48:33 +03:00
|
|
|
struct mips_bus_dma_tag aubus_mdt = {
|
|
|
|
._dmamap_ops = _BUS_DMAMAP_OPS_INITIALIZER,
|
|
|
|
._dmamem_ops = _BUS_DMAMEM_OPS_INITIALIZER,
|
|
|
|
._dmatag_ops = _BUS_DMATAG_OPS_INITIALIZER,
|
|
|
|
};
|
2002-07-29 19:39:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Probe for the aubus; always succeeds.
|
|
|
|
*/
|
|
|
|
static int
|
2011-07-11 03:13:22 +04:00
|
|
|
aubus_match(device_t parent, cfdata_t match, void *aux)
|
2002-07-29 19:39:11 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach the aubus.
|
|
|
|
*/
|
|
|
|
static void
|
2011-02-20 10:48:33 +03:00
|
|
|
aubus_attach(device_t parent, device_t self, void *aux)
|
2002-07-29 19:39:11 +04:00
|
|
|
{
|
|
|
|
struct aubus_attach_args aa;
|
2011-07-11 03:13:22 +04:00
|
|
|
device_t sc = self;
|
2006-02-07 02:23:53 +03:00
|
|
|
struct au_chipdep *chip;
|
|
|
|
const struct au_dev *ad;
|
2005-08-25 22:35:38 +04:00
|
|
|
int locs[AUBUSCF_NLOCS];
|
2002-07-29 19:39:11 +04:00
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
2006-02-07 02:23:53 +03:00
|
|
|
chip = au_chipdep();
|
|
|
|
KASSERT(chip != NULL);
|
2002-07-29 19:39:11 +04:00
|
|
|
|
2011-02-20 10:48:33 +03:00
|
|
|
aubus_mdt._cookie = sc;
|
|
|
|
|
2006-02-07 02:23:53 +03:00
|
|
|
for (ad = chip->devices; ad->name != NULL; ad++) {
|
2002-07-29 19:39:11 +04:00
|
|
|
aa.aa_name = ad->name;
|
|
|
|
aa.aa_st = aubus_st;
|
2003-04-01 21:29:11 +04:00
|
|
|
aa.aa_dt = &aubus_mdt;
|
2002-07-29 19:39:11 +04:00
|
|
|
aa.aa_addrs[0] = ad->addr[0];
|
|
|
|
aa.aa_addrs[1] = ad->addr[1];
|
|
|
|
aa.aa_addrs[2] = ad->addr[2];
|
|
|
|
aa.aa_irq[0] = ad->irq[0];
|
|
|
|
aa.aa_irq[1] = ad->irq[1];
|
|
|
|
|
2005-08-25 22:35:38 +04:00
|
|
|
locs[AUBUSCF_ADDR] = ad->addr[0];
|
2004-09-13 18:57:31 +04:00
|
|
|
|
2005-08-25 22:35:38 +04:00
|
|
|
(void) config_found_sm_loc(self, "aubus", locs, &aa,
|
2005-08-26 15:49:13 +04:00
|
|
|
aubus_print, config_stdsubmatch);
|
2002-07-29 19:39:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
aubus_print(void *aux, const char *pnp)
|
|
|
|
{
|
|
|
|
struct aubus_attach_args *aa = aux;
|
|
|
|
|
|
|
|
if (pnp)
|
2003-01-01 04:47:30 +03:00
|
|
|
aprint_normal("%s at %s", aa->aa_name, pnp);
|
2002-07-29 19:39:11 +04:00
|
|
|
|
|
|
|
if (aa->aa_addr != AUBUSCF_ADDR_DEFAULT)
|
2011-02-20 10:48:33 +03:00
|
|
|
aprint_normal(" addr 0x%"PRIxBUSADDR, aa->aa_addr);
|
2002-07-29 19:39:11 +04:00
|
|
|
if (aa->aa_irq[0] >= 0)
|
2003-01-01 04:47:30 +03:00
|
|
|
aprint_normal(" irq %d", aa->aa_irq[0]);
|
2002-07-29 19:39:11 +04:00
|
|
|
if (aa->aa_irq[1] >= 0)
|
2003-01-01 04:47:30 +03:00
|
|
|
aprint_normal(",%d", aa->aa_irq[1]);
|
2002-07-29 19:39:11 +04:00
|
|
|
return (UNCONF);
|
|
|
|
}
|
2003-04-01 21:29:11 +04:00
|
|
|
|
2011-02-20 10:48:33 +03:00
|
|
|
#if 0
|
2003-04-01 21:29:11 +04:00
|
|
|
void
|
2011-02-20 10:48:33 +03:00
|
|
|
aubus_alloc_dma_tag(device_t sc, bus_dma_tag_t pdt)
|
2003-04-01 21:29:11 +04:00
|
|
|
{
|
|
|
|
bus_dma_tag_t t;
|
|
|
|
|
|
|
|
t = pdt;
|
|
|
|
t->_cookie = sc;
|
2003-04-02 06:18:52 +04:00
|
|
|
t->_wbase = 0; /* XXX */
|
|
|
|
t->_physbase = 0; /* XXX */
|
|
|
|
t->_wsize = MIPS_KSEG1_START - MIPS_KSEG0_START;
|
|
|
|
t->_dmamap_create = _bus_dmamap_create;
|
|
|
|
t->_dmamap_destroy = _bus_dmamap_destroy;
|
|
|
|
t->_dmamap_load = _bus_dmamap_load;
|
|
|
|
t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf;
|
|
|
|
t->_dmamap_load_uio = _bus_dmamap_load_uio;
|
|
|
|
t->_dmamap_load_raw = _bus_dmamap_load_raw;
|
|
|
|
t->_dmamap_unload = _bus_dmamap_unload;
|
|
|
|
t->_dmamap_sync = _bus_dmamap_sync;
|
|
|
|
t->_dmamem_alloc = _bus_dmamem_alloc;
|
|
|
|
t->_dmamem_free = _bus_dmamem_free;
|
|
|
|
t->_dmamem_map = _bus_dmamem_map;
|
|
|
|
t->_dmamem_unmap = _bus_dmamem_unmap;
|
|
|
|
t->_dmamem_mmap = _bus_dmamem_mmap;
|
2003-04-01 21:29:11 +04:00
|
|
|
}
|
2011-02-20 10:48:33 +03:00
|
|
|
#endif
|