All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux dev-4.7] hwmon: (pmbus) Add support for MPS Multi-phase mp5023 controller (Pre-release)
@ 2021-12-06  9:47 Howard Chiu
  2021-12-06  9:56 ` Joel Stanley
  0 siblings, 1 reply; 2+ messages in thread
From: Howard Chiu @ 2021-12-06  9:47 UTC (permalink / raw)
  To: openbmc, joel; +Cc: Howard Chiu

Add support for mp5023 device from Monolithic Power Systems, Inc. (MPS)
vendor. This is a Hot-Swap Controller

This patch is a pre-release version for OpenBMC because I did not documentate it well yet.

Signed-off-by: Howard Chiu <howard.chiu@quantatw.com>
Change-Id: Ice992a1681e3800eb2b16d1622ab78eed0b4113f
---
 drivers/hwmon/pmbus/Kconfig  |  9 +++++
 drivers/hwmon/pmbus/Makefile |  1 +
 drivers/hwmon/pmbus/mp5023.c | 66 ++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+)
 create mode 100644 drivers/hwmon/pmbus/mp5023.c

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index ffb609cee3a4..b56bd8542864 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -276,6 +276,15 @@ config SENSORS_MP2975
 	  This driver can also be built as a module. If so, the module will
 	  be called mp2975.
 
+config SENSORS_MP5023
+	tristate "MPS MP5023"
+	help
+	  If you say yes here you get hardware monitoring support for MPS
+	  MP5023.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called mp5023.
+
 config SENSORS_PIM4328
 	tristate "Flex PIM4328 and compatibles"
 	help
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 0ed4d596a948..61cdc24b1309 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_SENSORS_MAX34440)	+= max34440.o
 obj-$(CONFIG_SENSORS_MAX8688)	+= max8688.o
 obj-$(CONFIG_SENSORS_MP2888)	+= mp2888.o
 obj-$(CONFIG_SENSORS_MP2975)	+= mp2975.o
+obj-$(CONFIG_SENSORS_MP5023)	+= mp5023.o
 obj-$(CONFIG_SENSORS_PM6764TR)	+= pm6764tr.o
 obj-$(CONFIG_SENSORS_PXE1610)	+= pxe1610.o
 obj-$(CONFIG_SENSORS_Q54SJ108A2)	+= q54sj108a2.o
diff --git a/drivers/hwmon/pmbus/mp5023.c b/drivers/hwmon/pmbus/mp5023.c
new file mode 100644
index 000000000000..2d2048c9765e
--- /dev/null
+++ b/drivers/hwmon/pmbus/mp5023.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for MPS MP5023 Hot-Swap Controller
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/of_device.h>
+#include "pmbus.h"
+
+static struct pmbus_driver_info mp5023_info = {
+	.pages = 1,
+
+	.format[PSC_VOLTAGE_IN] = direct,
+	.format[PSC_VOLTAGE_OUT] = direct,
+	.format[PSC_CURRENT_OUT] = direct,
+	.format[PSC_POWER] = direct,
+	.format[PSC_TEMPERATURE] = direct,
+
+	.m[PSC_VOLTAGE_IN] = 32,
+	.b[PSC_VOLTAGE_IN] = 0,
+	.R[PSC_VOLTAGE_IN] = 0,
+	.m[PSC_VOLTAGE_OUT] = 32,
+	.b[PSC_VOLTAGE_OUT] = 0,
+	.R[PSC_VOLTAGE_OUT] = 0,
+	.m[PSC_CURRENT_OUT] = 16,
+	.b[PSC_CURRENT_OUT] = 0,
+	.R[PSC_CURRENT_OUT] = 0,
+	.m[PSC_POWER] = 1,
+	.b[PSC_POWER] = 0,
+	.R[PSC_POWER] = 0,
+	.m[PSC_TEMPERATURE] = 2,
+	.b[PSC_TEMPERATURE] = 0,
+	.R[PSC_TEMPERATURE] = 0,
+
+	.func[0] =
+		PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN |
+		PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT |
+		PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
+};
+
+static int mp5023_probe(struct i2c_client *client)
+{
+	return pmbus_do_probe(client, &mp5023_info);
+}
+
+static const struct of_device_id __maybe_unused mp5023_of_match[] = {
+	{ .compatible = "mps,mp5023", },
+	{}
+};
+
+MODULE_DEVICE_TABLE(of, mp5023_of_match);
+
+static struct i2c_driver mp5023_driver = {
+	.driver = {
+		   .name = "mp5023",
+		   .of_match_table = of_match_ptr(mp5023_of_match),
+	},
+	.probe_new = mp5023_probe,
+};
+
+module_i2c_driver(mp5023_driver);
+
+MODULE_AUTHOR("Howard Chiu <howard.chiu@quantatw.com>");
+MODULE_DESCRIPTION("PMBus driver for MPS MP5023 HSC");
+MODULE_LICENSE("GPL");
-- 
2.25.1


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

* Re: [PATCH linux dev-4.7] hwmon: (pmbus) Add support for MPS Multi-phase mp5023 controller (Pre-release)
  2021-12-06  9:47 [PATCH linux dev-4.7] hwmon: (pmbus) Add support for MPS Multi-phase mp5023 controller (Pre-release) Howard Chiu
@ 2021-12-06  9:56 ` Joel Stanley
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Stanley @ 2021-12-06  9:56 UTC (permalink / raw)
  To: Howard Chiu; +Cc: OpenBMC Maillist, Howard Chiu

Hi Howard,

On Mon, 6 Dec 2021 at 09:49, Howard Chiu <howard10703049@gmail.com> wrote:
>
> Add support for mp5023 device from Monolithic Power Systems, Inc. (MPS)
> vendor. This is a Hot-Swap Controller
>
> This patch is a pre-release version for OpenBMC because I did not documentate it well yet.

