Skip to contentSkip to conversation

drivers/hwmon NTC Thermistor Initial

PATCH Superseded Donggeun Kim 2 participants 3 messages Jun 15, 2011

Subsystems (2)

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH v8 1/1 drivers/hwmon NTC Thermistor Initial

This patch adds 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.

--
Updates
v8
- remove compiler warning message
- update Documentation/hwmon/ntc_thermistor
- add EXPERIMENTAL Kconfig dependency
v7
- move header file location
- rename header and driver file
- style fixes
v6
- updated Documentation/hwmon/ntc
- style fixes
v5
- use binary search on sorted table
- removed unnecessary attributes
- style fixes
v4
- put in alphabetic order in Kconfig/Makefile
- handle additional error cases
- remove the exported function
v3
- style fixes
- removed symbol exports
- avoid divide-by-zero
- omitted files added (Kconfig/Makefile)
- removed unnecessary codes
- return error values, not default values for errors. v2
- added Documentation/hwmon/ntc
- followed hwmon sysfs
- detached the monitoring service
(thank you for the comments, Guenter Roeck)

---
 Documentation/hwmon/ntc_thermistor           |   93 +++++
 drivers/hwmon/Kconfig                        |   14 +
 drivers/hwmon/Makefile                       |    1 +
 drivers/hwmon/ntc_thermistor.c               |  477 ++++++++++++++++++++++++++
 include/linux/platform_data/ntc_thermistor.h |   53 +++
 5 files changed, 638 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/ntc_thermistor
 create mode 100644 drivers/hwmon/ntc_thermistor.c
 create mode 100644 include/linux/platform_data/ntc_thermistor.h
Documentation/hwmon/ntc_thermistor new file +92 -0
new file mode 100644
index 0000000..3bfda94
@@ -0,0 +1,93 @@
+Kernel driver ntc_thermistor
+========+
+Supported thermistors:
+* Murata NTC Thermistors NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333
+  Prefixes: 'ncp15wb473', 'ncp18wb473', 'ncp21wb473', 'ncp03wb473', 'ncp15wl333'
+  Datasheet: Publicly available at Murata
+
+Other NTC thermistors can be supported simply by adding compensation
+tables; e.g., NCP15WL333 support is added by the table ncpXXwl333.
+
+Authors:
+	MyungJoo Ham <[email protected]>
+
+Description
+-----------
+
+The NTC thermistor is a simple thermistor that requires users to provide the
+resistance and lookup the corresponding compensation table to get the
+temperature input.
+
+The NTC driver provides lookup tables with a linear approximation function
+and four circuit models with an option not to use any of the four models.
+
+The four circuit models provided are:
+
+	$: resister, [TH]: the thermistor
+
+ 1. connect = NTC_CONNECTED_POSITIVE, pullup_ohm > 0
+
+   [pullup_uV]
+       |    |
+      [TH]  $ (pullup_ohm)
+       |    |
+       +----+-----------------------[read_uV]
+       |
+       $ (pulldown_ohm)
+       |
+      --- (ground)
+
+ 2. connect = NTC_CONNECTED_POSITIVE, pullup_ohm = 0 (not-connected)
+
+   [pullup_uV]
+       |
+      [TH]
+       |
+       +----------------------------[read_uV]
+       |
+       $ (pulldown_ohm)
+       |
+      --- (ground)
+
+ 3. connect = NTC_CONNECTED_GROUND, pulldown_ohm > 0
+
+   [pullup_uV]
+       |
+       $ (pullup_ohm)
+       |
+       +----+-----------------------[read_uV]
+       |    |
+      [TH]  $ (pulldown_ohm)
+       |    |
+      -------- (ground)
+
+ 4. connect = NTC_CONNECTED_GROUND, pulldown_ohm = 0 (not-connected)
+
+   [pullup_uV]
+       |
+       $ (pullup_ohm)
+       |
+       +----------------------------[read_uV]
+       |
+      [TH]
+       |
+      --- (ground)
+
+When one of the four circuit models is used, read_uV, pullup_uV, pullup_ohm,
+pulldown_ohm, and connect should be provided. When none of the four models
+are suitable or the user can get the resistance directly, the user should
+provide read_ohm and _not_ provide the others.
+
+Sysfs Interface
+---------------
+name		the mandatory global attribute, the thermistor name.
+
+temp1_type	always 4 (thermistor)
+		RO
+
+temp1_input	measure the temperature and provide the measured value.
+		(reading this file initiates the reading procedure.)
+		RO
+
+Note that each NTC thermistor has only _one_ thermistor; thus, only temp1 exists.
drivers/hwmon/Kconfig +14 -0
index 16db83c..1e6e8a0 100644
@@ -767,6 +767,20 @@ config SENSORS_MAX6650
 	  This driver can also be built as a module.  If so, the module
 	  will be called max6650.
 
