Skip to content
Snippets Groups Projects
Select Git revision
  • fab24dcc395637557a7988a867e7b3a5823917a9
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

intel_pstate.c

Blame
  • intel_pstate.c 64.36 KiB
    /*
     * intel_pstate.c: Native P state management for Intel processors
     *
     * (C) Copyright 2012 Intel Corporation
     * Author: Dirk Brandewie <dirk.j.brandewie@intel.com>
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * as published by the Free Software Foundation; version 2
     * of the License.
     */
    
    #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
    
    #include <linux/kernel.h>
    #include <linux/kernel_stat.h>
    #include <linux/module.h>
    #include <linux/ktime.h>
    #include <linux/hrtimer.h>
    #include <linux/tick.h>
    #include <linux/slab.h>
    #include <linux/sched/cpufreq.h>
    #include <linux/list.h>
    #include <linux/cpu.h>
    #include <linux/cpufreq.h>
    #include <linux/sysfs.h>
    #include <linux/types.h>
    #include <linux/fs.h>
    #include <linux/debugfs.h>
    #include <linux/acpi.h>
    #include <linux/vmalloc.h>
    #include <trace/events/power.h>
    
    #include <asm/div64.h>
    #include <asm/msr.h>
    #include <asm/cpu_device_id.h>
    #include <asm/cpufeature.h>
    #include <asm/intel-family.h>
    
    #define INTEL_PSTATE_DEFAULT_SAMPLING_INTERVAL	(10 * NSEC_PER_MSEC)
    #define INTEL_PSTATE_HWP_SAMPLING_INTERVAL	(50 * NSEC_PER_MSEC)
    
    #define INTEL_CPUFREQ_TRANSITION_LATENCY	20000
    #define INTEL_CPUFREQ_TRANSITION_DELAY		500
    
    #ifdef CONFIG_ACPI
    #include <acpi/processor.h>
    #include <acpi/cppc_acpi.h>
    #endif
    
    #define FRAC_BITS 8
    #define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
    #define fp_toint(X) ((X) >> FRAC_BITS)
    
    #define EXT_BITS 6
    #define EXT_FRAC_BITS (EXT_BITS + FRAC_BITS)
    #define fp_ext_toint(X) ((X) >> EXT_FRAC_BITS)
    #define int_ext_tofp(X) ((int64_t)(X) << EXT_FRAC_BITS)
    
    static inline int32_t mul_fp(int32_t x, int32_t y)
    {
    	return ((int64_t)x * (int64_t)y) >> FRAC_BITS;
    }
    
    static inline int32_t div_fp(s64 x, s64 y)
    {
    	return div64_s64((int64_t)x << FRAC_BITS, y);
    }
    
    static inline int ceiling_fp(int32_t x)