84
78
static int w83l785ts_probe(struct i2c_client *client,
85
79
const struct i2c_device_id *id);
86
static int w83l785ts_detect(struct i2c_client *client, int kind,
80
static int w83l785ts_detect(struct i2c_client *client,
87
81
struct i2c_board_info *info);
88
82
static int w83l785ts_remove(struct i2c_client *client);
89
83
static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval);
148
142
/* Return 0 if detection is successful, -ENODEV otherwise */
149
static int w83l785ts_detect(struct i2c_client *new_client, int kind,
143
static int w83l785ts_detect(struct i2c_client *client,
150
144
struct i2c_board_info *info)
152
struct i2c_adapter *adapter = new_client->adapter;
146
struct i2c_adapter *adapter = client->adapter;
154
150
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
158
* Now we do the remaining detection. A negative kind means that
159
* the driver was loaded with no force parameter (default), so we
160
* must both detect and identify the chip (actually there is only
161
* one possible kind of chip for now, W83L785TS-S). A zero kind means
162
* that the driver was loaded with the force parameter, the detection
163
* step shall be skipped. A positive kind means that the driver
164
* was loaded with the force parameter and a given kind of chip is
165
* requested, so both the detection and the identification steps
168
if (kind < 0) { /* detection */
169
if (((w83l785ts_read_value(new_client,
170
W83L785TS_REG_CONFIG, 0) & 0x80) != 0x00)
171
|| ((w83l785ts_read_value(new_client,
172
W83L785TS_REG_TYPE, 0) & 0xFC) != 0x00)) {
173
dev_dbg(&adapter->dev,
174
"W83L785TS-S detection failed at 0x%02x.\n",
154
if ((w83l785ts_read_value(client, W83L785TS_REG_CONFIG, 0) & 0x80)
155
|| (w83l785ts_read_value(client, W83L785TS_REG_TYPE, 0) & 0xFC)) {
156
dev_dbg(&adapter->dev,
157
"W83L785TS-S detection failed at 0x%02x\n",
180
if (kind <= 0) { /* identification */
184
man_id = (w83l785ts_read_value(new_client,
185
W83L785TS_REG_MAN_ID1, 0) << 8) +
186
w83l785ts_read_value(new_client,
187
W83L785TS_REG_MAN_ID2, 0);
188
chip_id = w83l785ts_read_value(new_client,
189
W83L785TS_REG_CHIP_ID, 0);
191
if (man_id == 0x5CA3) { /* Winbond */
192
if (chip_id == 0x70) { /* W83L785TS-S */
197
if (kind <= 0) { /* identification failed */
198
dev_info(&adapter->dev,
199
"Unsupported chip (man_id=0x%04X, "
200
"chip_id=0x%02X).\n", man_id, chip_id);
163
man_id = (w83l785ts_read_value(client, W83L785TS_REG_MAN_ID1, 0) << 8)
164
+ w83l785ts_read_value(client, W83L785TS_REG_MAN_ID2, 0);
165
chip_id = w83l785ts_read_value(client, W83L785TS_REG_CHIP_ID, 0);
167
if (man_id != 0x5CA3 /* Winbond */
168
|| chip_id != 0x70) { /* W83L785TS-S */
169
dev_dbg(&adapter->dev,
170
"Unsupported chip (man_id=0x%04X, chip_id=0x%02X)\n",
205
175
strlcpy(info->type, "w83l785ts", I2C_NAME_SIZE);