+config SENSORS_NTC_THERMISTOR
+	tristate "NTC thermistor support"
+	depends on EXPERIMENTAL
+	help
+	  This driver supports NTC thermistors sensor reading and its
+	  interpretation. The driver can also monitor the temperature and
+	  send notifications about the temperature.
+
+	  Currently, this driver supports
+	  NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, and NCP15WL333.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called ntc-thermistor.
+
 config SENSORS_PC87360
 	tristate "National Semiconductor PC87360 family"
 	select HWMON_VID
drivers/hwmon/Makefile +1 -0
index 28061cf..e4ab597 100644
@@ -91,6 +91,7 @@ obj-$(CONFIG_SENSORS_MAX6639)	+= max6639.o
 obj-$(CONFIG_SENSORS_MAX6642)	+= max6642.o
 obj-$(CONFIG_SENSORS_MAX6650)	+= max6650.o
 obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o
+obj-$(CONFIG_SENSORS_NTC_THERMISTOR)	+= ntc_thermistor.o
 obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
 obj-$(CONFIG_SENSORS_PC87427)	+= pc87427.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
drivers/hwmon/ntc_thermistor.c new file +477 -0

477 lines not on this page · raw message

include/linux/platform_data/ntc_thermistor.h new file +53 -0

53 lines not on this page · raw message

Signature · 7 lines
1.7.4.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw

Hello Kim,

Quoted 141 lines · Donggeun Kim

This patch adds 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.

--
Updates
v8
- remove compiler warning message
- update Documentation/hwmon/ntc_thermistor
- add EXPERIMENTAL Kconfig dependency
v7
- move header file location
- rename header and driver file
- style fixes
v6
- updated Documentation/hwmon/ntc
- style fixes
v5
- use binary search on sorted table
- removed unnecessary attributes
- style fixes
v4
- put in alphabetic order in Kconfig/Makefile
- handle additional error cases
- remove the exported function
v3
- style fixes
- removed symbol exports
- avoid divide-by-zero
- omitted files added (Kconfig/Makefile)
- removed unnecessary codes
- return error values, not default values for errors. v2
- added Documentation/hwmon/ntc
- followed hwmon sysfs
- detached the monitoring service
(thank you for the comments, Guenter Roeck)

---
 Documentation/hwmon/ntc_thermistor           |   93 +++++
 drivers/hwmon/Kconfig                        |   14 +
 drivers/hwmon/Makefile                       |    1 +
 drivers/hwmon/ntc_thermistor.c               |  477
++++++++++++++++++++++++++
 include/linux/platform_data/ntc_thermistor.h |   53 +++
 5 files changed, 638 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/ntc_thermistor
 create mode 100644 drivers/hwmon/ntc_thermistor.c
 create mode 100644 include/linux/platform_data/ntc_thermistor.h

<Snip>

