linux kernel struct 之 cpufreq_driver

linux-4.9.37/include/linux/cpufrep.h

用于控制CPU频率的核心结构体,主要用于定义和管理CPU频率调节的驱动。

#define CPUFREQ_NAME_LEN        16

struct cpufreq_driver {
    char        name[CPUFREQ_NAME_LEN];
    u8        flags;
    void        *driver_data;

    /* needed by all drivers */
    int        (*init)(struct cpufreq_policy *policy);
    int        (*verify)(struct cpufreq_policy *policy);

    /* define one out of two */
    int        (*setpolicy)(struct cpufreq_policy *policy);

    /*
     * On failure, should always restore frequency to policy->restore_freq
     * (i.e. old freq).
     */
    int        (*target)(struct cpufreq_policy *policy,
                  unsigned int target_freq,
                  unsigned int relation);    /* Deprecated */
    int        (*target_index)(struct cpufreq_policy *policy,
                    unsigned int index);
    unsigned int    (*fast_switch)(struct cpufreq_policy *policy,
                       unsigned int target_freq);

    /*
     * Caches and returns the lowest driver-supported frequency greater than
     * or equal to the target frequency, subject to any driver limitations.
     * Does not set the frequency. Only to be implemented for drivers with
     * target().
     */
    unsigned int    (*resolve_freq)(struct cpufreq_policy *policy,
                    unsigned int target_freq);

    /*
     * Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION
     * unset.
     *
     * get_intermediate should return a stable intermediate frequency
     * platform wants to switch to and target_intermediate() should set CPU
     * to to that frequency, before jumping to the frequency corresponding
     * to 'index'. Core will take care of sending notifications and driver
     * doesn't have to handle them in target_intermediate() or
     * target_index().
     *
     * Drivers can return '0' from get_intermediate() in case they don't
     * wish to switch to intermediate frequency for some target frequency.
     * In that case core will directly call ->target_index().
     */
    unsigned int    (*get_intermediate)(struct cpufreq_policy *policy,
                        unsigned int index);
    int        (*target_intermediate)(struct cpufreq_policy *policy,
                           unsigned int index);

    /* should be defined, if possible */
    unsigned int    (*get)(unsigned int cpu);

    /* optional */
    int        (*bios_limit)(int cpu, unsigned int *limit);

    int        (*exit)(struct cpufreq_policy *policy);
    void        (*stop_cpu)(struct cpufreq_policy *policy);
    int        (*suspend)(struct cpufreq_policy *policy);
    int        (*resume)(struct cpufreq_policy *policy);

    /* Will be called after the driver is fully initialized */
    void        (*ready)(struct cpufreq_policy *policy);

    struct freq_attr **attr;

    /* platform specific boost support code */
    bool        boost_enabled;
    int        (*set_boost)(int state);
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值