Home | History | Annotate | Line # | Download | only in xscale
ixp425_ixme.c revision 1.3
      1  1.3  dyoung /*	$NetBSD: ixp425_ixme.c,v 1.3 2011/07/01 20:32:51 dyoung Exp $	*/
      2  1.1     scw 
      3  1.1     scw /*-
      4  1.1     scw  * Copyright (c) 2006 The NetBSD Foundation, Inc.
      5  1.1     scw  * All rights reserved.
      6  1.1     scw  *
      7  1.1     scw  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1     scw  * by Steve C. Woodford.
      9  1.1     scw  *
     10  1.1     scw  * Redistribution and use in source and binary forms, with or without
     11  1.1     scw  * modification, are permitted provided that the following conditions
     12  1.1     scw  * are met:
     13  1.1     scw  * 1. Redistributions of source code must retain the above copyright
     14  1.1     scw  *    notice, this list of conditions and the following disclaimer.
     15  1.1     scw  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1     scw  *    notice, this list of conditions and the following disclaimer in the
     17  1.1     scw  *    documentation and/or other materials provided with the distribution.
     18  1.1     scw  *
     19  1.1     scw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1     scw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1     scw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1     scw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1     scw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1     scw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1     scw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1     scw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1     scw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1     scw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1     scw  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1     scw  */
     31  1.1     scw 
     32  1.1     scw #include <sys/cdefs.h>
     33  1.3  dyoung __KERNEL_RCSID(0, "$NetBSD: ixp425_ixme.c,v 1.3 2011/07/01 20:32:51 dyoung Exp $");
     34  1.1     scw 
     35  1.1     scw #include <sys/param.h>
     36  1.1     scw #include <sys/systm.h>
     37  1.1     scw #include <sys/kernel.h>
     38  1.1     scw #include <sys/device.h>
     39  1.1     scw 
     40  1.1     scw #define _ARM32_BUS_DMA_PRIVATE
     41  1.3  dyoung #include <sys/bus.h>
     42  1.1     scw 
     43  1.1     scw #include <arm/xscale/ixp425var.h>
     44  1.1     scw #include <arm/xscale/ixp425_qmgr.h>
     45  1.1     scw #include <arm/xscale/ixp425_ixmevar.h>
     46  1.1     scw 
     47  1.1     scw #include "locators.h"
     48  1.1     scw 
     49  1.1     scw static int	ixme_match(struct device *, struct cfdata *, void *);
     50  1.1     scw static void	ixme_attach(struct device *, struct device *, void *);
     51  1.1     scw static int	ixme_search(struct device *, struct cfdata *, const int *,
     52  1.1     scw 		    void *);
     53  1.1     scw static int	ixme_print(void *, const char *);
     54  1.1     scw 
     55  1.1     scw struct ixme_softc {
     56  1.1     scw 	struct device sc_dev;
     57  1.1     scw 	struct arm32_dma_range sc_dr;
     58  1.1     scw 	struct arm32_bus_dma_tag sc_dt;
     59  1.1     scw 	void *sc_qmgr;
     60  1.1     scw };
     61  1.1     scw 
     62  1.1     scw CFATTACH_DECL(ixme, sizeof(struct ixme_softc),
     63  1.1     scw     ixme_match, ixme_attach, NULL, NULL);
     64  1.1     scw 
     65  1.1     scw static int
     66  1.1     scw ixme_match(struct device *parent, struct cfdata *self, void *arg)
     67  1.1     scw {
     68  1.1     scw 
     69  1.1     scw 	return (1);
     70  1.1     scw }
     71  1.1     scw 
     72  1.1     scw static void
     73  1.1     scw ixme_attach(struct device *parent, struct device *self, void *arg)
     74  1.1     scw {
     75  1.1     scw 	struct ixme_softc *sc = (void *)self;
     76  1.1     scw 	extern paddr_t physical_start, physical_end;
     77  1.1     scw 
     78  1.1     scw 	aprint_naive("\n");
     79  1.1     scw 	aprint_normal(": IXP4xx MicroEngine Support\n");
     80  1.1     scw 
     81  1.1     scw 	sc->sc_qmgr = ixpqmgr_init(&ixp425_bs_tag);
     82  1.1     scw 	if (sc->sc_qmgr == NULL) {
     83  1.1     scw 		panic("%s: ixme_attach: Failed to init Queue Manager",
     84  1.1     scw 		    sc->sc_dev.dv_xname);
     85  1.1     scw 	}
     86  1.1     scw 
     87  1.1     scw 	sc->sc_dr.dr_sysbase = physical_start;
     88  1.1     scw 	sc->sc_dr.dr_busbase = 0;
     89  1.1     scw 	sc->sc_dr.dr_len = physical_end - physical_start;
     90  1.1     scw 	sc->sc_dt._ranges = &sc->sc_dr;
     91  1.1     scw 	sc->sc_dt._nranges = 1;
     92  1.1     scw 
     93  1.1     scw 	sc->sc_dt._dmamap_create = _bus_dmamap_create;
     94  1.1     scw 	sc->sc_dt._dmamap_destroy = _bus_dmamap_destroy;
     95  1.1     scw 	sc->sc_dt._dmamap_load = _bus_dmamap_load;
     96  1.1     scw 	sc->sc_dt._dmamap_load_mbuf = _bus_dmamap_load_mbuf;
     97  1.1     scw 	sc->sc_dt._dmamap_load_uio = _bus_dmamap_load_uio;
     98  1.1     scw 	sc->sc_dt._dmamap_load_raw = _bus_dmamap_load_raw;
     99  1.1     scw 	sc->sc_dt._dmamap_unload = _bus_dmamap_unload;
    100  1.1     scw 	sc->sc_dt._dmamap_sync_pre = _bus_dmamap_sync;
    101  1.1     scw 	sc->sc_dt._dmamap_sync_post = NULL;
    102  1.1     scw 	sc->sc_dt._dmamem_alloc = _bus_dmamem_alloc;
    103  1.1     scw 	sc->sc_dt._dmamem_free = _bus_dmamem_free;
    104  1.1     scw 	sc->sc_dt._dmamem_map = _bus_dmamem_map;
    105  1.1     scw 	sc->sc_dt._dmamem_unmap = _bus_dmamem_unmap;
    106  1.1     scw 	sc->sc_dt._dmamem_mmap = _bus_dmamem_mmap;
    107  1.1     scw 
    108  1.1     scw 	config_search_ia(ixme_search, self, "ixme", NULL);
    109  1.1     scw }
    110  1.1     scw 
    111  1.1     scw static int
    112  1.1     scw ixme_search(struct device *parent, struct cfdata *cf, const int *ldesc,
    113  1.1     scw     void *arg)
    114  1.1     scw {
    115  1.1     scw 	struct ixme_softc *sc = (void *)parent;
    116  1.1     scw 	struct ixme_attach_args ixa;
    117  1.1     scw 
    118  1.1     scw 	if (cf->cf_loc[IXMECF_NPE] < 0 || cf->cf_loc[IXMECF_NPE] > 2)
    119  1.1     scw 		return (0);
    120  1.1     scw 
    121  1.1     scw 	ixa.ixa_iot = &ixp425_bs_tag;
    122  1.1     scw 	ixa.ixa_dt = &sc->sc_dt;
    123  1.1     scw 	ixa.ixa_npe = cf->cf_loc[IXMECF_NPE];
    124  1.1     scw 
    125  1.1     scw 	if (config_match(parent, cf, &ixa) > 0) {
    126  1.1     scw 		config_attach(parent, cf, &ixa, ixme_print);
    127  1.1     scw 		return (1);
    128  1.1     scw 	}
    129  1.1     scw 
    130  1.1     scw 	return (0);
    131  1.1     scw }
    132  1.1     scw 
    133  1.1     scw static int
    134  1.1     scw ixme_print(void *arg, const char *name)
    135  1.1     scw {
    136  1.1     scw 	struct ixme_attach_args *ixa = arg;
    137  1.1     scw 
    138  1.1     scw 	aprint_normal(" NPE-%c", 'A' + ixa->ixa_npe);
    139  1.1     scw 
    140  1.1     scw 	return (UNCONF);
    141  1.1     scw }
    142