aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorAlan Tull <atull@opensource.altera.com>2014-10-15 14:55:10 -0400
committerGuenter Roeck <linux@roeck-us.net>2014-11-30 23:13:13 -0500
commit77aa3585805920d871e09b9a60d9635e51b03d21 (patch)
tree84233bc0790cff63430ccf67d731aa856b488feb /drivers/hwmon
parentddbb4db4ced1ba784fcd3500179a7291b6c5d7b7 (diff)
hwmon: (ltc2978) Add regulator support
Add simple on/off regulator support for ltc2978 and other pmbus parts supported by the ltc2978 driver. Signed-off-by: Alan Tull <atull@opensource.altera.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Mark Brown <broonie@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pmbus/Kconfig11
-rw-r--r--drivers/hwmon/pmbus/ltc2978.c39
2 files changed, 47 insertions, 3 deletions
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 6e1e4935fc62..a674cd83a4e2 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -47,15 +47,22 @@ config SENSORS_LM25066
47 be called lm25066. 47 be called lm25066.
48 48
49config SENSORS_LTC2978 49config SENSORS_LTC2978
50 tristate "Linear Technologies LTC2974, LTC2978, LTC3880, and LTC3883" 50 tristate "Linear Technologies LTC2978 and compatibles"
51 default n 51 default n
52 help 52 help
53 If you say yes here you get hardware monitoring support for Linear 53 If you say yes here you get hardware monitoring support for Linear
54 Technology LTC2974, LTC2978, LTC3880, and LTC3883. 54 Technology LTC2974, LTC2977, LTC2978, LTC3880, LTC3883, and LTM4676.
55 55
56 This driver can also be built as a module. If so, the module will 56 This driver can also be built as a module. If so, the module will
57 be called ltc2978. 57 be called ltc2978.
58 58
59config SENSORS_LTC2978_REGULATOR
60 boolean "Regulator support for LTC2978 and compatibles"
61 depends on SENSORS_LTC2978 && REGULATOR
62 help
63 If you say yes here you get regulator support for Linear
64 Technology LTC2974, LTC2977, LTC2978, LTC3880, LTC3883, and LTM4676.
65
59config SENSORS_MAX16064 66config SENSORS_MAX16064
60 tristate "Maxim MAX16064" 67 tristate "Maxim MAX16064"
61 default n 68 default n
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index e24ed521051a..0835050ec245 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -22,6 +22,7 @@
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/regulator/driver.h>
25#include "pmbus.h" 26#include "pmbus.h"
26 27
27enum chips { ltc2974, ltc2977, ltc2978, ltc3880, ltc3883, ltm4676 }; 28enum chips { ltc2974, ltc2977, ltc2978, ltc3880, ltc3883, ltm4676 };
@@ -374,6 +375,19 @@ static const struct i2c_device_id ltc2978_id[] = {
374}; 375};
375MODULE_DEVICE_TABLE(i2c, ltc2978_id); 376MODULE_DEVICE_TABLE(i2c, ltc2978_id);
376 377
378#if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
379static const struct regulator_desc ltc2978_reg_desc[] = {
380 PMBUS_REGULATOR("vout", 0),
381 PMBUS_REGULATOR("vout", 1),
382 PMBUS_REGULATOR("vout", 2),
383 PMBUS_REGULATOR("vout", 3),
384 PMBUS_REGULATOR("vout", 4),
385 PMBUS_REGULATOR("vout", 5),
386 PMBUS_REGULATOR("vout", 6),
387 PMBUS_REGULATOR("vout", 7),
388};
389#endif /* CONFIG_SENSORS_LTC2978_REGULATOR */
390
377static int ltc2978_probe(struct i2c_client *client, 391static int ltc2978_probe(struct i2c_client *client,
378 const struct i2c_device_id *id) 392 const struct i2c_device_id *id)
379{ 393{
@@ -487,13 +501,36 @@ static int ltc2978_probe(struct i2c_client *client,
487 default: 501 default:
488 return -ENODEV; 502 return -ENODEV;
489 } 503 }
504
505#if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
506 info->num_regulators = info->pages;
507 info->reg_desc = ltc2978_reg_desc;
508 if (info->num_regulators > ARRAY_SIZE(ltc2978_reg_desc)) {
509 dev_err(&client->dev, "num_regulators too large!");
510 info->num_regulators = ARRAY_SIZE(ltc2978_reg_desc);
511 }
512#endif
513
490 return pmbus_do_probe(client, id, info); 514 return pmbus_do_probe(client, id, info);
491} 515}
492 516
493/* This is the driver that will be inserted */ 517#ifdef CONFIG_OF
518static const struct of_device_id ltc2978_of_match[] = {
519 { .compatible = "lltc,ltc2974" },
520 { .compatible = "lltc,ltc2977" },
521 { .compatible = "lltc,ltc2978" },
522 { .compatible = "lltc,ltc3880" },
523 { .compatible = "lltc,ltc3883" },
524 { .compatible = "lltc,ltm4676" },
525 { }
526};
527MODULE_DEVICE_TABLE(of, ltc2978_of_match);
528#endif
529
494static struct i2c_driver ltc2978_driver = { 530static struct i2c_driver ltc2978_driver = {
495 .driver = { 531 .driver = {
496 .name = "ltc2978", 532 .name = "ltc2978",
533 .of_match_table = of_match_ptr(ltc2978_of_match),
497 }, 534 },
498 .probe = ltc2978_probe, 535 .probe = ltc2978_probe,
499 .remove = pmbus_do_remove, 536 .remove = pmbus_do_remove,