two questions about w83792d.c for linux-2.4

Huang0 at Winbond.com.tw Huang0 at Winbond.com.tw
Mon Feb 21 04:16:18 CET 2005


Hi Jean


> > (1) The "set" lines in /etc/sensors.conf w83792d part for voltage
> > do NOT work! While all the "set" lines for fan and temperature limit
> > can work. I can't find the reason.
> >
> > The more strange thing is that, under linux-2.6, the "set" lines for
> > voltage CAN work!
> >
> > I attached the /etc/sensors.conf w83792d part in the end of this
mail,
> > for your reference.
> 
> The file doesn't look too bad, except for the fact that multipliers
are
> somewhat unusual. Typically voltages are being attenuated by
resistors,
> so the value we want "sensors" to report are greater than those
> measured by the chip, and the multipliers in the configuration file
are
> greater than 1. Here you have multipliers less than 1 almost
everywhere.
> I'll have to take a look at the datasheet and code again to understand
> why it is.

I think the reason most of my multipliers are less than 1 is that:
The /proc/in0-in6 measured value keep such as (CR[20]*4 + CR[3E]&0x03)
Which are different from the traditional one, because they are about 4
times of CR[20]. While the /proc/in7-in8 only keep such as CR[B0]/
CR[B1],
so their multipliers are greater than 1.
I explained it in my mail sent on 2005-02-18, please refer it.

So my in0-in6 multipliers in sensors.conf is the quarter of the
traditional
one. If you multiply my multipliers of in0-in6 with the value 4, you
will
find that most of them will be greater than 1, except in0 and in1(0.8)

The multipliers in sensors.conf is corresponding with the data sheet,
You may check it. :-)


> If the 2.6 driver works OK then the problem has to be in the 2.4
driver
> itself. Can you please show the relevant function of the driver,
> together with the functions and macros it might call?

OK, please refer to the following function, Is it what you need?
static void w83792d_in(struct i2c_client *client, int operation, int
ctl_name,
			int *nrels_mag, long *results)
{
	struct w83792d_data *data = client->data;
	int nr = ctl_name - W83792D_SYSCTL_IN0;
	u16 vol_max_tmp = 0;
	u16 vol_min_tmp = 0;
	u16 vol_count = 0;
	u16 low_bits = 0;

	/* result[0]: low limit, result[1]: high limit,
	   result[2]: current value */
	if (operation == SENSORS_PROC_REAL_INFO)
		*nrels_mag = 2;
	else if (operation == SENSORS_PROC_REAL_READ) {
		w83792d_update_client(client);
		/* Read High/Low limit. */
		vol_min_tmp = data->in_min[nr];
		vol_max_tmp = data->in_max[nr];
		if(nr <= 6){
			results[0] = (vol_min_tmp * 4);
			results[1] = (vol_max_tmp * 4);
		}else{
			results[0] = vol_min_tmp;
			results[1] = vol_max_tmp;
		}

		/* Read voltage measured value. */
		vol_count = data->in[nr];
		if(nr <= 6){
			vol_count = (vol_count << 2);
			switch (nr)
			{
			case 0:  /* vin0 */
				low_bits = (data->low_bits[0]) & 0x03;
				break;
			case 1:  /* vin1 */
				low_bits = (data->low_bits[0]) & 0x0c;
				break;
			case 2:  /* vin2 */
				low_bits = (data->low_bits[0]) & 0x30;
				break;
			case 3:  /* vin3 */
				low_bits = (data->low_bits[0]) & 0xc0;
				break;
			case 4:  /* vin4 */
				low_bits = (data->low_bits[1]) & 0x03;
				break;
			case 5:  /* vin5 */
				low_bits = (data->low_bits[1]) & 0x0c;
				break;
			case 6:  /* vin6 */
				low_bits = (data->low_bits[1]) & 0x30;
				break;
			default:
				break;
			}
			vol_count = vol_count | low_bits;
		}
		results[2] = vol_count;
		*nrels_mag = 3;
	} else if (operation == SENSORS_PROC_REAL_WRITE) {
		if( *nrels_mag < 3 ){
			return;
		}

		/* Write High/Low limit into register. */
		if(nr <= 6){
			data->in_min[nr] = SENSORS_LIMIT((results[0]/4),
0, 255);
			data->in_max[nr] = SENSORS_LIMIT((results[1]/4),
0, 255);
		}else{
			data->in_min[nr] = SENSORS_LIMIT(results[0], 0,
255);
			data->in_max[nr] = SENSORS_LIMIT(results[1], 0,
255);
		}

		switch (nr)
		{
		case 0:
			w83792d_write_value(client, W83792D_REG_IN0_MIN,
					    data->in_min[nr]);
			w83792d_write_value(client, W83792D_REG_IN0_MAX,
					    data->in_max[nr]);
			break;
		case 1:
			w83792d_write_value(client, W83792D_REG_IN1_MIN,
					    data->in_min[nr]);
			w83792d_write_value(client, W83792D_REG_IN1_MAX,
					    data->in_max[nr]);
			break;
		case 2:
			w83792d_write_value(client, W83792D_REG_IN2_MIN,
					    data->in_min[nr]);
			w83792d_write_value(client, W83792D_REG_IN2_MAX,
					    data->in_max[nr]);
			break;
		case 3:
			w83792d_write_value(client, W83792D_REG_IN3_MIN,
					    data->in_min[nr]);
		      	w83792d_write_value(client, W83792D_REG_IN3_MAX,
					    data->in_max[nr]);
			break;
		case 4:
	      		w83792d_write_value(client, W83792D_REG_IN4_MIN,
					    data->in_min[nr]);
			w83792d_write_value(client, W83792D_REG_IN4_MAX,
					    data->in_max[nr]);
	      		break;
		case 5:
      			w83792d_write_value(client, W83792D_REG_IN5_MIN,
					    data->in_min[nr]);
		      	w83792d_write_value(client, W83792D_REG_IN5_MAX,
					    data->in_max[nr]);
			break;
		case 6:
	      		w83792d_write_value(client, W83792D_REG_IN6_MIN,
					    data->in_min[nr]);
			w83792d_write_value(client, W83792D_REG_IN6_MAX,
					    data->in_max[nr]);
	      		break;
		case 7:
      			w83792d_write_value(client, W83792D_REG_IN7_MIN,
					    data->in_min[nr]);
		      	w83792d_write_value(client, W83792D_REG_IN7_MAX,
					    data->in_max[nr]);
			break;
		case 8:
	      		w83792d_write_value(client, W83792D_REG_IN8_MIN,
					    data->in_min[nr]);
			w83792d_write_value(client, W83792D_REG_IN8_MAX,
					    data->in_max[nr]);
	      		break;
		default:
      			break;
		}
	}
}


