All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (pmbus) Add driver for STMicroelectronics PM6764TR Voltage Regulator
@ 2020-10-22 11:51 Charles Hsu
  2020-10-22 13:04 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Hsu @ 2020-10-22 11:51 UTC (permalink / raw)
  To: netdev

Add the pmbus driver for the STMicroelectronics pm6764tr voltage regulator.

Signed-off-by: Charles Hsu <hsu.yungteng@gmail.com>
---
 drivers/hwmon/pmbus/Kconfig    |  8 ++++
 drivers/hwmon/pmbus/Makefile   |  1 +
 drivers/hwmon/pmbus/pm6764tr.c | 76 ++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/hwmon/pmbus/pm6764tr.c

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index a25faf69fce3..e976997ee163 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -287,4 +287,12 @@ config SENSORS_ZL6100
   This driver can also be built as a module. If so, the module will
   be called zl6100.

+config SENSORS_PM6764TR
+ tristate "PM6764TR"
+ help
+  If you say yes here you get hardware monitoring support for PM6764TR.
+
+  This driver can also be built as a module. If so, the module will
+  be called pm6764tr.
+
 endif # PMBUS
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 4c97ad0bd791..bb89fcf9544d 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -32,3 +32,4 @@ obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o
 obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o
 obj-$(CONFIG_SENSORS_XDPE122) += xdpe12284.o
 obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o
+obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o
\ No newline at end of file
diff --git a/drivers/hwmon/pmbus/pm6764tr.c b/drivers/hwmon/pmbus/pm6764tr.c
new file mode 100644
index 000000000000..e03b1441268e
--- /dev/null
+++ b/drivers/hwmon/pmbus/pm6764tr.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/i2c.h>
+#include <linux/pmbus.h>
+#include "pmbus.h"
+
+#define PM6764TR_PMBUS_READ_VOUT 0xD4
+
+static int pm6764tr_read_word_data(struct i2c_client *client, int
page, int reg)
+{
+ int ret;
+
+ switch (reg) {
+ case PMBUS_VIRT_READ_VMON:
+ ret = pmbus_read_word_data(client, page,
+   PM6764TR_PMBUS_READ_VOUT);
+ break;
+ default:
+ ret = -ENODATA;
+ break;
+ }
+ return ret;
+}
+
+static struct pmbus_driver_info pm6764tr_info = {
+ .pages = 1,
+ .format[PSC_VOLTAGE_IN] = linear,
+ .format[PSC_VOLTAGE_OUT] = vid,
+ .format[PSC_TEMPERATURE] = linear,
+ .format[PSC_CURRENT_OUT] = linear,
+ .format[PSC_POWER] = linear,
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |  PMBUS_HAVE_PIN |
+    PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_VMON |
+ PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_VOUT |
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
+    .read_word_data = pm6764tr_read_word_data,
+};
+
+static int pm6764tr_probe(struct i2c_client *client,
+  const struct i2c_device_id *id)
+{
+ return pmbus_do_probe(client, id, &pm6764tr_info);
+}
+
+static const struct i2c_device_id pm6764tr_id[] = {
+ {"pm6764tr", 0},
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, pm6764tr_id);
+
+static const struct of_device_id pm6764tr_of_match[] = {
+ {.compatible = "pm6764tr"},
+ {}
+};
+
+static struct i2c_driver pm6764tr_driver = {
+ .driver = {
+   .name = "pm6764tr",
+   .of_match_table = of_match_ptr(pm6764tr_of_match),
+   },
+ .probe = pm6764tr_probe,
+ .remove = pmbus_do_remove,
+ .id_table = pm6764tr_id,
+};
+
+module_i2c_driver(pm6764tr_driver);
+
+MODULE_AUTHOR("Charles Hsu");
+MODULE_DESCRIPTION("PMBus driver for ST PM6764TR");
+MODULE_LICENSE("GPL");
--
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (pmbus) Add driver for STMicroelectronics PM6764TR Voltage Regulator
  2020-10-22 11:51 [PATCH] hwmon: (pmbus) Add driver for STMicroelectronics PM6764TR Voltage Regulator Charles Hsu