drivers/hwmon/ntc_thermistor.c new file +5 -0
+
+static int __devinit ntc_thermistor_probe(struct platform_device *pdev)
+{
+       struct ntc_data *data;
+       struct ntc_thermistor_platform_data *pdata =

pdev->dev.platform_data;

drivers/hwmon/ntc_thermistor.c new file +22 -0
+       int ret = 0, i;
+
+       if (!pdata) {
+               dev_err(&pdev->dev, "No platform init data supplied.\n");
+               return -ENODEV;
+       }
+
+       /* Either one of the two is required. */
+       if (!pdata->read_uV && !pdata->read_ohm) {
+               dev_err(&pdev->dev, "Both read_uV and read_ohm missing."
+                               "Need either one of the two.\n");
+               return -EINVAL;
+       }
+
+       if (pdata->read_uV && pdata->read_ohm) {
+               dev_warn(&pdev->dev, "Only one of read_uV and read_ohm "
+                               "is needed; ignoring read_uV.\n");
+               pdata->read_uV = NULL;
+       }
+
+       if (pdata->read_uV && (pdata->pullup_uV == 0 ||
+                               (pdata->pullup_ohm == 0 && pdata->connect

==

(quoted diff) +2 -0
+                                NTC_CONNECTED_GROUND) ||
+                               (pdata->pulldown_ohm == 0 && pdata->connect

==

(quoted diff) +2 -0
+                                NTC_CONNECTED_POSITIVE) ||
+                               (pdata->connect != NTC_CONNECTED_POSITIVE

&&
+ pdata->connect != NTC_CONNECTED_GROUND)))
{

drivers/hwmon/ntc_thermistor.c new file +41 -0
+               dev_err(&pdev->dev, "Required data to use read_uV not "
+                               "supplied.\n");
+               return -EINVAL;
+       }
+
+       data = kzalloc(sizeof(struct ntc_data), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       data->dev = &pdev->dev;
+       data->pdata = pdata;
+       strncpy(data->name, pdev->id_entry->name, PLATFORM_NAME_SIZE);
+
+       switch (pdev->id_entry->driver_data) {
+       case TYPE_NCPXXWB473:
+               data->comp = ncpXXwb473;
+               data->n_comp = ARRAY_SIZE(ncpXXwb473);
+               break;
+       case TYPE_NCPXXWL333:
+               data->comp = ncpXXwl333;
+               data->n_comp = ARRAY_SIZE(ncpXXwl333);
+               break;
+       default:
+               dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n",
+                               pdev->id_entry->driver_data,
+                               pdev->id_entry->name);
+               ret = -EINVAL;
+               goto err;
+       }
+
+       data->mintemp = INT_MAX;
+       data->maxtemp = INT_MIN;
+
+       /*
+        * The compensation table is sorted by ohm value. Although it is
+        * normally assumed that the temperature value monotonically
+        * increases or decreases with the ohm value, but there could be
+        * different thermistors.
+        */
+       for (i = 0; i < data->n_comp; i++) {
+               if (data->comp[i].temp_C > data->maxtemp)

drivers/hwmon/ntc_thermistor.c line 400

Quoted 10 lines
drivers/hwmon/ntc_thermistor.c new file +10 -0
+                       data->maxtemp = data->comp[i].temp_C;
+               if (data->comp[i].temp_C < data->mintemp)
+                       data->mintemp = data->comp[i].temp_C;
+       }
+
+       if (data->mintemp != INT_MAX || data->maxtemp != INT_MIN) {
+               dev_err(data->dev, "error in compensation table\n");
+               ret = -EINVAL;
+               goto err;
+       }

Didnt understand this check. Shouldn't the compensation table allowed to modify this?

+

Quoted 145 lines
drivers/hwmon/ntc_thermistor.c new file +11 -0
+       platform_set_drvdata(pdev, data);
+
+       ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group);
+       if (ret) {
+               dev_err(data->dev, "unable to create sysfs files\n");
+               goto err;
+       }
+
+       data->hwmon_dev = hwmon_device_register(data->dev);
+       if (IS_ERR_OR_NULL(data->hwmon_dev)) {
+               dev_err(data->dev, "unable to register as hwmon

device.\n");

drivers/hwmon/ntc_thermistor.c new file +5 -0
+               ret = -EINVAL;
+               goto err_after_sysfs;
+       }
+
+       dev_info(&pdev->dev, "Thermistor %s:%d (type: %s/%lu) successfully

probed.\n",

drivers/hwmon/ntc_thermistor.c new file +60 -0
+                       pdev->name, pdev->id, pdev->id_entry->name,
+                       pdev->id_entry->driver_data);
+       return 0;
+err_after_sysfs:
+       sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
+err:
+       kfree(data);
+       return ret;
+}
+
+static int __devexit ntc_thermistor_remove(struct platform_device *pdev)
+{
+       struct ntc_data *data = platform_get_drvdata(pdev);
+
+       hwmon_device_unregister(data->hwmon_dev);
+       sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
+       platform_set_drvdata(pdev, NULL);
+
+       kfree(data);
+
+       return 0;
+}
+
+static const struct platform_device_id ntc_thermistor_id[] = {
+       { "ncp15wb473", TYPE_NCPXXWB473 },
+       { "ncp18wb473", TYPE_NCPXXWB473 },
+       { "ncp21wb473", TYPE_NCPXXWB473 },
+       { "ncp03wb473", TYPE_NCPXXWB473 },
+       { "ncp15wl333", TYPE_NCPXXWL333 },
+       { },
+};
+
+static struct platform_driver ntc_thermistor_driver = {
+       .driver = {
+               .name = "ntc-thermistor",
+               .owner = THIS_MODULE,
+       },
+       .probe = ntc_thermistor_probe,
+       .remove = __devexit_p(ntc_thermistor_remove),
+       .id_table = ntc_thermistor_id,
+};
+
+static int __init ntc_thermistor_init(void)
+{
+       return platform_driver_register(&ntc_thermistor_driver);
+}
+
+module_init(ntc_thermistor_init);
+
+static void __exit ntc_thermistor_cleanup(void)
+{
+       platform_driver_unregister(&ntc_thermistor_driver);
+}
+
+module_exit(ntc_thermistor_cleanup);
+
+MODULE_DESCRIPTION("NTC Thermistor Driver");
+MODULE_AUTHOR("MyungJoo Ham <[email protected]>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:ntc-thermistor");
include/linux/platform_data/ntc_thermistor.h new file +31 -0
new file mode 100644
index 0000000..abd2862
@@ -0,0 +1,53 @@
+/*
+ * ntc_thermistor.h - NTC Thermistors
+ *
+ *  Copyright (C) 2010 Samsung Electronics
+ *  MyungJoo Ham <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA
+ */
+#ifndef _LINUX_NTC_H
+#define _LINUX_NTC_H
+
+enum ntc_thermistor_type {
+       TYPE_NCPXXWB473,
+       TYPE_NCPXXWL333,
+};
+
+struct ntc_thermistor_platform_data {
+       /*
+        * One (not both) of read_uV and read_ohm should be provided and

only

include/linux/platform_data/ntc_thermistor.h new file +4 -0
+        * one of the two should be provided.
+        * Both functions should return negative value for an error case.
+        *
+        * pullup_uV, pullup_ohm, pulldown_ohm, and connect are required to

use

include/linux/platform_data/ntc_thermistor.h new file +18 -1
+        * read_uV()
+        *
+        * How to setup pullup_ohm, pulldown_ohm, and connect is
+        * described at Documentation/hwmon/ntc
+        *
+        * pullup/down_ohm: 0 for infinite / not-connected
+        */
+       int (*read_uV)(void);
+       unsigned int pullup_uV;
+
+       unsigned int pullup_ohm;
+       unsigned int pulldown_ohm;
+       enum { NTC_CONNECTED_POSITIVE, NTC_CONNECTED_GROUND } connect;
+
+       int (*read_ohm)(void);
+};
+
+#endif /* _LINUX_NTC_H */
--

