Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/nvidia Hide the debug output unless either TEGR...



details:   https://anonhg.NetBSD.org/src/rev/f917c3c2c35f
branches:  trunk
changeset: 823604:f917c3c2c35f
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Apr 28 09:46:49 2017 +0000

description:
Hide the debug output unless either TEGRA_XUSB_DEBUG is defined or
tegra_xusb_debug is set to 1.

diffstat:

 sys/arch/arm/nvidia/files.tegra  |    3 +-
 sys/arch/arm/nvidia/tegra_xusb.c |  175 ++++++++++++++++++++------------------
 2 files changed, 93 insertions(+), 85 deletions(-)

diffs (truncated from 525 to 300 lines):

diff -r 5e6b3c8391e4 -r f917c3c2c35f sys/arch/arm/nvidia/files.tegra
--- a/sys/arch/arm/nvidia/files.tegra   Fri Apr 28 06:59:49 2017 +0000
+++ b/sys/arch/arm/nvidia/files.tegra   Fri Apr 28 09:46:49 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.tegra,v 1.33 2017/04/23 12:31:38 jmcneill Exp $
+#      $NetBSD: files.tegra,v 1.34 2017/04/28 09:46:49 jmcneill Exp $
 #
 # Configuration info for NVIDIA Tegra ARM Peripherals
 #
@@ -99,6 +99,7 @@
 # XUSB (USB 3.0)
 attach xhci at fdt with tegra_xusb
 file   arch/arm/nvidia/tegra_xusb.c            tegra_xusb
+defflag        opt_tegra.h                             TEGRA_XUSB_DEBUG
 
 # SDMMC
 attach sdhc at fdt with tegra_sdhc
diff -r 5e6b3c8391e4 -r f917c3c2c35f sys/arch/arm/nvidia/tegra_xusb.c
--- a/sys/arch/arm/nvidia/tegra_xusb.c  Fri Apr 28 06:59:49 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_xusb.c  Fri Apr 28 09:46:49 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_xusb.c,v 1.5 2017/04/16 12:28:21 jmcneill Exp $ */
+/* $NetBSD: tegra_xusb.c,v 1.6 2017/04/28 09:46:49 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2016 Jonathan A. Kollasch
@@ -30,7 +30,7 @@
 #include "opt_tegra.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.5 2017/04/16 12:28:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.6 2017/04/28 09:46:49 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -57,6 +57,14 @@
 #include <dev/usb/xhcireg.h>
 #include <dev/usb/xhcivar.h>
 
+#ifdef TEGRA_XUSB_DEBUG
+int tegra_xusb_debug = 1;
+#else
+int tegra_xusb_debug = 0;
+#endif
+
+#define DPRINTF(...)   if (tegra_xusb_debug) device_printf(__VA_ARGS__)
+
 static int     tegra_xusb_match(device_t, cfdata_t, void *);
 static void    tegra_xusb_attach(device_t, device_t, void *);
 static void    tegra_xusb_mountroot(device_t);
@@ -126,10 +134,10 @@
        char intrstr[128];
        bus_addr_t addr;
        bus_size_t size;
-       int error;
+       struct fdtbus_reset *rst;
        struct clk *clk;
        uint32_t rate;
-       struct fdtbus_reset *rst;
+       int error;
 
        aprint_naive("\n");
        aprint_normal(": XUSB\n");
@@ -149,7 +157,7 @@
                aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
                return;
        }
-       printf("mapped %#llx\n", (uint64_t)addr);
+       DPRINTF(sc->sc_dev, "mapped %#llx\n", (uint64_t)addr);
 
        if (fdtbus_get_reg(faa->faa_phandle, 1, &addr, &size) != 0) {
                aprint_error(": couldn't get registers\n");
@@ -160,7 +168,7 @@
                aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
                return;
        }
-       printf("mapped %#llx\n", (uint64_t)addr);
+       DPRINTF(sc->sc_dev, "mapped %#llx\n", (uint64_t)addr);
 
        if (fdtbus_get_reg(faa->faa_phandle, 2, &addr, &size) != 0) {
                aprint_error(": couldn't get registers\n");
@@ -171,7 +179,7 @@
                aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
                return;
        }
-       printf("mapped %#llx\n", (uint64_t)addr);
+       DPRINTF(sc->sc_dev, "mapped %#llx\n", (uint64_t)addr);
 
        if (!fdtbus_intr_str(faa->faa_phandle, 0, intrstr, sizeof(intrstr))) {
                aprint_error_dev(self, "failed to decode interrupt\n");
@@ -204,40 +212,40 @@
        clk = fdtbus_clock_get(faa->faa_phandle, "pll_e");
        rate = clk_get_rate(clk);
        error = clk_enable(clk); /* XXX set frequency */
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to enable pll_e clock");
 
        clk = fdtbus_clock_get(faa->faa_phandle, "xusb_host_src");
        rate = clk_get_rate(clk);
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
        error = clk_set_rate(clk, 102000000);
        tegra_xusb_attach_check(sc, error, "failed to set xusb_host_src clock rate");
 
        rate = clk_get_rate(clk);
        error = clk_enable(clk); /* XXX set frequency */
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to enable xusb_host_src clock");
 
        clk = fdtbus_clock_get(faa->faa_phandle, "xusb_falcon_src");
        rate = clk_get_rate(clk);
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
        error = clk_set_rate(clk, 204000000);
        tegra_xusb_attach_check(sc, error, "failed to set xusb_falcon_src clock rate");
 
        rate = clk_get_rate(clk);
        error = clk_enable(clk);
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to enable xusb_falcon_src clock");
 
        clk = fdtbus_clock_get(faa->faa_phandle, "xusb_host");
        rate = clk_get_rate(clk);
        error = clk_enable(clk); /* XXX set frequency */
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
 
        clk = fdtbus_clock_get(faa->faa_phandle, "xusb_ss");
        rate = clk_get_rate(clk);
        error = clk_enable(clk); /* XXX set frequency */
