Skip to content

Instantly share code, notes, and snippets.

@myfreeweb myfreeweb/README.md Secret
Last active Aug 15, 2018

Embed
What would you like to do?
rk3399-freebsd-clock
commit 274e48cd199764c4a86e3b329be34db2dba94106
Author: Greg V <greg@unrelenting.technology>
Date: Wed Aug 15 21:06:16 2018 +0300
cpufreq_dt: (HACK) make the supply optional
We do not yet have a driver for the voltage controller used on the ROCKPro64 for the big cores.
But the default voltage is enough for max clock, so let us reclock it now.
(That voltage is probably too high, as the chip gets rather warm just idling in FreeBSD...)
diff --git a/sys/dev/cpufreq/cpufreq_dt.c b/sys/dev/cpufreq/cpufreq_dt.c
index 27f70c910e4..3a7e6a4c043 100644
--- a/sys/dev/cpufreq/cpufreq_dt.c
+++ b/sys/dev/cpufreq/cpufreq_dt.c
@@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$");
#include "cpufreq_if.h"
-#if 0
+#if 1
#define DEBUG(dev, msg...) device_printf(dev, "cpufreq_dt: " msg);
#else
#define DEBUG(dev, msg...)
@@ -188,7 +188,7 @@ cpufreq_dt_set(device_t dev, const struct cf_setting *set)
return (EINVAL);
}
- if (copp->uvolt_target < opp->uvolt_target) {
+ if (copp->uvolt_target < opp->uvolt_target && sc->reg) {
DEBUG(dev, "Changing regulator from %u to %u\n",
copp->uvolt_target, opp->uvolt_target);
error = regulator_set_voltage(sc->reg,
@@ -205,13 +205,14 @@ cpufreq_dt_set(device_t dev, const struct cf_setting *set)
if (error != 0) {
DEBUG(dev, "Failed, backout\n");
/* Restore previous voltage (best effort) */
+ if (sc->reg)
error = regulator_set_voltage(sc->reg,
copp->uvolt_min,
copp->uvolt_max);
return (ENXIO);
}
- if (copp->uvolt_target > opp->uvolt_target) {
+ if (copp->uvolt_target > opp->uvolt_target && sc->reg) {
error = regulator_set_voltage(sc->reg,
opp->uvolt_min,
opp->uvolt_max);
@@ -333,7 +334,7 @@ cpufreq_dt_oppv1_parse(struct cpufreq_dt_softc *sc, phandle_t node)
sc->opp[n].uvolt_target = sc->opp[n].uvolt_min;
sc->opp[n].clk_latency = lat;
- if (bootverbose)
+ //if (bootverbose)
device_printf(sc->dev, "%ju.%03ju MHz, %u uV\n",
sc->opp[n].freq / 1000000,
sc->opp[n].freq % 1000000,
@@ -413,7 +414,7 @@ cpufreq_dt_oppv2_parse(struct cpufreq_dt_softc *sc, phandle_t node)
}
OF_prop_free(volts);
- if (bootverbose)
+ //if (bootverbose)
device_printf(sc->dev, "%ju.%03ju Mhz (%u uV)\n",
sc->opp[i].freq / 1000000,
sc->opp[i].freq % 1000000,
@@ -439,15 +440,16 @@ cpufreq_dt_attach(device_t dev)
if (regulator_get_by_ofw_property(dev, node,
"cpu-supply", &sc->reg) != 0) {
- device_printf(dev, "no regulator for %s\n",
+ device_printf(dev, "WARN no regulator for %s\n",
ofw_bus_get_name(device_get_parent(dev)));
- return (ENXIO);
+ //return (ENXIO);
}
if (clk_get_by_ofw_index(dev, node, 0, &sc->clk) != 0) {
device_printf(dev, "no clock for %s\n",
ofw_bus_get_name(device_get_parent(dev)));
- regulator_release(sc->reg);
+ if (sc->reg)
+ regulator_release(sc->reg);
return (ENXIO);
}
commit 0f7431775c7270a2a8c67ee830ae2fbe0ddc583c
Author: Greg V <greg@unrelenting.technology>
Date: Wed Aug 15 21:05:42 2018 +0300
rk805: add rk808 compatibility
registers seem to be the same
TODO: rename the driver :)
diff --git a/sys/arm64/rockchip/rk805.c b/sys/arm64/rockchip/rk805.c
index 3ea64dd9f96..38f1312b238 100644
--- a/sys/arm64/rockchip/rk805.c
+++ b/sys/arm64/rockchip/rk805.c
@@ -53,6 +53,7 @@ MALLOC_DEFINE(M_RK805_REG, "RK805 regulator", "RK805 power regulator");
static struct ofw_compat_data compat_data[] = {
{"rockchip,rk805", 1},
+ {"rockchip,rk808", 1},
{NULL, 0}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.