579
593
long val = simple_strtol(buf, NULL, 10);
581
595
mutex_lock(&data->update_lock);
582
data->pwm_freq[nr] = FREQ_TO_REG(data->freq_map, val);
583
lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
584
(data->zone[nr].range << 4)
585
| data->pwm_freq[nr]);
596
/* The ADT7468 has a special high-frequency PWM output mode,
597
* where all PWM outputs are driven by a 22.5 kHz clock.
598
* This might confuse the user, but there's not much we can do. */
599
if (data->type == adt7468 && val >= 11300) { /* High freq. mode */
600
data->cfg5 &= ~ADT7468_HFPWM;
601
lm85_write_value(client, ADT7468_REG_CFG5, data->cfg5);
602
} else { /* Low freq. mode */
603
data->pwm_freq[nr] = FREQ_TO_REG(data->freq_map, val);
604
lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
605
(data->zone[nr].range << 4)
606
| data->pwm_freq[nr]);
607
if (data->type == adt7468) {
608
data->cfg5 |= ADT7468_HFPWM;
609
lm85_write_value(client, ADT7468_REG_CFG5, data->cfg5);
586
612
mutex_unlock(&data->update_lock);
1158
1184
/* Return 0 if detection is successful, -ENODEV otherwise */
1159
static int lm85_detect(struct i2c_client *client, int kind,
1160
struct i2c_board_info *info)
1185
static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info)
1162
1187
struct i2c_adapter *adapter = client->adapter;
1163
1188
int address = client->addr;
1164
1189
const char *type_name;
1190
int company, verstep;
1166
1192
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
1167
1193
/* We need to be able to do byte I/O */
1168
1194
return -ENODEV;
1171
/* If auto-detecting, determine the chip type */
1173
int company = lm85_read_value(client, LM85_REG_COMPANY);
1174
int verstep = lm85_read_value(client, LM85_REG_VERSTEP);
1176
dev_dbg(&adapter->dev, "Detecting device at 0x%02x with "
1177
"COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
1178
address, company, verstep);
1180
/* All supported chips have the version in common */
1181
if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC &&
1182
(verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) {
1183
dev_dbg(&adapter->dev, "Autodetection failed: "
1184
"unsupported version\n");
1189
/* Now, refine the detection */
1190
if (company == LM85_COMPANY_NATIONAL) {
1192
case LM85_VERSTEP_LM85C:
1195
case LM85_VERSTEP_LM85B:
1198
case LM85_VERSTEP_LM96000_1:
1199
case LM85_VERSTEP_LM96000_2:
1200
/* Check for Winbond WPCD377I */
1201
if (lm85_is_fake(client)) {
1202
dev_dbg(&adapter->dev,
1203
"Found Winbond WPCD377I, "
1209
} else if (company == LM85_COMPANY_ANALOG_DEV) {
1211
case LM85_VERSTEP_ADM1027:
1214
case LM85_VERSTEP_ADT7463:
1215
case LM85_VERSTEP_ADT7463C:
1218
case LM85_VERSTEP_ADT7468_1:
1219
case LM85_VERSTEP_ADT7468_2:
1223
} else if (company == LM85_COMPANY_SMSC) {
1225
case LM85_VERSTEP_EMC6D100_A0:
1226
case LM85_VERSTEP_EMC6D100_A1:
1227
/* Note: we can't tell a '100 from a '101 */
1230
case LM85_VERSTEP_EMC6D102:
1235
dev_dbg(&adapter->dev, "Autodetection failed: "
1236
"unknown vendor\n");
1243
type_name = "lm85b";
1246
type_name = "lm85c";
1249
type_name = "adm1027";
1252
type_name = "adt7463";
1255
type_name = "adt7468";
1258
type_name = "emc6d100";
1261
type_name = "emc6d102";
1197
/* Determine the chip type */
1198
company = lm85_read_value(client, LM85_REG_COMPANY);
1199
verstep = lm85_read_value(client, LM85_REG_VERSTEP);
1201
dev_dbg(&adapter->dev, "Detecting device at 0x%02x with "
1202
"COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
1203
address, company, verstep);
1205
/* All supported chips have the version in common */
1206
if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC &&
1207
(verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) {
1208
dev_dbg(&adapter->dev,
1209
"Autodetection failed: unsupported version\n");
1214
/* Now, refine the detection */
1215
if (company == LM85_COMPANY_NATIONAL) {
1217
case LM85_VERSTEP_LM85C:
1218
type_name = "lm85c";
1220
case LM85_VERSTEP_LM85B:
1221
type_name = "lm85b";
1223
case LM85_VERSTEP_LM96000_1:
1224
case LM85_VERSTEP_LM96000_2:
1225
/* Check for Winbond WPCD377I */
1226
if (lm85_is_fake(client)) {
1227
dev_dbg(&adapter->dev,
1228
"Found Winbond WPCD377I, ignoring\n");
1233
} else if (company == LM85_COMPANY_ANALOG_DEV) {
1235
case LM85_VERSTEP_ADM1027:
1236
type_name = "adm1027";
1238
case LM85_VERSTEP_ADT7463:
1239
case LM85_VERSTEP_ADT7463C:
1240
type_name = "adt7463";
1242
case LM85_VERSTEP_ADT7468_1:
1243
case LM85_VERSTEP_ADT7468_2:
1244
type_name = "adt7468";
1247
} else if (company == LM85_COMPANY_SMSC) {
1249
case LM85_VERSTEP_EMC6D100_A0:
1250
case LM85_VERSTEP_EMC6D100_A1:
1251
/* Note: we can't tell a '100 from a '101 */
1252
type_name = "emc6d100";
1254
case LM85_VERSTEP_EMC6D102:
1255
type_name = "emc6d102";
1257
case LM85_VERSTEP_EMC6D103_A0:
1258
case LM85_VERSTEP_EMC6D103_A1:
1259
type_name = "emc6d103";
1262
* Registers apparently missing in EMC6D103S/EMC6D103:A2
1263
* compared to EMC6D103:A0, EMC6D103:A1, and EMC6D102
1264
* (according to the data sheets), but used unconditionally
1265
* in the driver: 62[5:7], 6D[0:7], and 6E[0:7].
1266
* So skip EMC6D103S for now.
1267
case LM85_VERSTEP_EMC6D103S:
1268
type_name = "emc6d103s";
1273
dev_dbg(&adapter->dev,
1274
"Autodetection failed: unknown vendor\n");
1266
1278
strlcpy(info->type, type_name, I2C_NAME_SIZE);