Skip to contentSkip to conversation

w83627ehf fan controll?

lm-sensors Sebastian Band 5 participants 9 messages Dec 30, 2005 – Jan 29, 2006

lore
Share & tools
lore
#0 lore raw

Hello!

Is there any possible way, to controll the fan speed with the w83627ehf chip? I'm able to monitor the fan and the temp without any problem, but I don't have any *pwm entries in /sys/bus/i2c/devices/9191-0290/.
I use linux-2.6.14 and lm_sensors version 2.9.2.

Any help would be appreciated.

Sebastian

#2 lore raw
In reply to Sebastian Band

Hello Sebastian,

Quoted 1 line

Is there any possible way, to controll the fan speed with the

w83627ehf chip?

Quoted 1 line

I'm able to monitor the fan and the temp without any problem, but I

don't have any *pwm

Quoted 1 line

entries in /sys/bus/i2c/devices/9191-0290/.

Yes, there should be :) But as you see there are no pwm entries yet. Do you have interest in using a test version?

Hi Jean,
I have add some entries to test the chip (in my local CVS), But I have not finished the test. Did anyone do the same work on this driver? Actually I'm quiet confusing about the naming rule of device file, it did not cover all the PWM/SmartFan functions.
And how about to backport w83627ehf driver to lm_sensors2 , Or there's no need to do it....

Best Regards
Yuan Mu

==============================================The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Winbond is strictly prohibited; and any information in this email irrelevant to the official business of Winbond shall be deemed as neither given nor endorsed by Winbond. ==============================================If your computer is unable to decode Chinese font, please ignore the following message.It essentially repeats the statement in English given above.本信件內所含華邦電子的財產性機密性資訊, 僅授權原發信人指定之收信人取閱\之用. 假使您並非被指定之收信人或因任何原因在未經授權的情形之下收到本信件, 請您告知原發信人並立即將信件從電腦與網路伺服器中予以消除. 對於您的合作, 我們先此致謝. 特此提醒, 任何未經授權擅自使用華邦電子的機密資訊的行為是被嚴格禁止的. 信件與華邦電子營業無關之內容,不得視為華邦電子之立場或意見.

#3 lore raw
In reply to Sebastian Band

Hi Yuan & all,

Quoted 2 lines

I have add some entries to test the chip (in my local CVS), But I have not finished the test. Did anyone do the same work on this driver?

A number of persons are supposedly working on improving this driver. Cadu said he would improve the driver back in July but we didn't hear back since. I think Rudolf has a W83627EHF chip and may be willing to help too. And I also seem to remember that Aurelien has such a chip and wanted to help with the driver some times ago.

It's rare to have that many persons working on the same driver, so it's quite sad that nothing has been merged into the driver yet :(

If you have a patch to contribute, please do! :)

Quoted 2 lines

Actually I'm quiet confusing about the naming rule of device file, it did not cover all the PWM/SmartFan functions.

Same old story. We tried to standardize the PWM interface, but in the end nobody seems to be happy with that standard. I'm a bit tired of all this, so just implement any interface you like as long as it makes sense. All I am asking for is that fan stopped is PWM=0 and fan at full speed is PWM%5.

Quoted 2 lines

And how about to backport w83627ehf driver to lm_sensors2 , Or there's no need to do it....

Until a user asks for it, I consider there is no need. If several users do ask for it and someone wants to work on backporting it, fine with me. But this is a recent chip and the 2.4 kernel is aging, so I wouldn't be surprised if we had no request for a backport, ever.

As far as I am concerned, I started working on the w83627ehf driver long ago because I happened to have some spare time and someone needed support for that chip, but as I do not have a chip to test this driver, it's really better is someone else goes on working on the driver. And I also don't have that much spare time these days, as most of you probably have noticed already.

Thanks,

Signature · 1 line
Jean Delvare
#4 lore raw
In reply to Sebastian Band
Quoted 1 line · Jean Delvare

Hi Yuan & all,

Hi!

Quoted 9 lines
Quoted 2 lines

I have add some entries to test the chip (in my local CVS), But I have not finished the test. Did anyone do the same work on this driver?

