Lines Matching +full:gain +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0
23 #define ADMFM2000_MIN_GAIN -31000
24 #define ADMFM2000_DEFAULT_GAIN -0x20
32 u32 gain[2]; member
43 gpiod_set_value_cansleep(st->sw1_ch[i], (chan == 0) ? 1 : 0); in admfm2000_mode()
44 gpiod_set_value_cansleep(st->sw2_ch[i], (chan == 0) ? 0 : 1); in admfm2000_mode()
49 gpiod_set_value_cansleep(st->sw1_ch[i], (chan == 0) ? 0 : 1); in admfm2000_mode()
50 gpiod_set_value_cansleep(st->sw2_ch[i], (chan == 0) ? 1 : 0); in admfm2000_mode()
54 return -EINVAL; in admfm2000_mode()
66 gpiod_set_value_cansleep(st->dsa1_gpios[i], value & (1 << i)); in admfm2000_attenuation()
70 gpiod_set_value_cansleep(st->dsa2_gpios[i], value & (1 << i)); in admfm2000_attenuation()
73 return -EINVAL; in admfm2000_attenuation()
82 int gain; in admfm2000_read_raw() local
86 mutex_lock(&st->lock); in admfm2000_read_raw()
87 gain = ~(st->gain[chan->channel]) * -1000; in admfm2000_read_raw()
88 *val = gain / 1000; in admfm2000_read_raw()
89 *val2 = (gain % 1000) * 1000; in admfm2000_read_raw()
90 mutex_unlock(&st->lock); in admfm2000_read_raw()
94 return -EINVAL; in admfm2000_read_raw()
103 int gain, ret; in admfm2000_write_raw() local
106 gain = (val * 1000) - (val2 / 1000); in admfm2000_write_raw()
108 gain = (val * 1000) + (val2 / 1000); in admfm2000_write_raw()
110 if (gain > ADMFM2000_MAX_GAIN || gain < ADMFM2000_MIN_GAIN) in admfm2000_write_raw()
111 return -EINVAL; in admfm2000_write_raw()
115 mutex_lock(&st->lock); in admfm2000_write_raw()
116 st->gain[chan->channel] = ~((abs(gain) / 1000) & 0x1F); in admfm2000_write_raw()
118 ret = admfm2000_attenuation(indio_dev, chan->channel, in admfm2000_write_raw()
119 st->gain[chan->channel]); in admfm2000_write_raw()
120 mutex_unlock(&st->lock); in admfm2000_write_raw()
123 return -EINVAL; in admfm2000_write_raw()
135 return -EINVAL; in admfm2000_write_raw_get_fmt()
161 struct platform_device *pdev = to_platform_device(indio_dev->dev.parent); in admfm2000_channel_config()
162 struct device *dev = &pdev->dev; in admfm2000_channel_config()
175 if (reg >= indio_dev->num_channels) in admfm2000_channel_config()
176 return dev_err_probe(dev, -EINVAL, "reg bigger than: %d\n", in admfm2000_channel_config()
177 indio_dev->num_channels); in admfm2000_channel_config()
179 if (fwnode_property_present(child, "adi,mixer-mode")) in admfm2000_channel_config()
186 sw = st->sw1_ch; in admfm2000_channel_config()
187 dsa = st->dsa1_gpios; in admfm2000_channel_config()
190 sw = st->sw2_ch; in admfm2000_channel_config()
191 dsa = st->dsa2_gpios; in admfm2000_channel_config()
194 return -EINVAL; in admfm2000_channel_config()
202 "Failed to get gpios\n"); in admfm2000_channel_config()
211 "Failed to get gpios\n"); in admfm2000_channel_config()
224 struct device *dev = &pdev->dev; in admfm2000_probe()
231 return -ENOMEM; in admfm2000_probe()
235 indio_dev->name = "admfm2000"; in admfm2000_probe()
236 indio_dev->num_channels = ARRAY_SIZE(admfm2000_channels); in admfm2000_probe()
237 indio_dev->channels = admfm2000_channels; in admfm2000_probe()
238 indio_dev->info = &admfm2000_info; in admfm2000_probe()
239 indio_dev->modes = INDIO_DIRECT_MODE; in admfm2000_probe()
241 st->gain[0] = ADMFM2000_DEFAULT_GAIN; in admfm2000_probe()
242 st->gain[1] = ADMFM2000_DEFAULT_GAIN; in admfm2000_probe()
244 mutex_init(&st->lock); in admfm2000_probe()