aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-10-09 15:45:23 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-12-05 13:55:55 -0500
commit2fa5222efeb4a76597ceace21c0435d49a34715e (patch)
tree67381036996eba50dab2ff07cceeb580876cfa33 /drivers/hwmon
parentd9b24e373d160ffd56633cc9a4b2e4013c2682d1 (diff)
hwmon: (coretemp) Use model table instead of if/else to identify CPU models
Make the code easier to extend and easier to adjust by using a model table listing CPU models, stepping/mask, and associated TjMax. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/coretemp.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 1653d0ddd1d0..81c248dad4ba 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -211,6 +211,28 @@ static const struct tjmax __cpuinitconst tjmax_table[] = {
211 { "CPU CE4170", 110000 }, /* Model 0x1c, stepping 10 */ 211 { "CPU CE4170", 110000 }, /* Model 0x1c, stepping 10 */
212}; 212};
213 213
214struct tjmax_model {
215 u8 model;
216 u8 mask;
217 int tjmax;
218};
219
220#define ANY 0xff
221
222static const struct tjmax_model __cpuinitconst tjmax_model_table[] = {
223 { 0x1c, 10, 100000 }, /* D4xx, N4xx, D5xx, N5xx */
224 { 0x1c, ANY, 90000 }, /* Z5xx, N2xx, possibly others
225 * Note: Also matches 230 and 330,
226 * which are covered by tjmax_table
227 */
228 { 0x26, ANY, 90000 }, /* Atom Tunnel Creek (Exx), Lincroft (Z6xx)
229 * Note: TjMax for E6xxT is 110C, but CPU type
230 * is undetectable by software
231 */
232 { 0x27, ANY, 90000 }, /* Atom Medfield (Z2460) */
233 { 0x36, ANY, 100000 }, /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx) */
234};
235
214static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, 236static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
215 struct device *dev) 237 struct device *dev)
216{ 238{
@@ -229,20 +251,11 @@ static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
229 return tjmax_table[i].tjmax; 251 return tjmax_table[i].tjmax;
230 } 252 }
231 253
232 /* Atom CPUs */ 254 for (i = 0; i < ARRAY_SIZE(tjmax_model_table); i++) {
233 255 const struct tjmax_model *tm = &tjmax_model_table[i];
234 if (c->x86_model == 0x1c) { 256 if (c->x86_model == tm->model &&
235 /* 257 (tm->mask == ANY || c->x86_mask == tm->mask))
236 * TjMax for stepping 10 CPUs (N4xx, N5xx, D4xx, D5xx) 258 return tm->tjmax;
237 * is 100 degrees C, for all others it is 90 degrees C.
238 */
239 if (c->x86_mask == 10)
240 return 100000;
241 return 90000;
242 } else if (c->x86_model == 0x26 || c->x86_model == 0x27) {
243 return 90000;
244 } else if (c->x86_model == 0x36) {
245 return 100000;
246 } 259 }
247 260
248 /* Early chips have no MSR for TjMax */ 261 /* Early chips have no MSR for TjMax */