diff mbox series

[1/3] hwmon: (pmbus) add BEL PFE1100 power supply driver

Message ID 20191028234904.12441-2-rentao.bupt@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series hwmon: (pmbus) add driver for BEL PFE1100 and PFE3000 | expand

Commit Message

Tao Ren Oct. 28, 2019, 11:49 p.m. UTC
From: Tao Ren <rentao.bupt@gmail.com>

Add the driver to support BEL PFE1100 which is 1100 Wat AC to DC power
supply. The chip has only 1 page.

Signed-off-by: Tao Ren <rentao.bupt@gmail.com>
---
 drivers/hwmon/pmbus/Kconfig   |  9 +++++
 drivers/hwmon/pmbus/Makefile  |  1 +
 drivers/hwmon/pmbus/bel-pfe.c | 68 +++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 drivers/hwmon/pmbus/bel-pfe.c

Comments

Guenter Roeck Oct. 29, 2019, 12:42 p.m. UTC | #1
On Mon, Oct 28, 2019 at 04:49:02PM -0700, rentao.bupt@gmail.com wrote:
> From: Tao Ren <rentao.bupt@gmail.com>
> 
> Add the driver to support BEL PFE1100 which is 1100 Wat AC to DC power
> supply. The chip has only 1 page.
> 
> Signed-off-by: Tao Ren <rentao.bupt@gmail.com>

Please combine with the next patch.

> ---
>  drivers/hwmon/pmbus/Kconfig   |  9 +++++
>  drivers/hwmon/pmbus/Makefile  |  1 +
>  drivers/hwmon/pmbus/bel-pfe.c | 68 +++++++++++++++++++++++++++++++++++
>  3 files changed, 78 insertions(+)
>  create mode 100644 drivers/hwmon/pmbus/bel-pfe.c
> 
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index d62d69bb7e49..59859979571d 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -36,6 +36,15 @@ config SENSORS_ADM1275
>  	  This driver can also be built as a module. If so, the module will
>  	  be called adm1275.
>  
> +config SENSORS_BEL_PFE
> +	tristate "Bel PFE Compatible Power Supplies"
> +	help
> +	  If you say yes here you get hardware monitoring support for BEL
> +	  PFE1100 and PFE3000 Power Supplies.
> +
> +	  This driver can also be built as a module. If so, the module will
> +	  be called bel-pfe.
> +
>  config SENSORS_IBM_CFFPS
>  	tristate "IBM Common Form Factor Power Supply"
>  	depends on LEDS_CLASS
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 03bacfcfd660..3f8c1014938b 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -6,6 +6,7 @@
>  obj-$(CONFIG_PMBUS)		+= pmbus_core.o
>  obj-$(CONFIG_SENSORS_PMBUS)	+= pmbus.o
>  obj-$(CONFIG_SENSORS_ADM1275)	+= adm1275.o
> +obj-$(CONFIG_SENSORS_BEL_PFE)	+= bel-pfe.o
>  obj-$(CONFIG_SENSORS_IBM_CFFPS)	+= ibm-cffps.o
>  obj-$(CONFIG_SENSORS_INSPUR_IPSPS) += inspur-ipsps.o
>  obj-$(CONFIG_SENSORS_IR35221)	+= ir35221.o
> diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c
> new file mode 100644
> index 000000000000..117f9af21bf3
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/bel-pfe.c
> @@ -0,0 +1,68 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Hardware monitoring driver for BEL PFE family power supplies.
> + *
> + * Copyright (c) 2019 Facebook Inc.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/err.h>
> +#include <linux/i2c.h>

Alphabetic include file order, please.

> +#include "pmbus.h"
> +
> +enum chips {pfe1100};
> +
> +static struct pmbus_driver_info pfe_driver_info[] = {
> +	[pfe1100] = {
> +		.pages = 1,
> +		.format[PSC_VOLTAGE_IN] = linear,
> +		.format[PSC_VOLTAGE_OUT] = linear,
> +		.format[PSC_CURRENT_IN] = linear,
> +		.format[PSC_CURRENT_OUT] = linear,
> +		.format[PSC_POWER] = linear,
> +		.format[PSC_TEMPERATURE] = linear,
> +		.format[PSC_FAN] = linear,
> +
> +		.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> +			   PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> +			   PMBUS_HAVE_POUT |
> +			   PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |
> +			   PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT |
> +			   PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 |
> +			   PMBUS_HAVE_STATUS_TEMP |
> +			   PMBUS_HAVE_FAN12,
> +	},
> +};
> +
> +static int pfe_pmbus_probe(struct i2c_client *client,
> +			   const struct i2c_device_id *id)
> +{
> +	int model;
> +
> +	model = (int)id->driver_data;
> +	return pmbus_do_probe(client, id, &pfe_driver_info[model]);
> +}
> +
> +static const struct i2c_device_id pfe_device_id[] = {
> +	{"pfe1100", pfe1100},
> +	{}
> +};
> +
> +MODULE_DEVICE_TABLE(i2c, pfe_device_id);
> +
> +static struct i2c_driver pfe_pmbus_driver = {
> +	.driver = {
> +		   .name = "bel-pfe",
> +	},
> +	.probe = pfe_pmbus_probe,
> +	.remove = pmbus_do_remove,
> +	.id_table = pfe_device_id,
> +};
> +
> +module_i2c_driver(pfe_pmbus_driver);
> +
> +MODULE_AUTHOR("Tao Ren <rentao.bupt@gmail.com>");
> +MODULE_DESCRIPTION("PMBus driver for BEL PFE Family Power Supplies");
> +MODULE_LICENSE("GPL");
Tao Ren Oct. 29, 2019, 5:53 p.m. UTC | #2
On Tue, Oct 29, 2019 at 05:42:55AM -0700, Guenter Roeck wrote:
> On Mon, Oct 28, 2019 at 04:49:02PM -0700, rentao.bupt@gmail.com wrote:
> > From: Tao Ren <rentao.bupt@gmail.com>
> > 
> > Add the driver to support BEL PFE1100 which is 1100 Wat AC to DC power
> > supply. The chip has only 1 page.
> > 
> > Signed-off-by: Tao Ren <rentao.bupt@gmail.com>
> 
> Please combine with the next patch.

