~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/hwmon/w83l785ts.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * w83l785ts.c - Part of lm_sensors, Linux kernel modules for hardware
3
3
 *               monitoring
4
 
 * Copyright (C) 2003-2004  Jean Delvare <khali@linux-fr.org>
 
4
 * Copyright (C) 2003-2009  Jean Delvare <khali@linux-fr.org>
5
5
 *
6
6
 * Inspired from the lm83 driver. The W83L785TS-S is a sensor chip made
7
7
 * by Winbond. It reports a single external temperature with a 1 deg
52
52
static const unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
53
53
 
54
54
/*
55
 
 * Insmod parameters
56
 
 */
57
 
 
58
 
I2C_CLIENT_INSMOD_1(w83l785ts);
59
 
 
60
 
/*
61
55
 * The W83L785TS-S registers
62
56
 * Manufacturer ID is 0x5CA3 for Winbond.
63
57
 */
83
77
 
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);
94
88
 */
95
89
 
96
90
static const struct i2c_device_id w83l785ts_id[] = {
97
 
        { "w83l785ts", w83l785ts },
 
91
        { "w83l785ts", 0 },
98
92
        { }
99
93
};
100
94
MODULE_DEVICE_TABLE(i2c, w83l785ts_id);
108
102
        .remove         = w83l785ts_remove,
109
103
        .id_table       = w83l785ts_id,
110
104
        .detect         = w83l785ts_detect,
111
 
        .address_data   = &addr_data,
 
105
        .address_list   = normal_i2c,
112
106
};
113
107
 
114
108
/*
146
140
 */
147
141
 
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)
151
145
{
152
 
        struct i2c_adapter *adapter = new_client->adapter;
 
146
        struct i2c_adapter *adapter = client->adapter;
 
147
        u16 man_id;
 
148
        u8 chip_id;
153
149
 
154
150
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
155
151
                return -ENODEV;
156
152
 
157
 
        /*
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
166
 
         * are skipped.
167
 
         */
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",
175
 
                                new_client->addr);
176
 
                        return -ENODEV;
177
 
                }
 
153
        /* detection */
 
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",
 
158
                        client->addr);
 
159
                return -ENODEV;
178
160
        }
179
161
 
180
 
        if (kind <= 0) { /* identification */
181
 
                u16 man_id;
182
 
                u8 chip_id;
183
 
 
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);
190
 
 
191
 
                if (man_id == 0x5CA3) { /* Winbond */
192
 
                        if (chip_id == 0x70) { /* W83L785TS-S */
193
 
                                kind = w83l785ts;                       
194
 
                        }
195
 
                }
196
 
        
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);
201
 
                        return -ENODEV;
202
 
                }
 
162
        /* Identification */
 
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);
 
166
 
 
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",
 
171
                        man_id, chip_id);
 
172
                return -ENODEV;
203
173
        }
204
174
 
205
175
        strlcpy(info->type, "w83l785ts", I2C_NAME_SIZE);