Lines Matching +full:de +full:- +full:asserting
1 // SPDX-License-Identifier: GPL-2.0-only
5 * (C) 2002 Hiroshi Miura <miura@da-cha.org>
10 * software is provided AS-IS with no warranties.
19 * Suspend Modulation works by asserting and de-asserting the SUSP# pin
20 * to CPU(GX1/GXLV) for configurable durations. When asserting SUSP#
28 * 32us intervals which the SUSP# pin is asserted(ON)/de-asserted(OFF)
35 * F_eff = Fgx * ----------------------
43 * on_duration = off_duration * (stock_freq - freq) / freq
46 * on_duration = DURATION - off_duration
48 *---------------------------------------------------------------------------
51 * Dec. 12, 2003 Hiroshi Miura <miura@da-cha.org>
52 * - fix on/off register mistake
53 * - fix cpu_khz calc when it stops cpu modulation.
55 * Dec. 11, 2002 Hiroshi Miura <miura@da-cha.org>
56 * - rewrite for Cyrix MediaGX Cx5510/5520 and
60 * - cs5530_mod patch for 2.4.19-rc1.
62 *---------------------------------------------------------------------------
69 * Suspend Modulation - Definitions *
82 #include <asm/processor-cyrix.h>
104 #define SMISPDUP (1<<1) /* select how SMI re-enable suspend modulation: */
105 /* IRQTC timer or read SMI speedup disable reg.(F1BAR[08-09h]) */
123 /* PCI bus clock - defaults to 30.000 if cpu_khz is not available */
131 * is suspended -- processing power is just 0.39% of what it used to be,
132 * though. 781.25 kHz(!) for a 200 MHz processor -- wow. */
137 * - let's say 5%. (min = maxfreq / POLICY_MIN_DIV)
175 pci_write_config_byte(gx_params->cs55x0, reg, value); in gx_write_byte()
204 if ((gx_params->pci_suscfg & SUSMOD) == 0) in gx_get_cpuspeed()
207 return (stock_freq * gx_params->off_duration) in gx_get_cpuspeed()
208 / (gx_params->on_duration + gx_params->off_duration); in gx_get_cpuspeed()
228 for (i = max_duration; i > 0; i--) { in gx_validate_speed()
230 tmp_on = i - tmp_off; in gx_validate_speed()
233 * prefer it, too - lower latency */ in gx_validate_speed()
234 if (abs(tmp_freq - khz) <= abs(old_tmp_freq - khz)) { in gx_validate_speed()
259 new_khz = gx_validate_speed(khz, &gx_params->on_duration, in gx_set_cpuspeed()
260 &gx_params->off_duration); in gx_set_cpuspeed()
269 switch (gx_params->cs55x0->device) { in gx_set_cpuspeed()
271 pmer1 = gx_params->pci_pmer1 | IRQ_SPDUP | VID_SPDUP; in gx_set_cpuspeed()
272 /* FIXME: need to test other values -- Zwane,Miura */ in gx_set_cpuspeed()
279 if (gx_params->cs55x0->revision < 0x10) { in gx_set_cpuspeed()
281 suscfg = gx_params->pci_suscfg|SUSMOD; in gx_set_cpuspeed()
284 suscfg = gx_params->pci_suscfg|SUSMOD|PWRSVE; in gx_set_cpuspeed()
289 suscfg = gx_params->pci_suscfg | SUSMOD; in gx_set_cpuspeed()
297 suscfg = gx_params->pci_suscfg & ~(SUSMOD); in gx_set_cpuspeed()
298 gx_params->off_duration = 0; in gx_set_cpuspeed()
299 gx_params->on_duration = 0; in gx_set_cpuspeed()
303 gx_write_byte(PCI_MODOFF, gx_params->off_duration); in gx_set_cpuspeed()
304 gx_write_byte(PCI_MODON, gx_params->on_duration); in gx_set_cpuspeed()
307 pci_read_config_byte(gx_params->cs55x0, PCI_SUSCFG, &suscfg); in gx_set_cpuspeed()
311 gx_params->pci_suscfg = suscfg; in gx_set_cpuspeed()
316 gx_params->on_duration * 32, gx_params->off_duration * 32); in gx_set_cpuspeed()
337 return -EINVAL; in cpufreq_gx_verify()
339 policy->cpu = 0; in cpufreq_gx_verify()
344 * within policy->min and policy->max. If it is not, policy->max in cpufreq_gx_verify()
346 * policy->min may not be decreased, though. This way we guarantee a in cpufreq_gx_verify()
349 tmp_freq = gx_validate_speed(policy->min, &tmp1, &tmp2); in cpufreq_gx_verify()
350 if (tmp_freq < policy->min) in cpufreq_gx_verify()
352 policy->min = tmp_freq; in cpufreq_gx_verify()
353 if (policy->min > policy->max) in cpufreq_gx_verify()
354 policy->max = tmp_freq; in cpufreq_gx_verify()
355 tmp_freq = gx_validate_speed(policy->max, &tmp1, &tmp2); in cpufreq_gx_verify()
356 if (tmp_freq > policy->max) in cpufreq_gx_verify()
357 tmp_freq -= stock_freq / max_duration; in cpufreq_gx_verify()
358 policy->max = tmp_freq; in cpufreq_gx_verify()
359 if (policy->max < policy->min) in cpufreq_gx_verify()
360 policy->max = policy->min; in cpufreq_gx_verify()
379 return -EINVAL; in cpufreq_gx_target()
381 policy->cpu = 0; in cpufreq_gx_target()
384 while (tmp_freq < policy->min) { in cpufreq_gx_target()
388 while (tmp_freq > policy->max) { in cpufreq_gx_target()
389 tmp_freq -= stock_freq / max_duration; in cpufreq_gx_target()
402 if (!policy || policy->cpu != 0) in cpufreq_gx_cpu_init()
403 return -ENODEV; in cpufreq_gx_cpu_init()
418 policy->cpu = 0; in cpufreq_gx_cpu_init()
421 policy->min = maxfreq / max_duration; in cpufreq_gx_cpu_init()
423 policy->min = maxfreq / POLICY_MIN_DIV; in cpufreq_gx_cpu_init()
424 policy->max = maxfreq; in cpufreq_gx_cpu_init()
425 policy->cpuinfo.min_freq = maxfreq / max_duration; in cpufreq_gx_cpu_init()
426 policy->cpuinfo.max_freq = maxfreq; in cpufreq_gx_cpu_init()
441 .name = "gx-suspmod",
453 return -ENODEV; in cpufreq_gx_init()
463 return -ENOMEM; in cpufreq_gx_init()
465 params->cs55x0 = gx_pci; in cpufreq_gx_init()
469 pci_read_config_byte(params->cs55x0, PCI_SUSCFG, &(params->pci_suscfg)); in cpufreq_gx_init()
470 pci_read_config_byte(params->cs55x0, PCI_PMER1, &(params->pci_pmer1)); in cpufreq_gx_init()
471 pci_read_config_byte(params->cs55x0, PCI_PMER2, &(params->pci_pmer2)); in cpufreq_gx_init()
472 pci_read_config_byte(params->cs55x0, PCI_MODON, &(params->on_duration)); in cpufreq_gx_init()
473 pci_read_config_byte(params->cs55x0, PCI_MODOFF, in cpufreq_gx_init()
474 &(params->off_duration)); in cpufreq_gx_init()
488 pci_dev_put(gx_params->cs55x0); in cpufreq_gx_exit()
492 MODULE_AUTHOR("Hiroshi Miura <miura@da-cha.org>");