> Or we can have your driver commited as-is and have it fixed
afterwards,
> at your option.

If we can NOT find the exact reason about it, then we have to fix it
next
time after we commit it into CVS. :-(


> > (2) The file kernel/include/sensors.h should be auto-generated,
instead
> > of being edited manually. But I don't know how to auto-generate the
792
> > related codes into this file.
> >
> > Now I have to manually copy the codes such as
> > #define W83792D_SYSCTL_IN0 1000
> > #define W83792D_SYSCTL_IN1 1001
> > from my w83792d.c, because if I don't copy these codes, there will
be
> > compile error.
> >
> > Could you tell me how to auto-generate the file
> > kernel/include/sensors.h?
> > Is there any script I have to run?
> 
> No there is no script to run. All you have to do is put two comment
lines
> around the SYSCTL definitions in the driver itself. Our Makefile
system
> has a rule that automatically parses all chip drivers and extract the
> lines between these comment lines from all driver, and add them to
> sensors.h. These lines are:
> 
> /* -- SENSORS SYSCTL START -- */
> 
> /* -- SENSORS SYSCTL END -- */
> 
> See all other chip drivers, they have them. It is important that you
copy
> exactly these comments, or the build process won't detect the SYSCTLs
> properly. Also note that the driver itself has to be placed in
> kernel/chips and might even need to be properly declared into
> kernel/chips/Module.mk (if "make" builds the driver properly, it must
> be OK).

Yes, you are right. It works well now.

Thanks

Best Regards
Chunhao
2005-02-21


===========================================================================================The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original author of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such person, please kindly reply the sender indicating accordingly and delete all copies of it from your computer and network server immediately. We thank you for your cooperation. It is advisable that any unauthorized use of confidential information of Winbond is strictly prohibited; and any information in this email that does not relate 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. They essentially repea!
 t the&nbsp; English statement above.¥»«H¥ó¤º©Ò§tµØ¨¹¹q¤lªº°]²£©Ê¾÷±K©Ê¸ê°T, ¶È±ÂÅv­ìµo«H¤H«ü©w¤§¦¬«H¤H¨ú¾\¤§¥Î. °²¨Ï±z¨Ã«D³Q«ü©w¤§¦¬«H¤H©Î¦]¥ô¦ó­ì¦]¦b¥¼¸g±ÂÅvªº±¡§Î¤§¤U¦¬¨ì¥»«H¥ó, ½Ð±z§iª¾­ìµo«H¤H¨Ã¥ß§Y±N«H¥ó±q¹q¸£»Pºô¸ô¦øªA¾¹¤¤¤©¥H®ø°£. ¹ï©ó±zªº¦X§@, §Ú­Ì¥ý¦¹­PÁÂ. ¯S¦¹´£¿ô, ¥ô¦ó¥¼¸g±ÂÅv¾Õ¦Û¨Ï¥ÎµØ¨¹¹q¤lªº¾÷±K¸ê°Tªº¦æ¬°¬O³QÄY®æ¸T¤îªº. «H¥ó»PµØ¨¹¹q¤lÀç·~µLÃö¤§¤º®e,¤£±oµø¬°µØ¨¹¹q¤l¤§¥ß³õ©Î·N¨£.



More information about the lm-sensors mailing list