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