A number of persons are supposedly working on improving this driver. Cadu said he would improve the driver back in July but we didn't hear back since. I think Rudolf has a W83627EHF chip and may be willing to help too. And I also seem to remember that Aurelien has such a chip and wanted to help with the driver some times ago.

Quoted 5 lines

It's rare to have that many persons working on the same driver, so it's quite sad that nothing has been merged into the driver yet :(

If you have a patch to contribute, please do! :)

Yes I have started to work on it, but I have then stopped due to lack of time. Please find attached a patch between the current version in the kernel and my local version. It adds support for voltage inputs and it factorizes some code.

Quoted 9 lines
Quoted 2 lines

Actually I'm quiet confusing about the naming rule of device file, it did not cover all the PWM/SmartFan functions.

Same old story. We tried to standardize the PWM interface, but in the end nobody seems to be happy with that standard. I'm a bit tired of all this, so just implement any interface you like as long as it makes sense. All I am asking for is that fan stopped is PWM=0 and fan at full speed is PWM%5.

I have also started to work on pwm, until I understood the Asus guys have wired the fans directly to +12V. That's why I finally used a hardware solution instead of a software one :(

Bye,
Aurelien

Signature · 282 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32 at debian.org         | aurelien at aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net
-------------- next part --------------
--- /usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c	2005-10-28 02:02:08.000000000 +0200
+++ w83627ehf.c	2006-01-09 11:14:20.000000000 +0100
@@ -30,7 +30,7 @@
     Supports the following chips:
 
     Chip        #vin    #fan    #pwm    #temp   chip_id man_id
-    w83627ehf   -       5       -       3       0x88    0x5ca3
+    w83627ehf   10      5       -       3       0x88    0x5ca3
 
     This is a preliminary version of the driver, only supporting the
     fan and temperature inputs. The chip does much more than that.
@@ -114,6 +114,10 @@
 #define W83627EHF_REG_CHIP_ID		0x49
 #define W83627EHF_REG_MAN_ID		0x4F
 
+static const u16 W83627EHF_REG_IN[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x550, 0x551, 0x552 };
+static const u16 W83627EHF_REG_IN_MIN[] = { 0x2B, 0x2D, 0x2F, 0x31, 0x33, 0x35, 0x37, 0x554, 0x556, 0x558 };
+static const u16 W83627EHF_REG_IN_MAX[] = { 0x2C, 0x2E, 0x30, 0x32, 0x34, 0x36, 0x38, 0x555, 0x557, 0x559 };
+
 static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 };
 static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c };
 
@@ -137,6 +141,22 @@
  */
 
 static inline unsigned int
