summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
AgeCommit message (Collapse)AuthorFilesLines
2016-10-04Merge tag 'hwmon-for-linus-v4.9' of ↵Linus Torvalds28-2152/+3945
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon updates from Guenter Roeck: - New hwmon registration API, including ports of several drivers to the new API - New hwmon driver for APM X-Gene SoC - Added support for UCD90160, DPS-460, DPS-800, and SGD009 PMBUs chips - Various cleanups, minor improvements, and fixes in several drivers * tag 'hwmon-for-linus-v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (54 commits) hwmon: (nct6775) Add support for multiple virtual temperature sources hwmon: (adt7470) No need for additional synchronization on kthread_stop() hwmon: (lm95241) Update module description to include LM95231 hwmon: (lm95245) Select REGMAP_I2C hwmon: (ibmpowernv) Fix label for cores numbers not threads hwmon: (adt7470) Allow faster removal hwmon: (adt7470) Add write support to alarm_mask hwmon: (xgene) access mailbox as RAM hwmon: (lm95245) Use new hwmon registration API hwmon: (lm95241) Convert to use new hwmon registration API hwmon: (jc42) Convert to use new hwmon registration API hwmon: (max31790) Convert to use new hwmon registration API hwmon: (nct7904) Convert to use new hwmon registration API hwmon: (ltc4245) Convert to use new hwmon registration API hwmon: (tmp421) Convert to use new hwmon registration API hwmon: (tmp102) Convert to use new hwmon registration API hwmon: (lm90) Convert to use new hwmon registration API hwmon: (lm75) Convert to use new hwmon registration API hwmon: (xgene) Fix crash when alarm occurs before driver probe hwmon: (iio_hwmon) defer probe when no channel is found ...
2016-09-18hwmon: (nct6775) Add support for multiple virtual temperature sourcesGuenter Roeck1-2/+13
For virtual temperatures, the actual temperature values are written by software, presumably by the BIOS. This functionality is (as of right now) supported on NCT6791D, NCT6792D, and NCT6793D. On those chips, the temperatures are written into registers 0xea..0xef on page 0. This is known to be used on some Asus motherboards, where the actual temperature source can be configured in the BIOS. Report the 'virtual' temperatures for all monotoring sources to address this situation. Example for the resulting output (as seen with the 'sensors' command): nct6791-isa-0290 Adapter: ISA adapter ... Virtual_TEMP: +31.0°C PECI Agent 0: +38.5°C Virtual_TEMP: +32.0°C ... Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-18hwmon: (adt7470) No need for additional synchronization on kthread_stop()Daniel Wagner1-4/+0
The kthread_stop() waits for the thread to exit. There is no need for an additional synchronization needed to join on the kthread. The completion was added by 89fac11cb3e7 ("adt7470: make automatic fan control really work"). Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de> Cc: Darrick J. Wong <djwong@us.ibm.com> Cc: Jean Delvare <jdelvare@suse.com> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-13hwmon: (lm95241) Update module description to include LM95231Axel Lin1-1/+1
This driver also supports LM95231. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-13hwmon: (lm95245) Select REGMAP_I2CAxel Lin1-0/+1
This driver now uses regmap APIs, so it needs to select REGMAP_I2C. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-13hwmon: (ibmpowernv) Fix label for cores numbers not threadsMichael Neuling1-5/+3
Currently the label says "Core" but lists the thread numbers. This ends up looking like this: # cat /sys/class/hwmon/hwmon0/temp[1-4]_label Core 0-7 Core 8-15 Core 16-23 Core 24-31 This is misleading as it looks like it's cores 0-7 when it's actually threads 0-7. This changes the print to just give the core number, so the output now looks like this: # cat /sys/class/hwmon/hwmon0/temp[1-4]_label Core 0 Core 8 Core 16 Core 24 Signed-off-by: Michael Neuling <mikey@neuling.org> Acked-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-10hwmon: (adt7470) Allow faster removalJoshua Scott1-1/+4
adt7470_remove will wait for the update thread to complete before returning. This had a worst-case time of up to the user-configurable auto_update_interval. Replace msleep_interruptible with set_current_state and schedule_timeout so that kthread_stop will interrupt the sleep. Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-10hwmon: (adt7470) Add write support to alarm_maskJoshua Scott1-1/+24
Add write support for the alarm_mask. A base of 0 is provided so that either hex or decimal can be used. The hex format when reading alarm_mask is unchanged. Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (xgene) access mailbox as RAMArnd Bergmann1-14/+15
The newly added hwmon driver fails to build in an allmodconfig kernel: ERROR: "memblock_is_memory" [drivers/hwmon/xgene-hwmon.ko] undefined! According to comments in the code, the mailbox is a shared memory region, not a set of MMIO registers, so we should use memremap() for mapping it instead of ioremap or acpi_os_ioremap, and pointer dereferences instead of readl/writel. The driver already uses plain kernel pointers, so it's a bit unusual to work with functions that operate on __iomem pointers, and this fixes that part too. I'm using READ_ONCE/WRITE_ONCE here to keep the existing behavior regarding the ordering of the accesses from the CPU, but note that there are no barriers (also unchanged from before). I'm also keeping the endianness behavior, though I'm unsure whether the message data was supposed to be in LE32 format in the first place, it's possible this was meant to be interpreted as a byte stream instead. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Hoan Tran <hotran@apm.com> Tested-by: Hoan Tran <hotran@apm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (lm95245) Use new hwmon registration APIGuenter Roeck1-259/+379
Simplify code and reduce code size by using the new hwmon registration API. Other changes: - Convert to use regmap, and drop local caching. This avoids reading registers unnecessarily, and uses regmap for caching of non-volatile registers. - Add support for temp2_max, temp2_max_alarm, temp2_max_hyst, and temp2_offset. - Order include files alphabetically - Drop FSF address - Check errors from register read and write functions and report to userspace. - Accept negative hysteresis values. While unlikely, a maximum limit _can_ be set to a value smaller than 31 degrees C, which makes negative hysteresis values possible. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (lm95241) Convert to use new hwmon registration APIGuenter Roeck1-189/+241
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (jc42) Convert to use new hwmon registration APIGuenter Roeck1-144/+149
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (max31790) Convert to use new hwmon registration APIGuenter Roeck1-297/+224
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (nct7904) Convert to use new hwmon registration APIGuenter Roeck1-285/+270
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (ltc4245) Convert to use new hwmon registration APIGuenter Roeck1-187/+175
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (tmp421) Convert to use new hwmon registration APIGuenter Roeck1-75/+58
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (tmp102) Convert to use new hwmon registration APIGuenter Roeck2-65/+90
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (lm90) Convert to use new hwmon registration APIGuenter Roeck1-376/+435
Reduce driver complexity and size by converting it to the new hwmon API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (lm75) Convert to use new hwmon registration APIGuenter Roeck2-70/+116
Simplify code and reduce code size by using the new hwmon registration API. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (xgene) Fix crash when alarm occurs before driver probehotran1-19/+50
The system crashes during probing xgene-hwmon driver when temperature alarm interrupt occurs before. It's because - xgene_hwmon_probe() requests mailbox channel which also enables the mailbox interrupt. - As temperature alarm interrupt is pending, ISR runs and crashes when accesses into invalid resourse as unmapped PCC shared memory. This patch fixes this issue by saving this alarm message and scheduling a bottom handler after xgene_hwmon_probe() finish. Signed-off-by: Hoan Tran <hotran@apm.com> Reported-by: Itaru Kitayama <itaru.kitayama@riken.jp> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (iio_hwmon) defer probe when no channel is foundQuentin Schulz1-1/+4
iio_channel_get_all returns -ENODEV when it cannot find either phandles and properties in the Device Tree or channels whose consumer_dev_name matches iio_hwmon in iio_map_list. The iio_map_list is filled in by iio drivers which might be probed after iio_hwmon. It is better to defer the probe of iio_hwmon if such error is returned by iio_channel_get_all in order to let a chance to iio drivers to expose channels in iio_map_list. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (max6650) Allow fan shutdown and initial rpm targetMike Looijmans1-41/+67
The fan can be stopped by writing "3" to pwm1_enable in sysfs. Add devicetree property for early initialization of the fan controller to prevent overheating, for example when resetting the board while the fan was completely turned off. Also improve error reporting, I2C failures were ignored while writing new values. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (max6650) Add devicetree supportMike Looijmans1-11/+36
Parse devicetree parameters for voltage and prescaler setting. This allows using multiple max6550 devices with varying settings, and also makes it possible to instantiate and configure the device using devicetree. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (it87) Drop useless commentsJean Delvare1-4/+4
Remove the index comments at the end of it87_attributes_in. They serve no purpose (as there is no reference to them in it87_in_is_visible) and some of them were obviously wrong. Signed-off-by: Jean Delvare <jdelvare@suse.de> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (ucd9000) Add support for UCD90160 Power Supply SequencerMatt Weber2-4/+5
The UCD90160 Power Supply Sequencer reuses the existing register layout, so just an id addition was required. Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com> Signed-off-by: Ronak Desai <ronak.desai@rockwellcollins.com> [groeck: Updated description, ordered alphabetically, added documentation] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (scpi) Delete unnecessary assignment for the field "owner"Markus Elfring1-1/+0
The field "owner" is set by the core. Thus delete an unneeded initialisation. Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (ftsteutates) Add i2c detect functionalityThilo Cestonaro1-0/+45
Signed-off-by: Thilo Cestonaro <thilo@cestona.ro> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: Add xgene hwmon driverhotran3-0/+763
This patch adds hardware temperature and power reading support for APM X-Gene SoC using the mailbox communication interface. Signed-off-by: Hoan Tran <hotran@apm.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (core) Avoid cyclic dependency between hwmon and thermal_sysGuenter Roeck1-2/+8
If both hwmon and thermal_sys are built as modules, and CONFIG_THERMAL_HWMON is enabled, the following cyclic module dependency is reported. depmod: ERROR: Found 2 modules in dependency cycles! depmod: ERROR: Cycle detected: hwmon -> thermal_sys -> hwmon Fixes: e4bce763adb2 ("hwmon: (core) New hwmon registration API") Reported-by: Vignesh R <vigneshr@ti.com> Cc: Keerthy J <j-keerthy@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (adt7470) Expose PWM frequency to sysfsJoshua Scott1-0/+74
The ADT7470 supports a variety of PWM frequencies. This patch allows the frequency to be configured and viewed through the sysfs entry pwm1_freq. Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (ltc4151) Make shunt-resistor configurableDaniel Golle1-2/+20
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-08hwmon: (nct6775) Do not accept force_id unless chip is foundGuenter Roeck1-4/+4
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-08hwmon: (core) Add basic pwm attribute support to new APIGuenter Roeck1-0/+9
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-08hwmon: (core) Add fan attribute support to new APIGuenter Roeck1-0/+16
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-08hwmon: (core) Add energy and humidity attribute support to new APIGuenter Roeck1-0/+20
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-08hwmon: (core) Add power attribute support to new APIGuenter Roeck1-0/+30
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-08hwmon: (core) Add current attribute support to new APIGuenter Roeck1-0/+21
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-08hwmon: (core) Add voltage attribute support to new APIGuenter Roeck1-0/+21
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-08hwmon: (core) New hwmon registration APIGuenter Roeck1-27/+458
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-08hwmon: (core) Order include files alphabeticallyGuenter Roeck1-6/+4
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-08hwmon: (ntc_thermistor) Use devm_hwmon_device_register_with_groupsGuenter Roeck1-48/+9
Simplify code, reduce code size, and drop remove function as no longer needed. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (ntc_thermistor) Use dev instead of &pdev->dev where possibleGuenter Roeck1-27/+25
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-08hwmon: (ntc_thermistor) Use devm_iio_channel_getGuenter Roeck1-11/+1
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-08hwmon: (pmbus) Add explicit support for DPS-460, DPS-800, and SGD009Vadim Pasternak1-2/+18
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-08hwmon: (adt7411) add external thermal diode supportMichael Walle1-8/+43
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-08hwmon: (lm95241) Use more accurate limitsGuenter Roeck1-6/+2
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-08hwmon: (lm95241) Use BIT macro where appropriateGuenter Roeck1-24/+21
Drop some of the SHIFT defines since shift is implied with BIT(). Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (lm95241) Drop FSF addressGuenter Roeck1-4/+0
The FSF address may change, and providing it does not add any value. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (lm95241) Order include files alphabeticallyGuenter Roeck1-4/+4
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-08hwmon: (lm95241) Add support for fault attributesGuenter Roeck1-1/+19
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>