aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonggeun Kim <dg77.kim@samsung.com>2011-06-20 03:48:19 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-07-28 03:17:33 -0400
commitf22aaaa70d8c24e5dc7d23a219c4beace8354b65 (patch)
tree855158946f04f4d4846b7cab573d55652163ec18
parentdabaa0d2b4085a2037d80a40b86ba215f00b601e (diff)
hwmon: Driver for NTC Thermistors
Add support for NTC Thermistor series. In this release, the following thermistors are supported: NCP15WB473, NCP18WB473, NCP03WB473, and NCP15WL333. This driver is based on the datasheet of MURATA. The driver in the patch does conversion from the raw ADC value (either voltage or resistence) to temperature. In order to use voltage values as input, the circuit schematics should be provided with the platform data. A compensation table for each type of thermistor is provided for the conversion. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: KyungMin Park <kyungmin.park@samsung.com> Reviewed-by: Shubhrajyoti D <shubhrajyoti@ti.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
-rw-r--r--Documentation/hwmon/ntc_thermistor93
-rw-r--r--drivers/hwmon/Kconfig14
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/ntc_thermistor.c453
-rw-r--r--include/linux/platform_data/ntc_thermistor.h53
5 files changed, 614 insertions, 0 deletions
diff --git a/Documentation/hwmon/ntc_thermistor b/Documentation/hwmon/ntc_thermistor
new file mode 100644
index 000000000000..3bfda94096fd
--- /dev/null
+++ b/Documentation/hwmon/ntc_thermistor
@@ -0,0 +1,93 @@
1Kernel driver ntc_thermistor
2=================
3
4Supported thermistors:
5* Murata NTC Thermistors NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333
6 Prefixes: 'ncp15wb473', 'ncp18wb473', 'ncp21wb473', 'ncp03wb473', 'ncp15wl333'
7 Datasheet: Publicly available at Murata
8
9Other NTC thermistors can be supported simply by adding compensation
10tables; e.g., NCP15WL333 support is added by the table ncpXXwl333.
11
12Authors:
13 MyungJoo Ham <myungjoo.ham@samsung.com>
14
15Description
16-----------
17
18The NTC thermistor is a simple thermistor that requires users to provide the
19resistance and lookup the corresponding compensation table to get the
20temperature input.
21
22The NTC driver provides lookup tables with a linear approximation function
23and four circuit models with an option not to use any of the four models.
24
25The four circuit models provided are:
26
27 $: resister, [TH]: the thermistor
28
29 1. connect = NTC_CONNECTED_POSITIVE, pullup_ohm > 0
30
31 [pullup_uV]
32 | |
33 [TH] $ (pullup_ohm)
34 | |
35 +----+-----------------------[read_uV]
36 |
37 $ (pulldown_ohm)
38 |
39 --- (ground)
40
41 2. connect = NTC_CONNECTED_POSITIVE, pullup_ohm = 0 (not-connected)
42
43 [pullup_uV]
44 |
45 [TH]
46 |
47 +----------------------------[read_uV]
48 |
49 $ (pulldown_ohm)
50 |
51 --- (ground)
52
53 3. connect = NTC_CONNECTED_GROUND, pulldown_ohm > 0
54
55 [pullup_uV]
56 |
57 $ (pullup_ohm)
58 |
59 +----+-----------------------[read_uV]
60 | |
61 [TH] $ (pulldown_ohm)
62 | |
63 -------- (ground)
64
65 4. connect = NTC_CONNECTED_GROUND, pulldown_ohm = 0 (not-connected)
66
67 [pullup_uV]
68 |
69 $ (pullup_ohm)
70 |
71 +----------------------------[read_uV]
72 |
73 [TH]
74 |
75 --- (ground)
76
77When one of the four circuit models is used, read_uV, pullup_uV, pullup_ohm,
78pulldown_ohm, and connect should be provided. When none of the four models
79are suitable or the user can get the resistance directly, the user should
80provide read_ohm and _not_ provide the others.
81
82Sysfs Interface
83---------------
84name the mandatory global attribute, the thermistor name.
85
86temp1_type always 4 (thermistor)
87 RO
88
89temp1_input measure the temperature and provide the measured value.
90 (reading this file initiates the reading procedure.)
91 RO
92
93Note that each NTC thermistor has only _one_ thermistor; thus, only temp1 exists.
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index dec5eee3542f..770fc8195627 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -777,6 +777,20 @@ config SENSORS_MAX6650
777 This driver can also be built as a module. If so, the module 777 This driver can also be built as a module. If so, the module
778 will be called max6650. 778 will be called max6650.
779 779
780config SENSORS_NTC_THERMISTOR
781 tristate "NTC thermistor support"
782 depends on EXPERIMENTAL
783 help
784 This driver supports NTC thermistors sensor reading and its
785 interpretation. The driver can also monitor the temperature and
786 send notifications about the temperature.
787
788 Currently, this driver supports
789 NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, and NCP15WL333.
790
791 This driver can also be built as a module. If so, the module
792 will be called ntc-thermistor.
793
780config SENSORS_PC87360 794config SENSORS_PC87360
781 tristate "National Semiconductor PC87360 family" 795 tristate "National Semiconductor PC87360 family"
782 select HWMON_VID 796 select HWMON_VID
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index a6d519e568c0..1b7dc770aa60 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -92,6 +92,7 @@ obj-$(CONFIG_SENSORS_MAX6639) += max6639.o
92obj-$(CONFIG_SENSORS_MAX6642) += max6642.o 92obj-$(CONFIG_SENSORS_MAX6642) += max6642.o
93obj-$(CONFIG_SENSORS_MAX6650) += max6650.o 93obj-$(CONFIG_SENSORS_MAX6650) += max6650.o
94obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o 94obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o
95obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o
95obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 96obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
96obj-$(CONFIG_SENSORS_PC87427) += pc87427.o 97obj-$(CONFIG_SENSORS_PC87427) += pc87427.o
97obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 98obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
new file mode 100644
index 000000000000..d7926f4336b5
--- /dev/null
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -0,0 +1,453 @@
1/*
2 * ntc_thermistor.c - NTC Thermistors
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <linux/slab.h>
24#include <linux/module.h>
25#include <linux/pm_runtime.h>
26#include <linux/math64.h>
27#include <linux/platform_device.h>
28#include <linux/err.h>
29
30#include <linux/platform_data/ntc_thermistor.h>
31
32#include <linux/hwmon.h>
33#include <linux/hwmon-sysfs.h>
34
35struct ntc_compensation {
36 int temp_C;
37 unsigned int ohm;
38};
39
40/*
41 * A compensation table should be sorted by the values of .ohm
42 * in descending order.
43 * The following compensation tables are from the specification of Murata NTC
44 * Thermistors Datasheet
45 */
46const struct ntc_compensation ncpXXwb473[] = {
47 { .temp_C = -40, .ohm = 1747920 },
48 { .temp_C = -35, .ohm = 1245428 },
49 { .temp_C = -30, .ohm = 898485 },
50 { .temp_C = -25, .ohm = 655802 },
51 { .temp_C = -20, .ohm = 483954 },
52 { .temp_C = -15, .ohm = 360850 },
53 { .temp_C = -10, .ohm = 271697 },