+in_from_reg(u8 reg)
+{
+	return reg * 8;
+}
+
+static inline u8
+reg_from_in(int val)
+{
+	if (val < 0)
+		return 0;
+	if (val > 2040)
+		return 255;
+	return (val + 4) / 8;
+}
+
+static inline unsigned int
 fan_from_reg(u8 reg, unsigned int div)
 {
 	if (reg = 0 || reg = 255)
@@ -182,6 +202,9 @@
 	unsigned long last_updated;	/* In jiffies */
 
 	/* Register values */
+	u8 in[10];		/* Register value */
+	u8 in_max[10];		/* Register value */
+	u8 in_min[10];		/* Register value */
 	u8 fan[5];
 	u8 fan_min[5];
 	u8 fan_div[5];
@@ -324,6 +347,16 @@
 
 	if (time_after(jiffies, data->last_updated + HZ)
 	 || !data->valid) {
+		/* Measured voltages and limits */
+		for (i = 0; i < 10; i++) {
+			data->in[i] = w83627ehf_read_value(client,
+				      W83627EHF_REG_IN[i]);
+			data->in_min[i] = w83627ehf_read_value(client,
+				          W83627EHF_REG_IN_MIN[i]);
+			data->in_max[i] = w83627ehf_read_value(client,
+				          W83627EHF_REG_IN_MAX[i]);
+		}
+
 		/* Fan clock dividers */
 		i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);
 		data->fan_div[0] = (i >> 4) & 0x03;
@@ -402,6 +435,81 @@
 /*
  * Sysfs callback functions
  */
+#define show_in_reg(reg) \
+static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
+{ \
+	struct w83627ehf_data *data = w83627ehf_update_device(dev); \
+	return sprintf(buf,"%d\n", in_from_reg(data->reg[nr])); \
+}
+show_in_reg(in)
+show_in_reg(in_min)
+show_in_reg(in_max)
+
+#define store_in_reg(REG, reg) \
+static ssize_t \
+store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct w83627ehf_data *data = i2c_get_clientdata(client); \
+	u32 val; \
+	 \
+	val = simple_strtoul(buf, NULL, 10); \
+	 \
+	down(&data->update_lock); \
+	data->in_##reg[nr] = reg_from_in(val); \
+	w83627ehf_write_value(client, W83627EHF_REG_IN_##REG[nr], \
+			    data->in_##reg[nr]); \
+	 \
+	up(&data->update_lock); \
+	return count; \
+}
+store_in_reg(MIN, min)
+store_in_reg(MAX, max)
+	
+#define sysfs_in_offset(offset) \
+static ssize_t \
+show_regs_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
+{ \
+	return show_in(dev, buf, offset); \
+} \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
+
+#define sysfs_in_reg_offset(reg, offset) \
+static ssize_t show_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \
+{ \
+	return show_in_##reg (dev, buf, offset); \
+} \
+static ssize_t \
+store_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, \
+			    const char *buf, size_t count) \
+{ \
+	return store_in_##reg (dev, buf, count, offset); \
+} \
+static DEVICE_ATTR(in##offset##_##reg, S_IRUGO | S_IWUSR, \
+		  show_regs_in_##reg##offset, store_regs_in_##reg##offset);
+
+#define sysfs_in_offsets(offset) \
+sysfs_in_offset(offset) \
+sysfs_in_reg_offset(min, offset) \
+sysfs_in_reg_offset(max, offset)
+	
+sysfs_in_offsets(0);
+sysfs_in_offsets(1);
+sysfs_in_offsets(2);
+sysfs_in_offsets(3);
+sysfs_in_offsets(4);
+sysfs_in_offsets(5);
+sysfs_in_offsets(6);
+sysfs_in_offsets(7);
+sysfs_in_offsets(8);
+sysfs_in_offsets(9);
+
+#define device_create_file_in(client, offset) \
+do { \
+	device_create_file(&client->dev, &dev_attr_in##offset##_input); \
+	device_create_file(&client->dev, &dev_attr_in##offset##_max); \
+	device_create_file(&client->dev, &dev_attr_in##offset##_min); \
+} while (0)
 
 #define show_fan_reg(reg) \
 static ssize_t \
@@ -522,21 +630,23 @@
 static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
 		   show_reg_fan##offset##_div, NULL);
 
-sysfs_fan_offset(1);
-sysfs_fan_min_offset(1);
-sysfs_fan_div_offset(1);
-sysfs_fan_offset(2);
-sysfs_fan_min_offset(2);
-sysfs_fan_div_offset(2);
-sysfs_fan_offset(3);
-sysfs_fan_min_offset(3);
-sysfs_fan_div_offset(3);
-sysfs_fan_offset(4);
-sysfs_fan_min_offset(4);
-sysfs_fan_div_offset(4);
-sysfs_fan_offset(5);
-sysfs_fan_min_offset(5);
-sysfs_fan_div_offset(5);
+#define sysfs_fan_offsets(offset) \
+sysfs_fan_offset(offset) \
+sysfs_fan_min_offset(offset) \
+sysfs_fan_div_offset(offset)
+
+sysfs_fan_offsets(1);
+sysfs_fan_offsets(2);
+sysfs_fan_offsets(3);
+sysfs_fan_offsets(4);
+sysfs_fan_offsets(5);
+
+#define device_create_file_fan(client, offset) \
+do { \
+	device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
+	device_create_file(&client->dev, &dev_attr_fan##offset##_min); \
+	device_create_file(&client->dev, &dev_attr_fan##offset##_div); \
+} while (0)
 
 #define show_temp1_reg(reg) \
 static ssize_t \
@@ -639,6 +749,13 @@
 sysfs_temp_reg_offset(max, 3);
 sysfs_temp_reg_offset(max_hyst, 3);
 
+#define device_create_file_temp(client, offset) \
+do { \
+	device_create_file(&client->dev, &dev_attr_temp##offset##_input); \
+	device_create_file(&client->dev, &dev_attr_temp##offset##_max); \
+	device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \
+} while (0)
+
 /*
  * Driver and client management
  */
@@ -665,6 +782,13 @@
 					      W83627EHF_REG_TEMP_CONFIG[i],
 					      tmp & 0xfe);
 	}
+	w83627ehf_write_value(client, 0x00, 0x04);
+	w83627ehf_write_value(client, 0x02, 0x04);
+	w83627ehf_write_value(client, 0x04, 0x00);
+	w83627ehf_write_value(client, 0x10, 0x04);
+	w83627ehf_write_value(client, 0x12, 0x00);
+	w83627ehf_write_value(client, 0x60, 0x04);
+	w83627ehf_write_value(client, 0x62, 0x00);
 }
 
 static int w83627ehf_detect(struct i2c_adapter *adapter)
@@ -724,36 +848,31 @@
 		goto exit_detach;
 	}
 
-	device_create_file(&client->dev, &dev_attr_fan1_input);
-	device_create_file(&client->dev, &dev_attr_fan1_min);
-	device_create_file(&client->dev, &dev_attr_fan1_div);
-	device_create_file(&client->dev, &dev_attr_fan2_input);
-	device_create_file(&client->dev, &dev_attr_fan2_min);
-	device_create_file(&client->dev, &dev_attr_fan2_div);
-	device_create_file(&client->dev, &dev_attr_fan3_input);
-	device_create_file(&client->dev, &dev_attr_fan3_min);
-	device_create_file(&client->dev, &dev_attr_fan3_div);
+	device_create_file_in(client, 0);
+	device_create_file_in(client, 1);
+	device_create_file_in(client, 2);
+	device_create_file_in(client, 3);
+	device_create_file_in(client, 4);
+	device_create_file_in(client, 5);
+	device_create_file_in(client, 6);
+	device_create_file_in(client, 7);
+	device_create_file_in(client, 8);
+	device_create_file_in(client, 9);
+
+	device_create_file_fan(client, 1);
+	device_create_file_fan(client, 2);
+	device_create_file_fan(client, 3);
 
 	if (data->has_fan & (1 << 3)) {
-		device_create_file(&client->dev, &dev_attr_fan4_input);
-		device_create_file(&client->dev, &dev_attr_fan4_min);
-		device_create_file(&client->dev, &dev_attr_fan4_div);
+		device_create_file_fan(client, 4);
 	}
 	if (data->has_fan & (1 << 4)) {
-		device_create_file(&client->dev, &dev_attr_fan5_input);
-		device_create_file(&client->dev, &dev_attr_fan5_min);
-		device_create_file(&client->dev, &dev_attr_fan5_div);
+		device_create_file_fan(client, 5);
 	}
-
-	device_create_file(&client->dev, &dev_attr_temp1_input);
-	device_create_file(&client->dev, &dev_attr_temp1_max);
-	device_create_file(&client->dev, &dev_attr_temp1_max_hyst);
-	device_create_file(&client->dev, &dev_attr_temp2_input);
-	device_create_file(&client->dev, &dev_attr_temp2_max);
-	device_create_file(&client->dev, &dev_attr_temp2_max_hyst);
-	device_create_file(&client->dev, &dev_attr_temp3_input);
-	device_create_file(&client->dev, &dev_attr_temp3_max);
-	device_create_file(&client->dev, &dev_attr_temp3_max_hyst);
+	
+	device_create_file_temp(client, 1);
+	device_create_file_temp(client, 2);
+	device_create_file_temp(client, 3);
 
 	return 0;
#5 lore raw
In reply to Sebastian Band

Hi all,

Sorry for late response. I did some quick review of this code. Maybe Yuan can find it useful.

1) max and min regs are switched
2) code does not use sensor_dev_attr and uses old macro system
3) it contains some tweaks to force PWM (seems from Aurelian attempts to get his PWM working :)

I have a question now:

1) does anyone else has something to show?
2) does anyone has userspace voltage support?

