Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Add CPUFREQ option to set boot CPU frequency. ODROI...



details:   https://anonhg.NetBSD.org/src/rev/271c7c239ec8
branches:  trunk
changeset: 336761:271c7c239ec8
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Mar 17 22:29:40 2015 +0000

description:
Add CPUFREQ option to set boot CPU frequency. ODROID-C1 is advertised
as quad-core 1.5GHz but boots up at 1.2GHz; add CPUFREQ=1512 to config
and make sure to set the correct speed before attaching CPUs.

The speed can still be scaled down with machdep.cpu sysctls.

diffstat:

 sys/arch/arm/amlogic/amlogic_cpufreq.c    |  28 +++++++++++++++++++++-------
 sys/arch/arm/amlogic/amlogic_var.h        |   3 ++-
 sys/arch/arm/amlogic/files.amlogic        |   5 ++++-
 sys/arch/evbarm/amlogic/amlogic_machdep.c |   6 ++++--
 sys/arch/evbarm/conf/ODROID-C1            |   3 ++-
 5 files changed, 33 insertions(+), 12 deletions(-)

diffs (142 lines):

diff -r 159e90a1571c -r 271c7c239ec8 sys/arch/arm/amlogic/amlogic_cpufreq.c
--- a/sys/arch/arm/amlogic/amlogic_cpufreq.c    Tue Mar 17 19:41:42 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_cpufreq.c    Tue Mar 17 22:29:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_cpufreq.c,v 1.1 2015/03/05 23:43:53 jmcneill Exp $ */
+/* $NetBSD: amlogic_cpufreq.c,v 1.2 2015/03/17 22:29:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,8 +28,10 @@
 
 #include "locators.h"
 
+#include "opt_amlogic.h"
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_cpufreq.c,v 1.1 2015/03/05 23:43:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_cpufreq.c,v 1.2 2015/03/17 22:29:40 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -73,6 +75,20 @@
                          AMLOGIC_CBUS_OFFSET + (x), (v))
 
 void
+amlogic_cpufreq_bootstrap(void)
+{
+       cpufreq_set_rate = &meson8b_cpu_set_rate;
+       cpufreq_get_rate = &meson8b_cpu_get_rate;
+       cpufreq_get_available = &meson8b_cpu_get_available;
+
+#ifdef CPUFREQ
+       if (cpufreq_set_rate(CPUFREQ) == 0) {
+               amlogic_cpufreq_cb(NULL, NULL);
+       }
+#endif
+}
+
+void
 amlogic_cpufreq_init(void)
 {
        const struct sysctlnode *node, *cpunode, *freqnode;
@@ -80,10 +96,6 @@
        size_t nfreq;
        int error;
 
-       cpufreq_set_rate = &meson8b_cpu_set_rate;
-       cpufreq_get_rate = &meson8b_cpu_get_rate;
-       cpufreq_get_available = &meson8b_cpu_get_available;
-
        nfreq = cpufreq_get_available(availfreq, AMLOGIC_CPUFREQ_MAX);
        if (nfreq == 0)
                return;
@@ -259,7 +271,9 @@
 
        CBUS_WRITE(HHI_SYS_PLL_CNTL_REG, cntl);
 
-       a9tmr_update_freq(amlogic_get_rate_a9periph());
+       if (!cold) {
+               a9tmr_update_freq(amlogic_get_rate_a9periph());
+       }
 
        return 0;
 }
diff -r 159e90a1571c -r 271c7c239ec8 sys/arch/arm/amlogic/amlogic_var.h
--- a/sys/arch/arm/amlogic/amlogic_var.h        Tue Mar 17 19:41:42 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_var.h        Tue Mar 17 22:29:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_var.h,v 1.6 2015/03/08 12:44:55 jmcneill Exp $ */
+/* $NetBSD: amlogic_var.h,v 1.7 2015/03/17 22:29:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -56,6 +56,7 @@
 
 void   amlogic_bootstrap(void);
 
+void   amlogic_cpufreq_bootstrap(void);
 void   amlogic_cpufreq_init(void);
 
 void   amlogic_usbphy_init(int);
diff -r 159e90a1571c -r 271c7c239ec8 sys/arch/arm/amlogic/files.amlogic
--- a/sys/arch/arm/amlogic/files.amlogic        Tue Mar 17 19:41:42 2015 +0000
+++ b/sys/arch/arm/amlogic/files.amlogic        Tue Mar 17 22:29:40 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amlogic,v 1.6 2015/03/07 21:34:25 jmcneill Exp $
+#      $NetBSD: files.amlogic,v 1.7 2015/03/17 22:29:40 jmcneill Exp $
 #
 # Configuration info for Amlogic ARM Peripherals
 #
@@ -51,3 +51,6 @@
 
 # Memory parameters
 defparam opt_amlogic.h                 MEMSIZE
+
+# CPU parameters
+defparam opt_amlogic.h                 CPUFREQ
diff -r 159e90a1571c -r 271c7c239ec8 sys/arch/evbarm/amlogic/amlogic_machdep.c
--- a/sys/arch/evbarm/amlogic/amlogic_machdep.c Tue Mar 17 19:41:42 2015 +0000
+++ b/sys/arch/evbarm/amlogic/amlogic_machdep.c Tue Mar 17 22:29:40 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amlogic_machdep.c,v 1.15 2015/03/08 11:22:05 jmcneill Exp $ */
+/*     $NetBSD: amlogic_machdep.c,v 1.16 2015/03/17 22:29:40 jmcneill Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_machdep.c,v 1.15 2015/03/08 11:22:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_machdep.c,v 1.16 2015/03/17 22:29:40 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -436,6 +436,8 @@
 
        db_trap_callback = amlogic_db_trap;
 
+       amlogic_cpufreq_bootstrap();
+
        return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
 
 }
diff -r 159e90a1571c -r 271c7c239ec8 sys/arch/evbarm/conf/ODROID-C1
--- a/sys/arch/evbarm/conf/ODROID-C1    Tue Mar 17 19:41:42 2015 +0000
+++ b/sys/arch/evbarm/conf/ODROID-C1    Tue Mar 17 22:29:40 2015 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: ODROID-C1,v 1.9 2015/03/16 22:16:42 jmcneill Exp $
+#      $NetBSD: ODROID-C1,v 1.10 2015/03/17 22:29:40 jmcneill Exp $
 #
 #      Odroid-C1 (Amlogic S805) based SBC (Single Board Computer)
 #
@@ -18,6 +18,7 @@
 # CPU options
 
 options        CPU_CORTEXA5
+options        CPUFREQ=1512
 options        PMAPCOUNTERS
 
 # Architecture options



Home | Main Index | Thread Index | Old Index