Lines Matching +full:one +full:- +full:shot

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * lm75.c - Part of lm_sensors, Linux kernel modules for hardware
14 #include <linux/hwmon-sysfs.h>
57 * struct lm75_params - lm75 configuration parameters.
74 * than one.
115 /*-----------------------------------------------------------------------*/
122 * In case of being supported multiple configurations, the default one must
127 .clr_mask = 1 << 5, /* not one-shot mode */
132 .set_mask = 3 << 5, /* 12-bit mode*/
141 .set_mask = 2 << 5, /* 11-bit mode */
150 .set_mask = 2 << 5, /* 11-bit mode */
159 .set_mask = 2 << 5, /* 11-bit mode */
171 .set_mask = 3 << 5, /* 12-bit mode*/
221 .set_mask = 3 << 5, /* 12-bit mode */
222 .clr_mask = 1 << 7, /* not one-shot mode */
231 .set_mask = 3 << 5, /* 12-bit mode */
232 .clr_mask = 1 << 7, /* not one-shot mode */
240 .set_mask = 3 << 5, /* 12-bit mode */
241 .clr_mask = 1 << 7, /* not one-shot mode */
249 .set_mask = 3 << 5, /* 12-bit mode */
250 .clr_mask = 1 << 7, /* not one-shot mode*/
259 .clr_mask = 1 << 7, /* no one-shot mode*/
266 .set_mask = 3 << 5, /* 12-bit mode */
267 .clr_mask = 1 << 7, /* not one-shot mode*/
275 .set_mask = 3 << 5, /* 12-bit mode */
276 .clr_mask = 1 << 7, /* not one-shot mode*/
284 .set_mask = 3 << 5, /* 12-bit mode */
285 .clr_mask = 1 << 7, /* not one-shot mode*/
292 [tmp75b] = { /* not one-shot mode, Conversion rate 37Hz */
302 .clr_mask = 1 << 5, /*not one-shot mode*/
306 [tmp1075] = { /* not one-shot mode, 27.5 ms sample rate */
317 return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); in lm75_reg_to_mc()
326 value = data->current_conf & ~clr_mask; in lm75_write_config()
329 if (data->current_conf != value) { in lm75_write_config()
332 err = i2c_smbus_write_byte_data(data->client, LM75_REG_CONF, in lm75_write_config()
336 data->current_conf = value; in lm75_write_config()
352 *val = data->sample_time; in lm75_read()
355 return -EINVAL; in lm75_read()
370 return -EINVAL; in lm75_read()
372 err = regmap_read(data->regmap, reg, &regval); in lm75_read()
376 *val = lm75_reg_to_mc(regval, data->resolution); in lm75_read()
379 return -EINVAL; in lm75_read()
398 return -EINVAL; in lm75_write_temp()
405 if (data->params->resolution_limits) in lm75_write_temp()
406 resolution = data->params->resolution_limits; in lm75_write_temp()
408 resolution = data->resolution; in lm75_write_temp()
411 temp = DIV_ROUND_CLOSEST(temp << (resolution - 8), in lm75_write_temp()
412 1000) << (16 - resolution); in lm75_write_temp()
414 return regmap_write(data->regmap, reg, (u16)temp); in lm75_write_temp()
424 index = find_closest(val, data->params->sample_times, in lm75_update_interval()
425 (int)data->params->num_sample_times); in lm75_update_interval()
427 switch (data->kind) { in lm75_update_interval()
434 data->sample_time = data->params->sample_times[index]; in lm75_update_interval()
435 if (data->params->resolutions) in lm75_update_interval()
436 data->resolution = data->params->resolutions[index]; in lm75_update_interval()
439 err = regmap_read(data->regmap, LM75_REG_CONF, &reg); in lm75_update_interval()
443 reg |= (3 - index) << 6; in lm75_update_interval()
444 err = regmap_write(data->regmap, LM75_REG_CONF, reg); in lm75_update_interval()
447 data->sample_time = data->params->sample_times[index]; in lm75_update_interval()
450 err = i2c_smbus_write_byte_data(data->client, PCT2075_REG_IDLE, in lm75_update_interval()
454 data->sample_time = data->params->sample_times[index]; in lm75_update_interval()
466 return -EINVAL; in lm75_write_chip()
480 return -EINVAL; in lm75_write()
494 if (config_data->params->num_sample_times > 1) in lm75_is_visible()
559 regulator_disable(lm75->vs); in lm75_disable_regulator()
565 struct i2c_client *client = lm75->client; in lm75_remove()
567 i2c_smbus_write_byte_data(client, LM75_REG_CONF, lm75->orig_conf); in lm75_remove()
574 struct device *dev = &client->dev; in lm75_probe()
580 if (client->dev.of_node) in lm75_probe()
581 kind = (uintptr_t)of_device_get_match_data(&client->dev); in lm75_probe()
583 kind = i2c_match_id(lm75_ids, client)->driver_data; in lm75_probe()
585 if (!i2c_check_functionality(client->adapter, in lm75_probe()
587 return -EIO; in lm75_probe()
591 return -ENOMEM; in lm75_probe()
593 data->client = client; in lm75_probe()
594 data->kind = kind; in lm75_probe()
596 data->vs = devm_regulator_get(dev, "vs"); in lm75_probe()
597 if (IS_ERR(data->vs)) in lm75_probe()
598 return PTR_ERR(data->vs); in lm75_probe()
600 data->regmap = devm_regmap_init_i2c(client, &lm75_regmap_config); in lm75_probe()
601 if (IS_ERR(data->regmap)) in lm75_probe()
602 return PTR_ERR(data->regmap); in lm75_probe()
608 data->params = &device_params[data->kind]; in lm75_probe()
611 data->sample_time = data->params->default_sample_time; in lm75_probe()
612 data->resolution = data->params->default_resolution; in lm75_probe()
615 err = regulator_enable(data->vs); in lm75_probe()
631 data->orig_conf = status; in lm75_probe()
632 data->current_conf = status; in lm75_probe()
634 err = lm75_write_config(data, data->params->set_mask, in lm75_probe()
635 data->params->clr_mask); in lm75_probe()
643 hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, in lm75_probe()
649 dev_info(dev, "%s: sensor '%s'\n", dev_name(hwmon_dev), client->name); in lm75_probe()
806 /* Return 0 if detection is successful, -ENODEV otherwise */
810 struct i2c_adapter *adapter = new_client->adapter; in lm75_detect()
817 return -ENODEV; in lm75_detect()
820 * Now, we do the remaining detection. There is no identification- in lm75_detect()
822 * unused bits, registers cycling over 8-address boundaries, in lm75_detect()
823 * addresses 0x04-0x07 returning the last read value. in lm75_detect()
847 return -ENODEV; in lm75_detect()
858 return -ENODEV; in lm75_detect()
869 return -ENODEV; in lm75_detect()
875 return -ENODEV; in lm75_detect()
882 return -ENODEV; in lm75_detect()
889 return -ENODEV; in lm75_detect()
892 return -ENODEV; in lm75_detect()
895 strscpy(info->type, is_lm75a ? "lm75a" : "lm75", I2C_NAME_SIZE); in lm75_detect()
908 dev_dbg(&client->dev, "Can't read config? %d\n", status); in lm75_suspend()
923 dev_dbg(&client->dev, "Can't read config? %d\n", status); in lm75_resume()