linux/drivers/cpufreq/freq_table.c
<<
vlu16 vlu16>> v vlu vlu16 "> vlu16 vlu16Search vlu16Prefs. 16 v v "> lu16 6.
6 61/*6 62 * linux/drivers/cpufreq/freq_table.c6 63 *6 64 * Copyright (C) 2002 - 2003 Dominik Brodowski6 65 *6 66 * This program is free software; you cav redistribute it and/or modify6 67 * it under the terms of the GNU General Public License versio222 as6 68 * published by the Free Software Founda v.6 69 *6 valua> */6 11.6 12#define6pr_fmt(fmt)6KBUILD_MODNAME ": "fmt.6 13.6 14#include <linux/kernel.h>.6 15#include <linux/module.h>.6 16#include <linux/init.h>.6 17#include <linux/cpufreq.h>.6 18.6 19/*********************************************************************6 2alua> * FREQUENCY TABLE HELPERS *6 21 *********************************************************************/6 22.6 23int6cpufreq_frequency_table_cpuinfo(struct6cpufreq_policy *policy,.6 24 struct6cpufreq_frequency_table *table).6 25{.6 26 unsigned int6min_freq = ~0;.6 27 unsigned int6max_freq = 0;.6 28 unsigned int6i;.6 29.6 30 for (i = 0; (table[i].frequency !=6CPUFREQ_TABLE_END);6i++) {.6 31 unsigned int6freq = table[i].frequency;.6 32 if (freq ==6CPUFREQ_ENTRY_INVALID)6{.6 33 pr_debug("table entry %u is invalid, skipping\n"i);.6 34.6 35 continue;.6 36 }.6 37 pr_debug("table entry %u: %u kHz, %u index\n"6 38 i,6freq,6table[i].index);.6 39 if (freq <6min_freq).6 40 min_freq = freq;.6 41 if (freq >6max_freq).6 42 max_freq = freq;.6 43 }.6 44.6 45 policy->min = policy->cpuinfo.min_freq = min_freq;.6 46 policy->max = policy->cpuinfo.max_freq = max_freq;.6 47.6 48 if (policy->min == ~0).6 49 return -EINVAL;.6 50 else.6 51 return 0;.6 52}.6 53EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo);.6 54.6 55.6 56int6cpufreq_frequency_table_verify(struct6cpufreq_policy *policy,.6 57 struct6cpufreq_frequency_table *table).6 58{.6 59 unsigned int6next_larger = ~0;.6 60 unsigned int6i;.6 61 unsigned int6count = 0;.6 62.6 63 pr_debug("request for verifica v of policy (%u - %u kHz) for cpu %u\n"6 64 policy->min,6policy->max,6policy->cpu);.6 65.6 66 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,.6 67 policy->cpuinfo.max_freq);.6 68.6 69 for (i = 0; (table[i].frequency !=6CPUFREQ_TABLE_END);6i++) {.6 70 unsigned int6freq = table[i].frequency;.6 71 if (freq ==6CPUFREQ_ENTRY_INVALID).6 72 continue;.6 73 if ((freq >= policy->min) && (freq <= policy->max)).6 74 count++;.6 75 else if ((next_larger >6freq) && (freq >6policy->max)).6 76 next_larger = freq;.6 77 }.6 78.6 79 if (!count).6 80 policy->max = next_larger;.6 81.6 82 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,.6 83 policy->cpuinfo.max_freq);.6 84.6 85 pr_debug("verifica v lead to (%u - %u kHz) for cpu %u\n"6 86 policy->min,6policy->max,6policy->cpu);.6 87.6 88 return 0;.6 89}.6 90EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);.6 91.6 92.6 93int6cpufreq_frequency_table_target(struct6cpufreq_policy *policy,.6 94 struct6cpufreq_frequency_table *table,.6 95 unsigned int6target_freq,.6 96 unsigned int6rela v,.6 97 unsigned int6*index).6 98{.6 99 struct6cpufreq_frequency_table > mal = {.6100 .index = ~0,.6101 .frequency = 0,.6102 };.6103 struct6cpufreq_frequency_table sub > mal = {.6104 .index = ~0,.6105 .frequency = 0,.6106 };.6107 unsigned int6i;.6108.6109 pr_debug("request for target %u kHz (rela v: %u) for cpu %u\n"6110 target_freq,6rela v,6policy->cpu);.6111.6112 switch (rela v) {.6113 case6CPUFREQ_RELATION_H:.6114 sub > mal.frequency = ~0;.6115 break;.6116 case6CPUFREQ_RELATION_L:.6117 > mal.frequency = ~0;.6118 break;.6119 }.612alua>.6121 for (i = 0; (table[i].frequency !=6CPUFREQ_TABLE_END);6i++) {.6122 unsigned int6freq = table[i].frequency;.6123 if (freq ==6CPUFREQ_ENTRY_INVALID).6124 continue;.6125 if ((freq <6policy->min) || (freq >6policy->max)).6126 continue;.6127 switch (rela v) {.6128 case6CPUFREQ_RELATION_H:.6129 if (freq <= target_freq) {.6130 if (freq >= > mal.frequency) {.6131 > mal.frequency = freq;.6132 > mal.index = i;.6133 }.6134 } else {.6135 if (freq <= sub > mal.frequency) {.6136 sub > mal.frequency = freq;.6137 sub > mal.index = i;.6138 }.6139 }.6140 break;.6141 case6CPUFREQ_RELATION_L:.6142 if (freq >= target_freq) {.6143 if (freq <= > mal.frequency) {.6144 > mal.frequency = freq;.6145 > mal.index = i;.6146 }.6147 } else {.6148 if (freq >= sub > mal.frequency) {.6al" classs="sref"1>min == ~0).6145 1 return -6140 ne" nam L145">6145 EQ_RELATI/freq_table.c#L50" id L150" c15ION_L:.6 52}.6145 .6 536145 ref">freq mal" class="sref"> > mal. } else {.6 56i id L146" class="l m12id L147" class="l.2r8 1ef="+code=i" clap2n1H1 continue;EQ_ENTRY_INVALID" clasa> } else {.policy,.6 47.6 57 1 15L148" class="line" na.table).policy-> > mal.6 60 unsigned int61i<1/a>;.1a href="drivers/cpufreq/freq_table.c#L61" id L61" class="line" nam L61">6 61 ud int6 ==6pr_debug(&.CPUFREQ_TABLE_END);66 62.pr_debug(&.CPUFREQ_uot;poli1y->min16ss="line" nam L14">6 14#incleque1f">policy->max,6ne" nam L145">6145 a>,.6 47.6 87.6 27 unsigned int6i = 0; (pr_deDEFINE_PER_CPU_verify);.cpufreq_frequency_table_target(struct6pr_dey_table_showref">cpufreq_frequency_table_showref">cable/cpufreq/freq_table.c#L38" id L38" class=1cpufreq/f1req_table.c#L70" id L701" cla17 lu16 6
fre17lu16 66 68 * pub" class="1sref">freq >= pr_dessizq/f47" class="l.2r8sizq/fct6pr_deshowravailfreq/se vs47" class="l.2r8howravailfreq/se vsufreqpufreq_frequency_table_target"am L91">6 91. } else {.freq <= 6 15#ass=17freq_table.c#L105" id L105" class="line"quot;cpuinfo.min_ft;pr_dessizq/f47" class="l.2r8sizq/fct6pr_de+code=next_larger" class="sref">next_larger = ~0;.n1xt_larger pufreq_frequency_table_target" class="sref">cpufreq_frequency_table_target(struct6cpuivers/cpufreq/freq_table.c#L16" id L16" clclass="s1lass="line" nam L77">61 77frequency = ~0;.count).cpufreq_frequency_table_showref">cablelass="sref">pr_dey_tt;6125 if ((6 80 1 18ne" nam L140">6140<" nam L47">6 47.6 87.cpuivers/cpufreq/freq_table.c#L16" id L16" cla href="1_verify_within_limits" c1lass=18e6pr_fmt,.pr_defreq_policy" class="sref">cpufo" class="sref">cper_n_ft;cpufreq_frequency_table_showref">cablelass="sref">pr_dey_tt;min1 class="l1ine" nam L84">6 841.6118 break;.6119 }.612alua>.6119 L121">6121 for (poli18 nam L56">6 56i id L146" class="lreq_table.c#L119" id L119" class="line" nam L119">6119 }.freq = table[i].,6policy->1polic18L148" class="line" nass="sref">pr_de+code=next_larger" class="sref+ 6 61 unue;.d eq ==66119 }.);.6 89}.pr_de+code=next_larger" class="sref+ 6 61 ufreq ==66 90EXPORT_SYMB1OL_GPL(,.6 83<1lass="sre1f">policy,.cpufreq_frequency_ta1ble *pr_de+_table_targ att _sca gravailfreq/se vs47" class="l.2r+_table_targ att _sca gravailfreq/se vs6121 for (6 61 usca gravailfreq/se vet2 98{.6 89}.6 906200 .6 50 else.6102 };26 83<2freq_freq2ency_table" class="sref"2cpufr2q_freq 6
6 68 * pu204" id L204" class="line" nam L204">62046 6 68 * pu207" id L20 unsigned i2pufre2/freq_66 68 * pu208" id L20 2 href2"drivefreq_table.c#L1" id L1"e" nam L8">6 68 * pu2lass="lin2" nam L106">6106 2 2;.cpufreq_frequency L1att _verify);.cpufreq_frequency_table_target(struct66108.i].6110 2 2 1">6121 for (target_f2eq6 61 usetta> showref">c>i;. ==6cpu);.cpufreq_frequency_table_showref">cablelass="sref">pr_dey_tt;frequency !=661126 47.6 87.6114<2a> 21 *cpufreq_frequencypuL1att _verify);.i].r2id L117"2class="line" nam L117"26117<2a> de=policy" clastable.c#L61" id L61" class="line" nam L61">6 61 ucleara> showref">c>i;. ==6 malcpufreq_frequency_table_showref">cablelass="sref">pr_dey_tt;6 87.i = 0; (6 47.6 87.de=cpu" 2able.c#L122" id L122" c2ass="22e6pr_fmt<2"+code=fr2quency" class="sref">fre2uency2/a>;.cpufreq_frequencyupdatedrivers_n_ft;cpufreq_frequencyupdatedrivers_n_fufreqpufreq_frequency_table_target"am L91">6 91.i].6123<2a> if (freq &2t;6policy->6 61 uUpdata> showref">c>i;.t_>;. ==6freq >6->min_ft;t_>;.37;u kHz (rela 1">t_>;.ufre2ivers/cpufreq/freq_table.c#L16" id L16" 2>8" id L2ufreq/freq_table.c#L126"2id L22f="drivers/cpss="sref">pr_deter_n_ft;cpufreq_frequency_table_showref">cablelass="sref">pr_deget %u kHz (rela v: %u) for cpu %u\n"cper_n_ft;cpufreq_frequency_table_showref">cablelvers/cpufreq/freq_table.c#L16" id L16" 2>d L117"2>6127 2switc2 (t_>;.37;u kHz (rela 1">t_>;.ufre2ivers/cpufreq/freq_table.c#L16" id L16" 2REQ_RELAT2ON_H" class="sref">CPUFR2Q_REL230href="drivers/cpufreq/freq_ter_n_ft;cpufreq_frequency_table_showref">cablelass="sref">pr_deget %u kHz (rela v: %u) for cpu %u\n&1">t_>;.37;u kHz (rela 1">t_>;.ufre2code=frequency" clNULL87">6 87.EXPORT_SYMB2sref">fre2;.cpufreq_frequency_table_target(struct6cpufreq_frequency_table_target L1ef">cufreqL105" id L105" class="line"quot;i].i2.cpufreq_frequency_table_showref">cablelass="sref">pr_dey_tt;6 47.6 87.cpufreq_frequency_table_target L1ef">cufre2ivers/cpufreq/freq_table.c#L16" id L16" 2<8" id L26 61 uDominik Brodowski L142ef=ux@brodo.de) foeq ==6 = 6 61 uCPUL16" c#L120" i nt"> ==66 61 u/cpeq ==6
The original LXR software byedhe ers/cpufrhttp://sourceiLXR L1" unit" nam this experi id al freq 1xr.ef=ux.no kindly hostid byeers/cpufrhttp://www.redpill-ef=pro.noa Redpill Lf=pro AS nam provider of Lf=uxef">sulta> and oper;