1.7.4.1

Quoted 5 lines

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw
In reply to Donggeun Kim
Quoted 148 lines · Shubhrajyoti Datta

Hello Kim,

Quoted 144 lines · Donggeun Kim

This patch adds 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.

--
Updates
v8
- remove compiler warning message
- update Documentation/hwmon/ntc_thermistor
- add EXPERIMENTAL Kconfig dependency
v7
- move header file location
- rename header and driver file
- style fixes
v6
- updated Documentation/hwmon/ntc
- style fixes
v5
- use binary search on sorted table
- removed unnecessary attributes
- style fixes
v4
- put in alphabetic order in Kconfig/Makefile
- handle additional error cases
- remove the exported function
v3
- style fixes
- removed symbol exports
- avoid divide-by-zero
- omitted files added (Kconfig/Makefile)
- removed unnecessary codes
- return error values, not default values for errors. v2
- added Documentation/hwmon/ntc
- followed hwmon sysfs
- detached the monitoring service
(thank you for the comments, Guenter Roeck)

---
 Documentation/hwmon/ntc_thermistor           |   93 +++++
 drivers/hwmon/Kconfig                        |   14 +
 drivers/hwmon/Makefile                       |    1 +
 drivers/hwmon/ntc_thermistor.c               |  477
++++++++++++++++++++++++++
 include/linux/platform_data/ntc_thermistor.h |   53 +++
 5 files changed, 638 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/hwmon/ntc_thermistor
 create mode 100644 drivers/hwmon/ntc_thermistor.c
 create mode 100644 include/linux/platform_data/ntc_thermistor.h

