aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2012-11-06 09:49:16 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-01-09 23:08:37 -0500
commit0388c79c99ccb43f711af57d2e14fcd6a5f45a06 (patch)
tree1af306fe297ec0f6b02907222dfa3afe8a311779 /arch/powerpc
parent2f1d4ea7bcd96d3796eba4087388bdb37322ee7a (diff)
powerpc/pseries: Cleanup best_energy_hcall detection
Currently we search for the best_energy hcall using a custom function. Move this to using the firmware_feature_table. Signed-off-by: Michael Neuling <mikey@neuling.org> cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> cc: Linux PPC dev <linuxppc-dev@ozlabs.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/firmware.h3
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c1
-rw-r--r--arch/powerpc/platforms/pseries/pseries_energy.c37
3 files changed, 5 insertions, 36 deletions
diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index 973cc3be011b..097dee57a7a9 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -50,6 +50,7 @@
50#define FW_FEATURE_OPAL ASM_CONST(0x0000000010000000) 50#define FW_FEATURE_OPAL ASM_CONST(0x0000000010000000)
51#define FW_FEATURE_OPALv2 ASM_CONST(0x0000000020000000) 51#define FW_FEATURE_OPALv2 ASM_CONST(0x0000000020000000)
52#define FW_FEATURE_SET_MODE ASM_CONST(0x0000000040000000) 52#define FW_FEATURE_SET_MODE ASM_CONST(0x0000000040000000)
53#define FW_FEATURE_BEST_ENERGY ASM_CONST(0x0000000080000000)
53 54
54#ifndef __ASSEMBLY__ 55#ifndef __ASSEMBLY__
55 56
@@ -64,7 +65,7 @@ enum {
64 FW_FEATURE_BULK_REMOVE | FW_FEATURE_XDABR | 65 FW_FEATURE_BULK_REMOVE | FW_FEATURE_XDABR |
65 FW_FEATURE_MULTITCE | FW_FEATURE_SPLPAR | FW_FEATURE_LPAR | 66 FW_FEATURE_MULTITCE | FW_FEATURE_SPLPAR | FW_FEATURE_LPAR |
66 FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO | 67 FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO |
67 FW_FEATURE_SET_MODE, 68 FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY,
68 FW_FEATURE_PSERIES_ALWAYS = 0, 69 FW_FEATURE_PSERIES_ALWAYS = 0,
69 FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2, 70 FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2,
70 FW_FEATURE_POWERNV_ALWAYS = 0, 71 FW_FEATURE_POWERNV_ALWAYS = 0,
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index 55b98c3dc47a..aa3693f7fb27 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -62,6 +62,7 @@ firmware_features_table[FIRMWARE_MAX_FEATURES] = {
62 {FW_FEATURE_SPLPAR, "hcall-splpar"}, 62 {FW_FEATURE_SPLPAR, "hcall-splpar"},
63 {FW_FEATURE_VPHN, "hcall-vphn"}, 63 {FW_FEATURE_VPHN, "hcall-vphn"},
64 {FW_FEATURE_SET_MODE, "hcall-set-mode"}, 64 {FW_FEATURE_SET_MODE, "hcall-set-mode"},
65 {FW_FEATURE_BEST_ENERGY, "hcall-best-energy-1*"},
65}; 66};
66 67
67/* Build up the firmware features bitmask using the contents of 68/* Build up the firmware features bitmask using the contents of
diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c
index af281dce510a..a91e6dadda2c 100644
--- a/arch/powerpc/platforms/pseries/pseries_energy.c
+++ b/arch/powerpc/platforms/pseries/pseries_energy.c
@@ -21,6 +21,7 @@
21#include <asm/cputhreads.h> 21#include <asm/cputhreads.h>
22#include <asm/page.h> 22#include <asm/page.h>
23#include <asm/hvcall.h> 23#include <asm/hvcall.h>
24#include <asm/firmware.h>
24 25
25 26
26#define MODULE_VERS "1.0" 27#define MODULE_VERS "1.0"
@@ -32,40 +33,6 @@ static int sysfs_entries;
32 33
33/* Helper routines */ 34/* Helper routines */
34 35
35/*
36 * Routine to detect firmware support for hcall
37 * return 1 if H_BEST_ENERGY is supported
38 * else return 0
39 */
40
41static int check_for_h_best_energy(void)
42{
43 struct device_node *rtas = NULL;
44 const char *hypertas, *s;
45 int length;
46 int rc = 0;
47
48 rtas = of_find_node_by_path("/rtas");
49 if (!rtas)
50 return 0;
51
52 hypertas = of_get_property(rtas, "ibm,hypertas-functions", &length);
53 if (!hypertas) {
54 of_node_put(rtas);
55 return 0;
56 }
57
58 /* hypertas will have list of strings with hcall names */
59 for (s = hypertas; s < hypertas + length; s += strlen(s) + 1) {
60 if (!strncmp("hcall-best-energy-1", s, 19)) {
61 rc = 1; /* Found the string */
62 break;
63 }
64 }
65 of_node_put(rtas);
66 return rc;
67}
68
69/* Helper Routines to convert between drc_index to cpu numbers */ 36/* Helper Routines to convert between drc_index to cpu numbers */
70 37
71static u32 cpu_to_drc_index(int cpu) 38static u32 cpu_to_drc_index(int cpu)
@@ -262,7 +229,7 @@ static int __init pseries_energy_init(void)
262 int cpu, err; 229 int cpu, err;
263 struct device *cpu_dev; 230 struct device *cpu_dev;
264 231
265 if (!check_for_h_best_energy()) { 232 if (!firmware_has_feature(FW_FEATURE_BEST_ENERGY)) {
266 printk(KERN_INFO "Hypercall H_BEST_ENERGY not supported\n"); 233 printk(KERN_INFO "Hypercall H_BEST_ENERGY not supported\n");
267 return 0; 234 return 0;
268 } 235 }