summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus/lm25066.c
Commit message (Collapse)AuthorAgeFilesLines
* hwmon: (pmbus/lm25066) Let enum chips start with index 0Guenter Roeck2024-06-111-1/+1
| | | | | | | | | | | | | | | Commit ac0c26bae662 ("hwmon: (lm25066) Use i2c_get_match_data()") changed enum chips to start with 1 instead of 0, under the assumption that the data pointer in of_device_id must not start with 0 (NULL) if i2c_get_match_data() is used. However, that is perfectly fine as long as there is also an i2c_device_id array with the same data which is used as fallback in that case. Let enum chips start with 0 to avoid confusion against other drivers where the enum starts with 0 and i2c_get_match_data() is used as well. Cc: Rob Herring <robh@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Use PMBUS_REGULATOR_ONE to declare regulatorGuenter Roeck2024-02-251-1/+1
| | | | | | | | | | | | | | If a chip only provides a single regulator, it should be named 'vout' and not 'vout0'. Declare regulator using PMBUS_REGULATOR_ONE() to make that happen. Cc: Conor Dooley <conor@kernel.org> Cc: Naresh Solanki <naresh.solanki@9elements.com> Cc: Zev Weiss <zev@bewilderbeest.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20240223-player-buckskin-01405c5889c4@spud Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (lm25066) Use i2c_get_match_data()Rob Herring2023-12-111-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>
* hwmon: Switch i2c drivers back to use .probe()Uwe Kleine-König2023-06-081-1/+1
| | | | | | | | | | | | | 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>
* hwmon: (pmbus/lm25066) Add regulator supportZev Weiss2022-02-271-0/+14
| | | | | | | | | | | | While these chips aren't strictly advertised as voltage regulators per se, they (aside from the lm25056) support the PMBus OPERATION command to enable and disable their outputs and have status bits for reporting various warnings and faults, and can hence usefully support all the pmbus_regulator_ops operations. Signed-off-by: Zev Weiss <zev@bewilderbeest.net> Link: https://lore.kernel.org/r/20220219000742.20126-1-zev@bewilderbeest.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Support configurable sense resistor valuesZev Weiss2021-10-121-0/+11
| | | | | | | | | | | | | | 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>
* hwmon: (pmbus/lm25066) Add OF device ID tableZev Weiss2021-10-121-2/+23
| | | | | | | | | | | | | | | | 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>
* hwmon: (pmbus/lm25066) Mark lm25066_coeff array constZev Weiss2021-10-121-2/+2
| | | | | | | | | 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>
* hwmon: (pmbus/lm25066) Let compiler determine outer dimension of lm25066_coeffZev Weiss2021-10-121-1/+1
| | | | | | | | | | 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: 666c14906b49 ("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>
* hwmon: (pmbus/lm25066) Avoid forward declaration of lm25066_idZev Weiss2021-10-121-13/+10
| | | | | | | | | 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>
* hwmon: (pmbus/lm25066) Adjust lm25066 PSC_CURRENT_IN_L mantissaZev Weiss2021-10-121-1/+1
| | | | | | | | | 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>
* hwmon: (pmbus/lm25066) Add offset coefficientsZev Weiss2021-10-121-0/+23
| | | | | | | | | | | | | 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: 58615a94f6a1 ("hwmon: (pmbus/lm25066) Add support for LM25056") Fixes: e53e6497fc9f ("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>
* hwmon: (pmbus) Introduce PMBUS symbol namespaceGuenter Roeck2021-04-201-0/+1
| | | | | | | 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>
* hwmon: (pmbus/lm25066) Remove unnecessary pmbus_clear_cache function callErik Rosen2021-02-011-5/+0
| | | | | | | | | It is no longer necessary to clear the cache to update the sensor value from the chip. Signed-off-by: Erik Rosen <erik.rosen@metormote.com> Link: https://lore.kernel.org/r/20210201195929.1200-3-erik.rosen@metormote.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) shrink code and remove pmbus_do_remove()Bartosz Golaszewski2020-12-021-1/+0
| | | | | | | | | | | The only action currently performed in pmbus_do_remove() is removing the debugfs hierarchy. We can schedule a devm action at probe time and remove pmbus_do_remove() entirely from all pmbus drivers. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Link: https://lore.kernel.org/r/20201026105352.20359-1-brgl@bgdev.pl [groeck: Removed references to pmbus_do_remove from documentation] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon (pmbus) use simple i2c probe functionStephen Kitt2020-09-231-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | pmbus_do_probe doesn't use the id information provided in its second argument, so this can be removed, which then allows using the single-parameter i2c probe function ("probe_new") for probes. This avoids scanning the identifier tables during probes. Drivers which didn't use the id are converted as-is; drivers which did are modified as follows: * if the information in i2c_client is sufficient, that's used instead (client->name); * configured v. probed comparisons are performed by comparing the configured name to the detected name, instead of the ids; this involves strcmp but is still cheaper than comparing all the device names when scanning the tables; * anything else is handled by calling i2c_match_id() with the same level of error-handling (if any) as before. Additionally, the mismatch message in the ltc2978 driver is adjusted so that it no longer assumes that the driver_data is an index into ltc2978_id. Signed-off-by: Stephen Kitt <steve@sk2.org> Acked-by: Wolfram Sang <wsa@kernel.org> Link: https://lore.kernel.org/r/20200808210004.30880-1-steve@sk2.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) Add 'phase' parameter where needed for multi-phase supportGuenter Roeck2020-03-081-15/+24
| | | | | | | | | In preparation for multi-phase support, add 'phase' parameter to read_word and set_page functions. Actual multi-phase support will be added in a subsequent patch. Cc: Vadim Pasternak <vadimp@mellanox.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61Thomas Gleixner2019-05-241-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 675 mass ave cambridge ma 02139 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 441 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190520071858.739733335@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* hwmon: (lm25066) Support SAMPLES_FOR_AVG registerAdamski, Krzysztof (Nokia - PL/Wroclaw)2019-04-151-1/+16
| | | | | | | | | | Manufacturer specific SAMPLES_FOR_AVG register allows setting the number of samples used in computing the average values (PMBUS_VIRT_READ_*_AVG). The number we write is an exponent of base 2 of the number of samples so for example writing 3 will result in 8 samples average. Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Drop support for LM25063Guenter Roeck2018-01-021-65/+2
| | | | | | LM25063 was never released. Drop support for it. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Add support for TI LM5066IXo Wang2017-08-301-2/+39
| | | | | | | | | | The TI LM5066I hotswap controller is a more accurate version of the LM5066 device already supported. It has different measurement conversion coefficients than the LM5066, so it needs to be recognized as a different device. Signed-off-by: Xo Wang <xow@google.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Offset coefficient depends on CLXo Wang2017-08-301-2/+4
| | | | | | | | | When converting the DIRECT format CURRENT_IN and POWER commands, make the offset coefficient ("b") predicate on the value of the current limit setting. Signed-off-by: Xo Wang <xow@google.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) Use BIT macroGuenter Roeck2015-08-191-3/+4
| | | | | | Using the BIT macro makes the code a little easier to read. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Add support for LM25063Guenter Roeck2013-10-181-9/+82
| | | | Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Add support for LM25056Guenter Roeck2013-04-071-9/+123
| | | | Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Refactor device specific coefficientsGuenter Roeck2013-04-071-78/+118
| | | | | | | Initialize device specific coefficients from table instead of hard-coding it to simplify adding additional chips. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Clamp limit attributesGuenter Roeck2013-04-071-0/+13
| | | | | | | | | | Limits on all supported sensors and chips have to be within 0..0x0fff, and limits are always positive. Clamp written values in chip driver. Also clear value cache to ensure that the actually written value is read back and reported correctly. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus/lm25066) Report VAUX as vmonGuenter Roeck2013-04-071-52/+21
| | | | | | | | | So far the driver reported the voltage on VAUX as "vout2". This was not entirely appropriate as it is not an output voltage, and complicates the code. Use the new virtual "VMON" register set and report the voltage as "vmon" instead. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) Simplify remove functionsGuenter Roeck2012-03-181-7/+1
| | | | | | | | | Since devm_kzalloc() is now used to allocate driver memory, the client driver remove function has no purpose other than to call pmbus_do_remove(). This means we can get rid of it by redefining pmbus_do_remove() to use the same prototype, and pointing to it directly. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) Convert pmbus drivers to use devm_kzallocGuenter Roeck2012-03-181-20/+6
| | | | | | Marginally less code and eliminate the possibility of memory leaks. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: convert drivers/hwmon/* to use module_i2c_driver()Axel Lin2012-03-181-11/+1
| | | | | | | | | | | | | | | | | | This patch converts the drivers in drivers/hwmon/* to use the module_i2c_driver() macro which makes the code smaller and a bit simpler. Signed-off-by: Axel Lin <axel.lin@gmail.com> Cc: Corentin Labbe <corentin.labbe@geomatys.fr> Cc: Dirk Eibach <eibach@gdsys.de> Cc: "Mark M. Hoffman" <mhoffman@lightlink.com> Cc: Steve Glendinning <steve.glendinning@smsc.com> Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Guillaume Ligneul <guillaume.ligneul@gmail.com> Cc: David George <david.george@ska.ac.za> Cc: "Hans J. Koch" <hjk@hansjkoch.de> Cc: Marc Hulsman <m.hulsman@tudelft.nl> Cc: Rudolf Marek <r.marek@assembler.cz> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
* hwmon: (pmbus) Always call _pmbus_read_byte in core driverGuenter Roeck2011-10-241-2/+2
| | | | | | | | | | | | | Always call _pmbus_read_byte() instead of pmbus_read_byte() in PMBus core driver. With this change, device specific read functions can be implemented for all registers. Since the device specific read_byte function is now always called, we need to be more careful with page validations. Only fail if the passed page number is larger than 0, since -1 means "current page". Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
* hwmon: (pmbus) Replace EINVAL return codes with more appropriate errorsGuenter Roeck2011-10-241-4/+4
| | | | | | | EINVAL was over-used in the code. Replace it with more appropriate errors. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
* hwmon: (pmbus) Don't return errors from driver remove functionsGuenter Roeck2011-10-241-3/+2
| | | | | | | | | | | | | | | | | | | | | Driver remove functions have an error return value, but rarely return an error in practice. If a driver does return an error from its remove function, the driver won't be unloaded and is expected to stay alive. pmbus_do_remove() is defined as returning an int, but always returns 0 (no error). Calling code passes that return value on to high level driver remove functions, but does not evaluate it and removes driver data even if pmbus_do_remove() returned an error (which it in practice never does). Even if this code could never cause a real problem, it is nevertheless conceptually wrong. To reduce confusion and simplify the code, change pmbus_do_remove() to be a void function, and have PMBus client drivers always return zero in their driver remove functions. Reported-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
* hwmon: (pmbus/lm25066) Ignore byte writes to non-zero pagesGuenter Roeck2011-08-111-0/+12
| | | | | | | | | | | | | | pmbus_clear_faults() attempts to clear faults on non-existing real pages. As a result, the command error bit in the status register is set, and faults are not really cleared. All byte writes to non-zero pages are requests to clear the status register on that page. Since non-zero pages are virtual and do not exist on the chip, there is nothing to do, and such requests have to be ignored. This fixes above problem. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
* hwmon: (pmbus) Add client driver for LM25066, LM5064, and LM5066Guenter Roeck2011-07-281-0/+340
PMBus client driver supporting National Semiconductor LM25066, LM5064, and LM5066. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>