Signed-off-by: Markus Pietrek <mpie@xxxxxxxxxx>
Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
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, },
{ }
};