diff options
Diffstat (limited to 'drivers/hwmon/pmbus/ltc2978.c')
-rw-r--r-- | drivers/hwmon/pmbus/ltc2978.c | 39 |
1 files changed, 38 insertions, 1 deletions
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 | ||
27 | enum chips { ltc2974, ltc2977, ltc2978, ltc3880, ltc3883, ltm4676 }; | 28 | enum chips { ltc2974, ltc2977, ltc2978, ltc3880, ltc3883, ltm4676 }; |
@@ -374,6 +375,19 @@ static const struct i2c_device_id ltc2978_id[] = { | |||
374 | }; | 375 | }; |
375 | MODULE_DEVICE_TABLE(i2c, ltc2978_id); | 376 | MODULE_DEVICE_TABLE(i2c, ltc2978_id); |
376 | 377 | ||
378 | #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR) | ||
379 | static 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 | |||
377 | static int ltc2978_probe(struct i2c_client *client, | 391 | static 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 |
518 | static 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 | }; | ||
527 | MODULE_DEVICE_TABLE(of, ltc2978_of_match); | ||
528 | #endif | ||
529 | |||
494 | static struct i2c_driver ltc2978_driver = { | 530 | static 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, |