Lines Matching +full:speed +full:- +full:set

1 /*-
2 * Copyright (c) 2003-2005 Nate Lawson (SDG)
90 static int thr_rid; /* Driver-wide resource id. */
100 static int acpi_thr_set(device_t dev, const struct cf_setting *set);
101 static int acpi_thr_get(device_t dev, struct cf_setting *set);
146 * Add a child if there's a non-NULL P_BLK and correct length, or in acpi_throttle_identify()
154 if ((obj->Processor.PblkAddress && obj->Processor.PblkLength >= 4) || in acpi_throttle_identify()
188 struct cf_setting set; in acpi_throttle_attach() local
195 sc->cpu_dev = dev; in acpi_throttle_attach()
196 sc->cpu_handle = acpi_get_handle(dev); in acpi_throttle_attach()
200 status = AcpiEvaluateObject(sc->cpu_handle, NULL, NULL, &buf); in acpi_throttle_attach()
202 device_printf(dev, "attach failed to get Processor obj - %s\n", in acpi_throttle_attach()
207 sc->cpu_p_blk = obj->Processor.PblkAddress; in acpi_throttle_attach()
208 sc->cpu_p_blk_len = obj->Processor.PblkLength; in acpi_throttle_attach()
221 * Set our initial frequency to the highest since some systems in acpi_throttle_attach()
224 set.freq = 10000; in acpi_throttle_attach()
225 acpi_thr_set(dev, &set); in acpi_throttle_attach()
242 if (device_get_unit(sc->cpu_dev) == 0) { in acpi_throttle_evaluate()
250 duty_end = cpu_duty_offset + cpu_duty_width - 1; in acpi_throttle_evaluate()
252 device_printf(sc->cpu_dev, in acpi_throttle_evaluate()
257 device_printf(sc->cpu_dev, in acpi_throttle_evaluate()
271 status = AcpiEvaluateObject(sc->cpu_handle, "_PTC", NULL, &buf); in acpi_throttle_evaluate()
274 device_printf(sc->cpu_dev, "_PTC buffer too small\n"); in acpi_throttle_evaluate()
278 acpi_bus_alloc_gas(sc->cpu_dev, &sc->cpu_p_type, thr_rid, in acpi_throttle_evaluate()
279 &gas, &sc->cpu_p_cnt, 0); in acpi_throttle_evaluate()
280 if (sc->cpu_p_cnt != NULL && bootverbose) { in acpi_throttle_evaluate()
281 device_printf(sc->cpu_dev, "P_CNT from _PTC %#jx\n", in acpi_throttle_evaluate()
287 if (sc->cpu_p_cnt == NULL) { in acpi_throttle_evaluate()
290 * systems use it to indicate a fractional set of features in acpi_throttle_evaluate()
293 if (sc->cpu_p_blk_len < 4) in acpi_throttle_evaluate()
295 gas.Address = sc->cpu_p_blk; in acpi_throttle_evaluate()
298 acpi_bus_alloc_gas(sc->cpu_dev, &sc->cpu_p_type, thr_rid, in acpi_throttle_evaluate()
299 &gas, &sc->cpu_p_cnt, 0); in acpi_throttle_evaluate()
300 if (sc->cpu_p_cnt != NULL) { in acpi_throttle_evaluate()
302 device_printf(sc->cpu_dev, in acpi_throttle_evaluate()
303 "P_CNT from P_BLK %#x\n", sc->cpu_p_blk); in acpi_throttle_evaluate()
305 device_printf(sc->cpu_dev, "failed to attach P_CNT\n"); in acpi_throttle_evaluate()
325 * Disable throttling control on PIIX4 A and B-step. in acpi_throttle_quirks()
346 int i, speed; in acpi_thr_settings() local
355 for (i = 0, speed = CPU_MAX_SPEED; speed != 0; i++, speed--) { in acpi_thr_settings()
356 sets[i].freq = CPU_SPEED_PERCENT(speed); in acpi_thr_settings()
365 acpi_thr_set(device_t dev, const struct cf_setting *set) in acpi_thr_set() argument
368 uint32_t clk_val, p_cnt, speed; in acpi_thr_set() local
370 if (set == NULL) in acpi_thr_set()
378 speed = set->freq * CPU_MAX_SPEED / 10000; in acpi_thr_set()
379 if (speed * 10000 != set->freq * CPU_MAX_SPEED || in acpi_thr_set()
380 speed < 1 || speed > CPU_MAX_SPEED) in acpi_thr_set()
384 if (speed == sc->cpu_thr_state) in acpi_thr_set()
388 p_cnt = THR_GET_REG(sc->cpu_p_cnt); in acpi_thr_set()
390 THR_SET_REG(sc->cpu_p_cnt, p_cnt); in acpi_thr_set()
392 /* If we're at maximum speed, that's all */ in acpi_thr_set()
393 if (speed < CPU_MAX_SPEED) { in acpi_thr_set()
395 clk_val = (CPU_MAX_SPEED - 1) << cpu_duty_offset; in acpi_thr_set()
397 p_cnt |= (speed << cpu_duty_offset); in acpi_thr_set()
400 THR_SET_REG(sc->cpu_p_cnt, p_cnt); in acpi_thr_set()
402 THR_SET_REG(sc->cpu_p_cnt, p_cnt); in acpi_thr_set()
404 sc->cpu_thr_state = speed; in acpi_thr_set()
410 acpi_thr_get(device_t dev, struct cf_setting *set) in acpi_thr_get() argument
415 if (set == NULL) in acpi_thr_get()
420 p_cnt = THR_GET_REG(sc->cpu_p_cnt); in acpi_thr_get()
421 clk_val = (p_cnt >> cpu_duty_offset) & (CPU_MAX_SPEED - 1); in acpi_thr_get()
422 sc->cpu_thr_state = clk_val; in acpi_thr_get()
424 memset(set, CPUFREQ_VAL_UNKNOWN, sizeof(*set)); in acpi_thr_get()
425 set->freq = CPU_SPEED_PERCENT(clk_val); in acpi_thr_get()
426 set->dev = dev; in acpi_thr_get()