Home | History | Annotate | Line # | Download | only in dev
xcvbus.c revision 1.1.2.2
      1  1.1.2.2  yamt /* 	$NetBSD: xcvbus.c,v 1.1.2.2 2006/12/10 07:15:54 yamt Exp $ */
      2  1.1.2.2  yamt 
      3  1.1.2.2  yamt /*
      4  1.1.2.2  yamt  * Copyright (c) 2006 Jachym Holecek
      5  1.1.2.2  yamt  * All rights reserved.
      6  1.1.2.2  yamt  *
      7  1.1.2.2  yamt  * Written for DFC Design, s.r.o.
      8  1.1.2.2  yamt  *
      9  1.1.2.2  yamt  * Redistribution and use in source and binary forms, with or without
     10  1.1.2.2  yamt  * modification, are permitted provided that the following conditions
     11  1.1.2.2  yamt  * are met:
     12  1.1.2.2  yamt  *
     13  1.1.2.2  yamt  * 1. Redistributions of source code must retain the above copyright
     14  1.1.2.2  yamt  *    notice, this list of conditions and the following disclaimer.
     15  1.1.2.2  yamt  *
     16  1.1.2.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1.2.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     18  1.1.2.2  yamt  *    documentation and/or other materials provided with the distribution.
     19  1.1.2.2  yamt  *
     20  1.1.2.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.1.2.2  yamt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.1.2.2  yamt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.1.2.2  yamt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.1.2.2  yamt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.1.2.2  yamt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.1.2.2  yamt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.1.2.2  yamt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.1.2.2  yamt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.1.2.2  yamt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.1.2.2  yamt  */
     31  1.1.2.2  yamt 
     32  1.1.2.2  yamt #include <sys/cdefs.h>
     33  1.1.2.2  yamt __KERNEL_RCSID(0, "$NetBSD: xcvbus.c,v 1.1.2.2 2006/12/10 07:15:54 yamt Exp $");
     34  1.1.2.2  yamt 
     35  1.1.2.2  yamt #include <sys/param.h>
     36  1.1.2.2  yamt #include <sys/systm.h>
     37  1.1.2.2  yamt #include <sys/types.h>
     38  1.1.2.2  yamt #include <sys/device.h>
     39  1.1.2.2  yamt #include <sys/extent.h>
     40  1.1.2.2  yamt #include <sys/malloc.h>
     41  1.1.2.2  yamt 
     42  1.1.2.2  yamt #include <machine/bus.h>
     43  1.1.2.2  yamt #include <powerpc/ibm4xx/dev/plbvar.h>
     44  1.1.2.2  yamt 
     45  1.1.2.2  yamt #include <evbppc/virtex/dev/xcvbusvar.h>
     46  1.1.2.2  yamt 
     47  1.1.2.2  yamt 
     48  1.1.2.2  yamt static int	xcvbus_match(device_t, cfdata_t, void *);
     49  1.1.2.2  yamt static void	xcvbus_attach(device_t, device_t, void *);
     50  1.1.2.2  yamt 
     51  1.1.2.2  yamt 
     52  1.1.2.2  yamt CFATTACH_DECL(xcvbus, sizeof(struct device),
     53  1.1.2.2  yamt     xcvbus_match, xcvbus_attach, NULL, NULL);
     54  1.1.2.2  yamt 
     55  1.1.2.2  yamt 
     56  1.1.2.2  yamt static int
     57  1.1.2.2  yamt xcvbus_match(device_t parent, cfdata_t cf, void *aux)
     58  1.1.2.2  yamt {
     59  1.1.2.2  yamt 	struct plb_attach_args 		*paa = aux;
     60  1.1.2.2  yamt 
     61  1.1.2.2  yamt 	return (strcmp(paa->plb_name, cf->cf_name) == 0);
     62  1.1.2.2  yamt }
     63  1.1.2.2  yamt 
     64  1.1.2.2  yamt static void
     65  1.1.2.2  yamt xcvbus_attach(device_t parent, device_t self, void *aux)
     66  1.1.2.2  yamt {
     67  1.1.2.2  yamt 	struct plb_attach_args 		*paa = aux;
     68  1.1.2.2  yamt 
     69  1.1.2.2  yamt 	printf(": Xilinx Virtex FPGA\n");
     70  1.1.2.2  yamt 
     71  1.1.2.2  yamt 	virtex_autoconf(self, paa);
     72  1.1.2.2  yamt }
     73  1.1.2.2  yamt 
     74  1.1.2.2  yamt /*
     75  1.1.2.2  yamt  * Public interface.
     76  1.1.2.2  yamt  */
     77  1.1.2.2  yamt 
     78  1.1.2.2  yamt int
     79  1.1.2.2  yamt xcvbus_print(void *aux, const char *pnp)
     80  1.1.2.2  yamt {
     81  1.1.2.2  yamt 	struct xcvbus_attach_args 	*vaa = aux;
     82  1.1.2.2  yamt 
     83  1.1.2.2  yamt 	if (pnp)
     84  1.1.2.2  yamt 		aprint_normal("%s at %s", vaa->vaa_name, pnp);
     85  1.1.2.2  yamt 
     86  1.1.2.2  yamt 	if (vaa->vaa_addr != -1) {
     87  1.1.2.2  yamt 		if (vaa->_vaa_is_dcr)
     88  1.1.2.2  yamt 			aprint_normal(" dcr 0x%x", vaa->vaa_iot->pbs_base);
     89  1.1.2.2  yamt 		else
     90  1.1.2.2  yamt 			aprint_normal(" mem 0x%x", vaa->vaa_addr);
     91  1.1.2.2  yamt 	}
     92  1.1.2.2  yamt 
     93  1.1.2.2  yamt 	if (vaa->vaa_intr != -1)
     94  1.1.2.2  yamt 		aprint_normal(" intr %d", vaa->vaa_intr);
     95  1.1.2.2  yamt 	if (vaa->vaa_tx_dmac != NULL)
     96  1.1.2.2  yamt 		aprint_normal(" tx %d", vaa->vaa_tx_dmac->dmac_chan);
     97  1.1.2.2  yamt 	if (vaa->vaa_rx_dmac != NULL)
     98  1.1.2.2  yamt 		aprint_normal(" rx %d", vaa->vaa_rx_dmac->dmac_chan);
     99  1.1.2.2  yamt 
    100  1.1.2.2  yamt 	return (UNCONF);
    101  1.1.2.2  yamt }
    102  1.1.2.2  yamt 
    103  1.1.2.2  yamt int
    104  1.1.2.2  yamt xcvbus_child_match(struct device *parent, struct cfdata *cf, void *aux)
    105  1.1.2.2  yamt {
    106  1.1.2.2  yamt 	struct xcvbus_attach_args *vaa = aux;
    107  1.1.2.2  yamt 
    108  1.1.2.2  yamt 	return (strcmp(vaa->vaa_name, cf->cf_name) == 0);
    109  1.1.2.2  yamt }
    110