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.
This commit is contained in:
jmcneill 2015-03-17 22:29:40 +00:00
parent 9f48099ced
commit 8b8b794d16
5 changed files with 33 additions and 12 deletions

View File

@ -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>
@ -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>
@ -72,6 +74,20 @@ static size_t meson8b_cpu_get_available(u_int *, size_t);
bus_space_write_4(&amlogic_bs_tag, amlogic_core_bsh, \
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)
{
@ -80,10 +96,6 @@ amlogic_cpufreq_init(void)
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 @@ meson8b_cpu_set_rate(u_int rate)
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;
}

View File

@ -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>
@ -56,6 +56,7 @@ extern struct arm32_bus_dma_tag amlogic_dma_tag;
void amlogic_bootstrap(void);
void amlogic_cpufreq_bootstrap(void);
void amlogic_cpufreq_init(void);
void amlogic_usbphy_init(int);

View File

@ -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 @@ defparam opt_amlogic.h CONMODE
# Memory parameters
defparam opt_amlogic.h MEMSIZE
# CPU parameters
defparam opt_amlogic.h CPUFREQ

View File

@ -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 @@ initarm(void *arg)
db_trap_callback = amlogic_db_trap;
amlogic_cpufreq_bootstrap();
return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
}

View File

@ -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 @@ options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
# CPU options
options CPU_CORTEXA5
options CPUFREQ=1512
options PMAPCOUNTERS
# Architecture options