Commit graph

4446 commits

Author SHA1 Message Date
Guenter Roeck f8344f7693 hwmon: (lm90) Add basic support for TI TMP461
TMP461 is almost identical to TMP451 and was actually detected as TMP451
with the existing lm90 driver if its I2C address is 0x4c. Add support
for it to the lm90 driver. At the same time, improve the chip detection
function to at least try to distinguish between TMP451 and TMP461.

As a side effect, this fixes commit 24333ac26d ("hwmon: (tmp401) use
smb word operations instead of 2 smb byte operations"). TMP461 does not
support word operations on temperature registers, which causes bad
temperature readings with the tmp401 driver. The lm90 driver does not
perform word operations on temperature registers and thus does not have
this problem.

Support is listed as basic because TMP461 supports a sensor resolution
of 0.0625 degrees C, while the lm90 driver assumes a resolution of 0.125
degrees C. Also, the TMP461 supports negative temperatures with its
default temperature range, which is not the case for similar chips
supported by the lm90 and the tmp401 drivers. Those limitations will be
addressed with follow-up patches.

Fixes: 24333ac26d ("hwmon: (tmp401) use smb word operations instead of 2 smb byte operations")
Reported-by: David T. Wilson <david.wilson@nasa.gov>
Cc: David T. Wilson <david.wilson@nasa.gov>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-27 19:48:19 -07:00
Guenter Roeck f347e249fc hwmon: (lm90) Introduce flag indicating extended temperature support
A flag indicating extended temperature support makes it easier
to add support for additional chips with this functionality.

Cc: David T. Wilson <david.wilson@nasa.gov>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-27 19:48:19 -07:00
Denis Pauk f4cbba74c3 hwmon: (nct6775) add ProArt X570-CREATOR WIFI.
ASUS ProArt X570-CREATOR WIFI board has got an nct6775 chip, but by default
there's no use of it because of resource conflict with WMI method.

This commit adds ProArt X570-CREATOR WIFI to the list of boards that can be
monitored using ASUS WMI.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204807
Signed-off-by: Denis Pauk <pauk.denis@gmail.com>
Tested-by: Joel Wirāmu Pauling <jwp@redhat.com>
Link: https://lore.kernel.org/r/20211025194748.6784-1-pauk.denis@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-27 10:44:54 -07:00
Oskar Senft 0e346a86a5 hwmon: (nct7802) Make temperature/voltage sensors configurable
This change allows LTD and RTD inputs to be configured via
device tree bindings. If the DT bindings are not present or
invalid, the input configuration is not modified and left at
HW defaults.

Signed-off-by: Oskar Senft <osk@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20211020164213.174597-2-osk@google.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-27 10:42:49 -07:00
Greg Kroah-Hartman b1f4c00e41 FSI changes for v5.16
- SBEFIFO usersapce interfaces to perform FFDC (First Failure
    Data Capture) and detect timeouts
 
  - A fix to handle multiple messages in flight
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+nHMAt9PCBDH63wBa3ZZB4FHcJ4FAmFx+ZIACgkQa3ZZB4FH
 cJ7WHhAAn840J0zZS5mUMq7oJC6oWsSwEtKoBqoEwJq0nGGTDY7KX5r5umH1uEdR
 SlIjZ8WoNgZVpZEXXOXZyKWU8yzEckVjEYMWNWZGuabuAXMzTDyB/J376vn9IYQO
 ZkGYbu4B9CZssn0sDC671R/FHfPFk7L5jJ0sJgi5I3nDOApw+uvcGqw9r0AWmUfp
 7BHNLZvvUNO/Z3yqF+YaeDhOIXHRbN0kq7fwi+lp4s5UUhPZDmNrrbVu+6HqJe9E
 ghUST309zWUdtBToyzxkRb2U8rK8QDtkZppRPf+e/64RP8Fz1yNDPHG6HQX7cyYS
 1VyMbA5AzzbUE2XORmfbPGrJ9WmQSX8JOJX1bxq/eu15VJAeDVYuMVHm0ekNhi3u
 gwBvPXeyCwMCn0rQBGxbqoM9bHHj07vJ1FVaSWpWYjbTWo343itjVi54nYxgQxIA
 12TW8xRI1H7IHkgKtaCvrINxHgyXinfZuWrNXVKHsiT02Y+F08eXp0xotaMg0bmj
 nhvTw4wRZa0rHIFNFqj/yEKpIaaoDuPo1ZxT81NOAK4kxgzuFB/z2IsUXf+xJI4r
 2UAWyryth5wFbfu0BBq95onGOI+MgZwpksVNekcS1P2pByox+pKKvUsqXeSBRHnx
 DmiSZVME2zRUb+9jZHVfEVHBZBrMVzDn1pb9Fm1OId8cjeFupdA=
 =ug/2
 -----END PGP SIGNATURE-----

Merge tag 'fsi-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi into char-misc-next

Joel writes:

FSI changes for v5.16

 - SBEFIFO usersapce interfaces to perform FFDC (First Failure
   Data Capture) and detect timeouts

 - A fix to handle multiple messages in flight

* tag 'fsi-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi:
  fsi: sbefifo: Use interruptible mutex locking
  fsi: sbefifo: Add sysfs file indicating a timeout error
  docs: ABI: testing: Document the SBEFIFO timeout interface
  hwmon: (occ) Provide the SBEFIFO FFDC in binary sysfs
  docs: ABI: testing: Document the OCC hwmon FFDC binary interface
  fsi: occ: Store the SBEFIFO FFDC in the user response buffer
  fsi: occ: Use a large buffer for responses
  hwmon: (occ) Remove sequence numbering and checksum calculation
  fsi: occ: Force sequence numbering per OCC
2021-10-22 09:45:59 +02:00
Eddie James 5027a34a57 hwmon: (occ) Provide the SBEFIFO FFDC in binary sysfs
Save any FFDC provided by the OCC driver, and provide it to userspace
through a binary sysfs entry. Notify userspace pollers when there is an
error too.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20211019205307.36946-5-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-10-22 09:54:33 +10:30
Armin Wolf c0d79987a0 hwmon: (dell-smm) Speed up setting of fan speed
When setting the fan speed, i8k_set_fan() calls i8k_get_fan_status(),
causing an unnecessary SMM call since from the two users of this
function, only i8k_ioctl_unlocked() needs to know the new fan status
while dell_smm_write() ignores the new fan status.
Since SMM calls can be very slow while also making error reporting
difficult for dell_smm_write(), remove the function call from
i8k_set_fan() and call it separately in i8k_ioctl_unlocked().

Tested on a Dell Inspiron 3505.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-6-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf 927d89ee96 hwmon: (dell-smm) Add comment explaining usage of i8k_config_data[]
i8k_config_data[] should only be used for applying device specific
quirks in case autoconfig does not work properly on certain
devices.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-5-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf e64325e8c5 hwmon: (dell-smm) Return -ENOIOCTLCMD instead of -EINVAL
Returning -ENOIOCTLCMD gives the callers a better
hint of what went wrong and is the recommended
behavior.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-4-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf 38c5b0dd7d hwmon: (dell-smm) Use strscpy_pad()
Using strscpy_pad() allows for fewer memory accesses
since memset() will not unconditionally zero-out
the whole buffer.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf 6105870f79 hwmon: (dell-smm) Sort includes in alphabetical order
Sort includes for better overview.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Wan Jiabing 66ae4d562b hwmon: (tmp421) Add of_node_put() before return
Fix following coccicheck warning:
./drivers/hwmon/tmp421.c:416:1-23: WARNING: Function
for_each_child_of_node should have of_node_put() before return.

Early exits from for_each_child_of_node should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Link: https://lore.kernel.org/r/20211018121538.16482-1-wanjiabing@vivo.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-18 07:23:21 -07:00
Uwe Kleine-König efb389b8c3 hwmon: (max31722) Warn about failure to put device in stand-by in .remove()
When an spi driver's remove function returns a non-zero error code
nothing happens apart from emitting a generic error message. Make this
error message more device specific and return zero instead.

Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20211012153945.2651412-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-16 22:42:14 -07:00
Rafael J. Wysocki 2c59a32d12 hwmon: (acpi_power_meter) Use acpi_bus_get_acpi_device()
In read_domain_devices(), acpi_bus_get_device() is called to obtain
the ACPI device object attached to the given ACPI handle and
subsequently that object is passed to get_device() for reference
counting, but there is a window between the acpi_bus_get_device()
and get_device() calls in which the ACPI device object in question
may go away.

To address this issue, make read_domain_devices() use
acpi_bus_get_acpi_device() to reference count and return the given
ACPI device object in one go and export that function to modules.

While at it, also make read_domain_devices() and
remove_domain_devices() use acpi_dev_put() instead of calling
put_device() directly on the ACPI device objects returned by
acpi_bus_get_acpi_device().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/11871063.O9o76ZdvQC@kreacher
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-16 22:41:25 -07:00
Armin Wolf b1986c8e31 hwmon: (dell-smm) Add support for fanX_min, fanX_max and fanX_target
The nominal speed of each fan can be obtained with
i8k_get_fan_nominal_speed(), however the result is not available
from userspace.
Change that by adding fanX_min, fanX_max and fanX_target attributes.
All are RO since fan control happens over pwm.

Tested on a Dell Inspiron 3505 and a Dell Latitude C600.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210926221044.14327-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-16 14:58:42 -07:00
Krzysztof Adamski 3e4dd2e8bc hwmon: (tmp421) ignore non-channel related DT nodes
In case the DT contains some nodes not describing the input channels,
ignore them instead of exiting with error.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/8e9e332b18dc2cf545f8e8255157e408d356f916.1634206677.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-15 15:55:58 -07:00
Krzysztof Adamski 1a98068c71 hwmon: (tmp421) support HWMON_T_ENABLE
Since the recent patches added possibility of disabling sensor channels
via DT, it only make sense to allow controlling that from userspace via
HWMON_T_ENABLE mechanism. This patches adds support for that.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/a64c22e7323bd5a083f37aaaca91a745ac1beef3.1634206677.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-15 15:53:19 -07:00
Krzysztof Adamski f3fbf4b81d hwmon: (tmp421) really disable channels
Recent patch added possibility to disable selected channels. That would
only make sure that the ENODATA is returned for those channels but would
not configure the actual hardware.

With this patch, the config register is written to make sure the
channels are disabled also at hardware level.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/d451cacdf21bf8eff38a47c055aad8c0c6e8755a.1634206677.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-15 15:52:47 -07:00
Krzysztof Adamski 3fba10dc03 hwmon: (tmp421) support specifying n-factor via DT
Previous patches added a way to specify some channel specific parameters
in DT and n-factor is definitely one of them. This calibration mechanism
is board specific as its value depends on the diodes/transistors being
connected to the sensor and thus the DT seems like a right fit for that
information. It is very similar to the value of shunt resistor that some
drivers allows specifying in DT.

This patch adds a possibility to set n-factor for each channel via
"n-factor" DT property in each channel subnode.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/69d0bfcc5ba27c67f21d3eabfb100656a14c75b9.1634206677.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-15 15:49:32 -07:00
Krzysztof Adamski 45e9bda4ff hwmon: (tmp421) support disabling channels from DT
The previous patch introduced per channel subnodes in DT that let us
specify some channel specific properties. This built a ground for easily
disabling individual channels of the sensor that may not be connected to
any external diode and thus are not returning any meaningful data.

This patch adds support for parsing the "status" property of channels DT
subnodes and makes sure the -ENODATA is returned when disabled channels
value is read.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/a85d623f0792b862870933a875bdf802f4c017f1.1634206677.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-15 15:46:45 -07:00
Krzysztof Adamski c1143d1bc5 hwmon: (tmp421) add support for defining labels from DT
tmp42x is a multichannel temperature sensor with several external
channels. Since those channels can be used to connect diodes placed
anywhere in the system, their meaning will vary depending on the
project. For this case, the hwmon framework has an idea of labels which
allows us to assign the meaning to each channel.

The similar concept is already implemented in ina3221 - the label for
each channel can be defined via device tree. See commit a9e9dd9c6d
("hwmon: (ina3221) Read channel input source info from DT")

This patch adds support for similar feature to tmp421.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/dab0fda6ac0e8d7f163c3762a7fb1e595a4d8159.1634206677.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-15 15:44:21 -07:00
Eddie James 908dbf0242 hwmon: (occ) Remove sequence numbering and checksum calculation
Checksumming of the request and sequence numbering is now done in the
OCC interface driver in order to keep unique sequence numbers. So
remove those in the hwmon driver. Also, add the command length to the
send_cmd function pointer, since the checksum must be placed in the
last two bytes of the command. The submit interface must receive the
exact size of the command - previously it could be rounded to the
nearest 8 bytes with no consequence.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210721190231.117185-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-10-15 15:09:26 +10:30
Krzysztof Adamski 5e3dbeac37 hwmon: (tmp421) introduce a channel struct
This is a preparatory change. Upcoming patches will introduce more
per-channel parameters so it's worth organizing them into a struct.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/baf34d95983a6b58a3e39e4c098e5979e541572e.1634029538.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:25:34 -07:00
Uwe Kleine-König beee7890c3 hwmon: (adt7x10) Make adt7x10_remove() return void
Up to now adt7x10_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20211011132754.2479853-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:42 -07:00
Armin Wolf 8a0c75a1c3 hwmon: (dell-smm) Remove unnecessary includes
sched.h and io.h are not used anywhere in dell-smm-hwmon.c.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210926221044.14327-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:42 -07:00
Paul Fertser 952a11ca32 hwmon: cleanup non-bool "valid" data fields
We have bool so use it consistently in all the drivers.

The following Coccinelle script was used:

@@
identifier T;
type t = { char, int };
@@
struct T {
...
-	t valid;
+	bool valid;
...
}

@@
identifier v;
@@
(
- v->valid = 0
+ v->valid = false
|
- v->valid = 1
+ v->valid = true
)

followed by sed to fixup the comments:
sed '/bool valid;/{s/!=0/true/;s/zero/false/}'

Few whitespace changes were fixed manually. All modified drivers were
compile-tested.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Link: https://lore.kernel.org/r/20210924195202.27917-1-fercerpav@gmail.com
[groeck: Fixed up 'u8 valid' to 'boool valid' in atxp1.c]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Oleksij Rempel b87783e855 hwmon: (tmp103) Convert tmp103 to use new hwmon registration API
Use devm_hwmon_device_register_with_info() which will make thermal
framework work.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20211007125301.3030-1-o.rempel@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Vadim Pasternak b2be2422c0 hwmon: (mlxreg-fan) Support distinctive names per different cooling devices
Provide different names for cooling devices registration to allow
binding each cooling devices to relevant thermal zone. Thus, specific
cooling device can be associated with related thermal sensor by setting
thermal cooling device type for example to "mlxreg_fan2" and passing
this type to thermal_zone_bind_cooling_device() through 'cdev->type'.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210926053541.1806937-3-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Vadim Pasternak b1c2423734 hwmon: (mlxreg-fan) Modify PWM connectivity validation
Validate PWM connectivity only for additional PWM - "pwm1" is connected
on all systems, while "pwm2" - "pwm4" are optional. Validate
connectivity only for optional attributes by reading of related "pwm{n}"
registers - in case "pwm{n}" is not connected, register value is
supposed to be 0xff.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210926053541.1806937-2-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Oleksandr Natalenko 1508fb2915 hwmon: (nct6775) add Pro WS X570-ACE
ASUS Pro WS X570-ACE board has got an nct6775 chip, but by default
there's no use of it because of resource conflict:

```
ACPI Warning: SystemIO range 0x0000000000000295-0x0000000000000296 conflicts with OpRegion 0x0000000000000290-0x0000000000000299 (\AMW0.SHWM) (20210604/utaddress-204
)
ACPI: OSL: Resource conflict; ACPI support missing from driver?
ACPI: OSL: Resource conflict: System may be unstable or behave erratically
```

A workaround is to use `acpi_enforce_resources=lax`, but a proper
support needs to be added instead.

This commit adds Pro WS X570-ACE to the list of boards that can be monitored
using ASUS WMI.

Tested by me on this hardware:

```
Base Board Information
    Manufacturer: ASUSTeK COMPUTER INC.
    Product Name: Pro WS X570-ACE

BIOS Information
    Vendor: American Megatrends Inc.
    Version: 3801
    Release Date: 07/30/2021
```

Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Link: https://lore.kernel.org/r/20211003133344.9036-2-oleksandr@natalenko.name
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Brandon Wyman 8a5cfcfa94 hwmon: (pmbus/ibm-cffps) Use MFR_ID to choose version
There are multiple power supplies that will indicate
CFFPS_CCIN_VERSION_1, use the manufacturer ID to determine if it should
be treated as version cffps1 or version cffps2.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Link: https://lore.kernel.org/r/20211004144339.2634330-2-bjwyman@gmail.com
[groeck: Fixed continuation line alignment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Brandon Wyman a111ec399c hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry
Add support for the manufacturer ID to the debugfs entries.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Link: https://lore.kernel.org/r/20211004144339.2634330-1-bjwyman@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Denis Pauk 6e2baac88c hwmon: (nct6775) Add additional ASUS motherboards.
Add support:
* PRIME B360-PLUS
* PRIME X570-PRO
* ROG CROSSHAIR VIII FORMULA
* ROG STRIX B550-I GAMING
* ROG STRIX X570-F GAMING
* ROG STRIX Z390-E GAMING
* TUF GAMING B550-PRO
* TUF GAMING Z490-PLUS
* TUF GAMING Z490-PLUS (WI-FI)

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204807
Signed-off-by: Denis Pauk <pauk.denis@gmail.com>
Tested-by: matt-testalltheway <sefoci9222@rerunway.com>
Tested-by: Kamil Dudka <kdudka@redhat.com>
Tested-by: Robert Swiecki <robert@swiecki.net>
Tested-by: Kamil Pietrzak <kpietrzak@disroot.org>
Tested-by: Igor <igor@svelig.com>
Tested-by: Tor Vic <torvic9@mailbox.org>
Tested-by: Poezevara <nephartyz@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20211002210857.709956-2-pauk.denis@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Zev Weiss 94ee5fcc24 hwmon: (pmbus/lm25066) Support configurable sense resistor values
The appropriate mantissa values for the lm25066 family's direct-format
current and power readings are a function of the sense resistor
employed between the SENSE and VIN pins of the chip.  Instead of
assuming that resistance is always the same 1mOhm as used in the
datasheet, allow it to be configured via a device-tree property
("shunt-resistor-micro-ohms").

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20210928092242.30036-8-zev@bewilderbeest.net
[groeck: Fixed checkpatch warnings]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:41 -07:00
Zev Weiss b7792f3ea3 hwmon: (pmbus/lm25066) Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20210928092242.30036-7-zev@bewilderbeest.net
[groeck: Replaced reference to reasoning with reasoning, fixed checkpatch
 warnings, fixed compile warning comparing of_id->data w/ i2c_id->driver_data]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:40 -07:00
Zev Weiss df60a5daa7 hwmon: (pmbus/lm25066) Mark lm25066_coeff array const
lm25066_coeff is read-only. Mark it as such.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20210928092242.30036-6-zev@bewilderbeest.net
[groeck: Added description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:40 -07:00
Zev Weiss b7931a7b0e hwmon: (pmbus/lm25066) Let compiler determine outer dimension of lm25066_coeff
Maintaining this manually is error prone (there are currently only
five chips supported, not six); gcc can do it for us automatically.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Fixes: 666c14906b ("hwmon: (pmbus/lm25066) Drop support for LM25063")
Link: https://lore.kernel.org/r/20210928092242.30036-5-zev@bewilderbeest.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:40 -07:00
Zev Weiss 6d2ff184cb hwmon: (pmbus/lm25066) Avoid forward declaration of lm25066_id
Reordering things to put the table before the probe function
eliminates the need for it.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20210928092242.30036-4-zev@bewilderbeest.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:40 -07:00
Zev Weiss fa16188fa2 hwmon: (pmbus/lm25066) Adjust lm25066 PSC_CURRENT_IN_L mantissa
At least as of Revision J, the datasheet has a slightly different
value than what we'd had in the driver.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20210928092242.30036-3-zev@bewilderbeest.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:40 -07:00
Zev Weiss ae59dc455a hwmon: (pmbus/lm25066) Add offset coefficients
With the exception of the lm5066i, all the devices handled by this
driver had been missing their offset ('b') coefficients for direct
format readings.

Cc: stable@vger.kernel.org
Fixes: 58615a94f6 ("hwmon: (pmbus/lm25066) Add support for LM25056")
Fixes: e53e6497fc ("hwmon: (pmbus/lm25066) Refactor device specific coefficients")
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20210928092242.30036-2-zev@bewilderbeest.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:40 -07:00
Krzysztof Adamski cae0233946 hwmon: (tmp421) introduce MAX_CHANNELS define
There are few places where the maximal number of channels is used define
the size of arrays but when raw number is used it is not clear that they
really related to this quantity.
This commit introduces MAX_CHANNELS define and uses it those places to
give some context to the number.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Link: https://lore.kernel.org/r/abc1a213a25b890b799b35ad94bb543a2ade7fc8.1632473318.git.krzysztof.adamski@nokia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:40 -07:00
Daniel Dawson d55532f771 hwmon: (nct6683) Add another customer ID for NCT6683D sensor chip on some ASRock boards
This value was found on a Z370M Pro4 rev. 1.01, with an
NCT6683D-T chip.

Signed-off-by: Daniel Dawson <danielcdawson@gmail.com>
Link: https://lore.kernel.org/r/20210921165859.48714-1-danielcdawson@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:39 -07:00
Colin Ian King 000cc5bc49 hwmon: (mlxreg-fan) Fix out of bounds read on array fan->pwm
Array fan->pwm[] is MLXREG_FAN_MAX_PWM elements in size, however the
for-loop has a off-by-one error causing index i to be out of range
causing an out of bounds read on the array. Fix this by replacing
the <= operator with < in the for-loop.

Addresses-Coverity: ("Out-of-bounds read")
Reported-by: Vadim Pasternak <vadimp@nvidia.com>
Fixes: 35edbaab3bbf ("hwmon: (mlxreg-fan) Extend driver to support multiply cooling devices")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210920180921.16246-1-colin.king@canonical.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:38 -07:00
Denis Pauk 3fbbfc27f9 hwmon: (nct6775) Support access via Asus WMI
Support accessing the NCT677x via Asus WMI functions.

On mainboards that support this way of accessing the chip, the driver will
usually not work without this option since in these mainboards, ACPI will
mark the I/O port as used.

Code uses ACPI firmware interface to communicate with sensors with ASUS
motherboards:
* PRIME B460-PLUS,
* ROG CROSSHAIR VIII IMPACT,
* ROG STRIX B550-E GAMING,
* ROG STRIX B550-F GAMING,
* ROG STRIX B550-F GAMING (WI-FI),
* ROG STRIX Z490-I GAMING,
* TUF GAMING B550M-PLUS,
* TUF GAMING B550M-PLUS (WI-FI),
* TUF GAMING B550-PLUS,
* TUF GAMING X570-PLUS,
* TUF GAMING X570-PRO (WI-FI).

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204807
Signed-off-by: Denis Pauk <pauk.denis@gmail.com>
Co-developed-by: Bernhard Seibold <mail@bernhard-seibold.de>
Signed-off-by: Bernhard Seibold <mail@bernhard-seibold.de>
Tested-by: Pär Ekholm <pehlm@pekholm.org>
Tested-by: <to.eivind@gmail.com>
Tested-by: Artem S. Tashkinov <aros@gmx.com>
Tested-by: Vittorio Roberto Alfieri <me@rebtoor.com>
Tested-by: Sahan Fernando <sahan.h.fernando@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210917220240.56553-4-pauk.denis@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Denis Pauk 4914036eb6 hwmon: (nct6775) Use nct6775_*() function pointers in nct6775_data.
Prepare for platform specific callbacks usage:
* Use nct6775 function pointers in struct nct6775_data instead direct
  calls.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204807
Signed-off-by: Denis Pauk <pauk.denis@gmail.com>
Co-developed-by: Bernhard Seibold <mail@bernhard-seibold.de>
Signed-off-by: Bernhard Seibold <mail@bernhard-seibold.de>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210917220240.56553-3-pauk.denis@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Denis Pauk 2e7b988696 hwmon: (nct6775) Use superio_*() function pointers in sio_data.
Prepare for platform specific callbacks usage:
* Rearrange code for directly use struct nct6775_sio_data in superio_*()
  functions.
* Use superio function pointers in nct6775_sio_data struct instead direct
  calls.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204807
Signed-off-by: Denis Pauk <pauk.denis@gmail.com>
Co-developed-by: Bernhard Seibold <mail@bernhard-seibold.de>
Signed-off-by: Bernhard Seibold <mail@bernhard-seibold.de>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210917220240.56553-2-pauk.denis@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Vadim Pasternak d7efb2ebc7 hwmon: (mlxreg-fan) Extend driver to support multiply cooling devices
Add support for additional cooling devices in order to support the
systems, which can be equipped with up-to four PWM controllers.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Vadim Pasternak 150f1e0c6f hwmon: (mlxreg-fan) Extend driver to support multiply PWM
Add additional PWM attributes in order to support the systems, which
can be equipped with up-to four PWM controllers. System capability of
additional PWM support is validated through the reading of relevant
registers.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210916194719.871413-3-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Vadim Pasternak bc8de07e88 hwmon: (mlxreg-fan) Extend the maximum number of tachometers
Extend support of maximum tachometers from 12 to 14 in order to support
new systems, equipped with more fans.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210916194719.871413-2-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Arun Saravanan Balachandran e8ac01e5db hwmon: Add Maxim MAX6620 hardware monitoring driver
Add hardware monitoring driver for Maxim MAX6620 Fan controller

Originally-from: L. Grunenberg <contact@lgrunenberg.de>
Originally-from: Cumulus Networks <support@cumulusnetworks.com>
Originally-from: Shuotian Cheng <shuche@microsoft.com>
Signed-off-by: Arun Saravanan Balachandran <Arun_Saravanan_Balac@dell.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Armin Wolf d73287eed7 hwmon: (raspberrypi) Use generic notification mechanism
Use hwmon_notify_event() to make the code easier to
understand and to also generate udev events.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210905190049.11381-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Armin Wolf 6665e10a2e hwmon: (i5500_temp) Convert to devm_hwmon_device_register_with_info
Use devm_hwmon_device_register_with_info() to simplify code
and use register defines instead of hardcoded values.
Also use the BIT() macro for the alarms.

Only compile-tested.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210823170724.7662-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:37 -07:00
Yang Yingliang ada61aa0b1 hwmon: Fix possible memleak in __hwmon_device_register()
I got memory leak as follows when doing fault injection test:

unreferenced object 0xffff888102740438 (size 8):
  comm "27", pid 859, jiffies 4295031351 (age 143.992s)
  hex dump (first 8 bytes):
    68 77 6d 6f 6e 30 00 00                          hwmon0..
  backtrace:
    [<00000000544b5996>] __kmalloc_track_caller+0x1a6/0x300
    [<00000000df0d62b9>] kvasprintf+0xad/0x140
    [<00000000d3d2a3da>] kvasprintf_const+0x62/0x190
    [<000000005f8f0f29>] kobject_set_name_vargs+0x56/0x140
    [<00000000b739e4b9>] dev_set_name+0xb0/0xe0
    [<0000000095b69c25>] __hwmon_device_register+0xf19/0x1e50 [hwmon]
    [<00000000a7e65b52>] hwmon_device_register_with_info+0xcb/0x110 [hwmon]
    [<000000006f181e86>] devm_hwmon_device_register_with_info+0x85/0x100 [hwmon]
    [<0000000081bdc567>] tmp421_probe+0x2d2/0x465 [tmp421]
    [<00000000502cc3f8>] i2c_device_probe+0x4e1/0xbb0
    [<00000000f90bda3b>] really_probe+0x285/0xc30
    [<000000007eac7b77>] __driver_probe_device+0x35f/0x4f0
    [<000000004953d43d>] driver_probe_device+0x4f/0x140
    [<000000002ada2d41>] __device_attach_driver+0x24c/0x330
    [<00000000b3977977>] bus_for_each_drv+0x15d/0x1e0
    [<000000005bf2a8e3>] __device_attach+0x267/0x410

When device_register() returns an error, the name allocated in
dev_set_name() will be leaked, the put_device() should be used
instead of calling hwmon_dev_release() to give up the device
reference, then the name will be freed in kobject_cleanup().

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: bab2243ce1 ("hwmon: Introduce hwmon_device_register_with_groups")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20211012112758.2681084-1-yangyingliang@huawei.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:01 -07:00
Nadezda Lutovinova dd4d747ef0 hwmon: (w83793) Fix NULL pointer dereference by removing unnecessary structure field
If driver read tmp value sufficient for
(tmp & 0x08) && (!(tmp & 0x80)) && ((tmp & 0x7) == ((tmp >> 4) & 0x7))
from device then Null pointer dereference occurs.
(It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers)
Also lm75[] does not serve a purpose anymore after switching to
devm_i2c_new_dummy_device() in w83791d_detect_subclients().

The patch fixes possible NULL pointer dereference by removing lm75[].

Found by Linux Driver Verification project (linuxtesting.org).

Cc: stable@vger.kernel.org
Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
Link: https://lore.kernel.org/r/20210921155153.28098-3-lutovinova@ispras.ru
[groeck: Dropped unnecessary continuation lines, fixed multi-line alignments]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-02 05:14:11 -07:00
Nadezda Lutovinova 0f36b88173 hwmon: (w83792d) Fix NULL pointer dereference by removing unnecessary structure field
If driver read val value sufficient for
(val & 0x08) && (!(val & 0x80)) && ((val & 0x7) == ((val >> 4) & 0x7))
from device then Null pointer dereference occurs.
(It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers)
Also lm75[] does not serve a purpose anymore after switching to
devm_i2c_new_dummy_device() in w83791d_detect_subclients().

The patch fixes possible NULL pointer dereference by removing lm75[].

Found by Linux Driver Verification project (linuxtesting.org).

Cc: stable@vger.kernel.org
Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
Link: https://lore.kernel.org/r/20210921155153.28098-2-lutovinova@ispras.ru
[groeck: Dropped unnecessary continuation lines, fixed multipline alignment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-02 05:12:05 -07:00
Nadezda Lutovinova 943c15ac1b hwmon: (w83791d) Fix NULL pointer dereference by removing unnecessary structure field
If driver read val value sufficient for
(val & 0x08) && (!(val & 0x80)) && ((val & 0x7) == ((val >> 4) & 0x7))
from device then Null pointer dereference occurs.
(It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers)
Also lm75[] does not serve a purpose anymore after switching to
devm_i2c_new_dummy_device() in w83791d_detect_subclients().

The patch fixes possible NULL pointer dereference by removing lm75[].

Found by Linux Driver Verification project (linuxtesting.org).

Cc: stable@vger.kernel.org
Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
Link: https://lore.kernel.org/r/20210921155153.28098-1-lutovinova@ispras.ru
[groeck: Dropped unnecessary continuation lines, fixed multi-line alignment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-02 05:11:52 -07:00
Vadim Pasternak 2292e2f685 hwmon: (pmbus/mp2975) Add missed POUT attribute for page 1 mp2975 controller
Add missed attribute for reading POUT from page 1.
It is supported by device, but has been missed in initial commit.

Fixes: 2c6fcbb211 ("hwmon: (pmbus) Add support for MPS Multi-phase mp2975 controller")
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210927070740.2149290-1-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-02 04:45:49 -07:00
Brandon Wyman f067d5585c hwmon: (pmbus/ibm-cffps) max_power_out swap changes
The bytes for max_power_out from the ibm-cffps devices differ in byte
order for some power supplies.

The Witherspoon power supply returns the bytes in MSB/LSB order.

The Rainier power supply returns the bytes in LSB/MSB order.

The Witherspoon power supply uses version cffps1. The Rainier power
supply should use version cffps2. If version is cffps1, swap the bytes
before output to max_power_out.

Tested:
    Witherspoon before: 3148. Witherspoon after: 3148.
    Rainier before: 53255. Rainier after: 2000.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20210928205051.1222815-1-bjwyman@gmail.com
[groeck: Replaced yoda programming]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-02 04:38:53 -07:00
Eddie James ffa2600044 hwmon: (occ) Fix P10 VRM temp sensors
The P10 (temp sensor version 0x10) doesn't do the same VRM status
reporting that was used on P9. It just reports the temperature, so
drop the check for VRM fru type in the sysfs show function, and don't
set the name to "alarm".

Fixes: db4919ec86 ("hwmon: (occ) Add new temperature sensor type")
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20210929153604.14968-1-eajames@linux.ibm.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-02 04:35:09 -07:00
Uwe Kleine-König 6f7d704671 hwmon: (ltc2947) Properly handle errors when looking for the external clock
The return value of devm_clk_get should in general be propagated to
upper layer. In this case the clk is optional, use the appropriate
wrapper instead of interpreting all errors as "The optional clk is not
available".

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20210923201113.398932-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-09-24 05:02:24 -07:00
Paul Fertser 724e8af858 hwmon: (tmp421) fix rounding for negative values
Old code produces -24999 for 0b1110011100000000 input in standard format due to
always rounding up rather than "away from zero".

Use the common macro for division, unify and simplify the conversion code along
the way.

Fixes: 9410700b88 ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips")
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Link: https://lore.kernel.org/r/20210924093011.26083-3-fercerpav@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-09-24 05:00:53 -07:00
Paul Fertser 540effa7f2 hwmon: (tmp421) report /PVLD condition as fault
For both local and remote sensors all the supported ICs can report an
"undervoltage lockout" condition which means the conversion wasn't
properly performed due to insufficient power supply voltage and so the
measurement results can't be trusted.

Fixes: 9410700b88 ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips")
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Link: https://lore.kernel.org/r/20210924093011.26083-2-fercerpav@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-09-24 05:00:51 -07:00
Paul Fertser 2938b2978a hwmon: (tmp421) handle I2C errors
Function i2c_smbus_read_byte_data() can return a negative error number
instead of the data read if I2C transaction failed for whatever reason.

Lack of error checking can lead to serious issues on production
hardware, e.g. errors treated as temperatures produce spurious critical
temperature-crossed-threshold errors in BMC logs for OCP server
hardware. The patch was tested with Mellanox OCP Mezzanine card
emulating TMP421 protocol for temperature sensing which sometimes leads
to I2C protocol error during early boot up stage.

Fixes: 9410700b88 ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips")
Cc: stable@vger.kernel.org
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Link: https://lore.kernel.org/r/20210924093011.26083-1-fercerpav@gmail.com
[groeck: dropped unnecessary line breaks]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-09-24 04:59:10 -07:00
Vadim Pasternak e6fab7af6b hwmon: (mlxreg-fan) Return non-zero value when fan current state is enforced from sysfs
Fan speed minimum can be enforced from sysfs. For example, setting
current fan speed to 20 is used to enforce fan speed to be at 100%
speed, 19 - to be not below 90% speed, etcetera. This feature provides
ability to limit fan speed according to some system wise
considerations, like absence of some replaceable units or high system
ambient temperature.

Request for changing fan minimum speed is configuration request and can
be set only through 'sysfs' write procedure. In this situation value of
argument 'state' is above nominal fan speed maximum.

Return non-zero code in this case to avoid
thermal_cooling_device_stats_update() call, because in this case
statistics update violates thermal statistics table range.
The issues is observed in case kernel is configured with option
CONFIG_THERMAL_STATISTICS.

Here is the trace from KASAN:
[  159.506659] BUG: KASAN: slab-out-of-bounds in thermal_cooling_device_stats_update+0x7d/0xb0
[  159.516016] Read of size 4 at addr ffff888116163840 by task hw-management.s/7444
[  159.545625] Call Trace:
[  159.548366]  dump_stack+0x92/0xc1
[  159.552084]  ? thermal_cooling_device_stats_update+0x7d/0xb0
[  159.635869]  thermal_zone_device_update+0x345/0x780
[  159.688711]  thermal_zone_device_set_mode+0x7d/0xc0
[  159.694174]  mlxsw_thermal_modules_init+0x48f/0x590 [mlxsw_core]
[  159.700972]  ? mlxsw_thermal_set_cur_state+0x5a0/0x5a0 [mlxsw_core]
[  159.731827]  mlxsw_thermal_init+0x763/0x880 [mlxsw_core]
[  160.070233] RIP: 0033:0x7fd995909970
[  160.074239] Code: 73 01 c3 48 8b 0d 28 d5 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 99 2d 2c 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ..
[  160.095242] RSP: 002b:00007fff54f5d938 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[  160.103722] RAX: ffffffffffffffda RBX: 0000000000000013 RCX: 00007fd995909970
[  160.111710] RDX: 0000000000000013 RSI: 0000000001906008 RDI: 0000000000000001
[  160.119699] RBP: 0000000001906008 R08: 00007fd995bc9760 R09: 00007fd996210700
[  160.127687] R10: 0000000000000073 R11: 0000000000000246 R12: 0000000000000013
[  160.135673] R13: 0000000000000001 R14: 00007fd995bc8600 R15: 0000000000000013
[  160.143671]
[  160.145338] Allocated by task 2924:
[  160.149242]  kasan_save_stack+0x19/0x40
[  160.153541]  __kasan_kmalloc+0x7f/0xa0
[  160.157743]  __kmalloc+0x1a2/0x2b0
[  160.161552]  thermal_cooling_device_setup_sysfs+0xf9/0x1a0
[  160.167687]  __thermal_cooling_device_register+0x1b5/0x500
[  160.173833]  devm_thermal_of_cooling_device_register+0x60/0xa0
[  160.180356]  mlxreg_fan_probe+0x474/0x5e0 [mlxreg_fan]
[  160.248140]
[  160.249807] The buggy address belongs to the object at ffff888116163400
[  160.249807]  which belongs to the cache kmalloc-1k of size 1024
[  160.263814] The buggy address is located 64 bytes to the right of
[  160.263814]  1024-byte region [ffff888116163400, ffff888116163800)
[  160.277536] The buggy address belongs to the page:
[  160.282898] page:0000000012275840 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888116167000 pfn:0x116160
[  160.294872] head:0000000012275840 order:3 compound_mapcount:0 compound_pincount:0
[  160.303251] flags: 0x200000000010200(slab|head|node=0|zone=2)
[  160.309694] raw: 0200000000010200 ffffea00046f7208 ffffea0004928208 ffff88810004dbc0
[  160.318367] raw: ffff888116167000 00000000000a0006 00000001ffffffff 0000000000000000
[  160.327033] page dumped because: kasan: bad access detected
[  160.333270]
[  160.334937] Memory state around the buggy address:
[  160.356469] >ffff888116163800: fc ..

Fixes: 65afb4c8e7 ("hwmon: (mlxreg-fan) Add support for Mellanox FAN driver")
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210916183151.869427-1-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-09-16 14:48:20 -07:00
suma hegde 23c69b9036 hwmon: (k10temp) Remove residues of current and voltage
Commit id "b00647c46c9d7f6ee1ff6aaf335906101755e614",
adds reporting current and voltage to k10temp.c

The commit id "0a4e668b5d52eed8026f5d717196b02b55fb2dc6",
removed reporting current and voltage from k10temp.c

The curr and in(voltage) entries are not removed from
"k10temp_info" structure. Removing those residue entries.
while at it, update k10temp driver documentation

Signed-off-by: suma hegde <suma.hegde@amd.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210902174155.7365-2-nchatrad@amd.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-09-12 17:56:36 -07:00
Linus Torvalds 2d338201d5 Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:
 "147 patches, based on 7d2a07b769.

  Subsystems affected by this patch series: mm (memory-hotplug, rmap,
  ioremap, highmem, cleanups, secretmem, kfence, damon, and vmscan),
  alpha, percpu, procfs, misc, core-kernel, MAINTAINERS, lib,
  checkpatch, epoll, init, nilfs2, coredump, fork, pids, criu, kconfig,
  selftests, ipc, and scripts"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (94 commits)
  scripts: check_extable: fix typo in user error message
  mm/workingset: correct kernel-doc notations
  ipc: replace costly bailout check in sysvipc_find_ipc()
  selftests/memfd: remove unused variable
  Kconfig.debug: drop selecting non-existing HARDLOCKUP_DETECTOR_ARCH
  configs: remove the obsolete CONFIG_INPUT_POLLDEV
  prctl: allow to setup brk for et_dyn executables
  pid: cleanup the stale comment mentioning pidmap_init().
  kernel/fork.c: unexport get_{mm,task}_exe_file
  coredump: fix memleak in dump_vma_snapshot()
  fs/coredump.c: log if a core dump is aborted due to changed file permissions
  nilfs2: use refcount_dec_and_lock() to fix potential UAF
  nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group
  nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group
  nilfs2: fix memory leak in nilfs_sysfs_delete_##name##_group
  nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group
  nilfs2: fix NULL pointer in nilfs_##name##_attr_release
  nilfs2: fix memory leak in nilfs_sysfs_create_device_group
  trap: cleanup trap_init()
  init: move usermodehelper_enable() to populate_rootfs()
  ...
2021-09-08 12:55:35 -07:00
Daniel Lezcano d59eacaac9 hwmon/drivers/mr75203: use HZ macros
HZ unit conversion macros are available in units.h, use them and remove
the duplicate definition.

The new macro is an unsigned long.  The code dealing with it is
considering as an unsigned long also.

Link: https://lkml.kernel.org/r/20210816114732.1834145-7-daniel.lezcano@linaro.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Christian Eggers <ceggers@arri.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Lukasz Luba <lukasz.luba@arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-09-08 11:50:26 -07:00
Aleksa Savic 0e35f63f7f hwmon: add driver for Aquacomputer D5 Next
This driver exposes hardware sensors of the Aquacomputer D5 Next
watercooling pump, which communicates through a proprietary USB HID
protocol.

Available sensors are pump and fan speed, power, voltage and current, as
well as coolant temperature. Also available through debugfs are the serial
number, firmware version and power-on count.

Attaching a fan is optional and allows it to be controlled using
temperature curves directly from the pump. If it's not connected,
the fan-related sensors will report zeroes.

The pump can be configured either through software or via its physical
interface. Configuring the pump through this driver is not implemented,
as it seems to require sending it a complete configuration. That
includes addressable RGB LEDs, for which there is no standard sysfs
interface. Thus, that task is better suited for userspace tools.

This driver has been tested on x86_64, both in-kernel and as a module.

Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-28 08:53:30 -07:00
Chris Packham fc958a61ff hwmon: (adt7470) Convert to devm_hwmon_device_register_with_info API
Use the devm_hwmon_device_register_with_info API and remove code that
deals with the standard sensor attributes.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210826024121.15665-4-chris.packham@alliedtelesis.co.nz
[groeck: Fixed alignment issues]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-27 14:24:14 -07:00
Chris Packham ef67959c42 hwmon: (adt7470) Convert to use regmap
Convert the adt7470 to using regmap which allows better error handling.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210826024121.15665-3-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-27 14:20:29 -07:00
Chris Packham 23bd022aa6 hwmon: (adt7470) Fix some style issues
In preparation for the changes that follow fix up some existing style
issues.
Specifically:
- add blank line between variable declaration and code
- use strscpy instead of strlcpy
- remove unnecessary braces

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210826024121.15665-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-27 14:13:20 -07:00
Mario Limonciello 25572c818d hwmon: (k10temp) Add support for yellow carp
Yellow carp matches same behavior as green sardine and other Zen3
products, but have different CCD offsets.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20210827201527.24454-3-mario.limonciello@amd.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-27 13:54:58 -07:00
Mario Limonciello 0e3f52bbd9 hwmon: (k10temp) Rework the temperature offset calculation
Some of the existing assumptions made do not scale properly
to new silicon in upcoming changes.  This commit should cause
no functional changes to existing silicon.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20210827201527.24454-2-mario.limonciello@amd.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-27 13:52:56 -07:00
Mario Limonciello 02a2484cf8 hwmon: (k10temp) Don't show Tdie for all Zen/Zen2/Zen3 CPU/APU
Tdie is an offset calculation that should only be shown when temp_offset
is actually put into a table.  This is useless to show for all CPU/APU.
Show it only when necessary.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-27 09:44:57 -07:00
Mario Limonciello 128066c887 hwmon: (k10temp) Add additional missing Zen2 and Zen3 APUs
These follow the rest of the existing codepaths for families
17h and 19h.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-27 09:44:07 -07:00
Lukas Bulwahn b3a7ab2d43 hwmon: remove amd_energy driver in Makefile
Commit 9049572fb1 ("hwmon: Remove amd_energy driver") removes the driver,
but misses to adjust the Makefile.

Hence, ./scripts/checkkconfigsymbols.py warns:

SENSORS_AMD_ENERGY
Referencing files: drivers/hwmon/Makefile

Remove the missing piece of this driver removal.

Fixes: 9049572fb1 ("hwmon: Remove amd_energy driver")
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/r/20210817084811.10673-1-lukas.bulwahn@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:55:03 -07:00
Armin Wolf 8713b4a49c hwmon: (dell-smm) Rework SMM function debugging
Drop #ifdef DEBUG and use ktime_us_delta()
for improved precision.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210814190516.26718-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:27 -07:00
Armin Wolf 782a99c146 hwmon: (dell-smm) Mark i8k_get_fan_nominal_speed as __init
Mark function i8k_get_fan_nominal_speed() as __init since
it is only used in code also marked as __init.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210814143637.11922-5-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:27 -07:00
Armin Wolf c510f6accb hwmon: (dell-smm) Mark tables as __initconst
Both the config and the DMI tables never change and
are only used during module init for setting up
the device data struct.
Mark all of them as const and __initconst for a
smaller runtime memory footprint.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210814143637.11922-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:27 -07:00
Chris Packham 1125bacbf3 hwmon: (pmbus/bpa-rs600) Add workaround for incorrect Pin max
BPD-RS600 modules running firmware v5.70 misreport the MFR_PIN_MAX.
The indicate a maximum of 1640W instead of 700W. Detect the invalid
reading and return a sensible value instead.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210812014000.26293-3-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:27 -07:00
Chris Packham 7a8c68c57f hwmon: (pmbus/bpa-rs600) Don't use rated limits as warn limits
In the initial implementation a number of PMBUS_x_WARN_LIMITs were
mapped to MFR fields. This was incorrect as these MFR limits reflect the
rated limit as opposed to a limit which will generate warning. Instead
return -ENXIO like we were already doing for other WARN_LIMITs.

Subsequently these rated limits have been exposed generically as new
fields in the sysfs ABI so the values are still available.

Fixes: 15b2703e5e ("hwmon: (pmbus) Add driver for BluTek BPA-RS600")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210812014000.26293-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Nuno Sá 2aee7e67be hwmon: (axi-fan-control) Support temperature vs pwm points
The HW has some predefined points where it will associate a PWM value.
However some users might want to better set these points to their
usecases. This patch exposes these points as pwm auto_points:

 * pwm1_auto_point1_temp_hyst: temperature threshold below which PWM should
   be 0%;
 * pwm1_auto_point1_temp: temperature threshold above which PWM should be
   25%;
 * pwm1_auto_point2_temp_hyst: temperature threshold below which PWM should
   be 25%;
 * pwm1_auto_point2_temp: temperature threshold above which PWM should be
   50%;
 * pwm1_auto_point3_temp_hyst: temperature threshold below which PWM should
   be 50%;
 * pwm1_auto_point3_temp: temperature threshold above which PWM should be
   75%;
 * pwm1_auto_point4_temp_hyst: temperature threshold below which PWM should
   be 75%;
 * pwm1_auto_point4_temp: temperature threshold above which PWM should be
   100%;

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210811114853.159298-4-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Nuno Sá e66705de82 hwmon: (axi-fan-control) Handle irqs in natural order
The core will now start out of reset at boot as soon as clocking is
available. Hence, by the time we unmask the interrupts we already might
have some of them set. Thus, it's important to handle them in the
natural order the core generates them. Otherwise, we could process
'ADI_IRQ_SRC_PWM_CHANGED' before 'ADI_IRQ_SRC_TEMP_INCREASE' and
erroneously set 'update_tacho_params' to true.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210811114853.159298-3-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Nuno Sá a3933625de hwmon: (axi-fan-control) Make sure the clock is enabled
The core will only work if it's clock is enabled. This patch is a
minor enhancement to make sure that's the case.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210811114853.159298-2-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Brandon Wyman 76b72736f5 hwmon: (pmbus/ibm-cffps) Fix write bits for LED control
When doing a PMBus write for the LED control on the IBM Common Form
Factor Power Supplies (ibm-cffps), the DAh command requires that bit 7
be low and bit 6 be high in order to indicate that you are truly
attempting to do a write.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Link: https://lore.kernel.org/r/20210806225131.1808759-1-bjwyman@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Linus Walleij 2284ed9ffc hwmon: (w83781d) Match on device tree compatibles
I2C devices should match on the proper compatible string.
This is already used in one device tree in the kernel (MIPS)
so let's add the matches.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210729230543.2853485-2-linus.walleij@linaro.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Sebastian Andrzej Siewior e104d530f3 hwmon: Replace deprecated CPU-hotplug functions.
The functions get_online_cpus() and put_online_cpus() have been
deprecated during the CPU hotplug rework. They map directly to
cpus_read_lock() and cpus_read_unlock().

Replace deprecated CPU-hotplug functions with the official version.
The behavior remains unchanged.

Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20210803141621.780504-14-bigeasy@linutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Carlos Alberto Lopez Perez 95d88d054a hwmon: (dell-smm) Add Dell Precision 7510 to fan control whitelist
This allows manual PWM control without the BIOS fighting back on Dell
Precision 7510. Meanwhile at it, also sort alphabetically the entries
of the i8k_whitelist_fan_control struct.

Signed-off-by: Carlos Alberto Lopez Perez <clopez@igalia.com>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210802131538.8660-1-clopez@igalia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf 2757269a7d hwmon: (dell-smm-hwmon) Fix fan mutliplier detection for 3rd fan
There are up to three fans, but the detection omits the 3rd one.
Fix that by using DELL_SMM_NO_FANS.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Fixes: 747bc8b063 (hwmon: (dell-smm) Detect fan with index=2)
Link: https://lore.kernel.org/r/20210728221557.8891-7-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf deeba244b0 hwmon: (dell-smm-hwmon) Convert to devm_hwmon_device_register_with_info()
Convert to new registration API to get rid of attribute magic
numbers and reduce module size.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210728221557.8891-6-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf ba04d73c26 hwmon: (dell-smm-hwmon) Move variables into a driver private data structure
Move Variables into a driver private data structure.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210728221557.8891-5-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf a2cb66b476 hwmon: (dell-smm-hwmon) Use devm_add_action_or_reset()
Use devm_add_action_or_reset() for calling i8k_exit_procfs()
so the remove() function in dell_smm_driver can be omitted.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210728221557.8891-4-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf c9363cdf3a hwmon: (dell-smm-hwmon) Mark functions as __init
i8k_get_dmi_data() and i8k_get_dell_signature() are
only called during module init and probe, which both
are marked as __init.
Also mark these function as __init to lower the runtime
memory footprint.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210728221557.8891-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Armin Wolf 1492fa21c0 hwmon: (dell-smm-hwmon) Use platform device
Register a platform device for usage with
devm_hwmon_device_register_with_groups since
the platform device is necessary for future
changes.
Also fix some checkpatch warnings.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210728221557.8891-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Akshay Gupta 5a0f50d110 hwmon: Add support for SB-RMI power module
On AMD platforms the Out-of-band access is provided by
Advanced Platform Management Link (APML), APML is a
SMBus v2.0 compatible 2-wire processor client interface.
APML is also referred as the sideband interface (SBI).

APML is used to communicate with the
Side-Band Remote Management Interface (SB-RMI) which provides
Soft Mailbox messages to manage power consumption and
power limits of the CPU socket.

- This module add support to read power consumption,
  power limit & max power limit and write power limit.
- To instantiate this driver on a Board Management Controller (BMC)
  connected to an AMD CPU with SB-RMI support, the i2c bus number
  would be the bus connected from the BMC to the CPU.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Akshay Gupta <Akshay.Gupta@amd.com>
Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
Link: https://lore.kernel.org/r/20210726133615.9709-1-nchatrad@amd.com
[groeck: Fix uninitialized variable problem when reporting max power]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Armin Wolf 6f447ce0f7 hwmon: (w83627ehf) Make DEVICE_ATTR_RO static
Make DEVICE_ATTR_RO static to fix sparse warning:
warning: symbol 'dev_attr_cpu0_vid' was not declared. Should it be static?

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210724154817.18796-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Armin Wolf ef9e78c0d1 hwmon: (w83627ehf) Switch to SIMPLE_DEV_PM_OPS
Use SIMPLE_DEV_PM_OPS() to also assign poweroff
and thaw callbacks. Remove the now obsolete checking
of CONFIG_PM too.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210721192519.28784-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Martin Hundebøll 1ccdc18405 hwmon: intel-m10-bmc-hwmon: add n5010 sensors
Add the list of sensors supported by the Silicom n5010 PAC, and enable
the drivers as a subtype of the intel-m10-bmc multi-function driver.

Signed-off-by: Martin Hundebøll <mhu@silicom.dk>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Moritz Fischer <mdf@kernel.org>
Reviewed-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20210716135441.3235863-4-martin@geanix.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Armin Wolf 228f2aed87 hwmon: (w83627ehf) Remove w83627ehf_remove()
Using devm_request_region() allows us to omit
w83627ehf_remove() and also simplifies error
handling during probe.
Also fixed a checkpatch issue.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210709184501.6546-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Armin Wolf 964c1c91ed hwmon: (w83627ehf) Use platform_create_bundle
Using platform_create_bundle() simplifies the module
init code and allows w83627ehf_probe() to be marked
as __init, lowering the runtime memory footprint.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210709184501.6546-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Chris Packham 129cdce375 hwmon: (pmbus/bpa-rs600) Support BPD-RS600
The BPD-RS600 is the DC version of the BPA-RS600. The PMBUS interface is
the same between the two models. Keep the same compatible string but
accept either BPA-RS600 or BPD-RS600 in the PMBUS_MFR_MODEL.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210708220618.23576-1-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Linus Walleij bd56c1e960 hwmon: (ntc_thermistor) Use library interpolation
The kernel has a helper function for linear interpolation so
use it. It incidentally makes the code easier to read as well.

Tested on the ST-Ericsson HREFv60plus hardware reference design
with two thermistors forming a thermal zone.

Cc: Peter Rosin <peda@axentia.se>
Cc: Chris Lesiak <chris.lesiak@licor.com>
Cc: linux-iio@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210704222014.12058-1-linus.walleij@linaro.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
David Bartley 02c9dce4df hwmon: (k10temp) support Zen3 APUs
Add support for Zen3 Ryzen APU.

Signed-off-by: David Bartley <andareed@gmail.com>
Link: https://lore.kernel.org/r/20210517064131.4369-1-andareed@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:24 -07:00
Linus Torvalds eed0218e8c Char / Misc driver updates for 5.14-rc1
Here is the big set of char / misc and other driver subsystem updates
 for 5.14-rc1.  Included in here are:
 	- habanna driver updates
 	- fsl-mc driver updates
 	- comedi driver updates
 	- fpga driver updates
 	- extcon driver updates
 	- interconnect driver updates
 	- mei driver updates
 	- nvmem driver updates
 	- phy driver updates
 	- pnp driver updates
 	- soundwire driver updates
 	- lots of other tiny driver updates for char and misc drivers
 
 This is looking more and more like the "various driver subsystems mushed
 together" tree...
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCYOM8jQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymECgCg0yL+8WxDKO5Gg5llM5PshvLB1rQAn0y5pDgg
 nw78LV3HQ0U7qaZBtI91
 =x+AR
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char / misc driver updates from Greg KH:
 "Here is the big set of char / misc and other driver subsystem updates
  for 5.14-rc1. Included in here are:

   - habanalabs driver updates

   - fsl-mc driver updates

   - comedi driver updates

   - fpga driver updates

   - extcon driver updates

   - interconnect driver updates

   - mei driver updates

   - nvmem driver updates

   - phy driver updates

   - pnp driver updates

   - soundwire driver updates

   - lots of other tiny driver updates for char and misc drivers

  This is looking more and more like the "various driver subsystems
  mushed together" tree...

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'char-misc-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (292 commits)
  mcb: Use DEFINE_RES_MEM() helper macro and fix the end address
  PNP: moved EXPORT_SYMBOL so that it immediately followed its function/variable
  bus: mhi: pci-generic: Add missing 'pci_disable_pcie_error_reporting()' calls
  bus: mhi: Wait for M2 state during system resume
  bus: mhi: core: Fix power down latency
  intel_th: Wait until port is in reset before programming it
  intel_th: msu: Make contiguous buffers uncached
  intel_th: Remove an unused exit point from intel_th_remove()
  stm class: Spelling fix
  nitro_enclaves: Set Bus Master for the NE PCI device
  misc: ibmasm: Modify matricies to matrices
  misc: vmw_vmci: return the correct errno code
  siox: Simplify error handling via dev_err_probe()
  fpga: machxo2-spi: Address warning about unused variable
  lkdtm/heap: Add init_on_alloc tests
  selftests/lkdtm: Enable various testable CONFIGs
  lkdtm: Add CONFIG hints in errors where possible
  lkdtm: Enable DOUBLE_FAULT on all architectures
  lkdtm/heap: Add vmalloc linear overflow test
  lkdtm/bugs: XFAIL UNALIGNED_LOAD_STORE_WRITE
  ...
2021-07-05 13:42:16 -07:00
Linus Torvalds 8ec035ac4a fallthrough fixes for Clang for 5.14-rc1
Hi Linus,
 
 Please, pull the following patches that fix many fall-through warnings
 when building with Clang 12.0.0 and this[1] change reverted. Notice
 that in order to enable -Wimplicit-fallthrough for Clang, such change[1]
 is meant to be reverted at some point. So, these patches help to move
 in that direction.
 
 Thanks!
 
 [1] commit e2079e93f5 ("kbuild: Do not enable -Wimplicit-fallthrough for clang for now")
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEkmRahXBSurMIg1YvRwW0y0cG2zEFAmDaNe8ACgkQRwW0y0cG
 2zFfGA/9G1A/Hrf261/P9olyYe2TRBwLnO1tUDREm3qtJ2JdKpf+7EM3VDm+Ue/A
 qhNmwp5G7nmp7Nqq8MfbdFjeo/rPS67voXiOfO8b0pU+E4XlOc+B1BXL0BWtnP7b
 xvuauklQU6dmCp2u44vsxdBIO6ooR0uQh+7/+1la+mPyEk9mlooQ4lyFcpfA53yt
 zxEGrx0tZBrDXghEI1CkHxOaJaX3qhw4EUYvxe8n2L7Dgx+o2djL/G4/SRYH/xoq
 MZa8TLyCuR3J0Ph4TfDONhMmf8ZLn+j70xBhewcVfZ1JfvGSVw4DQNN44KZCDnrK
 tGsBo5VFksjbmX83LmT8UlqB1rTP4nVQtRmtOPvbQA9kd19yy+Y64Y58FcGU2FHl
 PWt3rQJ1JzBo3TtzQoz7HSJCt9QTil4U7hFbNtcp5BbWQfUPkRgpWcL3FOchZbZ6
 FnLMqHanw2lrKMzZEoyHvg6G7BT67k3rrFgtd/xGSn8ohtfKXaZBYa9PKrQ0LwuG
 o8tQtIX1owj4rbdI1t6Ob4X/tT6Y7DzH8nsF+TsJQ4XeSCD2rURUcYltBMIlEr16
 DFj7iWKIrrX80/JRsBXu7a9h8nn5YptxV12SGRq/Cu/2jfRwjDye4IzsCyqMf67n
 oEN6YC1XYaEUmKXTnI8Z0CxY0qwSTcNjeH5Ci9jWepinsqD3Jxw=
 =Kt2q
 -----END PGP SIGNATURE-----

Merge tag 'fallthrough-fixes-clang-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux

Pull fallthrough fixes from Gustavo Silva:
 "Fix many fall-through warnings when building with Clang 12.0.0 and
  '-Wimplicit-fallthrough' so that we at some point will be able to
  enable that warning by default"

* tag 'fallthrough-fixes-clang-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux: (26 commits)
  rxrpc: Fix fall-through warnings for Clang
  drm/nouveau/clk: Fix fall-through warnings for Clang
  drm/nouveau/therm: Fix fall-through warnings for Clang
  drm/nouveau: Fix fall-through warnings for Clang
  xfs: Fix fall-through warnings for Clang
  xfrm: Fix fall-through warnings for Clang
  tipc: Fix fall-through warnings for Clang
  sctp: Fix fall-through warnings for Clang
  rds: Fix fall-through warnings for Clang
  net/packet: Fix fall-through warnings for Clang
  net: netrom: Fix fall-through warnings for Clang
  ide: Fix fall-through warnings for Clang
  hwmon: (max6621) Fix fall-through warnings for Clang
  hwmon: (corsair-cpro) Fix fall-through warnings for Clang
  firewire: core: Fix fall-through warnings for Clang
  braille_console: Fix fall-through warnings for Clang
  ipv4: Fix fall-through warnings for Clang
  qlcnic: Fix fall-through warnings for Clang
  bnxt_en: Fix fall-through warnings for Clang
  netxen_nic: Fix fall-through warnings for Clang
  ...
2021-06-28 20:03:38 -07:00
Dmitry Osipenko a5f6c0f85a hwmon: Support set_trips() of thermal device ops
Support set_trips() callback of thermal device ops. This allows HWMON
device to operatively notify thermal core about temperature changes, which
is very handy to have in a case where HWMON sensor is used by CPU thermal
zone that performs passive cooling and emergency shutdown on overheat.
Thermal core will be able to react faster to temperature changes.

The set_trips() callback is entirely optional. If HWMON sensor doesn't
support setting thermal trips, then the callback is a NO-OP. The dummy
callback has no effect on the thermal core. The temperature trips are
either complement the temperature polling mechanism of thermal core or
replace the polling if sensor can set the trips and polling is disabled
by a particular device in a device-tree.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210623042231.16008-3-digetx@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-24 07:15:28 -07:00
Dmitry Osipenko b50aa49638 hwmon: (lm90) Prevent integer underflows of temperature calculations
The min/max/crit and all other temperature values that are passed to
the driver are unlimited and value that is close to INT_MIN results in
integer underflow of the temperature calculations made by the driver
for LM99 sensor. Temperature hysteresis is among those values that need
to be limited, but limiting of hysteresis is independent from the sensor
version. Add the missing limits.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210623042231.16008-2-digetx@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-24 07:14:27 -07:00
Dmitry Osipenko 4c7f85a321 hwmon: (lm90) Disable interrupt on suspend
I2C accesses are prohibited and will error out after suspending of the
I2C controller, hence we need to ensure that interrupt won't fire on
suspend when it's too late. Disable interrupt across suspend/resume.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-19 04:09:49 -07:00
Dmitry Osipenko 2abdc357c5 hwmon: (lm90) Unmask hardware interrupt
The ALERT interrupt is enabled by default after power-on, but it could
be masked by bootloader. For example this is the case on Acer A500 tablet
device. Unmask the hardware interrupt if interrupt is provided.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-19 04:09:49 -07:00
Dmitry Osipenko 94dbd23ed8 hwmon: (lm90) Use hwmon_notify_event()
Use hwmon_notify_event() to notify userspace and thermal core about
temperature changes.

Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-19 04:09:49 -07:00
Dmitry Osipenko d97fb837b8 hwmon: (lm90) Don't override interrupt trigger type
The lm90 driver sets interrupt trigger type to level-low. This type is
not suitable for sensors like NCT1008 that don't deassert interrupt line
until temperature is back to normal, resulting in interrupt storm. The
appropriate trigger type should come from OF device description and
currently it's overridden by the driver's trigger type. Don't specify
the trigger type in the driver code, letting interrupt core to use the
device-specific trigger type.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-19 04:09:49 -07:00
Dan Carpenter 9e25f01b5f hwmon: (pmbus/dps920ab) Delete some dead code
The debugfs_create_dir() function returns error pointers, it doesn't
return NULL.  But debugfs functions don't need to be checked in normal
situations and we can just delete this code.

Fixes: 1f442e213ce5 ("hwmon: (pmbus) Add driver for Delta DPS-920AB PSU")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YMyjmR54ErLtc1sH@mwanda
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-18 12:45:58 -07:00
Jonathan Cameron f0000797a3 hwmon: (ntc_thermistor) Drop unused headers.
The IIO usage in this driver is purely consumer so it should only
be including linux/iio/consumer.h  Whilst here drop pm_runtime.h
as there is no runtime power management in the driver.

Found using include-what-you-use and manual inspection of the
suggestions.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210611142257.103094-1-jic23@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:47 -07:00
Robert Marko 3efbcee8d4 hwmon: (pmbus) Add driver for Delta DPS-920AB PSU
This adds support for the Delta DPS-920AB PSU.

Only missing feature is fan control which the PSU supports.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Link: https://lore.kernel.org/r/20210607103431.2039073-1-robert.marko@sartura.hr
[groeck: Add MODULE_IMPORT_NS(PMBUS);]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:46 -07:00
Erik Rosen 317f9d808a hwmon: (pmbus/pim4328) Add PMBus driver for PIM4006, PIM4328 and PIM4820
Add hardware monitoring support for Flex power interface modules PIM4006,
PIM4328 and PIM4820.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:46 -07:00
Erik Rosen 5e86f128d9 hwmon: (pmbus) Allow phase function even if it's not on page
Allow the use of a phase function even if it does not exist on
the associated page.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:46 -07:00
Erik Rosen e8e00c83a2 hwmon: (pmbus) Add support for reading direct mode coefficients
Add support for reading and decoding direct format coefficients to
the PMBus core driver. If the new flag PMBUS_USE_COEFFICIENTS_CMD
is set, the driver will use the COEFFICIENTS register together with
the information in the pmbus_sensor_attr structs to initialize
relevant coefficients for the direct mode format.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
[groeck: Initialize ret with -EINVAL in pmbus_init_coefficients()]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:46 -07:00
Erik Rosen dbc0860f7a hwmon: (pmbus) Add new pmbus flag NO_WRITE_PROTECT
Some PMBus chips respond with invalid data when reading the WRITE_PROTECT
register. For such chips, this flag should be set so that the PMBus core
driver doesn't use the WRITE_PROTECT command to determine its behavior.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:46 -07:00
Madhava Reddy Siddareddygari 4e5418f787 hwmon: (pmbus_core) Check adapter PEC support
Currently, for Packet Error Checking (PEC) only the controller
is checked for support. This causes problems on the cisco-8000
platform where a SMBUS transaction errors are observed. This is
because PEC has to be enabled only if both controller and
adapter support it.

Added code to check PEC capability for adapter and enable it
only if both controller and adapter supports PEC.

Signed-off-by: Madhava Reddy Siddareddygari <msiddare@cisco.com>
[Upstream from SONiC https://github.com/Azure/sonic-linux-kernel/pull/215]
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Link: https://lore.kernel.org/r/20210605052700.541455-1-pmenzel@molgen.mpg.de
[groeck: Dropped unnecessary continuation line]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:46 -07:00
Ninad Malwade 6b6af85410 hwmon: (ina3221) use CVRF only for single-shot conversion
As per current logic the wait time per conversion is arouns 430ms
for 512 samples and around 860ms for 1024 samples for 3 channels
considering 140us as the bus voltage and shunt voltage sampling
conversion time.

This waiting time is a lot for the continuous mode and even for
the single shot mode. For continuous mode when moving average is
considered the waiting for CVRF bit is not required and the data
from the previous conversion is sufficuent. As mentioned in the
datasheet the conversion ready bit is provided to help coordinate
single-shot conversions, we can restrict the use to single-shot
mode only.

Also, the conversion time is for the averaged samples, the wait
time for the polling can omit the number of samples consideration.

Signed-off-by: Ninad Malwade <nmalwade@nvidia.com>
Link: https://lore.kernel.org/r/1622789683-30931-1-git-send-email-nmalwade@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:46 -07:00
Guenter Roeck 1814c4e84d hwmon: (max31790) Detect and report zero fan speed
If a fan is not running or not connected, of if fan monitoring is disabled,
the fan count register returns a fixed value of 0xffe0. So far this is then
translated to a RPM value larger than 0. Since this is misleading and does
not really make much sense, report a fan RPM of 0 in this situation.

Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
Cc: Václav Kubernát <kubernat@cesnet.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Václav Kubernát <kubernat@cesnet.cz>
Link: https://lore.kernel.org/r/20210526154022.3223012-7-linux@roeck-us.net
2021-06-17 04:21:46 -07:00
Guenter Roeck 2013607b85 hwmon: (max31790) Clear fan fault after reporting it
Fault bits in MAX31790 are sticky and have to be cleared explicitly.
A write operation into either the 'Target Duty Cycle' register or the
'Target Count' register is necessary to clear a fault.

At the same time, we can never clear cached fault status values before
reading them because the companion fault status for any given fan is
cleared as well when clearing a fault.

Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
Cc: Václav Kubernát <kubernat@cesnet.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Václav Kubernát <kubernat@cesnet.cz>
Link: https://lore.kernel.org/r/20210526154022.3223012-6-linux@roeck-us.net
2021-06-17 04:21:46 -07:00
Guenter Roeck 148c847c9e hwmon: (max31790) Fix pwmX_enable attributes
pwmX_enable supports three possible values:

0: Fan control disabled. Duty cycle is fixed to 0%
1: Fan control enabled, pwm mode. Duty cycle is determined by
   values written into Target Duty Cycle registers.
2: Fan control enabled, rpm mode
   Duty cycle is adjusted such that fan speed matches
   the values in Target Count registers

The current code does not do this; instead, it mixes pwm control
configuration with fan speed monitoring configuration. Worse, it
reports that pwm control would be disabled (pwmX_enable==0) when
it is in fact enabled in pwm mode. Part of the problem may be that
the chip sets the "TACH input enable" bit on its own whenever the
mode bit is set to RPM mode, but that doesn't mean that "TACH input
enable" accurately reflects the pwm mode.

Fix it up and only handle pwm control with the pwmX_enable attributes.
In the documentation, clarify that disabling pwm control (pwmX_enable=0)
sets the pwm duty cycle to 0%. In the code, explain why TACH_INPUT_EN
is set together with RPM_MODE.

While at it, only update the configuration register if the configuration
has changed, and only update the cached configuration if updating the
chip configuration was successful.

Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
Cc: Václav Kubernát <kubernat@cesnet.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Václav Kubernát <kubernat@cesnet.cz>
Reviewed-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Link: https://lore.kernel.org/r/20210526154022.3223012-4-linux@roeck-us.net
2021-06-17 04:21:46 -07:00
Guenter Roeck 897f633989 hwmon: (max31790) Report correct current pwm duty cycles
The MAX31790 has two sets of registers for pwm duty cycles, one to request
a duty cycle and one to read the actual current duty cycle. Both do not
have to be the same.

When reporting the pwm duty cycle to the user, the actual pwm duty cycle
from pwm duty cycle registers needs to be reported. When setting it, the
pwm target duty cycle needs to be written. Since we don't know the actual
pwm duty cycle after a target pwm duty cycle has been written, set the
valid flag to false to indicate that actual pwm duty cycle should be read
from the chip instead of using cached values.

Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
Cc: Václav Kubernát <kubernat@cesnet.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Václav Kubernát <kubernat@ceesnet.cz>
Reviewed-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Link: https://lore.kernel.org/r/20210526154022.3223012-3-linux@roeck-us.net
2021-06-17 04:21:45 -07:00
Guenter Roeck cbbf244f05 hwmon: (max31790) Fix fan speed reporting for fan7..12
Fans 7..12 do not have their own set of configuration registers.
So far the code ignored that and read beyond the end of the configuration
register range to get the tachometer period. This resulted in more or less
random fan speed values for those fans.

The datasheet is quite vague when it comes to defining the tachometer
period for fans 7..12. Experiments confirm that the period is the same
for both fans associated with a given set of configuration registers.

Fixes: 54187ff9d7 ("hwmon: (max31790) Convert to use new hwmon registration API")
Fixes: 195a4b4298 ("hwmon: Driver for Maxim MAX31790")
Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
Reviewed-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Cc: Václav Kubernát <kubernat@cesnet.cz>
Reviewed-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210526154022.3223012-2-linux@roeck-us.net
2021-06-17 04:21:45 -07:00
Joe Perches 07c6621a37 hwmon: (sht4x) Fix sht4x_read_values return value
Kernel doc for sht4x_read_values() shows 0 on success, 1 on failure but
the return value on success is actually always positive as it is set to
SHT4X_RESPONSE_LENGTH by a successful call to i2c_master_recv().

Miscellanea:

o Update the kernel doc for sht4x_read_values to 0 for success or -ERRNO
o Remove incorrectly used kernel doc /** header for other _read functions
o Typo fix succesfull->successful
o Reverse a test to unindent a block and use goto unlock
o Declare cmd[SHT4X_CMD_LEN] rather than cmd[]

At least for gcc 10.2, object size is reduced a tiny bit.

$ size drivers/hwmon/sht4x.o*
   text	   data	    bss	    dec	    hex	filename
   1752	    404	    256	   2412	    96c	drivers/hwmon/sht4x.o.new
   1825	    404	    256	   2485	    9b5	drivers/hwmon/sht4x.o.old

Signed-off-by: Joe Perches <joe@perches.com>
Link: https://lore.kernel.org/r/60eedce497137eb34448c0c77e01ec9d9c972ad7.camel@perches.com
Reviewed by: Navin Sankar Velliangiri <navin@linumiz.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Navin Sankar Velliangiri 505c254937 hwmon: Add sht4x Temperature and Humidity Sensor Driver
This patch adds a hwmon driver for the SHT4x Temperature and
Humidity sensor.

Signed-off-by: Navin Sankar Velliangiri <navin@linumiz.com>
[groeck: dropped unnecessary empty line and continuation lines]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Chu Lin 9da9c2dc57 hwmon: (adm1275) enable adm1272 temperature reporting
adm1272 supports temperature reporting but it is disabled by default.

Tested:
ls temp1_*
temp1_crit           temp1_highest        temp1_max
temp1_crit_alarm     temp1_input          temp1_max_alarm

cat temp1_input
26642

Signed-off-by: Chu Lin <linchuyuan@google.com>
Link: https://lore.kernel.org/r/20210512171043.2433694-1-linchuyuan@google.com
[groeck: Updated subject to reflect correct driver]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Vadim Pasternak e4db7719d0 hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controller
Add support for mp2888 device from Monolithic Power Systems, Inc. (MPS)
vendor. This is a digital, multi-phase, pulse-width modulation
controller.

This device supports:
- One power rail.
- Programmable Multi-Phase up to 10 Phases.
- PWM-VID Interface
- One pages 0 for telemetry.
- Programmable pins for PMBus Address.
- Built-In EEPROM to Store Custom Configurations.
- Can configured VOUT readout in direct or VID format and allows
  setting of different formats on rails 1 and 2. For VID the following
  protocols are available: VR13 mode with 5-mV DAC; VR13 mode with
  10-mV DAC, IMVP9 mode with 5-mV DAC.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20210511055619.118104-3-vadimp@nvidia.com
[groeck: Add MODULE_IMPORT_NS]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Vadim Pasternak 0c1acde1d3 hwmon: (pmbus) Increase maximum number of phases per page
Increase maximum number of phases from 8 to 10 to support multi-phase
devices allowing up to 10 phases.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210511055619.118104-2-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Zhen Lei 4943c6039d hwmon: (bt1-pvt) Remove redundant error printing in pvt_request_regs()
When devm_ioremap_resource() fails, a clear enough error message will be
printed by its subfunction __devm_ioremap_resource(). The error
information contains the device name, failure cause, and possibly resource
information.

Therefore, remove the error printing here to simplify code and reduce the
binary size.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20210511091843.4561-1-thunder.leizhen@huawei.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Erik Rosen ea541c185c hwmon: (pmbus) Add support for additional Flex BMR converters to pmbus
Add support for Flex BMR310, BMR456, BMR457, BMR458, BMR480, BMR490,
BMR491 and BMR492 to the pmbus driver

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Link: https://lore.kernel.org/r/20210507194023.61138-4-erik.rosen@metormote.com
[groeck: Fixed minor whitespace error]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Erik Rosen 86c908d90f hwmon: (pmbus) Add new flag PMBUS_READ_STATUS_AFTER_FAILED_CHECK
Some PMBus chips end up in an undefined state when trying to read an
unsupported register. For such chips, it is necessary to reset the
chip pmbus controller to a known state after a failed register check.
This can be done by reading a known register. By setting this flag the
driver will try to read the STATUS register after each failed
register check. This read may fail, but it will put the chip into a
known state.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Link: https://lore.kernel.org/r/20210507194023.61138-2-erik.rosen@metormote.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:45 -07:00
Armin Wolf 5c1c78e0a0 hwmon: (sch56xx-common) Simplify sch56xx_device_add
Use platform_device_register_simple() instead of
manually calling platform_device_alloc()/platform_device_add().

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210508131457.12780-5-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Armin Wolf 989c9c675b hwmon: (sch56xx-common) Use helper function
Use watchdog_set_nowayout() to process param
setting and change param type to bool.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210508131457.12780-4-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Armin Wolf 6df5cba5c9 hwmon: (sch56xx-common) Use strscpy
strlcpy is considered deprecated.
Replace it with strscpy.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210508131457.12780-3-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Armin Wolf 2be5f0d753 hwmon: (sch56xx) Use devres functions for watchdog
Use devm_kzalloc()/devm_watchdog_register() for
watchdog registration since it allows us to remove
the sch56xx_watchdog_data struct from the drivers
own data structs.
Remove sch56xx_watchdog_unregister since devres
takes care of that now.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210508131457.12780-2-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
[groeck: Dropped unnecessary return; at end of void function]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Andy Shevchenko ba9c5fc395 hwmon: (lm70) Use SPI_MODE_X_MASK
Use SPI_MODE_X_MASK instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210510141331.56736-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Guenter Roeck 97387c2f06 hwmon: (max31722) Remove non-standard ACPI device IDs
Valid Maxim Integrated ACPI device IDs would start with MXIM,
not with MAX1. On top of that, ACPI device IDs reflecting chip names
are almost always invalid.

Remove the invalid ACPI IDs.

Fixes: 04e1e70afe ("hwmon: (max31722) Add support for MAX31722/MAX31723 temperature sensors")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Guenter Roeck ac61c8aae4 hwmon: (lm70) Revert "hwmon: (lm70) Add support for ACPI"
This reverts commit b58bd4c6df.

None of the ACPI IDs introduced with the reverted patch is a valid ACPI
device ID. Any ACPI users of this driver are advised to use PRP0001 and
a devicetree-compatible device identification.

Fixes: b58bd4c6df ("hwmon: (lm70) Add support for ACPI")
Cc: Andrej Picej <andpicej@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Robert Marko ec081f9154 hwmon: (lm75) Add TI TMP1075 support
TI TMP1075 is a LM75 compatible sensor, so lets
add support for it.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Link: https://lore.kernel.org/r/20210429121150.106804-1-robert.marko@sartura.hr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:44 -07:00
Erik Rosen ab9d85e9d5 hwmon: (pmbus/zl6100) Add support for ZLS1003, ZLS4009 and ZL8802
Add support for Renesas ZL8802 Dual Channel/Dual Phase PMBus DC/DC
Digital Controller as well as ZLS1003 and ZLS4009 custom DC/DC
controller chips.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Link: https://lore.kernel.org/r/20210423153329.33457-2-erik.rosen@metormote.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:43 -07:00
Chris Packham 6e9ef8ca68 hwmon: (pmbus/bpa-rs600) Handle Vin readings >= 256V
The BPA-RS600 doesn't follow the PMBus spec for linear data.
Specifically it treats the mantissa as an unsigned 11-bit value instead
of a two's complement 11-bit value. At this point it's unclear whether
this only affects Vin or if Pin/Pout1 are affected as well. Erring on
the side of caution only Vin is dealt with here.

Fixes: 15b2703e5e ("hwmon: (pmbus) Add driver for BluTek BPA-RS600")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210616034218.25821-1-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17 04:21:25 -07:00
Greg Kroah-Hartman db4e54aefd Linux 5.13-rc6
-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAmDGe+4eHHRvcnZhbGRz
 QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiG/IUH/iyHVulAtAhL9bnR
 qL4M1kWfcG1sKS2TzGRZzo6YiUABf89vFP90r4sKxG3AKrb8YkTwmJr8B/sWwcsv
 PpKkXXTobbDfpSrsXGEapBkQOE7h2w739XeXyBLRPkoCR4UrEFn68TV2rLjMLBPS
 /EIZkonXLWzzWalgKDP4wSJ7GaQxi3LMx3dGAvbFArEGZ1mPHNlgWy2VokFY/yBf
 qh1EZ5rugysc78JCpTqfTf3fUPK2idQW5gtHSMbyESrWwJ/3XXL9o1ET3JWURYf1
 b0FgVztzddwgULoIGWLxDH5WWts3l54sjBLj0yrLUlnGKA5FjrZb12g9PdhdywuY
 /8KfjeE=
 =JfJm
 -----END PGP SIGNATURE-----

Merge tag 'v5.13-rc6' into char-misc-next

We need the fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-14 08:59:06 +02:00
Robert Marko e13d112724 hwmon: (tps23861) correct shunt LSB values
Current shunt LSB values got reversed during in the
original driver commit.

So, correct the current shunt LSB values according to
the datasheet.

This caused reading slightly skewed current values.

Fixes: fff7b8ab22 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Link: https://lore.kernel.org/r/20210609220728.499879-3-robert.marko@sartura.hr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-10 08:40:09 -07:00
Robert Marko b325d3526e hwmon: (tps23861) set current shunt value
TPS23861 has a configuration bit for setting of the
current shunt value used on the board.
Its bit 0 of the General Mask 1 register.

According to the datasheet bit values are:
0 for 255 mOhm (Default)
1 for 250 mOhm

So, configure the bit before registering the hwmon
device according to the value passed in the DTS or
default one if none is passed.

This caused potentially reading slightly skewed values
due to max current value being 1.02A when 250mOhm shunt
is used instead of 1.0A when 255mOhm is used.

Fixes: fff7b8ab22 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Link: https://lore.kernel.org/r/20210609220728.499879-2-robert.marko@sartura.hr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-10 08:38:52 -07:00
Robert Marko fb8543fb86 hwmon: (tps23861) define regmap max register
Define the max register address the device supports.
This allows reading the whole register space via
regmap debugfs, without it only register 0x0 is visible.

This was forgotten in the original driver commit.

Fixes: fff7b8ab22 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Link: https://lore.kernel.org/r/20210609220728.499879-1-robert.marko@sartura.hr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-10 08:36:19 -07:00
Greg Kroah-Hartman 800370b05b FSI changes for v5.14
- Bug fixes for the OCC, SCOM and SBEFIFO drivers
 
  - Performance fix for aspeed fsi master
 
  - Small fixes from the mailing lists
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+nHMAt9PCBDH63wBa3ZZB4FHcJ4FAmDBm5YACgkQa3ZZB4FH
 cJ6UtQ/8DwO1YMvokaILRK80up5mI5EOzNu3ULvrgSDw+cb4p8lYHElNipxkEo8X
 g6LhCjAU1q2Y3/y7TdGBX01AxhMOsi4PUdXQCLln+2ku0fGYZgakOxSS4313mVyZ
 e5nfhqM6RGFWCgXZctZwmO3wWkvoZCsBraN8wz92hQPYOD3IYGD/R+kcvuU8Ua4y
 NxiPPYaBDrZUfgaxI+30eBYzzkS9x1lWU57mecqrI/lcO49GAv+y0WjEcYhlISSi
 ue+//OGCgop2S4rJKIrBOXRk5A1zjY7vm2kYdji6j7usKsURzBQn4/ARdg5q8txt
 swoK9s4HgAKVg3PeXiqrCjV6VhyU2YMn+tCtCS+XRZoWxWGKBd8dyzbllEmMhYfJ
 j3Lsy1VVOX82bDBHtE6trOQHx7vCm9ab+2EIvG+QWmWVYhxS2TdstFQzwuNCpvKV
 BzeFEjkbo0F//PGfmVpJ0K4061qeFO4YN+7LLfxuDfgoXnZqexmcIks16GEJoxhC
 TdsqneYtOUBy5FEcRVMehL35NiHpEHk3Quo8po46fVkc0FRBxAhaZrpmfll2HZ9k
 3P9zXxKJa/8kdw8fqIbQcc8AN0ixcJ4VOmqaChkXAsoLzvPBbwPwgsDVXSfSIn6/
 UUja2lE2bSCPLiFV7kl9deKsZvQUONZJwlOnakkTYx3wrO+qDhU=
 =xHRF
 -----END PGP SIGNATURE-----

Merge tag 'fsi-for-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi into char-misc-next

Joel writes:

FSI changes for v5.14

 - Bug fixes for the OCC, SCOM and SBEFIFO drivers

 - Performance fix for aspeed fsi master

 - Small fixes from the mailing lists

* tag 'fsi-for-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/fsi:
  fsi/sbefifo: Fix reset timeout
  fsi/sbefifo: Clean up correct FIFO when receiving reset request from SBE
  fsi: master-ast-cf: Remove redundant error printing in fsi_master_acf_probe()
  fsi: Aspeed: Reduce poll timeout
  fsi: aspeed: convert to devm_platform_ioremap_resource
  hwmon: (occ) Print response status in first poll error message
  hwmon: (occ) Start sequence number at one
  fsi: occ: Log error for checksum failure
  fsi: occ: Don't accept response from un-initialized OCC
  fsi: scom: Remove retries
  fsi: scom: Reset the FSI2PIB engine for any error
  fsi: aspeed: Emit fewer barriers in opb operations
  fsi: core: Fix return of error values on failures
  fsi: Add missing MODULE_DEVICE_TABLE
2021-06-10 08:47:18 +02:00
Riwen Lu 78d1355234 hwmon: (scpi-hwmon) shows the negative temperature properly
The scpi hwmon shows the sub-zero temperature in an unsigned integer,
which would confuse the users when the machine works in low temperature
environment. This shows the sub-zero temperature in an signed value and
users can get it properly from sensors.

Signed-off-by: Riwen Lu <luriwen@kylinos.cn>
Tested-by: Xin Chen <chenxin@kylinos.cn>
Link: https://lore.kernel.org/r/20210604030959.736379-1-luriwen@kylinos.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-09 11:51:30 -07:00
Wilken Gottwalt 7656cd2177 hwmon: (corsair-psu) fix suspend behavior
During standby some PSUs turn off the microcontroller. A re-init is
required during resume or the microcontroller stays unresponsive.

Fixes: d115b51e0e ("hwmon: add Corsair PSU HID controller driver")
Signed-off-by: Wilken Gottwalt <wilken.gottwalt@posteo.net>
Link: https://lore.kernel.org/r/YLjCJiVtu5zgTabI@monster.powergraphx.local
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-09 11:51:30 -07:00
Eddie James 38483e8fed hwmon: (occ) Print response status in first poll error message
In order to better debug problems starting up the driver, print
the response status from the OCC in the error logged when the first
poll command fails.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210209171235.20624-5-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 14:29:58 +09:30
Eddie James 75028ef458 hwmon: (occ) Start sequence number at one
Initialize the sequence number at one, rather than zero, in order
to prevent false matches with the zero-initialized OCC SRAM
buffer before the OCC is fully initialized.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210209171235.20624-4-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-06-04 14:29:58 +09:30
Linus Torvalds 3bfc6ffb61 hwmon fixes for v5.13-rc4
The most notable fix is for the q54sj108a2 driver to let it actually
 instantiate. Also attribute fixes for pmbus/isl68137, pmbus/fsp-3y,
 and dell-smm-hwmon drivers.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmCudMsACgkQyx8mb86f
 mYGILQ//bmffBsY1y+D7h/a6l0cIq04fbQ1unfJ0prlb7hJw/jibZuB+lsOGNRd1
 B9KyKDzF9oV+cLY5VuvP4RZ9jHKjVyqdrjJAcbAeYBVI/lKqG8JXHKP1GBlmMQyD
 FmWOLCqUhQjvaEtztqjvmloGxs0Zmg49+3O4WOmgDFM/dRLVlLMGxXw2gGJBgsiK
 fA1AqClCzF9UR9vRVk+BS1I6LwXr7ft9VIZh1NaKLpBGuVLV1rF/CCDfodPlCzls
 ceKyFcHUwuZlR93L2L4umMgQVDi4RbRTI7RBJ76kUA16JCd/ph9ANuCKQeeAxuWa
 hPTpLFO+aCbRI79RlT8mZvw1lZaXbXRiGowHYx2o8ii+w1Jl+C/8LCsaXSm5oHVR
 O2P5zzSwYvRHhEKz7xjzwszyPOa+34yLfKSMRxyKnww2xAA2yWtUfAXQVqTDn+Co
 Sg9uGtchkhFGOiZ1Vq7OGRcjRDtm8wwWPMWHyIohcBlCeomAUaxCJfRQFB9mJO38
 8Jmdx6E9RmW49gr3yxYBohSUC7UN/RcOvu9we5yd6vO0OMJYiauZ2o8vFrX/h50+
 sQLOGKkXSQqIaDxoLMaJ3TC5XMyMxYTNwhUP+N3YNpPnVTor4Wcs+4zjYsGzzF58
 ucXOW+2Ho40wz8uOfLhPs7H6G5TC6h9bInaBDjySGVwcKZ7ZQmI=
 =78YS
 -----END PGP SIGNATURE-----

Merge tag 'hwmon-for-v5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:
 "The most notable fix is for the q54sj108a2 driver to let it actually
  instantiate.

  Also attribute fixes for pmbus/isl68137, pmbus/fsp-3y, and
  dell-smm-hwmon drivers"

* tag 'hwmon-for-v5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon/pmbus: (q54sj108a2) The PMBUS_MFR_ID is actually 6 chars instead of 5
  hwmon: (pmbus/isl68137) remove READ_TEMPERATURE_3 for RAA228228
  hwmon: (pmbus/fsp-3y) Fix FSP-3Y YH-5151E VOUT
  hwmon: (dell-smm-hwmon) Fix index values
2021-06-02 08:41:45 -10:00
Linus Torvalds 50f09a3dd5 Char/misc driver fixes for 5.13-rc3
Here is a big set of char/misc/other driver fixes for 5.13-rc3.
 
 The majority here is the fallout of the umn.edu re-review of all prior
 submissions.  That resulted in a bunch of reverts along with the
 "correct" changes made, such that there is no regression of any of the
 potential fixes that were made by those individuals.  I would like to
 thank the over 80 different developers who helped with the review and
 fixes for this mess.
 
 Other than that, there's a few habanna driver fixes for reported issues,
 and some dyndbg fixes for reported problems.
 
 All of these have been in linux-next for a while with no reported
 problems.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCYKZCBg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ynhRQCdGk6ri4oluyn/Z/2KAjvXDOmTmvgAn12VP42d
 S1Zmh4qRH2OWaLOBg7c2
 =qtxj
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH:
 "Here is a big set of char/misc/other driver fixes for 5.13-rc3.

  The majority here is the fallout of the umn.edu re-review of all prior
  submissions. That resulted in a bunch of reverts along with the
  "correct" changes made, such that there is no regression of any of the
  potential fixes that were made by those individuals. I would like to
  thank the over 80 different developers who helped with the review and
  fixes for this mess.

  Other than that, there's a few habanna driver fixes for reported
  issues, and some dyndbg fixes for reported problems.

  All of these have been in linux-next for a while with no reported
  problems"

* tag 'char-misc-5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (82 commits)
  misc: eeprom: at24: check suspend status before disable regulator
  uio_hv_generic: Fix another memory leak in error handling paths
  uio_hv_generic: Fix a memory leak in error handling paths
  uio/uio_pci_generic: fix return value changed in refactoring
  Revert "Revert "ALSA: usx2y: Fix potential NULL pointer dereference""
  dyndbg: drop uninformative vpr_info
  dyndbg: avoid calling dyndbg_emit_prefix when it has no work
  binder: Return EFAULT if we fail BINDER_ENABLE_ONEWAY_SPAM_DETECTION
  cdrom: gdrom: initialize global variable at init time
  brcmfmac: properly check for bus register errors
  Revert "brcmfmac: add a check for the status of usb_register"
  video: imsttfb: check for ioremap() failures
  Revert "video: imsttfb: fix potential NULL pointer dereferences"
  net: liquidio: Add missing null pointer checks
  Revert "net: liquidio: fix a NULL pointer dereference"
  media: gspca: properly check for errors in po1030_probe()
  Revert "media: gspca: Check the return value of write_bridge for timeout"
  media: gspca: mt9m111: Check write_bridge for timeout
  Revert "media: gspca: mt9m111: Check write_bridge for timeout"
  media: dvb: Add check on sp8870_readreg return
  ...
2021-05-20 06:31:52 -10:00
Gustavo A. R. Silva 58e31cf015 hwmon: (max6621) Fix fall-through warnings for Clang
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2021-05-17 19:50:37 -05:00
Gustavo A. R. Silva 3752445d79 hwmon: (corsair-cpro) Fix fall-through warnings for Clang
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Acked-by: Guenter Roeck <linux@roeck-us.net>
Marius Zachmann <mail@mariuszachmann.de>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2021-05-17 19:50:23 -05:00
Chu Lin f0fb26c456 hwmon/pmbus: (q54sj108a2) The PMBUS_MFR_ID is actually 6 chars instead of 5
The PMBUS_MFR_ID block is actually 6 chars for q54sj108a2.
/sys/bus/i2c/drivers/q54sj108a2_test# iotools smbus_read8 $BUS $ADDR 0x99
0x06

Tested: Devices are able to bind to the q54sj108a2 driver successfully.

Signed-off-by: Chu Lin <linchuyuan@google.com>
Link: https://lore.kernel.org/r/20210517222606.3457594-1-linchuyuan@google.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-17 16:02:05 -07:00
Grant Peltier 2a29db088c hwmon: (pmbus/isl68137) remove READ_TEMPERATURE_3 for RAA228228
The initial version of the RAA228228 datasheet claimed that the device
supported READ_TEMPERATURE_3 but not READ_TEMPERATURE_1. It has since been
discovered that the datasheet was incorrect. The RAA228228 does support
READ_TEMPERATURE_1 but does not support READ_TEMPERATURE_3.

Signed-off-by: Grant Peltier <grantpeltier93@gmail.com>
Fixes: 51fb91ed5a ("hwmon: (pmbus/isl68137) remove READ_TEMPERATURE_1 telemetry for RAA228228")
Link: https://lore.kernel.org/r/20210514211954.GA24646@raspberrypi
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-16 16:00:56 -07:00
Václav Kubernát c2a338c939 hwmon: (pmbus/fsp-3y) Fix FSP-3Y YH-5151E VOUT
After testing new YH-5151E devices, we found out that not all YH-5151E
work the same. The newly tested devices actually report vout correctly
in linear16 (even though they're still YH-5151E). We suspect that it is
because these new devices have a different firmware version, but that is
unconfirmed. The version cannot be queried through PMBus.

The compliant versions of YH-5151E report VOUT_MODE normally, so we turn
on the linear11 workaround only if VOUT_MODE doesn't report anything.

Signed-off-by: Václav Kubernát <kubernat@cesnet.cz>
Link: https://lore.kernel.org/r/20210513201110.313523-1-kubernat@cesnet.cz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-16 16:00:55 -07:00
Armin Wolf 35d470b5fb hwmon: (dell-smm-hwmon) Fix index values
When support for up to 10 temp sensors and for disabling automatic BIOS
fan control was added, noone updated the index values used for
disallowing fan support and fan type calls.
Fix those values.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210513154546.12430-1-W_Armin@gmx.de
Fixes: 1bb46a20e7 ("hwmon: (dell-smm) Support up to 10 temp sensors")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-16 16:00:55 -07:00
Greg Kroah-Hartman 99ae341767 Revert "hwmon: (lm80) fix a missing check of bus read in lm80 probe"
This reverts commit 9aa3aa15f4.

Because of recent interactions with developers from @umn.edu, all
commits from them have been recently re-reviewed to ensure if they were
correct or not.

Upon review, it was determined that this commit is not needed at all so
just revert it.  Also, the call to lm80_init_client() was not properly
handled, so if error handling is needed in the lm80_probe() function,
then it should be done properly, not half-baked like the commit being
reverted here did.

Cc: Kangjie Lu <kjlu@umn.edu>
Fixes: 9aa3aa15f4 ("hwmon: (lm80) fix a missing check of bus read in lm80 probe")
Cc: stable <stable@vger.kernel.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210503115736.2104747-5-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-13 17:30:01 +02:00
Guenter Roeck 3b5169c2eb hwmon: (adm9240) Fix writes into inX_max attributes
When converting the driver to use the devm_hwmon_device_register_with_info
API, the wrong register was selected when writing into inX_max attributes.
Fix it.

Fixes: 124b7e34a5 ("hwmon: (adm9240) Convert to devm_hwmon_device_register_with_info API")
Reported-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-12 18:53:11 -07:00
Andy Shevchenko 8370e5b093 hwmon: (ltc2992) Put fwnode in error case during ->probe()
In each iteration fwnode_for_each_available_child_node() bumps a reference
counting of a loop variable followed by dropping in on a next iteration,

Since in error case the loop is broken, we have to drop a reference count
by ourselves. Do it for port_fwnode in error case during ->probe().

Fixes: b0bd407e94 ("hwmon: (ltc2992) Add support")
Cc: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210510100136.3303142-1-andy.shevchenko@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-10 08:02:15 -07:00
Václav Kubernát 2d101db3e5 hwmon: (pmbus/fsp-3y) Fix FSP-3Y YH-5151E non-compliant vout encoding
I didn't properly test the driver for YH-5151E, so it was completely
broken. Firstly, the log/real mapping was incorrect in one case.
Secondly, PMBus specifies that output voltages should be in the linear16
encoding. However, the YH-5151E is non-compliant and uses linear11.
YM-2151E isn't affected by this. Fix this by converting the values
inside the read functions. linear16 gets the exponent from the VOUT_MODE
command. The device doesn't support it, so I have to manually supply the
value for it.

Both supported devices have now been tested to report correct vout
values.

Fixes: 1734b4135a ("hwmon: Add driver for fsp-3y PSUs and PDUs")
Signed-off-by: Václav Kubernát <kubernat@cesnet.cz>
Link: https://lore.kernel.org/r/20210429075337.110502-1-kubernat@cesnet.cz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-10 06:27:33 -07:00
Eddie James 5216dff22d hwmon: (occ) Fix poll rate limiting
The poll rate limiter time was initialized at zero. This breaks the
comparison in time_after if jiffies is large. Switch to storing the
next update time rather than the previous time, and initialize the
time when the device is probed.

Fixes: c10e753d43 ("hwmon (occ): Add sensor types and versions")
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20210429151336.18980-1-eajames@linux.ibm.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-10 06:27:33 -07:00
Wan Jiabing 726c945ab2 hwmon: (corsair-psu) Remove unneeded semicolons
Fix the following coccicheck warning:

./drivers/hwmon/corsair-psu.c:379:2-3: Unneeded semicolon

Remove unneeded semicolons.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Link: https://lore.kernel.org/r/20210427044219.7799-1-wanjiabing@vivo.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-10 06:27:33 -07:00
Linus Torvalds d8f9176b4e ACPI updates for 5.13-rc1
- Update ACPICA code in the kernel to upstream revision 20210331
    including the following changes:
 
    * Add parsing for IVRS IVHD 40h and device entry F0h (Alexander
      Monakov).
 
    * Add new CEDT table for CXL 2.0 and iASL support for it (Ben
      Widawsky, Bob Moore).
 
    * NFIT: add Location Cookie field (Bob Moore).
 
    * HMAT: add new fields/flags (Bob Moore).
 
    * Add new flags in SRAT (Bob Moore).
 
    * PMTT: add new fields/structures (Bob Moore).
 
    * Add CSI2Bus resource template (Bob Moore).
 
    * iASL: Decode subtable type field for VIOT (Bob Moore).
 
    * Fix various typos and spelling mistakes (Colin Ian King).
 
    * Add new predefined objects _BPC, _BPS, and _BPT (Erik Kaneda).
 
    * Add USB4 capabilities UUID (Erik Kaneda).
 
    * Add CXL ACPI device ID and _CBR object (Erik Kaneda).
 
    * MADT: add Multiprocessor Wakeup Structure (Erik Kaneda).
 
    * PCCT: add support for subtable type 5 (Erik Kaneda).
 
    * PPTT: add new version of subtable type 1 (Erik Kaneda).
 
    * Add SDEV secure access components (Erik Kaneda).
 
    * Add support for PHAT table (Erik Kaneda).
 
    * iASL: Add definitions for the VIOT table (Jean-Philippe Brucker).
 
    * acpisrc: Add missing conversion for VIOT support (Jean-Philippe
      Brucker).
 
    * IORT: Updates for revision E.b (Shameer Kolothum).
 
  - Rearrange message printing in ACPI-related code to avoid using the
    ACPICA's internal message printing macros outside ACPICA and do
    some related code cleanups (Rafael Wysocki).
 
  - Modify the device enumeration code to turn off all of the unused
    ACPI power resources at the end (Rafael Wysocki).
 
  - Change the ACPI power resources handling code to turn off unused
    ACPI power resources without checking their status which should
    not be necessary by the spec (Rafael Wysocki).
 
  - Add empty stubs for CPPC-related functions to be used when
    CONFIG_ACPI_CPPC_LIB is not set (Rafael Wysocki).
 
  - Simplify device enumeration code (Rafael Wysocki).
 
  - Change device enumeration code to use match_string() for string
    matching (Andy Shevchenko).
 
  - Modify irqresource_disabled() to retain the resouce flags that
    have been set already (Angela Czubak).
 
  - Add native backlight whitelist entry for GA401/GA502/GA503 (Luke
    Jones).
 
  - Modify the ACPI backlight driver to let the native backlight
    handling take over on hardware-reduced systems (Hans de Goede).
 
  - Introduce acpi_dev_get() and switch over the ACPI core code to
    using it (Andy Shevchenko).
 
  - Use kobj_attribute as callback argument instead of a local struct
    type in the CPPC linrary code (Nathan Chancellor).
 
  - Drop unneeded initializatio of a static variable from the ACPI
    processor driver (Tian Tao).
 
  - Drop unnecessary local variable assignment from the ACPI APEI
    code (Colin Ian King).
 
  - Document for_each_acpi_dev_match() macro (Andy Shevchenko).
 
  - Address assorted coding style issues in multiple places (Xiaofei
    Tan).
 
  - Capitalize TLAs in a few comments (Andy Shevchenko).
 
  - Correct assorted typos in comments (Tom Saeger).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmCHAL8SHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxZroQAIdFsRUTKmm8st9sdfEtF3QHLS3/EV2x
 1GlkL+3yE/WuEFXNd0mAv0MTcV2sNMKGd5oz74zLkciPC2dNR4168Ni6DhGSoELM
 0ZMOAu9E12Nyq7/1FdWalLQprtR8OuLVwgC2VckK+f//4vzpZ+6PtGMwAwtImSHK
 m3WRPimVbgOVJ1UWZjsfIm7kLBD4o4oCx0pdeEl77q0oQKmMdcByUh2YnjwKzFnP
 9zqV+SCi3HL4w67HO/uMe7x8isNyWONYXVqOvOkgXi7PeoX9v0XiWSCJ0KnAvbI1
 PZokJT8pTrKnFyL3zJS6pU/ZHj7ikFiTc+MfyyPcYRJZ5nBvRjqHKoPOtZ9yfU6n
 jgt/u3REhqwnHy0ikS8HsP+PWnAJF1Re3sNVvIMnX6XxTIndHCXZEoeldfeC23S9
 PmzGA0//iPngiYaOVM5BxIjRi2nRBHlVvzSIACICXDcszA81RHePFIzfjUgW3elp
 v6kAhkrXYajqrDb7NuvY4MTuuBo8w3q2xWJGu5VlDkNOblM0AExRhXmvp1RW0kL7
 +mi5X6xBFEB9M6hEoWKnleaZTXTlFYBreKsMPEEP7N7a5+UZRPedcjX1PflCkOB3
 uL5p/+x3br1fkDyK0P7wFf3VqiBXuwFajEdCmyHnizpD6m0oWC6pv9PUGYUCneJ1
 JGH5X/3Uu33D
 =5fuB
 -----END PGP SIGNATURE-----

Merge tag 'acpi-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These update the ACPICA code in the kernel to the most recent upstream
  revision including (but not limited to) new material introduced in the
  6.4 version of the spec, update message printing in the ACPI-related
  code, address a few issues and clean up code in a number of places.

  Specifics:

   - Update ACPICA code in the kernel to upstream revision 20210331
     including the following changes:

      * Add parsing for IVRS IVHD 40h and device entry F0h (Alexander
        Monakov).

      * Add new CEDT table for CXL 2.0 and iASL support for it (Ben
        Widawsky, Bob Moore).

      * NFIT: add Location Cookie field (Bob Moore).

      * HMAT: add new fields/flags (Bob Moore).

      * Add new flags in SRAT (Bob Moore).

      * PMTT: add new fields/structures (Bob Moore).

      * Add CSI2Bus resource template (Bob Moore).

      * iASL: Decode subtable type field for VIOT (Bob Moore).

      * Fix various typos and spelling mistakes (Colin Ian King).

      * Add new predefined objects _BPC, _BPS, and _BPT (Erik Kaneda).

      * Add USB4 capabilities UUID (Erik Kaneda).

      * Add CXL ACPI device ID and _CBR object (Erik Kaneda).

      * MADT: add Multiprocessor Wakeup Structure (Erik Kaneda).

      * PCCT: add support for subtable type 5 (Erik Kaneda).

      * PPTT: add new version of subtable type 1 (Erik Kaneda).

      * Add SDEV secure access components (Erik Kaneda).

      * Add support for PHAT table (Erik Kaneda).

      * iASL: Add definitions for the VIOT table (Jean-Philippe
        Brucker).

      * acpisrc: Add missing conversion for VIOT support (Jean-Philippe
        Brucker).

      * IORT: Updates for revision E.b (Shameer Kolothum).

   - Rearrange message printing in ACPI-related code to avoid using the
     ACPICA's internal message printing macros outside ACPICA and do
     some related code cleanups (Rafael Wysocki).

   - Modify the device enumeration code to turn off all of the unused
     ACPI power resources at the end (Rafael Wysocki).

   - Change the ACPI power resources handling code to turn off unused
     ACPI power resources without checking their status which should not
     be necessary by the spec (Rafael Wysocki).

   - Add empty stubs for CPPC-related functions to be used when
     CONFIG_ACPI_CPPC_LIB is not set (Rafael Wysocki).

   - Simplify device enumeration code (Rafael Wysocki).

   - Change device enumeration code to use match_string() for string
     matching (Andy Shevchenko).

   - Modify irqresource_disabled() to retain the resouce flags that have
     been set already (Angela Czubak).

   - Add native backlight whitelist entry for GA401/GA502/GA503 (Luke
     Jones).

   - Modify the ACPI backlight driver to let the native backlight
     handling take over on hardware-reduced systems (Hans de Goede).

   - Introduce acpi_dev_get() and switch over the ACPI core code to
     using it (Andy Shevchenko).

   - Use kobj_attribute as callback argument instead of a local struct
     type in the CPPC linrary code (Nathan Chancellor).

   - Drop unneeded initializatio of a static variable from the ACPI
     processor driver (Tian Tao).

   - Drop unnecessary local variable assignment from the ACPI APEI code
     (Colin Ian King).

   - Document for_each_acpi_dev_match() macro (Andy Shevchenko).

   - Address assorted coding style issues in multiple places (Xiaofei
     Tan).

   - Capitalize TLAs in a few comments (Andy Shevchenko).

   - Correct assorted typos in comments (Tom Saeger)"

* tag 'acpi-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (68 commits)
  ACPI: video: use native backlight for GA401/GA502/GA503
  ACPI: APEI: remove redundant assignment to variable rc
  ACPI: utils: Capitalize abbreviations in the comments
  ACPI: utils: Document for_each_acpi_dev_match() macro
  ACPI: bus: Introduce acpi_dev_get() and reuse it in ACPI code
  ACPI: scan: Utilize match_string() API
  resource: Prevent irqresource_disabled() from erasing flags
  ACPI: CPPC: Replace cppc_attr with kobj_attribute
  ACPI: scan: Call acpi_get_object_info() from acpi_set_pnp_ids()
  ACPI: scan: Drop sta argument from acpi_init_device_object()
  ACPI: scan: Drop sta argument from acpi_add_single_object()
  ACPI: scan: Rearrange checks in acpi_bus_check_add()
  ACPI: scan: Fold acpi_bus_type_and_status() into its caller
  ACPI: video: Check LCD flag on ACPI-reduced-hardware devices
  ACPI: utils: Add acpi_reduced_hardware() helper
  ACPI: dock: fix some coding style issues
  ACPI: sysfs: fix some coding style issues
  ACPI: PM: add a missed blank line after declarations
  ACPI: custom_method: fix a coding style issue
  ACPI: CPPC: fix some coding style issues
  ...
2021-04-26 15:03:23 -07:00
Linus Torvalds 47080f2286 hwmon updates for v5.13
The most notable change is the removal of the amd_energy driver. It was
 rendered all but unusable by making its attributes privileged-only to work
 around a security issue. A suggested remedy was rejected by AMD, so the
 only real solution was to remove the driver. For the future, we'll have
 to make sure that no privileged-access-only drivers are accepted into the
 hwmon subsystem in the first place. The hwmon ABI document was updated
 accordingly.
 
 Other changes:
 
 PMBus drivers:
 - Added driver for MAX15301
 - Added driver for BluTek BPA-RS600
 - Added driver for fsp-3y PSUs and PDUs
 - Added driver for Infineon IR36021
 - Added driver for ST STPDDC60
 - Added support for TI TPS53676 to tps53679 driver
 - Introduced PMBUS symbol namespace
   This was made necessary by a suggestion to use its exported functions
   from outside the hwmon subsystem.
 - Minor improvements and bug fixes
 
 New drivers:
 - Driver for NZXT Kraken X42/X52/X62/X72
 
 Driver enhancements:
 - Added support for Intel D5005 to intel-m10-bmc-hwmon driver
 - Added support for NCT6686D to nct6683 driver
 
 Other:
 - Converted sch5627 and amd9240 drivers to hwmon_device_register_with_info()
 - Added support for fan drawers capability and present registers to mlxreg-fan
   driver
 - Added Dell Latitude E7440 to fan control whitelist in dell-smm driver
 - Replaced snprintf in show functions with sysfs_emit
   Done with coccinelle script for all drivers to preempt endless per-driver
   submissions of the same change.
 - Use kobj_to_dev()
   Another coccinelle based change to preempt endless per-driver submissions
   of the same change.
 - Various minor fixes and improvements
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmCG+0QACgkQyx8mb86f
 mYEpXw/8Dv4d+oQAPpxt1MrcGIORnUPWuby92UBtgJWnf7x1nE3NTN7Z1DYDjO6F
 +oLSHtHZCUa9x7i7dbnEy5W+HOIiR8RQMOCZB6dDsZUFdUwbS683X/DrWHzJByPL
 Vm9m2KKWyarmiE6Ke5oKko9KICx/Q4r640sPju/exhu2qd9RA1A8yKmSmOb6+33m
 Yhu+nZjh2Qpc1KoDSI/lXTmgzGpw3FdVUBMiGXMuFhihjWnnSiZbm1LmpsChkMCl
 HGTOt2yZJorKbtyeclzgbVgrXbcP8/jwvSMfbc/0AvMHB/rsMSJWXqCLngvzYO9t
 0pcsxNDqzHSPMq0aBBTSylxpnWxCUwic1luXcA5zwzOhtsndg6OzGnYAyCKEx4Fu
 TbJClzKFE89qIOkGmd20lGp8FR0ZtpJsCGOPk0epyRzfHQYYtGPw65wssPDeYZXD
 RvY7YQGNh5fnRmjlSc6lngp+HLWTuirjJkgD8tYJyv5lUixBNAY4YRl+/wb8lju0
 5Q5lZWSfhu/Gn2qLW0iqBeevgxP6PIUMmUnYQ4BnqYlbI8ox3KrZvATPf9QZGrV/
 FpcsST0bi4wjOKZKvdKJidieK+J3KpA26PeOlnyD3nhRHA4kEoU92KwsccPZg7hz
 XY8MFXqy3+scOVXAb0ul1XvLn+PkuLazh05x5zfg2CQcw1gc0+E=
 =alEZ
 -----END PGP SIGNATURE-----

Merge tag 'hwmon-for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:
 "The most notable change is the removal of the amd_energy driver. It
  was rendered all but unusable by making its attributes privileged-only
  to work around a security issue. A suggested remedy was rejected by
  AMD, so the only real solution was to remove the driver. For the
  future, we'll have to make sure that no privileged-access-only drivers
  are accepted into the hwmon subsystem in the first place. The hwmon
  ABI document was updated accordingly.

  Other changes:

  PMBus drivers:
   - Added driver for MAX15301
   - Added driver for BluTek BPA-RS600
   - Added driver for fsp-3y PSUs and PDUs
   - Added driver for Infineon IR36021
   - Added driver for ST STPDDC60
   - Added support for TI TPS53676 to tps53679 driver
   - Introduced PMBUS symbol namespace. This was made necessary by a
     suggestion to use its exported functions from outside the hwmon
     subsystem.
   - Minor improvements and bug fixes

  New drivers:
   - Driver for NZXT Kraken X42/X52/X62/X72

  Driver enhancements:
   - Added support for Intel D5005 to intel-m10-bmc-hwmon driver
   - Added support for NCT6686D to nct6683 driver

  Other:
   - Converted sch5627 and amd9240 drivers to
     hwmon_device_register_with_info()
   - Added support for fan drawers capability and present registers to
     mlxreg-fan driver
   - Added Dell Latitude E7440 to fan control whitelist in dell-smm
     driver
   - Replaced snprintf in show functions with sysfs_emit. Done with
     coccinelle script for all drivers to preempt endless per-driver
     submissions of the same change.
   - Use kobj_to_dev().  Another coccinelle based change to preempt
     endless per-driver submissions of the same change.
   - Various minor fixes and improvements"

* tag 'hwmon-for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (38 commits)
  hwmon: Remove amd_energy driver
  hwmon: Clarify scope of attribute access
  hwmon: (pmbus) Introduce PMBUS symbol namespace
  hwmon: (pmbus) Add pmbus driver for MAX15301
  hwmon: (sch5627) Remove unnecessary error path
  hwmon: (sch5627) Use devres function
  hwmon: (pmbus/pxe1610) don't bail out when not all pages are active
  hwmon: Add driver for fsp-3y PSUs and PDUs
  hwmon: (intel-m10-bmc-hwmon) add sensor support of Intel D5005 card
  hwmon: (sch5627) Split sch5627_update_device()
  hwmon: (sch5627) Convert to hwmon_device_register_with_info()
  hwmon: (nct6683) remove useless function
  hwmon: (dell-smm) Add Dell Latitude E7440 to fan control whitelist
  MAINTAINERS: Add keyword pattern for hwmon registration functions
  hwmon: (mlxreg-fan) Add support for fan drawers capability and present registers
  hwmon: (pmbus/tps53679) Add support for TI TPS53676
  dt-bindings: Add trivial device entry for TPS53676
  hwmon: (ftsteutates) Rudimentary typo fixes
  hwmon: (pmbus) Add driver for BluTek BPA-RS600
  dt-bindings: Add vendor prefix and trivial device for BluTek BPA-RS600
  ...
2021-04-26 14:59:21 -07:00
Linus Torvalds 37f00ab4a0 ARM: SoC drivers for v5.13
Updates for SoC specific drivers include a few subsystems that
 have their own maintainers but send them through the soc tree:
 
 TEE/OP-TEE:
  -  Add tracepoints around calls to secure world
 
 Memory controller drivers:
  - Minor fixes for Renesas, Exynos, Mediatek and Tegra platforms
  - Add debug statistics to Tegra20 memory controller
  - Update Tegra bindings and convert to dtschema
 
 ARM SCMI Firmware:
  - Support for modular SCMI protocols and vendor specific extensions
  - New SCMI IIO driver
  - Per-cpu DVFS
 
 The other driver changes are all from the platform maintainers
 directly and reflect the drivers that don't fit into any other
 subsystem as well as treewide changes for a particular platform.
 
 SoCFPGA:
  - Various cleanups contributed by Krzysztof Kozlowski
 
 Mediatek:
  - add MT8183 support to mutex driver
  - MMSYS: use per SoC array to describe the possible routing
  - add MMSYS support for MT8183 and MT8167
  - add support for PMIC wrapper with integrated arbiter
  - add support for MT8192/MT6873
 
 Tegra:
  - Bug fixes to PMC and clock drivers
 
 NXP/i.MX:
  - Update SCU power domain driver to keep console domain power on.
  - Add missing ADC1 power domain to SCU power domain driver.
  - Update comments for single global power domain in SCU power domain
    driver.
  - Add i.MX51/i.MX53 unique id support to i.MX SoC driver.
 
 NXP/FSL SoC driver updates for v5.13
  - Add ACPI support for RCPM driver
  - Use generic io{read,write} for QE drivers after performance optimized
    for PowerPC
  - Fix QBMAN probe to cleanup HW states correctly for kexec
  - Various cleanup and style fix for QBMAN/QE/GUTS drivers
 
 OMAP:
  - Preparation to use devicetree for genpd
  - ti-sysc needs iorange check improved when the interconnect target module
    has no control registers listed
  - ti-sysc needs to probe l4_wkup and l4_cfg interconnects first to avoid
    issues with missing resources and unnecessary deferred probe
  - ti-sysc debug option can now detect more devices
  - ti-sysc now warns if an old incomplete devicetree data is found as we
    now rely on it being complete for am3 and 4
  - soc init code needs to check for prcm and prm nodes for omap4/5 and dra7
  - omap-prm driver needs to enable autoidle retention support for omap4
  - omap5 clocks are missing gpmc and ocmc clock registers
  - pci-dra7xx now needs to use builtin_platform_driver instead of using
    builtin_platform_driver_probe for deferred probe to work
 
 Raspberry Pi:
  - Fix-up all RPi firmware drivers so as for unbind to happen in an
    orderly fashion
  - Support for RPi's PoE hat PWM bus
 
 Qualcomm
  - Improved detection for SCM calling conventions
  - Support for OEM specific wifi firmware path
  - Added drivers for SC7280/SM8350: RPMH, LLCC< AOSS QMP
 
 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmCC2JwACgkQmmx57+YA
 GNkgRg//cBtq2NyDbjiNABxFSkmGCfcc0w0C2wjVzr4cfg6BLTbuvvlpZxI912pu
 P1G2sbsdfQJ8sSeIyZos+PilWK0zHrqlaGZfKI19US45dMjpteDBgsPd7wNZwBjQ
 jbops3YLjztZK1HpY4dIdvMnfxt7yRqhBWaTbPuCwQ35c5KsOM8NHB3cP3BUINWK
 x1uuBCv9svppzwdDiPxneV93WKEzabOUo+WBMPyh5vnyvmW17Iif4BA/VKQxzymm
 mWUi8HHpKBpvntJOKwAD2hnLAdpR3SwX20SLOpyLhnJMotbzNUEqq3LdRxDNPdHk
 ry+rarJ78JGlYfpcfegf2bLf5ITNMfOyRGkjtzeYpcZIXPjufOg9DA9YtAy37k0u
 L0T/9gQ+tQ01WGMca77OyUtIqJKdblZrQMfuH/yGlR99bqFQMV7rNc7GNlX1MXp/
 zw4aOYrRWGtGEeAjx5JJWcYydvMSJpCrqxTz3YhgeJECHB2iA6YkV3NROR4TLW//
 tfxaKqxR/KmSqE6hoVOAuuQ0BLXNlql/+4EE6MKsAOBiKPJclvmJg4CyuY8G21ev
 9Su0zJnXMzai7gNu32v1pizGj26+AOhxCEgAG0mGgk2jlQSn24CKgm5e7kCUewcF
 j/1XksNPT95v/K8MsLpXe5xGvF3jhA1BlFfvjJNZOrcZywBXRxg=
 =iidq
 -----END PGP SIGNATURE-----

Merge tag 'arm-drivers-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC driver updates from Arnd Bergmann:
 "Updates for SoC specific drivers include a few subsystems that have
  their own maintainers but send them through the soc tree:

  TEE/OP-TEE:
   - Add tracepoints around calls to secure world

  Memory controller drivers:
   - Minor fixes for Renesas, Exynos, Mediatek and Tegra platforms
   - Add debug statistics to Tegra20 memory controller
   - Update Tegra bindings and convert to dtschema

  ARM SCMI Firmware:
   - Support for modular SCMI protocols and vendor specific extensions
   - New SCMI IIO driver
   - Per-cpu DVFS

  The other driver changes are all from the platform maintainers
  directly and reflect the drivers that don't fit into any other
  subsystem as well as treewide changes for a particular platform.

  SoCFPGA:
   - Various cleanups contributed by Krzysztof Kozlowski

  Mediatek:
   - add MT8183 support to mutex driver
   - MMSYS: use per SoC array to describe the possible routing
   - add MMSYS support for MT8183 and MT8167
   - add support for PMIC wrapper with integrated arbiter
   - add support for MT8192/MT6873

  Tegra:
   - Bug fixes to PMC and clock drivers

  NXP/i.MX:
   - Update SCU power domain driver to keep console domain power on.
   - Add missing ADC1 power domain to SCU power domain driver.
   - Update comments for single global power domain in SCU power domain
     driver.
   - Add i.MX51/i.MX53 unique id support to i.MX SoC driver.

  NXP/FSL SoC driver updates for v5.13
   - Add ACPI support for RCPM driver
   - Use generic io{read,write} for QE drivers after performance
     optimized for PowerPC
   - Fix QBMAN probe to cleanup HW states correctly for kexec
   - Various cleanup and style fix for QBMAN/QE/GUTS drivers

  OMAP:
   - Preparation to use devicetree for genpd
   - ti-sysc needs iorange check improved when the interconnect target
     module has no control registers listed
   - ti-sysc needs to probe l4_wkup and l4_cfg interconnects first to
     avoid issues with missing resources and unnecessary deferred probe
   - ti-sysc debug option can now detect more devices
   - ti-sysc now warns if an old incomplete devicetree data is found as
     we now rely on it being complete for am3 and 4
   - soc init code needs to check for prcm and prm nodes for omap4/5 and
     dra7
   - omap-prm driver needs to enable autoidle retention support for
     omap4
   - omap5 clocks are missing gpmc and ocmc clock registers
   - pci-dra7xx now needs to use builtin_platform_driver instead of
     using builtin_platform_driver_probe for deferred probe to work

  Raspberry Pi:
   - Fix-up all RPi firmware drivers so as for unbind to happen in an
     orderly fashion
   - Support for RPi's PoE hat PWM bus

  Qualcomm
   - Improved detection for SCM calling conventions
   - Support for OEM specific wifi firmware path
   - Added drivers for SC7280/SM8350: RPMH, LLCC< AOSS QMP"

* tag 'arm-drivers-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (165 commits)
  soc: aspeed: fix a ternary sign expansion bug
  memory: mtk-smi: Add device-link between smi-larb and smi-common
  memory: samsung: exynos5422-dmc: handle clk_set_parent() failure
  memory: renesas-rpc-if: fix possible NULL pointer dereference of resource
  clk: socfpga: fix iomem pointer cast on 64-bit
  soc: aspeed: Adapt to new LPC device tree layout
  pinctrl: aspeed-g5: Adapt to new LPC device tree layout
  ipmi: kcs: aspeed: Adapt to new LPC DTS layout
  ARM: dts: Remove LPC BMC and Host partitions
  dt-bindings: aspeed-lpc: Remove LPC partitioning
  soc: fsl: enable acpi support in RCPM driver
  soc: qcom: mdt_loader: Detect truncated read of segments
  soc: qcom: mdt_loader: Validate that p_filesz < p_memsz
  soc: qcom: pdr: Fix error return code in pdr_register_listener
  firmware: qcom_scm: Fix kernel-doc function names to match
  firmware: qcom_scm: Suppress sysfs bind attributes
  firmware: qcom_scm: Workaround lack of "is available" call on SC7180
  firmware: qcom_scm: Reduce locking section for __get_convention()
  firmware: qcom_scm: Make __qcom_scm_is_call_available() return bool
  Revert "soc: fsl: qe: introduce qe_io{read,write}* wrappers"
  ...
2021-04-26 12:11:52 -07:00
Linus Torvalds 8900d92fd6 Staging/IIO driver updates for 5.13-rc1
Here is the big set of staging and IIO driver updates for 5.13-rc1.
 
 Lots of little churn in here, and some larger churn as well.  Major
 things are:
 	- removal of wimax drivers, no one has this hardware anymore for
 	  this failed "experiment".
 	- removal of the Google gasket driver, turns out no one wanted
 	  to maintain it or cares about it anymore, so they asked for it
 	  to be removed.
 	- comedi finally moves out of the staging directory into
 	  drivers/comedi/  This is one of the oldest kernel subsystems
 	  around, being created in the 2.0 kernel days, and was one of
 	  the first things added to drivers/staging/ when that was
 	  created over 15 years ago.  It should have been moved out of
 	  staging a long time ago, it's well maintained and used by
 	  loads of different devices in the real world every day.  Nice
 	  to see this finally happen.
 	- so many tiny coding style cleanups it's not funny.  Perfect
 	  storm of at least 2 different intern project application
 	  deadlines combined to provide a huge number of new
 	  contributions in this area from people learning how to do
 	  kernel development.  Great job to everyone involved here.
 
 There's also the normal updates for IIO drivers with new IIO drivers and
 updates all over that subsystem.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCYIa1zw8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ykfMACgq/Qj9n6NO/P4BX55XWjRkjOmxxwAoKrYEWkG
 fIdLmhh4FGWkxaJO3Izf
 =PCXb
 -----END PGP SIGNATURE-----

Merge tag 'staging-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO driver updates from Greg KH:
 "Here is the big set of staging and IIO driver updates for 5.13-rc1.

  Lots of little churn in here, and some larger churn as well. Major
  things are:

   - removal of wimax drivers, no one has this hardware anymore for this
     failed "experiment".

   - removal of the Google gasket driver, turns out no one wanted to
     maintain it or cares about it anymore, so they asked for it to be
     removed.

   - comedi finally moves out of the staging directory into drivers/comedi

     This is one of the oldest kernel subsystems around, being created
     in the 2.0 kernel days, and was one of the first things added to
     drivers/staging/ when that was created over 15 years ago.

     It should have been moved out of staging a long time ago, it's well
     maintained and used by loads of different devices in the real world
     every day. Nice to see this finally happen.

   - so many tiny coding style cleanups it's not funny.

     Perfect storm of at least 2 different intern project application
     deadlines combined to provide a huge number of new contributions in
     this area from people learning how to do kernel development. Great
     job to everyone involved here.

  There's also the normal updates for IIO drivers with new IIO drivers
  and updates all over that subsystem.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (907 commits)
  staging: octeon: Use 'for_each_child_of_node'
  Staging: rtl8723bs: rtw_xmit: fixed tabbing issue
  staging: rtl8188eu: remove unused function parameters
  staging: rtl8188eu: cmdThread is a task_struct
  staging: rtl8188eu: remove constant variable and dead code
  staging: rtl8188eu: change bLeisurePs' type to bool
  staging: rtl8723bs: remove empty #ifdef block
  staging: rtl8723bs: remove unused DBG_871X_LEVEL macro declarations
  staging: rtl8723bs: split too long line
  staging: rtl8723bs: fix indentation in if block
  staging: rtl8723bs: fix code indent issue
  staging: rtl8723bs: replace DBG_871X_LEVEL logs with netdev_*()
  staging: rtl8192e: indent statement properly
  staging: rtl8723bs: Remove led_blink_hdl() and everything related
  staging: comedi: move out of staging directory
  staging: rtl8723bs: remove sdio_drv_priv structure
  staging: rtl8723bs: remove unused argument in function
  staging: rtl8723bs: remove DBG_871X_SEL_NL macro declaration
  staging: rtl8723bs: replace DBG_871X_SEL_NL with netdev_dbg()
  staging: rtl8723bs: fix indentation issue introduced by long line split
  ...
2021-04-26 11:14:21 -07:00
Guenter Roeck 9049572fb1 hwmon: Remove amd_energy driver
Commit 60268b0e82 ("hwmon: (amd_energy) modify the visibility of
the counters") restricted visibility of AMD energy counters to work
around a side-channel attack using energy data to determine which
instructions are executed. The attack is described in 'PLATYPUS:
Software-based Power Side-Channel Attacks on x86'. It relies on quick
and accurate energy readings.

This change made the counters provided by the amd_energy driver
effectively unusable for non-provileged users. However, unprivileged
read access is the whole point of hardware monitoring attributes.

An attempt to remedy the situation by limiting and randomizing access
to chip registers was rejected by AMD. Since the driver is for all
practical purposes unusable, remove it.

Cc: Naveen Krishna Chatradhi <nchatrad@amd.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:52:08 -07:00
Guenter Roeck b94ca77eea hwmon: (pmbus) Introduce PMBUS symbol namespace
Exported pmbus symbols are only supposed to be used from PMBus code.
Introduce PMBUS symbol namespace to prevent misuse from other code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Erik Rosen 1e4063329f hwmon: (pmbus) Add pmbus driver for MAX15301
Add pmbus driver support for Maxim MAX15301 InTune Automatically
Compensated Digital PoL Controller with Driver and PMBus Telemetry

Even though the specification does not specifically mention it,
extensive empirical testing has revealed that auto-detection of
limit-registers will fail in a random fashion unless the delay
parameter is set to above about 80us. The default delay is set
to 100us to include some safety margin.

This patch is tested on a Flex BMR461 converter module.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Link: https://lore.kernel.org/r/20210419101251.24840-1-erik.rosen@metormote.com
[groeck: Added rationale for delay to driver header]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Armin Wolf bab10bf90a hwmon: (sch5627) Remove unnecessary error path
Calling remove() on error whould have only unregistered
the watchdog, and since a failure in registering him
is considered non-fatal and happens last, remove the
error path and return the error codes directly.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210417210920.15496-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Armin Wolf 93a6fb2c91 hwmon: (sch5627) Use devres function
Use devm_hwmon_device_register_with_info() and remove hwmon_dev
from sch5627_data struct as it is not needed anymore.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210417210920.15496-2-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Paul Fertser f025314306 hwmon: (pmbus/pxe1610) don't bail out when not all pages are active
Certain VRs might be configured to use only the first output channel and
so the mode for the second will be 0. Handle this gracefully.

Fixes: b9fa0a3acf ("hwmon: (pmbus/core) Add support for vid mode detection per page bases")
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Link: https://lore.kernel.org/r/20210416102926.13614-1-fercerpav@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Václav Kubernát 1734b4135a hwmon: Add driver for fsp-3y PSUs and PDUs
This patch adds support for these devices:
- YH-5151E - the PDU
- YM-2151E - the PSU

The device datasheet says that the devices support PMBus 1.2, but in my
testing, a lot of the commands aren't supported and if they are, they
sometimes behave strangely or inconsistently. For example, writes to the
PAGE command requires using PEC, otherwise the write won't work and the
page won't switch, even though, the standard says that PEC is optional.
On the other hand, writes to SMBALERT don't require PEC. Because of
this, the driver is mostly reverse engineered with the help of a tool
called pmbus_peek written by David Brownell (and later adopted by my
colleague Jan Kundrát).

The device also has some sort of a timing issue when switching pages,
which is explained further in the code.

Because of this, the driver support is limited. It exposes only the
values that have been tested to work correctly.

Signed-off-by: Václav Kubernát <kubernat@cesnet.cz>
Link: https://lore.kernel.org/r/20210414080019.3530794-1-kubernat@cesnet.cz
[groeck: Fixed up "missing braces around initializer" from 0-day]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Matthew Gerlach 25b000a80b hwmon: (intel-m10-bmc-hwmon) add sensor support of Intel D5005 card
Like the Intel N3000 card, the Intel D5005 has a MAX10 based
BMC.  This commit adds support for the D5005 sensors that are
monitored by the MAX10 BMC.

Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Signed-off-by: Russ Weight <russell.h.weight@linux.intel.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20210413225835.459662-3-matthew.gerlach@linux.intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Armin Wolf 790ac8fab1 hwmon: (sch5627) Split sch5627_update_device()
An error in sch5627_update_device() could cause sch5627_read()
to fail even if the error did not affect the target sensor type.
Split sch5627_update_device() to prevent that.

Tested on a Fujitsu Esprimo P720.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210411164225.11967-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Armin Wolf e7e0b466a8 hwmon: (sch5627) Convert to hwmon_device_register_with_info()
hwmon_device_register() is deprecated.
Convert driver to use hwmon_device_register_with_info() and
remove sysfs attributes which are now being handled by the
hwmon subsystem.

Channel handling was inspired by corsair-cpro.

Tested on a Fujitsu Esprimo P720.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210411164225.11967-2-W_Armin@gmx.de
[groeck: Replaced 0 with NULL]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Jiapeng Chong c3dd4b7d1e hwmon: (nct6683) remove useless function
Fix the following clang warning:

drivers/hwmon/nct6683.c:491:19: warning: unused function 'in_to_reg'
[-Wunused-function].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/1618293770-55307-1-git-send-email-jiapeng.chong@linux.alibaba.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Sebastian Oechsle 807b8c29db hwmon: (dell-smm) Add Dell Latitude E7440 to fan control whitelist
Allow manual PWM control on Dell Latitude E7440.

Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210411095741.zmllsuc7pevdipvy@icloud.com
Signed-off-by: Sebastian Oechsle <setboolean@icloud.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Vadim Pasternak f7bf7eb2d7 hwmon: (mlxreg-fan) Add support for fan drawers capability and present registers
Add support for fan drawer's capability and present registers in order
to set mapping between the fan drawers and tachometers. Some systems
are equipped with fan drawers with one tachometer inside. Others with
fan drawers with several tachometers inside. Using present register
along with tachometer-to-drawer mapping allows to skip reading missed
tachometers and expose input for them as zero, instead of exposing
fault code returned by hardware.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20210322172237.2213584-1-vadimp@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Erik Rosen cb3d37b590 hwmon: (pmbus/tps53679) Add support for TI TPS53676
Add support for TI TPS53676 controller to the tps53679 pmbus driver

The driver uses the USER_DATA_03 register to figure out how many phases
are enabled and to which channel they are assigned, and sets the number
of pages and phases accordingly.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Link: https://lore.kernel.org/r/20210322193734.75127-3-erik.rosen@metormote.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Bhaskar Chowdhury 73a76220e4 hwmon: (ftsteutates) Rudimentary typo fixes
s/Temprature/Temperature/
s/revsion/revision/

Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20210323043438.1321903-1-unixbhaskar@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Chris Packham 15b2703e5e hwmon: (pmbus) Add driver for BluTek BPA-RS600
The BPA-RS600 is a compact 600W AC to DC removable power supply module.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210317040231.21490-3-chris.packham@alliedtelesis.co.nz
[groeck: Added bpa-rs600 to index.rst]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Guenter Roeck 1f4d4af4d7 hwmon: replace snprintf in show functions with sysfs_emit
coccicheck complains about the use of snprintf() in sysfs
show functions.

drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf

This results in a large number of patch submissions. Fix it all in
one go using the following coccinelle rules. Use sysfs_emit instead
of scnprintf or sprintf since that makes more sense.

@depends on patch@
identifier show, dev, attr, buf;
@@

ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
	<...
  return
-		snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+		sysfs_emit(buf,
		...);
	...>
}

@depends on patch@
identifier show, dev, attr, buf, rc;
@@

ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
	<...
  rc =
-		snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+		sysfs_emit(buf,
		...);
	...>
}

While at it, remove unnecessary braces and as well as unnecessary
else after return statements to address checkpatch warnings in the
resulting patch.

Cc: Zihao Tang <tangzihao1@hisilicon.com>
Cc: Jay Fang <f.fangjian@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Chris Packham f807e8be46 hwmon: (pmbus) Replace - with _ in device names before registration
The hwmon sysfs ABI requires that the `name` property doesn't include
any dashes. But when the pmbus code picks the name up from the device
tree it quite often does. Replace '-' with '_' before registering the
device.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210317040231.21490-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Jonas Malaco 82e3430dfa hwmon: add driver for NZXT Kraken X42/X52/X62/X72
These are "all-in-one" CPU liquid coolers that can be monitored and
controlled through a proprietary USB HID protocol.

While the models have differently sized radiators and come with varying
numbers of fans, they are all indistinguishable at the software level.

The driver exposes fan/pump speeds and coolant temperature through the
standard hwmon sysfs interface.

Fan and pump control, while supported by the devices, are not currently
exposed.  The firmware accepts up to 61 trip points per channel
(fan/pump), but the same set of trip temperatures has to be maintained
for both; with pwmX_auto_point_Y_temp attributes, users would need to
maintain this invariant themselves.

Instead, fan and pump control, as well as LED control (which the device
also supports for 9 addressable RGB LEDs on the CPU water block) are
left for existing and already mature user-space tools, which can still
be used alongside the driver, thanks to hidraw.  A link to one, which I
also maintain, is provided in the documentation.

The implementation is based on USB traffic analysis.  It has been
runtime tested on x86_64, both as a built-in driver and as a module.

Signed-off-by: Jonas Malaco <jonas@protocubo.io>
Link: https://lore.kernel.org/r/20210319045544.416138-1-jonas@protocubo.io
[groeck: Removed unnecessary spinlock.h include]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Zihao Tang af9a973040 hwmon: (ina2xx) Convert sysfs sprintf/snprintf family to sysfs_emit
Fix the following coccicheck warning:

drivers/hwmon/ina2xx.c:313:8-16: WARNING: use scnprintf or sprintf
drivers/hwmon/ina2xx.c:453:8-16: WARNING: use scnprintf or sprintf
drivers/hwmon/ina2xx.c:484:8-16: WARNING: use scnprintf or sprintf
drivers/hwmon/ina2xx.c:540:8-16: WARNING: use scnprintf or sprintf

Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com>
Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1615892457-35501-1-git-send-email-f.fangjian@huawei.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Guenter Roeck 9d2227bb9b hwmon: Use kobj_to_dev()
coccinelle complains about

WARNING opportunity for kobj_to_dev()

in several files, resulting in one-by-one patch submissions.
Handle all remaining instances in one go.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Tian Tao f3e3464ec8 hwmon: (ds1621) Use kobj_to_dev()
fixed the following coccicheck:
./drivers/hwmon/ds1621.c:329:60-61: WARNING opportunity
for kobj_to_dev().

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1616032504-59817-1-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
zuoqilin 23bc3caf42 hwmon: (ftsteutates) Fix spelling typo
Change 'revsion' to 'revision'.

Signed-off-by: zuoqilin <zuoqilin@yulong.com>
Link: https://lore.kernel.org/r/20210318124637.1331-1-zuoqilin1@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Wilken Gottwalt c2d5f273c5 hwmon: (corsair-psu) add support for critical values
Adds support for reading the critical values of the temperature sensors
and the rail sensors (voltage and current) once and caches them. Updates
the naming of the constants following a more clear scheme. Also updates
the documentation and fixes some typos. Updates is_visible and ops_read
functions to be more readable.

The new sensors output of a Corsair HX850i will look like this:
corsairpsu-hid-3-1
Adapter: HID adapter
v_in:        230.00 V
v_out +12v:   12.14 V  (crit min =  +8.41 V, crit max = +15.59 V)
v_out +5v:     5.03 V  (crit min =  +3.50 V, crit max =  +6.50 V)
v_out +3.3v:   3.30 V  (crit min =  +2.31 V, crit max =  +4.30 V)
psu fan:        0 RPM
vrm temp:     +46.2°C  (crit = +70.0°C)
case temp:    +39.8°C  (crit = +70.0°C)
power total: 152.00 W
power +12v:  108.00 W
power +5v:    41.00 W
power +3.3v:   5.00 W
curr +12v:     9.00 A  (crit max = +85.00 A)
curr +5v:      8.31 A  (crit max = +40.00 A)
curr +3.3v:    1.62 A  (crit max = +40.00 A)

Signed-off-by: Wilken Gottwalt <wilken.gottwalt@posteo.net>
Link: https://lore.kernel.org/r/YFNg6vGk3sQmyqgB@monster.powergraphx.local
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Erik Rosen 42bfe7dd0f hwmon: (pmbus/stpddc60) Add ST STPDDC60 pmbus driver
Add hardware monitoring support for ST STPDDC60 Unversal Digital
Multicell Controller.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Link: https://lore.kernel.org/r/20210218115249.28513-3-erik.rosen@metormote.com
[groeck: Fixed whitespace error in Makefile]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Erik Rosen d3e33067a6 hwmon: (pmbus) Add pmbus_set_update() function to set update flag
For the STPDDC60 chip, the vout alarm-limits are represented as an offset
relative to the commanded output voltage. This means that the limits are
dynamic and must not be cached by the pmbus driver. This patch adds a
pmbus_set_sensor() function to pmbus_core to be able to set the update flag
on selected sensors after auto-detection of limit attributes.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
Link: https://lore.kernel.org/r/20210218115249.28513-2-erik.rosen@metormote.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Jiqi Li bfbbbe04d0 hwmon: (nct6683) Support NCT6686D
Add support for NCT6686D chip used in the Lenovo P620.

Signed-off-by: Jiqi Li <lijq9@lenovo.com>
Reviewed-by: Mark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/20210304104421.1912934-1-lijq9@lenovo.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Chris Packham e20a7198a2 hwmon: (pmbus) Add driver for Infineon IR36021
The IR36021 is a dual‐loop digital multi‐phase buck controller.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210301035954.16713-3-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Wilken Gottwalt 918f22104d hwmon: (corsair-psu) Update calculation of LINEAR11 values
Changes the way how LINEAR11 values are calculated. The new method
increases the precision of 2-3 digits.

old method:
	corsairpsu-hid-3-1
	Adapter: HID adapter
	v_in:        230.00 V
	v_out +12v:   12.00 V
	v_out +5v:     5.00 V
	v_out +3.3v:   3.00 V
	psu fan:        0 RPM
	vrm temp:     +44.0°C
	case temp:    +37.0°C
	power total: 152.00 W
	power +12v:  112.00 W
	power +5v:    38.00 W
	power +3.3v:   5.00 W
	curr in:          N/A
	curr +12v:     9.00 A
	curr +5v:      7.00 A
	curr +3.3v:  1000.00 mA

new method:
	corsairpsu-hid-3-1
	Adapter: HID adapter
	v_in:        230.00 V
	v_out +12v:   12.16 V
	v_out +5v:     5.01 V
	v_out +3.3v:   3.30 V
	psu fan:        0 RPM
	vrm temp:     +44.5°C
	case temp:    +37.8°C
	power total: 148.00 W
	power +12v:  108.00 W
	power +5v:    37.00 W
	power +3.3v:   4.50 W
	curr in:          N/A
	curr +12v:     9.25 A
	curr +5v:      7.50 A
	curr +3.3v:    1.50 A

Co-developed-by: Jack Doan <me@jackdoan.com>
Signed-off-by: Jack Doan <me@jackdoan.com>
Signed-off-by: Wilken Gottwalt <wilken.gottwalt@posteo.net>
Link: https://lore.kernel.org/r/YDoSMqFbgoTXyoru@monster.powergraphx.local
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Yang Li 77d76768d0 hwmon: Switch to using the new API kobj_to_dev()
fixed the following coccicheck:
./drivers/hwmon/hwmon.c:82:60-61: WARNING opportunity for kobj_to_dev()

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Link: https://lore.kernel.org/r/1614071667-5665-1-git-send-email-yang.lee@linux.alibaba.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00