Sure. Will combine the 2 patches in v2.

> > ---
> >  drivers/hwmon/pmbus/Kconfig   |  9 +++++
> >  drivers/hwmon/pmbus/Makefile  |  1 +
> >  drivers/hwmon/pmbus/bel-pfe.c | 68 +++++++++++++++++++++++++++++++++++
> >  3 files changed, 78 insertions(+)
> >  create mode 100644 drivers/hwmon/pmbus/bel-pfe.c
> > 
> > diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> > index d62d69bb7e49..59859979571d 100644
> > --- a/drivers/hwmon/pmbus/Kconfig
> > +++ b/drivers/hwmon/pmbus/Kconfig
> > @@ -36,6 +36,15 @@ config SENSORS_ADM1275
> >  	  This driver can also be built as a module. If so, the module will
> >  	  be called adm1275.
> >  
> > +config SENSORS_BEL_PFE
> > +	tristate "Bel PFE Compatible Power Supplies"
> > +	help
> > +	  If you say yes here you get hardware monitoring support for BEL
> > +	  PFE1100 and PFE3000 Power Supplies.
> > +
> > +	  This driver can also be built as a module. If so, the module will
> > +	  be called bel-pfe.
> > +
> >  config SENSORS_IBM_CFFPS
> >  	tristate "IBM Common Form Factor Power Supply"
> >  	depends on LEDS_CLASS
> > diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> > index 03bacfcfd660..3f8c1014938b 100644
> > --- a/drivers/hwmon/pmbus/Makefile
> > +++ b/drivers/hwmon/pmbus/Makefile
> > @@ -6,6 +6,7 @@
> >  obj-$(CONFIG_PMBUS)		+= pmbus_core.o
> >  obj-$(CONFIG_SENSORS_PMBUS)	+= pmbus.o
> >  obj-$(CONFIG_SENSORS_ADM1275)	+= adm1275.o
> > +obj-$(CONFIG_SENSORS_BEL_PFE)	+= bel-pfe.o
> >  obj-$(CONFIG_SENSORS_IBM_CFFPS)	+= ibm-cffps.o
> >  obj-$(CONFIG_SENSORS_INSPUR_IPSPS) += inspur-ipsps.o
> >  obj-$(CONFIG_SENSORS_IR35221)	+= ir35221.o
> > diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c
> > new file mode 100644
> > index 000000000000..117f9af21bf3
> > --- /dev/null
> > +++ b/drivers/hwmon/pmbus/bel-pfe.c
> > @@ -0,0 +1,68 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Hardware monitoring driver for BEL PFE family power supplies.
> > + *
> > + * Copyright (c) 2019 Facebook Inc.
> > + */
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +#include <linux/init.h>
> > +#include <linux/err.h>
> > +#include <linux/i2c.h>
> 
> Alphabetic include file order, please.

Got it. Will take care of it in v2.
 
