Esempio n. 1
0
void sis5595_fan_div(struct i2c_client *client, int operation,
		     int ctl_name, int *nrels_mag, long *results)
{
	struct sis5595_data *data = client->data;
	int old;

	if (operation == SENSORS_PROC_REAL_INFO)
		*nrels_mag = 0;
	else if (operation == SENSORS_PROC_REAL_READ) {
		sis5595_update_client(client);
		results[0] = DIV_FROM_REG(data->fan_div[0]);
		results[1] = DIV_FROM_REG(data->fan_div[1]);
		*nrels_mag = 2;
	} else if (operation == SENSORS_PROC_REAL_WRITE) {
		old = sis5595_read_value(client, SIS5595_REG_FANDIV);
		if (*nrels_mag >= 2) {
			data->fan_div[1] = DIV_TO_REG(results[1]);
			old = (old & 0x3f) | (data->fan_div[1] << 6);
		}
		if (*nrels_mag >= 1) {
			data->fan_div[0] = DIV_TO_REG(results[0]);
			old = (old & 0xcf) | (data->fan_div[0] << 4);
			sis5595_write_value(client, SIS5595_REG_FANDIV, old);
		}
	}
}
Esempio n. 2
0
/* Called when we have found a new GL520SM. It should set limits, etc. */
void gl520_init_client(struct i2c_client *client)
{
	/* Power-on defaults (bit 7=1) */
	gl520_write_value(client, GL520_REG_CONF, 0x80);

	/* No noisy output (bit 2=1), Comparator mode (bit 3=0), two fans (bit4=0),
	   standby mode (bit6=0) */
	gl520_write_value(client, GL520_REG_CONF, 0x04);

	/* Never interrupts */
	gl520_write_value(client, GL520_REG_MASK, 0x00);

	gl520_write_value(client, GL520_REG_TEMP1_HYST,
			  TEMP_TO_REG(GL520_INIT_TEMP_HYST));
	gl520_write_value(client, GL520_REG_TEMP1_OVER,
			  TEMP_TO_REG(GL520_INIT_TEMP_OVER));

	/* We set Temp2, but not Vin4. */
	gl520_write_value(client, GL520_REG_TEMP2_HYST,
			  TEMP_TO_REG(GL520_INIT_TEMP_HYST));
	gl520_write_value(client, GL520_REG_TEMP2_OVER,
			  TEMP_TO_REG(GL520_INIT_TEMP_OVER));

	gl520_write_value(client, GL520_REG_MISC, (DIV_TO_REG(2) << 6) |
			  (DIV_TO_REG(2) << 4));
	gl520_write_value(client, GL520_REG_FAN_LIMIT,
			  (FAN_TO_REG(GL520_INIT_FAN_MIN_1, 2) << 8) |
			  FAN_TO_REG(GL520_INIT_FAN_MIN_2, 2));

	gl520_write_value(client, GL520_REG_VIN1_LIMIT,
			  (IN_TO_REG(GL520_INIT_VIN_MAX_1) << 8) |
			  IN_TO_REG(GL520_INIT_VIN_MIN_1));
	gl520_write_value(client, GL520_REG_VIN2_LIMIT,
			  (IN_TO_REG(GL520_INIT_VIN_MAX_2) << 8) |
			  IN_TO_REG(GL520_INIT_VIN_MIN_2));
	gl520_write_value(client, GL520_REG_VIN3_LIMIT,
			  (IN_TO_REG(GL520_INIT_VIN_MAX_3) << 8) |
			  IN_TO_REG(GL520_INIT_VIN_MIN_3));
	gl520_write_value(client, GL520_REG_VDD_LIMIT,
			  (VDD_TO_REG(GL520_INIT_VDD_MAX) << 8) |
			  VDD_TO_REG(GL520_INIT_VDD_MIN));

	/* Clear status register (bit 5=1), start (bit6=1) */
	gl520_write_value(client, GL520_REG_CONF, 0x24);
	gl520_write_value(client, GL520_REG_CONF, 0x44);
}