diff options
author | Christian Krafft <krafft@de.ibm.com> | 2007-04-23 15:35:40 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@klappe.arndb.de> | 2007-04-23 15:44:39 -0400 |
commit | 24d560d7b9cf90451c6ef6248c09fb4cee1c76e6 (patch) | |
tree | 72ce3dac5fb300f6ef539170f260bc30c3de5503 /arch | |
parent | 91a69c9646a5b709381d99a171890e77377b1b9c (diff) |
[POWERPC] cbe_thermal: clean up computation of temperature
This patch introduces a little function for transforming
register values into temperature.
Signed-off-by: Christian Krafft <krafft@de.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/cell/cbe_thermal.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c b/arch/powerpc/platforms/cell/cbe_thermal.c index e8bcd2a767ce..0d486fd424a9 100644 --- a/arch/powerpc/platforms/cell/cbe_thermal.c +++ b/arch/powerpc/platforms/cell/cbe_thermal.c | |||
@@ -31,6 +31,11 @@ | |||
31 | #include "cbe_regs.h" | 31 | #include "cbe_regs.h" |
32 | #include "spu_priv1_mmio.h" | 32 | #include "spu_priv1_mmio.h" |
33 | 33 | ||
34 | static inline u8 reg_to_temp(u8 reg_value) | ||
35 | { | ||
36 | return ((reg_value & 0x3f) << 1) + 65; | ||
37 | } | ||
38 | |||
34 | static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev) | 39 | static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev) |
35 | { | 40 | { |
36 | struct spu *spu; | 41 | struct spu *spu; |
@@ -58,20 +63,14 @@ static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iom | |||
58 | 63 | ||
59 | static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf) | 64 | static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf) |
60 | { | 65 | { |
61 | int value; | 66 | u8 value; |
62 | struct cbe_pmd_regs __iomem *pmd_regs; | 67 | struct cbe_pmd_regs __iomem *pmd_regs; |
63 | 68 | ||
64 | pmd_regs = get_pmd_regs(sysdev); | 69 | pmd_regs = get_pmd_regs(sysdev); |
65 | 70 | ||
66 | value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1); | 71 | value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1); |
67 | /* clear all other bits */ | 72 | |
68 | value &= 0x3F; | 73 | return sprintf(buf, "%d\n", reg_to_temp(value)); |
69 | /* temp is stored in steps of 2 degrees */ | ||
70 | value *= 2; | ||
71 | /* base temp is 65 degrees */ | ||
72 | value += 65; | ||
73 | |||
74 | return sprintf(buf, "%d\n", (int) value); | ||
75 | } | 74 | } |
76 | 75 | ||
77 | static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos) | 76 | static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos) |
@@ -82,16 +81,9 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos) | |||
82 | pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id); | 81 | pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id); |
83 | value = in_be64(&pmd_regs->ts_ctsr2); | 82 | value = in_be64(&pmd_regs->ts_ctsr2); |
84 | 83 | ||
85 | /* access the corresponding byte */ | 84 | value = (value >> pos) & 0x3f; |
86 | value >>= pos; | ||
87 | /* clear all other bits */ | ||
88 | value &= 0x3F; | ||
89 | /* temp is stored in steps of 2 degrees */ | ||
90 | value *= 2; | ||
91 | /* base temp is 65 degrees */ | ||
92 | value += 65; | ||
93 | 85 | ||
94 | return sprintf(buf, "%d\n", (int) value); | 86 | return sprintf(buf, "%d\n", reg_to_temp(value)); |
95 | } | 87 | } |
96 | 88 | ||
97 | 89 | ||