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/acpi.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/mod_devicetable.h>
14 #include <linux/i2c.h>
15 #include <linux/iio/iio.h>
17 #include <linux/iio/common/st_sensors.h>
18 #include <linux/iio/common/st_sensors_i2c.h>
19 #include "st_pressure.h"
21 static const struct of_device_id st_press_of_match[] = {
23 .compatible = "st,lps001wp-press",
24 .data = LPS001WP_PRESS_DEV_NAME,
27 .compatible = "st,lps25h-press",
28 .data = LPS25H_PRESS_DEV_NAME,
31 .compatible = "st,lps331ap-press",
32 .data = LPS331AP_PRESS_DEV_NAME,
35 .compatible = "st,lps22hb-press",
36 .data = LPS22HB_PRESS_DEV_NAME,
39 .compatible = "st,lps33hw",
40 .data = LPS33HW_PRESS_DEV_NAME,
43 .compatible = "st,lps35hw",
44 .data = LPS35HW_PRESS_DEV_NAME,
47 .compatible = "st,lps22hh",
48 .data = LPS22HH_PRESS_DEV_NAME,
52 MODULE_DEVICE_TABLE(of, st_press_of_match);
55 static const struct acpi_device_id st_press_acpi_match[] = {
59 MODULE_DEVICE_TABLE(acpi, st_press_acpi_match);
62 static const struct i2c_device_id st_press_id_table[] = {
63 { LPS001WP_PRESS_DEV_NAME, LPS001WP },
64 { LPS25H_PRESS_DEV_NAME, LPS25H },
65 { LPS331AP_PRESS_DEV_NAME, LPS331AP },
66 { LPS22HB_PRESS_DEV_NAME, LPS22HB },
67 { LPS33HW_PRESS_DEV_NAME, LPS33HW },
68 { LPS35HW_PRESS_DEV_NAME, LPS35HW },
69 { LPS22HH_PRESS_DEV_NAME, LPS22HH },
72 MODULE_DEVICE_TABLE(i2c, st_press_id_table);
74 static int st_press_i2c_probe(struct i2c_client *client,
75 const struct i2c_device_id *id)
77 const struct st_sensor_settings *settings;
78 struct st_sensor_data *press_data;
79 struct iio_dev *indio_dev;
82 st_sensors_dev_name_probe(&client->dev, client->name, sizeof(client->name));
84 settings = st_press_get_settings(client->name);
86 dev_err(&client->dev, "device name %s not recognized.\n",
91 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*press_data));
95 press_data = iio_priv(indio_dev);
96 press_data->sensor_settings = (struct st_sensor_settings *)settings;
98 ret = st_sensors_i2c_configure(indio_dev, client);
102 ret = st_sensors_power_enable(indio_dev);
106 return st_press_common_probe(indio_dev);
109 static struct i2c_driver st_press_driver = {
111 .name = "st-press-i2c",
112 .of_match_table = st_press_of_match,
113 .acpi_match_table = ACPI_PTR(st_press_acpi_match),
115 .probe = st_press_i2c_probe,
116 .id_table = st_press_id_table,
118 module_i2c_driver(st_press_driver);
120 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
121 MODULE_DESCRIPTION("STMicroelectronics pressures i2c driver");
122 MODULE_LICENSE("GPL v2");
123 MODULE_IMPORT_NS(IIO_ST_SENSORS);