@@ -102,6 +102,11 @@ enum chip_ids {
102
102
yas533 ,
103
103
};
104
104
105
+ static const int yas530_volatile_reg [] = {
106
+ YAS530_ACTUATE_INIT_COIL ,
107
+ YAS530_MEASURE ,
108
+ };
109
+
105
110
struct yas5xx_calibration {
106
111
/* Linearization calibration x, y1, y2 */
107
112
s32 r [3 ];
@@ -123,11 +128,15 @@ struct yas5xx;
123
128
* @devid: device ID number
124
129
* @product_name: product name of the YAS variant
125
130
* @version_names: version letters or namings
131
+ * @volatile_reg: device-specific volatile registers
132
+ * @volatile_reg_qty: quantity of device-specific volatile registers
126
133
*/
127
134
struct yas5xx_chip_info {
128
135
unsigned int devid ;
129
136
char * product_name ;
130
137
char * version_names [2 ];
138
+ const int * volatile_reg ;
139
+ int volatile_reg_qty ;
131
140
};
132
141
133
142
/**
@@ -616,9 +625,26 @@ static const struct iio_info yas5xx_info = {
616
625
617
626
static bool yas5xx_volatile_reg (struct device * dev , unsigned int reg )
618
627
{
619
- return reg == YAS530_ACTUATE_INIT_COIL ||
620
- reg == YAS530_MEASURE ||
621
- (reg >= YAS5XX_MEASURE_DATA && reg < YAS5XX_MEASURE_DATA + 8 );
628
+ struct iio_dev * indio_dev = dev_get_drvdata (dev );
629
+ struct yas5xx * yas5xx = iio_priv (indio_dev );
630
+ const struct yas5xx_chip_info * ci = yas5xx -> chip_info ;
631
+ int reg_qty ;
632
+ int i ;
633
+
634
+ if (reg >= YAS5XX_MEASURE_DATA && reg < YAS5XX_MEASURE_DATA + 8 )
635
+ return true;
636
+
637
+ /*
638
+ * YAS versions share different registers on the same address,
639
+ * need to differentiate.
640
+ */
641
+ reg_qty = ci -> volatile_reg_qty ;
642
+ for (i = 0 ; i < reg_qty ; i ++ ) {
643
+ if (reg == ci -> volatile_reg [i ])
644
+ return true;
645
+ }
646
+
647
+ return false;
622
648
}
623
649
624
650
/* TODO: enable regmap cache, using mark dirty and sync at runtime resume */
@@ -923,16 +949,22 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
923
949
.devid = YAS530_DEVICE_ID ,
924
950
.product_name = "YAS530 MS-3E" ,
925
951
.version_names = { "A" , "B" },
952
+ .volatile_reg = yas530_volatile_reg ,
953
+ .volatile_reg_qty = ARRAY_SIZE (yas530_volatile_reg ),
926
954
},
927
955
[yas532 ] = {
928
956
.devid = YAS532_DEVICE_ID ,
929
957
.product_name = "YAS532 MS-3R" ,
930
958
.version_names = { "AB" , "AC" },
959
+ .volatile_reg = yas530_volatile_reg ,
960
+ .volatile_reg_qty = ARRAY_SIZE (yas530_volatile_reg ),
931
961
},
932
962
[yas533 ] = {
933
963
.devid = YAS532_DEVICE_ID ,
934
964
.product_name = "YAS533 MS-3F" ,
935
965
.version_names = { "AB" , "AC" },
966
+ .volatile_reg = yas530_volatile_reg ,
967
+ .volatile_reg_qty = ARRAY_SIZE (yas530_volatile_reg ),
936
968
},
937
969
};
938
970
0 commit comments