summaryrefslogtreecommitdiff
path: root/drivers/hwmon/pmbus
AgeCommit message (Collapse)AuthorFilesLines
2024-01-27hwmon: (pmbus/mp2975) Correct comment inside 'mp2975_read_byte_data'Konstantin Aladyshev1-4/+3
The current driver code no longer perfrom internal conversion from VID to direct. Instead it configures READ_VOUT using MFR_DC_LOOP_CTRL. Correct the comment message inside the 'mp2975_read_byte_data' function to match the driver logic. Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com> Fixes: c60fe56c169e ("hwmon: (pmbus/mp2975) Fix driver initialization for MP2975 device") Link: https://lore.kernel.org/r/20240127154844.989-1-aladyshev22@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-01-27hwmon: (pmbus/mp2975) Fix driver initialization for MP2975 deviceKonstantin Aladyshev1-0/+17
The commit 1feb31e810b0 ("hwmon: (pmbus/mp2975) Simplify VOUT code") has introduced a bug that makes it impossible to initialize MP2975 device: """ mp2975 5-0020: Failed to identify chip capabilities i2c i2c-5: new_device: Instantiated device mp2975 at 0x20 i2c i2c-5: delete_device: Deleting device mp2975 at 0x20 """ Since the 'read_byte_data' function was removed from the 'pmbus_driver_info ' structure the driver no longer reports correctly that VOUT mode is direct. Therefore 'pmbus_identify_common' fails with error, making it impossible to initialize the device. Restore 'read_byte_data' function to fix the issue. Tested: - before: it is not possible to initialize MP2975 device with the 'mp2975' driver, - after: 'mp2975' correctly initializes MP2975 device and all sensor data is correct. Fixes: 1feb31e810b0 ("hwmon: (pmbus/mp2975) Simplify VOUT code") Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com> Link: https://lore.kernel.org/r/20240126205714.2363-1-aladyshev22@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-01-02hwmon: (pmbus) Add support for MPS Multi-phase mp2856/mp2857 controllerPeter Yin3-0/+476
Add support for mp2856/mp2857 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a dual-loop, digital, multi-phase, modulation controller. Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com> Signed-off-by: Potin Lai <potin.lai.pt@gmail.com> Link: https://lore.kernel.org/r/20231211160519.21254-3-potin.lai.pt@gmail.com [groeck: Fix checkpatch issues, use i2c_get_match_data()] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-01-02hwmon: (pmbus) Add ltc4286 driverDelphine CC Chiu3-0/+186
Add a driver to support ltc4286 chip Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@Wiwynn.com> Link: https://lore.kernel.org/r/20231123015440.199822-3-Delphine_CC_Chiu@Wiwynn.com [groeck: Fixed formatting] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (pmbus) Add support for MPS Multi-phase mp5990Peter Yin3-0/+189
Add support for mp5990 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a Hot-Swap Controller. Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com> Link: https://lore.kernel.org/r/20231113155008.2147090-3-peteryin.openbmc@gmail.com [groeck: Improved and clarified comments] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (lm25066) Use i2c_get_match_data()Rob Herring1-11/+3
Use preferred i2c_get_match_data() instead of of_match_device() and i2c_match_id() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Adjust the 'chips' enum to not use 0, so that no match data can be distinguished from a valid enum value. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231115205703.3730448-3-robh@kernel.org [groeck: Use double cast for enum chips assignment to make compiler happy] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-28hwmon: (pmbus/max31785) Add delay between bus accessesLakshmi Yadlapati1-21/+167
The MAX31785 has shown erratic behaviour across multiple system designs, unexpectedly clock stretching and NAKing transactions. Experimentation shows that this seems to be triggered by a register access directly back to back with a previous register write. Experimentation also shows that inserting a small delay after register writes makes the issue go away. Use a similar solution to what the max15301 driver does to solve the same problem. Create a custom set of bus read and write functions that make sure that the delay is added. Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com> Link: https://lore.kernel.org/r/20231027044346.2167548-1-lakshmiy@us.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-28hwmon: (pmbus/mpq7932) Add a support for mpq2286 Power Management ICSaravanan Sekar1-1/+12
The MPQ2286 is a programmable, high frequency synchronous buck regulator designed to power a variety of Automotive system peripherals. Single buck converters with hardware monitoring capability is configurable over PMBus interface. Signed-off-by: Saravanan Sekar <saravanan@linumiz.com> Link: https://lore.kernel.org/r/20231011164754.449399-5-saravanan@linumiz.com [groeck: Updated subject (mpq2286 -> mpq7932)] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-28hwmon: (pmbus/core) Add helper macro to define single pmbus regulatorSaravanan Sekar1-0/+15
The bindings for single instance regulator should be named with no instance (e.g., buck not buck0). Introduce a new helper macro to define the single pmbus regulator. Signed-off-by: Saravanan Sekar <saravanan@linumiz.com> Link: https://lore.kernel.org/r/20231011164754.449399-4-saravanan@linumiz.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-28hwmon: (pmbus/mpq7932) Get page count based on chip infoSaravanan Sekar1-3/+3
Get page count using compatible match to support the series of chipsets which differs in number of regualator/page. Signed-off-by: Saravanan Sekar <saravanan@linumiz.com> Link: https://lore.kernel.org/r/20231011164754.449399-2-saravanan@linumiz.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-27hwmon: (pmbus/tda38640) Add workaround for SVID modePatrick Rudolph1-2/+152
TDA38640 can operate in either PMBus mode or SVID mode. In SVID mode, by design ENABLE pin is the only option for controlling the output rail i.e., ENABLE pin is chained to power good of another reglator & FPGA. In cases where the chip is configured for SVID mode, and the ENABLE pin is set at a fixed level or is left unconnected (with an internal pull-down), while requiring software control, the following workaround is necessary. The workaround utilizes ENABLE pin polarity flipping to control output rail. If property 'infineon,en-pin-fixed-level' is specified then determine if chip is in SVID mode by checking BIT15 of MTP memory offset 0x44 as described in the datasheet. If chip is in SVID mode then apply the workaround by 1. Determine EN pin level 2. Maps BIT7 of OPERATION(01h) to EN_PIN_POLARITY(BIT1) of PB_ON_OFF_CONFIG. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230831190731.265099-3-Naresh.Solanki@9elements.com [groeck: Dropped unnecessary line continuation] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-27hwmon: (pmbus) Add ON_OFF_CONFIG register bitsPatrick Rudolph1-0/+9
Add bits found in the ON_OFF_CONFIG register. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230831190731.265099-2-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-27hwmon: (pmbus/mp2975) Move PGOOD fixNaresh Solanki1-5/+5
The PGOOD fix was intended for MP2973 & MP2971 & not for MP2975. Fixes: acda945afb46 ("hwmon: (pmbus/mp2975) Fix PGOOD in READ_STATUS_WORD") Signed-off-by: Naresh Solanki <naresh.solanki@9elements.com> Link: https://lore.kernel.org/r/20231027103352.918895-1-naresh.solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: pmbus: Fix -EIO seen on pli1209Patrick Rudolph1-0/+26
After doing performance optimizations the pli1209 driver failed to probe with a probabilty of 2%. It wasn't able to read the PMBUS_OPERATION register due to an -EIO error. An investigation showed that the PLI1209 takes 230 usec to execute the CLEAR_FAULTS command. During that time it's busy and NACKs all requests on the SMBUS interface. It also NACKs reads on PMBUS_STATUS_BYTE making it impossible to poll the BUSY flag. Add a custom write_data function to just wait for not BUSY unconditionally after sending a CLEAR_FAULTS command. TEST: Verified using an I2C bus analyser that no more NACKs are seen after sending a CLEAR_FAULTS command. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230817092527.808631-3-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: pmbus: Drop unnecessary clear fault pagePatrick Rudolph1-1/+0
The pmbus_check_byte_register function already calls clear fault page, so there's no need to do it again in pmbus_identify_common. TEST: Verified using an I2C bus analyser to confirm that only one clear fault page is being send instead of two in a row. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230817092527.808631-2-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: pmbus: Reduce clear fault page invocationsPatrick Rudolph1-1/+2
Observing I2C traffic revealed consecutive transmission of CLEAR_FAULT commands. While this doesn't cause issues, it extends driver probe time. Avoid invoking pmbus_clear_fault_page for virtual registers, as they're managed by the driver, not the chip. TEST: Verified using an I2C bus analyzer that only one CLEAR_FAULT command is send instead 5 in a row. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230817092527.808631-1-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/ucd9200) fix Wvoid-pointer-to-enum-cast warningKrzysztof Kozlowski1-1/+1
'chip' is an enum, thus cast of pointer on 64-bit compile test with W=1 causes: ucd9200.c:106:10: error: cast to smaller integer type 'enum chips' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230810093157.94244-15-krzysztof.kozlowski@linaro.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/ucd9000) fix Wvoid-pointer-to-enum-cast warningKrzysztof Kozlowski1-1/+1
'chip' is an enum, thus cast of pointer on 64-bit compile test with W=1 causes: ucd9000.c:591:10: error: cast to smaller integer type 'enum chips' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230810093157.94244-14-krzysztof.kozlowski@linaro.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/tps53679) fix Wvoid-pointer-to-enum-cast warningKrzysztof Kozlowski1-1/+1
'chip_id' is an enum, thus cast of pointer on 64-bit compile test with W=1 causes: tps53679.c:238:13: error: cast to smaller integer type 'enum chips' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230810093157.94244-13-krzysztof.kozlowski@linaro.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/ibm-cffps) fix Wvoid-pointer-to-enum-cast warningKrzysztof Kozlowski1-1/+1
'vs' is an enum, thus cast of pointer on 64-bit compile test with W=1 causes: ibm-cffps.c:492:8: error: cast to smaller integer type 'enum versions' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230810093157.94244-12-krzysztof.kozlowski@linaro.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (max20730) fix Wvoid-pointer-to-enum-cast warningKrzysztof Kozlowski1-1/+1
'chip_id' is an enum, thus cast of pointer on 64-bit compile test with W=1 causes: max20730.c:719:13: error: cast to smaller integer type 'enum chips' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230810093157.94244-9-krzysztof.kozlowski@linaro.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Fix PGOOD in READ_STATUS_WORDPatrick Rudolph1-0/+5
MP2973 & MP2971 return PGOOD instead of PB_STATUS_POWER_GOOD_N. Fix that in the read_word_data hook. MP2975 should not be affected, but that has not been confirmed with hardware. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230731092204.2933045-1-Naresh.Solanki@9elements.com [groeck: Rephrased description to indicate that MP2975 is likely not affected] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Add OCP limitPatrick Rudolph1-11/+65
Add support for PMBUS_IOUT_OC_FAULT_LIMIT. Add a helper function to convert the limit to LINEAR11 format and read data->info.phases[0] on MP2971 and MP2973 as well. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230714135124.2645339-8-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Add regulator supportPatrick Rudolph2-0/+22
Add support to expose the PMBUS regulator. Tested on MP2973 and MP2971. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230714135124.2645339-7-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Add support for MP2971 and MP2973Patrick Rudolph1-33/+214
Add support for MP2971 and MP2973, the successor of MP2975. The major differences are: - On MP2973 and MP2971 the Vref cannot be read and thus most of the OVP/current calculations won't work. - MP2973 and MP2971 also support LINEAR format for VOUT - MP2973 and MP2971 do not support OVP2 - On MP2973 and MP2971 most registers are in LINEAR format - The IMVP9_EN bit has a different position - Per phase current sense haven't been implemented. As on MP2975 most of the FAULT_LIMIT and WARN_LIMIT registers have been redefined and doesn't provide the functionality as defined in PMBUS spec. Tested on MP2973 and MP2971. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230714135124.2645339-6-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Make phase count variablePatrick Rudolph1-13/+20
In order to add support for MP2973 and MP2971 replace hardcoded phase count for both channels by a variable. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230714135124.2645339-5-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Simplify VOUT codePatrick Rudolph1-50/+10
In order to upstream MP2973/MP2971 simplify the code by removing support for various VOUT formats. The MP2973 and MP2971 supports all PMBUS supported formats for VOUT, while the MP2975 only support DIRECT and VID for VOUT. In DIRECT mode all chips report the voltage in 1mV/LSB. Configure the chip to use DIRECT format for VOUT and drop the code conversion code for other formats. The to be added chips MP2973/MP2971 will be configured to also report VOUT in DIRECT format. The maximum voltage that can be reported in DIRECT format is 32768mV. This is sufficient as the maximum output voltage for VR12/VR13 is 3040 mV. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230714135124.2645339-4-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Prepare for MP2973 and MP2971Patrick Rudolph1-8/+19
Add support for differntiating between the chips. The following commits will make use of this mechanism. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230714135124.2645339-3-Naresh.Solanki@9elements.com [groeck: double-cast of_device_get_match_data() to make gcc happy] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/mp2975) Fix whitespace errorPatrick Rudolph1-1/+1
Fix whitespace error reported by checkpatch.pl Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230714135124.2645339-1-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/max20730) Remove strlcpy occurencesAzeem Shaikh1-31/+33
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with direct assignment. strlcpy in this file is used to copy fixed-length strings which can be completely avoided by direct assignment and is safe to do so. strlen() is used to return the length of @tbuf. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] https://github.com/KSPP/linux/issues/89 Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com> Reviewed-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230712214307.2424810-1-azeemshaikh38@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: Explicitly include correct DT includesRob Herring10-11/+11
The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it as merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230714174607.4057185-1-robh@kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-21hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attributeEddie James1-0/+38
Like the IBM CFFPS driver, export the PSU's firmware version to a debugfs attribute as reported in the manufacturer register. Signed-off-by: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/20230628153453.122213-1-eajames@linux.ibm.com [groeck: Dropped unused variable; changed buffer from char to u8] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-08-06hwmon: (pmbus/bel-pfe) Enable PMBUS_SKIP_STATUS_CHECK for pfe1100Tao Ren1-8/+8
Skip status check for both pfe1100 and pfe3000 because the communication error is also observed on pfe1100 devices. Signed-off-by: Tao Ren <rentao.bupt@gmail.com> Fixes: 626bb2f3fb3c hwmon: (pmbus) add driver for BEL PFE1100 and PFE3000 Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230804221403.28931-1-rentao.bupt@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-07-27hwmon: (pmbus_core) Fix Deadlock in pmbus_regulator_get_statusGuenter Roeck1-1/+2
pmbus_regulator_get_status() acquires update_lock. pmbus_regulator_get_error_flags() acquires it again, resulting in an immediate deadlock. Call _pmbus_get_flags() from pmbus_regulator_get_status() directly to avoid the problem. Reported-by: Patrick Rudolph <patrick.rudolph@9elements.com> Closes: https://lore.kernel.org/linux-hwmon/b7a3ad85-aab4-4718-a001-1d8b1c0eef36@roeck-us.net/T/#u Cc: Naresh Solanki <Naresh.Solanki@9elements.com> Cc: stable@vger.kernel.org # v6.2+ Fixes: c05f477c4ba3 ("hwmon: (pmbus/core) Implement regulator get_status") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-07-25hwmon: (pmbus_core) Fix NULL pointer dereferencePatrick Rudolph1-7/+8
Pass i2c_client to _pmbus_is_enabled to drop the assumption that a regulator device is passed in. This will fix the issue of a NULL pointer dereference when called from _pmbus_get_flags. Fixes: df5f6b6af01c ("hwmon: (pmbus/core) Generalise pmbus get status") Cc: stable@vger.kernel.org # v6.4 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230725125428.3966803-2-Naresh.Solanki@9elements.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-07-25hwmon: (pmbus_core) Fix pmbus_is_enabled()Patrick Rudolph1-1/+1
Refactor pmbus_is_enabled() to return the status without any additional processing as it is already done in _pmbus_is_enabled(). Fixes: df5f6b6af01c ("hwmon: (pmbus/core) Generalise pmbus get status") Cc: stable@vger.kernel.org # v6.4 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com> Link: https://lore.kernel.org/r/20230725125428.3966803-1-Naresh.Solanki@9elements.com [groeck: Rephrased commit message] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-07-03Merge tag 'driver-core-6.5-rc1' of ↵Linus Torvalds1-3/+3
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core updates from Greg KH: "Here are a small set of changes for 6.5-rc1 for some driver core changes. Included in here are: - device property cleanups to make it easier to write "agnostic" drivers when regards to the firmware layer underneath them (DT vs. ACPI) - debugfs documentation updates - devres additions - sysfs documentation and changes to handle empty directory creation logic better - tiny kernfs optimizations - other tiny changes All of these have been in linux-next for a while with no reported problems" * tag 'driver-core-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: sysfs: Skip empty folders creation sysfs: Improve readability by following the kernel coding style drivers: fwnode: fix fwnode_irq_get[_byname]() ata: ahci_platform: Make code agnostic to OF/ACPI device property: Implement device_is_compatible() ACPI: Move ACPI_DEVICE_CLASS() to mod_devicetable.h base/node: Use 'property' to identify an access parameter driver core: device.h: add some missing kerneldocs kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR isa: Remove unnecessary checks MAINTAINERS: add entry for auxiliary bus debugfs: Correct the 'debugfs_create_str' docs serial: qcom_geni: Comment use of devm_krealloc rather than devm_krealloc_array iio: adc: Use devm_krealloc_array hwmon: pmbus: Use devm_krealloc_array
2023-06-22hwmon: (pmbus/adm1275) Disable ADC while updating PMON_CONFIGGuenter Roeck1-1/+17
According to ADI, changing PMON_CONFIG while the ADC is running can have unexpected results. ADI recommends halting the ADC with PMON_CONTROL before setting PMON_CONFIG and then resume after. Follow ADI recommendation and disable ADC while PMON_CONFIG is updated. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230614163605.3688964-3-linux@roeck-us.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-06-22hwmon: (pmbus/adm1275) Prepare for protected write to PMON_CONFIGGuenter Roeck1-25/+31
According to ADI, changing PMON_CONFIG while ADC is running can have unexpected results. ADI recommends halting the ADC with PMON_CONTROL before setting PMON_CONFIG and then resume after. To prepare for this change, rename adm1275_read_pmon_config() and adm1275_write_pmon_config() to adm1275_read_samples() and adm1275_write_samples() to more accurately reflect the functionality of the code. Introduce new function adm1275_write_pmon_config() and use it for all code writing into the PMON_CONFIG register. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230614163605.3688964-2-linux@roeck-us.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-06-10hwmon: (pmbus/max16601) Add support for new revisions of MAX16508Guenter Roeck1-3/+3
New revisions of MAX16508 report MAX16508.xx or MAX16508y.xx as device ID, but are functionally similar to MAX16508. Add support for those chip variants. Cc: Vlad Sytchenko <vsytch@google.com> Cc: Steve Foreman <foremans@google.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-06-08hwmon: (pmbus/adm1266) Drop unnecessary error check for debugfs_create_dirOsama Muhammad1-2/+0
This patch removes the error checking for debugfs_create_dir in adm1266.c. This is because the debugfs_create_dir() does not return NULL but an ERR_PTR after an error. The DebugFS kernel API is developed in a way that the caller can safely ignore the errors that occur during the creation of DebugFS nodes.The debugfs Api handles it gracefully. The check is unnecessary. Link to the comment above debugfs_create_dir: https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L565 Signed-off-by: Osama Muhammad <osmtendev@gmail.com> Link: https://lore.kernel.org/r/20230526163938.9903-1-osmtendev@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-06-08hwmon: (pmbus/ucd9000) Drop unnecessary error check for debugfs_create_dirOsama Muhammad1-2/+0
This patch removes the error checking for debugfs_create_dir in ucd9000.c. This is because the debugfs_create_dir() does not return NULL but an ERR_PTR after an error. The DebugFS kernel API is developed in a way that the caller can safely ignore the errors that occur during the creation of DebugFS nodes.The debugfs Api handles it gracefully. The check is unnecessary. Link to the comment above debugfs_create_dir: https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L565 Signed-off-by: Osama Muhammad <osmtendev@gmail.com> Link: https://lore.kernel.org/r/20230526154906.6370-1-osmtendev@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-06-08hwmon: Switch i2c drivers back to use .probe()Uwe Kleine-König47-47/+47
After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type"), all drivers being converted to .probe_new() and then 03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert back to (the new) .probe() to be able to eventually drop .probe_new() from struct i2c_driver. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230505131718.1210071-1-u.kleine-koenig@pengutronix.de [groeck: Added missing change in pmbus/acbel-fsg032.c] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-06-08hwmon: (pmbus/adm1275) Fix problems with temperature monitoring on ADM1272Guenter Roeck1-26/+26
The PMON_CONFIG register on ADM1272 is a 16 bit register. Writing a 8 bit value into it clears the upper 8 bits of the register, resulting in unexpected side effects. Fix by writing the 16 bit register value. Also, it has been reported that temperature readings are sometimes widely inaccurate, to the point where readings may result in device shutdown due to errant overtemperature faults. Improve by enabling temperature sampling. While at it, move the common code for ADM1272 and ADM1278 into a separate function, and clarify in the error message that an attempt was made to enable both VOUT and temperature monitoring. Last but not least, return the error code reported by the underlying I2C controller and not -ENODEV if updating the PMON_CONFIG register fails. After all, this does not indicate that the chip is not present, but an error in the communication with the chip. Fixes: 4ff0ce227a1e ("hwmon: (pmbus/adm1275) Add support for ADM1272") Fixes: 9da9c2dc57b2 ("hwmon: (adm1275) enable adm1272 temperature reporting") Signed-off-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230602213447.3557346-1-linux@roeck-us.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-05-30hwmon: pmbus: Use devm_krealloc_arrayJames Clark1-3/+3
Now that it exists, use it instead of doing the multiplication manually. Acked-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: James Clark <james.clark@arm.com> Link: https://lore.kernel.org/r/20230509094942.396150-3-james.clark@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-26Merge tag 'thermal-6.4-rc1' of ↵Linus Torvalds1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull thermal control updates from Rafael Wysocki: "These mostly continue to prepare the thermal control subsystem for using unified representation of trip points, which includes cleanups, code refactoring and similar and update several drivers (for other reasons), which includes new hardware support. Specifics: - Add a thermal zone 'devdata' accessor and modify several drivers to use it (Daniel Lezcano) - Prevent drivers from using the 'device' internal thermal zone structure field directly (Daniel Lezcano) - Clean up the hwmon thermal driver (Daniel Lezcano) - Add thermal zone id accessor and thermal zone type accessor and prevent drivers from using thermal zone fields directly (Daniel Lezcano) - Clean up the acerhdf and tegra thermal drivers (Daniel Lezcano) - Add lower bound check for sysfs input to the x86_pkg_temp_thermal Intel thermal driver (Zhang Rui) - Add more thermal zone device encapsulation: prevent setting structure field directly, access the sensor device instead the thermal zone's device for trace, relocate the traces in drivers/thermal (Daniel Lezcano) - Use the generic trip point for the i.MX and remove the get_trip_temp ops (Daniel Lezcano) - Use the devm_platform_ioremap_resource() in the Hisilicon driver (Yang Li) - Remove R-Car H3 ES1.* handling as public has only access to the ES2 version and the upstream support for the ES1 has been shutdown (Wolfram Sang) - Add a delay after initializing the bank in order to let the time to the hardware to initialze itself before reading the temperature (Amjad Ouled-Ameur) - Add MT8365 support (Amjad Ouled-Ameur) - Preparational cleanup and DT bindings for RK3588 support (Sebastian Reichel) - Add driver support for RK3588 (Finley Xiao) - Use devm_reset_control_array_get_exclusive() for the Rockchip driver (Ye Xingchen) - Detect power gated thermal zones and return -EAGAIN when reading the temperature (Mikko Perttunen) - Remove thermal_bind_params structure as it is unused (Zhang Rui) - Drop unneeded quotes in DT bindings allowing to run yamllint (Rob Herring) - Update the power allocator documentation according to the thermal trace relocation (Lukas Bulwahn) - Fix sensor 1 interrupt status bitmask for the Mediatek LVTS sensor (Chen-Yu Tsai) - Use the dev_err_probe() helper in the Amlogic driver (Ye Xingchen) - Add AP domain support to LVTS thermal controllers for mt8195 (Balsam CHIHI) - Remove buggy call to thermal_of_zone_unregister() (Daniel Lezcano) - Make thermal_of_zone_[un]register() private to the thermal OF code (Daniel Lezcano) - Create a private copy of the thermal zone device parameters structure when registering a thermal zone (Daniel Lezcano) - Fix a kernel NULL pointer dereference in thermal_hwmon (Zhang Rui) - Revert recent message adjustment in thermal_hwmon (Rafael Wysocki) - Use of_property_present() for testing DT property presence in thermal control code (Rob Herring) - Clean up thermal_list_lock locking in the thermal core (Rafael Wysocki) - Add DLVR support for RFIM control in the int340x Intel thermal driver (Srinivas Pandruvada)" * tag 'thermal-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (55 commits) thermal: intel: int340x: Add DLVR support for RFIM control thermal/core: Alloc-copy-free the thermal zone parameters structure thermal/of: Unexport unused OF functions thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister thermal/drivers/mediatek/lvts_thermal: Add AP domain for mt8195 dt-bindings: thermal: mediatek: Add AP domain to LVTS thermal controllers for mt8195 thermal: amlogic: Use dev_err_probe() thermal/drivers/mediatek/lvts_thermal: Fix sensor 1 interrupt status bitmask MAINTAINERS: adjust entry in THERMAL/POWER_ALLOCATOR after header movement dt-bindings: thermal: Drop unneeded quotes thermal/core: Remove thermal_bind_params structure thermal/drivers/tegra-bpmp: Handle offline zones thermal/drivers/rockchip: use devm_reset_control_array_get_exclusive() dt-bindings: rockchip-thermal: Support the RK3588 SoC compatible thermal/drivers/rockchip: Support RK3588 SoC in the thermal driver thermal/drivers/rockchip: Support dynamic sized sensor array thermal/drivers/rockchip: Simplify channel id logic thermal/drivers/rockchip: Use dev_err_probe thermal/drivers/rockchip: Simplify clock logic thermal/drivers/rockchip: Simplify getting match data ...
2023-04-21hwmon: (pmbus/fsp-3y) Fix functionality bitmask in FSP-3Y YM-2151ETomáš Pecka1-1/+0
The bit flags in pmbus_driver_info functionality for YM-2151E chip were joined with a comma operator instead of a bitwise OR. This means that the last constant PMBUS_HAVE_IIN was not OR-ed with the other PM_BUS_HAVE_* constants for this page but it initialized the next element of the func array (which was not accessed from anywhere because of the number of pages). However, there is no need for setting PMBUS_HAVE_IIN in the 5Vsb page because this command does not seem to be paged. Obviously, the device only has one IIN sensor, so it doesn't make sense to query it again from the second page. Fixes: 1734b4135a62 ("hwmon: Add driver for fsp-3y PSUs and PDUs") Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz> Signed-off-by: Tomáš Pecka <tomas.pecka@cesnet.cz> Link: https://lore.kernel.org/r/20230420171939.212040-1-tomas.pecka@cesnet.cz Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-04-19hwmon: (pmbus/acbel-fsg032) Add Acbel power supplyLakshmi Yadlapati3-0/+95
Add the driver to support ACBEL FSG032 power supply. Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com> Link: https://lore.kernel.org/r/20230413132627.3444119-4-lakshmiy@us.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-04-19hwmon: (pmbus/ibm-cffps) Use default debugfs attributes and lock functionEddie James1-154/+118
Switch the driver to use the default debugfs attributes instead of ones that provide the same data under different names. Use the lock functions for the debugfs and led attributes, and simplify the input history operation by dropping the timer and lock. Signed-off-by: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/20230412161526.252294-3-eajames@linux.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-04-19hwmon: (pmbus/core) Add lock and unlock functionsEddie James2-0/+32
Debugfs operations may set the page number, which must be done atomically with the subsequent i2c operation. Lock the update_lock in the debugfs functions and provide a function for pmbus drivers to lock and unlock the update_lock. Signed-off-by: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/20230412161526.252294-2-eajames@linux.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>