* max1619
2005-05-19 6:24 max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` max1619 Alexey Fisher
` (22 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
> I made thiese driver in new module. What is next to do? It's testet
> with kernel 2.4.26 and didn't added laetes CVS. I'm redy to support
> thise driver and gona try to write savage driver (actualy i dont iven
> know why i need thees).
Well, please provide a patch against Linux 2.6.6-mm4. I'll review it and
if it's correct, we'll send it to Greg.
After that you'll need to provide user-space support and if possible
some docs. If you want to provide a 2.4 driver as well, this is welcome.
> And whan more quastion ... do yuo speek english only?
No, I speak French too, and can read German (but I can't pretend to
write it fluently).
> PS sensors-detect testet
Great :)
Thanks.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
2005-05-19 6:24 ` max1619 Jean Delvare
@ 2005-05-19 6:24 ` Alexey Fisher
2005-05-19 6:24 ` max1619 Jean Delvare
` (21 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Hi Jean,
I alredy made an user-space. am i need to send you all changet files or am i need to have acsess to CVS ?
About patch. Ok i do it but i dont know haw to do patch, im jast beginner.
Your help are needet by me.
Alexey mailto:fishor@gmx.net
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
2005-05-19 6:24 ` max1619 Jean Delvare
2005-05-19 6:24 ` max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` max1619 Alexey Fisher
` (20 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
> I alredy made an user-space. am i need to send you all changet files
> or am i need to have acsess to CVS ?
You would need to send a patch against CVS.
> About patch. Ok i do it but i dont know haw to do patch, im jast
> beginner. Your help are needet by me.
OK...
Basically you need to have two trees on your system, one with the
original files, one with the original files + your changes. Once you
have that and have ensured that your changes are correct, move to the
upper directory and use "diff -ruN" to generate the patch.
Complete example:
Say that you want to submit a patch against Linux 2.6.6-mm4. First get
the Linux 2.6.6 tree and untar it somewhere. In this example, I'll
suppose that you will untar it in ~/work.
So you have ~/work/linux-2.6.6.
Now, get the 2.6.6-mm4.bz2 patch and apply it:
cd ~/work/linux-2.6.6
bzcat /path/to/2.6.6-mm4.bz2 | patch -p1
At this point, I suggest you rename the directory:
cd ~/work
mv linux-2.6.6 linux-2.6.6-mm4
Now, duplicate the tree:
cd ~/work
cp -a linux-2.6.6-mm4 linux-2.6.6-mm4-max1619
After that, you can do all the changes you need in
linux-2.6.6-mm4-max1619. Test that it works as intended. Then you can
generate a patch and send it to us:
cd ~/work
diff -ruN linux-2.6.6-mm4 linux-2.6.6-mm4-max1619 > linux-2.6.6-mm4-max1619.diff
Same for the CVS repository. Check it out, duplicate the tree, do your
changes, generate a patch, and send it to us.
Thanks.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (2 preceding siblings ...)
2005-05-19 6:24 ` max1619 Jean Delvare
@ 2005-05-19 6:24 ` Alexey Fisher
2005-05-19 6:24 ` max1619 Alexey Fisher
` (19 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Jean, you may kill me, but i don't have an max6650.
Fan On or Off - it show the same speed.
and when i made "i2cset 0 0x1f 0x01 0x01" it went down to sleep...
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (3 preceding siblings ...)
2005-05-19 6:24 ` max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Alexey Fisher
2005-05-19 6:24 ` max1619 Alexey Fisher
` (18 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Hi Jean
this is CVS only. I'm not redy with kernel.
Do you hawe some think about C++ and about kernel?
I jast won to anderstend what i do.
Sanky
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm_sensors2-max1619.diff
Type: text/x-diff
Size: 25570 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040522/fd52b013/lm_sensors2-max1619.bin
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (4 preceding siblings ...)
2005-05-19 6:24 ` max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Alexey Fisher
2005-05-19 6:24 ` max1619 Alexey Fisher
` (17 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Hi Jean
> Not sure I get what you mean. At any rate, the Linux kernel is written
> in C and no C++ code is allowed. Just start from an existing driver, and
> it shouldn't be too hard to adapt the code for your MAX1619 chip.
I mean, i don't know C at all, i jas wont to lern it and it will be greate if
you have and can send me some DOC about C.
> + if (kind < 0)
> + {
> + u8 reg_config, reg_convrate;
> + reg_config = i2c_smbus_read_byte_data(new_client,
> + MAX1619_REG_R_CONFIG);
> + reg_convrate = i2c_smbus_read_byte_data(new_client,
> + MAX1619_REG_R_CONVRATE);
> +
> + if ((reg_config & 0x03) != 0x00 )
> + {
> You forgot to cgecj trhe conversion rate register . It has to be <> 0x07. You could use the status register as well, for which reg & 0x61
> should be 0.
Hear i'm not sure what you mean
if ((reg_config & 0x2A) != 0x00 || reg_convrate <= 0x07 || (reg_status &
0x61) != 0x00)
is it corect ?
> + i2c_smbus_write_byte_data(client, MAX1619_REG_W_CONVRATE,
> + 5); /* 2 Hz */
> + config = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONFIG);
> + if (config & 0x40)
> + i2c_smbus_write_byte_data(client, MAX1619_REG_W_CONFIG,
> + config & 0x0C); /* run */
> +}
>
> This doesn't preserve configuration bits. You should write back config &
> 0xBF.
I can't yus 0xbf wile it bringing up OVERT output, it's mean HYST and CRIT
can't do any think. For max1619 0x9f , this preserve and doesn't have OVERT
bit.
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (5 preceding siblings ...)
2005-05-19 6:24 ` max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Alexey Fisher
2005-05-19 6:24 ` max1619 Alexey Fisher
` (16 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Hi Jean
new diff is ready
some more quastions:
" || " mean "and"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm_sensors2-max1619.diff
Type: text/x-diff
Size: 23840 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040523/10b48692/lm_sensors2-max1619.bin
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (6 preceding siblings ...)
2005-05-19 6:24 ` max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Alexey Fisher
2005-05-19 6:24 ` max1619 Jean Delvare
` (15 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Hi Jean
> By the way, did
> you test your 2.4 driver?
yes i did and i tested new CVS
linux 2.6.6-mm5 is testet too.
here is two patches for linux kernel and for CVS
Thank you : - )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linux-2.6.6-mm5-max1619.diff
Type: text/x-diff
Size: 12917 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040525/43054f65/linux-2.6.6-mm5-max1619.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm_sensors2-max1619-prog.diff
Type: text/x-diff
Size: 1187 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040525/43054f65/lm_sensors2-max1619-prog.bin
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (7 preceding siblings ...)
2005-05-19 6:24 ` max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` max1619 Jean Delvare
` (14 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Hi Alexey,
> I mean, i don't know C at all, i jas wont to lern it and it will be
> greate if you have and can send me some DOC about C.
Sorry, I don't have such docs. I leant C partly in high school, but
mostly by reading existing code and discussing with people.
Frankly, if you never did C before and were already able to adapt driver
code to write your own driver, it's impressive. Keep it this way :)
> > You forgot to cgecj trhe conversion rate register . It has to be <> > 0x07. You could use the status register as well, for which reg &
> > 0x61 should be 0.
>
> Hear i'm not sure what you mean
Maybe because I completely mispelled my first sentence and didn't even
notice it? ;)
> if ((reg_config & 0x2A) != 0x00 || reg_convrate <= 0x07 ||
> (reg_status & 0x61) != 0x00)
>
> is it corect ?
Note quite. I'd say:
if ((reg_config & 0x03) != 0x00 || reg_convrate > 0x07
|| (reg_status & 0x61) != 0x00)
> > + config = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONFIG);
> > + if (config & 0x40)
> > + i2c_smbus_write_byte_data(client, MAX1619_REG_W_CONFIG,
> > + config & 0x0C); /* run */
> > +}
> >
> > This doesn't preserve configuration bits. You should write back
> > config & 0xBF.
>
> I can't yus 0xbf wile it bringing up OVERT output, it's mean HYST and
> CRIT can't do any think. For max1619 0x9f , this preserve and
> doesn't have OVERT bit.
Negative. Masking with 0xBF will *not* set bit 5 (POL). It will keep it
exactly the way it was. So, if the BIOS has changed that bit to match the
hardware setup, it won't be dropped.
Thanks.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (8 preceding siblings ...)
2005-05-19 6:24 ` max1619 Jean Delvare
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` max1619 Alexey Fisher
` (13 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
> Hi Jean
> this is CVS only. I'm not redy with kernel.
OK. My comments below.
> Do you hawe some think about C++ and about kernel?
> I jast won to anderstend what i do.
Not sure I get what you mean. At any rate, the Linux kernel is written
in C and no C++ code is allowed. Just start from an existing driver, and
it shouldn't be too hard to adapt the code for your MAX1619 chip.
diff -ruN lm_sensors2/doc/chips/max1619 lm_sensors/doc/chips/max1619
--- lm_sensors2/doc/chips/max1619 1970-01-01 01:00:00.000000000 +0100
+++ lm_sensors/doc/chips/max1619 2004-05-22 14:19:45.000000000 +0200
@@ -0,0 +1,73 @@
+Kernel driver `lm90.o'
+===========
You forgot to edit the header line!
+Supported chips:
+ * Maxim max1619
+ Prefix: `max1619'
+ Addresses scanned: I2C 0x4d
The MAX1619 supports 9 different addresses (same as the MAX1617).
+The different chipsets of the family are not strictly identical, although
+very similar. This driver doesn't handle any specific feature for now,
+but could if there ever was a need for it. For reference, here comes a
+non-exhaustive list of specific features:
This paragraph is irrelevant here, since your driver handles a single
chip.
+Additionally, there is a relative hysteresis value common to critical
+value. Remote hysteresis can be set from user-space.
The hysteresis value isn't common to anything, it's dedicated to the
remote temperature. Same goes for the critical limit.
All limits can be set (for all drivers) from user-space so mentioning it
here isn't particularly interesting.
+Chips 'max1619'
+
+LABEL LABEL CLASS COMPUTE CLASS MODE MAGN
+l_temp - - R- 0
+r_temp - - R- 0
+r_high r_temp r_temp RW 0
+r_low r_temp r-temp RW 0
+r_max r_temp r_temp RW 0
+r_hyst r_temp r_temp RW 0
+alarms - - R- 0
No, please use standard symbol names. temp1, temp2, temp2_max,
temp2_min, temp2_hyst, temp2_crit.
diff -ruN lm_sensors2/etc/sensors.conf.eg lm_sensors/etc/sensors.conf.eg
--- lm_sensors2/etc/sensors.conf.eg 2004-05-21 16:08:17.000000000 +0200
+++ lm_sensors/etc/sensors.conf.eg 2004-05-22 14:39:46.000000000 +0200
@@ -1718,6 +1718,26 @@
# should be higher than each of the high limits above
# set tcrit 85
+chip "max1619-*"
+
+ label l_temp "M/B Temp"
+ label r_temp "CPU Temp"
+ label r_low "CPU Low:"
+ label r_high "CPU High:"
+ label r_max "CPU Max:(Fan ON)"
+ label r_hyst "CPU Hyst:(Fan OFF)"
Labels for limits are never display, so I wouldn't bother setting them.
diff -ruN lm_sensors2/kernel/chips/max1619.c lm_sensors/kernel/chips/max1619.c
--- lm_sensors2/kernel/chips/max1619.c 1970-01-01 01:00:00.000000000 +0100
+++ lm_sensors/kernel/chips/max1619.c 2004-05-22 14:10:54.000000000 +0200
@@ -0,0 +1,561 @@
+/*
+ * max1619.c - Part of lm_sensors, Linux kernel modules for hardware
+ * monitoring
+ * Copyright (C) 2003-2004 Aleey Fisher <fishor@mail.ru>
You should mention the fact that you started from the lm90 driver.
+#ifndef I2C_DRIVERID_MAX1619
+#define I2C_DRIVERID_MAX1619 1049
+#endif
You don't really need an ID.
+static unsigned short normal_i2c[] = { 0x4d, SENSORS_I2C_END };
+static unsigned short normal_i2c_range[] = { SENSORS_I2C_END };
As said earlier, please support all address. You'll find the list in
adm1021.c.
+#define MAX1619_REG_R_MAN_ID 0xFE
+#define MAX1619_REG_R_CHIP_ID 0xFF
Please align constants using tabs, not white spaces.
+#define TEMP_FROM_REG(val) (val & 0x80 ? val-0x100 : val)
+#define TEMP_TO_REG(val) (val < 0 ? val+0x100 : val)
Your macros aren't safe. It's better to surround any use of the
parameters with parenthesis:
#define TEMP_FROM_REG(val) ((val) & 0x80 ? (val)-0x100 : (val))
#define TEMP_TO_REG(val) ((val) < 0 ? (val)+0x100 : (val))
+static struct i2c_driver max1619_driver = {
+ .owner = THIS_MODULE,
+ .name = "MAX1619 sensor driver",
+ .id = I2C_DRIVERID_MAX1619,
+ .flags = I2C_DF_NOTIFY,
+ .attach_adapter = max1619_attach_adapter,
+ .detach_client = max1619_detach_client
+};
Don't mention .id here, it's OK.
+/*
+ * Proc entries
+ * These files are created for each detected LM90.
+ */
Edit that comment!
+#define MAX1619_SYSCTL_LOCAL_TEMP 1200
+#define MAX1619_SYSCTL_REMOTE_TEMP 1201
+#define MAX1619_SYSCTL_REMOTE_CRYT 1205
+#define MAX1619_SYSCTL_REMOTE_TMAX 1207
+#define MAX1619_SYSCTL_REMOTE_THYST 1208
+#define MAX1619_SYSCTL_ALARMS 1210
You don't need all these. You need one SYSCTL value per file, not
symbol. You need one for temp1, one for temp2/min/max, one for
temp2_crit/hyst, and one for alarms.
+static ctl_table max1619_dir_table_template[] +{
+ {MAX1619_SYSCTL_LOCAL_TEMP, "l_temp", NULL, 0, 0644, NULL,
+ &i2c_proc_real, &i2c_sysctl_real, NULL, &max1619_local_temp},
This one can be read-only (444), since it doesn't have any limit.
+ {MAX1619_SYSCTL_ALARMS, "alarms", NULL, 0, 0644, NULL,
+ &i2c_proc_real, &i2c_sysctl_real, NULL, &max1619_alarms},
This one should be read-only as well.
+ if (kind < 0)
+ {
+ u8 reg_config, reg_convrate;
+ reg_config = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_CONFIG);
+ reg_convrate = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_CONVRATE);
+
+ if ((reg_config & 0x03) != 0x00 )
+ {
+#ifdef DEBUG
+ printk(KERN_DEBUG "max1619.o: Detection failed at 0x%02x.\n",
+ address);
+#endif
+ goto ERROR1;
+ }
+ }
You forgot to cgecj trhe conversion rate register . It has to be <0x07. You could use the status register as well, for which reg & 0x61
should be 0.
+ if (kind <= 0)
+ {
+ u8 man_id, chip_id;
+
+ man_id = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_MAN_ID);
+ chip_id = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_CHIP_ID);
+ if ((man_id & 0x4D) && (chip_id & 0x04))
+ {
+
+ kind = max1619;
+
+ }
+
+ }
You check is not correct. It should be (man_id = 0x4D) && (chip_id =
0x04).
+static void max1619_init_client(struct i2c_client *client)
+{
+ u8 config;
+
+ /*
+ * Start the conversions.
+ */
+
+ i2c_smbus_write_byte_data(client, MAX1619_REG_W_CONVRATE,
+ 5); /* 2 Hz */
+ config = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONFIG);
+ if (config & 0x40)
+ i2c_smbus_write_byte_data(client, MAX1619_REG_W_CONFIG,
+ config & 0x0C); /* run */
+}
This doesn't preserve configuration bits. You should write back config &
0xBF.
+static void max1619_remote_temp(struct i2c_client *client, int operation,
+ int ctl_name, int *nrels_mag, long *results)
+{
+ struct max1619_data *data = client->data;
+
+ if (operation = SENSORS_PROC_REAL_INFO)
+ *nrels_mag = 0; /* magnitude */
+ else if (operation = SENSORS_PROC_REAL_READ)
+ {
+ max1619_update_client(client);
+ results[0] = TEMP_FROM_REG(data->remote_temp);
+ *nrels_mag = 1;
+ }
+
+}
+
+static void max1619_remote_cryt(struct i2c_client *client, int operation,
+ int ctl_name, int *nrels_mag, long *results)
+{
+ struct max1619_data *data = client->data;
+
+ if (operation = SENSORS_PROC_REAL_INFO)
+ *nrels_mag = 0; /* magnitude */
+ else if (operation = SENSORS_PROC_REAL_READ)
+ {
+ max1619_update_client(client);
+ results[0] = TEMP_FROM_REG(data->remote_thigh);
+ results[1] = TEMP_FROM_REG(data->remote_tlow);
+ *nrels_mag = 2;
+ }
+ else if (operation = SENSORS_PROC_REAL_WRITE)
+ {
+ if (*nrels_mag >= 1)
+ {
+ data->remote_thigh = TEMP_TO_REG(results[0]);
+ i2c_smbus_write_byte_data(client,
+ MAX1619_REG_W_REMOTE_THIGH, data->remote_thigh);
+ }
+ if (*nrels_mag >= 2)
+ {
+ data->remote_tlow = TEMP_TO_REG(results[1]);
+ i2c_smbus_write_byte_data(client,
+ MAX1619_REG_W_REMOTE_TLOW,data->remote_tlow);
+
+ }
+ }
+}
Merge these two into a single one. The same file will return, in order,
high limit, low limit and current reading.
+static void max1619_remote_tmax(struct i2c_client *client, int operation,
+ int ctl_name, int *nrels_mag, long *results)
+{
+ struct max1619_data *data = client->data;
+
+ if (operation = SENSORS_PROC_REAL_INFO)
+ *nrels_mag = 0; /* magnitude */
+ else if (operation = SENSORS_PROC_REAL_READ)
+ {
+ max1619_update_client(client);
+ results[0] = TEMP_FROM_REG(data->remote_max);
+ *nrels_mag = 1;
+ }
+ else if (operation = SENSORS_PROC_REAL_WRITE)
+ {
+ if (*nrels_mag >= 1)
+ {
+ data->remote_max = TEMP_TO_REG(results[0]);
+ i2c_smbus_write_byte_data(client,
+ MAX1619_REG_W_REMOTE_TMAX,data->remote_max);
+ }
+ }
+}
+
+static void max1619_remote_thyst(struct i2c_client *client, int operation,
+ int ctl_name, int *nrels_mag, long *results)
+{
+ struct max1619_data *data = client->data;
+
+ if (operation = SENSORS_PROC_REAL_INFO)
+ *nrels_mag = 0; /* magnitude */
+ else if (operation = SENSORS_PROC_REAL_READ)
+ {
+ max1619_update_client(client);
+ results[0] = TEMP_FROM_REG(data->remote_hyst);
+ *nrels_mag = 1;
+ }
+ else if (operation = SENSORS_PROC_REAL_WRITE)
+ {
+ if (*nrels_mag >= 1 )
+ {
+ data->remote_hyst = TEMP_TO_REG(results[0]);
+ i2c_smbus_write_byte_data(client,
+ MAX1619_REG_W_REMOTE_THYST, data->remote_hyst);
+ }
+ }
+}
Merge these two ones as well. A single file should contain, in order,
the critical limit and the hysteresis value.
--- lm_sensors2/lib/chips.h 2004-05-17 21:02:31.000000000 +0200
+++ lm_sensors/lib/chips.h 2004-05-22 14:16:00.000000000 +0200
@@ -1855,6 +1855,18 @@
#define SENSORS_XEONTEMP_REMOTE_TEMP_OVER 56 /* RW */
#define SENSORS_XEONTEMP_ALARMS 81 /* R */
+/* MAX1619 chipp */
"chip", not "chipp".
diff -ruN lm_sensors2/prog/sensors/chips.c lm_sensors/prog/sensors/chips.c
--- lm_sensors2/prog/sensors/chips.c 2004-05-18 21:49:08.000000000 +0200
+++ lm_sensors/prog/sensors/chips.c 2004-05-22 14:17:42.000000000 +0200
(...)
+ if (!sensors_get_label_and_valid(*name, SENSORS_MAX1619_REMOTE_TEMP,
+ &label, &valid)
+ && !sensors_get_feature(*name, SENSORS_MAX1619_REMOTE_TEMP, &cur)
+ && !sensors_get_feature(*name, SENSORS_MAX1619_REMOTE_LOW, &low)
+ && !sensors_get_feature(*name, SENSORS_MAX1619_REMOTE_HIGH, &high))
+ {
+ if (valid) {
+ print_label(label, 10);
+ print_temp_info(cur, low, high, MINMAX, 1, 1);
Magnitude is 0 for these as well.
+ printf(" %s\n",
+ alarms&MAX1619_ALARM_REMOTE_OPEN?"DISCONNECT":
+ alarms&MAX1619_ALARM_REMOTE_OVERT?"FAN OFF":
OVERT belongs to the second set of limits (max/hyst) below.
OK, this is a really good job you did here :) Please correct everything
I mentioned and submit a new patch. I'll apply it to our CVS repository.
Thanks.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (9 preceding siblings ...)
2005-05-19 6:24 ` max1619 Jean Delvare
@ 2005-05-19 6:24 ` Alexey Fisher
2005-05-19 6:24 ` max1619 Jean Delvare
` (12 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
Hi Jean
I houp it's last one diff
if avery think is OK I begin with 2.6.6-mm4. Or i supou beginn with 2.6.6-mm5?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm_sensors2-max1619.diff
Type: text/x-diff
Size: 23781 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040524/099cbc06/lm_sensors2-max1619.bin
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (10 preceding siblings ...)
2005-05-19 6:24 ` max1619 Alexey Fisher
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` max1619 Jean Delvare
` (11 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
> I houp it's last one diff
I commited your work, with a few unimportant fixes (indentation and the
like). Thanks!
If you ever want to do any change to the driver, just send a patch based
on latest CVS.
> if avery think is OK I begin with 2.6.6-mm4. Or i supou beginn with
> 2.6.6-mm5?
Yes, 2.6.6-mm5 is fine.
It shouldn't be more difficult than for the 2.4 driver. By the way, did
you test your 2.4 driver?
Thanks.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (11 preceding siblings ...)
2005-05-19 6:24 ` max1619 Jean Delvare
@ 2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:25 ` max1619 Jean Delvare
` (10 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:24 UTC (permalink / raw)
To: lm-sensors
> Hi Jean
> new diff is ready
I'll review it.
> some more quastions:
> " || " mean "and"
No. || means "or". && means "and".
diff -ruN lm_sensors2/doc/chips/max1619 lm_sensors/doc/chips/max1619
--- lm_sensors2/doc/chips/max1619 1970-01-01 01:00:00.000000000 +0100
+++ lm_sensors/doc/chips/max1619 2004-05-23 13:03:21.000000000 +0200
+Module Parameters
+-----------------
Please insert the module parameters there. Just do "modinfo max1619" and
copy the parameter information here.
+LABEL FEATURE SYMBOL SYSCTL FILE:N
+temp1 SENSORS_MAX1619_LOCAL_TEMP temp1:3
N is 1 for this one.
+temp2 SENSORS_MAX1619_REMOTE_TEMP temp2:3
+temp2_max SENSORS_MAX1619_REMOTE_HIGH temp2_max_min:2
+temp2_min SENSORS_MAX1619_REMOTE_LOW temp2_max_min:1
temp2_max and temp2_min are in file temp2.
+temp2_crit SENSORS_MAX1619_REMOTE_HYST temp2_hyst_crit:1
+temp2_hyst SENSORS_MAX1619_REMOTE_MAX temp2_hyst_crit:1
N is 2 for temp2_hyst.
Please rename file temp2_hyst_crit to temp2_crit.
diff -ruN lm_sensors2/kernel/chips/max1619.c lm_sensors/kernel/chips/max1619.c
--- lm_sensors2/kernel/chips/max1619.c 1970-01-01 01:00:00.000000000 +0100
+++ lm_sensors/kernel/chips/max1619.c 2004-05-23 20:22:47.000000000 +0200
@@ -0,0 +1,525 @@
+/*
+ * max1619.c - Part of lm_sensors, Linux kernel modules for hardware
+ * monitoring
+ * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
+ * Alexey Fisher <fishor@mail.ru>
Hey, put your name first! You are the main author.
+/*
+ * Addresses to scan
+ */
+
+static unsigned short normal_i2c[] = { 0x18, 0x1a, 0x29, 0x2b,
+ 0x4c, 0x4e,0x4d, SENSORS_I2C_END };
+static unsigned short normal_i2c_range[] = { SENSORS_I2C_END };
This is not correct. The addresses are ranges for this driver, i.e not
only "0x18 and 0x1a" but "from 0x18 to 0x1a", which also includes 0x19.
Just use normal_i2c_range instead of normal_i2c, just as the adm1021
driver does.
+#define MAX1619_SYSCTL_REMOTE_CRIT_HYST 1202
Rename to MAX1619_SYSCTL_REMOTE_CRIT.
+static void max1619_remote_temp(struct i2c_client *client, int operation,
+ int ctl_name, int *nrels_mag, long *results)
+{
+ struct max1619_data *data = client->data;
+
+ if (operation = SENSORS_PROC_REAL_INFO)
+ *nrels_mag = 0; /* magnitude */
+ else if (operation = SENSORS_PROC_REAL_READ)
+ {
+ max1619_update_client(client);
+ results[0] = TEMP_FROM_REG(data->remote_temp);
+ results[1] = TEMP_FROM_REG(data->remote_low);
+ results[2] = TEMP_FROM_REG(data->remote_high);
+ *nrels_mag = 3;
+ }
Order is not correct. Must be high, low and current temperature, in that
order.
+ else if (operation = SENSORS_PROC_REAL_WRITE)
+ {
+ if (*nrels_mag >= 1)
+ {
+ data->remote_low = TEMP_TO_REG(results[1]);
+ i2c_smbus_write_byte_data(client,
+ MAX1619_REG_W_REMOTE_TLOW, data->remote_low);
+ }
+ if (*nrels_mag >= 2)
+ {
+ data->remote_high = TEMP_TO_REG(results[2]);
+ i2c_smbus_write_byte_data(client,
+ MAX1619_REG_W_REMOTE_THIGH,data->remote_high);
+
+ }
+ }
So same here: high first, low then.
And this is results[0] and results[1], not [1] and [2].
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>
+ Alexey Fisher <fishor@mail.ru>");
Same as above, put your name first.
+MODULE_DESCRIPTION("MAX1619 sensor driver");
+MODULE_LICENSE("GPL");
--- lm_sensors2/lib/chips.c 2004-05-17 20:36:31.000000000 +0200
+++ lm_sensors/lib/chips.c 2004-05-23 19:56:17.000000000 +0200
+ { SENSORS_MAX1619_REMOTE_TEMP, "temp2",
+ NOMAP, NOMAP,
+ R, MAX1619_SYSCTL_REMOTE_TEMP, VALUE(1), 0 },
+ { SENSORS_MAX1619_REMOTE_HIGH, "temp2_min",
+ NOMAP,NOMAP,
+ RW, MAX1619_SYSCTL_REMOTE_TEMP, VALUE(2), 0 },
+ { SENSORS_MAX1619_REMOTE_LOW, "temp2_max",
+ NOMAP, NOMAP,
+ RW, MAX1619_SYSCTL_REMOTE_TEMP, VALUE(3), 0 },
VALUE(N) are not correct, same change as in the driver is needed: max
first, min second, current reading last.
Everything else is just fine :) Congratulations.
I guess that your next patch should be OK and I'll be able to apply it.
Thanks!
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (12 preceding siblings ...)
2005-05-19 6:24 ` max1619 Jean Delvare
@ 2005-05-19 6:25 ` Jean Delvare
2005-05-19 6:25 ` max1619 Jean Delvare
` (9 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
> > +show_temp(temp_input1, TEMP_FROM_REG);
> > +show_temp(temp_input2, TEMP_FROM_REG);
> > +show_temp(temp_low2, TEMP_FROM_REG);
> > +show_temp(temp_high2, TEMP_FROM_REG);
> > +show_temp(temp_crit2, TEMP_FROM_REG);
> > +show_temp(temp_hyst2, TEMP_FROM_REG);
> >
> > TEMP_FROM_REG doesn't have to be passed by parameter, since it's
> > always the same.
>
> Jaen, I'm not sure what you mean. If you about "temp_hyst2", in these
> driverer hyst is chenchebl, not always the same.
What I mean is that you could avoid passing the converter as a
parameter:
+#define show_temp(value) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+ struct max1619_data *data = max1619_update_device(dev); \
+ return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \
+}
+show_temp(temp_input1);
+show_temp(temp_input2);
+show_temp(temp_low2);
+show_temp(temp_high2);
+show_temp(temp_crit2);
+show_temp(temp_hyst2);
Because all the files use the same converter (TEMP_FROM_REG).
> Actioly i dont know who is Greg. Am i can finde his Email in
> documentation ?
Greg Kroah-Hartman (aka Greg KH) is the person responsible (among
several over things) of the I2C subsystem in Linux 2.6. He was in CC: in
my previous post. And yes, you will find his contact information several
times in both CREDITS and MAINTAINERS files.
Thanks.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (13 preceding siblings ...)
2005-05-19 6:25 ` max1619 Jean Delvare
@ 2005-05-19 6:25 ` Jean Delvare
2005-05-19 6:25 ` max1619 Alexey Fisher
` (8 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
> here is two patches for linux kernel and for CVS
I've applied the CVS patch. I changed "temp2_hyst" to "temp2_crit_hyst"
though. In 2.6, hysteresis files have to reflect what they are an
hysteresis for.
About the linux kernel patch now:
diff -ruN linux-2.6.6-mm5/drivers/i2c/chips/Kconfig linux-2.6.6-mm5-max1619/drivers/i2c/chips/Kconfig
--- linux-2.6.6-mm5/drivers/i2c/chips/Kconfig 2004-05-25 08:51:38.000000000 +0200
+++ linux-2.6.6-mm5-max1619/drivers/i2c/chips/Kconfig 2004-05-25 09:01:53.000000000 +0200
+config SENSORS_MAX1619
+ tristate "Maxim MAX1619 sensor chip"
+ depends on I2C
depends on I2C && EXPERIMENTAL
diff -ruN linux-2.6.6-mm5/drivers/i2c/chips/max1619.c linux-2.6.6-mm5-max1619/drivers/i2c/chips/max1619.c
--- linux-2.6.6-mm5/drivers/i2c/chips/max1619.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.6-mm5-max1619/drivers/i2c/chips/max1619.c 2004-05-25 09:19:28.000000000 +0200
+ * max1619.c - Part of lm_sensors, Linux kernel modules for hardware
+ * monitoring
+ * Copyright (C) 2003-2004 Alexey Fisher <fishor@mail.ru>
+ * Jean Delvare <khali@linux-fr.org>
Please align "monitoring" on "Part" and "Jean" on "Alexey", using spaces.
+ * Based on the lm90 driver. The MAX1619 is a sensor chip made by Maxim .
+ * It reports up to two temperatures (its own plus up to
+ * one external one) . Complete datasheet can be
+ * obtained from Maxim's website at:
+ * http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf
No white spaces before dots please.
+#define show_temp(value, converter) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+ struct max1619_data *data = max1619_update_device(dev); \
+ return sprintf(buf, "%d\n", converter(data->value)); \
+}
+show_temp(temp_input1, TEMP_FROM_REG);
+show_temp(temp_input2, TEMP_FROM_REG);
+show_temp(temp_low2, TEMP_FROM_REG);
+show_temp(temp_high2, TEMP_FROM_REG);
+show_temp(temp_crit2, TEMP_FROM_REG);
+show_temp(temp_hyst2, TEMP_FROM_REG);
TEMP_FROM_REG doesn't have to be passed by parameter, since it's always
the same.
+static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2,
+ set_temp_crit2);
+static DEVICE_ATTR(temp2_hyst, S_IWUSR | S_IRUGO, show_temp_hyst2,
+ set_temp_hyst2);
File has to be named temp2_crit_hyst instead of temp2_hyst.
+static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct i2c_client *new_client;
+ struct max1619_data *data;
+ int err = 0;
+ const char *name = "";
Broken indentation, you have 8 spaces instead of one tabulation.
+ /* The common I2C client data is placed right before the
+ LM90-specific data. */
You forgot to update that comment.
+ if (kind <= 0) { /* identification */
+
+ man_id = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_MAN_ID);
+ chip_id = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_CHIP_ID);
+
+ if ((man_id = 0x4D) && (chip_id = 0x04))
+ {
+ kind = max1619;
+ }
+
+ }
Discard these extra empty lines. Move the opening { at the end of the
"if..." line.
+ if (kind = max1619)
+ {
+ name = "max1619";
+ }
Same here, opening curly brace is misplaced.
+ device_create_file(&new_client->dev, &dev_attr_temp2_crit);
+ device_create_file(&new_client->dev, &dev_attr_temp2_hyst);
Rename here too.
+MODULE_AUTHOR("Alexey Fisher <fishor@mail.ru>" \
+ "Jean Delvare <khali@linux-fr.org>");
No \ here. You can just split the string over lines and the compiler
will join them for you:
MODULE_AUTHOR("Alexey Fisher <fishor@mail.ru> and "
"Jean Delvare <khali@linux-fr.org>");
In any case, *you* are the author, I don't deserve to have my name here
;)
Rest is just fine. I told you you could do it! Very impressive :)
Once you have fixed everything, and have tested the new version with
lm_sensors CVS, you should be able to submit your new driver to Greg KH
for inclusion into the main 2.6 tree. Briefly explain what the driver is
for and how you wrote it (including the fact that I reviewed it). Don't
forget to CC: the lm_sensors mailing list. Note that you have to send
the patch *inline* (as opposed to in attachement) when sending patches
to Greg. Make sure that your e-mail client won't break it (various
e-mail clients would break long lines or replace tabs with spaces...).
Thanks, and congratulations again :)
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (14 preceding siblings ...)
2005-05-19 6:25 ` max1619 Jean Delvare
@ 2005-05-19 6:25 ` Alexey Fisher
2005-05-19 6:25 ` max1619 Jean Delvare
` (7 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
Hi Jean
About this misterious chip, yesterday i did open my computer and found many
chips ;-) . Some i identifide and some not.
W48C111-16H - Fregency generator
SST 28SF040A - EEPROM
HIN 211CAS - ???
LTC 1736 CG - Step Down
W40S11-02W - SDRAM buff
H043 FDS - ???
4431 AWGT 118 - ???
AD373 - ???
H8 3434 - PROM
LM 358 - ??? somthing for powersuplay
4463 AH(A or D) T12A - ???
724661-001 - ???
P12AB FST3383 - ???
PCA3356 TK41111 - ???
LM4880M - amplfire
OCDC42K MC4303 - ???
PU 2211 OCK - ???
EP7209-CV-D - mp3 (whau i have a mp3 :-o )
maybe you can halp me to recognise some of them :-)
i tested sensors-detect
Next adapter: SMBus PIIX4 adapter at 2180 (Non-I2C SMBus adapter)
Do you want to scan it? (YES/no/selectively):
Client found at address 0x1f
Probing for `Maxim MAX6650/MAX6651'... Success!
(confidence 4, driver `max6650')
Client found at address 0x30
Client at address 0x4d can not be probed - unload all client drivers first!
Client found at address 0x50
Probing for `SPD EEPROM'... Success!
(confidence 8, driver `eeprom')
Probing for `DDC monitor'... Failed!
Probing for `Maxim MAX6900'... Failed!
Client found at address 0x69
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (15 preceding siblings ...)
2005-05-19 6:25 ` max1619 Alexey Fisher
@ 2005-05-19 6:25 ` Jean Delvare
2005-05-19 6:25 ` max1619 Alexey Fisher
` (6 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
> Jean, you may kill me, but i don't have an max6650.
Definitely not a good reason to kill someone ;) (if there can be good
reasons...)
> Fan On or Off - it show the same speed.
> and when i made "i2cset 0 0x1f 0x01 0x01" it went down to sleep...
I have to agree. Taking a look at the dump you sent [1], it definitely
doesn't look like a MAX6650/1 chip. Your chip has 2 or 4 registers,
obviously no more, while even the MAX6650 has more than that.
Your best chance is to open your computer case and physically search for
your MAX1619. The other chip might be connected directly to it.
If not, just look for any small chip made by Maxim or any other typical
manufacturer (Dallas, National Semiconductor, Analog Devices...)
From just the dump it's nearly impossible to find out what it is, it
doesn't carry enough information.
I've slighly improved the MAX6650/1 detection in sensors-detect, but I
doubt it will be enough to defeat your chip, whatever it is.
Good luck.
John, can you confirm that the change makes sense and that
sensors-detect still sees your chip? It it's OK, I'd like you to do the
same in the driver itself.
It would also be great if you could compare Alexey's mysterious chip
dump (at 0x1f) with yours and find a way to prevent the later from being
misdetected as the former.
Thanks.
[1] http://archives.andrew.net.au/lm-sensors/msg07974.html
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (16 preceding siblings ...)
2005-05-19 6:25 ` max1619 Jean Delvare
@ 2005-05-19 6:25 ` Alexey Fisher
2005-05-19 6:25 ` max1619 Jean Delvare
` (5 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
i have chip H8/3437
http://crio.mib.infn.it/wig/electronics/Componenti/Hitachi/Microcontrollori/h33to006d1.pdf
this one is with two registers for i2c
i did try other chips and didn't finde any think.
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (17 preceding siblings ...)
2005-05-19 6:25 ` max1619 Alexey Fisher
@ 2005-05-19 6:25 ` Jean Delvare
2005-05-19 6:25 ` max1619 Alexey Fisher
` (4 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
> i have chip H8/3437
> http://crio.mib.infn.it/wig/electronics/Componenti/Hitachi/Microcontrollori/h33to006d1.pdf
>
> this one is with two registers for i2c
> i did try other chips and didn't finde any think.
It doesn't even look like an i2c chip to me. Searching the datasheet for
"i2c", "Philips" or "smbus" didn't return anything. Why do you think it
is an i2c chip?
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (18 preceding siblings ...)
2005-05-19 6:25 ` max1619 Jean Delvare
@ 2005-05-19 6:25 ` Alexey Fisher
2005-05-19 6:25 ` max1619 Alexey Fisher
` (3 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
Hi Greg.
This is a driver for "Remote/Local Temperature Sensor with Dual-Alarm Outputs
and SMBus Serial Interface" MAX1619. I found this chip an my Laptop SAMSUNG
NV5000. Daryng I use Linux cooling didn't worked at all, naw with this
driwer it's working. I hope this will be usefool for ather too.
I didn't hade any expiriens with programming, but i didn't wont to wait wann
some body make it vor me. Jean halped me correrct any mysteiks wich i made.
Thanks Jaen :)
diff -ruN linux-2.6.6-mm5/drivers/i2c/chips/Kconfig linux-2.6.6-mm5-max1619/drivers/i2c/chips/Kconfig
--- linux-2.6.6-mm5/drivers/i2c/chips/Kconfig 2004-05-25 08:51:38.000000000 +0200
+++ linux-2.6.6-mm5-max1619/drivers/i2c/chips/Kconfig 2004-05-27 14:00:25.000000000 +0200
@@ -145,6 +145,16 @@
This driver can also be built as a module. If so, the module
will be called lm90.
+config SENSORS_MAX1619
+ tristate "Maxim MAX1619 sensor chip"
+ depends on I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for MAX1619 sensor chip.
+
+ This driver can also be built as a module. If so, the module
+ will be called max1619.
+
config SENSORS_VIA686A
tristate "VIA686A"
depends on I2C && EXPERIMENTAL
diff -ruN linux-2.6.6-mm5/drivers/i2c/chips/Makefile linux-2.6.6-mm5-max1619/drivers/i2c/chips/Makefile
--- linux-2.6.6-mm5/drivers/i2c/chips/Makefile 2004-05-25 08:51:38.000000000 +0200
+++ linux-2.6.6-mm5-max1619/drivers/i2c/chips/Makefile 2004-05-27 13:58:08.000000000 +0200
@@ -19,6 +19,7 @@
obj-$(CONFIG_SENSORS_LM83) += lm83.o
obj-$(CONFIG_SENSORS_LM85) += lm85.o
obj-$(CONFIG_SENSORS_LM90) += lm90.o
+obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
diff -ruN linux-2.6.6-mm5/drivers/i2c/chips/max1619.c linux-2.6.6-mm5-max1619/drivers/i2c/chips/max1619.c
--- linux-2.6.6-mm5/drivers/i2c/chips/max1619.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.6-mm5-max1619/drivers/i2c/chips/max1619.c 2004-05-27 14:11:52.000000000 +0200
@@ -0,0 +1,378 @@
+/*
+ * max1619.c - Part of lm_sensors, Linux kernel modules for hardware
+ * monitoring
+ * Copyright (C) 2003-2004 Alexey Fisher <fishor@mail.ru>
+ * Jean Delvare <khali@linux-fr.org>
+ *
+ * Based on the lm90 driver. The MAX1619 is a sensor chip made by Maxim.
+ * It reports up to two temperatures (its own plus up to
+ * one external one). Complete datasheet can be
+ * obtained from Maxim's website at:
+ * http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf
+ *
+ * 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.
+ */
+
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+
+
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { 0x18, 0x1a, 0x29, 0x2b,
+ 0x4c, 0x4e, I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
+
+/*
+ * Insmod parameters
+ */
+
+SENSORS_INSMOD_1(max1619);
+
+/*
+ * The MAX1619 registers
+ */
+
+#define MAX1619_REG_R_MAN_ID 0xFE
+#define MAX1619_REG_R_CHIP_ID 0xFF
+#define MAX1619_REG_R_CONFIG 0x03
+#define MAX1619_REG_W_CONFIG 0x09
+#define MAX1619_REG_R_CONVRATE 0x04
+#define MAX1619_REG_W_CONVRATE 0x0A
+#define MAX1619_REG_R_STATUS 0x02
+#define MAX1619_REG_R_LOCAL_TEMP 0x00
+#define MAX1619_REG_R_REMOTE_TEMP 0x01
+#define MAX1619_REG_R_REMOTE_HIGH 0x07
+#define MAX1619_REG_W_REMOTE_HIGH 0x0D
+#define MAX1619_REG_R_REMOTE_LOW 0x08
+#define MAX1619_REG_W_REMOTE_LOW 0x0E
+#define MAX1619_REG_R_REMOTE_CRIT 0x10
+#define MAX1619_REG_W_REMOTE_CRIT 0x12
+#define MAX1619_REG_R_TCRIT_HYST 0x11
+#define MAX1619_REG_W_TCRIT_HYST 0x13
+
+/*
+ * Conversions and various macros
+ */
+
+#define TEMP_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000)
+#define TEMP_TO_REG(val) ((val < 0 ? val+0x100*1000 : val) / 1000)
+
+/*
+ * Functions declaration
+ */
+
+static int max1619_attach_adapter(struct i2c_adapter *adapter);
+static int max1619_detect(struct i2c_adapter *adapter, int address,
+ int kind);
+static void max1619_init_client(struct i2c_client *client);
+static int max1619_detach_client(struct i2c_client *client);
+static struct max1619_data *max1619_update_device(struct device *dev);
+
+/*
+ * Driver data (common to all clients)
+ */
+
+static struct i2c_driver max1619_driver = {
+ .owner = THIS_MODULE,
+ .name = "max1619",
+ .flags = I2C_DF_NOTIFY,
+ .attach_adapter = max1619_attach_adapter,
+ .detach_client = max1619_detach_client,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct max1619_data {
+ struct i2c_client client;
+ struct semaphore update_lock;
+ char valid; /* zero until following fields are valid */
+ unsigned long last_updated; /* in jiffies */
+
+ /* registers values */
+ u8 temp_input1; /* local */
+ u8 temp_input2, temp_low2, temp_high2; /* remote */
+ u8 temp_crit2;
+ u8 temp_hyst2;
+ u8 alarms;
+};
+
+/*
+ * Internal variables
+ */
+
+static int max1619_id = 0;
+
+/*
+ * Sysfs stuff
+ */
+
+#define show_temp(value) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+ struct max1619_data *data = max1619_update_device(dev); \
+ return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \
+}
+show_temp(temp_input1);
+show_temp(temp_input2);
+show_temp(temp_low2);
+show_temp(temp_high2);
+show_temp(temp_crit2);
+show_temp(temp_hyst2);
+
+#define set_temp2(value, reg) \
+static ssize_t set_##value(struct device *dev, const char *buf, \
+ size_t count) \
+{ \
+ struct i2c_client *client = to_i2c_client(dev); \
+ struct max1619_data *data = i2c_get_clientdata(client); \
+ data->value = TEMP_TO_REG(simple_strtol(buf, NULL, 10)); \
+ i2c_smbus_write_byte_data(client, reg, data->value); \
+ return count; \
+}
+
+set_temp2(temp_low2, MAX1619_REG_W_REMOTE_LOW);
+set_temp2(temp_high2, MAX1619_REG_W_REMOTE_HIGH);
+set_temp2(temp_crit2, MAX1619_REG_W_REMOTE_CRIT);
+set_temp2(temp_hyst2, MAX1619_REG_W_TCRIT_HYST);
+
+static ssize_t show_alarms(struct device *dev, char *buf)
+{
+ struct max1619_data *data = max1619_update_device(dev);
+ return sprintf(buf, "%d\n", data->alarms);
+}
+
+static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL);
+static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL);
+static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2,
+ set_temp_low2);
+static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2,
+ set_temp_high2);
+static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2,
+ set_temp_crit2);
+static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst2,
+ set_temp_hyst2);
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
+
+/*
+ * Real code
+ */
+
+static int max1619_attach_adapter(struct i2c_adapter *adapter)
+{
+ if (!(adapter->class & I2C_CLASS_HWMON))
+ return 0;
+ return i2c_detect(adapter, &addr_data, max1619_detect);
+}
+
+/*
+ * The following function does more than just detection. If detection
+ * succeeds, it also registers the new chip.
+ */
+static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct i2c_client *new_client;
+ struct max1619_data *data;
+ int err = 0;
+ const char *name = "";
+ u8 reg_config=0, reg_convrate=0, reg_status=0;
+ u8 man_id, chip_id;
+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+ goto exit;
+
+ if (!(data = kmalloc(sizeof(struct max1619_data), GFP_KERNEL))) {
+ err = -ENOMEM;
+ goto exit;
+ }
+ memset(data, 0, sizeof(struct max1619_data));
+
+ /* The common I2C client data is placed right before the
+ MAX1619-specific data. */
+ new_client = &data->client;
+ i2c_set_clientdata(new_client, data);
+ new_client->addr = address;
+ new_client->adapter = adapter;
+ new_client->driver = &max1619_driver;
+ new_client->flags = 0;
+
+ /*
+ * Now we do the remaining detection. A negative kind means that
+ * the driver was loaded with no force parameter (default), so we
+ * must both detect and identify the chip. A zero kind means that
+ * the driver was loaded with the force parameter, the detection
+ * step shall be skipped. A positive kind means that the driver
+ * was loaded with the force parameter and a given kind of chip is
+ * requested, so both the detection and the identification steps
+ * are skipped.
+ */
+ if (kind < 0) { /* detection */
+ reg_config = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_CONFIG);
+ reg_convrate = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_CONVRATE);
+ reg_status = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_STATUS);
+ if ((reg_config & 0x03) != 0x00
+ || reg_convrate > 0x07 || (reg_status & 0x61 ) !=0x00) {
+ dev_dbg(&adapter->dev,
+ "MAX1619 detection failed at 0x%02x.\n",
+ address);
+ goto exit_free;
+ }
+ }
+
+ if (kind <= 0) { /* identification */
+
+ man_id = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_MAN_ID);
+ chip_id = i2c_smbus_read_byte_data(new_client,
+ MAX1619_REG_R_CHIP_ID);
+
+ if ((man_id = 0x4D) && (chip_id = 0x04)){
+ kind = max1619;
+ }
+ }
+
+ if (kind <= 0) { /* identification failed */
+ dev_info(&adapter->dev,
+ "Unsupported chip (man_id=0x%02X, "
+ "chip_id=0x%02X).\n", man_id, chip_id);
+ goto exit_free;
+ }
+
+
+ if (kind = max1619){
+ name = "max1619";
+ }
+
+ /* We can fill in the remaining client fields */
+ strlcpy(new_client->name, name, I2C_NAME_SIZE);
+ new_client->id = max1619_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 exit_free;
+
+ /* Initialize the MAX1619 chip */
+ max1619_init_client(new_client);
+
+ /* Register sysfs hooks */
+ device_create_file(&new_client->dev, &dev_attr_temp1_input);
+ device_create_file(&new_client->dev, &dev_attr_temp2_input);
+ device_create_file(&new_client->dev, &dev_attr_temp2_min);
+ device_create_file(&new_client->dev, &dev_attr_temp2_max);
+ device_create_file(&new_client->dev, &dev_attr_temp2_crit);
+ device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst);
+ device_create_file(&new_client->dev, &dev_attr_alarms);
+
+ return 0;
+
+exit_free:
+ kfree(data);
+exit:
+ return err;
+}
+
+static void max1619_init_client(struct i2c_client *client)
+{
+ u8 config;
+
+ /*
+ * Start the conversions.
+ */
+ i2c_smbus_write_byte_data(client, MAX1619_REG_W_CONVRATE,
+ 5); /* 2 Hz */
+ config = i2c_smbus_read_byte_data(client, MAX1619_REG_R_CONFIG);
+ if (config & 0x40)
+ i2c_smbus_write_byte_data(client, MAX1619_REG_W_CONFIG,
+ config & 0xBF); /* run */
+}
+
+static int max1619_detach_client(struct i2c_client *client)
+{
+ int err;
+
+ if ((err = i2c_detach_client(client))) {
+ dev_err(&client->dev, "Client deregistration failed, "
+ "client not detached.\n");
+ return err;
+ }
+
+ kfree(i2c_get_clientdata(client));
+ return 0;
+}
+
+static struct max1619_data *max1619_update_device(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct max1619_data *data = i2c_get_clientdata(client);
+
+ down(&data->update_lock);
+
+ if ((jiffies - data->last_updated > HZ * 2) ||
+ (jiffies < data->last_updated) ||
+ !data->valid) {
+
+ dev_dbg(&client->dev, "Updating max1619 data.\n");
+ data->temp_input1 = i2c_smbus_read_byte_data(client,
+ MAX1619_REG_R_LOCAL_TEMP);
+ data->temp_input2 = i2c_smbus_read_byte_data(client,
+ MAX1619_REG_R_REMOTE_TEMP);
+ data->temp_high2 = i2c_smbus_read_byte_data(client,
+ MAX1619_REG_R_REMOTE_HIGH);
+ data->temp_low2 = i2c_smbus_read_byte_data(client,
+ MAX1619_REG_R_REMOTE_LOW);
+ data->temp_crit2 = i2c_smbus_read_byte_data(client,
+ MAX1619_REG_R_REMOTE_CRIT);
+ data->temp_hyst2 = i2c_smbus_read_byte_data(client,
+ MAX1619_REG_R_TCRIT_HYST);
+ data->alarms = i2c_smbus_read_byte_data(client,
+ MAX1619_REG_R_STATUS);
+
+ data->last_updated = jiffies;
+ data->valid = 1;
+ }
+
+ up(&data->update_lock);
+
+ return data;
+}
+
+static int __init sensors_max1619_init(void)
+{
+ return i2c_add_driver(&max1619_driver);
+}
+
+static void __exit sensors_max1619_exit(void)
+{
+ i2c_del_driver(&max1619_driver);
+}
+
+MODULE_AUTHOR("Alexey Fisher <fishor@mail.ru> and"
+ "Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("MAX1619 sensor driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_max1619_init);
+module_exit(sensors_max1619_exit);
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (19 preceding siblings ...)
2005-05-19 6:25 ` max1619 Alexey Fisher
@ 2005-05-19 6:25 ` Alexey Fisher
2005-05-19 6:25 ` max1619 Greg KH
` (2 subsequent siblings)
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
?????? Jean,
Thursday, May 27, 2004, 8:00:47 PM, you wrote:
>> i have chip H8/3437
>> http://crio.mib.infn.it/wig/electronics/Componenti/Hitachi/Microcontrollori/h33to006d1.pdf
>>
>> this one is with two registers for i2c
>> i did try other chips and didn't finde any think.
JD> It doesn't even look like an i2c chip to me. Searching the datasheet for
JD> "i2c", "Philips" or "smbus" didn't return anything. Why do you think it
JD> is an i2c chip?
this chip wich i wrot to you is not an i2c chip. this one to handle powersuplay and many other staf. About how its look like I don't anderstend enythink, realy, i don't have eny expiriens.
But any whay thanky for your halp.
--
Best regards,
Alexey mailto:fishor@gmx.net
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (20 preceding siblings ...)
2005-05-19 6:25 ` max1619 Alexey Fisher
@ 2005-05-19 6:25 ` Greg KH
2005-05-19 6:25 ` max1619 Alexey Fisher
2005-05-19 6:25 ` max1619 Jean Delvare
23 siblings, 0 replies; 25+ messages in thread
From: Greg KH @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
On Thu, May 27, 2004 at 10:16:34PM +0200, Alexey Fisher wrote:
> Hi Greg.
> This is a driver for "Remote/Local Temperature Sensor with Dual-Alarm Outputs
> and SMBus Serial Interface" MAX1619. I found this chip an my Laptop SAMSUNG
> NV5000. Daryng I use Linux cooling didn't worked at all, naw with this
> driwer it's working. I hope this will be usefool for ather too.
>
> I didn't hade any expiriens with programming, but i didn't wont to wait wann
> some body make it vor me. Jean halped me correrct any mysteiks wich i made.
> Thanks Jaen :)
Applied to my trees, and I'll send it off to Linus in a bit.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (21 preceding siblings ...)
2005-05-19 6:25 ` max1619 Greg KH
@ 2005-05-19 6:25 ` Alexey Fisher
2005-05-19 6:25 ` max1619 Jean Delvare
23 siblings, 0 replies; 25+ messages in thread
From: Alexey Fisher @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
> +show_temp(temp_input1, TEMP_FROM_REG);
> +show_temp(temp_input2, TEMP_FROM_REG);
> +show_temp(temp_low2, TEMP_FROM_REG);
> +show_temp(temp_high2, TEMP_FROM_REG);
> +show_temp(temp_crit2, TEMP_FROM_REG);
> +show_temp(temp_hyst2, TEMP_FROM_REG);
>
> TEMP_FROM_REG doesn't have to be passed by parameter, since it's always
> the same.
>
Jaen, I'm not sure what you mean. If you about "temp_hyst2", in these driverer
hyst is chenchebl, not always the same.
> Once you have fixed everything, and have tested the new version with
> lm_sensors CVS, you should be able to submit your new driver to Greg KH
> for inclusion into the main 2.6 tree. Briefly explain what the driver is
> for and how you wrote it (including the fact that I reviewed it). Don't
> forget to CC: the lm_sensors mailing list. Note that you have to send
> the patch *inline* (as opposed to in attachement) when sending patches
> to Greg. Make sure that your e-mail client won't break it (various
> e-mail clients would break long lines or replace tabs with spaces...).
Actioly i dont know who is Greg. Am i can finde his Email in documentation ?
> Thanks, and congratulations again :)
Thank you, without your halp i newer did it :-)
^ permalink raw reply [flat|nested] 25+ messages in thread* max1619
2005-05-19 6:24 max1619 Alexey Fisher
` (22 preceding siblings ...)
2005-05-19 6:25 ` max1619 Alexey Fisher
@ 2005-05-19 6:25 ` Jean Delvare
23 siblings, 0 replies; 25+ messages in thread
From: Jean Delvare @ 2005-05-19 6:25 UTC (permalink / raw)
To: lm-sensors
> About this misterious chip, yesterday i did open my computer and found
> many chips ;-) . Some i identifide and some not.
>
> W48C111-16H - Fregency generator
> SST 28SF040A - EEPROM
> HIN 211CAS - ???
> LTC 1736 CG - Step Down
> W40S11-02W - SDRAM buff
> H043 FDS - ???
> 4431 AWGT 118 - ???
> AD373 - ???
> H8 3434 - PROM
> LM 358 - ??? somthing for powersuplay
> 4463 AH(A or D) T12A - ???
> 724661-001 - ???
> P12AB FST3383 - ???
> PCA3356 TK41111 - ???
> LM4880M - amplfire
> OCDC42K MC4303 - ???
> PU 2211 OCK - ???
> EP7209-CV-D - mp3 (whau i have a mp3 :-o )
>
> maybe you can halp me to recognise some of them :-)
Not really. I hardly know any of these.
Your best chance is to ask Google about them. You are looking for a chip
that is I2C or SMBus compatible, with 0x1f being a possible address
(some docs could refer to is as 0x3e, which is more or less the "read
address" for i2c address 0x1f).
Remember that you are probably after a really small chip, since it has
very few registers.
Good luck.
--
Jean Delvare
http://khali.linux-fr.org/
^ permalink raw reply [flat|nested] 25+ messages in thread