u8 rpm_output[2]; /* The fan RPM data for fans 1 and 2 is then * written to registers RPM1 and RPM2
*/
u8 fan_fault[2]; /* The Fan Fault Threshold Registers are used to * set the fan fault threshold levels for fan 1 * and fan 2
*/
u8 config; /* The Configuration Register is an 8-bit read/ * writable multi-function control register * 7: Fan Fault Clear * 1 = Clear Fan Fault * 0 = Normal Operation (default) * 6: Resolution Selection for RPM Output Registers * RPM Output Registers (RPM1 and RPM2) will be * set for * 1 = 25 RPM (9-bit) resolution * 0 = 50 RPM (8-bit) resolution (default) * 5: Duty Cycle Control Method * The V OUT duty cycle will be controlled via * 1 = the SMBus interface. * 0 = via the V IN analog input pin. (default) * 4,3: Fan 2 Pulses Per Rotation * 00 = 1 * 01 = 2 (default) * 10 = 4 * 11 = 8 * 2,1: Fan 1 Pulses Per Rotation * 00 = 1 * 01 = 2 (default) * 10 = 4 * 11 = 8 * 0: Shutdown Mode * 1 = Shutdown mode. * 0 = Normal operation. (default)
*/
u8 status; /* The Status register provides all the information * about what is going on within the TC654/TC655 * devices. * 7,6: Unimplemented, Read as '0' * 5: Over-Temperature Fault Condition * 1 = Over-Temperature condition has occurred * 0 = Normal operation. V IN is less than 2.6V * 4: RPM2 Counter Overflow * 1 = Fault condition * 0 = Normal operation * 3: RPM1 Counter Overflow * 1 = Fault condition * 0 = Normal operation * 2: V IN Input Status * 1 = V IN is open * 0 = Normal operation. voltage present at V IN * 1: Fan 2 Fault * 1 = Fault condition * 0 = Normal operation * 0: Fan 1 Fault * 1 = Fault condition * 0 = Normal operation
*/
u8 duty_cycle; /* The DUTY_CYCLE register is a 4-bit read/ * writable register used to control the duty * cycle of the V OUT output.
*/
};
/* helper to grab and cache data, at most one time per second */ staticstruct tc654_data *tc654_update_client(struct device *dev)
{ struct tc654_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; int ret = 0;
mutex_lock(&data->update_lock); if (time_before(jiffies, data->last_updated + TC654_UPDATE_INTERVAL) &&
likely(data->valid)) goto out;
ret = i2c_smbus_read_byte_data(client, TC654_REG_RPM(0)); if (ret < 0) goto out;
data->rpm_output[0] = ret;
ret = i2c_smbus_read_byte_data(client, TC654_REG_RPM(1)); if (ret < 0) goto out;
data->rpm_output[1] = ret;
ret = i2c_smbus_read_byte_data(client, TC654_REG_FAN_FAULT(0)); if (ret < 0) goto out;
data->fan_fault[0] = ret;
ret = i2c_smbus_read_byte_data(client, TC654_REG_FAN_FAULT(1)); if (ret < 0) goto out;
data->fan_fault[1] = ret;
ret = i2c_smbus_read_byte_data(client, TC654_REG_CONFIG); if (ret < 0) goto out;
data->config = ret;
ret = i2c_smbus_read_byte_data(client, TC654_REG_STATUS); if (ret < 0) goto out;
data->status = ret;
ret = i2c_smbus_read_byte_data(client, TC654_REG_DUTY_CYCLE); if (ret < 0) goto out;
data->duty_cycle = ret & 0x0f;
if (ret < 0) /* upon error, encode it in return value */
data = ERR_PTR(ret);
return data;
}
/* * sysfs attributes
*/
static ssize_t fan_show(struct device *dev, struct device_attribute *da, char *buf)
{ int nr = to_sensor_dev_attr(da)->index; struct tc654_data *data = tc654_update_client(dev); int val;
if (IS_ERR(data)) return PTR_ERR(data);
if (data->config & TC654_REG_CONFIG_RES)
val = data->rpm_output[nr] * TC654_HIGH_RPM_RESOLUTION; else
val = data->rpm_output[nr] * TC654_LOW_RPM_RESOLUTION;
return sprintf(buf, "%d\n", val);
}
static ssize_t fan_min_show(struct device *dev, struct device_attribute *da, char *buf)
{ int nr = to_sensor_dev_attr(da)->index; struct tc654_data *data = tc654_update_client(dev);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.