Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/rockchip rk3399_iomux: add some #ifdef'd out co...



details:   https://anonhg.NetBSD.org/src/rev/511588a19191
branches:  trunk
changeset: 964882:511588a19191
user:      tnn <tnn%NetBSD.org@localhost>
date:      Tue Aug 20 23:32:33 2019 +0000

description:
rk3399_iomux: add some #ifdef'd out code to enable the on-chip debug port

diffstat:

 sys/arch/arm/rockchip/rk3399_iomux.c |  38 ++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 2 deletions(-)

diffs (64 lines):

diff -r 516b606e574f -r 511588a19191 sys/arch/arm/rockchip/rk3399_iomux.c
--- a/sys/arch/arm/rockchip/rk3399_iomux.c      Tue Aug 20 21:18:10 2019 +0000
+++ b/sys/arch/arm/rockchip/rk3399_iomux.c      Tue Aug 20 23:32:33 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_iomux.c,v 1.4 2019/04/30 22:42:32 jmcneill Exp $ */
+/* $NetBSD: rk3399_iomux.c,v 1.5 2019/08/20 23:32:33 tnn Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 //#define RK3399_IOMUX_DEBUG
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.4 2019/04/30 22:42:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.5 2019/08/20 23:32:33 tnn Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -450,6 +450,36 @@
        return of_match_compat_data(faa->faa_phandle, compat_data);
 }
 
+#ifdef RK3399_IOMUX_FORCE_ENABLE_SWJ_DP
+/*
+ * This enables the SWJ-DP (Serial Wire JTAG Debug Port).
+ * If you enable this you must also disable sdhc due to pin conflicts.
+ */
+static void
+rk3399_iomux_force_enable_swj_dp(struct rk3399_iomux_softc * const sc)
+{
+       struct syscon * const syscon = sc->sc_syscon[RK_IOMUX_REGS_GRF];
+       uint32_t val;
+
+       aprint_normal_dev(sc->sc_dev, "enabling on-chip debugging\n");
+#define GRF_GPIO4B_IOMUX       0xe024
+#define GRF_GPIO4B_IOMUX_TCK   __BITS(5,4)
+#define GRF_GPIO4B_IOMUX_TMS   __BITS(7,6)
+#define GRF_SOC_CON7           0xe21c
+#define GRF_SOC_CON7_FORCE_JTAG        __BIT(12)
+       LOCK(syscon);
+       val = RD4(syscon, GRF_GPIO4B_IOMUX);
+       val &= ~(GRF_GPIO4B_IOMUX_TCK | GRF_GPIO4B_IOMUX_TMS);
+       val |= __SHIFTIN(0x2, GRF_GPIO4B_IOMUX_TCK);
+       val |= __SHIFTIN(0x2, GRF_GPIO4B_IOMUX_TMS);
+       WR4(syscon, GRF_GPIO4B_IOMUX, val);
+       val = RD4(syscon, GRF_SOC_CON7);
+       val |= GRF_SOC_CON7_FORCE_JTAG;
+       WR4(syscon, GRF_SOC_CON7, val);
+       UNLOCK(syscon);
+}
+#endif
+
 static void
 rk3399_iomux_attach(device_t parent, device_t self, void *aux)
 {
@@ -492,4 +522,8 @@
 
                config_found(self, &cfaa, NULL);
        }
+
+#ifdef RK3399_IOMUX_FORCE_ENABLE_SWJ_DP
+       rk3399_iomux_force_enable_swj_dp(sc);
+#endif
 }



Home | Main Index | Thread Index | Old Index