summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus/adm1275.c
AgeCommit message (Collapse)AuthorFilesLines
2022-03-02hwmon: (adm1275) Allow setting sample averagingPotin Lai1-1/+39
Current driver assume PWR_AVG and VI_AVG as 1 by default, and user needs to set sample averaging via sysfs manually. This patch parses the properties "adi,power-sample-average" and "adi,volt-curr-sample-average" from device tree, and setting sample averaging during probe. Input value must be one of value in the list [1, 2, 4, 8, 16, 32, 64, 128]. Signed-off-by: Potin Lai <potin.lai@quantatw.com> Link: https://lore.kernel.org/r/20220302123817.27025-2-potin.lai@quantatw.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-06-17hwmon: (adm1275) enable adm1272 temperature reportingChu Lin1-8/+6
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-04-20hwmon: (pmbus) Introduce PMBUS symbol namespaceGuenter Roeck1-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>
2020-12-02hwmon: (pmbus) shrink code and remove pmbus_do_remove()Bartosz Golaszewski1-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>
2020-09-23hwmon (pmbus) use simple i2c probe functionStephen Kitt1-6/+5
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>
2020-07-19hwmon: (adm1275) Enable adm1278 ADM1278_TEMP1_ENManikandan Elumalai1-7/+6
The adm1278 temp attribute need it for openbmc platform . This feature not enabled by default, so PMON_CONFIG needs to enable it. Signed-off-by: Manikandan Elumalai <manikandan.hcl.ers.epl@gmail.com> Link: https://lore.kernel.org/r/20200622153727.GA9347@cnn [groeck: Split long line] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-09hwmon: (adm1275) Make sure we are reading enough data for different chipsChu Lin1-2/+8
Issue: When PEC is enabled, binding adm1272 to the adm1275 would fail due to PEC error. See below: adm1275: probe of xxxx failed with error -74 Diagnosis: Per the datasheet of adm1272, adm1278, adm1293 and amd1294, PMON_CONFIG (0xd4) is 16bits wide. On the other hand, PMON_CONFIG (0xd4) for adm1275 is 8bits wide. The driver should not assume everything is 8bits wide and read only 8bits from it. Solution: If it is adm1272, adm1278, adm1293 and adm1294, use i2c_read_word. Else, use i2c_read_byte Testing: Binding adm1272 to the driver. The change is only tested on adm1272. Signed-off-by: Chu Lin <linchuyuan@google.com> Link: https://lore.kernel.org/r/20200709040612.3977094-1-linchuyuan@google.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-03-08hwmon: (pmbus) Add 'phase' parameter where needed for multi-phase supportGuenter Roeck1-13/+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>
2019-06-23hwmon: (pmbus/adm1275) Fix power sampling supportGuenter Roeck1-19/+65
Not every chip supported by this driver supports setting the number of samples for power averaging. Also, the power monitoring register is not always a 16-bit register, and the configuration bits used for voltage sampling are different depending on the register width. Some conditional code is needed to fix the problem. On top of all that, the compiler complains about problems with FIELD_GET and FIELD_PREP macros if the file is built with W=1. Avoid using those macros to silence the warning. Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com> Cc: Alexander Sverdlin <alexander.sverdlin@nokia.com> Reviewed-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (pmbus/adm1275) support PMBUS_VIRT_*_SAMPLESAdamski, Krzysztof (Nokia - PL/Wroclaw)1-1/+58
The device supports setting the number of samples for averaging the measurements. There are two separate settings - PWR_AVG for averaging PIN and VI_AVG for averaging VIN/VAUX/IOUT, both being part of PMON_CONFIG register. The values are stored as exponent of base 2 of the actual number of samples that will be taken. Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> [groeck: Dropped unused variables] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157Thomas Gleixner1-10/+1
Based on 3 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 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 [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] 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 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 [author] [graeme] [gregory] [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema] [hk] [hemahk]@[ti] [com] 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 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1105 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-02hwmon: (adm1275) Allow setting shunt reg valueKun Yi1-2/+13
The ADM series of hotswap controllers support extending the current measurement range by using a sensing resistor value other than the typical 1 mOhm. For example, using a 0.5 mOhm sensing resistor doubles the maximal current can be measured. Current driver assumes a shunt resistor value of 1 mOhm in calculation, meaning for other resistor values, hwmon will report scaled current/power measurements. This patch parses device tree parameter "shunt-resistor-micro-ohms", if there is one. Signed-off-by: Kun Yi <kunyi@google.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-03-22hwmon: (pmbus/adm1275) Add support for ADM1272Guenter Roeck1-1/+66
The chip is quite similar to other chips in the series, but as usual it comes with its own quirks. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-03-10hwmon: (pmbus/adm1275) Accept negative page register valuesGuenter Roeck1-2/+2
A negative page register value means that no page needs to be selected. This is used by status register read operations and needs to be accepted. The failure to do so so results in missed status and limit registers. Fixes: da8e48ab483e1 ("hwmon: (pmbus) Always call _pmbus_read_byte in core driver") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-03-27driver: (adm1275) set the m,b and R coefficients correctly for powerShikhar Dogra1-2/+2
Seems like coefficient values for m, b and R under power have been put in the wrong order. Rearranging them properly to get correct values of coefficients for power. For specs, please refer to table 7 (page 35) on http://www.analog.com/media/en/technical-documentation/data-sheets/ADM1075.pdf Fixes: 904b296f308d ("hwmon: (adm1275) Introduce configuration data structure for coeffcients") Signed-off-by: Shikhar Dogra <shidogra@cisco.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-02hwmon: (adm1275) Enable adm1278 VOUT samplingYi Li1-4/+16
The adm1278 can optionally monitor the VOUT pin. This functionality is not enabled at reset, so PMON_CONFIG needs to be modified in order to enable it. Signed-off-by: Yi Li <adamliyi@msn.com> Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-03-05hwmon: (adm1275) Add support for ADM1278Guenter Roeck1-1/+55
ADM1278 is mostly compatible to other chips of the same series. Besides the usual difference in coefficients, it supports a temperature sensor, and it can measure both input and output voltage at the same time. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-08-09hwmon: (adm1275) Add support for ADM1293 and ADM1294Guenter Roeck1-8/+133
ADM1293 and ADM1294 are mostly compatible with other chips of the same series, but have more configuration options. There are also some differences in register details. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-08-09hwmon: (adm1275) Introduce new feature flagsGuenter Roeck1-43/+54
Introduce have_vout, have_vaux_status, have_pin_max, and have_uc_fault to simplify adding support for new chips. Also simplify error returns where appropriate to return immediately on error. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-08-09hwmon: (adm1275) Introduce configuration data structure for coeffcientsGuenter Roeck1-45/+68
Each new chip supported by the driver has a new set of coefficients, making hard-coding coefficients more and more cumbersome. Introduce a datastructure and table to simplify configuration. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-08-09hwmon: (adm1275) Use BIT macroGuenter Roeck1-9/+10
Use BIT macro to simplify adding new bit masks. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-03-18hwmon: (adm1275) Add support for ADM1075Guenter Roeck1-4/+84
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-03-18hwmon: (pmbus) Simplify remove functionsGuenter Roeck1-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>
2012-03-18hwmon: (pmbus) Convert pmbus drivers to use devm_kzallocGuenter Roeck1-13/+3
Marginally less code and eliminate the possibility of memory leaks. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-03-18hwmon: convert drivers/hwmon/* to use module_i2c_driver()Axel Lin1-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>
2012-01-05hwmon: (pmbus/adm1275) Validate device IDGuenter Roeck1-21/+50
Since manufacturer and device ID are known, read and validate it. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> [Dan Carpenter <dan.carpenter@oracle.com>: Fixed memory leak] Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
2011-10-24hwmon: (pmbus) Always call _pmbus_read_byte in core driverGuenter Roeck1-1/+1
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>
2011-10-24hwmon: (pmbus/adm1275) Add support for ADM1276Guenter Roeck1-8/+51
ADM1276 is mostly compatible to ADM1275, with added support for input power measurement. Add support for it to the ADM1275 driver. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
2011-10-24hwmon: (pmbus/adm1275) Add support for second current limitGuenter Roeck1-7/+88
ADM1275 supports a second current limit, which can be configured as either lower or upper limit. Add support for it and report it as either lower or upper critical current limit. Also replace error return code EINVAL for unsupported pages with ENXIO as this is more appropriate for the observed condition. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
2011-10-24hwmon: (pmbus) Don't return errors from driver remove functionsGuenter Roeck1-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>
2011-07-28hwmon: (adm1275) Add support for peak attributesGuenter Roeck1-0/+60
Add support for voltage and current peak (historic maximum) attributes. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
2011-07-28hwmon: (pmbus) Add support for VID output voltage modeGuenter Roeck1-3/+3
In VID mode, output voltages are measured and reported as VID values, and have to be converted to voltages using VID conversion tables or functions. Support is added for VR11 only at this time. This patch enables support for PMBus devices supporting VID VR11 based output voltage selection such as NCP4200 and NCP4208. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
2011-07-28hwmon: (pmbus) Move PMBus drivers to drivers/hwmon/pmbusGuenter Roeck1-0/+131
Since the number of PMBus drivers is getting large, move them into directory drivers/hwmon/pmbus to improve readability and scalability. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>