@ 2020-10-22 13:04 ` Andrew Lunn
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2020-10-22 13:04 UTC (permalink / raw)
  To: Charles Hsu; +Cc: netdev

On Thu, Oct 22, 2020 at 07:51:51PM +0800, Charles Hsu wrote:
> Add the pmbus driver for the STMicroelectronics pm6764tr voltage regulator.
> 
> Signed-off-by: Charles Hsu <hsu.yungteng@gmail.com>

Hi Charles

Seems a bit odd sending a HWMON driver to the netdev list!


> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 4c97ad0bd791..bb89fcf9544d 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -32,3 +32,4 @@ obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o
>  obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o
>  obj-$(CONFIG_SENSORS_XDPE122) += xdpe12284.o
>  obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o
> +obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o

This file is sorted. Please don't insert at the end.

> +#define PM6764TR_PMBUS_READ_VOUT 0xD4
> +
> +static int pm6764tr_read_word_data(struct i2c_client *client, int
> page, int reg)
> +{
> + int ret;
> +
> + switch (reg) {
> + case PMBUS_VIRT_READ_VMON:
> + ret = pmbus_read_word_data(client, page,
> +   PM6764TR_PMBUS_READ_VOUT);
> + break;
> + default:
> + ret = -ENODATA;
> + break;
> + }
> + return ret;
> +}


It looks like your mailer has corrupted your patch.

   Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] hwmon: (pmbus) Add driver for STMicroelectronics PM6764TR Voltage Regulator
@ 2020-10-22 12:00 Charles Hsu
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Hsu @ 2020-10-22 12:00 UTC (permalink / raw)
  To: linux-kernel

Add the pmbus driver for the STMicroelectronics pm6764tr voltage regulator.

Signed-off-by: Charles Hsu <hsu.yungteng@gmail.com>
---
 drivers/hwmon/pmbus/Kconfig    |  8 ++++
 drivers/hwmon/pmbus/Makefile   |  1 +
 drivers/hwmon/pmbus/pm6764tr.c | 76 ++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/hwmon/pmbus/pm6764tr.c

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index a25faf69fce3..e976997ee163 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -287,4 +287,12 @@ config SENSORS_ZL6100
   This driver can also be built as a module. If so, the module will
   be called zl6100.

+config SENSORS_PM6764TR
+ tristate "PM6764TR"
+ help
+  If you say yes here you get hardware monitoring support for PM6764TR.
+
+  This driver can also be built as a module. If so, the module will
+  be called pm6764tr.
+
 endif # PMBUS
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 4c97ad0bd791..bb89fcf9544d 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -32,3 +32,4 @@ obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o
 obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o
 obj-$(CONFIG_SENSORS_XDPE122) += xdpe12284.o
 obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o
+obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o
\ No newline at end of file
diff --git a/drivers/hwmon/pmbus/pm6764tr.c b/drivers/hwmon/pmbus/pm6764tr.c
new file mode 100644
index 000000000000..e03b1441268e
--- /dev/null
+++ b/drivers/hwmon/pmbus/pm6764tr.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/i2c.h>
+#include <linux/pmbus.h>
+#include "pmbus.h"
+
+#define PM6764TR_PMBUS_READ_VOUT 0xD4
+
+static int pm6764tr_read_word_data(struct i2c_client *client, int
page, int reg)
+{
+ int ret;
+
+ switch (reg) {
+ case PMBUS_VIRT_READ_VMON:
+ ret = pmbus_read_word_data(client, page,
+   PM6764TR_PMBUS_READ_VOUT);
+ break;
+ default:
+ ret = -ENODATA;
+ break;
+ }
+ return ret;
+}
+
+static struct pmbus_driver_info pm6764tr_info = {
+ .pages = 1,
+ .format[PSC_VOLTAGE_IN] = linear,
+ .format[PSC_VOLTAGE_OUT] = vid,
+ .format[PSC_TEMPERATURE] = linear,
+ .format[PSC_CURRENT_OUT] = linear,
+ .format[PSC_POWER] = linear,
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |  PMBUS_HAVE_PIN |
+    PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_VMON |
+ PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_VOUT |
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
+    .read_word_data = pm6764tr_read_word_data,
+};
+
+static int pm6764tr_probe(struct i2c_client *client,
+  const struct i2c_device_id *id)
+{
+ return pmbus_do_probe(client, id, &pm6764tr_info);
+}
+
+static const struct i2c_device_id pm6764tr_id[] = {
+ {"pm6764tr", 0},
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, pm6764tr_id);
+
+static const struct of_device_id pm6764tr_of_match[] = {
+ {.compatible = "pm6764tr"},
+ {}
+};
+
+static struct i2c_driver pm6764tr_driver = {
+ .driver = {
+   .name = "pm6764tr",
+   .of_match_table = of_match_ptr(pm6764tr_of_match),
+   },
+ .probe = pm6764tr_probe,
+ .remove = pmbus_do_remove,
+ .id_table = pm6764tr_id,
+};
+
+module_i2c_driver(pm6764tr_driver);
+
+MODULE_AUTHOR("Charles Hsu");
+MODULE_DESCRIPTION("PMBus driver for ST PM6764TR");
+MODULE_LICENSE("GPL");
--
2.25.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-22 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22 11:51 [PATCH] hwmon: (pmbus) Add driver for STMicroelectronics PM6764TR Voltage Regulator Charles Hsu
2020-10-22 13:04 ` Andrew Lunn
2020-10-22 12:00 Charles Hsu

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.