1 /* $NetBSD: xcvbus.c,v 1.4 2023/12/20 14:18:38 thorpej 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.4 2023/12/20 14:18:38 thorpej Exp $");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/types.h>
38 #include <sys/device.h>
39
40 #include <sys/bus.h>
41 #include <powerpc/ibm4xx/dev/plbvar.h>
42
43 #include <evbppc/virtex/dev/xcvbusvar.h>
44
45
46 static int xcvbus_match(device_t, cfdata_t, void *);
47 static void xcvbus_attach(device_t, device_t, void *);
48
49
50 CFATTACH_DECL_NEW(xcvbus, 0,
51 xcvbus_match, xcvbus_attach, NULL, NULL);
52
53
54 static int
xcvbus_match(device_t parent,cfdata_t cf,void * aux)55 xcvbus_match(device_t parent, cfdata_t cf, void *aux)
56 {
57 struct plb_attach_args *paa = aux;
58
59 return (strcmp(paa->plb_name, cf->cf_name) == 0);
60 }
61
62 static void
xcvbus_attach(device_t parent,device_t self,void * aux)63 xcvbus_attach(device_t parent, device_t self, void *aux)
64 {
65 struct plb_attach_args *paa = aux;
66
67 printf(": Xilinx Virtex FPGA\n");
68
69 virtex_autoconf(self, paa);
70 }
71
72 /*
73 * Public interface.
74 */
75
76 int
xcvbus_print(void * aux,const char * pnp)77 xcvbus_print(void *aux, const char *pnp)
78 {
79 struct xcvbus_attach_args *vaa = aux;
80
81 if (pnp)
82 aprint_normal("%s at %s", vaa->vaa_name, pnp);
83
84 if (vaa->vaa_addr != -1) {
85 if (vaa->_vaa_is_dcr)
86 aprint_normal(" dcr 0x%x", vaa->vaa_iot->pbs_base);
87 else
88 aprint_normal(" mem 0x%x", vaa->vaa_addr);
89 }
90
91 if (vaa->vaa_intr != -1)
92 aprint_normal(" intr %d", vaa->vaa_intr);
93 if (vaa->vaa_tx_dmac != NULL)
94 aprint_normal(" tx %d", vaa->vaa_tx_dmac->dmac_chan);
95 if (vaa->vaa_rx_dmac != NULL)
96 aprint_normal(" rx %d", vaa->vaa_rx_dmac->dmac_chan);
97
98 return (UNCONF);
99 }
100
101 int
xcvbus_child_match(device_t parent,cfdata_t cf,void * aux)102 xcvbus_child_match(device_t parent, cfdata_t cf, void *aux)
103 {
104 struct xcvbus_attach_args *vaa = aux;
105
106 return (strcmp(vaa->vaa_name, cf->cf_name) == 0);
107 }
108