I cant work much on this next moth (feb) busy with final exams. Well maybe I will - as brain relax subroutine :)

Yuan have you this on your own schedule?

Thanks,
Regards
Rudolf

Quoted 12 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +1 -1
@@ -30,7 +30,7 @@
     Supports the following chips:
 
     Chip        #vin    #fan    #pwm    #temp   chip_id man_id
-    w83627ehf   -       5       -       3       0x88    0x5ca3
+    w83627ehf   10      5       -       3       0x88    0x5ca3
 
     This is a preliminary version of the driver, only supporting the
     fan and temperature inputs. The chip does much more than that.

w83627ehf.c line 120

Quoted 7 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +4 -0
@@ -114,6 +114,10 @@
 #define W83627EHF_REG_CHIP_ID		0x49
 #define W83627EHF_REG_MAN_ID		0x4F
 
+static const u16 W83627EHF_REG_IN[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x550, 0x551, 0x552 };
+static const u16 W83627EHF_REG_IN_MIN[] = { 0x2B, 0x2D, 0x2F, 0x31, 0x33, 0x35, 0x37, 0x554, 0x556, 0x558 };
+static const u16 W83627EHF_REG_IN_MAX[] = { 0x2C, 0x2E, 0x30, 0x32, 0x34, 0x36, 0x38, 0x555, 0x557, 0x559 };
+