<Snip>

drivers/hwmon/ntc_thermistor.c new file +27 -0
+
+static int __devinit ntc_thermistor_probe(struct platform_device *pdev)
+{
+       struct ntc_data *data;
+       struct ntc_thermistor_platform_data *pdata >> pdev->dev.platform_data;
+       int ret = 0, i;
+
+       if (!pdata) {
+               dev_err(&pdev->dev, "No platform init data supplied.\n");
+               return -ENODEV;
+       }
+
+       /* Either one of the two is required. */
+       if (!pdata->read_uV && !pdata->read_ohm) {
+               dev_err(&pdev->dev, "Both read_uV and read_ohm missing."
+                               "Need either one of the two.\n");
+               return -EINVAL;
+       }
+
+       if (pdata->read_uV && pdata->read_ohm) {
+               dev_warn(&pdev->dev, "Only one of read_uV and read_ohm "
+                               "is needed; ignoring read_uV.\n");
+               pdata->read_uV = NULL;
+       }
+
+       if (pdata->read_uV && (pdata->pullup_uV = 0 ||
+                               (pdata->pullup_ohm = 0 && pdata->connect

=

(quoted diff) +2 -0
+                                NTC_CONNECTED_GROUND) ||
+                               (pdata->pulldown_ohm = 0 && pdata->connect

=

(quoted diff) +2 -0
+                                NTC_CONNECTED_POSITIVE) ||
+                               (pdata->connect != NTC_CONNECTED_POSITIVE

&&
+ pdata->connect != NTC_CONNECTED_GROUND)))
{

drivers/hwmon/ntc_thermistor.c new file +46 -0
+               dev_err(&pdev->dev, "Required data to use read_uV not "
+                               "supplied.\n");
+               return -EINVAL;
+       }
+
+       data = kzalloc(sizeof(struct ntc_data), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       data->dev = &pdev->dev;
+       data->pdata = pdata;
+       strncpy(data->name, pdev->id_entry->name, PLATFORM_NAME_SIZE);
+
+       switch (pdev->id_entry->driver_data) {
+       case TYPE_NCPXXWB473:
+               data->comp = ncpXXwb473;
+               data->n_comp = ARRAY_SIZE(ncpXXwb473);
+               break;
+       case TYPE_NCPXXWL333:
+               data->comp = ncpXXwl333;
+               data->n_comp = ARRAY_SIZE(ncpXXwl333);
+               break;
+       default:
+               dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n",
+                               pdev->id_entry->driver_data,
+                               pdev->id_entry->name);
+               ret = -EINVAL;
+               goto err;
+       }
+
+       data->mintemp = INT_MAX;
+       data->maxtemp = INT_MIN;
+
+       /*
+        * The compensation table is sorted by ohm value. Although it is
+        * normally assumed that the temperature value monotonically
+        * increases or decreases with the ohm value, but there could be
+        * different thermistors.
+        */
+       for (i = 0; i < data->n_comp; i++) {
+               if (data->comp[i].temp_C > data->maxtemp)
+                       data->maxtemp = data->comp[i].temp_C;
+               if (data->comp[i].temp_C < data->mintemp)
+                       data->mintemp = data->comp[i].temp_C;
+       }
+
Quoted 9 lines

drivers/hwmon/ntc_thermistor.c line 400

Quoted 6 lines
drivers/hwmon/ntc_thermistor.c new file +5 -0
+       if (data->mintemp != INT_MAX || data->maxtemp != INT_MIN) {
+               dev_err(data->dev, "error in compensation table\n");
+               ret = -EINVAL;
+               goto err;
+       }

Didnt understand this check. Shouldn't the compensation table allowed to modify this?

I think it is my mistake.
The operator of checking line should be changed to '=' from '!='. Thank you for your review.

Quoted 146 lines

+

Quoted 145 lines
drivers/hwmon/ntc_thermistor.c new file +11 -0
+       platform_set_drvdata(pdev, data);
+
+       ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group);
+       if (ret) {
+               dev_err(data->dev, "unable to create sysfs files\n");
+               goto err;
+       }
+
+       data->hwmon_dev = hwmon_device_register(data->dev);
+       if (IS_ERR_OR_NULL(data->hwmon_dev)) {
+               dev_err(data->dev, "unable to register as hwmon

device.\n");

drivers/hwmon/ntc_thermistor.c new file +5 -0
+               ret = -EINVAL;
+               goto err_after_sysfs;
+       }
+
+       dev_info(&pdev->dev, "Thermistor %s:%d (type: %s/%lu) successfully

probed.\n",

drivers/hwmon/ntc_thermistor.c new file +60 -0
+                       pdev->name, pdev->id, pdev->id_entry->name,
+                       pdev->id_entry->driver_data);
+       return 0;
+err_after_sysfs:
+       sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
+err:
+       kfree(data);
+       return ret;
+}
+
+static int __devexit ntc_thermistor_remove(struct platform_device *pdev)
+{
+       struct ntc_data *data = platform_get_drvdata(pdev);
+
+       hwmon_device_unregister(data->hwmon_dev);
+       sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
+       platform_set_drvdata(pdev, NULL);
+
+       kfree(data);
+
+       return 0;
+}
+
+static const struct platform_device_id ntc_thermistor_id[] = {
+       { "ncp15wb473", TYPE_NCPXXWB473 },
+       { "ncp18wb473", TYPE_NCPXXWB473 },
+       { "ncp21wb473", TYPE_NCPXXWB473 },
+       { "ncp03wb473", TYPE_NCPXXWB473 },
+       { "ncp15wl333", TYPE_NCPXXWL333 },
+       { },
+};
+
+static struct platform_driver ntc_thermistor_driver = {
+       .driver = {
+               .name = "ntc-thermistor",
+               .owner = THIS_MODULE,
+       },
+       .probe = ntc_thermistor_probe,
+       .remove = __devexit_p(ntc_thermistor_remove),
+       .id_table = ntc_thermistor_id,
+};
+
+static int __init ntc_thermistor_init(void)
+{
+       return platform_driver_register(&ntc_thermistor_driver);
+}
+
+module_init(ntc_thermistor_init);
+
+static void __exit ntc_thermistor_cleanup(void)
+{
+       platform_driver_unregister(&ntc_thermistor_driver);
+}
+
+module_exit(ntc_thermistor_cleanup);
+
+MODULE_DESCRIPTION("NTC Thermistor Driver");
+MODULE_AUTHOR("MyungJoo Ham <[email protected]>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:ntc-thermistor");
include/linux/platform_data/ntc_thermistor.h new file +31 -0
new file mode 100644
index 0000000..abd2862
@@ -0,0 +1,53 @@
+/*
+ * ntc_thermistor.h - NTC Thermistors
+ *
+ *  Copyright (C) 2010 Samsung Electronics
+ *  MyungJoo Ham <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA
+ */
+#ifndef _LINUX_NTC_H
+#define _LINUX_NTC_H
+
+enum ntc_thermistor_type {
+       TYPE_NCPXXWB473,
+       TYPE_NCPXXWL333,
+};
+
+struct ntc_thermistor_platform_data {
+       /*
+        * One (not both) of read_uV and read_ohm should be provided and

only

include/linux/platform_data/ntc_thermistor.h new file +4 -0
+        * one of the two should be provided.
+        * Both functions should return negative value for an error case.
+        *
+        * pullup_uV, pullup_ohm, pulldown_ohm, and connect are required to

use

include/linux/platform_data/ntc_thermistor.h new file +18 -1
+        * read_uV()
+        *
+        * How to setup pullup_ohm, pulldown_ohm, and connect is
+        * described at Documentation/hwmon/ntc
+        *
+        * pullup/down_ohm: 0 for infinite / not-connected
+        */
+       int (*read_uV)(void);
+       unsigned int pullup_uV;
+
+       unsigned int pullup_ohm;
+       unsigned int pulldown_ohm;
+       enum { NTC_CONNECTED_POSITIVE, NTC_CONNECTED_GROUND } connect;
+
+       int (*read_ohm)(void);
+};
+
+#endif /* _LINUX_NTC_H */
--

1.7.4.1

Quoted 6 lines
Quoted 5 lines

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors