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 Jun 29, 2018
1 parent b511c96 commit 8d8bba0
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
9 changes: 9 additions & 0 deletions patch/config-arista-dps1900.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/debian/build/build_amd64_none_amd64/.config b/debian/build/build_amd64_none_amd64/.config
index 6b6aea9..14e32cb 100644
--- a/debian/build/build_amd64_none_amd64/.config
+++ b/debian/build/build_amd64_none_amd64/.config
@@ -6820,3 +6821,4 @@ CONFIG_FONT_SUPPORT=y
# CONFIG_FONTS is not set
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
+CONFIG_SENSORS_DPS1900=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 @@ -28,6 +28,8 @@ driver-pca954x-i2c-mux-force-deselect-on-exit-flag.patch
linux-3.19-mmc-sdhci-Add-a-quirk-for-AMD-SDHC-transfer-mode-reg.patch
linux-3.19-mmc-sdhci-pci-enable-the-clear-transfer-mode-registe.patch
linux-3.19-mmc-sdhci-pci-enable-sdhci-doesn-t-support-hs200-qui.patch
driver-hwmon-pmbus-dps1900.patch
config-arista-dps1900.patch
rtnetlink-catch-EOPNOTSUPP-errors.patch
bridge-per-port-multicast-broadcast-flood-flags.patch
driver-support-tun-config-carrier-enable.patch
Expand Down

0 comments on commit 8d8bba0

Please sign in to comment.