Lines Matching +full:single +full:- +full:ended
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net>
24 " 0 = four single ended inputs\n"
26 " 2 = single ended and differential mixed\n"
40 * 0x00 = four single ended inputs
42 * 0x20 = single ended and differential mixed
64 #define REG_TO_SIGNED(reg) (((reg) & 0x80) ? ((reg) - 256) : (reg))
97 return sprintf(buf, "%d\n", data->aout * 10); in out0_output_show()
115 return -EINVAL; in out0_output_store()
117 data->aout = val; in out0_output_store()
118 i2c_smbus_write_byte_data(client, data->control, data->aout); in out0_output_store()
128 return sprintf(buf, "%u\n", !(!(data->control & PCF8591_CONTROL_AOEF))); in out0_enable_show()
144 mutex_lock(&data->update_lock); in out0_enable_store()
146 data->control |= PCF8591_CONTROL_AOEF; in out0_enable_store()
148 data->control &= ~PCF8591_CONTROL_AOEF; in out0_enable_store()
149 i2c_smbus_write_byte(client, data->control); in out0_enable_store()
150 mutex_unlock(&data->update_lock); in out0_enable_store()
187 data = devm_kzalloc(&client->dev, sizeof(struct pcf8591_data), in pcf8591_probe()
190 return -ENOMEM; in pcf8591_probe()
193 mutex_init(&data->update_lock); in pcf8591_probe()
199 err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group); in pcf8591_probe()
205 err = device_create_file(&client->dev, &dev_attr_in2_input); in pcf8591_probe()
210 /* Register input3 only in "four single ended inputs" mode */ in pcf8591_probe()
212 err = device_create_file(&client->dev, &dev_attr_in3_input); in pcf8591_probe()
217 data->hwmon_dev = hwmon_device_register(&client->dev); in pcf8591_probe()
218 if (IS_ERR(data->hwmon_dev)) { in pcf8591_probe()
219 err = PTR_ERR(data->hwmon_dev); in pcf8591_probe()
226 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); in pcf8591_probe()
227 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); in pcf8591_probe()
235 hwmon_device_unregister(data->hwmon_dev); in pcf8591_remove()
236 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt); in pcf8591_remove()
237 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group); in pcf8591_remove()
245 data->control = PCF8591_INIT_CONTROL; in pcf8591_init_client()
246 data->aout = PCF8591_INIT_AOUT; in pcf8591_init_client()
248 i2c_smbus_write_byte_data(client, data->control, data->aout); in pcf8591_init_client()
263 mutex_lock(&data->update_lock); in pcf8591_read_channel()
265 if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { in pcf8591_read_channel()
266 data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) in pcf8591_read_channel()
268 i2c_smbus_write_byte(client, data->control); in pcf8591_read_channel()
278 mutex_unlock(&data->update_lock); in pcf8591_read_channel()