Files
Arch-R/projects/Odroid_C2/patches/linux/linux-008-max_freq_dvfs_table.patch
Jonas Karlman 73b406c456 projects/Odroid_C2: switch to linux-amlogic-3.14
This makes Odroid C2 use linux-amlogic and similar linux patches as WeTek Hub
u-boot patch updated to allow overwriting env vars
boot.ini updated to reflect missing features in linux-amlogic
2016-09-19 21:52:29 +02:00

97 lines
2.6 KiB
Diff

From dee146cbbb8428b073fba85390577590fc365d86 Mon Sep 17 00:00:00 2001
From: Joy Cho <joy.cho@hardkernel.com>
Date: Wed, 31 Aug 2016 16:27:48 +0900
Subject: [PATCH] ODROID-C2: Add setup routine to set max. cpu frequency of
dvfs table
- set "max_freq" in boot.ini
- in MHz unit
ex) setenv max_freq "1656"
Change-Id: I352c9540d0c34d3ec0ba0f470dae9d4e0786c001
---
drivers/amlogic/mailbox/scpi_protocol.c | 53 +++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/drivers/amlogic/mailbox/scpi_protocol.c b/drivers/amlogic/mailbox/scpi_protocol.c
index ec787d2..f3aa3e0 100644
--- a/drivers/amlogic/mailbox/scpi_protocol.c
+++ b/drivers/amlogic/mailbox/scpi_protocol.c
@@ -85,6 +85,12 @@ static int high_priority_cmds[] = {
SCPI_CMD_SENSOR_CFG_BOUNDS,
};
+#if defined(CONFIG_ARCH_MESON64_ODROIDC2)
+#define DVFS_COUNT_MAX 13
+#define DVFS_COUNT_1536 6
+static unsigned long max_freq_dvfs;
+#endif
+
static struct scpi_opp *scpi_opps[MAX_DVFS_DOMAINS];
static int scpi_linux_errmap[SCPI_ERR_MAX] = {
@@ -236,6 +242,9 @@ struct scpi_opp *scpi_dvfs_get_opps(u8 domain)
struct scpi_opp *opps;
size_t opps_sz;
int count, ret;
+#if defined(CONFIG_ARCH_MESON64_ODROIDC2)
+ int i, max_index;
+#endif
if (domain >= MAX_DVFS_DOMAINS)
return ERR_PTR(-EINVAL);
@@ -254,6 +263,27 @@ struct scpi_opp *scpi_dvfs_get_opps(u8 domain)
return ERR_PTR(-ENOMEM);
count = DVFS_OPP_COUNT(buf.header);
+
+#if defined(CONFIG_ARCH_MESON64_ODROIDC2)
+ max_index = 0;
+ if (max_freq_dvfs) {
+ for (i = 0; i < count; i++) {
+ if (buf.opp[i].freq_hz == max_freq_dvfs)
+ break;
+ else
+ max_index++;
+ }
+ count = max_index + 1;
+ }
+ /* if no param "max_freq_dvfs or wrong "max_freq_dvfs"
+ * from boot.ini, consider stable max value */
+ if ((max_freq_dvfs == 0) || (count > DVFS_COUNT_MAX))
+ count = DVFS_COUNT_1536; /* default max : 1.536GHz */
+
+ pr_info("dvfs [%s] - new count %d, max_freq %ld\n", __func__,
+ count, max_freq_dvfs);
+#endif
+
opps_sz = count * sizeof(*(opps->opp));
opps->count = count;
@@ -422,3 +452,25 @@ int scpi_send_usr_data(u32 client_id, u32 *val, u32 size)
}
EXPORT_SYMBOL_GPL(scpi_send_usr_data);
+#if defined(CONFIG_ARCH_MESON64_ODROIDC2)
+static int __init get_max_freq(char *str)
+{
+ int ret;
+
+ if (NULL == str) {
+ /* consider default set */
+ max_freq_dvfs = 1536000000;
+ return -EINVAL;
+ }
+
+ ret = kstrtoul(str, 0, &max_freq_dvfs);
+
+ /* in unit Hz */
+ max_freq_dvfs *= 1000000;
+
+ pr_info("dvfs [%s] - max_freq : %ld\n", __func__, max_freq_dvfs);
+
+ return 0;
+}
+__setup("max_freq=", get_max_freq);
+#endif