Wed Jan 1 12:46:44 2020 UTC ()
Quiet chatty printfs


(jmcneill)
diff -r1.5 -r1.6 src/sys/dev/fdt/fdt_port.c

cvs diff -r1.5 -r1.6 src/sys/dev/fdt/fdt_port.c (expand / switch to unified diff)

--- src/sys/dev/fdt/fdt_port.c 2019/12/15 14:18:16 1.5
+++ src/sys/dev/fdt/fdt_port.c 2020/01/01 12:46:44 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fdt_port.c,v 1.5 2019/12/15 14:18:16 jakllsch Exp $ */ 1/* $NetBSD: fdt_port.c,v 1.6 2020/01/01 12:46:44 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Manuel Bouyer. 8 * by Manuel Bouyer.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * ports and endpoints management. from 33 * ports and endpoints management. from
34 * linux/Documentation/devicetree/bindings/graph.txt 34 * linux/Documentation/devicetree/bindings/graph.txt
35 * Given a device and its node, it enumerates all ports and endpoints for this 35 * Given a device and its node, it enumerates all ports and endpoints for this
36 * device, and register connections with the remote endpoints. 36 * device, and register connections with the remote endpoints.
37 */ 37 */
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40 40
41__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.5 2019/12/15 14:18:16 jakllsch Exp $"); 41__KERNEL_RCSID(1, "$NetBSD: fdt_port.c,v 1.6 2020/01/01 12:46:44 jmcneill Exp $");
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/device.h> 45#include <sys/device.h>
46#include <sys/bus.h> 46#include <sys/bus.h>
47#include <sys/kmem.h> 47#include <sys/kmem.h>
48 48
49#include <dev/fdt/fdtvar.h> 49#include <dev/fdt/fdtvar.h>
50#include <dev/fdt/fdt_port.h> 50#include <dev/fdt/fdt_port.h>
51 51
52struct fdt_endpoint; 52struct fdt_endpoint;
53 53
54struct fdt_port { 54struct fdt_port {
@@ -180,45 +180,45 @@ fdt_endpoint_activate(struct fdt_endpoin @@ -180,45 +180,45 @@ fdt_endpoint_activate(struct fdt_endpoin
180 struct fdt_endpoint *rep = fdt_endpoint_remote(ep); 180 struct fdt_endpoint *rep = fdt_endpoint_remote(ep);
181 struct fdt_device_ports *rdp; 181 struct fdt_device_ports *rdp;
182 int error = 0; 182 int error = 0;
183 183
184 if (rep == NULL) 184 if (rep == NULL)
185 return ENODEV; 185 return ENODEV;
186 186
187 KASSERT(ep->ep_active == rep->ep_active); 187 KASSERT(ep->ep_active == rep->ep_active);
188 KASSERT(ep->ep_enabled == rep->ep_enabled); 188 KASSERT(ep->ep_enabled == rep->ep_enabled);
189 if (!activate && ep->ep_enabled) 189 if (!activate && ep->ep_enabled)
190 return EBUSY; 190 return EBUSY;
191 191
192 rdp = rep->ep_port->port_dp; 192 rdp = rep->ep_port->port_dp;
193 device_printf(rdp->dp_dev, "activating port %d endpoint %d\n", 193 aprint_debug_dev(rdp->dp_dev, "activating port %d endpoint %d\n",
194 fdt_endpoint_port_index(rep), fdt_endpoint_index(rep)); 194 fdt_endpoint_port_index(rep), fdt_endpoint_index(rep));
195 if (rdp->dp_ep_activate) 195 if (rdp->dp_ep_activate)
196 error = rdp->dp_ep_activate(rdp->dp_dev, rep, activate); 196 error = rdp->dp_ep_activate(rdp->dp_dev, rep, activate);
197 197
198 if (error == 0) 198 if (error == 0)
199 rep->ep_active = ep->ep_active = activate; 199 rep->ep_active = ep->ep_active = activate;
200 return error; 200 return error;
201} 201}
202 202
203int 203int
204fdt_endpoint_activate_direct(struct fdt_endpoint *ep, bool activate) 204fdt_endpoint_activate_direct(struct fdt_endpoint *ep, bool activate)
205{ 205{
206 struct fdt_device_ports *dp; 206 struct fdt_device_ports *dp;
207 int error = 0; 207 int error = 0;
208 208
209 dp = ep->ep_port->port_dp; 209 dp = ep->ep_port->port_dp;
210device_printf(dp->dp_dev, "activating port %d endpoint %d (direct)\n", 210 aprint_debug_dev(dp->dp_dev, "activating port %d endpoint %d (direct)\n",
211 fdt_endpoint_port_index(ep), fdt_endpoint_index(ep)); 211 fdt_endpoint_port_index(ep), fdt_endpoint_index(ep));
212 if (dp->dp_ep_activate) 212 if (dp->dp_ep_activate)
213 error = dp->dp_ep_activate(dp->dp_dev, ep, activate); 213 error = dp->dp_ep_activate(dp->dp_dev, ep, activate);
214 214
215 return error; 215 return error;
216} 216}
217 217
218int 218int
219fdt_endpoint_enable(struct fdt_endpoint *ep, bool enable) 219fdt_endpoint_enable(struct fdt_endpoint *ep, bool enable)
220{ 220{
221 struct fdt_endpoint *rep = fdt_endpoint_remote(ep); 221 struct fdt_endpoint *rep = fdt_endpoint_remote(ep);
222 struct fdt_device_ports *rdp; 222 struct fdt_device_ports *rdp;
223 int error = 0; 223 int error = 0;
224 224
@@ -362,28 +362,28 @@ fdt_endpoints_register(int phandle, stru @@ -362,28 +362,28 @@ fdt_endpoints_register(int phandle, stru
362 ep->ep_rphandle = fdtbus_get_phandle(child, "remote-endpoint"); 362 ep->ep_rphandle = fdtbus_get_phandle(child, "remote-endpoint");
363 ep->ep_rep = fdt_endpoint_get_from_phandle( 363 ep->ep_rep = fdt_endpoint_get_from_phandle(
364 port->port_ep[i].ep_rphandle); 364 port->port_ep[i].ep_rphandle);
365 rep = ep->ep_rep; 365 rep = ep->ep_rep;
366 if (rep != NULL && rep->ep_rep != NULL) { 366 if (rep != NULL && rep->ep_rep != NULL) {
367 aprint_error("%s: ", ep_name(ep, buf, sizeof(buf))); 367 aprint_error("%s: ", ep_name(ep, buf, sizeof(buf)));
368 aprint_error("remote endpoint %s ", 368 aprint_error("remote endpoint %s ",
369 ep_name(rep, buf, sizeof(buf))); 369 ep_name(rep, buf, sizeof(buf)));
370 aprint_error("already connected to %s\n", 370 aprint_error("already connected to %s\n",
371 ep_name(rep->ep_rep, buf, sizeof(buf))); 371 ep_name(rep->ep_rep, buf, sizeof(buf)));
372 } else if (rep != NULL) { 372 } else if (rep != NULL) {
373 rep->ep_rep = ep; 373 rep->ep_rep = ep;
374 rep->ep_rphandle = child; 374 rep->ep_rphandle = child;
375 aprint_verbose("%s ", ep_name(ep, buf, sizeof(buf))); 375 aprint_debug("%s ", ep_name(ep, buf, sizeof(buf)));
376 aprint_verbose("connected to %s\n", 376 aprint_debug("connected to %s\n",
377 ep_name(rep, buf, sizeof(buf))); 377 ep_name(rep, buf, sizeof(buf)));
378 if (rep->ep_type == EP_OTHER) 378 if (rep->ep_type == EP_OTHER)
379 rep->ep_type = ep->ep_type; 379 rep->ep_type = ep->ep_type;
380 else if (ep->ep_type == EP_OTHER) 380 else if (ep->ep_type == EP_OTHER)
381 ep->ep_type = rep->ep_type; 381 ep->ep_type = rep->ep_type;
382 dp = port->port_dp; 382 dp = port->port_dp;
383 if (dp->dp_ep_connect) 383 if (dp->dp_ep_connect)
384 dp->dp_ep_connect(dp->dp_dev, ep, true); 384 dp->dp_ep_connect(dp->dp_dev, ep, true);
385 dp = rep->ep_port->port_dp; 385 dp = rep->ep_port->port_dp;
386 if (dp->dp_ep_connect) 386 if (dp->dp_ep_connect)
387 dp->dp_ep_connect(dp->dp_dev, rep, true); 387 dp->dp_ep_connect(dp->dp_dev, rep, true);
388 } 388 }
389 i++; 389 i++;