summaryrefslogtreecommitdiff
path: root/drivers/hwmon
AgeCommit message (Collapse)Author
2016-09-09hwmon: (ltc4151) Make shunt-resistor configurableDaniel Golle
Allow to specify the resistance of the attached shunt via DT by adding the shunt-resistor property. Fall-back to the previous default (1 mOhm) if unset. Signed-off-by: Daniel Golle <daniel@makrotopia.org> [groeck: Fixed 'line over 80 columns' checkpatch warning] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (nct6775) Do not accept force_id unless chip is foundGuenter Roeck
Since commit 698a7c24a544 ("hwmon: (nct6775) Support two SuperIO chips in the same system"), the driver supports two Super-IO chips. This has the undesirable side effect that force_id always detects a second chip at address 0xfff8, even if no chip exists at that address. nct6775: Found NCT6793D or compatible chip at 0x4e:0xfff8 If no chip at all is found at a given SIO address, it does not make sense to instantiate it. Limit force_id to only work if some chip is found, that is if the chip ID returns a value other than 0xffff. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) Add basic pwm attribute support to new APIGuenter Roeck
Add basic pwm attribute support (no auto attributes) to new API. Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) Add fan attribute support to new APIGuenter Roeck
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) Add energy and humidity attribute support to new APIGuenter Roeck
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) Add power attribute support to new APIGuenter Roeck
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) Add current attribute support to new APIGuenter Roeck
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) Add voltage attribute support to new APIGuenter Roeck
Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) New hwmon registration APIGuenter Roeck
Up to now, each hwmon driver has to implement its own sysfs attributes. This requires a lot of template code, and distracts from the driver's core function to read and write chip registers. To be able to reduce driver complexity, move sensor attribute handling and thermal zone registration into hwmon core. By using the new API, driver code and data size is typically reduced by 20-70%, depending on driver complexity and the number of sysfs attributes supported. With this patch, the new API only supports thermal sensors. Support for other sensor types will be added with subsequent patches. Acked-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (core) Order include files alphabeticallyGuenter Roeck
Ordering include files alphabetically makes it easier to add new ones. Stop including linux/spinlock.h and linux/kdev_t.h since both are not needed. Reviewed-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (ntc_thermistor) Use devm_hwmon_device_register_with_groupsGuenter Roeck
Simplify code, reduce code size, and drop remove function as no longer needed. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (ntc_thermistor) Use dev instead of &pdev->dev where possibleGuenter Roeck
Instead of repeatedly accessing &pdev->dev, use a local variable dev instead where possible. Also drop 'dev' from private data since it is unnecessary. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (ntc_thermistor) Use devm_iio_channel_getGuenter Roeck
Use devm_iio_channel_get() instead of iio_channel_get to simplify error handling and device removal. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (pmbus) Add explicit support for DPS-460, DPS-800, and SGD009Vadim Pasternak
Provide support for PSU DPS-460, DPS-800 from Delta Electronics, INC and for SGD009 from Acbel Polytech, INC. These devices do not support the STATUS_CML register, and reports a communication error in response to this command. For this reason, the status register check is disabled for these controllers. Signed-off-by: Vadim Pasternak <vadimp@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (adt7411) add external thermal diode supportMichael Walle
If the EXT_TDM bit is set, the chip supports a second temperature sensor instead of two voltage sensors. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Use more accurate limitsGuenter Roeck
The lower temperature limit is -128 degrees C. The supported upper limits are 127.875 or 255.875 degrees C. Also, don't fail if a value outside the supported range is provided when setting a temperature limit. Instead, clamp the provided value to the available value range. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Use BIT macro where appropriateGuenter Roeck
Drop some of the SHIFT defines since shift is implied with BIT(). Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Drop FSF addressGuenter Roeck
The FSF address may change, and providing it does not add any value. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Order include files alphabeticallyGuenter Roeck
Simplify detecting duplicate include files and finding the right place for adding new ones. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Add support for fault attributesGuenter Roeck
The chip reports if remote diodes are present, which can be used for the fault attrributes. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Fix overflow problems, write conversion rate to chipGuenter Roeck
Writing the update_interval attribute could result in an overflow if a number close to the maximum unsigned long was written. At the same time, even though the chip supports setting the conversion rate, the selected conversion rate was not actually written to the chip. Fix the second problem by selecting valid (supported) conversion rates, and writing the selected conversion rate to the chip. This also fixes the first problem, since arbitrary conversion rates are now converted to actually supported conversion rates. Also, set the default chip conversion rate to 1 second. Previously, the chip was configured for continuous conversion, but readings were only retrieved every seond, which doesn't make much sense. If we only read a value from the chip every second, we can as well save some power and only convert in one-second intervals. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-29hwmon: (it87) Add missing sysfs attribute group terminatorJean Delvare
Attribute array it87_attributes_in lacks its NULL terminator, causing random behavior when operating on the attribute group. Fixes: 52929715634a ("hwmon: (it87) Use is_visible for voltage sensors") Signed-off-by: Jean Delvare <jdelvare@suse.de> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-12hwmon: (it87) Features mask must be 32 bit wideGuenter Roeck
Coverity reports: result_independent_of_operands: data->features & (65536UL /* 1UL << 16 */) is always 0 regardless of the values of its operands. This occurs as the logical operand of if. data->features needs to be 32 bit wide since there are more than 16 features. Fixes: cc18da79d9b7 ("hwmon: (it87) Support up to 6 temperature sensors ... "); Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01Merge tag 'hwmon-for-linus-v4.8-2' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull more hwmon updates from Guenter Roeck: - Improved error handling in tmp102, lm75, and lm90 drivers - Bug fixes in sht3x, ftsteutates, iio_hwmon, and adt7411 drivers * tag 'hwmon-for-linus-v4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (adt7411) set sane values for CFG1 and CFG3 hwmon: (iio_hwmon) fix memory leak in name attribute hwmon: (ftsteutates) Fix potential memory access error hwmon: (tmp102) Improve error handling hwmon: (lm75) Improve error handling hwmon: (lm90) Improve error handling hwmon: (lm90) Add missing assignment hwmon: (sht3x) set initial jiffies to last_update
2016-07-31hwmon: (adt7411) set sane values for CFG1 and CFG3Michael Walle
According to the datasheet we have to set some bits as 0 and others as 1. Make sure we do this for CFG1 and CFG3. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31hwmon: (iio_hwmon) fix memory leak in name attributeQuentin Schulz
The "name" variable's memory is now freed when the device is destructed thanks to devm function. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Reported-by: Guenter Roeck <linux@roeck-us.net> Fixes: e0f8a24e0edfd ("staging:iio::hwmon interface client driver.") Fixes: 61bb53bcbdd86 ("hwmon: (iio_hwmon) Add support for humidity sensors") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31hwmon: (ftsteutates) Fix potential memory access errorGuenter Roeck
Using set_bit() to set a bit in an integer is not a good idea, since the function expects an unsigned long as argument, which can be 64 bit wide. Coverity reports this problem as >>> CID 1364488: Memory - illegal accesses (INCOMPATIBLE_CAST) >>> Pointer "&ret" points to an object whose effective type is "int" >>> (32 bits, signed) but is dereferenced as a wider "unsigned +long" (64 bits, unsigned). This may lead to memory corruption. 245 set_bit(1, (unsigned long *)&ret); Just use BIT instead. Cc: Thilo Cestonaro <thilo@cestona.ro> Fixes: 08426eda58e0 ("hwmon: Add driver for FTS BMC chip "Teutates"") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31hwmon: (tmp102) Improve error handlingGuenter Roeck
Use devm_add_action_or_reset() instead of devm_add_action(), and check its return code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31hwmon: (lm75) Improve error handlingGuenter Roeck
Use devm_add_action_or_reset() instead of devm_add_action(), and check its return value. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31hwmon: (lm90) Improve error handlingGuenter Roeck
Replace devm_add_action() with devm_add_action_or_reset(), and check its return value. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31hwmon: (lm90) Add missing assignmentGuenter Roeck
Coverity reports the following error. >>> CID 1364474: Error handling issues (CHECKED_RETURN) >>> Calling "lm90_read_reg" without checking return value (as is done >>> elsewhere 28 out of 29 times). 532 lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); 533 if (val < 0) 534 return val; Fixes: 10bfef47bd259 ("hwmon: (lm90) Read limit registers only once") Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31hwmon: (sht3x) set initial jiffies to last_updateMatt Ranostay
Handling the wraparound requires the data->last_update to be set to an initial jiffies value. Otherwise on 32-bit systems you will not be able to request a reading till the 5 minute jiffies rollover happens. Cc: Guenter Roeck <linux@roeck-us.net> Cc: David Frey <david.frey@sensirion.com> Signed-off-by: Matt Ranostay <mranostay@gmail.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Fixes: 7c84f7f80d6fc ("hwmon: add support for Sensirion SHT3x sensors") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-27Merge branch 'i2c/for-4.8' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "Here is the I2C pull request for 4.8: - the core and i801 driver gained support for SMBus Host Notify - core support for more than one address in DT - i2c_add_adapter() has now better error messages. We can remove all error messages from drivers calling it as a next step. - bigger updates to rk3x driver to support rk3399 SoC - the at24 eeprom driver got refactored and can now read special variants with unique serials or fixed MAC addresses. The rest is regular driver updates and bugfixes" * 'i2c/for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (66 commits) i2c: i801: use IS_ENABLED() instead of checking for built-in or module Documentation: i2c: slave: give proper example for pm usage Documentation: i2c: slave: describe buffer problems a bit better i2c: bcm2835: Don't complain on -EPROBE_DEFER from getting our clock i2c: i2c-smbus: drop useless stubs i2c: efm32: fix a failure path in efm32_i2c_probe() Revert "i2c: core: Cleanup I2C ACPI namespace" Revert "i2c: core: Add function for finding the bus speed from ACPI" i2c: Update the description of I2C_SMBUS i2c: i2c-smbus: fix i2c_handle_smbus_host_notify documentation eeprom: at24: tweak the loop_until_timeout() macro eeprom: at24: add support for at24mac series eeprom: at24: support reading the serial number for 24csxx eeprom: at24: platform_data: use BIT() macro eeprom: at24: split at24_eeprom_write() into specialized functions eeprom: at24: split at24_eeprom_read() into specialized functions eeprom: at24: hide the read/write loop behind a macro eeprom: at24: call read/write functions via function pointers eeprom: at24: coding style fixes eeprom: at24: move at24_read() below at24_eeprom_write() ...
2016-07-20hwmon: (ftsteutates) Remove unused including <linux/version.h>Wei Yongjun
Remove including <linux/version.h> that don't need it. Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-20hwmon: (adt7411) set bit 3 in CFG1 registerMichael Walle
According to the datasheet you should only write 1 to this bit. If it is not set, at least AIN3 will return bad values on newer silicon revisions. Fixes: d84ca5b345c2 ("hwmon: Add driver for ADT7411 voltage and temperature sensor") Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-20hwmon: Add driver for FTS BMC chip "Teutates"Thilo Cestonaro
This driver implements hardware monitoring and watchdog support for the FTS BMC Chip "Teutates". Signed-off-by: Thilo Cestonaro <thilo@cestona.ro> [groeck: Updated subject and description; fixed dependencies] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-16hwmon: (sht3x) add humidity heater element controlMatt Ranostay
The enables control of the SHT31 sensors heating element that can turned on to remove excess humidity. Cc: Guenter Roeck <linux@roeck-us.net> Cc: David Frey <david.frey@sensirion.com> Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-12hwmon: (jc42) Add support for generic JC-42.4 devicetree bindingGuenter Roeck
With this change, JC-42.4 compatible temperature sensors can be configured in devicetree by providing a generic "jedec,jc-42.4-temp" binding. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-12hwmon: (tmp102) Convert to use regmap, and drop local cacheGuenter Roeck
By converting the driver to regmap, we can use regmap to cache non-volatile registers. Stop caching the temperature register; while potentially reading it more often can result in reading it more often than necessary, this is offset by the gain due to not re-reading the limit registers. A positive side effect of this change is that limit registers can now be read and updated before the first temperature conversion is complete. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-12hwmon: (tmp102) Rework chip configurationGuenter Roeck
So far the chip was forced into polarity 0, even if it was preconfigured differently. Do not touch the polarity when configuring the chip. Also, the configuration register was read beack to check if the configuration 'sticks'. Ultimately, that is similar to checking if the chip is a tmp102 in the first place. Checking if a write into the configuration register was successful is really not the way to do it, and quite risky if the chip is not a tmp102, so drop that check. Instead, verify if the configuration register has unexpected bits set before writing into it. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-12hwmon: (tmp102) Improve handling of initial read delayGuenter Roeck
If the chip was in shutdown mode when the driver was loaded, the first conversion is ready no more than 35 milli-seconds after the chip was taken out of shutdown. The driver delay was so far set to 333 ms (HZ / 3), which is much higher than the maximum time needed by the chip. Reduce the time to 35 milli-seconds. Introduce a 'valid' flag to ensure that sensor data is actually read even if requested less than 333 ms after the driver was loaded. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Drop unnecessary else statementsGuenter Roeck
checkpatch rightfully complains that else after return is unnecessary. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Use bool for valid flagGuenter Roeck
Use bool for valid flag and leave it up to the compiler to find an optimal representation. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Read limit registers only onceGuenter Roeck
Read limit registers only once at startup or after errors to improve driver performance. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Simplify read functionsGuenter Roeck
Return both error code and register value as return code from read functions, and always check for errors. This reduces code size on x86_64 by more than 1k while at the same time improving error resiliency. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Use devm_hwmon_device_register_with_groupsGuenter Roeck
Since all other cleanup handled with devm_add_action, we can use devm_hwmon_device_register_with_groups() to register the hwmon device, and drop the remove function. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Use devm_add_action for cleanupGuenter Roeck
Use devm_add_action where possible to simplify error handling and cleanup on remove. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm75) Convert to use regmapGuenter Roeck
Convert to use regmap. Leave caching to regmap and drop the register update function. While this can result in additional read operations if the temperature register is read continuously, it avoids re-reading the limit registers and thus overall reduces complexity. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm75) Add update_interval attributeGuenter Roeck
Since we know the chip's update interval, let's make it available to the user. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm75) Drop lm75_read_value and lm75_write_valueGuenter Roeck
lm75_read_value and lm75_write_value don't really add any value. Replace with direct smbus access functions. Signed-off-by: Guenter Roeck <linux@roeck-us.net>