-       device_printf(sc->sc_dev, "xusb_ss rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "xusb_ss rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to enable xusb_ss clock");
 
        psc->sc_clk_ss_src = fdtbus_clock_get(faa->faa_phandle, "xusb_ss_src");
@@ -245,37 +253,36 @@
                "failed to get xusb_ss_src clock");
 
        rate = clk_get_rate(psc->sc_clk_ss_src);
-       device_printf(sc->sc_dev, "xusb_ss_src rate %u\n", rate);
+       DPRINTF(sc->sc_dev, "xusb_ss_src rate %u\n", rate);
        error = clk_set_rate(psc->sc_clk_ss_src, 2000000);
        rate = clk_get_rate(psc->sc_clk_ss_src);
-       device_printf(sc->sc_dev, "xusb_ss_src rate %u error %d\n", rate,
-           error);
+       DPRINTF(sc->sc_dev, "xusb_ss_src rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to get xusb_ss_src clock rate");
 
        rate = clk_get_rate(psc->sc_clk_ss_src);
-       device_printf(sc->sc_dev, "ss_src rate %u\n", rate);
+       DPRINTF(sc->sc_dev, "ss_src rate %u\n", rate);
        tegra_xusb_attach_check(sc, error, "failed to set xusb_ss_src clock rate");
 
        error = clk_set_rate(psc->sc_clk_ss_src, 120000000);
        rate = clk_get_rate(psc->sc_clk_ss_src);
