linux/drivers/macintosh/windfarm_rm31.c
<<
on v v/spa >2 v/form>2 va on v href="../linux+vic/v.2/drivers/macintosh/windfarm_rm31.c">on v vimg src="../.static/gfx/right.png" alt=">>">onv/spa >2onvspa class="lxr_search">on von v vinput typ> 3hidden" nam> 3navtarget" tion> 3">on v vinput typ> 3text" nam> 3search" id 3search">on v vbutt/optyp> 3submit">Search2 v/form>2 v/spa >2onvspa class="lxr_prefs">2 va href="+prefs?return=drivers/macintosh/windfarm_rm31.c"on v onclick="return ajax_prefs();">on v Prefs2 v/a>onv/spa >2 v v/div>2 v vform ac.2 ="ajax+*" method="post" onsubmit="return false;">onvinput typ> 3hidden" nam> 3ajax_lookup" id 3ajax_lookup" tion> 3">o v v/form>2o v vdiv class="headingbott/m">
2 v
2 v vdiv id 3search_results" class="search_results"2 >2 v v/div>2 vdiv id 3content">2 vdiv id 3file_contents">

3L1">   1v/a>vspa  class="comment">/*v/spa >2
3L2">   2v/a>vspa  class="comment"> * Windfarm PowerMac thermal control.v/spa >2
3L3">   3v/a>vspa  class="comment"> * Control loops for RackMack3,1 (Xserve G5)v/spa >2
3L4">   4v/a>vspa  class="comment"> *v/spa >2
3L5">   5v/a>vspa  class="comment"> * Copyright (C) 2012 Benjamin Herrenschmidt, IBM Corp.v/spa >2
3L6">   6v/a>vspa  class="comment"> *v/spa >2
3L7">   7v/a>vspa  class="comment"> * Use and redistribute under the terms of the GNU GPL>22 v/spa >2
3L8">   8v/a>vspa  class="comment"> */v/spa >2
3L9">   9v/a>#include <linux/typ>s.hv/a>>2
3L10">  /v4.a>#include <linux/errno.hv/a>>2
3L11">  114.a>#include <linux/kernel.hv/a>>2
3L12">  124.a>#include <linux/device.hv/a>>2
3L13">  134.a>#include <linux/platform_device.hv/a>>2
3L14">  144.a>#include <linux/reboot.hv/a>>2
3L15">  154.a>#include <asm/prom.hv/a>>2
3L16">  164.a>#include <asm/smu.hv/a>>2
3L17">  17v/a>2
3L18">  184.a>#include "windfarm.hv/a>"2
3L19">  194.a>#include "windfarm_pid.hv/a>"2
3L20">  204.a>#include "windfarm_mpu.hv/a>"2
3L21">  21v/a>2
3L22">  224.a>#define va href="+code=VERSION" class="sref">VERSION4.a> vspa  class="string">"1.0"2
3L23">  23v/a>2
3L24">  244.a>#undef va href="+code=DEBUG" class="sref">DEBUGv/a>2
3L25">  254.a>#undef va href="+code=LOTSA_DEBUG" class="sref">LOTSA_DEBUGv/a>2
3L26">  26v/a>2
3L27">  274.a>#ifdef va href="+code=DEBUG" class="sref">DEBUGv/a>2
3L28">  284.a>#define va href="+code=DBG" class="sref">DBGv/a>(va href="+code=args" class="sref">argsv/a>...)    va href="+code=printk" class="sref">printkv/a>(va href="+code=args" class="sref">argsv/a>)2
3L29">  294.a>#else2
3L30">  304.a>#define va href="+code=DBG" class="sref">DBGv/a>(va href="+code=args" class="sref">argsv/a>...)    do { } while(0)2
3L31">  314.a>#endif2
3L32">  32v/a>2
3L33">  334.a>#ifdef va href="+code=LOTSA_DEBUG" class="sref">LOTSA_DEBUGv/a>2
3L34">  344.a>#define va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(va href="+code=args" class="sref">argsv/a>...)       va href="+code=printk" class="sref">printkv/a>(va href="+code=args" class="sref">argsv/a>)2
3L35">  354.a>#else2
3L36">  364.a>#define va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(va href="+code=args" class="sref">argsv/a>...)       do { } while(0)2
3L37">  374.a>#endif2
3L38">  38v/a>2
3L39">  39v/a>vspa  class="comment">/* define this to force CPU overtemp to 60 degree, useful for testingv/spa >2
3L40">  40v/a>vspa  class="comment"> * the overtemp codev/spa >2
3L41">  41v/a>vspa  class="comment"> */v/spa >2
3L42">  424.a>#undef va href="+code=HACKED_OVERTEMP" class="sref">HACKED_OVERTEMPv/a>2
3L43">  43v/a>2
3L44">  44v/a>vspa  class="comment">/* We currently only handle 2 chips */v/spa >2
3L45">  454.a>#define va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>        22
3L46">  464.a>#define va href="+code=NR_CPU_FANS" class="sref">NR_CPU_FANS4.a>     3 * va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>2
3L47">  47v/a>2
3L48">  48v/a>vspa  class="comment">/* Controls and sensors */v/spa >2
3L49">  49v/a>static struct va href="+code=wf_sensor" class="sref">wf_sensor4.a> *va href="+code=sens_cpu_temp" class="sref">sens_cpu_temp4.a>[va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>];2
3L50">  50v/a>static struct va href="+code=wf_sensor" class="sref">wf_sensor4.a> *va href="+code=sens_cpu_volts" class="sref">sens_cpu_volts4.a>[va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>];2
3L51">  51v/a>static struct va href="+code=wf_sensor" class="sref">wf_sensor4.a> *va href="+code=sens_cpu_amps" class="sref">sens_cpu_amps4.a>[va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>];2
3L52">  52v/a>static struct va href="+code=wf_sensor" class="sref">wf_sensor4.a> *va href="+code=backside_temp" class="sref">backside_temp4.a>;2
3L53">  53v/a>static struct va href="+code=wf_sensor" class="sref">wf_sensor4.a> *va href="+code=slots_temp" class="sref">slots_temp4.a>;2
3L54">  54v/a>static struct va href="+code=wf_sensor" class="sref">wf_sensor4.a> *va href="+code=dimms_temp" class="sref">dimms_temp4.a>;2
3L55">  55v/a>2
3L56">  56v/a>static struct va href="+code=wf_control" class="sref">wf_control4.a> *va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>][3];2
3L57">  57v/a>static struct va href="+code=wf_control" class="sref">wf_control4.a> *va href="+code=backside_fan" class="sref">backside_fan4.a>;2
3L58">  58v/a>static struct va href="+code=wf_control" class="sref">wf_control4.a> *va href="+code=slots_fan" class="sref">slots_fan4.a>;2
3L59">  59v/a>static struct va href="+code=wf_control" class="sref">wf_control4.a> *va href="+code=cpufreq_clamp" class="sref">cpufreq_clamp4.a>;2
3L60">  60v/a>2
3L61">  61v/a>vspa  class="comment">/* We keep a temperature history for average calcula92
3L62">  624.a>#define va href="+code=CPU_TEMP_HIST_SIZE" class="sref">CPU_TEMP_HIST_SIZE4.a>      1802
3L63">  63v/a>2
3L64">  64v/a>vspa  class="comment">/* PID loop state */v/spa >2
3L65">  65v/a>static const struct va href="+code=mpu_data" class="sref">mpu_data4.a> *va href="+code=cpu_mpu_data" class="sref">cpu_mpu_data4.a>[va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>];2
3L66">  66v/a>static struct va href="+code=wf_cpu_pid_state" class="sref">wf_cpu_pid_state4.a> va href="+code=cpu_pid" class="sref">cpu_pid4.a>[va href="+code=NR_CHIPS" class="sref">NR_CHIPS4.a>];2
3L67">  67v/a>static va href="+code=u32" class="sref">u32v/a> va href="+code=cpu_thist" class="sref">cpu_thist4.a>[va href="+code=CPU_TEMP_HIST_SIZE" class="sref">CPU_TEMP_HIST_SIZE4.a>];2
3L68">  68v/a>static int va href="+code=cpu_thist_pt" class="sref">cpu_thist_pt4.a>;2
3L69">  69v/a>static va href="+code=s64" class="sref">s64v/a> va href="+code=cpu_thist_total" class="sref">cpu_thist_total4.a>;2
3L70">  70v/a>static va href="+code=s32" class="sref">s32v/a> va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> = 100 << 16;2
3L71">  71v/a>static struct va href="+code=wf_pid_state" class="sref">wf_pid_state4.a> va href="+code=backside_pid" class="sref">backside_pid4.a>;2
3L72">  72v/a>static int va href="+code=backside_tick" class="sref">backside_tick4.a>;2
3L73">  73v/a>static struct va href="+code=wf_pid_state" class="sref">wf_pid_state4.a> va href="+code=slots_pid" class="sref">slots_pid4.a>;2
3L74">  74v/a>static int va href="+code=slots_tick" class="sref">slots_tick4.a>;2
3L75">  75v/a>static int va href="+code=slots_speed" class="sref">slots_speed4.a>;2
3L76">  76v/a>static struct va href="+code=wf_pid_state" class="sref">wf_pid_state4.a> va href="+code=dimms_pid" class="sref">dimms_pid4.a>;2
3L77">  77v/a>static int va href="+code=dimms_output_clamp" class="sref">dimms_output_clamp4.a>;2
3L78">  78v/a>2
3L79">  79v/a>static int va href="+code=nr_chips" class="sref">nr_chips4.a>;2
3L80">  80v/a>static va href="+code=bool" class="sref">bool4.a> va href="+code=have_all_controls" class="sref">have_all_controls4.a>;2
3L81">  81v/a>static va href="+code=bool" class="sref">bool4.a> va href="+code=have_all_sensors" class="sref">have_all_sensors4.a>;2
3L82">  82v/a>static va href="+code=bool" class="sref">bool4.a> va href="+code=started" class="sref">started4.a>;2
3L83">  83v/a>2
3L84">  84v/a>static int va href="+code=failure_state" class="sref">failure_state4.a>;2
3L85">  854.a>#define va href="+code=FAILURE_SENSOR" class="sref">FAILURE_SENSOR4.a>          12
3L86">  864.a>#define va href="+code=FAILURE_FAN" class="sref">FAILURE_FAN4.a>             22
3L87">  874.a>#define va href="+code=FAILURE_PERM" class="sref">FAILURE_PERM4.a>            42
3L88">  884.a>#define va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>    82
3L89">  894.a>#define va href="+code=FAILURE_HIGH_OVERTEMP" class="sref">FAILURE_HIGH_OVERTEMP4.a>   162
3L90">  90v/a>2
3L91">  91v/a>vspa  class="comment">/* Overtemp tion>s */v/spa >2
3L92">  924.a>#define va href="+code=LOW_OVER_AVERAGE" class="sref">LOW_OVER_AVERAGE4.a>        02
3L93">  934.a>#define va href="+code=LOW_OVER_IMMEDIATE" class="sref">LOW_OVER_IMMEDIATE4.a>      (10 << 16)2
3L94">  944.a>#define va href="+code=LOW_OVER_CLEAR" class="sref">LOW_OVER_CLEAR4.a>          ((-10) << 16)2
3L95">  954.a>#define va href="+code=HIGH_OVER_IMMEDIATE" class="sref">HIGH_OVER_IMMEDIATE4.a>     (14 << 16)2
3L96">  964.a>#define va href="+code=HIGH_OVER_AVERAGE" class="sref">HIGH_OVER_AVERAGE4.a>       (10 << 16)2
3L97">  974.a>#define va href="+code=HIGH_OVER_IMMEDIATE" class="sref">HIGH_OVER_IMMEDIATE4.a>     (14 << 16)2
3L98">  98v/a>2
3L99">  99v/a>2
3L100"> 100v/a>static void va href="+code=cpu_max_all_fans" class="sref">cpu_max_all_fansv/a>(void)2
3L101"> 101v/a>{2
3L102"> 1024.a>        int va href="+code=i" class="sref">i4.a>;2
3L103"> 103v/a>2
3L104"> 1044.a>        vspa  class="comment">/* We max all CPU fans in casepof a sensor error. We also do thev/spa >2
3L105"> 105v/a>vspa  class="comment">         * cpufreq clamping now, even if it's supposedly done later by thev/spa >2
3L106"> 106v/a>vspa  class="comment">         * generic code anyway, we do it earlier here to react fasterv/spa >2
3L107"> 107v/a>vspa  class="comment">         */v/spa >2
3L108"> 1084.a>        if (va href="+code=cpufreq_clamp" class="sref">cpufreq_clamp4.a>)2
3L109"> 1094.a>                va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=cpufreq_clamp" class="sref">cpufreq_clamp4.a>);2
3L110"> 1/v4.a>        for (va href="+code=i" class="sref">i4.a> = 0; va href="+code=i" class="sref">i4.a> < va href="+code=nr_chips" class="sref">nr_chips4.a>; va href="+code=i" class="sref">i4.a>++) {2
3L111"> 1114.a>                if (va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=i" class="sref">i4.a>][0])2
3L112"> 1124.a>                        va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=i" class="sref">i4.a>][0]);2
3L113"> 1134.a>                if (va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=i" class="sref">i4.a>][1])2
3L114"> 1144.a>                        va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=i" class="sref">i4.a>][1]);2
3L115"> 1154.a>                if (va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=i" class="sref">i4.a>][2])2
3L116"> 1164.a>                        va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=i" class="sref">i4.a>][2]);2
3L117"> 117v/a>        }2
3L118"> 1184.a>}2
3L119"> 119v/a>2
3L120"> 120v/a>static int va href="+code=cpu_check_overtemp" class="sref">cpu_check_overtempv/a>(va href="+code=s32" class="sref">s32v/a> va href="+code=temp" class="sref">tempv/a>)2
3L121"> 121v/a>{2
3L122"> 1224.a>        int va href="+code=new_state" class="sref">new_state4.a> = 0;2
3L123"> 1234.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=t_avg" class="sref">t_avgv/a>, va href="+code=t_old" class="sref">t_old4.a>;2
3L124"> 1244.a>        static va href="+code=bool" class="sref">bool4.a> va href="+code=first" class="sref">first4.a> = va href="+code=true" class="sref">true4.a>;2
3L125"> 125v/a>2
3L126"> 1264.a>        vspa  class="comment">/* First check for immediate overtemps */v/spa >2
3L127"> 127v/a>        if (va href="+code=temp" class="sref">tempv/a> >= (va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> + va href="+code=LOW_OVER_IMMEDIATE" class="sref">LOW_OVER_IMMEDIATE4.a>)) {2
3L128"> 1284.a>                va href="+code=new_state" class="sref">new_state4.a> |= va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>;2
3L129"> 1294.a>                if ((va href="+code=failure_state" class="sref">failure_state4.a> & va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>) == 0)2
3L130"> 1304.a>                        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_ERR" class="sref">KERN_ERR4.a> vspa  class="string">"windfarm: Overtemp due to immediate CPU"2
3L131"> 1314.a>                               vspa  class="string">" temperature !\n");2
3L132"> 1324.a>        }2
3L133"> 133v/a>        if (va href="+code=temp" class="sref">tempv/a> >= (va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> + va href="+code=HIGH_OVER_IMMEDIATE" class="sref">HIGH_OVER_IMMEDIATE4.a>)) {2
3L134"> 1344.a>                va href="+code=new_state" class="sref">new_state4.a> |= va href="+code=FAILURE_HIGH_OVERTEMP" class="sref">FAILURE_HIGH_OVERTEMP4.a>;2
3L135"> 1354.a>                if ((va href="+code=failure_state" class="sref">failure_state4.a> & va href="+code=FAILURE_HIGH_OVERTEMP" class="sref">FAILURE_HIGH_OVERTEMP4.a>) == 0)2
3L136"> 1364.a>                        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_ERR" class="sref">KERN_ERR4.a> vspa  class="string">"windfarm: Critical overtemp due to"2
3L137"> 1374.a>                               vspa  class="string">" immediate CPU temperature !\n");2
3L138"> 1384.a>        }2
3L139"> 139v/a>2
3L140"> 1404.a>        vspa  class="comment">/*2
3L141"> 141v/a>vspa  class="comment">         * The first time around, initialize the array with the first4.spa >2
3L142"> 142v/a>vspa  class="comment">         * temperature reading4.spa >2
3L143"> 143v/a>vspa  class="comment">         */v/spa >2
3L144"> 144v/a>        if (va href="+code=first" class="sref">first4.a>) {2
3L145"> 1454.a>                int va href="+code=i" class="sref">i4.a>;2
3L146"> 146v/a>2
3L147"> 1474.a>                va href="+code=cpu_thist_total" class="sref">cpu_thist_total4.a> = 0;2
3L148"> 1484.a>                for (va href="+code=i" class="sref">i4.a> = 0; va href="+code=i" class="sref">i4.a> < va href="+code=CPU_TEMP_HIST_SIZE" class="sref">CPU_TEMP_HIST_SIZE4.a>; va href="+code=i" class="sref">i4.a>++) {2
3L149"> 1494.a>                        va href="+code=cpu_thist" class="sref">cpu_thist4.a>[va href="+code=i" class="sref">i4.a>] = va href="+code=temp" class="sref">tempv/a>;2
3L150"> 1504.a>                        va href="+code=cpu_thist_total" class="sref">cpu_thist_total4.a> += va href="+code=temp" class="sref">tempv/a>;2
3L151"> 1514.a>                }2
3L152"> 1524.a>                va href="+code=first" class="sref">first4.a> = va href="+code=false" class="sref">falsev/a>;2
3L153"> 1534.a>        }2
3L154"> 154v/a>2
3L155"> 1554.a>        vspa  class="comment">/*2
3L156"> 156v/a>vspa  class="comment">         * We calcula9e a history of max temperatures and use that for thev/spa >2
3L157"> 157v/a>vspa  class="comment">         * overtemp managementv/spa >2
3L158"> 158v/a>vspa  class="comment">         */v/spa >2
3L159"> 1594.a>        va href="+code=t_old" class="sref">t_old4.a> = va href="+code=cpu_thist" class="sref">cpu_thist4.a>[va href="+code=cpu_thist_pt" class="sref">cpu_thist_pt4.a>];2
3L160"> 1604.a>        va href="+code=cpu_thist" class="sref">cpu_thist4.a>[va href="+code=cpu_thist_pt" class="sref">cpu_thist_pt4.a>] = va href="+code=temp" class="sref">tempv/a>;2
3L161"> 1614.a>        va href="+code=cpu_thist_pt" class="sref">cpu_thist_pt4.a> = (va href="+code=cpu_thist_pt" class="sref">cpu_thist_pt4.a> + 1) % va href="+code=CPU_TEMP_HIST_SIZE" class="sref">CPU_TEMP_HIST_SIZE4.a>;2
3L162"> 1624.a>        va href="+code=cpu_thist_total" class="sref">cpu_thist_total4.a> -= va href="+code=t_old" class="sref">t_old4.a>;2
3L163"> 1634.a>        va href="+code=cpu_thist_total" class="sref">cpu_thist_total4.a> += va href="+code=temp" class="sref">tempv/a>;2
3L164"> 1644.a>        va href="+code=t_avg" class="sref">t_avgv/a> = va href="+code=cpu_thist_total" class="sref">cpu_thist_total4.a> / va href="+code=CPU_TEMP_HIST_SIZE" class="sref">CPU_TEMP_HIST_SIZE4.a>;2
3L165"> 165v/a>2
3L166"> 1664.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"  t_avg = %d.%03d (out: %d.%03d, in: %d.%03d)\n",2
3L167"> 1674.a>                 va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=t_avg" class="sref">t_avgv/a>), va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=t_old" class="sref">t_old4.a>), va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=temp" class="sref">tempv/a>));2
3L168"> 168v/a>2
3L169"> 1694.a>        vspa  class="comment">/* Now check for average overtemps */v/spa >2
3L170"> 1704.a>        if (va href="+code=t_avg" class="sref">t_avgv/a> >= (va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> + va href="+code=LOW_OVER_AVERAGE" class="sref">LOW_OVER_AVERAGE4.a>)) {2
3L171"> 1714.a>                va href="+code=new_state" class="sref">new_state4.a> |= va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>;2
3L172"> 1724.a>                if ((va href="+code=failure_state" class="sref">failure_state4.a> & va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>) == 0)2
3L173"> 1734.a>                        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_ERR" class="sref">KERN_ERR4.a> vspa  class="string">"windfarm: Overtemp due to average CPU"2
3L174"> 1744.a>                               vspa  class="string">" temperature !\n");2
3L175"> 1754.a>        }2
3L176"> 1764.a>        if (va href="+code=t_avg" class="sref">t_avgv/a> >= (va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> + va href="+code=HIGH_OVER_AVERAGE" class="sref">HIGH_OVER_AVERAGE4.a>)) {2
3L177"> 1774.a>                va href="+code=new_state" class="sref">new_state4.a> |= va href="+code=FAILURE_HIGH_OVERTEMP" class="sref">FAILURE_HIGH_OVERTEMP4.a>;2
3L178"> 1784.a>                if ((va href="+code=failure_state" class="sref">failure_state4.a> & va href="+code=FAILURE_HIGH_OVERTEMP" class="sref">FAILURE_HIGH_OVERTEMP4.a>) == 0)2
3L179"> 1794.a>                        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_ERR" class="sref">KERN_ERR4.a> vspa  class="string">"windfarm: Critical overtemp due to"2
3L180"> 1804.a>                               vspa  class="string">" average CPU temperature !\n");2
3L181"> 1814.a>        }2
3L182"> 182v/a>2
3L183"> 1834.a>        vspa  class="comment">/* Now handle overtemp condi92
3L184"> 184v/a>vspa  class="comment">         * overtemp handling core as it's not fully suited to the needs of thosev/spa >2
3L185"> 185v/a>vspa  class="comment">         * new machine. This will be fixed later.v/spa >2
3L186"> 186v/a>vspa  class="comment">         */v/spa >2
3L187"> 187v/a>        if (va href="+code=new_state" class="sref">new_state4.a>) {2
3L188"> 1884.a>                vspa  class="comment">/* High overtemp -> immediate shutdown */v/spa >2
3L189"> 1894.a>                if (va href="+code=new_state" class="sref">new_state4.a> & va href="+code=FAILURE_HIGH_OVERTEMP" class="sref">FAILURE_HIGH_OVERTEMP4.a>)2
3L190"> 1904.a>                        va href="+code=machine_power_off" class="sref">machine_power_offv/a>();2
3L191"> 1914.a>                if ((va href="+code=failure_state" class="sref">failure_state4.a> & va href="+code=new_state" class="sref">new_state4.a>) != va href="+code=new_state" class="sref">new_state4.a>)2
3L192"> 1924.a>                        va href="+code=cpu_max_all_fans" class="sref">cpu_max_all_fansv/a>();2
3L193"> 1934.a>                va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=new_state" class="sref">new_state4.a>;2
3L194"> 1944.a>        } else if ((va href="+code=failure_state" class="sref">failure_state4.a> & va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>) &&2
3L195"> 1954.a>                   (va href="+code=temp" class="sref">tempv/a> < (va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> + va href="+code=LOW_OVER_CLEAR" class="sref">LOW_OVER_CLEAR4.a>))) {2
3L196"> 1964.a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_ERR" class="sref">KERN_ERR4.a> vspa  class="string">"windfarm: Overtemp condi9);2
3L197"> 1974.a>                va href="+code=failure_state" class="sref">failure_state4.a> &= ~va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>;2
3L198"> 1984.a>        }2
3L199"> 199v/a>2
3L200"> 2004.a>        return va href="+code=failure_state" class="sref">failure_state4.a> & (va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a> | va href="+code=FAILURE_HIGH_OVERTEMP" class="sref">FAILURE_HIGH_OVERTEMP4.a>);2
3L201"> 201v/a>}2
3L202"> 202v/a>2
3L203"> 203v/a>static int va href="+code=read_one_cpu_vals" class="sref">read_one_cpu_valsv/a>(int va href="+code=cpu" class="sref">cpuv/a>, va href="+code=s32" class="sref">s32v/a> *va href="+code=temp" class="sref">tempv/a>, va href="+code=s32" class="sref">s32v/a> *va href="+code=power" class="sref">power4.a>)2
3L204"> 2044.a>{2
3L205"> 2054.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=dtemp" class="sref">dtempv/a>, va href="+code=volts" class="sref">volts4.a>, va href="+code=amps" class="sref">amps4.a>;2
3L206"> 2064.a>        int va href="+code=rc" class="sref">rc4.a>;2
3L207"> 207v/a>2
3L208"> 2084.a>        vspa  class="comment">/* Get diode temperature */v/spa >2
3L209"> 2094.a>        va href="+code=rc" class="sref">rc4.a> = va href="+code=wf_sensor_get" class="sref">wf_sensor_getv/a>(va href="+code=sens_cpu_temp" class="sref">sens_cpu_temp4.a>[va href="+code=cpu" class="sref">cpuv/a>], &va href="+code=dtemp" class="sref">dtempv/a>);2
3L210"> 2104.a>        if (va href="+code=rc" class="sref">rc4.a>) {2
3L211"> 2114.a>                va href="+code=DBG" class="sref">DBGv/a>(vspa  class="string">"  CPU%d: temp reading error !\n", va href="+code=cpu" class="sref">cpuv/a>);2
3L212"> 2124.a>                return -va href="+code=EIO" class="sref">EIO4.a>;2
3L213"> 2134.a>        }2
3L214"> 2144.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"  CPU%d: temp   = %d.%03d\n", va href="+code=cpu" class="sref">cpuv/a>, va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>((va href="+code=dtemp" class="sref">dtempv/a>)));2
3L215"> 2154.a>        *va href="+code=temp" class="sref">tempv/a> = va href="+code=dtemp" class="sref">dtempv/a>;2
3L216"> 216v/a>2
3L217"> 217v/a>        vspa  class="comment">/* Get voltage */v/spa >2
3L218"> 2184.a>        va href="+code=rc" class="sref">rc4.a> = va href="+code=wf_sensor_get" class="sref">wf_sensor_getv/a>(va href="+code=sens_cpu_volts" class="sref">sens_cpu_volts4.a>[va href="+code=cpu" class="sref">cpuv/a>], &va href="+code=volts" class="sref">volts4.a>);2
3L219"> 2194.a>        if (va href="+code=rc" class="sref">rc4.a>) {2
3L220"> 2204.a>                va href="+code=DBG" class="sref">DBGv/a>(vspa  class="string">"  CPU%d, volts reading error !\n", va href="+code=cpu" class="sref">cpuv/a>);2
3L221"> 2214.a>                return -va href="+code=EIO" class="sref">EIO4.a>;2
3L222"> 2224.a>        }2
3L223"> 2234.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"  CPU%d: volts  = %d.%03d\n", va href="+code=cpu" class="sref">cpuv/a>, va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>((va href="+code=volts" class="sref">volts4.a>)));2
3L224"> 224v/a>2
3L225"> 2254.a>        vspa  class="comment">/* Get current */v/spa >2
3L226"> 2264.a>        va href="+code=rc" class="sref">rc4.a> = va href="+code=wf_sensor_get" class="sref">wf_sensor_getv/a>(va href="+code=sens_cpu_amps" class="sref">sens_cpu_amps4.a>[va href="+code=cpu" class="sref">cpuv/a>], &va href="+code=amps" class="sref">amps4.a>);2
3L227"> 227v/a>        if (va href="+code=rc" class="sref">rc4.a>) {2
3L228"> 2284.a>                va href="+code=DBG" class="sref">DBGv/a>(vspa  class="string">"  CPU%d, current reading error !\n", va href="+code=cpu" class="sref">cpuv/a>);2
3L229"> 2294.a>                return -va href="+code=EIO" class="sref">EIO4.a>;2
3L230"> 2304.a>        }2
3L231"> 2314.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"  CPU%d: amps   = %d.%03d\n", va href="+code=cpu" class="sref">cpuv/a>, va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>((va href="+code=amps" class="sref">amps4.a>)));2
3L232"> 232v/a>2
3L233"> 2334.a>        vspa  class="comment">/* Calcula9e power */v/spa >2
3L234"> 234v/a>2
3L235"> 2354.a>        vspa  class="comment">/* Scale voltage and current raw sensor tion>s according to fixed scalesv/spa >2
3L236"> 236v/a>vspa  class="comment">         * obtained in Darwin and calcula9e power from I and Vv/spa >2
3L237"> 237v/a>vspa  class="comment">         */v/spa >2
3L238"> 2384.a>        *va href="+code=power" class="sref">power4.a> = (((va href="+code=u64" class="sref">u644.a>)va href="+code=volts" class="sref">volts4.a>) * ((va href="+code=u64" class="sref">u644.a>)va href="+code=amps" class="sref">amps4.a>)) >> 16;2
3L239"> 239v/a>2
3L240"> 2404.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"  CPU%d: power  = %d.%03d\n", va href="+code=cpu" class="sref">cpuv/a>, va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>((*va href="+code=power" class="sref">power4.a>)));2
3L241"> 241v/a>2
3L242"> 2424.a>        return 0;2
3L243"> 243v/a>2
3L244"> 244v/a>}2
3L245"> 245v/a>2
3L246"> 246v/a>static void va href="+code=cpu_fans_tick" class="sref">cpu_fans_tickv/a>(void)2
3L247"> 2474.a>{2
3L248"> 2484.a>        int va href="+code=err" class="sref">errv/a>, va href="+code=cpu" class="sref">cpuv/a>, va href="+code=i" class="sref">i4.a>;2
3L249"> 2494.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=speed" class="sref">speedv/a>, va href="+code=temp" class="sref">tempv/a>, va href="+code=power" class="sref">power4.a>, va href="+code=t_max" class="sref">t_maxv/a> = 0;2
3L250"> 250v/a>2
3L251"> 2514.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"* cpu fans_tick_split()\n");2
3L252"> 252v/a>2
3L253"> 2534.a>        for (va href="+code=cpu" class="sref">cpuv/a> = 0; va href="+code=cpu" class="sref">cpuv/a> < va href="+code=nr_chips" class="sref">nr_chips4.a>; ++va href="+code=cpu" class="sref">cpuv/a>) {2
3L254"> 2544.a>                struct va href="+code=wf_cpu_pid_state" class="sref">wf_cpu_pid_statev/a> *va href="+code=sp" class="sref">spv/a> = &va href="+code=cpu_pid" class="sref">cpu_pid4.a>[va href="+code=cpu" class="sref">cpuv/a>];2
3L255"> 255v/a>2
3L256"> 2564.a>                vspa  class="comment">/* Read current speed */v/spa >2
3L257"> 2574.a>                va href="+code=wf_control_get" class="sref">wf_control_getv/a>(va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=cpu" class="sref">cpuv/a>][0], &va href="+code=sp" class="sref">spv/a>->va href="+code=target" class="sref">targetv/a>);2
3L258"> 258v/a>2
3L259"> 2594.a>                va href="+code=err" class="sref">errv/a> = va href="+code=read_one_cpu_vals" class="sref">read_one_cpu_valsv/a>(va href="+code=cpu" class="sref">cpuv/a>, &va href="+code=temp" class="sref">tempv/a>, &va href="+code=power" class="sref">power4.a>);2
3L260"> 2604.a>                if (va href="+code=err" class="sref">errv/a>) {2
3L261"> 2614.a>                        va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=FAILURE_SENSOR" class="sref">FAILURE_SENSOR4.a>;2
3L262"> 2624.a>                        va href="+code=cpu_max_all_fans" class="sref">cpu_max_all_fansv/a>();2
3L263"> 2634.a>                        return;2
3L264"> 2644.a>                }2
3L265"> 265v/a>2
3L266"> 2664.a>                vspa  class="comment">/* Keep track of highest temp */v/spa >2
3L267"> 2674.a>                va href="+code=t_max" class="sref">t_maxv/a> = va href="+code=max" class="sref">maxv/a>(va href="+code=t_max" class="sref">t_maxv/a>, va href="+code=temp" class="sref">tempv/a>);2
3L268"> 268v/a>2
3L269"> 2694.a>                vspa  class="comment">/* Handle possible overtemps */v/spa >2
3L270"> 2704.a>                if (va href="+code=cpu_check_overtemp" class="sref">cpu_check_overtempv/a>(va href="+code=t_max" class="sref">t_maxv/a>))2
3L271"> 2714.a>                        return;2
3L272"> 272v/a>2
3L273"> 2734.a>                vspa  class="comment">/* Run PID */v/spa >2
3L274"> 2744.a>                va href="+code=wf_cpu_pid_run" class="sref">wf_cpu_pid_runv/a>(va href="+code=sp" class="sref">spv/a>, va href="+code=power" class="sref">power4.a>, va href="+code=temp" class="sref">tempv/a>);2
3L275"> 275v/a>2
3L276"> 2764.a>                va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"  CPU%d: target = %d RPM\n", va href="+code=cpu" class="sref">cpuv/a>, va href="+code=sp" class="sref">spv/a>->va href="+code=target" class="sref">targetv/a>);2
3L277"> 277v/a>2
3L278"> 2784.a>                vspa  class="comment">/* Apply DIMMs clamp */v/spa >2
3L279"> 2794.a>                va href="+code=speed" class="sref">speedv/a> = va href="+code=max" class="sref">maxv/a>(va href="+code=sp" class="sref">spv/a>->va href="+code=target" class="sref">targetv/a>, va href="+code=dimms_output_clamp" class="sref">dimms_output_clampv/a>);2
3L280"> 280v/a>2
3L281"> 2814.a>                vspa  class="comment">/* Apply result to all cpu fans */v/spa >2
3L282"> 2824.a>                for (va href="+code=i" class="sref">i4.a> = 0; va href="+code=i" class="sref">i4.a> < 3; va href="+code=i" class="sref">i4.a>++) {2
3L283"> 2834.a>                        va href="+code=err" class="sref">errv/a> = va href="+code=wf_control_set" class="sref">wf_control_setv/a>(va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=cpu" class="sref">cpuv/a>][va href="+code=i" class="sref">i4.a>], va href="+code=speed" class="sref">speedv/a>);2
3L284"> 2844.a>                        if (va href="+code=err" class="sref">errv/a>) {2
3L285"> 2854.a>                                va href="+code=pr_warning" class="sref">pr_warningv/a>(vspa  class="string">"wf_rm31: Fa  %s reports error %d\n",2
3L286"> 2864.a>                                           va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=cpu" class="sref">cpuv/a>][va href="+code=i" class="sref">i4.a>]->va href="+code=nam>" class="sref">nam>v/a>, va href="+code=err" class="sref">errv/a>);2
3L287"> 2874.a>                                va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=FAILURE_FAN" class="sref">FAILURE_FAN4.a>;2
3L288"> 2884.a>                        }2
3L289"> 2894.a>                }2
3L290"> 2904.a>        }2
3L291"> 291v/a>}2
3L292"> 292v/a>2
3L293"> 293v/a>vspa  class="comment">/* Implementa92
3L294"> 2944.a>static int va href="+code=cpu_setup_pid" class="sref">cpu_setup_pidv/a>(int va href="+code=cpu" class="sref">cpuv/a>)2
3L295"> 2954.a>{2
3L296"> 2964.a>        struct va href="+code=wf_cpu_pid_param" class="sref">wf_cpu_pid_paramv/a> va href="+code=pid" class="sref">pidv/a>;2
3L297"> 2974.a>        const struct va href="+code=mpu_data" class="sref">mpu_datav/a> *va href="+code=mpu" class="sref">mpuv/a> = va href="+code=cpu_mpu_data" class="sref">cpu_mpu_data4.a>[va href="+code=cpu" class="sref">cpuv/a>];2
3L298"> 2984.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=tmax" class="sref">tmaxv/a>, va href="+code=ttarget" class="sref">ttargetv/a>, va href="+code=ptarget" class="sref">ptargetv/a>;2
3L299"> 2994.a>        int va href="+code=fmin" class="sref">fminv/a>, va href="+code=fmax" class="sref">fmaxv/a>, va href="+code=hsize" class="sref">hsizev/a>;2
3L300"> 300v/a>2
3L301"> 3014.a>        vspa  class="comment">/* Get PID params from the appropriate MPU EEPROM */v/spa >2
3L302"> 3024.a>        va href="+code=tmax" class="sref">tmaxv/a> = va href="+code=mpu" class="sref">mpuv/a>->va href="+code=tmax" class="sref">tmaxv/a> << 16;2
3L303"> 3034.a>        va href="+code=ttarget" class="sref">ttargetv/a> = va href="+code=mpu" class="sref">mpuv/a>->va href="+code=ttarget" class="sref">ttargetv/a> << 16;2
3L304"> 3044.a>        va href="+code=ptarget" class="sref">ptargetv/a> = ((va href="+code=s32" class="sref">s32v/a>)(va href="+code=mpu" class="sref">mpuv/a>->va href="+code=pmaxh" class="sref">pmaxhv/a> - va href="+code=mpu" class="sref">mpuv/a>->va href="+code=padjmax" class="sref">padjmaxv/a>)) << 16;2
3L305"> 305v/a>2
3L306"> 3064.a>        va href="+code=DBG" class="sref">DBGv/a>(vspa  class="string">"wf_72: CPU%d ttarget = %d.%03d, tmax = %d.%03d\n",2
3L307"> 3074.a>            va href="+code=cpu" class="sref">cpuv/a>, va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=ttarget" class="sref">ttargetv/a>), va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=tmax" class="sref">tmaxv/a>));2
3L308"> 308v/a>2
3L309"> 3094.a>        vspa  class="comment">/* We keep a global tmax for overtemp calcula92
3L310"> 3104.a>        if (va href="+code=tmax" class="sref">tmaxv/a> < va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a>)2
3L311"> 3114.a>                va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> = va href="+code=tmax" class="sref">tmaxv/a>;2
3L312"> 312v/a>2
3L313"> 3134.a>        vspa  class="comment">/* Set PID min/max by using the rear fan min/max */v/spa >2
3L314"> 3144.a>        va href="+code=fmin" class="sref">fminv/a> = va href="+code=wf_control_get_min" class="sref">wf_control_get_minv/a>(va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=cpu" class="sref">cpuv/a>][0]);2
3L315"> 3154.a>        va href="+code=fmax" class="sref">fmaxv/a> = va href="+code=wf_control_get_max" class="sref">wf_control_get_maxv/a>(va href="+code=cpu_fans" class="sref">cpu_fans4.a>[va href="+code=cpu" class="sref">cpuv/a>][0]);2
3L316"> 3164.a>        va href="+code=DBG" class="sref">DBGv/a>(vspa  class="string">"wf_72: CPU%d max RPM range = [%d..%d]\n", va href="+code=cpu" class="sref">cpuv/a>, va href="+code=fmin" class="sref">fminv/a>, va href="+code=fmax" class="sref">fmaxv/a>);2
3L317"> 317v/a>2
3L318"> 3184.a>        vspa  class="comment">/* History size */v/spa >2
3L319"> 3194.a>        va href="+code=hsize" class="sref">hsizev/a> = va href="+code=min_t" class="sref">min_tv/a>(int, va href="+code=mpu" class="sref">mpuv/a>->va href="+code=tguardband" class="sref">tguardbandv/a>, va href="+code=WF_PID_MAX_HISTORY" class="sref">WF_PID_MAX_HISTORYv/a>);2
3L320"> 3204.a>        va href="+code=DBG" class="sref">DBGv/a>(vspa  class="string">"wf_72: CPU%d history size = %d\n", va href="+code=cpu" class="sref">cpuv/a>, va href="+code=hsize" class="sref">hsizev/a>);2
3L321"> 321v/a>2
3L322"> 3224.a>        vspa  class="comment">/* Initialize PID loop */v/spa >2
3L323"> 3234.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=interval" class="sref">interval4.a>    = 1;    vspa  class="comment">/* seconds */v/spa >2
3L324"> 3244.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=history_len" class="sref">history_lenv/a> = va href="+code=hsize" class="sref">hsizev/a>;2
3L325"> 3254.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=gd" class="sref">gd4.a>          = va href="+code=mpu" class="sref">mpuv/a>->va href="+code=pid_gd" class="sref">pid_gdv/a>;2
3L326"> 3264.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=gp" class="sref">gp4.a>          = va href="+code=mpu" class="sref">mpuv/a>->va href="+code=pid_gp" class="sref">pid_gpv/a>;2
3L327"> 327v/a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=gr" class="sref">gr4.a>          = va href="+code=mpu" class="sref">mpuv/a>->va href="+code=pid_gr" class="sref">pid_grv/a>;2
3L328"> 3284.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=tmax" class="sref">tmaxv/a>        = va href="+code=tmax" class="sref">tmaxv/a>;2
3L329"> 3294.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=ttarget" class="sref">ttargetv/a>     = va href="+code=ttarget" class="sref">ttargetv/a>;2
3L330"> 3304.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=pmaxadj" class="sref">pmaxadjv/a>     = va href="+code=ptarget" class="sref">ptargetv/a>;2
3L331"> 3314.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=min" class="sref">minv/a>         = va href="+code=fmin" class="sref">fminv/a>;2
3L332"> 3324.a>        va href="+code=pid" class="sref">pidv/a>.va href="+code=max" class="sref">maxv/a>         = va href="+code=fmax" class="sref">fmaxv/a>;2
3L333"> 333v/a>2
3L334"> 3344.a>        va href="+code=wf_cpu_pid_init" class="sref">wf_cpu_pid_initv/a>(&va href="+code=cpu_pid" class="sref">cpu_pid4.a>[va href="+code=cpu" class="sref">cpuv/a>], &va href="+code=pid" class="sref">pidv/a>);2
3L335"> 3354.a>        va href="+code=cpu_pid" class="sref">cpu_pid4.a>[va href="+code=cpu" class="sref">cpuv/a>].va href="+code=target" class="sref">targetv/a> = 4000;2
3L336"> 3364.a>        2
3L337"> 337v/a>        return 0;2
3L338"> 3384.a>}2
3L339"> 339v/a>2
3L340"> 3404.a>vspa  class="comment">/* Backside/U3 fan */v/spa >2
3L341"> 341v/a>static struct va href="+code=wf_pid_param" class="sref">wf_pid_paramv/a> va href="+code=backside_param" class="sref">backside_paramv/a> = {2
3L342"> 3424.a>        .va href="+code=interval" class="sref">interval4.a>       = 1,2
3L343"> 3434.a>        .va href="+code=history_len" class="sref">history_lenv/a>    = 2,2
3L344"> 3444.a>        .va href="+code=gd" class="sref">gd4.a>             = 0x00500000,2
3L345"> 3454.a>        .va href="+code=gp" class="sref">gp4.a>             = 0x0004cccc,2
3L346"> 3464.a>        .va href="+code=gr" class="sref">gr4.a>             = 0,2
3L347"> 3474.a>        .va href="+code=itarget" class="sref">itargetv/a>        = 70 << 16,2
3L348"> 3484.a>        .va href="+code=addi9addi9       = 0,2
3L349"> 3494.a>        .va href="+code=min" class="sref">minv/a>            = 20,2
3L350"> 3504.a>        .va href="+code=max" class="sref">maxv/a>            = 100,2
3L351"> 3514.a>};2
3L352"> 352v/a>2
3L353"> 353v/a>vspa  class="comment">/* DIMMs temperature (clamp the backside fan) */v/spa >2
3L354"> 354v/a>static struct va href="+code=wf_pid_param" class="sref">wf_pid_paramv/a> va href="+code=dimms_param" class="sref">dimms_paramv/a> = {2
3L355"> 3554.a>        .va href="+code=interval" class="sref">interval4.a>       = 1,2
3L356"> 3564.a>        .va href="+code=history_len" class="sref">history_lenv/a>    = 20,2
3L357"> 3574.a>        .va href="+code=gd" class="sref">gd4.a>             = 0,2
3L358"> 3584.a>        .va href="+code=gp" class="sref">gp4.a>             = 0,2
3L359"> 3594.a>        .va href="+code=gr" class="sref">gr4.a>             = 0x06553600,2
3L360"> 3604.a>        .va href="+code=itarget" class="sref">itargetv/a>        = 50 << 16,2
3L361"> 3614.a>        .va href="+code=addi9addi9       = 0,2
3L362"> 3624.a>        .va href="+code=min" class="sref">minv/a>            = 4000,2
3L363"> 3634.a>        .va href="+code=max" class="sref">maxv/a>            = 14000,2
3L364"> 3644.a>};2
3L365"> 365v/a>2
3L366"> 366v/a>static void va href="+code=backside_fan_tick" class="sref">backside_fan_tickv/a>(void)2
3L367"> 3674.a>{2
3L368"> 3684.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=temp" class="sref">tempv/a>, va href="+code=dtemp" class="sref">dtempv/a>;2
3L369"> 3694.a>        int va href="+code=speed" class="sref">speedv/a>, va href="+code=dspeed" class="sref">dspeedv/a>, va href="+code=fan_min" class="sref">fan_minv/a>;2
3L370"> 3704.a>        int va href="+code=err" class="sref">errv/a>;2
3L371"> 371v/a>2
3L372"> 3724.a>        if (!va href="+code=backside_fan" class="sref">backside_fan4.a> || !va href="+code=backside_temp" class="sref">backside_temp4.a> || !va href="+code=dimms_temp" class="sref">dimms_temp4.a> || !va href="+code=backside_tick" class="sref">backside_tickv/a>)2
3L373"> 3734.a>                return;2
3L374"> 3744.a>        if (--va href="+code=backside_tick" class="sref">backside_tickv/a> > 0)2
3L375"> 3754.a>                return;2
3L376"> 3764.a>        va href="+code=backside_tick" class="sref">backside_tickv/a> = va href="+code=backside_pid" class="sref">backside_pidv/a>.va href="+code=param" class="sref">paramv/a>.va href="+code=interval" class="sref">interval4.a>;2
3L377"> 377v/a>2
3L378"> 3784.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"* backside fans tick\n");2
3L379"> 379v/a>2
3L380"> 3804.a>        vspa  class="comment">/* Update fan speed from actual fans */v/spa >2
3L381"> 3814.a>        va href="+code=err" class="sref">errv/a> = va href="+code=wf_control_get" class="sref">wf_control_getv/a>(va href="+code=backside_fan" class="sref">backside_fan4.a>, &va href="+code=speed" class="sref">speedv/a>);2
3L382"> 3824.a>        if (!va href="+code=err" class="sref">errv/a>)2
3L383"> 3834.a>                va href="+code=backside_pid" class="sref">backside_pidv/a>.va href="+code=target" class="sref">targetv/a> = va href="+code=speed" class="sref">speedv/a>;2
3L384"> 384v/a>2
3L385"> 3854.a>        va href="+code=err" class="sref">errv/a> = va href="+code=wf_sensor_get" class="sref">wf_sensor_getv/a>(va href="+code=backside_temp" class="sref">backside_temp4.a>, &va href="+code=temp" class="sref">tempv/a>);2
3L386"> 3864.a>        if (va href="+code=err" class="sref">errv/a>) {2
3L387"> 3874.a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa  class="string">"windfarm: U3 temp sensor error %d\n",2
3L388"> 3884.a>                       va href="+code=err" class="sref">errv/a>);2
3L389"> 3894.a>                va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=FAILURE_SENSOR" class="sref">FAILURE_SENSOR4.a>;2
3L390"> 3904.a>                va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=backside_fan" class="sref">backside_fan4.a>);2
3L391"> 3914.a>                return;2
3L392"> 3924.a>        }2
3L393"> 3934.a>        va href="+code=speed" class="sref">speedv/a> = va href="+code=wf_pid_run" class="sref">wf_pid_runv/a>(&va href="+code=backside_pid" class="sref">backside_pidv/a>, va href="+code=temp" class="sref">tempv/a>);2
3L394"> 394v/a>2
3L395"> 3954.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"backside PID temp=%d.%.3d speed=%d\n",2
3L396"> 3964.a>                 va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=temp" class="sref">tempv/a>), va href="+code=speed" class="sref">speedv/a>);2
3L397"> 397v/a>2
3L398"> 3984.a>        va href="+code=err" class="sref">errv/a> = va href="+code=wf_sensor_get" class="sref">wf_sensor_getv/a>(va href="+code=dimms_temp" class="sref">dimms_temp4.a>, &va href="+code=dtemp" class="sref">dtempv/a>);2
3L399"> 3994.a>        if (va href="+code=err" class="sref">errv/a>) {2
3L400"> 4004.a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa  class="string">"windfarm: DIMMs temp sensor error %d\n",2
3L401"> 4014.a>                       va href="+code=err" class="sref">errv/a>);2
3L402"> 4024.a>                va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=FAILURE_SENSOR" class="sref">FAILURE_SENSOR4.a>;2
3L403"> 4034.a>                va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=backside_fan" class="sref">backside_fan4.a>);2
3L404"> 4044.a>                return;2
3L405"> 4054.a>        }2
3L406"> 4064.a>        va href="+code=dspeed" class="sref">dspeedv/a> = va href="+code=wf_pid_run" class="sref">wf_pid_runv/a>(&va href="+code=dimms_pid" class="sref">dimms_pidv/a>, va href="+code=dtemp" class="sref">dtempv/a>);2
3L407"> 407v/a>        va href="+code=dimms_output_clamp" class="sref">dimms_output_clampv/a> = va href="+code=dspeed" class="sref">dspeedv/a>;2
3L408"> 408v/a>2
3L409"> 4094.a>        va href="+code=fan_min" class="sref">fan_minv/a> = (va href="+code=dspeed" class="sref">dspeedv/a> * 100) / 14000;2
3L410"> 4104.a>        va href="+code=fan_min" class="sref">fan_minv/a> = va href="+code=max" class="sref">maxv/a>(va href="+code=fan_min" class="sref">fan_minv/a>, va href="+code=backside_param" class="sref">backside_paramv/a>.va href="+code=min" class="sref">minv/a>);2
3L411"> 4114.a>        va href="+code=speed" class="sref">speedv/a> = va href="+code=max" class="sref">maxv/a>(va href="+code=speed" class="sref">speedv/a>, va href="+code=fan_min" class="sref">fan_minv/a>);2
3L412"> 412v/a>2
3L413"> 4134.a>        va href="+code=err" class="sref">errv/a> = va href="+code=wf_control_set" class="sref">wf_control_setv/a>(va href="+code=backside_fan" class="sref">backside_fan4.a>, va href="+code=speed" class="sref">speedv/a>);2
3L414"> 4144.a>        if (va href="+code=err" class="sref">errv/a>) {2
3L415"> 4154.a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa  class="string">"windfarm: backside fan error %d\n", va href="+code=err" class="sref">errv/a>);2
3L416"> 4164.a>                va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=FAILURE_FAN" class="sref">FAILURE_FAN4.a>;2
3L417"> 417v/a>        }2
3L418"> 4184.a>}2
3L419"> 419v/a>2
3L420"> 4204.a>static void va href="+code=backside_setup_pid" class="sref">backside_setup_pidv/a>(void)2
3L421"> 421v/a>{2
3L422"> 4224.a>        vspa  class="comment">/* first time initialize things */v/spa >2
3L423"> 4234.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=fmin" class="sref">fminv/a> = va href="+code=wf_control_get_min" class="sref">wf_control_get_minv/a>(va href="+code=backside_fan" class="sref">backside_fan4.a>);2
3L424"> 4244.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=fmax" class="sref">fmaxv/a> = va href="+code=wf_control_get_max" class="sref">wf_control_get_maxv/a>(va href="+code=backside_fan" class="sref">backside_fan4.a>);2
3L425"> 4254.a>        struct va href="+code=wf_pid_param" class="sref">wf_pid_paramv/a> va href="+code=param" class="sref">paramv/a>;2
3L426"> 4264.a>2
3L427"> 427v/a>        va href="+code=param" class="sref">paramv/a> = va href="+code=backside_param" class="sref">backside_paramv/a>;2
3L428"> 4284.a>        va href="+code=param" class="sref">paramv/a>.va href="+code=min" class="sref">minv/a> = va href="+code=max" class="sref">maxv/a>(va href="+code=param" class="sref">paramv/a>.va href="+code=min" class="sref">minv/a>, va href="+code=fmin" class="sref">fminv/a>);2
3L429"> 4294.a>        va href="+code=param" class="sref">paramv/a>.va href="+code=max" class="sref">maxv/a> = va href="+code=min" class="sref">minv/a>(va href="+code=param" class="sref">paramv/a>.va href="+code=max" class="sref">maxv/a>, va href="+code=fmax" class="sref">fmaxv/a>);2
3L430"> 4304.a>        va href="+code=wf_pid_init" class="sref">wf_pid_initv/a>(&va href="+code=backside_pid" class="sref">backside_pidv/a>, &va href="+code=param" class="sref">paramv/a>);2
3L431"> 431v/a>2
3L432"> 4324.a>        va href="+code=param" class="sref">paramv/a> = va href="+code=dimms_param" class="sref">dimms_paramv/a>;2
3L433"> 4334.a>        va href="+code=wf_pid_init" class="sref">wf_pid_initv/a>(&va href="+code=dimms_pid" class="sref">dimms_pidv/a>, &va href="+code=param" class="sref">paramv/a>);2
3L434"> 434v/a>2
3L435"> 4354.a>        va href="+code=backside_tick" class="sref">backside_tickv/a> = 1;2
3L436"> 4364.a>2
3L437"> 437v/a>        va href="+code=pr_info" class="sref">pr_infov/a>(vspa  class="string">"wf_rm31: Backside control loop started.\n");2
3L438"> 4384.a>}2
3L439"> 439v/a>2
3L440"> 4404.a>vspa  class="comment">/* Slots fan */v/spa >2
3L441"> 441v/a>static const struct va href="+code=wf_pid_param" class="sref">wf_pid_paramv/a> va href="+code=slots_param" class="sref">slots_paramv/a> = {2
3L442"> 4424.a>        .va href="+code=interval" class="sref">interval4.a>       = 1,2
3L443"> 4434.a>        .va href="+code=history_len" class="sref">history_lenv/a>    = 20,2
3L444"> 4444.a>        .va href="+code=gd" class="sref">gd4.a>             = 0,2
3L445"> 4454.a>        .va href="+code=gp" class="sref">gp4.a>             = 0,2
3L446"> 4464.a>        .va href="+code=gr" class="sref">gr4.a>             = 0x00100000,2
3L447"> 4474.a>        .va href="+code=itarget" class="sref">itargetv/a>        = 3200000,2
3L448"> 4484.a>        .va href="+code=addi9addi9       = 0,2
3L449"> 4494.a>        .va href="+code=min" class="sref">minv/a>            = 20,2
3L450"> 4504.a>        .va href="+code=max" class="sref">maxv/a>            = 100,2
3L451"> 4514.a>};2
3L452"> 452v/a>2
3L453"> 453v/a>static void va href="+code=slots_fan_tick" class="sref">slots_fan_tickv/a>(void)2
3L454"> 454v/a>{2
3L455"> 4554.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=temp" class="sref">tempv/a>;2
3L456"> 4564.a>        int va href="+code=speed" class="sref">speedv/a>;2
3L457"> 4574.a>        int va href="+code=err" class="sref">errv/a>;2
3L458"> 458v/a>2
3L459"> 4594.a>        if (!va href="+code=slots_fan" class="sref">slots_fan4.a> || !va href="+code=slots_temp" class="sref">slots_temp4.a> || !va href="+code=slots_tick" class="sref">slots_tickv/a>)2
3L460"> 4604.a>                return;2
3L461"> 4614.a>        if (--va href="+code=slots_tick" class="sref">slots_tickv/a> > 0)2
3L462"> 4624.a>                return;2
3L463"> 4634.a>        va href="+code=slots_tick" class="sref">slots_tickv/a> = va href="+code=slots_pid" class="sref">slots_pidv/a>.va href="+code=param" class="sref">paramv/a>.va href="+code=interval" class="sref">interval4.a>;2
3L464"> 464v/a>2
3L465"> 4654.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"* slots fans tick\n");2
3L466"> 4664.a>2
3L467"> 467v/a>        va href="+code=err" class="sref">errv/a> = va href="+code=wf_sensor_get" class="sref">wf_sensor_getv/a>(va href="+code=slots_temp" class="sref">slots_temp4.a>, &va href="+code=temp" class="sref">tempv/a>);2
3L468"> 4684.a>        if (va href="+code=err" class="sref">errv/a>) {2
3L469"> 4694.a>                va href="+code=pr_warning" class="sref">pr_warningv/a>(vspa  class="string">"wf_rm31: slots temp sensor error %d\n", va href="+code=err" class="sref">errv/a>);2
3L470"> 4704.a>                va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=FAILURE_SENSOR" class="sref">FAILURE_SENSOR4.a>;2
3L471"> 4714.a>                va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=slots_fan" class="sref">slots_fan4.a>);2
3L472"> 4724.a>                return;2
3L473"> 4734.a>        }2
3L474"> 4744.a>        va href="+code=speed" class="sref">speedv/a> = va href="+code=wf_pid_run" class="sref">wf_pid_runv/a>(&va href="+code=slots_pid" class="sref">slots_pidv/a>, va href="+code=temp" class="sref">tempv/a>);2
3L475"> 475v/a>2
3L476"> 4764.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"slots PID temp=%d.%.3d speed=%d\n",2
3L477"> 4774.a>                 va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=temp" class="sref">tempv/a>), va href="+code=speed" class="sref">speedv/a>);2
3L478"> 478v/a>2
3L479"> 4794.a>        va href="+code=slots_speed" class="sref">slots_speedv/a> = va href="+code=speed" class="sref">speedv/a>;2
3L480"> 4804.a>        va href="+code=err" class="sref">errv/a> = va href="+code=wf_control_set" class="sref">wf_control_setv/a>(va href="+code=slots_fan" class="sref">slots_fan4.a>, va href="+code=speed" class="sref">speedv/a>);2
3L481"> 4814.a>        if (va href="+code=err" class="sref">errv/a>) {2
3L482"> 4824.a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa  class="string">"windfarm: slots bay fan error %d\n", va href="+code=err" class="sref">errv/a>);2
3L483"> 4834.a>                va href="+code=failure_state" class="sref">failure_state4.a> |= va href="+code=FAILURE_FAN" class="sref">FAILURE_FAN4.a>;2
3L484"> 4844.a>        }2
3L485"> 4854.a>}2
3L486"> 4864.a>2
3L487"> 4874.a>static void va href="+code=slots_setup_pid" class="sref">slots_setup_pidv/a>(void)2
3L488"> 4884.a>{2
3L489"> 4894.a>        vspa  class="comment">/* first time initialize things */v/spa >2
3L490"> 4904.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=fmin" class="sref">fminv/a> = va href="+code=wf_control_get_min" class="sref">wf_control_get_minv/a>(va href="+code=slots_fan" class="sref">slots_fan4.a>);2
3L491"> 4914.a>        va href="+code=s32" class="sref">s32v/a> va href="+code=fmax" class="sref">fmaxv/a> = va href="+code=wf_control_get_max" class="sref">wf_control_get_maxv/a>(va href="+code=slots_fan" class="sref">slots_fan4.a>);2
3L492"> 4924.a>        struct va href="+code=wf_pid_param" class="sref">wf_pid_paramv/a> va href="+code=param" class="sref">paramv/a> = va href="+code=slots_param" class="sref">slots_paramv/a>;2
3L493"> 493v/a>2
3L494"> 4944.a>        va href="+code=param" class="sref">paramv/a>.va href="+code=min" class="sref">minv/a> = va href="+code=max" class="sref">maxv/a>(va href="+code=param" class="sref">paramv/a>.va href="+code=min" class="sref">minv/a>, va href="+code=fmin" class="sref">fminv/a>);2
3L495"> 4954.a>        va href="+code=param" class="sref">paramv/a>.va href="+code=max" class="sref">maxv/a> = va href="+code=min" class="sref">minv/a>(va href="+code=param" class="sref">paramv/a>.va href="+code=max" class="sref">maxv/a>, va href="+code=fmax" class="sref">fmaxv/a>);2
3L496"> 4964.a>        va href="+code=wf_pid_init" class="sref">wf_pid_initv/a>(&va href="+code=slots_pid" class="sref">slots_pidv/a>, &va href="+code=param" class="sref">paramv/a>);2
3L497"> 497v/a>        va href="+code=slots_tick" class="sref">slots_tickv/a> = 1;2
3L498"> 498v/a>2
3L499"> 4994.a>        va href="+code=pr_info" class="sref">pr_infov/a>(vspa  class="string">"wf_rm31: Slots control loop started.\n");2
3L500"> 5004.a>}2
3L501"> 501v/a>2
3L502"> 5024.a>static void va href="+code=set_fail_state" class="sref">set_fail_statev/a>(void)2
3L503"> 5034.a>{2
3L504"> 5044.a>        va href="+code=cpu_max_all_fans" class="sref">cpu_max_all_fansv/a>();2
3L505"> 505v/a>2
3L506"> 5064.a>        if (va href="+code=backside_fan" class="sref">backside_fan4.a>)2
3L507"> 5074.a>                va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=backside_fan" class="sref">backside_fan4.a>);2
3L508"> 5084.a>        if (va href="+code=slots_fan" class="sref">slots_fan4.a>)2
3L509"> 5094.a>                va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=slots_fan" class="sref">slots_fan4.a>);2
3L510"> 5104.a>}2
3L511"> 511v/a>2
3L512"> 5124.a>static void va href="+code=rm31_tick" class="sref">rm31_tickv/a>(void)2
3L513"> 5134.a>{2
3L514"> 5144.a>        int va href="+code=i" class="sref">iv/a>, va href="+code=last_failure" class="sref">last_failurev/a>;2
3L515"> 515v/a>2
3L516"> 5164.a>        if (!va href="+code=started" class="sref">startedv/a>) {2
3L517"> 5174.a>                va href="+code=started" class="sref">startedv/a> = 1;2
3L518"> 5184.a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_INFO" class="sref">KERN_INFOv/a> vspa  class="string">"windfarm: CPUs control loops started.\n");2
3L519"> 5194.a>                for (va href="+code=i" class="sref">iv/a> = 0; va href="+code=i" class="sref">iv/a> < va href="+code=nr_chips" class="sref">nr_chipsv/a>; ++va href="+code=i" class="sref">iv/a>) {2
3L520"> 5204.a>                        if (va href="+code=cpu_setup_pid" class="sref">cpu_setup_pidv/a>(va href="+code=i" class="sref">iv/a>) < 0) {2
3L521"> 5214.a>                                va href="+code=failure_state" class="sref">failure_state4.a> = va href="+code=FAILURE_PERM" class="sref">FAILURE_PERMv/a>;2
3L522"> 5224.a>                                va href="+code=set_fail_state" class="sref">set_fail_statev/a>();2
3L523"> 5234.a>                                break;2
3L524"> 5244.a>                        }2
3L525"> 5254.a>                }2
3L526"> 5264.a>                va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"cpu_all_tmax=%d.%03d\n", va href="+code=FIX32TOPRINT" class="sref">FIX32TOPRINTv/a>(va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a>));2
3L527"> 527v/a>2
3L528"> 5284.a>                va href="+code=backside_setup_pid" class="sref">backside_setup_pidv/a>();2
3L529"> 5294.a>                va href="+code=slots_setup_pid" class="sref">slots_setup_pidv/a>();2
3L530"> 5304.a>2
3L531"> 531v/a>#ifdef va href="+code=HACKED_OVERTEMP" class="sref">HACKED_OVERTEMP4.a>2
3L532"> 5324.a>                va href="+code=cpu_all_tmax" class="sref">cpu_all_tmaxv/a> = 60 << 16;2
3L533"> 5334.a>#endif2
3L534"> 5344.a>        }2
3L535"> 535v/a>2
3L536"> 5364.a>        vspa  class="comment">/* Permanent failure, bail out */v/spa >2
3L537"> 537v/a>        if (va href="+code=failure_state" class="sref">failure_state4.a> & va href="+code=FAILURE_PERM" class="sref">FAILURE_PERMv/a>)2
3L538"> 5384.a>                return;2
3L539"> 539v/a>2
3L540"> 5404.a>        vspa  class="comment">/*v/spa >2
3L541"> 541v/a>vspa  class="comment">         * Clear all failure bits except low overtemp which will be eventuallyv/spa >2
3L542"> 5424.a>vspa  class="comment">         * cleared by the control loop itselfv/spa >2
3L543"> 5434.a>vspa  class="comment">         */v/spa >2
3L544"> 5444.a>        va href="+code=last_failure" class="sref">last_failurev/a> = va href="+code=failure_state" class="sref">failure_state4.a>;2
3L545"> 5454.a>        va href="+code=failure_state" class="sref">failure_state4.a> &= va href="+code=FAILURE_LOW_OVERTEMP" class="sref">FAILURE_LOW_OVERTEMP4.a>;2
3L546"> 5464.a>        va href="+code=backside_fan_tick" class="sref">backside_fan_tickv/a>();2
3L547"> 547v/a>        va href="+code=slots_fan_tick" class="sref">slots_fan_tickv/a>();2
3L548"> 548v/a>2
3L549"> 5494.a>        vspa  class="comment">/* We do CPUs last because they ca  be clamped high byv/spa >2
3L550"> 5504.a>vspa  class="comment">         * DIMM temperaturev/spa >2
3L551"> 551v/a>vspa  class="comment">         */v/spa >2
3L552"> 5524.a>        va href="+code=cpu_fans_tick" class="sref">cpu_fans_tickv/a>();2
3L553"> 553v/a>2
3L554"> 5544.a>        va href="+code=DBG_LOTS" class="sref">DBG_LOTSv/a>(vspa  class="string">"  last_failure: 0x%x, failure_state: %x\n",2
3L555"> 5554.a>                 va href="+code=last_failure" class="sref">last_failurev/a>, va href="+code=failure_state" class="sref">failure_state4.a>);2
3L556"> 5564.a>2
3L557"> 5574.a>        vspa  class="comment">/* Check for failures. Any failure causes cpufreq clamping */v/spa >2
3L558"> 5584.a>        if (va href="+code=failure_state" class="sref">failure_state4.a> && va href="+code=last_failure" class="sref">last_failurev/a> == 0 && va href="+code=cpufreq_clamp" class="sref">cpufreq_clampv/a>)2
3L559"> 5594.a>                va href="+code=wf_control_set_max" class="sref">wf_control_set_maxv/a>(va href="+code=cpufreq_clamp" class="sref">cpufreq_clampv/a>);2
3L560"> 5604.a>        if (va href="+code=failure_state" class="sref">failure_state4.a> == 0 && va href="+code=last_failure" class="sref">last_failurev/a> && va href="+code=cpufreq_clamp" class="sref">cpufreq_clampv/a>)2
3L561"> 5614.a>                va href="+code=wf_control_set_min" class="sref">wf_control_set_minv/a>(va href="+code=cpufreq_clamp" class="sref">cpufreq_clampv/a>);2
3L562"> 562v/a>2
3L563"> 5634.a>        vspa  class="comment">/* That's it for now, we might want to deal with other failuresv/spa >2
3L564"> 564v/a>vspa  class="comment">         * differently in the future thoughv/spa >2
3L565"> 5654.a>vspa  class="comment">         */v/spa >2
3L566"> 5664.a>}2
3L567"> 567v/a>2
3L568"> 5684.a>static void va href="+code=rm31_new_control" class="sref">rm31_new_controlv/a>(struct va href="+code=wf_control" class="sref">wf_control4.a> *va href="+code=ct" class="sref">ctv/a>)2
3L569"> 5694.a>{2
3L570"> 5704.a>        va href="+code=bool" class="sref">boolv/a> va href="+code=all_controls" class="sref">all_controls4.a>;2
3L571"> 571v/a>2
3L572"> 5724.a>        if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-fan-a-0"))2
3L573"> 5734.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[0][0] = va href="+code=ct" class="sref">ctv/a>;2
3L574"> 5744.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-fan-b-0"))2
3L575"> 5754.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[0][1] = va href="+code=ct" class="sref">ctv/a>;2
3L576"> 5764.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-fan-c-0"))2
3L577"> 5774.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[0][2] = va href="+code=ct" class="sref">ctv/a>;2
3L578"> 5784.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-fan-a-1"))2
3L579"> 5794.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[1][0] = va href="+code=ct" class="sref">ctv/a>;2
3L580"> 5804.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-fan-b-1"))2
3L581"> 5814.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[1][1] = va href="+code=ct" class="sref">ctv/a>;2
3L582"> 5824.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-fan-c-1"))2
3L583"> 5834.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[1][2] = va href="+code=ct" class="sref">ctv/a>;2
3L584"> 5844.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"backside-fan"))2
3L585"> 5854.a>                va href="+code=backside_fan" class="sref">backside_fan4.a> = va href="+code=ct" class="sref">ctv/a>;2
3L586"> 5864.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"slots-fan"))2
3L587"> 5874.a>                va href="+code=slots_fan" class="sref">slots_fan4.a> = va href="+code=ct" class="sref">ctv/a>;2
3L588"> 5884.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=ct" class="sref">ctv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpufreq-clamp"))2
3L589"> 5894.a>                va href="+code=cpufreq_clamp" class="sref">cpufreq_clampv/a> = va href="+code=ct" class="sref">ctv/a>;2
3L590"> 5904.a>2
3L591"> 5914.a>        va href="+code=all_controls" class="sref">all_controls4.a> =2
3L592"> 5924.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[0][0] &&2
3L593"> 5934.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[0][1] &&2
3L594"> 5944.a>                va href="+code=cpu_fans" class="sref">cpu_fans4.a>[0][2] &&2
3L595"> 5954.a>                va href="+code=backside_fan" class="sref">backside_fan4.a> &&2
3L596"> 5964.a>                va href="+code=slots_fan" class="sref">slots_fan4.a>;2
3L597"> 597v/a>        if (va href="+code=nr_chips" class="sref">nr_chipsv/a> > 1)2
3L598"> 5984.a>                va href="+code=all_controls" class="sref">all_controls4.a> &=2
3L599"> 5994.a>                        va href="+code=cpu_fans" class="sref">cpu_fans4.a>[1][0] &&2
3L600"> 6004.a>                        va href="+code=cpu_fans" class="sref">cpu_fans4.a>[1][1] &&2
3L601"> 6014.a>                        va href="+code=cpu_fans" class="sref">cpu_fans4.a>[1][2];2
3L602"> 6024.a>        va href="+code=have_all_controls" class="sref">have_all_controlsv/a> = va href="+code=all_controls" class="sref">all_controls4.a>;2
3L603"> 6034.a>}2
3L604"> 604v/a>2
3L605"> 605v/a>2
3L606"> 6064.a>static void va href="+code=rm31_new_sensor" class="sref">rm31_new_sensorv/a>(struct va href="+code=wf_sensor" class="sref">wf_sensor4.a> *va href="+code=sr" class="sref">srv/a>)2
3L607"> 6074.a>{2
3L608"> 6084.a>        va href="+code=bool" class="sref">boolv/a> va href="+code=all_sensors" class="sref">all_sensors4.a>;2
3L609"> 609v/a>2
3L610"> 6104.a>        if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-diode-temp-0"))2
3L611"> 6114.a>                va href="+code=sens_cpu_temp" class="sref">sens_cpu_temp4.a>[0] = va href="+code=sr" class="sref">srv/a>;2
3L612"> 6124.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-diode-temp-1"))2
3L613"> 6134.a>                va href="+code=sens_cpu_temp" class="sref">sens_cpu_temp4.a>[1] = va href="+code=sr" class="sref">srv/a>;2
3L614"> 6144.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-voltage-0"))2
3L615"> 6154.a>                va href="+code=sens_cpu_volts" class="sref">sens_cpu_volts4.a>[0] = va href="+code=sr" class="sref">srv/a>;2
3L616"> 6164.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-voltage-1"))2
3L617"> 6174.a>                va href="+code=sens_cpu_volts" class="sref">sens_cpu_volts4.a>[1] = va href="+code=sr" class="sref">srv/a>;2
3L618"> 6184.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-current-0"))2
3L619"> 6194.a>                va href="+code=sens_cpu_amps" class="sref">sens_cpu_amps4.a>[0] = va href="+code=sr" class="sref">srv/a>;2
3L620"> 6204.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"cpu-current-1"))2
3L621"> 6214.a>                va href="+code=sens_cpu_amps" class="sref">sens_cpu_amps4.a>[1] = va href="+code=sr" class="sref">srv/a>;2
3L622"> 6224.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"backside-temp"))2
3L623"> 6234.a>                va href="+code=backside_temp" class="sref">backside_tempv/a> = va href="+code=sr" class="sref">srv/a>;2
3L624"> 6244.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"slots-temp"))2
3L625"> 6254.a>                va href="+code=slots_temp" class="sref">slots_temp4.a> = va href="+code=sr" class="sref">srv/a>;2
3L626"> 6264.a>        else if (!va href="+code=strcmp" class="sref">strcmpv/a>(va href="+code=sr" class="sref">srv/a>->va href="+code=nam>" class="sref">nam>v/a>, vspa  class="string">"dimms-temp"))2
3L627"> 6274.a>                va href="+code=dimms_temp" class="sref">dimms_temp4.a> = va href="+code=sr" class="sref">srv/a>;2
3L628"> 628v/a>2
3L629"> 6294.a>        va href="+code=all_sensors" class="sref">all_sensors4.a> =2
3L630"> 6304.a>                va href="+code=sens_cpu_temp" class="sref">sens_cpu_temp4.a>[0] &&2
3L631"> 6314.a>                va href="+code=sens_cpu_volts" class="sref">sens_cpu_volts4.a>[0] &&2
3L632"> 6324.a>                va href="+code=sens_cpu_amps" class="sref">sens_cpu_amps4.a>[0] &&2
3L633"> 6334.a>                va href="+code=backside_temp" class="sref">backside_tempv/a> &&2
3L634"> 6344.a>                va href="+code=slots_temp" class="sref">slots_temp4.a> &&2
3L635"> 6354.a>                va href="+code=dimms_temp" class="sref">dimms_temp4.a>;2
3L636"> 6364.a>        if (va href="+code=nr_chips" class="sref">nr_chipsv/a> > 1)2
3L637"> 6374.a>                va href="+code=all_sensors" class="sref">all_sensors4.a> &=2
3L638"> 6384.a>                        va href="+code=sens_cpu_temp" class="sref">sens_cpu_temp4.a>[1] &&2
3L639"> 6394.a>                        va href="+code=sens_cpu_volts" class="sref">sens_cpu_volts4.a>[1] &&2
3L640"> 6404.a>                        va href="+code=sens_cpu_amps" class="sref">sens_cpu_amps4.a>[1];2
3L641"> 641v/a>2
3L642"> 6424.a>        va href="+code=have_all_sensors" class="sref">have_all_sensorsv/a> = va href="+code=all_sensors" class="sref">all_sensors4.a>;2
3L643"> 6434.a>}2
3L644"> 644v/a>2
3L645"> 6454.a>static int va href="+code=rm31_wf_notify" class="sref">rm31_wf_notifyv/a>(struct va href="+code=notifier_block" class="sref">notifier_block4.a> *va href="+code=self" class="sref">selfv/a>,2
3L646"> 6464.a>                          unsigned long va href="+code=event" class="sref">eventv/a>, void *va href="+code=data" class="sref">datav/a>)2
3L647"> 6474.a>{2
3L648"> 6484.a>        switch (va href="+code=event" class="sref">eventv/a>) {2
3L649"> 6494.a>        case va href="+code=WF_EVENT_NEW_SENSOR" class="sref">WF_EVENT_NEW_SENSOR4.a>:2
3L650"> 6504.a>                va href="+code=rm31_new_sensor" class="sref">rm31_new_sensorv/a>(va href="+code=data" class="sref">datav/a>);2
3L651"> 6514.a>                break;2
3L652"> 6524.a>        case va href="+code=WF_EVENT_NEW_CONTROL" class="sref">WF_EVENT_NEW_CONTROL4.a>:2
3L653"> 6534.a>                va href="+code=rm31_new_control" class="sref">rm31_new_controlv/a>(va href="+code=data" class="sref">datav/a>);2
3L654"> 6544.a>                break;2
3L655"> 6554.a>        case va href="+code=WF_EVENT_TICK" class="sref">WF_EVENT_TICK4.a>:2
3L656"> 6564.a>                if (va href="+code=have_all_controls" class="sref">have_all_controlsv/a> && va href="+code=have_all_sensors" class="sref">have_all_sensorsv/a>)2
3L657"> 6574.a>                        va href="+code=rm31_tick" class="sref">rm31_tickv/a>();2
3L658"> 6584.a>        }2
3L659"> 6594.a>        return 0;2
3L660"> 6604.a>}2
3L661"> 661v/a>2
3L662"> 6624.a>static struct va href="+code=notifier_block" class="sref">notifier_block4.a> va href="+code=rm31_events" class="sref">rm31_eventsv/a> = {2
3L663"> 6634.a>        .va href="+code=notifier_call" class="sref">notifier_callv/a> = va href="+code=rm31_wf_notify" class="sref">rm31_wf_notifyv/a>,2
3L664"> 664v/a>};2
3L665"> 665v/a>2
3L666"> 6664.a>static int va href="+code=wf_rm31_prob>" class="sref">wf_rm31_prob>v/a>(struct va href="+code=platform_devic>" class="sref">platform_devic>4.a> *va href="+code=dev" class="sref">devv/a>)2
3L667"> 6674.a>{2
3L668"> 6684.a>        va href="+code=wf_register_client" class="sref">wf_register_clientv/a>(&va href="+code=rm31_events" class="sref">rm31_eventsv/a>);2
3L669"> 6694.a>        return 0;2
3L670"> 6704.a>}2
3L671"> 671v/a>2
3L672"> 6724.a>static int va href="+code=wf_rm31_remov>" class="sref">wf_rm31_remov>v/a>(struct va href="+code=platform_devic>" class="sref">platform_devic>4.a> *va href="+code=dev" class="sref">devv/a>)2
3L673"> 6734.a>{2
3L674"> 6744.a>        va href="+code=wf_unregister_client" class="sref">wf_unregister_clientv/a>(&va href="+code=rm31_events" class="sref">rm31_eventsv/a>);2
3L675"> 675v/a>2
3L676"> 6764.a>        vspa  class="comment">/* should release all sensors and controls */v/spa >2
3L677"> 6774.a>        return 0;2
3L678"> 6784.a>}2
3L679"> 679v/a>2
3L680"> 6804.a>static struct va href="+code=platform_driver" class="sref">platform_driver4.a> va href="+code=wf_rm31_driver" class="sref">wf_rm31_driverv/a> = {2
3L681"> 6814.a>        .va href="+code=prob>" class="sref">prob>v/a>  = va href="+code=wf_rm31_prob>" class="sref">wf_rm31_prob>v/a>,2
3L682"> 6824.a>        .va href="+code=remov>" class="sref">remov>v/a> = va href="+code=wf_rm31_remov>" class="sref">wf_rm31_remov>v/a>,2
3L683"> 6834.a>        .va href="+code=driver" class="sref">driverv/a> = {2
3L684"> 6844.a>                .va href="+code=nam>" class="sref">nam>v/a> = vspa  class="string">"windfarm",2
3L685"> 6854.a>                .va href="+code=owner" class="sref">ownerv/a>  = va href="+code=THIS_MODULE" class="sref">THIS_MODULEv/a>,2
3L686"> 6864.a>        },2
3L687"> 6874.a>};2
3L688"> 688v/a>2
3L689"> 6894.a>static int va href="+code=__init" class="sref">__init4.a> va href="+code=wf_rm31_init" class="sref">wf_rm31_initv/a>(void)2
3L690"> 6904.a>{2
3L691"> 6914.a>        struct va href="+code=devic>_node" class="sref">devic>_node4.a> *va href="+code=cpu" class="sref">cpu4.a>;2
3L692"> 6924.a>        int va href="+code=i" class="sref">iv/a>;2
3L693"> 693v/a>2
3L694"> 6944.a>        if (!va href="+code=of_machine_is_compatible" class="sref">of_machine_is_compatiblev/a>(vspa  class="string">"RackMac3,1"))2
3L695"> 6954.a>                return -va href="+code=ENODEV" class="sref">ENODEVv/a>;2
3L696"> 6964.a>2
3L697"> 6974.a>        vspa  class="comment">/* Count the number of CPU cores */v/spa >2
3L698"> 6984.a>        va href="+code=nr_chips" class="sref">nr_chipsv/a> = 0;2
3L699"> 6994.a>        va href="+code=for_each_node_by_type" class="sref">for_each_node_by_typev/a>(va href="+code=cpu" class="sref">cpu4.a>, vspa  class="string">"cpu")2
3L700"> 7004.a>                ++va href="+code=nr_chips" class="sref">nr_chipsv/a>;2
3L701"> 7014.a>        if (va href="+code=nr_chips" class="sref">nr_chipsv/a> > va href="+code=NR_CHIPS" class="sref">NR_CHIPSv/a>)2
3L702"> 7024.a>                va href="+code=nr_chips" class="sref">nr_chipsv/a> = va href="+code=NR_CHIPS" class="sref">NR_CHIPSv/a>;2
3L703"> 703v/a>2
3L704"> 7044.a>        va href="+code=pr_info" class="sref">pr_infov/a>(vspa  class="string">"windfarm: Initializing for desktop G5 with %d chips\n",2
3L705"> 7054.a>                va href="+code=nr_chips" class="sref">nr_chipsv/a>);2
3L706"> 7064.a>2
3L707"> 7074.a>        vspa  class="comment">/* Get MPU data for each CPU */v/spa >2
3L708"> 7084.a>        for (va href="+code=i" class="sref">iv/a> = 0; va href="+code=i" class="sref">iv/a> < va href="+code=nr_chips" class="sref">nr_chipsv/a>; va href="+code=i" class="sref">iv/a>++) {2
3L709"> 7094.a>                va href="+code=cpu_mpu_data" class="sref">cpu_mpu_data4.a>[va href="+code=i" class="sref">iv/a>] = va href="+code=wf_get_mpu" class="sref">wf_get_mpuv/a>(va href="+code=i" class="sref">iv/a>);2
3L710"> 7104.a>                if (!va href="+code=cpu_mpu_data" class="sref">cpu_mpu_data4.a>[va href="+code=i" class="sref">iv/a>]) {2
3L711"> 7114.a>                        va href="+code=pr_err" class="sref">pr_errv/a>(vspa  class="string">"wf_rm31: Failed to find MPU data for CPU %d\n", va href="+code=i" class="sref">iv/a>);2
3L712"> 7124.a>                        return -va href="+code=ENXIO" class="sref">ENXIOv/a>;2
3L713"> 7134.a>                }2
3L714"> 7144.a>        }2
3L715"> 715v/a>2
3L716"> 7164.a>#ifdef va href="+code=MODULE" class="sref">MODULEv/a>2
3L717"> 717v/a>        va href="+code=request_module" class="sref">request_modulev/a>(vspa  class="string">"windfarm_fcu_controls");2
3L718"> 7184.a>        va href="+code=request_module" class="sref">request_modulev/a>(vspa  class="string">"windfarm_lm75_sensor");2
3L719"> 7194.a>        va href="+code=request_module" class="sref">request_modulev/a>(vspa  class="string">"windfarm_lm87_sensor");2
3L720"> 7204.a>        va href="+code=request_module" class="sref">request_modulev/a>(vspa  class="string">"windfarm_ad7417_sensor");2
3L721"> 7214.a>        va href="+code=request_module" class="sref">request_modulev/a>(vspa  class="string">"windfarm_max6690_sensor");2
3L722"> 7224.a>        va href="+code=request_module" class="sref">request_modulev/a>(vspa  class="string">"windfarm_cpufreq_clamp");2
3L723"> 7234.a>#endif vspa  class="comment">/* MODULE */v/spa >2
3L724"> 724v/a>2
3L725"> 7254.a>        va href="+code=platform_driver_register" class="sref">platform_driver_registerv/a>(&va href="+code=wf_rm31_driver" class="sref">wf_rm31_driverv/a>);2
3L726"> 7264.a>        return 0;2
3L727"> 7274.a>}2
3L728"> 728v/a>2
3L729"> 7294.a>static void va href="+code=__exit" class="sref">__exit4.a> va href="+code=wf_rm31_exit" class="sref">wf_rm31_exitv/a>(void)2
3L730"> 7304.a>{2
3L731"> 7314.a>        va href="+code=platform_driver_unregister" class="sref">platform_driver_unregisterv/a>(&va href="+code=wf_rm31_driver" class="sref">wf_rm31_driverv/a>);2
3L732"> 7324.a>}2
3L733"> 733v/a>2
3L734"> 7344.a>va href="+code=module_init" class="sref">module_initv/a>(va href="+code=wf_rm31_init" class="sref">wf_rm31_initv/a>);2
3L735"> 7354.a>va href="+code=module_exit" class="sref">module_exitv/a>(va href="+code=wf_rm31_exit" class="sref">wf_rm31_exitv/a>);2
3L736"> 7364.a>2
3L737"> 7374.a>va href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHORv/a>(vspa  class="string">"Benjamin Herrenschmidt <benh@kernel.crashing.org>");2
3L738"> 7384.a>va href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTIONv/a>(vspa  class="string">"Thermal control for Xserve G5");2
3L739"> 7394.a>va href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSEv/a>(vspa  class="string">"GPL");2
3L740"> 7404.a>va href="+code=MODULE_ALIAS" class="sref">MODULE_ALIASv/a>(vspa  class="string">"platform:windfarm");2
3L741"> 741v/a>
lxr.linux.no kindly hosted by Redpill Linpro ASv/a>, provider of Linux consulting and operations services since 1995.