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 Only route USB ports to XHCI controller ...
details: https://anonhg.NetBSD.org/src/rev/aeaef0debd9e
branches: trunk
changeset: 352902:aeaef0debd9e
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Apr 14 00:19:34 2017 +0000
description:
Only route USB ports to XHCI controller after the firmware is loaded
successfully. This gives us working USB (via USB2 controllers) until the
tegra-firmware package is installed.
diffstat:
sys/arch/arm/nvidia/tegra_var.h | 3 ++-
sys/arch/arm/nvidia/tegra_xusb.c | 23 ++++++++++++++---------
sys/arch/arm/nvidia/tegra_xusbpad.c | 30 ++++++++++++++----------------
3 files changed, 30 insertions(+), 26 deletions(-)
diffs (183 lines):
diff -r cc7cfe09f444 -r aeaef0debd9e sys/arch/arm/nvidia/tegra_var.h
--- a/sys/arch/arm/nvidia/tegra_var.h Fri Apr 14 00:05:46 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_var.h Fri Apr 14 00:19:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_var.h,v 1.30 2016/03/26 08:42:07 skrll Exp $ */
+/* $NetBSD: tegra_var.h,v 1.31 2017/04/14 00:19:34 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -90,6 +90,7 @@
uint32_t tegra_fuse_read(u_int);
void tegra_xusbpad_sata_enable(void);
+void tegra_xusbpad_xhci_enable(void);
struct videomode;
int tegra_dc_port(device_t);
diff -r cc7cfe09f444 -r aeaef0debd9e sys/arch/arm/nvidia/tegra_xusb.c
--- a/sys/arch/arm/nvidia/tegra_xusb.c Fri Apr 14 00:05:46 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_xusb.c Fri Apr 14 00:19:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_xusb.c,v 1.3 2017/02/27 12:38:00 skrll Exp $ */
+/* $NetBSD: tegra_xusb.c,v 1.4 2017/04/14 00:19:34 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.3 2017/02/27 12:38:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_xusb.c,v 1.4 2017/04/14 00:19:34 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -93,7 +93,7 @@
uint32_t);
static void tegra_xusb_init(struct tegra_xusb_softc * const);
-static void tegra_xusb_load_fw(struct tegra_xusb_softc * const);
+static int tegra_xusb_load_fw(struct tegra_xusb_softc * const);
static int xusb_mailbox_send(struct tegra_xusb_softc * const, uint32_t);
@@ -337,9 +337,12 @@
val = bus_space_read_4(bst, ipfsh, 0x0);
device_printf(sc->sc_dev, "%s ipfs 0x0 = 0x%x\n", __func__, val);
- tegra_xusb_load_fw(psc);
+ if (tegra_xusb_load_fw(psc) != 0)
+ return;
device_printf(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);
@@ -579,7 +582,7 @@
#define FWHEADER_FWIMG_LEN 100
#define FWHEADER__LEN 256
-static void
+static int
tegra_xusb_load_fw(struct tegra_xusb_softc * const psc)
{
struct xhci_softc * const sc = &psc->sc_xhci;
@@ -596,8 +599,8 @@
#else
if ((error = firmware_open("nvidia/tegra124", "xusb.bin", &fw)) != 0) {
aprint_error_dev(sc->sc_dev,
- "could not open firmware file %s: %d\n", "xusb.bin", error);
- return;
+ "couldn't load firmware from 'nvidia/tegra124/xusb.bin': %d\n", error);
+ return error;
}
firmware_size = firmware_get_size(fw);
#endif
@@ -607,7 +610,7 @@
#if !defined(TEGRA124_XUSB_BIN_STATIC)
firmware_close(fw);
#endif
- return;
+ return error;
}
firmware_image = psc->sc_fw_dma.addr;
@@ -621,7 +624,7 @@
if (error != 0) {
fw_dma_free(psc, &psc->sc_fw_dma);
firmware_close(fw);
- return;
+ return error;
}
firmware_close(fw);
#endif
@@ -733,6 +736,8 @@
XUSB_CSB_FALCON_CPUCTL_STARTCPU);
device_printf(sc->sc_dev, "XUSB_FALC_CPUCTL 0x%x\n",
csb_read_4(psc, XUSB_CSB_FALCON_CPUCTL_REG));
+
+ return 0;
}
static uint32_t
diff -r cc7cfe09f444 -r aeaef0debd9e sys/arch/arm/nvidia/tegra_xusbpad.c
--- a/sys/arch/arm/nvidia/tegra_xusbpad.c Fri Apr 14 00:05:46 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_xusbpad.c Fri Apr 14 00:19:34 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_xusbpad.c,v 1.4 2017/04/11 11:32:51 jmcneill Exp $ */
+/* $NetBSD: tegra_xusbpad.c,v 1.5 2017/04/14 00:19:34 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_tegra.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_xusbpad.c,v 1.4 2017/04/11 11:32:51 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_xusbpad.c,v 1.5 2017/04/14 00:19:34 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -59,8 +59,6 @@
static void padregdump(void);
#endif
-static void tegra_xusbpad_setup(struct tegra_xusbpad_softc * const);
-
static struct tegra_xusbpad_softc *xusbpad_softc = NULL;
CFATTACH_DECL_NEW(tegra_xusbpad, sizeof(struct tegra_xusbpad_softc),
@@ -103,16 +101,6 @@
aprint_naive("\n");
aprint_normal(": XUSB PADCTL\n");
-
-#ifdef TEGRA_XUSBPAD_DEBUG
- padregdump();
-#endif
-
- tegra_xusbpad_setup(sc);
-
-#ifdef TEGRA_XUSBPAD_DEBUG
- padregdump();
-#endif
}
static void
@@ -189,15 +177,23 @@
}
#endif
-static void
-tegra_xusbpad_setup(struct tegra_xusbpad_softc * const sc)
+void
+tegra_xusbpad_xhci_enable(void)
{
+ struct tegra_xusbpad_softc * const sc = xusbpad_softc;
const uint32_t skucalib = tegra_fuse_read(TEGRA_FUSE_SKU_CALIB_REG);
#ifdef TEGRA_XUSBPAD_DEBUG
uint32_t val;
#endif
+ if (sc == NULL) {
+ aprint_error("%s: xusbpad driver not loaded\n", __func__);
+ return;
+ }
+
+
#ifdef TEGRA_XUSBPAD_DEBUG
+ padregdump(void);
printf("SKU CALIB 0x%x\n", skucalib);
#endif
const uint32_t hcl[3] = {
@@ -350,5 +346,7 @@
device_printf(sc->sc_dev, "XUSB_PADCTL_USB2_PORT_CAP_REG is 0x%x\n", val);
val = bus_space_read_4(sc->sc_bst, sc->sc_bsh, XUSB_PADCTL_SS_PORT_MAP_REG);
device_printf(sc->sc_dev, "XUSB_PADCTL_SS_PORT_MAP_REG is 0x%x\n", val);
+
+ padregdump();
#endif
}
Home |
Main Index |
Thread Index |
Old Index