1 // SPDX-License-Identifier: GPL-2.0-only
3 * STMicroelectronics pressures driver
5 * Copyright 2013 STMicroelectronics Inc.
7 * Denis Ciocca <denis.ciocca@st.com>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/slab.h>
13 #include <linux/i2c.h>
14 #include <linux/iio/iio.h>
16 #include <linux/iio/common/st_sensors.h>
17 #include <linux/iio/common/st_sensors_i2c.h>
18 #include "st_pressure.h"
20 static const struct of_device_id st_press_of_match
[] = {
22 .compatible
= "st,lps001wp-press",
23 .data
= LPS001WP_PRESS_DEV_NAME
,
26 .compatible
= "st,lps25h-press",
27 .data
= LPS25H_PRESS_DEV_NAME
,
30 .compatible
= "st,lps331ap-press",
31 .data
= LPS331AP_PRESS_DEV_NAME
,
34 .compatible
= "st,lps22hb-press",
35 .data
= LPS22HB_PRESS_DEV_NAME
,
38 .compatible
= "st,lps33hw",
39 .data
= LPS33HW_PRESS_DEV_NAME
,
42 .compatible
= "st,lps35hw",
43 .data
= LPS35HW_PRESS_DEV_NAME
,
46 .compatible
= "st,lps22hh",
47 .data
= LPS22HH_PRESS_DEV_NAME
,
51 MODULE_DEVICE_TABLE(of
, st_press_of_match
);
54 static const struct acpi_device_id st_press_acpi_match
[] = {
58 MODULE_DEVICE_TABLE(acpi
, st_press_acpi_match
);
61 static const struct i2c_device_id st_press_id_table
[] = {
62 { LPS001WP_PRESS_DEV_NAME
, LPS001WP
},
63 { LPS25H_PRESS_DEV_NAME
, LPS25H
},
64 { LPS331AP_PRESS_DEV_NAME
, LPS331AP
},
65 { LPS22HB_PRESS_DEV_NAME
, LPS22HB
},
66 { LPS33HW_PRESS_DEV_NAME
, LPS33HW
},
67 { LPS35HW_PRESS_DEV_NAME
, LPS35HW
},
68 { LPS22HH_PRESS_DEV_NAME
, LPS22HH
},
71 MODULE_DEVICE_TABLE(i2c
, st_press_id_table
);
73 static int st_press_i2c_probe(struct i2c_client
*client
,
74 const struct i2c_device_id
*id
)
76 const struct st_sensor_settings
*settings
;
77 struct st_sensor_data
*press_data
;
78 struct iio_dev
*indio_dev
;
81 st_sensors_dev_name_probe(&client
->dev
, client
->name
, sizeof(client
->name
));
83 settings
= st_press_get_settings(client
->name
);
85 dev_err(&client
->dev
, "device name %s not recognized.\n",
90 indio_dev
= devm_iio_device_alloc(&client
->dev
, sizeof(*press_data
));
94 press_data
= iio_priv(indio_dev
);
95 press_data
->sensor_settings
= (struct st_sensor_settings
*)settings
;
97 ret
= st_sensors_i2c_configure(indio_dev
, client
);
101 ret
= st_press_common_probe(indio_dev
);
108 static int st_press_i2c_remove(struct i2c_client
*client
)
110 st_press_common_remove(i2c_get_clientdata(client
));
115 static struct i2c_driver st_press_driver
= {
117 .name
= "st-press-i2c",
118 .of_match_table
= st_press_of_match
,
119 .acpi_match_table
= ACPI_PTR(st_press_acpi_match
),
121 .probe
= st_press_i2c_probe
,
122 .remove
= st_press_i2c_remove
,
123 .id_table
= st_press_id_table
,
125 module_i2c_driver(st_press_driver
);
127 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
128 MODULE_DESCRIPTION("STMicroelectronics pressures i2c driver");
129 MODULE_LICENSE("GPL v2");