summaryrefslogtreecommitdiff
path: root/drivers/hwmon
AgeCommit message (Collapse)AuthorFilesLines
2021-03-10hwmon: peci: cleanupOlender, Agata3-44/+30
Add cleanup fixes after implementing energy sensor for all modules: cpu, dimm, platform to make all files consistent. Change-Id: I359b3627867df23dc4d80891437c0e53a04c16be Signed-off-by: Olender, Agata <agata.olender@intel.com>
2021-03-02Stop reading DRAM_MIN_PWRZbigniew Lukwinski1-33/+9
This commit is about disabling reading DRAM_MIN_PWR from DRAM_POWER_INFO PCS. Starting from SPR DRAM_MIN_PWR is deprecated. BIOS does not update DRAM min power anymore. Value of 0 shall be reported as DRAM min power. Change-Id: I4c4b3116e5d99989808fb4803740a00aa285a78f Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
2021-02-25hwmon: peci: TDP used for max DRAM powerZbigniew Lukwinski2-30/+4
This commit replaces 'Maximal DRAM Power' (MSR@61Ch - MSR_DRAM_POWER_INFO_HIGH) with the 'Spec DRAM Power'('TDP') (MSR@61Ch - MSR_DRAM_POWER_INFO_LOW) while maximal DRAM power calculation. This is to be compliant with SPS ME Node Manager. In case package power it already works with the same way - TDP is taken as maximal power. Change-Id: Iba55f0aa0ab73b32e4a068bb8bbd11136190fb75 Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
2021-02-19hwmon: (aspeed-pwm-tacho) Add pwm chip driver supportJae Hyun Yoo1-0/+124
This commit adds pwm chip driver support into aspeed-g6-pwm-tacho driver to enable beep speaker driver. The pwm chip driver cannot be added as a separate platform driver because it makes resource conflicts with existing pwm-tacho driver so it uses hacky tweak on the existing driver. Note: Do not try upstream this hacky implementation. Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com> Change-Id: I22ad12be2ae3a061d7942fec813cdb11be321db7
2021-02-19hwmon: peci: add energy sensor to peci-dimmpowerOlender, Agata1-56/+232
Add support for energy consumption of DIMMs sensor. Energy is reported in micro Joules and exposed under energyN_input file. Change-Id: I6fdcfb9873312df837fcaaeeed513b2991c6c8b5 Signed-off-by: Olender, Agata <agata.olender@intel.com>
2021-02-18hwmon: peci: cumulative energy sensorOlender, Agata2-69/+133
Change energy sensor to cumulative energy sensor. Actually energy sensor implementation works as simply translation for value read from PCS register to microjoules. With this change, energy sensor will behave as accumulative sensor> After every read on energyN_input file new energy sample will be gathered, and the difference between new sample and previous one will be added to sensor value. This approach solves problems with counters overflow and interpretation of the energy sensor value. Change-Id: I8ef0e6e52198af0f4a2f96c76589b4e02289ac6a Signed-off-by: Olender, Agata <agata.olender@intel.com>
2021-02-08fixup! hwmon: peci: add energy sensor to peci-cpupowerJae Hyun Yoo1-1/+1
Fix a kernel crash issue caused by division by zero. Feb 03 21:57:25 intel-obmc kernel: Division by zero in kernel. Feb 03 21:57:25 intel-obmc kernel: CPU: 0 PID: 391 Comm: cpusensor Not tainted 5.8.17-629ba88-dirty-0815a94 #1 Feb 03 21:57:25 intel-obmc kernel: Hardware name: Generic DT based system Feb 03 21:57:25 intel-obmc kernel: Backtrace: Feb 03 21:57:25 intel-obmc kernel: [<80106fb8>] (dump_backtrace) from [<8010720c>] (show_stack+0x20/0x24) Feb 03 21:57:25 intel-obmc kernel: r7:00000000 r6:9e217e80 r5:9e217e20 r4:8090dd9c Feb 03 21:57:25 intel-obmc kernel: [<801071ec>] (show_stack) from [<807a3114>] (dump_stack+0x28/0x30) Feb 03 21:57:25 intel-obmc kernel: [<807a30ec>] (dump_stack) from [<8010739c>] (__div0+0x20/0x28) Feb 03 21:57:25 intel-obmc kernel: r5:9e217e20 r4:00000000 Feb 03 21:57:25 intel-obmc kernel: [<8010737c>] (__div0) from [<807a1d9c>] (Ldiv0+0x8/0x2c) Feb 03 21:57:25 intel-obmc kernel: [<805e6a0c>] (peci_cpupower_get_average_power) from [<805e6764>] (peci_cpupower_read+0xbc/0x104) Feb 03 21:57:25 intel-obmc kernel: r10:977fbf68 r9:9da0c720 r8:9d988c08 r7:977a0000 r6:00000001 r5:9e217e80 Feb 03 21:57:25 intel-obmc kernel: r4:977fbe30 Feb 03 21:57:25 intel-obmc kernel: [<805e66a8>] (peci_cpupower_read) from [<805e0e84>] (hwmon_attr_show+0x50/0xfc) Feb 03 21:57:25 intel-obmc kernel: r7:977a0000 r6:8085a708 r5:805e66a8 r4:9d9d7400 Feb 03 21:57:25 intel-obmc kernel: [<805e0e34>] (hwmon_attr_show) from [<80501224>] (dev_attr_show+0x28/0x58) Feb 03 21:57:25 intel-obmc kernel: r9:9da0c720 r8:9d988c08 r7:977a0000 r6:8085a708 r5:9d9d7400 r4:9d9539d8 Feb 03 21:57:25 intel-obmc kernel: [<805011fc>] (dev_attr_show) from [<802bfad4>] (sysfs_kf_seq_show+0x8c/0x104) Feb 03 21:57:25 intel-obmc kernel: r5:00001000 r4:9d9539d8 Feb 03 21:57:25 intel-obmc kernel: [<802bfa48>] (sysfs_kf_seq_show) from [<802be1ac>] (kernfs_seq_show+0x34/0x38) Feb 03 21:57:25 intel-obmc kernel: r9:00000001 r8:9d9539f0 r7:977fbf68 r6:00000000 r5:00000000 r4:9d9539d8 Feb 03 21:57:26 intel-obmc kernel: [<802be178>] (kernfs_seq_show) from [<8025ea38>] (seq_read+0xd0/0x5dc) Feb 03 21:57:26 intel-obmc kernel: [<8025e968>] (seq_read) from [<802bee9c>] (kernfs_fop_read+0x3c/0x1cc) Feb 03 21:57:26 intel-obmc kernel: r10:00000000 r9:977fbf68 r8:00000001 r7:977fbf68 r6:0245f868 r5:9da0c720 Feb 03 21:57:26 intel-obmc kernel: r4:802bee60 Feb 03 21:57:26 intel-obmc kernel: [<802bee60>] (kernfs_fop_read) from [<80234ccc>] (vfs_read+0xa4/0x158) Feb 03 21:57:26 intel-obmc kernel: r10:00000000 r9:977fbf68 r8:00000001 r7:0245f868 r6:9d929500 r5:00000000 Feb 03 21:57:26 intel-obmc kernel: r4:802bee60 Feb 03 21:57:26 intel-obmc kernel: [<80234c28>] (vfs_read) from [<80235224>] (ksys_read+0x70/0xf8) Feb 03 21:57:26 intel-obmc kernel: r9:977fa000 r8:80100224 r7:00000000 r6:00000000 r5:9d929500 r4:9d929500 Feb 03 21:57:26 intel-obmc kernel: [<802351b4>] (ksys_read) from [<802352c4>] (sys_read+0x18/0x1c) Feb 03 21:57:26 intel-obmc kernel: r7:00000003 r6:7e80c9f0 r5:76f9a840 r4:024584fc Feb 03 21:57:26 intel-obmc kernel: [<802352ac>] (sys_read) from [<80100040>] (ret_fast_syscall+0x0/0x54) Feb 03 21:57:26 intel-obmc kernel: Exception stack(0x977fbfa8 to 0x977fbff0) Feb 03 21:57:26 intel-obmc kernel: bfa0: 024584fc 76f9a840 00000017 0245f868 00000200 00000000 Feb 03 21:57:26 intel-obmc kernel: bfc0: 024584fc 76f9a840 7e80c9f0 00000003 0245f868 00000200 024371f0 7e80ca40 Reported-by: Johnathan Mantey <johnathanx.mantey@intel.com> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com> Change-Id: I36a047ee8a941f3aba672536894d0df8a4e18c32
2021-01-27hwmon: peci: adjust energy sensor value to S32 typeOlender, Agata1-2/+2
Adjust energy sensor to be 31 bits counter and return only positive values using S32 type - that is a part of common sensor struct for all hwmon peci sensors. Change-Id: Iae602401f228aa0e8789de8c8cf3a4796c9aadd9 Signed-off-by: Olender, Agata <agata.olender@intel.com>
2021-01-05hwmon: peci: add energy sensor to peci-cpupowerOlender, Agata3-149/+335
Add support for energy consumption of CPU package sensor. Energy is reported in micro Joules and exposed under energyN_input file. Change-Id: I853e9ba8f7223a3cbfbbdf82719aee78999486da Signed-off-by: Olender, Agata <agata.olender@intel.com>
2020-11-05Merge v5.8.17, commit '6d07b544ce203a684d9ca52635dcf2f4fc89b7d4' into ↵Jason M. Bills10-63/+171
dev-5.8-intel
2020-10-30Merge tag 'v5.8.17' into dev-5.8Joel Stanley4-44/+106
This is the 5.8.17 stable release Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-10-29hwmon: (bt1-pvt) Wait for the completion with timeoutSerge Semin1-1/+12
[ Upstream commit 0ffd21d5985506d164ada9e8fff6daae8ef469a1 ] If the PVT sensor is suddenly powered down while a caller is waiting for the conversion completion, the request won't be finished and the task will hang up on this procedure until the power is back up again. Let's call the wait_for_completion_timeout() method instead to prevent that. The cached timeout is exactly what we need to predict for how long conversion could normally last. Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver") Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Link: https://lore.kernel.org/r/20200920110924.19741-4-Sergey.Semin@baikalelectronics.ru Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29hwmon: (bt1-pvt) Cache current update timeoutSerge Semin2-39/+49
[ Upstream commit 0015503e5f6357f286bef34d039e43359fa4efd4 ] Instead of converting the update timeout data to the milliseconds each time on the read procedure let's preserve the currently set timeout in the dedicated driver private data cache. The cached value will be then used in the timeout read method and in the alarm-less data conversion to prevent the caller task hanging up in case if the PVT sensor is suddenly powered down. Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver") Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Link: https://lore.kernel.org/r/20200920110924.19741-3-Sergey.Semin@baikalelectronics.ru Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29hwmon: (bt1-pvt) Test sensor power supply on probeSerge Semin1-0/+40
[ Upstream commit a6db1561291fc0f2f9aa23bf38f381adc63e7b14 ] Baikal-T1 PVT sensor has got a dedicated power supply domain (feed up by the external GPVT/VPVT_18 pins). In case if it isn't powered up, the registers will be accessible, but the sensor conversion just won't happen. Due to that an attempt to read data from any PVT sensor will cause the task hanging up. For instance that will happen if XP11 jumper isn't installed on the Baikal-T1-based BFK3.1 board. Let's at least test whether the conversion work on the device probe procedure. By doing so will make sure that the PVT sensor is powered up at least at boot time. Fixes: 87976ce2825d ("hwmon: Add Baikal-T1 PVT sensor driver") Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Link: https://lore.kernel.org/r/20200920110924.19741-2-Sergey.Semin@baikalelectronics.ru Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29hwmon: (w83627ehf) Fix a resource leak in probeDan Carpenter1-1/+5
[ Upstream commit 18360b33a071e5883250fd1e04bfdeff8c3887a3 ] Smatch has a new check for resource leaks which found a bug in probe: drivers/hwmon/w83627ehf.c:2417 w83627ehf_probe() warn: 'res->start' not released on lines: 2412. We need to clean up if devm_hwmon_device_register_with_info() fails. Fixes: 266cd5835947 ("hwmon: (w83627ehf) convert to with_info interface") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Dr. David Alan Gilbert <linux@treblig.org> Link: https://lore.kernel.org/r/20200921125212.GA1128194@mwanda Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29hwmon: (pmbus/max34440) Fix status register reads for MAX344{51,60,61}Guenter Roeck1-3/+0
[ Upstream commit 6c094b31ea2ad773824362ba0fccb88d36f8d32d ] Starting with MAX34451, the chips of this series support STATUS_IOUT and STATUS_TEMPERATURE commands, and no longer report over-current and over-temperature status with STATUS_MFR_SPECIFIC. Fixes: 7a001dbab4ade ("hwmon: (pmbus/max34440) Add support for MAX34451.") Fixes: 50115ac9b6f35 ("hwmon: (pmbus/max34440) Add support for MAX34460 and MAX34461") Reported-by: Steve Foreman <foremans@google.com> Cc: Steve Foreman <foremans@google.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-10hwmon: (pmbus/core) Add support for rated attributesZbigniew Lukwinski2-8/+54
Adding implementation for new attributes (rated_min/rated_max) to cover PMBus specification about rated values reporting: MFR_VIN_MIN, MFR_VIN_MAX, MFR_IIN_MAX, MFR_PIN_MAX, MFR_VOUT_MIN, MFR_VOUT_MAX, MFR_IOUT_MAX, MFR_POUT_MAX, MFR_MAX_TEMP_1/2/3. Tested with OpenBMC stack. All rated attributes were available and reported correct values. Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
2020-10-10hwmon: (core) Add support for rated attributesZbigniew Lukwinski1-0/+10
Adding implementation for new attributes (rated_min/rated_max) for currentX, inX, powerX, tempX and humidityX. Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
2020-10-10hwmon: peci: dimmpower implementationZbigniew Lukwinski3-0/+517
1. Peci dimmpower module implementation. 2. Enable DIMM avarage power, power limit, power limit max setting, power limit min setting reading and expose them under power1_avarage, power1_cap, power1_cap_max, power1_cap_min in sysfs. 3. Enable DIMM power limit writing through power1_cap. Tested: * on WilsonCity platform, * power1_avarage, power1_cap, power1_cap_max and power1_cap_min work as expected Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
2020-10-10hwmon: peci: cpupower extensionZbigniew Lukwinski2-118/+436
1. Use hwmon peci pcs utils to refactor peci cpupower module. 2. Enable CPU power limit, power limit max (TDP) setting, power limit min setting reading and expose them under power1_cap, power1_cap_max, power1_cap_min. 3. Enable CPU power limit writing through power1_cap. Tested: * on WilsonCity platform, * power1_avarage works as before the change, * power1_cap, power1_cap_max, power1_cap_min work as expected. Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
2020-10-10hwmon: peci: PCS utilsZbigniew Lukwinski2-6/+555
1. Helpers for reading/writing PCS registers added. 2. PECI sensor configuration structure definition and helpers added. 3. New PECI PCS index and parameters definitions added. Tested: * on WilsonCity platform * hwmon/peci modules work as before the change Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
2020-10-10pwm and tach driver changes for ast2600Ayushi Smriti1-157/+171
This commit includes additions/changes in driver code to support 9 PWM outputs and 9 fan tachometer inputs for ast2600 as per archer city usage Signed-off-by: Ayushi Smriti <smriti.ayushi@intel.com>
2020-10-10Add peci-cpupower driverZhikuiRen3-0/+246
peci-cpupower reads CPU energy counter through peci and computes average power in mW since last read. Signed-off-by: ZhikuiRen <zhikui.ren@intel.com>
2020-10-10arm: ast2600: add pwm_tacho driver from aspeedVernon Mauery3-0/+1037
Add the pwm_tacho driver from Aspeed to get pwm working until an upstream PWM/Tacho driver is available. This was copied from the v5.02 BSP from Aspeed. Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
2020-10-10pmbus: add 'fault' and 'beep' attributesJae Hyun Yoo2-0/+31
This commit adds two more attirbutes to reflect MFR_SPECIFIC bit in the STATUS_WORD and 'Unit Off For Insufficient Input Voltage' bit in the STATUS_INPUT into 'fault' and 'beep' attributes respectively. The attributes will be enumerated as 'inX_fault' and 'inX_beep' in a 'vin' group. Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
2020-10-07peci-cputemp: label CPU cores from zero instead of oneZev Weiss1-1/+1
Zero-based numbering is more consistent with all other cpu/core numbering I'm aware of (including the PECI spec). OpenBMC-Staging-Count: 1 Signed-off-by: Zev Weiss <zev@bewilderbeest.net> Reviewed-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> Link: https://lore.kernel.org/r/20200926212734.23836-3-zev@bewilderbeest.net Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-10-06aspeed-pwm-tacho: change default fan speedJames Feist1-1/+1
Change it from max to 58% Signed-off-by: James Feist <james.feist@linux.intel.com>
2020-09-10hwmon: (pmbus) Expose PEC debugfs attributeAndrew Jeffery1-0/+39
Enable runtime debug control of whether the PEC byte is exchanged with the PMBus device. Some manufacturers have asked for the PEC to be disabled as part of debugging driver communication issues with devices. OpenBMC-Staging-Count: 1 Link: https://lore.kernel.org/r/20200910021106.2958382-1-andrew@aj.id.au Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-10Merge tag 'v5.8.8' into dev-5.8Joel Stanley4-18/+25
This is the 5.8.8 stable release Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-09-09hwmon: (applesmc) check status earlier.Tom Rix1-15/+16
[ Upstream commit cecf7560f00a8419396a2ed0f6e5d245ccb4feac ] clang static analysis reports this representative problem applesmc.c:758:10: warning: 1st function call argument is an uninitialized value left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ buffer is filled by the earlier call ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, ... This problem is reported because a goto skips the status check. Other similar problems use data from applesmc_read_key before checking the status. So move the checks to before the use. Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Henrik Rydberg <rydberg@bitmath.org> Link: https://lore.kernel.org/r/20200820131932.10590-1-trix@redhat.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-09-09hwmon: (pmbus/isl68137) remove READ_TEMPERATURE_1 telemetry for RAA228228Grant Peltier1-1/+6
[ Upstream commit 51fb91ed5a6fa855a74731610cd5435d83d6e17f ] Per the RAA228228 datasheet, READ_TEMPERATURE_1 is not a supported PMBus command. Signed-off-by: Grant Peltier <grantpeltier93@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-09-03hwmon: (gsc-hwmon) Scale temperature to millidegreesTim Harvey1-0/+1
commit c1ae18d313e24bc7833e1749dd36dba5d47f259c upstream. The GSC registers report temperature in decidegrees celcius so we need to scale it to represent the hwmon sysfs API of millidegrees. Cc: stable@vger.kernel.org Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support") Signed-off-by: Tim Harvey <tharvey@gateworks.com> Link: https://lore.kernel.org/r/1598548824-16898-1-git-send-email-tharvey@gateworks.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-03hwmon: (nct7904) Correct divide by 0Jason Baron1-2/+2
[ Upstream commit 8aebbbb2d573d0b4afc08b90ac7d73dba2d9da97 ] We hit a kernel panic due to a divide by 0 in nct7904_read_fan() for the hwmon_fan_min case. Extend the check to hwmon_fan_input case as well for safety. [ 1656.545650] divide error: 0000 [#1] SMP PTI [ 1656.545779] CPU: 12 PID: 18010 Comm: sensors Not tainted 5.4.47 #1 [ 1656.546065] RIP: 0010:nct7904_read+0x1e9/0x510 [nct7904] ... [ 1656.546549] RAX: 0000000000149970 RBX: ffffbd6b86bcbe08 RCX: 0000000000000000 ... [ 1656.547548] Call Trace: [ 1656.547665] hwmon_attr_show+0x32/0xd0 [hwmon] [ 1656.547783] dev_attr_show+0x18/0x50 [ 1656.547898] sysfs_kf_seq_show+0x99/0x120 [ 1656.548013] seq_read+0xd8/0x3e0 [ 1656.548127] vfs_read+0x89/0x130 [ 1656.548234] ksys_read+0x7d/0xb0 [ 1656.548342] do_syscall_64+0x48/0x110 [ 1656.548451] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: d65a5102a99f5 ("hwmon: (nct7904) Convert to use new hwmon registration API") Signed-off-by: Jason Baron <jbaron@akamai.com> Link: https://lore.kernel.org/r/1598026814-2604-1-git-send-email-jbaron@akamai.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-08-06hwmon: (occ) Add new temperature sensor typeEddie James1-0/+65
The latest version of the On-Chip Controller (OCC) has a different format for the temperature sensor data. Add a new temperature sensor version to handle this data. OpenBMC-Staging-Count: 3 Signed-off-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-08-06hwmon: Add PECI dimmtemp driverJae Hyun Yoo3-0/+440
This commit adds PECI dimmtemp hwmon driver. OpenBMC-Staging-Count: 3 Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> Reviewed-by: Haiyue Wang <haiyue.wang@linux.intel.com> Reviewed-by: James Feist <james.feist@linux.intel.com> Reviewed-by: Vernon Mauery <vernon.mauery@linux.intel.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-08-06hwmon: Add PECI cputemp driverJae Hyun Yoo4-0/+535
This commit adds PECI cputemp hwmon driver. OpenBMC-Staging-Count: 3 Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> Reviewed-by: Haiyue Wang <haiyue.wang@linux.intel.com> Reviewed-by: James Feist <james.feist@linux.intel.com> Reviewed-by: Vernon Mauery <vernon.mauery@linux.intel.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-08-06pmbus (max31785): Wrap all I2C accessors in one-shot failure handlersAndrew Jeffery1-42/+165
The MAX31785(A) has shown erratic behaviour across multiple system designs, unexpectedly clock stretching and NAKing transactions. Perform a one-shot retry if necessary for all access attempts. OpenBMC-Staging-Count: 12 Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Tested-by: George Keishing <gkeishin@in.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-08-06pmbus (core): One-shot retries for failure to set pageAndrew Jeffery1-2/+12
Work around the shonky behaviour seen with the MAX31785 where we fail to set the page register in some circumstances. There's no real elegant way to do this. We can propagate the error up, but that forces us to retry the operation way up the call tree in any number of places. It also forces callers to split out pmbus_set_page() from the pmbus_{read,write}_{byte,word}_data() functions in order to differentiate between a failure to set the page and a failure to read a register (that might not exist, in which case an error is anticiptated). OpenBMC-Staging-Count: 12 Cc: Eddie James <eajames@linux.vnet.ibm.com> Cc: Matt Spinler <mspinler@linux.vnet.ibm.com> Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Eddie James <eajames@linux.vnet.ibm.com> Tested-by: George Keishing <gkeishin@in.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-08-06pmbus (core): Use driver callbacks in pmbus_get_fan_rate()Andrew Jeffery1-4/+4
The driver may have overridden the pmbus_read_byte_data() callback, so make sure we use that to achieve expected behaviour. This helps in the MAX31785 case where we may need to perform a one-shot retry of transfers in the face of a failure. OpenBMC-Staging-Count: 12 Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Eddie James <eajames@linux.vnet.ibm.com> Tested-by: George Keishing <gkeishin@in.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-08-06pmbus (max31785): Add support for devicetree configurationAndrew Jeffery1-0/+318
OpenBMC-Staging-Count: 12 Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Tested-by: George Keishing <gkeishin@in.ibm.com> Signed-off-by: Joel Stanley <joel@jms.id.au>
2020-07-18hwmon: (drivetemp) Avoid SCT usage on Toshiba DT01ACA family drivesMaciej S. Szmigiero1-0/+43
It has been observed that Toshiba DT01ACA family drives have WRITE FPDMA QUEUED command timeouts and sometimes just freeze until power-cycled under heavy write loads when their temperature is getting polled in SCT mode. The SMART mode seems to be fine, though. Let's make sure we don't use SCT mode for these drives then. While only the 3 TB model was actually caught exhibiting the problem let's play safe here to avoid data corruption and extend the ban to the whole family. Fixes: 5b46903d8bf3 ("hwmon: Driver for disk and solid state drives with temperature sensors") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Link: https://lore.kernel.org/r/0cb2e7022b66c6d21d3f189a12a97878d0e7511b.1595075458.git.mail@maciej.szmigiero.name Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-15hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe()Cristian Marussi1-1/+1
SMATCH detected a potential buffer overflow in the manipulation of hwmon_attributes array inside the scmi_hwmon_probe function: drivers/hwmon/scmi-hwmon.c:226 scmi_hwmon_probe() error: buffer overflow 'hwmon_attributes' 6 <= 9 Fix it by statically declaring the size of the array as the maximum possible as defined by hwmon_max define. Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Link: https://lore.kernel.org/r/20200715121338.GA18761@e119603-lin.cambridge.arm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-15hwmon: (nct6775) Accept PECI Calibration as temperature source for NCT6798DGuenter Roeck1-3/+3
Stefan Dietrich reports invalid temperature source messages on Asus Formula XII Z490. nct6775 nct6775.656: Invalid temperature source 28 at index 0, source register 0x100, temp register 0x73 Debugging suggests that temperature source 28 reports the CPU temperature. Let's assume that temperature sources 28 and 29 reflect "PECI Agent {0,1} Calibration", similar to other chips of the series. Reported-by: Stefan Dietrich <roots@gmx.de> Cc: Stefan Dietrich <roots@gmx.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-09hwmon: (adm1275) Make sure we are reading enough data for different chipsChu Lin1-2/+8
Issue: When PEC is enabled, binding adm1272 to the adm1275 would fail due to PEC error. See below: adm1275: probe of xxxx failed with error -74 Diagnosis: Per the datasheet of adm1272, adm1278, adm1293 and amd1294, PMON_CONFIG (0xd4) is 16bits wide. On the other hand, PMON_CONFIG (0xd4) for adm1275 is 8bits wide. The driver should not assume everything is 8bits wide and read only 8bits from it. Solution: If it is adm1272, adm1278, adm1293 and adm1294, use i2c_read_word. Else, use i2c_read_byte Testing: Binding adm1272 to the driver. The change is only tested on adm1272. Signed-off-by: Chu Lin <linchuyuan@google.com> Link: https://lore.kernel.org/r/20200709040612.3977094-1-linchuyuan@google.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-07hwmon: (emc2103) fix unable to change fan pwm1_enable attributeVishwas M1-1/+1
This patch fixes a bug which does not let FAN mode to be changed from sysfs(pwm1_enable). i.e pwm1_enable can not be set to 3, it will always remain at 0. This is caused because the device driver handles the result of "read_u8_from_i2c(client, REG_FAN_CONF1, &conf_reg)" incorrectly. The driver thinks an error has occurred if the (result != 0). This has been fixed by changing the condition to (result < 0). Signed-off-by: Vishwas M <vishwas.reddy.vr@gmail.com> Link: https://lore.kernel.org/r/20200707142747.118414-1-vishwas.reddy.vr@gmail.com Fixes: 9df7305b5a86 ("hwmon: Add driver for SMSC EMC2103 temperature monitor and fan controller") Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-07hwmon: (amd_energy) match for supported modelsNaveen Krishna Chatradhi1-1/+1
The energy counters of certain models seems to be reporting inconsistent values. Hence, match for the supported models. Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters") Link: https://lore.kernel.org/r/20200706171715.124993-1-nchatrad@amd.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-06hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflowEvgeny Novikov1-0/+2
aspeed_create_fan() reads a pwm_port value using of_property_read_u32(). If pwm_port will be more than ARRAY_SIZE(pwm_port_params), there will be a buffer overflow in aspeed_create_pwm_port()->aspeed_set_pwm_port_enable(). The patch fixes the potential buffer overflow. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov <novikov@ispras.ru> Link: https://lore.kernel.org/r/20200703111518.9644-1-novikov@ispras.ru Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-03hwmon: (pmbus) fix a typo in Kconfig SENSORS_IR35221 optionTao Ren1-1/+1
Fix a typo in SENSORS_IR35221 option: module name should be "ir35221" instead of "ir35521". Fixes: 8991ebd9c9a6 ("hwmon: (pmbus) Add client driver for IR35221") Cc: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Tao Ren <rentao.bupt@gmail.com> Link: https://lore.kernel.org/r/20200702221349.18139-1-rentao.bupt@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-06-26hwmon: (acpi_power_meter) Fix potential memory leak in acpi_power_meter_add()Misono Tomohiro1-1/+3
Although it rarely happens, we should call free_capabilities() if error happens after read_capabilities() to free allocated strings. Fixes: de584afa5e188 ("hwmon driver for ACPI 4.0 power meters") Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Link: https://lore.kernel.org/r/20200625043242.31175-1-misono.tomohiro@jp.fujitsu.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-06-24hwmon: (max6697) Make sure the OVERT mask is set correctlyChu Lin1-3/+4
Per the datasheet for max6697, OVERT mask and ALERT mask are different. For example, the 7th bit of OVERT is the local channel but for alert mask, the 6th bit is the local channel. Therefore, we can't apply the same mask for both registers. In addition to that, the max6697 driver is supposed to be compatibale with different models. I manually went over all the listed chips and made sure all chip types have the same layout. Testing; mask value of 0x9 should map to 0x44 for ALERT and 0x84 for OVERT. I used iotool to read the reg value back to verify. I only tested this change on max6581. Reference: https://datasheets.maximintegrated.com/en/ds/MAX6581.pdf https://datasheets.maximintegrated.com/en/ds/MAX6697.pdf https://datasheets.maximintegrated.com/en/ds/MAX6699.pdf Signed-off-by: Chu Lin <linchuyuan@google.com> Fixes: 5372d2d71c46e ("hwmon: Driver for Maxim MAX6697 and compatibles") Signed-off-by: Guenter Roeck <linux@roeck-us.net>