Skip to content

Commit

Permalink
Support Delta DPS1900 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
deni64k authored and lguohan committed Jul 30, 2018
1 parent 77895c5 commit 70fdaa2
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
21 changes: 21 additions & 0 deletions patch/config-arista-dps1900.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Enable CONFIG_SENSORS_DPS1900

From: gulv <gulv@microsoft.com>


---
debian/build/build_amd64_none_amd64/.config | 1 +
1 file changed, 1 insertion(+)

diff --git a/debian/build/build_amd64_none_amd64/.config b/debian/build/build_amd64_none_amd64/.config
index 29bcb1f..d59a9e0 100644
--- a/debian/build/build_amd64_none_amd64/.config
+++ b/debian/build/build_amd64_none_amd64/.config
@@ -3956,6 +3956,7 @@ CONFIG_SENSORS_DNI_DPS460=m
CONFIG_SENSORS_TPS53679=m
CONFIG_SENSORS_UCD9000=m
CONFIG_SENSORS_UCD9200=m
+CONFIG_SENSORS_DPS1900=m
# CONFIG_SENSORS_ZL6100 is not set
# CONFIG_SENSORS_SHT15 is not set
CONFIG_SENSORS_SHT21=m
104 changes: 104 additions & 0 deletions patch/driver-hwmon-pmbus-dps1900.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 510f055..f8ca77e 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -131,4 +131,14 @@ config SENSORS_ZL6100
This driver can also be built as a module. If so, the module will
be called zl6100.

+config SENSORS_DPS1900
+ tristate "Delta DPS1900"
+ default n
+ help
+ If you say yes here you get hardware monitoring support for Delta
+ DPS1900.
+
+ This driver can also be built as a module. If so, the module will
+ be called dps1900.
+
endif # PMBUS
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index be70828..8276d89 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_SENSORS_MAX8688) += max8688.o
obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o
obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o
obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o
+obj-$(CONFIG_SENSORS_DPS1900) += dps1900.o
diff --git a/drivers/hwmon/pmbus/dps1900.c b/drivers/hwmon/pmbus/dps1900.c
new file mode 100644
index 0000000..8f90c04
--- /dev/null
+++ b/drivers/hwmon/pmbus/dps1900.c
@@ -0,0 +1,70 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/i2c/pmbus.h>
+#include "pmbus.h"
+
+static int dps1900_read_word_data(struct i2c_client *client, int page, int reg)
+{
+ if (reg >= PMBUS_VIRT_BASE ||
+ reg == PMBUS_OT_WARN_LIMIT ||
+ reg == PMBUS_OT_FAULT_LIMIT ||
+ reg == PMBUS_UT_WARN_LIMIT ||
+ reg == PMBUS_UT_FAULT_LIMIT ||
+ reg == PMBUS_VIN_OV_FAULT_LIMIT ||
+ reg == PMBUS_VIN_OV_WARN_LIMIT ||
+ reg == PMBUS_VIN_UV_WARN_LIMIT ||
+ reg == PMBUS_VIN_UV_FAULT_LIMIT ||
+ reg == PMBUS_VOUT_UV_WARN_LIMIT ||
+ reg == PMBUS_VOUT_OV_WARN_LIMIT ||
+ reg == PMBUS_POUT_OP_FAULT_LIMIT ||
+ reg == PMBUS_POUT_OP_WARN_LIMIT ||
+ reg == PMBUS_PIN_OP_WARN_LIMIT ||
+ reg == PMBUS_IIN_OC_FAULT_LIMIT ||
+ reg == PMBUS_IOUT_UC_FAULT_LIMIT ||
+ reg == PMBUS_POUT_MAX)
+ return -ENXIO;
+ return pmbus_read_word_data(client, page, reg);
+}
+
+static struct pmbus_driver_info dps1900_info = {
+ .pages = 1,
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+ | PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
+ | PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12
+ | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP
+ | PMBUS_HAVE_STATUS_INPUT,
+ .read_word_data = dps1900_read_word_data,
+};
+
+static int dps1900_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ return pmbus_do_probe(client, id, &dps1900_info);
+}
+
+static const struct i2c_device_id dps1900_id[] = {
+ {"dps1900", 0},
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, dps1900_id);
+
+/* This is the driver that will be inserted */
+static struct i2c_driver dps1900_driver = {
+ .driver = {
+ .name = "dps1900",
+ },
+ .probe = dps1900_probe,
+ .remove = pmbus_do_remove,
+ .id_table = dps1900_id,
+};
+
+module_i2c_driver(dps1900_driver);
+
+MODULE_AUTHOR("Arista Networks");
+MODULE_DESCRIPTION("PMBus driver for Delta DPS1900");
+MODULE_LICENSE("GPL");
2 changes: 2 additions & 0 deletions patch/series
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ driver-hwmon-max6620-fix-rpm-calc.patch
driver-hwmon-max6620-update.patch
driver-hwmon-pmbus-dni_dps460.patch
driver-hwmon-pmbus-dni_dps460-update-pmbus-core.patch
driver-hwmon-pmbus-dps1900.patch
driver-support-tun-config-carrier-enable.patch
driver-support-optoe.patch
driver-support-optoe-EOF_fix.patch
bridge-add-per-port-broadcast-flood-flag.patch
config-dell-s6000.patch
config-dell-z9100.patch
config-ingrasys-s9100.patch
config-arista-dps1900.patch
config-arista-7060-cx32s.patch
config-mitac-ly1200.patch
config-optoe.patch
Expand Down

0 comments on commit 70fdaa2

Please sign in to comment.