ichss.c (6655857ec7b8ca3beb28de35e587e8f28cde6f2e) | ichss.c (e94a0c1a18e6974bd6467d32a0f0fec8bffe5307) |
---|---|
1/*- 2 * Copyright (c) 2004-2005 Nate Lawson (SDG) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 83 unchanged lines hidden (view full) --- 92 (bus_space_write_1(rman_get_bustag((reg)), \ 93 rman_get_bushandle((reg)), 0, (val))) 94 95static int ichss_pci_probe(device_t dev); 96static int ichss_probe(device_t dev); 97static int ichss_attach(device_t dev); 98static int ichss_detach(device_t dev); 99static int ichss_settings(device_t dev, struct cf_setting *sets, | 1/*- 2 * Copyright (c) 2004-2005 Nate Lawson (SDG) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 83 unchanged lines hidden (view full) --- 92 (bus_space_write_1(rman_get_bustag((reg)), \ 93 rman_get_bushandle((reg)), 0, (val))) 94 95static int ichss_pci_probe(device_t dev); 96static int ichss_probe(device_t dev); 97static int ichss_attach(device_t dev); 98static int ichss_detach(device_t dev); 99static int ichss_settings(device_t dev, struct cf_setting *sets, |
100 int *count, int *type); | 100 int *count); |
101static int ichss_set(device_t dev, const struct cf_setting *set); 102static int ichss_get(device_t dev, struct cf_setting *set); | 101static int ichss_set(device_t dev, const struct cf_setting *set); 102static int ichss_get(device_t dev, struct cf_setting *set); |
103static int ichss_type(device_t dev, int *type); |
|
103 104static device_method_t ichss_methods[] = { 105 /* Device interface */ 106 DEVMETHOD(device_probe, ichss_probe), 107 DEVMETHOD(device_attach, ichss_attach), 108 DEVMETHOD(device_detach, ichss_detach), 109 110 /* cpufreq interface */ 111 DEVMETHOD(cpufreq_drv_set, ichss_set), 112 DEVMETHOD(cpufreq_drv_get, ichss_get), | 104 105static device_method_t ichss_methods[] = { 106 /* Device interface */ 107 DEVMETHOD(device_probe, ichss_probe), 108 DEVMETHOD(device_attach, ichss_attach), 109 DEVMETHOD(device_detach, ichss_detach), 110 111 /* cpufreq interface */ 112 DEVMETHOD(cpufreq_drv_set, ichss_set), 113 DEVMETHOD(cpufreq_drv_get, ichss_get), |
114 DEVMETHOD(cpufreq_drv_type, ichss_type), |
|
113 DEVMETHOD(cpufreq_drv_settings, ichss_settings), 114 {0, 0} 115}; 116static driver_t ichss_driver = { 117 "ichss", ichss_methods, sizeof(struct ichss_softc) 118}; 119static devclass_t ichss_devclass; 120DRIVER_MODULE(ichss, cpu, ichss_driver, ichss_devclass, 0, 0); --- 83 unchanged lines hidden (view full) --- 204 device_probe_and_attach(child); 205 206 return (ENXIO); 207} 208 209static int 210ichss_probe(device_t dev) 211{ | 115 DEVMETHOD(cpufreq_drv_settings, ichss_settings), 116 {0, 0} 117}; 118static driver_t ichss_driver = { 119 "ichss", ichss_methods, sizeof(struct ichss_softc) 120}; 121static devclass_t ichss_devclass; 122DRIVER_MODULE(ichss, cpu, ichss_driver, ichss_devclass, 0, 0); --- 83 unchanged lines hidden (view full) --- 206 device_probe_and_attach(child); 207 208 return (ENXIO); 209} 210 211static int 212ichss_probe(device_t dev) 213{ |
212 struct cf_setting set; | |
213 device_t perf_dev; | 214 device_t perf_dev; |
214 int count, type; | 215 int error, type; |
215 216 /* 217 * If the ACPI perf driver has attached and is not just offering 218 * info, let it manage things. 219 */ 220 perf_dev = device_find_child(device_get_parent(dev), "acpi_perf", -1); 221 if (perf_dev && device_is_attached(perf_dev)) { | 216 217 /* 218 * If the ACPI perf driver has attached and is not just offering 219 * info, let it manage things. 220 */ 221 perf_dev = device_find_child(device_get_parent(dev), "acpi_perf", -1); 222 if (perf_dev && device_is_attached(perf_dev)) { |
222 type = 0; 223 count = 1; 224 CPUFREQ_DRV_SETTINGS(perf_dev, &set, &count, &type); 225 if ((type & CPUFREQ_FLAG_INFO_ONLY) == 0) | 223 error = CPUFREQ_DRV_TYPE(perf_dev, &type); 224 if (error == 0 && (type & CPUFREQ_FLAG_INFO_ONLY) == 0) |
226 return (ENXIO); 227 } 228 229 device_set_desc(dev, "SpeedStep ICH"); 230 return (-1000); 231} 232 233static int --- 36 unchanged lines hidden (view full) --- 270static int 271ichss_detach(device_t dev) 272{ 273 /* TODO: teardown BM and CTRL registers. */ 274 return (ENXIO); 275} 276 277static int | 225 return (ENXIO); 226 } 227 228 device_set_desc(dev, "SpeedStep ICH"); 229 return (-1000); 230} 231 232static int --- 36 unchanged lines hidden (view full) --- 269static int 270ichss_detach(device_t dev) 271{ 272 /* TODO: teardown BM and CTRL registers. */ 273 return (ENXIO); 274} 275 276static int |
278ichss_settings(device_t dev, struct cf_setting *sets, int *count, int *type) | 277ichss_settings(device_t dev, struct cf_setting *sets, int *count) |
279{ 280 struct ichss_softc *sc; 281 struct cf_setting set; 282 int first, i; 283 284 if (sets == NULL || count == NULL) 285 return (EINVAL); 286 if (*count < 2) { --- 12 unchanged lines hidden (view full) --- 299 first = (i == 0) ? 1 : 0; 300 ichss_set(dev, &sc->sets[i]); 301 ichss_set(dev, &sc->sets[first]); 302 } 303 } 304 305 bcopy(sc->sets, sets, sizeof(sc->sets)); 306 *count = 2; | 278{ 279 struct ichss_softc *sc; 280 struct cf_setting set; 281 int first, i; 282 283 if (sets == NULL || count == NULL) 284 return (EINVAL); 285 if (*count < 2) { --- 12 unchanged lines hidden (view full) --- 298 first = (i == 0) ? 1 : 0; 299 ichss_set(dev, &sc->sets[i]); 300 ichss_set(dev, &sc->sets[first]); 301 } 302 } 303 304 bcopy(sc->sets, sets, sizeof(sc->sets)); 305 *count = 2; |
307 *type = CPUFREQ_TYPE_ABSOLUTE; | |
308 309 return (0); 310} 311 312static int 313ichss_set(device_t dev, const struct cf_setting *set) 314{ 315 struct ichss_softc *sc; --- 61 unchanged lines hidden (view full) --- 377 sc->sets[state].freq = rate / 1000000; 378 DPRINT("ichss: get calibrated new rate of %d\n", 379 sc->sets[state].freq); 380 } 381 *set = sc->sets[state]; 382 383 return (0); 384} | 306 307 return (0); 308} 309 310static int 311ichss_set(device_t dev, const struct cf_setting *set) 312{ 313 struct ichss_softc *sc; --- 61 unchanged lines hidden (view full) --- 375 sc->sets[state].freq = rate / 1000000; 376 DPRINT("ichss: get calibrated new rate of %d\n", 377 sc->sets[state].freq); 378 } 379 *set = sc->sets[state]; 380 381 return (0); 382} |
383 384static int 385ichss_type(device_t dev, int *type) 386{ 387 388 if (type == NULL) 389 return (EINVAL); 390 391 *type = CPUFREQ_TYPE_ABSOLUTE; 392 return (0); 393} |
|