GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / iio / chemical / atlas-ph-sensor.c
1 /*
2  * atlas-ph-sensor.c - Support for Atlas Scientific OEM pH-SM sensor
3  *
4  * Copyright (C) 2015 Matt Ranostay <mranostay@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  */
16
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/interrupt.h>
20 #include <linux/delay.h>
21 #include <linux/mutex.h>
22 #include <linux/err.h>
23 #include <linux/irq.h>
24 #include <linux/irq_work.h>
25 #include <linux/gpio.h>
26 #include <linux/i2c.h>
27 #include <linux/of_device.h>
28 #include <linux/regmap.h>
29 #include <linux/iio/iio.h>
30 #include <linux/iio/buffer.h>
31 #include <linux/iio/trigger.h>
32 #include <linux/iio/trigger_consumer.h>
33 #include <linux/iio/triggered_buffer.h>
34 #include <linux/pm_runtime.h>
35
36 #define ATLAS_REGMAP_NAME       "atlas_ph_regmap"
37 #define ATLAS_DRV_NAME          "atlas_ph"
38
39 #define ATLAS_REG_DEV_TYPE              0x00
40 #define ATLAS_REG_DEV_VERSION           0x01
41
42 #define ATLAS_REG_INT_CONTROL           0x04
43 #define ATLAS_REG_INT_CONTROL_EN        BIT(3)
44
45 #define ATLAS_REG_PWR_CONTROL           0x06
46
47 #define ATLAS_REG_PH_CALIB_STATUS       0x0d
48 #define ATLAS_REG_PH_CALIB_STATUS_MASK  0x07
49 #define ATLAS_REG_PH_CALIB_STATUS_LOW   BIT(0)
50 #define ATLAS_REG_PH_CALIB_STATUS_MID   BIT(1)
51 #define ATLAS_REG_PH_CALIB_STATUS_HIGH  BIT(2)
52
53 #define ATLAS_REG_EC_CALIB_STATUS               0x0f
54 #define ATLAS_REG_EC_CALIB_STATUS_MASK          0x0f
55 #define ATLAS_REG_EC_CALIB_STATUS_DRY           BIT(0)
56 #define ATLAS_REG_EC_CALIB_STATUS_SINGLE        BIT(1)
57 #define ATLAS_REG_EC_CALIB_STATUS_LOW           BIT(2)
58 #define ATLAS_REG_EC_CALIB_STATUS_HIGH          BIT(3)
59
60 #define ATLAS_REG_PH_TEMP_DATA          0x0e
61 #define ATLAS_REG_PH_DATA               0x16
62
63 #define ATLAS_REG_EC_PROBE              0x08
64 #define ATLAS_REG_EC_TEMP_DATA          0x10
65 #define ATLAS_REG_EC_DATA               0x18
66 #define ATLAS_REG_TDS_DATA              0x1c
67 #define ATLAS_REG_PSS_DATA              0x20
68
69 #define ATLAS_REG_ORP_CALIB_STATUS      0x0d
70 #define ATLAS_REG_ORP_DATA              0x0e
71
72 #define ATLAS_PH_INT_TIME_IN_US         450000
73 #define ATLAS_EC_INT_TIME_IN_US         650000
74 #define ATLAS_ORP_INT_TIME_IN_US        450000
75
76 enum {
77         ATLAS_PH_SM,
78         ATLAS_EC_SM,
79         ATLAS_ORP_SM,
80 };
81
82 struct atlas_data {
83         struct i2c_client *client;
84         struct iio_trigger *trig;
85         struct atlas_device *chip;
86         struct regmap *regmap;
87         struct irq_work work;
88
89         __be32 buffer[6]; /* 96-bit data + 32-bit pad + 64-bit timestamp */
90 };
91
92 static const struct regmap_config atlas_regmap_config = {
93         .name = ATLAS_REGMAP_NAME,
94         .reg_bits = 8,
95         .val_bits = 8,
96 };
97
98 static const struct iio_chan_spec atlas_ph_channels[] = {
99         {
100                 .type = IIO_PH,
101                 .address = ATLAS_REG_PH_DATA,
102                 .info_mask_separate =
103                         BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
104                 .scan_index = 0,
105                 .scan_type = {
106                         .sign = 'u',
107                         .realbits = 32,
108                         .storagebits = 32,
109                         .endianness = IIO_BE,
110                 },
111         },
112         IIO_CHAN_SOFT_TIMESTAMP(1),
113         {
114                 .type = IIO_TEMP,
115                 .address = ATLAS_REG_PH_TEMP_DATA,
116                 .info_mask_separate =
117                         BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
118                 .output = 1,
119                 .scan_index = -1
120         },
121 };
122
123 #define ATLAS_EC_CHANNEL(_idx, _addr) \
124         {\
125                 .type = IIO_CONCENTRATION, \
126                 .indexed = 1, \
127                 .channel = _idx, \
128                 .address = _addr, \
129                 .info_mask_separate = \
130                         BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), \
131                 .scan_index = _idx + 1, \
132                 .scan_type = { \
133                         .sign = 'u', \
134                         .realbits = 32, \
135                         .storagebits = 32, \
136                         .endianness = IIO_BE, \
137                 }, \
138         }
139
140 static const struct iio_chan_spec atlas_ec_channels[] = {
141         {
142                 .type = IIO_ELECTRICALCONDUCTIVITY,
143                 .address = ATLAS_REG_EC_DATA,
144                 .info_mask_separate =
145                         BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
146                 .scan_index = 0,
147                 .scan_type = {
148                         .sign = 'u',
149                         .realbits = 32,
150                         .storagebits = 32,
151                         .endianness = IIO_BE,
152                 },
153         },
154         ATLAS_EC_CHANNEL(0, ATLAS_REG_TDS_DATA),
155         ATLAS_EC_CHANNEL(1, ATLAS_REG_PSS_DATA),
156         IIO_CHAN_SOFT_TIMESTAMP(3),
157         {
158                 .type = IIO_TEMP,
159                 .address = ATLAS_REG_EC_TEMP_DATA,
160                 .info_mask_separate =
161                         BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
162                 .output = 1,
163                 .scan_index = -1
164         },
165 };
166
167 static const struct iio_chan_spec atlas_orp_channels[] = {
168         {
169                 .type = IIO_VOLTAGE,
170                 .address = ATLAS_REG_ORP_DATA,
171                 .info_mask_separate =
172                         BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
173                 .scan_index = 0,
174                 .scan_type = {
175                         .sign = 's',
176                         .realbits = 32,
177                         .storagebits = 32,
178                         .endianness = IIO_BE,
179                 },
180         },
181         IIO_CHAN_SOFT_TIMESTAMP(1),
182 };
183
184 static int atlas_check_ph_calibration(struct atlas_data *data)
185 {
186         struct device *dev = &data->client->dev;
187         int ret;
188         unsigned int val;
189
190         ret = regmap_read(data->regmap, ATLAS_REG_PH_CALIB_STATUS, &val);
191         if (ret)
192                 return ret;
193
194         if (!(val & ATLAS_REG_PH_CALIB_STATUS_MASK)) {
195                 dev_warn(dev, "device has not been calibrated\n");
196                 return 0;
197         }
198
199         if (!(val & ATLAS_REG_PH_CALIB_STATUS_LOW))
200                 dev_warn(dev, "device missing low point calibration\n");
201
202         if (!(val & ATLAS_REG_PH_CALIB_STATUS_MID))
203                 dev_warn(dev, "device missing mid point calibration\n");
204
205         if (!(val & ATLAS_REG_PH_CALIB_STATUS_HIGH))
206                 dev_warn(dev, "device missing high point calibration\n");
207
208         return 0;
209 }
210
211 static int atlas_check_ec_calibration(struct atlas_data *data)
212 {
213         struct device *dev = &data->client->dev;
214         int ret;
215         unsigned int val;
216         __be16  rval;
217
218         ret = regmap_bulk_read(data->regmap, ATLAS_REG_EC_PROBE, &rval, 2);
219         if (ret)
220                 return ret;
221
222         val = be16_to_cpu(rval);
223         dev_info(dev, "probe set to K = %d.%.2d", val / 100, val % 100);
224
225         ret = regmap_read(data->regmap, ATLAS_REG_EC_CALIB_STATUS, &val);
226         if (ret)
227                 return ret;
228
229         if (!(val & ATLAS_REG_EC_CALIB_STATUS_MASK)) {
230                 dev_warn(dev, "device has not been calibrated\n");
231                 return 0;
232         }
233
234         if (!(val & ATLAS_REG_EC_CALIB_STATUS_DRY))
235                 dev_warn(dev, "device missing dry point calibration\n");
236
237         if (val & ATLAS_REG_EC_CALIB_STATUS_SINGLE) {
238                 dev_warn(dev, "device using single point calibration\n");
239         } else {
240                 if (!(val & ATLAS_REG_EC_CALIB_STATUS_LOW))
241                         dev_warn(dev, "device missing low point calibration\n");
242
243                 if (!(val & ATLAS_REG_EC_CALIB_STATUS_HIGH))
244                         dev_warn(dev, "device missing high point calibration\n");
245         }
246
247         return 0;
248 }
249
250 static int atlas_check_orp_calibration(struct atlas_data *data)
251 {
252         struct device *dev = &data->client->dev;
253         int ret;
254         unsigned int val;
255
256         ret = regmap_read(data->regmap, ATLAS_REG_ORP_CALIB_STATUS, &val);
257         if (ret)
258                 return ret;
259
260         if (!val)
261                 dev_warn(dev, "device has not been calibrated\n");
262
263         return 0;
264 };
265
266 struct atlas_device {
267         const struct iio_chan_spec *channels;
268         int num_channels;
269         int data_reg;
270
271         int (*calibration)(struct atlas_data *data);
272         int delay;
273 };
274
275 static struct atlas_device atlas_devices[] = {
276         [ATLAS_PH_SM] = {
277                                 .channels = atlas_ph_channels,
278                                 .num_channels = 3,
279                                 .data_reg = ATLAS_REG_PH_DATA,
280                                 .calibration = &atlas_check_ph_calibration,
281                                 .delay = ATLAS_PH_INT_TIME_IN_US,
282         },
283         [ATLAS_EC_SM] = {
284                                 .channels = atlas_ec_channels,
285                                 .num_channels = 5,
286                                 .data_reg = ATLAS_REG_EC_DATA,
287                                 .calibration = &atlas_check_ec_calibration,
288                                 .delay = ATLAS_EC_INT_TIME_IN_US,
289         },
290         [ATLAS_ORP_SM] = {
291                                 .channels = atlas_orp_channels,
292                                 .num_channels = 2,
293                                 .data_reg = ATLAS_REG_ORP_DATA,
294                                 .calibration = &atlas_check_orp_calibration,
295                                 .delay = ATLAS_ORP_INT_TIME_IN_US,
296         },
297 };
298
299 static int atlas_set_powermode(struct atlas_data *data, int on)
300 {
301         return regmap_write(data->regmap, ATLAS_REG_PWR_CONTROL, on);
302 }
303
304 static int atlas_set_interrupt(struct atlas_data *data, bool state)
305 {
306         return regmap_update_bits(data->regmap, ATLAS_REG_INT_CONTROL,
307                                   ATLAS_REG_INT_CONTROL_EN,
308                                   state ? ATLAS_REG_INT_CONTROL_EN : 0);
309 }
310
311 static int atlas_buffer_postenable(struct iio_dev *indio_dev)
312 {
313         struct atlas_data *data = iio_priv(indio_dev);
314         int ret;
315
316         ret = iio_triggered_buffer_postenable(indio_dev);
317         if (ret)
318                 return ret;
319
320         ret = pm_runtime_get_sync(&data->client->dev);
321         if (ret < 0) {
322                 pm_runtime_put_noidle(&data->client->dev);
323                 return ret;
324         }
325
326         return atlas_set_interrupt(data, true);
327 }
328
329 static int atlas_buffer_predisable(struct iio_dev *indio_dev)
330 {
331         struct atlas_data *data = iio_priv(indio_dev);
332         int ret;
333
334         ret = iio_triggered_buffer_predisable(indio_dev);
335         if (ret)
336                 return ret;
337
338         ret = atlas_set_interrupt(data, false);
339         if (ret)
340                 return ret;
341
342         pm_runtime_mark_last_busy(&data->client->dev);
343         return pm_runtime_put_autosuspend(&data->client->dev);
344 }
345
346 static const struct iio_trigger_ops atlas_interrupt_trigger_ops = {
347         .owner = THIS_MODULE,
348 };
349
350 static const struct iio_buffer_setup_ops atlas_buffer_setup_ops = {
351         .postenable = atlas_buffer_postenable,
352         .predisable = atlas_buffer_predisable,
353 };
354
355 static void atlas_work_handler(struct irq_work *work)
356 {
357         struct atlas_data *data = container_of(work, struct atlas_data, work);
358
359         iio_trigger_poll(data->trig);
360 }
361
362 static irqreturn_t atlas_trigger_handler(int irq, void *private)
363 {
364         struct iio_poll_func *pf = private;
365         struct iio_dev *indio_dev = pf->indio_dev;
366         struct atlas_data *data = iio_priv(indio_dev);
367         int ret;
368
369         ret = regmap_bulk_read(data->regmap, data->chip->data_reg,
370                               (u8 *) &data->buffer,
371                               sizeof(__be32) * (data->chip->num_channels - 2));
372
373         if (!ret)
374                 iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
375                                 iio_get_time_ns(indio_dev));
376
377         iio_trigger_notify_done(indio_dev->trig);
378
379         return IRQ_HANDLED;
380 }
381
382 static irqreturn_t atlas_interrupt_handler(int irq, void *private)
383 {
384         struct iio_dev *indio_dev = private;
385         struct atlas_data *data = iio_priv(indio_dev);
386
387         irq_work_queue(&data->work);
388
389         return IRQ_HANDLED;
390 }
391
392 static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val)
393 {
394         struct device *dev = &data->client->dev;
395         int suspended = pm_runtime_suspended(dev);
396         int ret;
397
398         ret = pm_runtime_get_sync(dev);
399         if (ret < 0) {
400                 pm_runtime_put_noidle(dev);
401                 return ret;
402         }
403
404         if (suspended)
405                 usleep_range(data->chip->delay, data->chip->delay + 100000);
406
407         ret = regmap_bulk_read(data->regmap, reg, (u8 *) val, sizeof(*val));
408
409         pm_runtime_mark_last_busy(dev);
410         pm_runtime_put_autosuspend(dev);
411
412         return ret;
413 }
414
415 static int atlas_read_raw(struct iio_dev *indio_dev,
416                           struct iio_chan_spec const *chan,
417                           int *val, int *val2, long mask)
418 {
419         struct atlas_data *data = iio_priv(indio_dev);
420
421         switch (mask) {
422         case IIO_CHAN_INFO_RAW: {
423                 int ret;
424                 __be32 reg;
425
426                 switch (chan->type) {
427                 case IIO_TEMP:
428                         ret = regmap_bulk_read(data->regmap, chan->address,
429                                               (u8 *) &reg, sizeof(reg));
430                         break;
431                 case IIO_PH:
432                 case IIO_CONCENTRATION:
433                 case IIO_ELECTRICALCONDUCTIVITY:
434                 case IIO_VOLTAGE:
435                         ret = iio_device_claim_direct_mode(indio_dev);
436                         if (ret)
437                                 return ret;
438
439                         ret = atlas_read_measurement(data, chan->address, &reg);
440
441                         iio_device_release_direct_mode(indio_dev);
442                         break;
443                 default:
444                         ret = -EINVAL;
445                 }
446
447                 if (!ret) {
448                         *val = be32_to_cpu(reg);
449                         ret = IIO_VAL_INT;
450                 }
451                 return ret;
452         }
453         case IIO_CHAN_INFO_SCALE:
454                 switch (chan->type) {
455                 case IIO_TEMP:
456                         *val = 10;
457                         return IIO_VAL_INT;
458                 case IIO_PH:
459                         *val = 1; /* 0.001 */
460                         *val2 = 1000;
461                         break;
462                 case IIO_ELECTRICALCONDUCTIVITY:
463                         *val = 1; /* 0.00001 */
464                         *val2 = 100000;
465                         break;
466                 case IIO_CONCENTRATION:
467                         *val = 0; /* 0.000000001 */
468                         *val2 = 1000;
469                         return IIO_VAL_INT_PLUS_NANO;
470                 case IIO_VOLTAGE:
471                         *val = 1; /* 0.1 */
472                         *val2 = 10;
473                         break;
474                 default:
475                         return -EINVAL;
476                 }
477                 return IIO_VAL_FRACTIONAL;
478         }
479
480         return -EINVAL;
481 }
482
483 static int atlas_write_raw(struct iio_dev *indio_dev,
484                            struct iio_chan_spec const *chan,
485                            int val, int val2, long mask)
486 {
487         struct atlas_data *data = iio_priv(indio_dev);
488         __be32 reg = cpu_to_be32(val / 10);
489
490         if (val2 != 0 || val < 0 || val > 20000)
491                 return -EINVAL;
492
493         if (mask != IIO_CHAN_INFO_RAW || chan->type != IIO_TEMP)
494                 return -EINVAL;
495
496         return regmap_bulk_write(data->regmap, chan->address,
497                                  &reg, sizeof(reg));
498 }
499
500 static const struct iio_info atlas_info = {
501         .driver_module = THIS_MODULE,
502         .read_raw = atlas_read_raw,
503         .write_raw = atlas_write_raw,
504 };
505
506 static const struct i2c_device_id atlas_id[] = {
507         { "atlas-ph-sm", ATLAS_PH_SM},
508         { "atlas-ec-sm", ATLAS_EC_SM},
509         { "atlas-orp-sm", ATLAS_ORP_SM},
510         {}
511 };
512 MODULE_DEVICE_TABLE(i2c, atlas_id);
513
514 static const struct of_device_id atlas_dt_ids[] = {
515         { .compatible = "atlas,ph-sm", .data = (void *)ATLAS_PH_SM, },
516         { .compatible = "atlas,ec-sm", .data = (void *)ATLAS_EC_SM, },
517         { .compatible = "atlas,orp-sm", .data = (void *)ATLAS_ORP_SM, },
518         { }
519 };
520 MODULE_DEVICE_TABLE(of, atlas_dt_ids);
521
522 static int atlas_probe(struct i2c_client *client,
523                        const struct i2c_device_id *id)
524 {
525         struct atlas_data *data;
526         struct atlas_device *chip;
527         const struct of_device_id *of_id;
528         struct iio_trigger *trig;
529         struct iio_dev *indio_dev;
530         int ret;
531
532         indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
533         if (!indio_dev)
534                 return -ENOMEM;
535
536         of_id = of_match_device(atlas_dt_ids, &client->dev);
537         if (!of_id)
538                 chip = &atlas_devices[id->driver_data];
539         else
540                 chip = &atlas_devices[(unsigned long)of_id->data];
541
542         indio_dev->info = &atlas_info;
543         indio_dev->name = ATLAS_DRV_NAME;
544         indio_dev->channels = chip->channels;
545         indio_dev->num_channels = chip->num_channels;
546         indio_dev->modes = INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE;
547         indio_dev->dev.parent = &client->dev;
548
549         trig = devm_iio_trigger_alloc(&client->dev, "%s-dev%d",
550                                       indio_dev->name, indio_dev->id);
551
552         if (!trig)
553                 return -ENOMEM;
554
555         data = iio_priv(indio_dev);
556         data->client = client;
557         data->trig = trig;
558         data->chip = chip;
559         trig->dev.parent = indio_dev->dev.parent;
560         trig->ops = &atlas_interrupt_trigger_ops;
561         iio_trigger_set_drvdata(trig, indio_dev);
562
563         i2c_set_clientdata(client, indio_dev);
564
565         data->regmap = devm_regmap_init_i2c(client, &atlas_regmap_config);
566         if (IS_ERR(data->regmap)) {
567                 dev_err(&client->dev, "regmap initialization failed\n");
568                 return PTR_ERR(data->regmap);
569         }
570
571         ret = pm_runtime_set_active(&client->dev);
572         if (ret)
573                 return ret;
574
575         if (client->irq <= 0) {
576                 dev_err(&client->dev, "no valid irq defined\n");
577                 return -EINVAL;
578         }
579
580         ret = chip->calibration(data);
581         if (ret)
582                 return ret;
583
584         ret = iio_trigger_register(trig);
585         if (ret) {
586                 dev_err(&client->dev, "failed to register trigger\n");
587                 return ret;
588         }
589
590         ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
591                 &atlas_trigger_handler, &atlas_buffer_setup_ops);
592         if (ret) {
593                 dev_err(&client->dev, "cannot setup iio trigger\n");
594                 goto unregister_trigger;
595         }
596
597         init_irq_work(&data->work, atlas_work_handler);
598
599         /* interrupt pin toggles on new conversion */
600         ret = devm_request_threaded_irq(&client->dev, client->irq,
601                                         NULL, atlas_interrupt_handler,
602                                         IRQF_TRIGGER_RISING |
603                                         IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
604                                         "atlas_irq",
605                                         indio_dev);
606         if (ret) {
607                 dev_err(&client->dev, "request irq (%d) failed\n", client->irq);
608                 goto unregister_buffer;
609         }
610
611         ret = atlas_set_powermode(data, 1);
612         if (ret) {
613                 dev_err(&client->dev, "cannot power device on");
614                 goto unregister_buffer;
615         }
616
617         pm_runtime_enable(&client->dev);
618         pm_runtime_set_autosuspend_delay(&client->dev, 2500);
619         pm_runtime_use_autosuspend(&client->dev);
620
621         ret = iio_device_register(indio_dev);
622         if (ret) {
623                 dev_err(&client->dev, "unable to register device\n");
624                 goto unregister_pm;
625         }
626
627         return 0;
628
629 unregister_pm:
630         pm_runtime_disable(&client->dev);
631         atlas_set_powermode(data, 0);
632
633 unregister_buffer:
634         iio_triggered_buffer_cleanup(indio_dev);
635
636 unregister_trigger:
637         iio_trigger_unregister(data->trig);
638
639         return ret;
640 }
641
642 static int atlas_remove(struct i2c_client *client)
643 {
644         struct iio_dev *indio_dev = i2c_get_clientdata(client);
645         struct atlas_data *data = iio_priv(indio_dev);
646
647         iio_device_unregister(indio_dev);
648         iio_triggered_buffer_cleanup(indio_dev);
649         iio_trigger_unregister(data->trig);
650
651         pm_runtime_disable(&client->dev);
652         pm_runtime_set_suspended(&client->dev);
653         pm_runtime_put_noidle(&client->dev);
654
655         return atlas_set_powermode(data, 0);
656 }
657
658 #ifdef CONFIG_PM
659 static int atlas_runtime_suspend(struct device *dev)
660 {
661         struct atlas_data *data =
662                      iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
663
664         return atlas_set_powermode(data, 0);
665 }
666
667 static int atlas_runtime_resume(struct device *dev)
668 {
669         struct atlas_data *data =
670                      iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
671
672         return atlas_set_powermode(data, 1);
673 }
674 #endif
675
676 static const struct dev_pm_ops atlas_pm_ops = {
677         SET_RUNTIME_PM_OPS(atlas_runtime_suspend,
678                            atlas_runtime_resume, NULL)
679 };
680
681 static struct i2c_driver atlas_driver = {
682         .driver = {
683                 .name   = ATLAS_DRV_NAME,
684                 .of_match_table = of_match_ptr(atlas_dt_ids),
685                 .pm     = &atlas_pm_ops,
686         },
687         .probe          = atlas_probe,
688         .remove         = atlas_remove,
689         .id_table       = atlas_id,
690 };
691 module_i2c_driver(atlas_driver);
692
693 MODULE_AUTHOR("Matt Ranostay <mranostay@gmail.com>");
694 MODULE_DESCRIPTION("Atlas Scientific pH-SM sensor");
695 MODULE_LICENSE("GPL");