Lines Matching +full:i2cxl +full:- +full:maxsonar +full:- +full:ez_datasheet

1 // SPDX-License-Identifier: GPL-2.0+
3 * mb1232.c - Support for MaxBotix I2CXL-MaxSonar-EZ series ultrasonic
7 * Copyright (c) 2019 Andreas Klinger <ak@it-klinger.de>
10 * https://www.maxbotix.com/documents/I2CXL-MaxSonar-EZ_Datasheet.pdf
27 /* registers of MaxSonar device */
57 complete(&data->ranging); in mb1232_handle_irq()
64 struct i2c_client *client = data->client; in mb1232_read_distance()
69 mutex_lock(&data->lock); in mb1232_read_distance()
71 reinit_completion(&data->ranging); in mb1232_read_distance()
75 dev_err(&client->dev, "write command - err: %d\n", ret); in mb1232_read_distance()
79 if (data->irqnr >= 0) { in mb1232_read_distance()
81 ret = wait_for_completion_killable_timeout(&data->ranging, in mb1232_read_distance()
86 ret = -ETIMEDOUT; in mb1232_read_distance()
96 dev_err(&client->dev, "i2c_master_recv: ret=%d\n", ret); in mb1232_read_distance()
103 dev_err(&client->dev, "distance=%d\n", distance); in mb1232_read_distance()
104 ret = -EINVAL; in mb1232_read_distance()
108 mutex_unlock(&data->lock); in mb1232_read_distance()
113 mutex_unlock(&data->lock); in mb1232_read_distance()
121 struct iio_dev *indio_dev = pf->indio_dev; in mb1232_trigger_handler()
124 data->scan.distance = mb1232_read_distance(data); in mb1232_trigger_handler()
125 if (data->scan.distance < 0) in mb1232_trigger_handler()
128 iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, in mb1232_trigger_handler()
129 pf->timestamp); in mb1232_trigger_handler()
132 iio_trigger_notify_done(indio_dev->trig); in mb1232_trigger_handler()
143 if (channel->type != IIO_DISTANCE) in mb1232_read_raw()
144 return -EINVAL; in mb1232_read_raw()
159 return -EINVAL; in mb1232_read_raw()
189 struct device *dev = &client->dev; in mb1232_probe()
191 if (!i2c_check_functionality(client->adapter, in mb1232_probe()
194 return -ENODEV; in mb1232_probe()
198 return -ENOMEM; in mb1232_probe()
202 data->client = client; in mb1232_probe()
204 indio_dev->info = &mb1232_info; in mb1232_probe()
205 indio_dev->name = id->name; in mb1232_probe()
206 indio_dev->modes = INDIO_DIRECT_MODE; in mb1232_probe()
207 indio_dev->channels = mb1232_channels; in mb1232_probe()
208 indio_dev->num_channels = ARRAY_SIZE(mb1232_channels); in mb1232_probe()
210 mutex_init(&data->lock); in mb1232_probe()
212 init_completion(&data->ranging); in mb1232_probe()
214 data->irqnr = fwnode_irq_get(dev_fwnode(&client->dev), 0); in mb1232_probe()
215 if (data->irqnr <= 0) { in mb1232_probe()
217 data->irqnr = -1; in mb1232_probe()
219 ret = devm_request_irq(dev, data->irqnr, mb1232_handle_irq, in mb1232_probe()
220 IRQF_TRIGGER_FALLING, id->name, indio_dev); in mb1232_probe()
251 { "maxbotix-mb1202", },
252 { "maxbotix-mb1212", },
253 { "maxbotix-mb1222", },
254 { "maxbotix-mb1232", },
255 { "maxbotix-mb1242", },
256 { "maxbotix-mb7040", },
257 { "maxbotix-mb7137", },
264 .name = "maxbotix-mb1232",
272 MODULE_AUTHOR("Andreas Klinger <ak@it-klinger.de>");
273 MODULE_DESCRIPTION("Maxbotix I2CXL-MaxSonar i2c ultrasonic ranger driver");