From 5f7c7837ef09d4c5c0c443b7cc542aa25ec79bab Mon Sep 17 00:00:00 2001
From: Ketut Putu Kumajaya <ketut.kumajaya@gmail.com>
Date: Thu, 19 Sep 2013 14:37:30 +0700
Subject: sgxfreq: add sysfs interface to store frequency limit

Utilize all in kernel GPU frequencies but we can limit it to spesific
value. Replacement for the old in kernel gpu_oc sysfs interface to
verclock the GPU, have no harm to non-overclocked kernel

Change-Id: I2d9d1f05b0306de074ffdd327e9bf2a23c9d973f
(cherry picked from commit b401521a4f1f8fad4daf3e261c27177873346cf4)
---
 pvr-source/services4/system/omap4/sgxfreq.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/pvr-source/services4/system/omap4/sgxfreq.c b/pvr-source/services4/system/omap4/sgxfreq.c
index 7e8e8fd..65543a5 100644
--- a/pvr-source/services4/system/omap4/sgxfreq.c
+++ b/pvr-source/services4/system/omap4/sgxfreq.c
@@ -107,6 +107,26 @@ static ssize_t show_frequency_limit(struct device *dev,
 	return sprintf(buf, "%lu\n", sfd.freq_limit);
 }
 
+/*
+ * sysfs interface to store sgxfreq frequency limit
+ * author: ketut.kumajaya@gmail.com
+*/
+static ssize_t store_frequency_limit(struct device *dev,
+				    struct device_attribute *attr,
+				    const char *buf, size_t count)
+{
+	unsigned long freq_limit;
+
+	if (kstrtoul(buf, 0, &freq_limit)) {
+		pr_err("sgxfreq: failed storing frequency_limit\n");
+		return -EINVAL;
+	}
+
+	freq_limit = sgxfreq_set_freq_limit(freq_limit);
+	pr_info("sgxfreq: frequency_limit=%lu\n", freq_limit);
+	return count;
+}
+
 static ssize_t show_frequency(struct device *dev,
 			      struct device_attribute *attr,
 			      char *buf)
@@ -169,7 +189,7 @@ static ssize_t store_governor(struct device *dev,
 
 static DEVICE_ATTR(frequency_list, 0444, show_frequency_list, NULL);
 static DEVICE_ATTR(frequency_request, 0444, show_frequency_request, NULL);
-static DEVICE_ATTR(frequency_limit, 0444, show_frequency_limit, NULL);
+static DEVICE_ATTR(frequency_limit, 0644, show_frequency_limit, store_frequency_limit);
 static DEVICE_ATTR(frequency, 0444, show_frequency, NULL);
 static DEVICE_ATTR(governor_list, 0444, show_governor_list, NULL);
 static DEVICE_ATTR(governor, 0644, show_governor, store_governor);
-- 
cgit v1.1