From: <atull@opensource.altera.com>
To: linux@roeck-us.net, jdelvare@suse.de
Cc: lm-sensors@lm-sensors.org, lgirdwood@gmail.com,
broonie@kernel.org, linux-kernel@vger.kernel.org,
delicious.quinoa@gmail.com, dinguyen@opensource.altera.com,
yvanderv@opensource.altera.com,
Alan Tull <atull@opensource.altera.com>
Subject: [lm-sensors] [PATCH v2 2/2] pmbus: ltc2978: add regulator gating
Date: Fri, 22 Aug 2014 21:11:34 +0000 [thread overview]
Message-ID: <1408741894-24879-3-git-send-email-atull@opensource.altera.com> (raw)
In-Reply-To: <1408741894-24879-1-git-send-email-atull@opensource.altera.com>
From: Alan Tull <atull@opensource.altera.com>
Add regulator with support for enabling or disabling all
supplies.
Signed-off-by: Alan Tull <atull@opensource.altera.com>
v2: Remove '#include <linux/regulator/machine.h>'
Kconfig fixes
Remove hardwired regulator_init_data
---
drivers/hwmon/pmbus/Kconfig | 7 +++++
drivers/hwmon/pmbus/ltc2978.c | 60 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 6e1e493..79117b7 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -56,6 +56,13 @@ config SENSORS_LTC2978
This driver can also be built as a module. If so, the module will
be called ltc2978.
+config SENSORS_LTC2978_REGULATOR
+ boolean "Regulator support for LTC2974, LTC2978, LTC3880, and LTC3883"
+ depends on SENSORS_LTC2978 && REGULATOR
+ help
+ If you say yes here you get regulator support for Linear
+ Technology LTC2974, LTC2978, LTC3880, and LTC3883.
+
config SENSORS_MAX16064
tristate "Maxim MAX16064"
default n
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index e24ed52..2bdcfe2 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -20,6 +20,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
+#include <linux/regulator/driver.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include "pmbus.h"
@@ -151,6 +152,60 @@ static int ltc2978_read_word_data_common(struct i2c_client *client, int page,
return ret;
}
+#if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
+static int ltc2978_write_pmbus_operation(struct regulator_dev *rdev, u8 value)
+{
+ struct device *dev = rdev_get_dev(rdev);
+ struct i2c_client *client = to_i2c_client(dev->parent);
+ int ret;
+
+ ret = pmbus_set_page(client, 0xff);
+ if (ret < 0)
+ return ret;
+
+ return i2c_smbus_write_byte_data(client, PMBUS_OPERATION, value);
+}
+
+static int ltc2978_enable_all(struct regulator_dev *rdev)
+{
+ return ltc2978_write_pmbus_operation(rdev, 0x80);
+}
+
+static int ltc2978_disable_all(struct regulator_dev *rdev)
+{
+ return ltc2978_write_pmbus_operation(rdev, 0);
+}
+
+static int ltc2978_is_enabled(struct regulator_dev *rdev)
+{
+ struct device *dev = rdev_get_dev(rdev);
+ struct i2c_client *client = to_i2c_client(dev->parent);
+ int ret;
+
+ ret = pmbus_set_page(client, 0xff);
+ if (ret < 0)
+ return ret;
+
+ ret = i2c_smbus_read_byte_data(client, PMBUS_OPERATION);
+ if (ret < 0)
+ return ret;
+
+ return !!(ret & 0x80);
+}
+
+static struct regulator_ops ltc2978_regulator_ops = {
+ .enable = ltc2978_enable_all,
+ .disable = ltc2978_disable_all,
+ .is_enabled = ltc2978_is_enabled,
+};
+
+static const struct regulator_desc ltc2978_reg_desc = {
+ .name = "ltc2978",
+ .ops = <c2978_regulator_ops,
+ .owner = THIS_MODULE,
+};
+#endif
+
static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg)
{
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
@@ -487,6 +542,11 @@ static int ltc2978_probe(struct i2c_client *client,
default:
return -ENODEV;
}
+
+#if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
+ info->reg_desc = <c2978_reg_desc;
+#endif
+
return pmbus_do_probe(client, id, info);
}
--
1.7.9.5
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: <atull@opensource.altera.com>
To: <linux@roeck-us.net>, <jdelvare@suse.de>
Cc: <lm-sensors@lm-sensors.org>, <lgirdwood@gmail.com>,
<broonie@kernel.org>, <linux-kernel@vger.kernel.org>,
<delicious.quinoa@gmail.com>, <dinguyen@opensource.altera.com>,
<yvanderv@opensource.altera.com>,
Alan Tull <atull@opensource.altera.com>
Subject: [PATCH v2 2/2] pmbus: ltc2978: add regulator gating
Date: Fri, 22 Aug 2014 16:11:34 -0500 [thread overview]
Message-ID: <1408741894-24879-3-git-send-email-atull@opensource.altera.com> (raw)
In-Reply-To: <1408741894-24879-1-git-send-email-atull@opensource.altera.com>
From: Alan Tull <atull@opensource.altera.com>
Add regulator with support for enabling or disabling all
supplies.
Signed-off-by: Alan Tull <atull@opensource.altera.com>
v2: Remove '#include <linux/regulator/machine.h>'
Kconfig fixes
Remove hardwired regulator_init_data
---
drivers/hwmon/pmbus/Kconfig | 7 +++++
drivers/hwmon/pmbus/ltc2978.c | 60 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 6e1e493..79117b7 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -56,6 +56,13 @@ config SENSORS_LTC2978
This driver can also be built as a module. If so, the module will
be called ltc2978.
+config SENSORS_LTC2978_REGULATOR
+ boolean "Regulator support for LTC2974, LTC2978, LTC3880, and LTC3883"
+ depends on SENSORS_LTC2978 && REGULATOR
+ help
+ If you say yes here you get regulator support for Linear
+ Technology LTC2974, LTC2978, LTC3880, and LTC3883.
+
config SENSORS_MAX16064
tristate "Maxim MAX16064"
default n
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index e24ed52..2bdcfe2 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -20,6 +20,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
+#include <linux/regulator/driver.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include "pmbus.h"
@@ -151,6 +152,60 @@ static int ltc2978_read_word_data_common(struct i2c_client *client, int page,
return ret;
}
+#if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
+static int ltc2978_write_pmbus_operation(struct regulator_dev *rdev, u8 value)
+{
+ struct device *dev = rdev_get_dev(rdev);
+ struct i2c_client *client = to_i2c_client(dev->parent);
+ int ret;
+
+ ret = pmbus_set_page(client, 0xff);
+ if (ret < 0)
+ return ret;
+
+ return i2c_smbus_write_byte_data(client, PMBUS_OPERATION, value);
+}
+
+static int ltc2978_enable_all(struct regulator_dev *rdev)
+{
+ return ltc2978_write_pmbus_operation(rdev, 0x80);
+}
+
+static int ltc2978_disable_all(struct regulator_dev *rdev)
+{
+ return ltc2978_write_pmbus_operation(rdev, 0);
+}
+
+static int ltc2978_is_enabled(struct regulator_dev *rdev)
+{
+ struct device *dev = rdev_get_dev(rdev);
+ struct i2c_client *client = to_i2c_client(dev->parent);
+ int ret;
+
+ ret = pmbus_set_page(client, 0xff);
+ if (ret < 0)
+ return ret;
+
+ ret = i2c_smbus_read_byte_data(client, PMBUS_OPERATION);
+ if (ret < 0)
+ return ret;
+
+ return !!(ret & 0x80);
+}
+
+static struct regulator_ops ltc2978_regulator_ops = {
+ .enable = ltc2978_enable_all,
+ .disable = ltc2978_disable_all,
+ .is_enabled = ltc2978_is_enabled,
+};
+
+static const struct regulator_desc ltc2978_reg_desc = {
+ .name = "ltc2978",
+ .ops = <c2978_regulator_ops,
+ .owner = THIS_MODULE,
+};
+#endif
+
static int ltc2978_read_word_data(struct i2c_client *client, int page, int reg)
{
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
@@ -487,6 +542,11 @@ static int ltc2978_probe(struct i2c_client *client,
default:
return -ENODEV;
}
+
+#if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
+ info->reg_desc = <c2978_reg_desc;
+#endif
+
return pmbus_do_probe(client, id, info);
}
--
1.7.9.5
next prev parent reply other threads:[~2014-08-22 21:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-22 21:11 [lm-sensors] [PATCH v2 0/2] dd regulator support for pmbus and ltc2978 atull
2014-08-22 21:11 ` atull
2014-08-22 21:11 ` [lm-sensors] [PATCH v2 1/2] pmbus: add regulator support atull
2014-08-22 21:11 ` atull
2014-08-22 21:44 ` [lm-sensors] " Mark Brown
2014-08-22 21:44 ` Mark Brown
2014-08-23 0:31 ` [lm-sensors] " atull
2014-08-23 0:31 ` atull
2014-08-23 14:00 ` [lm-sensors] " Guenter Roeck
2014-08-23 14:00 ` Guenter Roeck
2014-08-23 14:54 ` [lm-sensors] " Mark Brown
2014-08-23 14:54 ` Mark Brown
2014-08-24 0:48 ` [lm-sensors] " Alan Tull
2014-08-24 0:48 ` Alan Tull
2014-08-22 21:11 ` atull [this message]
2014-08-22 21:11 ` [PATCH v2 2/2] pmbus: ltc2978: add regulator gating atull
2014-08-22 21:45 ` [lm-sensors] " Mark Brown
2014-08-22 21:45 ` Mark Brown
2014-08-23 15:10 ` [lm-sensors] " Guenter Roeck
2014-08-23 15:10 ` Guenter Roeck
2014-08-23 15:53 ` [lm-sensors] " Mark Brown
2014-08-23 15:53 ` Mark Brown
2014-08-24 13:30 ` [lm-sensors] " Alan Tull
2014-08-24 13:30 ` Alan Tull
2014-08-25 17:02 ` [lm-sensors] " Guenter Roeck
2014-08-25 17:02 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408741894-24879-3-git-send-email-atull@opensource.altera.com \
--to=atull@opensource.altera.com \
--cc=broonie@kernel.org \
--cc=delicious.quinoa@gmail.com \
--cc=dinguyen@opensource.altera.com \
--cc=jdelvare@suse.de \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
--cc=yvanderv@opensource.altera.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.