Commit 57d03554 authored by Linus Walleij's avatar Linus Walleij Committed by Jonathan Cameron

iio: magn: st_magn: inline per-sensor data

We have #defines for all the individual sensor registers and
value/mask pairs #defined at the top of the file and used at
exactly one spot.

This is usually good if the #defines give a meaning to the
opaque magic numbers.

However in this case, the semantic meaning is inherent in the
name of the C99-addressable fields, and that means duplication
of information, and only makes the code hard to maintain since
you every time have to add a new #define AND update the site
where it is to be used.

Get rid of the #defines and just open code the values into the
appropriate struct elements. Make sure to explicitly address
the .hz and .value fields in the st_sensor_odr_avl struct
so that the meaning of all values is clear.

This patch is purely syntactic should have no semantic effect.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent d8594fa2
...@@ -46,139 +46,12 @@ ...@@ -46,139 +46,12 @@
#define ST_MAGN_FS_AVL_15000MG 15000 #define ST_MAGN_FS_AVL_15000MG 15000
#define ST_MAGN_FS_AVL_16000MG 16000 #define ST_MAGN_FS_AVL_16000MG 16000
/* CUSTOM VALUES FOR SENSOR 0 */ /* Special L addresses for Sensor 2 */
#define ST_MAGN_0_ODR_ADDR 0x00
#define ST_MAGN_0_ODR_MASK 0x1c
#define ST_MAGN_0_ODR_AVL_1HZ_VAL 0x00
#define ST_MAGN_0_ODR_AVL_2HZ_VAL 0x01
#define ST_MAGN_0_ODR_AVL_3HZ_VAL 0x02
#define ST_MAGN_0_ODR_AVL_8HZ_VAL 0x03
#define ST_MAGN_0_ODR_AVL_15HZ_VAL 0x04
#define ST_MAGN_0_ODR_AVL_30HZ_VAL 0x05
#define ST_MAGN_0_ODR_AVL_75HZ_VAL 0x06
#define ST_MAGN_0_ODR_AVL_220HZ_VAL 0x07
#define ST_MAGN_0_PW_ADDR 0x02
#define ST_MAGN_0_PW_MASK 0x03
#define ST_MAGN_0_PW_ON 0x00
#define ST_MAGN_0_PW_OFF 0x03
#define ST_MAGN_0_FS_ADDR 0x01
#define ST_MAGN_0_FS_MASK 0xe0
#define ST_MAGN_0_FS_AVL_1300_VAL 0x01
#define ST_MAGN_0_FS_AVL_1900_VAL 0x02
#define ST_MAGN_0_FS_AVL_2500_VAL 0x03
#define ST_MAGN_0_FS_AVL_4000_VAL 0x04
#define ST_MAGN_0_FS_AVL_4700_VAL 0x05
#define ST_MAGN_0_FS_AVL_5600_VAL 0x06
#define ST_MAGN_0_FS_AVL_8100_VAL 0x07
#define ST_MAGN_0_FS_AVL_1300_GAIN_XY 1100
#define ST_MAGN_0_FS_AVL_1900_GAIN_XY 855
#define ST_MAGN_0_FS_AVL_2500_GAIN_XY 670
#define ST_MAGN_0_FS_AVL_4000_GAIN_XY 450
#define ST_MAGN_0_FS_AVL_4700_GAIN_XY 400
#define ST_MAGN_0_FS_AVL_5600_GAIN_XY 330
#define ST_MAGN_0_FS_AVL_8100_GAIN_XY 230
#define ST_MAGN_0_FS_AVL_1300_GAIN_Z 980
#define ST_MAGN_0_FS_AVL_1900_GAIN_Z 760
#define ST_MAGN_0_FS_AVL_2500_GAIN_Z 600
#define ST_MAGN_0_FS_AVL_4000_GAIN_Z 400
#define ST_MAGN_0_FS_AVL_4700_GAIN_Z 355
#define ST_MAGN_0_FS_AVL_5600_GAIN_Z 295
#define ST_MAGN_0_FS_AVL_8100_GAIN_Z 205
#define ST_MAGN_0_MULTIREAD_BIT false
/* CUSTOM VALUES FOR SENSOR 1 */
#define ST_MAGN_1_WAI_EXP 0x3c
#define ST_MAGN_1_ODR_ADDR 0x00
#define ST_MAGN_1_ODR_MASK 0x1c
#define ST_MAGN_1_ODR_AVL_1HZ_VAL 0x00
#define ST_MAGN_1_ODR_AVL_2HZ_VAL 0x01
#define ST_MAGN_1_ODR_AVL_3HZ_VAL 0x02
#define ST_MAGN_1_ODR_AVL_8HZ_VAL 0x03
#define ST_MAGN_1_ODR_AVL_15HZ_VAL 0x04
#define ST_MAGN_1_ODR_AVL_30HZ_VAL 0x05
#define ST_MAGN_1_ODR_AVL_75HZ_VAL 0x06
#define ST_MAGN_1_ODR_AVL_220HZ_VAL 0x07
#define ST_MAGN_1_PW_ADDR 0x02
#define ST_MAGN_1_PW_MASK 0x03
#define ST_MAGN_1_PW_ON 0x00
#define ST_MAGN_1_PW_OFF 0x03
#define ST_MAGN_1_FS_ADDR 0x01
#define ST_MAGN_1_FS_MASK 0xe0
#define ST_MAGN_1_FS_AVL_1300_VAL 0x01
#define ST_MAGN_1_FS_AVL_1900_VAL 0x02
#define ST_MAGN_1_FS_AVL_2500_VAL 0x03
#define ST_MAGN_1_FS_AVL_4000_VAL 0x04
#define ST_MAGN_1_FS_AVL_4700_VAL 0x05
#define ST_MAGN_1_FS_AVL_5600_VAL 0x06
#define ST_MAGN_1_FS_AVL_8100_VAL 0x07
#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 909
#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 1169
#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 1492
#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 2222
#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 2500
#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 3030
#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 4347
#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 1020
#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 1315
#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 1666
#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 2500
#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 2816
#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 3389
#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 4878
#define ST_MAGN_1_MULTIREAD_BIT false
/* CUSTOM VALUES FOR SENSOR 2 */
#define ST_MAGN_2_WAI_EXP 0x3d
#define ST_MAGN_2_ODR_ADDR 0x20
#define ST_MAGN_2_ODR_MASK 0x1c
#define ST_MAGN_2_ODR_AVL_1HZ_VAL 0x00
#define ST_MAGN_2_ODR_AVL_2HZ_VAL 0x01
#define ST_MAGN_2_ODR_AVL_3HZ_VAL 0x02
#define ST_MAGN_2_ODR_AVL_5HZ_VAL 0x03
#define ST_MAGN_2_ODR_AVL_10HZ_VAL 0x04
#define ST_MAGN_2_ODR_AVL_20HZ_VAL 0x05
#define ST_MAGN_2_ODR_AVL_40HZ_VAL 0x06
#define ST_MAGN_2_ODR_AVL_80HZ_VAL 0x07
#define ST_MAGN_2_PW_ADDR 0x22
#define ST_MAGN_2_PW_MASK 0x03
#define ST_MAGN_2_PW_ON 0x00
#define ST_MAGN_2_PW_OFF 0x03
#define ST_MAGN_2_FS_ADDR 0x21
#define ST_MAGN_2_FS_MASK 0x60
#define ST_MAGN_2_FS_AVL_4000_VAL 0x00
#define ST_MAGN_2_FS_AVL_8000_VAL 0x01
#define ST_MAGN_2_FS_AVL_12000_VAL 0x02
#define ST_MAGN_2_FS_AVL_16000_VAL 0x03
#define ST_MAGN_2_FS_AVL_4000_GAIN 146
#define ST_MAGN_2_FS_AVL_8000_GAIN 292
#define ST_MAGN_2_FS_AVL_12000_GAIN 438
#define ST_MAGN_2_FS_AVL_16000_GAIN 584
#define ST_MAGN_2_MULTIREAD_BIT false
#define ST_MAGN_2_OUT_X_L_ADDR 0x28 #define ST_MAGN_2_OUT_X_L_ADDR 0x28
#define ST_MAGN_2_OUT_Y_L_ADDR 0x2a #define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
#define ST_MAGN_2_OUT_Z_L_ADDR 0x2c #define ST_MAGN_2_OUT_Z_L_ADDR 0x2c
/* CUSTOM VALUES FOR SENSOR 3 */ /* Special L addresses for sensor 3 */
#define ST_MAGN_3_WAI_ADDR 0x4f
#define ST_MAGN_3_WAI_EXP 0x40
#define ST_MAGN_3_ODR_ADDR 0x60
#define ST_MAGN_3_ODR_MASK 0x0c
#define ST_MAGN_3_ODR_AVL_10HZ_VAL 0x00
#define ST_MAGN_3_ODR_AVL_20HZ_VAL 0x01
#define ST_MAGN_3_ODR_AVL_50HZ_VAL 0x02
#define ST_MAGN_3_ODR_AVL_100HZ_VAL 0x03
#define ST_MAGN_3_PW_ADDR 0x60
#define ST_MAGN_3_PW_MASK 0x03
#define ST_MAGN_3_PW_ON 0x00
#define ST_MAGN_3_PW_OFF 0x03
#define ST_MAGN_3_BDU_ADDR 0x62
#define ST_MAGN_3_BDU_MASK 0x10
#define ST_MAGN_3_DRDY_IRQ_ADDR 0x62
#define ST_MAGN_3_DRDY_INT_MASK 0x01
#define ST_MAGN_3_IHL_IRQ_ADDR 0x63
#define ST_MAGN_3_IHL_IRQ_MASK 0x04
#define ST_MAGN_3_FS_AVL_15000_GAIN 1500
#define ST_MAGN_3_MULTIREAD_BIT false
#define ST_MAGN_3_OUT_X_L_ADDR 0x68 #define ST_MAGN_3_OUT_X_L_ADDR 0x68
#define ST_MAGN_3_OUT_Y_L_ADDR 0x6a #define ST_MAGN_3_OUT_Y_L_ADDR 0x6a
#define ST_MAGN_3_OUT_Z_L_ADDR 0x6c #define ST_MAGN_3_OUT_Z_L_ADDR 0x6c
...@@ -240,77 +113,78 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { ...@@ -240,77 +113,78 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
}, },
.ch = (struct iio_chan_spec *)st_magn_16bit_channels, .ch = (struct iio_chan_spec *)st_magn_16bit_channels,
.odr = { .odr = {
.addr = ST_MAGN_0_ODR_ADDR, .addr = 0x00,
.mask = ST_MAGN_0_ODR_MASK, .mask = 0x1c,
.odr_avl = { .odr_avl = {
{ 1, ST_MAGN_0_ODR_AVL_1HZ_VAL, }, { .hz = 1, .value = 0x00 },
{ 2, ST_MAGN_0_ODR_AVL_2HZ_VAL, }, { .hz = 2, .value = 0x01 },
{ 3, ST_MAGN_0_ODR_AVL_3HZ_VAL, }, { .hz = 3, .value = 0x02 },
{ 8, ST_MAGN_0_ODR_AVL_8HZ_VAL, }, { .hz = 8, .value = 0x03 },
{ 15, ST_MAGN_0_ODR_AVL_15HZ_VAL, }, { .hz = 15, .value = 0x04 },
{ 30, ST_MAGN_0_ODR_AVL_30HZ_VAL, }, { .hz = 30, .value = 0x05 },
{ 75, ST_MAGN_0_ODR_AVL_75HZ_VAL, }, { .hz = 75, .value = 0x06 },
/* 220 Hz, 0x07 reportedly exist */
}, },
}, },
.pw = { .pw = {
.addr = ST_MAGN_0_PW_ADDR, .addr = 0x02,
.mask = ST_MAGN_0_PW_MASK, .mask = 0x03,
.value_on = ST_MAGN_0_PW_ON, .value_on = 0x00,
.value_off = ST_MAGN_0_PW_OFF, .value_off = 0x03,
}, },
.fs = { .fs = {
.addr = ST_MAGN_0_FS_ADDR, .addr = 0x01,
.mask = ST_MAGN_0_FS_MASK, .mask = 0xe0,
.fs_avl = { .fs_avl = {
[0] = { [0] = {
.num = ST_MAGN_FS_AVL_1300MG, .num = ST_MAGN_FS_AVL_1300MG,
.value = ST_MAGN_0_FS_AVL_1300_VAL, .value = 0x01,
.gain = ST_MAGN_0_FS_AVL_1300_GAIN_XY, .gain = 1100,
.gain2 = ST_MAGN_0_FS_AVL_1300_GAIN_Z, .gain2 = 980,
}, },
[1] = { [1] = {
.num = ST_MAGN_FS_AVL_1900MG, .num = ST_MAGN_FS_AVL_1900MG,
.value = ST_MAGN_0_FS_AVL_1900_VAL, .value = 0x02,
.gain = ST_MAGN_0_FS_AVL_1900_GAIN_XY, .gain = 855,
.gain2 = ST_MAGN_0_FS_AVL_1900_GAIN_Z, .gain2 = 760,
}, },
[2] = { [2] = {
.num = ST_MAGN_FS_AVL_2500MG, .num = ST_MAGN_FS_AVL_2500MG,
.value = ST_MAGN_0_FS_AVL_2500_VAL, .value = 0x03,
.gain = ST_MAGN_0_FS_AVL_2500_GAIN_XY, .gain = 670,
.gain2 = ST_MAGN_0_FS_AVL_2500_GAIN_Z, .gain2 = 600,
}, },
[3] = { [3] = {
.num = ST_MAGN_FS_AVL_4000MG, .num = ST_MAGN_FS_AVL_4000MG,
.value = ST_MAGN_0_FS_AVL_4000_VAL, .value = 0x04,
.gain = ST_MAGN_0_FS_AVL_4000_GAIN_XY, .gain = 450,
.gain2 = ST_MAGN_0_FS_AVL_4000_GAIN_Z, .gain2 = 400,
}, },
[4] = { [4] = {
.num = ST_MAGN_FS_AVL_4700MG, .num = ST_MAGN_FS_AVL_4700MG,
.value = ST_MAGN_0_FS_AVL_4700_VAL, .value = 0x05,
.gain = ST_MAGN_0_FS_AVL_4700_GAIN_XY, .gain = 400,
.gain2 = ST_MAGN_0_FS_AVL_4700_GAIN_Z, .gain2 = 355,
}, },
[5] = { [5] = {
.num = ST_MAGN_FS_AVL_5600MG, .num = ST_MAGN_FS_AVL_5600MG,
.value = ST_MAGN_0_FS_AVL_5600_VAL, .value = 0x06,
.gain = ST_MAGN_0_FS_AVL_5600_GAIN_XY, .gain = 330,
.gain2 = ST_MAGN_0_FS_AVL_5600_GAIN_Z, .gain2 = 295,
}, },
[6] = { [6] = {
.num = ST_MAGN_FS_AVL_8100MG, .num = ST_MAGN_FS_AVL_8100MG,
.value = ST_MAGN_0_FS_AVL_8100_VAL, .value = 0x07,
.gain = ST_MAGN_0_FS_AVL_8100_GAIN_XY, .gain = 230,
.gain2 = ST_MAGN_0_FS_AVL_8100_GAIN_Z, .gain2 = 205,
}, },
}, },
}, },
.multi_read_bit = ST_MAGN_0_MULTIREAD_BIT, .multi_read_bit = false,
.bootime = 2, .bootime = 2,
}, },
{ {
.wai = ST_MAGN_1_WAI_EXP, .wai = 0x3c,
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = { .sensors_supported = {
[0] = LSM303DLHC_MAGN_DEV_NAME, [0] = LSM303DLHC_MAGN_DEV_NAME,
...@@ -318,175 +192,175 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { ...@@ -318,175 +192,175 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
}, },
.ch = (struct iio_chan_spec *)st_magn_16bit_channels, .ch = (struct iio_chan_spec *)st_magn_16bit_channels,
.odr = { .odr = {
.addr = ST_MAGN_1_ODR_ADDR, .addr = 0x00,
.mask = ST_MAGN_1_ODR_MASK, .mask = 0x1c,
.odr_avl = { .odr_avl = {
{ 1, ST_MAGN_1_ODR_AVL_1HZ_VAL, }, { .hz = 1, .value = 0x00 },
{ 2, ST_MAGN_1_ODR_AVL_2HZ_VAL, }, { .hz = 2, .value = 0x01 },
{ 3, ST_MAGN_1_ODR_AVL_3HZ_VAL, }, { .hz = 3, .value = 0x02 },
{ 8, ST_MAGN_1_ODR_AVL_8HZ_VAL, }, { .hz = 8, .value = 0x03 },
{ 15, ST_MAGN_1_ODR_AVL_15HZ_VAL, }, { .hz = 15, .value = 0x04 },
{ 30, ST_MAGN_1_ODR_AVL_30HZ_VAL, }, { .hz = 30, .value = 0x05 },
{ 75, ST_MAGN_1_ODR_AVL_75HZ_VAL, }, { .hz = 75, .value = 0x06 },
{ 220, ST_MAGN_1_ODR_AVL_220HZ_VAL, }, { .hz = 220, .value = 0x07 },
}, },
}, },
.pw = { .pw = {
.addr = ST_MAGN_1_PW_ADDR, .addr = 0x02,
.mask = ST_MAGN_1_PW_MASK, .mask = 0x03,
.value_on = ST_MAGN_1_PW_ON, .value_on = 0x00,
.value_off = ST_MAGN_1_PW_OFF, .value_off = 0x03,
}, },
.fs = { .fs = {
.addr = ST_MAGN_1_FS_ADDR, .addr = 0x01,
.mask = ST_MAGN_1_FS_MASK, .mask = 0xe0,
.fs_avl = { .fs_avl = {
[0] = { [0] = {
.num = ST_MAGN_FS_AVL_1300MG, .num = ST_MAGN_FS_AVL_1300MG,
.value = ST_MAGN_1_FS_AVL_1300_VAL, .value = 0x01,
.gain = ST_MAGN_1_FS_AVL_1300_GAIN_XY, .gain = 909,
.gain2 = ST_MAGN_1_FS_AVL_1300_GAIN_Z, .gain2 = 1020,
}, },
[1] = { [1] = {
.num = ST_MAGN_FS_AVL_1900MG, .num = ST_MAGN_FS_AVL_1900MG,
.value = ST_MAGN_1_FS_AVL_1900_VAL, .value = 0x02,
.gain = ST_MAGN_1_FS_AVL_1900_GAIN_XY, .gain = 1169,
.gain2 = ST_MAGN_1_FS_AVL_1900_GAIN_Z, .gain2 = 1315,
}, },
[2] = { [2] = {
.num = ST_MAGN_FS_AVL_2500MG, .num = ST_MAGN_FS_AVL_2500MG,
.value = ST_MAGN_1_FS_AVL_2500_VAL, .value = 0x03,
.gain = ST_MAGN_1_FS_AVL_2500_GAIN_XY, .gain = 1492,
.gain2 = ST_MAGN_1_FS_AVL_2500_GAIN_Z, .gain2 = 1666,
}, },
[3] = { [3] = {
.num = ST_MAGN_FS_AVL_4000MG, .num = ST_MAGN_FS_AVL_4000MG,
.value = ST_MAGN_1_FS_AVL_4000_VAL, .value = 0x04,
.gain = ST_MAGN_1_FS_AVL_4000_GAIN_XY, .gain = 2222,
.gain2 = ST_MAGN_1_FS_AVL_4000_GAIN_Z, .gain2 = 2500,
}, },
[4] = { [4] = {
.num = ST_MAGN_FS_AVL_4700MG, .num = ST_MAGN_FS_AVL_4700MG,
.value = ST_MAGN_1_FS_AVL_4700_VAL, .value = 0x05,
.gain = ST_MAGN_1_FS_AVL_4700_GAIN_XY, .gain = 2500,
.gain2 = ST_MAGN_1_FS_AVL_4700_GAIN_Z, .gain2 = 2816,
}, },
[5] = { [5] = {
.num = ST_MAGN_FS_AVL_5600MG, .num = ST_MAGN_FS_AVL_5600MG,
.value = ST_MAGN_1_FS_AVL_5600_VAL, .value = 0x06,
.gain = ST_MAGN_1_FS_AVL_5600_GAIN_XY, .gain = 3030,
.gain2 = ST_MAGN_1_FS_AVL_5600_GAIN_Z, .gain2 = 3389,
}, },
[6] = { [6] = {
.num = ST_MAGN_FS_AVL_8100MG, .num = ST_MAGN_FS_AVL_8100MG,
.value = ST_MAGN_1_FS_AVL_8100_VAL, .value = 0x07,
.gain = ST_MAGN_1_FS_AVL_8100_GAIN_XY, .gain = 4347,
.gain2 = ST_MAGN_1_FS_AVL_8100_GAIN_Z, .gain2 = 4878,
}, },
}, },
}, },
.multi_read_bit = ST_MAGN_1_MULTIREAD_BIT, .multi_read_bit = false,
.bootime = 2, .bootime = 2,
}, },
{ {
.wai = ST_MAGN_2_WAI_EXP, .wai = 0x3d,
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = { .sensors_supported = {
[0] = LIS3MDL_MAGN_DEV_NAME, [0] = LIS3MDL_MAGN_DEV_NAME,
}, },
.ch = (struct iio_chan_spec *)st_magn_2_16bit_channels, .ch = (struct iio_chan_spec *)st_magn_2_16bit_channels,
.odr = { .odr = {
.addr = ST_MAGN_2_ODR_ADDR, .addr = 0x20,
.mask = ST_MAGN_2_ODR_MASK, .mask = 0x1c,
.odr_avl = { .odr_avl = {
{ 1, ST_MAGN_2_ODR_AVL_1HZ_VAL, }, { .hz = 1, .value = 0x00 },
{ 2, ST_MAGN_2_ODR_AVL_2HZ_VAL, }, { .hz = 2, .value = 0x01 },
{ 3, ST_MAGN_2_ODR_AVL_3HZ_VAL, }, { .hz = 3, .value = 0x02 },
{ 5, ST_MAGN_2_ODR_AVL_5HZ_VAL, }, { .hz = 5, .value = 0x03 },
{ 10, ST_MAGN_2_ODR_AVL_10HZ_VAL, }, { .hz = 10, .value = 0x04 },
{ 20, ST_MAGN_2_ODR_AVL_20HZ_VAL, }, { .hz = 20, .value = 0x05 },
{ 40, ST_MAGN_2_ODR_AVL_40HZ_VAL, }, { .hz = 40, .value = 0x06 },
{ 80, ST_MAGN_2_ODR_AVL_80HZ_VAL, }, { .hz = 80, .value = 0x07 },
}, },
}, },
.pw = { .pw = {
.addr = ST_MAGN_2_PW_ADDR, .addr = 0x22,
.mask = ST_MAGN_2_PW_MASK, .mask = 0x03,
.value_on = ST_MAGN_2_PW_ON, .value_on = 0x00,
.value_off = ST_MAGN_2_PW_OFF, .value_off = 0x03,
}, },
.fs = { .fs = {
.addr = ST_MAGN_2_FS_ADDR, .addr = 0x21,
.mask = ST_MAGN_2_FS_MASK, .mask = 0x60,
.fs_avl = { .fs_avl = {
[0] = { [0] = {
.num = ST_MAGN_FS_AVL_4000MG, .num = ST_MAGN_FS_AVL_4000MG,
.value = ST_MAGN_2_FS_AVL_4000_VAL, .value = 0x00,
.gain = ST_MAGN_2_FS_AVL_4000_GAIN, .gain = 146,
}, },
[1] = { [1] = {
.num = ST_MAGN_FS_AVL_8000MG, .num = ST_MAGN_FS_AVL_8000MG,
.value = ST_MAGN_2_FS_AVL_8000_VAL, .value = 0x01,
.gain = ST_MAGN_2_FS_AVL_8000_GAIN, .gain = 292,
}, },
[2] = { [2] = {
.num = ST_MAGN_FS_AVL_12000MG, .num = ST_MAGN_FS_AVL_12000MG,
.value = ST_MAGN_2_FS_AVL_12000_VAL, .value = 0x02,
.gain = ST_MAGN_2_FS_AVL_12000_GAIN, .gain = 438,
}, },
[3] = { [3] = {
.num = ST_MAGN_FS_AVL_16000MG, .num = ST_MAGN_FS_AVL_16000MG,
.value = ST_MAGN_2_FS_AVL_16000_VAL, .value = 0x03,
.gain = ST_MAGN_2_FS_AVL_16000_GAIN, .gain = 584,
}, },
}, },
}, },
.multi_read_bit = ST_MAGN_2_MULTIREAD_BIT, .multi_read_bit = false,
.bootime = 2, .bootime = 2,
}, },
{ {
.wai = ST_MAGN_3_WAI_EXP, .wai = 0x40,
.wai_addr = ST_MAGN_3_WAI_ADDR, .wai_addr = 0x4f,
.sensors_supported = { .sensors_supported = {
[0] = LSM303AGR_MAGN_DEV_NAME, [0] = LSM303AGR_MAGN_DEV_NAME,
}, },
.ch = (struct iio_chan_spec *)st_magn_3_16bit_channels, .ch = (struct iio_chan_spec *)st_magn_3_16bit_channels,
.odr = { .odr = {
.addr = ST_MAGN_3_ODR_ADDR, .addr = 0x60,
.mask = ST_MAGN_3_ODR_MASK, .mask = 0x0c,
.odr_avl = { .odr_avl = {
{ 10, ST_MAGN_3_ODR_AVL_10HZ_VAL, }, { .hz = 10, .value = 0x00 },
{ 20, ST_MAGN_3_ODR_AVL_20HZ_VAL, }, { .hz = 20, .value = 0x01 },
{ 50, ST_MAGN_3_ODR_AVL_50HZ_VAL, }, { .hz = 50, .value = 0x02 },
{ 100, ST_MAGN_3_ODR_AVL_100HZ_VAL, }, { .hz = 100, .value = 0x03 },
}, },
}, },
.pw = { .pw = {
.addr = ST_MAGN_3_PW_ADDR, .addr = 0x60,
.mask = ST_MAGN_3_PW_MASK, .mask = 0x03,
.value_on = ST_MAGN_3_PW_ON, .value_on = 0x00,
.value_off = ST_MAGN_3_PW_OFF, .value_off = 0x03,
}, },
.fs = { .fs = {
.fs_avl = { .fs_avl = {
[0] = { [0] = {
.num = ST_MAGN_FS_AVL_15000MG, .num = ST_MAGN_FS_AVL_15000MG,
.gain = ST_MAGN_3_FS_AVL_15000_GAIN, .gain = 1500,
}, },
}, },
}, },
.bdu = { .bdu = {
.addr = ST_MAGN_3_BDU_ADDR, .addr = 0x62,
.mask = ST_MAGN_3_BDU_MASK, .mask = 0x10,
}, },
.drdy_irq = { .drdy_irq = {
.addr = ST_MAGN_3_DRDY_IRQ_ADDR, .addr = 0x62,
.mask_int1 = ST_MAGN_3_DRDY_INT_MASK, .mask_int1 = 0x01,
.addr_ihl = ST_MAGN_3_IHL_IRQ_ADDR, .addr_ihl = 0x63,
.mask_ihl = ST_MAGN_3_IHL_IRQ_MASK, .mask_ihl = 0x04,
.addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
}, },
.multi_read_bit = ST_MAGN_3_MULTIREAD_BIT, .multi_read_bit = false,
.bootime = 2, .bootime = 2,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment