Lines Matching +full:4 +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0
24 #define LTC2991_CHANNEL_T_MSB(x) (0x0A + ((x) * 4))
25 #define LTC2991_CHANNEL_C_MSB(x) (0x0C + ((x) * 4))
32 #define LTC2991_V1_V2_EN BIT(4)
37 #define LTC2991_V3_V4_DIFF_EN BIT(4)
44 #define LTC2991_V7_V8_DIFF_EN BIT(4)
47 #define LTC2991_V5_V6_DIFF_EN BIT(4)
49 #define LTC2991_REPEAT_ACQ_EN BIT(4)
52 #define LTC2991_MAX_CHANNEL 4
53 #define LTC2991_T_INT_CH_NR 4
69 return regmap_read(st->regmap, addr, val); in ltc2991_read_reg()
71 ret = regmap_bulk_read(st->regmap, addr, &regvals, reg_len); in ltc2991_read_reg()
99 static int ltc2991_read_in(struct device *dev, u32 attr, int channel, long *val) in ltc2991_read_in() argument
106 if (channel == LTC2991_VCC_CH_NR) in ltc2991_read_in()
109 reg = LTC2991_CHANNEL_V_MSB(channel - 1); in ltc2991_read_in()
113 return -EOPNOTSUPP; in ltc2991_read_in()
117 static int ltc2991_get_curr(struct ltc2991_state *st, u32 reg, int channel, in ltc2991_get_curr() argument
126 /* Vx-Vy, 19.075uV/LSB */ in ltc2991_get_curr()
128 st->r_sense_uohm[channel]); in ltc2991_get_curr()
133 static int ltc2991_read_curr(struct device *dev, u32 attr, int channel, in ltc2991_read_curr() argument
141 reg = LTC2991_CHANNEL_C_MSB(channel); in ltc2991_read_curr()
142 return ltc2991_get_curr(st, reg, channel, val); in ltc2991_read_curr()
144 return -EOPNOTSUPP; in ltc2991_read_curr()
148 static int ltc2991_get_temp(struct ltc2991_state *st, u32 reg, int channel, in ltc2991_get_temp() argument
163 static int ltc2991_read_temp(struct device *dev, u32 attr, int channel, in ltc2991_read_temp() argument
171 if (channel == LTC2991_T_INT_CH_NR) in ltc2991_read_temp()
174 reg = LTC2991_CHANNEL_T_MSB(channel); in ltc2991_read_temp()
176 return ltc2991_get_temp(st, reg, channel, val); in ltc2991_read_temp()
178 return -EOPNOTSUPP; in ltc2991_read_temp()
183 u32 attr, int channel, long *val) in ltc2991_read() argument
187 return ltc2991_read_in(dev, attr, channel, val); in ltc2991_read()
189 return ltc2991_read_curr(dev, attr, channel, val); in ltc2991_read()
191 return ltc2991_read_temp(dev, attr, channel, val); in ltc2991_read()
193 return -EOPNOTSUPP; in ltc2991_read()
199 int channel) in ltc2991_is_visible() argument
207 if (channel == LTC2991_VCC_CH_NR) in ltc2991_is_visible()
209 if (st->temp_en[(channel - 1) / 2]) in ltc2991_is_visible()
211 if (channel % 2) in ltc2991_is_visible()
213 if (!st->r_sense_uohm[(channel - 1) / 2]) in ltc2991_is_visible()
220 if (st->r_sense_uohm[channel]) in ltc2991_is_visible()
228 if (st->temp_en[channel] || in ltc2991_is_visible()
229 channel == LTC2991_T_INT_CH_NR) in ltc2991_is_visible()
306 return -EINVAL; in ltc2991_init()
310 "shunt-resistor-micro-ohms", in ltc2991_init()
314 return dev_err_probe(dev, -EINVAL, in ltc2991_init()
317 st->r_sense_uohm[addr] = val; in ltc2991_init()
338 "adi,temperature-enable"); in ltc2991_init()
340 st->temp_en[addr] = ret; in ltc2991_init()
361 ret = regmap_write(st->regmap, LTC2991_V5_V8_CTRL, v5_v8_reg_data); in ltc2991_init()
364 "Error: Failed to set V5-V8 CTRL reg.\n"); in ltc2991_init()
366 ret = regmap_write(st->regmap, LTC2991_V1_V4_CTRL, v1_v4_reg_data); in ltc2991_init()
369 "Error: Failed to set V1-V4 CTRL reg.\n"); in ltc2991_init()
371 ret = regmap_write(st->regmap, LTC2991_PWM_TH_LSB_T_INT, in ltc2991_init()
378 return regmap_write(st->regmap, LTC2991_CH_EN_TRIGGER, in ltc2991_init()
390 st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL); in ltc2991_i2c_probe()
392 return -ENOMEM; in ltc2991_i2c_probe()
394 st->regmap = devm_regmap_init_i2c(client, &ltc2991_regmap_config); in ltc2991_i2c_probe()
395 if (IS_ERR(st->regmap)) in ltc2991_i2c_probe()
396 return PTR_ERR(st->regmap); in ltc2991_i2c_probe()
398 ret = ltc2991_init(st, &client->dev); in ltc2991_i2c_probe()
402 hwmon_dev = devm_hwmon_device_register_with_info(&client->dev, in ltc2991_i2c_probe()
403 client->name, st, in ltc2991_i2c_probe()