Min and max are switched.

Quoted 38 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +19 -0
 static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 };
 static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c };
 
@@ -137,6 +141,22 @@
  */
 
 static inline unsigned int
+in_from_reg(u8 reg)
+{
+	return reg * 8;
+}
+
+static inline u8
+reg_from_in(int val)
+{
+	if (val < 0)
+		return 0;
+	if (val > 2040)
+		return 255;
+	return (val + 4) / 8;
+}
+
+static inline unsigned int
 fan_from_reg(u8 reg, unsigned int div)
 {
 	if (reg = 0 || reg = 255)
@@ -182,6 +202,9 @@
 	unsigned long last_updated;	/* In jiffies */
 
 	/* Register values */
+	u8 in[10];		/* Register value */
+	u8 in_max[10];		/* Register value */
+	u8 in_min[10];		/* Register value */
 	u8 fan[5];
 	u8 fan_min[5];
 	u8 fan_div[5];
@@ -324,6 +347,16 @@
 

w83627ehf.c line 357

Quoted 10 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +8 -0
 	if (time_after(jiffies, data->last_updated + HZ)
 	 || !data->valid) {
+		/* Measured voltages and limits */
+		for (i = 0; i < 10; i++) {
+			data->in[i] = w83627ehf_read_value(client,
+				      W83627EHF_REG_IN[i]);
+			data->in_min[i] = w83627ehf_read_value(client,
+				          W83627EHF_REG_IN_MIN[i]);
+			data->in_max[i] = w83627ehf_read_value(client,
+				          W83627EHF_REG_IN_MAX[i]);

Maybe one tab missing?

Quoted 25 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +18 -0
+		}
+
 		/* Fan clock dividers */
 		i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);
 		data->fan_div[0] = (i >> 4) & 0x03;
@@ -402,6 +435,81 @@
 /*
  * Sysfs callback functions
  */
+#define show_in_reg(reg) \
+static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
+{ \
+	struct w83627ehf_data *data = w83627ehf_update_device(dev); \
+	return sprintf(buf,"%d\n", in_from_reg(data->reg[nr])); \
+}
+show_in_reg(in)
+show_in_reg(in_min)
+show_in_reg(in_max)
+
+#define store_in_reg(REG, reg) \
+static ssize_t \
+store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct w83627ehf_data *data = i2c_get_clientdata(client); \

w83627ehf.c line 463

Quoted 10 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +10 -0
+	u32 val; \
+	 \
+	val = simple_strtoul(buf, NULL, 10); \
+	 \
+	down(&data->update_lock); \
+	data->in_##reg[nr] = reg_from_in(val); \
+	w83627ehf_write_value(client, W83627EHF_REG_IN_##REG[nr], \
+			    data->in_##reg[nr]); \
+	 \
+	up(&data->update_lock); \

I think I have seen some patch that is changing this semaphore to mutexes.

w83627ehf.c line 475

Quoted 12 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +12 -0
+	return count; \
+}
+store_in_reg(MIN, min)
+store_in_reg(MAX, max)
+	
+#define sysfs_in_offset(offset) \
+static ssize_t \
+show_regs_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
+{ \
+	return show_in(dev, buf, offset); \
+} \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);

