Skip to content

Commit 45a4e42

Browse files
LorenzoBianconijic23
authored andcommitted
iio: gyro: st_gyro: fix L3GD20H support
Add proper support for L3GD20H gyroscope sensor. In particular: - use L3GD20H as device name instead of L3GD20 - fix available full scales - fix available sample frequencies Note that the original patch listed first below introduced broken support for this part. The second patch drops the support as it didn't work. This new patch brings in working support. Fixes: 9444a30 (IIO: Add support for L3GD20H gyroscope) Fixes: a065771 ("iio:gyro: bug on L3GD20H gyroscope support") Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 1911f48 commit 45a4e42

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

drivers/iio/gyro/st_gyro.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define LSM330DL_GYRO_DEV_NAME "lsm330dl_gyro"
2020
#define LSM330DLC_GYRO_DEV_NAME "lsm330dlc_gyro"
2121
#define L3GD20_GYRO_DEV_NAME "l3gd20"
22+
#define L3GD20H_GYRO_DEV_NAME "l3gd20h"
2223
#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui"
2324
#define LSM330_GYRO_DEV_NAME "lsm330_gyro"
2425
#define LSM9DS0_GYRO_DEV_NAME "lsm9ds0_gyro"

drivers/iio/gyro/st_gyro_core.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define ST_GYRO_DEFAULT_OUT_Z_L_ADDR 0x2c
3636

3737
/* FULLSCALE */
38+
#define ST_GYRO_FS_AVL_245DPS 245
3839
#define ST_GYRO_FS_AVL_250DPS 250
3940
#define ST_GYRO_FS_AVL_500DPS 500
4041
#define ST_GYRO_FS_AVL_2000DPS 2000
@@ -196,17 +197,17 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
196197
.wai = 0xd7,
197198
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
198199
.sensors_supported = {
199-
[0] = L3GD20_GYRO_DEV_NAME,
200+
[0] = L3GD20H_GYRO_DEV_NAME,
200201
},
201202
.ch = (struct iio_chan_spec *)st_gyro_16bit_channels,
202203
.odr = {
203204
.addr = 0x20,
204205
.mask = 0xc0,
205206
.odr_avl = {
206-
{ .hz = 95, .value = 0x00, },
207-
{ .hz = 190, .value = 0x01, },
208-
{ .hz = 380, .value = 0x02, },
209-
{ .hz = 760, .value = 0x03, },
207+
{ .hz = 100, .value = 0x00, },
208+
{ .hz = 200, .value = 0x01, },
209+
{ .hz = 400, .value = 0x02, },
210+
{ .hz = 800, .value = 0x03, },
210211
},
211212
},
212213
.pw = {
@@ -224,7 +225,7 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
224225
.mask = 0x30,
225226
.fs_avl = {
226227
[0] = {
227-
.num = ST_GYRO_FS_AVL_250DPS,
228+
.num = ST_GYRO_FS_AVL_245DPS,
228229
.value = 0x00,
229230
.gain = IIO_DEGREE_TO_RAD(8750),
230231
},

drivers/iio/gyro/st_gyro_i2c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ static const struct of_device_id st_gyro_of_match[] = {
4040
.compatible = "st,l3gd20-gyro",
4141
.data = L3GD20_GYRO_DEV_NAME,
4242
},
43+
{
44+
.compatible = "st,l3gd20h-gyro",
45+
.data = L3GD20H_GYRO_DEV_NAME,
46+
},
4347
{
4448
.compatible = "st,l3g4is-gyro",
4549
.data = L3G4IS_GYRO_DEV_NAME,
@@ -95,6 +99,7 @@ static const struct i2c_device_id st_gyro_id_table[] = {
9599
{ LSM330DL_GYRO_DEV_NAME },
96100
{ LSM330DLC_GYRO_DEV_NAME },
97101
{ L3GD20_GYRO_DEV_NAME },
102+
{ L3GD20H_GYRO_DEV_NAME },
98103
{ L3G4IS_GYRO_DEV_NAME },
99104
{ LSM330_GYRO_DEV_NAME },
100105
{ LSM9DS0_GYRO_DEV_NAME },

drivers/iio/gyro/st_gyro_spi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static const struct spi_device_id st_gyro_id_table[] = {
5252
{ LSM330DL_GYRO_DEV_NAME },
5353
{ LSM330DLC_GYRO_DEV_NAME },
5454
{ L3GD20_GYRO_DEV_NAME },
55+
{ L3GD20H_GYRO_DEV_NAME },
5556
{ L3G4IS_GYRO_DEV_NAME },
5657
{ LSM330_GYRO_DEV_NAME },
5758
{ LSM9DS0_GYRO_DEV_NAME },

0 commit comments

Comments
 (0)