Skip to content
/ linux Public

Commit 9f93aa1

Browse files
mshychgroeck
authored andcommitted
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>
1 parent 915d466 commit 9f93aa1

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

drivers/hwmon/powr1220.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define ADC_STEP_MV 2
2323
#define ADC_MAX_LOW_MEASUREMENT_MV 2000
2424

25+
enum powr1xxx_chips { powr1014, powr1220 };
26+
2527
enum powr1220_regs {
2628
VMON_STATUS0,
2729
VMON_STATUS1,
@@ -74,6 +76,7 @@ enum powr1220_adc_values {
7476
struct powr1220_data {
7577
struct i2c_client *client;
7678
struct mutex update_lock;
79+
u8 max_channels;
7780
bool adc_valid[MAX_POWR1220_ADC_VALUES];
7881
/* the next value is in jiffies */
7982
unsigned long adc_last_updated[MAX_POWR1220_ADC_VALUES];
@@ -171,6 +174,11 @@ static umode_t
171174
powr1220_is_visible(const void *data, enum hwmon_sensor_types type, u32
172175
attr, int channel)
173176
{
177+
struct powr1220_data *chip_data = (struct powr1220_data *)data;
178+
179+
if (channel >= chip_data->max_channels)
180+
return 0;
181+
174182
switch (type) {
175183
case hwmon_in:
176184
switch (attr) {
@@ -271,6 +279,8 @@ static const struct hwmon_chip_info powr1220_chip_info = {
271279
.info = powr1220_info,
272280
};
273281

282+
static const struct i2c_device_id powr1220_ids[];
283+
274284
static int powr1220_probe(struct i2c_client *client)
275285
{
276286
struct powr1220_data *data;
@@ -283,6 +293,15 @@ static int powr1220_probe(struct i2c_client *client)
283293
if (!data)
284294
return -ENOMEM;
285295

296+
switch (i2c_match_id(powr1220_ids, client)->driver_data) {
297+
case powr1014:
298+
data->max_channels = 10;
299+
break;
300+
default:
301+
data->max_channels = 12;
302+
break;
303+
}
304+
286305
mutex_init(&data->update_lock);
287306
data->client = client;
288307

@@ -296,7 +315,8 @@ static int powr1220_probe(struct i2c_client *client)
296315
}
297316

298317
static const struct i2c_device_id powr1220_ids[] = {
299-
{ "powr1220", 0, },
318+
{ "powr1014", powr1014, },
319+
{ "powr1220", powr1220, },
300320
{ }
301321
};
302322

0 commit comments

Comments
 (0)