Why this way?

What about this:

static struct sensor_device_attribute sda_in_input[] = {
	SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0),
	SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1),

and

static struct sensor_device_attribute sda_in_min[] = {
       SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0),
       SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1),
       SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2),

/* following are the sysfs callback functions */
static ssize_t show_in(struct device *dev, struct device_attribute *attr,
char *buf)

{
        struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
        int nr = sensor_attr->index;
        struct w83792d_data *data = w83792d_update_device(dev);
        return sprintf(buf,"%ld\n", IN_FROM_REG(nr,(in_count_from_reg(nr, data))));
}

I think you get it :)

Quoted 94 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +61 -15
+
+#define sysfs_in_reg_offset(reg, offset) \
+static ssize_t show_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \
+{ \
+	return show_in_##reg (dev, buf, offset); \
+} \
+static ssize_t \
+store_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, \
+			    const char *buf, size_t count) \
+{ \
+	return store_in_##reg (dev, buf, count, offset); \
+} \
+static DEVICE_ATTR(in##offset##_##reg, S_IRUGO | S_IWUSR, \
+		  show_regs_in_##reg##offset, store_regs_in_##reg##offset);
+
+#define sysfs_in_offsets(offset) \
+sysfs_in_offset(offset) \
+sysfs_in_reg_offset(min, offset) \
+sysfs_in_reg_offset(max, offset)
+	
+sysfs_in_offsets(0);
+sysfs_in_offsets(1);
+sysfs_in_offsets(2);
+sysfs_in_offsets(3);
+sysfs_in_offsets(4);
+sysfs_in_offsets(5);
+sysfs_in_offsets(6);
+sysfs_in_offsets(7);
+sysfs_in_offsets(8);
+sysfs_in_offsets(9);
+
+#define device_create_file_in(client, offset) \
+do { \
+	device_create_file(&client->dev, &dev_attr_in##offset##_input); \
+	device_create_file(&client->dev, &dev_attr_in##offset##_max); \
+	device_create_file(&client->dev, &dev_attr_in##offset##_min); \
+} while (0)
 
 #define show_fan_reg(reg) \
 static ssize_t \
@@ -522,21 +630,23 @@
 static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
 		   show_reg_fan##offset##_div, NULL);
 
-sysfs_fan_offset(1);
-sysfs_fan_min_offset(1);
-sysfs_fan_div_offset(1);
-sysfs_fan_offset(2);
-sysfs_fan_min_offset(2);
-sysfs_fan_div_offset(2);
-sysfs_fan_offset(3);
-sysfs_fan_min_offset(3);
-sysfs_fan_div_offset(3);
-sysfs_fan_offset(4);
-sysfs_fan_min_offset(4);
-sysfs_fan_div_offset(4);
-sysfs_fan_offset(5);
-sysfs_fan_min_offset(5);
-sysfs_fan_div_offset(5);
+#define sysfs_fan_offsets(offset) \
+sysfs_fan_offset(offset) \
+sysfs_fan_min_offset(offset) \
+sysfs_fan_div_offset(offset)
+
+sysfs_fan_offsets(1);
+sysfs_fan_offsets(2);
+sysfs_fan_offsets(3);
+sysfs_fan_offsets(4);
+sysfs_fan_offsets(5);
+
+#define device_create_file_fan(client, offset) \
+do { \
+	device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
+	device_create_file(&client->dev, &dev_attr_fan##offset##_min); \
+	device_create_file(&client->dev, &dev_attr_fan##offset##_div); \
+} while (0)
 
 #define show_temp1_reg(reg) \
 static ssize_t \
@@ -639,6 +749,13 @@
 sysfs_temp_reg_offset(max, 3);
 sysfs_temp_reg_offset(max_hyst, 3);
 
+#define device_create_file_temp(client, offset) \
+do { \
+	device_create_file(&client->dev, &dev_attr_temp##offset##_input); \
+	device_create_file(&client->dev, &dev_attr_temp##offset##_max); \
+	device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \
+} while (0)
+
 /*
  * Driver and client management
  */

w83627ehf.c line 791

Quoted 10 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +7 -0
@@ -665,6 +782,13 @@
 					      W83627EHF_REG_TEMP_CONFIG[i],
 					      tmp & 0xfe);
 	}
+	w83627ehf_write_value(client, 0x00, 0x04);
+	w83627ehf_write_value(client, 0x02, 0x04);
+	w83627ehf_write_value(client, 0x04, 0x00);
+	w83627ehf_write_value(client, 0x10, 0x04);
+	w83627ehf_write_value(client, 0x12, 0x00);
+	w83627ehf_write_value(client, 0x60, 0x04);
+	w83627ehf_write_value(client, 0x62, 0x00);

It seems this are your own tweaks. This needs to be removed.

Quoted 68 lines
w83627ehf.c renamed from usr/src/linux-2.6.14/drivers/hwmon/w83627ehf.c +20 -26
 }
 
 static int w83627ehf_detect(struct i2c_adapter *adapter)
@@ -724,36 +848,31 @@
 		goto exit_detach;
 	}
 
-	device_create_file(&client->dev, &dev_attr_fan1_input);
-	device_create_file(&client->dev, &dev_attr_fan1_min);
-	device_create_file(&client->dev, &dev_attr_fan1_div);
-	device_create_file(&client->dev, &dev_attr_fan2_input);
-	device_create_file(&client->dev, &dev_attr_fan2_min);
-	device_create_file(&client->dev, &dev_attr_fan2_div);
-	device_create_file(&client->dev, &dev_attr_fan3_input);
-	device_create_file(&client->dev, &dev_attr_fan3_min);
-	device_create_file(&client->dev, &dev_attr_fan3_div);
+	device_create_file_in(client, 0);
+	device_create_file_in(client, 1);
+	device_create_file_in(client, 2);
+	device_create_file_in(client, 3);
+	device_create_file_in(client, 4);
+	device_create_file_in(client, 5);
+	device_create_file_in(client, 6);
+	device_create_file_in(client, 7);
+	device_create_file_in(client, 8);
+	device_create_file_in(client, 9);
+
+	device_create_file_fan(client, 1);
+	device_create_file_fan(client, 2);
+	device_create_file_fan(client, 3);
 
 	if (data->has_fan & (1 << 3)) {
-		device_create_file(&client->dev, &dev_attr_fan4_input);
-		device_create_file(&client->dev, &dev_attr_fan4_min);
-		device_create_file(&client->dev, &dev_attr_fan4_div);
+		device_create_file_fan(client, 4);
 	}
 	if (data->has_fan & (1 << 4)) {
-		device_create_file(&client->dev, &dev_attr_fan5_input);
-		device_create_file(&client->dev, &dev_attr_fan5_min);
-		device_create_file(&client->dev, &dev_attr_fan5_div);
+		device_create_file_fan(client, 5);
 	}
-
-	device_create_file(&client->dev, &dev_attr_temp1_input);
-	device_create_file(&client->dev, &dev_attr_temp1_max);
-	device_create_file(&client->dev, &dev_attr_temp1_max_hyst);
-	device_create_file(&client->dev, &dev_attr_temp2_input);
-	device_create_file(&client->dev, &dev_attr_temp2_max);
-	device_create_file(&client->dev, &dev_attr_temp2_max_hyst);
-	device_create_file(&client->dev, &dev_attr_temp3_input);
-	device_create_file(&client->dev, &dev_attr_temp3_max);
-	device_create_file(&client->dev, &dev_attr_temp3_max_hyst);
+	
+	device_create_file_temp(client, 1);
+	device_create_file_temp(client, 2);
+	device_create_file_temp(client, 3);
 
 	return 0;
 
 
 
------------------------------------------------------------------------

_______________________________________________
lm-sensors mailing list
lm-sensors at lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#6 lore raw
In reply to Sebastian Band

Hi Rudolf, Aurelien,

Quoted 1 line

Sorry for late response. I did some quick review of this code. Maybe

Yuan can find it useful.

Quoted 3 lines

1) max and min regs are switched
2) code does not use sensor_dev_attr and uses old macro system

Yes, that's true.

Quoted 1 line

3) it contains some tweaks to force PWM (seems from Aurelian attempts

to get his PWM working :)

Quoted 1 line

I use a voltmeter to measure the output of PWM pins of the chip, I don't expect they can wire all the pwm pins....
Maybe Aurelien can use the same way?

Quoted 5 lines

I have a question now:

1) does anyone else has something to show?
2) does anyone has userspace voltage support?

