Skip to content

Commit 234a56c

Browse files
committed
Merge tag 'hwmon-for-linus-v4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck: - new driver for Microchip TC74 - support for ncpXXwf104 added to ntc_thermistor driver - minor cleanup * tag 'hwmon-for-linus-v4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: add driver for Microchip TC74 hwmon: (ntc_thermistor) Improve precision of resistance calculation hwmon: (ntc_thermistor) fix iio raw to microvolts conversion hwmon: (atxp1) Drop auto-detection hwmon: (atxp1) Drop FSF mailing address hwmon: Allow compile test of GPIO consumers if !GPIOLIB hwmon: (sht15) Constify platform_device_id hwmon: (max197) Constify platform_device_id hwmon: (ntc_thermistor) Add support for ncpXXwf104
2 parents a57f14b + 761c177 commit 234a56c

File tree

11 files changed

+290
-78
lines changed

11 files changed

+290
-78
lines changed

Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Requires node properties:
99
"murata,ncp21wb473"
1010
"murata,ncp03wb473"
1111
"murata,ncp15wl333"
12+
"murata,ncp03wf104"
1213

1314
/* Usage of vendor name "ntc" is deprecated */
1415
<DEPRECATED> "ntc,ncp15wb473"

Documentation/hwmon/ntc_thermistor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ Kernel driver ntc_thermistor
22
=================
33

44
Supported thermistors from Murata:
5-
* Murata NTC Thermistors NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333
6-
Prefixes: 'ncp15wb473', 'ncp18wb473', 'ncp21wb473', 'ncp03wb473', 'ncp15wl333'
5+
* Murata NTC Thermistors NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473,
6+
NCP15WL333, NCP03WF104
7+
Prefixes: 'ncp15wb473', 'ncp18wb473', 'ncp21wb473', 'ncp03wb473',
8+
'ncp15wl333', 'ncp03wf104'
79
Datasheet: Publicly available at Murata
810

911
Supported thermistors from EPCOS:

Documentation/hwmon/tc74

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Kernel driver tc74
2+
====================
3+
4+
Supported chips:
5+
* Microchip TC74
6+
Prefix: 'tc74'
7+
Datasheet: Publicly available at Microchip website.
8+
9+
Description
10+
-----------
11+
12+
Driver supports the above part.
13+
14+
The tc74 has an 8-bit sensor, with 1 degree centigrade resolution
15+
and +- 2 degrees centigrade accuracy.
16+
17+
Notes
18+
-----
19+
20+
Currently entering low power standby mode is not supported.

drivers/hwmon/Kconfig

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ config SENSORS_G762
509509

510510
config SENSORS_GPIO_FAN
511511
tristate "GPIO fan"
512-
depends on GPIOLIB
512+
depends on GPIOLIB || COMPILE_TEST
513513
depends on THERMAL || THERMAL=n
514514
help
515515
If you say yes here you get support for fans connected to GPIO lines.
@@ -1106,8 +1106,8 @@ config SENSORS_NTC_THERMISTOR
11061106
send notifications about the temperature.
11071107

11081108
Currently, this driver supports
1109-
NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, and NCP15WL333
1110-
from Murata and B57330V2103 from EPCOS.
1109+
NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333,
1110+
and NCP03WF104 from Murata and B57330V2103 from EPCOS.
11111111

11121112
This driver can also be built as a module. If so, the module
11131113
will be called ntc-thermistor.
@@ -1186,7 +1186,7 @@ config SENSORS_PWM_FAN
11861186

11871187
config SENSORS_SHT15
11881188
tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
1189-
depends on GPIOLIB
1189+
depends on GPIOLIB || COMPILE_TEST
11901190
help
11911191
If you say yes here you get support for the Sensiron SHT10, SHT11,
11921192
SHT15, SHT71, SHT75 humidity and temperature sensors.
@@ -1452,6 +1452,16 @@ config SENSORS_INA2XX
14521452
This driver can also be built as a module. If so, the module
14531453
will be called ina2xx.
14541454