> > +#include "pmbus.h"
> > +
> > +enum chips {pfe1100};
> > +
> > +static struct pmbus_driver_info pfe_driver_info[] = {
> > +	[pfe1100] = {
> > +		.pages = 1,
> > +		.format[PSC_VOLTAGE_IN] = linear,
> > +		.format[PSC_VOLTAGE_OUT] = linear,
> > +		.format[PSC_CURRENT_IN] = linear,
> > +		.format[PSC_CURRENT_OUT] = linear,
> > +		.format[PSC_POWER] = linear,
> > +		.format[PSC_TEMPERATURE] = linear,
> > +		.format[PSC_FAN] = linear,
> > +
> > +		.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> > +			   PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> > +			   PMBUS_HAVE_POUT |
> > +			   PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |
> > +			   PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT |
> > +			   PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 |
> > +			   PMBUS_HAVE_STATUS_TEMP |
> > +			   PMBUS_HAVE_FAN12,
> > +	},
> > +};
> > +
> > +static int pfe_pmbus_probe(struct i2c_client *client,
> > +			   const struct i2c_device_id *id)
> > +{
> > +	int model;
> > +
> > +	model = (int)id->driver_data;
> > +	return pmbus_do_probe(client, id, &pfe_driver_info[model]);
> > +}
> > +
> > +static const struct i2c_device_id pfe_device_id[] = {
> > +	{"pfe1100", pfe1100},
> > +	{}
> > +};
> > +
> > +MODULE_DEVICE_TABLE(i2c, pfe_device_id);
> > +
> > +static struct i2c_driver pfe_pmbus_driver = {
> > +	.driver = {
> > +		   .name = "bel-pfe",
> > +	},
> > +	.probe = pfe_pmbus_probe,
> > +	.remove = pmbus_do_remove,
> > +	.id_table = pfe_device_id,
> > +};
> > +
> > +module_i2c_driver(pfe_pmbus_driver);
> > +
> > +MODULE_AUTHOR("Tao Ren <rentao.bupt@gmail.com>");
> > +MODULE_DESCRIPTION("PMBus driver for BEL PFE Family Power Supplies");
> > +MODULE_LICENSE("GPL");
diff mbox series

Patch

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index d62d69bb7e49..59859979571d 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -36,6 +36,15 @@  config SENSORS_ADM1275
 	  This driver can also be built as a module. If so, the module will
 	  be called adm1275.
 
+config SENSORS_BEL_PFE
+	tristate "Bel PFE Compatible Power Supplies"
+	help
+	  If you say yes here you get hardware monitoring support for BEL
+	  PFE1100 and PFE3000 Power Supplies.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called bel-pfe.
+
 config SENSORS_IBM_CFFPS
 	tristate "IBM Common Form Factor Power Supply"
 	depends on LEDS_CLASS
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 03bacfcfd660..3f8c1014938b 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -6,6 +6,7 @@ 
 obj-$(CONFIG_PMBUS)		+= pmbus_core.o
 obj-$(CONFIG_SENSORS_PMBUS)	+= pmbus.o
 obj-$(CONFIG_SENSORS_ADM1275)	+= adm1275.o
+obj-$(CONFIG_SENSORS_BEL_PFE)	+= bel-pfe.o
 obj-$(CONFIG_SENSORS_IBM_CFFPS)	+= ibm-cffps.o
 obj-$(CONFIG_SENSORS_INSPUR_IPSPS) += inspur-ipsps.o
 obj-$(CONFIG_SENSORS_IR35221)	+= ir35221.o
diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c
new file mode 100644
index 000000000000..117f9af21bf3
--- /dev/null
+++ b/drivers/hwmon/pmbus/bel-pfe.c
@@ -0,0 +1,68 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Hardware monitoring driver for BEL PFE family power supplies.
+ *
+ * Copyright (c) 2019 Facebook Inc.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include "pmbus.h"
+
+enum chips {pfe1100};
+
+static struct pmbus_driver_info pfe_driver_info[] = {
+	[pfe1100] = {
+		.pages = 1,
+		.format[PSC_VOLTAGE_IN] = linear,
+		.format[PSC_VOLTAGE_OUT] = linear,
+		.format[PSC_CURRENT_IN] = linear,
+		.format[PSC_CURRENT_OUT] = linear,
+		.format[PSC_POWER] = linear,
+		.format[PSC_TEMPERATURE] = linear,
+		.format[PSC_FAN] = linear,
+
+		.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
+			   PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
+			   PMBUS_HAVE_POUT |
+			   PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |
+			   PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT |
+			   PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 |
+			   PMBUS_HAVE_STATUS_TEMP |
+			   PMBUS_HAVE_FAN12,
+	},
+};
+
+static int pfe_pmbus_probe(struct i2c_client *client,
+			   const struct i2c_device_id *id)
+{
+	int model;
+
+	model = (int)id->driver_data;
+	return pmbus_do_probe(client, id, &pfe_driver_info[model]);
+}
+
+static const struct i2c_device_id pfe_device_id[] = {
+	{"pfe1100", pfe1100},
+	{}
+};
+
+MODULE_DEVICE_TABLE(i2c, pfe_device_id);
+
+static struct i2c_driver pfe_pmbus_driver = {
+	.driver = {
+		   .name = "bel-pfe",
+	},
+	.probe = pfe_pmbus_probe,
+	.remove = pmbus_do_remove,
+	.id_table = pfe_device_id,
+};
+
+module_i2c_driver(pfe_pmbus_driver);
+
+MODULE_AUTHOR("Tao Ren <rentao.bupt@gmail.com>");
+MODULE_DESCRIPTION("PMBus driver for BEL PFE Family Power Supplies");
+MODULE_LICENSE("GPL");