sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / iio / accel / st_accel_i2c.c
blobc0f8867aa1eaf917574bc181f75fc0b8b397ffab
1 /*
2 * STMicroelectronics accelerometers driver
4 * Copyright 2012-2013 STMicroelectronics Inc.
6 * Denis Ciocca <denis.ciocca@st.com>
8 * Licensed under the GPL-2.
9 */
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/slab.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_accel.h"
21 #ifdef CONFIG_OF
22 static const struct of_device_id st_accel_of_match[] = {
24 .compatible = "st,lis3lv02dl-accel",
25 .data = LIS3LV02DL_ACCEL_DEV_NAME,
28 .compatible = "st,lsm303dlh-accel",
29 .data = LSM303DLH_ACCEL_DEV_NAME,
32 .compatible = "st,lsm303dlhc-accel",
33 .data = LSM303DLHC_ACCEL_DEV_NAME,
36 .compatible = "st,lis3dh-accel",
37 .data = LIS3DH_ACCEL_DEV_NAME,
40 .compatible = "st,lsm330d-accel",
41 .data = LSM330D_ACCEL_DEV_NAME,
44 .compatible = "st,lsm330dl-accel",
45 .data = LSM330DL_ACCEL_DEV_NAME,
48 .compatible = "st,lsm330dlc-accel",
49 .data = LSM330DLC_ACCEL_DEV_NAME,
52 .compatible = "st,lis331dl-accel",
53 .data = LIS331DL_ACCEL_DEV_NAME,
56 .compatible = "st,lis331dlh-accel",
57 .data = LIS331DLH_ACCEL_DEV_NAME,
60 .compatible = "st,lsm303dl-accel",
61 .data = LSM303DL_ACCEL_DEV_NAME,
64 .compatible = "st,lsm303dlm-accel",
65 .data = LSM303DLM_ACCEL_DEV_NAME,
68 .compatible = "st,lsm330-accel",
69 .data = LSM330_ACCEL_DEV_NAME,
72 .compatible = "st,lsm303agr-accel",
73 .data = LSM303AGR_ACCEL_DEV_NAME,
76 .compatible = "st,lis2dh12-accel",
77 .data = LIS2DH12_ACCEL_DEV_NAME,
80 .compatible = "st,h3lis331dl-accel",
81 .data = H3LIS331DL_DRIVER_NAME,
84 .compatible = "st,lis3l02dq",
85 .data = LIS3L02DQ_ACCEL_DEV_NAME,
88 .compatible = "st,lng2dm-accel",
89 .data = LNG2DM_ACCEL_DEV_NAME,
91 {},
93 MODULE_DEVICE_TABLE(of, st_accel_of_match);
94 #else
95 #define st_accel_of_match NULL
96 #endif
98 static int st_accel_i2c_probe(struct i2c_client *client,
99 const struct i2c_device_id *id)
101 struct iio_dev *indio_dev;
102 struct st_sensor_data *adata;
103 int err;
105 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adata));
106 if (!indio_dev)
107 return -ENOMEM;
109 adata = iio_priv(indio_dev);
110 st_sensors_of_i2c_probe(client, st_accel_of_match);
112 st_sensors_i2c_configure(indio_dev, client, adata);
114 err = st_accel_common_probe(indio_dev);
115 if (err < 0)
116 return err;
118 return 0;
121 static int st_accel_i2c_remove(struct i2c_client *client)
123 st_accel_common_remove(i2c_get_clientdata(client));
125 return 0;
128 static const struct i2c_device_id st_accel_id_table[] = {
129 { LSM303DLH_ACCEL_DEV_NAME },
130 { LSM303DLHC_ACCEL_DEV_NAME },
131 { LIS3DH_ACCEL_DEV_NAME },
132 { LSM330D_ACCEL_DEV_NAME },
133 { LSM330DL_ACCEL_DEV_NAME },
134 { LSM330DLC_ACCEL_DEV_NAME },
135 { LIS331DLH_ACCEL_DEV_NAME },
136 { LSM303DL_ACCEL_DEV_NAME },
137 { LSM303DLM_ACCEL_DEV_NAME },
138 { LSM330_ACCEL_DEV_NAME },
139 { LSM303AGR_ACCEL_DEV_NAME },
140 { LIS2DH12_ACCEL_DEV_NAME },
141 { LIS3L02DQ_ACCEL_DEV_NAME },
142 { LNG2DM_ACCEL_DEV_NAME },
145 MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
147 static struct i2c_driver st_accel_driver = {
148 .driver = {
149 .name = "st-accel-i2c",
150 .of_match_table = of_match_ptr(st_accel_of_match),
152 .probe = st_accel_i2c_probe,
153 .remove = st_accel_i2c_remove,
154 .id_table = st_accel_id_table,
156 module_i2c_driver(st_accel_driver);
158 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
159 MODULE_DESCRIPTION("STMicroelectronics accelerometers i2c driver");
160 MODULE_LICENSE("GPL v2");