1455+
config SENSORS_TC74
1456+
tristate "Microchip TC74"
1457+
depends on I2C
1458+
help
1459+
If you say yes here you get support for Microchip TC74 single
1460+
input temperature sensor chips.
1461+
1462+
This driver can also be built as a module. If so, the module
1463+
will be called tc74.
1464+
14551465
config SENSORS_THMC50
14561466
tristate "Texas Instruments THMC50 / Analog Devices ADM1022"
14571467
depends on I2C

drivers/hwmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
140140
obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
141141
obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
142142
obj-$(CONFIG_SENSORS_AMC6821) += amc6821.o
143+
obj-$(CONFIG_SENSORS_TC74) += tc74.o
143144
obj-$(CONFIG_SENSORS_THMC50) += thmc50.o
144145
obj-$(CONFIG_SENSORS_TMP102) += tmp102.o
145146
obj-$(CONFIG_SENSORS_TMP103) += tmp103.o

drivers/hwmon/atxp1.c

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
* GNU General Public License for more details.
1414
*
15-
* You should have received a copy of the GNU General Public License
16-
* along with this program; if not, write to the Free Software
17-
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18-
*
15+
* The ATXP1 can reside on I2C addresses 0x37 or 0x4e. The chip is
16+
* not auto-detected by the driver and must be instantiated explicitly.
17+
* See Documentation/i2c/instantiating-devices for more information.
1918
*/
2019

2120
#include <linux/kernel.h>
@@ -43,8 +42,6 @@ MODULE_AUTHOR("Sebastian Witt <[email protected]>");
4342
#define ATXP1_VIDMASK 0x1f
4443
#define ATXP1_GPIO1MASK 0x0f
4544

46-
static const unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
47-
4845
struct atxp1_data {
4946
struct i2c_client *client;
5047
struct mutex update_lock;
@@ -259,48 +256,6 @@ static struct attribute *atxp1_attrs[] = {
259256
};
260257
ATTRIBUTE_GROUPS(atxp1);
261258

262-
/* Return 0 if detection is successful, -ENODEV otherwise */
263-
static int atxp1_detect(struct i2c_client *new_client,
264-
struct i2c_board_info *info)
265-
{
266-
struct i2c_adapter *adapter = new_client->adapter;
267-
268-
u8 temp;
269-
270-
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
271-
return -ENODEV;
272-
273-
/* Detect ATXP1, checking if vendor ID registers are all zero */
274-
if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) &&
275-
(i2c_smbus_read_byte_data(new_client, 0x3f) == 0) &&
276-
(i2c_smbus_read_byte_data(new_client, 0xfe) == 0) &&
277-
(i2c_smbus_read_byte_data(new_client, 0xff) == 0)))
278-
return -ENODEV;
279-
280-
/*
281-
* No vendor ID, now checking if registers 0x10,0x11 (non-existent)
282-
* showing the same as register 0x00
283-
*/
284-
temp = i2c_smbus_read_byte_data(new_client, 0x00);
285-
286-
if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) &&
287-
(i2c_smbus_read_byte_data(new_client, 0x11) == temp)))
288-
return -ENODEV;
289-
290-
/* Get VRM */
291-
temp = vid_which_vrm();
292-
293-
if ((temp != 90) && (temp != 91)) {
294-
dev_err(&adapter->dev, "atxp1: Not supporting VRM %d.%d\n",
295-
temp / 10, temp % 10);
296-
return -ENODEV;
297-
}
298-
299-
strlcpy(info->type, "atxp1", I2C_NAME_SIZE);
300-
301-
return 0;
302-
}
303-
304259
static int atxp1_probe(struct i2c_client *client,
305260
const struct i2c_device_id *id)
306261
{
@@ -314,6 +269,11 @@ static int atxp1_probe(struct i2c_client *client,
314269

315270
/* Get VRM */
316271
data->vrm = vid_which_vrm();
272+
if (data->vrm != 90 && data->vrm != 91) {
273+
dev_err(dev, "atxp1: Not supporting VRM %d.%d\n",
274+
data->vrm / 10, data->vrm % 10);
275+
return -ENODEV;
276+
}
317277

318278
data->client = client;
319279
mutex_init(&data->update_lock);
@@ -342,8 +302,6 @@ static struct i2c_driver atxp1_driver = {
342302
},
343303
.probe = atxp1_probe,
344304
.id_table = atxp1_id,
345-
.detect = atxp1_detect,
346-
.address_list = normal_i2c,
347305
};
348306

349307
module_i2c_driver(atxp1_driver);

drivers/hwmon/max197.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ static int max197_remove(struct platform_device *pdev)
324324
return 0;
325325
}
326326

