acpi_throttle.c (ededc31dd116dad6c47cc599286bc19af998ecf7) acpi_throttle.c (e94a0c1a18e6974bd6467d32a0f0fec8bffe5307)
1/*-
2 * Copyright (c) 2003-2005 Nate Lawson (SDG)
3 * Copyright (c) 2001 Michael Smith
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 83 unchanged lines hidden (view full) ---

92static int thr_quirks; /* Indicate any hardware bugs. */
93
94static void acpi_throttle_identify(driver_t *driver, device_t parent);
95static int acpi_throttle_probe(device_t dev);
96static int acpi_throttle_attach(device_t dev);
97static int acpi_throttle_evaluate(struct acpi_throttle_softc *sc);
98static int acpi_throttle_quirks(struct acpi_throttle_softc *sc);
99static int acpi_thr_settings(device_t dev, struct cf_setting *sets,
1/*-
2 * Copyright (c) 2003-2005 Nate Lawson (SDG)
3 * Copyright (c) 2001 Michael Smith
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 83 unchanged lines hidden (view full) ---

92static int thr_quirks; /* Indicate any hardware bugs. */
93
94static void acpi_throttle_identify(driver_t *driver, device_t parent);
95static int acpi_throttle_probe(device_t dev);
96static int acpi_throttle_attach(device_t dev);
97static int acpi_throttle_evaluate(struct acpi_throttle_softc *sc);
98static int acpi_throttle_quirks(struct acpi_throttle_softc *sc);
99static int acpi_thr_settings(device_t dev, struct cf_setting *sets,
100 int *count, int *type);
100 int *count);
101static int acpi_thr_set(device_t dev, const struct cf_setting *set);
102static int acpi_thr_get(device_t dev, struct cf_setting *set);
101static int acpi_thr_set(device_t dev, const struct cf_setting *set);
102static int acpi_thr_get(device_t dev, struct cf_setting *set);
103static int acpi_thr_type(device_t dev, int *type);
103
104static device_method_t acpi_throttle_methods[] = {
105 /* Device interface */
106 DEVMETHOD(device_identify, acpi_throttle_identify),
107 DEVMETHOD(device_probe, acpi_throttle_probe),
108 DEVMETHOD(device_attach, acpi_throttle_attach),
109
110 /* cpufreq interface */
111 DEVMETHOD(cpufreq_drv_set, acpi_thr_set),
112 DEVMETHOD(cpufreq_drv_get, acpi_thr_get),
104
105static device_method_t acpi_throttle_methods[] = {
106 /* Device interface */
107 DEVMETHOD(device_identify, acpi_throttle_identify),
108 DEVMETHOD(device_probe, acpi_throttle_probe),
109 DEVMETHOD(device_attach, acpi_throttle_attach),
110
111 /* cpufreq interface */
112 DEVMETHOD(cpufreq_drv_set, acpi_thr_set),
113 DEVMETHOD(cpufreq_drv_get, acpi_thr_get),
114 DEVMETHOD(cpufreq_drv_type, acpi_thr_type),
113 DEVMETHOD(cpufreq_drv_settings, acpi_thr_settings),
114 {0, 0}
115};
116
117static driver_t acpi_throttle_driver = {
118 "acpi_throttle",
119 acpi_throttle_methods,
120 sizeof(struct acpi_throttle_softc),

--- 194 unchanged lines hidden (view full) ---

315 break;
316 }
317 }
318
319 return (0);
320}
321
322static int
115 DEVMETHOD(cpufreq_drv_settings, acpi_thr_settings),
116 {0, 0}
117};
118
119static driver_t acpi_throttle_driver = {
120 "acpi_throttle",
121 acpi_throttle_methods,
122 sizeof(struct acpi_throttle_softc),

--- 194 unchanged lines hidden (view full) ---

317 break;
318 }
319 }
320
321 return (0);
322}
323
324static int
323acpi_thr_settings(device_t dev, struct cf_setting *sets, int *count, int *type)
325acpi_thr_settings(device_t dev, struct cf_setting *sets, int *count)
324{
325 struct acpi_throttle_softc *sc;
326 int i, speed;
327
328 sc = device_get_softc(dev);
329 if (sets == NULL || count == NULL)
330 return (EINVAL);
331 if (*count < CPU_MAX_SPEED)
332 return (E2BIG);
333
334 /* Return a list of valid settings for this driver. */
335 memset(sets, CPUFREQ_VAL_UNKNOWN, sizeof(*sets) * CPU_MAX_SPEED);
336 for (i = 0, speed = CPU_MAX_SPEED; speed != 0; i++, speed--) {
337 sets[i].freq = CPU_SPEED_PERCENT(speed);
338 sets[i].dev = dev;
339 }
340 *count = CPU_MAX_SPEED;
326{
327 struct acpi_throttle_softc *sc;
328 int i, speed;
329
330 sc = device_get_softc(dev);
331 if (sets == NULL || count == NULL)
332 return (EINVAL);
333 if (*count < CPU_MAX_SPEED)
334 return (E2BIG);
335
336 /* Return a list of valid settings for this driver. */
337 memset(sets, CPUFREQ_VAL_UNKNOWN, sizeof(*sets) * CPU_MAX_SPEED);
338 for (i = 0, speed = CPU_MAX_SPEED; speed != 0; i++, speed--) {
339 sets[i].freq = CPU_SPEED_PERCENT(speed);
340 sets[i].dev = dev;
341 }
342 *count = CPU_MAX_SPEED;
341 *type = CPUFREQ_TYPE_RELATIVE;
342
343 return (0);
344}
345
346static int
347acpi_thr_set(device_t dev, const struct cf_setting *set)
348{
349 struct acpi_throttle_softc *sc;

--- 54 unchanged lines hidden (view full) ---

404 sc->cpu_thr_state = clk_val;
405
406 memset(set, CPUFREQ_VAL_UNKNOWN, sizeof(*set));
407 set->freq = CPU_SPEED_PERCENT(clk_val);
408 set->dev = dev;
409
410 return (0);
411}
343
344 return (0);
345}
346
347static int
348acpi_thr_set(device_t dev, const struct cf_setting *set)
349{
350 struct acpi_throttle_softc *sc;

--- 54 unchanged lines hidden (view full) ---

405 sc->cpu_thr_state = clk_val;
406
407 memset(set, CPUFREQ_VAL_UNKNOWN, sizeof(*set));
408 set->freq = CPU_SPEED_PERCENT(clk_val);
409 set->dev = dev;
410
411 return (0);
412}
413
414static int
415acpi_thr_type(device_t dev, int *type)
416{
417
418 if (type == NULL)
419 return (EINVAL);
420
421 *type = CPUFREQ_TYPE_RELATIVE;
422 return (0);
423}