-       device_printf(sc->sc_dev, "ss_src rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "ss_src rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to get xusb_ss_src clock rate");
 
        error = clk_enable(psc->sc_clk_ss_src);
-       device_printf(sc->sc_dev, "ss_src rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "ss_src rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to enable xusb_ss_src clock");
 
 #if 0
        clk = fdtbus_clock_get(faa->faa_phandle, "xusb_hs_src");
        error = 0;
        rate = clk_get_rate(clk);
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
 #endif
 
        clk = fdtbus_clock_get(faa->faa_phandle, "xusb_fs_src");
        rate = clk_get_rate(clk);
        error = clk_enable(clk); /* XXX set frequency */
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
        tegra_xusb_attach_check(sc, error, "failed to enable xusb_fs_src clock");
 
        rst = fdtbus_reset_get(faa->faa_phandle, "xusb_host");
@@ -311,29 +318,29 @@
        uint32_t val;
        int error;
 
-       device_printf(sc->sc_dev, "%s()\n", __func__);
+       DPRINTF(sc->sc_dev, "%s()\n", __func__);
 
        val = bus_space_read_4(bst, ipfsh, 0x0);
-       device_printf(sc->sc_dev, "%s ipfs 0x0 = 0x%x\n", __func__, val);
+       DPRINTF(sc->sc_dev, "%s ipfs 0x0 = 0x%x\n", __func__, val);
 
        if (tegra_xusb_load_fw(psc) != 0)
                return;
-       device_printf(sc->sc_dev, "post fw\n");
+       DPRINTF(sc->sc_dev, "post fw\n");
 
        tegra_xusbpad_xhci_enable();
 
        clk = fdtbus_clock_get(psc->sc_phandle, "xusb_falcon_src");
        rate = clk_get_rate(clk);
        error = clk_enable(clk);
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
 
        clk = fdtbus_clock_get(psc->sc_phandle, "xusb_host_src");
        rate = clk_get_rate(clk);
        error = clk_enable(clk);
-       device_printf(sc->sc_dev, "rate %u error %d\n", rate, error);
+       DPRINTF(sc->sc_dev, "rate %u error %d\n", rate, error);
 
        val = bus_space_read_4(bst, ipfsh, 0x0);
-       device_printf(sc->sc_dev, "%s ipfs 0x0 = 0x%x\n", __func__, val);
+       DPRINTF(sc->sc_dev, "%s ipfs 0x0 = 0x%x\n", __func__, val);
 
        rst = fdtbus_reset_get(psc->sc_phandle, "xusb_host");
        fdtbus_reset_deassert(rst);
@@ -345,7 +352,7 @@
        fdtbus_reset_deassert(rst);
 
        val = csb_read_4(psc, XUSB_CSB_FALCON_CPUCTL_REG);
-       device_printf(sc->sc_dev, "XUSB_FALC_CPUCTL 0x%x\n", val);
+       DPRINTF(sc->sc_dev, "XUSB_FALC_CPUCTL 0x%x\n", val);
 
 
        error = xhci_init(sc);
@@ -376,20 +383,20 @@
        uint32_t msg;
        int error;
 
-       device_printf(sc->sc_dev, "%s()\n", __func__);
+       DPRINTF(sc->sc_dev, "%s()\n", __func__);
 
        irv = bus_space_read_4(bst, fpcih, T_XUSB_CFG_ARU_SMI_INTR_REG);
-       device_printf(sc->sc_dev, "XUSB_CFG_ARU_SMI_INTR 0x%x\n", irv);
+       DPRINTF(sc->sc_dev, "XUSB_CFG_ARU_SMI_INTR 0x%x\n", irv);
        bus_space_write_4(bst, fpcih, T_XUSB_CFG_ARU_SMI_INTR_REG, irv);
 
        if (irv & T_XUSB_CFG_ARU_SMI_INTR_FW_HANG)
-               device_printf(sc->sc_dev, "firmware hang\n");
+               aprint_error_dev(sc->sc_dev, "firmware hang\n");
 
        msg = bus_space_read_4(bst, fpcih, T_XUSB_CFG_ARU_MAILBOX_DATA_OUT_REG);
-       device_printf(sc->sc_dev, "XUSB_CFG_ARU_MBOX_DATA_OUT 0x%x\n", msg);
+       DPRINTF(sc->sc_dev, "XUSB_CFG_ARU_MBOX_DATA_OUT 0x%x\n", msg);
 
        val = bus_space_read_4(bst, fpcih, T_XUSB_CFG_ARU_MAILBOX_CMD_REG);
-       device_printf(sc->sc_dev, "XUSB_CFG_ARU_MBOX_CMD 0x%x\n", val);
+       DPRINTF(sc->sc_dev, "XUSB_CFG_ARU_MBOX_CMD 0x%x\n", val);
        val &= ~T_XUSB_CFG_ARU_MAILBOX_CMD_DEST_SMI;
        bus_space_write_4(bst, fpcih, T_XUSB_CFG_ARU_MAILBOX_CMD_REG, val);
 
@@ -402,19 +409,19 @@
        switch (type) {
        case 2:
        case 3:
-               device_printf(sc->sc_dev, "FALC_CLOCK %u\n", data * 1000);
+               DPRINTF(sc->sc_dev, "FALC_CLOCK %u\n", data * 1000);
                break;
        case 4:
        case 5:
-               device_printf(sc->sc_dev, "SSPI_CLOCK %u\n", data * 1000);
+               DPRINTF(sc->sc_dev, "SSPI_CLOCK %u\n", data * 1000);
                rate = clk_get_rate(psc->sc_clk_ss_src);
-               device_printf(sc->sc_dev, "rate of psc->sc_clk_ss_src %u\n",
+               DPRINTF(sc->sc_dev, "rate of psc->sc_clk_ss_src %u\n",
                    rate);
                error = clk_set_rate(psc->sc_clk_ss_src, data * 1000);
                if (error != 0)
                        goto clk_fail;
                rate = clk_get_rate(psc->sc_clk_ss_src);
-               device_printf(sc->sc_dev,
+               DPRINTF(sc->sc_dev,
                    "rate of psc->sc_clk_ss_src %u after\n", rate);
                if (data == (rate / 1000)) {
                        msg = __SHIFTIN(128, MAILBOX_DATA_TYPE) |
@@ -455,52 +462,52 @@
        const bus_space_handle_t ipfsh = psc->sc_bsh_ipfs;
        const bus_space_handle_t fpcih = psc->sc_bsh_fpci;
 
-       device_printf(sc->sc_dev, "%s()\n", __func__);
+       DPRINTF(sc->sc_dev, "%s()\n", __func__);
 
-       device_printf(sc->sc_dev, "%s ipfs 0x0 = 0x%x\n", __func__,
+       DPRINTF(sc->sc_dev, "%s ipfs 0x0 = 0x%x\n", __func__,
            bus_space_read_4(bst, ipfsh, 0x0));
 
-       device_printf(sc->sc_dev, "%s ipfs 0x40 = 0x%x\n", __func__,
+       DPRINTF(sc->sc_dev, "%s ipfs 0x40 = 0x%x\n", __func__,
            bus_space_read_4(bst, ipfsh, 0x40));
 
-       device_printf(sc->sc_dev, "%s ipfs 0x80 = 0x%x\n", __func__,
+       DPRINTF(sc->sc_dev, "%s ipfs 0x80 = 0x%x\n", __func__,
            bus_space_read_4(bst, ipfsh, 0x80));
        /* FPCI_BAR0_START and FPCI_BAR0_ACCESS_TYPE */
        bus_space_write_4(bst, ipfsh, 0x80, 0x00100000);
-       device_printf(sc->sc_dev, "%s ipfs 0x80 = 0x%x\n", __func__,
+       DPRINTF(sc->sc_dev, "%s ipfs 0x80 = 0x%x\n", __func__,



Home | Main Index | Thread Index | Old Index