327-
static struct platform_device_id max197_device_ids[] = {
327+
static const struct platform_device_id max197_device_ids[] = {
328328
{ "max197", max197 },
329329
{ "max199", max199 },
330330
{ }

drivers/hwmon/ntc_thermistor.c

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static const struct platform_device_id ntc_thermistor_id[] = {
5353
{ "ncp03wb473", TYPE_NCPXXWB473 },
5454
{ "ncp15wl333", TYPE_NCPXXWL333 },
5555
{ "b57330v2103", TYPE_B57330V2103},
56+
{ "ncp03wf104", TYPE_NCPXXWF104 },
5657
{ },
5758
};
5859

@@ -135,6 +136,43 @@ static const struct ntc_compensation ncpXXwl333[] = {
135136
{ .temp_c = 125, .ohm = 707 },
136137
};
137138

139+
static const struct ntc_compensation ncpXXwf104[] = {
140+
{ .temp_c = -40, .ohm = 4397119 },
141+
{ .temp_c = -35, .ohm = 3088599 },
142+
{ .temp_c = -30, .ohm = 2197225 },
143+
{ .temp_c = -25, .ohm = 1581881 },
144+
{ .temp_c = -20, .ohm = 1151037 },
145+
{ .temp_c = -15, .ohm = 846579 },
146+
{ .temp_c = -10, .ohm = 628988 },
147+
{ .temp_c = -5, .ohm = 471632 },
148+
{ .temp_c = 0, .ohm = 357012 },
149+
{ .temp_c = 5, .ohm = 272500 },
150+
{ .temp_c = 10, .ohm = 209710 },
151+
{ .temp_c = 15, .ohm = 162651 },
152+
{ .temp_c = 20, .ohm = 127080 },
153+
{ .temp_c = 25, .ohm = 100000 },
154+
{ .temp_c = 30, .ohm = 79222 },
155+
{ .temp_c = 35, .ohm = 63167 },
156+
{ .temp_c = 40, .ohm = 50677 },
157+
{ .temp_c = 45, .ohm = 40904 },
158+
{ .temp_c = 50, .ohm = 33195 },
159+
{ .temp_c = 55, .ohm = 27091 },
160+
{ .temp_c = 60, .ohm = 22224 },
161+
{ .temp_c = 65, .ohm = 18323 },
162+
{ .temp_c = 70, .ohm = 15184 },
163+
{ .temp_c = 75, .ohm = 12635 },
164+
{ .temp_c = 80, .ohm = 10566 },
165+
{ .temp_c = 85, .ohm = 8873 },
166+
{ .temp_c = 90, .ohm = 7481 },
167+
{ .temp_c = 95, .ohm = 6337 },
168+
{ .temp_c = 100, .ohm = 5384 },
169+
{ .temp_c = 105, .ohm = 4594 },
170+
{ .temp_c = 110, .ohm = 3934 },
171+
{ .temp_c = 115, .ohm = 3380 },
172+
{ .temp_c = 120, .ohm = 2916 },
173+
{ .temp_c = 125, .ohm = 2522 },
174+
};
175+
138176
/*
139177
* The following compensation table is from the specification of EPCOS NTC
140178
* Thermistors Datasheet
@@ -190,20 +228,21 @@ struct ntc_data {
190228
static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
191229
{
192230
struct iio_channel *channel = pdata->chan;
193-
s64 result;
194-
int val, ret;
231+
int raw, uv, ret;
195232

196-
ret = iio_read_channel_raw(channel, &val);
233+
ret = iio_read_channel_raw(channel, &raw);
197234
if (ret < 0) {
198235
pr_err("read channel() error: %d\n", ret);
199236
return ret;
200237
}
201238

202-
/* unit: mV */
203-
result = pdata->pullup_uv * (s64) val;
204-
result >>= 12;
239+
ret = iio_convert_raw_to_processed(channel, raw, &uv, 1000);
240+
if (ret < 0) {
241+
/* Assume 12 bit ADC with vref at pullup_uv */
242+
uv = (pdata->pullup_uv * (s64)raw) >> 12;
243+
}
205244

206-
return (int)result;
245+
return uv;
207246
}
208247

209248
static const struct of_device_id ntc_match[] = {
@@ -219,6 +258,8 @@ static const struct of_device_id ntc_match[] = {
219258
.data = &ntc_thermistor_id[4] },
220259
{ .compatible = "epcos,b57330v2103",
221260
.data = &ntc_thermistor_id[5]},
261+
{ .compatible = "murata,ncp03wf104",
262+
.data = &ntc_thermistor_id[6] },
222263

223264
/* Usage of vendor name "ntc" is deprecated */
224265
{ .compatible = "ntc,ncp15wb473",
@@ -309,30 +350,27 @@ static inline u64 div64_u64_safe(u64 dividend, u64 divisor)
309350
static int get_ohm_of_thermistor(struct ntc_data *data, unsigned int uv)
310351
{
311352
struct ntc_thermistor_platform_data *pdata = data->pdata;
312-
u64 mv = uv / 1000;
313-
u64 pmv = pdata->pullup_uv / 1000;
353+
u32 puv = pdata->pullup_uv;
314354
u64 n, puo, pdo;
315355
puo = pdata->pullup_ohm;
316356
pdo = pdata->pulldown_ohm;
317357

318-
if (mv == 0) {
319-
if (pdata->connect == NTC_CONNECTED_POSITIVE)
320-
return INT_MAX;
321-
return 0;
322-
}
323-
if (mv >= pmv)
358+
if (uv == 0)
359+
return (pdata->connect == NTC_CONNECTED_POSITIVE) ?
360+
INT_MAX : 0;
361+
if (uv >= puv)
324362
return (pdata->connect == NTC_CONNECTED_POSITIVE) ?
325363
0 : INT_MAX;
326364

327365
if (pdata->connect == NTC_CONNECTED_POSITIVE && puo == 0)
328-
n = div64_u64_safe(pdo * (pmv - mv), mv);
366+
n = div_u64(pdo * (puv - uv), uv);
329367
else if (pdata->connect == NTC_CONNECTED_GROUND && pdo == 0)
330-
n = div64_u64_safe(puo * mv, pmv - mv);
368+
n = div_u64(puo * uv, puv - uv);
331369
else if (pdata->connect == NTC_CONNECTED_POSITIVE)
332-
n = div64_u64_safe(pdo * puo * (pmv - mv),
333-
puo * mv - pdo * (pmv - mv));
370+
n = div64_u64_safe(pdo * puo * (puv - uv),
371+
puo * uv - pdo * (puv - uv));
334372
else
335-
n = div64_u64_safe(pdo * puo * mv, pdo * (pmv - mv) - puo * mv);
373+
n = div64_u64_safe(pdo * puo * uv, pdo * (puv - uv) - puo * uv);
336374

337375
if (n > INT_MAX)
338376
n = INT_MAX;
@@ -567,6 +605,10 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
567605
data->comp = b57330v2103;
568606
data->n_comp = ARRAY_SIZE(b57330v2103);
569607
break;
608+
case TYPE_NCPXXWF104:
609+
data->comp = ncpXXwf104;
610+
data->n_comp = ARRAY_SIZE(ncpXXwf104);
611+
break;
570612
default:
571613
dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n",
572614
pdev_id->driver_data, pdev_id->name);

drivers/hwmon/sht15.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ static int sht15_remove(struct platform_device *pdev)
10741074
return 0;
10751075
}
10761076

1077-
static struct platform_device_id sht15_device_ids[] = {
1077+
static const struct platform_device_id sht15_device_ids[] = {
10781078
{ "sht10", sht10 },
10791079
{ "sht11", sht11 },
10801080
{ "sht15", sht15 },

0 commit comments

Comments
 (0)