summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/powr1220.c
diff options
context:
space:
mode:
authorMichael Shych <michaelsh@nvidia.com>2022-01-18 08:56:11 +0100
committerGuenter Roeck <linux@roeck-us.net>2022-02-28 02:03:17 +0100
commit9f93aa1005fa1b960f10e0ee3ed8c4e697526053 (patch)
tree312df43ecd874e4dcb99ac8b6c3492a01cbbe478 /drivers/hwmon/powr1220.c
parenthwmon: (powr1220) Upgrade driver to support hwmon info infrastructure (diff)
downloadlinux-9f93aa1005fa1b960f10e0ee3ed8c4e697526053.tar.xz
linux-9f93aa1005fa1b960f10e0ee3ed8c4e697526053.zip
hwmon: (powr1220) Add support for Lattice's POWR1014 power manager IC
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 differences of POWR1014 compared to POWR1220 are amount of VMON input lines: 10 on POWR1014 and 12 lines on POWR1220 and number of output control signals: 14 on POWR1014 and 20 on POWR1220. Signed-off-by: Michael Shych <michaelsh@nvidia.com> Reviewed-by: Vadim Pasternak <vadimp@nvidia.com> Link: https://lore.kernel.org/r/20220118075611.10665-4-michaelsh@nvidia.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/powr1220.c')
-rw-r--r--drivers/hwmon/powr1220.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
index 0fa1a136eec8..f77dc6db31ac 100644
--- a/drivers/hwmon/powr1220.c
+++ b/drivers/hwmon/powr1220.c
@@ -22,6 +22,8 @@
#define ADC_STEP_MV 2
#define ADC_MAX_LOW_MEASUREMENT_MV 2000
+enum powr1xxx_chips { powr1014, powr1220 };
+
enum powr1220_regs {
VMON_STATUS0,
VMON_STATUS1,
@@ -74,6 +76,7 @@ enum powr1220_adc_values {
struct powr1220_data {
struct i2c_client *client;
struct mutex update_lock;
+ u8 max_channels;
bool adc_valid[MAX_POWR1220_ADC_VALUES];
/* the next value is in jiffies */
unsigned long adc_last_updated[MAX_POWR1220_ADC_VALUES];
@@ -171,6 +174,11 @@ static umode_t
powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
attr, int channel)
{
+ struct powr1220_data *chip_data = (struct powr1220_data *)data;
+
+ if (channel >= chip_data->max_channels)
+ return 0;
+
switch (type) {
case hwmon_in:
switch (attr) {
@@ -271,6 +279,8 @@ static const struct hwmon_chip_info powr1220_chip_info = {
.info = powr1220_info,
};
+static const struct i2c_device_id powr1220_ids[];
+
static int powr1220_probe(struct i2c_client *client)
{
struct powr1220_data *data;
@@ -283,6 +293,15 @@ static int powr1220_probe(struct i2c_client *client)
if (!data)
return -ENOMEM;
+ switch (i2c_match_id(powr1220_ids, client)->driver_data) {
+ case powr1014:
+ data->max_channels = 10;
+ break;
+ default:
+ data->max_channels = 12;
+ break;
+ }
+
mutex_init(&data->update_lock);
data->client = client;
@@ -296,7 +315,8 @@ static int powr1220_probe(struct i2c_client *client)
}
static const struct i2c_device_id powr1220_ids[] = {
- { "powr1220", 0, },
+ { "powr1014", powr1014, },
+ { "powr1220", powr1220, },
{ }
};