+/*---------------------------------------------------------------------------*/
+
+static ssize_t utilisation_period_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct kbase_device *kbdev = dev_get_drvdata(dev);
+ struct rk_context *platform = get_rk_context(kbdev);
+ ssize_t ret = 0;
+
+ ret += snprintf(buf, PAGE_SIZE, "%u\n", platform->utilisation_period);
+
+ return ret;
+}
+
+static ssize_t utilisation_period_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t count)
+{
+ struct kbase_device *kbdev = dev_get_drvdata(dev);
+ struct rk_context *platform = get_rk_context(kbdev);
+ int ret = 0;
+
+ ret = kstrtouint(buf, 0, &platform->utilisation_period);
+ if (ret) {
+ E("invalid input period : %s.", buf);
+ return ret;
+ }
+ D("set utilisation_period to '%d'.", platform->utilisation_period);
+
+ return count;
+}
+
+static ssize_t utilisation_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct kbase_device *kbdev = dev_get_drvdata(dev);
+ struct rk_context *platform = get_rk_context(kbdev);
+ ssize_t ret = 0;
+ unsigned long period_in_us = platform->utilisation_period * 1000;
+ unsigned long total_time;
+ unsigned long busy_time;
+ unsigned long utilisation;
+
+ kbase_pm_reset_dvfs_utilisation(kbdev);
+ usleep_range(period_in_us, period_in_us + 100);
+ kbase_pm_get_dvfs_utilisation(kbdev, &total_time, &busy_time);
+ /* 'devfreq_dev_profile' instance registered to devfreq
+ * also uses kbase_pm_reset_dvfs_utilisation
+ * and kbase_pm_get_dvfs_utilisation.
+ * it's better to cat this file when DVFS is disabled.
+ */
+ D("total_time : %lu, busy_time : %lu.", total_time, busy_time);
+
+ utilisation = busy_time * 100 / total_time;
+ ret += snprintf(buf, PAGE_SIZE, "%ld\n", utilisation);
+
+ return ret;
+}
+
+static DEVICE_ATTR_RW(utilisation_period);
+static DEVICE_ATTR_RO(utilisation);
+
+static int kbase_platform_rk_create_sysfs_files(struct device *dev)
+{
+ int ret = 0;
+
+ ret = device_create_file(dev, &dev_attr_utilisation_period);
+ if (ret) {
+ E("fail to create sysfs file 'utilisation_period'.");
+ goto out;
+ }
+
+ ret = device_create_file(dev, &dev_attr_utilisation);
+ if (ret) {
+ E("fail to create sysfs file 'utilisation'.");
+ goto remove_utilisation_period;
+ }
+
+ return 0;
+
+remove_utilisation_period:
+ device_remove_file(dev, &dev_attr_utilisation_period);
+out:
+ return ret;
+}
+
+static void kbase_platform_rk_remove_sysfs_files(struct device *dev)
+{
+ device_remove_file(dev, &dev_attr_utilisation_period);
+ device_remove_file(dev, &dev_attr_utilisation);
+}