| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: amdtemp.c,v 1.12 2011/07/31 22:04:07 jmcneill Exp $ */ | | 1 | /* $NetBSD: amdtemp.c,v 1.12.8.1 2012/03/08 17:38:03 riz Exp $ */ |
2 | /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ | | 2 | /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 5 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Christoph Egger. | | 9 | * by Christoph Egger. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -38,27 +38,27 @@ | | | @@ -38,27 +38,27 @@ |
38 | * copyright notice and this permission notice appear in all copies. | | 38 | * copyright notice and this permission notice appear in all copies. |
39 | * | | 39 | * |
40 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 40 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
41 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 41 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
42 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 42 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
43 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 43 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
44 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 44 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
45 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 45 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
46 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 46 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
47 | */ | | 47 | */ |
48 | | | 48 | |
49 | | | 49 | |
50 | #include <sys/cdefs.h> | | 50 | #include <sys/cdefs.h> |
51 | __KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.12 2011/07/31 22:04:07 jmcneill Exp $ "); | | 51 | __KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.12.8.1 2012/03/08 17:38:03 riz Exp $ "); |
52 | | | 52 | |
53 | #include <sys/param.h> | | 53 | #include <sys/param.h> |
54 | #include <sys/bus.h> | | 54 | #include <sys/bus.h> |
55 | #include <sys/cpu.h> | | 55 | #include <sys/cpu.h> |
56 | #include <sys/systm.h> | | 56 | #include <sys/systm.h> |
57 | #include <sys/device.h> | | 57 | #include <sys/device.h> |
58 | #include <sys/kmem.h> | | 58 | #include <sys/kmem.h> |
59 | #include <sys/module.h> | | 59 | #include <sys/module.h> |
60 | | | 60 | |
61 | #include <machine/specialreg.h> | | 61 | #include <machine/specialreg.h> |
62 | | | 62 | |
63 | #include <dev/pci/pcireg.h> | | 63 | #include <dev/pci/pcireg.h> |
64 | #include <dev/pci/pcivar.h> | | 64 | #include <dev/pci/pcivar.h> |
| @@ -186,27 +186,27 @@ static int | | | @@ -186,27 +186,27 @@ static int |
186 | amdtemp_match(device_t parent, cfdata_t match, void *aux) | | 186 | amdtemp_match(device_t parent, cfdata_t match, void *aux) |
187 | { | | 187 | { |
188 | struct pci_attach_args *pa = aux; | | 188 | struct pci_attach_args *pa = aux; |
189 | pcireg_t cpu_signature; | | 189 | pcireg_t cpu_signature; |
190 | uint32_t family; | | 190 | uint32_t family; |
191 | | | 191 | |
192 | if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD) | | 192 | if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD) |
193 | return 0; | | 193 | return 0; |
194 | | | 194 | |
195 | switch (PCI_PRODUCT(pa->pa_id)) { | | 195 | switch (PCI_PRODUCT(pa->pa_id)) { |
196 | case PCI_PRODUCT_AMD_AMD64_MISC: | | 196 | case PCI_PRODUCT_AMD_AMD64_MISC: |
197 | case PCI_PRODUCT_AMD_AMD64_F10_MISC: | | 197 | case PCI_PRODUCT_AMD_AMD64_F10_MISC: |
198 | case PCI_PRODUCT_AMD_AMD64_F11_MISC: | | 198 | case PCI_PRODUCT_AMD_AMD64_F11_MISC: |
199 | case PCI_PRODUCT_AMD_F14_NB: | | 199 | case PCI_PRODUCT_AMD_F14_NB: /* Family12h too */ |
200 | break; | | 200 | break; |
201 | default: | | 201 | default: |
202 | return 0; | | 202 | return 0; |
203 | } | | 203 | } |
204 | | | 204 | |
205 | cpu_signature = pci_conf_read(pa->pa_pc, | | 205 | cpu_signature = pci_conf_read(pa->pa_pc, |
206 | pa->pa_tag, CPUID_FAMILY_MODEL_R); | | 206 | pa->pa_tag, CPUID_FAMILY_MODEL_R); |
207 | | | 207 | |
208 | /* This CPUID northbridge register has been introduced | | 208 | /* This CPUID northbridge register has been introduced |
209 | * in Revision F */ | | 209 | * in Revision F */ |
210 | if (cpu_signature == 0x0) | | 210 | if (cpu_signature == 0x0) |
211 | return 0; | | 211 | return 0; |
212 | | | 212 | |
| @@ -258,27 +258,28 @@ amdtemp_attach(device_t parent, device_t | | | @@ -258,27 +258,28 @@ amdtemp_attach(device_t parent, device_t |
258 | sc->sc_sensor = NULL; | | 258 | sc->sc_sensor = NULL; |
259 | | | 259 | |
260 | sc->sc_pc = pa->pa_pc; | | 260 | sc->sc_pc = pa->pa_pc; |
261 | sc->sc_pcitag = pa->pa_tag; | | 261 | sc->sc_pcitag = pa->pa_tag; |
262 | sc->sc_adjustment = 0; | | 262 | sc->sc_adjustment = 0; |
263 | | | 263 | |
264 | switch (sc->sc_family) { | | 264 | switch (sc->sc_family) { |
265 | case 0xf: /* AMD K8 NPT */ | | 265 | case 0xf: /* AMD K8 NPT */ |
266 | amdtemp_k8_init(sc, cpu_signature); | | 266 | amdtemp_k8_init(sc, cpu_signature); |
267 | break; | | 267 | break; |
268 | | | 268 | |
269 | case 0x10: /* AMD Barcelona/Phenom */ | | 269 | case 0x10: /* AMD Barcelona/Phenom */ |
270 | case 0x11: /* AMD Griffin */ | | 270 | case 0x11: /* AMD Griffin */ |
271 | case 0x14: /* AMD Fusion */ | | 271 | case 0x12: /* AMD Lynx/Sabine (Llano) */ |
| | | 272 | case 0x14: /* AMD Brazos (Ontario/Zacate/Desna) */ |
272 | amdtemp_family10_init(sc); | | 273 | amdtemp_family10_init(sc); |
273 | break; | | 274 | break; |
274 | | | 275 | |
275 | default: | | 276 | default: |
276 | aprint_normal(", family 0x%x not supported\n", | | 277 | aprint_normal(", family 0x%x not supported\n", |
277 | sc->sc_family); | | 278 | sc->sc_family); |
278 | return; | | 279 | return; |
279 | } | | 280 | } |
280 | | | 281 | |
281 | aprint_normal("\n"); | | 282 | aprint_normal("\n"); |
282 | | | 283 | |
283 | if (sc->sc_adjustment != 0) | | 284 | if (sc->sc_adjustment != 0) |
284 | aprint_debug_dev(self, "Workaround enabled\n"); | | 285 | aprint_debug_dev(self, "Workaround enabled\n"); |
| @@ -286,52 +287,54 @@ amdtemp_attach(device_t parent, device_t | | | @@ -286,52 +287,54 @@ amdtemp_attach(device_t parent, device_t |
286 | sc->sc_sme = sysmon_envsys_create(); | | 287 | sc->sc_sme = sysmon_envsys_create(); |
287 | sc->sc_sensor_len = sizeof(envsys_data_t) * sc->sc_numsensors; | | 288 | sc->sc_sensor_len = sizeof(envsys_data_t) * sc->sc_numsensors; |
288 | sc->sc_sensor = kmem_zalloc(sc->sc_sensor_len, KM_SLEEP); | | 289 | sc->sc_sensor = kmem_zalloc(sc->sc_sensor_len, KM_SLEEP); |
289 | | | 290 | |
290 | if (sc->sc_sensor == NULL) | | 291 | if (sc->sc_sensor == NULL) |
291 | goto bad; | | 292 | goto bad; |
292 | | | 293 | |
293 | switch (sc->sc_family) { | | 294 | switch (sc->sc_family) { |
294 | case 0xf: | | 295 | case 0xf: |
295 | amdtemp_k8_setup_sensors(sc, device_unit(self)); | | 296 | amdtemp_k8_setup_sensors(sc, device_unit(self)); |
296 | break; | | 297 | break; |
297 | case 0x10: | | 298 | case 0x10: |
298 | case 0x11: | | 299 | case 0x11: |
| | | 300 | case 0x12: |
299 | case 0x14: | | 301 | case 0x14: |
300 | amdtemp_family10_setup_sensors(sc, device_unit(self)); | | 302 | amdtemp_family10_setup_sensors(sc, device_unit(self)); |
301 | break; | | 303 | break; |
302 | } | | 304 | } |
303 | | | 305 | |
304 | /* | | 306 | /* |
305 | * Set properties in sensors. | | 307 | * Set properties in sensors. |
306 | */ | | 308 | */ |
307 | for (i = 0; i < sc->sc_numsensors; i++) { | | 309 | for (i = 0; i < sc->sc_numsensors; i++) { |
308 | if (sysmon_envsys_sensor_attach(sc->sc_sme, | | 310 | if (sysmon_envsys_sensor_attach(sc->sc_sme, |
309 | &sc->sc_sensor[i])) | | 311 | &sc->sc_sensor[i])) |
310 | goto bad; | | 312 | goto bad; |
311 | } | | 313 | } |
312 | | | 314 | |
313 | /* | | 315 | /* |
314 | * Register the sysmon_envsys device. | | 316 | * Register the sysmon_envsys device. |
315 | */ | | 317 | */ |
316 | sc->sc_sme->sme_name = device_xname(self); | | 318 | sc->sc_sme->sme_name = device_xname(self); |
317 | sc->sc_sme->sme_cookie = sc; | | 319 | sc->sc_sme->sme_cookie = sc; |
318 | | | 320 | |
319 | switch (sc->sc_family) { | | 321 | switch (sc->sc_family) { |
320 | case 0xf: | | 322 | case 0xf: |
321 | sc->sc_sme->sme_refresh = amdtemp_k8_refresh; | | 323 | sc->sc_sme->sme_refresh = amdtemp_k8_refresh; |
322 | break; | | 324 | break; |
323 | case 0x10: | | 325 | case 0x10: |
324 | case 0x11: | | 326 | case 0x11: |
| | | 327 | case 0x12: |
325 | case 0x14: | | 328 | case 0x14: |
326 | sc->sc_sme->sme_refresh = amdtemp_family10_refresh; | | 329 | sc->sc_sme->sme_refresh = amdtemp_family10_refresh; |
327 | break; | | 330 | break; |
328 | } | | 331 | } |
329 | | | 332 | |
330 | error = sysmon_envsys_register(sc->sc_sme); | | 333 | error = sysmon_envsys_register(sc->sc_sme); |
331 | if (error) { | | 334 | if (error) { |
332 | aprint_error_dev(self, "unable to register with sysmon " | | 335 | aprint_error_dev(self, "unable to register with sysmon " |
333 | "(error=%d)\n", error); | | 336 | "(error=%d)\n", error); |
334 | goto bad; | | 337 | goto bad; |
335 | } | | 338 | } |
336 | | | 339 | |
337 | (void)pmf_device_register(self, NULL, NULL); | | 340 | (void)pmf_device_register(self, NULL, NULL); |