summaryrefslogtreecommitdiff
path: root/drivers/hwmon
AgeCommit message (Collapse)Author
2022-08-29hwmon: (gpio-fan) Fix array out of bounds accessArmin Wolf
The driver does not check if the cooling state passed to gpio_fan_set_cur_state() exceeds the maximum cooling state as stored in fan_data->num_speeds. Since the cooling state is later used as an array index in set_fan_speed(), an array out of bounds access can occur. This can be exploited by setting the state of the thermal cooling device to arbitrary values, causing for example a kernel oops when unavailable memory is accessed this way. Example kernel oops: [ 807.987276] Unable to handle kernel paging request at virtual address ffffff80d0588064 [ 807.987369] Mem abort info: [ 807.987398] ESR = 0x96000005 [ 807.987428] EC = 0x25: DABT (current EL), IL = 32 bits [ 807.987477] SET = 0, FnV = 0 [ 807.987507] EA = 0, S1PTW = 0 [ 807.987536] FSC = 0x05: level 1 translation fault [ 807.987570] Data abort info: [ 807.987763] ISV = 0, ISS = 0x00000005 [ 807.987801] CM = 0, WnR = 0 [ 807.987832] swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000001165000 [ 807.987872] [ffffff80d0588064] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000 [ 807.987961] Internal error: Oops: 96000005 [#1] PREEMPT SMP [ 807.987992] Modules linked in: cmac algif_hash aes_arm64 algif_skcipher af_alg bnep hci_uart btbcm bluetooth ecdh_generic ecc 8021q garp stp llc snd_soc_hdmi_codec brcmfmac vc4 brcmutil cec drm_kms_helper snd_soc_core cfg80211 snd_compress bcm2835_codec(C) snd_pcm_dmaengine syscopyarea bcm2835_isp(C) bcm2835_v4l2(C) sysfillrect v4l2_mem2mem bcm2835_mmal_vchiq(C) raspberrypi_hwmon sysimgblt videobuf2_dma_contig videobuf2_vmalloc fb_sys_fops videobuf2_memops rfkill videobuf2_v4l2 videobuf2_common i2c_bcm2835 snd_bcm2835(C) videodev snd_pcm snd_timer snd mc vc_sm_cma(C) gpio_fan uio_pdrv_genirq uio drm fuse drm_panel_orientation_quirks backlight ip_tables x_tables ipv6 [ 807.988508] CPU: 0 PID: 1321 Comm: bash Tainted: G C 5.15.56-v8+ #1575 [ 807.988548] Hardware name: Raspberry Pi 3 Model B Rev 1.2 (DT) [ 807.988574] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 807.988608] pc : set_fan_speed.part.5+0x34/0x80 [gpio_fan] [ 807.988654] lr : gpio_fan_set_cur_state+0x34/0x50 [gpio_fan] [ 807.988691] sp : ffffffc008cf3bd0 [ 807.988710] x29: ffffffc008cf3bd0 x28: ffffff80019edac0 x27: 0000000000000000 [ 807.988762] x26: 0000000000000000 x25: 0000000000000000 x24: ffffff800747c920 [ 807.988787] x23: 000000000000000a x22: ffffff800369f000 x21: 000000001999997c [ 807.988854] x20: ffffff800369f2e8 x19: ffffff8002ae8080 x18: 0000000000000000 [ 807.988877] x17: 0000000000000000 x16: 0000000000000000 x15: 000000559e271b70 [ 807.988938] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 [ 807.988960] x11: 0000000000000000 x10: ffffffc008cf3c20 x9 : ffffffcfb60c741c [ 807.989018] x8 : 000000000000000a x7 : 00000000ffffffc9 x6 : 0000000000000009 [ 807.989040] x5 : 000000000000002a x4 : 0000000000000000 x3 : ffffff800369f2e8 [ 807.989062] x2 : 000000000000e780 x1 : 0000000000000001 x0 : ffffff80d0588060 [ 807.989084] Call trace: [ 807.989091] set_fan_speed.part.5+0x34/0x80 [gpio_fan] [ 807.989113] gpio_fan_set_cur_state+0x34/0x50 [gpio_fan] [ 807.989199] cur_state_store+0x84/0xd0 [ 807.989221] dev_attr_store+0x20/0x38 [ 807.989262] sysfs_kf_write+0x4c/0x60 [ 807.989282] kernfs_fop_write_iter+0x130/0x1c0 [ 807.989298] new_sync_write+0x10c/0x190 [ 807.989315] vfs_write+0x254/0x378 [ 807.989362] ksys_write+0x70/0xf8 [ 807.989379] __arm64_sys_write+0x24/0x30 [ 807.989424] invoke_syscall+0x4c/0x110 [ 807.989442] el0_svc_common.constprop.3+0xfc/0x120 [ 807.989458] do_el0_svc+0x2c/0x90 [ 807.989473] el0_svc+0x24/0x60 [ 807.989544] el0t_64_sync_handler+0x90/0xb8 [ 807.989558] el0t_64_sync+0x1a0/0x1a4 [ 807.989579] Code: b9403801 f9402800 7100003f 8b35cc00 (b9400416) [ 807.989627] ---[ end trace 8ded4c918658445b ]--- Fix this by checking the cooling state and return an error if it exceeds the maximum cooling state. Tested on a Raspberry Pi 3. Fixes: b5cf88e46bad ("(gpio-fan): Add thermal control hooks") Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220830011101.178843-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-08-17hwmon: (pmbus) Fix vout margin cachingVincent Whitchurch
The code currently uses a zero margin to mean not cached, but this results in the cache being bypassed if the (low) margin is set to zero, leading to lots of unnecessary SMBus transactions in that case. Use a negative value instead. Fixes: 07fb76273db89d93 ("hwmon: (pmbus) Introduce and use cached vout margins") Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com> Link: https://lore.kernel.org/r/20220816144414.2358974-1-vincent.whitchurch@axis.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-08-17hwmon: (pmbus) Use dev_err_probe() to filter -EPROBE_DEFER error messagesChristophe JAILLET
devm_regulator_register() can return -EPROBE_DEFER, so better use dev_err_probe() instead of dev_err(), it is less verbose in such a case. It is also more informative, which can't hurt. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/3adf1cea6e32e54c0f71f4604b4e98d992beaa71.1660741419.git.christophe.jaillet@wanadoo.fr Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-08-10hwmon: (nct6775) Fix platform driver suspend regressionZev Weiss
Commit c3963bc0a0cf ("hwmon: (nct6775) Split core and platform driver") introduced a slight change in nct6775_suspend() in order to avoid an otherwise-needless symbol export for nct6775_update_device(), replacing a call to that function with a simple dev_get_drvdata() instead. As it turns out, there is no guarantee that nct6775_update_device() is ever called prior to suspend. If this happens, the resume function ends up writing bad data into the various chip registers, which results in a crash shortly after resume. To fix the problem, just add the symbol export and return to using nct6775_update_device() as was employed previously. Reported-by: Zoltán Kővágó <dirty.ice.hu@gmail.com> Tested-by: Zoltán Kővágó <dirty.ice.hu@gmail.com> Fixes: c3963bc0a0cf ("hwmon: (nct6775) Split core and platform driver") Cc: stable@kernel.org Signed-off-by: Zev Weiss <zev@bewilderbeest.net> Link: https://lore.kernel.org/r/20220810052646.13825-1-zev@bewilderbeest.net [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-08-10hwmon: (lm90) Fix error return value from detect functionGuenter Roeck
lm90_detect_nuvoton() is supposed to return NULL if it can not detect a chip, or a pointer to the chip name if it does. Under some circumstances it returns an error pointer instead. Some versions of gcc interpret an ERR_PTR as region of size 0 and generate an error message. In function ‘__fortify_strlen’, inlined from ‘strlcpy’ at ./include/linux/fortify-string.h:159:10, inlined from ‘lm90_detect’ at drivers/hwmon/lm90.c:2550:2: ./include/linux/fortify-string.h:50:33: error: ‘__builtin_strlen’ reading 1 or more bytes from a region of size 0 50 | #define __underlying_strlen __builtin_strlen | ^ ./include/linux/fortify-string.h:141:24: note: in expansion of macro ‘__underlying_strlen’ 141 | return __underlying_strlen(p); | ^~~~~~~~~~~~~~~~~~~ Returning NULL instead of ERR_PTR() fixes the problem. Fixes: c7cebce984a2 ("hwmon: (lm90) Rework detect function") Reported-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Kees Cook <keescook@chromium.org> Tested-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-08-02Merge tag 'hwmon-for-v5.20' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon updates from Guenter Roeck: - Substantial rewrite of lm90 driver to support several additional chips and improve support for existing chips. - Add support of ROG ZENITH II EXTREME, Maximus XI Hero, and Strix Z690-a D4 to asus-ec-sensors driver - Add support of F71858AD to f71882fg driver - Add support of Aquacomputer Quadro to aquacomputer_d5next driver - Improved assembler code and add support for Dell G5 5590 as well as XPS 13 7390 in dell-smm driver - Add support for ASUS TUF GAMING B550-PLUS WIFI II to nct775 driver - Add support for IEEE 754 half precision to PMBus core. Also support for Analog Devices LT7182S, improve regulator support, and report various MFR register values in debugfs. - Various other minor improvements and fixes * tag 'hwmon-for-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (85 commits) hwmon: (aquacomputer_d5next) Add support for Aquacomputer Quadro fan controller hwmon: (dell-smm) Improve documentation hwmon: (nct6775) add ASUS TUF GAMING B550-PLUS WIFI II hwmon: (occ) Replace open-coded variant of %*phN specifier hwmon: (sht15) Fix wrong assumptions in device remove callback hwmon: (aquacomputer_d5next) Add support for reading the +12V voltage sensor on D5 Next hwmon: (tps23861) fix byte order in current and voltage registers hwmon: (aspeed-pwm-tacho) increase fan tach period (again) hwmon: (aquacomputer_d5next) Add D5 Next fan control support hwmon: (mcp3021) improve driver support for newer hwmon interface hwmon: (asus-ec-sensors) add definitions for ROG ZENITH II EXTREME hwmon: (aquacomputer_d5next) Move device-specific data into struct aqc_data hwmon: (asus-ec-sensors) add missing sensors for X570-I GAMING hwmon: (drivetemp) Add module alias hwmon: (asus_wmi_sensors) Save a few bytes of memory hwmon: (lm90) Use worker for alarm notifications hwmon: (asus-ec-sensors) add support for Maximus XI Hero hwmon: (dell-smm) Improve assembly code hwmon: (pmbus/ltc2978) Set voltage resolution hwmon: (pmbus) Add list_voltage to pmbus ops ...
2022-08-01Merge tag 'x86_misc_for_v6.0_rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull misc x86 updates from Borislav Petkov: - Add a bunch of PCI IDs for new AMD CPUs and use them in k10temp - Free the pmem platform device on the registration error path * tag 'x86_misc_for_v6.0_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: hwmon: (k10temp): Add support for new family 17h and 19h models x86/amd_nb: Add AMD PCI IDs for SMN communication x86/pmem: Fix platform-device leak in error path
2022-07-27hwmon: (aquacomputer_d5next) Add support for Aquacomputer Quadro fan controllerAleksa Savic
Extend aquacomputer_d5next driver to expose hardware temperature sensors and fans of the Aquacomputer Quadro fan controller, which communicates through a proprietary USB HID protocol. Implemented by Jack Doan [1]. Four temperature sensors and PWM controllable fans are available. The liquid flow sensor is also exposed, implemented by Leonard Anderweit [2]. Additionally, serial number, firmware version and power-on count are exposed through debugfs. This driver has been tested on x86_64. [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/5 [2] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/pull/9 Originally-from: Jack Doan <me@jackdoan.com> Originally-from: Leonard Anderweit <leonard.anderweit@gmail.com> Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> Link: https://lore.kernel.org/r/20220727100606.9328-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-26hwmon: (nct6775) add ASUS TUF GAMING B550-PLUS WIFI IIRobert Schmidt
Add ASUS TUF GAMING B550-PLUS WIFI II to the WMI monitoring list to enable support for HW monitoring on that board. Signed-off-by: Robert Schmidt <r-schmidt@web.de> Link: https://lore.kernel.org/r/YuBZodZHOnDll5zy@hydra Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-26hwmon: (occ) Replace open-coded variant of %*phN specifierAndy Shevchenko
printf()-like functions in the kernel have extensions, such as %*phN to dump small pieces of memory as hex bytes. Replace custom approach with the direct use of %*phN. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220726143110.4809-1-andriy.shevchenko@linux.intel.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-26hwmon: (sht15) Fix wrong assumptions in device remove callbackUwe Kleine-König
Taking a lock at the beginning of .remove() doesn't prevent new readers. With the existing approach it can happen, that a read occurs just when the lock was taken blocking the reader until the lock is released at the end of the remove callback which then accessed *data that is already freed then. To actually fix this problem the hwmon core needs some adaption. Until this is implemented take the optimistic approach of assuming that all readers are gone after hwmon_device_unregister() and sysfs_remove_group() as most other drivers do. (And once the core implements that, taking the lock would deadlock.) So drop the lock, move the reset to after device unregistration to keep the device in a workable state until it's deregistered. Also add a error message in case the reset fails and return 0 anyhow. (Returning an error code, doesn't stop the platform device unregistration and only results in a little helpful error message before the devm cleanup handlers are called.) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20220725194344.150098-1-u.kleine-koenig@pengutronix.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-26hwmon: (aquacomputer_d5next) Add support for reading the +12V voltage sensor ↵Aleksa Savic
on D5 Next Add support for reading the +12V voltage that the D5 Next pump receives. Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> Link: https://lore.kernel.org/r/20220726120203.33773-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-21hwmon: (tps23861) fix byte order in current and voltage registersAlexandru Gagniuc
Trying to use this driver on a big-endian machine results in garbage values for voltage and current. The tps23861 registers are little- endian, and regmap_read_bulk() does not do byte order conversion. Thus on BE machines, the most significant bytes got modified, and were trimmed by the VOLTAGE_CURRENT_MASK. To resolve this use uint16_t values, and convert them to host byte order using le16_to_cpu(). This results in correct readings on MIPS. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Link: https://lore.kernel.org/r/20220721032255.2850647-1-mr.nuke.me@gmail.com [groeck: Use __le16 instead of uint16_t] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-21hwmon: (aspeed-pwm-tacho) increase fan tach period (again)Paul Fertser
The old value allows measuring fan speeds down to about 970 RPM and gives timeout for anything less than that. It is problematic because it can also be used as an indicator for fan failure or absence. Despite having read the relevant section of "ASPEED AST2500/AST2520 A2 Datasheet – V1.7" multiple times I wasn't able to figure out what exactly "fan tach period" and "fan tach falling point of period" mean (both are set by the driver from the constant this patch is amending). Experimentation with a Tioga Pass OCP board (AST2500 BMC) showed that value of 0x0108 gives time outs for speeds below 1500 RPM and the value offered by the patch is good for at least 750 RPM (the fans can't spin any slower so the lower bound is unknown). Measuring with the fans spinning takes about 30 ms, sometimes down to 18 ms, so about the same as with the previous value. This constant was last changed with commit 762b1e888013 ("hwmon: (aspeed-pwm-tacho) increase fan tach period") Signed-off-by: Paul Fertser <fercerpav@gmail.com> Link: https://lore.kernel.org/r/20220714142344.27071-1-fercerpav@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-21hwmon: (aquacomputer_d5next) Add D5 Next fan control supportAleksa Savic
Define pump and fan speed register offsets in D5 Next control report, as well as its size, to expose PWM fan control. Originally-from: Jack Doan <me@jackdoan.com> Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> Link: https://lore.kernel.org/r/20220717171412.11142-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-20hwmon: (k10temp): Add support for new family 17h and 19h modelsMario Limonciello
Add the support for CCD offsets used on family 17h models A0h-AFh, and family 19h models 60h-7Fh. [ bp: Merge into a single patch. ] Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20220719195256.1516-1-mario.limonciello@amd.com
2022-07-15hwmon: (mcp3021) improve driver support for newer hwmon interfaceMarc Ferland
This driver is currently broken, it does not show the in0_input sysfs file and also returns the following message on startup: hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info(). This patch converts the driver and also cleans up the 'read' function. Signed-off-by: Marc Ferland <ferlandm@amotus.ca> Link: https://lore.kernel.org/r/20220712193504.1374656-1-ferlandm@amotus.ca Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (asus-ec-sensors) add definitions for ROG ZENITH II EXTREMEUrs Schroffenegger
Add definitions for ROG ZENITH II EXTREME and some unknown yet temperature sensors in the second EC bank. Details are available at [1, 2]. [1] https://github.com/zeule/asus-ec-sensors/pull/26 [2] https://github.com/zeule/asus-ec-sensors/issues/16 Signed-off-by: Urs Schroffenegger <nabajour@lampshade.ch> Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com> Link: https://lore.kernel.org/r/20220710202639.1812058-2-eugene.shalygin@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (aquacomputer_d5next) Move device-specific data into struct aqc_dataAleksa Savic
As preparation for adding support for more devices in upcoming patches, move device-specific data, such as number of fans, temperature sensors, register offsets etc. to struct aqc_data. This is made possible by the fact that the supported Aquacomputer devices share the same layouts of sensor substructures. This allows aqc_raw_event() and others to stay general and not be cluttered with similar loops for each device. Signed-off-by: Jack Doan <me@jackdoan.com> Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> Link: https://lore.kernel.org/r/20220707115050.90021-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (asus-ec-sensors) add missing sensors for X570-I GAMINGEugene Shalygin
VRM and chipset temperature for ROG STRIX X570-I GAMING were missing according to a user contribution to the LHM project [1]. [1] https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/pull/767 Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com> Link: https://lore.kernel.org/r/20220710085539.1682869-1-eugene.shalygin@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (drivetemp) Add module aliasLinus Walleij
Adding a MODULE_ALIAS() to drivetemp will make the driver easier for modprobe to autoprobe. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20220712214624.1845158-1-linus.walleij@linaro.org Fixes: 5b46903d8bf3 ("hwmon: Driver for disk and solid state drives with temperature sensors") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (asus_wmi_sensors) Save a few bytes of memoryChristophe JAILLET
The first 'for' loop of asus_wmi_configure_sensor_setup() only computes the number and type of sensors that exist in the system. Here, the 'temp_sensor' structure is only used to store the data collected by asus_wmi_sensor_info(). There is no point in using a devm_ variant for this allocation. This wastes some memory for no good reason. Use the stack instead. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/e23cea6c489fabb109a61e8a33d146a6b74c0529.1656741926.git.christophe.jaillet@wanadoo.fr Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Use worker for alarm notificationsGuenter Roeck
Reporting alarms using hwmon_notify_event() may result in a callback from the thermal subsystem. This means that such notifications must not hold the update lock to avoid a deadlock. To avoid this situation, use a worker to handle notifications. Reported-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Fixes: f6d0775119fb ("hwmon: (lm90) Rework alarm/status handling") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (asus-ec-sensors) add support for Maximus XI HeroMichael Carns
Add definitions for ROG MAXIMUS XI HERO and ROG MAXIMUS XI HERO (WI-FI) boards. Signed-off-by: Michael Carns <mike@carns.com> Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com> Link: https://lore.kernel.org/r/20220627225437.87462-1-eugene.shalygin@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (dell-smm) Improve assembly codeArmin Wolf
The new assembly code works on both 32 bit and 64 bit cpus and allows for more compiler optimisations. Since clang runs out of registers on 32 bit x86 when using CC_OUT, we need to execute "setc" ourself. Also modify the debug message so we can still see the result (eax) when the carry flag was set. Tested with 32 bit and 64 bit kernels on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220220190851.17965-1-W_Armin@gmx.de [groeck: Rebased to v5.19-rc3] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus/ltc2978) Set voltage resolutionMårten Lindahl
The LTC2977 regulator does not set the regulator_desc .n_voltages value which is needed in order to let the regulator core list the regulator voltage range. This patch defines a regulator_desc with a voltage range, and uses it for defining voltage resolution for regulators LTC2972/LTC2974/LTC2975/ LTC2977/LTC2978/LTC2979/LTC2980/LTM2987 based on that they all have a 16 bit ADC with the same stepwise 122.07uV resolution. It also scales the resolution to a 1mV resolution which is easier to handle. Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com> Link: https://lore.kernel.org/r/20220614095144.3472305-1-marten.lindahl@axis.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus) Add list_voltage to pmbus opsMårten Lindahl
When checking if a regulator supports a voltage range, the regulator needs to have a list_voltage callback set to the regulator_ops or else -EINVAL will be returned. This support does not exist for the pmbus regulators, so this patch adds pmbus_regulator_list_voltage to the pmbus_regulator_ops. Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com> Link: https://lore.kernel.org/r/20220614093856.3470672-3-marten.lindahl@axis.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus) Introduce and use cached vout marginsMårten Lindahl
When setting a new voltage the voltage boundaries are read every time to check that the new voltage is within the proper range. Checking these voltage boundaries consists of reading one of PMBUS_MFR_VOUT_MIN/ PMBUS_VOUT_MARGIN_LOW registers and then PMBUS_MFR_VOUT_MAX/ PMBUS_VOUT_MARGIN_HIGH together with writing the PMBUS_CLEAR_FAULTS register. Since these boundaries are never being changed, it can be cached and thus saving unnecessary smbus transmissions. Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com> Link: https://lore.kernel.org/r/20220614093856.3470672-2-marten.lindahl@axis.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (gsc-hwmon) Add missing of_node_put()Liang He
In gsc_hwmon_get_devtree_pdata(), of_find_compatible_node() will return a node pointer with refcount incremented. We should use of_node_put() in fail path or when it is not used anymore. Signed-off-by: Liang He <windhl@126.com> Link: https://lore.kernel.org/r/20220616114024.3985770-1-windhl@126.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (dell-smm) Add Dell G5 5590 to DMI tableArmin Wolf
According to Bug 215983 at bugzilla.kernel.org, the Dell G5 5590 supports the SMM interface and can thus be loaded with ignore_dmi being set. Add the model the DMI table to allow for automatic loadig on this model. Compile-tested only. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20220612232208.27901-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (dell-smm) Add Dell XPS 13 7390 to fan control whitelistArmin Wolf
A user reported that the program dell-bios-fan-control worked on his Dell XPS 13 7390 to switch off automatic fan control. Since it uses the same mechanism as the dell_smm_hwmon module, add this model to the fan control whitelist. Compile-tested only. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20220612041806.11367-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (nct6775) Drop duplicate NULL check in ->init() and ->exit()Andy Shevchenko
Since platform_device_unregister() is NULL-aware, we don't need to duplicate this check. Remove it and fold the rest of the code. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Zev Weiss <zev@bewilderbeest.net> Link: https://lore.kernel.org/r/20220610103324.87483-1-andriy.shevchenko@linux.intel.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus) fix build error unused-functionRen Zhijie
If CONFIG_PMBUS is y and CONFIG_DEBUG_FS is not set. make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-, will be failed, like this: drivers/hwmon/pmbus/pmbus_core.c:593:13: error: ‘pmbus_check_block_register’ defined but not used [-Werror=unused-function] static bool pmbus_check_block_register(struct i2c_client *client, int page, ^~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[3]: *** [drivers/hwmon/pmbus/pmbus_core.o] Error 1 make[2]: *** [drivers/hwmon/pmbus] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [drivers/hwmon] Error 2 make[1]: *** Waiting for unfinished jobs.... make: *** [drivers] Error 2 To fix building warning, use __maybe_unused to attach this func. Reported-by: Hulk Robot <hulkci@huawei.com> Fixes: c3ffc3a1ff83("hwmon: (pmbus) add a function to check the presence of a block register") Signed-off-by: Ren Zhijie <renzhijie2@huawei.com> Link: https://lore.kernel.org/r/20220609120448.139907-1-renzhijie2@huawei.com [groeck: Fixed continuation line alignment] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Read the channel's temperature offset from device-treeSlawomir Stepien
Try to read the channel's temperature offset from device-tree. Having offset in device-tree node is not mandatory. The offset can only be set for remote channels. Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com> Link: https://lore.kernel.org/r/20220607063504.1287855-3-sst@poczta.fm Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Add support for 2nd remote channel's offset registerSlawomir Stepien
The ADT7481 have LM90_HAVE_TEMP3 and LM90_HAVE_OFFSET flags, but the support of second remote channel's offset is missing. Add that implementation. Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com> Link: https://lore.kernel.org/r/20220607063504.1287855-2-sst@poczta.fm Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (occ) Delete unnecessary NULL checkZiyang Xuan
kvfree(NULL) is safe. NULL check before kvfree() is not needed. Delete them to simplify the code. Generated by coccinelle script: scripts/coccinelle/free/ifnullfree.cocci Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com> Reviewed-by: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/20220606131401.4053036-1-william.xuanziyang@huawei.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Read the channel's label from device-treeSlawomir Stepien
Try to read the channel's label from device-tree. Having label in device-tree node is not mandatory. Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com> Link: https://lore.kernel.org/r/20220525073657.573327-7-sst@poczta.fm Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Define maximum number of channels that are supportedSlawomir Stepien
Use this define in all the places where literal '3' was used in this context. Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com> Link: https://lore.kernel.org/r/20220525073657.573327-6-sst@poczta.fm Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Add compatible entry for adt7481Slawomir Stepien
This will allow binding the driver with the device from the device tree. Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com> Link: https://lore.kernel.org/r/20220525073657.573327-4-sst@poczta.fm Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: Allow to compile ASB100 and FSCHMD on !X86Uwe Kleine-König
The two drivers compile just fine on ARCH=arm. Allow to select these drivers if COMPILE_TEST is enabled. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Jean Delvare <jdelvare@suse.de> Link: https://lore.kernel.org/r/20220527153445.1871086-1-u.kleine-koenig@pengutronix.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus) add MFR_* registers to debugfsAdam Wujek
Add registers to debugfs: PMBUS_MFR_ID PMBUS_MFR_MODEL PMBUS_MFR_REVISION PMBUS_MFR_LOCATION PMBUS_MFR_DATE PMBUS_MFR_SERIAL To reduce the number of debugfs entries, only values from page 0 are reported. It is assumed that values of these registers are the same for all pages. Please note that the PMBUS standard allows added registers to be page-specific. Signed-off-by: Adam Wujek <dev_public@wujek.eu> Link: https://lore.kernel.org/r/20220601013232.801133-2-dev_public@wujek.eu Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus) add a function to check the presence of a block registerAdam Wujek
Other functions (like pmbus_check_byte_register) cannot be used to check the presence of a block register, because it will generate error when PEC is used. Signed-off-by: Adam Wujek <dev_public@wujek.eu> Link: https://lore.kernel.org/r/20220601013232.801133-1-dev_public@wujek.eu Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (asus-ec-sensors) add support for Strix Z690-a D4Shady Nawara
adds T_Sensor and VRM Temp sensors for the Asus Strix z690-a D4 motherboard Signed-off-by: Shady Nawara <shady.nawara@outlook.com> Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com> Link: https://lore.kernel.org/r/20220603122758.1561064-1-eugene.shalygin@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (sch56xx-common) Add DMI override tableArmin Wolf
Some devices like the Fujitsu Celsius W380 do contain a working sch56xx hardware monitoring device, but do not contain the necessary DMI onboard device. Do not check for the presence of an suitable onboard device on these machines. The list of affected machines was created using data collected by the Linux Hardware Project. Tested on a Fujitsu Esprimo P720, but sadly not on a affected machine. Fixes: 393935baa45e (hwmon: (sch56xx-common) Add automatic module loading on supported devices) Signed-off-by: Armin Wolf <W_Armin@gmx.de> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220604220200.2567-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm75) Replace kernel.h with the necessary inclusionsChristophe JAILLET
When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved. Replace kernel.h inclusion with the list of what is really being used. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/4e07ed43274ad912d4efcfc04f673f25e8f89fdc.1654289489.git.christophe.jaillet@wanadoo.fr Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (f71882fg) Add support for F71858AD (0x0903)Aleksander Mazur
Treat F71858AD like F71858FG. Tested on Igel D220. Signed-off-by: Aleksander Mazur <deweloper@wp.pl> Link: https://lore.kernel.org/r/20220605012114.3d85a75a@mocarz Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus) Add support for Analog Devices LT7182SGuenter Roeck
Add support for Analog Devices LT7182S Dual Channel 6A, 20V PolyPhase Step-Down Silent Switcher with Digital Power System Management. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (pmbus) Add IEEE 754 half precision support to PMBus coreGuenter Roeck
Add support for the IEEE 754 half precision data format as specified in PMBus v1.3.1. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Support temp_samples attributeGuenter Roeck
Several of the chips supported by this driver support configuring the number of samples (or the fault queue depth) necessary before a fault or alarm is reported. This is done either with a bit in the configuration register or with a separate "consecutive alert" register. Support this functionality with the temp_samples attribute. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (lm90) Add table with supported Analog/ONSEMI devicesGuenter Roeck
Add table with device names and known register values for supported devices from Analog / ON Semiconductor. Signed-off-by: Guenter Roeck <linux@roeck-us.net>