hwmon: Add support for JEDEC JC 42.4 compliant temperature sensors
Subsystems (4)
PATCH v2 1/1 hwmon: Add support for JEDEC JC 42.4 compliant temperature sensors
---
v2 changes:
- Added support for MAX6604
- Added support for TSE2002B3 and TS3000B3 (IDT)
- Define Manufacturer IDs separately and only once per manufacturer
- Rearranged chip defines to alphabetic order
--- Documentation/hwmon/jc42 | 97 ++++++++ MAINTAINERS | 7 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/jc42.c | 594 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 710 insertions(+), 0 deletions(-) create mode 100644 Documentation/hwmon/jc42 create mode 100644 drivers/hwmon/jc42.c
Documentation/hwmon/jc42 new file +97 -0
@@ -0,0 +1,97 @@ +Kernel driver jc42 +================== + +Supported chips: + * Analog Devices ADT7408 + Prefix: 'adt7408' + Addresses scanned: I2C 0x18 - 0x1f + Datasheets: + http://www.analog.com/static/imported-files/data_sheets/ADT7408.pdf + * IDT TSE2002B3, TS3000B3 + Prefix: 'tse2002b3', 'ts3000b3' + Addresses scanned: I2C 0x18 - 0x1f + Datasheets: + http://www.idt.com/products/getdoc.cfm?docid=18715691 + http://www.idt.com/products/getdoc.cfm?docid=18715692 + * Maxim MAX6604 + Prefix: 'max6604' + Addresses scanned: I2C 0x18 - 0x1f + Datasheets: + http://datasheets.maxim-ic.com/en/ds/MAX6604.pdf + * Microchip MCP9805, MCP98242, MCP98243, MCP9843 + Prefixes: 'mcp9805', 'mcp98242', 'mcp98243', 'mcp9843' + Addresses scanned: I2C 0x18 - 0x1f + Datasheets: + http://ww1.microchip.com/downloads/en/DeviceDoc/21977b.pdf + http://ww1.microchip.com/downloads/en/DeviceDoc/21996a.pdf + http://ww1.microchip.com/downloads/en/DeviceDoc/22153c.pdf + * NXP Semiconductors SE97, SE97B + Prefix: 'se97' + Addresses scanned: I2C 0x18 - 0x1f + Datasheets: + http://www.nxp.com/documents/data_sheet/SE97.pdf + http://www.nxp.com/documents/data_sheet/SE97B.pdf + * NXP Semiconductors SE98 + Prefix: 'se98' + Addresses scanned: I2C 0x18 - 0x1f + Datasheets: + http://www.nxp.com/documents/data_sheet/SE98.pdf + * ON Semiconductor CAT34TS02, CAT6095 + Prefix: 'cat34ts02', 'cat6095' + Addresses scanned: I2C 0x18 - 0x1f + Datasheet: + http://www.onsemi.com/pub_link/Collateral/CAT34TS02-D.PDF + http://www.onsemi.com/pub/Collateral/CAT6095-D.PDF + * ST Microelectronics STTS424, STTS424E02 + Prefix: 'stts424' + Addresses scanned: I2C 0x18 - 0x1f + Datasheets: + http://www.st.com/stonline/products/literature/ds/13447/stts424.pdf + http://www.st.com/stonline/products/literature/ds/13448/stts424e02.pdf + * JEDEC JC 42.4 compliant temperature sensor chips + Prefix: 'jc42' + Addresses scanned: I2C 0x18 - 0x1f + Datasheet: - + +Author: + Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/[email protected]> + + +Description +----------- + +This driver implements support for JEDEC JC 42.4 compliant temperature sensors. +The driver auto-detects the chips listed above, but can be manually instantiated +to support other JC 42.4 compliant chips. + +Example: the following will load the driver for a generic JC 42.4 compliant +temperature sensor at address 0x18 on I2C bus #1: + +# modprobe jc42 +# echo jc42 0x18 > /sys/bus/i2c/devices/i2c-1/new_device + +A JC 42.4 compliant chip supports a single temperature sensor. Minimum, maximum, +and critical temperature can be configured. There are alarms for high, low, +and critical thresholds. + +There is also an hysteresis to control the thresholds for resetting alarms. +Per JC 42.4 specification, the hysteresis threshold can be configured to 0, 1.5, +3.0, and 6.0 degrees C. Configured hysteresis values will be rounded to those +limits. The chip supports only a single register to configure the hysteresis, +which applies to all limits. This register can be written by writing into +temp1_crit_hyst. Other hysteresis attributes are read-only. + +Sysfs entries +------------- + +temp1_input Temperature (RO) +temp1_min Minimum temperature (RW) +temp1_max Maximum temperature (RW) +temp1_crit Critical high temperature (RW) + +temp1_crit_hyst Critical hysteresis temperature (RW) +temp1_max_hyst Maximum hysteresis temperature (RO) + +temp1_min_alarm Temperature low alarm +temp1_max_alarm Temperature high alarm +temp1_crit_alarm Temperature critical alarm
MAINTAINERS +7 -0
@@ -3182,6 +3182,13 @@ F: Documentation/video4linux/*.ivtv F: drivers/media/video/ivtv/ F: include/linux/ivtv* +JC42.4 TEMPERATURE SENSOR DRIVER +M: Guenter Roeck <[email protected]> +L: [email protected] +S: Maintained +F: drivers/hwmon/jc42.c +F: Documentation/hwmon/jc42 + JFS FILESYSTEM M: Dave Kleikamp <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +11 -0
@@ -446,6 +446,17 @@ config SENSORS_IT87 This driver can also be built as a module. If so, the module will be called it87. +config SENSORS_JC42 + tristate "JEDEC JC42.4 compliant temperature sensors" + help + If you say yes here you get support for Jedec JC42.4 compliant + temperature sensors. Support will include, but not be limited to, + ADT7408, CAT34TS02,, CAT6095, MAX6604, MCP9805, MCP98242, MCP98243, + MCP9843, SE97, SE98, STTS424, TSE2002B3, and TS3000B3. + + This driver can also be built as a module. If so, the module + will be called jc42. + config SENSORS_LM63 tristate "National Semiconductor LM63 and LM64" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -55,6 +55,7 @@ obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o obj-$(CONFIG_SENSORS_IT87) += it87.o +obj-$(CONFIG_SENSORS_JC42) += jc42.o obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o obj-$(CONFIG_SENSORS_K10TEMP) += k10temp.o obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o
drivers/hwmon/jc42.c new file +594 -0
594 lines not on this page · raw message
Signature · 1 line
1.7.0.87.g0901d
Joe Perches
maintainerdrivers/hwmon/jc42.c
Quoted 5 lines · Guenter Roeck
drivers/hwmon/jc42.c new file +0
-0
[]
Quoted 9 lines
drivers/hwmon/jc42.c new file +9
-0+struct jc42_chips { +u16 manid; +u16 devid; +u16 devid_mask; +}; + +static struct jc42_chips jc42_chips[] = { + {ADT_MANID ,ADT7408_DEVID ,ADT7408_DEVID_MASK }, + {IDT_MANID ,TS3000B3_DEVID ,TS3000B3_DEVID_MASK },
drivers/hwmon/jc42.c line 134
Quoted 10 lines
drivers/hwmon/jc42.c new file +10
-0+ { MAX_MANID, MAX6604_DEVID, MAX6604_DEVID_MASK }, + { MCP_MANID, MCP98242_DEVID, MCP98242_DEVID_MASK }, + { MCP_MANID, MCP98243_DEVID, MCP98243_DEVID_MASK }, + { MCP_MANID, MCP9843_DEVID, MCP9843_DEVID_MASK }, + { NXP_MANID, SE97_DEVID, SE97_DEVID_MASK }, + { ONS_MANID, CAT6095_DEVID, CAT6095_DEVID_MASK }, + { NXP_MANID, SE98_DEVID, SE98_DEVID_MASK }, + { STM_MANID, STTS424_DEVID, STTS424_DEVID_MASK }, + { STM_MANID, STTS424E_DEVID, STTS424E_DEVID_MASK }, +};
[]
drivers/hwmon/jc42.c line 448
Quoted 8 lines
drivers/hwmon/jc42.c new file +8
-0+for (i =0 ; i <ARRAY_SIZE (jc42_chips); i++) { +if (manid == jc42_chips[i].manid + && (devid & jc42_chips[i].devid_mask) == + jc42_chips[i].devid) { +strlcpy (info->type,"jc42" ,I2C_NAME_SIZE ); +return 0 ; + } + }
Decidedly trivial:
Kernel style seems to prefer having logical tests at end of line rather than start of line.
Maybe this bit would be more readable with a temporary:
for (i = 0; i < ARRAY_SIZE(jc42_chips); i++) {
struct jc42_chips *chip = &jc42_chips[i];
if (manid == chip->manid &&
(devid & chip->devid_mask) == chip->devid) {
strlcpy(info->type, "jc42", I2C_NAME_SIZE);
return 0;
}
}Quoted 38 lines · Joe Perches
drivers/hwmon/jc42.c
Quoted 5 lines · Guenter Roeck
drivers/hwmon/jc42.c new file +0
-0[]
Quoted 9 lines
drivers/hwmon/jc42.c new file +9
-0+struct jc42_chips { +u16 manid; +u16 devid; +u16 devid_mask; +}; + +static struct jc42_chips jc42_chips[] = { + {ADT_MANID ,ADT7408_DEVID ,ADT7408_DEVID_MASK }, + {IDT_MANID ,TS3000B3_DEVID ,TS3000B3_DEVID_MASK },drivers/hwmon/jc42.c line 134
Quoted 10 lines
drivers/hwmon/jc42.c new file +10
-0+ { MAX_MANID, MAX6604_DEVID, MAX6604_DEVID_MASK }, + { MCP_MANID, MCP98242_DEVID, MCP98242_DEVID_MASK }, + { MCP_MANID, MCP98243_DEVID, MCP98243_DEVID_MASK }, + { MCP_MANID, MCP9843_DEVID, MCP9843_DEVID_MASK }, + { NXP_MANID, SE97_DEVID, SE97_DEVID_MASK }, + { ONS_MANID, CAT6095_DEVID, CAT6095_DEVID_MASK }, + { NXP_MANID, SE98_DEVID, SE98_DEVID_MASK }, + { STM_MANID, STTS424_DEVID, STTS424_DEVID_MASK }, + { STM_MANID, STTS424E_DEVID, STTS424E_DEVID_MASK }, +};[]
drivers/hwmon/jc42.c line 448
Quoted 8 lines
drivers/hwmon/jc42.c new file +8
-0+for (i =0 ; i <ARRAY_SIZE (jc42_chips); i++) { +if (manid == jc42_chips[i].manid + && (devid & jc42_chips[i].devid_mask) == + jc42_chips[i].devid) { +strlcpy (info->type,"jc42" ,I2C_NAME_SIZE ); +return 0 ; + } + }Decidedly trivial:
Quoted 3 lines
Kernel style seems to prefer having logical tests at end of line rather than start of line.
Ok. Would be nice to have checkpatch.pl complain about it, though, if it is a to-be-enforced rule.
Quoted 11 lines
Maybe this bit would be more readable with a temporary:
for (i = 0; i < ARRAY_SIZE(jc42_chips); i++) { struct jc42_chips *chip = &jc42_chips[i]; if (manid == chip->manid && (devid & chip->devid_mask) == chip->devid) { strlcpy(info->type, "jc42", I2C_NAME_SIZE); return 0; } }
Agreed. I'll change that.
Thanks,
Guenter
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Joe Perches
drivers/hwmon/jc42.c line 448
Quoted 8 lines · Guenter Roeck
drivers/hwmon/jc42.c new file +8
-0+for (i =0 ; i <ARRAY_SIZE (jc42_chips); i++) { +if (manid == jc42_chips[i].manid + && (devid & jc42_chips[i].devid_mask) == + jc42_chips[i].devid) { +strlcpy (info->type,"jc42" ,I2C_NAME_SIZE ); +return 0 ; + } + }Decidedly trivial:
Quoted 5 lines
Quoted 2 lines
Kernel style seems to prefer having logical tests at end of line rather than start of line.
Ok. Would be nice to have checkpatch.pl complain about it, though, if it is a to-be-enforced rule.
Please, not again. This has been discussed before, with the conclusion that nobody really cares and we don't want to add pointless warnings to checkpatch.pl, which in the end will just dissuade people from running the script and/or contributing to the kernel at all.
Signature · 1 line
Jean Delvare
Joe Perches
maintainerPATCH 1/1 scripts/checkpatch.pl: Add strict test of logical test continuations at beginning of line
Quoted 10 lines · Jean Delvare
Quoted 5 lines · Guenter Roeck
Quoted 2 lines · Joe Perches
Kernel style seems to prefer having logical tests at end of line rather than start of line.
Ok. Would be nice to have checkpatch.pl complain about it, though, if it is a to-be-enforced rule.
Please, not again. This has been discussed before, with the conclusion that nobody really cares and we don't want to add pointless warnings to checkpatch.pl, which in the end will just dissuade people from running the script and/or contributing to the kernel at all.
I don't remember that discussion. Link?
Here's a patch that makes it a "--strict" option
for those who really want to get all the style
checking options.
It also corrects a spelling typo.
---
scripts/checkpatch.pl +6 -1
@@ -2180,6 +2180,11 @@ sub process { ERROR("space required before the open parenthesis '('\n" . $herecurr); } +# Strict only - logical tests should be at EOL, not beginning of new lines + if ($line=~/^.\s*(\&\&|\|\|)/) { + CHK("logical test continuations should be on the previous line\n" . $hereprev); + } + # Check for illegal assignment in if conditional -- and check for trailing # statements after the conditional. if ($line =~ /do\s*(?!{)/) {
@@ -2299,7 +2304,7 @@ sub process { #no spaces allowed after \ in define if ($line=~/\#\s*define.*\\\s$/) { - WARN("Whitepspace after \\ makes next lines useless\n" . $herecurr); + WARN("Whitespace after \\ makes next lines useless\n" . $herecurr); } #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
Re: [PATCH] scripts/checkpatch.pl: Add strict test of logical test continuations at beginning of line
Quoted 5 lines · Joe Perches
Quoted 4 lines · Jean Delvare
Quoted 3 lines · Guenter Roeck
Quoted 2 lines · Joe Perches
Kernel style seems to prefer having logical tests at end of line rather than start of line.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Ok. Would be nice to have checkpatch.pl complain about it, though, if it is a to-be-enforced rule.
Please, not again. This has been discussed before, with the conclusion that nobody really cares and we don't want to add pointless warnings to checkpatch.pl, which in the end will just dissuade people from running the script and/or contributing to the kernel at all.
I don't remember that discussion. Link?
http://lkml.org/lkml/2009/12/5/65
You started the thread, so I would think you'd remember it.
Quoted 5 lines
Here's a patch that makes it a "--strict" option
for those who really want to get all the style
checking options.It also corrects a spelling typo.
It's the wrong way of writing patches. Separate things go to separate patches.
Quoted 7 lines
Signed-off-by Joe Perches <[email protected]---
scripts/checkpatch.pl +0
-0
scripts/checkpatch.pl sub process { · line 2187
Quoted 8 lines
scripts/checkpatch.pl +5
-0@@ -2180,6 +2180,11 @@ sub process { ERROR("space required before the open parenthesis '('\n" . $herecurr); } +# Strict only - logical tests should be at EOL, not beginning of new lines + if ($line=~/^.\s*(\&\&|\|\|)/) { + CHK("logical test continuations should be on the previous line\n" . $hereprev); + } +
As long as it doesn't bug me by default, I don't really care. But I still believe this is a waste of everybody's time.
Quoted 14 lines
scripts/checkpatch.pl +1
-1# Check for illegal assignment in if conditional -- and check for trailing # statements after the conditional. if ($line =~ /do\s*(?!{)/) {@@ -2299,7 +2304,7 @@ sub process { #no spaces allowed after \ in define if ($line=~/\#\s*define.*\\\s$/) { - WARN("Whitepspace after \\ makes next lines useless\n" . $herecurr); + WARN("Whitespace after \\ makes next lines useless\n" . $herecurr); } #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
Signature · 1 line
Jean Delvare
Joe Perches
maintainerRe: [PATCH] scripts/checkpatch.pl: Add strict test of logical test continuations at beginning of line
Quoted 4 lines · Jean Delvare
Quoted 1 line · Joe Perches
I don't remember that discussion. Link?
http://lkml.org/lkml/2009/12/5/65
You started the thread, so I would think you'd remember it.
Though there are differences in opinion about what's important, I try to forget the trivial. Just ask my sweet wife...
Re: [PATCH] scripts/checkpatch.pl: Add strict test of logical test continuations at beginning of line
Quoted 9 lines · Joe Perches
Quoted 4 lines · Jean Delvare
Quoted 1 line · Joe Perches
I don't remember that discussion. Link?
http://lkml.org/lkml/2009/12/5/65
You started the thread, so I would think you'd remember it.Though there are differences in opinion about what's important, I try to forget the trivial. Just ask my sweet wife...
Same issue hit me twice now, so it isn't as if nobody cares.
For my part, I don't care where to put the &&. But I would like to have a means to get beyond the basic stuff before submitting my patches, to give reviewers an opportunity to find the _real_ problems in my code.
Guenter
Quoted 4 lines · On Sun, 11 Jul 2010 07:53:04 -0700 Guenter Roeck…
drivers/hwmon/jc42.c new file +4
-0+static int jc42_probe (struct i2c_client *new_client, +const struct i2c_device_id *id) +{ +struct jc42_data *data;
drivers/hwmon/jc42.c line 465
Quoted 10 lines
drivers/hwmon/jc42.c new file +10
-0+int config, cap, err; + + data =kzalloc (sizeof (struct jc42_data ),GFP_KERNEL ); +if (!data) { + err = -ENOMEM ; + goto exit; + } + +i2c_set_clientdata (new_client, data); + data->valid = false;
I think it would be acceptable to assume that memset(..., 0, ...) sets a bool to `false' ;)
Quoted 1 line
drivers/hwmon/jc42.c new file +1
-0+mutex_init (&data->update_lock);
Quoted 12 lines · Andrew Morton
Quoted 9 lines · On Sun, 11 Jul 2010 07:53:04 -0700 Guenter Roeck…
drivers/hwmon/jc42.c new file +9
-0+static int jc42_probe (struct i2c_client *new_client, +const struct i2c_device_id *id) +{ +struct jc42_data *data; +int config, cap, err; + + data =kzalloc (sizeof (struct jc42_data ),GFP_KERNEL ); +if (!data) { + err = -ENOMEM ;
Quoted 9 lines
drivers/hwmon/jc42.c line 465
Quoted 5 lines
drivers/hwmon/jc42.c new file +5
-0+ goto exit; + } + +i2c_set_clientdata (new_client, data); + data->valid = false;I think it would be acceptable to assume that
memset(..., 0, ...)sets a bool to `false' ;)
Guess so. Wonder where I got that from. Thanks for noticing...
Guenter