ne1619 (almost solved)
Quoted 7 lines
Quoted 3 lines
Not bad, but it's not perfect yet. VCCP is bad (I don't know what it is) and +12V is very bad too. The temperatures look correct.
I know, what I "needed" was CPU temperature. Temperatures are really correct, memory (+2.5), +3.3V, +5.5V too.
Quoted 6 lines
IMHO VCCP looks like "CPU Core (+1.5 V)" from intel Active Monitor
Nominal Value 1,500 Current Value 1,447 Upper Threshold 2,300 Lower Threshold 0,700.
These guys are crazy. They accept a deviation of over 50% on VCore. We tolerate 5%...
Quoted 2 lines
value "+12V" isn't in Active Monitor, maybe simply isn't(?) on my chip.
I read the datasheet and this one is tricky. The pin that reports +12V is shared with another function, so depending on how your chip is hardwired, you have +12V or not. Obviously you don't have it. Our driver doesn't support this possibility yet. This may also explain your wrong limits for VCCP, but I'd like you to try some things to be sure.
I suspect you have an old config file at /etc/sensors.conf, with no section for the adm1025. If I'm right, you should copy the new one (etc/sensors.conf.eg from lm_sensors-2.8.0) to /etc/sensors.conf, run "sensors -s" and run "sensors" again. You should at least see VCCP labeled VCore. Maybe the limits will change too. Please let me know what they are.
In the meantime, I'll fix our driver to support your configuration. I have an idea on how to do that, I'll think of it while sleeping.
BTW, is the data at address Ox44 on your I2C bus still the same? ;) Just curious.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Dne ne 27. ?ervence 2003 23:34 jste napsal(a):
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Not bad, but it's not perfect yet. VCCP is bad (I don't know what it is) and +12V is very bad too. The temperatures look correct.
I know, what I "needed" was CPU temperature. Temperatures are really correct, memory (+2.5), +3.3V, +5.5V too.
IMHO VCCP looks like "CPU Core (+1.5 V)" from intel Active Monitor
Quoted 7 lines
Quoted 4 lines
Nominal Value 1,500 Current Value 1,447 Upper Threshold 2,300 Lower Threshold 0,700.These guys are crazy. They accept a deviation of over 50% on VCore. We tolerate 5%...
;-), intel is sometime interesting.
Quoted 9 lines
Quoted 2 lines
value "+12V" isn't in Active Monitor, maybe simply isn't(?) on my chip.
I read the datasheet and this one is tricky. The pin that reports +12V is shared with another function, so depending on how your chip is hardwired, you have +12V or not. Obviously you don't have it. Our driver doesn't support this possibility yet. This may also explain your wrong limits for VCCP, but I'd like you to try some things to be sure.
Quoted 6 lines
I suspect you have an old config file at
/etc/sensors.conf, with no section for the adm1025. If I'm right, you should copy the new one (etc/sensors.conf.eg from lm_sensors-2.8.0) to/etc/sensors.conf, run "sensors -s" and run "sensors" again. You should at least see VCCP labeled VCore. Maybe the limits will change too. Please let me know what they are.
OK, I did it. Now, line with VCCP is
VCore: +1.46 V (min = +1.40 V, max = +1.55 V).
Quoted 2 lines
In the meantime, I'll fix our driver to support your configuration. I have an idea on how to do that, I'll think of it while sleeping.
great :o)
Quoted 2 lines
BTW, is the data at address Ox44 on your I2C bus still the same? ;) Just curious.
you think this magic line? 00: 00 00 0f 3f 00 00 02 00 50 00 00 00 00 00 00 00 It's constantly. I tested something and after 2-3 reboots looks this line still same, so maybe you have new fun ...
good night ...
Signature · 1 line
Ondrej Cecak
Quoted 10 lines
Quoted 7 lines
I suspect you have an old config file at
/etc/sensors.conf, with no section for the adm1025. If I'm right, you should copy the new one (etc/sensors.conf.eg from lm_sensors-2.8.0) to/etc/sensors.conf, run"sensors -s" and run "sensors" again. You should at least see VCCP labeled VCore. Maybe the limits will change too. Please let me know what they are.OK, I did it. Now, line with VCCP is
VCore: +1.46 V (min = +1.40 V, max = +1.55 V).
Far better isnt' it :) This is because the driver (as all our drivers) default to an old version of the VRM standard (8.x). The config file changes this to use the new standard (9.0).
Quoted 4 lines
Quoted 2 lines
In the meantime, I'll fix our driver to support your configuration. I have an idea on how to do that, I'll think of it while sleeping.
great :o)
OK, just finished. I fixed a pair of actual or potential bugs and cleaned the code up (over 10% reduction in source code size). Could you please give it a try and tell me how it works for you? Remplace the file in kernel/chips with this new one, recompile, reinstall and you're done.
What you should expect to see:
1* +12V reading = 0 (because it's not wired on your board, and that's why it doesn't appear in Intel's software).
2* Slightly higher default voltage limits (both min and max). 3* No more ALARM for VCore nor +12V.
4* No need to force the driver anymore.
You may have to reboot your system (sigh) in order to see 1* and 3*. That's because our driver used to overwrite a configuration bit. I fixed that but if it has already been overwritten by the previous version of the driver, it won't help.
I admit the changes aren't very important from the user-side, but I have indeed changed many things in the simplification process so I'd like to see how it turns out, and that's why I'm very interested in you testing the new driver.
I'll also appreciate a dump of the /proc/sys/dev/sensors/adm1025-i2c-0-2d/* files. You could play a bit with limits in the config file too, and see if it does what it is supposed to do.
Quoted 6 lines
Quoted 2 lines
BTW, is the data at address Ox44 on your I2C bus still the same? ;) Just curious.
you think this magic line? 00: 00 00 0f 3f 00 00 02 00 50 00 00 00 00 00 00 00 It's constantly. I tested something and after 2-3 reboots looks this line still same, so maybe you have new fun ...
No fun, it just confirms it must be some kind of EEPROM. I don't have any idea of what it can stand for however, so I won't go any further unless the other guy can help (not heard from him yet).
Signature · 630 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
-------------- next part --------------
/*
adm1025.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (c) 2000 Chen-Yuan Wu <[email protected]>
Copyright (c) 2003 Jean Delvare <[email protected]>
Based on the adm9240 driver.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Supports the Analog Devices ADM1025 and the Philips NE1619.
See doc/chips/adm1025 for details */
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/ioport.h>
#include <linux/sysctl.h>
#include <linux/types.h>
#include <linux/i2c.h>
#include <linux/i2c-proc.h>
#include <linux/init.h>
#include <asm/errno.h>
#include <asm/io.h>
#include "version.h"
#include "sensors_vid.h"
MODULE_LICENSE("GPL");
/* Addresses to scan */
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
static unsigned short normal_i2c_range[] = { 0x2c, 0x2e, SENSORS_I2C_END };
static unsigned int normal_isa[] = { SENSORS_ISA_END };
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
/* Insmod parameters */
SENSORS_INSMOD_1(adm1025);
/* Many ADM1025 constants specified below */
/* The ADM1025 registers */
/* These are all read-only */
#define ADM1025_REG_2_5V 0x20 /* not used directly, see */
#define ADM1025_REG_VCCP1 0x21 /* ADM1025_REG_IN(nr) below */
#define ADM1025_REG_3_3V 0x22
#define ADM1025_REG_5V 0x23
#define ADM1025_REG_12V 0x24
#define ADM1025_REG_VCC 0x25
#define ADM1025_REG_RTEMP 0x26
#define ADM1025_REG_TEMP 0x27
#define ADM1025_REG_COMPANY_ID 0x3E /* 0x41 for Analog Devices,
0xA1 for Philips */
#define ADM1025_REG_DIE_REV 0x3F /* 0x20-0x2F for ADM1025 and compatible */
#define ADM1025_REG_STATUS1 0x41
#define ADM1025_REG_STATUS2 0x42
#define ADM1025_REG_VID 0x47
#define ADM1025_REG_VID4 0x49 /* actually R/W
but we don't write to it */
/* These are read/write */
#define ADM1025_REG_TEST 0x15 /* unused */
#define ADM1025_REG_2_5V_HIGH 0x2B /* not used directly, see */
#define ADM1025_REG_2_5V_LOW 0x2C /* ADM1025_REG_IN_MAX(nr) and */
#define ADM1025_REG_VCCP1_HIGH 0x2D /* ADM1025_REG_IN_MIN(nr) below */
#define ADM1025_REG_VCCP1_LOW 0x2E
#define ADM1025_REG_3_3V_HIGH 0x2F
#define ADM1025_REG_3_3V_LOW 0x30
#define ADM1025_REG_5V_HIGH 0x31
#define ADM1025_REG_5V_LOW 0x32
#define ADM1025_REG_12V_HIGH 0x33
#define ADM1025_REG_12V_LOW 0x34
#define ADM1025_REG_VCC_HIGH 0x35
#define ADM1025_REG_VCC_LOW 0x36
#define ADM1025_REG_RTEMP_HIGH 0x37
#define ADM1025_REG_RTEMP_LOW 0x38
#define ADM1025_REG_TEMP_HIGH 0x39
#define ADM1025_REG_TEMP_LOW 0x3A
#define ADM1025_REG_CONFIG 0x40
/* Useful macros */
#define ADM1025_REG_IN(nr) (ADM1025_REG_2_5V + (nr))
#define ADM1025_REG_IN_MAX(nr) (ADM1025_REG_2_5V_HIGH + (nr) * 2)
#define ADM1025_REG_IN_MIN(nr) (ADM1025_REG_2_5V_LOW + (nr) * 2)
/* Conversions. Rounding and limit checking is only done on the TO_REG
variants. Note that you should be a bit careful with which arguments
these macros are called: arguments may be evaluated more than once.
Fixing this is just not worth it. */
#define IN_TO_REG(val) (SENSORS_LIMIT(((val) & 0xff),0,255))
#define IN_FROM_REG(val) (val)
#define TEMP_FROM_REG(val) (((val)>=0x80?(val)-0x100:(val))*10)
#define TEMP_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-5)/10):\
((val)+5)/10),0,255)
#define ALARMS_FROM_REG(val) (val)
/* Initial limits */
#define ADM1025_INIT_IN 192
#define ADM1025_INIT_IN_MIN (ADM1025_INIT_IN * 90 / 100)
#define ADM1025_INIT_IN_MAX (ADM1025_INIT_IN * 110 / 100)
#define ADM1025_INIT_RTEMP_MAX 600
#define ADM1025_INIT_RTEMP_MIN 0
#define ADM1025_INIT_TEMP_MAX 600
#define ADM1025_INIT_TEMP_MIN 0
/* For each registered ADM1025, we need to keep some data in memory. That
data is pointed to by adm1025_list[NR]->data. The structure itself is
dynamically allocated, at the same time when a new adm1025 client is
allocated. */
struct adm1025_data {
int sysctl_id;
enum chips type;
struct semaphore update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
u8 in[6]; /* Register value */
u8 in_max[6]; /* Register value */
u8 in_min[6]; /* Register value */
u8 rtemp; /* Register value */
u8 rtemp_max; /* Register value */
u8 rtemp_min; /* Register value */
u8 temp; /* Register value */
u8 temp_max; /* Register value */
u8 temp_min; /* Register value */
u16 alarms; /* Register encoding, combined */
u8 analog_out; /* Register value */
u8 vid; /* Register value combined */
u8 vrm;
};
static int adm1025_attach_adapter(struct i2c_adapter *adapter);
static int adm1025_detect(struct i2c_adapter *adapter, int address,
unsigned short flags, int kind);
static int adm1025_detach_client(struct i2c_client *client);
static void adm1025_update_client(struct i2c_client *client);
static void adm1025_init_client(struct i2c_client *client);
static void adm1025_in(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_remote_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_alarms(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
/*static void adm1025_analog_out(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag,
long *results);*/
static void adm1025_vid(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_vrm(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
/* I choose here for semi-static ADM1025 allocation. Complete dynamic
allocation could also be used; the code needed for this would probably
take more memory than the datastructure takes now. */
static int adm1025_id = 0;
static struct i2c_driver adm1025_driver = {
.owner = THIS_MODULE,
.name = "ADM1025 sensor driver",
.id = I2C_DRIVERID_ADM1025,
.flags = I2C_DF_NOTIFY,
.attach_adapter = adm1025_attach_adapter,
.detach_client = adm1025_detach_client,
};
/* The /proc/sys entries */
/* -- SENSORS SYSCTL START -- */
#define ADM1025_SYSCTL_IN0 1000 /* Volts * 100 */
#define ADM1025_SYSCTL_IN1 1001
#define ADM1025_SYSCTL_IN2 1002
#define ADM1025_SYSCTL_IN3 1003
#define ADM1025_SYSCTL_IN4 1004
#define ADM1025_SYSCTL_IN5 1005
#define ADM1025_SYSCTL_RTEMP 1251 /* Degrees Celcius * 10 */
#define ADM1025_SYSCTL_TEMP 1250
#define ADM1025_SYSCTL_ALARMS 2001 /* bitvector */
#define ADM1025_SYSCTL_VID 2003 /* Volts * 1000 */
#define ADM1025_SYSCTL_VRM 2004
#define ADM1025_ALARM_IN0 0x0001
#define ADM1025_ALARM_IN1 0x0002
#define ADM1025_ALARM_IN2 0x0004
#define ADM1025_ALARM_IN3 0x0008
#define ADM1025_ALARM_IN4 0x0100
#define ADM1025_ALARM_IN5 0x0200
#define ADM1025_ALARM_RTEMP 0x0020
#define ADM1025_ALARM_TEMP 0x0010
/* -- SENSORS SYSCTL END -- */
/* These files are created for each detected ADM1025. This is just a template;
though at first sight, you might think we could use a statically
allocated list, we need some way to get back to the parent - which
is done through one of the 'extra' fields which are initialized
when a new copy is allocated. */
static ctl_table adm1025_dir_table_template[] = {
{ADM1025_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_RTEMP, "temp2", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_remote_temp},
{ADM1025_SYSCTL_TEMP, "temp1", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_temp},
{ADM1025_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_alarms},
{ADM1025_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_vid},
{ADM1025_SYSCTL_VRM, "vrm", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_vrm},
{0}
};
static int adm1025_attach_adapter(struct i2c_adapter *adapter)
{
return i2c_detect(adapter, &addr_data, adm1025_detect);
}
static int adm1025_detect(struct i2c_adapter *adapter, int address,
unsigned short flags, int kind)
{
int i;
struct i2c_client *new_client;
struct adm1025_data *data;
int err = 0;
const char *type_name = "";
const char *client_name = "";
/* Make sure we aren't probing the ISA bus!! This is just a safety check
at this moment; i2c_detect really won't call us. */
#ifdef DEBUG
if (i2c_is_isa_adapter(adapter)) {
printk
("adm1025.o: adm1025_detect called for an ISA bus adapter?!?\n");
return 0;
}
#endif
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
goto ERROR0;
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access adm1025_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct adm1025_data),
GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct adm1025_data *) (new_client + 1);
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
new_client->driver = &adm1025_driver;
new_client->flags = 0;
/* Now, we do the remaining detection. */
if (kind < 0) {
if((i2c_smbus_read_byte_data(new_client,ADM1025_REG_CONFIG) & 0x80) != 0x00)
goto ERROR1;
}
/* Determine the chip type. */
if (kind <= 0) {
i = i2c_smbus_read_byte_data(new_client, ADM1025_REG_COMPANY_ID);
if (((i2c_smbus_read_byte_data(new_client, ADM1025_REG_DIE_REV) & 0xf0) = 0x20)
&& ((i = 0x41) /* ADM1025 */
|| (i = 0xA1))) /* NE1619 */
kind = adm1025;
else {
if (kind = 0)
printk
("adm1025.o: Ignoring 'force' parameter for unknown chip at "
"adapter %d, address 0x%02x\n",
i2c_adapter_id(adapter), address);
goto ERROR1;
}
}
if (kind = adm1025) {
type_name = "adm1025";
client_name = "ADM1025 chip";
} else {
#ifdef DEBUG
printk("adm1025.o: Internal error: unknown kind (%d)?!?",
kind);
#endif
goto ERROR1;
}
/* Fill in the remaining client fields and put it into the global list */
strcpy(new_client->name, client_name);
data->type = kind;
new_client->id = adm1025_id++;
data->valid = 0;
init_MUTEX(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
goto ERROR3;
/* Register a new directory entry with module sensors */
if ((i = i2c_register_entry(new_client,
type_name,
adm1025_dir_table_template)) < 0) {
err = i;
goto ERROR4;
}
data->sysctl_id = i;
/* Initialize the ADM1025 chip */
adm1025_init_client(new_client);
return 0;
/* OK, this is not exactly good programming practice, usually. But it is
very code-efficient in this case. */
ERROR4:
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
ERROR0:
return err;
}
static int adm1025_detach_client(struct i2c_client *client)
{
int err;
i2c_deregister_entry(((struct adm1025_data *) (client->data))->
sysctl_id);
if ((err = i2c_detach_client(client))) {
printk
("adm1025.o: Client deregistration failed, client not detached.\n");
return err;
}
kfree(client);
return 0;
}
/* Called when we have found a new ADM1025. It should set limits, etc. */
static void adm1025_init_client(struct i2c_client *client)
{
struct adm1025_data *data = client->data;
u8 reg, nr;
data->vrm = DEFAULT_VRM;
/* Restore power-up default values (configuration and status
registers). This makes some other initializations
unnecessary. Set the chip in standby mode until the
limits are properly set. Note that we take great care not to
change the bits 1-6 of the configuration register, since
they hold data we want to preserve. */
reg = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
i2c_smbus_write_byte_data(client, ADM1025_REG_CONFIG, 0x80);
for (nr = 0; nr < 6; nr++) {
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(nr),
IN_TO_REG(ADM1025_INIT_IN_MIN));
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(nr),
IN_TO_REG(ADM1025_INIT_IN_MAX));
}
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_HIGH,
TEMP_TO_REG(ADM1025_INIT_RTEMP_MAX));
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_LOW,
TEMP_TO_REG(ADM1025_INIT_RTEMP_MIN));
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH,
TEMP_TO_REG(ADM1025_INIT_TEMP_MAX));
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW,
TEMP_TO_REG(ADM1025_INIT_TEMP_MIN));
/* Restore configuration and start monitoring */
i2c_smbus_write_byte_data(client, ADM1025_REG_CONFIG, (reg|0x01)&0x7F);
}
static void adm1025_update_client(struct i2c_client *client)
{
struct adm1025_data *data = client->data;
u8 nr;
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2)
|| (jiffies < data->last_updated) || !data->valid) {
#ifdef DEBUG
printk("Starting adm1025 update\n");
#endif
/* Voltages */
for (nr = 0; nr < 6; nr++) {
data->in[nr] = i2c_smbus_read_byte_data(client, ADM1025_REG_IN(nr));
/* data->in_min[nr] = i2c_smbus_read_byte_data(client, ADM1025_REG_IN_MIN(nr));
data->in_max[nr] = i2c_smbus_read_byte_data(client, ADM1025_REG_IN_MAX(nr));*/
}
/* Temperatures */
data->temp = i2c_smbus_read_byte_data(client, ADM1025_REG_TEMP);
data->rtemp = i2c_smbus_read_byte_data(client, ADM1025_REG_RTEMP);
/* data->temp_max = i2c_smbus_read_byte_data(client, ADM1025_REG_TEMP_HIGH);
data->temp_min = i2c_smbus_read_byte_data(client, ADM1025_REG_TEMP_LOW);
data->rtemp_max = i2c_smbus_read_byte_data(client, ADM1025_REG_RTEMP_HIGH);
data->rtemp_min = i2c_smbus_read_byte_data(client, ADM1025_REG_RTEMP_LOW);*/
/* VID */
data->vid = (i2c_smbus_read_byte_data(client, ADM1025_REG_VID) & 0x0f)
+ ((i2c_smbus_read_byte_data(client, ADM1025_REG_VID4) & 0x01) << 4);
/* Alarms */
data->alarms = (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS1) & 0x3f)
+ ((i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS2) & 0x43) << 8);
data->last_updated = jiffies;
data->valid = 1;
}
up(&data->update_lock);
}
/* The next few functions are the call-back functions of the /proc/sys and
sysctl files. Which function is used is defined in the ctl_table in
the extra1 field.
Each function must return the magnitude (power of 10 to divide the data
with) if it is called with operation=SENSORS_PROC_REAL_INFO. It must
put a maximum of *nrels elements in results reflecting the data of this
file, and set *nrels to the number it actually put in it, if operation=
SENSORS_PROC_REAL_READ. Finally, it must get upto *nrels elements from
results and write them to the chip, if operations=SENSORS_PROC_REAL_WRITE.
Note that on SENSORS_PROC_REAL_READ, I do not check whether results is
large enough (by checking the incoming value of *nrels). This is not very
good practice, but as long as you put less than about 5 values in results,
you can assume it is large enough. */
void adm1025_in(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
int scales[6] = { 250, 225, 330, 500, 1200, 330 };
struct adm1025_data *data = client->data;
int nr = ctl_name - ADM1025_SYSCTL_IN0;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 2;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = IN_FROM_REG(data->in_min[nr]) * scales[nr] / 192;
results[1] = IN_FROM_REG(data->in_max[nr]) * scales[nr] / 192;
results[2] = IN_FROM_REG(data->in[nr]) * scales[nr] / 192;
*nrels_mag = 3;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1) {
data->in_min[nr] = IN_TO_REG((results[0] * 192) / scales[nr]);
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(nr),
data->in_min[nr]);
}
if (*nrels_mag >= 2) {
data->in_max[nr] = IN_TO_REG((results[1] * 192) / scales[nr]);
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(nr),
data->in_max[nr]);
}
}
}
void adm1025_temp(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 1;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = TEMP_FROM_REG(data->temp_max);
results[1] = TEMP_FROM_REG(data->temp_min);
results[2] = TEMP_FROM_REG(data->temp);
*nrels_mag = 3;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1) {
data->temp_max = TEMP_TO_REG(results[0]);
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH,
data->temp_max);
}
if (*nrels_mag >= 2) {
data->temp_min = TEMP_TO_REG(results[1]);
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW,
data->temp_min);
}
}
}
void adm1025_remote_temp(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 1;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = TEMP_FROM_REG(data->rtemp_max);
results[1] = TEMP_FROM_REG(data->rtemp_min);
results[2] = TEMP_FROM_REG(data->rtemp);
*nrels_mag = 3;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1) {
data->rtemp_max = TEMP_TO_REG(results[0]);
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_HIGH,
data->rtemp_max);
}
if (*nrels_mag >= 2) {
data->rtemp_min = TEMP_TO_REG(results[1]);
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_LOW,
data->rtemp_min);
}
}
}
void adm1025_alarms(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 0;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = ALARMS_FROM_REG(data->alarms);
*nrels_mag = 1;
}
}
void adm1025_vid(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 3;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = vid_from_reg(data->vid, data->vrm);
*nrels_mag = 1;
}
}
void adm1025_vrm(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 1;
else if (operation = SENSORS_PROC_REAL_READ) {
results[0] = data->vrm;
*nrels_mag = 1;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1)
data->vrm = results[0];
}
}
static int __init sm_adm1025_init(void)
{
printk("adm1025.o version %s (%s)\n", LM_VERSION, LM_DATE);
return i2c_add_driver(&adm1025_driver);
}
static void __exit sm_adm1025_exit(void)
{
i2c_del_driver(&adm1025_driver);
}
MODULE_AUTHOR("Chen-Yuan Wu <[email protected]>"
" and Jean Delvare <[email protected]>");
MODULE_DESCRIPTION("ADM1025 driver");
module_init(sm_adm1025_init);
module_exit(sm_adm1025_exit);Dne po 28. ?ervence 2003 16:57 jste napsal(a):
Quoted 8 lines
OK, just finished. I fixed a pair of actual or potential bugs and cleaned the code up (over 10% reduction in source code size). Could you please give it a try and tell me how it works for you? Remplace the file in kernel/chips with this new one, recompile, reinstall and you're done.
What you should expect to see:
1* +12V reading = 0 (because it's not wired on your board, and that's why it doesn't appear in Intel's software).
+12V: +0.06 V (min = +10.68 V, max = +13.06 V) ALARM +12V: +0.00 V (min = +0.00 V, max = +0.00 V)
Quoted 1 line
2* Slightly higher default voltage limits (both min and max).
after reinstall ne1619 driver are values of min/max voltage 0.
e.g.
+2.5V: +2.48 V (min = +0.00 V, max = +0.00 V) +2.5V: +2.48 V (min = +0.00 V, max = +0.00 V)
(I only replaced driver, recompiled lm_sensors and rebooted)
Quoted 1 line
3* No more ALARM for VCore nor +12V.
OK
Quoted 1 line
4* No need to force the driver anymore.
perfect.
btw: speed of fan can show lm_sensors with ne1619 too?
Quoted 10 lines
You may have to reboot your system (sigh) in order to see 1* and 3*. That's because our driver used to overwrite a configuration bit. I fixed that but if it has already been overwritten by the previous version of the driver, it won't help.
I admit the changes aren't very important from the user-side, but I have indeed changed many things in the simplification process so I'd like to see how it turns out, and that's why I'm very interested in you testing the new driver.
Quoted 4 lines
I'll also appreciate a dump of the
/proc/sys/dev/sensors/adm1025-i2c-0-2d/*files. You could play a bit with limits in the config file too, and see if it does what it is supposed to do.
OK, current values are:
alarms 0
in0 0.00 0.00 2.48
in1 1.40 1.55 1.46
in2 0.00 0.00 3.33 in3 0.00 0.00 5.02 in4 0.00 0.00 0.00 in5 0.00 0.00 3.26
temp1 0.0 0.0 43.0
temp2 0.0 0.0 43.0
vid 1.500
vrm 9.0
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
BTW, is the data at address Ox44 on your I2C bus still the same? ;) Just curious.
you think this magic line? 00: 00 00 0f 3f 00 00 02 00 50 00 00 00 00 00 00 00 It's constantly. I tested something and after 2-3 reboots looks this line still same, so maybe you have new fun ...
No fun, it just confirms it must be some kind of EEPROM. I don't have any idea of what it can stand for however, so I won't go any further unless the other guy can help (not heard from him yet).
all right, bye ...
Signature · 1 line
Ondrej Cecak
Quoted 6 lines
after reinstall ne1619 driver are values of min/max voltage 0.
e.g.
+2.5V: +2.48 V (min = +0.00 V, max = +0.00 V)
My bad, fixed in the attached version. Can you please try again? (No need rebooting this time, just unload the old module and load the new one instead.)
Quoted 1 line
btw: speed of fan can show
lm_sensorswith ne1619 too?
Negative on that, it's a 6-voltage 2-temperature chip, period. No fan monitoring. I'm surprised too, but that's how it it.
Quoted 5 lines
OK, current values are:
alarms 0
in0 0.00 0.00 2.48
in1 1.40 1.55 1.46
Quoted 8 lines
in2 0.00 0.00 3.33 in3 0.00 0.00 5.02 in4 0.00 0.00 0.00 in5 0.00 0.00 3.26temp1 0.0 0.0 43.0
temp2 0.0 0.0 43.0
vid 1.500
vrm 9.0
Bad of course because of the bug... Oh, please provide the output of "sensors" too (almost similar, but much more pleasant to read, isn't it).
Thanks!
Signature · 630 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
-------------- next part --------------
/*
adm1025.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (c) 2000 Chen-Yuan Wu <[email protected]>
Copyright (c) 2003 Jean Delvare <[email protected]>
Based on the adm9240 driver.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Supports the Analog Devices ADM1025 and the Philips NE1619.
See doc/chips/adm1025 for details */
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/ioport.h>
#include <linux/sysctl.h>
#include <linux/types.h>
#include <linux/i2c.h>
#include <linux/i2c-proc.h>
#include <linux/init.h>
#include <asm/errno.h>
#include <asm/io.h>
#include "version.h"
#include "sensors_vid.h"
MODULE_LICENSE("GPL");
/* Addresses to scan */
static unsigned short normal_i2c[] = { SENSORS_I2C_END };
static unsigned short normal_i2c_range[] = { 0x2c, 0x2e, SENSORS_I2C_END };
static unsigned int normal_isa[] = { SENSORS_ISA_END };
static unsigned int normal_isa_range[] = { SENSORS_ISA_END };
/* Insmod parameters */
SENSORS_INSMOD_1(adm1025);
/* Many ADM1025 constants specified below */
/* The ADM1025 registers */
/* These are all read-only */
#define ADM1025_REG_2_5V 0x20 /* not used directly, see */
#define ADM1025_REG_VCCP1 0x21 /* ADM1025_REG_IN(nr) below */
#define ADM1025_REG_3_3V 0x22
#define ADM1025_REG_5V 0x23
#define ADM1025_REG_12V 0x24
#define ADM1025_REG_VCC 0x25
#define ADM1025_REG_RTEMP 0x26
#define ADM1025_REG_TEMP 0x27
#define ADM1025_REG_COMPANY_ID 0x3E /* 0x41 for Analog Devices,
0xA1 for Philips */
#define ADM1025_REG_DIE_REV 0x3F /* 0x20-0x2F for ADM1025 and compatible */
#define ADM1025_REG_STATUS1 0x41
#define ADM1025_REG_STATUS2 0x42
#define ADM1025_REG_VID 0x47
#define ADM1025_REG_VID4 0x49 /* actually R/W
but we don't write to it */
/* These are read/write */
#define ADM1025_REG_TEST 0x15 /* unused */
#define ADM1025_REG_2_5V_HIGH 0x2B /* not used directly, see */
#define ADM1025_REG_2_5V_LOW 0x2C /* ADM1025_REG_IN_MAX(nr) and */
#define ADM1025_REG_VCCP1_HIGH 0x2D /* ADM1025_REG_IN_MIN(nr) below */
#define ADM1025_REG_VCCP1_LOW 0x2E
#define ADM1025_REG_3_3V_HIGH 0x2F
#define ADM1025_REG_3_3V_LOW 0x30
#define ADM1025_REG_5V_HIGH 0x31
#define ADM1025_REG_5V_LOW 0x32
#define ADM1025_REG_12V_HIGH 0x33
#define ADM1025_REG_12V_LOW 0x34
#define ADM1025_REG_VCC_HIGH 0x35
#define ADM1025_REG_VCC_LOW 0x36
#define ADM1025_REG_RTEMP_HIGH 0x37
#define ADM1025_REG_RTEMP_LOW 0x38
#define ADM1025_REG_TEMP_HIGH 0x39
#define ADM1025_REG_TEMP_LOW 0x3A
#define ADM1025_REG_CONFIG 0x40
/* Useful macros */
#define ADM1025_REG_IN(nr) (ADM1025_REG_2_5V + (nr))
#define ADM1025_REG_IN_MAX(nr) (ADM1025_REG_2_5V_HIGH + (nr) * 2)
#define ADM1025_REG_IN_MIN(nr) (ADM1025_REG_2_5V_LOW + (nr) * 2)
/* Conversions. Rounding and limit checking is only done on the TO_REG
variants. Note that you should be a bit careful with which arguments
these macros are called: arguments may be evaluated more than once.
Fixing this is just not worth it. */
#define IN_TO_REG(val) (SENSORS_LIMIT(((val) & 0xff),0,255))
#define IN_FROM_REG(val) (val)
#define TEMP_FROM_REG(val) (((val)>=0x80?(val)-0x100:(val))*10)
#define TEMP_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-5)/10):\
((val)+5)/10),0,255)
#define ALARMS_FROM_REG(val) (val)
/* Initial limits */
#define ADM1025_INIT_IN 192
#define ADM1025_INIT_IN_MIN (ADM1025_INIT_IN * 90 / 100)
#define ADM1025_INIT_IN_MAX (ADM1025_INIT_IN * 110 / 100)
#define ADM1025_INIT_RTEMP_MAX 600
#define ADM1025_INIT_RTEMP_MIN 0
#define ADM1025_INIT_TEMP_MAX 600
#define ADM1025_INIT_TEMP_MIN 0
/* For each registered ADM1025, we need to keep some data in memory. That
data is pointed to by adm1025_list[NR]->data. The structure itself is
dynamically allocated, at the same time when a new adm1025 client is
allocated. */
struct adm1025_data {
int sysctl_id;
enum chips type;
struct semaphore update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
u8 in[6]; /* Register value */
u8 in_max[6]; /* Register value */
u8 in_min[6]; /* Register value */
u8 rtemp; /* Register value */
u8 rtemp_max; /* Register value */
u8 rtemp_min; /* Register value */
u8 temp; /* Register value */
u8 temp_max; /* Register value */
u8 temp_min; /* Register value */
u16 alarms; /* Register encoding, combined */
u8 analog_out; /* Register value */
u8 vid; /* Register value combined */
u8 vrm;
};
static int adm1025_attach_adapter(struct i2c_adapter *adapter);
static int adm1025_detect(struct i2c_adapter *adapter, int address,
unsigned short flags, int kind);
static int adm1025_detach_client(struct i2c_client *client);
static void adm1025_update_client(struct i2c_client *client);
static void adm1025_init_client(struct i2c_client *client);
static void adm1025_in(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_remote_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_alarms(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
/*static void adm1025_analog_out(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag,
long *results);*/
static void adm1025_vid(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
static void adm1025_vrm(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
/* I choose here for semi-static ADM1025 allocation. Complete dynamic
allocation could also be used; the code needed for this would probably
take more memory than the datastructure takes now. */
static int adm1025_id = 0;
static struct i2c_driver adm1025_driver = {
.owner = THIS_MODULE,
.name = "ADM1025 sensor driver",
.id = I2C_DRIVERID_ADM1025,
.flags = I2C_DF_NOTIFY,
.attach_adapter = adm1025_attach_adapter,
.detach_client = adm1025_detach_client,
};
/* The /proc/sys entries */
/* -- SENSORS SYSCTL START -- */
#define ADM1025_SYSCTL_IN0 1000 /* Volts * 100 */
#define ADM1025_SYSCTL_IN1 1001
#define ADM1025_SYSCTL_IN2 1002
#define ADM1025_SYSCTL_IN3 1003
#define ADM1025_SYSCTL_IN4 1004
#define ADM1025_SYSCTL_IN5 1005
#define ADM1025_SYSCTL_RTEMP 1251 /* Degrees Celcius * 10 */
#define ADM1025_SYSCTL_TEMP 1250
#define ADM1025_SYSCTL_ALARMS 2001 /* bitvector */
#define ADM1025_SYSCTL_VID 2003 /* Volts * 1000 */
#define ADM1025_SYSCTL_VRM 2004
#define ADM1025_ALARM_IN0 0x0001
#define ADM1025_ALARM_IN1 0x0002
#define ADM1025_ALARM_IN2 0x0004
#define ADM1025_ALARM_IN3 0x0008
#define ADM1025_ALARM_IN4 0x0100
#define ADM1025_ALARM_IN5 0x0200
#define ADM1025_ALARM_RTEMP 0x0020
#define ADM1025_ALARM_TEMP 0x0010
/* -- SENSORS SYSCTL END -- */
/* These files are created for each detected ADM1025. This is just a template;
though at first sight, you might think we could use a statically
allocated list, we need some way to get back to the parent - which
is done through one of the 'extra' fields which are initialized
when a new copy is allocated. */
static ctl_table adm1025_dir_table_template[] = {
{ADM1025_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_in},
{ADM1025_SYSCTL_RTEMP, "temp2", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_remote_temp},
{ADM1025_SYSCTL_TEMP, "temp1", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_temp},
{ADM1025_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_alarms},
{ADM1025_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_vid},
{ADM1025_SYSCTL_VRM, "vrm", NULL, 0, 0644, NULL, &i2c_proc_real,
&i2c_sysctl_real, NULL, &adm1025_vrm},
{0}
};
static int adm1025_attach_adapter(struct i2c_adapter *adapter)
{
return i2c_detect(adapter, &addr_data, adm1025_detect);
}
static int adm1025_detect(struct i2c_adapter *adapter, int address,
unsigned short flags, int kind)
{
int i;
struct i2c_client *new_client;
struct adm1025_data *data;
int err = 0;
const char *type_name = "";
const char *client_name = "";
/* Make sure we aren't probing the ISA bus!! This is just a safety check
at this moment; i2c_detect really won't call us. */
#ifdef DEBUG
if (i2c_is_isa_adapter(adapter)) {
printk
("adm1025.o: adm1025_detect called for an ISA bus adapter?!?\n");
return 0;
}
#endif
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
goto ERROR0;
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access adm1025_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct adm1025_data),
GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct adm1025_data *) (new_client + 1);
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
new_client->driver = &adm1025_driver;
new_client->flags = 0;
/* Now, we do the remaining detection. */
if (kind < 0) {
if((i2c_smbus_read_byte_data(new_client,ADM1025_REG_CONFIG) & 0x80) != 0x00)
goto ERROR1;
}
/* Determine the chip type. */
if (kind <= 0) {
i = i2c_smbus_read_byte_data(new_client, ADM1025_REG_COMPANY_ID);
if (((i2c_smbus_read_byte_data(new_client, ADM1025_REG_DIE_REV) & 0xf0) = 0x20)
&& ((i = 0x41) /* ADM1025 */
|| (i = 0xA1))) /* NE1619 */
kind = adm1025;
else {
if (kind = 0)
printk
("adm1025.o: Ignoring 'force' parameter for unknown chip at "
"adapter %d, address 0x%02x\n",
i2c_adapter_id(adapter), address);
goto ERROR1;
}
}
if (kind = adm1025) {
type_name = "adm1025";
client_name = "ADM1025 chip";
} else {
#ifdef DEBUG
printk("adm1025.o: Internal error: unknown kind (%d)?!?",
kind);
#endif
goto ERROR1;
}
/* Fill in the remaining client fields and put it into the global list */
strcpy(new_client->name, client_name);
data->type = kind;
new_client->id = adm1025_id++;
data->valid = 0;
init_MUTEX(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
goto ERROR3;
/* Register a new directory entry with module sensors */
if ((i = i2c_register_entry(new_client,
type_name,
adm1025_dir_table_template)) < 0) {
err = i;
goto ERROR4;
}
data->sysctl_id = i;
/* Initialize the ADM1025 chip */
adm1025_init_client(new_client);
return 0;
/* OK, this is not exactly good programming practice, usually. But it is
very code-efficient in this case. */
ERROR4:
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
ERROR0:
return err;
}
static int adm1025_detach_client(struct i2c_client *client)
{
int err;
i2c_deregister_entry(((struct adm1025_data *) (client->data))->
sysctl_id);
if ((err = i2c_detach_client(client))) {
printk
("adm1025.o: Client deregistration failed, client not detached.\n");
return err;
}
kfree(client);
return 0;
}
/* Called when we have found a new ADM1025. It should set limits, etc. */
static void adm1025_init_client(struct i2c_client *client)
{
struct adm1025_data *data = client->data;
u8 reg, nr;
data->vrm = DEFAULT_VRM;
/* Restore power-up default values (configuration and status
registers). This makes some other initializations
unnecessary. Set the chip in standby mode until the
limits are properly set. Note that we take great care not to
change the bits 1-6 of the configuration register, since
they hold data we want to preserve. */
reg = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
i2c_smbus_write_byte_data(client, ADM1025_REG_CONFIG, 0x80);
for (nr = 0; nr < 6; nr++) {
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(nr),
data->in_min[nr] = IN_TO_REG(ADM1025_INIT_IN_MIN));
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(nr),
data->in_max[nr] = IN_TO_REG(ADM1025_INIT_IN_MAX));
}
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_HIGH,
data->rtemp_max=TEMP_TO_REG(ADM1025_INIT_RTEMP_MAX));
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_LOW,
data->rtemp_min=TEMP_TO_REG(ADM1025_INIT_RTEMP_MIN));
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH,
data->temp_max=TEMP_TO_REG(ADM1025_INIT_TEMP_MAX));
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW,
data->temp_min=TEMP_TO_REG(ADM1025_INIT_TEMP_MIN));
/* Restore configuration and start monitoring */
i2c_smbus_write_byte_data(client, ADM1025_REG_CONFIG, (reg|0x01)&0x7F);
}
static void adm1025_update_client(struct i2c_client *client)
{
struct adm1025_data *data = client->data;
u8 nr;
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2)
|| (jiffies < data->last_updated) || !data->valid) {
#ifdef DEBUG
printk("Starting adm1025 update\n");
#endif
/* Voltages */
for (nr = 0; nr < 6; nr++) {
data->in[nr] = i2c_smbus_read_byte_data(client, ADM1025_REG_IN(nr));
/* data->in_min[nr] = i2c_smbus_read_byte_data(client, ADM1025_REG_IN_MIN(nr));
data->in_max[nr] = i2c_smbus_read_byte_data(client, ADM1025_REG_IN_MAX(nr));*/
}
/* Temperatures */
data->temp = i2c_smbus_read_byte_data(client, ADM1025_REG_TEMP);
data->rtemp = i2c_smbus_read_byte_data(client, ADM1025_REG_RTEMP);
/* data->temp_max = i2c_smbus_read_byte_data(client, ADM1025_REG_TEMP_HIGH);
data->temp_min = i2c_smbus_read_byte_data(client, ADM1025_REG_TEMP_LOW);
data->rtemp_max = i2c_smbus_read_byte_data(client, ADM1025_REG_RTEMP_HIGH);
data->rtemp_min = i2c_smbus_read_byte_data(client, ADM1025_REG_RTEMP_LOW);*/
/* VID */
data->vid = (i2c_smbus_read_byte_data(client, ADM1025_REG_VID) & 0x0f)
+ ((i2c_smbus_read_byte_data(client, ADM1025_REG_VID4) & 0x01) << 4);
/* Alarms */
data->alarms = (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS1) & 0x3f)
+ ((i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS2) & 0x43) << 8);
data->last_updated = jiffies;
data->valid = 1;
}
up(&data->update_lock);
}
/* The next few functions are the call-back functions of the /proc/sys and
sysctl files. Which function is used is defined in the ctl_table in
the extra1 field.
Each function must return the magnitude (power of 10 to divide the data
with) if it is called with operation=SENSORS_PROC_REAL_INFO. It must
put a maximum of *nrels elements in results reflecting the data of this
file, and set *nrels to the number it actually put in it, if operation=
SENSORS_PROC_REAL_READ. Finally, it must get upto *nrels elements from
results and write them to the chip, if operations=SENSORS_PROC_REAL_WRITE.
Note that on SENSORS_PROC_REAL_READ, I do not check whether results is
large enough (by checking the incoming value of *nrels). This is not very
good practice, but as long as you put less than about 5 values in results,
you can assume it is large enough. */
void adm1025_in(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
int scales[6] = { 250, 225, 330, 500, 1200, 330 };
struct adm1025_data *data = client->data;
int nr = ctl_name - ADM1025_SYSCTL_IN0;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 2;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = IN_FROM_REG(data->in_min[nr]) * scales[nr] / 192;
results[1] = IN_FROM_REG(data->in_max[nr]) * scales[nr] / 192;
results[2] = IN_FROM_REG(data->in[nr]) * scales[nr] / 192;
*nrels_mag = 3;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1) {
data->in_min[nr] = IN_TO_REG((results[0] * 192) / scales[nr]);
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(nr),
data->in_min[nr]);
}
if (*nrels_mag >= 2) {
data->in_max[nr] = IN_TO_REG((results[1] * 192) / scales[nr]);
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(nr),
data->in_max[nr]);
}
}
}
void adm1025_temp(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 1;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = TEMP_FROM_REG(data->temp_max);
results[1] = TEMP_FROM_REG(data->temp_min);
results[2] = TEMP_FROM_REG(data->temp);
*nrels_mag = 3;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1) {
data->temp_max = TEMP_TO_REG(results[0]);
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH,
data->temp_max);
}
if (*nrels_mag >= 2) {
data->temp_min = TEMP_TO_REG(results[1]);
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW,
data->temp_min);
}
}
}
void adm1025_remote_temp(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 1;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = TEMP_FROM_REG(data->rtemp_max);
results[1] = TEMP_FROM_REG(data->rtemp_min);
results[2] = TEMP_FROM_REG(data->rtemp);
*nrels_mag = 3;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1) {
data->rtemp_max = TEMP_TO_REG(results[0]);
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_HIGH,
data->rtemp_max);
}
if (*nrels_mag >= 2) {
data->rtemp_min = TEMP_TO_REG(results[1]);
i2c_smbus_write_byte_data(client, ADM1025_REG_RTEMP_LOW,
data->rtemp_min);
}
}
}
void adm1025_alarms(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 0;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = ALARMS_FROM_REG(data->alarms);
*nrels_mag = 1;
}
}
void adm1025_vid(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 3;
else if (operation = SENSORS_PROC_REAL_READ) {
adm1025_update_client(client);
results[0] = vid_from_reg(data->vid, data->vrm);
*nrels_mag = 1;
}
}
void adm1025_vrm(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results)
{
struct adm1025_data *data = client->data;
if (operation = SENSORS_PROC_REAL_INFO)
*nrels_mag = 1;
else if (operation = SENSORS_PROC_REAL_READ) {
results[0] = data->vrm;
*nrels_mag = 1;
} else if (operation = SENSORS_PROC_REAL_WRITE) {
if (*nrels_mag >= 1)
data->vrm = results[0];
}
}
static int __init sm_adm1025_init(void)
{
printk("adm1025.o version %s (%s)\n", LM_VERSION, LM_DATE);
return i2c_add_driver(&adm1025_driver);
}
static void __exit sm_adm1025_exit(void)
{
i2c_del_driver(&adm1025_driver);
}
MODULE_AUTHOR("Chen-Yuan Wu <[email protected]>"
" and Jean Delvare <[email protected]>");
MODULE_DESCRIPTION("ADM1025 driver");
module_init(sm_adm1025_init);
module_exit(sm_adm1025_exit);Dne po 28. ?ervence 2003 22:38 jste napsal(a):
Quoted 9 lines
Quoted 5 lines
after reinstall ne1619 driver are values of min/max voltage 0.
e.g.
+2.5V: +2.48 V (min = +0.00 V, max = +0.00 V)
My bad, fixed in the attached version. Can you please try again? (No need rebooting this time, just unload the old module and load the new one instead.)
problem solved ...
Quoted 4 lines
Quoted 1 line
btw: speed of fan can show
lm_sensorswith ne1619 too?Negative on that, it's a 6-voltage 2-temperature chip, period. No fan monitoring. I'm surprised too, but that's how it it.
I'm not sure if I understand you. Intel sw can show fan speed, e.g.
Sensor Name System Fan 1 Current Value 3 840 Upper Threshold not applicable Lower Threshold 500.
Current driver cannot show that or something else?
Quoted 13 lines
Quoted 5 lines
OK, current values are:
alarms 0
in0 0.00 0.00 2.48
in1 1.40 1.55 1.46Quoted 8 lines
in2 0.00 0.00 3.33 in3 0.00 0.00 5.02 in4 0.00 0.00 0.00 in5 0.00 0.00 3.26temp1 0.0 0.0 43.0
temp2 0.0 0.0 43.0
vid 1.500
vrm 9.0
btw:
hippopotamus:/proc/sys/dev/sensors/adm1025-i2c-0-2d# ls alarms in0 in1 in2 in3 in4 in5 temp1 temp1 temp2 vid vrm hippopotamus:/proc/sys/dev/sensors/adm1025-i2c-0-2d# cat temp1 cat: temp1: nen? adres??em (= temp1 in't directory ...) temp2 is normal proc file with values ... there are two files "temp1" in this directory, but i didn't reboot ...
Quoted 5 lines
Bad of course because of the bug... Oh, please provide the output of "sensors" too (almost similar, but much more pleasant to read, isn't it).
Thanks!
you're welcome ...
adm1025-i2c-0-2d
Adapter: SMBus I801 adapter at efa0
Algorithm: Non-I2C SMBus adapter
+2.5V: +2.48 V (min = +2.23 V, max = +2.74 V) VCore: +1.46 V (min = +1.40 V, max = +1.55 V) +3.3V: +3.33 V (min = +2.95 V, max = +3.62 V) +5V: +5.02 V (min = +4.47 V, max = +5.49 V) +12V: +0.00 V (min = +10.75 V, max = +13.18 V) VCC: +3.26 V (min = +2.95 V, max = +3.62 V) SYS Temp: +43.0?C (min = +0?C, max = +60?C) CPU Temp: +42.0?C (min = +0?C, max = +60?C) vid: +1.50 V
Signature · 1 line
Ondrej Cecak
Quoted 6 lines
Quoted 4 lines
My bad, fixed in the attached version. Can you please try again? (No need rebooting this time, just unload the old module and load the new one instead.)
problem solved ...
Great.
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
btw: speed of fan can show
lm_sensorswith ne1619 too?Negative on that, it's a 6-voltage 2-temperature chip, period. No fan monitoring. I'm surprised too, but that's how it it.
Quoted 7 lines
I'm not sure if I understand you. Intel sw can show fan speed, e.g.
Sensor Name System Fan 1 Current Value 3 840 Upper Threshold not applicable Lower Threshold 500.Current driver cannot show that or something else?
Not the driver, but the *chipset* doesn't even know about them. Don't hit me! I'm only the messenger ;)
Intel must get their information from somewhere else. Possibilities are:
another bus driver we don't support yet (unlikely), another chip on the first bus (unlikely again, the only unknown one is that thing at 0x44 and I still believe it looks like an EEPROM; I could be wrong of course; does the fan speed value sometimes change with that Linux software? if yes the data at 0x44 would have to move the same way too, and you say it didn't) or non-I2C chip (could be ACPI; is your system ACPI-compliant? did you ever try enabling ACPI in your kernel, using the bug ACPI patch?)
Quoted 8 lines
btw:
hippopotamus:/proc/sys/dev/sensors/adm1025-i2c-0-2d# ls alarms in0 in1 in2 in3 in4 in5 temp1 temp1 temp2 vid vrm hippopotamus:/proc/sys/dev/sensors/adm1025-i2c-0-2d# cat temp1 cat: temp1: nen? adres??em (= temp1 in't directory ...) temp2 is normal proc file with values ... there are two files "temp1" in this directory, but i didn't reboot ...
I think I remember something similar some times ago (see:
http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticket85) but it is supposed to be fixed. Just in case, is any part of the I2C subsystem or device drivers hard-compiled into your kernel?
Quoted 2 lines
(later) this problem solved reboot system ... sorry for useless messages :o(
Not useless at all. I don't like the idea you had to reboot your system to get rid of the problem. Didn't you forget to unload the old module before reloading the new one?
I'd like you to try unloading the adm1025 module, and check in /proc if the entries have really gone. Then reload it and check if the entries are back for good, and one of each kind only. If you can reproduce the problem, we'll try to fix it.
Quoted 12 lines
adm1025-i2c-0-2d
Adapter: SMBus I801 adapter at efa0
Algorithm: Non-I2C SMBus adapter+2.5V: +2.48 V (min = +2.23 V, max = +2.74 V) VCore: +1.46 V (min = +1.40 V, max = +1.55 V) +3.3V: +3.33 V (min = +2.95 V, max = +3.62 V) +5V: +5.02 V (min = +4.47 V, max = +5.49 V) +12V: +0.00 V (min = +10.75 V, max = +13.18 V) VCC: +3.26 V (min = +2.95 V, max = +3.62 V) SYS Temp: +43.0?C (min = +0?C, max = +60?C) CPU Temp: +42.0?C (min = +0?C, max = +60?C) vid: +1.50 V
The limits are still a bit too low, probably a common rounding issue, I'll take a look at it tomorrow (and probably ask you to test then, if you don't mind).
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Dne po 28. cervence 2003 23:24 jste napsal(a):
Quoted 16 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
btw: speed of fan can show
lm_sensorswith ne1619 too?Negative on that, it's a 6-voltage 2-temperature chip, period. No fan monitoring. I'm surprised too, but that's how it it.
Quoted 7 lines
I'm not sure if I understand you. Intel sw can show fan speed, e.g.
Sensor Name System Fan 1 Current Value 3 840 Upper Threshold not applicable Lower Threshold 500.Current driver cannot show that or something else?
Not the driver, but the *chipset* doesn't even know about them. Don't hit me! I'm only the messenger ;)
Quoted 9 lines
Intel must get their information from somewhere else. Possibilities are:
another bus driver we don't support yet (unlikely), another chip on the first bus (unlikely again, the only unknown one is that thing at0x44and I still believe it looks like an EEPROM; I could be wrong of course; does the fan speed value sometimes change with that Linux software? if yes the data at0x44would have to move the same way too, and you say it didn't) or non-I2C chip (could be ACPI; is your system ACPI-compliant? did you ever try enabling ACPI in your kernel, using the bug ACPI patch?)
all right, I don't know situation about sensors, chips and ... fan speed isn't important value, temperature of CPU was my problem ;-)
fan speed isn't constantly, but data at 0x44 is.
ACPI from current Marcelo's kernel (2.4.21) don't work, I'm curious to new ACPI in kernel 2.4.x (maybe 22, but evidently 23) ...
Quoted 9 lines
Quoted 8 lines
btw:
hippopotamus:/proc/sys/dev/sensors/adm1025-i2c-0-2d# ls alarms in0 in1 in2 in3 in4 in5 temp1 temp1 temp2 vid vrm hippopotamus:/proc/sys/dev/sensors/adm1025-i2c-0-2d# cat temp1 cat: temp1: nen? adres??em (= temp1 in't directory ...) temp2 is normal proc file with values ... there are two files "temp1" in this directory, but i didn't reboot ...
Quoted 4 lines
I think I remember something similar some times ago (see:
http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticket85) but it is supposed to be fixed. Just in case, is any part of the I2C subsystem or device drivers hard-compiled into your kernel?
no, just modules.
Quoted 6 lines
Quoted 2 lines
(later) this problem solved reboot system ... sorry for useless messages :o(
Not useless at all. I don't like the idea you had to reboot your system to get rid of the problem. Didn't you forget to unload the old module before reloading the new one?
You're right, this "windows reboot tactics" are bad, but I had to reboot to windows, because I had to find something in windows closed source program.
Quoted 4 lines
I'd like you to try unloading the adm1025 module, and check in /proc if the entries have really gone. Then reload it and check if the entries are back for good, and one of each kind only. If you can reproduce the problem, we'll try to fix it.
It works perfectly. Maybe I made mistake, becase ran gkrellm made Oops ... I detected it after I mailed you.
Quoted 13 lines
Quoted 12 lines
adm1025-i2c-0-2d
Adapter: SMBus I801 adapter at efa0
Algorithm: Non-I2C SMBus adapter+2.5V: +2.48 V (min = +2.23 V, max = +2.74 V) VCore: +1.46 V (min = +1.40 V, max = +1.55 V) +3.3V: +3.33 V (min = +2.95 V, max = +3.62 V) +5V: +5.02 V (min = +4.47 V, max = +5.49 V) +12V: +0.00 V (min = +10.75 V, max = +13.18 V) VCC: +3.26 V (min = +2.95 V, max = +3.62 V) SYS Temp: +43.0?C (min = +0?C, max = +60?C) CPU Temp: +42.0?C (min = +0?C, max = +60?C) vid: +1.50 V
Quoted 3 lines
The limits are still a bit too low, probably a common rounding issue, I'll take a look at it tomorrow (and probably ask you to test then, if you don't mind).
with pleasure, but in Czech Republic is now 23:49 ;-))))
Signature · 1 line
Ondrej Cecak
Quoted 3 lines
ACPI from current Marcelo's kernel (2.4.21) don't work, I'm curious to new ACPI in kernel 2.4.x (maybe 22, but evidently 23) ...
The ACPI support in 2.4.x is really thin so far, you really have to use the ACPI patch if you want real support:
http://sourceforge.net/project/showfiles.php?group_id6832&release_id1534
That's what I use (well, the previous version actually) on my laptop.
Quoted 2 lines
It works perfectly. Maybe I made mistake, becase ran gkrellm made Oops ... I detected it after I mailed you.
Oops are at kernel level, so if gkrellm made oops, it's likely to be because of one of our drivers... Let us know if it happens again.
Quoted 5 lines
Quoted 3 lines
The limits are still a bit too low, probably a common rounding issue, I'll take a look at it tomorrow (and probably ask you to test then, if you don't mind).
with pleasure, but in Czech Republic is now 23:49 ;-))))
Was the same here, Czech Republic and France are in the same time zone :)
OK, I updated the driver. I would like you to checkout from CVS this time (because more than just one file was changed). You don't have to checkout i2c (but you are welcome to do so if you wish, since some bugs were fixed since 2.8.0 was released). Don't forget to run "ldconfig" after installation of lm_sensors, since I bumped the library revision. Also, you will want to manually update the sensors.conf file (I added various comments to the adm1025 section).
How to get CVS checkouts is described on our download page:
http://secure.netroedge.com/~lm78/download.html#cvs
If you can't use CVS for any reason, I can make a snapshot available to you as a simple tar.gz file.
Thanks for testing! This is very very appreciated :)
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/