Lines Matching +full:attr +full:- +full:cnt +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-or-later
10 #include <linux/hwmon-sysfs.h>
63 static int nct7363_read_fan(struct device *dev, u32 attr, int channel, in nct7363_read_fan() argument
70 u16 cnt; in nct7363_read_fan() local
72 switch (attr) { in nct7363_read_fan()
75 * High-byte register should be read first to latch in nct7363_read_fan()
76 * synchronous low-byte value in nct7363_read_fan()
78 ret = regmap_bulk_read(data->regmap, in nct7363_read_fan()
84 cnt = (regval[0] << 5) | (regval[1] & NCT7363_FANINX_LVAL_MASK); in nct7363_read_fan()
85 *val = fan_from_reg(cnt); in nct7363_read_fan()
88 ret = regmap_bulk_read(data->regmap, in nct7363_read_fan()
94 cnt = (regval[0] << 5) | (regval[1] & NCT7363_FANINX_LVAL_MASK); in nct7363_read_fan()
95 *val = fan_from_reg(cnt); in nct7363_read_fan()
98 ret = regmap_read(data->regmap, in nct7363_read_fan()
106 return -EOPNOTSUPP; in nct7363_read_fan()
110 static int nct7363_write_fan(struct device *dev, u32 attr, int channel, in nct7363_write_fan() argument
118 return -EINVAL; in nct7363_write_fan()
120 switch (attr) { in nct7363_write_fan()
127 ret = regmap_bulk_write(data->regmap, in nct7363_write_fan()
132 return -EOPNOTSUPP; in nct7363_write_fan()
136 static umode_t nct7363_fan_is_visible(const void *_data, u32 attr, int channel) in nct7363_fan_is_visible() argument
140 switch (attr) { in nct7363_fan_is_visible()
143 if (data->fanin_mask & BIT(channel)) in nct7363_fan_is_visible()
147 if (data->fanin_mask & BIT(channel)) in nct7363_fan_is_visible()
157 static int nct7363_read_pwm(struct device *dev, u32 attr, int channel, in nct7363_read_pwm() argument
164 switch (attr) { in nct7363_read_pwm()
166 ret = regmap_read(data->regmap, in nct7363_read_pwm()
174 return -EOPNOTSUPP; in nct7363_read_pwm()
178 static int nct7363_write_pwm(struct device *dev, u32 attr, int channel, in nct7363_write_pwm() argument
184 switch (attr) { in nct7363_write_pwm()
187 return -EINVAL; in nct7363_write_pwm()
189 ret = regmap_write(data->regmap, in nct7363_write_pwm()
195 return -EOPNOTSUPP; in nct7363_write_pwm()
199 static umode_t nct7363_pwm_is_visible(const void *_data, u32 attr, int channel) in nct7363_pwm_is_visible() argument
203 switch (attr) { in nct7363_pwm_is_visible()
205 if (data->pwm_mask & BIT(channel)) in nct7363_pwm_is_visible()
216 u32 attr, int channel, long *val) in nct7363_read() argument
220 return nct7363_read_fan(dev, attr, channel, val); in nct7363_read()
222 return nct7363_read_pwm(dev, attr, channel, val); in nct7363_read()
224 return -EOPNOTSUPP; in nct7363_read()
229 u32 attr, int channel, long val) in nct7363_write() argument
233 return nct7363_write_fan(dev, attr, channel, val); in nct7363_write()
235 return nct7363_write_pwm(dev, attr, channel, val); in nct7363_write()
237 return -EOPNOTSUPP; in nct7363_write()
243 u32 attr, int channel) in nct7363_is_visible() argument
247 return nct7363_fan_is_visible(data, attr, channel); in nct7363_is_visible()
249 return nct7363_pwm_is_visible(data, attr, channel); in nct7363_is_visible()
311 if (data->pwm_mask & BIT(i)) in nct7363_init_chip()
313 if (data->fanin_mask & BIT(i)) in nct7363_init_chip()
318 ret = regmap_write(data->regmap, NCT7363_REG_FUNC_CFG_BASE(i), in nct7363_init_chip()
326 ret = regmap_write(data->regmap, NCT7363_REG_PWMEN_BASE(i), in nct7363_init_chip()
327 VALUE_TO_REG(data->pwm_mask, i)); in nct7363_init_chip()
331 ret = regmap_write(data->regmap, NCT7363_REG_FANINEN_BASE(i), in nct7363_init_chip()
332 VALUE_TO_REG(data->fanin_mask, i)); in nct7363_init_chip()
349 ret = of_parse_phandle_with_args(child, "pwms", "#pwm-cells", in nct7363_present_pwm_fanin()
355 return -EINVAL; in nct7363_present_pwm_fanin()
356 data->pwm_mask |= BIT(args.args[0]); in nct7363_present_pwm_fanin()
358 fanin_cnt = of_property_count_u8_elems(child, "tach-ch"); in nct7363_present_pwm_fanin()
360 return -EINVAL; in nct7363_present_pwm_fanin()
362 ret = of_property_read_u8_array(child, "tach-ch", fanin_ch, fanin_cnt); in nct7363_present_pwm_fanin()
369 return -EINVAL; in nct7363_present_pwm_fanin()
370 data->fanin_mask |= BIT(index); in nct7363_present_pwm_fanin()
400 struct device *dev = &client->dev; in nct7363_probe()
408 return -ENOMEM; in nct7363_probe()
410 data->regmap = devm_regmap_init_i2c(client, &nct7363_regmap_config); in nct7363_probe()
411 if (IS_ERR(data->regmap)) in nct7363_probe()
412 return PTR_ERR(data->regmap); in nct7363_probe()
414 for_each_child_of_node(dev->of_node, child) { in nct7363_probe()
428 devm_hwmon_device_register_with_info(dev, client->name, data, in nct7363_probe()
436 .name = "nct7363",