hwmon: Driver for Maxim MAX6697 and compatibles
PATCH v4 1/1 hwmon: Driver for Maxim MAX6697 and compatibles
Add support for MAX6581, MAX6602, MAX6622, MAX6636, MAX6689, MAX6693, MAX6694, MAX6697, MAX6698, and MAX6699 temperature sensors
---
v2:
- Add suppport for platform data and devicetree based chip initialization
- Drop S_IRUGOWU macro: s/S_IRUGOWU/S_IRUGO | S_IWUSR/
v3:
- Clarify devicetree documentation and platform data, indicating that all configuration information must be specified
- Fix alert-mask and over-temperature-mask values in devicetree example
- Align bit masks in configuration data with tempX index values
- Fix memset size in initialization code
- Handle extended temperature range for MAX6581 correctly
- Make data caching time dependent on chip type and configuration data
- Fix have_ext bit map for MAX6581
- Sort entries in max6697_chip_data[] array alphabetically
- Fix race condition when reading alarms
- Define and use constants for second index in data->temp array
- Rename show_temp11 to show_temp_input. Drop second index (always zero)
- Use DIV_ROUND_CLOSEST to convert milli-degrees to degrees in set_temp
- Handle error return in set_temp correctly
- Make max6697_attributes a two-dimensional array to reduce risk of errors when accessing it
- Drop temp1_fault as it is never used (local temperature sensor can not be faulty)
- Fix reading extended-range-enable property
- If no configuration data is specified, read extended range and resistance cancellation configuration from chip
- Drop some unnecessary comments
- Include linux/types.h in platform_data/max6697.h
- Drop unused define MAX6697_MAX_CONFIG_REG
- Add comments to fields in struct max6697_platform_data
- Add support to configure beta compensation on MAX6693 and MAX6694 v4:
- s/beta/Beta at beginning of sentence in device tree description file
- Optimize temperature calculation in show_temp_input
- Accept temperatures up to 255 degrees C (191 degrees C in extended temperature mode) for MAX6581
- Define reg as int in max6697_init_chip to be able to catch error cases
- Optimize assignment to data->temp_offset in max6697_init_chip
- smbus->SMBus in platform_data/max6697.h
Documentation/devicetree/bindings/i2c/max6697.txt | 64 ++ Documentation/hwmon/max6697 | 58 ++ drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/max6697.c | 726 +++++++++++++++++++++ include/linux/platform_data/max6697.h | 36 + 6 files changed, 896 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/max6697.txt create mode 100644 Documentation/hwmon/max6697 create mode 100644 drivers/hwmon/max6697.c create mode 100644 include/linux/platform_data/max6697.h
Documentation/devicetree/bindings/i2c/max6697.txt new file +64 -0
@@ -0,0 +1,64 @@ +max6697 properties + +Required properties: +- compatible: + Should be one of + maxim,max6581 + maxim,max6602 + maxim,max6622 + maxim,max6636 + maxim,max6689 + maxim,max6693 + maxim,max6694 + maxim,max6697 + maxim,max6698 + maxim,max6699 +- reg: I2C address + +Optional properties: + +- smbus-timeout-disable + Set to disable SMBus timeout. If not specified, SMBus timeout will be + enabled. +- extended-range-enable + Only valid for MAX6581. Set to enable extended temperature range. + Extended temperature will be disabled if not specified. +- beta-compensation-enable + Only valid for MAX6693 and MX6694. Set to enable beta compensation on + remote temperature channel 1. + Beta compensation will be disabled if not specified. +- alert-mask + Alert bit mask. Alert disabled for bits set. + Select bit 0 for local temperature, bit 1..7 for remote temperatures. + If not specified, alert will be enabled for all channels. +- over-temperature-mask + Over-temperature bit mask. Over-temperature reporting disabled for + bits set. + Select bit 0 for local temperature, bit 1..7 for remote temperatures. + If not specified, over-temperature reporting will be enabled for all + channels. +- resistance-cancellation + Boolean for all chips other than MAX6581. Set to enable resistance + cancellation on remote temperature channel 1. + For MAX6581, resistance cancellation enabled for all channels if + specified as boolean, otherwise as per bit mask specified. + Only supported for remote temperatures (bit 1..7). + If not specified, resistance cancellation will be disabled for all + channels. +- transistor-ideality + For MAX6581 only. Two values; first is bit mask, second is ideality + select value as per MAX6581 data sheet. Select bit 1..7 for remote + channels. + Transistor ideality will be initialized to default (1.008) if not + specified. + +Example: + +temp-sensor@1a { + compatible = "maxim,max6697"; + reg = <0x1a>; + smbus-timeout-disable; + resistance-cancellation; + alert-mask = <0x72>; + over-temperature-mask = <0x7f>; +};
Documentation/hwmon/max6697 new file +58 -0
58 lines not on this page · raw message
drivers/hwmon/Kconfig +11 -0
@@ -854,6 +854,17 @@ config SENSORS_MAX6650 This driver can also be built as a module. If so, the module will be called max6650. +config SENSORS_MAX6697 + tristate "Maxim MAX6697 and compatibles" + depends on I2C + help + If you say yes here you get support for MAX6581, MAX6602, MAX6622, + MAX6636, MAX6689, MAX6693, MAX6694, MAX6697, MAX6698, and MAX6699 + temperature sensor chips. + + This driver can also be built as a module. If so, the module + will be called max6697. + config SENSORS_MCP3021 tristate "Microchip MCP3021 and compatibles" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -99,6 +99,7 @@ obj-$(CONFIG_SENSORS_MAX197) += max197.o obj-$(CONFIG_SENSORS_MAX6639) += max6639.o obj-$(CONFIG_SENSORS_MAX6642) += max6642.o obj-$(CONFIG_SENSORS_MAX6650) += max6650.o +obj-$(CONFIG_SENSORS_MAX6697) += max6697.o obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o obj-$(CONFIG_SENSORS_MCP3021) += mcp3021.o obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o
drivers/hwmon/max6697.c new file +726 -0
726 lines not on this page · raw message
include/linux/platform_data/max6697.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* max6697.h +* Copyright (c) 2012 Guenter Roeck <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef MAX6697_H +#define MAX6697_H + +#include <linux/types.h> + +/* +* For all bit masks: +* bit 0: local temperature +* bit 1..7: remote temperatures +*/ +struct max6697_platform_data { +bool smbus_timeout_disable;/* set to disable SMBus timeouts */ +bool extended_range_enable;/* set to enable extended temp range */ +bool beta_compensation;/* set to enable beta compensation */ +u8 alert_mask;/* set bit to 1 to disable alert */ +u8 over_temperature_mask;/* set bit to 1 to disable */ +u8 resistance_cancellation;/* set bit to 0 to disable +* bit mask for MAX6581, +* boolean for other chips +*/ +u8 ideality_mask;/* set bit to 0 to disable */ +u8 ideality_value;/* transistor ideality as per +* MAX6581 datasheet +*/ +}; + +#endif /* MAX6697_H */
Signature · 1 line
1.7.9.7
Quoted 15 lines · Guenter Roeck
Add support for MAX6581, MAX6602, MAX6622, MAX6636, MAX6689, MAX6693, MAX6694, MAX6697, MAX6698, and MAX6699 temperature sensors
Signed-off-by Guenter Roeck <[email protected]>---
(...)
v4:
- s/beta/Beta at beginning of sentence in device tree description file
- Optimize temperature calculation inshow_temp_input
- Accept temperatures up to 255 degrees C (191 degrees C in extended temperature mode) for MAX6581
- Define reg as int inmax6697_init_chipto be able to catch error cases
- Optimize assignment todata->temp_offsetinmax6697_init_chip
-smbus->SMBusinplatform_data/max6697.h
Quoted 11 lines
Documentation/devicetree/bindings/i2c/max6697.txt | 64 ++ Documentation/hwmon/max6697 | 58 ++ drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/max6697.c | 726 +++++++++++++++++++++ include/linux/platform_data/max6697.h | 36 + 6 files changed, 896 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/max6697.txt create mode 100644 Documentation/hwmon/max6697 create mode 100644 drivers/hwmon/max6697.c create mode 100644 include/linux/platform_data/max6697.h
Please update lm-sensors' wiki to mention this driver.
Signature · 1 line
Jean Delvare
Guenter Roeck
maintainerQuoted 28 lines · Jean Delvare
Quoted 15 lines · Guenter Roeck
Add support for MAX6581, MAX6602, MAX6622, MAX6636, MAX6689, MAX6693, MAX6694, MAX6697, MAX6698, and MAX6699 temperature sensors
Signed-off-by Guenter Roeck <[email protected]>---
(...)
v4:
- s/beta/Beta at beginning of sentence in device tree description file
- Optimize temperature calculation inshow_temp_input
- Accept temperatures up to 255 degrees C (191 degrees C in extended temperature mode) for MAX6581
- Define reg as int inmax6697_init_chipto be able to catch error cases
- Optimize assignment todata->temp_offsetinmax6697_init_chip
-smbus->SMBusinplatform_data/max6697.hQuoted 11 lines
Documentation/devicetree/bindings/i2c/max6697.txt | 64 ++ Documentation/hwmon/max6697 | 58 ++ drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/max6697.c | 726 +++++++++++++++++++++ include/linux/platform_data/max6697.h | 36 + 6 files changed, 896 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/max6697.txt create mode 100644 Documentation/hwmon/max6697 create mode 100644 drivers/hwmon/max6697.c create mode 100644 include/linux/platform_data/max6697.h
Quoted 4 lines
Reviewed-by Jean Delvare <[email protected]>Please update lm-sensors' wiki to mention this driver.
Done. Thanks a lot for the review!
Guenter