@@ -22,6 +22,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/cpuacct.h>
+#include <linux/math64.h>
#include <mach/hardware.h>
#include <plat/clock.h>
@@ -218,10 +219,30 @@ static void omap_cpuacct_freq_show(void *cpuacct_data, struct cgroup_map_cb *cb)
}
}
+
+/* Returns power (in milliWatt seconds) for cgroup */
+static u64 omap_cpuacct_power_usage(void *cpuacct_data)
+{
+ int i;
+ u64 *cpuacct_freq = cpuacct_data;
+ u64 totalpower = 0;
+
+ /* mpu_opps table starts at 1 */
+ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
+ totalpower += cpuacct_freq[i] * mpu_opps[i + 1].power;
+
+ /* milliwatt seconds */
+ totalpower = div64_u64(totalpower, NSEC_PER_SEC);
+
+ return totalpower;
+}
+
+
static struct cpuacct_cpufreq_calls omap_cpuacct_cpufreq = {
.init = omap_cpuacct_freq_init,
.charge = omap_cpuacct_freq_charge,
- .show = omap_cpuacct_freq_show,
+ .cpufreq_show = omap_cpuacct_freq_show,
+ .power_usage = omap_cpuacct_power_usage,
};
static int __init omap_cpuacct_init(void)
@@ -31,6 +31,7 @@ struct omap_opp {
unsigned long rate;
u8 opp_id;
u16 min_vdd;
+ unsigned long power; /* power consumed running at OPP in milliWatts */
};
extern struct omap_opp *mpu_opps;