30 #include <linux/types.h>
31 #include <linux/module.h>
32 #include <linux/errno.h>
33 #include <linux/kernel.h>
35 #include <linux/sched.h>
36 #include <linux/i2c.h>
42 #include <asm/machdep.h>
44 #include <asm/sections.h>
71 #define T(x,y) (((x)<<8) | (y)*0x100/10 )
93 print_temp(
const char *
s,
int temp )
95 printk(
"%s%d.%d C", s ? s :
"", temp>>8, (temp & 255)*10/256 );
101 return sprintf(buf,
"%d.%d\n",
x.temp>>8, (
x.temp & 255)*10/256 );
107 return sprintf(buf,
"%d.%d\n",
x.casetemp>>8, (
x.casetemp & 255)*10/256 );
124 if( len < 1 || len > 2 || data < 0 )
128 tmp[1] = (len == 1) ? data : (data >> 8);
142 if( len != 1 && len != 2 )
149 return (len == 2)? ((
unsigned int)buf[0] << 8) | buf[1] : buf[0];
153 tune_fan(
int fan_setting )
155 int val = (fan_setting << 3) | 7;
160 print_temp(
"CPU-temp: ",
x.temp );
162 print_temp(
", Case: ",
x.casetemp );
163 printk(
", Fan: %d (tuned %+d)\n", 11-fan_setting,
x.fan_level-fan_setting );
165 x.fan_level = fan_setting;
179 casetemp =
read_reg(
x.fan, 0x0b, 1) << 8;
180 casetemp |= (
read_reg(
x.fan, 0x06, 1) & 0x7) << 5;
183 print_temp(
"CPU-temp: ", temp );
184 print_temp(
", Case: ", casetemp );
185 printk(
", Fan: %d\n", 11-
x.fan_level );
191 for( i=0; (temp & 0xffff) > fan_table[i].temp ; i++ )
194 level = fan_table[
i].fan_down_setting;
197 for( i=0; (temp & 0xffff) >= fan_table[i+1].temp ; i++ )
200 level = fan_table[
i].fan_up_setting;
209 setup_hardware(
void )
222 if( (val=
read_reg(
x.thermostat, 1, 1)) >= 0 ) {
225 printk(
"Failed writing config register\n");
239 if(
x.overheat_temp == (80 << 8) ) {
240 x.overheat_temp = 75 << 8;
241 x.overheat_hyst = 70 << 8;
245 print_temp(
"Reducing overheating limit to ",
x.overheat_temp );
246 print_temp(
" (Hyst: ",
x.overheat_hyst );
259 "Failed to create temperature attribute file(s).\n");
275 static int control_loop(
void *
dummy)
307 static const unsigned short scan_ds1775[] = {
308 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
311 static const unsigned short scan_adm1030[] = {
312 0x2c, 0x2d, 0x2e, 0x2f,
329 if(
x.thermostat &&
x.fan ) {
345 if (client ==
x.thermostat)
347 else if (client ==
x.fan)
364 printk(
"ADM1030 fan controller [@%02x]\n", cl->
addr );
374 int hyst_temp, os_temp,
temp;
383 if( temp < 0x1600 || temp > 0x3c00 )
387 if( hyst_temp < 0 || os_temp < 0 )
390 printk(
"DS1775 digital thermometer [@%02x]\n", cl->
addr );
391 print_temp(
"Temp: ", temp );
392 print_temp(
" Hyst: ", hyst_temp );
393 print_temp(
" OS: ", os_temp );
397 x.overheat_temp = os_temp;
398 x.overheat_hyst = hyst_temp;
407 {
"therm_ds1775",
ds1775 },
421 switch (id->driver_data) {
423 return attach_fan( cl );
425 return attach_thermostat(cl);
432 .name =
"therm_windtunnel",
434 .attach_adapter = do_attach,
437 .id_table = therm_windtunnel_id,
447 return i2c_add_driver( &g4fan_driver );
459 .compatible =
"adm1030"
465 .name =
"temperature",
467 .of_match_table = therm_of_match,
469 .probe = therm_of_probe,
470 .remove = therm_of_remove,
496 if( info->
id != 3 ) {
497 printk(
KERN_ERR "therm_windtunnel: unsupported thermal design %d\n", info->
id );
502 x.of_dev = of_platform_device_create(np,
"temperature",
NULL);