Hmm, As what you see, I have do some modify in my local CVS, and the code is send to Sebastian with a user tool to give convenience in testing, but still no reply yet.

Quoted 1 line

I cant work much on this next moth (feb) busy with final exams. Well

maybe I will - as brain relax subroutine :)

Quoted 2 lines

Yuan have you this on your own schedule?

I will take a holiday from 1/26/2006 to 2/5/2005, and I'm doing something else now, maybe I can send my patch out before I leave,then Aurelien and someone else can test and modify it?

Best Regards
Yuan Mu

=============================================The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Winbond is strictly prohibited; and any information in this email irrelevant to the official business of Winbond shall be deemed as neither given nor endorsed by Winbond.

#7 lore raw
In reply to Sebastian Band

Hi all,
The attachments is the diff of linux-2.6.16-rc1 and my local CVS, These two patches use new sensor attr and add more functions, any comments and modify are welcome. Hope someone can help fix the bugs in these patches and send it out.Thanks.

It depends on "[PATCH 15/17] hwmon: Semaphore to mutex conversions" hwmon-convert-semaphores-to-mutexes.patch
The first patch is w83627ehf_use_new_sensor_device_attr.patch.txt w83627ehf_add_more_functions.patch.txt is the second.

Best Regards
Yuan Mu