It would be helpful if you linked to the upstream submission, if
you've made one.

This is a very simple patch, and Gunter is a very responsive
maintainer. I strongly encourage you to submit it upstream and then we
can merge that version into the openbmc tree.

>
> Signed-off-by: Howard Chiu <howard.chiu@quantatw.com>
> Change-Id: Ice992a1681e3800eb2b16d1622ab78eed0b4113f

Please remove your Gerrit Change-Id lines, we do not keep them in the
kernel tree. If you run scripts/checkpatch.pl on your file before
submitting, it will produce a warning about this.

Please run checkpatch against all of your patches before submitting.

FInally, you mention dev-4.7 in your subject. We don't maintain that
tree anymore; I am only merging patches for dev-5.15. Please test your
patches against that kernel version and resubmit.

Cheers,

Joel

> ---
>  drivers/hwmon/pmbus/Kconfig  |  9 +++++
>  drivers/hwmon/pmbus/Makefile |  1 +
>  drivers/hwmon/pmbus/mp5023.c | 66 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 76 insertions(+)
>  create mode 100644 drivers/hwmon/pmbus/mp5023.c
>
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index ffb609cee3a4..b56bd8542864 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -276,6 +276,15 @@ config SENSORS_MP2975
>           This driver can also be built as a module. If so, the module will
>           be called mp2975.
>
> +config SENSORS_MP5023
> +       tristate "MPS MP5023"
> +       help
> +         If you say yes here you get hardware monitoring support for MPS
> +         MP5023.
> +
> +         This driver can also be built as a module. If so, the module will
> +         be called mp5023.
> +
>  config SENSORS_PIM4328
>         tristate "Flex PIM4328 and compatibles"
>         help
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 0ed4d596a948..61cdc24b1309 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -31,6 +31,7 @@ obj-$(CONFIG_SENSORS_MAX34440)        += max34440.o
>  obj-$(CONFIG_SENSORS_MAX8688)  += max8688.o
>  obj-$(CONFIG_SENSORS_MP2888)   += mp2888.o
>  obj-$(CONFIG_SENSORS_MP2975)   += mp2975.o
> +obj-$(CONFIG_SENSORS_MP5023)   += mp5023.o
>  obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o
>  obj-$(CONFIG_SENSORS_PXE1610)  += pxe1610.o
>  obj-$(CONFIG_SENSORS_Q54SJ108A2)       += q54sj108a2.o
> diff --git a/drivers/hwmon/pmbus/mp5023.c b/drivers/hwmon/pmbus/mp5023.c
> new file mode 100644
> index 000000000000..2d2048c9765e
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/mp5023.c
> @@ -0,0 +1,66 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Driver for MPS MP5023 Hot-Swap Controller
> + */
> +
> +#include <linux/module.h>
> +#include <linux/i2c.h>
> +#include <linux/of_device.h>
> +#include "pmbus.h"
> +
> +static struct pmbus_driver_info mp5023_info = {
> +       .pages = 1,
> +
> +       .format[PSC_VOLTAGE_IN] = direct,
> +       .format[PSC_VOLTAGE_OUT] = direct,
> +       .format[PSC_CURRENT_OUT] = direct,
> +       .format[PSC_POWER] = direct,
> +       .format[PSC_TEMPERATURE] = direct,
> +
> +       .m[PSC_VOLTAGE_IN] = 32,
> +       .b[PSC_VOLTAGE_IN] = 0,
> +       .R[PSC_VOLTAGE_IN] = 0,
> +       .m[PSC_VOLTAGE_OUT] = 32,
> +       .b[PSC_VOLTAGE_OUT] = 0,
> +       .R[PSC_VOLTAGE_OUT] = 0,
> +       .m[PSC_CURRENT_OUT] = 16,
> +       .b[PSC_CURRENT_OUT] = 0,
> +       .R[PSC_CURRENT_OUT] = 0,
> +       .m[PSC_POWER] = 1,
> +       .b[PSC_POWER] = 0,
> +       .R[PSC_POWER] = 0,
> +       .m[PSC_TEMPERATURE] = 2,
> +       .b[PSC_TEMPERATURE] = 0,
> +       .R[PSC_TEMPERATURE] = 0,
> +
> +       .func[0] =
> +               PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN |
> +               PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT |
> +               PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
> +};
> +
> +static int mp5023_probe(struct i2c_client *client)
> +{
> +       return pmbus_do_probe(client, &mp5023_info);
> +}
> +
> +static const struct of_device_id __maybe_unused mp5023_of_match[] = {
> +       { .compatible = "mps,mp5023", },
> +       {}
> +};
> +
> +MODULE_DEVICE_TABLE(of, mp5023_of_match);
> +
> +static struct i2c_driver mp5023_driver = {
> +       .driver = {
> +                  .name = "mp5023",
> +                  .of_match_table = of_match_ptr(mp5023_of_match),
> +       },
> +       .probe_new = mp5023_probe,
> +};
> +
> +module_i2c_driver(mp5023_driver);
> +
> +MODULE_AUTHOR("Howard Chiu <howard.chiu@quantatw.com>");
> +MODULE_DESCRIPTION("PMBus driver for MPS MP5023 HSC");
> +MODULE_LICENSE("GPL");
> --
> 2.25.1
>

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

end of thread, other threads:[~2021-12-06  9:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06  9:47 [PATCH linux dev-4.7] hwmon: (pmbus) Add support for MPS Multi-phase mp5023 controller (Pre-release) Howard Chiu
2021-12-06  9:56 ` Joel Stanley

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.