1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver
5 * Copyright (c) Andreas Klinger <ak@it-klinger.de>
8 * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf
11 #include <linux/device.h>
12 #include <linux/errno.h>
13 #include <linux/i2c.h>
14 #include <linux/mod_devicetable.h>
15 #include <linux/module.h>
16 #include <linux/types.h>
18 #include "mprls0025pa.h"
20 static int mpr_i2c_init(struct device
*unused
)
25 static int mpr_i2c_read(struct mpr_data
*data
, const u8 unused
, const u8 cnt
)
28 struct i2c_client
*client
= to_i2c_client(data
->dev
);
30 if (cnt
> MPR_MEASUREMENT_RD_SIZE
)
33 memset(data
->buffer
, 0, MPR_MEASUREMENT_RD_SIZE
);
34 ret
= i2c_master_recv(client
, data
->buffer
, cnt
);
43 static int mpr_i2c_write(struct mpr_data
*data
, const u8 cmd
, const u8 unused
)
46 struct i2c_client
*client
= to_i2c_client(data
->dev
);
47 u8 wdata
[MPR_PKT_SYNC_LEN
];
49 memset(wdata
, 0, sizeof(wdata
));
52 ret
= i2c_master_send(client
, wdata
, MPR_PKT_SYNC_LEN
);
55 else if (ret
!= MPR_PKT_SYNC_LEN
)
61 static const struct mpr_ops mpr_i2c_ops
= {
64 .write
= mpr_i2c_write
,
67 static int mpr_i2c_probe(struct i2c_client
*client
)
69 if (!i2c_check_functionality(client
->adapter
, I2C_FUNC_SMBUS_READ_BYTE
))
72 return mpr_common_probe(&client
->dev
, &mpr_i2c_ops
, client
->irq
);
75 static const struct of_device_id mpr_i2c_match
[] = {
76 { .compatible
= "honeywell,mprls0025pa" },
79 MODULE_DEVICE_TABLE(of
, mpr_i2c_match
);
81 static const struct i2c_device_id mpr_i2c_id
[] = {
85 MODULE_DEVICE_TABLE(i2c
, mpr_i2c_id
);
87 static struct i2c_driver mpr_i2c_driver
= {
88 .probe
= mpr_i2c_probe
,
89 .id_table
= mpr_i2c_id
,
91 .name
= "mprls0025pa",
92 .of_match_table
= mpr_i2c_match
,
95 module_i2c_driver(mpr_i2c_driver
);
97 MODULE_AUTHOR("Andreas Klinger <ak@it-klinger.de>");
98 MODULE_DESCRIPTION("Honeywell MPR pressure sensor i2c driver");
99 MODULE_LICENSE("GPL");
100 MODULE_IMPORT_NS("IIO_HONEYWELL_MPRLS0025PA");