Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / iio / pressure / st_pressure_i2c.c
blob389523d6ae32106fcf396e2ae0290de4b9d759a7
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * STMicroelectronics pressures driver
5 * Copyright 2013 STMicroelectronics Inc.
7 * Denis Ciocca <denis.ciocca@st.com>
8 */
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/mod_devicetable.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,
50 .compatible = "st,lps22df",
51 .data = LPS22DF_PRESS_DEV_NAME,
53 {},
55 MODULE_DEVICE_TABLE(of, st_press_of_match);
57 static const struct acpi_device_id st_press_acpi_match[] = {
58 {"SNO9210", LPS22HB},
59 { },
61 MODULE_DEVICE_TABLE(acpi, st_press_acpi_match);
63 static const struct i2c_device_id st_press_id_table[] = {
64 { LPS001WP_PRESS_DEV_NAME, LPS001WP },
65 { LPS25H_PRESS_DEV_NAME, LPS25H },
66 { LPS331AP_PRESS_DEV_NAME, LPS331AP },
67 { LPS22HB_PRESS_DEV_NAME, LPS22HB },
68 { LPS33HW_PRESS_DEV_NAME, LPS33HW },
69 { LPS35HW_PRESS_DEV_NAME, LPS35HW },
70 { LPS22HH_PRESS_DEV_NAME, LPS22HH },
71 { LPS22DF_PRESS_DEV_NAME, LPS22DF },
72 {},
74 MODULE_DEVICE_TABLE(i2c, st_press_id_table);
76 static int st_press_i2c_probe(struct i2c_client *client)
78 const struct st_sensor_settings *settings;
79 struct st_sensor_data *press_data;
80 struct iio_dev *indio_dev;
81 int ret;
83 st_sensors_dev_name_probe(&client->dev, client->name, sizeof(client->name));
85 settings = st_press_get_settings(client->name);
86 if (!settings) {
87 dev_err(&client->dev, "device name %s not recognized.\n",
88 client->name);
89 return -ENODEV;
92 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*press_data));
93 if (!indio_dev)
94 return -ENOMEM;
96 press_data = iio_priv(indio_dev);
97 press_data->sensor_settings = (struct st_sensor_settings *)settings;
99 ret = st_sensors_i2c_configure(indio_dev, client);
100 if (ret < 0)
101 return ret;
103 ret = st_sensors_power_enable(indio_dev);
104 if (ret)
105 return ret;
107 return st_press_common_probe(indio_dev);
110 static struct i2c_driver st_press_driver = {
111 .driver = {
112 .name = "st-press-i2c",
113 .of_match_table = st_press_of_match,
114 .acpi_match_table = st_press_acpi_match,
116 .probe = st_press_i2c_probe,
117 .id_table = st_press_id_table,
119 module_i2c_driver(st_press_driver);
121 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
122 MODULE_DESCRIPTION("STMicroelectronics pressures i2c driver");
123 MODULE_LICENSE("GPL v2");
124 MODULE_IMPORT_NS(IIO_ST_SENSORS);