lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200127102540.31742-1-o.rempel@pengutronix.de>
Date:   Mon, 27 Jan 2020 11:25:39 +0100
From:   Oleksij Rempel <o.rempel@...gutronix.de>
To:     Jean Delvare <jdelvare@...e.com>, Markus Pietrek <mpie@...-ge.com>,
        Guenter Roeck <linux@...ck-us.net>
Cc:     Oleksij Rempel <o.rempel@...gutronix.de>, kernel@...gutronix.de,
        linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH V1 1/2] hwmon: (powr1220) Add support for Lattice's POWR1014 power manager IC

From: Markus Pietrek <mpie@...-ge.com>

This patch adds support for Lattice's POWR1014 power manager IC. Read
access to all the ADCs on the chip are supported through the hwmon
sysfs files.

The main difference of POWR1014 compared to POWR1220 is amount of VMON
input lines: 10 on POWR1014 and 12 lines on POWR1220.

Signed-off-by: Markus Pietrek <mpie@...-ge.com>
Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
---
 drivers/hwmon/powr1220.c | 65 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
index 65997421ee3c..ad7a82f132e6 100644
--- a/drivers/hwmon/powr1220.c
+++ b/drivers/hwmon/powr1220.c
@@ -19,6 +19,9 @@
 #include <linux/mutex.h>
 #include <linux/delay.h>
 
+#define I2C_CLIENT_DATA_1014 1014
+#define I2C_CLIENT_DATA_1220 1220
+
 #define ADC_STEP_MV			2
 #define ADC_MAX_LOW_MEASUREMENT_MV	2000
 
@@ -246,6 +249,51 @@ static SENSOR_DEVICE_ATTR_RO(in11_label, powr1220_label, VMON12);
 static SENSOR_DEVICE_ATTR_RO(in12_label, powr1220_label, VCCA);
 static SENSOR_DEVICE_ATTR_RO(in13_label, powr1220_label, VCCINP);
 
+static struct attribute *powr1014_attrs[] = {
+	&sensor_dev_attr_in0_input.dev_attr.attr,
+	&sensor_dev_attr_in1_input.dev_attr.attr,
+	&sensor_dev_attr_in2_input.dev_attr.attr,
+	&sensor_dev_attr_in3_input.dev_attr.attr,
+	&sensor_dev_attr_in4_input.dev_attr.attr,
+	&sensor_dev_attr_in5_input.dev_attr.attr,
+	&sensor_dev_attr_in6_input.dev_attr.attr,
+	&sensor_dev_attr_in7_input.dev_attr.attr,
+	&sensor_dev_attr_in8_input.dev_attr.attr,
+	&sensor_dev_attr_in9_input.dev_attr.attr,
+	&sensor_dev_attr_in12_input.dev_attr.attr,
+	&sensor_dev_attr_in13_input.dev_attr.attr,
+
+	&sensor_dev_attr_in0_highest.dev_attr.attr,
+	&sensor_dev_attr_in1_highest.dev_attr.attr,
+	&sensor_dev_attr_in2_highest.dev_attr.attr,
+	&sensor_dev_attr_in3_highest.dev_attr.attr,
+	&sensor_dev_attr_in4_highest.dev_attr.attr,
+	&sensor_dev_attr_in5_highest.dev_attr.attr,
+	&sensor_dev_attr_in6_highest.dev_attr.attr,
+	&sensor_dev_attr_in7_highest.dev_attr.attr,
+	&sensor_dev_attr_in8_highest.dev_attr.attr,
+	&sensor_dev_attr_in9_highest.dev_attr.attr,
+	&sensor_dev_attr_in12_highest.dev_attr.attr,
+	&sensor_dev_attr_in13_highest.dev_attr.attr,
+
+	&sensor_dev_attr_in0_label.dev_attr.attr,
+	&sensor_dev_attr_in1_label.dev_attr.attr,
+	&sensor_dev_attr_in2_label.dev_attr.attr,
+	&sensor_dev_attr_in3_label.dev_attr.attr,
+	&sensor_dev_attr_in4_label.dev_attr.attr,
+	&sensor_dev_attr_in5_label.dev_attr.attr,
+	&sensor_dev_attr_in6_label.dev_attr.attr,
+	&sensor_dev_attr_in7_label.dev_attr.attr,
+	&sensor_dev_attr_in8_label.dev_attr.attr,
+	&sensor_dev_attr_in9_label.dev_attr.attr,
+	&sensor_dev_attr_in12_label.dev_attr.attr,
+	&sensor_dev_attr_in13_label.dev_attr.attr,
+
+	NULL
+};
+
+ATTRIBUTE_GROUPS(powr1014);
+
 static struct attribute *powr1220_attrs[] = {
 	&sensor_dev_attr_in0_input.dev_attr.attr,
 	&sensor_dev_attr_in1_input.dev_attr.attr,
@@ -300,9 +348,21 @@ ATTRIBUTE_GROUPS(powr1220);
 static int powr1220_probe(struct i2c_client *client,
 		const struct i2c_device_id *id)
 {
+	const struct attribute_group **attr_groups = NULL;
 	struct powr1220_data *data;
 	struct device *hwmon_dev;
 
+	switch (id->driver_data) {
+	case I2C_CLIENT_DATA_1014:
+		attr_groups = powr1014_groups;
+		break;
+	case I2C_CLIENT_DATA_1220:
+		attr_groups = powr1220_groups;
+		break;
+	default:
+		return -EINVAL;
+	}
+
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
 		return -ENODEV;
 
@@ -314,13 +374,14 @@ static int powr1220_probe(struct i2c_client *client,
 	data->client = client;
 
 	hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
-			client->name, data, powr1220_groups);
+			client->name, data, attr_groups);
 
 	return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
 static const struct i2c_device_id powr1220_ids[] = {
-	{ "powr1220", 0, },
+	{ "powr1014", I2C_CLIENT_DATA_1014, },
+	{ "powr1220", I2C_CLIENT_DATA_1220, },
 	{ }
 };
 
-- 
2.25.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