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
58 * struct lm75_params - lm75 configuration parameters.
76 * than one.
120 /*-----------------------------------------------------------------------*/
127 * In case of being supported multiple configurations, the default one must
132 .clr_mask = 1 << 5, /* not one-shot mode */
146 .set_mask = 3 << 5, /* 12-bit mode*/
155 .set_mask = 2 << 5, /* 11-bit mode */
164 .set_mask = 2 << 5, /* 11-bit mode */
173 .set_mask = 2 << 5, /* 11-bit mode */
185 .set_mask = 3 << 5, /* 12-bit mode*/
235 .set_mask = 3 << 5, /* 12-bit mode */
236 .clr_mask = 1 << 7, /* not one-shot mode */
245 .set_mask = 3 << 5, /* 12-bit mode */
246 .clr_mask = 1 << 7, /* not one-shot mode */
254 .set_mask = 3 << 5, /* 12-bit mode */
255 .clr_mask = 1 << 7, /* not one-shot mode */
263 .set_mask = 3 << 5, /* 12-bit mode */
264 .clr_mask = 1 << 7, /* not one-shot mode*/
273 .set_mask = 0x60C0, /* 12-bit mode, 8 samples / second */
274 .clr_mask = 1 << 15, /* no one-shot mode*/
281 .set_mask = 3 << 5, /* 12-bit mode */
282 .clr_mask = 1 << 7, /* not one-shot mode*/
290 .set_mask = 3 << 5, /* 12-bit mode */
291 .clr_mask = 1 << 7, /* not one-shot mode*/
299 .set_mask = 3 << 5, /* 12-bit mode */
300 .clr_mask = 1 << 7, /* not one-shot mode*/
307 [tmp75b] = { /* not one-shot mode, Conversion rate 37Hz */
317 .clr_mask = 1 << 5, /*not one-shot mode*/
321 [tmp1075] = { /* not one-shot mode, 27.5 ms sample rate */
332 return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); in lm75_reg_to_mc()
340 clr_mask |= LM75_SHUTDOWN << (8 * data->params->config_reg_16bits); in lm75_write_config()
341 value = data->current_conf & ~clr_mask; in lm75_write_config()
344 if (data->current_conf != value) { in lm75_write_config()
346 if (data->params->config_reg_16bits) in lm75_write_config()
347 err = regmap_write(data->regmap, LM75_REG_CONF, value); in lm75_write_config()
349 err = i2c_smbus_write_byte_data(data->client, in lm75_write_config()
354 data->current_conf = value; in lm75_write_config()
364 if (data->params->config_reg_16bits) { in lm75_read_config()
365 ret = regmap_read(data->regmap, LM75_REG_CONF, &status); in lm75_read_config()
369 return i2c_smbus_read_byte_data(data->client, LM75_REG_CONF); in lm75_read_config()
391 *val = data->sample_time; in lm75_read()
394 return -EINVAL; in lm75_read()
412 return -EINVAL; in lm75_read()
414 err = regmap_read(data->regmap, reg, ®val); in lm75_read()
419 switch (data->kind) { in lm75_read()
424 return -EINVAL; in lm75_read()
427 *val = lm75_reg_to_mc(regval, data->resolution); in lm75_read()
431 return -EINVAL; in lm75_read()
450 return -EINVAL; in lm75_write_temp()
457 if (data->params->resolution_limits) in lm75_write_temp()
458 resolution = data->params->resolution_limits; in lm75_write_temp()
460 resolution = data->resolution; in lm75_write_temp()
463 temp = DIV_ROUND_CLOSEST(temp << (resolution - 8), in lm75_write_temp()
464 1000) << (16 - resolution); in lm75_write_temp()
466 return regmap_write(data->regmap, reg, (u16)temp); in lm75_write_temp()
476 index = find_closest(val, data->params->sample_times, in lm75_update_interval()
477 (int)data->params->num_sample_times); in lm75_update_interval()
479 switch (data->kind) { in lm75_update_interval()
486 data->sample_time = data->params->sample_times[index]; in lm75_update_interval()
487 if (data->params->resolutions) in lm75_update_interval()
488 data->resolution = data->params->resolutions[index]; in lm75_update_interval()
492 err = regmap_read(data->regmap, LM75_REG_CONF, ®); in lm75_update_interval()
496 reg |= (3 - index) << 6; in lm75_update_interval()
497 err = regmap_write(data->regmap, LM75_REG_CONF, reg); in lm75_update_interval()
500 data->sample_time = data->params->sample_times[index]; in lm75_update_interval()
503 err = i2c_smbus_write_byte_data(data->client, PCT2075_REG_IDLE, in lm75_update_interval()
507 data->sample_time = data->params->sample_times[index]; in lm75_update_interval()
519 return -EINVAL; in lm75_write_chip()
533 return -EINVAL; in lm75_write()
547 if (config_data->params->num_sample_times > 1) in lm75_is_visible()
560 if (config_data->params->alarm) in lm75_is_visible()
617 regulator_disable(lm75->vs); in lm75_disable_regulator()
623 struct i2c_client *client = lm75->client; in lm75_remove()
625 i2c_smbus_write_byte_data(client, LM75_REG_CONF, lm75->orig_conf); in lm75_remove()
630 struct device *dev = &client->dev; in lm75_probe()
635 if (!i2c_check_functionality(client->adapter, in lm75_probe()
637 return -EIO; in lm75_probe()
641 return -ENOMEM; in lm75_probe()
643 data->client = client; in lm75_probe()
644 data->kind = (uintptr_t)i2c_get_match_data(client); in lm75_probe()
646 data->vs = devm_regulator_get(dev, "vs"); in lm75_probe()
647 if (IS_ERR(data->vs)) in lm75_probe()
648 return PTR_ERR(data->vs); in lm75_probe()
650 data->regmap = devm_regmap_init_i2c(client, &lm75_regmap_config); in lm75_probe()
651 if (IS_ERR(data->regmap)) in lm75_probe()
652 return PTR_ERR(data->regmap); in lm75_probe()
658 data->params = &device_params[data->kind]; in lm75_probe()
661 data->sample_time = data->params->default_sample_time; in lm75_probe()
662 data->resolution = data->params->default_resolution; in lm75_probe()
665 err = regulator_enable(data->vs); in lm75_probe()
681 data->orig_conf = status; in lm75_probe()
682 data->current_conf = status; in lm75_probe()
684 err = lm75_write_config(data, data->params->set_mask, in lm75_probe()
685 data->params->clr_mask); in lm75_probe()
693 hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, in lm75_probe()
699 if (client->irq) { in lm75_probe()
700 if (data->params->alarm) { in lm75_probe()
702 client->irq, in lm75_probe()
706 client->name, in lm75_probe()
716 dev_info(dev, "%s: sensor '%s'\n", dev_name(hwmon_dev), client->name); in lm75_probe()
878 /* Return 0 if detection is successful, -ENODEV otherwise */
882 struct i2c_adapter *adapter = new_client->adapter; in lm75_detect()
889 return -ENODEV; in lm75_detect()
892 * Now, we do the remaining detection. There is no identification- in lm75_detect()
894 * unused bits, registers cycling over 8-address boundaries, in lm75_detect()
895 * addresses 0x04-0x07 returning the last read value. in lm75_detect()
919 return -ENODEV; in lm75_detect()
930 return -ENODEV; in lm75_detect()
941 return -ENODEV; in lm75_detect()
947 return -ENODEV; in lm75_detect()
954 return -ENODEV; in lm75_detect()
961 return -ENODEV; in lm75_detect()
964 return -ENODEV; in lm75_detect()
967 strscpy(info->type, is_lm75a ? "lm75a" : "lm75", I2C_NAME_SIZE); in lm75_detect()
980 dev_dbg(&client->dev, "Can't read config? %d\n", status); in lm75_suspend()
995 dev_dbg(&client->dev, "Can't read config? %d\n", status); in lm75_resume()