=============================================The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Winbond is strictly prohibited; and any information in this email irrelevant to the official business of Winbond shall be deemed as neither given nor endorsed by Winbond. -------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: w83627ehf_use_new_sensor_device_attr.patch.txt
Url: http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060124/d5f60576/w83627ehf_use_new_sensor_device_attr.patch-0001.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: w83627ehf_add_more_functions.patch.txt
Url: http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20060124/d5f60576/w83627ehf_add_more_functions.patch-0001.txt

#8 lore raw
In reply to Sebastian Band

Hi Yuan,

Quoted 9 lines

The attachments is the diff of linux-2.6.16-rc1 and my local CVS, These two patches use new sensor attr and add more functions, any comments and modify are welcome. Hope someone can help fix the bugs in these patches and send it out.Thanks.

It depends on "[PATCH 15/17] hwmon: Semaphore to mutex conversions" hwmon-convert-semaphores-to-mutexes.patch
The first patch is w83627ehf_use_new_sensor_device_attr.patch.txt w83627ehf_add_more_functions.patch.txt is the second.

I've applied the first one to start with (use new sensor device attr), it was really good. Let alone a few minor alignment issues, the only change I'd like to do is:

for (i = 0; i < 5; i++) {
- if (!(data->has_fan & (1 << i)))
- continue;
- device_create_file_fan(dev, i);
+ if (data->has_fan & (1 << i))
+ device_create_file_fan(dev, i);
}

It's clearer and shorter that way. OK?

Also, next time, please provide -p1-style patches so that I can apply them easily using quilt. And please also include your Signed-off-by line.

I'll try to find some time tomorrow to review the second patch, unless Rudolf Marek (or anyone else for that matter) beats me to it.

Thanks,

Signature · 1 line
Jean Delvare