Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/samsung Add delay and enable mct timecounter.



details:   https://anonhg.NetBSD.org/src/rev/d81ed8aad7b1
branches:  trunk
changeset: 354299:d81ed8aad7b1
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jun 11 01:09:44 2017 +0000

description:
Add delay and enable mct timecounter.

diffstat:

 sys/arch/arm/samsung/exynos_platform.c |   8 ++++--
 sys/arch/arm/samsung/mct.c             |  41 +++++++++++++++++++++++++++------
 sys/arch/arm/samsung/mct_var.h         |   3 +-
 3 files changed, 40 insertions(+), 12 deletions(-)

diffs (151 lines):

diff -r 0a3e45c634c4 -r d81ed8aad7b1 sys/arch/arm/samsung/exynos_platform.c
--- a/sys/arch/arm/samsung/exynos_platform.c    Sun Jun 11 00:54:26 2017 +0000
+++ b/sys/arch/arm/samsung/exynos_platform.c    Sun Jun 11 01:09:44 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos_platform.c,v 1.2 2017/06/10 23:22:36 jmcneill Exp $ */
+/* $NetBSD: exynos_platform.c,v 1.3 2017/06/11 01:09:44 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,7 @@
 #include "ukbd.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exynos_platform.c,v 1.2 2017/06/10 23:22:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_platform.c,v 1.3 2017/06/11 01:09:44 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -130,7 +130,9 @@
 static void
 exynos_platform_delay(u_int us)
 {
-       gtmr_delay(us);
+       extern void mct_delay(u_int);
+
+       mct_delay(us);
 }
 
 static u_int
diff -r 0a3e45c634c4 -r d81ed8aad7b1 sys/arch/arm/samsung/mct.c
--- a/sys/arch/arm/samsung/mct.c        Sun Jun 11 00:54:26 2017 +0000
+++ b/sys/arch/arm/samsung/mct.c        Sun Jun 11 01:09:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mct.c,v 1.10 2016/01/07 04:45:10 marty Exp $   */
+/*     $NetBSD: mct.c,v 1.11 2017/06/11 01:09:44 jmcneill Exp $        */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: mct.c,v 1.10 2016/01/07 04:45:10 marty Exp $");
+__KERNEL_RCSID(1, "$NetBSD: mct.c,v 1.11 2017/06/11 01:09:44 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -56,11 +56,11 @@
 static void mct_attach(device_t, device_t, void *);
 
 static int clockhandler(void *);
+static u_int mct_get_timecount(struct timecounter *);
 
 CFATTACH_DECL_NEW(exyo_mct, 0, mct_match, mct_attach, NULL, NULL);
 
 
-#if 0
 static struct timecounter mct_timecounter = {
        .tc_get_timecount = mct_get_timecount,
        .tc_poll_pps = 0,
@@ -71,7 +71,6 @@
        .tc_priv = &mct_sc,
        .tc_next = NULL,
 };
-#endif
 
 static inline uint32_t
 mct_read_global(struct mct_softc *sc, bus_size_t o)
@@ -157,6 +156,7 @@
        self->dv_private = sc;
        sc->sc_dev = self;
        sc->sc_bst = faa->faa_bst;
+       sc->sc_freq = EXYNOS_F_IN_FREQ;
 
        error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh);
        if (error) {
@@ -166,7 +166,7 @@
        }
 
        aprint_naive("\n");
-       aprint_normal(": Exynos SoC multi core timer (64 bits) - NOT IMPLEMENTED\n");
+       aprint_normal(": Exynos SoC multi core timer (64 bits)\n");
 
        evcnt_attach_dynamic(&sc->sc_ev_missing_ticks, EVCNT_TYPE_MISC, NULL,
                device_xname(self), "missing interrupts");
@@ -187,6 +187,30 @@
        return ((uint64_t) hi << 32) | lo;
 }
 
+static u_int
+mct_get_timecount(struct timecounter *tc)
+{
+       struct mct_softc *sc = tc->tc_priv;
+
+       return (u_int)mct_gettime(sc);
+}
+
+void
+mct_delay(u_int us)
+{
+       struct mct_softc *sc = &mct_sc;
+
+       if (sc->sc_bsh == (bus_space_handle_t)0)
+               return;
+
+       int64_t mct_ticks = ((uint64_t)us * sc->sc_freq) / 1000000;
+       uint64_t ticks_prev = mct_gettime(sc);
+       while (mct_ticks > 0) {
+               uint64_t ticks_cur = mct_gettime(sc);
+               mct_ticks -= (ticks_cur - ticks_prev);
+               ticks_prev = ticks_cur;
+       }
+}
 
 /* interrupt handler */
 static int
@@ -250,8 +274,6 @@
        mct_write_global(sc, MCT_G_TCON, tcon);
 }
 
-
-#if 0
 void
 cpu_initclocks(void)
 {
@@ -284,4 +306,7 @@
 #endif
 }
 
-#endif
+void
+setstatclockrate(int newhz)
+{
+}
diff -r 0a3e45c634c4 -r d81ed8aad7b1 sys/arch/arm/samsung/mct_var.h
--- a/sys/arch/arm/samsung/mct_var.h    Sun Jun 11 00:54:26 2017 +0000
+++ b/sys/arch/arm/samsung/mct_var.h    Sun Jun 11 01:09:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mct_var.h,v 1.4 2015/12/21 00:54:35 marty Exp $        */
+/*     $NetBSD: mct_var.h,v 1.5 2017/06/11 01:09:44 jmcneill Exp $     */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -52,6 +52,7 @@
 } mct_sc;
 
 void mct_init_cpu_clock(struct cpu_info *ci);
+void mct_delay(u_int);
 
 #endif /* _ARM_SAMSUNG_MCT_VAR_H_ */
 



Home | Main Index | Thread Index | Old Index