Lines Matching +full:pga +full:- +full:gain
2 * ads1015.c - lm_sensors driver for ads1015 12-bit 4-input ADC
31 #include <linux/hwmon-sysfs.h>
45 /* PGA fullscale voltages in mV */
78 unsigned int pga = data->channel_data[channel].pga; in ads1015_read_adc() local
79 unsigned int data_rate = data->channel_data[channel].data_rate; in ads1015_read_adc()
81 const unsigned int * const rate_table = data->id == ads1115 ? in ads1015_read_adc()
85 mutex_lock(&data->update_lock); in ads1015_read_adc()
98 config |= (pga & 0x0007) << 9; in ads1015_read_adc()
113 res = -EIO; in ads1015_read_adc()
120 mutex_unlock(&data->update_lock); in ads1015_read_adc()
128 unsigned int pga = data->channel_data[channel].pga; in ads1015_reg_to_mv() local
129 int fullscale = fullscale_table[pga]; in ads1015_reg_to_mv()
130 const int mask = data->id == ads1115 ? 0x7fff : 0x7ff0; in ads1015_reg_to_mv()
142 int index = attr->index; in show_in()
171 hwmon_device_unregister(data->hwmon_dev); in ads1015_remove()
173 device_remove_file(&client->dev, &ads1015_in[k].dev_attr); in ads1015_remove()
183 if (!client->dev.of_node in ads1015_get_channels_config_of()
184 || !of_get_next_child(client->dev.of_node, NULL)) in ads1015_get_channels_config_of()
185 return -EINVAL; in ads1015_get_channels_config_of()
187 for_each_child_of_node(client->dev.of_node, node) { in ads1015_get_channels_config_of()
190 unsigned int pga = ADS1015_DEFAULT_PGA; in ads1015_get_channels_config_of() local
194 dev_err(&client->dev, "invalid reg on %pOF\n", node); in ads1015_get_channels_config_of()
200 dev_err(&client->dev, in ads1015_get_channels_config_of()
206 if (!of_property_read_u32(node, "ti,gain", &pval)) { in ads1015_get_channels_config_of()
207 pga = pval; in ads1015_get_channels_config_of()
208 if (pga > 6) { in ads1015_get_channels_config_of()
209 dev_err(&client->dev, "invalid gain on %pOF\n", in ads1015_get_channels_config_of()
211 return -EINVAL; in ads1015_get_channels_config_of()
218 dev_err(&client->dev, in ads1015_get_channels_config_of()
220 return -EINVAL; in ads1015_get_channels_config_of()
224 data->channel_data[channel].enabled = true; in ads1015_get_channels_config_of()
225 data->channel_data[channel].pga = pga; in ads1015_get_channels_config_of()
226 data->channel_data[channel].data_rate = data_rate; in ads1015_get_channels_config_of()
237 struct ads1015_platform_data *pdata = dev_get_platdata(&client->dev); in ads1015_get_channels_config()
241 memcpy(data->channel_data, pdata->channel_data, in ads1015_get_channels_config()
242 sizeof(data->channel_data)); in ads1015_get_channels_config()
253 data->channel_data[k].enabled = true; in ads1015_get_channels_config()
254 data->channel_data[k].pga = ADS1015_DEFAULT_PGA; in ads1015_get_channels_config()
255 data->channel_data[k].data_rate = ADS1015_DEFAULT_DATA_RATE; in ads1015_get_channels_config()
266 data = devm_kzalloc(&client->dev, sizeof(struct ads1015_data), in ads1015_probe()
269 return -ENOMEM; in ads1015_probe()
271 if (client->dev.of_node) in ads1015_probe()
272 data->id = (enum ads1015_chips) in ads1015_probe()
273 of_device_get_match_data(&client->dev); in ads1015_probe()
275 data->id = id->driver_data; in ads1015_probe()
277 mutex_init(&data->update_lock); in ads1015_probe()
282 if (!data->channel_data[k].enabled) in ads1015_probe()
284 err = device_create_file(&client->dev, &ads1015_in[k].dev_attr); in ads1015_probe()
289 data->hwmon_dev = hwmon_device_register(&client->dev); in ads1015_probe()
290 if (IS_ERR(data->hwmon_dev)) { in ads1015_probe()
291 err = PTR_ERR(data->hwmon_dev); in ads1015_probe()
299 device_remove_file(&client->dev, &ads1015_in[k].dev_attr); in ads1015_probe()