1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * STMicroelectronics st_lsm6dsx sensor driver
4 *
5 * Copyright 2016 STMicroelectronics Inc.
6 *
7 * Lorenzo Bianconi <lorenzo.bianconi@st.com>
8 * Denis Ciocca <denis.ciocca@st.com>
9 */
10
11 #ifndef ST_LSM6DSX_H
12 #define ST_LSM6DSX_H
13
14 #include <linux/device.h>
15 #include <linux/iio/iio.h>
16 #include <linux/regulator/consumer.h>
17
18 #define ST_LSM6DS3_DEV_NAME "lsm6ds3"
19 #define ST_LSM6DS3H_DEV_NAME "lsm6ds3h"
20 #define ST_LSM6DSL_DEV_NAME "lsm6dsl"
21 #define ST_LSM6DSM_DEV_NAME "lsm6dsm"
22 #define ST_ISM330DLC_DEV_NAME "ism330dlc"
23 #define ST_LSM6DSO_DEV_NAME "lsm6dso"
24 #define ST_ASM330LHH_DEV_NAME "asm330lhh"
25 #define ST_LSM6DSOX_DEV_NAME "lsm6dsox"
26 #define ST_LSM6DSR_DEV_NAME "lsm6dsr"
27 #define ST_LSM6DS3TRC_DEV_NAME "lsm6ds3tr-c"
28 #define ST_ISM330DHCX_DEV_NAME "ism330dhcx"
29 #define ST_LSM9DS1_DEV_NAME "lsm9ds1-imu"
30 #define ST_LSM6DS0_DEV_NAME "lsm6ds0"
31 #define ST_LSM6DSRX_DEV_NAME "lsm6dsrx"
32 #define ST_LSM6DST_DEV_NAME "lsm6dst"
33 #define ST_LSM6DSOP_DEV_NAME "lsm6dsop"
34 #define ST_ASM330LHHX_DEV_NAME "asm330lhhx"
35 #define ST_LSM6DSTX_DEV_NAME "lsm6dstx"
36 #define ST_LSM6DSV_DEV_NAME "lsm6dsv"
37 #define ST_LSM6DSV16X_DEV_NAME "lsm6dsv16x"
38 #define ST_LSM6DSO16IS_DEV_NAME "lsm6dso16is"
39 #define ST_ISM330IS_DEV_NAME "ism330is"
40 #define ST_ASM330LHB_DEV_NAME "asm330lhb"
41 #define ST_ASM330LHHXG1_DEV_NAME "asm330lhhxg1"
42
43 enum st_lsm6dsx_hw_id {
44 ST_LSM6DS3_ID = 1,
45 ST_LSM6DS3H_ID,
46 ST_LSM6DSL_ID,
47 ST_LSM6DSM_ID,
48 ST_ISM330DLC_ID,
49 ST_LSM6DSO_ID,
50 ST_ASM330LHH_ID,
51 ST_LSM6DSOX_ID,
52 ST_LSM6DSR_ID,
53 ST_LSM6DS3TRC_ID,
54 ST_ISM330DHCX_ID,
55 ST_LSM9DS1_ID,
56 ST_LSM6DS0_ID,
57 ST_LSM6DSRX_ID,
58 ST_LSM6DST_ID,
59 ST_LSM6DSOP_ID,
60 ST_ASM330LHHX_ID,
61 ST_LSM6DSTX_ID,
62 ST_LSM6DSV_ID,
63 ST_LSM6DSV16X_ID,
64 ST_LSM6DSO16IS_ID,
65 ST_ISM330IS_ID,
66 ST_ASM330LHB_ID,
67 ST_ASM330LHHXG1_ID,
68 ST_LSM6DSX_MAX_ID,
69 };
70
71 #define ST_LSM6DSX_BUFF_SIZE 512
72 #define ST_LSM6DSX_CHAN_SIZE 2
73 #define ST_LSM6DSX_SAMPLE_SIZE 6
74 #define ST_LSM6DSX_TAG_SIZE 1
75 #define ST_LSM6DSX_TAGGED_SAMPLE_SIZE (ST_LSM6DSX_SAMPLE_SIZE + \
76 ST_LSM6DSX_TAG_SIZE)
77 #define ST_LSM6DSX_MAX_WORD_LEN ((32 / ST_LSM6DSX_SAMPLE_SIZE) * \
78 ST_LSM6DSX_SAMPLE_SIZE)
79 #define ST_LSM6DSX_MAX_TAGGED_WORD_LEN ((32 / ST_LSM6DSX_TAGGED_SAMPLE_SIZE) \
80 * ST_LSM6DSX_TAGGED_SAMPLE_SIZE)
81 #define ST_LSM6DSX_SHIFT_VAL(val, mask) (((val) << __ffs(mask)) & (mask))
82 #define st_lsm6dsx_field_get(mask, reg) ((reg & mask) >> __ffs(mask))
83
84 #define ST_LSM6DSX_CHANNEL_ACC(addr, mod, scan_idx, events) \
85 { \
86 .type = IIO_ACCEL, \
87 .address = addr, \
88 .modified = 1, \
89 .channel2 = mod, \
90 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
91 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
92 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
93 .scan_index = scan_idx, \
94 .scan_type = { \
95 .sign = 's', \
96 .realbits = 16, \
97 .storagebits = 16, \
98 .endianness = IIO_LE, \
99 }, \
100 .event_spec = events, \
101 .num_event_specs = ARRAY_SIZE(events), \
102 .ext_info = st_lsm6dsx_ext_info, \
103 }
104
105 #define ST_LSM6DSX_CHANNEL(chan_type, addr, mod, scan_idx) \
106 { \
107 .type = chan_type, \
108 .address = addr, \
109 .modified = 1, \
110 .channel2 = mod, \
111 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
112 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
113 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
114 .scan_index = scan_idx, \
115 .scan_type = { \
116 .sign = 's', \
117 .realbits = 16, \
118 .storagebits = 16, \
119 .endianness = IIO_LE, \
120 }, \
121 .ext_info = st_lsm6dsx_ext_info, \
122 }
123
124 struct st_lsm6dsx_reg {
125 u8 addr;
126 u8 mask;
127 };
128
129 struct st_lsm6dsx_sensor;
130 struct st_lsm6dsx_hw;
131
132 struct st_lsm6dsx_odr {
133 u32 milli_hz;
134 u8 val;
135 };
136
137 #define ST_LSM6DSX_ODR_LIST_SIZE 8
138 struct st_lsm6dsx_odr_table_entry {
139 struct st_lsm6dsx_reg reg;
140
141 struct st_lsm6dsx_odr odr_avl[ST_LSM6DSX_ODR_LIST_SIZE];
142 int odr_len;
143 };
144
145 struct st_lsm6dsx_samples_to_discard {
146 struct {
147 u32 milli_hz;
148 u16 samples;
149 } val[ST_LSM6DSX_ODR_LIST_SIZE];
150 };
151
152 struct st_lsm6dsx_fs {
153 u32 gain;
154 u8 val;
155 };
156
157 #define ST_LSM6DSX_FS_LIST_SIZE 4
158 struct st_lsm6dsx_fs_table_entry {
159 struct st_lsm6dsx_reg reg;
160
161 struct st_lsm6dsx_fs fs_avl[ST_LSM6DSX_FS_LIST_SIZE];
162 int fs_len;
163 };
164
165 /**
166 * struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings
167 * @update_fifo: Update FIFO configuration callback.
168 * @read_fifo: Read FIFO callback.
169 * @fifo_th: FIFO threshold register info (addr + mask).
170 * @fifo_diff: FIFO diff status register info (addr + mask).
171 * @max_size: Sensor max fifo length in FIFO words.
172 * @th_wl: FIFO threshold word length.
173 */
174 struct st_lsm6dsx_fifo_ops {
175 int (*update_fifo)(struct st_lsm6dsx_sensor *sensor, bool enable);
176 int (*read_fifo)(struct st_lsm6dsx_hw *hw);
177 struct {
178 u8 addr;
179 u16 mask;
180 } fifo_th;
181 struct {
182 u8 addr;
183 u16 mask;
184 } fifo_diff;
185 u16 max_size;
186 u8 th_wl;
187 };
188
189 /**
190 * struct st_lsm6dsx_hw_ts_settings - ST IMU hw timer settings
191 * @timer_en: Hw timer enable register info (addr + mask).
192 * @hr_timer: Hw timer resolution register info (addr + mask).
193 * @fifo_en: Hw timer FIFO enable register info (addr + mask).
194 * @decimator: Hw timer FIFO decimator register info (addr + mask).
195 * @freq_fine: Difference in % of ODR with respect to the typical.
196 * @ts_sensitivity: Nominal timestamp sensitivity.
197 * @ts_trim_coeff: Coefficient for calculating the calibrated timestamp gain.
198 * This coefficient comes into play when linearizing the formula
199 * used to calculate the calibrated timestamp (please see the
200 * relevant formula in the AN for the specific IMU).
201 * For example, in the case of LSM6DSO we have:
202 *
203 * 1 / (1 + x) ~= 1 - x (Taylor’s Series)
204 * ttrim[s] = 1 / (40000 * (1 + 0.0015 * val)) (from AN5192)
205 * ttrim[ns] ~= 25000 - 37.5 * val
206 * ttrim[ns] ~= 25000 - (37500 * val) / 1000
207 *
208 * so, replacing ts_sensitivity = 25000 and
209 * ts_trim_coeff = 37500
210 *
211 * ttrim[ns] ~= ts_sensitivity - (ts_trim_coeff * val) / 1000
212 */
213 struct st_lsm6dsx_hw_ts_settings {
214 struct st_lsm6dsx_reg timer_en;
215 struct st_lsm6dsx_reg hr_timer;
216 struct st_lsm6dsx_reg fifo_en;
217 struct st_lsm6dsx_reg decimator;
218 u8 freq_fine;
219 u16 ts_sensitivity;
220 u16 ts_trim_coeff;
221 };
222
223 /**
224 * struct st_lsm6dsx_shub_settings - ST IMU hw i2c controller settings
225 * @page_mux: register page mux info (addr + mask).
226 * @master_en: master config register info (addr + mask).
227 * @pullup_en: i2c controller pull-up register info (addr + mask).
228 * @aux_sens: aux sensor register info (addr + mask).
229 * @wr_once: write_once register info (addr + mask).
230 * @emb_func: embedded function register info (addr + mask).
231 * @num_ext_dev: max number of slave devices.
232 * @shub_out: sensor hub first output register info.
233 * @slv0_addr: slave0 address in secondary page.
234 * @dw_slv0_addr: slave0 write register address in secondary page.
235 * @batch_en: Enable/disable FIFO batching.
236 * @pause: controller pause value.
237 */
238 struct st_lsm6dsx_shub_settings {
239 struct st_lsm6dsx_reg page_mux;
240 struct {
241 bool sec_page;
242 u8 addr;
243 u8 mask;
244 } master_en;
245 struct {
246 bool sec_page;
247 u8 addr;
248 u8 mask;
249 } pullup_en;
250 struct st_lsm6dsx_reg aux_sens;
251 struct st_lsm6dsx_reg wr_once;
252 struct st_lsm6dsx_reg emb_func;
253 u8 num_ext_dev;
254 struct {
255 bool sec_page;
256 u8 addr;
257 } shub_out;
258 u8 slv0_addr;
259 u8 dw_slv0_addr;
260 u8 batch_en;
261 u8 pause;
262 };
263
264 enum st_lsm6dsx_event_id {
265 ST_LSM6DSX_EVENT_WAKEUP,
266 ST_LSM6DSX_EVENT_TAP,
267 ST_LSM6DSX_EVENT_MAX
268 };
269
270 struct st_lsm6dsx_event_src {
271 struct st_lsm6dsx_reg value;
272 struct st_lsm6dsx_reg x_value;
273 struct st_lsm6dsx_reg y_value;
274 struct st_lsm6dsx_reg z_value;
275 u8 enable_mask;
276 u8 enable_axis_reg;
277 u8 enable_x_mask;
278 u8 enable_y_mask;
279 u8 enable_z_mask;
280 struct st_lsm6dsx_reg status;
281 u8 status_x_mask;
282 u8 status_y_mask;
283 u8 status_z_mask;
284 };
285
286 struct st_lsm6dsx_event_settings {
287 struct st_lsm6dsx_reg enable_reg;
288 struct st_lsm6dsx_event_src sources[ST_LSM6DSX_EVENT_MAX];
289 };
290
291 enum st_lsm6dsx_sensor_id {
292 ST_LSM6DSX_ID_GYRO,
293 ST_LSM6DSX_ID_ACC,
294 ST_LSM6DSX_ID_EXT0,
295 ST_LSM6DSX_ID_EXT1,
296 ST_LSM6DSX_ID_EXT2,
297 ST_LSM6DSX_ID_MAX
298 };
299
300 enum st_lsm6dsx_ext_sensor_id {
301 ST_LSM6DSX_ID_MAGN,
302 };
303
304 /**
305 * struct st_lsm6dsx_ext_dev_settings - i2c controller slave settings
306 * @i2c_addr: I2c slave address list.
307 * @wai: Wai address info.
308 * @id: external sensor id.
309 * @odr_table: Output data rate of the sensor [Hz].
310 * @fs_table: Configured sensor sensitivity table depending on full scale.
311 * @temp_comp: Temperature compensation register info (addr + mask).
312 * @pwr_table: Power on register info (addr + mask).
313 * @off_canc: Offset cancellation register info (addr + mask).
314 * @bdu: Block data update register info (addr + mask).
315 * @out: Output register info.
316 */
317 struct st_lsm6dsx_ext_dev_settings {
318 u8 i2c_addr[2];
319 struct {
320 u8 addr;
321 u8 val;
322 } wai;
323 enum st_lsm6dsx_ext_sensor_id id;
324 struct st_lsm6dsx_odr_table_entry odr_table;
325 struct st_lsm6dsx_fs_table_entry fs_table;
326 struct st_lsm6dsx_reg temp_comp;
327 struct {
328 struct st_lsm6dsx_reg reg;
329 u8 off_val;
330 u8 on_val;
331 } pwr_table;
332 struct st_lsm6dsx_reg off_canc;
333 struct st_lsm6dsx_reg bdu;
334 struct {
335 u8 addr;
336 u8 len;
337 } out;
338 };
339
340 /**
341 * struct st_lsm6dsx_settings - ST IMU sensor settings
342 * @reset: register address for reset.
343 * @boot: register address for boot.
344 * @bdu: register address for Block Data Update.
345 * @id: List of hw id/device name supported by the driver configuration.
346 * @channels: IIO channels supported by the device.
347 * @irq_config: interrupts related registers.
348 * @drdy_mask: register info for data-ready mask (addr + mask).
349 * @odr_table: Hw sensors odr table (Hz + val).
350 * @samples_to_discard: Number of samples to discard for filters settling time.
351 * @fs_table: Hw sensors gain table (gain + val).
352 * @decimator: List of decimator register info (addr + mask).
353 * @batch: List of FIFO batching register info (addr + mask).
354 * @fifo_ops: Sensor hw FIFO parameters.
355 * @ts_settings: Hw timer related settings.
356 * @shub_settings: i2c controller related settings.
357 */
358 struct st_lsm6dsx_settings {
359 struct st_lsm6dsx_reg reset;
360 struct st_lsm6dsx_reg boot;
361 struct st_lsm6dsx_reg bdu;
362 struct {
363 enum st_lsm6dsx_hw_id hw_id;
364 const char *name;
365 u8 wai;
366 } id[ST_LSM6DSX_MAX_ID];
367 struct {
368 const struct iio_chan_spec *chan;
369 int len;
370 } channels[2];
371 struct {
372 struct st_lsm6dsx_reg irq1;
373 struct st_lsm6dsx_reg irq2;
374 u8 irq1_func;
375 u8 irq2_func;
376 struct st_lsm6dsx_reg lir;
377 struct st_lsm6dsx_reg clear_on_read;
378 struct st_lsm6dsx_reg hla;
379 struct st_lsm6dsx_reg od;
380 } irq_config;
381 struct st_lsm6dsx_reg drdy_mask;
382 struct st_lsm6dsx_odr_table_entry odr_table[2];
383 struct st_lsm6dsx_samples_to_discard samples_to_discard[2];
384 struct st_lsm6dsx_fs_table_entry fs_table[2];
385 struct st_lsm6dsx_reg decimator[ST_LSM6DSX_ID_MAX];
386 struct st_lsm6dsx_reg batch[2];
387 struct st_lsm6dsx_fifo_ops fifo_ops;
388 struct st_lsm6dsx_hw_ts_settings ts_settings;
389 struct st_lsm6dsx_shub_settings shub_settings;
390 struct st_lsm6dsx_event_settings event_settings;
391 };
392
393 enum st_lsm6dsx_fifo_mode {
394 ST_LSM6DSX_FIFO_BYPASS = 0x0,
395 ST_LSM6DSX_FIFO_CONT = 0x6,
396 };
397
398 /**
399 * struct st_lsm6dsx_sensor - ST IMU sensor instance
400 * @name: Sensor name.
401 * @id: Sensor identifier.
402 * @hw: Pointer to instance of struct st_lsm6dsx_hw.
403 * @gain: Configured sensor sensitivity.
404 * @odr: Output data rate of the sensor [mHz].
405 * hwfifo_odr_mHz: Batch data rate for hardware FIFO [mHz]
406 * @samples_to_discard: Number of samples to discard for filters settling time.
407 * @watermark: Sensor watermark level.
408 * @decimator: Sensor decimation factor.
409 * @sip: Number of samples in a given pattern.
410 * @ts_ref: Sensor timestamp reference for hw one.
411 * @ext_info: Sensor settings if it is connected to i2c controller
412 */
413 struct st_lsm6dsx_sensor {
414 char name[32];
415 enum st_lsm6dsx_sensor_id id;
416 struct st_lsm6dsx_hw *hw;
417
418 u32 gain;
419 u32 odr;
420 u32 hwfifo_odr_mHz;
421
422 u16 samples_to_discard;
423 u16 watermark;
424 u8 decimator;
425 u8 sip;
426 s64 ts_ref;
427
428 struct {
429 const struct st_lsm6dsx_ext_dev_settings *settings;
430 u32 slv_odr;
431 u8 addr;
432 } ext_info;
433 };
434
435 /**
436 * struct st_lsm6dsx_hw - ST IMU MEMS hw instance
437 * @dev: Pointer to instance of struct device (I2C or SPI).
438 * @regmap: Register map of the device.
439 * @irq: Device interrupt line (I2C or SPI).
440 * @fifo_lock: Mutex to prevent concurrent access to the hw FIFO.
441 * @conf_lock: Mutex to prevent concurrent FIFO configuration update.
442 * @page_lock: Mutex to prevent concurrent memory page configuration.
443 * @suspend_mask: Suspended sensor bitmask.
444 * @enable_mask: Enabled sensor bitmask.
445 * @fifo_mask: Enabled hw FIFO bitmask.
446 * @ts_gain: Hw timestamp rate after internal calibration.
447 * @ts_sip: Total number of timestamp samples in a given pattern.
448 * @sip: Total number of samples (acc/gyro/ts) in a given pattern.
449 * @buff: Device read buffer.
450 * @irq_routing: pointer to interrupt routing configuration.
451 * @enable_event: enabled event bitmask.
452 * @iio_devs: Pointers to acc/gyro iio_dev instances.
453 * @settings: Pointer to the specific sensor settings in use.
454 * @orientation: sensor chip orientation relative to main hardware.
455 * @scan: Temporary buffers used to align data before iio_push_to_buffers()
456 */
457 struct st_lsm6dsx_hw {
458 struct device *dev;
459 struct regmap *regmap;
460 int irq;
461
462 struct mutex fifo_lock;
463 struct mutex conf_lock;
464 struct mutex page_lock;
465
466 u8 suspend_mask;
467 u8 enable_mask;
468 u8 fifo_mask;
469 s64 ts_gain;
470 u8 ts_sip;
471 u8 sip;
472
473 u8 irq_routing;
474 u8 enable_event[ST_LSM6DSX_EVENT_MAX];
475
476 u8 *buff;
477
478 struct iio_dev *iio_devs[ST_LSM6DSX_ID_MAX];
479
480 const struct st_lsm6dsx_settings *settings;
481
482 struct iio_mount_matrix orientation;
483 /* Ensure natural alignment of buffer elements */
484 struct {
485 __le16 channels[3];
486 aligned_s64 ts;
487 } scan[ST_LSM6DSX_ID_MAX];
488 };
489
490 static __maybe_unused const unsigned long st_lsm6dsx_available_scan_masks[] = {
491 0x7, 0x0,
492 };
493
494 extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
495
496 int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
497 struct regmap *regmap);
498 int st_lsm6dsx_sensor_set_enable(struct st_lsm6dsx_sensor *sensor,
499 bool enable);
500 int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw);
501 int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val);
502 int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
503 u16 watermark);
504 int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable);
505 int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
506 int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw);
507 int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw);
508 int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw);
509 int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u32 odr, u8 *val);
510 int st_lsm6dsx_shub_probe(struct st_lsm6dsx_hw *hw, const char *name);
511 int st_lsm6dsx_shub_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable);
512 int st_lsm6dsx_shub_read_output(struct st_lsm6dsx_hw *hw, u8 *data, int len);
513 int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable);
514
515 static inline int
st_lsm6dsx_update_bits_locked(struct st_lsm6dsx_hw * hw,unsigned int addr,unsigned int mask,unsigned int val)516 st_lsm6dsx_update_bits_locked(struct st_lsm6dsx_hw *hw, unsigned int addr,
517 unsigned int mask, unsigned int val)
518 {
519 int err;
520
521 mutex_lock(&hw->page_lock);
522 err = regmap_update_bits(hw->regmap, addr, mask, val);
523 mutex_unlock(&hw->page_lock);
524
525 return err;
526 }
527
528 static inline int
st_lsm6dsx_read_locked(struct st_lsm6dsx_hw * hw,unsigned int addr,void * val,unsigned int len)529 st_lsm6dsx_read_locked(struct st_lsm6dsx_hw *hw, unsigned int addr,
530 void *val, unsigned int len)
531 {
532 int err;
533
534 mutex_lock(&hw->page_lock);
535 err = regmap_bulk_read(hw->regmap, addr, val, len);
536 mutex_unlock(&hw->page_lock);
537
538 return err;
539 }
540
541 static inline int
st_lsm6dsx_write_locked(struct st_lsm6dsx_hw * hw,unsigned int addr,unsigned int val)542 st_lsm6dsx_write_locked(struct st_lsm6dsx_hw *hw, unsigned int addr,
543 unsigned int val)
544 {
545 int err;
546
547 mutex_lock(&hw->page_lock);
548 err = regmap_write(hw->regmap, addr, val);
549 mutex_unlock(&hw->page_lock);
550
551 return err;
552 }
553
554 static inline const struct iio_mount_matrix *
st_lsm6dsx_get_mount_matrix(const struct iio_dev * iio_dev,const struct iio_chan_spec * chan)555 st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev,
556 const struct iio_chan_spec *chan)
557 {
558 struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
559 struct st_lsm6dsx_hw *hw = sensor->hw;
560
561 return &hw->orientation;
562 }
563
564 static inline int
st_lsm6dsx_device_set_enable(struct st_lsm6dsx_sensor * sensor,bool enable)565 st_lsm6dsx_device_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable)
566 {
567 if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
568 sensor->id == ST_LSM6DSX_ID_EXT1 ||
569 sensor->id == ST_LSM6DSX_ID_EXT2)
570 return st_lsm6dsx_shub_set_enable(sensor, enable);
571
572 return st_lsm6dsx_sensor_set_enable(sensor, enable);
573 }
574
575 static const
576 struct iio_chan_spec_ext_info __maybe_unused st_lsm6dsx_ext_info[] = {
577 IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix),
578 { }
579 };
580
581 #endif /* ST_LSM6DSX_H */
582